@odoo/o-spreadsheet 16.4.28 → 16.4.30
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.
- package/dist/o-spreadsheet.cjs.js +321 -344
- package/dist/o-spreadsheet.d.ts +6 -6
- package/dist/o-spreadsheet.esm.js +321 -344
- package/dist/o-spreadsheet.iife.js +321 -344
- package/dist/o-spreadsheet.iife.min.js +238 -238
- package/dist/o_spreadsheet.xml +6 -5
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
!function(e,t){"use strict";let o=e=>e;function i(e,...t){if(1===t.length&&"object"==typeof t[0]){const o=t[0];e=e.replace(/\%\(?([^\)]+)\)s/g,((e,t)=>o[t]))}else t.length>0&&(e=e.replace(/\%s/g,(()=>t.shift())));return e}const s=function(e,...t){return i(o(e),...t)},r=function(e,...t){return new n(e,t)};class n extends String{values;constructor(e,t){super(e),this.values=t}valueOf(){const e=super.valueOf();return i(o(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{errorType;logLevel;constructor(e,t,o=l.error){super(t),this.errorType=e,this.logLevel=o}}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(e){super(a.NotAvailable,e||r("Data not available"),e?l.error:l.silent)}}class p extends c{constructor(e){super(a.UnknownFunction,r('Unknown function: "%s"',e))}}const m=.5,f="#f5f5f5",b="#F8F9FA",v="#E8EAED",S="#595959",C="#666666",E="#3266ca",w="#FFFFFF",x="#EBEBEB",y="#CACACA",I=11982760,R="#01666b",T="#188038",A="#E6F4EA",O="#CEEAD6",M="#E0E2E4",N="#4A4F59",_=["#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"],F=26,D=48,L=96,P=23,k=15,U=18,V=14,B=4,z=4,H=3,$=z,W=17,G=250,q="400",Z=10,Y="'Roboto', arial",j="bottom",X="overflow",K="thin",Q="#000000",J={style:"thin",color:T},ee=a.InvalidReference,te="START_REVISION",oe=1,ie=20,se="??",re="difference",ne="#00A04A",ae="#DC6965",le=.4,ce=["'","*","?","/","\\","[","]"],he=/'|\*|\?|\/|\\|\[|\]/,de="|",ue=r("Invalid expression");var ge;!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.IconPicker=25]="IconPicker",e[e.TopBarComposer=30]="TopBarComposer",e[e.Popover=35]="Popover",e[e.FigureAnchor=1e3]="FigureAnchor",e[e.FigureSnapLine=1001]="FigureSnapLine"}(ge||(ge={}));let pe=0;function me(){return pe}const fe="\n",be=[6,7,8,9,10,11,12,14,18,24,36];function ve(e){return'"'===e[0]&&(e=e.slice(1)),'"'===e[e.length-1]&&"\\"!==e[e.length-2]?e.slice(0,e.length-1):e}function Se(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Ce(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&&e?.constructor===Object}(e)||e instanceof Array))throw new Error("Unsupported type: only objects and arrays are supported");for(const o in e)t[o]=Ce(e[o]);return t;case"number":case"string":case"boolean":case"function":case"undefined":return e;default:throw new Error("Unsupported type: "+typeof e)}}function Ee(e){return e.startsWith("'")&&(e=e.slice(1,-1).replace(/''/g,"'")),e}function we(e){return e.match(/\w/g)?.length!==e.length&&(e=`'${e}'`),e}function xe(e,t,o){return e<t?t:e>o?o:e}function ye(e,t,o=1){if(t<=e&&o>0)return[];if(0===o)throw new Error("range() step must not be zero");const i=Math.ceil(Math.abs((t-e)/o)),s=Array(i);for(let t=0;t<i;t++)s[t]=e+t*o;return s}function Ie(e){return e.reduce(((e,t,o,i)=>{if(1===Math.abs(t-i[o-1])){e[e.length-1].push(t)}else e.push([t]);return e}),[])}function*Re(e,t){t.next();for(const o of e){const e=t.next();yield{...o,next:e.done?void 0:e.value}}}const Te=/^\[(.+)\]\((.+)\)$/,Ae=/^https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,4}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)$/;function Oe(e){return Te.test(e)}function Me(e){return Ae.test(e)}function Ne(e,t){return`[${e}](${t})`}function _e(e){const t=e.match(Te)||[],o=t[1],i=t[2];if(!o||!i)throw new Error(`Could not parse markdown link ${e}.`);return{label:o,url:i}}const Fe="o-spreadsheet://";function De(e){return e.startsWith(Fe)}function Le(e){return`${Fe}${e}`}function Pe(e){if(e.startsWith(Fe))return e.substr(Fe.length);throw new Error(`${e} is not a valid sheet link`)}function ke(e){return void 0!==e}function Ue(e){return void 0===e||Object.values(e).every((e=>"object"==typeof e?Ue(e):!e))}function Ve(e,t){for(let[o,i]of Object.entries(t))if(We(i,e))return parseInt(o,10);const o=Object.keys(t),i=0===o.length?0:et(o.map((e=>parseInt(e,10))));return t[i+1]=e,i+1}function Be(e){let t="";for(let o=0,i=e.length;o<i;o++)t+=e[o];return t}function ze(e){let t,o=!1;const i=()=>(o||(t=e instanceof Function?e():e,o=!0),t);return i.map=e=>ze((()=>e(i()))),i}function He(e,t){let o=e.slice(t).find((e=>e));return o||(o=e.slice(0,t).reverse().find((e=>e))),o||""}function $e(e,t){return"after"===e?t+1:t}function We(e,t){if(e===t)return!0;if(e&&!t||t&&!e)return!1;if(typeof e!=typeof t)return!1;if("object"!=typeof e)return e===t;const o=new Set;Object.keys(e).forEach((e=>o.add(e))),Object.keys(t).forEach((e=>o.add(e)));for(let i of o){if(typeof e[i]!=typeof e[i])return!1;if("object"==typeof e[i]){if(!We(e[i],t[i]))return!1}else if(e[i]!==t[i])return!1}return!0}function Ge(e,t){return t.every((t=>e.includes(t)))}function qe(e){const t={...e};return Object.keys(t).forEach((e=>!t[e]&&delete t[e])),t}function Ze(e,t=(e=>e)){if(!e.length)return[];const o=Array(e[0].length);for(let i=0;i<e[0].length;i++){o[i]=Array(e.length);for(let s=0;s<e.length;s++)o[i][s]=t(e[s][i])}return o}const Ye=["\t","\f","\v",String.fromCharCode(parseInt("00a0",16)),String.fromCharCode(parseInt("1680",16)),String.fromCharCode(parseInt("2000",16)),String.fromCharCode(parseInt("200a",16)),String.fromCharCode(parseInt("2028",16)),String.fromCharCode(parseInt("2029",16)),String.fromCharCode(parseInt("202f",16)),String.fromCharCode(parseInt("205f",16)),String.fromCharCode(parseInt("3000",16)),String.fromCharCode(parseInt("feff",16))],je=new RegExp(Ye.join("|")+"|(\r\n|\r|\n)","g");function Xe(e){return e?je.test(e)?e.replace(je,((e,t)=>t?fe:" ")):e:""}class Ke extends Set{addMany(e){for(const t of e)super.add(t);return this}deleteMany(e){let t=!1;for(const o of e)t||=super.delete(o);return t}}function Qe(e){const t=new Map,o=e.name?e.name+" (memoized)":"memoized";return{[o]:(...o)=>(t.has(o[0])||t.set(o[0],e(...o)),t.get(o[0]))}[o]}function Je(e,t){return e.filter(((e,o)=>!t.includes(o)))}function et(e){let t=e.length;if(t<1e5)return Math.max(...e);let o=-1/0;for(;t--;)o=e[t]>o?e[t]:o;return o}function tt(e){let t=e.length;if(t<1e5)return Math.min(...e);let o=1/0;for(;t--;)o=e[t]<o?e[t]:o;return o}const ot=/rgba?\(|\s+|\)/gi,it=/^#([A-F\d]{2}){3,4}$/,st=["#eb6d00","#0074d9","#ad8e00","#169ed4","#b10dc9","#00a82d","#00a3a3","#f012be","#3d9970","#111111","#62A300","#ff4136","#949494","#85144b","#001f3f"];function rt(e){return nt(e.toString(16).padStart(6,"0"))}function nt(e){let t=e;if(e.startsWith("rgb")?t=function(e){const t=e.replace(ot,"").split(",");let o=255;if(3!==t.length&&4!==t.length)throw new Error("invalid color");if(4===t.length){const e=parseFloat(t.pop()||"1");o=Math.round(255*(e||1))}const i=t.map((e=>parseInt(e,10)));255!==o&&i.push(o);return"#"+Be(i.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}`),!it.test(t))throw new Error(`invalid color input: ${e}`);return t}function at(e){try{return nt(e),!0}catch(e){return!1}}const lt=e=>e>=0&&e<=255;function ct(e,t,o,i=1){if(!lt(e)||!lt(t)||!lt(o)||i<0||i>1)throw new Error(`Invalid RGBA values ${[e,t,o,i]}`);return{a:i,b:o,g:t,r:e}}function ht(e){let{r:t,g:o,b:i}=ut(e);t/=255,o/=255,i/=255;const s=e=>e<=.03928?e/12.92:((e+.055)/1.055)**2.4;return.2126*s(t)+.7152*s(o)+.0722*s(i)}function dt(e){let t=e.r.toString(16),o=e.g.toString(16),i=e.b.toString(16),s=Math.round(255*e.a).toString(16);return 1===t.length&&(t="0"+t),1===o.length&&(o="0"+o),1===i.length&&(i="0"+i),1===s.length&&(s="0"+s),"ff"===s&&(s=""),("#"+t+o+i+s).toUpperCase()}function ut(e){let t,o,i,s;if(7===(e=nt(e)).length)t=parseInt(e[1]+e[2],16),o=parseInt(e[3]+e[4],16),i=parseInt(e[5]+e[6],16),s=255;else{if(9!==e.length)throw new Error("Invalid color");t=parseInt(e[1]+e[2],16),o=parseInt(e[3]+e[4],16),i=parseInt(e[5]+e[6],16),s=parseInt(e[7]+e[8],16)}return s=+(s/255).toFixed(3),{a:s,r:t,g:o,b:i}}function gt(e){(e={...e}).s/=100,e.l/=100;let t=(1-Math.abs(2*e.l-1))*e.s,o=t*(1-Math.abs(e.h/60%2-1)),i=e.l-t/2,s=0,r=0,n=0;return 0<=e.h&&e.h<60?(s=t,r=o,n=0):60<=e.h&&e.h<120?(s=o,r=t,n=0):120<=e.h&&e.h<180?(s=0,r=t,n=o):180<=e.h&&e.h<240?(s=0,r=o,n=t):240<=e.h&&e.h<300?(s=o,r=0,n=t):300<=e.h&&e.h<360&&(s=t,r=0,n=o),s=Math.round(255*(s+i)),r=Math.round(255*(r+i)),n=Math.round(255*(n+i)),{a:e.a,r:s,g:r,b:n}}function pt(e){const t=e.r/255,o=e.g/255,i=e.b/255;let s=Math.min(t,o,i),r=Math.max(t,o,i),n=r-s,a=0,l=0,c=0;return a=0===n?0:r===t?(o-i)/n%6:r===o?(i-t)/n+2:(t-o)/n+4,a=Math.round(60*a),a<0&&(a+=360),c=(r+s)/2,l=0===n?0:n/(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}}function mt(e){return dt(gt(e))}function ft(e){return pt(ut(e))}function bt(e){if(e<0)throw new Error(`number must be positive. Got ${e}`);return e<26?String.fromCharCode(65+e):bt(Math.floor(e/26)-1)+bt(e%26)}const vt={};for(const e of"ABCDEFGHIJKLMNOPQRSTUVWXYZ"){const t=e.charCodeAt(0)-64;vt[e]=t,vt[e.toLowerCase()]=t}function St(e){let t=-1;let o=1;for(let i=e.length-1;i>=0;i--){t+=vt[e[i]]*o,o*=26}return t}function Ct(e){return e>="A"&&e<="Z"||e>="a"&&e<="z"}function Et(e){return e>="0"&&e<="9"}function wt(e){let t;e=e.trim();for(let o=0;o<e.length;o++){const i=e[o];if(!t){if("$"===i&&0===o||Ct(i))continue;t=o}if(!Et(i)){if("$"===i&&o===t)continue;throw new Error(`Invalid cell description: ${e}`)}}if(!t||t===e.length)throw new Error(`Invalid cell description: ${e}`);const o="$"===e[0]?e.slice(1,t):e.slice(0,t),i="$"===e[t]?e.slice(t+1):e.slice(t);if(o.length<1||o.length>3||i.length<1||i.length>7)throw new Error(`Invalid cell description: ${e}`);const s=St(o),r=Number(i)-1;if(isNaN(r))throw new Error(`Invalid cell description: ${e}`);return{col:s,row:r}}function xt(e,t,o={colFixed:!1,rowFixed:!1}){return(o.colFixed?"$":"")+bt(e)+(o.rowFixed?"$":"")+String(t+1)}class yt{jsDate;constructor(e,t,o,i=0,s=0,r=0){this.jsDate=new Date(Date.UTC(e,t,o,i,s,r,0))}static fromTimestamp(e){const t=new Date(e);return new yt(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate(),t.getUTCHours(),t.getUTCMinutes(),t.getUTCSeconds())}static now(){const e=new Date;return new yt(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds())}toString(){return this.jsDate.toString()}toLocaleDateString(){return this.jsDate.toLocaleDateString()}getTime(){return this.jsDate.getTime()}getFullYear(){return this.jsDate.getUTCFullYear()}getMonth(){return this.jsDate.getUTCMonth()}getDate(){return this.jsDate.getUTCDate()}getDay(){return this.jsDate.getUTCDay()}getHours(){return this.jsDate.getUTCHours()}getMinutes(){return this.jsDate.getUTCMinutes()}getSeconds(){return this.jsDate.getUTCSeconds()}setFullYear(e){this.jsDate.setFullYear(e)}setDate(e){this.jsDate.setUTCDate(e)}setHours(e){this.jsDate.setUTCHours(e)}setMinutes(e){this.jsDate.setUTCMinutes(e)}setSeconds(e){this.jsDate.setUTCSeconds(e)}}const It=new yt(1899,11,30),Rt=864e5,Tt=2e3,At=yt.now().getFullYear(),Ot=yt.now().getMonth(),Mt=yt.fromTimestamp(0).getTime()-It.getTime(),Nt=/^\d{1,2}(\/|-|\s)\d{1,2}((\/|-|\s)\d{1,4})?$/,_t=/^\d{3,4}(\/|-|\s)\d{1,2}(\/|-|\s)\d{1,2}$/,Ft=/\/|-|\s/,Dt=/^(\d{1,4})[\/-\s](\d{1,2})([\/-\s](\d{1,4}))?$/,Lt=/((\d+(:\d+)?(:\d+)?\s*(AM|PM))|(\d+:\d+(:\d+)?))$/;function Pt(e,t){return null!==Ut(e,t)}const kt=new Map;function Ut(e,t){return kt.has(t)||kt.set(t,new Map),kt.get(t).has(e)||kt.get(t).set(e,function(e,t){e=e.trim();let o=null;const i=e.match(Lt);if(i){if(o=function(e){if(e=e.trim(),Lt.test(e)){const t=/AM/i.test(e),o=/PM/i.test(e),i=(t||o?e.substring(0,e.length-2).trim():e).split(/:/),s=i.length>=2,r=3===i.length;let n=Number(i[0]),a=s?Number(i[1]):0,l=r?Number(i[2]):0,c=r?"hh:mm:ss":"hh:mm";if(t||o)c+=" a";else if(!s)return null;n>=12&&t?n-=12:n<12&&o&&(n+=12),a+=Math.floor(l/60),l%=60,n+=Math.floor(a/60),a%=60,n>=24&&(c="hhhh:mm:ss");return{value:n/24+a/1440+l/86400,format:c,jsDate:new yt(1899,11,30,n,a,l)}}return null}(i[0]),null===o)return null;e=e.replace(i[0],"").trim()}let s=null;const r=function(e,t){const o=e.match(Dt);if(!o)return null;const[,i,s,,r]=o;if(i.length>2&&r&&r.length>2)return null;if(i.length>2)return{year:i,month:s,day:r,dateString:e,type:"ymd"};const n=function(e){switch(e.dateFormat[0]){case"d":return"dmy";case"m":return"mdy";case"y":return"ymd"}throw new Error("Invalid date format in locale")}(t);if(!r)return"dmy"===n?{day:i,month:s,year:r,dateString:e,type:"dmy"}:{month:i,day:s,year:r,dateString:e,type:"mdy"};if(r.length>2)return"mdy"===n?{month:i,day:s,year:r,dateString:e,type:"mdy"}:{day:i,month:s,year:r,dateString:e,type:"dmy"};if("mdy"===n)return{month:i,day:s,year:r,dateString:e,type:"mdy"};if("ymd"===n)return{year:i,month:s,day:r,dateString:e,type:"ymd"};if("dmy"===n)return{day:i,month:s,year:r,dateString:e,type:"dmy"};return null}(e,t);if(r){const t=r.dateString.match(Ft)[0];if(s=function(e,t){let{year:o,month:i,day:s}=e;const r=function(e){if(!e)return Ot;const t=Number(e);if(t>=1&&t<=12)return t-1;return null}(i),n=function(e){if(!e)return 1;const t=Number(e);if(t>=0&&t<=31)return t;return null}(s),a=function(e){if(!e)return At;const t=Number(e);switch(e.length){case 1:return Tt+t;case 2:return Tt+(Tt+t>At+10?-100:0)+t;case 3:case 4:return t}return null}(o);if(null===a||null===r||null===n)return null;const l=2===i?.length&&r+1<10||2===s?.length&&n<10,c=2!==o?.length,h=new yt(a,r,n);if(h.getMonth()!==r||h.getDate()!==n)return null;const d=h.getTime()-It.getTime(),u=function(e,t,o,i){const s=e.year?i?"yyyy":"yy":void 0,r=e.month?o?"mm":"m":void 0,n=e.day?o?"dd":"d":void 0;switch(e.type){case"mdy":return[r,n,s].filter(ke).join(t);case"ymd":return[s,r,n].filter(ke).join(t);case"dmy":return[n,r,s].filter(ke).join(t)}}(e,t,l,c);return{value:Math.round(d/Rt),format:u,jsDate:h}}(r,t),null===s)return null;e=e.replace(r.dateString,"").trim()}if(""!==e||!s&&!o)return null;if(s&&s.jsDate&&o&&o.jsDate)return{value:s.value+o.value,format:s.format+" "+("hhhh:mm:ss"===o.format?"hh:mm:ss":o.format),jsDate:new yt(s.jsDate.getFullYear()+o.jsDate.getFullYear()-1899,s.jsDate.getMonth()+o.jsDate.getMonth()-11,s.jsDate.getDate()+o.jsDate.getDate()-30,s.jsDate.getHours()+o.jsDate.getHours(),s.jsDate.getMinutes()+o.jsDate.getMinutes(),s.jsDate.getSeconds()+o.jsDate.getSeconds())};return s||o}(e,t)),kt.get(t).get(e)}function Vt(e){const t=Math.trunc(e);let o=yt.fromTimestamp(t*Rt-Mt),i=e-t;i=i<0?1+i:i;const s=Math.round(24*i),r=Math.round(24*(i-s/24)*60),n=Math.round(24*(i-s/24-r/24/60)*60*60);return o.setHours(s),o.setMinutes(r),o.setSeconds(n),o}function Bt(e){const t=e.getTime()-It.getTime();return Math.round(t/Rt)}function zt(e){return new yt(e.getFullYear(),e.getMonth()+1,0).getDate()}function Ht(e){return zt(e)===e.getDate()}function $t(e,t,o){const i=e.getFullYear(),s=e.getMonth(),r=e.getDate(),n=new yt(i,s+t,1);return o&&r===zt(e)||r>zt(n)?n.setDate(zt(n)):n.setDate(r),n}function Wt(e){const t=Math.trunc(e);return t%4==0&&t%100!=0||t%400==0}function Gt(e,t,o){if(e===t)return 0;if(e>t){const o=t;t=e,e=o}const i=Vt(e),s=Vt(t);let r=i.getDate(),n=s.getDate();const a=i.getMonth(),l=s.getMonth(),c=i.getFullYear(),h=s.getFullYear();let d=0,u=0;switch(o){case 0:31===r&&(r=30),30===r&&31===n&&(n=30),1===a&&r===(Wt(c)?29:28)&&(r=30,1===l&&n===(Wt(h)?29:28)&&(n=30)),d=c+(30*a+r)/360,u=h+(30*l+n)/360;break;case 1:let o=365;const i=c===h;if(!i&&!(c+1===h)||!i&&a<l||!i&&a===l&&r<n){let e=0,t=0;for(let o=c;o<=h;o++)e++,t+=Wt(o)?366:365;o=t/e}else i?Wt(c)&&(o=366):(Wt(c)&&a<2&&(o=366),Wt(h)&&(l>1||1===l&&29===n)&&(o=366));d=e/o,u=t/o;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===n&&(n=30),d=c+(30*a+r)/360,u=h+(30*l+n)/360}return u-d}function qt(e,t){const o=12*(t.getFullYear()-e.getFullYear())+t.getMonth()-e.getMonth();return e.getDate()>t.getDate()?o-1:o}function Zt(e,t){const o=e.getTime(),i=t.getTime();return Math.floor((i-o)/Rt)}function Yt(e,t){const o=t.getFullYear()-e.getFullYear(),i=e.getMonth(),s=t.getMonth(),r=e.getDate(),n=t.getDate();return s>i||s===i&&n>=r?o:o-1}const jt=140,Xt=20,Kt=.035;function Qt(e){return Xt+(jt-Xt)*Math.exp(-Kt*(e-1))}const Jt=[{name:"English (US)",code:"en_US",thousandsSeparator:",",decimalSeparator:".",dateFormat:"m/d/yyyy",timeFormat:"hh:mm:ss a",formulaArgSeparator:","},{name:"French",code:"fr_FR",thousandsSeparator:" ",decimalSeparator:",",dateFormat:"dd/mm/yyyy",timeFormat:"hh:mm:ss",formulaArgSeparator:";"}],eo=Jt[0],to=Qe((function(e){return e=Se(e),new RegExp(`(^-?\\d+(${e}?\\d*(e\\d+)?)?|^-?${e}\\d+)(?!\\w|!)`)})),oo=Qe((function(e){const t=Se(e.decimalSeparator),o="(\\s*"+`(\\d+(${Se(e.thousandsSeparator)}\\d{3,})*(${t}\\d*)?)`+"|"+`(${t}\\d+)`+")(e(\\+|-)?\\d+)?(\\s*%)?",i="(\\s*-)?",s="(\\s*[\\$€])?",r="^(("+[i+s+o,i+o+s,s+i+o].join(")|(")+"))$";return new RegExp(r,"i")}));function io(e,t){return!!e&&oo(t).test(e.trim())}const so=Qe((function(e){return new RegExp(`[$€${Se(e.thousandsSeparator)}]`,"g")}));function ro(e,t){"."!==t.decimalSeparator&&(e=e.replace(t.decimalSeparator,".")),e=e.replace(so(t),"");let o=Number(e);return isNaN(o)&&e.includes("%")&&(o=Number(e.split("%")[0]),!isNaN(o))?o/100:o}function no(e,t,o){const i=[...e].sort(((e,t)=>e-t));let s=(i.length+(o?-1:1))*t;if(o||s--,Number.isInteger(s))return i[s];const r=Math.ceil(s),n=Math.floor(s);return i[r]*(s-n)+i[n]*(r-s)}const ao=20,lo=11,co=/(\d+?)(?=(\d{3})+(?!\d)|$)/g,ho=/0/g,uo={0:r("January"),1:r("February"),2:r("March"),3:r("April"),4:r("May"),5:r("June"),6:r("July"),7:r("August"),8:r("September"),9:r("October"),10:r("November"),11:r("December")},go={0:r("Sunday"),1:r("Monday"),2:r("Tuesday"),3:r("Wednesday"),4:r("Thursday"),5:r("Friday"),6:r("Saturday")},po={};function mo(e){let t=po[e];return void 0===t&&(t=function(e){if(""===e)throw new Error("A format cannot be empty");let t=0,o=[];for(;t<e.length;){let i;if("["===e.charAt(t)){if("$"!==e.charAt(t+1))throw new Error(`Currency formats have to be prefixed by a $: ${e}`);if(i=e.substring(t+1).indexOf("]")+t+2,0===i)throw new Error(`Invalid currency brackets format: ${e}`);const s=e.substring(t+2,i-1);if(s.includes("["))throw new Error(`Invalid currency format: ${e}`);o.push({type:"STRING",format:s})}else{const s=e.substring(t).indexOf("[");i=s>-1?s+t:e.length;const r=e.substring(t,i);xo(r)?o.push({type:"DATE",format:r}):o.push({type:"NUMBER",format:Uo(r)})}t=i}return o}(e),po[e]=t),t}function fo(e,{format:t,locale:o}){switch(typeof e){case"string":return e.includes('\\"')?e.replace(/\\"/g,'"'):e;case"boolean":return e?"TRUE":"FALSE";case"number":t||(t=Oo(e));return function(e,t,o){if("DATE"===t[0].type)return Io(e,t[0].format);let i=e<0?"-":"";for(let s of t)switch(s.type){case"NUMBER":i+=bo(Math.abs(e),s.format,o);break;case"STRING":i+=s.format}return i}(e,mo(t),o);case"object":return"0"}}function bo(e,t,o){t.isPercent&&(e*=100),e/=t.magnitude;let i=0;void 0!==t.decimalPart&&(i=t.decimalPart.length);const{integerDigits:s,decimalDigits:r}=So(e,i);let n=function(e,t,o){const i="0"===e?"":e;let s=i;const r=t.length-i.length;if(r>0){const e=(t.substring(0,r).match(ho)||[]).length;s="0".repeat(e)+s}o&&(s=s.match(co)?.join(o)||s);return s}(s,t.integerPart,t.thousandsSeparator?o.thousandsSeparator:void 0);return void 0!==t.decimalPart&&(n+=o.decimalSeparator+function(e,t){let o=e;if(t.length-e.length>0){const i=(t.substring(e.length,t.length+1).match(ho)||[]).length;o+="0".repeat(i)}return o}(r||"",t.decimalPart)),t.isPercent&&(n+="%"),n}const vo=[];function So(e,t=ao){const o=e.toString();if(o.includes("e"))return function(e,t=ao){let o=vo[t];o||(o=new Intl.NumberFormat("en-US",{maximumFractionDigits:t,useGrouping:!1}),vo[t]=o);const[i,s]=o.format(e).split(".");return{integerDigits:i,decimalDigits:s}}(e,t);if(Number.isInteger(e))return{integerDigits:o,decimalDigits:void 0};const i=o.indexOf(".");let s=o.substring(0,i),r=o.substring(i+1);if(0===t)return Number(r[0])>=5&&(s=(Number(s)+1).toString()),{integerDigits:s,decimalDigits:void 0};if(r.length>t){const{integerDigits:e,decimalDigits:o}=function(e,t){let o="0",i=e,s=e.slice(0,t);const r=t;if(Number(e[r])<5)return{integerDigits:o,decimalDigits:s};const n=s.match(Eo)?.[0]||"",a=(Number(s)+1).toString(),l=s.slice(n.length),c=a.length>l.length;c&&!n?(o="1",i=void 0):i=c?n.slice(0,-1)+a:n+a;return{integerDigits:o,decimalDigits:i}}(r,t);r=o,"0"!==e&&(s=(Number(s)+Number(e)).toString())}return{integerDigits:s,decimalDigits:Co(r||"")}}function Co(e){let t=e.length-1;for(;t>=0&&"0"===e[t];)t--;return e.slice(0,t+1)||void 0}const Eo=/^0+/;function wo(e,t){const{integerDigits:o,decimalDigits:i}=So(e,20);return i?o+t+i:o}function xo(e){if(!yo.has(e[0]))return!1;try{return Io(1,e),!0}catch(e){return!1}}const yo=new Set(["h","m","y","d"]);function Io(e,t){const o=Vt(e),i=t.indexOf("h");let s="",r="";return i>0?(s=Ro(o,t.substring(0,i-1)),r=To(o,t.substring(i))):0===i?r=To(o,t):i<0&&(s=Ro(o,t)),s+(s&&r?" ":"")+r}function Ro(e,t){const o=t.match(/\/|-|\s/)?.[0];return(o?t.split(o):[t]).map((o=>{switch(o){case"d":return e.getDate();case"dd":return e.getDate().toString().padStart(2,"0");case"ddd":return go[e.getDay()].slice(0,3);case"dddd":return go[e.getDay()];case"m":return e.getMonth()+1;case"mm":return String(e.getMonth()+1).padStart(2,"0");case"mmm":return uo[e.getMonth()].slice(0,3);case"mmmm":return uo[e.getMonth()];case"mmmmm":return uo[e.getMonth()].slice(0,1);case"yy":const o=String(e.getFullYear()).replace("-","").padStart(2,"0");return o.slice(o.length-2);case"yyyy":return e.getFullYear();default:throw new Error(`invalid format: ${t}`)}})).join(o)}function To(e,t){let o=t.split(/:|\s/);const i=e.getHours(),s="a"===o[o.length-1];let r=i,n="";return s&&(r=0===r?12:r>12?r-12:r,n=i>=12?" PM":" AM",o.pop()),o.map((o=>{switch(o){case"hhhh":return Math.floor((e.getTime()-It.getTime())/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(":")+n}const Ao=Qe((function(e){return new RegExp(`[0-9]+${Se(e.decimalSeparator)}[0-9]`)}));function Oo(e){let{integerDigits:t,decimalDigits:o}=So(e);if(!o)return"0";const i=t.replace("-","").length;if(i+2>lo)return"0";const s=lo-i-1;return({decimalDigits:o}=So(e,Math.min(s,o.length))),o?"0."+"0".repeat(o.length):"0"}function Mo(e,t){if(!Pt(e,t))return;return Ut(e,t).format}function No(e){if(!io(e,eo))return;const t=e.includes(".")?"0.00":"0",o=e.match(/[\$€]/);if(o){const i=e.match(/[\d]/),s="[$"+o.values().next().value+"]";return i.index<o.index?"#,##"+t+s:s+"#,##"+t}return e.includes("%")?t+"%":void 0}function _o(e){const t=e.decimalPlaces??2,o=e.position??"before",i=e.code??"",s=e.symbol??"",r="#,##0"+(t?"."+"0".repeat(t):"");let n=`${i} ${s}`.trim();return"after"===o&&i&&(n=" "+n),function(e,t,o){const i=`[$${e}]`;return"before"===t?i+o:o+i}(n,o,r)}function Fo(e){return Bo(mo(e).map((e=>"NUMBER"===e.type?{type:e.type,format:{...e.format,decimalPart:void 0}}:e)))}function Do(e,t,o,i){const s=mo(e||"#,##0"),r=[];for(let e=0;e<s.length;e++){const i=s[e];if("NUMBER"!==i.type){r.push(i);continue}r.push({...i,format:{...i.format,magnitude:t,decimalPart:void 0}}),r.push({type:"STRING",format:o});const n=s[e+1];"STRING"===n?.type&&["k","m","b"].includes(n.format)&&e++}return Bo(r)}function Lo(e,t,o){const i=mo(e).map((e=>"NUMBER"===e.type?{...e,format:Po(e.format,t)}:e)),s=Bo(i);return po[s]=i,s}function Po(e,t){const o={...e},i=Math.sign(t),s=o.decimalPart?.length||0,r=Math.min(Math.max(0,s+i),ao);return o.decimalPart="0".repeat(r),""===o.decimalPart&&delete o.decimalPart,o}const ko=/,*?$/;function Uo(e){if(function(e){return Boolean(e.replace(Vo,""))}(e=e.trim()))throw new Error(`Invalid number format: ${e}`);const t=e.includes("%"),o=e.match(ko)?.[0]||"",i=o?1e3**o.length:1;let s=e.slice(0,e.length-(o.length||0));const r=s.includes(",");if(/\..*,/.test(s))throw new Error("A format can't contain ',' symbol in the decimal part");s=s.replace("%","").replace(",","");const n=s.match(/[\%|,]/);if(n)throw new Error(`A format can only contain a single '${n[0]}' symbol`);const[a,l]=s.split(".");if(l&&l.length>20)throw new Error("A format can't contain more than 20 decimal places");return void 0!==l?{integerPart:a,isPercent:t,thousandsSeparator:r,decimalPart:l,magnitude:i}:{integerPart:a,isPercent:t,thousandsSeparator:r,magnitude:i}}const Vo=/[,#0.%]/g;function Bo(e){let t="";for(let o of e){let e;switch(o.type){case"NUMBER":const t=o.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=`[$${o.format}]`;break;case"DATE":e=o.format}t+=e}return t}const zo=new RegExp(/\$?([A-Z]{1,3})\$?([0-9]{1,7})/,"i"),Ho=new RegExp(/^\$?([A-Z]{1,3})\$?([0-9]{1,7})$/,"i"),$o=new RegExp(/^\$?([A-Z]{1,3})+$/,"i"),Wo=new RegExp(/^\$?([0-9]{1,7})+$/,"i"),Go=new RegExp(/^\s*('.+'!|[^']+!)?\$?([A-Z]{1,3})$/,"i"),qo=new RegExp(/^\s*('.+'!|[^']+!)?\$?([0-9]{1,7})$/,"i"),Zo=new RegExp(/^\s*('.+'!|[^']+!)?/.source+"("+[zo.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 Yo(e){return Go.test(e)}function jo(e){return qo.test(e)}function Xo(e){return $o.test(e)}function Ko(e){return Wo.test(e)}function Qo(e){return Ho.test(e)}function Jo(e){const t=e.split("!"),o=t.pop();return{sheetName:Ee(t.join("!"))||void 0,xc:o}}function ei(e){const t=function(e){let t,o,i,s,r;e.includes("!")&&(e=e.split("!").at(-1)),e.includes("$")&&(e=e.replace(/\$/g,"")),t=e.includes(":")?e.split(":").map((e=>e.trim())):[e.trim()];let n=!1,a=!1,l=!1;const c=t[0],h=t[1]&&t[1];if(Yo(c))s=r=St(c),o=i=0,n=!0;else if(jo(c))o=i=parseInt(c,10)-1,s=r=0,a=!0;else{const e=wt(c);s=r=e.col,o=i=e.row,l=!0}if(2===t.length)if(Yo(h))r=St(h),n=!0;else if(jo(h))i=parseInt(h,10)-1,a=!0;else{const e=wt(h);r=e.col,i=e.row,o=n?i:o,s=a?r:s,l=!0}if(n&&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:o,left:s,bottom:n?void 0:i,right:a?void 0:r};return l=l&&(a||n),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 ti(e){const t=ei(e);if(void 0===t.bottom||void 0===t.right)throw new Error("This does not support unbounded ranges");return t}function oi(e){const{bottom:t,top:o,left:i,right:s}=e;return!(void 0!==t&&isNaN(t)||isNaN(o)||isNaN(i)||void 0!==s&&isNaN(s))&&((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:o,left:i,right:s}=e,n="hasHeader"in e&&e.hasHeader,a=t===o&&i===s;if(void 0===o&&void 0!==s)return 0!==t||n?`${xt(i,t)}:${bt(s)}`:`${bt(i)}:${bt(s)}`;if(void 0===s&&void 0!==o)return 0!==i||n?`${xt(i,t)}:${o+1}`:`${t+1}:${o+1}`;if(void 0!==o&&void 0!==s)return a?xt(i,t):`${xt(i,t)}:${xt(s,o)}`;throw new Error(r("Bad zone format"))}function si(e,t,o,i,s){const r="left"===t?"columns":"rows",n="before"===i?o-1:o,a=e["left"===t?"right":"bottom"];return e[t]<=n&&a&&a>n?Si(e,r,"RESIZE",s):n<e[t]?Si(e,r,"MOVE",s):{...e}}function ri(e,t,o,i,s){const r="left"===t?"columns":"rows",n="before"===i?o-1:o,a="left"===t?"right":"bottom";return e[t]<=n&&e[a]>n?Si(e,r,"RESIZE",s):n<e[t]?Si(e,r,"MOVE",s):{...e}}function ni(e,t,o){const i="left"===t?"right":"bottom";let s=e[t],r=e[i];for(let n of o.sort(((e,t)=>t-e)))e[t]>n&&(s--,r--),e[t]<n&&e[i]>=n&&r--;return{...e,[t]:s,[i]:r}}function ai(e,t,o){const i="left"===t?"right":"bottom";let s=e[t],r=e[i];const n=e[i];for(let i of o.sort(((e,t)=>t-e)))e[t]>i&&(s--,void 0!==r&&r--),void 0!==n&&void 0!==r&&e[t]<=i&&n>=i&&r--;if(!(void 0!==r&&s>r))return{...e,[t]:s,[i]:r}}function li(...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 ci(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 hi(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 ui(e,t,o){const{left:i,right:s,top:r,bottom:n}=o;return e>=i&&e<=s&&t>=r&&t<=n}function gi(e,t){return hi(li(t,e),t)}function pi(e,t){const o=e.map(ei),i=t.map(ti),s=Math.max(...o.concat(i).map((e=>e.bottom||0))),r=Math.max(...o.concat(i).map((e=>e.right||0))),n=o.map((e=>({...e,bottom:void 0===e.bottom?s+1:e.bottom,right:void 0===e.right?r+1:e.right}))),a=i.map((e=>({...e,bottom:void 0===e.bottom?s+1:e.bottom,right:void 0===e.right?r+1:e.right}))),l=function(e,t){const o=new Set(t.map((({col:e,row:t})=>`${e}-${t}`)));return e.filter((({col:e,row:t})=>!o.has(`${e}-${t}`)))}(n.map(vi).flat(),a.map(vi).flat()),c=function(e){if(0===e.length)return[];const[t,...o]=[...e].sort(((e,t)=>e.row-t.row)).sort(((e,t)=>e.col-t.col)),i=[];let s=wi(t);for(const{col:e,row:t}of o)if(!ui(e,t,s))if(e===s.left&&t===s.bottom+1){const e=s.bottom+1;s={...s,bottom:e}}else i.push(s),s=wi({col:e,row:t});return[...i,s]}(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=[],o=mi(e),i=(e,t)=>e.top===t.top&&e.bottom===t.bottom&&e.right+1===t.left;for(;o.length;){const e=o.reduce(((e,t)=>i(e,t)?li(e,t):e),o.shift());t.push(e)}return mi(t)}(c).map((e=>({...e,bottom:e.bottom===s+1?void 0:e.bottom,right:e.right===r+1?void 0:e.right}))).map(ii)}function mi(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(),o=[];for(;0!==t.length;){const e=t.shift();t.some((t=>gi(e,t)))||o.push(e)}return o.reverse()}function fi(e){return{numberOfRows:e.bottom-e.top+1,numberOfCols:e.right-e.left+1}}function bi(e){const{numberOfCols:t,numberOfRows:o}=fi(e);return 1===t||1===o}function vi(e){const t=[],[o,i]=[e.right,e.left].sort(((e,t)=>e-t)),[s,r]=[e.top,e.bottom].sort(((e,t)=>e-t));for(const e of ye(o,i+1))for(const o of ye(s,r+1))t.push({col:e,row:o});return t}function Si(e,t,o,i){const s="both"===t?i[0]:"columns"===t?i:0,r="both"===t?i[1]:"rows"===t?i:0,n="hasHeader"in e&&e.hasHeader;let a;a=!function(e){return void 0===e.bottom}(e)||n?!(xi(e)&&!n)||"columns"!==t:"rows"!==t;const l={...e};return a&&"MOVE"===o&&(l.left+=s,l.top+=r),void 0!==l.right&&(l.right+=s),void 0!==l.bottom&&(l.bottom+=r),l}function Ci(e,t){let o,i;const{left:s,right:r,top:n,bottom:a}=e,{left:l,right:c,top:h,bottom:d}=t;return o=l!=s?l:c!=r?c:l,i=h!=n?h:d!=a?d:h,{col:o,row:i}}function Ei(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 xi(e){return void 0===e.right}function yi(e){return(e.bottom-e.top+1)*(e.right-e.left+1)}function Ii(...e){return e.length<2||1===pi(e.map(ii),[]).length}class Ri{getSheetSize;_zone;parts;invalidXc;prefixSheet=!1;sheetId;invalidSheetName;constructor(e,t){this.getSheetSize=t,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 Ri?e:new Ri(e,t.getSheetSize)}get unboundedZone(){return this._zone}get zone(){const{left:e,top:t,bottom:o,right:i}=this._zone;if(void 0!==i&&void 0!==o)return this._zone;if(void 0===o&&void 0!==i)return{right:i,top:t,left:e,bottom:this.getSheetSize(this.sheetId).numberOfRows-1};if(void 0===i&&void 0!==o)return{bottom:o,left:e,top:t,right:this.getSheetSize(this.sheetId).numberOfCols-1};throw new Error(r("Bad zone format"))}static getRangeParts(e,t){const o=e.split(":").map((e=>{const t=jo(e);return{colFixed:!t&&e.startsWith("$"),rowFixed:t?e.startsWith("$"):e.includes("$",1)}})),i=void 0===t.bottom,s=void 0===t.right;return i&&(o[0].rowFixed=o[0].rowFixed||o[1].rowFixed,o[1].rowFixed=o[0].rowFixed||o[1].rowFixed),s&&(o[0].colFixed=o[0].colFixed||o[1].colFixed,o[1].colFixed=o[0].colFixed||o[1].colFixed),o}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(){const e={...this._zone};let t=this.parts;if(void 0!==e.right&&e.right<e.left){let o=e.right;e.right=e.left,e.left=o,t=[{colFixed:t[1]?.colFixed||!1,rowFixed:t[0]?.rowFixed||!1},{colFixed:t[0]?.colFixed||!1,rowFixed:t[1]?.rowFixed||!1}]}if(void 0!==e.bottom&&e.bottom<e.top){let o=e.bottom;e.bottom=e.top,e.top=o,t=[{colFixed:t[0]?.colFixed||!1,rowFixed:t[1]?.rowFixed||!1},{colFixed:t[1]?.colFixed||!1,rowFixed:t[0]?.rowFixed||!1}]}return this.clone({zone:e,parts:t})}clone(e){return new Ri({zone:e?.zone?e.zone:{...this._zone},sheetId: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:e?.parts?e.parts:this.parts.map((e=>({rowFixed:e.rowFixed,colFixed:e.colFixed}))),prefixSheet:e?.prefixSheet?e.prefixSheet:this.prefixSheet},this.getSheetSize)}}function Ti(e,t,o){const i=o.sheetId===e?t:o.sheetId;return o.clone({sheetId:i})}function Ai(e,t,o){return o?e.getRangeFromSheetXC(t,o):void 0}function Oi(e,t,o){const i=[];return t.forEach((t=>{const s=function(e,t){e=e.toLocaleLowerCase();let o=0,i=0,s=(t=t.toLocaleLowerCase()).length,r=0;for(let n=0;n<s;n++)t[n]===e[r]?(r++,i+=100+i-n/200):i=0,o+=i;return r===e.length?o:0}(e,o(t));s>0&&i.push({score:s,elem:t})})),i.sort(((e,t)=>t.score-e.score)),i.map((e=>e.elem))}function Mi(e){const t=[];for(let o=0;o<e;o++){const e={cells:{}};t.push(e)}return t}function Ni(e,t=1){return t*(e+z)-z}const _i={};function Fi(e,t,o){const i=Li(o);if(_i[i]||(_i[i]={}),void 0===_i[i][t]){e.save(),e.font=i;const o=e.measureText(t).width;e.restore(),_i[i][t]=o}return _i[i][t]}function Di(e){return Math.round(96*e/72)}function Li(e){return`${e.italic?"italic ":""}${e.bold?"bold":q} ${Pi(e)}px ${Y}`}function Pi(e){return Di(e?.fontSize||Z)}function ki(e,t,o,i){if(Fi(e,t,i)<=o)return[t];const s=[];let r="";for(let n of t){Fi(e,r+n,i)>o?(s.push(r),r=n):r+=n}return s.push(r),s}function Ui(e,t,o,i){o||(o={});const s=[],r=t.includes(fe)?t.split(fe):[t];for(const t of r){const r=t.includes(" ")?t.split(" "):[t];if(!i){s.push(t);continue}let n="",a=i;for(let t of r){const r=ki(e,t,i,o),l=r.pop(),c=Fi(e,l,o);if(r.length)""!==n&&(s.push(n),n="",a=i),r.forEach((e=>{s.push(e)})),n=l,a=i-c;else{const t=""===n?l:" "+l,r=Fi(e,t,o);r<=a?(n+=t,a-=r):(s.push(n),n=l,a=i-c)}}""!==n&&s.push(n)}return s}function Vi(e){return e?e.toLowerCase():""}class Bi{isFastIdStrategy=!1;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)}))}}class zi extends t.Component{static template="o-spreadsheet-ChartJsComponent";canvas=t.useRef("graphContainer");chart;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;We(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){const t=e.chartJsConfig;t.data&&t.data.datasets?(this.chart.data=t.data,t.options?.title&&(this.chart.config.options.title=t.options.title),t.options&&"valueLabel"in t.options&&t.options?.valueLabel&&(this.chart.config.options.valueLabel=t.options.valueLabel)):this.chart.data.datasets=void 0,this.chart.config.options.tooltips=t.options?.tooltips,this.chart.config.options.legend=t.options?.legend,this.chart.config.options.scales=t.options?.scales,this.chart.update({duration:0})}}zi.props={figure:Object};const Hi={};let $i=0;function Wi(e,...t){const o="__sheet__"+$i++;return function(e,t){const o=document.createElement("style");o.textContent=function(e){const t=e.split(/(\{|\}|;)/).map((e=>e.trim())),o=[],i=[];let s=[];function r(e,t){const i=[];for(const s of o[e]){let n=t&&t+" "+s||s;n.includes("&")&&(n=s.replace(/&/g,t||"")),e<o.length-1&&(n=r(e+1,n)),i.push(n)}return i.join(", ")}function n(){s.length&&(i.push(r(0)+" {"),i.push(...s),i.push("}"),s=[])}for(;t.length;){let e=t.shift();"}"===e?(n(),o.pop()):("{"===t[0]&&(n(),o.push(e.split(/\s*,\s*/)),t.shift()),";"===t[0]&&s.push(" "+e+";"))}return i.join("\n")}(t),Hi[e]=o}(o,String.raw(e,...t)),function(e){const t=Hi[e];t.setAttribute("component",e),document.head.appendChild(t)}(o),o}function Gi({strikethrough:e,underline:t}){return e||t?`${e?"line-through":""} ${t?"underline":""}`:"none"}function qi(e){const t=Zi(e);return e?(e.fillColor&&(t.background=e.fillColor),t):t}function Zi(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 o=e.strikethrough?"line-through":"";o=e.underline?o+" underline":o,t["text-decoration"]=o}return e.textColor&&(t.color=e.textColor),t}function Yi(e){return Object.entries(e).filter((([e,t])=>void 0!==t)).map((([e,t])=>`${e}:${t};`)).join(" ")}const ji=1.2;Wi`
|
|
1
|
+
!function(e,t){"use strict";let o=e=>e;function i(e,...t){if(1===t.length&&"object"==typeof t[0]){const o=t[0];e=e.replace(/\%\(?([^\)]+)\)s/g,((e,t)=>o[t]))}else t.length>0&&(e=e.replace(/\%s/g,(()=>t.shift())));return e}const s=function(e,...t){return i(o(e),...t)},r=function(e,...t){return new n(e,t)};class n extends String{values;constructor(e,t){super(e),this.values=t}valueOf(){const e=super.valueOf();return i(o(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{errorType;logLevel;constructor(e,t,o=l.error){super(t),this.errorType=e,this.logLevel=o}}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(e){super(a.NotAvailable,e||r("Data not available"),e?l.error:l.silent)}}class p extends c{constructor(e){super(a.UnknownFunction,r('Unknown function: "%s"',e))}}const m=.5,f="#f5f5f5",b="#F8F9FA",v="#E8EAED",S="#595959",C="#666666",E="#3266ca",w="#FFFFFF",x="#EBEBEB",y="#CACACA",I=11982760,R="#01666b",T="#188038",A="#E6F4EA",O="#CEEAD6",M="#E0E2E4",N="#4A4F59",_=["#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"],F=26,D=48,L=96,P=23,k=15,U=18,V=14,B=4,z=4,H=3,$=z,W=17,G=250,q="400",Z=10,Y="'Roboto', arial",j="bottom",X="overflow",K="thin",Q="#000000",J={style:"thin",color:T},ee=a.InvalidReference,te="START_REVISION",oe=1,ie=20,se="??",re="difference",ne="#00A04A",ae="#DC6965",le=.4,ce=["'","*","?","/","\\","[","]"],he=/'|\*|\?|\/|\\|\[|\]/,de="|",ue=r("Invalid expression");var ge;!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.IconPicker=25]="IconPicker",e[e.TopBarComposer=30]="TopBarComposer",e[e.Popover=35]="Popover",e[e.FigureAnchor=1e3]="FigureAnchor",e[e.FigureSnapLine=1001]="FigureSnapLine"}(ge||(ge={}));let pe=0;function me(){return pe}const fe="\n",be=[6,7,8,9,10,11,12,14,18,24,36];function ve(e){return'"'===e[0]&&(e=e.slice(1)),'"'===e[e.length-1]&&"\\"!==e[e.length-2]?e.slice(0,e.length-1):e}function Se(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Ce(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&&e?.constructor===Object}(e)||e instanceof Array))throw new Error("Unsupported type: only objects and arrays are supported");for(const o in e)t[o]=Ce(e[o]);return t;case"number":case"string":case"boolean":case"function":case"undefined":return e;default:throw new Error("Unsupported type: "+typeof e)}}function Ee(e){return e.startsWith("'")&&(e=e.slice(1,-1).replace(/''/g,"'")),e}function we(e){return e.match(/\w/g)?.length!==e.length&&(e=`'${e}'`),e}function xe(e,t,o){return e<t?t:e>o?o:e}function ye(e,t,o=1){if(t<=e&&o>0)return[];if(0===o)throw new Error("range() step must not be zero");const i=Math.ceil(Math.abs((t-e)/o)),s=Array(i);for(let t=0;t<i;t++)s[t]=e+t*o;return s}function Ie(e){return e.reduce(((e,t,o,i)=>{if(1===Math.abs(t-i[o-1])){e[e.length-1].push(t)}else e.push([t]);return e}),[])}function*Re(e,t){t.next();for(const o of e){const e=t.next();yield{...o,next:e.done?void 0:e.value}}}const Te=/^\[(.+)\]\((.+)\)$/,Ae=/^https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,4}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)$/;function Oe(e){return Te.test(e)}function Me(e){return Ae.test(e)}function Ne(e,t){return`[${e}](${t})`}function _e(e){const t=e.match(Te)||[],o=t[1],i=t[2];if(!o||!i)throw new Error(`Could not parse markdown link ${e}.`);return{label:o,url:i}}const Fe="o-spreadsheet://";function De(e){return e.startsWith(Fe)}function Le(e){return`${Fe}${e}`}function Pe(e){if(e.startsWith(Fe))return e.substr(Fe.length);throw new Error(`${e} is not a valid sheet link`)}function ke(e){return void 0!==e}function Ue(e){return void 0===e||Object.values(e).every((e=>"object"==typeof e?Ue(e):!e))}function Ve(e,t){for(let[o,i]of Object.entries(t))if(We(i,e))return parseInt(o,10);const o=Object.keys(t),i=0===o.length?0:et(o.map((e=>parseInt(e,10))));return t[i+1]=e,i+1}function Be(e){let t="";for(let o=0,i=e.length;o<i;o++)t+=e[o];return t}function ze(e){let t,o=!1;const i=()=>(o||(t=e instanceof Function?e():e,o=!0),t);return i.map=e=>ze((()=>e(i()))),i}function He(e,t){let o=e.slice(t).find((e=>e));return o||(o=e.slice(0,t).reverse().find((e=>e))),o||""}function $e(e,t){return"after"===e?t+1:t}function We(e,t){if(e===t)return!0;if(e&&!t||t&&!e)return!1;if(typeof e!=typeof t)return!1;if("object"!=typeof e)return!1;const o=new Set;Object.keys(e).forEach((e=>o.add(e))),Object.keys(t).forEach((e=>o.add(e)));for(let i of o){if(typeof e[i]!=typeof e[i])return!1;if("object"==typeof e[i]){if(!We(e[i],t[i]))return!1}else if(e[i]!==t[i])return!1}return!0}function Ge(e,t){return t.every((t=>e.includes(t)))}function qe(e){const t={...e};return Object.keys(t).forEach((e=>!t[e]&&delete t[e])),t}function Ze(e,t=(e=>e)){if(!e.length)return[];const o=Array(e[0].length);for(let i=0;i<e[0].length;i++){o[i]=Array(e.length);for(let s=0;s<e.length;s++)o[i][s]=t(e[s][i])}return o}const Ye=["\t","\f","\v",String.fromCharCode(parseInt("00a0",16)),String.fromCharCode(parseInt("1680",16)),String.fromCharCode(parseInt("2000",16)),String.fromCharCode(parseInt("200a",16)),String.fromCharCode(parseInt("2028",16)),String.fromCharCode(parseInt("2029",16)),String.fromCharCode(parseInt("202f",16)),String.fromCharCode(parseInt("205f",16)),String.fromCharCode(parseInt("3000",16)),String.fromCharCode(parseInt("feff",16))],je=new RegExp(Ye.join("|")+"|(\r\n|\r|\n)","g");function Xe(e){return e?je.test(e)?e.replace(je,((e,t)=>t?fe:" ")):e:""}class Ke extends Set{addMany(e){for(const t of e)super.add(t);return this}deleteMany(e){let t=!1;for(const o of e)t||=super.delete(o);return t}}function Qe(e){const t=new Map,o=e.name?e.name+" (memoized)":"memoized";return{[o]:(...o)=>(t.has(o[0])||t.set(o[0],e(...o)),t.get(o[0]))}[o]}function Je(e,t){return e.filter(((e,o)=>!t.includes(o)))}function et(e){let t=e.length;if(t<1e5)return Math.max(...e);let o=-1/0;for(;t--;)o=e[t]>o?e[t]:o;return o}function tt(e){let t=e.length;if(t<1e5)return Math.min(...e);let o=1/0;for(;t--;)o=e[t]<o?e[t]:o;return o}const ot=/rgba?\(|\s+|\)/gi,it=/^#([A-F\d]{2}){3,4}$/,st=["#eb6d00","#0074d9","#ad8e00","#169ed4","#b10dc9","#00a82d","#00a3a3","#f012be","#3d9970","#111111","#62A300","#ff4136","#949494","#85144b","#001f3f"];function rt(e){return nt(e.toString(16).padStart(6,"0"))}function nt(e){let t=e;if(e.startsWith("rgb")?t=function(e){const t=e.replace(ot,"").split(",");let o=255;if(3!==t.length&&4!==t.length)throw new Error("invalid color");if(4===t.length){const e=parseFloat(t.pop()||"1");o=Math.round(255*(e||1))}const i=t.map((e=>parseInt(e,10)));255!==o&&i.push(o);return"#"+Be(i.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}`),!it.test(t))throw new Error(`invalid color input: ${e}`);return t}function at(e){try{return nt(e),!0}catch(e){return!1}}const lt=e=>e>=0&&e<=255;function ct(e,t,o,i=1){if(!lt(e)||!lt(t)||!lt(o)||i<0||i>1)throw new Error(`Invalid RGBA values ${[e,t,o,i]}`);return{a:i,b:o,g:t,r:e}}function ht(e){let{r:t,g:o,b:i}=ut(e);t/=255,o/=255,i/=255;const s=e=>e<=.03928?e/12.92:((e+.055)/1.055)**2.4;return.2126*s(t)+.7152*s(o)+.0722*s(i)}function dt(e){let t=e.r.toString(16),o=e.g.toString(16),i=e.b.toString(16),s=Math.round(255*e.a).toString(16);return 1===t.length&&(t="0"+t),1===o.length&&(o="0"+o),1===i.length&&(i="0"+i),1===s.length&&(s="0"+s),"ff"===s&&(s=""),("#"+t+o+i+s).toUpperCase()}function ut(e){let t,o,i,s;if(7===(e=nt(e)).length)t=parseInt(e[1]+e[2],16),o=parseInt(e[3]+e[4],16),i=parseInt(e[5]+e[6],16),s=255;else{if(9!==e.length)throw new Error("Invalid color");t=parseInt(e[1]+e[2],16),o=parseInt(e[3]+e[4],16),i=parseInt(e[5]+e[6],16),s=parseInt(e[7]+e[8],16)}return s=+(s/255).toFixed(3),{a:s,r:t,g:o,b:i}}function gt(e){(e={...e}).s/=100,e.l/=100;let t=(1-Math.abs(2*e.l-1))*e.s,o=t*(1-Math.abs(e.h/60%2-1)),i=e.l-t/2,s=0,r=0,n=0;return 0<=e.h&&e.h<60?(s=t,r=o,n=0):60<=e.h&&e.h<120?(s=o,r=t,n=0):120<=e.h&&e.h<180?(s=0,r=t,n=o):180<=e.h&&e.h<240?(s=0,r=o,n=t):240<=e.h&&e.h<300?(s=o,r=0,n=t):300<=e.h&&e.h<360&&(s=t,r=0,n=o),s=Math.round(255*(s+i)),r=Math.round(255*(r+i)),n=Math.round(255*(n+i)),{a:e.a,r:s,g:r,b:n}}function pt(e){const t=e.r/255,o=e.g/255,i=e.b/255;let s=Math.min(t,o,i),r=Math.max(t,o,i),n=r-s,a=0,l=0,c=0;return a=0===n?0:r===t?(o-i)/n%6:r===o?(i-t)/n+2:(t-o)/n+4,a=Math.round(60*a),a<0&&(a+=360),c=(r+s)/2,l=0===n?0:n/(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}}function mt(e){return dt(gt(e))}function ft(e){return pt(ut(e))}function bt(e){if(e<0)throw new Error(`number must be positive. Got ${e}`);return e<26?String.fromCharCode(65+e):bt(Math.floor(e/26)-1)+bt(e%26)}const vt={};for(const e of"ABCDEFGHIJKLMNOPQRSTUVWXYZ"){const t=e.charCodeAt(0)-64;vt[e]=t,vt[e.toLowerCase()]=t}function St(e){let t=-1;let o=1;for(let i=e.length-1;i>=0;i--){t+=vt[e[i]]*o,o*=26}return t}function Ct(e){return e>="A"&&e<="Z"||e>="a"&&e<="z"}function Et(e){return e>="0"&&e<="9"}function wt(e){let t;e=e.trim();for(let o=0;o<e.length;o++){const i=e[o];if(!t){if("$"===i&&0===o||Ct(i))continue;t=o}if(!Et(i)){if("$"===i&&o===t)continue;throw new Error(`Invalid cell description: ${e}`)}}if(!t||t===e.length)throw new Error(`Invalid cell description: ${e}`);const o="$"===e[0]?e.slice(1,t):e.slice(0,t),i="$"===e[t]?e.slice(t+1):e.slice(t);if(o.length<1||o.length>3||i.length<1||i.length>7)throw new Error(`Invalid cell description: ${e}`);const s=St(o),r=Number(i)-1;if(isNaN(r))throw new Error(`Invalid cell description: ${e}`);return{col:s,row:r}}function xt(e,t,o={colFixed:!1,rowFixed:!1}){return(o.colFixed?"$":"")+bt(e)+(o.rowFixed?"$":"")+String(t+1)}class yt{jsDate;constructor(e,t,o,i=0,s=0,r=0){this.jsDate=new Date(Date.UTC(e,t,o,i,s,r,0))}static fromTimestamp(e){const t=new Date(e);return new yt(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate(),t.getUTCHours(),t.getUTCMinutes(),t.getUTCSeconds())}static now(){const e=new Date;return new yt(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds())}toString(){return this.jsDate.toString()}toLocaleDateString(){return this.jsDate.toLocaleDateString()}getTime(){return this.jsDate.getTime()}getFullYear(){return this.jsDate.getUTCFullYear()}getMonth(){return this.jsDate.getUTCMonth()}getDate(){return this.jsDate.getUTCDate()}getDay(){return this.jsDate.getUTCDay()}getHours(){return this.jsDate.getUTCHours()}getMinutes(){return this.jsDate.getUTCMinutes()}getSeconds(){return this.jsDate.getUTCSeconds()}setFullYear(e){this.jsDate.setFullYear(e)}setDate(e){this.jsDate.setUTCDate(e)}setHours(e){this.jsDate.setUTCHours(e)}setMinutes(e){this.jsDate.setUTCMinutes(e)}setSeconds(e){this.jsDate.setUTCSeconds(e)}}const It=new yt(1899,11,30),Rt=864e5,Tt=2e3,At=yt.now().getFullYear(),Ot=yt.now().getMonth(),Mt=yt.fromTimestamp(0).getTime()-It.getTime(),Nt=/^\d{1,2}(\/|-|\s)\d{1,2}((\/|-|\s)\d{1,4})?$/,_t=/^\d{3,4}(\/|-|\s)\d{1,2}(\/|-|\s)\d{1,2}$/,Ft=/\/|-|\s/,Dt=/^(\d{1,4})[\/-\s](\d{1,2})([\/-\s](\d{1,4}))?$/,Lt=/((\d+(:\d+)?(:\d+)?\s*(AM|PM))|(\d+:\d+(:\d+)?))$/;function Pt(e,t){return null!==Ut(e,t)}const kt=new Map;function Ut(e,t){return kt.has(t)||kt.set(t,new Map),kt.get(t).has(e)||kt.get(t).set(e,function(e,t){e=e.trim();let o=null;const i=e.match(Lt);if(i){if(o=function(e){if(e=e.trim(),Lt.test(e)){const t=/AM/i.test(e),o=/PM/i.test(e),i=(t||o?e.substring(0,e.length-2).trim():e).split(/:/),s=i.length>=2,r=3===i.length;let n=Number(i[0]),a=s?Number(i[1]):0,l=r?Number(i[2]):0,c=r?"hh:mm:ss":"hh:mm";if(t||o)c+=" a";else if(!s)return null;n>=12&&t?n-=12:n<12&&o&&(n+=12),a+=Math.floor(l/60),l%=60,n+=Math.floor(a/60),a%=60,n>=24&&(c="hhhh:mm:ss");return{value:n/24+a/1440+l/86400,format:c,jsDate:new yt(1899,11,30,n,a,l)}}return null}(i[0]),null===o)return null;e=e.replace(i[0],"").trim()}let s=null;const r=function(e,t){const o=e.match(Dt);if(!o)return null;const[,i,s,,r]=o;if(i.length>2&&r&&r.length>2)return null;if(i.length>2)return{year:i,month:s,day:r,dateString:e,type:"ymd"};const n=function(e){switch(e.dateFormat[0]){case"d":return"dmy";case"m":return"mdy";case"y":return"ymd"}throw new Error("Invalid date format in locale")}(t);if(!r)return"dmy"===n?{day:i,month:s,year:r,dateString:e,type:"dmy"}:{month:i,day:s,year:r,dateString:e,type:"mdy"};if(r.length>2)return"mdy"===n?{month:i,day:s,year:r,dateString:e,type:"mdy"}:{day:i,month:s,year:r,dateString:e,type:"dmy"};if("mdy"===n)return{month:i,day:s,year:r,dateString:e,type:"mdy"};if("ymd"===n)return{year:i,month:s,day:r,dateString:e,type:"ymd"};if("dmy"===n)return{day:i,month:s,year:r,dateString:e,type:"dmy"};return null}(e,t);if(r){const t=r.dateString.match(Ft)[0];if(s=function(e,t){let{year:o,month:i,day:s}=e;const r=function(e){if(!e)return Ot;const t=Number(e);if(t>=1&&t<=12)return t-1;return null}(i),n=function(e){if(!e)return 1;const t=Number(e);if(t>=0&&t<=31)return t;return null}(s),a=function(e){if(!e)return At;const t=Number(e);switch(e.length){case 1:return Tt+t;case 2:return Tt+(Tt+t>At+10?-100:0)+t;case 3:case 4:return t}return null}(o);if(null===a||null===r||null===n)return null;const l=2===i?.length&&r+1<10||2===s?.length&&n<10,c=2!==o?.length,h=new yt(a,r,n);if(h.getMonth()!==r||h.getDate()!==n)return null;const d=h.getTime()-It.getTime(),u=function(e,t,o,i){const s=e.year?i?"yyyy":"yy":void 0,r=e.month?o?"mm":"m":void 0,n=e.day?o?"dd":"d":void 0;switch(e.type){case"mdy":return[r,n,s].filter(ke).join(t);case"ymd":return[s,r,n].filter(ke).join(t);case"dmy":return[n,r,s].filter(ke).join(t)}}(e,t,l,c);return{value:Math.round(d/Rt),format:u,jsDate:h}}(r,t),null===s)return null;e=e.replace(r.dateString,"").trim()}if(""!==e||!s&&!o)return null;if(s&&s.jsDate&&o&&o.jsDate)return{value:s.value+o.value,format:s.format+" "+("hhhh:mm:ss"===o.format?"hh:mm:ss":o.format),jsDate:new yt(s.jsDate.getFullYear()+o.jsDate.getFullYear()-1899,s.jsDate.getMonth()+o.jsDate.getMonth()-11,s.jsDate.getDate()+o.jsDate.getDate()-30,s.jsDate.getHours()+o.jsDate.getHours(),s.jsDate.getMinutes()+o.jsDate.getMinutes(),s.jsDate.getSeconds()+o.jsDate.getSeconds())};return s||o}(e,t)),kt.get(t).get(e)}function Vt(e){const t=Math.trunc(e);let o=yt.fromTimestamp(t*Rt-Mt),i=e-t;i=i<0?1+i:i;const s=Math.round(24*i),r=Math.round(24*(i-s/24)*60),n=Math.round(24*(i-s/24-r/24/60)*60*60);return o.setHours(s),o.setMinutes(r),o.setSeconds(n),o}function Bt(e){const t=e.getTime()-It.getTime();return Math.round(t/Rt)}function zt(e){return new yt(e.getFullYear(),e.getMonth()+1,0).getDate()}function Ht(e){return zt(e)===e.getDate()}function $t(e,t,o){const i=e.getFullYear(),s=e.getMonth(),r=e.getDate(),n=new yt(i,s+t,1);return o&&r===zt(e)||r>zt(n)?n.setDate(zt(n)):n.setDate(r),n}function Wt(e){const t=Math.trunc(e);return t%4==0&&t%100!=0||t%400==0}function Gt(e,t,o){if(e===t)return 0;if(e>t){const o=t;t=e,e=o}const i=Vt(e),s=Vt(t);let r=i.getDate(),n=s.getDate();const a=i.getMonth(),l=s.getMonth(),c=i.getFullYear(),h=s.getFullYear();let d=0,u=0;switch(o){case 0:31===r&&(r=30),30===r&&31===n&&(n=30),1===a&&r===(Wt(c)?29:28)&&(r=30,1===l&&n===(Wt(h)?29:28)&&(n=30)),d=c+(30*a+r)/360,u=h+(30*l+n)/360;break;case 1:let o=365;const i=c===h;if(!i&&!(c+1===h)||!i&&a<l||!i&&a===l&&r<n){let e=0,t=0;for(let o=c;o<=h;o++)e++,t+=Wt(o)?366:365;o=t/e}else i?Wt(c)&&(o=366):(Wt(c)&&a<2&&(o=366),Wt(h)&&(l>1||1===l&&29===n)&&(o=366));d=e/o,u=t/o;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===n&&(n=30),d=c+(30*a+r)/360,u=h+(30*l+n)/360}return u-d}function qt(e,t){const o=12*(t.getFullYear()-e.getFullYear())+t.getMonth()-e.getMonth();return e.getDate()>t.getDate()?o-1:o}function Zt(e,t){const o=e.getTime(),i=t.getTime();return Math.floor((i-o)/Rt)}function Yt(e,t){const o=t.getFullYear()-e.getFullYear(),i=e.getMonth(),s=t.getMonth(),r=e.getDate(),n=t.getDate();return s>i||s===i&&n>=r?o:o-1}const jt=140,Xt=20,Kt=.035;function Qt(e){return Xt+(jt-Xt)*Math.exp(-Kt*(e-1))}const Jt=[{name:"English (US)",code:"en_US",thousandsSeparator:",",decimalSeparator:".",dateFormat:"m/d/yyyy",timeFormat:"hh:mm:ss a",formulaArgSeparator:","},{name:"French",code:"fr_FR",thousandsSeparator:" ",decimalSeparator:",",dateFormat:"dd/mm/yyyy",timeFormat:"hh:mm:ss",formulaArgSeparator:";"}],eo=Jt[0],to=Qe((function(e){return e=Se(e),new RegExp(`(^-?\\d+(${e}?\\d*(e\\d+)?)?|^-?${e}\\d+)(?!\\w|!)`)})),oo=Qe((function(e){const t=Se(e.decimalSeparator),o="(\\s*"+`(\\d+(${Se(e.thousandsSeparator)}\\d{3,})*(${t}\\d*)?)`+"|"+`(${t}\\d+)`+")(e(\\+|-)?\\d+)?(\\s*%)?",i="(\\s*-)?",s="(\\s*[\\$€])?",r="^(("+[i+s+o,i+o+s,s+i+o].join(")|(")+"))$";return new RegExp(r,"i")}));function io(e,t){return!!e&&oo(t).test(e.trim())}const so=Qe((function(e){return new RegExp(`[$€${Se(e.thousandsSeparator)}]`,"g")}));function ro(e,t){"."!==t.decimalSeparator&&(e=e.replace(t.decimalSeparator,".")),e=e.replace(so(t),"");let o=Number(e);return isNaN(o)&&e.includes("%")&&(o=Number(e.split("%")[0]),!isNaN(o))?o/100:o}function no(e,t,o){const i=[...e].sort(((e,t)=>e-t));let s=(i.length+(o?-1:1))*t;if(o||s--,Number.isInteger(s))return i[s];const r=Math.ceil(s),n=Math.floor(s);return i[r]*(s-n)+i[n]*(r-s)}const ao=20,lo=11,co=/(\d+?)(?=(\d{3})+(?!\d)|$)/g,ho=/0/g,uo={0:r("January"),1:r("February"),2:r("March"),3:r("April"),4:r("May"),5:r("June"),6:r("July"),7:r("August"),8:r("September"),9:r("October"),10:r("November"),11:r("December")},go={0:r("Sunday"),1:r("Monday"),2:r("Tuesday"),3:r("Wednesday"),4:r("Thursday"),5:r("Friday"),6:r("Saturday")},po={};function mo(e){let t=po[e];return void 0===t&&(t=function(e){if(""===e)throw new Error("A format cannot be empty");let t=0,o=[];for(;t<e.length;){let i;if("["===e.charAt(t)){if("$"!==e.charAt(t+1))throw new Error(`Currency formats have to be prefixed by a $: ${e}`);if(i=e.substring(t+1).indexOf("]")+t+2,0===i)throw new Error(`Invalid currency brackets format: ${e}`);const s=e.substring(t+2,i-1);if(s.includes("["))throw new Error(`Invalid currency format: ${e}`);o.push({type:"STRING",format:s})}else{const s=e.substring(t).indexOf("[");i=s>-1?s+t:e.length;const r=e.substring(t,i);xo(r)?o.push({type:"DATE",format:r}):o.push({type:"NUMBER",format:Uo(r)})}t=i}return o}(e),po[e]=t),t}function fo(e,{format:t,locale:o}){switch(typeof e){case"string":return e.includes('\\"')?e.replace(/\\"/g,'"'):e;case"boolean":return e?"TRUE":"FALSE";case"number":t||(t=Oo(e));return function(e,t,o){if("DATE"===t[0].type)return Io(e,t[0].format);let i=e<0?"-":"";for(let s of t)switch(s.type){case"NUMBER":i+=bo(Math.abs(e),s.format,o);break;case"STRING":i+=s.format}return i}(e,mo(t),o);case"object":return"0"}}function bo(e,t,o){t.isPercent&&(e*=100),e/=t.magnitude;let i=0;void 0!==t.decimalPart&&(i=t.decimalPart.length);const{integerDigits:s,decimalDigits:r}=So(e,i);let n=function(e,t,o){const i="0"===e?"":e;let s=i;const r=t.length-i.length;if(r>0){const e=(t.substring(0,r).match(ho)||[]).length;s="0".repeat(e)+s}o&&(s=s.match(co)?.join(o)||s);return s}(s,t.integerPart,t.thousandsSeparator?o.thousandsSeparator:void 0);return void 0!==t.decimalPart&&(n+=o.decimalSeparator+function(e,t){let o=e;if(t.length-e.length>0){const i=(t.substring(e.length,t.length+1).match(ho)||[]).length;o+="0".repeat(i)}return o}(r||"",t.decimalPart)),t.isPercent&&(n+="%"),n}const vo=[];function So(e,t=ao){const o=e.toString();if(o.includes("e"))return function(e,t=ao){let o=vo[t];o||(o=new Intl.NumberFormat("en-US",{maximumFractionDigits:t,useGrouping:!1}),vo[t]=o);const[i,s]=o.format(e).split(".");return{integerDigits:i,decimalDigits:s}}(e,t);if(Number.isInteger(e))return{integerDigits:o,decimalDigits:void 0};const i=o.indexOf(".");let s=o.substring(0,i),r=o.substring(i+1);if(0===t)return Number(r[0])>=5&&(s=(Number(s)+1).toString()),{integerDigits:s,decimalDigits:void 0};if(r.length>t){const{integerDigits:e,decimalDigits:o}=function(e,t){let o="0",i=e,s=e.slice(0,t);const r=t;if(Number(e[r])<5)return{integerDigits:o,decimalDigits:s};const n=s.match(Eo)?.[0]||"",a=(Number(s)+1).toString(),l=s.slice(n.length),c=a.length>l.length;c&&!n?(o="1",i=void 0):i=c?n.slice(0,-1)+a:n+a;return{integerDigits:o,decimalDigits:i}}(r,t);r=o,"0"!==e&&(s=(Number(s)+Number(e)).toString())}return{integerDigits:s,decimalDigits:Co(r||"")}}function Co(e){let t=e.length-1;for(;t>=0&&"0"===e[t];)t--;return e.slice(0,t+1)||void 0}const Eo=/^0+/;function wo(e,t){const{integerDigits:o,decimalDigits:i}=So(e,20);return i?o+t+i:o}function xo(e){if(!yo.has(e[0]))return!1;try{return Io(1,e),!0}catch(e){return!1}}const yo=new Set(["h","m","y","d"]);function Io(e,t){const o=Vt(e),i=t.indexOf("h");let s="",r="";return i>0?(s=Ro(o,t.substring(0,i-1)),r=To(o,t.substring(i))):0===i?r=To(o,t):i<0&&(s=Ro(o,t)),s+(s&&r?" ":"")+r}function Ro(e,t){const o=t.match(/\/|-|\s/)?.[0];return(o?t.split(o):[t]).map((o=>{switch(o){case"d":return e.getDate();case"dd":return e.getDate().toString().padStart(2,"0");case"ddd":return go[e.getDay()].slice(0,3);case"dddd":return go[e.getDay()];case"m":return e.getMonth()+1;case"mm":return String(e.getMonth()+1).padStart(2,"0");case"mmm":return uo[e.getMonth()].slice(0,3);case"mmmm":return uo[e.getMonth()];case"mmmmm":return uo[e.getMonth()].slice(0,1);case"yy":const o=String(e.getFullYear()).replace("-","").padStart(2,"0");return o.slice(o.length-2);case"yyyy":return e.getFullYear();default:throw new Error(`invalid format: ${t}`)}})).join(o)}function To(e,t){let o=t.split(/:|\s/);const i=e.getHours(),s="a"===o[o.length-1];let r=i,n="";return s&&(r=0===r?12:r>12?r-12:r,n=i>=12?" PM":" AM",o.pop()),o.map((o=>{switch(o){case"hhhh":return Math.floor((e.getTime()-It.getTime())/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(":")+n}const Ao=Qe((function(e){return new RegExp(`[0-9]+${Se(e.decimalSeparator)}[0-9]`)}));function Oo(e){let{integerDigits:t,decimalDigits:o}=So(e);if(!o)return"0";const i=t.replace("-","").length;if(i+2>lo)return"0";const s=lo-i-1;return({decimalDigits:o}=So(e,Math.min(s,o.length))),o?"0."+"0".repeat(o.length):"0"}function Mo(e,t){if(!Pt(e,t))return;return Ut(e,t).format}function No(e){if(!io(e,eo))return;const t=e.includes(".")?"0.00":"0",o=e.match(/[\$€]/);if(o){const i=e.match(/[\d]/),s="[$"+o.values().next().value+"]";return i.index<o.index?"#,##"+t+s:s+"#,##"+t}return e.includes("%")?t+"%":void 0}function _o(e){const t=e.decimalPlaces??2,o=e.position??"before",i=e.code??"",s=e.symbol??"",r="#,##0"+(t?"."+"0".repeat(t):"");let n=`${i} ${s}`.trim();return"after"===o&&i&&(n=" "+n),function(e,t,o){const i=`[$${e}]`;return"before"===t?i+o:o+i}(n,o,r)}function Fo(e){return Bo(mo(e).map((e=>"NUMBER"===e.type?{type:e.type,format:{...e.format,decimalPart:void 0}}:e)))}function Do(e,t,o,i){const s=mo(e||"#,##0"),r=[];for(let e=0;e<s.length;e++){const i=s[e];if("NUMBER"!==i.type){r.push(i);continue}r.push({...i,format:{...i.format,magnitude:t,decimalPart:void 0}}),r.push({type:"STRING",format:o});const n=s[e+1];"STRING"===n?.type&&["k","m","b"].includes(n.format)&&e++}return Bo(r)}function Lo(e,t,o){const i=mo(e).map((e=>"NUMBER"===e.type?{...e,format:Po(e.format,t)}:e)),s=Bo(i);return po[s]=i,s}function Po(e,t){const o={...e},i=Math.sign(t),s=o.decimalPart?.length||0,r=Math.min(Math.max(0,s+i),ao);return o.decimalPart="0".repeat(r),""===o.decimalPart&&delete o.decimalPart,o}const ko=/,*?$/;function Uo(e){if(function(e){return Boolean(e.replace(Vo,""))}(e=e.trim()))throw new Error(`Invalid number format: ${e}`);const t=e.includes("%"),o=e.match(ko)?.[0]||"",i=o?1e3**o.length:1;let s=e.slice(0,e.length-(o.length||0));const r=s.includes(",");if(/\..*,/.test(s))throw new Error("A format can't contain ',' symbol in the decimal part");s=s.replace("%","").replace(",","");const n=s.match(/[\%|,]/);if(n)throw new Error(`A format can only contain a single '${n[0]}' symbol`);const[a,l]=s.split(".");if(l&&l.length>20)throw new Error("A format can't contain more than 20 decimal places");return void 0!==l?{integerPart:a,isPercent:t,thousandsSeparator:r,decimalPart:l,magnitude:i}:{integerPart:a,isPercent:t,thousandsSeparator:r,magnitude:i}}const Vo=/[,#0.%]/g;function Bo(e){let t="";for(let o of e){let e;switch(o.type){case"NUMBER":const t=o.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=`[$${o.format}]`;break;case"DATE":e=o.format}t+=e}return t}const zo=new RegExp(/\$?([A-Z]{1,3})\$?([0-9]{1,7})/,"i"),Ho=new RegExp(/^\$?([A-Z]{1,3})\$?([0-9]{1,7})$/,"i"),$o=new RegExp(/^\$?([A-Z]{1,3})+$/,"i"),Wo=new RegExp(/^\$?([0-9]{1,7})+$/,"i"),Go=new RegExp(/^\s*('.+'!|[^']+!)?\$?([A-Z]{1,3})$/,"i"),qo=new RegExp(/^\s*('.+'!|[^']+!)?\$?([0-9]{1,7})$/,"i"),Zo=new RegExp(/^\s*('.+'!|[^']+!)?/.source+"("+[zo.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 Yo(e){return Go.test(e)}function jo(e){return qo.test(e)}function Xo(e){return $o.test(e)}function Ko(e){return Wo.test(e)}function Qo(e){return Ho.test(e)}function Jo(e){const t=e.split("!"),o=t.pop();return{sheetName:Ee(t.join("!"))||void 0,xc:o}}function ei(e){const t=function(e){let t,o,i,s,r;e.includes("!")&&(e=e.split("!").at(-1)),e.includes("$")&&(e=e.replace(/\$/g,"")),t=e.includes(":")?e.split(":").map((e=>e.trim())):[e.trim()];let n=!1,a=!1,l=!1;const c=t[0],h=t[1]&&t[1];if(Yo(c))s=r=St(c),o=i=0,n=!0;else if(jo(c))o=i=parseInt(c,10)-1,s=r=0,a=!0;else{const e=wt(c);s=r=e.col,o=i=e.row,l=!0}if(2===t.length)if(Yo(h))r=St(h),n=!0;else if(jo(h))i=parseInt(h,10)-1,a=!0;else{const e=wt(h);r=e.col,i=e.row,o=n?i:o,s=a?r:s,l=!0}if(n&&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:o,left:s,bottom:n?void 0:i,right:a?void 0:r};return l=l&&(a||n),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 ti(e){const t=ei(e);if(void 0===t.bottom||void 0===t.right)throw new Error("This does not support unbounded ranges");return t}function oi(e){const{bottom:t,top:o,left:i,right:s}=e;return!(void 0!==t&&isNaN(t)||isNaN(o)||isNaN(i)||void 0!==s&&isNaN(s))&&((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:o,left:i,right:s}=e,n="hasHeader"in e&&e.hasHeader,a=t===o&&i===s;if(void 0===o&&void 0!==s)return 0!==t||n?`${xt(i,t)}:${bt(s)}`:`${bt(i)}:${bt(s)}`;if(void 0===s&&void 0!==o)return 0!==i||n?`${xt(i,t)}:${o+1}`:`${t+1}:${o+1}`;if(void 0!==o&&void 0!==s)return a?xt(i,t):`${xt(i,t)}:${xt(s,o)}`;throw new Error(r("Bad zone format"))}function si(e,t,o,i,s){const r="left"===t?"columns":"rows",n="before"===i?o-1:o,a=e["left"===t?"right":"bottom"];return e[t]<=n&&a&&a>n?Si(e,r,"RESIZE",s):n<e[t]?Si(e,r,"MOVE",s):{...e}}function ri(e,t,o,i,s){const r="left"===t?"columns":"rows",n="before"===i?o-1:o,a="left"===t?"right":"bottom";return e[t]<=n&&e[a]>n?Si(e,r,"RESIZE",s):n<e[t]?Si(e,r,"MOVE",s):{...e}}function ni(e,t,o){const i="left"===t?"right":"bottom";let s=e[t],r=e[i];for(let n of o.sort(((e,t)=>t-e)))e[t]>n&&(s--,r--),e[t]<n&&e[i]>=n&&r--;return{...e,[t]:s,[i]:r}}function ai(e,t,o){const i="left"===t?"right":"bottom";let s=e[t],r=e[i];const n=e[i];for(let i of o.sort(((e,t)=>t-e)))e[t]>i&&(s--,void 0!==r&&r--),void 0!==n&&void 0!==r&&e[t]<=i&&n>=i&&r--;if(!(void 0!==r&&s>r))return{...e,[t]:s,[i]:r}}function li(...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 ci(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 hi(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 ui(e,t,o){const{left:i,right:s,top:r,bottom:n}=o;return e>=i&&e<=s&&t>=r&&t<=n}function gi(e,t){return hi(li(t,e),t)}function pi(e,t){const o=e.map(ei),i=t.map(ti),s=Math.max(...o.concat(i).map((e=>e.bottom||0))),r=Math.max(...o.concat(i).map((e=>e.right||0))),n=o.map((e=>({...e,bottom:void 0===e.bottom?s+1:e.bottom,right:void 0===e.right?r+1:e.right}))),a=i.map((e=>({...e,bottom:void 0===e.bottom?s+1:e.bottom,right:void 0===e.right?r+1:e.right}))),l=function(e,t){const o=new Set(t.map((({col:e,row:t})=>`${e}-${t}`)));return e.filter((({col:e,row:t})=>!o.has(`${e}-${t}`)))}(n.map(vi).flat(),a.map(vi).flat()),c=function(e){if(0===e.length)return[];const[t,...o]=[...e].sort(((e,t)=>e.row-t.row)).sort(((e,t)=>e.col-t.col)),i=[];let s=wi(t);for(const{col:e,row:t}of o)if(!ui(e,t,s))if(e===s.left&&t===s.bottom+1){const e=s.bottom+1;s={...s,bottom:e}}else i.push(s),s=wi({col:e,row:t});return[...i,s]}(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=[],o=mi(e),i=(e,t)=>e.top===t.top&&e.bottom===t.bottom&&e.right+1===t.left;for(;o.length;){const e=o.reduce(((e,t)=>i(e,t)?li(e,t):e),o.shift());t.push(e)}return mi(t)}(c).map((e=>({...e,bottom:e.bottom===s+1?void 0:e.bottom,right:e.right===r+1?void 0:e.right}))).map(ii)}function mi(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(),o=[];for(;0!==t.length;){const e=t.shift();t.some((t=>gi(e,t)))||o.push(e)}return o.reverse()}function fi(e){return{numberOfRows:e.bottom-e.top+1,numberOfCols:e.right-e.left+1}}function bi(e){const{numberOfCols:t,numberOfRows:o}=fi(e);return 1===t||1===o}function vi(e){const t=[],[o,i]=[e.right,e.left].sort(((e,t)=>e-t)),[s,r]=[e.top,e.bottom].sort(((e,t)=>e-t));for(const e of ye(o,i+1))for(const o of ye(s,r+1))t.push({col:e,row:o});return t}function Si(e,t,o,i){const s="both"===t?i[0]:"columns"===t?i:0,r="both"===t?i[1]:"rows"===t?i:0,n="hasHeader"in e&&e.hasHeader;let a;a=!function(e){return void 0===e.bottom}(e)||n?!(xi(e)&&!n)||"columns"!==t:"rows"!==t;const l={...e};return a&&"MOVE"===o&&(l.left+=s,l.top+=r),void 0!==l.right&&(l.right+=s),void 0!==l.bottom&&(l.bottom+=r),l}function Ci(e,t){let o,i;const{left:s,right:r,top:n,bottom:a}=e,{left:l,right:c,top:h,bottom:d}=t;return o=l!=s?l:c!=r?c:l,i=h!=n?h:d!=a?d:h,{col:o,row:i}}function Ei(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 xi(e){return void 0===e.right}function yi(e){return(e.bottom-e.top+1)*(e.right-e.left+1)}function Ii(...e){return e.length<2||1===pi(e.map(ii),[]).length}class Ri{getSheetSize;_zone;parts;invalidXc;prefixSheet=!1;sheetId;invalidSheetName;constructor(e,t){this.getSheetSize=t,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 Ri?e:new Ri(e,t.getSheetSize)}get unboundedZone(){return this._zone}get zone(){const{left:e,top:t,bottom:o,right:i}=this._zone;if(void 0!==i&&void 0!==o)return this._zone;if(void 0===o&&void 0!==i)return{right:i,top:t,left:e,bottom:this.getSheetSize(this.sheetId).numberOfRows-1};if(void 0===i&&void 0!==o)return{bottom:o,left:e,top:t,right:this.getSheetSize(this.sheetId).numberOfCols-1};throw new Error(r("Bad zone format"))}static getRangeParts(e,t){const o=e.split(":").map((e=>{const t=jo(e);return{colFixed:!t&&e.startsWith("$"),rowFixed:t?e.startsWith("$"):e.includes("$",1)}})),i=void 0===t.bottom,s=void 0===t.right;return i&&(o[0].rowFixed=o[0].rowFixed||o[1].rowFixed,o[1].rowFixed=o[0].rowFixed||o[1].rowFixed),s&&(o[0].colFixed=o[0].colFixed||o[1].colFixed,o[1].colFixed=o[0].colFixed||o[1].colFixed),o}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(){const e={...this._zone};let t=this.parts;if(void 0!==e.right&&e.right<e.left){let o=e.right;e.right=e.left,e.left=o,t=[{colFixed:t[1]?.colFixed||!1,rowFixed:t[0]?.rowFixed||!1},{colFixed:t[0]?.colFixed||!1,rowFixed:t[1]?.rowFixed||!1}]}if(void 0!==e.bottom&&e.bottom<e.top){let o=e.bottom;e.bottom=e.top,e.top=o,t=[{colFixed:t[0]?.colFixed||!1,rowFixed:t[1]?.rowFixed||!1},{colFixed:t[1]?.colFixed||!1,rowFixed:t[0]?.rowFixed||!1}]}return this.clone({zone:e,parts:t})}clone(e){return new Ri({zone:e?.zone?e.zone:{...this._zone},sheetId: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:e?.parts?e.parts:this.parts.map((e=>({rowFixed:e.rowFixed,colFixed:e.colFixed}))),prefixSheet:e?.prefixSheet?e.prefixSheet:this.prefixSheet},this.getSheetSize)}}function Ti(e,t,o){const i=o.sheetId===e?t:o.sheetId;return o.clone({sheetId:i})}function Ai(e,t,o){return o?e.getRangeFromSheetXC(t,o):void 0}function Oi(e,t,o){const i=[];return t.forEach((t=>{const s=function(e,t){e=e.toLocaleLowerCase();let o=0,i=0,s=(t=t.toLocaleLowerCase()).length,r=0;for(let n=0;n<s;n++)t[n]===e[r]?(r++,i+=100+i-n/200):i=0,o+=i;return r===e.length?o:0}(e,o(t));s>0&&i.push({score:s,elem:t})})),i.sort(((e,t)=>t.score-e.score)),i.map((e=>e.elem))}function Mi(e){const t=[];for(let o=0;o<e;o++){const e={cells:{}};t.push(e)}return t}function Ni(e,t=1){return t*(e+z)-z}const _i={};function Fi(e,t,o){const i=Li(o);if(_i[i]||(_i[i]={}),void 0===_i[i][t]){e.save(),e.font=i;const o=e.measureText(t).width;e.restore(),_i[i][t]=o}return _i[i][t]}function Di(e){return Math.round(96*e/72)}function Li(e){return`${e.italic?"italic ":""}${e.bold?"bold":q} ${Pi(e)}px ${Y}`}function Pi(e){return Di(e?.fontSize||Z)}function ki(e,t,o,i){if(Fi(e,t,i)<=o)return[t];const s=[];let r="";for(let n of t){Fi(e,r+n,i)>o?(s.push(r),r=n):r+=n}return s.push(r),s}function Ui(e,t,o,i){o||(o={});const s=[],r=t.includes(fe)?t.split(fe):[t];for(const t of r){const r=t.includes(" ")?t.split(" "):[t];if(!i){s.push(t);continue}let n="",a=i;for(let t of r){const r=ki(e,t,i,o),l=r.pop(),c=Fi(e,l,o);if(r.length)""!==n&&(s.push(n),n="",a=i),r.forEach((e=>{s.push(e)})),n=l,a=i-c;else{const t=""===n?l:" "+l,r=Fi(e,t,o);r<=a?(n+=t,a-=r):(s.push(n),n=l,a=i-c)}}""!==n&&s.push(n)}return s}function Vi(e){return e?e.toLowerCase():""}class Bi{isFastIdStrategy=!1;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)}))}}class zi extends t.Component{static template="o-spreadsheet-ChartJsComponent";canvas=t.useRef("graphContainer");chart;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;We(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){const t=e.chartJsConfig;t.data&&t.data.datasets?(this.chart.data=t.data,t.options?.title&&(this.chart.config.options.title=t.options.title),t.options&&"valueLabel"in t.options&&t.options?.valueLabel&&(this.chart.config.options.valueLabel=t.options.valueLabel)):this.chart.data.datasets=void 0,this.chart.config.options.tooltips=t.options?.tooltips,this.chart.config.options.legend=t.options?.legend,this.chart.config.options.scales=t.options?.scales,this.chart.update({duration:0})}}zi.props={figure:Object};const Hi={};let $i=0;function Wi(e,...t){const o="__sheet__"+$i++;return function(e,t){const o=document.createElement("style");o.textContent=function(e){const t=e.split(/(\{|\}|;)/).map((e=>e.trim())),o=[],i=[];let s=[];function r(e,t){const i=[];for(const s of o[e]){let n=t&&t+" "+s||s;n.includes("&")&&(n=s.replace(/&/g,t||"")),e<o.length-1&&(n=r(e+1,n)),i.push(n)}return i.join(", ")}function n(){s.length&&(i.push(r(0)+" {"),i.push(...s),i.push("}"),s=[])}for(;t.length;){let e=t.shift();"}"===e?(n(),o.pop()):("{"===t[0]&&(n(),o.push(e.split(/\s*,\s*/)),t.shift()),";"===t[0]&&s.push(" "+e+";"))}return i.join("\n")}(t),Hi[e]=o}(o,String.raw(e,...t)),function(e){const t=Hi[e];t.setAttribute("component",e),document.head.appendChild(t)}(o),o}function Gi({strikethrough:e,underline:t}){return e||t?`${e?"line-through":""} ${t?"underline":""}`:"none"}function qi(e){const t=Zi(e);return e?(e.fillColor&&(t.background=e.fillColor),t):t}function Zi(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 o=e.strikethrough?"line-through":"";o=e.underline?o+" underline":o,t["text-decoration"]=o}return e.textColor&&(t.color=e.textColor),t}function Yi(e){return Object.entries(e).filter((([e,t])=>void 0!==t)).map((([e,t])=>`${e}:${t};`)).join(" ")}const ji=1.2;Wi`
|
|
2
2
|
div.o-scorecard {
|
|
3
3
|
font-family: ${Y};
|
|
4
4
|
user-select: none;
|
|
@@ -348,13 +348,13 @@
|
|
|
348
348
|
}
|
|
349
349
|
}
|
|
350
350
|
}
|
|
351
|
-
`;class Bg extends t.Component{static template="o-spreadsheet-LinkEditor";static components={Menu:Vr};menuItems=Vg.getMenuItems();link=t.useState(this.defaultState);menu=t.useState({isOpen:!1});linkEditorRef=t.useRef("linkEditor");position=Nr(this.linkEditorRef);urlInput=t.useRef("urlInput");setup(){t.onMounted((()=>this.urlInput.el?.focus()))}get defaultState(){const{col:e,row:t}=this.props.cellPosition,o=this.env.model.getters.getActiveSheetId(),i=this.env.model.getters.getEvaluatedCell({sheetId:o,col:e,row:t});return i.link?{url:i.link.url,label:i.formattedValue,isUrlEditable:i.link.isUrlEditable}:{label:i.formattedValue,url:"",isUrlEditable:!0}}get menuPosition(){return{x:this.position.x+320-12-2,y:this.position.y+100}}onSpecialLink(e){const{detail:t}=e,o=as(t);o&&(this.link.url=o.url,this.link.label=o.label,this.link.isUrlEditable=o.isUrlEditable)}getUrlRepresentation(e){return rs(e,this.env.model.getters)}openMenu(){this.menu.isOpen=!0}removeLink(){this.link.url="",this.link.isUrlEditable=!0}save(){const{col:e,row:t}=this.props.cellPosition,o=this.env.model.getters.getLocale(),i=this.link.label?bg(this.link.label,o):this.link.url;this.env.model.dispatch("UPDATE_CELL",{col:e,row:t,sheetId:this.env.model.getters.getActiveSheetId(),content:Ne(i,this.link.url)}),this.props.onClosed?.()}cancel(){this.props.onClosed?.()}onKeyDown(e){switch(e.key){case"Enter":this.link.url&&this.save(),e.stopPropagation();break;case"Escape":this.cancel(),e.stopPropagation()}}}const zg={onOpen:(e,t)=>({isOpen:!0,props:{cellPosition:e},Component:Bg,cellCorner:"BottomLeft"})};Bg.props={cellPosition:Object,onClosed:{type:Function,optional:!0}};const Hg=new Ji;function $g(e){return 8===(e=nt(e).replace("#","")).length?e.slice(6)+e.slice(0,6):e}Hg.add("ErrorToolTip",vr).add("LinkCell",zr).add("LinkEditor",zg).add("FilterMenu",wr);class Wg{sheetId;title;getters;constructor(e,t,o){this.title=e.title,this.sheetId=t,this.getters=o}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 Gg(e,t){return"REMOVE_COLUMNS_ROWS"===t.type?ai(e,"COL"===t.dimension?"left":"top",t.elements):"ADD_COLUMNS_ROWS"===t.type?si(e,"COL"===t.dimension?"left":"top",t.base,t.position,t.quantity):{...e}}function qg(e,t,o,i){let s=!1;const r=[];for(let i in o){let n=o[i];if(n.labelCell){const e=jg(n.labelCell,t);n.labelCell!==e&&(s=!0,n={...n,labelCell:e})}const a=jg(n.dataRange,t);void 0===a||e.getRangeString(a,a.sheetId)===ee?(s=!0,n=void 0):a!==n.dataRange&&(s=!0,n={...n,dataRange:a}),r[i]=n}let n=i;const a=jg(n,t);a!==n&&(s=!0,n=a);return{isStale:s,dataSets:r.filter(ke),labelRange:n}}function Zg(e,t,o){return o.map((o=>({dataRange:Ti(e,t,o.dataRange),labelCell:o.labelCell?Ti(e,t,o.labelCell):void 0})))}function Yg(e,t,o){return o?Ti(e,t,o):void 0}function jg(e,t){if(!e)return;const o=t(e);switch(o.changeType){case"NONE":return e;case"REMOVE":return;default:return o.range}}function Xg(e,t,o,i){const s=[];for(const r of t){const t=e.getRangeFromSheetXC(o,r),{unboundedZone:n,sheetId:a,invalidSheetName:l,invalidXc:c}=t;if(!l&&!c)if(n.left!==n.right&&n.top!==n.bottom){if(void 0===n.right)continue;for(let t=n.left;t<=n.right;t++){const o={...n,left:t,right:t};s.push(Kg(e,a,o,i?{top:o.top,bottom:o.top,left:o.left,right:o.left}:void 0))}}else s.push(Kg(e,a,n,i?{top:n.top,bottom:n.top,left:n.left,right:n.left}:void 0))}return s}function Kg(e,t,o,i){if(o.left!==o.right&&o.top!==o.bottom)throw new Error(`Zone should be a single column or row: ${ii(o)}`);if(i){const s=ii(o),r=ii(i);return{labelCell:e.getRangeFromSheetXC(t,r),dataRange:e.getRangeFromSheetXC(t,s)}}return{labelCell:void 0,dataRange:e.getRangeFromSheetXC(t,ii(o))}}function Qg(e,t){const o=t.labelCell?.zone;let i=t.dataRange.zone;if(o){const{numberOfRows:e,numberOfCols:t}=fi(i);1===e?i={...i,left:i.left+1}:1===t&&(i={...i,top:i.top+1})}const s=t.dataRange.clone({zone:i});return{label:t.labelCell?e.getRangeString(t.labelCell,"forceSheetReference",!0):void 0,range:e.getRangeString(s,"forceSheetReference",!0)}}function Jg(e,t,o){if(!t)return;let i={...t.zone};o&&t.zone.bottom>t.zone.top&&(i.top=i.top+1);const s=t.clone({zone:i});return e.getRangeString(s,"forceSheetReference",!0)}function ep(e,t){let o;if(e.labelRange){const i=Gg(ei(e.labelRange),t);o=i?ii(i):void 0}const i=e.dataSets.map(ei).map((e=>Gg(e,t))).filter(ke).map(ii);return{...e,labelRange:o,dataSets:i}}const tp=["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 op{graphColorIndex=0;next(){return tp[this.graphColorIndex++%tp.length]}}function ip(e){return e&&ht(e)<.3?"#FFFFFF":"#000000"}function sp(e){if(e.dataSets){const t=void 0!==e.dataSets.find((e=>!Zo.test(e)));if(t)return 35;if(e.dataSets.map(ei).some((e=>e.top!==e.bottom&&xi(e))))return 35}return 0}function rp(e){if(e.labelRange){if(!Zo.test(e.labelRange||""))return 36}return 0}function np(e,t,o){if(!o)return!1;if(!e)return!1;if(!t)return!0;const i=yi(t.dataRange.zone);return!(yi(e.zone)<i)}function ap(e,t,o,i){if(e){if("text"===o||t?.type!==ls.number||e.type!==ls.number)return e.formattedValue;{let s=t.value-e.value;if("percentage"===o&&0!==s&&(s=s/e.value*100),"percentage"!==o&&e.format)return fo(s,{format:e.format,locale:i});const r=Math.abs(parseFloat(s.toFixed(2))).toLocaleString();return"percentage"===o?r+"%":r}}return""}function lp(e,t,o,i,s){if("text"===t||e?.type!==ls.number||o?.type!==ls.number)return;const r=o.value-e.value;return r>0?i:r<0?s:void 0}function cp(e,t,o){if("text"===o||e?.type!==ls.number||t?.type!==ls.number)return"neutral";const i=t.value-e.value;return i>0?"up":i<0?"down":"neutral"}const hp={Errors:{26:r("The range is invalid"),54:r("The argument is missing. Please provide a value"),55:r("The second argument is missing. Please provide a value"),56:r("The minpoint must be a number"),57:r("The midpoint must be a number"),58:r("The maxpoint must be a number"),59:r("The first value must be a number"),60:r("The second value must be a number"),50:r("Minimum must be smaller then Maximum"),53:r("Minimum must be smaller then Midpoint"),52:r("Midpoint must be smaller then Maximum"),51:r("Lower inflection point must be smaller than upper inflection point"),61:r("Invalid Minpoint formula"),63:r("Invalid Maxpoint formula"),62:r("Invalid Midpoint formula"),64:r("Invalid upper inflection point formula"),65:r("Invalid lower inflection point formula"),25: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")},dp={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")},up={Series:r("Series"),Errors:{Unexpected:r("The chart definition is invalid for an unknown reason"),35:r("The dataset is invalid"),36:r("Labels are invalid"),37:r("The key value is invalid"),38:r("The baseline value is invalid"),39:r("The data range is invalid"),40:r("A minimum range limit value is needed"),41:r("The minimum range limit value must be a number"),42:r("A maximum range limit value is needed"),43:r("The maximum range limit value must be a number"),44:r("Minimum range limit must be smaller than maximum range limit"),45:r("The lower inflection point value must be a number"),46:r("The upper inflection point value must be a number")}},gp={Custom:r("Custom")},pp=r("Merged cells are preventing this operation. Unmerge those cells and try again."),mp={Errors:{Unexpected:r("Cannot split the selection for an unknown reason"),94:r("There is no match for the selected separator in the selection"),91:r("Only a selection from a single column can be split"),93:r("Splitting will overwrite existing content")}};function fp(e,t){if(t.dataRange){const o=t.labelCell?[ii(t.labelCell.zone)]:[],i=pi([ii(t.dataRange.zone)],o)[0];if(void 0===i)return[];const s=e.getRangeFromSheetXC(t.dataRange.sheetId,i);return e.getRangeValues(s).map((e=>""===e?void 0:e))}return[]}function bp(e,t){const o=ye(0,Math.max(e.length,...t.map((e=>e.data?.length||0)))).filter((o=>{const i=e[o],s=t.map((e=>e.data?.[o]));return i||s.some((e=>0===e||Boolean(e)))}));return{labels:o.map((t=>e[t]||"")),dataSetsValues:t.map((e=>({...e,data:o.map((t=>e.data[t]))})))}}function vp(e,t){const o=new Set(e),i={};o.forEach((e=>{i[e]=new Array(t.length).fill(0)}));for(const o of ye(0,e.length)){const r=e[o];for(const e of ye(0,t.length))i[r][e]+="number"==typeof(s=t[e].data[o])?s:0}var s;return{labels:Array.from(o),dataSetsValues:t.map(((e,t)=>({...e,data:Array.from(o).map((e=>i[e][t]))})))}}function Sp(e){return e?e.length>ie?e.substring(0,ie)+"…":e:""}function Cp(e,t,o,{format:i,locale:r}){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:s(e.title),fontColor:o},legend:{onClick:void 0},tooltips:{callbacks:{label:function(e,t){let o=t.datasets?.[e.datasetIndex||0]?.label;const s=""!==e.yLabel?e.yLabel:t.datasets?.[e.datasetIndex||0]?.data?.[e.index||0],n=i&&"number"==typeof s?fo(s,{format:i,locale:r}):s?.toLocaleString()||"";return o?`${o}: ${n}`:n}}}},data:{labels:t.map(Sp),datasets:[]}}}function Ep(e,t,o){let i={values:[],formattedValues:[]};if(o)o.invalidXc||o.invalidSheetName||(i={formattedValues:e.getRangeFormattedValues(o),values:e.getRangeValues(o).map((e=>String(e)))});else if(1===t.length)for(let o=0;o<fp(e,t[0]).length;o++)i.formattedValues.push(""),i.values.push("");else if(t[0]){i={formattedValues:ye(0,fp(e,t[0]).length).map((e=>e.toString())),values:i.formattedValues}}return i}function wp(e,t){for(const o of t){const t=e.getRangeFormats(o.dataRange).find((e=>void 0!==e&&!xo(e)));if(t)return t}}function xp(e,t){const o=[];for(const[i,s]of Object.entries(t)){let t;if(s.labelCell){const o=s.labelCell,r=o?e.getEvaluatedCell({sheetId:o.sheetId,col:o.zone.left,row:o.zone.top}):void 0;t=r&&o?Sp(r.formattedValue):t=`${up.Series} ${parseInt(i)+1}`}else t=t=`${up.Series} ${parseInt(i)+1}`;let r=s.dataRange?fp(e,s):[];o.push({data:r,label:t})}return o}function yp(e){return 0===e?"origin":e-1}class Ip extends Wg{dataSets;labelRange;background;verticalAxisPosition;legendPosition;stacked;aggregated;type="bar";dataSetsHaveTitle;constructor(e,t,o){super(e,t,o),this.dataSets=Xg(o,e.dataSets,t,e.dataSetsHaveTitle),this.labelRange=Ai(o,t,e.labelRange),this.background=e.background,this.verticalAxisPosition=e.verticalAxisPosition,this.legendPosition=e.legendPosition,this.stacked=e.stacked,this.aggregated=e.aggregated,this.dataSetsHaveTitle=e.dataSetsHaveTitle}static transformDefinition(e,t){return ep(e,t)}static validateChartDefinition(e,t){return e.checkValidations(t,sp,rp)}static getDefinitionFromContextCreation(e){return{background:e.background,dataSets:e.range?e.range:[],dataSetsHaveTitle:!1,stacked:!1,aggregated:!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=Zg(this.sheetId,e,this.dataSets),o=Yg(this.sheetId,e,this.labelRange),i=this.getDefinitionWithSpecificDataSets(t,o,e);return new Ip(i,e,this.getters)}copyInSheetId(e){const t=this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange,e);return new Ip(t,e,this.getters)}getDefinition(){return this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange)}getDefinitionWithSpecificDataSets(e,t,o){return{type:"bar",dataSetsHaveTitle:!!e.length&&Boolean(e[0].labelCell),background:this.background,dataSets:e.map((e=>this.getters.getRangeString(e.dataRange,o||this.sheetId))),legendPosition:this.legendPosition,verticalAxisPosition:this.verticalAxisPosition,labelRange:t?this.getters.getRangeString(t,o||this.sheetId):void 0,title:this.title,stacked:this.stacked,aggregated:this.aggregated}}getDefinitionForExcel(){if(this.aggregated)return;const e=this.dataSets.map((e=>Qg(this.getters,e))).filter((e=>""!==e.range&&e.range!==ee)),t=Jg(this.getters,this.labelRange,np(this.labelRange,this.dataSets[0],this.dataSetsHaveTitle));return{...this.getDefinition(),backgroundColor:$g(this.background||w),fontColor:$g(ip(this.background)),dataSets:e,labelRange:t}}updateRanges(e){const{dataSets:t,labelRange:o,isStale:i}=qg(this.getters,e,this.dataSets,this.labelRange);if(!i)return this;const s=this.getDefinitionWithSpecificDataSets(t,o);return new Ip(s,this.sheetId,this.getters)}}function Rp(e){return e.dataRange&&!Zo.test(e.dataRange)?39:0}function Tp(e,t){return t((t=>t.sectionRule?e(t.sectionRule.rangeMin,"rangeMin"):0),(t=>t.sectionRule?e(t.sectionRule.rangeMax,"rangeMax"):0))}function Ap(e){return e.sectionRule&&Number(e.sectionRule.rangeMin)>=Number(e.sectionRule.rangeMax)?44:0}function Op(e,t){if(""===e)switch(t){case"rangeMin":return 40;case"rangeMax":return 42}return 0}function Mp(e,t){if(isNaN(e))switch(t){case"rangeMin":return 41;case"rangeMax":return 43;case"lowerInflectionPointValue":return 45;case"upperInflectionPointValue":return 46}return 0}class Np extends Wg{dataRange;sectionRule;background;type="gauge";constructor(e,t,o){super(e,t,o),this.dataRange=Ai(this.getters,this.sheetId,e.dataRange),this.sectionRule=e.sectionRule,this.background=e.background}static validateChartDefinition(e,t){return e.checkValidations(t,Rp,e.chainValidations(Tp(Op,e.batchValidations),Tp(Mp,e.batchValidations),Ap),e.chainValidations((o=Mp,(0,e.batchValidations)((e=>e.sectionRule?o(e.sectionRule.lowerInflectionPoint.value,"lowerInflectionPointValue"):0),(e=>e.sectionRule?o(e.sectionRule.upperInflectionPoint.value,"upperInflectionPointValue"):0)))));var o}static transformDefinition(e,t){let o;return e.dataRange&&(o=Gg(ei(e.dataRange),t)),{...e,dataRange:o?ii(o):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=Yg(this.sheetId,e,this.dataRange),o=this.getDefinitionWithSpecificRanges(t,e);return new Np(o,e,this.getters)}copyInSheetId(e){const t=this.getDefinitionWithSpecificRanges(this.dataRange,e);return new Np(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=jg(this.dataRange,e);if(this.dataRange===t)return this;const o=this.getDefinitionWithSpecificRanges(t);return new Np(o,this.sheetId,this.getters)}}const _p={second:1e3,minute:6e4,hour:36e5,day:864e5,month:2592e6,year:31536e6},Fp={inSeconds:function(e){return Math.floor(e/_p.second)},inMinutes:function(e){return Math.floor(e/_p.minute)},inHours:function(e){return Math.floor(e/_p.hour)},inDays:function(e){return Math.floor(e/_p.day)},inMonths:function(e){return Math.floor(e/_p.month)},inYears:function(e){return Math.floor(e/_p.year)}},Dp=/^((d|dd|m|mm|yyyy|yy|hh|h|ss|a)(-|:|\s|\/))*(d|dd|m|mm|yyyy|yy|hh|h|ss|a)$/i;function Lp(e,t,o){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),s=function(e,t,o){const i=e.map((e=>Ut(e,o)?.jsDate));if(i.some((e=>void 0===e))||e.length<2)return;const s=i.map((e=>e.getTime())),r=et(s)-tt(s),n=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(_p.second>=_p[n]&&Fp.inSeconds(r)<180)return"second";if(_p.minute>=_p[n]&&Fp.inMinutes(r)<180)return"minute";if(_p.hour>=_p[n]&&Fp.inHours(r)<96)return"hour";if(_p.day>=_p[n]&&Fp.inDays(r)<90)return"day";if(_p.month>=_p[n]&&Fp.inMonths(r)<36)return"month";return"year"}(e,i,o),r={};return s&&(r[s]=i),{parser:i,displayFormats:r,unit:s}}class Pp extends Wg{dataSets;labelRange;background;verticalAxisPosition;legendPosition;labelsAsText;stacked;aggregated;type="line";dataSetsHaveTitle;cumulative;constructor(e,t,o){super(e,t,o),this.dataSets=Xg(this.getters,e.dataSets,t,e.dataSetsHaveTitle),this.labelRange=Ai(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.aggregated=e.aggregated,this.dataSetsHaveTitle=e.dataSetsHaveTitle,this.cumulative=e.cumulative}static validateChartDefinition(e,t){return e.checkValidations(t,sp,rp)}static transformDefinition(e,t){return ep(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,aggregated:!1,cumulative:!1}}getDefinition(){return this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange)}getDefinitionWithSpecificDataSets(e,t,o){return{type:"line",dataSetsHaveTitle:!!e.length&&Boolean(e[0].labelCell),background:this.background,dataSets:e.map((e=>this.getters.getRangeString(e.dataRange,o||this.sheetId))),legendPosition:this.legendPosition,verticalAxisPosition:this.verticalAxisPosition,labelRange:t?this.getters.getRangeString(t,o||this.sheetId):void 0,title:this.title,labelsAsText:this.labelsAsText,stacked:this.stacked,aggregated:this.aggregated,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:o,isStale:i}=qg(this.getters,e,this.dataSets,this.labelRange);if(!i)return this;const s=this.getDefinitionWithSpecificDataSets(t,o);return new Pp(s,this.sheetId,this.getters)}getDefinitionForExcel(){if(this.aggregated)return;const e=this.dataSets.map((e=>Qg(this.getters,e))).filter((e=>""!==e.range&&e.range!==ee)),t=Jg(this.getters,this.labelRange,np(this.labelRange,this.dataSets[0],this.dataSetsHaveTitle));return{...this.getDefinition(),backgroundColor:$g(this.background||w),fontColor:$g(ip(this.background)),dataSets:e,labelRange:t}}copyForSheetId(e){const t=Zg(this.sheetId,e,this.dataSets),o=Yg(this.sheetId,e,this.labelRange),i=this.getDefinitionWithSpecificDataSets(t,o,e);return new Pp(i,e,this.getters)}copyInSheetId(e){const t=this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange,e);return new Pp(t,e,this.getters)}}function kp(e,t){return Vp(e,t)||Bp(e,t)}function Up(e,t){return function(e,t){return!e.labelsAsText&&Vp(e.labelRange,t)}(e,t)?"time":function(e,t){return!e.labelsAsText&&Bp(e.labelRange,t)}(e,t)?"linear":"category"}function Vp(e,t){if(!e||!Bp(e,t))return!1;const o=t.getEvaluatedCell({sheetId:e.sheetId,col:e.zone.left,row:e.zone.top}).format;return Boolean(o&&Dp.test(o))}function Bp(e,t){if(!e)return!1;const o=t.getRangeValues(e);return!o.some((e=>isNaN(Number(e))&&e))&&!o.every((e=>!e))}class zp extends Wg{dataSets;labelRange;background;legendPosition;type="pie";aggregated;dataSetsHaveTitle;constructor(e,t,o){super(e,t,o),this.dataSets=Xg(o,e.dataSets,t,e.dataSetsHaveTitle),this.labelRange=Ai(o,t,e.labelRange),this.background=e.background,this.legendPosition=e.legendPosition,this.aggregated=e.aggregated,this.dataSetsHaveTitle=e.dataSetsHaveTitle}static transformDefinition(e,t){return ep(e,t)}static validateChartDefinition(e,t){return e.checkValidations(t,sp,rp)}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,aggregated:!1}}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,o){return{type:"pie",dataSetsHaveTitle:!!e.length&&Boolean(e[0].labelCell),background:this.background,dataSets:e.map((e=>this.getters.getRangeString(e.dataRange,o||this.sheetId))),legendPosition:this.legendPosition,labelRange:t?this.getters.getRangeString(t,o||this.sheetId):void 0,title:this.title,aggregated:this.aggregated}}copyForSheetId(e){const t=Zg(this.sheetId,e,this.dataSets),o=Yg(this.sheetId,e,this.labelRange),i=this.getDefinitionWithSpecificDataSets(t,o,e);return new zp(i,e,this.getters)}copyInSheetId(e){const t=this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange,e);return new zp(t,e,this.getters)}getDefinitionForExcel(){if(this.aggregated)return;const e=this.dataSets.map((e=>Qg(this.getters,e))).filter((e=>""!==e.range&&e.range!==ee)),t=Jg(this.getters,this.labelRange,np(this.labelRange,this.dataSets[0],this.dataSetsHaveTitle));return{...this.getDefinition(),backgroundColor:$g(this.background||w),fontColor:$g(ip(this.background)),verticalAxisPosition:"left",dataSets:e,labelRange:t}}updateRanges(e){const{dataSets:t,labelRange:o,isStale:i}=qg(this.getters,e,this.dataSets,this.labelRange);if(!i)return this;const s=this.getDefinitionWithSpecificDataSets(t,o);return new zp(s,this.sheetId,this.getters)}}function Hp(e,t){const o=[],i=et(t.map((e=>e.data.length)));for(let t=0;t<=i;t++)o.push(e.next());return o}function $p(e){return e.keyValue&&!Zo.test(e.keyValue)?37:0}function Wp(e){return e.baseline&&!Zo.test(e.baseline)?38:0}class Gp extends Wg{keyValue;baseline;baselineMode;baselineDescr;background;baselineColorUp;baselineColorDown;fontColor;type="scorecard";constructor(e,t,o){super(e,t,o),this.keyValue=Ai(o,t,e.keyValue),this.baseline=Ai(o,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,$p,Wp)}static getDefinitionFromContextCreation(e){return{background:e.background,type:"scorecard",keyValue:e.range?e.range[0]:void 0,title:e.title||"",baselineMode:re,baselineColorUp:ne,baselineColorDown:ae,baseline:e.auxiliaryRange||""}}static transformDefinition(e,t){let o,i;return e.baseline&&(o=Gg(ei(e.baseline),t)),e.keyValue&&(i=Gg(ei(e.keyValue),t)),{...e,baseline:o?ii(o):void 0,keyValue:i?ii(i):void 0}}copyForSheetId(e){const t=Yg(this.sheetId,e,this.baseline),o=Yg(this.sheetId,e,this.keyValue),i=this.getDefinitionWithSpecificRanges(t,o,e);return new Gp(i,e,this.getters)}copyInSheetId(e){const t=this.getDefinitionWithSpecificRanges(this.baseline,this.keyValue,e);return new Gp(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,o){return{baselineColorDown:this.baselineColorDown,baselineColorUp:this.baselineColorUp,baselineMode:this.baselineMode,title:this.title,type:"scorecard",background:this.background,baseline:e?this.getters.getRangeString(e,o||this.sheetId):void 0,baselineDescr:this.baselineDescr,keyValue:t?this.getters.getRangeString(t,o||this.sheetId):void 0}}getDefinitionForExcel(){}updateRanges(e){const t=jg(this.baseline,e),o=jg(this.keyValue,e);if(this.baseline===t&&this.keyValue===o)return this;const i=this.getDefinitionWithSpecificRanges(t,o);return new Gp(i,this.sheetId,this.getters)}}const qp=new Ji;qp.add("bar",{match:e=>"bar"===e,createChart:(e,t,o)=>new Ip(e,t,o),getChartRuntime:function(e,t){let o=Ep(t,e.dataSets,e.labelRange).formattedValues,i=xp(t,e.dataSets);e.dataSetsHaveTitle&&i[0]&&o.length>i[0].data.length&&o.shift(),({labels:o,dataSetsValues:i}=bp(o,i)),e.aggregated&&({labels:o,dataSetsValues:i}=vp(o,i));const s=function(e,t,o){const i=ip(e.background),s=Cp(e,t,i,o),r={labels:{fontColor:i}};return!e.labelRange&&1===e.dataSets.length||"none"===e.legendPosition?r.display=!1:r.position=e.legendPosition,s.options.legend={...s.options?.legend,...r},s.options.layout={padding:{left:20,right:20,top:e.title?10:25,bottom:10}},s.options.scales={xAxes:[{ticks:{maxRotation:60,minRotation:15,padding:5,labelOffset:2,fontColor:i}}],yAxes:[{position:e.verticalAxisPosition,ticks:{fontColor:i,beginAtZero:!0,callback:e=>o.format?fo(e,o):e?.toLocaleString()||e}}]},e.stacked&&(s.options.scales.xAxes[0].stacked=!0,s.options.scales.yAxes[0].stacked=!0),s}(e,o,{format:wp(t,e.dataSets),locale:t.getLocale()}),r=new op;for(let{label:e,data:t}of i){const o=r.next(),i={label:e,data:t,borderColor:o,backgroundColor:o};s.data.datasets.push(i)}return{chartJsConfig:s,background:e.background||w}},validateChartDefinition:(e,t)=>Ip.validateChartDefinition(e,t),transformDefinition:(e,t)=>Ip.transformDefinition(e,t),getChartDefinitionFromContextCreation:e=>Ip.getDefinitionFromContextCreation(e),name:r("Bar"),sequence:10}),qp.add("line",{match:e=>"line"===e,createChart:(e,t,o)=>new Pp(e,t,o),getChartRuntime:function(e,t){const o=Up(e,t),i=Ep(t,e.dataSets,e.labelRange);let s="linear"===o?i.values:i.formattedValues,r=xp(t,e.dataSets);e.dataSetsHaveTitle&&r[0]&&s.length>r[0].data.length&&s.shift(),({labels:s,dataSetsValues:r}=bp(s,r)),"time"===o&&({labels:s,dataSetsValues:r}=function(e,t){if(0===e.length||e.every((e=>!e)))return{labels:e,dataSetsValues:t};const o=[...e],i=Ce(t);for(let e=0;e<o.length;e++)if(!o[e]){o[e]=He(o,e);for(let t of i)t.data[e]=void 0}return{labels:o,dataSetsValues:i}}(s,r)),e.aggregated&&({labels:s,dataSetsValues:r}=vp(s,r));const n=t.getLocale(),a={format:wp(t,e.dataSets),locale:n},l=function(e,t,o){const i=ip(e.background),s=Cp(e,t,i,o),r={labels:{fontColor:i,generateLabels(e){const{data:t}=e,o=window.Chart.defaults.global.legend.labels.generateLabels(e);for(const[e,i]of o.entries())i.fillStyle=t.datasets[e].borderColor;return o}}};return!e.labelRange&&1===e.dataSets.length||"none"===e.legendPosition?r.display=!1:r.position=e.legendPosition,s.options.legend={...s.options?.legend,...r},s.options.layout={padding:{left:20,right:20,top:e.title?10:25,bottom:10}},s.options.scales={xAxes:[{ticks:{maxRotation:60,minRotation:15,padding:5,labelOffset:2,fontColor:i}}],yAxes:[{position:e.verticalAxisPosition,ticks:{fontColor:i,beginAtZero:!0,callback:e=>o.format?fo(e,o):e?.toLocaleString()||e}}]},e.stacked&&(s.options.scales.yAxes[0].stacked=!0),s}(e,s,a),c=function(e,t){if(t)return e.getEvaluatedCell({sheetId:t.sheetId,col:t.zone.left,row:t.zone.top}).format}(t,e.labelRange);"time"===o?(l.options.scales.xAxes[0].type="time",l.options.scales.xAxes[0].time=Lp(s,c,n),l.options.scales.xAxes[0].ticks.maxTicksLimit=15):"linear"===o&&(l.options.scales.xAxes[0].type="linear",l.options.scales.xAxes[0].ticks.callback=e=>fo(e,a),l.options.tooltips.callbacks.title=e=>fo(e[0]?.xLabel||"",a));const h=new op;for(let[t,{label:i,data:n}]of r.entries()){["linear","time"].includes(o)&&(n=n.map(((e,t)=>({x:s[t]||void 0,y:e}))));const r=h.next();let a=ut(r);if(e.stacked&&(a.a=le),e.cumulative){let e=0;n=n.map((t=>isNaN(t)?t:(e+=parseFloat(t),e)))}const c={label:i,data:n,lineTension:0,borderColor:r,backgroundColor:dt(a),pointBackgroundColor:r,fill:!!e.stacked&&yp(t)};l.data.datasets.push(c)}return{chartJsConfig:l,background:e.background||w}},validateChartDefinition:(e,t)=>Pp.validateChartDefinition(e,t),transformDefinition:(e,t)=>Pp.transformDefinition(e,t),getChartDefinitionFromContextCreation:e=>Pp.getDefinitionFromContextCreation(e),name:r("Line"),sequence:20}),qp.add("pie",{match:e=>"pie"===e,createChart:(e,t,o)=>new zp(e,t,o),getChartRuntime:function(e,t){let o=Ep(t,e.dataSets,e.labelRange).formattedValues,i=xp(t,e.dataSets);e.dataSetsHaveTitle&&i[0]&&o.length>i[0].data.length&&o.shift(),({labels:o,dataSetsValues:i}=bp(o,i)),e.aggregated&&({labels:o,dataSetsValues:i}=vp(o,i));const s=function(e,t,o){const i=ip(e.background),s=Cp(e,t,i,o),r={labels:{fontColor:i}};return!e.labelRange&&1===e.dataSets.length||"none"===e.legendPosition?r.display=!1:r.position=e.legendPosition,s.options.legend={...s.options?.legend,...r},s.options.layout={padding:{left:20,right:20,top:e.title?10:25,bottom:10}},s.options.tooltips.callbacks.title=function(e,t){return t.datasets[e[0].datasetIndex].label},s}(e,o,{format:wp(t,e.dataSets),locale:t.getLocale()}),r=new op;for(let{label:e,data:t}of i){const o={label:e,data:t,borderColor:"#FFFFFF",backgroundColor:Hp(r,i)};s.data.datasets.push(o)}return{chartJsConfig:s,background:e.background||w}},validateChartDefinition:(e,t)=>zp.validateChartDefinition(e,t),transformDefinition:(e,t)=>zp.transformDefinition(e,t),getChartDefinitionFromContextCreation:e=>zp.getDefinitionFromContextCreation(e),name:r("Pie"),sequence:30}),qp.add("scorecard",{match:e=>"scorecard"===e,createChart:(e,t,o)=>new Gp(e,t,o),getChartRuntime:function(e,t){let o,i,r="",n="";if(e.keyValue){const i={sheetId:e.keyValue.sheetId,col:e.keyValue.zone.left,row:e.keyValue.zone.top};o=t.getEvaluatedCell(i),r=String(o.value),n=o.formattedValue}const a=e.baseline;if(a){const o={sheetId:e.baseline.sheetId,col:e.baseline.zone.left,row:e.baseline.zone.top};i=t.getEvaluatedCell(o)}const{background:l,fontColor:c}=t.getStyleOfSingleCellChart(e.background,e.keyValue),h=t.getLocale();return{title:s(e.title),keyValue:n||r,baselineDisplay:ap(i,o,e.baselineMode,h),baselineArrow:cp(i,o,e.baselineMode),baselineColor:lp(i,e.baselineMode,o,e.baselineColorUp,e.baselineColorDown),baselineDescr:e.baselineDescr?s(e.baselineDescr):"",fontColor:c,background:l,baselineStyle:"percentage"!==e.baselineMode&&a?t.getCellStyle({sheetId:a.sheetId,col:a.zone.left,row:a.zone.top}):void 0,keyValueStyle:e.keyValue?t.getCellStyle({sheetId:e.keyValue.sheetId,col:e.keyValue.zone.left,row:e.keyValue.zone.top}):void 0}},validateChartDefinition:(e,t)=>Gp.validateChartDefinition(e,t),transformDefinition:(e,t)=>Gp.transformDefinition(e,t),getChartDefinitionFromContextCreation:e=>Gp.getDefinitionFromContextCreation(e),name:r("Scorecard"),sequence:40}),qp.add("gauge",{match:e=>"gauge"===e,createChart:(e,t,o)=>new Np(e,t,o),getChartRuntime:function(e,t){const o=function(e,t){const o=Cp(e,[],ip(e.background),{locale:t});return o.options.hover=void 0,o.options.events=[],o.options.layout={padding:{left:30,right:30,top:e.title?10:25,bottom:25}},o.options.needle={radiusPercentage:2,widthPercentage:3.2,lengthPercentage:80,color:"#000000"},o.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},o}(e,t.getLocale()),i=e.sectionRule.colors,s=e.sectionRule.lowerInflectionPoint,r=e.sectionRule.upperInflectionPoint,n=Number(s.value),a=Number(r.value),l=Number(e.sectionRule.rangeMin),c=Number(e.sectionRule.rangeMax),h=c-l,d=[];if(""!==s.value){const e="number"===s.type?n:l+h*n/100;d.push({value:xe(e,l,c),color:i.lowerColor})}if(""!==r.value){const e="number"===r.type?a:l+h*a/100;d.push({value:xe(e,l,c),color:i.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(i.upperColor);const p=e.dataRange,m=h/30;let f=l-m,b=null,v=!1;if(void 0!==p){const e=t.getEvaluatedCell({sheetId:p.sheetId,col:p.zone.left,row:p.zone.top});e.type===ls.number&&(f=xe(e.value,l-m,c+m),b=()=>t.getRangeFormattedValues(p)[0],v=!0)}return o.options.valueLabel.display=v,o.options.valueLabel.formatter=b,o.data.datasets.push({data:u,minValue:Number(e.sectionRule.rangeMin),value:f,backgroundColor:g}),{chartJsConfig:o,background:t.getStyleOfSingleCellChart(e.background,p).background}},validateChartDefinition:(e,t)=>Np.validateChartDefinition(e,t),transformDefinition:(e,t)=>Np.transformDefinition(e,t),getChartDefinitionFromContextCreation:e=>Np.getDefinitionFromContextCreation(e),name:r("Gauge"),sequence:50});const Zp=new Ji;Zp.add("line",zi),Zp.add("bar",zi),Zp.add("pie",zi),Zp.add("gauge",zi),Zp.add("scorecard",Xi);const Yp=new Ji;Wi`
|
|
351
|
+
`;class Bg extends t.Component{static template="o-spreadsheet-LinkEditor";static components={Menu:Vr};menuItems=Vg.getMenuItems();link=t.useState(this.defaultState);menu=t.useState({isOpen:!1});linkEditorRef=t.useRef("linkEditor");position=Nr(this.linkEditorRef);urlInput=t.useRef("urlInput");setup(){t.onMounted((()=>this.urlInput.el?.focus()))}get defaultState(){const{col:e,row:t}=this.props.cellPosition,o=this.env.model.getters.getActiveSheetId(),i=this.env.model.getters.getEvaluatedCell({sheetId:o,col:e,row:t});return i.link?{url:i.link.url,label:i.formattedValue,isUrlEditable:i.link.isUrlEditable}:{label:i.formattedValue,url:"",isUrlEditable:!0}}get menuPosition(){return{x:this.position.x+320-12-2,y:this.position.y+100}}onSpecialLink(e){const{detail:t}=e,o=as(t);o&&(this.link.url=o.url,this.link.label=o.label,this.link.isUrlEditable=o.isUrlEditable)}getUrlRepresentation(e){return rs(e,this.env.model.getters)}openMenu(){this.menu.isOpen=!0}removeLink(){this.link.url="",this.link.isUrlEditable=!0}save(){const{col:e,row:t}=this.props.cellPosition,o=this.env.model.getters.getLocale(),i=this.link.label?bg(this.link.label,o):this.link.url;this.env.model.dispatch("UPDATE_CELL",{col:e,row:t,sheetId:this.env.model.getters.getActiveSheetId(),content:Ne(i,this.link.url)}),this.props.onClosed?.()}cancel(){this.props.onClosed?.()}onKeyDown(e){switch(e.key){case"Enter":this.link.url&&this.save(),e.stopPropagation(),e.preventDefault();break;case"Escape":this.cancel(),e.stopPropagation()}}}const zg={onOpen:(e,t)=>({isOpen:!0,props:{cellPosition:e},Component:Bg,cellCorner:"BottomLeft"})};Bg.props={cellPosition:Object,onClosed:{type:Function,optional:!0}};const Hg=new Ji;function $g(e){return 8===(e=nt(e).replace("#","")).length?e.slice(6)+e.slice(0,6):e}Hg.add("ErrorToolTip",vr).add("LinkCell",zr).add("LinkEditor",zg).add("FilterMenu",wr);class Wg{sheetId;title;getters;constructor(e,t,o){this.title=e.title,this.sheetId=t,this.getters=o}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 Gg(e,t){return"REMOVE_COLUMNS_ROWS"===t.type?ai(e,"COL"===t.dimension?"left":"top",t.elements):"ADD_COLUMNS_ROWS"===t.type?si(e,"COL"===t.dimension?"left":"top",t.base,t.position,t.quantity):{...e}}function qg(e,t,o,i){let s=!1;const r=[];for(let i in o){let n=o[i];if(n.labelCell){const e=jg(n.labelCell,t);n.labelCell!==e&&(s=!0,n={...n,labelCell:e})}const a=jg(n.dataRange,t);void 0===a||e.getRangeString(a,a.sheetId)===ee?(s=!0,n=void 0):a!==n.dataRange&&(s=!0,n={...n,dataRange:a}),r[i]=n}let n=i;const a=jg(n,t);a!==n&&(s=!0,n=a);return{isStale:s,dataSets:r.filter(ke),labelRange:n}}function Zg(e,t,o){return o.map((o=>({dataRange:Ti(e,t,o.dataRange),labelCell:o.labelCell?Ti(e,t,o.labelCell):void 0})))}function Yg(e,t,o){return o?Ti(e,t,o):void 0}function jg(e,t){if(!e)return;const o=t(e);switch(o.changeType){case"NONE":return e;case"REMOVE":return;default:return o.range}}function Xg(e,t,o,i){const s=[];for(const r of t){const t=e.getRangeFromSheetXC(o,r),{unboundedZone:n,sheetId:a,invalidSheetName:l,invalidXc:c}=t;if(!l&&!c)if(n.left!==n.right&&n.top!==n.bottom){if(void 0===n.right)continue;for(let t=n.left;t<=n.right;t++){const o={...n,left:t,right:t};s.push(Kg(e,a,o,i?{top:o.top,bottom:o.top,left:o.left,right:o.left}:void 0))}}else s.push(Kg(e,a,n,i?{top:n.top,bottom:n.top,left:n.left,right:n.left}:void 0))}return s}function Kg(e,t,o,i){if(o.left!==o.right&&o.top!==o.bottom)throw new Error(`Zone should be a single column or row: ${ii(o)}`);if(i){const s=ii(o),r=ii(i);return{labelCell:e.getRangeFromSheetXC(t,r),dataRange:e.getRangeFromSheetXC(t,s)}}return{labelCell:void 0,dataRange:e.getRangeFromSheetXC(t,ii(o))}}function Qg(e,t){const o=t.labelCell?.zone;let i=t.dataRange.zone;if(o){const{numberOfRows:e,numberOfCols:t}=fi(i);1===e?i={...i,left:i.left+1}:1===t&&(i={...i,top:i.top+1})}const s=t.dataRange.clone({zone:i});return{label:t.labelCell?e.getRangeString(t.labelCell,"forceSheetReference",!0):void 0,range:e.getRangeString(s,"forceSheetReference",!0)}}function Jg(e,t,o){if(!t)return;let i={...t.zone};o&&t.zone.bottom>t.zone.top&&(i.top=i.top+1);const s=t.clone({zone:i});return e.getRangeString(s,"forceSheetReference",!0)}function ep(e,t){let o;if(e.labelRange){const i=Gg(ei(e.labelRange),t);o=i?ii(i):void 0}const i=e.dataSets.map(ei).map((e=>Gg(e,t))).filter(ke).map(ii);return{...e,labelRange:o,dataSets:i}}const tp=["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 op{graphColorIndex=0;next(){return tp[this.graphColorIndex++%tp.length]}}function ip(e){return e&&ht(e)<.3?"#FFFFFF":"#000000"}function sp(e){if(e.dataSets){const t=void 0!==e.dataSets.find((e=>!Zo.test(e)));if(t)return 35;if(e.dataSets.map(ei).some((e=>e.top!==e.bottom&&xi(e))))return 35}return 0}function rp(e){if(e.labelRange){if(!Zo.test(e.labelRange||""))return 36}return 0}function np(e,t,o){if(!o)return!1;if(!e)return!1;if(!t)return!0;const i=yi(t.dataRange.zone);return!(yi(e.zone)<i)}function ap(e,t,o,i){if(e){if("text"===o||t?.type!==ls.number||e.type!==ls.number)return e.formattedValue;{let s=t.value-e.value;if("percentage"===o&&0!==s&&(s=s/e.value*100),"percentage"!==o&&e.format)return fo(s,{format:e.format,locale:i});const r=Math.abs(parseFloat(s.toFixed(2))).toLocaleString();return"percentage"===o?r+"%":r}}return""}function lp(e,t,o,i,s){if("text"===t||e?.type!==ls.number||o?.type!==ls.number)return;const r=o.value-e.value;return r>0?i:r<0?s:void 0}function cp(e,t,o){if("text"===o||e?.type!==ls.number||t?.type!==ls.number)return"neutral";const i=t.value-e.value;return i>0?"up":i<0?"down":"neutral"}const hp={Errors:{26:r("The range is invalid"),54:r("The argument is missing. Please provide a value"),55:r("The second argument is missing. Please provide a value"),56:r("The minpoint must be a number"),57:r("The midpoint must be a number"),58:r("The maxpoint must be a number"),59:r("The first value must be a number"),60:r("The second value must be a number"),50:r("Minimum must be smaller then Maximum"),53:r("Minimum must be smaller then Midpoint"),52:r("Midpoint must be smaller then Maximum"),51:r("Lower inflection point must be smaller than upper inflection point"),61:r("Invalid Minpoint formula"),63:r("Invalid Maxpoint formula"),62:r("Invalid Midpoint formula"),64:r("Invalid upper inflection point formula"),65:r("Invalid lower inflection point formula"),25: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")},dp={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")},up={Series:r("Series"),Errors:{Unexpected:r("The chart definition is invalid for an unknown reason"),35:r("The dataset is invalid"),36:r("Labels are invalid"),37:r("The key value is invalid"),38:r("The baseline value is invalid"),39:r("The data range is invalid"),40:r("A minimum range limit value is needed"),41:r("The minimum range limit value must be a number"),42:r("A maximum range limit value is needed"),43:r("The maximum range limit value must be a number"),44:r("Minimum range limit must be smaller than maximum range limit"),45:r("The lower inflection point value must be a number"),46:r("The upper inflection point value must be a number")}},gp={Custom:r("Custom")},pp=r("Merged cells are preventing this operation. Unmerge those cells and try again."),mp={Errors:{Unexpected:r("Cannot split the selection for an unknown reason"),94:r("There is no match for the selected separator in the selection"),91:r("Only a selection from a single column can be split"),93:r("Splitting will overwrite existing content")}};function fp(e,t){if(t.dataRange){const o=t.labelCell?[ii(t.labelCell.zone)]:[],i=pi([ii(t.dataRange.zone)],o)[0];if(void 0===i)return[];const s=e.getRangeFromSheetXC(t.dataRange.sheetId,i);return e.getRangeValues(s).map((e=>""===e?void 0:e))}return[]}function bp(e,t){const o=ye(0,Math.max(e.length,...t.map((e=>e.data?.length||0)))).filter((o=>{const i=e[o],s=t.map((e=>e.data?.[o]));return i||s.some((e=>0===e||Boolean(e)))}));return{labels:o.map((t=>e[t]||"")),dataSetsValues:t.map((e=>({...e,data:o.map((t=>e.data[t]))})))}}function vp(e,t){const o=new Set(e),i={};o.forEach((e=>{i[e]=new Array(t.length).fill(0)}));for(const o of ye(0,e.length)){const r=e[o];for(const e of ye(0,t.length))i[r][e]+="number"==typeof(s=t[e].data[o])?s:0}var s;return{labels:Array.from(o),dataSetsValues:t.map(((e,t)=>({...e,data:Array.from(o).map((e=>i[e][t]))})))}}function Sp(e){return e?e.length>ie?e.substring(0,ie)+"…":e:""}function Cp(e,t,o,{format:i,locale:r}){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:s(e.title),fontColor:o},legend:{onClick:void 0},tooltips:{callbacks:{label:function(e,t){let o=t.datasets?.[e.datasetIndex||0]?.label;const s=""!==e.yLabel?e.yLabel:t.datasets?.[e.datasetIndex||0]?.data?.[e.index||0],n=i&&"number"==typeof s?fo(s,{format:i,locale:r}):s?.toLocaleString()||"";return o?`${o}: ${n}`:n}}}},data:{labels:t.map(Sp),datasets:[]}}}function Ep(e,t,o){let i={values:[],formattedValues:[]};if(o)o.invalidXc||o.invalidSheetName||(i={formattedValues:e.getRangeFormattedValues(o),values:e.getRangeValues(o).map((e=>String(e)))});else if(1===t.length)for(let o=0;o<fp(e,t[0]).length;o++)i.formattedValues.push(""),i.values.push("");else if(t[0]){i={formattedValues:ye(0,fp(e,t[0]).length).map((e=>e.toString())),values:i.formattedValues}}return i}function wp(e,t){for(const o of t){const t=e.getRangeFormats(o.dataRange).find((e=>void 0!==e&&!xo(e)));if(t)return t}}function xp(e,t){const o=[];for(const[i,s]of Object.entries(t)){let t;if(s.labelCell){const o=s.labelCell,r=o?e.getEvaluatedCell({sheetId:o.sheetId,col:o.zone.left,row:o.zone.top}):void 0;t=r&&o?Sp(r.formattedValue):t=`${up.Series} ${parseInt(i)+1}`}else t=t=`${up.Series} ${parseInt(i)+1}`;let r=s.dataRange?fp(e,s):[];o.push({data:r,label:t})}return o}function yp(e){return 0===e?"origin":e-1}class Ip extends Wg{dataSets;labelRange;background;verticalAxisPosition;legendPosition;stacked;aggregated;type="bar";dataSetsHaveTitle;constructor(e,t,o){super(e,t,o),this.dataSets=Xg(o,e.dataSets,t,e.dataSetsHaveTitle),this.labelRange=Ai(o,t,e.labelRange),this.background=e.background,this.verticalAxisPosition=e.verticalAxisPosition,this.legendPosition=e.legendPosition,this.stacked=e.stacked,this.aggregated=e.aggregated,this.dataSetsHaveTitle=e.dataSetsHaveTitle}static transformDefinition(e,t){return ep(e,t)}static validateChartDefinition(e,t){return e.checkValidations(t,sp,rp)}static getDefinitionFromContextCreation(e){return{background:e.background,dataSets:e.range?e.range:[],dataSetsHaveTitle:!1,stacked:!1,aggregated:!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=Zg(this.sheetId,e,this.dataSets),o=Yg(this.sheetId,e,this.labelRange),i=this.getDefinitionWithSpecificDataSets(t,o,e);return new Ip(i,e,this.getters)}copyInSheetId(e){const t=this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange,e);return new Ip(t,e,this.getters)}getDefinition(){return this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange)}getDefinitionWithSpecificDataSets(e,t,o){return{type:"bar",dataSetsHaveTitle:!!e.length&&Boolean(e[0].labelCell),background:this.background,dataSets:e.map((e=>this.getters.getRangeString(e.dataRange,o||this.sheetId))),legendPosition:this.legendPosition,verticalAxisPosition:this.verticalAxisPosition,labelRange:t?this.getters.getRangeString(t,o||this.sheetId):void 0,title:this.title,stacked:this.stacked,aggregated:this.aggregated}}getDefinitionForExcel(){if(this.aggregated)return;const e=this.dataSets.map((e=>Qg(this.getters,e))).filter((e=>""!==e.range&&e.range!==ee)),t=Jg(this.getters,this.labelRange,np(this.labelRange,this.dataSets[0],this.dataSetsHaveTitle));return{...this.getDefinition(),backgroundColor:$g(this.background||w),fontColor:$g(ip(this.background)),dataSets:e,labelRange:t}}updateRanges(e){const{dataSets:t,labelRange:o,isStale:i}=qg(this.getters,e,this.dataSets,this.labelRange);if(!i)return this;const s=this.getDefinitionWithSpecificDataSets(t,o);return new Ip(s,this.sheetId,this.getters)}}function Rp(e){return e.dataRange&&!Zo.test(e.dataRange)?39:0}function Tp(e,t){return t((t=>t.sectionRule?e(t.sectionRule.rangeMin,"rangeMin"):0),(t=>t.sectionRule?e(t.sectionRule.rangeMax,"rangeMax"):0))}function Ap(e){return e.sectionRule&&Number(e.sectionRule.rangeMin)>=Number(e.sectionRule.rangeMax)?44:0}function Op(e,t){if(""===e)switch(t){case"rangeMin":return 40;case"rangeMax":return 42}return 0}function Mp(e,t){if(isNaN(e))switch(t){case"rangeMin":return 41;case"rangeMax":return 43;case"lowerInflectionPointValue":return 45;case"upperInflectionPointValue":return 46}return 0}class Np extends Wg{dataRange;sectionRule;background;type="gauge";constructor(e,t,o){super(e,t,o),this.dataRange=Ai(this.getters,this.sheetId,e.dataRange),this.sectionRule=e.sectionRule,this.background=e.background}static validateChartDefinition(e,t){return e.checkValidations(t,Rp,e.chainValidations(Tp(Op,e.batchValidations),Tp(Mp,e.batchValidations),Ap),e.chainValidations((o=Mp,(0,e.batchValidations)((e=>e.sectionRule?o(e.sectionRule.lowerInflectionPoint.value,"lowerInflectionPointValue"):0),(e=>e.sectionRule?o(e.sectionRule.upperInflectionPoint.value,"upperInflectionPointValue"):0)))));var o}static transformDefinition(e,t){let o;return e.dataRange&&(o=Gg(ei(e.dataRange),t)),{...e,dataRange:o?ii(o):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=Yg(this.sheetId,e,this.dataRange),o=this.getDefinitionWithSpecificRanges(t,e);return new Np(o,e,this.getters)}copyInSheetId(e){const t=this.getDefinitionWithSpecificRanges(this.dataRange,e);return new Np(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=jg(this.dataRange,e);if(this.dataRange===t)return this;const o=this.getDefinitionWithSpecificRanges(t);return new Np(o,this.sheetId,this.getters)}}const _p={second:1e3,minute:6e4,hour:36e5,day:864e5,month:2592e6,year:31536e6},Fp={inSeconds:function(e){return Math.floor(e/_p.second)},inMinutes:function(e){return Math.floor(e/_p.minute)},inHours:function(e){return Math.floor(e/_p.hour)},inDays:function(e){return Math.floor(e/_p.day)},inMonths:function(e){return Math.floor(e/_p.month)},inYears:function(e){return Math.floor(e/_p.year)}},Dp=/^((d|dd|m|mm|yyyy|yy|hh|h|ss|a)(-|:|\s|\/))*(d|dd|m|mm|yyyy|yy|hh|h|ss|a)$/i;function Lp(e,t,o){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),s=function(e,t,o){const i=e.map((e=>Ut(e,o)?.jsDate));if(i.some((e=>void 0===e))||e.length<2)return;const s=i.map((e=>e.getTime())),r=et(s)-tt(s),n=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(_p.second>=_p[n]&&Fp.inSeconds(r)<180)return"second";if(_p.minute>=_p[n]&&Fp.inMinutes(r)<180)return"minute";if(_p.hour>=_p[n]&&Fp.inHours(r)<96)return"hour";if(_p.day>=_p[n]&&Fp.inDays(r)<90)return"day";if(_p.month>=_p[n]&&Fp.inMonths(r)<36)return"month";return"year"}(e,i,o),r={};return s&&(r[s]=i),{parser:i,displayFormats:r,unit:s}}class Pp extends Wg{dataSets;labelRange;background;verticalAxisPosition;legendPosition;labelsAsText;stacked;aggregated;type="line";dataSetsHaveTitle;cumulative;constructor(e,t,o){super(e,t,o),this.dataSets=Xg(this.getters,e.dataSets,t,e.dataSetsHaveTitle),this.labelRange=Ai(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.aggregated=e.aggregated,this.dataSetsHaveTitle=e.dataSetsHaveTitle,this.cumulative=e.cumulative}static validateChartDefinition(e,t){return e.checkValidations(t,sp,rp)}static transformDefinition(e,t){return ep(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,aggregated:!1,cumulative:!1}}getDefinition(){return this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange)}getDefinitionWithSpecificDataSets(e,t,o){return{type:"line",dataSetsHaveTitle:!!e.length&&Boolean(e[0].labelCell),background:this.background,dataSets:e.map((e=>this.getters.getRangeString(e.dataRange,o||this.sheetId))),legendPosition:this.legendPosition,verticalAxisPosition:this.verticalAxisPosition,labelRange:t?this.getters.getRangeString(t,o||this.sheetId):void 0,title:this.title,labelsAsText:this.labelsAsText,stacked:this.stacked,aggregated:this.aggregated,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:o,isStale:i}=qg(this.getters,e,this.dataSets,this.labelRange);if(!i)return this;const s=this.getDefinitionWithSpecificDataSets(t,o);return new Pp(s,this.sheetId,this.getters)}getDefinitionForExcel(){if(this.aggregated)return;const e=this.dataSets.map((e=>Qg(this.getters,e))).filter((e=>""!==e.range&&e.range!==ee)),t=Jg(this.getters,this.labelRange,np(this.labelRange,this.dataSets[0],this.dataSetsHaveTitle));return{...this.getDefinition(),backgroundColor:$g(this.background||w),fontColor:$g(ip(this.background)),dataSets:e,labelRange:t}}copyForSheetId(e){const t=Zg(this.sheetId,e,this.dataSets),o=Yg(this.sheetId,e,this.labelRange),i=this.getDefinitionWithSpecificDataSets(t,o,e);return new Pp(i,e,this.getters)}copyInSheetId(e){const t=this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange,e);return new Pp(t,e,this.getters)}}function kp(e,t){return Vp(e,t)||Bp(e,t)}function Up(e,t){return function(e,t){return!e.labelsAsText&&Vp(e.labelRange,t)}(e,t)?"time":function(e,t){return!e.labelsAsText&&Bp(e.labelRange,t)}(e,t)?"linear":"category"}function Vp(e,t){if(!e||!Bp(e,t))return!1;const o=t.getEvaluatedCell({sheetId:e.sheetId,col:e.zone.left,row:e.zone.top}).format;return Boolean(o&&Dp.test(o))}function Bp(e,t){if(!e)return!1;const o=t.getRangeValues(e);return!o.some((e=>isNaN(Number(e))&&e))&&!o.every((e=>!e))}class zp extends Wg{dataSets;labelRange;background;legendPosition;type="pie";aggregated;dataSetsHaveTitle;constructor(e,t,o){super(e,t,o),this.dataSets=Xg(o,e.dataSets,t,e.dataSetsHaveTitle),this.labelRange=Ai(o,t,e.labelRange),this.background=e.background,this.legendPosition=e.legendPosition,this.aggregated=e.aggregated,this.dataSetsHaveTitle=e.dataSetsHaveTitle}static transformDefinition(e,t){return ep(e,t)}static validateChartDefinition(e,t){return e.checkValidations(t,sp,rp)}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,aggregated:!1}}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,o){return{type:"pie",dataSetsHaveTitle:!!e.length&&Boolean(e[0].labelCell),background:this.background,dataSets:e.map((e=>this.getters.getRangeString(e.dataRange,o||this.sheetId))),legendPosition:this.legendPosition,labelRange:t?this.getters.getRangeString(t,o||this.sheetId):void 0,title:this.title,aggregated:this.aggregated}}copyForSheetId(e){const t=Zg(this.sheetId,e,this.dataSets),o=Yg(this.sheetId,e,this.labelRange),i=this.getDefinitionWithSpecificDataSets(t,o,e);return new zp(i,e,this.getters)}copyInSheetId(e){const t=this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange,e);return new zp(t,e,this.getters)}getDefinitionForExcel(){if(this.aggregated)return;const e=this.dataSets.map((e=>Qg(this.getters,e))).filter((e=>""!==e.range&&e.range!==ee)),t=Jg(this.getters,this.labelRange,np(this.labelRange,this.dataSets[0],this.dataSetsHaveTitle));return{...this.getDefinition(),backgroundColor:$g(this.background||w),fontColor:$g(ip(this.background)),verticalAxisPosition:"left",dataSets:e,labelRange:t}}updateRanges(e){const{dataSets:t,labelRange:o,isStale:i}=qg(this.getters,e,this.dataSets,this.labelRange);if(!i)return this;const s=this.getDefinitionWithSpecificDataSets(t,o);return new zp(s,this.sheetId,this.getters)}}function Hp(e,t){const o=[],i=et(t.map((e=>e.data.length)));for(let t=0;t<=i;t++)o.push(e.next());return o}function $p(e){return e.keyValue&&!Zo.test(e.keyValue)?37:0}function Wp(e){return e.baseline&&!Zo.test(e.baseline)?38:0}class Gp extends Wg{keyValue;baseline;baselineMode;baselineDescr;background;baselineColorUp;baselineColorDown;fontColor;type="scorecard";constructor(e,t,o){super(e,t,o),this.keyValue=Ai(o,t,e.keyValue),this.baseline=Ai(o,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,$p,Wp)}static getDefinitionFromContextCreation(e){return{background:e.background,type:"scorecard",keyValue:e.range?e.range[0]:void 0,title:e.title||"",baselineMode:re,baselineColorUp:ne,baselineColorDown:ae,baseline:e.auxiliaryRange||""}}static transformDefinition(e,t){let o,i;return e.baseline&&(o=Gg(ei(e.baseline),t)),e.keyValue&&(i=Gg(ei(e.keyValue),t)),{...e,baseline:o?ii(o):void 0,keyValue:i?ii(i):void 0}}copyForSheetId(e){const t=Yg(this.sheetId,e,this.baseline),o=Yg(this.sheetId,e,this.keyValue),i=this.getDefinitionWithSpecificRanges(t,o,e);return new Gp(i,e,this.getters)}copyInSheetId(e){const t=this.getDefinitionWithSpecificRanges(this.baseline,this.keyValue,e);return new Gp(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,o){return{baselineColorDown:this.baselineColorDown,baselineColorUp:this.baselineColorUp,baselineMode:this.baselineMode,title:this.title,type:"scorecard",background:this.background,baseline:e?this.getters.getRangeString(e,o||this.sheetId):void 0,baselineDescr:this.baselineDescr,keyValue:t?this.getters.getRangeString(t,o||this.sheetId):void 0}}getDefinitionForExcel(){}updateRanges(e){const t=jg(this.baseline,e),o=jg(this.keyValue,e);if(this.baseline===t&&this.keyValue===o)return this;const i=this.getDefinitionWithSpecificRanges(t,o);return new Gp(i,this.sheetId,this.getters)}}const qp=new Ji;qp.add("bar",{match:e=>"bar"===e,createChart:(e,t,o)=>new Ip(e,t,o),getChartRuntime:function(e,t){let o=Ep(t,e.dataSets,e.labelRange).formattedValues,i=xp(t,e.dataSets);e.dataSetsHaveTitle&&i[0]&&o.length>i[0].data.length&&o.shift(),({labels:o,dataSetsValues:i}=bp(o,i)),e.aggregated&&({labels:o,dataSetsValues:i}=vp(o,i));const s=function(e,t,o){const i=ip(e.background),s=Cp(e,t,i,o),r={labels:{fontColor:i}};return!e.labelRange&&1===e.dataSets.length||"none"===e.legendPosition?r.display=!1:r.position=e.legendPosition,s.options.legend={...s.options?.legend,...r},s.options.layout={padding:{left:20,right:20,top:e.title?10:25,bottom:10}},s.options.scales={xAxes:[{ticks:{maxRotation:60,minRotation:15,padding:5,labelOffset:2,fontColor:i}}],yAxes:[{position:e.verticalAxisPosition,ticks:{fontColor:i,beginAtZero:!0,callback:e=>o.format?fo(e,o):e?.toLocaleString()||e}}]},e.stacked&&(s.options.scales.xAxes[0].stacked=!0,s.options.scales.yAxes[0].stacked=!0),s}(e,o,{format:wp(t,e.dataSets),locale:t.getLocale()}),r=new op;for(let{label:e,data:t}of i){const o=r.next(),i={label:e,data:t,borderColor:o,backgroundColor:o};s.data.datasets.push(i)}return{chartJsConfig:s,background:e.background||w}},validateChartDefinition:(e,t)=>Ip.validateChartDefinition(e,t),transformDefinition:(e,t)=>Ip.transformDefinition(e,t),getChartDefinitionFromContextCreation:e=>Ip.getDefinitionFromContextCreation(e),name:r("Bar"),sequence:10}),qp.add("line",{match:e=>"line"===e,createChart:(e,t,o)=>new Pp(e,t,o),getChartRuntime:function(e,t){const o=Up(e,t),i=Ep(t,e.dataSets,e.labelRange);let s="linear"===o?i.values:i.formattedValues,r=xp(t,e.dataSets);e.dataSetsHaveTitle&&r[0]&&s.length>r[0].data.length&&s.shift(),({labels:s,dataSetsValues:r}=bp(s,r)),"time"===o&&({labels:s,dataSetsValues:r}=function(e,t){if(0===e.length||e.every((e=>!e)))return{labels:e,dataSetsValues:t};const o=[...e],i=Ce(t);for(let e=0;e<o.length;e++)if(!o[e]){o[e]=He(o,e);for(let t of i)t.data[e]=void 0}return{labels:o,dataSetsValues:i}}(s,r)),e.aggregated&&({labels:s,dataSetsValues:r}=vp(s,r));const n=t.getLocale(),a={format:wp(t,e.dataSets),locale:n},l=function(e,t,o){const i=ip(e.background),s=Cp(e,t,i,o),r={labels:{fontColor:i,generateLabels(e){const{data:t}=e,o=window.Chart.defaults.global.legend.labels.generateLabels(e);for(const[e,i]of o.entries())i.fillStyle=t.datasets[e].borderColor;return o}}};return!e.labelRange&&1===e.dataSets.length||"none"===e.legendPosition?r.display=!1:r.position=e.legendPosition,s.options.legend={...s.options?.legend,...r},s.options.layout={padding:{left:20,right:20,top:e.title?10:25,bottom:10}},s.options.scales={xAxes:[{ticks:{maxRotation:60,minRotation:15,padding:5,labelOffset:2,fontColor:i}}],yAxes:[{position:e.verticalAxisPosition,ticks:{fontColor:i,beginAtZero:!0,callback:e=>o.format?fo(e,o):e?.toLocaleString()||e}}]},e.stacked&&(s.options.scales.yAxes[0].stacked=!0),s}(e,s,a),c=function(e,t){if(t)return e.getEvaluatedCell({sheetId:t.sheetId,col:t.zone.left,row:t.zone.top}).format}(t,e.labelRange);"time"===o?(l.options.scales.xAxes[0].type="time",l.options.scales.xAxes[0].time=Lp(s,c,n),l.options.scales.xAxes[0].ticks.maxTicksLimit=15):"linear"===o&&(l.options.scales.xAxes[0].type="linear",l.options.scales.xAxes[0].ticks.callback=e=>fo(e,a),l.options.tooltips.callbacks.title=e=>fo(e[0]?.xLabel||"",a));const h=new op;for(let[t,{label:i,data:n}]of r.entries()){["linear","time"].includes(o)&&(n=n.map(((e,t)=>({x:s[t]||void 0,y:e}))));const r=h.next();let a=ut(r);if(e.stacked&&(a.a=le),e.cumulative){let e=0;n=n.map((t=>isNaN(t)?t:(e+=parseFloat(t),e)))}const c={label:i,data:n,lineTension:0,borderColor:r,backgroundColor:dt(a),pointBackgroundColor:r,fill:!!e.stacked&&yp(t)};l.data.datasets.push(c)}return{chartJsConfig:l,background:e.background||w}},validateChartDefinition:(e,t)=>Pp.validateChartDefinition(e,t),transformDefinition:(e,t)=>Pp.transformDefinition(e,t),getChartDefinitionFromContextCreation:e=>Pp.getDefinitionFromContextCreation(e),name:r("Line"),sequence:20}),qp.add("pie",{match:e=>"pie"===e,createChart:(e,t,o)=>new zp(e,t,o),getChartRuntime:function(e,t){let o=Ep(t,e.dataSets,e.labelRange).formattedValues,i=xp(t,e.dataSets);e.dataSetsHaveTitle&&i[0]&&o.length>i[0].data.length&&o.shift(),({labels:o,dataSetsValues:i}=bp(o,i)),e.aggregated&&({labels:o,dataSetsValues:i}=vp(o,i));const s=function(e,t,o){const i=ip(e.background),s=Cp(e,t,i,o),r={labels:{fontColor:i}};return!e.labelRange&&1===e.dataSets.length||"none"===e.legendPosition?r.display=!1:r.position=e.legendPosition,s.options.legend={...s.options?.legend,...r},s.options.layout={padding:{left:20,right:20,top:e.title?10:25,bottom:10}},s.options.tooltips.callbacks.title=function(e,t){return t.datasets[e[0].datasetIndex].label},s}(e,o,{format:wp(t,e.dataSets),locale:t.getLocale()}),r=new op;for(let{label:e,data:t}of i){const o={label:e,data:t,borderColor:"#FFFFFF",backgroundColor:Hp(r,i)};s.data.datasets.push(o)}return{chartJsConfig:s,background:e.background||w}},validateChartDefinition:(e,t)=>zp.validateChartDefinition(e,t),transformDefinition:(e,t)=>zp.transformDefinition(e,t),getChartDefinitionFromContextCreation:e=>zp.getDefinitionFromContextCreation(e),name:r("Pie"),sequence:30}),qp.add("scorecard",{match:e=>"scorecard"===e,createChart:(e,t,o)=>new Gp(e,t,o),getChartRuntime:function(e,t){let o,i,r="",n="";if(e.keyValue){const i={sheetId:e.keyValue.sheetId,col:e.keyValue.zone.left,row:e.keyValue.zone.top};o=t.getEvaluatedCell(i),r=String(o.value),n=o.formattedValue}const a=e.baseline;if(a){const o={sheetId:e.baseline.sheetId,col:e.baseline.zone.left,row:e.baseline.zone.top};i=t.getEvaluatedCell(o)}const{background:l,fontColor:c}=t.getStyleOfSingleCellChart(e.background,e.keyValue),h=t.getLocale();return{title:s(e.title),keyValue:n||r,baselineDisplay:ap(i,o,e.baselineMode,h),baselineArrow:cp(i,o,e.baselineMode),baselineColor:lp(i,e.baselineMode,o,e.baselineColorUp,e.baselineColorDown),baselineDescr:e.baselineDescr?s(e.baselineDescr):"",fontColor:c,background:l,baselineStyle:"percentage"!==e.baselineMode&&a?t.getCellStyle({sheetId:a.sheetId,col:a.zone.left,row:a.zone.top}):void 0,keyValueStyle:e.keyValue?t.getCellStyle({sheetId:e.keyValue.sheetId,col:e.keyValue.zone.left,row:e.keyValue.zone.top}):void 0}},validateChartDefinition:(e,t)=>Gp.validateChartDefinition(e,t),transformDefinition:(e,t)=>Gp.transformDefinition(e,t),getChartDefinitionFromContextCreation:e=>Gp.getDefinitionFromContextCreation(e),name:r("Scorecard"),sequence:40}),qp.add("gauge",{match:e=>"gauge"===e,createChart:(e,t,o)=>new Np(e,t,o),getChartRuntime:function(e,t){const o=function(e,t){const o=Cp(e,[],ip(e.background),{locale:t});return o.options.hover=void 0,o.options.events=[],o.options.layout={padding:{left:30,right:30,top:e.title?10:25,bottom:25}},o.options.needle={radiusPercentage:2,widthPercentage:3.2,lengthPercentage:80,color:"#000000"},o.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},o}(e,t.getLocale()),i=e.sectionRule.colors,s=e.sectionRule.lowerInflectionPoint,r=e.sectionRule.upperInflectionPoint,n=Number(s.value),a=Number(r.value),l=Number(e.sectionRule.rangeMin),c=Number(e.sectionRule.rangeMax),h=c-l,d=[];if(""!==s.value){const e="number"===s.type?n:l+h*n/100;d.push({value:xe(e,l,c),color:i.lowerColor})}if(""!==r.value){const e="number"===r.type?a:l+h*a/100;d.push({value:xe(e,l,c),color:i.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(i.upperColor);const p=e.dataRange,m=h/30;let f=l-m,b=null,v=!1;if(void 0!==p){const e=t.getEvaluatedCell({sheetId:p.sheetId,col:p.zone.left,row:p.zone.top});e.type===ls.number&&(f=xe(e.value,l-m,c+m),b=()=>t.getRangeFormattedValues(p)[0],v=!0)}return o.options.valueLabel.display=v,o.options.valueLabel.formatter=b,o.data.datasets.push({data:u,minValue:Number(e.sectionRule.rangeMin),value:f,backgroundColor:g}),{chartJsConfig:o,background:t.getStyleOfSingleCellChart(e.background,p).background}},validateChartDefinition:(e,t)=>Np.validateChartDefinition(e,t),transformDefinition:(e,t)=>Np.transformDefinition(e,t),getChartDefinitionFromContextCreation:e=>Np.getDefinitionFromContextCreation(e),name:r("Gauge"),sequence:50});const Zp=new Ji;Zp.add("line",zi),Zp.add("bar",zi),Zp.add("pie",zi),Zp.add("gauge",zi),Zp.add("scorecard",Xi);const Yp=new Ji;Wi`
|
|
352
352
|
.o-chart-container {
|
|
353
353
|
width: 100%;
|
|
354
354
|
height: 100%;
|
|
355
355
|
position: relative;
|
|
356
356
|
}
|
|
357
|
-
`;class jp extends t.Component{static template="o-spreadsheet-ChartFigure";static components={};onDoubleClick(){this.env.model.dispatch("SELECT_FIGURE",{id:this.props.figure.id}),this.env.openSidePanel("ChartPanel")}get chartType(){return this.env.model.getters.getChartType(this.props.figure.id)}get chartComponent(){const e=this.chartType,t=Zp.get(e);if(!t)throw new Error(`Component is not defined for type ${e}`);return t}}jp.props={figure:Object,onFigureDeleted:Function};class Xp extends t.Component{static template="o-spreadsheet-ImageFigure";static components={};get figureId(){return this.props.figure.id}get getImagePath(){return this.env.model.getters.getImagePath(this.figureId)}}function Kp(e,t){const o=Ce(t),i=e.getSheetViewDimension(),s=i.width,r=i.height;if(o.width>s){const e=s/o.width;o.width=s,o.height=o.height*e}if(o.height>r){const e=r/o.height;o.height=r,o.width=o.width*e}return o}Xp.props={figure:Object,onFigureDeleted:Function};const Qp=new Ji;function Jp(e,t){return{id:"copy",name:r("Copy"),sequence:2,description:"Ctrl+C",execute:async()=>{t.model.dispatch("SELECT_FIGURE",{id:e}),t.model.dispatch("COPY"),await t.clipboard.write(t.model.getters.getClipboardContent())},icon:"o-spreadsheet-Icon.COPY"}}function em(e,t){return{id:"cut",name:r("Cut"),sequence:3,description:"Ctrl+X",execute:async()=>{t.model.dispatch("SELECT_FIGURE",{id:e}),t.model.dispatch("CUT"),await t.clipboard.write(t.model.getters.getClipboardContent())},icon:"o-spreadsheet-Icon.CUT"}}function tm(e,t,o){return{id:"delete",name:r("Delete"),sequence:10,execute:()=>{o.model.dispatch("DELETE_FIGURE",{sheetId:o.model.getters.getActiveSheetId(),id:e}),t()},icon:"o-spreadsheet-Icon.DELETE"}}Qp.add("chart",{Component:jp,SidePanelComponent:"ChartPanel",menuBuilder:function(e,t,o){return Lg([{id:"edit",name:r("Edit"),sequence:1,execute:()=>{o.model.dispatch("SELECT_FIGURE",{id:e}),o.openSidePanel("ChartPanel")},icon:"o-spreadsheet-Icon.EDIT"},Jp(e,o),em(e,o),tm(e,t,o)])}}),Qp.add("image",{Component:Xp,keepRatio:!0,minFigSize:20,borderWidth:0,menuBuilder:function(e,t,o){return Lg([Jp(e,o),em(e,o),{id:"reset_size",name:r("Reset size"),sequence:4,execute:async()=>{const t=o.model.getters.getImagePath(e),i=o.model.getters.getImageSize(e)??await(o.imageProvider?.getImageOriginalSize(t));if(!o.model.getters.getImageSize(e)){o.model.getters.getImage(e).size=i}const{height:s,width:r}=Kp(o.model.getters,i);o.model.dispatch("UPDATE_FIGURE",{sheetId:o.model.getters.getActiveSheetId(),id:e,height:s,width:r})},icon:"o-spreadsheet-Icon.REFRESH"},tm(e,t,o)])}});const om=(new Ji).add("ADD_COLUMNS_ROWS",(function(e){const t=[];let o=e.base;"after"===e.position&&o++;for(let i=0;i<e.quantity;i++)t.push(i+o);return[{type:"REMOVE_COLUMNS_ROWS",dimension:e.dimension,elements:t,sheetId:e.sheetId}]})).add("REMOVE_COLUMNS_ROWS",(function(e){const t=[],o=[...e.elements].sort(((e,t)=>e-t));for(let i of Ie(o)){const o=0===i[0]?0:i[0]-1,s=0===i[0]?"before":"after";t.push({type:"ADD_COLUMNS_ROWS",dimension:e.dimension,quantity:i.length,base:o,sheetId:e.sheetId,position:s})}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 ps.values())om.contains(e)||om.add(e,im);function im(e){return[e]}function sm(e){const t=e.model.dispatch("CUT");t.isSuccessful||t.isCancelledBecause(20)&&e.raiseError(r("This operation is not allowed with multiple selections."))}const rm={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 nm={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 am(e,t){t.isSuccessful||(t.reasons.includes(21)?e.raiseError(nm.wrongPasteSelection):t.reasons.includes(2)?e.raiseError(nm.willRemoveExistingMerge):t.reasons.includes(23)?e.raiseError(nm.wrongFigurePasteOption):t.reasons.includes(78)&&e.raiseError(nm.frozenPaneOverlap))}function lm(e,t,o){const i=e.model.dispatch("PASTE",{target:t,pasteOption:o});am(e,i)}function cm(e,t,o,i){const s=e.model.dispatch("PASTE_FROM_OS_CLIPBOARD",{target:t,text:o,pasteOption:i});am(e,s)}function hm(e,t){const o=qp.getAll().find((t=>t.match(e.type)));if(!o)throw new Error("Unknown chart type.");return o.transformDefinition(e,t)}function dm(e,t){let o=e;e.left!==e.right&&(o={...e,left:e.left+1});const i=[ii(o)],r=t.getActiveSheetId(),n=t.getCell({sheetId:r,col:e.left,row:e.top});if(1===yi(e)&&n?.content)return{type:"scorecard",title:"",background:n.style?.fillColor||void 0,keyValue:ii(e),baselineMode:re,baselineColorUp:ne,baselineColorDown:ae};let a="";const l=t.getEvaluatedCellsInZone(r,{...o,bottom:o.top}),c=!!l.find((e=>e.type!==ls.empty&&e.type!==ls.number));if(c){const e=l.filter((e=>e.type!==ls.error&&e.type!==ls.empty)).map((e=>e.formattedValue)),t=e.splice(-1)[0];a=e.join(", "),t&&(a+=(a?" "+s("and")+" ":"")+t)}let h;e.left!==e.right&&(h=ii({...e,right:e.left}));const d=o.right===o.left?"none":"top";return kp(h?t.getRangeFromSheetXC(r,h):void 0,t)?{title:a,dataSets:i,labelsAsText:!1,stacked:!1,aggregated:!1,cumulative:!1,labelRange:h,type:"line",dataSetsHaveTitle:c,verticalAxisPosition:"left",legendPosition:d}:{title:a,dataSets:i,labelRange:h,type:"bar",stacked:!1,aggregated:!1,dataSetsHaveTitle:c,verticalAxisPosition:"left",legendPosition:d}}function um(e,t){e.model.dispatch("SET_FORMATTING",{sheetId:e.model.getters.getActiveSheetId(),target:e.model.getters.getSelectedZones(),format:t})}function gm(e,t){e.model.dispatch("SET_FORMATTING",{sheetId:e.model.getters.getActiveSheetId(),target:e.model.getters.getSelectedZones(),style:t})}const pm=async e=>mm(e,"onlyValue");async function mm(e,t){const o=e.model.getters.getClipboardTextContent(),i=await e.clipboard.readText();switch(i.status){case"ok":const s=e.model.getters.getSelectedZones();i&&i.content!==o?cm(e,s,i.content,t):lm(e,s,t),e.model.getters.isCutOperation()&&"onlyValue"!==t&&await e.clipboard.write({[cs.PlainText]:""});break;case"notImplemented":e.raiseError(r("Pasting from the context menu is not supported in this browser. Use keyboard shortcuts ctrl+c / ctrl+v instead."));break;case"permissionDenied":e.raiseError(r("Access to the clipboard denied by the browser. Please enable clipboard permission for this page in your browser settings."))}}const fm=(e,t)=>{const o=t.model.getters.getActiveSheetId(),i=t.model.getters.getElementsFromSelection(e),s=t.model.getters.checkElementsIncludeAllVisibleHeaders(o,e,i),r=t.model.getters.checkElementsIncludeAllNonFrozenHeaders(o,e,i);return!s&&!r},bm=e=>{const t=e.model.getters.getActiveRows();let o,i;if(t.size)o=tt([...t]),i=t.size;else{const t=e.model.getters.getSelectedZones()[0];o=t.top,i=t.bottom-t.top+1}e.model.dispatch("ADD_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),position:"before",base:o,quantity:i,dimension:"ROW"})},vm=e=>{const t=e.model.getters.getActiveCols();let o,i;if(t.size)o=tt([...t]),i=t.size;else{const t=e.model.getters.getSelectedZones()[0];o=t.left,i=t.right-t.left+1}e.model.dispatch("ADD_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),position:"before",dimension:"COL",base:o,quantity:i})},Sm=e=>{const t=e.model.getters.getActiveCols();let o,i;if(t.size)o=et([...t]),i=t.size;else{const t=e.model.getters.getSelectedZones()[0];o=t.right,i=t.right-t.left+1}e.model.dispatch("ADD_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),position:"after",dimension:"COL",base:o,quantity:i})};const Cm=async e=>{if(e.imageProvider){const t=e.model.getters.getActiveSheetId(),o=e.model.uuidGenerator.uuidv4(),i=await async function(e){try{return await e.imageProvider.requestImage()}catch{return void e.raiseError(r("An unexpected error occurred during the image transfer"))}}(e);if(!i)throw new Error("No image provider was given to the environment");const s=Kp(e.model.getters,i.size),n=function(e,t){const{x:o,y:i}=e.getMainViewportCoordinates(),{scrollX:s,scrollY:r}=e.getActiveSheetScrollInfo(),n=e.getSheetViewDimension(),a=e.getVisibleRect(e.getActiveMainViewport()),l=Math.min(a.width,n.width-o),c=Math.min(a.height,n.height-i);return{x:o+s+Math.max(0,(l-t.width)/2),y:i+r+Math.max(0,(c-t.height)/2)}}(e.model.getters,s);e.model.dispatch("CREATE_IMAGE",{sheetId:t,figureId:o,position:n,size:s,definition:i})}},Em=e=>um(e,"0.00%"),wm=e=>{let{col:t,row:o}=e.model.getters.getActivePosition();e.model.dispatch("OPEN_CELL_POPOVER",{col:t,row:o,popoverType:"LinkEditor"})},xm=e=>{const t=e.model.getters.getActiveSheetId(),o=e.model.getters.getSelectedZones();return e.model.getters.doesZonesContainFilter(t,o)},ym=e=>1===e.model.getters.getSelectedZones().length,Im=(e,t)=>{if(!ym(e))return!1;const o="COL"===t?e.model.getters.getActiveCols():e.model.getters.getActiveRows(),i="COL"===t?e.model.getters.getActiveRows():e.model.getters.getActiveCols(),s=e.model.getters.getActiveSheetId(),r=hi(e.model.getters.getSelectedZone(),e.model.getters.getSheetZone(s));return function(e){const t=Array.from(e).sort(((e,t)=>e-t));for(let e=1;e<t.length;e++)if(t[e]-t[e-1]!=1)return!1;return!0}(o)&&(0===i.size||r)},Rm={name:r("Undo"),description:"Ctrl+Z",execute:e=>e.model.dispatch("REQUEST_UNDO"),isEnabled:e=>e.model.getters.canUndo(),icon:"o-spreadsheet-Icon.UNDO"},Tm={name:r("Redo"),description:"Ctrl+Y",execute:e=>e.model.dispatch("REQUEST_REDO"),isEnabled:e=>e.model.getters.canRedo(),icon:"o-spreadsheet-Icon.REDO"},Am={name:r("Copy"),description:"Ctrl+C",isReadonlyAllowed:!0,execute:async e=>{e.model.dispatch("COPY"),await e.clipboard.write(e.model.getters.getClipboardContent())},icon:"o-spreadsheet-Icon.COPY"},Om={name:r("Cut"),description:"Ctrl+X",execute:async e=>{sm(e),await e.clipboard.write(e.model.getters.getClipboardContent())},icon:"o-spreadsheet-Icon.CUT"},Mm={name:r("Paste"),description:"Ctrl+V",execute:async e=>mm(e),icon:"o-spreadsheet-Icon.PASTE"},Nm={name:r("Paste special"),isVisible:e=>!e.model.getters.isCutOperation(),icon:"o-spreadsheet-Icon.PASTE"},_m={name:r("Paste value only"),description:"Ctrl+Shift+V",execute:pm},Fm={name:r("Paste format only"),execute:e=>mm(e,"onlyFormat")},Dm={name:r("Find and replace"),description:"Ctrl+H",isReadonlyAllowed:!0,execute:e=>{e.openSidePanel("FindAndReplace",{})},icon:"o-spreadsheet-Icon.FIND_AND_REPLACE"},Lm={name:r("Delete values"),execute:e=>e.model.dispatch("DELETE_CONTENT",{sheetId:e.model.getters.getActiveSheetId(),target:e.model.getters.getSelectedZones()})},Pm={name:e=>{if(e.model.getters.getSelectedZones().length>1)return r("Delete rows");let t,o;const i=e.model.getters.getActiveRows();if(0!==i.size)t=tt([...i]),o=et([...i]);else{const i=e.model.getters.getSelectedZones()[0];t=i.top,o=i.bottom}return t===o?r("Delete row %s",(t+1).toString()):r("Delete rows %s - %s",(t+1).toString(),(o+1).toString())},execute:e=>{let t=[...e.model.getters.getActiveRows()];if(!t.length){const o=e.model.getters.getSelectedZones()[0];for(let e=o.top;e<=o.bottom;e++)t.push(e)}e.model.dispatch("REMOVE_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),dimension:"ROW",elements:t})},isVisible:e=>fm("ROW",e)},km={...Pm,isVisible:ym},Um={name:e=>{if(e.model.getters.getSelectedZones().length>1)return r("Clear rows");let t,o;const i=e.model.getters.getActiveRows();if(0!==i.size)t=tt([...i]),o=et([...i]);else{const i=e.model.getters.getSelectedZones()[0];t=i.top,o=i.bottom}return t===o?r("Clear row %s",(t+1).toString()):r("Clear rows %s - %s",(t+1).toString(),(o+1).toString())},execute:e=>{const t=e.model.getters.getActiveSheetId(),o=[...e.model.getters.getActiveRows()].map((o=>e.model.getters.getRowsZone(t,o,o)));e.model.dispatch("DELETE_CONTENT",{target:o,sheetId:e.model.getters.getActiveSheetId()})}},Vm={name:e=>{if(e.model.getters.getSelectedZones().length>1)return r("Delete columns");let t,o;const i=e.model.getters.getActiveCols();if(0!==i.size)t=tt([...i]),o=et([...i]);else{const i=e.model.getters.getSelectedZones()[0];t=i.left,o=i.right}return t===o?r("Delete column %s",bt(t)):r("Delete columns %s - %s",bt(t),bt(o))},execute:e=>{let t=[...e.model.getters.getActiveCols()];if(!t.length){const o=e.model.getters.getSelectedZones()[0];for(let e=o.left;e<=o.right;e++)t.push(e)}e.model.dispatch("REMOVE_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),dimension:"COL",elements:t})},isVisible:e=>fm("COL",e)},Bm={...Vm,isVisible:ym},zm={name:e=>{if(e.model.getters.getSelectedZones().length>1)return r("Clear columns");let t,o;const i=e.model.getters.getActiveCols();if(0!==i.size)t=tt([...i]),o=et([...i]);else{const i=e.model.getters.getSelectedZones()[0];t=i.left,o=i.right}return t===o?r("Clear column %s",bt(t)):r("Clear columns %s - %s",bt(t),bt(o))},execute:e=>{const t=e.model.getters.getActiveSheetId(),o=[...e.model.getters.getActiveCols()].map((o=>e.model.getters.getColsZone(t,o,o)));e.model.dispatch("DELETE_CONTENT",{target:o,sheetId:e.model.getters.getActiveSheetId()})}},Hm={name:r("Delete cells"),isVisible:ym},$m={name:r("Delete cell and shift up"),execute:e=>{const t=e.model.getters.getSelectedZone(),o=e.model.dispatch("DELETE_CELL",{zone:t,shiftDimension:"ROW"});am(e,o)}},Wm={name:r("Delete cell and shift left"),execute:e=>{const t=e.model.getters.getSelectedZone(),o=e.model.dispatch("DELETE_CELL",{zone:t,shiftDimension:"COL"});am(e,o)}},Gm={name:r("Merge cells"),isEnabled:e=>!qm(e),isActive:e=>Zm(e),execute:e=>function(e){if(qm(e))return;const t=e.model.getters.getSelectedZones(),o=[t[t.length-1]],i=e.model.getters.getActiveSheetId();Zm(e)?e.model.dispatch("REMOVE_MERGE",{sheetId:i,target:o}):function(e,t,o){const i=e.model.dispatch("ADD_MERGE",{sheetId:t,target:o});i.isCancelledBecause(83)?e.raiseError(rm.MergeInFilter):i.isCancelledBecause(3)&&e.askConfirmation(rm.MergeIsDestructive,(()=>{e.model.dispatch("ADD_MERGE",{sheetId:t,target:o,force:!0})}))}(e,i,o)}(e),icon:"o-spreadsheet-Icon.MERGE_CELL"};function qm(e){const t=e.model.getters.getSelectedZones(),{top:o,left:i,right:s,bottom:r}=e.model.getters.getSelectedZone(),{sheetId:n}=e.model.getters.getActivePosition(),{xSplit:a,ySplit:l}=e.model.getters.getPaneDivisions(n);return t.length>1||o===r&&i===s||i<a&&a<=s||o<l&&l<=r}function Zm(e){if(!qm(e)){const t=e.model.getters.getSelectedZones(),{col:o,row:i,sheetId:s}=e.model.getters.getActivePosition(),r=e.model.getters.expandZone(s,wi({col:o,row:i}));return hi(t[0],r)}return!1}var Ym=Object.freeze({__proto__:null,undo:Rm,redo:Tm,copy:Am,cut:Om,paste:Mm,pasteSpecial:Nm,pasteSpecialValue:_m,pasteSpecialFormat:Fm,findAndReplace:Dm,deleteValues:Lm,deleteRows:Pm,deleteRow:km,clearRows:Um,deleteCols:Vm,deleteCol:Bm,clearCols:zm,deleteCells:Hm,deleteCellShiftUp:$m,deleteCellShiftLeft:Wm,mergeCells:Gm});const jm={name:e=>{const t=xf(e);return 1===t?r("Insert row"):r("Insert %s rows",t.toString())},isVisible:e=>Im(e,"ROW"),icon:"o-spreadsheet-Icon.INSERT_ROW"},Xm={name:e=>{const t=xf(e);return 1===t?r("Insert row above"):r("Insert %s rows above",t.toString())},execute:bm,isVisible:e=>Im(e,"ROW"),icon:"o-spreadsheet-Icon.INSERT_ROW_BEFORE"},Km={...Xm,name:e=>{const t=xf(e);return 1===t?r("Row above"):r("%s Rows above",t.toString())}},Qm={...Xm,name:e=>{const t=xf(e);return 1===t?r("Insert row"):r("Insert %s rows",t.toString())},isVisible:ym,icon:"o-spreadsheet-Icon.INSERT_ROW_BEFORE"},Jm={execute:e=>{const t=e.model.getters.getActiveRows();let o,i;if(t.size)o=et([...t]),i=t.size;else{const t=e.model.getters.getSelectedZones()[0];o=t.bottom,i=t.bottom-t.top+1}e.model.dispatch("ADD_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),position:"after",base:o,quantity:i,dimension:"ROW"})},name:e=>{const t=xf(e);return 1===t?r("Insert row below"):r("Insert %s rows below",t.toString())},isVisible:e=>Im(e,"ROW"),icon:"o-spreadsheet-Icon.INSERT_ROW_AFTER"},ef={...Jm,name:e=>{const t=xf(e);return 1===t?r("Row below"):r("%s Rows below",t.toString())}},tf={name:e=>{const t=yf(e);return 1===t?r("Insert column"):r("Insert %s columns",t.toString())},isVisible:e=>Im(e,"COL"),icon:"o-spreadsheet-Icon.INSERT_COL"},of={name:e=>{const t=yf(e);return 1===t?r("Insert column left"):r("Insert %s columns left",t.toString())},execute:vm,isVisible:e=>Im(e,"COL"),icon:"o-spreadsheet-Icon.INSERT_COL_BEFORE"},sf={...of,name:e=>{const t=yf(e);return 1===t?r("Column left"):r("%s Columns left",t.toString())}},rf={...of,name:e=>{const t=yf(e);return 1===t?r("Insert column"):r("Insert %s columns",t.toString())},isVisible:ym,icon:"o-spreadsheet-Icon.INSERT_COL_BEFORE"},nf={name:e=>{const t=yf(e);return 1===t?r("Insert column right"):r("Insert %s columns right",t.toString())},execute:Sm,isVisible:e=>Im(e,"COL"),icon:"o-spreadsheet-Icon.INSERT_COL_AFTER"},af={...nf,name:e=>{const t=yf(e);return 1===t?r("Column right"):r("%s Columns right",t.toString())},execute:Sm},lf={name:r("Insert cells"),isVisible:e=>ym(e)&&0===e.model.getters.getActiveCols().size&&0===e.model.getters.getActiveRows().size,icon:"o-spreadsheet-Icon.INSERT_CELL"},cf={name:r("Insert cells and shift down"),execute:e=>{const t=e.model.getters.getSelectedZone(),o=e.model.dispatch("INSERT_CELL",{zone:t,shiftDimension:"ROW"});am(e,o)},isVisible:e=>0===e.model.getters.getActiveRows().size&&0===e.model.getters.getActiveCols().size,icon:"o-spreadsheet-Icon.INSERT_CELL_SHIFT_DOWN"},hf={name:r("Insert cells and shift right"),execute:e=>{const t=e.model.getters.getSelectedZone(),o=e.model.dispatch("INSERT_CELL",{zone:t,shiftDimension:"COL"});am(e,o)},isVisible:e=>0===e.model.getters.getActiveRows().size&&0===e.model.getters.getActiveCols().size,icon:"o-spreadsheet-Icon.INSERT_CELL_SHIFT_RIGHT"},df={name:r("Chart"),execute:e=>{const t=e.model.getters,o=e.model.uuidGenerator.uuidv4(),i=t.getActiveSheetId();1===yi(e.model.getters.getSelectedZone())&&e.model.selection.selectTableAroundSelection();const s={width:536,height:335},r=function(e,t){const{x:o,y:i}=e.getMainViewportCoordinates(),{scrollX:s,scrollY:r}=e.getActiveSheetScrollInfo(),{width:n,height:a}=e.getVisibleRect(e.getActiveMainViewport());return{x:o+s+Math.max(0,(n-t.width)/2),y:i+r+Math.max(0,(a-t.height)/2)}}(t,s);e.model.dispatch("CREATE_CHART",{sheetId:i,id:o,position:r,size:s,definition:dm(e.model.getters.getSelectedZone(),e.model.getters)}).isSuccessful&&(e.model.dispatch("SELECT_FIGURE",{id:o}),e.openSidePanel("ChartPanel"))},icon:"o-spreadsheet-Icon.INSERT_CHART"},uf={name:r("Image"),description:"Ctrl+O",execute:Cm,isVisible:e=>void 0!==e.imageProvider,icon:"o-spreadsheet-Icon.INSERT_IMAGE"},gf={name:r("Function"),icon:"o-spreadsheet-Icon.SHOW_HIDE_FORMULA"},pf={name:r("SUM"),execute:e=>e.startCellEdition("=SUM(")},mf={name:r("AVERAGE"),execute:e=>e.startCellEdition("=AVERAGE(")},ff={name:r("COUNT"),execute:e=>e.startCellEdition("=COUNT(")},bf={name:r("MAX"),execute:e=>e.startCellEdition("=MAX(")},vf={name:r("MIN"),execute:e=>e.startCellEdition("=MIN(")},Sf={name:r("All"),children:[function(){return wf(fu.getKeys().filter((e=>!fu.get(e).hidden)))}]};const Cf={name:r("Link"),execute:wm,icon:"o-spreadsheet-Icon.INSERT_LINK"},Ef={name:r("Insert sheet"),execute:e=>{const t=e.model.getters.getActiveSheetId(),o=e.model.getters.getSheetIds().indexOf(t)+1,i=e.model.uuidGenerator.uuidv4();e.model.dispatch("CREATE_SHEET",{sheetId:i,position:o}),e.model.dispatch("ACTIVATE_SHEET",{sheetIdFrom:t,sheetIdTo:i})},icon:"o-spreadsheet-Icon.INSERT_SHEET"};function wf(e){return e.sort().map(((e,t)=>({name:e,sequence:10*t,execute:t=>t.startCellEdition(`=${e}(`)})))}function xf(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 yf(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}}const If=new Ug;If.add("cut",{...Om,sequence:10}).add("copy",{...Am,sequence:20}).add("paste",{...Mm,sequence:30}).add("paste_special",{...Nm,sequence:40,separator:!0}).addChild("paste_value_only",["paste_special"],{..._m,sequence:10}).addChild("paste_format_only",["paste_special"],{...Fm,sequence:20}).add("add_row_before",{...Qm,sequence:70}).add("add_column_before",{...rf,sequence:90}).add("insert_cell",{...lf,sequence:100,separator:!0}).addChild("insert_cell_down",["insert_cell"],{...cf,name:r("Shift down"),sequence:10}).addChild("insert_cell_right",["insert_cell"],{...hf,name:r("Shift right"),sequence:20}).add("delete_row",{...km,sequence:110,icon:"o-spreadsheet-Icon.DELETE"}).add("delete_column",{...Bm,sequence:120,icon:"o-spreadsheet-Icon.DELETE"}).add("delete_cell",{...Hm,sequence:130,separator:!0,icon:"o-spreadsheet-Icon.DELETE"}).addChild("delete_cell_up",["delete_cell"],{...$m,name:r("Shift up"),sequence:10,icon:"o-spreadsheet-Icon.DELETE_CELL_SHIFT_UP"}).addChild("delete_cell_left",["delete_cell"],{...Wm,name:r("Shift left"),sequence:20,icon:"o-spreadsheet-Icon.DELETE_CELL_SHIFT_LEFT"}).add("insert_link",{...Cf,name:e=>{const t=e.model.getters.getActiveSheetId(),{col:o,row:i}=e.model.getters.getActivePosition(),s=e.model.getters.getEvaluatedCell({sheetId:t,col:o,row:i});return s&&s.link?r("Edit link"):r("Insert link")},sequence:150,separator:!0});const Rf=[ls.number,ls.error,ls.text,ls.boolean];function Tf(e,t,o,i,s){let n=fs.Success,a=i.right>i.left;if(e.model.getters.doesIntersectMerge(t,i)){let o;a=!1;for(let s=i.top;s<=i.bottom;s++){o=[];for(let r=i.left;r<=i.right;r++){let i=e.model.getters.getMerge({sheetId:t,col:r,row:s});i&&!o.includes(i.id.toString())&&o.push(i.id.toString())}if(o.length>=2){a=!0;break}}}const{col:l,row:c}=o;if(a)n=e.model.dispatch("SORT_CELLS",{sheetId:t,col:l,row:c,zone:i,sortDirection:s});else{const o=e.model.getters.getContiguousZone(t,i);hi(o,i)?n=e.model.dispatch("SORT_CELLS",{sheetId:t,col:l,row:c,zone:i,sortDirection:s}):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?"),(()=>{i=o,n=e.model.dispatch("SORT_CELLS",{sheetId:t,col:l,row:c,zone:i,sortDirection:s})}),(()=>{n=e.model.dispatch("SORT_CELLS",{sheetId:t,col:l,row:c,zone:i,sortDirection:s})}))}if(n.isCancelledBecause(66)){const{col:t,row:s}=o;e.model.selection.selectZone({cell:{col:t,row:s},zone:i}),e.raiseError(r("Cannot sort. To sort, select only cells or only merges that have the same size."))}}const Af={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 Of(e,t,o){const i=e.model.dispatch("CREATE_FILTER_TABLE",{target:o,sheetId:t});i.isCancelledBecause(81)?e.raiseError(Af.filterOverlap):i.isCancelledBecause(83)?e.raiseError(Af.mergeInFilter):i.isCancelledBecause(84)&&e.raiseError(Af.nonContinuousTargets)}const Mf={name:r("Sort range"),isVisible:ym,icon:"o-spreadsheet-Icon.SORT_RANGE"},Nf={name:r("Ascending (A ⟶ Z)"),execute:e=>{const{anchor:t,zones:o}=e.model.getters.getSelection(),i=e.model.getters.getActiveSheetId();Tf(e,i,t.cell,o[0],"ascending")},icon:"o-spreadsheet-Icon.SORT_ASCENDING"},_f={name:r("Descending (Z ⟶ A)"),execute:e=>{const{anchor:t,zones:o}=e.model.getters.getSelection(),i=e.model.getters.getActiveSheetId();Tf(e,i,t.cell,o[0],"descending")},icon:"o-spreadsheet-Icon.SORT_DESCENDING"},Ff={name:r("Create filter"),execute:e=>{const t=e.model.getters.getActiveSheetId(),o=e.model.getters.getSelection().zones;Of(e,t,o)},isVisible:e=>!xm(e),isEnabled:e=>Ii(...e.model.getters.getSelectedZones()),icon:"o-spreadsheet-Icon.MENU_FILTER_ICON"},Df={name:r("Remove filter"),execute:e=>{const t=e.model.getters.getActiveSheetId();e.model.dispatch("REMOVE_FILTER_TABLE",{sheetId:t,target:e.model.getters.getSelectedZones()})},isVisible:xm,icon:"o-spreadsheet-Icon.MENU_FILTER_ICON"},Lf={name:r("Split text to columns"),sequence:1,execute:e=>e.openSidePanel("SplitToColumns",{}),isEnabled:e=>e.model.getters.isSingleColSelected(),icon:"o-spreadsheet-Icon.SPLIT_TEXT"},Pf={name:r("Automatic"),execute:e=>um(e,""),isActive:e=>function(e){const t=e.model.getters.getCell(e.model.getters.getActivePosition());return!t||!t.format}(e)},kf={name:r("Number"),description:e=>fo(1000.12,{format:"#,##0.00",locale:e.model.getters.getLocale()}),execute:e=>um(e,"#,##0.00"),isActive:e=>vb(e,"#,##0.00")},Uf={name:r("Format as percent"),execute:Em,icon:"o-spreadsheet-Icon.PERCENT"},Vf={name:r("Percent"),description:e=>fo(.1012,{format:"0.00%",locale:e.model.getters.getLocale()}),execute:Em,isActive:e=>vb(e,"0.00%")},Bf={name:r("Currency"),description:e=>fo(1000.12,{format:e.model.config.defaultCurrencyFormat,locale:e.model.getters.getLocale()}),execute:e=>um(e,e.model.config.defaultCurrencyFormat),isActive:e=>vb(e,e.model.config.defaultCurrencyFormat)},zf={name:r("Currency rounded"),description:e=>fo(1e3,{format:Fo(e.model.config.defaultCurrencyFormat),locale:e.model.getters.getLocale()}),execute:e=>um(e,Fo(e.model.config.defaultCurrencyFormat)),isActive:e=>vb(e,Fo(e.model.config.defaultCurrencyFormat)),isVisible:e=>{const t=e.model.config.defaultCurrencyFormat;return t!==Fo(t)}},Hf={name:r("Custom currency"),isVisible:e=>void 0!==e.loadCurrencies,execute:e=>e.openSidePanel("CustomCurrency",{})},$f={name:r("Date"),description:e=>{const t=e.model.getters.getLocale();return fo(ir("9/26/2023",eo),{format:t.dateFormat,locale:t})},execute:e=>um(e,e.model.getters.getLocale().dateFormat),isActive:e=>vb(e,e.model.getters.getLocale().dateFormat)},Wf={name:r("Time"),description:e=>{const t=e.model.getters.getLocale();return fo(ir("9/26/2023 10:43:00 PM",eo),{format:t.timeFormat,locale:t})},execute:e=>um(e,e.model.getters.getLocale().timeFormat),isActive:e=>vb(e,e.model.getters.getLocale().timeFormat)},Gf={name:r("Date time"),description:e=>{const t=e.model.getters.getLocale();return fo(ir("9/26/2023 22:43:00",eo),{format:t.dateFormat+" "+t.timeFormat,locale:t})},execute:e=>{const t=e.model.getters.getLocale();um(e,t.dateFormat+" "+t.timeFormat)},isActive:e=>{const t=e.model.getters.getLocale();return vb(e,t.dateFormat+" "+t.timeFormat)}},qf={name:r("Duration"),description:"27:51:38",execute:e=>um(e,"hhhh:mm:ss"),isActive:e=>vb(e,"hhhh:mm:ss")},Zf={name:r("Increase decimal places"),icon:"o-spreadsheet-Icon.INCREASE_DECIMAL",execute:e=>e.model.dispatch("SET_DECIMAL",{sheetId:e.model.getters.getActiveSheetId(),target:e.model.getters.getSelectedZones(),step:1})},Yf={name:r("Decrease decimal places"),icon:"o-spreadsheet-Icon.DECRASE_DECIMAL",execute:e=>e.model.dispatch("SET_DECIMAL",{sheetId:e.model.getters.getActiveSheetId(),target:e.model.getters.getSelectedZones(),step:-1})},jf={name:r("Bold"),description:"Ctrl+B",execute:e=>gm(e,{bold:!e.model.getters.getCurrentStyle().bold}),icon:"o-spreadsheet-Icon.BOLD",isActive:e=>!!e.model.getters.getCurrentStyle().bold},Xf={name:r("Italic"),description:"Ctrl+I",execute:e=>gm(e,{italic:!e.model.getters.getCurrentStyle().italic}),icon:"o-spreadsheet-Icon.ITALIC",isActive:e=>!!e.model.getters.getCurrentStyle().italic},Kf={name:r("Underline"),description:"Ctrl+U",execute:e=>gm(e,{underline:!e.model.getters.getCurrentStyle().underline}),icon:"o-spreadsheet-Icon.UNDERLINE",isActive:e=>!!e.model.getters.getCurrentStyle().underline},Qf={name:r("Strikethrough"),execute:e=>gm(e,{strikethrough:!e.model.getters.getCurrentStyle().strikethrough}),icon:"o-spreadsheet-Icon.STRIKE",isActive:e=>!!e.model.getters.getCurrentStyle().strikethrough},Jf={name:r("Font size"),children:be.map((e=>({name:e.toString(),sequence:e,id:`font_size_${e}`,execute:t=>gm(t,{fontSize:e}),isActive:t=>function(e,t){const o=e.model.getters.getCurrentStyle().fontSize||Z;return o===t}(t,e)}))),icon:"o-spreadsheet-Icon.FONT_SIZE"},eb={name:r("Alignment"),icon:"o-spreadsheet-Icon.ALIGN_LEFT"},tb={name:r("Horizontal align"),icon:e=>function(e){switch(Sb(e)){case"right":return"o-spreadsheet-Icon.ALIGN_RIGHT";case"center":return"o-spreadsheet-Icon.ALIGN_CENTER";default:return"o-spreadsheet-Icon.ALIGN_LEFT"}}(e)},ob={name:r("Left"),description:"Ctrl+Shift+L",execute:e=>gm(e,{align:"left"}),isActive:e=>"left"===Sb(e),icon:"o-spreadsheet-Icon.ALIGN_LEFT"},ib={name:r("Center"),description:"Ctrl+Shift+E",execute:e=>gm(e,{align:"center"}),isActive:e=>"center"===Sb(e),icon:"o-spreadsheet-Icon.ALIGN_CENTER"},sb={name:r("Right"),description:"Ctrl+Shift+R",execute:e=>gm(e,{align:"right"}),isActive:e=>"right"===Sb(e),icon:"o-spreadsheet-Icon.ALIGN_RIGHT"},rb={name:r("Vertical align"),icon:e=>function(e){switch(Cb(e)){case"top":return"o-spreadsheet-Icon.ALIGN_TOP";case"middle":return"o-spreadsheet-Icon.ALIGN_MIDDLE";default:return"o-spreadsheet-Icon.ALIGN_BOTTOM"}}(e)},nb={name:r("Top"),execute:e=>gm(e,{verticalAlign:"top"}),isActive:e=>"top"===Cb(e),icon:"o-spreadsheet-Icon.ALIGN_TOP"},ab={name:r("Middle"),execute:e=>gm(e,{verticalAlign:"middle"}),isActive:e=>"middle"===Cb(e),icon:"o-spreadsheet-Icon.ALIGN_MIDDLE"},lb={name:r("Bottom"),execute:e=>gm(e,{verticalAlign:"bottom"}),isActive:e=>"bottom"===Cb(e),icon:"o-spreadsheet-Icon.ALIGN_BOTTOM"},cb={name:r("Wrapping"),icon:"o-spreadsheet-Icon.WRAPPING_OVERFLOW"},hb={name:r("Wrapping"),icon:e=>function(e){switch(Eb(e)){case"wrap":return"o-spreadsheet-Icon.WRAPPING_WRAP";case"clip":return"o-spreadsheet-Icon.WRAPPING_CLIP";default:return"o-spreadsheet-Icon.WRAPPING_OVERFLOW"}}(e)},db={name:r("Overflow"),execute:e=>gm(e,{wrapping:"overflow"}),isActive:e=>"overflow"===Eb(e),icon:"o-spreadsheet-Icon.WRAPPING_OVERFLOW"},ub={name:r("Wrap"),execute:e=>gm(e,{wrapping:"wrap"}),isActive:e=>"wrap"===Eb(e),icon:"o-spreadsheet-Icon.WRAPPING_WRAP"},gb={name:r("Clip"),execute:e=>gm(e,{wrapping:"clip"}),isActive:e=>"clip"===Eb(e),icon:"o-spreadsheet-Icon.WRAPPING_CLIP"},pb={name:r("Text Color"),icon:"o-spreadsheet-Icon.TEXT_COLOR"},mb={name:r("Fill Color"),icon:"o-spreadsheet-Icon.FILL_COLOR"},fb={name:r("Conditional formatting"),execute:e=>{e.openSidePanel("ConditionalFormatting",{selection:e.model.getters.getSelectedZones()})},icon:"o-spreadsheet-Icon.CONDITIONAL_FORMAT"},bb={name:r("Clear formatting"),description:"Ctrl+<",execute:e=>e.model.dispatch("CLEAR_FORMATTING",{sheetId:e.model.getters.getActiveSheetId(),target:e.model.getters.getSelectedZones()}),icon:"o-spreadsheet-Icon.CLEAR_FORMAT"};function vb(e,t){return e.model.getters.getCell(e.model.getters.getActivePosition())?.format===t}function Sb(e){const t=e.model.getters.getCurrentStyle();if(t.align)return t.align;return e.model.getters.getActiveCell().defaultAlign}function Cb(e){const t=e.model.getters.getCurrentStyle();return t.verticalAlign?t.verticalAlign:j}function Eb(e){const t=e.model.getters.getCurrentStyle();return t.wrapping?t.wrapping:X}var wb=Object.freeze({__proto__:null,formatNumberAutomatic:Pf,formatNumberNumber:kf,formatPercent:Uf,formatNumberPercent:Vf,formatNumberCurrency:Bf,formatNumberCurrencyRounded:zf,formatCustomCurrency:Hf,formatNumberDate:$f,formatNumberTime:Wf,formatNumberDateTime:Gf,formatNumberDuration:qf,incraseDecimalPlaces:Zf,decraseDecimalPlaces:Yf,formatBold:jf,formatItalic:Xf,formatUnderline:Kf,formatStrikethrough:Qf,formatFontSize:Jf,formatAlignment:eb,formatAlignmentHorizontal:tb,formatAlignmentLeft:ob,formatAlignmentCenter:ib,formatAlignmentRight:sb,formatAlignmentVertical:rb,formatAlignmentTop:nb,formatAlignmentMiddle:ab,formatAlignmentBottom:lb,formatWrappingIcon:cb,formatWrapping:hb,formatWrappingOverflow:db,formatWrappingWrap:ub,formatWrappingClip:gb,textColor:pb,fillColor:mb,formatCF:fb,clearFormat:bb});function xb(e,t,o){const i=e.model.getters.getActiveSheetId(),s="COL"===t?"FREEZE_COLUMNS":"FREEZE_ROWS";e.model.dispatch(s,{sheetId:i,quantity:o}).isCancelledBecause(68)&&e.raiseError(pp)}const yb={name:e=>{const t=e.model.getters.getElementsFromSelection("COL");let o=t[0],i=t[t.length-1];return 1===t.length?r("Hide column %s",bt(o).toString()):i-o+1===t.length?r("Hide columns %s - %s",bt(o).toString(),bt(i).toString()):r("Hide columns")},execute: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(),o=e.model.getters.getElementsFromSelection("COL");return!e.model.getters.checkElementsIncludeAllVisibleHeaders(t,"COL",o)},icon:"o-spreadsheet-Icon.HIDE_COL"},Ib={name:r("Unhide columns"),execute: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)))}},Rb={name:r("Unhide all columns"),execute: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},Tb={name:e=>{const t=e.model.getters.getElementsFromSelection("ROW");let o=t[0],i=t[t.length-1];return 1===t.length?r("Hide row %s",(o+1).toString()):i-o+1===t.length?r("Hide rows %s - %s",(o+1).toString(),(i+1).toString()):r("Hide rows")},execute: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(),o=e.model.getters.getElementsFromSelection("ROW");return!e.model.getters.checkElementsIncludeAllVisibleHeaders(t,"ROW",o)},icon:"o-spreadsheet-Icon.HIDE_ROW"},Ab={name:r("Unhide rows"),execute: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)))}},Ob={name:r("Unhide all rows"),execute: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},Mb={name:r("Unfreeze"),isVisible:e=>{const{xSplit:t,ySplit:o}=e.model.getters.getPaneDivisions(e.model.getters.getActiveSheetId());return t+o>0},execute:e=>e.model.dispatch("UNFREEZE_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId()}),icon:"o-spreadsheet-Icon.UNFREEZE"},Nb={name:r("Freeze"),icon:"o-spreadsheet-Icon.FREEZE"},_b={name:r("No rows"),execute:e=>e.model.dispatch("UNFREEZE_ROWS",{sheetId:e.model.getters.getActiveSheetId()}),isReadonlyAllowed:!0,isVisible:e=>!!e.model.getters.getPaneDivisions(e.model.getters.getActiveSheetId()).ySplit},Fb={name:r("1 row"),execute:e=>xb(e,"ROW",1),isReadonlyAllowed:!0},Db={name:r("2 rows"),execute:e=>xb(e,"ROW",2),isReadonlyAllowed:!0},Lb={name:r("Up to current row"),execute:e=>{const{bottom:t}=e.model.getters.getSelectedZone();xb(e,"ROW",t+1)},isReadonlyAllowed:!0},Pb={name:r("No columns"),execute:e=>e.model.dispatch("UNFREEZE_COLUMNS",{sheetId:e.model.getters.getActiveSheetId()}),isReadonlyAllowed:!0,isVisible:e=>!!e.model.getters.getPaneDivisions(e.model.getters.getActiveSheetId()).xSplit},kb={name:r("1 column"),execute:e=>xb(e,"COL",1),isReadonlyAllowed:!0},Ub={name:r("2 columns"),execute:e=>xb(e,"COL",2),isReadonlyAllowed:!0},Vb={name:r("Up to current column"),execute:e=>{const{right:t}=e.model.getters.getSelectedZone();xb(e,"COL",t+1)},isReadonlyAllowed:!0},Bb={name:e=>e.model.getters.getGridLinesVisibility(e.model.getters.getActiveSheetId())?r("Hide gridlines"):r("Show gridlines"),execute:e=>{const t=e.model.getters.getActiveSheetId();e.model.dispatch("SET_GRID_LINES_VISIBILITY",{sheetId:t,areGridLinesVisible:!e.model.getters.getGridLinesVisibility(t)})},icon:"o-spreadsheet-Icon.SHOW_HIDE_GRID"},zb={name:e=>e.model.getters.shouldShowFormulas()?r("Hide formulas"):r("Show formulas"),execute:e=>e.model.dispatch("SET_FORMULA_VISIBILITY",{show:!e.model.getters.shouldShowFormulas()}),isReadonlyAllowed:!0,icon:"o-spreadsheet-Icon.SHOW_HIDE_FORMULA"},Hb={name:e=>$b(e)?r("Remove selected filters"):r("Create filter"),isActive:e=>$b(e),isEnabled:e=>!Wb(e),execute:e=>function(e){if($b(e))return void e.model.dispatch("REMOVE_FILTER_TABLE",{sheetId:e.model.getters.getActiveSheetId(),target:e.model.getters.getSelectedZones()});if(Wb(e))return;e.model.selection.selectTableAroundSelection();const t=e.model.getters.getActiveSheetId(),o=e.model.getters.getSelectedZones();Of(e,t,o)}(e),icon:"o-spreadsheet-Icon.FILTER_ICON_INACTIVE"};function $b(e){const t=e.model.getters.getActiveSheetId(),o=e.model.getters.getSelectedZones();return e.model.getters.doesZonesContainFilter(t,o)}function Wb(e){return!Ii(...e.model.getters.getSelectedZones())}var Gb=Object.freeze({__proto__:null,hideCols:yb,unhideCols:Ib,unhideAllCols:Rb,hideRows:Tb,unhideRows:Ab,unhideAllRows:Ob,unFreezePane:Mb,freezePane:Nb,unFreezeRows:_b,freezeFirstRow:Fb,freezeSecondRow:Db,freezeCurrentRow:Lb,unFreezeCols:Pb,freezeFirstCol:kb,freezeSecondCol:Ub,freezeCurrentCol:Vb,viewGridlines:Bb,viewFormulas:zb,createRemoveFilter:Hb});const qb=new Ug;qb.add("cut",{...Om,sequence:10}).add("copy",{...Am,sequence:20}).add("paste",{...Mm,sequence:30}).add("paste_special",{...Nm,sequence:40,separator:!0}).addChild("paste_value_only",["paste_special"],{..._m,sequence:10}).addChild("paste_format_only",["paste_special"],{...Fm,sequence:20}).add("sort_columns",{...Mf,name:e=>e.model.getters.getActiveCols().size>1?r("Sort columns"):r("Sort column"),sequence:50,separator:!0}).addChild("sort_ascending",["sort_columns"],{...Nf,sequence:10}).addChild("sort_descending",["sort_columns"],{..._f,sequence:20}).add("add_column_before",{...of,sequence:70}).add("add_column_after",{...nf,sequence:80}).add("delete_column",{...Vm,sequence:90,icon:"o-spreadsheet-Icon.DELETE"}).add("clear_column",{...zm,sequence:100,icon:"o-spreadsheet-Icon.CLEAR"}).add("hide_columns",{...yb,sequence:105,separator:!0}).add("unhide_columns",{...Ib,sequence:106,separator:!0}).add("conditional_formatting",{...fb,sequence:110});const Zb=new Ug;Zb.add("format_number_automatic",{...Pf,sequence:10,separator:!0}).add("format_number_number",{...kf,sequence:20}).add("format_number_percent",{...Vf,sequence:30,separator:!0}).add("format_number_currency",{...Bf,sequence:40}).add("format_number_currency_rounded",{...zf,sequence:50}).add("format_custom_currency",{...Hf,sequence:60,separator:!0}).add("format_number_date",{...$f,sequence:70}).add("format_number_time",{...Wf,sequence:80}).add("format_number_date_time",{...Gf,sequence:90}).add("format_number_duration",{...qf,sequence:100,separator:!0});const Yb={name:r("More formats"),icon:"o-spreadsheet-Icon.NUMBER_FORMATS",children:[()=>Zb.getAll()]},jb=new Ug;jb.add("cut",{...Om,sequence:10}).add("copy",{...Am,sequence:20}).add("paste",{...Mm,sequence:30}).add("paste_special",{...Nm,sequence:40,separator:!0}).addChild("paste_value_only",["paste_special"],{..._m,sequence:10}).addChild("paste_format_only",["paste_special"],{...Fm,sequence:20}).add("add_row_before",{...Xm,sequence:50}).add("add_row_after",{...Jm,sequence:60}).add("delete_row",{...Pm,sequence:70,icon:"o-spreadsheet-Icon.DELETE"}).add("clear_row",{...Um,sequence:80,icon:"o-spreadsheet-Icon.CLEAR"}).add("hide_rows",{...Tb,sequence:85,separator:!0}).add("unhide_rows",{...Ab,sequence:86,separator:!0}).add("conditional_formatting",{...fb,sequence:90});const Xb=new Ug;Xb.add("file",{name:r("File"),sequence:10}).addChild("settings",["file"],{name:r("Settings"),sequence:100,execute:e=>e.openSidePanel("Settings"),icon:"o-spreadsheet-Icon.COG"}).add("edit",{name:r("Edit"),sequence:20}).addChild("undo",["edit"],{...Rm,sequence:10}).addChild("redo",["edit"],{...Tm,sequence:20,separator:!0}).addChild("copy",["edit"],{...Am,sequence:30}).addChild("cut",["edit"],{...Om,sequence:40}).addChild("paste",["edit"],{...Mm,sequence:50}).addChild("paste_special",["edit"],{...Nm,sequence:60,separator:!0}).addChild("paste_special_value",["edit","paste_special"],{..._m,sequence:10}).addChild("paste_special_format",["edit","paste_special"],{...Fm,sequence:20}).addChild("find_and_replace",["edit"],{...Dm,sequence:65,separator:!0}).addChild("delete",["edit"],{name:r("Delete"),icon:"o-spreadsheet-Icon.DELETE",sequence:70}).addChild("edit_delete_cell_values",["edit","delete"],{...Lm,sequence:10}).addChild("edit_delete_row",["edit","delete"],{...Pm,sequence:20}).addChild("edit_delete_column",["edit","delete"],{...Vm,sequence:30}).addChild("edit_delete_cell_shift_up",["edit","delete"],{...$m,sequence:40}).addChild("edit_delete_cell_shift_left",["edit","delete"],{...Wm,sequence:50}).addChild("edit_unhide_columns",["edit"],{...Rb,sequence:80}).addChild("edit_unhide_rows",["edit"],{...Ob,sequence:80}).add("view",{name:r("View"),sequence:30}).addChild("unfreeze_panes",["view"],{...Mb,sequence:4}).addChild("freeze_panes",["view"],{...Nb,sequence:5,separator:!0}).addChild("unfreeze_rows",["view","freeze_panes"],{..._b,sequence:5}).addChild("freeze_first_row",["view","freeze_panes"],{...Fb,sequence:10}).addChild("freeze_second_row",["view","freeze_panes"],{...Db,sequence:15}).addChild("freeze_current_row",["view","freeze_panes"],{...Lb,sequence:20,separator:!0}).addChild("unfreeze_columns",["view","freeze_panes"],{...Pb,sequence:25}).addChild("freeze_first_col",["view","freeze_panes"],{...kb,sequence:30}).addChild("freeze_second_col",["view","freeze_panes"],{...Ub,sequence:35}).addChild("freeze_current_col",["view","freeze_panes"],{...Vb,sequence:40}).addChild("view_gridlines",["view"],{...Bb,sequence:10}).addChild("view_formulas",["view"],{...zb,sequence:15}).add("insert",{name:r("Insert"),sequence:40}).addChild("insert_row",["insert"],{...jm,sequence:10}).addChild("insert_row_before",["insert","insert_row"],{...Km,sequence:10}).addChild("insert_row_after",["insert","insert_row"],{...ef,sequence:20}).addChild("insert_column",["insert"],{...tf,sequence:20}).addChild("insert_column_before",["insert","insert_column"],{...sf,sequence:10}).addChild("insert_column_after",["insert","insert_column"],{...af,sequence:20}).addChild("insert_cell",["insert"],{...lf,sequence:43}).addChild("insert_cell_down",["insert","insert_cell"],{...cf,name:r("Shift down"),sequence:10}).addChild("insert_cell_right",["insert","insert_cell"],{...hf,name:r("Shift right"),sequence:20}).addChild("insert_sheet",["insert"],{...Ef,sequence:80,separator:!0}).addChild("insert_chart",["insert"],{...df,sequence:50}).addChild("insert_image",["insert"],{...uf,sequence:55}).addChild("insert_function",["insert"],{...gf,sequence:60}).addChild("insert_function_sum",["insert","insert_function"],{...pf,sequence:0}).addChild("insert_function_average",["insert","insert_function"],{...mf,sequence:10}).addChild("insert_function_count",["insert","insert_function"],{...ff,sequence:20}).addChild("insert_function_max",["insert","insert_function"],{...bf,sequence:30}).addChild("insert_function_min",["insert","insert_function"],{...vf,sequence:40,separator:!0}).addChild("categorie_function_all",["insert","insert_function"],{...Sf,sequence:50}).addChild("categories_function_list",["insert","insert_function"],(()=>{const e=fu.content;return[...new Set(fu.getAll().filter((e=>!e.hidden)).map((e=>e.category)))].filter(ke).sort().map(((t,o)=>{const i=Object.keys(e).filter((o=>e[o].category===t&&!e[o].hidden));return{name:t,children:wf(i)}}))})).addChild("insert_link",["insert"],{...Cf,separator:!0,sequence:70}).add("format",{name:r("Format"),sequence:50}).addChild("format_number",["format"],{...Yb,name:r("Number"),sequence:10,separator:!0}).addChild("format_bold",["format"],{...jf,sequence:20}).addChild("format_italic",["format"],{...Xf,sequence:30}).addChild("format_underline",["format"],{...Kf,sequence:40}).addChild("format_strikethrough",["format"],{...Qf,sequence:50,separator:!0}).addChild("format_font_size",["format"],{...Jf,sequence:60,separator:!0}).addChild("format_alignment",["format"],{...eb,sequence:70}).addChild("format_alignment_left",["format","format_alignment"],{...ob,sequence:10}).addChild("format_alignment_center",["format","format_alignment"],{...ib,sequence:20}).addChild("format_alignment_right",["format","format_alignment"],{...sb,sequence:30,separator:!0}).addChild("format_alignment_top",["format","format_alignment"],{...nb,sequence:40}).addChild("format_alignment_middle",["format","format_alignment"],{...ab,sequence:50}).addChild("format_alignment_bottom",["format","format_alignment"],{...lb,sequence:60,separator:!0}).addChild("format_wrapping",["format"],{...cb,sequence:80,separator:!0}).addChild("format_wrapping_overflow",["format","format_wrapping"],{...db,sequence:10}).addChild("format_wrapping_wrap",["format","format_wrapping"],{...ub,sequence:20}).addChild("format_wrapping_clip",["format","format_wrapping"],{...gb,sequence:30}).addChild("format_cf",["format"],{...fb,sequence:90,separator:!0}).addChild("format_clearFormat",["format"],{...bb,sequence:100,separator:!0}).add("data",{name:r("Data"),sequence:60}).addChild("sort_range",["data"],{...Mf,sequence:10,separator:!0}).addChild("sort_ascending",["data","sort_range"],{...Nf,sequence:10}).addChild("sort_descending",["data","sort_range"],{..._f,sequence:20}).addChild("split_to_columns",["data"],{...Lf,sequence:20,separator:!0}).addChild("add_data_filter",["data"],{...Ff,sequence:30}).addChild("remove_data_filter",["data"],{...Df,sequence:30});const Kb=new class extends Ji{addTransformation(e,t,o){for(let i of t)this.content[i]||(this.content[i]=new Map),this.content[i].set(e,o);return this}getTransformation(e,t){return this.content[e]&&this.content[e].get(t)}},Qb={ArrowDown:"down",ArrowLeft:"left",ArrowRight:"right",ArrowUp:"up"};function Jb(e,t){const o=Qb[e.key];e.shiftKey?t.resizeAnchorZone(o,Or(e)?"end":1):t.moveAnchorCell(o,Or(e)?"end":1)}const ev=new Bi;Wi`
|
|
357
|
+
`;class jp extends t.Component{static template="o-spreadsheet-ChartFigure";static components={};onDoubleClick(){this.env.model.dispatch("SELECT_FIGURE",{id:this.props.figure.id}),this.env.openSidePanel("ChartPanel")}get chartType(){return this.env.model.getters.getChartType(this.props.figure.id)}get chartComponent(){const e=this.chartType,t=Zp.get(e);if(!t)throw new Error(`Component is not defined for type ${e}`);return t}}jp.props={figure:Object,onFigureDeleted:Function};class Xp extends t.Component{static template="o-spreadsheet-ImageFigure";static components={};get figureId(){return this.props.figure.id}get getImagePath(){return this.env.model.getters.getImagePath(this.figureId)}}function Kp(e,t){const o=Ce(t),i=e.getSheetViewDimension(),s=i.width,r=i.height;if(o.width>s){const e=s/o.width;o.width=s,o.height=o.height*e}if(o.height>r){const e=r/o.height;o.height=r,o.width=o.width*e}return o}Xp.props={figure:Object,onFigureDeleted:Function};const Qp=new Ji;function Jp(e,t){return{id:"copy",name:r("Copy"),sequence:2,description:"Ctrl+C",execute:async()=>{t.model.dispatch("SELECT_FIGURE",{id:e}),t.model.dispatch("COPY"),await t.clipboard.write(t.model.getters.getClipboardContent())},icon:"o-spreadsheet-Icon.COPY"}}function em(e,t){return{id:"cut",name:r("Cut"),sequence:3,description:"Ctrl+X",execute:async()=>{t.model.dispatch("SELECT_FIGURE",{id:e}),t.model.dispatch("CUT"),await t.clipboard.write(t.model.getters.getClipboardContent())},icon:"o-spreadsheet-Icon.CUT"}}function tm(e,t,o){return{id:"delete",name:r("Delete"),sequence:10,execute:()=>{o.model.dispatch("DELETE_FIGURE",{sheetId:o.model.getters.getActiveSheetId(),id:e}),t()},icon:"o-spreadsheet-Icon.DELETE"}}Qp.add("chart",{Component:jp,SidePanelComponent:"ChartPanel",menuBuilder:function(e,t,o){return Lg([{id:"edit",name:r("Edit"),sequence:1,execute:()=>{o.model.dispatch("SELECT_FIGURE",{id:e}),o.openSidePanel("ChartPanel")},icon:"o-spreadsheet-Icon.EDIT"},Jp(e,o),em(e,o),tm(e,t,o)])}}),Qp.add("image",{Component:Xp,keepRatio:!0,minFigSize:20,borderWidth:0,menuBuilder:function(e,t,o){return Lg([Jp(e,o),em(e,o),{id:"reset_size",name:r("Reset size"),sequence:4,execute:async()=>{const t=o.model.getters.getImagePath(e),i=o.model.getters.getImageSize(e)??await(o.imageProvider?.getImageOriginalSize(t));if(!o.model.getters.getImageSize(e)){o.model.getters.getImage(e).size=i}const{height:s,width:r}=Kp(o.model.getters,i);o.model.dispatch("UPDATE_FIGURE",{sheetId:o.model.getters.getActiveSheetId(),id:e,height:s,width:r})},icon:"o-spreadsheet-Icon.REFRESH"},tm(e,t,o)])}});const om=(new Ji).add("ADD_COLUMNS_ROWS",(function(e){const t=[];let o=e.base;"after"===e.position&&o++;for(let i=0;i<e.quantity;i++)t.push(i+o);return[{type:"REMOVE_COLUMNS_ROWS",dimension:e.dimension,elements:t,sheetId:e.sheetId}]})).add("REMOVE_COLUMNS_ROWS",(function(e){const t=[],o=[...e.elements].sort(((e,t)=>e-t));for(let i of Ie(o)){const o=0===i[0]?0:i[0]-1,s=0===i[0]?"before":"after";t.push({type:"ADD_COLUMNS_ROWS",dimension:e.dimension,quantity:i.length,base:o,sheetId:e.sheetId,position:s})}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 ps.values())om.contains(e)||om.add(e,im);function im(e){return[e]}function sm(e){const t=e.model.dispatch("CUT");t.isSuccessful||t.isCancelledBecause(20)&&e.raiseError(r("This operation is not allowed with multiple selections."))}const rm={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 nm={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 am(e,t){t.isSuccessful||(t.reasons.includes(21)?e.raiseError(nm.wrongPasteSelection):t.reasons.includes(2)?e.raiseError(nm.willRemoveExistingMerge):t.reasons.includes(23)?e.raiseError(nm.wrongFigurePasteOption):t.reasons.includes(78)&&e.raiseError(nm.frozenPaneOverlap))}function lm(e,t,o){const i=e.model.dispatch("PASTE",{target:t,pasteOption:o});am(e,i)}function cm(e,t,o,i){const s=e.model.dispatch("PASTE_FROM_OS_CLIPBOARD",{target:t,text:o,pasteOption:i});am(e,s)}function hm(e,t){const o=qp.getAll().find((t=>t.match(e.type)));if(!o)throw new Error("Unknown chart type.");return o.transformDefinition(e,t)}function dm(e,t){let o=e;e.left!==e.right&&(o={...e,left:e.left+1});const i=[ii(o)],r=t.getActiveSheetId(),n=t.getCell({sheetId:r,col:e.left,row:e.top});if(1===yi(e)&&n?.content)return{type:"scorecard",title:"",background:n.style?.fillColor||void 0,keyValue:ii(e),baselineMode:re,baselineColorUp:ne,baselineColorDown:ae};let a="";const l=t.getEvaluatedCellsInZone(r,{...o,bottom:o.top}),c=!!l.find((e=>e.type!==ls.empty&&e.type!==ls.number));if(c){const e=l.filter((e=>e.type!==ls.error&&e.type!==ls.empty)).map((e=>e.formattedValue)),t=e.splice(-1)[0];a=e.join(", "),t&&(a+=(a?" "+s("and")+" ":"")+t)}let h;e.left!==e.right&&(h=ii({...e,right:e.left}));const d=o.right===o.left?"none":"top";return kp(h?t.getRangeFromSheetXC(r,h):void 0,t)?{title:a,dataSets:i,labelsAsText:!1,stacked:!1,aggregated:!1,cumulative:!1,labelRange:h,type:"line",dataSetsHaveTitle:c,verticalAxisPosition:"left",legendPosition:d}:{title:a,dataSets:i,labelRange:h,type:"bar",stacked:!1,aggregated:!1,dataSetsHaveTitle:c,verticalAxisPosition:"left",legendPosition:d}}function um(e,t){e.model.dispatch("SET_FORMATTING",{sheetId:e.model.getters.getActiveSheetId(),target:e.model.getters.getSelectedZones(),format:t})}function gm(e,t){e.model.dispatch("SET_FORMATTING",{sheetId:e.model.getters.getActiveSheetId(),target:e.model.getters.getSelectedZones(),style:t})}const pm=async e=>mm(e,"onlyValue");async function mm(e,t){const o=e.model.getters.getClipboardTextContent(),i=await e.clipboard.readText();switch(i.status){case"ok":const s=e.model.getters.getSelectedZones();i&&i.content!==o?cm(e,s,i.content,t):lm(e,s,t),e.model.getters.isCutOperation()&&"onlyValue"!==t&&await e.clipboard.write({[cs.PlainText]:""});break;case"notImplemented":e.raiseError(r("Pasting from the context menu is not supported in this browser. Use keyboard shortcuts ctrl+c / ctrl+v instead."));break;case"permissionDenied":e.raiseError(r("Access to the clipboard denied by the browser. Please enable clipboard permission for this page in your browser settings."))}}const fm=(e,t)=>{const o=t.model.getters.getActiveSheetId(),i=t.model.getters.getElementsFromSelection(e),s=t.model.getters.checkElementsIncludeAllVisibleHeaders(o,e,i),r=t.model.getters.checkElementsIncludeAllNonFrozenHeaders(o,e,i);return!s&&!r},bm=e=>{const t=e.model.getters.getActiveRows();let o,i;if(t.size)o=tt([...t]),i=t.size;else{const t=e.model.getters.getSelectedZones()[0];o=t.top,i=t.bottom-t.top+1}e.model.dispatch("ADD_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),position:"before",base:o,quantity:i,dimension:"ROW"})},vm=e=>{const t=e.model.getters.getActiveCols();let o,i;if(t.size)o=tt([...t]),i=t.size;else{const t=e.model.getters.getSelectedZones()[0];o=t.left,i=t.right-t.left+1}e.model.dispatch("ADD_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),position:"before",dimension:"COL",base:o,quantity:i})},Sm=e=>{const t=e.model.getters.getActiveCols();let o,i;if(t.size)o=et([...t]),i=t.size;else{const t=e.model.getters.getSelectedZones()[0];o=t.right,i=t.right-t.left+1}e.model.dispatch("ADD_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),position:"after",dimension:"COL",base:o,quantity:i})};const Cm=async e=>{if(e.imageProvider){const t=e.model.getters.getActiveSheetId(),o=e.model.uuidGenerator.uuidv4(),i=await async function(e){try{return await e.imageProvider.requestImage()}catch{return void e.raiseError(r("An unexpected error occurred during the image transfer"))}}(e);if(!i)throw new Error("No image provider was given to the environment");const s=Kp(e.model.getters,i.size),n=function(e,t){const{x:o,y:i}=e.getMainViewportCoordinates(),{scrollX:s,scrollY:r}=e.getActiveSheetScrollInfo(),n=e.getSheetViewDimension(),a=e.getVisibleRect(e.getActiveMainViewport()),l=Math.min(a.width,n.width-o),c=Math.min(a.height,n.height-i);return{x:o+s+Math.max(0,(l-t.width)/2),y:i+r+Math.max(0,(c-t.height)/2)}}(e.model.getters,s);e.model.dispatch("CREATE_IMAGE",{sheetId:t,figureId:o,position:n,size:s,definition:i})}},Em=e=>um(e,"0.00%"),wm=e=>{let{col:t,row:o}=e.model.getters.getActivePosition();e.model.dispatch("OPEN_CELL_POPOVER",{col:t,row:o,popoverType:"LinkEditor"})},xm=e=>1===e.model.getters.getSelectedZones().length,ym=(e,t)=>{if(!xm(e))return!1;const o="COL"===t?e.model.getters.getActiveCols():e.model.getters.getActiveRows(),i="COL"===t?e.model.getters.getActiveRows():e.model.getters.getActiveCols(),s=e.model.getters.getActiveSheetId(),r=hi(e.model.getters.getSelectedZone(),e.model.getters.getSheetZone(s));return function(e){const t=Array.from(e).sort(((e,t)=>e-t));for(let e=1;e<t.length;e++)if(t[e]-t[e-1]!=1)return!1;return!0}(o)&&(0===i.size||r)},Im={name:r("Undo"),description:"Ctrl+Z",execute:e=>e.model.dispatch("REQUEST_UNDO"),isEnabled:e=>e.model.getters.canUndo(),icon:"o-spreadsheet-Icon.UNDO"},Rm={name:r("Redo"),description:"Ctrl+Y",execute:e=>e.model.dispatch("REQUEST_REDO"),isEnabled:e=>e.model.getters.canRedo(),icon:"o-spreadsheet-Icon.REDO"},Tm={name:r("Copy"),description:"Ctrl+C",isReadonlyAllowed:!0,execute:async e=>{e.model.dispatch("COPY"),await e.clipboard.write(e.model.getters.getClipboardContent())},icon:"o-spreadsheet-Icon.COPY"},Am={name:r("Cut"),description:"Ctrl+X",execute:async e=>{sm(e),await e.clipboard.write(e.model.getters.getClipboardContent())},icon:"o-spreadsheet-Icon.CUT"},Om={name:r("Paste"),description:"Ctrl+V",execute:async e=>mm(e),icon:"o-spreadsheet-Icon.PASTE"},Mm={name:r("Paste special"),isVisible:e=>!e.model.getters.isCutOperation(),icon:"o-spreadsheet-Icon.PASTE"},Nm={name:r("Paste value only"),description:"Ctrl+Shift+V",execute:pm},_m={name:r("Paste format only"),execute:e=>mm(e,"onlyFormat")},Fm={name:r("Find and replace"),description:"Ctrl+H",isReadonlyAllowed:!0,execute:e=>{e.openSidePanel("FindAndReplace",{})},icon:"o-spreadsheet-Icon.FIND_AND_REPLACE"},Dm={name:r("Delete values"),execute:e=>e.model.dispatch("DELETE_CONTENT",{sheetId:e.model.getters.getActiveSheetId(),target:e.model.getters.getSelectedZones()})},Lm={name:e=>{if(e.model.getters.getSelectedZones().length>1)return r("Delete rows");let t,o;const i=e.model.getters.getActiveRows();if(0!==i.size)t=tt([...i]),o=et([...i]);else{const i=e.model.getters.getSelectedZones()[0];t=i.top,o=i.bottom}return t===o?r("Delete row %s",(t+1).toString()):r("Delete rows %s - %s",(t+1).toString(),(o+1).toString())},execute:e=>{let t=[...e.model.getters.getActiveRows()];if(!t.length){const o=e.model.getters.getSelectedZones()[0];for(let e=o.top;e<=o.bottom;e++)t.push(e)}e.model.dispatch("REMOVE_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),dimension:"ROW",elements:t})},isVisible:e=>fm("ROW",e)},Pm={...Lm,isVisible:xm},km={name:e=>{if(e.model.getters.getSelectedZones().length>1)return r("Clear rows");let t,o;const i=e.model.getters.getActiveRows();if(0!==i.size)t=tt([...i]),o=et([...i]);else{const i=e.model.getters.getSelectedZones()[0];t=i.top,o=i.bottom}return t===o?r("Clear row %s",(t+1).toString()):r("Clear rows %s - %s",(t+1).toString(),(o+1).toString())},execute:e=>{const t=e.model.getters.getActiveSheetId(),o=[...e.model.getters.getActiveRows()].map((o=>e.model.getters.getRowsZone(t,o,o)));e.model.dispatch("DELETE_CONTENT",{target:o,sheetId:e.model.getters.getActiveSheetId()})}},Um={name:e=>{if(e.model.getters.getSelectedZones().length>1)return r("Delete columns");let t,o;const i=e.model.getters.getActiveCols();if(0!==i.size)t=tt([...i]),o=et([...i]);else{const i=e.model.getters.getSelectedZones()[0];t=i.left,o=i.right}return t===o?r("Delete column %s",bt(t)):r("Delete columns %s - %s",bt(t),bt(o))},execute:e=>{let t=[...e.model.getters.getActiveCols()];if(!t.length){const o=e.model.getters.getSelectedZones()[0];for(let e=o.left;e<=o.right;e++)t.push(e)}e.model.dispatch("REMOVE_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),dimension:"COL",elements:t})},isVisible:e=>fm("COL",e)},Vm={...Um,isVisible:xm},Bm={name:e=>{if(e.model.getters.getSelectedZones().length>1)return r("Clear columns");let t,o;const i=e.model.getters.getActiveCols();if(0!==i.size)t=tt([...i]),o=et([...i]);else{const i=e.model.getters.getSelectedZones()[0];t=i.left,o=i.right}return t===o?r("Clear column %s",bt(t)):r("Clear columns %s - %s",bt(t),bt(o))},execute:e=>{const t=e.model.getters.getActiveSheetId(),o=[...e.model.getters.getActiveCols()].map((o=>e.model.getters.getColsZone(t,o,o)));e.model.dispatch("DELETE_CONTENT",{target:o,sheetId:e.model.getters.getActiveSheetId()})}},zm={name:r("Delete cells"),isVisible:xm},Hm={name:r("Delete cell and shift up"),execute:e=>{const t=e.model.getters.getSelectedZone(),o=e.model.dispatch("DELETE_CELL",{zone:t,shiftDimension:"ROW"});am(e,o)}},$m={name:r("Delete cell and shift left"),execute:e=>{const t=e.model.getters.getSelectedZone(),o=e.model.dispatch("DELETE_CELL",{zone:t,shiftDimension:"COL"});am(e,o)}},Wm={name:r("Merge cells"),isEnabled:e=>!Gm(e),isActive:e=>qm(e),execute:e=>function(e){if(Gm(e))return;const t=e.model.getters.getSelectedZones(),o=[t[t.length-1]],i=e.model.getters.getActiveSheetId();qm(e)?e.model.dispatch("REMOVE_MERGE",{sheetId:i,target:o}):function(e,t,o){const i=e.model.dispatch("ADD_MERGE",{sheetId:t,target:o});i.isCancelledBecause(83)?e.raiseError(rm.MergeInFilter):i.isCancelledBecause(3)&&e.askConfirmation(rm.MergeIsDestructive,(()=>{e.model.dispatch("ADD_MERGE",{sheetId:t,target:o,force:!0})}))}(e,i,o)}(e),icon:"o-spreadsheet-Icon.MERGE_CELL"};function Gm(e){const t=e.model.getters.getSelectedZones(),{top:o,left:i,right:s,bottom:r}=e.model.getters.getSelectedZone(),{sheetId:n}=e.model.getters.getActivePosition(),{xSplit:a,ySplit:l}=e.model.getters.getPaneDivisions(n);return t.length>1||o===r&&i===s||i<a&&a<=s||o<l&&l<=r}function qm(e){if(!Gm(e)){const t=e.model.getters.getSelectedZones(),{col:o,row:i,sheetId:s}=e.model.getters.getActivePosition(),r=e.model.getters.expandZone(s,wi({col:o,row:i}));return hi(t[0],r)}return!1}var Zm=Object.freeze({__proto__:null,undo:Im,redo:Rm,copy:Tm,cut:Am,paste:Om,pasteSpecial:Mm,pasteSpecialValue:Nm,pasteSpecialFormat:_m,findAndReplace:Fm,deleteValues:Dm,deleteRows:Lm,deleteRow:Pm,clearRows:km,deleteCols:Um,deleteCol:Vm,clearCols:Bm,deleteCells:zm,deleteCellShiftUp:Hm,deleteCellShiftLeft:$m,mergeCells:Wm});const Ym={name:e=>{const t=wf(e);return 1===t?r("Insert row"):r("Insert %s rows",t.toString())},isVisible:e=>ym(e,"ROW"),icon:"o-spreadsheet-Icon.INSERT_ROW"},jm={name:e=>{const t=wf(e);return 1===t?r("Insert row above"):r("Insert %s rows above",t.toString())},execute:bm,isVisible:e=>ym(e,"ROW"),icon:"o-spreadsheet-Icon.INSERT_ROW_BEFORE"},Xm={...jm,name:e=>{const t=wf(e);return 1===t?r("Row above"):r("%s Rows above",t.toString())}},Km={...jm,name:e=>{const t=wf(e);return 1===t?r("Insert row"):r("Insert %s rows",t.toString())},isVisible:xm,icon:"o-spreadsheet-Icon.INSERT_ROW_BEFORE"},Qm={execute:e=>{const t=e.model.getters.getActiveRows();let o,i;if(t.size)o=et([...t]),i=t.size;else{const t=e.model.getters.getSelectedZones()[0];o=t.bottom,i=t.bottom-t.top+1}e.model.dispatch("ADD_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),position:"after",base:o,quantity:i,dimension:"ROW"})},name:e=>{const t=wf(e);return 1===t?r("Insert row below"):r("Insert %s rows below",t.toString())},isVisible:e=>ym(e,"ROW"),icon:"o-spreadsheet-Icon.INSERT_ROW_AFTER"},Jm={...Qm,name:e=>{const t=wf(e);return 1===t?r("Row below"):r("%s Rows below",t.toString())}},ef={name:e=>{const t=xf(e);return 1===t?r("Insert column"):r("Insert %s columns",t.toString())},isVisible:e=>ym(e,"COL"),icon:"o-spreadsheet-Icon.INSERT_COL"},tf={name:e=>{const t=xf(e);return 1===t?r("Insert column left"):r("Insert %s columns left",t.toString())},execute:vm,isVisible:e=>ym(e,"COL"),icon:"o-spreadsheet-Icon.INSERT_COL_BEFORE"},of={...tf,name:e=>{const t=xf(e);return 1===t?r("Column left"):r("%s Columns left",t.toString())}},sf={...tf,name:e=>{const t=xf(e);return 1===t?r("Insert column"):r("Insert %s columns",t.toString())},isVisible:xm,icon:"o-spreadsheet-Icon.INSERT_COL_BEFORE"},rf={name:e=>{const t=xf(e);return 1===t?r("Insert column right"):r("Insert %s columns right",t.toString())},execute:Sm,isVisible:e=>ym(e,"COL"),icon:"o-spreadsheet-Icon.INSERT_COL_AFTER"},nf={...rf,name:e=>{const t=xf(e);return 1===t?r("Column right"):r("%s Columns right",t.toString())},execute:Sm},af={name:r("Insert cells"),isVisible:e=>xm(e)&&0===e.model.getters.getActiveCols().size&&0===e.model.getters.getActiveRows().size,icon:"o-spreadsheet-Icon.INSERT_CELL"},lf={name:r("Insert cells and shift down"),execute:e=>{const t=e.model.getters.getSelectedZone(),o=e.model.dispatch("INSERT_CELL",{zone:t,shiftDimension:"ROW"});am(e,o)},isVisible:e=>0===e.model.getters.getActiveRows().size&&0===e.model.getters.getActiveCols().size,icon:"o-spreadsheet-Icon.INSERT_CELL_SHIFT_DOWN"},cf={name:r("Insert cells and shift right"),execute:e=>{const t=e.model.getters.getSelectedZone(),o=e.model.dispatch("INSERT_CELL",{zone:t,shiftDimension:"COL"});am(e,o)},isVisible:e=>0===e.model.getters.getActiveRows().size&&0===e.model.getters.getActiveCols().size,icon:"o-spreadsheet-Icon.INSERT_CELL_SHIFT_RIGHT"},hf={name:r("Chart"),execute:e=>{const t=e.model.getters,o=e.model.uuidGenerator.uuidv4(),i=t.getActiveSheetId();1===yi(e.model.getters.getSelectedZone())&&e.model.selection.selectTableAroundSelection();const s={width:536,height:335},r=function(e,t){const{x:o,y:i}=e.getMainViewportCoordinates(),{scrollX:s,scrollY:r}=e.getActiveSheetScrollInfo(),{width:n,height:a}=e.getVisibleRect(e.getActiveMainViewport());return{x:o+s+Math.max(0,(n-t.width)/2),y:i+r+Math.max(0,(a-t.height)/2)}}(t,s);e.model.dispatch("CREATE_CHART",{sheetId:i,id:o,position:r,size:s,definition:dm(e.model.getters.getSelectedZone(),e.model.getters)}).isSuccessful&&(e.model.dispatch("SELECT_FIGURE",{id:o}),e.openSidePanel("ChartPanel"))},icon:"o-spreadsheet-Icon.INSERT_CHART"},df={name:r("Image"),description:"Ctrl+O",execute:Cm,isVisible:e=>void 0!==e.imageProvider,icon:"o-spreadsheet-Icon.INSERT_IMAGE"},uf={name:r("Function"),icon:"o-spreadsheet-Icon.SHOW_HIDE_FORMULA"},gf={name:r("SUM"),execute:e=>e.startCellEdition("=SUM(")},pf={name:r("AVERAGE"),execute:e=>e.startCellEdition("=AVERAGE(")},mf={name:r("COUNT"),execute:e=>e.startCellEdition("=COUNT(")},ff={name:r("MAX"),execute:e=>e.startCellEdition("=MAX(")},bf={name:r("MIN"),execute:e=>e.startCellEdition("=MIN(")},vf={name:r("All"),children:[function(){return Ef(fu.getKeys().filter((e=>!fu.get(e).hidden)))}]};const Sf={name:r("Link"),execute:wm,icon:"o-spreadsheet-Icon.INSERT_LINK"},Cf={name:r("Insert sheet"),execute:e=>{const t=e.model.getters.getActiveSheetId(),o=e.model.getters.getSheetIds().indexOf(t)+1,i=e.model.uuidGenerator.uuidv4();e.model.dispatch("CREATE_SHEET",{sheetId:i,position:o}),e.model.dispatch("ACTIVATE_SHEET",{sheetIdFrom:t,sheetIdTo:i})},icon:"o-spreadsheet-Icon.INSERT_SHEET"};function Ef(e){return e.sort().map(((e,t)=>({name:e,sequence:10*t,execute:t=>t.startCellEdition(`=${e}(`)})))}function wf(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 xf(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}}const yf=new Ug;yf.add("cut",{...Am,sequence:10}).add("copy",{...Tm,sequence:20}).add("paste",{...Om,sequence:30}).add("paste_special",{...Mm,sequence:40,separator:!0}).addChild("paste_value_only",["paste_special"],{...Nm,sequence:10}).addChild("paste_format_only",["paste_special"],{..._m,sequence:20}).add("add_row_before",{...Km,sequence:70}).add("add_column_before",{...sf,sequence:90}).add("insert_cell",{...af,sequence:100,separator:!0}).addChild("insert_cell_down",["insert_cell"],{...lf,name:r("Shift down"),sequence:10}).addChild("insert_cell_right",["insert_cell"],{...cf,name:r("Shift right"),sequence:20}).add("delete_row",{...Pm,sequence:110,icon:"o-spreadsheet-Icon.DELETE"}).add("delete_column",{...Vm,sequence:120,icon:"o-spreadsheet-Icon.DELETE"}).add("delete_cell",{...zm,sequence:130,separator:!0,icon:"o-spreadsheet-Icon.DELETE"}).addChild("delete_cell_up",["delete_cell"],{...Hm,name:r("Shift up"),sequence:10,icon:"o-spreadsheet-Icon.DELETE_CELL_SHIFT_UP"}).addChild("delete_cell_left",["delete_cell"],{...$m,name:r("Shift left"),sequence:20,icon:"o-spreadsheet-Icon.DELETE_CELL_SHIFT_LEFT"}).add("insert_link",{...Sf,name:e=>{const t=e.model.getters.getActiveSheetId(),{col:o,row:i}=e.model.getters.getActivePosition(),s=e.model.getters.getEvaluatedCell({sheetId:t,col:o,row:i});return s&&s.link?r("Edit link"):r("Insert link")},sequence:150,separator:!0});const If=[ls.number,ls.error,ls.text,ls.boolean];function Rf(e,t,o,i,s){let n=fs.Success,a=i.right>i.left;if(e.model.getters.doesIntersectMerge(t,i)){let o;a=!1;for(let s=i.top;s<=i.bottom;s++){o=[];for(let r=i.left;r<=i.right;r++){let i=e.model.getters.getMerge({sheetId:t,col:r,row:s});i&&!o.includes(i.id.toString())&&o.push(i.id.toString())}if(o.length>=2){a=!0;break}}}const{col:l,row:c}=o;if(a)n=e.model.dispatch("SORT_CELLS",{sheetId:t,col:l,row:c,zone:i,sortDirection:s});else{const o=e.model.getters.getContiguousZone(t,i);hi(o,i)?n=e.model.dispatch("SORT_CELLS",{sheetId:t,col:l,row:c,zone:i,sortDirection:s}):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?"),(()=>{i=o,n=e.model.dispatch("SORT_CELLS",{sheetId:t,col:l,row:c,zone:i,sortDirection:s})}),(()=>{n=e.model.dispatch("SORT_CELLS",{sheetId:t,col:l,row:c,zone:i,sortDirection:s})}))}if(n.isCancelledBecause(66)){const{col:t,row:s}=o;e.model.selection.selectZone({cell:{col:t,row:s},zone:i}),e.raiseError(r("Cannot sort. To sort, select only cells or only merges that have the same size."))}}const Tf={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 Af(e,t,o){const i=e.model.getters.getActiveSheetId(),s="COL"===t?"FREEZE_COLUMNS":"FREEZE_ROWS";e.model.dispatch(s,{sheetId:i,quantity:o}).isCancelledBecause(68)&&e.raiseError(pp)}const Of={name:e=>{const t=e.model.getters.getElementsFromSelection("COL");let o=t[0],i=t[t.length-1];return 1===t.length?r("Hide column %s",bt(o).toString()):i-o+1===t.length?r("Hide columns %s - %s",bt(o).toString(),bt(i).toString()):r("Hide columns")},execute: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(),o=e.model.getters.getElementsFromSelection("COL");return!e.model.getters.checkElementsIncludeAllVisibleHeaders(t,"COL",o)},icon:"o-spreadsheet-Icon.HIDE_COL"},Mf={name:r("Unhide columns"),execute: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)))}},Nf={name:r("Unhide all columns"),execute: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},_f={name:e=>{const t=e.model.getters.getElementsFromSelection("ROW");let o=t[0],i=t[t.length-1];return 1===t.length?r("Hide row %s",(o+1).toString()):i-o+1===t.length?r("Hide rows %s - %s",(o+1).toString(),(i+1).toString()):r("Hide rows")},execute: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(),o=e.model.getters.getElementsFromSelection("ROW");return!e.model.getters.checkElementsIncludeAllVisibleHeaders(t,"ROW",o)},icon:"o-spreadsheet-Icon.HIDE_ROW"},Ff={name:r("Unhide rows"),execute: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)))}},Df={name:r("Unhide all rows"),execute: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},Lf={name:r("Unfreeze"),isVisible:e=>{const{xSplit:t,ySplit:o}=e.model.getters.getPaneDivisions(e.model.getters.getActiveSheetId());return t+o>0},execute:e=>e.model.dispatch("UNFREEZE_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId()}),icon:"o-spreadsheet-Icon.UNFREEZE"},Pf={name:r("Freeze"),icon:"o-spreadsheet-Icon.FREEZE"},kf={name:r("No rows"),execute:e=>e.model.dispatch("UNFREEZE_ROWS",{sheetId:e.model.getters.getActiveSheetId()}),isReadonlyAllowed:!0,isVisible:e=>!!e.model.getters.getPaneDivisions(e.model.getters.getActiveSheetId()).ySplit},Uf={name:r("1 row"),execute:e=>Af(e,"ROW",1),isReadonlyAllowed:!0},Vf={name:r("2 rows"),execute:e=>Af(e,"ROW",2),isReadonlyAllowed:!0},Bf={name:r("Up to current row"),execute:e=>{const{bottom:t}=e.model.getters.getSelectedZone();Af(e,"ROW",t+1)},isReadonlyAllowed:!0},zf={name:r("No columns"),execute:e=>e.model.dispatch("UNFREEZE_COLUMNS",{sheetId:e.model.getters.getActiveSheetId()}),isReadonlyAllowed:!0,isVisible:e=>!!e.model.getters.getPaneDivisions(e.model.getters.getActiveSheetId()).xSplit},Hf={name:r("1 column"),execute:e=>Af(e,"COL",1),isReadonlyAllowed:!0},$f={name:r("2 columns"),execute:e=>Af(e,"COL",2),isReadonlyAllowed:!0},Wf={name:r("Up to current column"),execute:e=>{const{right:t}=e.model.getters.getSelectedZone();Af(e,"COL",t+1)},isReadonlyAllowed:!0},Gf={name:e=>e.model.getters.getGridLinesVisibility(e.model.getters.getActiveSheetId())?r("Hide gridlines"):r("Show gridlines"),execute:e=>{const t=e.model.getters.getActiveSheetId();e.model.dispatch("SET_GRID_LINES_VISIBILITY",{sheetId:t,areGridLinesVisible:!e.model.getters.getGridLinesVisibility(t)})},icon:"o-spreadsheet-Icon.SHOW_HIDE_GRID"},qf={name:e=>e.model.getters.shouldShowFormulas()?r("Hide formulas"):r("Show formulas"),execute:e=>e.model.dispatch("SET_FORMULA_VISIBILITY",{show:!e.model.getters.shouldShowFormulas()}),isReadonlyAllowed:!0,icon:"o-spreadsheet-Icon.SHOW_HIDE_FORMULA"},Zf={name:e=>Yf(e)?r("Remove selected filters"):r("Create filter"),isActive:e=>Yf(e),isEnabled:e=>!jf(e),execute:e=>Xf(e),icon:"o-spreadsheet-Icon.FILTER_ICON_INACTIVE"};function Yf(e){const t=e.model.getters.getActiveSheetId(),o=e.model.getters.getSelectedZones();return e.model.getters.doesZonesContainFilter(t,o)}function jf(e){return!Ii(...e.model.getters.getSelectedZones())}function Xf(e){if(Yf(e))return void e.model.dispatch("REMOVE_FILTER_TABLE",{sheetId:e.model.getters.getActiveSheetId(),target:e.model.getters.getSelectedZones()});if(jf(e))return;e.model.selection.selectTableAroundSelection();const t=e.model.getters.getActiveSheetId(),o=e.model.getters.getSelectedZones();!function(e,t,o){const i=e.model.dispatch("CREATE_FILTER_TABLE",{target:o,sheetId:t});i.isCancelledBecause(81)?e.raiseError(Tf.filterOverlap):i.isCancelledBecause(83)?e.raiseError(Tf.mergeInFilter):i.isCancelledBecause(84)&&e.raiseError(Tf.nonContinuousTargets)}(e,t,o)}var Kf=Object.freeze({__proto__:null,hideCols:Of,unhideCols:Mf,unhideAllCols:Nf,hideRows:_f,unhideRows:Ff,unhideAllRows:Df,unFreezePane:Lf,freezePane:Pf,unFreezeRows:kf,freezeFirstRow:Uf,freezeSecondRow:Vf,freezeCurrentRow:Bf,unFreezeCols:zf,freezeFirstCol:Hf,freezeSecondCol:$f,freezeCurrentCol:Wf,viewGridlines:Gf,viewFormulas:qf,createRemoveFilter:Zf,createRemoveFilterAction:Xf});const Qf={name:r("Sort range"),isVisible:xm,icon:"o-spreadsheet-Icon.SORT_RANGE"},Jf={name:r("Ascending (A ⟶ Z)"),execute:e=>{const{anchor:t,zones:o}=e.model.getters.getSelection(),i=e.model.getters.getActiveSheetId();Rf(e,i,t.cell,o[0],"ascending")},icon:"o-spreadsheet-Icon.SORT_ASCENDING"},eb={name:r("Descending (Z ⟶ A)"),execute:e=>{const{anchor:t,zones:o}=e.model.getters.getSelection(),i=e.model.getters.getActiveSheetId();Rf(e,i,t.cell,o[0],"descending")},icon:"o-spreadsheet-Icon.SORT_DESCENDING"},tb={name:e=>(e=>{const t=e.model.getters.getActiveSheetId(),o=e.model.getters.getSelectedZones();return e.model.getters.doesZonesContainFilter(t,o)})(e)?r("Remove filter"):r("Create filter"),execute:e=>Xf(e),isEnabled:e=>Ii(...e.model.getters.getSelectedZones()),icon:"o-spreadsheet-Icon.MENU_FILTER_ICON"},ob={name:r("Split text to columns"),sequence:1,execute:e=>e.openSidePanel("SplitToColumns",{}),isEnabled:e=>e.model.getters.isSingleColSelected(),icon:"o-spreadsheet-Icon.SPLIT_TEXT"},ib={name:r("Automatic"),execute:e=>um(e,""),isActive:e=>function(e){const t=e.model.getters.getCell(e.model.getters.getActivePosition());return!t||!t.format}(e)},sb={name:r("Number"),description:e=>fo(1000.12,{format:"#,##0.00",locale:e.model.getters.getLocale()}),execute:e=>um(e,"#,##0.00"),isActive:e=>Vb(e,"#,##0.00")},rb={name:r("Format as percent"),execute:Em,icon:"o-spreadsheet-Icon.PERCENT"},nb={name:r("Percent"),description:e=>fo(.1012,{format:"0.00%",locale:e.model.getters.getLocale()}),execute:Em,isActive:e=>Vb(e,"0.00%")},ab={name:r("Currency"),description:e=>fo(1000.12,{format:e.model.config.defaultCurrencyFormat,locale:e.model.getters.getLocale()}),execute:e=>um(e,e.model.config.defaultCurrencyFormat),isActive:e=>Vb(e,e.model.config.defaultCurrencyFormat)},lb={name:r("Currency rounded"),description:e=>fo(1e3,{format:Fo(e.model.config.defaultCurrencyFormat),locale:e.model.getters.getLocale()}),execute:e=>um(e,Fo(e.model.config.defaultCurrencyFormat)),isActive:e=>Vb(e,Fo(e.model.config.defaultCurrencyFormat)),isVisible:e=>{const t=e.model.config.defaultCurrencyFormat;return t!==Fo(t)}},cb={name:r("Custom currency"),isVisible:e=>void 0!==e.loadCurrencies,execute:e=>e.openSidePanel("CustomCurrency",{})},hb={name:r("Date"),description:e=>{const t=e.model.getters.getLocale();return fo(ir("9/26/2023",eo),{format:t.dateFormat,locale:t})},execute:e=>um(e,e.model.getters.getLocale().dateFormat),isActive:e=>Vb(e,e.model.getters.getLocale().dateFormat)},db={name:r("Time"),description:e=>{const t=e.model.getters.getLocale();return fo(ir("9/26/2023 10:43:00 PM",eo),{format:t.timeFormat,locale:t})},execute:e=>um(e,e.model.getters.getLocale().timeFormat),isActive:e=>Vb(e,e.model.getters.getLocale().timeFormat)},ub={name:r("Date time"),description:e=>{const t=e.model.getters.getLocale();return fo(ir("9/26/2023 22:43:00",eo),{format:t.dateFormat+" "+t.timeFormat,locale:t})},execute:e=>{const t=e.model.getters.getLocale();um(e,t.dateFormat+" "+t.timeFormat)},isActive:e=>{const t=e.model.getters.getLocale();return Vb(e,t.dateFormat+" "+t.timeFormat)}},gb={name:r("Duration"),description:"27:51:38",execute:e=>um(e,"hhhh:mm:ss"),isActive:e=>Vb(e,"hhhh:mm:ss")},pb={name:r("Increase decimal places"),icon:"o-spreadsheet-Icon.INCREASE_DECIMAL",execute:e=>e.model.dispatch("SET_DECIMAL",{sheetId:e.model.getters.getActiveSheetId(),target:e.model.getters.getSelectedZones(),step:1})},mb={name:r("Decrease decimal places"),icon:"o-spreadsheet-Icon.DECRASE_DECIMAL",execute:e=>e.model.dispatch("SET_DECIMAL",{sheetId:e.model.getters.getActiveSheetId(),target:e.model.getters.getSelectedZones(),step:-1})},fb={name:r("Bold"),description:"Ctrl+B",execute:e=>gm(e,{bold:!e.model.getters.getCurrentStyle().bold}),icon:"o-spreadsheet-Icon.BOLD",isActive:e=>!!e.model.getters.getCurrentStyle().bold},bb={name:r("Italic"),description:"Ctrl+I",execute:e=>gm(e,{italic:!e.model.getters.getCurrentStyle().italic}),icon:"o-spreadsheet-Icon.ITALIC",isActive:e=>!!e.model.getters.getCurrentStyle().italic},vb={name:r("Underline"),description:"Ctrl+U",execute:e=>gm(e,{underline:!e.model.getters.getCurrentStyle().underline}),icon:"o-spreadsheet-Icon.UNDERLINE",isActive:e=>!!e.model.getters.getCurrentStyle().underline},Sb={name:r("Strikethrough"),execute:e=>gm(e,{strikethrough:!e.model.getters.getCurrentStyle().strikethrough}),icon:"o-spreadsheet-Icon.STRIKE",isActive:e=>!!e.model.getters.getCurrentStyle().strikethrough},Cb={name:r("Font size"),children:be.map((e=>({name:e.toString(),sequence:e,id:`font_size_${e}`,execute:t=>gm(t,{fontSize:e}),isActive:t=>function(e,t){const o=e.model.getters.getCurrentStyle().fontSize||Z;return o===t}(t,e)}))),icon:"o-spreadsheet-Icon.FONT_SIZE"},Eb={name:r("Alignment"),icon:"o-spreadsheet-Icon.ALIGN_LEFT"},wb={name:r("Horizontal align"),icon:e=>function(e){switch(Bb(e)){case"right":return"o-spreadsheet-Icon.ALIGN_RIGHT";case"center":return"o-spreadsheet-Icon.ALIGN_CENTER";default:return"o-spreadsheet-Icon.ALIGN_LEFT"}}(e)},xb={name:r("Left"),description:"Ctrl+Shift+L",execute:e=>gm(e,{align:"left"}),isActive:e=>"left"===Bb(e),icon:"o-spreadsheet-Icon.ALIGN_LEFT"},yb={name:r("Center"),description:"Ctrl+Shift+E",execute:e=>gm(e,{align:"center"}),isActive:e=>"center"===Bb(e),icon:"o-spreadsheet-Icon.ALIGN_CENTER"},Ib={name:r("Right"),description:"Ctrl+Shift+R",execute:e=>gm(e,{align:"right"}),isActive:e=>"right"===Bb(e),icon:"o-spreadsheet-Icon.ALIGN_RIGHT"},Rb={name:r("Vertical align"),icon:e=>function(e){switch(zb(e)){case"top":return"o-spreadsheet-Icon.ALIGN_TOP";case"middle":return"o-spreadsheet-Icon.ALIGN_MIDDLE";default:return"o-spreadsheet-Icon.ALIGN_BOTTOM"}}(e)},Tb={name:r("Top"),execute:e=>gm(e,{verticalAlign:"top"}),isActive:e=>"top"===zb(e),icon:"o-spreadsheet-Icon.ALIGN_TOP"},Ab={name:r("Middle"),execute:e=>gm(e,{verticalAlign:"middle"}),isActive:e=>"middle"===zb(e),icon:"o-spreadsheet-Icon.ALIGN_MIDDLE"},Ob={name:r("Bottom"),execute:e=>gm(e,{verticalAlign:"bottom"}),isActive:e=>"bottom"===zb(e),icon:"o-spreadsheet-Icon.ALIGN_BOTTOM"},Mb={name:r("Wrapping"),icon:"o-spreadsheet-Icon.WRAPPING_OVERFLOW"},Nb={name:r("Wrapping"),icon:e=>function(e){switch(Hb(e)){case"wrap":return"o-spreadsheet-Icon.WRAPPING_WRAP";case"clip":return"o-spreadsheet-Icon.WRAPPING_CLIP";default:return"o-spreadsheet-Icon.WRAPPING_OVERFLOW"}}(e)},_b={name:r("Overflow"),execute:e=>gm(e,{wrapping:"overflow"}),isActive:e=>"overflow"===Hb(e),icon:"o-spreadsheet-Icon.WRAPPING_OVERFLOW"},Fb={name:r("Wrap"),execute:e=>gm(e,{wrapping:"wrap"}),isActive:e=>"wrap"===Hb(e),icon:"o-spreadsheet-Icon.WRAPPING_WRAP"},Db={name:r("Clip"),execute:e=>gm(e,{wrapping:"clip"}),isActive:e=>"clip"===Hb(e),icon:"o-spreadsheet-Icon.WRAPPING_CLIP"},Lb={name:r("Text Color"),icon:"o-spreadsheet-Icon.TEXT_COLOR"},Pb={name:r("Fill Color"),icon:"o-spreadsheet-Icon.FILL_COLOR"},kb={name:r("Conditional formatting"),execute:e=>{e.openSidePanel("ConditionalFormatting",{selection:e.model.getters.getSelectedZones()})},icon:"o-spreadsheet-Icon.CONDITIONAL_FORMAT"},Ub={name:r("Clear formatting"),description:"Ctrl+<",execute:e=>e.model.dispatch("CLEAR_FORMATTING",{sheetId:e.model.getters.getActiveSheetId(),target:e.model.getters.getSelectedZones()}),icon:"o-spreadsheet-Icon.CLEAR_FORMAT"};function Vb(e,t){return e.model.getters.getCell(e.model.getters.getActivePosition())?.format===t}function Bb(e){const t=e.model.getters.getCurrentStyle();if(t.align)return t.align;return e.model.getters.getActiveCell().defaultAlign}function zb(e){const t=e.model.getters.getCurrentStyle();return t.verticalAlign?t.verticalAlign:j}function Hb(e){const t=e.model.getters.getCurrentStyle();return t.wrapping?t.wrapping:X}var $b=Object.freeze({__proto__:null,formatNumberAutomatic:ib,formatNumberNumber:sb,formatPercent:rb,formatNumberPercent:nb,formatNumberCurrency:ab,formatNumberCurrencyRounded:lb,formatCustomCurrency:cb,formatNumberDate:hb,formatNumberTime:db,formatNumberDateTime:ub,formatNumberDuration:gb,incraseDecimalPlaces:pb,decraseDecimalPlaces:mb,formatBold:fb,formatItalic:bb,formatUnderline:vb,formatStrikethrough:Sb,formatFontSize:Cb,formatAlignment:Eb,formatAlignmentHorizontal:wb,formatAlignmentLeft:xb,formatAlignmentCenter:yb,formatAlignmentRight:Ib,formatAlignmentVertical:Rb,formatAlignmentTop:Tb,formatAlignmentMiddle:Ab,formatAlignmentBottom:Ob,formatWrappingIcon:Mb,formatWrapping:Nb,formatWrappingOverflow:_b,formatWrappingWrap:Fb,formatWrappingClip:Db,textColor:Lb,fillColor:Pb,formatCF:kb,clearFormat:Ub});const Wb=new Ug;Wb.add("cut",{...Am,sequence:10}).add("copy",{...Tm,sequence:20}).add("paste",{...Om,sequence:30}).add("paste_special",{...Mm,sequence:40,separator:!0}).addChild("paste_value_only",["paste_special"],{...Nm,sequence:10}).addChild("paste_format_only",["paste_special"],{..._m,sequence:20}).add("sort_columns",{...Qf,name:e=>e.model.getters.getActiveCols().size>1?r("Sort columns"):r("Sort column"),sequence:50,separator:!0}).addChild("sort_ascending",["sort_columns"],{...Jf,sequence:10}).addChild("sort_descending",["sort_columns"],{...eb,sequence:20}).add("add_column_before",{...tf,sequence:70}).add("add_column_after",{...rf,sequence:80}).add("delete_column",{...Um,sequence:90,icon:"o-spreadsheet-Icon.DELETE"}).add("clear_column",{...Bm,sequence:100,icon:"o-spreadsheet-Icon.CLEAR"}).add("hide_columns",{...Of,sequence:105,separator:!0}).add("unhide_columns",{...Mf,sequence:106,separator:!0}).add("conditional_formatting",{...kb,sequence:110});const Gb=new Ug;Gb.add("format_number_automatic",{...ib,sequence:10,separator:!0}).add("format_number_number",{...sb,sequence:20}).add("format_number_percent",{...nb,sequence:30,separator:!0}).add("format_number_currency",{...ab,sequence:40}).add("format_number_currency_rounded",{...lb,sequence:50}).add("format_custom_currency",{...cb,sequence:60,separator:!0}).add("format_number_date",{...hb,sequence:70}).add("format_number_time",{...db,sequence:80}).add("format_number_date_time",{...ub,sequence:90}).add("format_number_duration",{...gb,sequence:100,separator:!0});const qb={name:r("More formats"),icon:"o-spreadsheet-Icon.NUMBER_FORMATS",children:[()=>Gb.getAll()]},Zb=new Ug;Zb.add("cut",{...Am,sequence:10}).add("copy",{...Tm,sequence:20}).add("paste",{...Om,sequence:30}).add("paste_special",{...Mm,sequence:40,separator:!0}).addChild("paste_value_only",["paste_special"],{...Nm,sequence:10}).addChild("paste_format_only",["paste_special"],{..._m,sequence:20}).add("add_row_before",{...jm,sequence:50}).add("add_row_after",{...Qm,sequence:60}).add("delete_row",{...Lm,sequence:70,icon:"o-spreadsheet-Icon.DELETE"}).add("clear_row",{...km,sequence:80,icon:"o-spreadsheet-Icon.CLEAR"}).add("hide_rows",{..._f,sequence:85,separator:!0}).add("unhide_rows",{...Ff,sequence:86,separator:!0}).add("conditional_formatting",{...kb,sequence:90});const Yb=new Ug;Yb.add("file",{name:r("File"),sequence:10}).addChild("settings",["file"],{name:r("Settings"),sequence:100,execute:e=>e.openSidePanel("Settings"),icon:"o-spreadsheet-Icon.COG"}).add("edit",{name:r("Edit"),sequence:20}).addChild("undo",["edit"],{...Im,sequence:10}).addChild("redo",["edit"],{...Rm,sequence:20,separator:!0}).addChild("copy",["edit"],{...Tm,sequence:30}).addChild("cut",["edit"],{...Am,sequence:40}).addChild("paste",["edit"],{...Om,sequence:50}).addChild("paste_special",["edit"],{...Mm,sequence:60,separator:!0}).addChild("paste_special_value",["edit","paste_special"],{...Nm,sequence:10}).addChild("paste_special_format",["edit","paste_special"],{..._m,sequence:20}).addChild("find_and_replace",["edit"],{...Fm,sequence:65,separator:!0}).addChild("delete",["edit"],{name:r("Delete"),icon:"o-spreadsheet-Icon.DELETE",sequence:70}).addChild("edit_delete_cell_values",["edit","delete"],{...Dm,sequence:10}).addChild("edit_delete_row",["edit","delete"],{...Lm,sequence:20}).addChild("edit_delete_column",["edit","delete"],{...Um,sequence:30}).addChild("edit_delete_cell_shift_up",["edit","delete"],{...Hm,sequence:40}).addChild("edit_delete_cell_shift_left",["edit","delete"],{...$m,sequence:50}).addChild("edit_unhide_columns",["edit"],{...Nf,sequence:80}).addChild("edit_unhide_rows",["edit"],{...Df,sequence:80}).add("view",{name:r("View"),sequence:30}).addChild("unfreeze_panes",["view"],{...Lf,sequence:4}).addChild("freeze_panes",["view"],{...Pf,sequence:5,separator:!0}).addChild("unfreeze_rows",["view","freeze_panes"],{...kf,sequence:5}).addChild("freeze_first_row",["view","freeze_panes"],{...Uf,sequence:10}).addChild("freeze_second_row",["view","freeze_panes"],{...Vf,sequence:15}).addChild("freeze_current_row",["view","freeze_panes"],{...Bf,sequence:20,separator:!0}).addChild("unfreeze_columns",["view","freeze_panes"],{...zf,sequence:25}).addChild("freeze_first_col",["view","freeze_panes"],{...Hf,sequence:30}).addChild("freeze_second_col",["view","freeze_panes"],{...$f,sequence:35}).addChild("freeze_current_col",["view","freeze_panes"],{...Wf,sequence:40}).addChild("view_gridlines",["view"],{...Gf,sequence:10}).addChild("view_formulas",["view"],{...qf,sequence:15}).add("insert",{name:r("Insert"),sequence:40}).addChild("insert_row",["insert"],{...Ym,sequence:10}).addChild("insert_row_before",["insert","insert_row"],{...Xm,sequence:10}).addChild("insert_row_after",["insert","insert_row"],{...Jm,sequence:20}).addChild("insert_column",["insert"],{...ef,sequence:20}).addChild("insert_column_before",["insert","insert_column"],{...of,sequence:10}).addChild("insert_column_after",["insert","insert_column"],{...nf,sequence:20}).addChild("insert_cell",["insert"],{...af,sequence:43}).addChild("insert_cell_down",["insert","insert_cell"],{...lf,name:r("Shift down"),sequence:10}).addChild("insert_cell_right",["insert","insert_cell"],{...cf,name:r("Shift right"),sequence:20}).addChild("insert_sheet",["insert"],{...Cf,sequence:80,separator:!0}).addChild("insert_chart",["insert"],{...hf,sequence:50}).addChild("insert_image",["insert"],{...df,sequence:55}).addChild("insert_function",["insert"],{...uf,sequence:60}).addChild("insert_function_sum",["insert","insert_function"],{...gf,sequence:0}).addChild("insert_function_average",["insert","insert_function"],{...pf,sequence:10}).addChild("insert_function_count",["insert","insert_function"],{...mf,sequence:20}).addChild("insert_function_max",["insert","insert_function"],{...ff,sequence:30}).addChild("insert_function_min",["insert","insert_function"],{...bf,sequence:40,separator:!0}).addChild("categorie_function_all",["insert","insert_function"],{...vf,sequence:50}).addChild("categories_function_list",["insert","insert_function"],(()=>{const e=fu.content;return[...new Set(fu.getAll().filter((e=>!e.hidden)).map((e=>e.category)))].filter(ke).sort().map(((t,o)=>{const i=Object.keys(e).filter((o=>e[o].category===t&&!e[o].hidden));return{name:t,children:Ef(i)}}))})).addChild("insert_link",["insert"],{...Sf,separator:!0,sequence:70}).add("format",{name:r("Format"),sequence:50}).addChild("format_number",["format"],{...qb,name:r("Number"),sequence:10,separator:!0}).addChild("format_bold",["format"],{...fb,sequence:20}).addChild("format_italic",["format"],{...bb,sequence:30}).addChild("format_underline",["format"],{...vb,sequence:40}).addChild("format_strikethrough",["format"],{...Sb,sequence:50,separator:!0}).addChild("format_font_size",["format"],{...Cb,sequence:60,separator:!0}).addChild("format_alignment",["format"],{...Eb,sequence:70}).addChild("format_alignment_left",["format","format_alignment"],{...xb,sequence:10}).addChild("format_alignment_center",["format","format_alignment"],{...yb,sequence:20}).addChild("format_alignment_right",["format","format_alignment"],{...Ib,sequence:30,separator:!0}).addChild("format_alignment_top",["format","format_alignment"],{...Tb,sequence:40}).addChild("format_alignment_middle",["format","format_alignment"],{...Ab,sequence:50}).addChild("format_alignment_bottom",["format","format_alignment"],{...Ob,sequence:60,separator:!0}).addChild("format_wrapping",["format"],{...Mb,sequence:80,separator:!0}).addChild("format_wrapping_overflow",["format","format_wrapping"],{..._b,sequence:10}).addChild("format_wrapping_wrap",["format","format_wrapping"],{...Fb,sequence:20}).addChild("format_wrapping_clip",["format","format_wrapping"],{...Db,sequence:30}).addChild("format_cf",["format"],{...kb,sequence:90,separator:!0}).addChild("format_clearFormat",["format"],{...Ub,sequence:100,separator:!0}).add("data",{name:r("Data"),sequence:60}).addChild("sort_range",["data"],{...Qf,sequence:10,separator:!0}).addChild("sort_ascending",["data","sort_range"],{...Jf,sequence:10}).addChild("sort_descending",["data","sort_range"],{...eb,sequence:20}).addChild("split_to_columns",["data"],{...ob,sequence:20,separator:!0}).addChild("add_remove_data_filter",["data"],{...tb,sequence:30});const jb=new class extends Ji{addTransformation(e,t,o){for(let i of t)this.content[i]||(this.content[i]=new Map),this.content[i].set(e,o);return this}getTransformation(e,t){return this.content[e]&&this.content[e].get(t)}},Xb={ArrowDown:"down",ArrowLeft:"left",ArrowRight:"right",ArrowUp:"up"};function Kb(e,t){const o=Xb[e.key];e.shiftKey?t.resizeAnchorZone(o,Or(e)?"end":1):t.moveAnchorCell(o,Or(e)?"end":1)}const Qb=new Bi;Wi`
|
|
358
358
|
.o-selection {
|
|
359
359
|
.o-selection-input {
|
|
360
360
|
padding: 2px 0px;
|
|
@@ -405,7 +405,7 @@
|
|
|
405
405
|
font-size: calc(100% + 4px);
|
|
406
406
|
}
|
|
407
407
|
}
|
|
408
|
-
`;class
|
|
408
|
+
`;class Jb extends t.Component{static template="o-spreadsheet-SelectionInput";id=Qb.uuidv4();previousRanges=this.props.ranges()||[];originSheet=this.env.model.getters.getActiveSheetId();state=t.useState({isMissing:!1,mode:"select-range"});focusedInput=t.useRef("focusedInput");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+1,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}get isConfirmable(){return this.hasFocus&&this.ranges.every((e=>e.isValidRange))}get isResettable(){return this.previousRanges.join()!==this.ranges.map((e=>e.xc)).join()}setup(){t.useEffect((()=>this.focusedInput.el?.focus()),(()=>[this.focusedInput.el])),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),t=!this.isInvalid&&this.ranges.every((e=>e.isValidRange));t&&this.previousRanges.join()!==e.join()&&this.triggerChange()}getColor(e){return"color: "+(e.color||"#000")+";"}triggerChange(){const e=this.env.model.getters.getSelectionInputValue(this.id);this.props.onSelectionChanged?.(e)}onKeydown(e){if("F2"===e.key)e.preventDefault(),e.stopPropagation(),this.state.mode="select-range"===this.state.mode?"text-edit":"select-range";else if(e.key.startsWith("Arrow"))e.stopPropagation(),"select-range"===this.state.mode&&(e.preventDefault(),Kb(e,this.env.model.selection));else if("Enter"===e.key){e.target.blur(),this.confirm()}}extractRanges(e){return this.props.hasSingleRange?e.split(",")[0]:e}focus(e){this.state.isMissing=!1,this.state.mode="select-range",this.env.model.dispatch("FOCUS_RANGE",{id:this.id,rangeId:e})}addEmptyInput(){this.env.model.dispatch("ADD_EMPTY_RANGE",{id:this.id})}removeInput(e){this.env.model.dispatch("REMOVE_RANGE",{id:this.id,rangeId:e}),this.triggerChange(),this.props.onSelectionConfirmed?.()}onInputChanged(e,t){const o=t.target,i=this.extractRanges(o.value);this.env.model.dispatch("CHANGE_RANGE",{id:this.id,rangeId:e,value:i}),this.triggerChange()}reset(){this.env.model.dispatch("ENABLE_NEW_SELECTION_INPUT",{id:this.id,initialRanges:this.previousRanges,hasSingleRange:this.props.hasSingleRange}),this.confirm()}confirm(){let e=!1;const t=this.env.model.getters.getSelectionInput(this.id),o=[];for(const i of t){if(""===i.xc){if(this.env.model.dispatch("REMOVE_RANGE",{id:this.id,rangeId:i.id}).isSuccessful)continue}o.push(i.xc),this.env.model.getters.isRangeValid(i.xc)&&(e=!0)}this.props.required&&!e&&(this.state.isMissing=!0);const i=this.env.model.getters.getActiveSheetId();this.originSheet!==i&&this.env.model.dispatch("ACTIVATE_SHEET",{sheetIdFrom:i,sheetIdTo:this.originSheet}),this.props.onSelectionChanged?.(o),this.props.onSelectionConfirmed?.(),this.previousRanges=this.props.ranges(),o.join()!==this.previousRanges.join()&&this.enableNewSelectionInput(),this.env.model.dispatch("UNFOCUS_SELECTION_INPUT")}}Jb.props={ranges:Function,hasSingleRange:{type:Boolean,optional:!0},required:{type:Boolean,optional:!0},isInvalid:{type:Boolean,optional:!0},class:{type:String,optional:!0},onSelectionChanged:{type:Function,optional:!0},onSelectionConfirmed:{type:Function,optional:!0}},Wi`
|
|
409
409
|
.o-sidepanel-error,
|
|
410
410
|
.o-sidepanel-warning {
|
|
411
411
|
margin-top: 10px;
|
|
@@ -416,7 +416,7 @@
|
|
|
416
416
|
width: 1.2em;
|
|
417
417
|
}
|
|
418
418
|
}
|
|
419
|
-
`;class
|
|
419
|
+
`;class ev extends t.Component{static template="o-spreadsheet-SidePanelErrors";get divClasses(){return"warning"===this.props.msgType?"o-sidepanel-warning text-warning":"o-sidepanel-error text-danger"}}ev.props={messages:Array,msgType:String};class tv extends t.Component{static template="o-spreadsheet-LineBarPieConfigPanel";static components={SelectionInput:Jb,SidePanelErrors:ev};state=t.useState({datasetDispatchResult:void 0,labelsDispatchResult:void 0});dataSeriesRanges=[];labelRange;setup(){this.dataSeriesRanges=this.props.definition.dataSets,this.labelRange=this.props.definition.labelRange}get errorMessages(){return[...this.state.datasetDispatchResult?.reasons||[],...this.state.labelsDispatchResult?.reasons||[]].map((e=>up.Errors[e]||up.Errors.Unexpected))}get isDatasetInvalid(){return!!this.state.datasetDispatchResult?.isCancelledBecause(35)}get isLabelInvalid(){return!!this.state.labelsDispatchResult?.isCancelledBecause(36)}onUpdateDataSetsHaveTitle(e){this.props.updateChart(this.props.figureId,{dataSetsHaveTitle:e.target.checked})}onDataSeriesRangesChanged(e){this.dataSeriesRanges=e,this.state.datasetDispatchResult=this.props.canUpdateChart(this.props.figureId,{dataSets:this.dataSeriesRanges})}onDataSeriesConfirmed(){this.dataSeriesRanges=function(e,t){const o=[];for(const i of t){if(!e.isRangeValid(i)){o.push(i);continue}const{sheetName:t}=Jo(i),s=t?`${t}!`:"",r=ei(i);if(r.bottom!==r.top&&r.left!=r.right)if(r.right)for(let e=r.left;e<=r.right;++e)o.push(`${s}${ii({left:e,right:e,top:r.top,bottom:r.bottom})}`);else for(let e=r.top;e<=r.bottom;++e)o.push(`${s}${ii({left:r.left,right:r.right,top:e,bottom:e})}`);else o.push(i)}return o}(this.env.model.getters,this.dataSeriesRanges),this.state.datasetDispatchResult=this.props.updateChart(this.props.figureId,{dataSets:this.dataSeriesRanges})}getDataSeriesRanges(){return this.dataSeriesRanges}onLabelRangeChanged(e){this.labelRange=e[0],this.state.labelsDispatchResult=this.props.canUpdateChart(this.props.figureId,{labelRange:this.labelRange})}onLabelRangeConfirmed(){this.state.labelsDispatchResult=this.props.updateChart(this.props.figureId,{labelRange:this.labelRange})}getLabelRange(){return this.labelRange||""}onUpdateAggregated(e){this.props.updateChart(this.props.figureId,{aggregated:e.target.checked})}calculateHeaderPosition(){if(this.isDatasetInvalid||this.isLabelInvalid)return;const e=this.env.model.getters,t=e.getActiveSheetId(),o=Ai(e,t,this.labelRange),i=Xg(e,this.dataSeriesRanges,t,this.props.definition.dataSetsHaveTitle);return i.length?i[0].dataRange.zone.top+1:o?o.zone.top+1:void 0}}tv.props={figureId:String,definition:Object,updateChart:Function,canUpdateChart:Function};class ov extends tv{static template="o-spreadsheet-BarConfigPanel";onUpdateStacked(e){this.props.updateChart(this.props.figureId,{stacked:e.target.checked})}onUpdateAggregated(e){this.props.updateChart(this.props.figureId,{aggregated:e.target.checked})}}function iv(e,t,o=(()=>{})){const i=r=>{t(r),window.removeEventListener("mousedown",o),window.removeEventListener("mouseup",i),window.removeEventListener("dragstart",s),window.removeEventListener("mousemove",e),window.removeEventListener("wheel",e)};function s(e){e.preventDefault()}window.addEventListener("mousedown",o),window.addEventListener("mouseup",i),window.addEventListener("dragstart",s),window.addEventListener("mousemove",e),window.addEventListener("wheel",e,{passive:!1})}function sv(e,t,o,i=!1){let s,r,n,a,l,c=null;const h=e.model.getters,d=h.getActiveSheetId(),u=Ir();let g,p;const m=o=>{if(s=o,c)return;const{x:n,y:f}=h.getMainViewportCoordinates();let{top:b,left:v,bottom:S,right:C}=h.getActiveMainViewport(),{scrollX:E,scrollY:w}=h.getActiveSheetDOMScrollInfo();const{xSplit:x,ySplit:y}=h.getPaneDivisions(d);let I=!1,R=jt;const T=s.clientX-u.left;if(g=h.getColIndex(T),"vertical"!==i){const t=r.clientX-u.left,o=h.getEdgeScrollCol(T,t,a);if(o.canEdgeScroll){let t;switch(I=!0,R=Math.min(R,o.delay),o.direction){case"reset":g=x,t=x;break;case 1:g=C,t=v+1;break;case-1:for(g=v-1;e.model.getters.isColHidden(d,g);)g--;t=g}E=h.getColDimensions(d,t).start-n}}const A=s.clientY-u.top;if(p=h.getRowIndex(A),"horizontal"!==i){const t=r.clientY-u.top,o=h.getEdgeScrollRow(A,t,l);if(o.canEdgeScroll){let t;switch(I=!0,R=Math.min(R,o.delay),o.direction){case"reset":p=y,t=y;break;case 1:p=S,t=b+o.direction;break;case-1:for(p=b-1;e.model.getters.isRowHidden(d,p);)p--;t=p}w=e.model.getters.getRowDimensions(d,t).start-f}}I||(-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,s),I&&(e.model.dispatch("SET_VIEWPORT_OFFSET",{offsetX:E,offsetY:w}),c=setTimeout((()=>{c=null,m(s)}),Math.round(R))),r=s};iv(m,(()=>{clearTimeout(c),o()}),(e=>{r=e,n=e,a=n.clientX-u.left,l=n.clientY-u.top}))}const rv=216,nv=186;Wi`
|
|
420
420
|
.o-color-picker {
|
|
421
421
|
padding: ${8}px 0;
|
|
422
422
|
/** FIXME: this is useless, overiden by the popover container */
|
|
@@ -583,7 +583,7 @@
|
|
|
583
583
|
}
|
|
584
584
|
}
|
|
585
585
|
}
|
|
586
|
-
`;class
|
|
586
|
+
`;class av extends t.Component{static template="o-spreadsheet-ColorPicker";static defaultProps={currentColor:""};static components={Popover:Lr};COLORS=_;state=t.useState({showGradient:!1,currentHslaColor:at(this.props.currentColor)?{...ft(this.props.currentColor),a:1}:{h:0,s:100,l:100,a:1},customHexColor:at(this.props.currentColor)?nt(this.props.currentColor):""});get colorPickerStyle(){return void 0!==this.props.maxHeight&&this.props.maxHeight<=0?Yi({display:"none"}):""}get popoverProps(){return{anchorRect:this.props.anchorRect,maxHeight:this.props.maxHeight,positioning:"BottomLeft",verticalOffset:0}}get gradientHueStyle(){return Yi({background:`hsl(${this.state.currentHslaColor?.h||0} 100% 50%)`})}get sliderStyle(){const e=this.state.currentHslaColor?.h||0;return Yi({"margin-left":`${xe(Math.round(e/360*rv),1,rv)-9}px`})}get pointerStyle(){const{s:e,l:t}=this.state.currentHslaColor||{s:0,l:0};return Yi({left:`${-8+Math.round(rv*xe(e/100,0,1))}px`,top:`${-8+Math.round(nv*xe(1-2*t/(200-e),0,1))}px`,background:mt(this.state.currentHslaColor)})}get colorPreviewStyle(){return Yi({"background-color":mt(this.state.currentHslaColor)})}get checkmarkColor(){return ip(this.props.currentColor)}get isHexColorInputValid(){return!this.state.customHexColor||at(this.state.customHexColor)}setCustomGradient({x:e,y:t}){const o=xe(e,0,rv),i=xe(t,0,nv),s=o/rv,r=100*s,n=100*(1-i/nv)*(1-.5*s);this.updateColor({s:r,l:n})}setCustomHue(e){const t=Math.round(xe(360*e/rv,0,359));this.updateColor({h:t})}updateColor(e){this.state.currentHslaColor={...this.state.currentHslaColor,...e},this.state.customHexColor=mt(this.state.currentHslaColor)}onColorClick(e){e&&this.props.onColorPicked(nt(e))}resetColor(){this.props.onColorPicked("")}toggleColorPicker(){this.state.showGradient=!this.state.showGradient}dragGradientPointer(e){const t={x:e.offsetX,y:e.offsetY};this.setCustomGradient(t);const o=e.clientX,i=e.clientY;iv((e=>{const s=e.clientX,r=e.clientY,n={x:t.x+(s-o),y:t.y+(r-i)};this.setCustomGradient(n)}),(()=>{}))}dragHuePointer(e){const t=e.offsetX,o=e.clientX;this.setCustomHue(t);iv((e=>{const i=e.clientX,s=t+(i-o);this.setCustomHue(s)}),(()=>{}))}setHexColor(e){const t=e.target.value.slice(0,7);this.state.customHexColor=t,at(t)&&(this.state.currentHslaColor={...ft(t),a:1})}addCustomColor(e){(function(e){try{return mt(e),!0}catch(e){return!1}})(this.state.currentHslaColor)&&at(this.state.customHexColor)&&this.props.onColorPicked(nt(this.state.customHexColor))}isSameColor(e,t){return function(e,t,o=0){if(!at(e)||!at(t))return!1;const i=ut(e),s=ut(t);return i.a===s.a&&Math.sqrt(((i.r-s.r)/255)**2+((i.g-s.g)/255)**2+((i.b-s.b)/255)**2)<=o}(e,t)}}av.props={onColorPicked:Function,currentColor:{type:String,optional:!0},maxHeight:{type:Number,optional:!0},anchorRect:Object},Wi`
|
|
587
587
|
.o-color-picker-widget {
|
|
588
588
|
display: flex;
|
|
589
589
|
position: relative;
|
|
@@ -616,7 +616,7 @@
|
|
|
616
616
|
}
|
|
617
617
|
}
|
|
618
618
|
}
|
|
619
|
-
`;class
|
|
619
|
+
`;class lv extends t.Component{static template="o-spreadsheet-ColorPickerWidget";static components={ColorPicker:av};colorPickerButtonRef=t.useRef("colorPickerButton");get iconStyle(){return this.props.currentColor?`border-color: ${this.props.currentColor}`:"border-bottom-style: hidden"}get colorPickerAnchorRect(){const e=this.colorPickerButtonRef.el.getBoundingClientRect();return{x:e.x,y:e.y,width:e.width,height:e.height}}}lv.props={currentColor:{type:String,optional:!0},toggleColorPicker:Function,showColorPicker:Boolean,onColorPicked:Function,icon:String,title:{type:String,optional:!0},disabled:{type:Boolean,optional:!0},dropdownMaxHeight:{type:Number,optional:!0},class:{type:String,optional:!0}};class cv extends t.Component{static template="o-spreadsheet-LineBarPieDesignPanel";static components={ColorPickerWidget:lv};state=t.useState({title:"",fillColorTool:!1});onClick(e){this.state.fillColorTool=!1}setup(){this.state.title=s(this.props.definition.title),t.useExternalListener(window,"click",this.onClick)}toggleColorPicker(){this.state.fillColorTool=!this.state.fillColorTool}updateBackgroundColor(e){this.props.updateChart(this.props.figureId,{background:e})}updateTitle(){this.props.updateChart(this.props.figureId,{title:this.state.title})}updateSelect(e,t){this.props.updateChart(this.props.figureId,{[e]:t.target.value})}}cv.props={figureId:String,definition:Object,updateChart:Function,canUpdateChart:Function};class hv extends t.Component{static template="o-spreadsheet-GaugeChartConfigPanel";static components={SelectionInput:Jb,SidePanelErrors:ev};state=t.useState({dataRangeDispatchResult:void 0});dataRange=this.props.definition.dataRange;get configurationErrorMessages(){return[...this.state.dataRangeDispatchResult?.reasons||[]].map((e=>up.Errors[e]||up.Errors.Unexpected))}get isDataRangeInvalid(){return!!this.state.dataRangeDispatchResult?.isCancelledBecause(39)}onDataRangeChanged(e){this.dataRange=e[0],this.state.dataRangeDispatchResult=this.props.canUpdateChart(this.props.figureId,{dataRange:this.dataRange})}updateDataRange(){this.state.dataRangeDispatchResult=this.props.updateChart(this.props.figureId,{dataRange:this.dataRange})}getDataRange(){return this.dataRange||""}}hv.props={figureId:String,definition:Object,updateChart:Function,canUpdateChart:Function},Wi`
|
|
620
620
|
.o-gauge-color-set {
|
|
621
621
|
table {
|
|
622
622
|
table-layout: fixed;
|
|
@@ -646,7 +646,7 @@
|
|
|
646
646
|
box-sizing: border-box;
|
|
647
647
|
}
|
|
648
648
|
}
|
|
649
|
-
`;class
|
|
649
|
+
`;class dv extends t.Component{static template="o-spreadsheet-GaugeChartDesignPanel";static components={ColorPickerWidget:lv,SidePanelErrors:ev};state=t.useState({title:"",openedMenu:void 0,sectionRuleDispatchResult:void 0,sectionRule:Ce(this.props.definition.sectionRule)});setup(){this.state.title=s(this.props.definition.title),t.useExternalListener(window,"click",this.closeMenus)}get designErrorMessages(){return[...this.state.sectionRuleDispatchResult?.reasons||[]].map((e=>up.Errors[e]||up.Errors.Unexpected))}updateBackgroundColor(e){this.state.openedMenu=void 0,this.props.updateChart(this.props.figureId,{background:e})}updateTitle(){this.props.updateChart(this.props.figureId,{title:this.state.title})}isRangeMinInvalid(){return!!(this.state.sectionRuleDispatchResult?.isCancelledBecause(40)||this.state.sectionRuleDispatchResult?.isCancelledBecause(41)||this.state.sectionRuleDispatchResult?.isCancelledBecause(44))}isRangeMaxInvalid(){return!!(this.state.sectionRuleDispatchResult?.isCancelledBecause(42)||this.state.sectionRuleDispatchResult?.isCancelledBecause(43)||this.state.sectionRuleDispatchResult?.isCancelledBecause(44))}get isLowerInflectionPointInvalid(){return!(!this.state.sectionRuleDispatchResult?.isCancelledBecause(45)&&!this.state.sectionRuleDispatchResult?.isCancelledBecause(47))}get isUpperInflectionPointInvalid(){return!(!this.state.sectionRuleDispatchResult?.isCancelledBecause(46)&&!this.state.sectionRuleDispatchResult?.isCancelledBecause(47))}updateSectionColor(e,t){const o=Ce(this.state.sectionRule);o.colors[e]=t,this.updateSectionRule(o),this.closeMenus()}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})}canUpdateSectionRule(e){this.state.sectionRuleDispatchResult=this.props.canUpdateChart(this.props.figureId,{sectionRule:e})}closeMenus(){this.state.openedMenu=void 0}}dv.props={figureId:String,definition:Object,updateChart:Function,canUpdateChart:Function};class uv extends tv{static template="o-spreadsheet-LineConfigPanel";get canTreatLabelsAsText(){const e=this.env.model.getters.getChart(this.props.figureId);return!!(e&&e instanceof Pp)&&kp(e.labelRange,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})}onUpdateAggregated(e){this.props.updateChart(this.props.figureId,{aggregated:e.target.checked})}onUpdateCumulative(e){this.props.updateChart(this.props.figureId,{cumulative:e.target.checked})}}class gv extends t.Component{static template="o-spreadsheet-ScorecardChartConfigPanel";static components={SelectionInput:Jb,SidePanelErrors:ev};state=t.useState({keyValueDispatchResult:void 0,baselineDispatchResult:void 0});keyValue=this.props.definition.keyValue;baseline=this.props.definition.baseline;get errorMessages(){return[...this.state.keyValueDispatchResult?.reasons||[],...this.state.baselineDispatchResult?.reasons||[]].map((e=>up.Errors[e]||up.Errors.Unexpected))}get isKeyValueInvalid(){return!!this.state.keyValueDispatchResult?.isCancelledBecause(37)}get isBaselineInvalid(){return!!this.state.keyValueDispatchResult?.isCancelledBecause(38)}onKeyValueRangeChanged(e){this.keyValue=e[0],this.state.keyValueDispatchResult=this.props.canUpdateChart(this.props.figureId,{keyValue:this.keyValue})}updateKeyValueRange(){this.state.keyValueDispatchResult=this.props.updateChart(this.props.figureId,{keyValue:this.keyValue})}getKeyValueRange(){return this.keyValue||""}onBaselineRangeChanged(e){this.baseline=e[0],this.state.baselineDispatchResult=this.props.canUpdateChart(this.props.figureId,{baseline:this.baseline})}updateBaselineRange(){this.state.baselineDispatchResult=this.props.updateChart(this.props.figureId,{baseline:this.baseline})}getBaselineRange(){return this.baseline||""}updateBaselineMode(e){this.props.updateChart(this.props.figureId,{baselineMode:e.target.value})}}gv.props={figureId:String,definition:Object,updateChart:Function,canUpdateChart:Function};class pv extends t.Component{static template="o-spreadsheet-ScorecardChartDesignPanel";static components={ColorPickerWidget:lv};state=t.useState({title:"",openedColorPicker:void 0});setup(){this.state.title=s(this.props.definition.title),t.useExternalListener(window,"click",this.closeMenus)}updateTitle(){this.props.updateChart(this.props.figureId,{title:this.state.title})}updateBaselineDescr(e){this.props.updateChart(this.props.figureId,{baselineDescr:e.target.value})}toggleColorPicker(e){this.state.openedColorPicker===e?this.state.openedColorPicker=void 0: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.closeMenus()}closeMenus(){this.state.openedColorPicker=void 0}}pv.props={figureId:String,definition:Object,updateChart:Function,canUpdateChart:Function};const mv=new Ji;mv.add("line",{configuration:uv,design:class extends cv{static template="o-spreadsheet-LineChartDesignPanel"}}).add("bar",{configuration:ov,design:class extends cv{static template="o-spreadsheet-BarChartDesignPanel"}}).add("pie",{configuration:tv,design:cv}).add("gauge",{configuration:hv,design:dv}).add("scorecard",{configuration:gv,design:pv}),Wi`
|
|
650
650
|
.o-chart {
|
|
651
651
|
.o-panel {
|
|
652
652
|
display: flex;
|
|
@@ -669,7 +669,7 @@
|
|
|
669
669
|
}
|
|
670
670
|
}
|
|
671
671
|
}
|
|
672
|
-
`;class
|
|
672
|
+
`;class fv extends t.Component{static template="o-spreadsheet-ChartPanel";state;get figureId(){return this.state.figureId}setup(){const e=this.env.model.getters.getSelectedFigureId();e?(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()}))):this.props.onCloseSidePanel()}updateChart(e,t){if(e!==this.figureId)return;const o={...this.getChartDefinition(),...t};return this.env.model.dispatch("UPDATE_CHART",{definition:o,id:e,sheetId:this.env.model.getters.getFigureSheetId(e)})}canUpdateChart(e,t){if(e!==this.figureId||!this.env.model.getters.isChartDefined(e))return;const o={...this.getChartDefinition(),...t};return this.env.model.canDispatch("UPDATE_CHART",{definition:o,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 o=function(e,t){return qp.get(t).getChartDefinitionFromContextCreation(e)}(t,e);this.env.model.dispatch("UPDATE_CHART",{definition:o,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=mv.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 qp.getKeys())e[t]=qp.get(t).name;return e}()}activatePanel(e){this.state.panel=e}}fv.props={onCloseSidePanel:Function},Wi`
|
|
673
673
|
.o-spreadsheet {
|
|
674
674
|
.o-icon {
|
|
675
675
|
.small-text {
|
|
@@ -680,7 +680,7 @@
|
|
|
680
680
|
}
|
|
681
681
|
}
|
|
682
682
|
}
|
|
683
|
-
`;function
|
|
683
|
+
`;function bv(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 vv={arrowGood:{template:"ARROW_UP",img:bv('<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:bv('<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:bv('<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:bv('<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:bv('<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:bv('<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:bv('<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:bv('<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:bv('<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>')}},Sv={arrows:{good:"arrowGood",neutral:"arrowNeutral",bad:"arrowBad"},smiley:{good:"smileyGood",neutral:"smileyNeutral",bad:"smileyBad"},dots:{good:"dotGood",neutral:"dotNeutral",bad:"dotBad"}};Wi`
|
|
684
684
|
.o-icon-picker {
|
|
685
685
|
position: absolute;
|
|
686
686
|
z-index: ${ge.IconPicker};
|
|
@@ -699,7 +699,7 @@
|
|
|
699
699
|
outline: 1px solid gray;
|
|
700
700
|
}
|
|
701
701
|
}
|
|
702
|
-
`;class
|
|
702
|
+
`;class Cv extends t.Component{static template="o-spreadsheet-IconPicker";icons=vv;iconSets=Sv;onIconClick(e){e&&this.props.onIconPicked(e)}}Cv.props={onIconPicked:Function},Wi`
|
|
703
703
|
label {
|
|
704
704
|
vertical-align: middle;
|
|
705
705
|
}
|
|
@@ -969,13 +969,13 @@
|
|
|
969
969
|
}
|
|
970
970
|
}
|
|
971
971
|
}
|
|
972
|
-
`;class
|
|
972
|
+
`;class Ev extends t.Component{static template="o-spreadsheet-ConditionalFormattingPanel";static components={SelectionInput:Jb,IconPicker:Cv,ColorPickerWidget:lv};icons=vv;cellIsOperators=dp;iconSets=Sv;getTextDecoration=Gi;colorNumberString=rt;activeSheetId;state;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(),o=this.env.model.getters.getRulesSelection(e,this.props.selection||[]);if(1===o.length){const e=this.conditionalFormats.find((e=>e.id===o[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(),o=this.env.model.getters.getRulesSelection(t,e.selection||[]);if(1===o.length){const e=this.conditionalFormats.find((e=>e.id===o[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()).map((e=>({...e,rule:Ig(e.rule,this.env.model.getters.getLocale())})))}get isRangeValid(){return this.state.errors.includes(25)}errorMessage(e){return hp.Errors[e]||hp.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 Yi({"font-weight":e.style.bold?"bold":"normal","text-decoration":Gi(e.style),"font-style":e.style.italic?"italic":"normal",color:e.style.textColor||"none","background-color":e.style.fillColor||"none"});if("ColorScaleRule"===e.type){const t=rt(e.minimum.color),o=e.midpoint?rt(e.midpoint.color):null,i=rt(e.maximum.color),s="background-image: linear-gradient(to right, ";return o?s+t+", "+o+", "+i+")":s+t+", "+i+")"}return""}getDescription(e){switch(e.rule.type){case"CellIsRule":const t=dp[e.rule.operator];return 1===e.rule.values.length?`${t} ${e.rule.values[0]}`:2===e.rule.values.length?s("%s %s and %s",t,e.rule.values[0],e.rule.values[1]):t;case"ColorScaleRule":return hp.ColorScale;case"IconSetRule":return hp.IconSet;default:return""}}saveConditionalFormat(){if(this.state.currentCF){if(this.state.currentCF.ranges.some((e=>!e.match(Zo))))return void(this.state.errors=[26]);const e=this.env.model.getters.getActiveSheetId(),t=this.env.model.getters.getLocale(),o=this.env.model.dispatch("ADD_CONDITIONAL_FORMAT",{cf:{rule:yg(this.getEditorRule(),t),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});o.isSuccessful?this.switchToList():this.state.errors=o.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(){return!!this.state.errors?.includes(54)}get isValue2Invalid(){return!!this.state.errors?.includes(55)}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(61)||this.state.errors.includes(53)||this.state.errors.includes(50)||this.state.errors.includes(56);case"midpoint":return this.state.errors.includes(62)||this.state.errors.includes(57)||this.state.errors.includes(52);case"maximum":return this.state.errors.includes(63)||this.state.errors.includes(58);default:return!1}}setColorScaleColor(e,t){const o=this.state.rules.colorScale[e];o&&(o.color=Number.parseInt(t.substr(1),16)),this.closeMenus()}getPreviewGradient(){const e=this.state.rules.colorScale,t=rt(e.minimum.color),o=rt(e.midpoint?.color||I),i=rt(e.maximum.color),s="background-image: linear-gradient(to right, ";return void 0===e.midpoint?s+t+", "+i+")":s+t+", "+o+", "+i+")"}getThresholdColor(e){return rt(e?e.color:I)}onMidpointChange(e){const t=e.target.value,o=this.state.rules.colorScale;o.midpoint="none"===t?void 0:{color:I,value:"",...o.midpoint,type:t}}isInflectionPointInvalid(e){switch(e){case"lowerInflectionPoint":return this.state.errors.includes(60)||this.state.errors.includes(65)||this.state.errors.includes(51);case"upperInflectionPoint":return this.state.errors.includes(59)||this.state.errors.includes(64)||this.state.errors.includes(51);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}}Ev.props={selection:{type:Object,optional:!0},onCloseSidePanel:Function},Wi`
|
|
973
973
|
.o-custom-currency {
|
|
974
974
|
.o-format-proposals {
|
|
975
975
|
color: black;
|
|
976
976
|
}
|
|
977
977
|
}
|
|
978
|
-
`;class
|
|
978
|
+
`;class wv extends t.Component{static template="o-spreadsheet-CustomCurrencyPanel";availableCurrencies;state;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=e.position,o="before"===e.position?"after":"before",i=this.state.currencySymbol.trim()?this.state.currencySymbol:"",s=this.state.currencyCode.trim()?this.state.currencyCode:"",r=e.decimalPlaces;if(!i&&!s)return[];const n=i?_o({symbol:i,position:t,decimalPlaces:r}):"",a=n?Fo(n):"",l=_o({symbol:i,position:t,decimalPlaces:r,code:s}),c=Fo(l),h=i?_o({symbol:i,position:o,decimalPlaces:r}):"",d=h?Fo(h):"",u=_o({symbol:i,position:o,decimalPlaces:r,code:s}),g=Fo(u);return[...new Set([a,n,c,l,d,h,g,u])].filter((e=>""!==e)).map((e=>({format:e,example:fo(1e3,{format:e,locale:this.env.model.getters.getLocale()})})))}get isSameFormat(){const e=this.formatProposals[this.state.selectedFormatIndex];return!!e&&e.format===this.getCommonFormat()}async updateAvailableCurrencies(){if(0===Yp.getAll().length){(await(this.env.loadCurrencies?.())||[]).forEach(((e,t)=>{Yp.add(t.toString(),e)}))}const e={name:this.env._t(gp.Custom),code:"",symbol:"",decimalPlaces:2,position:"after"};this.availableCurrencies=[e,...Yp.getAll()]}updateSelectCurrency(e){const t=e.target;this.state.selectedCurrencyIndex=parseInt(t.value,10);const o=this.availableCurrencies[this.state.selectedCurrencyIndex];this.state.currencyCode=o.code,this.state.currencySymbol=o.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}getCommonFormat(){const e=this.env.model.getters.getSelectedZones(),t=this.env.model.getters.getActiveSheetId(),o=e.map((e=>this.env.model.getters.getEvaluatedCellsInZone(t,e))).flat(),i=o[0].format;return o.every((e=>e.format===i))?i:void 0}currencyDisplayName(e){return e.name+(e.code?` (${e.code})`:"")}}wv.props={onCloseSidePanel:Function},Wi`
|
|
979
979
|
.o-find-and-replace {
|
|
980
980
|
.o-far-item {
|
|
981
981
|
display: block;
|
|
@@ -1008,11 +1008,11 @@
|
|
|
1008
1008
|
}
|
|
1009
1009
|
}
|
|
1010
1010
|
}
|
|
1011
|
-
`;class
|
|
1011
|
+
`;class xv extends t.Component{static template="o-spreadsheet-FindAndReplacePanel";state=t.useState(this.initialState());debounceTimeoutId;showFormulaState=!1;findAndReplaceRef=t.useRef("findAndReplace");get hasSearchResult(){return null!==this.env.model.getters.getCurrentSelectedMatchIndex()}get pendingSearch(){return void 0!==this.debounceTimeoutId}setup(){this.showFormulaState=this.env.model.getters.shouldShowFormulas(),t.onMounted((()=>this.focusInput())),t.onWillUnmount((()=>{clearTimeout(this.debounceTimeoutId),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(),e.stopPropagation(),this.onSelectNextCell())}onKeydownReplace(e){"Enter"===e.key&&(e.preventDefault(),e.stopPropagation(),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})}debouncedUpdateSearch(){clearTimeout(this.debounceTimeoutId),this.debounceTimeoutId=setTimeout((()=>{this.updateSearch(),this.debounceTimeoutId=void 0}),200)}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}}}}xv.props={onCloseSidePanel:Function},Wi`
|
|
1012
1012
|
.o-locale-preview {
|
|
1013
1013
|
color: dimgrey;
|
|
1014
1014
|
}
|
|
1015
|
-
`;class
|
|
1015
|
+
`;class yv extends t.Component{static template="o-spreadsheet-SettingsPanel";loadedLocales=[];setup(){t.onWillStart((()=>this.loadLocales()))}onLocaleChange(e){const t=this.loadedLocales.find((t=>t.code===e));t&&this.env.model.dispatch("UPDATE_LOCALE",{locale:t})}async loadLocales(){this.loadedLocales=(await this.env.loadLocales()).filter(fg).sort(((e,t)=>e.name.localeCompare(t.name)))}get numberFormatPreview(){return fo(1234567.89,{format:"#,##0.00",locale:this.env.model.getters.getLocale()})}get dateFormatPreview(){const e=this.env.model.getters.getLocale();return fo(1.6,{format:e.dateFormat,locale:e})}get dateTimeFormatPreview(){const e=this.env.model.getters.getLocale();return fo(1.6,{format:e.dateFormat+" "+e.timeFormat,locale:e})}get currentLocale(){return this.env.model.getters.getLocale()}get supportedLocales(){const e=this.currentLocale,t=this.loadedLocales.find((t=>t.code===e.code));if(!t){return[...this.loadedLocales,e].sort(((e,t)=>e.name.localeCompare(t.name)))}if(!We(e,t)){const o=this.loadedLocales.indexOf(t),i=[...this.loadedLocales];return i[o]=e,i.sort(((e,t)=>e.name.localeCompare(t.name))),i}return this.loadedLocales}}yv.props={onCloseSidePanel:Function};const Iv={SplitIsDestructive:r("This will overwrite data in the subsequent columns. Split anyway?")};const Rv=[{name:r("Detect automatically"),value:"auto"},{name:r("Custom separator"),value:"custom"},{name:r("Space"),value:" "},{name:r("Comma"),value:","},{name:r("Semicolon"),value:";"},{name:r("Line Break"),value:fe}];class Tv extends t.Component{static template="o-spreadsheet-SplitIntoColumnsPanel";static components={SidePanelErrors:ev};state=t.useState({separatorValue:"auto",addNewColumns:!1,customSeparator:""});setup(){t.onWillUpdateProps((()=>{"inactive"!==this.env.model.getters.getEditionMode()&&this.props.onCloseSidePanel()})),t.onMounted((()=>{this.env.model.dispatch("STOP_EDITION")}))}onSeparatorChange(e){this.state.separatorValue=e}updateCustomSeparator(e){e.target&&(this.state.customSeparator=e.target.value)}updateAddNewColumnsCheckbox(e){e.target&&(this.state.addNewColumns=e.target.checked)}confirm(){(function(e,t,o){let i=e.model.dispatch("SPLIT_TEXT_INTO_COLUMNS",{separator:t,addNewColumns:o});return i.isCancelledBecause(93)&&e.askConfirmation(Iv.SplitIsDestructive,(()=>{i=e.model.dispatch("SPLIT_TEXT_INTO_COLUMNS",{separator:t,addNewColumns:o,force:!0})})),i})(this.env,this.separatorValue,this.state.addNewColumns).isSuccessful&&this.props.onCloseSidePanel()}get errorMessages(){const e=this.env.model.canDispatch("SPLIT_TEXT_INTO_COLUMNS",{separator:this.separatorValue,addNewColumns:this.state.addNewColumns,force:!0}).reasons,t=new Set;for(const o of e)switch(o){case 93:case 92:break;default:t.add(mp.Errors[o]||mp.Errors.Unexpected)}return Array.from(t)}get warningMessages(){const e=[];return this.env.model.canDispatch("SPLIT_TEXT_INTO_COLUMNS",{separator:this.separatorValue,addNewColumns:this.state.addNewColumns,force:!1}).reasons.includes(93)&&e.push(mp.Errors[93]),e}get separatorValue(){return"custom"===this.state.separatorValue?this.state.customSeparator:"auto"===this.state.separatorValue?this.env.model.getters.getAutomaticSeparator():this.state.separatorValue}get separators(){return Rv}get isConfirmDisabled(){return!this.separatorValue||this.errorMessages.length>0}}Tv.props={onCloseSidePanel:Function};const Av=new Ji;Av.add("ConditionalFormatting",{title:r("Conditional formatting"),Body:Ev}),Av.add("ChartPanel",{title:r("Chart"),Body:fv}),Av.add("FindAndReplace",{title:r("Find and Replace"),Body:xv}),Av.add("CustomCurrency",{title:r("Custom currency format"),Body:wv}),Av.add("SplitToColumns",{title:r("Split text into columns"),Body:Tv}),Av.add("Settings",{title:r("Spreadsheet settings"),Body:yv});const Ov=new class extends Ji{mapping={};uuidGenerator=new Bi;add(e,t){const o={...t,id:this.uuidGenerator.uuidv4()};return super.add(e,o)}};Wi`
|
|
1016
1016
|
div.o-figure {
|
|
1017
1017
|
box-sizing: border-box;
|
|
1018
1018
|
position: absolute;
|
|
@@ -1085,7 +1085,7 @@
|
|
|
1085
1085
|
}
|
|
1086
1086
|
}
|
|
1087
1087
|
}
|
|
1088
|
-
`;class
|
|
1088
|
+
`;class Mv extends t.Component{static template="o-spreadsheet-FigureComponent";static components={Menu:Vr};static defaultProps={onFigureDeleted:()=>{},onMouseDown:()=>{},onClickAnchor:()=>{}};menuState=t.useState({isOpen:!1,position:null,menuItems:[]});figureRef=t.useRef("figure");menuButtonRef=t.useRef("menuButton");menuButtonRect=Nr(this.menuButtonRef);borderWidth;get isSelected(){return this.env.model.getters.getSelectedFigureId()===this.props.figure.id}get figureRegistry(){return Qp}getBorderWidth(){return this.env.isDashboard()?0:this.isSelected?2:this.borderWidth}get borderStyle(){return`border: ${this.getBorderWidth()}px solid ${this.isSelected?E:"#c9ccd2"};`}get wrapperStyle(){const{x:e,y:t,width:o,height:i}=this.props.figure;return Yi({left:`${e}px`,top:`${t}px`,width:`${o}px`,height:`${i}px`,"z-index":String(ge.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)",Yi(t)}setup(){const e=Qp.get(this.props.figure.tag).borderWidth;this.borderWidth=void 0!==e?e:1,t.useEffect(((e,t,o)=>{e===t&&o?.focus({preventScroll:!0})}),(()=>[this.env.model.getters.getSelectedFigureId(),this.props.figure.id,this.figureRef.el])),t.onWillUnmount((()=>{this.props.onFigureDeleted()}))}clickAnchor(e,t,o){this.props.onClickAnchor(e,t,o)}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.stopPropagation(),e.preventDefault(),e.stopPropagation();break;case"ArrowDown":case"ArrowLeft":case"ArrowRight":case"ArrowUp":const o={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+o[0],y:t.y+o[1]}),e.stopPropagation(),e.preventDefault(),e.stopPropagation()}}onContextMenu(e){if(this.env.isDashboard())return;const t={x:e.clientX,y:e.clientY};this.openContextMenu(t)}showMenu(){const{x:e,y:t,width:o}=this.menuButtonRect,i={x:e>=G?e-G:e+o,y:t};this.openContextMenu(i)}openContextMenu(e){this.menuState.isOpen=!0,this.menuState.position=e,this.menuState.menuItems=Qp.get(this.props.figure.tag).menuBuilder(this.props.figure.id,this.props.onFigureDeleted,this.env)}}Mv.props={figure:Object,style:{type:String,optional:!0},onFigureDeleted:{type:Function,optional:!0},onMouseDown:{type:Function,optional:!0},onClickAnchor:{type:Function,optional:!0}},Wi`
|
|
1089
1089
|
.o-autofill {
|
|
1090
1090
|
position: absolute;
|
|
1091
1091
|
height: ${8}px;
|
|
@@ -1113,9 +1113,9 @@
|
|
|
1113
1113
|
pointer-events: none;
|
|
1114
1114
|
white-space: nowrap;
|
|
1115
1115
|
}
|
|
1116
|
-
`;class
|
|
1116
|
+
`;class Nv extends t.Component{static template="o-spreadsheet-Autofill";state=t.useState({position:{left:0,top:0},handler:!1});get style(){const{left:e,top:t}=this.props.position;return Yi({top:`${t}px`,left:`${e}px`,visibility:this.props.isVisible?"visible":"hidden"})}get handlerStyle(){const{left:e,top:t}=this.state.handler?this.state.position:this.props.position;return Yi({top:`${t}px`,left:`${e}px`})}get styleNextValue(){const{left:e,top:t}=this.state.position;return Yi({top:`${t+5}px`,left:`${e+15}px`})}getTooltip(){const e=this.env.model.getters.getAutofillTooltip();return e&&!e.component&&(e.component=_v),e}onMouseDown(e){let t,o;this.state.handler=!0;const i=e.clientX-this.props.position.left,s=e.clientY-this.props.position.top;sv(this.env,((e,r,n)=>{if(this.state.position={left:n.clientX-i,top:n.clientY-s},t!==e||o!==r){const i=this.env.model.getters.getActiveSheetId(),s=this.env.model.getters.getNumberCols(i),n=this.env.model.getters.getNumberRows(i);t=-1===e?t:xe(e,0,s),o=-1===r?o:xe(r,0,n),void 0!==t&&void 0!==o&&this.env.model.dispatch("AUTOFILL_SELECT",{col:t,row:o})}}),(()=>{this.state.handler=!1,this.state.position={...this.props.position},this.env.model.dispatch("AUTOFILL")}))}onDblClick(){this.env.model.dispatch("AUTOFILL_AUTO")}}Nv.props={position:Object,isVisible:Boolean};class _v extends t.Component{static template=t.xml`
|
|
1117
1117
|
<div t-esc="props.content"/>
|
|
1118
|
-
`}
|
|
1118
|
+
`}_v.props={content:String},Wi`
|
|
1119
1119
|
.o-client-tag {
|
|
1120
1120
|
position: absolute;
|
|
1121
1121
|
border-top-left-radius: 4px;
|
|
@@ -1125,7 +1125,7 @@
|
|
|
1125
1125
|
opacity: 0;
|
|
1126
1126
|
pointer-events: none;
|
|
1127
1127
|
}
|
|
1128
|
-
`;class
|
|
1128
|
+
`;class Fv extends t.Component{static template="o-spreadsheet-ClientTag";get tagStyle(){const{col:e,row:t,color:o}=this.props,{height:i}=this.env.model.getters.getSheetViewDimensionWithHeaders(),{x:s,y:r}=this.env.model.getters.getVisibleRect({left:e,top:t,right:e,bottom:t});return Yi({bottom:i-r+15+"px",left:s-1+"px",border:`1px solid ${o}`,"background-color":o,opacity:this.props.active?"1 !important":void 0})}}Fv.props={active:Boolean,name:String,color:String,col:Number,row:Number},Wi`
|
|
1129
1129
|
.o-autocomplete-dropdown {
|
|
1130
1130
|
pointer-events: auto;
|
|
1131
1131
|
background-color: #fff;
|
|
@@ -1144,7 +1144,7 @@
|
|
|
1144
1144
|
}
|
|
1145
1145
|
}
|
|
1146
1146
|
}
|
|
1147
|
-
`;class
|
|
1147
|
+
`;class Dv extends t.Component{static template="o-spreadsheet-TextValueProvider"}Dv.props={values:Array,selectedIndex:Number,onValueSelected:Function};class Lv{el;constructor(e){this.el=e}updateEl(e){this.el=e}selectRange(e,t){let o=window.getSelection();const{start:i,end:s}=this.getCurrentSelection();if(i===e&&s===t)return;const r=o.getRangeAt(0);let n;if(this.el.contains(r.startContainer)?n=r:(n=document.createRange(),o.removeAllRanges(),o.addRange(n)),e===t&&0===e)n.setStart(this.el,0),n.setEnd(this.el,0);else{const i=this.getText().length;(e<0||t>i)&&(console.warn(`wrong selection asked start ${e}, end ${t}, text content length ${i}`),e<0&&(e=0),t>i&&(t=i),e>i&&(e=i));let s=this.findChildAtCharacterIndex(e),r=this.findChildAtCharacterIndex(t);n.setStart(s.node,s.offset),o.extend(r.node,r.offset)}}findChildAtCharacterIndex(e){let t,o,i=Tr(this.el),s=e,r=!0;do{t=i.next(),t.done||t.value.hasChildNodes()||(t.value.textContent&&t.value.textContent.length<s?s-=t.value.textContent.length:t.value.textContent&&t.value.textContent.length>=s&&i.return(t.value),o=t.value),t.done||"P"!==t.value.nodeName||(r?r=!1:s--)}while(!t.done&&s);return t.value?{node:t.value,offset:s}:{node:o,offset:s}}setText(e){if(0===e.length)return void this.removeAll();const t=Array.from(this.el.childNodes),o=e.length;for(let i=0;i<o;i++){const o=e[i],s=t[i];let r,n=!1;s&&"P"===s.nodeName?r=s:(n=!0,r=document.createElement("p"));const a=o.length,l=Array.from(r.childNodes);for(let e=0;e<a;e++){const t=o[e],i=l[e];if(i&&"tagName"in i&&"SPAN"===i.tagName&&Pv(t,i))continue;if(!t.value&&!t.class){i&&r.removeChild(i);continue}const s=document.createElement("span");s.innerText=t.value,s.style.color=t.color||"",t.class&&s.classList.add(t.class),i?r.replaceChild(s,i):r.appendChild(s)}if(l.length>a)for(let e=a;e<l.length;e++)r.removeChild(l[e]);if(!r.hasChildNodes()){const e=document.createElement("span");e.appendChild(document.createElement("br")),r.appendChild(e)}n&&(s?this.el.replaceChild(r,s):this.el.appendChild(r))}if(t.length>o)for(let e=o;e<t.length;e++)this.el.removeChild(t[e])}scrollSelectionIntoView(){const e=document.getSelection()?.focusNode;if(!e||!this.el.contains(e))return;(e instanceof HTMLElement?e:e.parentElement)?.scrollIntoView({block:"nearest"})}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:o,endSelectionOffset:i}=this.getStartAndEndSelection();return{start:this.findSelectionIndex(e,o),end:this.findSelectionIndex(t,i)}}findSelectionIndex(e,t){let o=0,i=Tr(this.el),s=i.next(),r=!0;for(;!s.done&&s.value!==e;)s.value.hasChildNodes()||s.value.textContent&&(o+=s.value.textContent.length),("P"===s.value.nodeName||"DIV"===s.value.nodeName&&s.value!==this.el)&&(r?r=!1:o++),s=i.next();if(s.value!==e)return 0;if(s.value.hasChildNodes()){const e=[...s.value.childNodes].slice(0,t);o+=e.reduce(((t,o,i)=>{if(null!==o.textContent){let s=o.textContent.length;return"P"===o.nodeName&&i!==e.length-1&&s++,t+s}return t}),0)}else o+=t;return"P"!==e.nodeName||r||""!==e.textContent||o++,o}getStartAndEndSelection(){const e=document.getSelection();return{startElement:e.anchorNode||this.el,startSelectionOffset:e.anchorOffset,endElement:e.focusNode||this.el,endSelectionOffset:e.focusOffset}}getText(){let e="",t=Tr(this.el),o=t.next(),i=!0;for(;!o.done;)o.value.hasChildNodes()||(e+=o.value.textContent),("P"===o.value.nodeName||"DIV"===o.value.nodeName&&o.value!==this.el)&&(i?i=!1:e+=fe),o=t.next();return e}}function Pv(e,t){const o=(e.color?nt(e.color):"")===(t.style?.color?nt(t.style.color):""),i=We([e.class],[...t.classList]),s=t.innerText===e.value;return o&&i&&s}Wi`
|
|
1148
1148
|
.o-formula-assistant {
|
|
1149
1149
|
.o-formula-assistant-head {
|
|
1150
1150
|
background-color: #f2f2f2;
|
|
@@ -1170,7 +1170,7 @@
|
|
|
1170
1170
|
color: gray;
|
|
1171
1171
|
}
|
|
1172
1172
|
}
|
|
1173
|
-
`;class
|
|
1173
|
+
`;class kv extends t.Component{static template="o-spreadsheet-FunctionDescriptionProvider";assistantState=t.useState({allowCellSelectionBehind:!1});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)}get formulaArgSeparator(){return this.env.model.getters.getLocale().formulaArgSeparator+" "}}kv.props={functionName:String,functionDescription:Object,argToFocus:Number};const Uv=fu.content,Vv="selector-flag",Bv="#4a4e4d",zv="#3da4ab",Hv={OPERATOR:zv,NUMBER:"#02c39a",STRING:"#00a82d",FUNCTION:Bv,DEBUGGER:zv,LEFT_PAREN:Bv,RIGHT_PAREN:Bv,ARG_SEPARATOR:Bv,MATCHING_PAREN:"#000000"};Wi`
|
|
1174
1174
|
.o-composer-container {
|
|
1175
1175
|
.o-composer {
|
|
1176
1176
|
overflow-y: auto;
|
|
@@ -1191,7 +1191,7 @@
|
|
|
1191
1191
|
|
|
1192
1192
|
span {
|
|
1193
1193
|
white-space: pre-wrap;
|
|
1194
|
-
&.${
|
|
1194
|
+
&.${Vv}:after {
|
|
1195
1195
|
content: "${"␣"}";
|
|
1196
1196
|
color: ${"#a9a9a9"};
|
|
1197
1197
|
}
|
|
@@ -1205,12 +1205,12 @@
|
|
|
1205
1205
|
pointer-events: none;
|
|
1206
1206
|
}
|
|
1207
1207
|
}
|
|
1208
|
-
`;class Gv extends t.Component{static template="o-spreadsheet-Composer";static components={TextValueProvider:Pv,FunctionDescriptionProvider:Vv};static defaultProps={inputStyle:"",isDefaultFocus:!1};composerRef=t.useRef("o_composer");contentHelper=new kv(this.composerRef.el);composerState=t.useState({positionStart:0,positionEnd:0});autoCompleteState=t.useState({showProvider:!1,values:[],selectedIndex:0});functionDescriptionState=t.useState({showDescription:!1,functionName:"",functionDescription:{},argToFocus:0});compositionActive=!1;get assistantStyle(){if(this.props.delimitation&&this.props.rect){const{x:e,y:t,height:o}=this.props.rect;let i={};return t>this.props.delimitation.height-(t+o)&&(i.top="-3px",i.transform="translate(0, -100%)"),e+300>this.props.delimitation.width&&(i.right="0px"),i.width="300px",Yi(i)}return Yi({width:"300px"})}shouldProcessInputEvents=!1;tokens=[];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)};keyCodeMapping={NumpadDecimal:this.processNumpadDecimal};setup(){t.onMounted((()=>{const e=this.composerRef.el;this.props.isDefaultFocus&&this.env.focusableElement.setFocusableElement(e),this.contentHelper.updateEl(e)})),t.useEffect((()=>{this.processContent()})),t.onPatched((()=>{"inactive"===this.env.model.getters.getEditionMode()&&this.processTokenAtCursor()}))}processArrowKeys(e){if(this.env.model.getters.isSelectingForComposer()||"inactive"===this.env.model.getters.getEditionMode())return this.functionDescriptionState.showDescription=!1,e.preventDefault(),e.stopPropagation(),void Jb(e,this.env.model.selection);const t=this.env.model.getters.getCurrentContent();"cellFocus"!==this.props.focus||this.autoCompleteState.showProvider||t.startsWith("=")?(e.stopPropagation(),this.handleArrowKeysForAutocomplete(e)):this.env.model.dispatch("STOP_EDITION")}handleArrowKeysForAutocomplete(e){["ArrowUp","ArrowDown"].includes(e.key)&&this.autoCompleteState.showProvider&&(e.preventDefault(),"ArrowUp"===e.key?(this.autoCompleteState.selectedIndex--,this.autoCompleteState.selectedIndex<0&&(this.autoCompleteState.selectedIndex=this.autoCompleteState.values.length-1)):this.autoCompleteState.selectedIndex=(this.autoCompleteState.selectedIndex+1)%this.autoCompleteState.values.length)}processTabKey(e){if(e.preventDefault(),e.stopPropagation(),"inactive"!==this.env.model.getters.getEditionMode()){if(this.autoCompleteState.showProvider){const e=this.autoCompleteState.values[this.autoCompleteState.selectedIndex]?.text;if(e)return void this.autoComplete(e)}this.env.model.dispatch("STOP_EDITION")}const t=e.shiftKey?"left":"right";this.env.model.selection.moveAnchorCell(t,1)}processEnterKey(e){if(e.preventDefault(),e.stopPropagation(),e.altKey||e.ctrlKey)return void this.composerRef.el?.dispatchEvent(new InputEvent("input",{inputType:"insertParagraph",bubbles:!0,isComposing:!1}));if(this.autoCompleteState.showProvider){const e=this.autoCompleteState.values[this.autoCompleteState.selectedIndex]?.text;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()}processNumpadDecimal(e){e.stopPropagation(),e.preventDefault();const t=this.env.model.getters.getLocale(),o=this.contentHelper.getCurrentSelection(),i=this.env.model.getters.getCurrentContent(),s=i.slice(0,o.start)+t.decimalSeparator+i.slice(o.end);this.env.model.dispatch("SET_CURRENT_CONTENT",{content:s,selection:{start:o.start+1,end:o.start+1}}),this.processContent()}onCompositionStart(){this.compositionActive=!0}onCompositionEnd(){this.compositionActive=!1}onKeydown(e){if("inactive"===this.env.model.getters.getEditionMode())return;let t=this.keyMapping[e.key]||this.keyCodeMapping[e.code];t?t.call(this,e):e.stopPropagation()}onPaste(e){"inactive"!==this.env.model.getters.getEditionMode()&&e.stopPropagation()}onInput(e){if(!this.shouldProcessInputEvents)return;if("insertFromPaste"===e.inputType&&"inactive"===this.env.model.getters.getEditionMode())return;let t;if(e.stopPropagation(),t="inactive"===this.env.model.getters.getEditionMode()?e.data||"":this.contentHelper.getText(),"inactive"===this.props.focus)return this.props.onComposerCellFocused?.(t);let o=this.contentHelper.getCurrentSelection();if("insertParagraph"===e.inputType){const e=Math.min(o.start,o.end),i=Math.max(o.start,o.end);t=t.slice(0,e)+fe+t.slice(i),o={start:e+1,end:e+1}}this.env.model.dispatch("STOP_COMPOSER_RANGE_SELECTION"),this.env.model.dispatch("SET_CURRENT_CONTENT",{content:t,selection:o}),this.processTokenAtCursor()}onKeyup(e){if(this.contentHelper.el===document.activeElement){if(this.autoCompleteState.showProvider&&["ArrowUp","ArrowDown"].includes(e.key))return;if(this.env.model.getters.isSelectingForComposer()&&e.key?.startsWith("Arrow"))return;const{start:t,end:o}=this.env.model.getters.getComposerSelection(),{start:i,end:s}=this.contentHelper.getCurrentSelection();i===t&&s===o||this.env.model.dispatch("CHANGE_COMPOSER_CURSOR_SELECTION",{start:i,end:s}),this.processTokenAtCursor()}}showAutocomplete(e){const t=e.toUpperCase();if(!this.env.model.getters.getCurrentContent().startsWith("=")||"TRUE"===t||"FALSE"===t)return;this.autoCompleteState.showProvider=!0;let o=Object.entries(fu.content).filter((([e,{hidden:t}])=>!t)).map((([e,{description:t}])=>({text:e,description:t})));o=e?Oi(e,o,(e=>e.text)):o.sort(((e,t)=>e.text.localeCompare(t.text))),this.autoCompleteState.values=o.slice(0,10),this.autoCompleteState.selectedIndex=0}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"),this.props.onComposerContentFocused(),this.props.focus,this.env.model.dispatch("CHANGE_COMPOSER_CURSOR_SELECTION",e),this.processTokenAtCursor()}onDblClick(){if(this.env.model.getters.isReadonly())return;const e=this.env.model.getters.getCurrentContent();if(e.startsWith("=")){const t=this.env.model.getters.getCurrentTokens(),o=this.contentHelper.getCurrentSelection();if(o.start===o.end)return;const i=e.substring(o.start,o.end),s=t.filter((e=>e.value.includes(i)&&e.start<=o.start&&e.end>=o.end))[0];if(!s)return;"REFERENCE"===s.type&&this.env.model.dispatch("CHANGE_COMPOSER_CURSOR_SELECTION",{start:s.start,end:s.end})}}processContent(){if(this.compositionActive)return;this.shouldProcessInputEvents=!1,"inactive"!==this.props.focus&&this.contentHelper.el.focus();const e=this.getContentLines();if(this.contentHelper.setText(e),0!==e.length&&0!==e.length[0]){if("inactive"!==this.props.focus){const{start:e,end:t}=this.env.model.getters.getComposerSelection();this.contentHelper.selectRange(e,t)}this.contentHelper.scrollSelectionIntoView()}this.shouldProcessInputEvents=!0}getContentLines(){let e=this.env.model.getters.getCurrentContent();const t=e.startsWith("=");return""===e?[]:t&&"inactive"!==this.props.focus?this.splitHtmlContentIntoLines(this.getColoredTokens()):this.splitHtmlContentIntoLines([{value:e}])}getColoredTokens(){const e=this.env.model.getters.getCurrentTokens(),t=this.env.model.getters.getTokenAtCursor(),o=[],{end:i,start:s}=this.env.model.getters.getComposerSelection();for(const r of e){switch(r.type){case"OPERATOR":case"NUMBER":case"ARG_SEPARATOR":case"STRING":o.push({value:r.value,color:Wv[r.type]||"#000"});break;case"REFERENCE":const{xc:e,sheetName:i}=Jo(r.value);o.push({value:r.value,color:this.rangeColor(e,i)||"#000"});break;case"SYMBOL":const s=r.value.toUpperCase();"TRUE"===s||"FALSE"===s?o.push({value:r.value,color:Wv.NUMBER}):s in fu.content?o.push({value:r.value,color:Wv.FUNCTION}):o.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?o.push({value:r.value,color:Wv.MATCHING_PAREN}):o.push({value:r.value,color:Wv[r.type]||"#000"});break;default:o.push({value:r.value,color:"#000"})}this.env.model.getters.showSelectionIndicator()&&i===s&&i===r.end&&(o[o.length-1].class=zv)}return o}splitHtmlContentIntoLines(e){const t=[];let o=[];for(const i of e)if(i.value.includes(fe)){const e=i.value.split(fe),s=e.pop();for(const s of e)o.push({color:i.color,value:s}),t.push(o),o=[];o.push({...i,value:s})}else o.push(i);o.length&&t.push(o);const i=[];for(const e of t)e.every(this.isContentEmpty)?i.push([e[0]]):i.push(e.filter((e=>!this.isContentEmpty(e))));return i}isContentEmpty(e){return!(e.value||e.class)}rangeColor(e,t){if("inactive"===this.props.focus)return;const o=this.env.model.getters.getHighlights(),i=t?this.env.model.getters.getSheetIdByName(t):this.env.model.getters.getCurrentEditedCell()?.sheetId,s=o.find((t=>{if(t.sheetId!==i)return!1;let o=this.env.model.getters.getRangeFromSheetXC(i,e).zone;return o=1===yi(o)?this.env.model.getters.expandZone(i,o):o,hi(o,t.zone)}));return s&&s.color?s.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)return;if("SYMBOL"===e.type)return void this.showAutocomplete(e.value);const t=e.functionContext,o=t?.parent.toUpperCase();if(t&&o&&o in Bv&&"UNKNOWN"!==e.type){const e=Bv[o],i=t.argPosition;this.functionDescriptionState.functionName=o,this.functionDescriptionState.functionDescription=e,this.functionDescriptionState.argToFocus=e.getArgToFocus(i+1)-1,this.functionDescriptionState.showDescription=!0}}}autoComplete(e){if(e){const t=this.env.model.getters.getTokenAtCursor();if(t){let o=t.end,i=t.end;["SYMBOL","FUNCTION"].includes(t.type)&&(o=t.start);const s=this.env.model.getters.getCurrentTokens();if(s.length){e+="(";const o=s.map((e=>e.start)).indexOf(t.start);if(o+1<s.length){"LEFT_PAREN"===s[o+1].type&&i++}}this.env.model.dispatch("CHANGE_COMPOSER_CURSOR_SELECTION",{start:o,end:i})}this.env.model.dispatch("REPLACE_COMPOSER_CURSOR_SELECTION",{text:e})}this.processTokenAtCursor()}}Gv.props={inputStyle:{type:String,optional:!0},rect:{type:Object,optional:!0},delimitation:{type:Object,optional:!0},focus:{validate:e=>["inactive","cellFocus","contentFocus"].includes(e)},onComposerCellFocused:{type:Function,optional:!0},onComposerContentFocused:Function,isDefaultFocus:{type:Boolean,optional:!0}};const qv=3*.4*window.devicePixelRatio||1;Wi`
|
|
1208
|
+
`;class $v extends t.Component{static template="o-spreadsheet-Composer";static components={TextValueProvider:Dv,FunctionDescriptionProvider:kv};static defaultProps={inputStyle:"",isDefaultFocus:!1};composerRef=t.useRef("o_composer");contentHelper=new Lv(this.composerRef.el);composerState=t.useState({positionStart:0,positionEnd:0});autoCompleteState=t.useState({showProvider:!1,values:[],selectedIndex:0});functionDescriptionState=t.useState({showDescription:!1,functionName:"",functionDescription:{},argToFocus:0});compositionActive=!1;get assistantStyle(){if(this.props.delimitation&&this.props.rect){const{x:e,y:t,height:o}=this.props.rect;let i={};return t>this.props.delimitation.height-(t+o)&&(i.top="-3px",i.transform="translate(0, -100%)"),e+300>this.props.delimitation.width&&(i.right="0px"),i.width="300px",Yi(i)}return Yi({width:"300px"})}shouldProcessInputEvents=!1;tokens=[];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)};keyCodeMapping={NumpadDecimal:this.processNumpadDecimal};setup(){t.onMounted((()=>{const e=this.composerRef.el;this.props.isDefaultFocus&&this.env.focusableElement.setFocusableElement(e),this.contentHelper.updateEl(e)})),t.useEffect((()=>{this.processContent()})),t.onPatched((()=>{"inactive"===this.env.model.getters.getEditionMode()&&this.processTokenAtCursor()}))}processArrowKeys(e){if(this.env.model.getters.isSelectingForComposer()||"inactive"===this.env.model.getters.getEditionMode())return this.functionDescriptionState.showDescription=!1,e.preventDefault(),e.stopPropagation(),void Kb(e,this.env.model.selection);const t=this.env.model.getters.getCurrentContent();"cellFocus"!==this.props.focus||this.autoCompleteState.showProvider||t.startsWith("=")?(e.stopPropagation(),this.handleArrowKeysForAutocomplete(e)):this.env.model.dispatch("STOP_EDITION")}handleArrowKeysForAutocomplete(e){["ArrowUp","ArrowDown"].includes(e.key)&&this.autoCompleteState.showProvider&&(e.preventDefault(),"ArrowUp"===e.key?(this.autoCompleteState.selectedIndex--,this.autoCompleteState.selectedIndex<0&&(this.autoCompleteState.selectedIndex=this.autoCompleteState.values.length-1)):this.autoCompleteState.selectedIndex=(this.autoCompleteState.selectedIndex+1)%this.autoCompleteState.values.length)}processTabKey(e){if(e.preventDefault(),e.stopPropagation(),"inactive"!==this.env.model.getters.getEditionMode()){if(this.autoCompleteState.showProvider){const e=this.autoCompleteState.values[this.autoCompleteState.selectedIndex]?.text;if(e)return void this.autoComplete(e)}this.env.model.dispatch("STOP_EDITION")}const t=e.shiftKey?"left":"right";this.env.model.selection.moveAnchorCell(t,1)}processEnterKey(e){if(e.preventDefault(),e.stopPropagation(),e.altKey||e.ctrlKey)return void this.composerRef.el?.dispatchEvent(new InputEvent("input",{inputType:"insertParagraph",bubbles:!0,isComposing:!1}));if(this.autoCompleteState.showProvider){const e=this.autoCompleteState.values[this.autoCompleteState.selectedIndex]?.text;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()}processNumpadDecimal(e){e.stopPropagation(),e.preventDefault();const t=this.env.model.getters.getLocale(),o=this.contentHelper.getCurrentSelection(),i=this.env.model.getters.getCurrentContent(),s=i.slice(0,o.start)+t.decimalSeparator+i.slice(o.end);this.env.model.dispatch("SET_CURRENT_CONTENT",{content:s,selection:{start:o.start+1,end:o.start+1}}),this.processContent()}onCompositionStart(){this.compositionActive=!0}onCompositionEnd(){this.compositionActive=!1}onKeydown(e){if("inactive"===this.env.model.getters.getEditionMode())return;let t=this.keyMapping[e.key]||this.keyCodeMapping[e.code];t?t.call(this,e):e.stopPropagation()}onPaste(e){"inactive"!==this.env.model.getters.getEditionMode()&&e.stopPropagation()}onInput(e){if(!this.shouldProcessInputEvents)return;if("insertFromPaste"===e.inputType&&"inactive"===this.env.model.getters.getEditionMode())return;let t;if(e.stopPropagation(),t="inactive"===this.env.model.getters.getEditionMode()?e.data||"":this.contentHelper.getText(),"inactive"===this.props.focus)return this.props.onComposerCellFocused?.(t);let o=this.contentHelper.getCurrentSelection();if("insertParagraph"===e.inputType){const e=Math.min(o.start,o.end),i=Math.max(o.start,o.end);t=t.slice(0,e)+fe+t.slice(i),o={start:e+1,end:e+1}}this.env.model.dispatch("STOP_COMPOSER_RANGE_SELECTION"),this.env.model.dispatch("SET_CURRENT_CONTENT",{content:t,selection:o}),this.processTokenAtCursor()}onKeyup(e){if(this.contentHelper.el===document.activeElement){if(this.autoCompleteState.showProvider&&["ArrowUp","ArrowDown"].includes(e.key))return;if(this.env.model.getters.isSelectingForComposer()&&e.key?.startsWith("Arrow"))return;const{start:t,end:o}=this.env.model.getters.getComposerSelection(),{start:i,end:s}=this.contentHelper.getCurrentSelection();i===t&&s===o||this.env.model.dispatch("CHANGE_COMPOSER_CURSOR_SELECTION",{start:i,end:s}),this.processTokenAtCursor()}}showAutocomplete(e){const t=e.toUpperCase();if(!this.env.model.getters.getCurrentContent().startsWith("=")||"TRUE"===t||"FALSE"===t)return;this.autoCompleteState.showProvider=!0;let o=Object.entries(fu.content).filter((([e,{hidden:t}])=>!t)).map((([e,{description:t}])=>({text:e,description:t})));o=e?Oi(e,o,(e=>e.text)):o.sort(((e,t)=>e.text.localeCompare(t.text))),this.autoCompleteState.values=o.slice(0,10),this.autoCompleteState.selectedIndex=0}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"),this.props.onComposerContentFocused(),this.props.focus,this.env.model.dispatch("CHANGE_COMPOSER_CURSOR_SELECTION",e),this.processTokenAtCursor()}onDblClick(){if(this.env.model.getters.isReadonly())return;const e=this.env.model.getters.getCurrentContent();if(e.startsWith("=")){const t=this.env.model.getters.getCurrentTokens(),o=this.contentHelper.getCurrentSelection();if(o.start===o.end)return;const i=e.substring(o.start,o.end),s=t.filter((e=>e.value.includes(i)&&e.start<=o.start&&e.end>=o.end))[0];if(!s)return;"REFERENCE"===s.type&&this.env.model.dispatch("CHANGE_COMPOSER_CURSOR_SELECTION",{start:s.start,end:s.end})}}onContextMenu(e){"inactive"===this.env.model.getters.getEditionMode()&&this.props.onInputContextMenu?.(e)}processContent(){if(this.compositionActive)return;this.shouldProcessInputEvents=!1,"inactive"!==this.props.focus&&this.contentHelper.el.focus();const e=this.getContentLines();if(this.contentHelper.setText(e),0!==e.length&&0!==e.length[0]){if("inactive"!==this.props.focus){const{start:e,end:t}=this.env.model.getters.getComposerSelection();this.contentHelper.selectRange(e,t)}this.contentHelper.scrollSelectionIntoView()}this.shouldProcessInputEvents=!0}getContentLines(){let e=this.env.model.getters.getCurrentContent();const t=e.startsWith("=");return""===e?[]:t&&"inactive"!==this.props.focus?this.splitHtmlContentIntoLines(this.getColoredTokens()):this.splitHtmlContentIntoLines([{value:e}])}getColoredTokens(){const e=this.env.model.getters.getCurrentTokens(),t=this.env.model.getters.getTokenAtCursor(),o=[],{end:i,start:s}=this.env.model.getters.getComposerSelection();for(const r of e){switch(r.type){case"OPERATOR":case"NUMBER":case"ARG_SEPARATOR":case"STRING":o.push({value:r.value,color:Hv[r.type]||"#000"});break;case"REFERENCE":const{xc:e,sheetName:i}=Jo(r.value);o.push({value:r.value,color:this.rangeColor(e,i)||"#000"});break;case"SYMBOL":const s=r.value.toUpperCase();"TRUE"===s||"FALSE"===s?o.push({value:r.value,color:Hv.NUMBER}):s in fu.content?o.push({value:r.value,color:Hv.FUNCTION}):o.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?o.push({value:r.value,color:Hv.MATCHING_PAREN}):o.push({value:r.value,color:Hv[r.type]||"#000"});break;default:o.push({value:r.value,color:"#000"})}this.env.model.getters.showSelectionIndicator()&&i===s&&i===r.end&&(o[o.length-1].class=Vv)}return o}splitHtmlContentIntoLines(e){const t=[];let o=[];for(const i of e)if(i.value.includes(fe)){const e=i.value.split(fe),s=e.pop();for(const s of e)o.push({color:i.color,value:s}),t.push(o),o=[];o.push({...i,value:s})}else o.push(i);o.length&&t.push(o);const i=[];for(const e of t)e.every(this.isContentEmpty)?i.push([e[0]]):i.push(e.filter((e=>!this.isContentEmpty(e))));return i}isContentEmpty(e){return!(e.value||e.class)}rangeColor(e,t){if("inactive"===this.props.focus)return;const o=this.env.model.getters.getHighlights(),i=t?this.env.model.getters.getSheetIdByName(t):this.env.model.getters.getCurrentEditedCell()?.sheetId,s=o.find((t=>{if(t.sheetId!==i)return!1;let o=this.env.model.getters.getRangeFromSheetXC(i,e).zone;return o=1===yi(o)?this.env.model.getters.expandZone(i,o):o,hi(o,t.zone)}));return s&&s.color?s.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)return;if("SYMBOL"===e.type)return void this.showAutocomplete(e.value);const t=e.functionContext,o=t?.parent.toUpperCase();if(t&&o&&o in Uv&&"UNKNOWN"!==e.type){const e=Uv[o],i=t.argPosition;this.functionDescriptionState.functionName=o,this.functionDescriptionState.functionDescription=e,this.functionDescriptionState.argToFocus=e.getArgToFocus(i+1)-1,this.functionDescriptionState.showDescription=!0}}}autoComplete(e){if(e){const t=this.env.model.getters.getTokenAtCursor();if(t){let o=t.end,i=t.end;["SYMBOL","FUNCTION"].includes(t.type)&&(o=t.start);const s=this.env.model.getters.getCurrentTokens();if(s.length){e+="(";const o=s.map((e=>e.start)).indexOf(t.start);if(o+1<s.length){"LEFT_PAREN"===s[o+1].type&&i++}}this.env.model.dispatch("CHANGE_COMPOSER_CURSOR_SELECTION",{start:o,end:i})}this.env.model.dispatch("REPLACE_COMPOSER_CURSOR_SELECTION",{text:e})}this.processTokenAtCursor()}}$v.props={inputStyle:{type:String,optional:!0},rect:{type:Object,optional:!0},delimitation:{type:Object,optional:!0},focus:{validate:e=>["inactive","cellFocus","contentFocus"].includes(e)},onComposerCellFocused:{type:Function,optional:!0},onComposerContentFocused:Function,isDefaultFocus:{type:Boolean,optional:!0},onInputContextMenu:{type:Function,optional:!0}};const Wv=3*.4*window.devicePixelRatio||1;Wi`
|
|
1209
1209
|
div.o-grid-composer {
|
|
1210
1210
|
z-index: ${ge.GridComposer};
|
|
1211
1211
|
box-sizing: border-box;
|
|
1212
1212
|
position: absolute;
|
|
1213
|
-
border: ${
|
|
1213
|
+
border: ${Wv}px solid ${E};
|
|
1214
1214
|
|
|
1215
1215
|
display: flex;
|
|
1216
1216
|
align-items: center;
|
|
@@ -1226,7 +1226,7 @@
|
|
|
1226
1226
|
padding: 6px 7px;
|
|
1227
1227
|
border-radius: 4px;
|
|
1228
1228
|
}
|
|
1229
|
-
`;class
|
|
1229
|
+
`;class Gv extends t.Component{static template="o-spreadsheet-GridComposer";static components={Composer:$v};rect=this.defaultRect;isEditing=!1;isCellReferenceVisible;get defaultRect(){return{x:0,y:0,width:0,height:0}}setup(){t.onWillUpdateProps((()=>{this.updateComponentPosition(),this.updateCellReferenceVisibility()}))}get shouldDisplayCellReference(){return this.isCellReferenceVisible}get cellReference(){if(!this.env.model.getters.getCurrentEditedCell())return"";const{col:e,row:t,sheetId:o}=this.env.model.getters.getCurrentEditedCell();return`${o!==this.env.model.getters.getActiveSheetId()?we(this.env.model.getters.getSheetName(o))+"!":""}${xt(e,t)}`}get cellReferenceStyle(){const{x:e,y:t}=this.rect;return Yi({left:e-Wv+"px",top:t-28+"px"})}get composerProps(){const{width:e,height:t}=this.env.model.getters.getSheetViewDimensionWithHeaders();return{rect:{...this.rect},delimitation:{width:e,height:t},focus:this.props.focus,isDefaultFocus:!0,onComposerContentFocused:this.props.onComposerContentFocused,onComposerCellFocused:this.props.onComposerCellFocused,onInputContextMenu:this.props.onInputContextMenu}}get containerStyle(){if("inactive"===this.env.model.getters.getEditionMode()||!this.rect)return"\n position: absolute;\n z-index: -1000;\n ";const e=this.env.model.getters.getCurrentContent().startsWith("="),t=this.env.model.getters.getActiveCell(),o=this.env.model.getters.getActivePosition(),i=this.env.model.getters.getCellComputedStyle(o),{x:s,y:r,width:n,height:a}=this.rect,l=!e&&i.fillColor||"#ffffff",c=!e&&i.textColor||"#000000",h=!e&&i.fontSize||10,d=!e&&i.bold?"bold":void 0,u=!e&&i.italic?"italic":"normal",g=e?"none":Gi(i);let p="left";e||(p=i.align||t.defaultAlign);const m=this.props.gridDims.height-this.rect.y;return Yi({left:s-1+"px",top:`${r}px`,"min-width":`${n+1}px`,"min-height":`${a+1}px`,"max-width":`${this.props.gridDims.width-this.rect.x}px`,"max-height":`${m}px`,background:l,color:c,"font-size":`${Di(h)}px`,"font-weight":d,"font-style":u,"text-decoration":g,"text-align":p})}updateComponentPosition(){const e="inactive"!==this.env.model.getters.getEditionMode();if(this.isEditing!==e){if(this.isEditing=e,!e)return this.rect=this.defaultRect,void this.env.focusableElement.focus();const t=this.env.model.getters.getActivePosition(),o=this.env.model.getters.expandZone(t.sheetId,wi(t));this.rect=this.env.model.getters.getVisibleRect(o)}}updateCellReferenceVisibility(){if("inactive"===this.env.model.getters.getEditionMode())return void(this.isCellReferenceVisible=!1);if(this.isCellReferenceVisible)return;const e=this.env.model.getters.getActiveSheetId(),t=this.env.model.getters.getSelectedZone();We(this.env.model.getters.getVisibleRect(t),this.rect)&&e===this.env.model.getters.getCurrentEditedCell().sheetId||(this.isCellReferenceVisible=!0)}}Gv.props={focus:{validate:e=>["inactive","cellFocus","contentFocus"].includes(e)},onComposerContentFocused:Function,gridDims:Object,onComposerCellFocused:Function,onInputContextMenu:Function};const qv=Wi`
|
|
1230
1230
|
.o-filter-icon {
|
|
1231
1231
|
color: ${T};
|
|
1232
1232
|
position: absolute;
|
|
@@ -1240,7 +1240,7 @@
|
|
|
1240
1240
|
background: ${T};
|
|
1241
1241
|
color: #fff;
|
|
1242
1242
|
}
|
|
1243
|
-
`;class
|
|
1243
|
+
`;class Zv extends t.Component{static style=qv;static template="o-spreadsheet-FilterIcon";get style(){const{x:e,y:t}=this.props.position;return`top:${t}px;left:${e}px`}}Zv.props={position:Object,isActive:Boolean,onClick:Function};const Yv=Wi``;class jv extends t.Component{static style=Yv;static template="o-spreadsheet-FilterIconsOverlay";static components={FilterIcon:Zv};static defaultProps={gridPosition:{x:0,y:0}};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(),o=this.env.model.getters.getRowDimensionsInViewport(t,e.row),i=this.env.model.getters.getColDimensionsInViewport(t,e.col),s=this.env.model.getters.getCell({sheetId:t,...e}),r=this.getIconVerticalPosition(o,s);return{x:i.end-W+this.props.gridPosition.x-2-1,y:r+this.props.gridPosition.y}}getIconVerticalPosition(e,t){const o=Math.floor((e.size-W)/2);switch(t?.style?.verticalAlign){case"bottom":return e.end-2-W;case"top":return e.start+2;default:return e.end-W-o}}isFilterActive(e){const t=this.env.model.getters.getActiveSheetId();return this.env.model.getters.isFilterActive({sheetId:t,...e})}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:o,row:i}=e;this.env.model.dispatch("OPEN_CELL_POPOVER",{col:o,row:i,popoverType:"FilterMenu"})}isPositionVisible(e,t){const o=this.env.model.getters.getVisibleRect({left:e,right:e,top:t,bottom:t});return!(0===o.width||0===o.height)}}function Xv(e,t){return{...t,...Qv(e,{x:t.x,y:t.y})}}function Kv(e,t){return{...t,...Jv(e,{x:t.x,y:t.y})}}function Qv(e,{x:t,y:o}){const{x:i,y:s}=e.getMainViewportCoordinates(),{scrollX:r,scrollY:n}=e.getActiveSheetScrollInfo();return{x:t=t<i?t:t-r,y:o=o<s?o:o-n}}function Jv(e,{x:t,y:o}){const{x:i,y:s}=e.getMainViewportCoordinates(),{scrollX:r,scrollY:n}=e.getActiveSheetScrollInfo();return{x:t=i&&t<i?t:t+r,y:o=s&&o<s?o:o+n}}function eS(e,t,o){return Math.min(Math.max(e,t),o)}jv.props={gridPosition:{type:Object,optional:!0}};const tS=5;function oS(e,t,o){return o.map((e=>sS(t,e))).filter((o=>function(e,t,o){const{x:i,y:s}=e.getMainViewportCoordinates(),r=[];switch(o.axisType){case"top":case"bottom":case"vCenter":if(t.y<s)return!0;r.push({x:t.x,y:o.position}),r.push({x:t.x+t.width,y:o.position});break;case"left":case"right":case"hCenter":if(t.x<i)return!0;r.push({x:o.position,y:t.y}),r.push({x:o.position,y:t.y+t.height})}return r.some(e.isPositionVisible)}(e,t,o))).map((o=>function(e,t,o){const i=Xv(e,t);return sS(i,o.axisType)}(e,t,o)))}function iS(e,t,o,i,s){const r=oS(e,t,o);let n;for(const t of i){const o=oS(e,t,s);for(const e of r)for(const i of o){if(a=e.position,l=i.position,!(Math.abs(a-l)<=tS))continue;const o=e.position-i.position;n&&o===n.snapOffset?n.matchedFigIds.push(t.id):(!n||Math.abs(o)<=Math.abs(n.snapOffset))&&(n={matchedFigIds:[t.id],snapOffset:o,snappedAxisType:e.axisType,position:i.position})}}var a,l;return n}function sS(e,t){let o=0;switch(t){case"top":o=e.y;break;case"bottom":o=e.y+e.height-oe;break;case"vCenter":o=e.y+Math.floor(e.height/2)-oe;break;case"left":o=e.x;break;case"right":o=e.x+e.width-oe;break;case"hCenter":o=e.x+Math.floor(e.width/2)-oe}return{position:o,axisType:t}}Wi`
|
|
1244
1244
|
.o-figure-snap-line {
|
|
1245
1245
|
position: relative;
|
|
1246
1246
|
z-index: ${ge.FigureSnapLine};
|
|
@@ -1253,11 +1253,11 @@
|
|
|
1253
1253
|
height: 0px;
|
|
1254
1254
|
}
|
|
1255
1255
|
}
|
|
1256
|
-
`;class
|
|
1256
|
+
`;class rS extends t.Component{static template="o-spreadsheet-FiguresContainer";static components={FigureComponent:Mv};dnd=t.useState({draggedFigure:void 0,horizontalSnap:void 0,verticalSnap:void 0});setup(){t.onMounted((()=>{this.render()}))}getVisibleFigures(){const e=this.env.model.getters.getVisibleFigures();return this.dnd.draggedFigure&&!e.some((e=>e.id===this.dnd.draggedFigure?.id))&&e.push(this.env.model.getters.getFigure(this.env.model.getters.getActiveSheetId(),this.dnd.draggedFigure?.id)),e}get containers(){const e=this.getVisibleFigures(),t=[];for(const o of["topLeft","topRight","bottomLeft","bottomRight"]){const i=e.filter((e=>this.getFigureContainer(e)===o));i.length>0&&t.push({type:o,figures:i,style:this.getContainerStyle(o),inverseViewportStyle:this.getInverseViewportPositionStyle(o)})}return this.dnd.draggedFigure&&t.push({type:"dnd",figures:[this.getDndFigure()],style:this.getContainerStyle("dnd"),inverseViewportStyle:this.getInverseViewportPositionStyle("dnd")}),t}getContainerStyle(e){return this.rectToCss(this.getContainerRect(e))}rectToCss(e){return Yi({left:`${e.x}px`,top:`${e.y}px`,width:`${e.width}px`,height:`${e.height}px`})}getContainerRect(e){const{width:t,height:o}=this.env.model.getters.getMainViewportRect(),{x:i,y:s}=this.env.model.getters.getMainViewportCoordinates(),r=["bottomRight","topRight"].includes(e)?i:0,n=t-r,a=["bottomRight","bottomLeft"].includes(e)?s:0;return{x:r,y:a,width:n,height:o-a}}getInverseViewportPositionStyle(e){const{scrollX:t,scrollY:o}=this.env.model.getters.getActiveSheetScrollInfo(),{x:i,y:s}=this.env.model.getters.getMainViewportCoordinates();return Yi({left:`${["bottomRight","topRight"].includes(e)?-(i+t):0}px`,top:`${["bottomRight","bottomLeft"].includes(e)?-(s+o):0}px`})}getFigureContainer(e){const{x:t,y:o}=this.env.model.getters.getMainViewportCoordinates();return e.id===this.dnd.draggedFigure?.id?"dnd":e.x<t&&e.y<o?"topLeft":e.x<t?"bottomLeft":e.y<o?"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 o=this.env.model.getters.getActiveSheetId(),i={x:t.clientX,y:t.clientY},s={maxX:this.env.model.getters.getColDimensions(o,this.env.model.getters.getNumberCols(o)-1).end,maxY:this.env.model.getters.getRowDimensions(o,this.env.model.getters.getNumberRows(o)-1).end},{x:r,y:n}=Xv(this.env.model.getters,e),a={...e,x:r,y:n};iv((t=>{const o=this.env.model.getters,r=function({x:e,y:t},{x:o,y:i},s,{x:r,y:n},{maxX:a,maxY:l},{scrollX:c,scrollY:h}){const d=r?0:-c,u=n?0:-h,g=e-o,p=eS(s.x+g,d,a-s.width-c),m=t-i,f=eS(s.y+m,u,l-s.height-h);return{...s,x:p,y:f}}({x:t.clientX,y:t.clientY},i,a,this.env.model.getters.getMainViewportCoordinates(),s,o.getActiveSheetScrollInfo()),n=this.getOtherFigures(e.id),l=function(e,t,o){const i={...t},s=iS(e,i,["hCenter","right","left"],o,["hCenter","right","left"]),r=iS(e,i,["vCenter","bottom","top"],o,["vCenter","bottom","top"]),{y:n,x:a}=e.getMainViewportCoordinates(),{scrollY:l,scrollX:c}=e.getActiveSheetScrollInfo();if(r){i.y-=r.snapOffset;const e=t.y<n,o=i.y<n;e&&!o?i.y+=l:!e&&o&&(i.y-=l)}if(s){i.x-=s.snapOffset;const e=t.x<a,o=i.x<a;e&&!o?i.x+=c:!e&&o&&(i.x-=c)}return{snappedFigure:i,verticalSnapLine:s,horizontalSnapLine:r}}(o,Kv(o,r),n);this.dnd.draggedFigure=Xv(o,l.snappedFigure),this.dnd.horizontalSnap=this.getSnap(l.horizontalSnapLine),this.dnd.verticalSnap=this.getSnap(l.verticalSnapLine)}),(t=>{if(!this.dnd.draggedFigure)return;let{x:i,y:s}=Kv(this.env.model.getters,this.dnd.draggedFigure);this.dnd.draggedFigure=void 0,this.dnd.horizontalSnap=void 0,this.dnd.verticalSnap=void 0,this.env.model.dispatch("UPDATE_FIGURE",{sheetId:o,id:e.id,x:i,y:s})}))}startResize(e,t,o,i){i.stopPropagation();const s={x:i.clientX,y:i.clientY},{x:r,y:n}=Xv(this.env.model.getters,e),a={...e,x:r,y:n},l=Qp.get(e.tag).keepRatio||!1,c=Qp.get(e.tag).minFigSize||80;iv((i=>{const r={x:i.clientX,y:i.clientY},n=function(e,t,o,{x:i,y:s},{x:r,y:n},a,l,{scrollX:c,scrollY:h}){let{x:d,y:u,width:g,height:p}=e;if(a&&0!=t&&0!=o){const a=Math.min(t*(r-i),e.width-l),c=Math.min(o*(n-s),e.height-l),h=Math.min(a/e.width,c/e.height);g=e.width*(1-h),p=e.height*(1-h),t<0&&(d=e.x+e.width*h),o<0&&(u=e.y+e.height*h)}else{const a=Math.max(t*(i-r),l-e.width),c=Math.max(o*(s-n),l-e.height);g=e.width+a,p=e.height+c,t<0&&(d=e.x-a),o<0&&(u=e.y-c)}return d+c<=0&&(g=g+d+c,d=-c),u+h<=0&&(p=p+u+h,u=-h),{...e,x:d,y:u,width:g,height:p}}(a,t,o,r,s,l,c,this.env.model.getters.getActiveSheetScrollInfo()),h=this.getOtherFigures(e.id),d=function(e,t,o,i,s){const r={...i},n=iS(e,r,[-1===t?"left":"right"],s,["right","left"]);n&&(1===t?r.width-=n.snapOffset:-1===t&&(r.x-=n.snapOffset,r.width+=n.snapOffset));const a=iS(e,r,[-1===o?"top":"bottom"],s,["bottom","top"]);return a&&(1===o?r.height-=a.snapOffset:-1===o&&(r.y-=a.snapOffset,r.height+=a.snapOffset)),r.x=Math.round(r.x),r.y=Math.round(r.y),r.height=Math.round(r.height),r.width=Math.round(r.width),{snappedFigure:r,verticalSnapLine:n,horizontalSnapLine:a}}(this.env.model.getters,t,o,n,h);this.dnd.draggedFigure=d.snappedFigure,this.dnd.horizontalSnap=this.getSnap(d.horizontalSnapLine),this.dnd.verticalSnap=this.getSnap(d.verticalSnapLine)}),(i=>{if(!this.dnd.draggedFigure)return;let{x:s,y:r}=Kv(this.env.model.getters,this.dnd.draggedFigure);const n={x:s,y:r};t&&(n.width=this.dnd.draggedFigure.width),o&&(n.height=this.dnd.draggedFigure.height),this.env.model.dispatch("UPDATE_FIGURE",{sheetId:this.env.model.getters.getActiveSheetId(),id:e.id,...n}),this.dnd.draggedFigure=void 0,this.dnd.horizontalSnap=void 0,this.dnd.verticalSnap=void 0}))}getOtherFigures(e){return this.getVisibleFigures().filter((t=>t.id!==e))}getDndFigure(){const e=this.getVisibleFigures().find((e=>e.id===this.dnd.draggedFigure?.id));if(!e)throw new Error("Dnd figure not found");return{...e,...this.dnd.draggedFigure}}getFigureStyle(e){return e.id!==this.dnd.draggedFigure?.id?"":Yi({opacity:"0.9",cursor:"grabbing"})}getSnap(e){if(!e||!this.dnd.draggedFigure)return;const t=e.matchedFigIds.map((e=>this.getVisibleFigures().find((t=>t.id===e)))).filter(ke).map((e=>{const t=Xv(this.env.model.getters,e),o=this.getFigureContainer(e);return _r(t,this.getContainerRect(o))})).filter(ke),o=function(...e){return Dr(li(...e.map(Fr)))}(this.dnd.draggedFigure,...t);return{line:e,containerStyle:this.rectToCss(o),lineStyle:this.getSnapLineStyle(e,o)}}getSnapLineStyle(e,t){return e?["top","vCenter","bottom"].includes(e.snappedAxisType)?Yi({top:e.position-t.y+"px",left:"0px",width:"100%"}):Yi({top:"0px",left:e.position-t.x+"px",height:"100%"}):""}}function nS(e,...o){t.useEffect((e=>(e?.addEventListener(...o),()=>e?.removeEventListener(...o))),(()=>[e.el]))}rS.props={onFigureDeleted:Function};function aS(e,o,i){let s={col:void 0,row:void 0};const{Date:r}=window;let n=0,a=0,l=0;function c(){return{col:e.model.getters.getColIndex(n),row:e.model.getters.getRowIndex(a)}}const{pause:h,resume:d}=function(e,o){let i;const{setInterval:s,clearInterval:r}=window;return t.useEffect((()=>(i=s(e,o),()=>r(i))),(()=>[o])),{pause:()=>{r(i),i=void 0},resume:()=>{void 0===i&&(i=s(e,o))}}}((function(){const{col:e,row:t}=c(),o=r.now()-l;o>300&&(e!==s.col||t!==s.row)&&u(void 0,void 0);if(o>300){if(e<0||t<0)return;u(e,t)}}),200);function u(e,t){e===s.col&&t===s.row||(s.col=e,s.row=t,i({col:e,row:t}))}return nS(o,"mousemove",(function(e){o.el===e.target&&(n=e.offsetX,a=e.offsetY,l=r.now())})),nS(o,"mouseleave",h),nS(o,"mouseenter",d),nS(o,"mousedown",(function(){const{col:e,row:t}=c();e===s.col&&t===s.row||u(void 0,void 0)})),s}Wi`
|
|
1257
1257
|
.o-paint-format-cursor {
|
|
1258
1258
|
cursor: url("data:image/svg+xml,${encodeURIComponent('\n<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="14" height="16"><path d="M6.5.4c1.3-.8 2.9-.1 3.8 1.4l2.9 5.1c.2.4.9 1.6-.4 2.3l-1.6.9 1.8 3.1c.2.4.1 1-.2 1.2l-1.6 1c-.3.1-.9 0-1.1-.4l-1.8-3.1-1.6 1c-.6.4-1.7 0-2.2-.8L0 4.3"/><path fill="#fff" d="M9.1 2a1.4 1.1 60 0 0-1.7-.6L5.5 2.5l.9 1.6-1 .6-.9-1.6-.6.4 1.8 3.1-1.3.7-1.8-3.1-1 .6 3.8 6.6 6.8-3.98M3.9 8.8 10.82 5l.795 1.4-6.81 3.96"/></svg>\n')}"), auto;
|
|
1259
1259
|
}
|
|
1260
|
-
`;class
|
|
1260
|
+
`;class lS extends t.Component{static template="o-spreadsheet-GridOverlay";static components={FiguresContainer:rS};static defaultProps={onCellHovered:()=>{},onCellDoubleClicked:()=>{},onCellClicked:()=>{},onCellRightClicked:()=>{},onGridResized:()=>{},onFigureDeleted:()=>{}};gridOverlay;setup(){this.gridOverlay=t.useRef("gridOverlay"),aS(this.env,this.gridOverlay,this.props.onCellHovered);const e=new ResizeObserver((()=>{this.props.onGridResized({height:this.gridOverlayEl.clientHeight,width:this.gridOverlayEl.clientWidth})}));t.onMounted((()=>{e.observe(this.gridOverlayEl)})),t.onWillUnmount((()=>{e.disconnect()})),function(e,t,o){let i=null,s=null;nS(e,"touchstart",(function(e){1===e.touches.length&&(i=e.touches[0].clientX,s=e.touches[0].clientY)})),nS(e,"touchend",(function(){i=null,s=null})),nS(e,"touchmove",(function(e){if(1!==e.touches.length)return;o()&&(e.preventDefault(),e.stopPropagation());const r=e.touches[0].clientX,n=e.touches[0].clientY;t(i-r,s-n),i=r,s=n}))}(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}get style(){return this.props.gridOverlayDimensions}get isPaintingFormat(){return this.env.model.getters.isPaintingFormat()}onMouseDown(e){if(e.button>0)return;const[t,o]=this.getCartesianCoordinates(e);this.props.onCellClicked(t,o,{expandZone:e.shiftKey,addZone:Or(e)})}onDoubleClick(e){const[t,o]=this.getCartesianCoordinates(e);this.props.onCellDoubleClicked(t,o)}onContextMenu(e){const[t,o]=this.getCartesianCoordinates(e);this.props.onCellRightClicked(t,o,{x:e.clientX,y:e.clientY})}getCartesianCoordinates(e){return[this.env.model.getters.getColIndex(e.offsetX),this.env.model.getters.getRowIndex(e.offsetY)]}}lS.props={onCellHovered:{type:Function,optional:!0},onCellDoubleClicked:{type:Function,optional:!0},onCellClicked:{type:Function,optional:!0},onCellRightClicked:{type:Function,optional:!0},onGridResized:{type:Function,optional:!0},onFigureDeleted:{type:Function,optional:!0},onGridMoved:Function,gridOverlayDimensions:String};class cS extends t.Component{static template="o-spreadsheet-GridPopover";static components={Popover:Lr};zIndex=ge.GridPopover;get cellPopover(){const e=this.env.model.getters.getCellPopover(this.props.hoveredCell);if(!e.isOpen)return{isOpen:!1};const t=e.anchorRect;return{...e,anchorRect:{...t,x:t.x+this.props.gridRect.x,y:t.y+this.props.gridRect.y}}}}cS.props={hoveredCell:Object,onClosePopover:Function,onMouseWheel:Function,gridRect:Object};class hS extends t.Component{PADDING=0;MAX_SIZE_MARGIN=0;MIN_ELEMENT_SIZE=0;lastSelectedElementIndex=null;state=t.useState({resizerIsActive:!1,isResizing:!1,isMoving:!1,isSelecting:!1,waitingForMove:!1,activeElement:0,draggerLinePosition:0,draggerShadowPosition:0,draggerShadowThickness:0,delta:0,base:0,position:"before"});_computeHandleDisplay(e){const t=this._getEvOffset(e),o=this._getElementIndex(t);if(o<0)return;const i=this._getDimensionsInViewport(o);t-i.start<this.PADDING&&o!==this._getViewportOffset()?(this.state.resizerIsActive=!0,this.state.draggerLinePosition=i.start,this.state.activeElement=this._getPreviousVisibleElement(o)):i.end-t<this.PADDING?(this.state.resizerIsActive=!0,this.state.draggerLinePosition=i.end,this.state.activeElement=o):this.state.resizerIsActive=!1}_computeGrabDisplay(e){const t=this._getElementIndex(this._getEvOffset(e)),o=this._getActiveElements(),i=this._getSelectedZoneStart(),s=this._getSelectedZoneEnd();o.has(i)&&i<=t&&t<=s?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),o=this.state.draggerLinePosition,i=this._getElementSize(this.state.activeElement),s=o-i+this.MIN_ELEMENT_SIZE,r=this._getMaxSize();iv((e=>{this.state.delta=this._getClientPosition(e)-t,this.state.draggerLinePosition=o+this.state.delta,this.state.draggerLinePosition<s&&(this.state.draggerLinePosition=s,this.state.delta=this.MIN_ELEMENT_SIZE-i),this.state.draggerLinePosition>r&&(this.state.draggerLinePosition=r,this.state.delta=r-o)}),(e=>{this.state.isResizing=!1,0!==this.state.delta&&this._updateSize()}))}select(e){if(e.button>0)return;const t=this._getElementIndex(this._getEvOffset(e));t<0||(!0!==this.state.waitingForMove?("editing"===this.env.model.getters.getEditionMode()&&this.env.model.selection.getBackToDefault(),this.startSelection(e,t)):this.env.model.getters.isGridSelectionActive()?this.startMovement(e):this._selectElement(t,!1))}startMovement(e){this.state.waitingForMove=!1,this.state.isMoving=!0;const t=this._getDimensionsInViewport(this._getSelectedZoneStart()),o=this._getDimensionsInViewport(this._getSelectedZoneEnd()),i=t.start;this.state.draggerLinePosition=i,this.state.base=this._getSelectedZoneStart(),this.state.draggerShadowPosition=i,this.state.draggerShadowThickness=o.end-t.start;sv(this.env,((e,o)=>{let i="COL"===this._getType()?e:o;if(i>=0){const e=this._getDimensionsInViewport(i);i<=this._getSelectedZoneStart()?(this.state.draggerLinePosition=e.start,this.state.draggerShadowPosition=e.start,this.state.base=i,this.state.position="before"):this._getSelectedZoneEnd()<i?(this.state.draggerLinePosition=e.end,this.state.draggerShadowPosition=e.end-this.state.draggerShadowThickness,this.state.base=i,this.state.position="after"):(this.state.draggerLinePosition=t.start,this.state.draggerShadowPosition=t.start,this.state.base=this._getSelectedZoneStart())}}),(()=>{this.state.isMoving=!1,this.state.base!==this._getSelectedZoneStart()&&this._moveElements(),this._computeGrabDisplay(e)}))}startSelection(e,t){this.state.isSelecting=!0,e.shiftKey?this._increaseSelection(t):this._selectElement(t,Or(e)),this.lastSelectedElementIndex=t;sv(this.env,((e,t)=>{let o="COL"===this._getType()?e:t;o!==this.lastSelectedElementIndex&&-1!==o&&(this._increaseSelection(o),this.lastSelectedElementIndex=o)}),(()=>{this.state.isSelecting=!1,this.lastSelectedElementIndex=null,this.env.model.dispatch(Or(e)?"PREPARE_SELECTION_INPUT_EXPANSION":"STOP_SELECTION_INPUT"),this._computeGrabDisplay(e)}))}onMouseUp(e){this.lastSelectedElementIndex=null}onContextMenu(e){e.preventDefault();const t=this._getElementIndex(this._getEvOffset(e));if(t<0)return;this._getActiveElements().has(t)||this._selectElement(t,!1);const o=this._getType();this.props.onOpenContextMenu(o,e.clientX,e.clientY)}}Wi`
|
|
1261
1261
|
.o-col-resizer {
|
|
1262
1262
|
position: absolute;
|
|
1263
1263
|
top: 0;
|
|
@@ -1316,7 +1316,7 @@
|
|
|
1316
1316
|
top: calc(${V}px / 2 - ${U}px / 2);
|
|
1317
1317
|
}
|
|
1318
1318
|
}
|
|
1319
|
-
`,
|
|
1319
|
+
`,hS.props={onOpenContextMenu:Function};class dS extends hS{static template="o-spreadsheet-ColResizer";colResizerRef;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),o=this.env.model.getters.getActiveCols();this.env.model.dispatch("RESIZE_COLUMNS_ROWS",{dimension:"COL",sheetId:this.env.model.getters.getActiveSheetId(),elements:o.has(e)?[...o]:[e],size:t})}_moveElements(){const e=[],t=this._getSelectedZoneStart(),o=this._getSelectedZoneEnd();for(let i=t;i<=o;i++)e.push(i);const i=this.env.model.dispatch("MOVE_COLUMNS_ROWS",{sheetId:this.env.model.getters.getActiveSheetId(),dimension:"COL",base:this.state.base,elements:e,position:this.state.position});!i.isSuccessful&&i.reasons.includes(2)&&this.env.raiseError(pp)}_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 o;for(o=e-1;o>=0&&this.env.model.getters.isColHidden(t,o);o--);return o}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}}Wi`
|
|
1320
1320
|
.o-row-resizer {
|
|
1321
1321
|
position: absolute;
|
|
1322
1322
|
top: ${F}px;
|
|
@@ -1377,7 +1377,7 @@
|
|
|
1377
1377
|
background-color: lightgrey;
|
|
1378
1378
|
}
|
|
1379
1379
|
}
|
|
1380
|
-
`,
|
|
1380
|
+
`,dS.props={onOpenContextMenu:Function};class uS extends hS{static template="o-spreadsheet-RowResizer";setup(){super.setup(),this.rowResizerRef=t.useRef("rowResizer"),this.PADDING=5,this.MAX_SIZE_MARGIN=60,this.MIN_ELEMENT_SIZE=10}rowResizerRef;_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),o=this.env.model.getters.getActiveRows();this.env.model.dispatch("RESIZE_COLUMNS_ROWS",{dimension:"ROW",sheetId:this.env.model.getters.getActiveSheetId(),elements:o.has(e)?[...o]:[e],size:t})}_moveElements(){const e=[],t=this._getSelectedZoneStart(),o=this._getSelectedZoneEnd();for(let i=t;i<=o;i++)e.push(i);const i=this.env.model.dispatch("MOVE_COLUMNS_ROWS",{sheetId:this.env.model.getters.getActiveSheetId(),dimension:"ROW",base:this.state.base,elements:e,position:this.state.position});!i.isSuccessful&&i.reasons.includes(2)&&this.env.raiseError(pp)}_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 o;for(o=e-1;o>=0&&this.env.model.getters.isRowHidden(t,o);o--);return o}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}}Wi`
|
|
1381
1381
|
.o-overlay {
|
|
1382
1382
|
.all {
|
|
1383
1383
|
position: absolute;
|
|
@@ -1388,7 +1388,7 @@
|
|
|
1388
1388
|
height: ${F}px;
|
|
1389
1389
|
}
|
|
1390
1390
|
}
|
|
1391
|
-
`,
|
|
1391
|
+
`,uS.props={onOpenContextMenu:Function};class gS extends t.Component{static template="o-spreadsheet-HeadersOverlay";static components={ColResizer:dS,RowResizer:uS};selectAll(){this.env.model.selection.selectAll()}}function pS(e,o,i){const s=t.useRef(e);t.useEffect((function(){const e=s.el,t=window.devicePixelRatio||1,r=e.getContext("2d",{alpha:!1}),n={ctx:r,dpr:t,thinLineWidth:.4*t},{width:a,height:l}=i();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),o.drawGrid(n)}))}function mS(e){function t(e,t){return e*(0===t?1:P)}return o=>{const i=t(o.shiftKey&&!Ar()?o.deltaY:o.deltaX,o.deltaMode),s=t(o.shiftKey&&!Ar()?o.deltaX:o.deltaY,o.deltaMode);e(i,s)}}gS.props={onOpenContextMenu:Function},Wi`
|
|
1392
1392
|
.o-border {
|
|
1393
1393
|
position: absolute;
|
|
1394
1394
|
&:hover {
|
|
@@ -1398,7 +1398,7 @@
|
|
|
1398
1398
|
.o-moving {
|
|
1399
1399
|
cursor: grabbing;
|
|
1400
1400
|
}
|
|
1401
|
-
`;class
|
|
1401
|
+
`;class fS extends t.Component{static template="o-spreadsheet-Border";get style(){const e=["n","w","e"].includes(this.props.orientation),t=["n","w","s"].includes(this.props.orientation),o=["n","s"].includes(this.props.orientation),i=["w","e"].includes(this.props.orientation),s=this.props.zone,r=this.env.model.getters.getVisibleRect(s),n=r.x,a=r.x+r.width-4,l=r.y,c=r.y+r.height-4;return Yi({left:`${t?n:a}px`,top:`${e?l:c}px`,width:`${o?a-n:4}px`,height:`${i?c-l:4}px`})}onMouseDown(e){this.props.onMoveHighlight(e.clientX,e.clientY)}}fS.props={zone:Object,orientation:String,isMoving:Boolean,onMoveHighlight:Function},Wi`
|
|
1402
1402
|
.o-corner {
|
|
1403
1403
|
position: absolute;
|
|
1404
1404
|
height: 6px;
|
|
@@ -1420,11 +1420,11 @@
|
|
|
1420
1420
|
.o-resizing {
|
|
1421
1421
|
cursor: grabbing;
|
|
1422
1422
|
}
|
|
1423
|
-
`;class
|
|
1423
|
+
`;class bS extends t.Component{static template="o-spreadsheet-Corner";isTop="n"===this.props.orientation[0];isLeft="w"===this.props.orientation[1];get style(){const e=this.props.zone,t=this.isLeft?e.left:e.right,o=this.isTop?e.top:e.bottom,i=this.env.model.getters.getVisibleRect({left:t,right:t,top:o,bottom:o});if(i.width*i.height==0)return"display:none";return Yi({left:(this.isLeft?i.x:i.x+i.width)-4+"px",top:(this.isTop?i.y:i.y+i.height)-4+"px","background-color":this.props.color})}onMouseDown(e){this.props.onResizeHighlight(this.isLeft,this.isTop)}}bS.props={zone:Object,color:String,orientation:String,isResizing:Boolean,onResizeHighlight:Function},Wi`
|
|
1424
1424
|
.o-highlight {
|
|
1425
1425
|
z-index: ${ge.Highlight};
|
|
1426
1426
|
}
|
|
1427
|
-
`;class
|
|
1427
|
+
`;class vS extends t.Component{static template="o-spreadsheet-Highlight";static components={Corner:bS,Border:fS};highlightState=t.useState({shiftingMode:"none"});onResizeHighlight(e,t){const o=this.env.model.getters.getActiveSheetId();this.highlightState.shiftingMode="isResizing";const i=this.props.zone,s=e?i.right:i.left,r=t?i.bottom:i.top;let n=e?i.left:i.right,a=t?i.top:i.bottom,l=i;this.env.model.dispatch("START_CHANGE_HIGHLIGHT",{range:this.env.model.getters.getRangeDataFromZone(o,l)});sv(this.env,((e,t)=>{if(n!==e||a!==t){n=xe(-1===e?n:e,0,this.env.model.getters.getNumberCols(o)-1),a=xe(-1===t?a:t,0,this.env.model.getters.getNumberRows(o)-1);let i={left:Math.min(s,n),top:Math.min(r,a),right:Math.max(s,n),bottom:Math.max(r,a)};i=this.env.model.getters.expandZone(o,i),hi(i,l)||(this.env.model.dispatch("CHANGE_HIGHLIGHT",{range:this.env.model.getters.getRangeFromZone(o,this.env.model.getters.getUnboundedZone(o,i)).rangeData}),l=i)}}),(()=>{this.highlightState.shiftingMode="none",this.env.model.dispatch("STOP_COMPOSER_RANGE_SELECTION")}))}onMoveHighlight(e,t){this.highlightState.shiftingMode="isMoving";const o=this.props.zone,i=Ir(),s=this.env.model.getters.getActiveSheetId(),r=this.env.model.getters.getColIndex(e-i.left),n=this.env.model.getters.getRowIndex(t-i.top),a=-o.left,l=this.env.model.getters.getNumberCols(s)-o.right-1,c=-o.top,h=this.env.model.getters.getNumberRows(s)-o.bottom-1;let d=o;this.env.model.dispatch("START_CHANGE_HIGHLIGHT",{range:this.env.model.getters.getRangeDataFromZone(s,d)});let u=r,g=n;sv(this.env,((e,t)=>{if(u!==e||g!==t){u=-1===e?u:e,g=-1===t?g:t;const i=xe(u-r,a,l),p=xe(g-n,c,h);let m={left:o.left+i,top:o.top+p,right:o.right+i,bottom:o.bottom+p};m=this.env.model.getters.expandZone(s,m),hi(m,d)||(this.env.model.dispatch("CHANGE_HIGHLIGHT",{range:this.env.model.getters.getRangeFromZone(s,this.env.model.getters.getUnboundedZone(s,m)).rangeData}),d=m)}}),(()=>{this.highlightState.shiftingMode="none",this.env.model.dispatch("STOP_COMPOSER_RANGE_SELECTION")}))}}vS.props={zone:Object,color:String};class SS{direction;el;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}}Wi`
|
|
1428
1428
|
.o-scrollbar {
|
|
1429
1429
|
position: absolute;
|
|
1430
1430
|
overflow: auto;
|
|
@@ -1440,7 +1440,7 @@
|
|
|
1440
1440
|
border-left: 1px solid #e2e3e3;
|
|
1441
1441
|
}
|
|
1442
1442
|
}
|
|
1443
|
-
`;class
|
|
1443
|
+
`;class CS extends t.Component{static template=t.xml`
|
|
1444
1444
|
<div
|
|
1445
1445
|
t-attf-class="o-scrollbar {{props.direction}}"
|
|
1446
1446
|
t-on-scroll="onScroll"
|
|
@@ -1448,7 +1448,7 @@
|
|
|
1448
1448
|
t-att-style="positionCss">
|
|
1449
1449
|
<div t-att-style="sizeCss"/>
|
|
1450
1450
|
</div>
|
|
1451
|
-
`;static defaultProps={width:1,height:1};scrollbarRef;scrollbar;setup(){this.scrollbarRef=t.useRef("scrollbar"),this.scrollbar=new
|
|
1451
|
+
`;static defaultProps={width:1,height:1};scrollbarRef;scrollbar;setup(){this.scrollbarRef=t.useRef("scrollbar"),this.scrollbar=new SS(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 Yi({width:`${this.props.width}px`,height:`${this.props.height}px`})}get positionCss(){return Yi(this.props.position)}onScroll(e){this.props.offset!==this.scrollbar.scroll&&this.props.onScroll(this.scrollbar.scroll)}}CS.props={width:{type:Number,optional:!0},height:{type:Number,optional:!0},direction:String,position:Object,offset:Number,onScroll:Function};class ES extends t.Component{static components={ScrollBar:CS};static template=t.xml`
|
|
1452
1452
|
<ScrollBar
|
|
1453
1453
|
t-if="isDisplayed"
|
|
1454
1454
|
width="width"
|
|
@@ -1456,7 +1456,7 @@
|
|
|
1456
1456
|
offset="offset"
|
|
1457
1457
|
direction="'horizontal'"
|
|
1458
1458
|
onScroll.bind="onScroll"
|
|
1459
|
-
/>`;static defaultProps={leftOffset:0};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.leftOffset+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})}}
|
|
1459
|
+
/>`;static defaultProps={leftOffset:0};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.leftOffset+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})}}ES.props={leftOffset:{type:Number,optional:!0}};class wS extends t.Component{static components={ScrollBar:CS};static template=t.xml`
|
|
1460
1460
|
<ScrollBar
|
|
1461
1461
|
t-if="isDisplayed"
|
|
1462
1462
|
height="height"
|
|
@@ -1464,13 +1464,13 @@
|
|
|
1464
1464
|
offset="offset"
|
|
1465
1465
|
direction="'vertical'"
|
|
1466
1466
|
onScroll.bind="onScroll"
|
|
1467
|
-
/>`;static defaultProps={topOffset:0};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.topOffset+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})}}yS.props={topOffset:{type:Number,optional:!0}};const IS={ROW:jb,COL:qb,CELL:If};class RS extends t.Component{static template="o-spreadsheet-Grid";static components={GridComposer:Zv,GridOverlay:hS,GridPopover:dS,HeadersOverlay:mS,Menu:Vr,Autofill:Fv,ClientTag:Lv,Highlight:CS,Popover:Lr,VerticalScrollBar:yS,HorizontalScrollBar:xS,FilterIconsOverlay:Kv};HEADER_HEIGHT=F;HEADER_WIDTH=D;menuState;gridRef;onMouseWheel;canvasPosition;hoveredCell;setup(){this.menuState=t.useState({isOpen:!1,position:null,menuItems:[]}),this.gridRef=t.useRef("grid"),this.canvasPosition=Nr(this.gridRef),this.hoveredCell=t.useState({col:void 0,row:void 0}),t.useChildSubEnv({getPopoverContainerRect:()=>this.getGridRect()}),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.focusDefaultElement())),this.props.exposeFocus((()=>this.focusDefaultElement())),fS("canvas",this.env.model,(()=>this.env.model.getters.getSheetViewDimensionWithHeaders())),t.useEffect((()=>this.focusDefaultElement()),(()=>[this.env.model.getters.getActiveSheetId()])),this.onMouseWheel=bS(((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 Yi({top:"26px",left:"48px",height:"calc(100% - 41px)",width:"calc(100% - 63px)"})}onClosePopover(){this.env.model.getters.hasOpenedPopover()&&this.closeOpenedPopover(),this.focusDefaultElement()}keyDownMapping={ENTER:()=>{this.env.model.getters.getActiveCell().type===ls.empty?this.props.onGridComposerCellFocused():this.props.onComposerContentFocused()},TAB:()=>this.env.model.selection.moveAnchorCell("right",1),"SHIFT+TAB":()=>this.env.model.selection.moveAnchorCell("left",1),F2:()=>{this.env.model.getters.getActiveCell().type===ls.empty?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()})},ESCAPE:()=>{this.env.model.getters.hasOpenedPopover()?this.closeOpenedPopover():this.menuState.isOpen?this.closeMenu():this.env.model.getters.isPaintingFormat()?this.env.model.dispatch("CANCEL_PAINT_FORMAT"):this.env.model.dispatch("CLEAN_CLIPBOARD_HIGHLIGHT")},"CTRL+A":()=>this.env.model.selection.loopSelection(),"CTRL+Z":()=>this.env.model.dispatch("REQUEST_UNDO"),"CTRL+Y":()=>this.env.model.dispatch("REQUEST_REDO"),F4:()=>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}}),"CTRL+O":()=>Cm(this.env),"ALT+=":()=>{const e=this.env.model.getters.getActiveSheetId(),t=this.env.model.getters.getSelectedZone(),{anchor:o}=this.env.model.getters.getSelection(),i=this.env.model.getters.getAutomaticSums(e,t,o.cell);if(this.env.model.getters.isSingleCellOrMerge(e,t)||this.env.model.getters.isEmpty(e,t)&&i.length<=1){const t=i[0]?.zone,o=t?this.env.model.getters.zoneToXC(e,i[0].zone):"",s=`=SUM(${o})`;this.props.onGridComposerCellFocused(s,{start:5,end:5+o.length})}else this.env.model.dispatch("SUM_SELECTION")},"ALT+ENTER":()=>{const e=this.env.model.getters.getActiveCell();e.link&&ns(e.link,this.env)},"CTRL+HOME":()=>{const e=this.env.model.getters.getActiveSheetId(),{col:t,row:o}=this.env.model.getters.getNextVisibleCellPosition({sheetId:e,col:0,row:0});this.env.model.selection.selectCell(t,o)},"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),o=this.env.model.getters.findVisibleHeader(e,"ROW",this.env.model.getters.getNumberRows(e)-1,0);this.env.model.selection.selectCell(t,o)},"SHIFT+ ":()=>{const e=this.env.model.getters.getActiveSheetId(),t={...this.env.model.getters.getSelectedZone(),left:0,right:this.env.model.getters.getNumberCols(e)-1},o=this.env.model.getters.getActivePosition();this.env.model.selection.selectZone({cell:o,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},o=this.env.model.getters.getActivePosition();this.env.model.selection.selectZone({cell:o,zone:t})},"CTRL+SHIFT+E":()=>this.setHorizontalAlign("center"),"CTRL+SHIFT+L":()=>this.setHorizontalAlign("left"),"CTRL+SHIFT+R":()=>this.setHorizontalAlign("right"),"CTRL+SHIFT+V":()=>pm(this.env),"CTRL+SHIFT+<":()=>this.clearFormatting(),"CTRL+<":()=>this.clearFormatting(),"CTRL+SHIFT+ ":()=>{this.env.model.selection.selectAll()},"CTRL+ALT+=":()=>{const e=this.env.model.getters.getActiveCols(),t=this.env.model.getters.getActiveRows(),o=1===this.env.model.getters.getSelectedZones().length,i=e.size>0&&o,s=t.size>0&&o;i&&!s?vm(this.env):s&&!i&&bm(this.env)},"CTRL+ALT+-":()=>{const e=[...this.env.model.getters.getActiveCols()],t=[...this.env.model.getters.getActiveRows()];e.length>0&&0===t.length?this.env.model.dispatch("REMOVE_COLUMNS_ROWS",{sheetId:this.env.model.getters.getActiveSheetId(),dimension:"COL",elements:e}):t.length>0&&0===e.length&&this.env.model.dispatch("REMOVE_COLUMNS_ROWS",{sheetId:this.env.model.getters.getActiveSheetId(),dimension:"ROW",elements:t})},"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"),"CTRL+K":()=>wm(this.env)};focusDefaultElement(){this.env.model.getters.getSelectedFigureId()||"inactive"!==this.env.model.getters.getEditionMode()||this.env.focusableElement.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}}get isAutofillVisible(){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:D,gridOffsetY:F})}moveCanvas(e,t){const{scrollX:o,scrollY:i}=this.env.model.getters.getActiveSheetDOMScrollInfo();this.env.model.dispatch("SET_VIEWPORT_OFFSET",{offsetX:o+e,offsetY:i+t})}getClientPositionKey(e){return`${e.id}-${e.position?.sheetId}-${e.position?.col}-${e.position?.row}`}isCellHovered(e,t){return this.hoveredCell.col===e&&this.hoveredCell.row===t}getGridRect(){return{...this.canvasPosition,...this.env.model.getters.getSheetViewDimensionWithHeaders()}}onCellClicked(e,t,{addZone:o,expandZone:i}){o&&this.env.model.dispatch("PREPARE_SELECTION_INPUT_EXPANSION"),this.env.model.getters.hasOpenedPopover()&&this.closeOpenedPopover(),"editing"===this.env.model.getters.getEditionMode()&&this.env.model.dispatch("STOP_EDITION"),i?this.env.model.selection.setAnchorCorner(e,t):o?this.env.model.selection.addCellToSelection(e,t):this.env.model.selection.selectCell(e,t);let s=e,r=t;nv(this.env,((e,t,o)=>{o.preventDefault(),(e!==s&&-1!=e||t!==r&&-1!=t)&&(s=-1===e?s:e,r=-1===t?r:t,this.env.model.selection.setAnchorCorner(s,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 o=this.env.model.getters.getActiveSheetId();({col:e,row:t}=this.env.model.getters.getMainCellPosition({sheetId:o,col:e,row:t}));this.env.model.getters.getEvaluatedCell({sheetId:o,col:e,row:t}).type===ls.empty?this.props.onGridComposerCellFocused():this.props.onComposerContentFocused()}closeOpenedPopover(){this.env.model.dispatch("CLOSE_CELL_POPOVER")}processArrows(e){e.preventDefault(),e.stopPropagation(),this.env.model.getters.hasOpenedPopover()&&this.closeOpenedPopover(),Jb(e,this.env.model.selection),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="";Or(e)&&(t+="CTRL+"),e.altKey&&(t+="ALT+"),e.shiftKey&&(t+="SHIFT+"),t+=e.key.toUpperCase();let o=this.keyDownMapping[t];return o?(e.preventDefault(),e.stopPropagation(),void o()):void 0}onInputContextMenu(e){e.preventDefault();const t=this.env.model.getters.getSelectedZone(),{left:o,top:i}=t;let s="CELL";this.env.model.dispatch("STOP_EDITION"),this.env.model.getters.getActiveCols().has(o)?s="COL":this.env.model.getters.getActiveRows().has(i)&&(s="ROW");const{x:r,y:n,width:a,height:l}=this.env.model.getters.getVisibleRect(t);this.toggleContextMenu(s,r+a,n+l)}onCellRightClicked(e,t,{x:o,y:i}){const s=this.env.model.getters.getSelectedZones();let r="CELL";ui(e,t,s[s.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,o,i)}toggleContextMenu(e,t,o){this.env.model.getters.hasOpenedPopover()&&this.closeOpenedPopover(),this.menuState.isOpen=!0,this.menuState.position={x:t,y:o},this.menuState.menuItems=IS[e].getMenuItems()}copy(e,t){if(!this.gridEl.contains(document.activeElement))return;const o=t.clipboardData;if(!o)return void this.displayWarningCopyPasteNotSupported();if("inactive"!==this.env.model.getters.getEditionMode())return;e?sm(this.env):this.env.model.dispatch("COPY");const i=this.env.model.getters.getClipboardContent();for(const e in i)o.setData(e,i[e]);t.preventDefault()}async paste(e){if(!this.gridEl.contains(document.activeElement))return;const t=e.clipboardData;if(t){if(t.types.indexOf(cs.PlainText)>-1){const e=t.getData(cs.PlainText),o=this.env.model.getters.getSelectedZones();this.env.model.getters.getClipboardTextContent()===e?lm(this.env,o):cm(this.env,o,e),this.env.model.getters.isCutOperation()&&await this.env.clipboard.write({[cs.PlainText]:""})}}else this.displayWarningCopyPasteNotSupported()}displayWarningCopyPasteNotSupported(){this.env.raiseError(r("Copy/Paste is not supported in this browser."))}clearFormatting(){this.env.model.dispatch("CLEAR_FORMATTING",{sheetId:this.env.model.getters.getActiveSheetId(),target:this.env.model.getters.getSelectedZones()})}setHorizontalAlign(e){this.env.model.dispatch("SET_FORMATTING",{sheetId:this.env.model.getters.getActiveSheetId(),target:this.env.model.getters.getSelectedZones(),style:{align:e}})}closeMenu(){this.menuState.isOpen=!1,this.focusDefaultElement()}}RS.props={sidePanelIsOpen:Boolean,exposeFocus:Function,focusComposer:String,onComposerContentFocused:Function,onGridComposerCellFocused:Function};class TS{xmlString;constructor(e){this.xmlString=e}toString(){return this.xmlString}}const AS=["areaChart","area3DChart","lineChart","line3DChart","stockChart","radarChart","scatterChart","pieChart","pie3DChart","doughnutChart","barChart","bar3DChart","ofPieChart","surfaceChart","surface3DChart","bubbleChart"],OS="000000",MS={arrow:"3Arrows",smiley:"3Symbols",dot:"3TrafficLights1"},NS={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"},_S="http://schemas.openxmlformats.org/drawingml/2006/main",FS="http://schemas.openxmlformats.org/drawingml/2006/chart",DS={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"},LS={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",image:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/image"},PS="http://schemas.openxmlformats.org/officeDocument/2006/relationships",kS=.75,US=.143,VS=8.43,BS=12.75,zS=30,HS=100,$S=164,WS={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}]},GS=["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"],qS="[Content_Types].xml";var ZS;!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"}(ZS||(ZS={}));class YS{_parsingWarnings=new Set;_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,o){let i=`${e} ${t?'"'+t+'" is':"are"} not yet supported. `;o&&(i+=`Only ${o.join(", ")} are currently supported.`),this._conversionWarnings.has(i)||this._conversionWarnings.add(i)}}const jS=["thin"],XS=["general","left","center","right"],KS=["top","center","bottom"],QS=["Arial"],JS=["solid"],eC=["expression","cellIs","colorScale","iconSet","containsText","notContainsText","beginsWith","endsWith","containsBlanks","notContainsBlanks"],tC={b:"boolean",d:"date",e:"error",inlineStr:"inlineStr",n:"number",s:"sharedString",str:"str"},oC={dashDot:"thin",dashDotDot:"thin",dashed:"dashed",dotted:"dotted",double:"thin",hair:"thin",medium:"medium",mediumDashDot:"thin",mediumDashDotDot:"thin",mediumDashed:"thin",none:void 0,slantDashDot:"thin",thick:"thick",thin:"thin"},iC={general:void 0,left:"left",center:"center",right:"right",fill:"left",justify:"left",centerContinuous:"center",distributed:"center"},sC={top:"top",center:"middle",bottom:"bottom",justify:"middle",distributed:"middle"},rC={top:"top",middle:"center",bottom:"bottom"};const nC={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},aC={num:"number",percent:"percentage",max:"value",min:"value",percentile:"percentile",formula:"formula"},lC={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"},cC={b:"bottom",t:"top",l:"left",r:"right",tr:"right"},hC={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},dC={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"},uC={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},gC={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},pC={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"},mC={"image/avif":"avif","image/bmp":"bmp","image/gif":"gif","image/vnd.microsoft.icon":"ico","image/jpeg":"jpeg","image/png":"png","image/tiff":"tiff","image/webp":"webp"},fC={avif:"image/avif",bmp:"image/bmp",gif:"image/gif",ico:"image/vnd.microsoft.icon",jpeg:"image/jpeg",png:"image/png",tiff:"image/tiff",webp:"image/webp",jpg:"image/jpeg"};function bC(e){if(!e)return;let t;if(e.rgb)t=e.rgb;else if(e.auto)t=OS;else{if(!e.indexed)return;t=pC[e.indexed]}var o;return t=6===(o=t).length?"#"+o+"FF":"#"+o.slice(2)+o.slice(0,2),e.tint&&(t=function(e,t){const o=ut(e),i=pt(o);t<0&&(i.l=i.l*(1+t));t>0&&(i.l=i.l*(1-t)+(100-100*(1-t)));return dt(gt(i))}(t,e.tint)),t=t.toUpperCase(),9===t.length&&t.endsWith("FF")&&(t=t.slice(0,7)),t}function vC(e,t){const o=e.split("/"),i=t.split("/");let s="",r=0;for(let e=0;e<o.length-1;e++)o[e]===i[e]?r++:s+="../";return s+=i.slice(r).join("/"),s}function SC(e,t=0){const o={};for(let i=0;i<e.length;i++)e[i]&&(o[i+t]=e[i]);return o}function CC(e){const t=[];for(let o of Object.keys(e).map(Number))t[o]=e[o];return t}function EC(e){return e.replace(/_x([0-9a-zA-Z]{4})_/g,((e,t)=>String.fromCharCode(parseInt(t,16))))}const wC=/^(yy|yyyy|m{1,5}|d{1,4}|h{1,2}|s{1,2}|am\/pm|a\/m|\s|-|\/|\.|:)+$/i;function xC(e,t,o){if(0===e)return;let i=uC[e]||t.find((t=>t.id===e))?.format;if(i)try{let e=i.replace(/(.*?);.*/,"$1");e=e.replace(/\[(.*)-[A-Z0-9]{3}\]/g,"[$1]"),e=e.replace(/\[\$\]/g,"");const t=e.match(/"/g)?.length||0;if(t/2+(e.match(/\[/g)?.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 wC.test(e)}(e)&&(e=function(e){return e=e.toLowerCase(),e=e.replace(/mmmmm/g,"mmm"),e=e.replace(/am\/pm|a\/m/g,"a"),e=e.replace(/hhhh/g,"hh"),e=e.replace(/\bh\b/g,"hh"),e}(e)),function(e){try{return fo(0,{format:e,locale:eo}),!0}catch(e){return!1}}(e))return e}catch(e){}o.generateNotSupportedWarning(ZS.NumFmtIdNotSupported,i||`nmFmtId ${e}`)}function yC(e,t){const o=e.borders.map((e=>{!function(e,t){e.diagonal&&t.generateNotSupportedWarning(ZS.DiagonalBorderNotSupported)}(e,t);const o={top:IC(e.top,t),bottom:IC(e.bottom,t),left:IC(e.left,t),right:IC(e.right,t)};return Object.keys(o).forEach((e=>void 0===o[e]&&delete o[e])),o}));return SC(o,1)}function IC(e,t){if(!e)return;!function(e,t){jS.includes(e.style)||t.generateNotSupportedWarning(ZS.BorderStyleNotSupported,e.style,jS)}(e,t);const o=oC[e.style];return o?{style:o,color:bC(e.color)}:void 0}function RC(e,t){return SC(e.styles.map((o=>TC({fontStyle:e.fonts[o.fontId],fillStyle:e.fills[o.fillId],alignment:o.alignment},t))),1)}function TC(e,t){return function(e,t,o){e&&e.name&&!QS.includes(e.name)&&o.generateNotSupportedWarning(ZS.FontNotSupported,e.name,QS);t&&t.patternType&&!JS.includes(t.patternType)&&o.generateNotSupportedWarning(ZS.FillStyleNotSupported,t.patternType,JS)}(e?.fontStyle,e?.fillStyle,t),function(e,t){e&&!XS.includes(e)&&t.generateNotSupportedWarning(ZS.HorizontalAlignmentNotSupported,e,XS)}(e?.alignment?.horizontal,t),function(e,t){e&&!KS.includes(e)&&t.generateNotSupportedWarning(ZS.VerticalAlignmentNotSupported,e,KS)}(e?.alignment?.vertical,t),{bold:e.fontStyle?.bold,italic:e.fontStyle?.italic,strikethrough:e.fontStyle?.strike,underline:e.fontStyle?.underline,verticalAlign:e.alignment?.vertical?sC[e.alignment.vertical]:void 0,align:e.alignment?.horizontal?iC[e.alignment.horizontal]:void 0,fillColor:"solid"===e.fillStyle?.patternType?bC(e.fillStyle?.fgColor):bC(e.fillStyle?.bgColor),textColor:bC(e.fontStyle?.color),fontSize:e.fontStyle?.size,wrapping:e.alignment?.wrapText?"wrap":"overflow"}}function AC(e,t){const o=[];for(let i of e.styles){const s=xC(i.numFmtId,e.numFmts,t);s&&(o[i.numFmtId]=s)}return SC(o,1)}function OC(e,t,o){const i=[];let s=1;for(let n of e){if(0===n.cfRules.length)continue;FC(n,t,o);const e=n.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=MC(s++,n);t&&i.push(t);continue;case"iconSet":const c=NC(s++,n,o);c&&i.push(c);continue;case"containsText":case"notContainsText":case"beginsWith":case"endsWith":if(!e.text)continue;a=nC[e.type],l.push(e.text);break;case"containsBlanks":case"notContainsBlanks":a=nC[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&&i.push({id:(s++).toString(),ranges:n.sqref,stopIfTrue:e.stopIfTrue,rule:{type:"CellIsRule",operator:a,values:l,style:TC({fontStyle:t[e.dxfId].font,fillStyle:t[e.dxfId].fill},o)}})}}var r;return i}function MC(e,t){const o=t.cfRules[0].colorScale;if(!o||o.cfvos.length!==o.colors.length||o.cfvos.length<2||o.cfvos.length>3)return;const i=[];for(let e=0;e<o.cfvos.length;e++)i.push({color:(s=bC(o.colors[e])||"#FFFFFF",9===s.length&&(s=s.slice(0,7)),parseInt(s.replace("#",""),16)),type:aC[o.cfvos[e].type],value:o.cfvos[e].value});var s;const r=i[0],n=2===i.length?i[1]:i[2],a=3===i.length?i[1]:void 0;return{id:e.toString(),stopIfTrue:t.cfRules[0].stopIfTrue,ranges:t.sqref,rule:{type:"ColorScaleRule",minimum:r,midpoint:a,maximum:n}}}function NC(e,t,o){const i=t.cfRules[0].iconSet;if(!i)return;let s=i.cfvos,r=i.cfIcons;if(s.length<3||r&&r.length<3)return;s.length>3&&(s=[s[0],s[Math.floor(s.length/2)],s[s.length-1]]),r&&r.length>3&&(r=[r[0],r[Math.floor(r.length/2)],r[r.length-1]]);const n=[];for(let e=1;e<=2;e++){const t=aC[s[e].type];if("value"===t)return;n.push({value:s[e].value||"",operator:s[e].gte?"ge":"gt",type:t})}let a={lower:r?_C(r[0].iconSet,r[0].iconId):_C(i.iconSet,0),middle:r?_C(r[1].iconSet,r[1].iconId):_C(i.iconSet,1),upper:r?_C(r[2].iconSet,r[2].iconId):_C(i.iconSet,2)};i.reverse&&(a={upper:a.lower,middle:a.middle,lower:a.upper});for(let e of Object.keys(a))if(!a[e])switch(o.generateNotSupportedWarning(ZS.CfIconSetEmptyIconNotSupported),e){case"upper":a[e]=Ev.dots.good;break;case"middle":a[e]=Ev.dots.neutral;break;case"lower":a[e]=Ev.dots.bad}return{id:e.toString(),stopIfTrue:t.cfRules[0].stopIfTrue,ranges:t.sqref,rule:{type:"IconSetRule",icons:a,upperInflectionPoint:n[1],lowerInflectionPoint:n[0]}}}function _C(e,t){const o=lC[e];return o?0===t?Ev[o].bad:1===t?Ev[o].neutral:Ev[o].good:""}function FC(e,t,o){if(e.cfRules.length>1&&o.generateNotSupportedWarning(ZS.MultipleRulesCfNotSupported),eC.includes(e.cfRules[0].type)||o.generateNotSupportedWarning(ZS.CfTypeNotSupported,e.cfRules[0].type),e.cfRules[0].dxfId){const i=t[e.cfRules[0].dxfId];i.border&&o.generateNotSupportedWarning(ZS.CfFormatBorderNotSupported),i.alignment&&o.generateNotSupportedWarning(ZS.CfFormatAlignmentNotSupported),i.numFmt&&o.generateNotSupportedWarning(ZS.CfFormatNumFmtNotSupported)}}function DC(e){switch(e){case"IsNotEmpty":case"NotContains":return"notContainsBlanks";case"IsEmpty":return"containsBlanks";default:return e.charAt(0).toLowerCase()+e.slice(1)}}function LC(e){return Math.round(kS*e*100)/100}function PC(e){return Math.round(US*e*100)/100}function kC(e){if(e)return{style:e.style,color:{rgb:e.color}}}function UC(e,t){let o={};e.style&&(o=t.styles[e.style]);const i=function(e,t){if(e.format)return t.formats[e.format];return}(e,t),s={};if(e.border){const o=t.borders[e.border];s.left=kC(o.left),s.right=kC(o.right),s.bottom=kC(o.bottom),s.top=kC(o.top)}const r={font:{size:o?.fontSize||Z,color:{rgb:o?.textColor?o.textColor:"000000"},family:2,name:"Arial"},fill:o?.fillColor?{fgColor:{rgb:o.fillColor}}:{reservedAttribute:"none"},numFmt:i?{format:i,id:0}:void 0,border:s||{},alignment:{horizontal:o.align,vertical:o.verticalAlign?rC[o.verticalAlign]:void 0,wrapText:"wrap"===o.wrapping}};return r.font.strike=!!o?.strikethrough||void 0,r.font.underline=!!o?.underline||void 0,r.font.bold=!!o?.bold||void 0,r.font.italic=!!o?.italic||void 0,r}function VC(e,t){const{id:o}=zC(t.font,e.fonts),{id:i}=zC(t.fill,e.fills),{id:s}=zC(t.border,e.borders),r=function(e,t){if(!e)return 0;let o=gC[e.format];if(!o){const{id:i}=zC(e,t);o=i+$S}return o}(t.numFmt,e.numFmts),n={fontId:o,fillId:i,borderId:s,numFmtId:r,alignment:{vertical:t.alignment.vertical,horizontal:t.alignment.horizontal,wrapText:t.alignment.wrapText}},{id:a}=zC(n,e.styles);return a}function BC(e,t,o){let i,s=e.find((e=>e.path===t));return s?(i=`rId${(s.rels.length+1).toString()}`,s.rels.push({...o,id:i})):(i="rId1",e.push({path:t,rels:[{...o,id:i}]})),i}function zC(e,t){for(let[o,i]of Object.entries(t))if(JSON.stringify(i)===JSON.stringify(e))return{id:parseInt(o,10),list:t};let o=t.findIndex((t=>JSON.stringify(t)===JSON.stringify(e)));return-1===o&&(t.push(e),o=t.length-1),{id:o,list:t}}const HC=[];function $C(e){const t=HC.findIndex((t=>t===e));return-1===t?(HC.push(e),HC.length):t+1}const WC=[];function GC(e){const t=WC.findIndex((t=>t===e));return-1===t?(WC.push(e),WC.length):t+1}function qC(e){return Math.round(914400*e/96)}function ZC(e,t,o){let i,s,r=e;if(({xc:r,sheetName:i}=Jo(e)),i){const e=o.sheets.findIndex((e=>e.name===i));if(e<0)throw new Error("Unable to find a sheet with the name "+i);s=e}else s=Number(t);const n=ei(r);return void 0===n.right&&(n.right=o.sheets[s].colNumber),void 0===n.bottom&&(n.bottom=o.sheets[s].rowNumber),(n.right-n.left+1)*(n.bottom-n.top+1)}function YC(e){return Math.round(96*e/914400)}function jC(e,t){let o=0;for(let i=0;i<e;i++){const e=t.cols.find((e=>i>=e.min&&i<=e.max));e?.width?o+=e.width:t.sheetFormat?.defaultColWidth?o+=t.sheetFormat.defaultColWidth:o+=VS}return o/US}function XC(e,t){let o=0;for(let i=0;i<e;i++){const e=t.rows[i];e?.height?o+=e.height:t.sheetFormat?.defaultRowHeight?o+=t.sheetFormat.defaultRowHeight:o+=BS}return o/kS}function KC(e){let t=1;return e.figures.map((o=>function(e,t,o){const i=jC(e.anchors[0].col,o)+YC(e.anchors[0].colOffset),s=jC(e.anchors[1].col,o)+YC(e.anchors[1].colOffset),r=XC(e.anchors[0].row,o)+YC(e.anchors[0].rowOffset),n=XC(e.anchors[1].row,o)+YC(e.anchors[1].rowOffset),a={id:t,x:i,y:r};if("dataSets"in e.data)return{...a,width:s-i,height:n-r,tag:"chart",data:QC(e.data)};if(function(e){return"imageSrc"in e}(e.data))return{...a,width:YC(e.data.size.cx),height:YC(e.data.size.cy),tag:"image",data:{path:e.data.imageSrc,mimetype:e.data.mimetype}};return}(o,(t++).toString(),e))).filter(ke)}function QC(e){const t=void 0!==e.dataSets[0].label,o=e.labelRange?JC(e.labelRange,t):void 0;let i=e.dataSets.map((e=>JC(e.range,t)));return"pie"===e.type&&i.reverse(),{dataSets:i,dataSetsHaveTitle:t,labelRange:o,title:e.title||"",type:e.type,background:bC({rgb:e.backgroundColor})||"#FFFFFF",verticalAxisPosition:e.verticalAxisPosition,legendPosition:e.legendPosition,stacked:e.stacked||!1,aggregated:!1,cumulative:e.cumulative||!1,labelsAsText:!1}}function JC(e,t){let{sheetName:o,xc:i}=Jo(e);o=o?we(o)+"!":"";let s=ei(i);if(t&&void 0!==s.bottom&&void 0!==s.right){const e=s.bottom-s.top+1,t=s.right-s.left+1;1===e?s={...s,left:s.left-1}:1===t&&(s={...s,top:s.top-1})}return o+ii(s)}const eE=new RegExp(/'?\[([0-9]*)\](.*)'?!(\$?[a-zA-Z]*\$?[0-9]*)/g),tE=new RegExp(/SUBTOTAL\(([0-9]*),/g),oE=new RegExp(zo.source,"ig");function iE(e,t){const o=function(e){const t={};for(let o of e.rows)for(let e of o.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 i of e.rows.map((e=>e.cells)).flat())i?.formula&&(i.formula.content=void 0===i.formula.sharedIndex||i.formula.content?"="+i.formula.content:"="+rE(i.xc,o[i.formula.sharedIndex]),i.formula.content=sE(i.formula.content,t))}function sE(e,t){return e=(e=(e=(e=e.replace("_xlfn.","")).replace(/#REF!/g,"#REF")).replace(tE,((e,t)=>{const o=dC[t];return o?o+"(":e}))).replace(eE,((e,o,i,s)=>{o=Number(o)-1,s=s.replace(/\$/g,"");const r=t.externalBooks[o].sheetNames.findIndex((e=>e===i));if(-1===r)return e;const n=t.externalBooks[o].datasets.find((e=>e.sheetId===r))?.data;if(!n)return e;const a=n&&n[s];return(Number(a)?a:`"${a}"`)||e}))}function rE(e,t){const o=wt(t.refCellXc);let i,s=t.formula.slice();do{if(i=oE.exec(s),i){const t=wt(i[0].replace("$","")),r=wt(e),n={colFixed:i[0].startsWith("$"),rowFixed:i[0].includes("$",1)},a={col:r.col-o.col,row:r.row-o.row},l={col:n.colFixed?t.col:t.col+a.col,row:n.rowFixed?t.row:t.row+a.row};s=s.slice(0,i.index)+xt(l.col,l.row,n)+s.slice(i.index+i[0].length)}}while(i);return s}function nE(e,t){return e.sheets.map((o=>{iE(o,e);const i=function(e){const t=[0,0];for(let o of e.rows)t[0]=Math.max(t[0],et(o.cells.map((e=>wt(e.xc).col)))),t[1]=Math.max(t[1],o.index);return t[0]=Math.max(t[0],zS),t[1]=Math.max(t[1],HS),t}(o),s=o.sheetViews[0];return{id:o.sheetName,areGridLinesVisible:!s||s.showGridLines,name:o.sheetName,colNumber:i[0],rowNumber:i[1],cells:cE(o,e,i,t),merges:o.merges,cols:aE(o,i[0]),rows:lE(o,i[1]),conditionalFormats:OC(o.cfs,e.dxfs,t),figures:KC(o),isVisible:o.isVisible,panes:s?{xSplit:s.pane.xSplit,ySplit:s.pane.ySplit}:{xSplit:0,ySplit:0},filterTables:[]}}))}function aE(e,t){const o={};for(let s=1;s<t+1;s++){const t=e.cols.find((e=>e.min<=s&&s<=e.max));let r;r=t&&t.width?t.width:e.sheetFormat?.defaultColWidth?e.sheetFormat.defaultColWidth:VS,o[s-1]={size:(i=r,i?Math.round(i/US*100)/100:i),isHidden:t?.hidden}}var i;return o}function lE(e,t){const o={};for(let s=1;s<t+1;s++){const t=e.rows.find((e=>e.index===s));let r;r=t&&t.height?t.height:e.sheetFormat?.defaultRowHeight?e.sheetFormat.defaultRowHeight:BS,o[s-1]={size:(i=r,i?Math.round(i/kS*100)/100:i),isHidden:t?.hidden}}var i;return o}function cE(e,t,o,i){const s={},r=t.sharedStrings.map((e=>e.replace(/\n/g,"")));const n=e.hyperlinks.reduce(((e,t)=>(e[t.xc]=t,e)),{});for(let o of e.rows)for(let e of o.cells)s[e.xc]={content:hE(e,n,r,i),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 i of e.rows.filter((e=>e.styleIndex)))for(let e=1;e<=o[0];e++){const o=xt(e-1,i.index-1);let r=s[o];r||(r={},s[o]=r),r.style=r.style?r.style:i.styleIndex+1,r.border=r.border?r.border:t.styles[i.styleIndex].borderId+1,r.format=r.format?r.format:t.styles[i.styleIndex].numFmtId+1}for(let i of e.cols.filter((e=>e.styleIndex)))for(let e=i.min;e<=Math.min(i.max,o[0]);e++)for(let r=1;r<=o[1];r++){const o=xt(e-1,r-1);let n=s[o];n||(n={},s[o]=n),n.style=n.style?n.style:i.styleIndex+1,n.border=n.border?n.border:t.styles[i.styleIndex].borderId+1,n.format=n.format?n.format:t.styles[i.styleIndex].numFmtId+1}return s}function hE(e,t,o,i){let s;switch(e.type){case"sharedString":s=o[parseInt(e.value,10)];break;case"boolean":s=Number(e.value)?"TRUE":"FALSE";break;case"date":case"error":case"inlineStr":case"number":case"str":s=e.value}return s&&t[e.xc]&&(s=function(e,t,o){const i=e.display||t;e.relTarget||e.location||o.generateNotSupportedWarning(ZS.BadlyFormattedHyperlink);const s=e.relTarget?e.relTarget:Le(Jo(e.location).sheetName);return Ne(i,s)}(t[e.xc],s,i)),e.formula&&(s=e.formula.content),s}const dE={fillColor:"#000000",textColor:"#ffffff",bold:!0},uE={bold:!0},gE={style:"thin",color:"#000000FF"};function pE(e,t){for(const o of t.sheets)for(const t of o.tables){const i=e.sheets.find((e=>e.name===o.sheetName));i&&t.autoFilter&&(i.filterTables||(i.filterTables=[]),i.filterTables.push({range:t.ref}))}!function(e,t){const o=CC(e.styles),i=CC(e.borders);for(let s of t.sheets)for(let t of s.tables){const r=e.sheets.find((e=>e.name===s.sheetName));if(!r)continue;const n=ti(t.ref);for(let e=0;e<t.headerRowCount;e++)mE(dE,{...n,bottom:n.top+e},r.cells,o);for(let e=0;e<t.totalsRowCount;e++)mE(uE,{...n,top:n.bottom-e},r.cells,o);t.style?.showFirstColumn&&mE(uE,{...n,right:n.left},r.cells,o),t.style?.showLastColumn&&mE(uE,{...n,left:n.right},r.cells,o);for(let e=n.left;e<=n.right;e++)for(let o=n.top;o<=n.bottom;o++){const s=xt(e,o),a=r.cells[s],l={left:e===n.left||t.style?.showColumnStripes?gE:void 0,right:e===n.right?gE:void 0,top:o===n.top||t.style?.showRowStripes||o>n.bottom-t.totalsRowCount?gE:void 0,bottom:o===n.bottom?gE:void 0},c=a?.border?{...i[a.border],...l}:l;let h=i.findIndex((e=>We(e,c)));-1===h&&(h=i.length,i.push(c)),a?a.border=h:r.cells[s]={border:h}}}e.styles=SC(o),e.borders=SC(i)}(e,t),function(e,t){for(let o of e){const e=t.find((e=>e.sheetName===o.name)).tables;for(let t of e){const e=t.name+"[";for(let i of vi(ti(t.ref))){const s=xt(i.col,i.row),r=o.cells[s];if(r&&r.content&&r.content.startsWith("=")){let o;for(;-1!==(o=r.content.indexOf(e));){let i=r.content.slice(o+e.length),n=i.indexOf("]");i.startsWith("[")&&(n=i.indexOf("]",n+1),n=i.indexOf("]",n+1)),i=i.slice(0,n);const a=fE(i,t,s);r.content=r.content.slice(0,o)+a+r.content.slice(e.length+o+n+1)}}}}}}(e.sheets,t.sheets)}function mE(e,t,o,i){for(let s=t.left;s<=t.right;s++)for(let r=t.top;r<=t.bottom;r++){const t=xt(s,r),n=o[t],a=n?.style?{...i[n.style],...e}:e;let l=i.findIndex((e=>We(e,a)));-1===l&&(l=i.length,i.push(a)),n?n.style=l:o[t]={style:l}}}function fE(e,t,o){const i=e.split(","),s=ti(t.ref),r={...s};let n=!0;if(1===i.length){const e=t.cols.findIndex((e=>e.name===i[0]));r.left=r.right=e+s.left,t.headerRowCount&&(r.top+=t.headerRowCount),t.totalsRowCount&&(r.bottom-=1)}else{switch(i[0].slice(1,i[0].length-1)){case"#All":r.top=t.headerRowCount?s.top+t.headerRowCount:s.top,r.bottom=s.bottom;break;case"#Data":r.top=t.headerRowCount?s.top+t.headerRowCount:s.top,r.bottom=t.totalsRowCount?s.bottom+1:s.bottom;break;case"#This Row":r.top=r.bottom=wt(o).row;break;case"#Headers":r.top=r.bottom=s.top,t.headerRowCount||(n=!1);break;case"#Totals":r.top=r.bottom=s.bottom,t.totalsRowCount||(n=!1)}const e=i[1].slice(1,i[1].length-1),a=t.cols.findIndex((t=>t.name===e));r.left=r.right=a+s.left}return n?r.top!==r.bottom?ii(r):xt(r.left,r.top):ee}function bE(e,t,o){return{content:(new XMLSerializer).serializeToString(e),path:t,contentType:o}}function vE(e){return String(e).replace(/\&/g,"&").replace(/\</g,"<").replace(/\>/g,">").replace(/\"/g,""").replace(/\'/g,"'").replace(/[\x00-\x08\x0B\x0C\x0E-\x1F]/g,"")}function SE(e){return new TS(e.map((([e,t])=>`${e}="${vE(t)}"`)).join(" "))}function CE(e,t="text/xml"){const o=(new DOMParser).parseFromString(e.toString(),t),i=o.querySelector("parsererror");if(i){const t=i.innerHTML,o=parseInt(t.split(":")[0],10),s=e.toString().trim().split("\n"),r=s.slice(Math.max(o-3,0),Math.min(o+2,s.length)).join("\n");throw new Error(`XML string could not be parsed: ${t}\n${r}`)}return o}function EE(e,t){return xE`
|
|
1467
|
+
/>`;static defaultProps={topOffset:0};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.topOffset+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})}}wS.props={topOffset:{type:Number,optional:!0}};const xS={ROW:Zb,COL:Wb,CELL:yf};class yS extends t.Component{static template="o-spreadsheet-Grid";static components={GridComposer:Gv,GridOverlay:lS,GridPopover:cS,HeadersOverlay:gS,Menu:Vr,Autofill:Nv,ClientTag:Fv,Highlight:vS,Popover:Lr,VerticalScrollBar:wS,HorizontalScrollBar:ES,FilterIconsOverlay:jv};HEADER_HEIGHT=F;HEADER_WIDTH=D;menuState;gridRef;onMouseWheel;canvasPosition;hoveredCell;setup(){this.menuState=t.useState({isOpen:!1,position:null,menuItems:[]}),this.gridRef=t.useRef("grid"),this.canvasPosition=Nr(this.gridRef),this.hoveredCell=t.useState({col:void 0,row:void 0}),t.useChildSubEnv({getPopoverContainerRect:()=>this.getGridRect()}),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.focusDefaultElement())),this.props.exposeFocus((()=>this.focusDefaultElement())),pS("canvas",this.env.model,(()=>this.env.model.getters.getSheetViewDimensionWithHeaders())),t.useEffect((()=>this.focusDefaultElement()),(()=>[this.env.model.getters.getActiveSheetId()])),this.onMouseWheel=mS(((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 Yi({top:"26px",left:"48px",height:"calc(100% - 41px)",width:"calc(100% - 63px)"})}onClosePopover(){this.env.model.getters.hasOpenedPopover()&&this.closeOpenedPopover(),this.focusDefaultElement()}keyDownMapping={ENTER:()=>{this.env.model.getters.getActiveCell().type===ls.empty?this.props.onGridComposerCellFocused():this.props.onComposerContentFocused()},TAB:()=>this.env.model.selection.moveAnchorCell("right",1),"SHIFT+TAB":()=>this.env.model.selection.moveAnchorCell("left",1),F2:()=>{this.env.model.getters.getActiveCell().type===ls.empty?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()})},ESCAPE:()=>{this.env.model.getters.hasOpenedPopover()?this.closeOpenedPopover():this.menuState.isOpen?this.closeMenu():this.env.model.getters.isPaintingFormat()?this.env.model.dispatch("CANCEL_PAINT_FORMAT"):this.env.model.dispatch("CLEAN_CLIPBOARD_HIGHLIGHT")},"CTRL+A":()=>this.env.model.selection.loopSelection(),"CTRL+Z":()=>this.env.model.dispatch("REQUEST_UNDO"),"CTRL+Y":()=>this.env.model.dispatch("REQUEST_REDO"),F4:()=>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}}),"CTRL+O":()=>Cm(this.env),"ALT+=":()=>{const e=this.env.model.getters.getActiveSheetId(),t=this.env.model.getters.getSelectedZone(),{anchor:o}=this.env.model.getters.getSelection(),i=this.env.model.getters.getAutomaticSums(e,t,o.cell);if(this.env.model.getters.isSingleCellOrMerge(e,t)||this.env.model.getters.isEmpty(e,t)&&i.length<=1){const t=i[0]?.zone,o=t?this.env.model.getters.zoneToXC(e,i[0].zone):"",s=`=SUM(${o})`;this.props.onGridComposerCellFocused(s,{start:5,end:5+o.length})}else this.env.model.dispatch("SUM_SELECTION")},"ALT+ENTER":()=>{const e=this.env.model.getters.getActiveCell();e.link&&ns(e.link,this.env)},"CTRL+HOME":()=>{const e=this.env.model.getters.getActiveSheetId(),{col:t,row:o}=this.env.model.getters.getNextVisibleCellPosition({sheetId:e,col:0,row:0});this.env.model.selection.selectCell(t,o)},"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),o=this.env.model.getters.findVisibleHeader(e,"ROW",this.env.model.getters.getNumberRows(e)-1,0);this.env.model.selection.selectCell(t,o)},"SHIFT+ ":()=>{const e=this.env.model.getters.getActiveSheetId(),t={...this.env.model.getters.getSelectedZone(),left:0,right:this.env.model.getters.getNumberCols(e)-1},o=this.env.model.getters.getActivePosition();this.env.model.selection.selectZone({cell:o,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},o=this.env.model.getters.getActivePosition();this.env.model.selection.selectZone({cell:o,zone:t})},"CTRL+SHIFT+E":()=>this.setHorizontalAlign("center"),"CTRL+SHIFT+L":()=>this.setHorizontalAlign("left"),"CTRL+SHIFT+R":()=>this.setHorizontalAlign("right"),"CTRL+SHIFT+V":()=>pm(this.env),"CTRL+SHIFT+<":()=>this.clearFormatting(),"CTRL+<":()=>this.clearFormatting(),"CTRL+SHIFT+ ":()=>{this.env.model.selection.selectAll()},"CTRL+ALT+=":()=>{const e=this.env.model.getters.getActiveCols(),t=this.env.model.getters.getActiveRows(),o=1===this.env.model.getters.getSelectedZones().length,i=e.size>0&&o,s=t.size>0&&o;i&&!s?vm(this.env):s&&!i&&bm(this.env)},"CTRL+ALT+-":()=>{const e=[...this.env.model.getters.getActiveCols()],t=[...this.env.model.getters.getActiveRows()];e.length>0&&0===t.length?this.env.model.dispatch("REMOVE_COLUMNS_ROWS",{sheetId:this.env.model.getters.getActiveSheetId(),dimension:"COL",elements:e}):t.length>0&&0===e.length&&this.env.model.dispatch("REMOVE_COLUMNS_ROWS",{sheetId:this.env.model.getters.getActiveSheetId(),dimension:"ROW",elements:t})},"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"),"CTRL+K":()=>wm(this.env)};focusDefaultElement(){this.env.model.getters.getSelectedFigureId()||"inactive"!==this.env.model.getters.getEditionMode()||this.env.focusableElement.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}}get isAutofillVisible(){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:D,gridOffsetY:F})}moveCanvas(e,t){const{scrollX:o,scrollY:i}=this.env.model.getters.getActiveSheetDOMScrollInfo();this.env.model.dispatch("SET_VIEWPORT_OFFSET",{offsetX:o+e,offsetY:i+t})}getClientPositionKey(e){return`${e.id}-${e.position?.sheetId}-${e.position?.col}-${e.position?.row}`}isCellHovered(e,t){return this.hoveredCell.col===e&&this.hoveredCell.row===t}getGridRect(){return{...this.canvasPosition,...this.env.model.getters.getSheetViewDimensionWithHeaders()}}onCellClicked(e,t,{addZone:o,expandZone:i}){o&&this.env.model.dispatch("PREPARE_SELECTION_INPUT_EXPANSION"),this.env.model.getters.hasOpenedPopover()&&this.closeOpenedPopover(),"editing"===this.env.model.getters.getEditionMode()&&this.env.model.dispatch("STOP_EDITION"),i?this.env.model.selection.setAnchorCorner(e,t):o?this.env.model.selection.addCellToSelection(e,t):this.env.model.selection.selectCell(e,t);let s=e,r=t;sv(this.env,((e,t,o)=>{o.preventDefault(),(e!==s&&-1!=e||t!==r&&-1!=t)&&(s=-1===e?s:e,r=-1===t?r:t,this.env.model.selection.setAnchorCorner(s,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 o=this.env.model.getters.getActiveSheetId();({col:e,row:t}=this.env.model.getters.getMainCellPosition({sheetId:o,col:e,row:t}));this.env.model.getters.getEvaluatedCell({sheetId:o,col:e,row:t}).type===ls.empty?this.props.onGridComposerCellFocused():this.props.onComposerContentFocused()}closeOpenedPopover(){this.env.model.dispatch("CLOSE_CELL_POPOVER")}processArrows(e){e.preventDefault(),e.stopPropagation(),this.env.model.getters.hasOpenedPopover()&&this.closeOpenedPopover(),Kb(e,this.env.model.selection),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="";Or(e)&&(t+="CTRL+"),e.altKey&&(t+="ALT+"),e.shiftKey&&(t+="SHIFT+"),t+=e.key.toUpperCase();let o=this.keyDownMapping[t];return o?(e.preventDefault(),e.stopPropagation(),void o()):void 0}onInputContextMenu(e){e.preventDefault();const t=this.env.model.getters.getSelectedZone(),{left:o,top:i}=t;let s="CELL";this.env.model.dispatch("STOP_EDITION"),this.env.model.getters.getActiveCols().has(o)?s="COL":this.env.model.getters.getActiveRows().has(i)&&(s="ROW");const{x:r,y:n,width:a}=this.env.model.getters.getVisibleRect(t);this.toggleContextMenu(s,this.canvasPosition.x+r+a,this.canvasPosition.y+n)}onCellRightClicked(e,t,{x:o,y:i}){const s=this.env.model.getters.getSelectedZones();let r="CELL";ui(e,t,s[s.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,o,i)}toggleContextMenu(e,t,o){this.env.model.getters.hasOpenedPopover()&&this.closeOpenedPopover(),this.menuState.isOpen=!0,this.menuState.position={x:t,y:o},this.menuState.menuItems=xS[e].getMenuItems()}copy(e,t){if(!this.gridEl.contains(document.activeElement))return;const o=t.clipboardData;if(!o)return void this.displayWarningCopyPasteNotSupported();if("inactive"!==this.env.model.getters.getEditionMode())return;e?sm(this.env):this.env.model.dispatch("COPY");const i=this.env.model.getters.getClipboardContent();for(const e in i)o.setData(e,i[e]);t.preventDefault()}async paste(e){if(!this.gridEl.contains(document.activeElement))return;const t=e.clipboardData;if(t){if(t.types.indexOf(cs.PlainText)>-1){const e=t.getData(cs.PlainText),o=this.env.model.getters.getSelectedZones();this.env.model.getters.getClipboardTextContent()===e?lm(this.env,o):cm(this.env,o,e),this.env.model.getters.isCutOperation()&&await this.env.clipboard.write({[cs.PlainText]:""})}}else this.displayWarningCopyPasteNotSupported()}displayWarningCopyPasteNotSupported(){this.env.raiseError(r("Copy/Paste is not supported in this browser."))}clearFormatting(){this.env.model.dispatch("CLEAR_FORMATTING",{sheetId:this.env.model.getters.getActiveSheetId(),target:this.env.model.getters.getSelectedZones()})}setHorizontalAlign(e){this.env.model.dispatch("SET_FORMATTING",{sheetId:this.env.model.getters.getActiveSheetId(),target:this.env.model.getters.getSelectedZones(),style:{align:e}})}closeMenu(){this.menuState.isOpen=!1,this.focusDefaultElement()}}yS.props={sidePanelIsOpen:Boolean,exposeFocus:Function,focusComposer:String,onComposerContentFocused:Function,onGridComposerCellFocused:Function};class IS{xmlString;constructor(e){this.xmlString=e}toString(){return this.xmlString}}const RS=["areaChart","area3DChart","lineChart","line3DChart","stockChart","radarChart","scatterChart","pieChart","pie3DChart","doughnutChart","barChart","bar3DChart","ofPieChart","surfaceChart","surface3DChart","bubbleChart"],TS="000000",AS={arrow:"3Arrows",smiley:"3Symbols",dot:"3TrafficLights1"},OS={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"},MS="http://schemas.openxmlformats.org/drawingml/2006/main",NS="http://schemas.openxmlformats.org/drawingml/2006/chart",_S={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"},FS={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",image:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/image"},DS="http://schemas.openxmlformats.org/officeDocument/2006/relationships",LS=.75,PS=.143,kS=8.43,US=12.75,VS=30,BS=100,zS=164,HS={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}]},$S=["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"],WS="[Content_Types].xml";var GS;!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"}(GS||(GS={}));class qS{_parsingWarnings=new Set;_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,o){let i=`${e} ${t?'"'+t+'" is':"are"} not yet supported. `;o&&(i+=`Only ${o.join(", ")} are currently supported.`),this._conversionWarnings.has(i)||this._conversionWarnings.add(i)}}const ZS=["thin"],YS=["general","left","center","right"],jS=["top","center","bottom"],XS=["Arial"],KS=["solid"],QS=["expression","cellIs","colorScale","iconSet","containsText","notContainsText","beginsWith","endsWith","containsBlanks","notContainsBlanks"],JS={b:"boolean",d:"date",e:"error",inlineStr:"inlineStr",n:"number",s:"sharedString",str:"str"},eC={dashDot:"thin",dashDotDot:"thin",dashed:"dashed",dotted:"dotted",double:"thin",hair:"thin",medium:"medium",mediumDashDot:"thin",mediumDashDotDot:"thin",mediumDashed:"thin",none:void 0,slantDashDot:"thin",thick:"thick",thin:"thin"},tC={general:void 0,left:"left",center:"center",right:"right",fill:"left",justify:"left",centerContinuous:"center",distributed:"center"},oC={top:"top",center:"middle",bottom:"bottom",justify:"middle",distributed:"middle"},iC={top:"top",middle:"center",bottom:"bottom"};const sC={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},rC={num:"number",percent:"percentage",max:"value",min:"value",percentile:"percentile",formula:"formula"},nC={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"},aC={b:"bottom",t:"top",l:"left",r:"right",tr:"right"},lC={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},cC={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"},hC={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},dC={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},uC={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"},gC={"image/avif":"avif","image/bmp":"bmp","image/gif":"gif","image/vnd.microsoft.icon":"ico","image/jpeg":"jpeg","image/png":"png","image/tiff":"tiff","image/webp":"webp"},pC={avif:"image/avif",bmp:"image/bmp",gif:"image/gif",ico:"image/vnd.microsoft.icon",jpeg:"image/jpeg",png:"image/png",tiff:"image/tiff",webp:"image/webp",jpg:"image/jpeg"};function mC(e){if(!e)return;let t;if(e.rgb)t=e.rgb;else if(e.auto)t=TS;else{if(!e.indexed)return;t=uC[e.indexed]}var o;return t=6===(o=t).length?"#"+o+"FF":"#"+o.slice(2)+o.slice(0,2),e.tint&&(t=function(e,t){const o=ut(e),i=pt(o);t<0&&(i.l=i.l*(1+t));t>0&&(i.l=i.l*(1-t)+(100-100*(1-t)));return dt(gt(i))}(t,e.tint)),t=t.toUpperCase(),9===t.length&&t.endsWith("FF")&&(t=t.slice(0,7)),t}function fC(e,t){const o=e.split("/"),i=t.split("/");let s="",r=0;for(let e=0;e<o.length-1;e++)o[e]===i[e]?r++:s+="../";return s+=i.slice(r).join("/"),s}function bC(e,t=0){const o={};for(let i=0;i<e.length;i++)e[i]&&(o[i+t]=e[i]);return o}function vC(e){const t=[];for(let o of Object.keys(e).map(Number))t[o]=e[o];return t}function SC(e){return e.replace(/_x([0-9a-zA-Z]{4})_/g,((e,t)=>String.fromCharCode(parseInt(t,16))))}const CC=/^(yy|yyyy|m{1,5}|d{1,4}|h{1,2}|s{1,2}|am\/pm|a\/m|\s|-|\/|\.|:)+$/i;function EC(e,t,o){if(0===e)return;let i=hC[e]||t.find((t=>t.id===e))?.format;if(i)try{let e=i.replace(/(.*?);.*/,"$1");e=e.replace(/\[(.*)-[A-Z0-9]{3}\]/g,"[$1]"),e=e.replace(/\[\$\]/g,"");const t=e.match(/"/g)?.length||0;if(t/2+(e.match(/\[/g)?.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 CC.test(e)}(e)&&(e=function(e){return e=e.toLowerCase(),e=e.replace(/mmmmm/g,"mmm"),e=e.replace(/am\/pm|a\/m/g,"a"),e=e.replace(/hhhh/g,"hh"),e=e.replace(/\bh\b/g,"hh"),e}(e)),function(e){try{return fo(0,{format:e,locale:eo}),!0}catch(e){return!1}}(e))return e}catch(e){}o.generateNotSupportedWarning(GS.NumFmtIdNotSupported,i||`nmFmtId ${e}`)}function wC(e,t){const o=e.borders.map((e=>{!function(e,t){e.diagonal&&t.generateNotSupportedWarning(GS.DiagonalBorderNotSupported)}(e,t);const o={top:xC(e.top,t),bottom:xC(e.bottom,t),left:xC(e.left,t),right:xC(e.right,t)};return Object.keys(o).forEach((e=>void 0===o[e]&&delete o[e])),o}));return bC(o,1)}function xC(e,t){if(!e)return;!function(e,t){ZS.includes(e.style)||t.generateNotSupportedWarning(GS.BorderStyleNotSupported,e.style,ZS)}(e,t);const o=eC[e.style];return o?{style:o,color:mC(e.color)}:void 0}function yC(e,t){return bC(e.styles.map((o=>IC({fontStyle:e.fonts[o.fontId],fillStyle:e.fills[o.fillId],alignment:o.alignment},t))),1)}function IC(e,t){return function(e,t,o){e&&e.name&&!XS.includes(e.name)&&o.generateNotSupportedWarning(GS.FontNotSupported,e.name,XS);t&&t.patternType&&!KS.includes(t.patternType)&&o.generateNotSupportedWarning(GS.FillStyleNotSupported,t.patternType,KS)}(e?.fontStyle,e?.fillStyle,t),function(e,t){e&&!YS.includes(e)&&t.generateNotSupportedWarning(GS.HorizontalAlignmentNotSupported,e,YS)}(e?.alignment?.horizontal,t),function(e,t){e&&!jS.includes(e)&&t.generateNotSupportedWarning(GS.VerticalAlignmentNotSupported,e,jS)}(e?.alignment?.vertical,t),{bold:e.fontStyle?.bold,italic:e.fontStyle?.italic,strikethrough:e.fontStyle?.strike,underline:e.fontStyle?.underline,verticalAlign:e.alignment?.vertical?oC[e.alignment.vertical]:void 0,align:e.alignment?.horizontal?tC[e.alignment.horizontal]:void 0,fillColor:"solid"===e.fillStyle?.patternType?mC(e.fillStyle?.fgColor):mC(e.fillStyle?.bgColor),textColor:mC(e.fontStyle?.color),fontSize:e.fontStyle?.size,wrapping:e.alignment?.wrapText?"wrap":"overflow"}}function RC(e,t){const o=[];for(let i of e.styles){const s=EC(i.numFmtId,e.numFmts,t);s&&(o[i.numFmtId]=s)}return bC(o,1)}function TC(e,t,o){const i=[];let s=1;for(let n of e){if(0===n.cfRules.length)continue;NC(n,t,o);const e=n.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=AC(s++,n);t&&i.push(t);continue;case"iconSet":const c=OC(s++,n,o);c&&i.push(c);continue;case"containsText":case"notContainsText":case"beginsWith":case"endsWith":if(!e.text)continue;a=sC[e.type],l.push(e.text);break;case"containsBlanks":case"notContainsBlanks":a=sC[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&&i.push({id:(s++).toString(),ranges:n.sqref,stopIfTrue:e.stopIfTrue,rule:{type:"CellIsRule",operator:a,values:l,style:IC({fontStyle:t[e.dxfId].font,fillStyle:t[e.dxfId].fill},o)}})}}var r;return i}function AC(e,t){const o=t.cfRules[0].colorScale;if(!o||o.cfvos.length!==o.colors.length||o.cfvos.length<2||o.cfvos.length>3)return;const i=[];for(let e=0;e<o.cfvos.length;e++)i.push({color:(s=mC(o.colors[e])||"#FFFFFF",9===s.length&&(s=s.slice(0,7)),parseInt(s.replace("#",""),16)),type:rC[o.cfvos[e].type],value:o.cfvos[e].value});var s;const r=i[0],n=2===i.length?i[1]:i[2],a=3===i.length?i[1]:void 0;return{id:e.toString(),stopIfTrue:t.cfRules[0].stopIfTrue,ranges:t.sqref,rule:{type:"ColorScaleRule",minimum:r,midpoint:a,maximum:n}}}function OC(e,t,o){const i=t.cfRules[0].iconSet;if(!i)return;let s=i.cfvos,r=i.cfIcons;if(s.length<3||r&&r.length<3)return;s.length>3&&(s=[s[0],s[Math.floor(s.length/2)],s[s.length-1]]),r&&r.length>3&&(r=[r[0],r[Math.floor(r.length/2)],r[r.length-1]]);const n=[];for(let e=1;e<=2;e++){const t=rC[s[e].type];if("value"===t)return;n.push({value:s[e].value||"",operator:s[e].gte?"ge":"gt",type:t})}let a={lower:r?MC(r[0].iconSet,r[0].iconId):MC(i.iconSet,0),middle:r?MC(r[1].iconSet,r[1].iconId):MC(i.iconSet,1),upper:r?MC(r[2].iconSet,r[2].iconId):MC(i.iconSet,2)};i.reverse&&(a={upper:a.lower,middle:a.middle,lower:a.upper});for(let e of Object.keys(a))if(!a[e])switch(o.generateNotSupportedWarning(GS.CfIconSetEmptyIconNotSupported),e){case"upper":a[e]=Sv.dots.good;break;case"middle":a[e]=Sv.dots.neutral;break;case"lower":a[e]=Sv.dots.bad}return{id:e.toString(),stopIfTrue:t.cfRules[0].stopIfTrue,ranges:t.sqref,rule:{type:"IconSetRule",icons:a,upperInflectionPoint:n[1],lowerInflectionPoint:n[0]}}}function MC(e,t){const o=nC[e];return o?0===t?Sv[o].bad:1===t?Sv[o].neutral:Sv[o].good:""}function NC(e,t,o){if(e.cfRules.length>1&&o.generateNotSupportedWarning(GS.MultipleRulesCfNotSupported),QS.includes(e.cfRules[0].type)||o.generateNotSupportedWarning(GS.CfTypeNotSupported,e.cfRules[0].type),e.cfRules[0].dxfId){const i=t[e.cfRules[0].dxfId];i.border&&o.generateNotSupportedWarning(GS.CfFormatBorderNotSupported),i.alignment&&o.generateNotSupportedWarning(GS.CfFormatAlignmentNotSupported),i.numFmt&&o.generateNotSupportedWarning(GS.CfFormatNumFmtNotSupported)}}function _C(e){switch(e){case"IsNotEmpty":case"NotContains":return"notContainsBlanks";case"IsEmpty":return"containsBlanks";default:return e.charAt(0).toLowerCase()+e.slice(1)}}function FC(e){return Math.round(LS*e*100)/100}function DC(e){return Math.round(PS*e*100)/100}function LC(e,t){let o={};e.style&&(o=t.styles[e.style]);const i=function(e,t){if(e.format)return t.formats[e.format];return}(e,t),s={font:{size:o?.fontSize||Z,color:{rgb:o?.textColor?o.textColor:"000000"},family:2,name:"Arial"},fill:o?.fillColor?{fgColor:{rgb:o.fillColor}}:{reservedAttribute:"none"},numFmt:i?{format:i,id:0}:void 0,border:e.border||0,alignment:{horizontal:o.align,vertical:o.verticalAlign?iC[o.verticalAlign]:void 0,wrapText:"wrap"===o.wrapping}};return s.font.strike=!!o?.strikethrough||void 0,s.font.underline=!!o?.underline||void 0,s.font.bold=!!o?.bold||void 0,s.font.italic=!!o?.italic||void 0,s}function PC(e,t){const o=function(e,t){if(!e)return 0;let o=dC[e.format];o||(o=UC(e,t)+zS);return o}(t.numFmt,e.numFmts),i={fontId:UC(t.font,e.fonts),fillId:UC(t.fill,e.fills),borderId:t.border,numFmtId:o,alignment:{vertical:t.alignment.vertical,horizontal:t.alignment.horizontal,wrapText:t.alignment.wrapText}};return UC(i,e.styles)}function kC(e,t,o){let i,s=e.find((e=>e.path===t));return s?(i=`rId${(s.rels.length+1).toString()}`,s.rels.push({...o,id:i})):(i="rId1",e.push({path:t,rels:[{...o,id:i}]})),i}function UC(e,t){let o=t.length;const i="object"==typeof e?We:(e,t)=>e===t;for(let s=0;s<o;s++)if(i(e,t[s]))return s;return t[t.length]=e,t.length-1}const VC=[];function BC(e){const t=VC.findIndex((t=>t===e));return-1===t?(VC.push(e),VC.length):t+1}const zC=[];function HC(e){const t=zC.findIndex((t=>t===e));return-1===t?(zC.push(e),zC.length):t+1}function $C(e){return Math.round(914400*e/96)}function WC(e,t,o){let i,s,r=e;if(({xc:r,sheetName:i}=Jo(e)),i){const e=o.sheets.findIndex((e=>e.name===i));if(e<0)throw new Error("Unable to find a sheet with the name "+i);s=e}else s=Number(t);const n=ei(r);return void 0===n.right&&(n.right=o.sheets[s].colNumber),void 0===n.bottom&&(n.bottom=o.sheets[s].rowNumber),(n.right-n.left+1)*(n.bottom-n.top+1)}function GC(e){return Math.round(96*e/914400)}function qC(e,t){let o=0;for(let i=0;i<e;i++){const e=t.cols.find((e=>i>=e.min&&i<=e.max));e?.width?o+=e.width:t.sheetFormat?.defaultColWidth?o+=t.sheetFormat.defaultColWidth:o+=kS}return o/PS}function ZC(e,t){let o=0;for(let i=0;i<e;i++){const e=t.rows[i];e?.height?o+=e.height:t.sheetFormat?.defaultRowHeight?o+=t.sheetFormat.defaultRowHeight:o+=US}return o/LS}function YC(e){let t=1;return e.figures.map((o=>function(e,t,o){const i=qC(e.anchors[0].col,o)+GC(e.anchors[0].colOffset),s=qC(e.anchors[1].col,o)+GC(e.anchors[1].colOffset),r=ZC(e.anchors[0].row,o)+GC(e.anchors[0].rowOffset),n=ZC(e.anchors[1].row,o)+GC(e.anchors[1].rowOffset),a={id:t,x:i,y:r};if("dataSets"in e.data)return{...a,width:s-i,height:n-r,tag:"chart",data:jC(e.data)};if(function(e){return"imageSrc"in e}(e.data))return{...a,width:GC(e.data.size.cx),height:GC(e.data.size.cy),tag:"image",data:{path:e.data.imageSrc,mimetype:e.data.mimetype}};return}(o,(t++).toString(),e))).filter(ke)}function jC(e){const t=void 0!==e.dataSets[0].label,o=e.labelRange?XC(e.labelRange,t):void 0;let i=e.dataSets.map((e=>XC(e.range,t)));return"pie"===e.type&&i.reverse(),{dataSets:i,dataSetsHaveTitle:t,labelRange:o,title:e.title||"",type:e.type,background:mC({rgb:e.backgroundColor})||"#FFFFFF",verticalAxisPosition:e.verticalAxisPosition,legendPosition:e.legendPosition,stacked:e.stacked||!1,aggregated:!1,cumulative:e.cumulative||!1,labelsAsText:!1}}function XC(e,t){let{sheetName:o,xc:i}=Jo(e);o=o?we(o)+"!":"";let s=ei(i);if(t&&void 0!==s.bottom&&void 0!==s.right){const e=s.bottom-s.top+1,t=s.right-s.left+1;1===e?s={...s,left:s.left-1}:1===t&&(s={...s,top:s.top-1})}return o+ii(s)}const KC=new RegExp(/'?\[([0-9]*)\](.*)'?!(\$?[a-zA-Z]*\$?[0-9]*)/g),QC=new RegExp(/SUBTOTAL\(([0-9]*),/g),JC=new RegExp(zo.source,"ig");function eE(e,t){const o=function(e){const t={};for(let o of e.rows)for(let e of o.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 i of e.rows.map((e=>e.cells)).flat())i?.formula&&(i.formula.content=void 0===i.formula.sharedIndex||i.formula.content?"="+i.formula.content:"="+oE(i.xc,o[i.formula.sharedIndex]),i.formula.content=tE(i.formula.content,t))}function tE(e,t){return e=(e=(e=(e=e.replace("_xlfn.","")).replace(/#REF!/g,"#REF")).replace(QC,((e,t)=>{const o=cC[t];return o?o+"(":e}))).replace(KC,((e,o,i,s)=>{o=Number(o)-1,s=s.replace(/\$/g,"");const r=t.externalBooks[o].sheetNames.findIndex((e=>e===i));if(-1===r)return e;const n=t.externalBooks[o].datasets.find((e=>e.sheetId===r))?.data;if(!n)return e;const a=n&&n[s];return(Number(a)?a:`"${a}"`)||e}))}function oE(e,t){const o=wt(t.refCellXc);let i,s=t.formula.slice();do{if(i=JC.exec(s),i){const t=wt(i[0].replace("$","")),r=wt(e),n={colFixed:i[0].startsWith("$"),rowFixed:i[0].includes("$",1)},a={col:r.col-o.col,row:r.row-o.row},l={col:n.colFixed?t.col:t.col+a.col,row:n.rowFixed?t.row:t.row+a.row};s=s.slice(0,i.index)+xt(l.col,l.row,n)+s.slice(i.index+i[0].length)}}while(i);return s}function iE(e,t){return e.sheets.map((o=>{eE(o,e);const i=function(e){const t=[0,0];for(let o of e.rows)t[0]=Math.max(t[0],et(o.cells.map((e=>wt(e.xc).col)))),t[1]=Math.max(t[1],o.index);return t[0]=Math.max(t[0],VS),t[1]=Math.max(t[1],BS),t}(o),s=o.sheetViews[0];return{id:o.sheetName,areGridLinesVisible:!s||s.showGridLines,name:o.sheetName,colNumber:i[0],rowNumber:i[1],cells:nE(o,e,i,t),merges:o.merges,cols:sE(o,i[0]),rows:rE(o,i[1]),conditionalFormats:TC(o.cfs,e.dxfs,t),figures:YC(o),isVisible:o.isVisible,panes:s?{xSplit:s.pane.xSplit,ySplit:s.pane.ySplit}:{xSplit:0,ySplit:0},filterTables:[]}}))}function sE(e,t){const o={};for(let s=1;s<t+1;s++){const t=e.cols.find((e=>e.min<=s&&s<=e.max));let r;r=t&&t.width?t.width:e.sheetFormat?.defaultColWidth?e.sheetFormat.defaultColWidth:kS,o[s-1]={size:(i=r,i?Math.round(i/PS*100)/100:i),isHidden:t?.hidden}}var i;return o}function rE(e,t){const o={};for(let s=1;s<t+1;s++){const t=e.rows.find((e=>e.index===s));let r;r=t&&t.height?t.height:e.sheetFormat?.defaultRowHeight?e.sheetFormat.defaultRowHeight:US,o[s-1]={size:(i=r,i?Math.round(i/LS*100)/100:i),isHidden:t?.hidden}}var i;return o}function nE(e,t,o,i){const s={},r=t.sharedStrings.map((e=>e.replace(/\n/g,"")));const n=e.hyperlinks.reduce(((e,t)=>(e[t.xc]=t,e)),{});for(let o of e.rows)for(let e of o.cells)s[e.xc]={content:aE(e,n,r,i),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 i of e.rows.filter((e=>e.styleIndex)))for(let e=1;e<=o[0];e++){const o=xt(e-1,i.index-1);let r=s[o];r||(r={},s[o]=r),r.style=r.style?r.style:i.styleIndex+1,r.border=r.border?r.border:t.styles[i.styleIndex].borderId+1,r.format=r.format?r.format:t.styles[i.styleIndex].numFmtId+1}for(let i of e.cols.filter((e=>e.styleIndex)))for(let e=i.min;e<=Math.min(i.max,o[0]);e++)for(let r=1;r<=o[1];r++){const o=xt(e-1,r-1);let n=s[o];n||(n={},s[o]=n),n.style=n.style?n.style:i.styleIndex+1,n.border=n.border?n.border:t.styles[i.styleIndex].borderId+1,n.format=n.format?n.format:t.styles[i.styleIndex].numFmtId+1}return s}function aE(e,t,o,i){let s;switch(e.type){case"sharedString":s=o[parseInt(e.value,10)];break;case"boolean":s=Number(e.value)?"TRUE":"FALSE";break;case"date":case"error":case"inlineStr":case"number":case"str":s=e.value}return s&&t[e.xc]&&(s=function(e,t,o){const i=e.display||t;e.relTarget||e.location||o.generateNotSupportedWarning(GS.BadlyFormattedHyperlink);const s=e.relTarget?e.relTarget:Le(Jo(e.location).sheetName);return Ne(i,s)}(t[e.xc],s,i)),e.formula&&(s=e.formula.content),s}const lE={fillColor:"#000000",textColor:"#ffffff",bold:!0},cE={bold:!0},hE={style:"thin",color:"#000000FF"};function dE(e,t){for(const o of t.sheets)for(const t of o.tables){const i=e.sheets.find((e=>e.name===o.sheetName));i&&t.autoFilter&&(i.filterTables||(i.filterTables=[]),i.filterTables.push({range:t.ref}))}!function(e,t){const o=vC(e.styles),i=vC(e.borders);for(let s of t.sheets)for(let t of s.tables){const r=e.sheets.find((e=>e.name===s.sheetName));if(!r)continue;const n=ti(t.ref);for(let e=0;e<t.headerRowCount;e++)uE(lE,{...n,bottom:n.top+e},r.cells,o);for(let e=0;e<t.totalsRowCount;e++)uE(cE,{...n,top:n.bottom-e},r.cells,o);t.style?.showFirstColumn&&uE(cE,{...n,right:n.left},r.cells,o),t.style?.showLastColumn&&uE(cE,{...n,left:n.right},r.cells,o);for(let e=n.left;e<=n.right;e++)for(let o=n.top;o<=n.bottom;o++){const s=xt(e,o),a=r.cells[s],l={left:e===n.left||t.style?.showColumnStripes?hE:void 0,right:e===n.right?hE:void 0,top:o===n.top||t.style?.showRowStripes||o>n.bottom-t.totalsRowCount?hE:void 0,bottom:o===n.bottom?hE:void 0},c=a?.border?{...i[a.border],...l}:l;let h=i.findIndex((e=>We(e,c)));-1===h&&(h=i.length,i.push(c)),a?a.border=h:r.cells[s]={border:h}}}e.styles=bC(o),e.borders=bC(i)}(e,t),function(e,t){for(let o of e){const e=t.find((e=>e.sheetName===o.name)).tables;for(let t of e){const e=t.name+"[";for(let i of vi(ti(t.ref))){const s=xt(i.col,i.row),r=o.cells[s];if(r&&r.content&&r.content.startsWith("=")){let o;for(;-1!==(o=r.content.indexOf(e));){let i=r.content.slice(o+e.length),n=i.indexOf("]");i.startsWith("[")&&(n=i.indexOf("]",n+1),n=i.indexOf("]",n+1)),i=i.slice(0,n);const a=gE(i,t,s);r.content=r.content.slice(0,o)+a+r.content.slice(e.length+o+n+1)}}}}}}(e.sheets,t.sheets)}function uE(e,t,o,i){for(let s=t.left;s<=t.right;s++)for(let r=t.top;r<=t.bottom;r++){const t=xt(s,r),n=o[t],a=n?.style?{...i[n.style],...e}:e;let l=i.findIndex((e=>We(e,a)));-1===l&&(l=i.length,i.push(a)),n?n.style=l:o[t]={style:l}}}function gE(e,t,o){const i=e.split(","),s=ti(t.ref),r={...s};let n=!0;if(1===i.length){const e=t.cols.findIndex((e=>e.name===i[0]));r.left=r.right=e+s.left,t.headerRowCount&&(r.top+=t.headerRowCount),t.totalsRowCount&&(r.bottom-=1)}else{switch(i[0].slice(1,i[0].length-1)){case"#All":r.top=t.headerRowCount?s.top+t.headerRowCount:s.top,r.bottom=s.bottom;break;case"#Data":r.top=t.headerRowCount?s.top+t.headerRowCount:s.top,r.bottom=t.totalsRowCount?s.bottom+1:s.bottom;break;case"#This Row":r.top=r.bottom=wt(o).row;break;case"#Headers":r.top=r.bottom=s.top,t.headerRowCount||(n=!1);break;case"#Totals":r.top=r.bottom=s.bottom,t.totalsRowCount||(n=!1)}const e=i[1].slice(1,i[1].length-1),a=t.cols.findIndex((t=>t.name===e));r.left=r.right=a+s.left}return n?r.top!==r.bottom?ii(r):xt(r.left,r.top):ee}function pE(e,t,o){return{content:(new XMLSerializer).serializeToString(e),path:t,contentType:o}}function mE(e){return String(e).replace(/\&/g,"&").replace(/\</g,"<").replace(/\>/g,">").replace(/\"/g,""").replace(/\'/g,"'").replace(/[\x00-\x08\x0B\x0C\x0E-\x1F]/g,"")}function fE(e){return new IS(e.map((([e,t])=>`${e}="${mE(t)}"`)).join(" "))}function bE(e,t="text/xml"){const o=(new DOMParser).parseFromString(e.toString(),t),i=o.querySelector("parsererror");if(i){const t=i.innerHTML,o=parseInt(t.split(":")[0],10),s=e.toString().trim().split("\n"),r=s.slice(Math.max(o-3,0),Math.min(o+2,s.length)).join("\n");throw new Error(`XML string could not be parsed: ${t}\n${r}`)}return o}function vE(e){if(e)return{style:e.style,color:{rgb:e.color}}}function SE(e,t){return EE`
|
|
1468
1468
|
<Override ContentType="${t}" PartName="${e}" />
|
|
1469
|
-
`}function wE(e){return new TS(e.join("\n"))}function xE(e,...t){let o=[e[0]];for(let i=0;i<t.length;i++){const s=t[i]instanceof TS?t[i]:vE(t[i]);o.push(s+e[i+1])}return new TS(Be(o))}function yE(e){return e.replace(/NAMESPACE.*NAMESPACE(.*)/,"$1")}function IE(e){return e.replaceAll(/([a-zA-Z0-9]+):([a-zA-Z0-9]+)/g,"NAMESPACE$1NAMESPACE$2")}class RE{value;constructor(e){this.value=e}asString(){return EC(String(this.value))}asBool(){return"true"===this.value||"false"!==this.value&&Boolean(Number(this.value))}asNum(){return Number(this.value)}}class TE{rootFile;xlsxFileStructure;warningManager;relationships;currentFile=void 0;constructor(e,t,o){this.rootFile=e,this.currentFile=e.file.fileName,this.xlsxFileStructure=t,this.warningManager=o,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()})))}getListOfXMLFiles(){return Object.entries(this.xlsxFileStructure).filter((([e])=>"images"!==e)).map((([e,t])=>t)).flat().filter(ke)}mapOnElements(e,t){const o=[],i=this.currentFile;let s;if(e.children){const t=this.querySelector(e.parent,e.query)?.children;s=t||[]}else s=this.querySelectorAll(e.parent,e.query);if(s)for(let e of s)try{o.push(t(e))}catch(t){this.catchErrorOnElement(t,e)}return this.currentFile=i,o}catchErrorOnElement(e,t){const o=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([o,e.message].join("\n"))}extractAttr(e,t,o){const i=e.attributes[t];i||this.handleMissingValue(e,`attribute "${t}"`,o);const s=i?.value?i.value:o?.default;return void 0===s?void 0:new RE(s)}extractTextContent(e,t){if(void 0!==t?.default&&"string"!=typeof t.default)throw new Error("extractTextContent default value should be a string");const o="preserve"===e?.attributes["xml:space"]?.value;let i=e?.textContent;return e&&null!==i||this.handleMissingValue(e,"text content",t),i&&(i=o?i:i.trim()),i?EC(i):t?.default}extractChildAttr(e,t,o,i){let s;s="number"==typeof t?e.children[t]:this.querySelector(e,t),s||this.handleMissingValue(e,"number"==typeof t?`child at index ${t}`:`child <${t}>`,i);const r=s?this.extractAttr(s,o,i)?.asString():i?.default;return void 0!==r?new RE(r):void 0}extractChildTextContent(e,t,o){if(void 0!==o?.default&&"string"!=typeof o.default)throw new Error("extractTextContent default value should be a string");let i=this.querySelector(e,t);return i||this.handleMissingValue(e,`child <${t}>`,o),i?this.extractTextContent(i,o):o?.default}handleMissingValue(e,t,o){if(o?.required){if(!o?.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 ${o.default}`)}}extractColor(e,t,o){if(!e)return o?{rgb:o}:void 0;const i=this.extractAttr(e,"theme")?.asString();let s;if(void 0!==i){if(!t||!t.clrScheme)throw new Error("Color referencing a theme but no theme was provided");s=this.getThemeColor(i,t.clrScheme)}else s=this.extractAttr(e,"rgb")?.asString();return{rgb:s,auto:this.extractAttr(e,"auto")?.asBool(),indexed:this.extractAttr(e,"indexed")?.asNum(),tint:this.extractAttr(e,"tint")?.asNum()}}getTargetXmlFile(e){if(!e)throw new Error("Undefined target file");const t=this.processRelationshipTargetName(e.target),o=this.getListOfXMLFiles().find((e=>e.file.fileName.endsWith(t)));if(!o||!o.file)throw new Error("Cannot find target file");return o}getTargetImageFile(e){if(!e)throw new Error("Undefined target file");const t=this.processRelationshipTargetName(e.target),o=this.xlsxFileStructure.images.find((e=>e.fileName.endsWith(t)));if(!o)throw new Error("Cannot find target file");return o}querySelector(e,t){const o=IE(t);return e.querySelector(o)}querySelectorAll(e,t){const o=IE(t);return e.querySelectorAll(o)}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}}processRelationshipTargetName(e){return e.replace(/\.+\//,"")}}class AE extends TE{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:OS}).asString(),lastClr:this.extractChildAttr(e,0,"lastClr",{default:OS}).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 OE extends TE{theme;constructor(e,t,o,i){super(e,t,o),this.theme=i}extractConditionalFormattings(){const e=this.mapOnElements({parent:this.rootFile.file.xml,query:"worksheet > conditionalFormatting"},(e=>({sqref:this.extractAttr(e,"sqref",{required:!0}).asString().split(" "),pivot:this.extractAttr(e,"pivot")?.asBool(),cfRules:this.extractCFRules(e,this.theme)})));return e.push(...this.mapOnElements({parent:this.rootFile.file.xml,query:"extLst x14:conditionalFormatting"},(e=>({sqref:this.extractChildTextContent(e,"xm:sqref",{required:!0}).split(" "),pivot:this.extractAttr(e,"xm:pivot")?.asBool(),cfRules:this.extractCFRules(e,this.theme)})))),e}extractCFRules(e,t){return this.mapOnElements({parent:e,query:"cfRule, x14:cfRule"},(e=>{const o=this.extractAttr(e,"type",{required:!0}).asString();if("dataBar"===o)throw new Error("Databars conditional formats are not supported.");return{type:o,priority:this.extractAttr(e,"priority",{required:!0}).asNum(),colorScale:this.extractCfColorScale(e,t),formula:this.extractCfFormula(e),iconSet:this.extractCfIconSet(e),dxfId:this.extractAttr(e,"dxfId")?.asNum(),stopIfTrue:this.extractAttr(e,"stopIfTrue")?.asBool(),aboveAverage:this.extractAttr(e,"aboveAverage")?.asBool(),percent:this.extractAttr(e,"percent")?.asBool(),bottom:this.extractAttr(e,"bottom")?.asBool(),operator:this.extractAttr(e,"operator")?.asString(),text:this.extractAttr(e,"text")?.asString(),timePeriod:this.extractAttr(e,"timePeriod")?.asString(),rank:this.extractAttr(e,"rank")?.asNum(),stdDev:this.extractAttr(e,"stdDev")?.asNum(),equalAverage:this.extractAttr(e,"equalAverage")?.asBool()}}))}extractCfFormula(e){return this.mapOnElements({parent:e,query:"formula"},(e=>this.extractTextContent(e,{required:!0})))}extractCfColorScale(e,t){const o=this.querySelector(e,"colorScale");if(o)return{colors:this.mapOnElements({parent:o,query:"color"},(e=>this.extractColor(e,t,"ffffff"))),cfvos:this.extractCFVos(o)}}extractCfIconSet(e){const t=this.querySelector(e,"iconSet, x14:iconSet");if(t)return{iconSet:this.extractAttr(t,"iconSet",{default:"3TrafficLights1"}).asString(),showValue:this.extractAttr(t,"showValue",{default:!0}).asBool(),percent:this.extractAttr(t,"percent",{default:!0}).asBool(),reverse:this.extractAttr(t,"reverse")?.asBool(),custom:this.extractAttr(t,"custom")?.asBool(),cfvos:this.extractCFVos(t),cfIcons:this.extractCfIcons(t)}}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=>({type:this.extractAttr(e,"type",{required:!0}).asString(),gte:this.extractAttr(e,"gte",{default:!0})?.asBool(),value:e.attributes.val?this.extractAttr(e,"val")?.asString():this.extractChildTextContent(e,"f, xm:f")})))}}class ME extends TE{extractChart(){return this.mapOnElements({parent:this.rootFile.file.xml,query:"c:chartSpace"},(e=>{const t=this.getChartType(e);if(!hC[t])throw new Error(`Unsupported chart type ${t}`);const o=this.mapOnElements({parent:e,query:"c:title a:t"},(e=>e.textContent||"")).join(""),i=this.extractChildAttr(e,"c:grouping","val",{default:"clustered"}).asString();return{title:o,type:hC[t],dataSets:this.extractChartDatasets(this.querySelector(e,`c:${t}`)),labelRange:this.extractChildTextContent(e,"c:ser c:cat c:f"),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:cC[this.extractChildAttr(e,"c:legendPos","val",{default:"b"}).asString()],stacked:"stacked"===i,fontColor:"000000"}}))[0]}extractChartDatasets(e){return this.mapOnElements({parent:e,query:"c:ser"},(e=>({label:this.extractChildTextContent(e,"c:tx 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=yE(e.tagName);if(AS.some((e=>e===t)))return t}throw new Error("Unknown chart type")}}class NE extends TE{extractFigures(){return this.mapOnElements({parent:this.rootFile.file.xml,query:"xdr:wsDr",children:!0},(e=>{if("twoCellAnchor"!==yE(e.tagName))throw new Error("Only twoCellAnchor are supported for xlsx drawings.");const t=this.querySelector(e,"c:chart"),o=this.querySelector(e,"a:blip");if(!t&&!o)throw new Error("Only chart and image figures are currently supported.");return{anchors:[this.extractFigureAnchor("xdr:from",e),this.extractFigureAnchor("xdr:to",e)],data:t?this.extractChart(t):this.extractImage(e)}}))}extractFigureAnchor(e,t){const o=this.querySelector(t,e);if(!o)throw new Error(`Missing anchor element ${e}`);return{col:Number(this.extractChildTextContent(o,"xdr:col",{required:!0})),colOffset:Number(this.extractChildTextContent(o,"xdr:colOff",{required:!0})),row:Number(this.extractChildTextContent(o,"xdr:row",{required:!0})),rowOffset:Number(this.extractChildTextContent(o,"xdr:rowOff",{required:!0}))}}extractChart(e){const t=this.extractAttr(e,"r:id",{required:!0}).asString(),o=this.getTargetXmlFile(this.relationships[t]),i=new ME(o,this.xlsxFileStructure,this.warningManager).extractChart();if(!i)throw new Error("Unable to extract chart definition");return i}extractImage(e){const t=this.querySelector(e,"a:blip"),o=this.extractAttr(t,"r:embed",{required:!0}).asString(),i=this.getTargetImageFile(this.relationships[o]);if(!i)throw new Error("Unable to extract image");const s=this.querySelector(e,"a:xfrm"),r=i.fileName.split(".").at(-1);return{imageSrc:i.imageSrc,mimetype:r?fC[r]:void 0,size:{cx:this.extractChildAttr(s,"a:ext","cx",{required:!0}).asNum(),cy:this.extractChildAttr(s,"a:ext","cy",{required:!0}).asNum()}}}}class _E extends TE{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 FE extends TE{getTable(){return this.mapOnElements({query:"table",parent:this.rootFile.file.xml},(e=>({displayName:this.extractAttr(e,"displayName",{required:!0}).asString(),name:this.extractAttr(e,"name")?.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=>({name:this.extractAttr(e,"name")?.asString(),showFirstColumn:this.extractAttr(e,"showFirstColumn")?.asBool(),showLastColumn:this.extractAttr(e,"showLastColumn")?.asBool(),showRowStripes:this.extractAttr(e,"showRowStripes")?.asBool(),showColumnStripes:this.extractAttr(e,"showColumnStripes")?.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 DE extends TE{theme;constructor(e,t,o,i){super(e,t,o),this.theme=i}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=vC(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=vC(this.xlsxFileStructure.workbook.file.fileName,this.rootFile.file.fileName),t=this.extractRelationships(this.xlsxFileStructure.workbook.rels).find((t=>t.target===e)).id,o=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(!o)throw new Error("Cannot find corresponding workbook sheet");return o}extractConditionalFormats(){return new OE(this.rootFile,this.xlsxFileStructure,this.warningManager,this.theme).extractConditionalFormattings()}extractFigures(e){return this.mapOnElements({parent:e,query:"drawing"},(e=>{const t=this.extractAttr(e,"r:id",{required:!0})?.asString(),o=this.getTargetXmlFile(this.relationships[t]);return new NE(o,this.xlsxFileStructure,this.warningManager).extractFigures()}))[0]||[]}extractTables(e){return this.mapOnElements({query:"tablePart",parent:e},(e=>{const t=this.extractAttr(e,"r:id",{required:!0})?.asString(),o=this.getTargetXmlFile(this.relationships[t]);return new FE(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 _E(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:VS.toString()}).asNum(),defaultRowHeight:this.extractAttr(t,"defaultRowHeight",{default:BS.toString()}).asNum()}}extractCols(e){return this.mapOnElements({parent:e,query:"cols col"},(e=>({width:this.extractAttr(e,"width")?.asNum(),customWidth:this.extractAttr(e,"customWidth")?.asBool(),bestFit:this.extractAttr(e,"bestFit")?.asBool(),hidden:this.extractAttr(e,"hidden")?.asBool(),min:this.extractAttr(e,"min",{required:!0})?.asNum(),max:this.extractAttr(e,"max",{required:!0})?.asNum(),styleIndex:this.extractAttr(e,"style")?.asNum()})))}extractRows(e){return this.mapOnElements({parent:e,query:"sheetData row"},(e=>({index:this.extractAttr(e,"r",{required:!0})?.asNum(),cells:this.extractCells(e),height:this.extractAttr(e,"ht")?.asNum(),customHeight:this.extractAttr(e,"customHeight")?.asBool(),hidden:this.extractAttr(e,"hidden")?.asBool(),styleIndex:this.extractAttr(e,"s")?.asNum()})))}extractCells(e){return this.mapOnElements({parent:e,query:"c"},(e=>({xc:this.extractAttr(e,"r",{required:!0})?.asString(),styleIndex:this.extractAttr(e,"s")?.asNum(),type:tC[this.extractAttr(e,"t",{default:"n"})?.asString()],value:this.extractChildTextContent(e,"v"),formula:this.extractCellFormula(e)})))}extractCellFormula(e){const t=this.querySelector(e,"f");if(t)return{content:this.extractTextContent(t),sharedIndex:this.extractAttr(t,"si")?.asNum(),ref:this.extractAttr(t,"ref")?.asString()}}extractHyperLinks(e){return this.mapOnElements({parent:e,query:"hyperlink"},(e=>{const t=this.extractAttr(e,"r:id")?.asString();return{xc:this.extractAttr(e,"ref",{required:!0})?.asString(),location:this.extractAttr(e,"location")?.asString(),display:this.extractAttr(e,"display")?.asString(),relTarget:t?this.relationships[t].target:void 0}}))}extractSharedFormulas(e){const t=this.querySelectorAll(e,"f[si][ref]"),o={};for(let e of t){const t=this.extractAttr(e,"si",{required:!0}).asNum(),i=this.extractTextContent(e,{required:!0});o[t]=i}const i=[];for(let e=0;e<Object.keys(o).length;e++)o[e]?i.push(o[e]):(this.warningManager.addParsingWarning(`Missing shared formula ${e}, replacing it by empty formula`),i.push(""));return i}}class LE extends TE{theme;constructor(e,t,o){super(e.styles,e,t),this.theme=o}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){const t=this.extractChildAttr(e,"name","val",{default:"Arial"}).asString(),o=this.extractChildAttr(e,"sz","val",{default:Z.toString()}).asNum(),i=this.extractColor(this.querySelector(e,"color"),this.theme),s=this.querySelector(e,"i")||void 0,r=s&&"0"!==s.attributes.val?.value,n=this.querySelector(e,"b")||void 0,a=n&&"0"!==n.attributes.val?.value,l=this.querySelector(e,"strike")||void 0,c=l&&"0"!==l.attributes.val?.value,h=this.querySelector(e,"u")||void 0;return{name:t,size:o,color:i,italic:r,bold:a,underline:h&&"none"!==h.attributes.val?.value,strike:c}}getFills(){return this.mapOnElements({parent:this.rootFile.file.xml,query:"fill"},(e=>this.extractFill(e)))}extractFill(e){const t=e.children[0];return"patternFill"===t.tagName?{patternType:t.attributes.patternType?.value,bgColor:this.extractColor(this.querySelector(t,"bgColor"),this.theme),fgColor:this.extractColor(this.querySelector(t,"fgColor"),this.theme)}:{patternType:"solid",fgColor:this.extractColor(this.querySelectorAll(t,"color")[1],this.theme)}}getBorders(){return this.mapOnElements({parent:this.rootFile.file.xml,query:"border"},(e=>this.extractBorder(e)))}extractBorder(e){const t={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 t.diagonal&&(t.diagonalUp=this.extractAttr(e,"diagonalUp")?.asBool(),t.diagonalDown=this.extractAttr(e,"diagonalDown")?.asBool()),t}extractSingleBorder(e,t,o){const i=this.querySelector(e,t);if(i&&i.attributes.style)return{style:this.extractAttr(i,"style",{required:!0,default:"thin"}).asString(),color:this.extractColor(i.children[0],o,"000000")}}extractAlignment(e){return{horizontal:this.extractAttr(e,"horizontal",{default:"general"}).asString(),vertical:this.extractAttr(e,"vertical",{default:"bottom"}).asString(),textRotation:this.extractAttr(e,"textRotation")?.asNum(),wrapText:this.extractAttr(e,"wrapText")?.asBool(),indent:this.extractAttr(e,"indent")?.asNum(),relativeIndent:this.extractAttr(e,"relativeIndent")?.asNum(),justifyLastLine:this.extractAttr(e,"justifyLastLine")?.asBool(),shrinkToFit:this.extractAttr(e,"shrinkToFit")?.asBool(),readingOrder:this.extractAttr(e,"readingOrder")?.asNum()}}getDxfs(){return this.mapOnElements({query:"dxf",parent:this.rootFile.file.xml},(e=>{const t=this.querySelector(e,"font"),o=this.querySelector(e,"fill"),i=this.querySelector(e,"border"),s=this.querySelector(e,"numFmt"),r=this.querySelector(e,"alignment");return{font:t?this.extractFont(t):void 0,fill:o?this.extractFill(o):void 0,numFmt:s?this.extractNumFormats(s):void 0,alignment:r?this.extractAlignment(r):void 0,border:i?this.extractBorder(i):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 PE extends TE{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})}))),o={};for(let e of t)o[e.xc]=e.value;return{sheetId:this.extractAttr(e,"sheetId",{required:!0}).asNum(),data:o}}))}}function kE(e,t){const o=function(e,t){const o=t[qS],i=o.querySelectorAll(`Override[ContentType="${e}"]`),s=[];for(let e of i){const t=e?.attributes.PartName.value;s.push(t.substring(1))}return s}(e,t);return function(e,t){const o=[];for(let i of e){const e=UE(i,t);o.push({file:{fileName:i,xml:t[i]},rels:e?{fileName:e,xml:t[e]}:void 0})}return o}(o,t)}function UE(e,t){if(e===qS)return"_rels/.rels";let o="";const i=e.split("/");for(let e=0;e<i.length-1;e++)o+=i[e]+"/";return o+="_rels/",o+=i[i.length-1]+".rels",t[o]||(o=void 0),o}class VE{warningManager;xmls;images;constructor(e){this.warningManager=new YS,this.xmls={},this.images=[];for(let t of Object.keys(e))if(t.endsWith(".xml")||t.endsWith(".rels")){const o=e[t].replaceAll(/(<\/?)([a-zA-Z0-9]+):([a-zA-Z0-9]+)/g,"$1NAMESPACE$2NAMESPACE$3");this.xmls[t]=CE(new TS(o))}else t.includes("media/image")&&this.images.push({fileName:t,imageSrc:e[t].imageSrc})}convertXlsx(){const e=this.getXlsxData();return this.convertImportedData(e)}getXlsxData(){const e=this.buildXlsxFileStructure(),t=e.theme?new AE(e.theme,e,this.warningManager).getTheme():void 0,o=e.sharedStrings?new AE(e.sharedStrings,e,this.warningManager).getSharedStrings():[],i=e.sheets.sort(((e,t)=>e.file.fileName.localeCompare(t.file.fileName,void 0,{numeric:!0}))).map((o=>new DE(o,e,this.warningManager,t).getSheet())),s=e.externalLinks.map((t=>new PE(t,e,this.warningManager).getExternalBook())),r=new LE(e,this.warningManager,t);return{fonts:r.getFonts(),fills:r.getFills(),borders:r.getBorders(),dxfs:r.getDxfs(),numFmts:r.getNumFormats(),styles:r.getStyles(),sheets:i,sharedStrings:o,externalBooks:s}}buildXlsxFileStructure(){const e={sheets:kE(DS.sheet,this.xmls),workbook:kE(DS.workbook,this.xmls)[0],styles:kE(DS.styles,this.xmls)[0],sharedStrings:kE(DS.sharedStrings,this.xmls)[0],theme:kE(DS.themes,this.xmls)[0],charts:kE(DS.chart,this.xmls),figures:kE(DS.drawing,this.xmls),tables:kE(DS.table,this.xmls),pivots:kE(DS.pivot,this.xmls),externalLinks:kE(DS.externalLink,this.xmls),images:this.images};if(!e.workbook.rels)throw Error(r("Cannot find workbook relations file"));return e}convertImportedData(e){const t={version:12,sheets:nE(e,this.warningManager),styles:RC(e,this.warningManager),formats:AC(e,this.warningManager),borders:yC(e,this.warningManager),entities:{},revisionId:te};return pE(t,e),Object.keys(e.styles).map((t=>{e.styles[t]=qe(e.styles[t])})),t}}function BE(e){const t=rg(e);let o=[];return{text:"".concat(...t.map((e=>{if("REFERENCE"===e.type&&zo.test(e.value)){const t=e.value.trim();return o.includes(t)||o.push(t),`${de}${o.indexOf(t)}${de}`}return e.value}))),dependencies:o}}const zE=14,HE="Sheet1";function $E(e,t){if(!e)return jE();if(e["[Content_Types].xml"]){const o=new VE(e);if(e=o.convertXlsx(),t)for(let e of o.warningManager.warnings.sort())console.warn(e)}return"version"in e&&e.version<zE&&(e=function(e){for(let t=WE.findIndex((t=>t.from===e.version));t<WE.length;t++)e=WE[t].applyMigration(e);return e}(e)),e=function(e){return e=function(e){if(e.uniqueFigureIds)return e;const t=new Set,o=new Bi;for(const i of e.sheets||[])for(const e of i.figures||[])t.has(e.id)&&(e.id+=o.uuidv4()),t.add(e.id);return e.uniqueFigureIds=!0,e}(e),e=function(e){const t=Object.assign(jE(),e,{version:zE});t.sheets=t.sheets?t.sheets.map(((e,t)=>Object.assign(YE(`Sheet${t+1}`,`Sheet${t+1}`),e))):[],0===t.sheets.length&&t.sheets.push(YE(HE,"Sheet1"));fg(t.settings.locale)||(t.settings.locale=eo);return t}(e),e}(e),e}const WE=[{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 o=t.cells[e];o.content&&o.content.startsWith("=")&&(o.formula=BE(o.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:o,...i}=t.figures[e].data,s=[];for(let e of o)if(e.labelCell){const t=ti(e.dataRange),o=e.labelCell+":"+xt(t.right,t.bottom);s.push(o)}else s.push(e.dataRange);i.dataSetsHaveTitle=Boolean(o[0].labelCell),i.dataSets=s,t.figures[e].data=i}return e}},{description:"remove single quotes in sheet names",from:7,to:8,applyMigration(e){const t=[],o=new RegExp(he,"g");for(let i of e.sheets||[]){if(!i.name)continue;const e=i.name,s=e.replace(o,"_");let r=1,n=s;for(;t.includes(n);)n=`${s}${r}`,r++;i.name=n,t.push(n);const a=t=>{if(void 0===t)return t;let o=t.replace(e,n),i=t;for(;i!==o;)i=o,o=i.replace(e,n);return i};for(let e in i.cells){const t=i.cells[e];t.formula&&(t.formula.dependencies=t.formula.dependencies.map(a))}for(let e of i.figures||[])if("chart"===e.type){const t=e.data.dataSets.map(a),o=a(e.data.labelRange);e.data={...e.data,dataSets:t,labelRange:o}}for(let e of i.conditionalFormats||[]){e.ranges=e.ranges.map(a);for(const t of["minimum","maximum","midpoint","upperInflectionPoint","lowerInflectionPoint"])"formula"===e.rule[t]?.type&&(e.rule[t].value=a(e.rule[t].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 o=t.cells[e];if(o.formula){let{text:e,dependencies:t}=o.formula;for(let[o,i]of Object.entries(t)){const t=`\\${de}${o}\\${de}`;e=e.replace(new RegExp(t,"g"),i)}o.content=e,delete o.formula}}return e}},{description:"normalize the formats of the cells",from:10,to:11,applyMigration(e){const t={};for(let o of e.sheets||[])for(let e in o.cells||[]){const i=o.cells[e];i.format&&(i.format=Ve(i.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}},{description:"Fix datafilter duplication",from:12,to:12.5,applyMigration:e=>ZE(e)},{description:"Change Border description structure",from:12.5,to:13,applyMigration(e){for(const t in e.borders){const o=e.borders[t];for(const e in o)Array.isArray(o[e])&&(o[e]={style:o[e][0],color:o[e][1]})}return e}},{description:"Add locale to spreadsheet settings",from:13,to:14,applyMigration:e=>(e.settings||(e.settings={}),e.settings.locale||(e.settings.locale=eo),e)},{description:"Fix datafilter duplication (post saas-16.4)",from:14,to:14.5,applyMigration:e=>ZE(e)}];function GE(e,t){return t=function(e,t){if(0!==Object.keys(e).length)return t;const o=[],i=[],s=e=>{if("CREATE_SHEET"===e.type)o.push(e.sheetId);else if("sheetId"in e&&!o.includes(e.sheetId))return{...e,sheetId:HE};return e};for(const e of t)"REMOTE_REVISION"===e.type?i.push({...e,commands:e.commands.map(s)}):i.push(e);return i}(e,t),t=qE(t,"SORT_CELLS"),t=function(e,t){const o=[],i={};for(const t of e.sheets||[])t.figures?.forEach((e=>{"chart"===e.tag&&(i[e.id]=e.data)}));for(const e of t)if("REMOTE_REVISION"===e.type){const t=[];for(const o of e.commands){let e=o;switch(o.type){case"CREATE_CHART":i[o.id]=o.definition;break;case"UPDATE_CHART":if(!i[o.id]){console.log(`Fix chart definition: chart with id ${o.id} not found.`);continue}const t={...i[o.id],...o.definition};e={...o,definition:t},i[o.id]=t}t.push(e)}o.push({...e,commands:t})}else o.push(e);return o}(e,t=qE(t,"SET_DECIMAL")),t}function qE(e,t){const o=[];for(const i of e)"REMOTE_REVISION"===i.type?o.push({...i,commands:i.commands.filter((e=>e.type!==t))}):o.push(i);return o}function ZE(e){for(let t of e.sheets||[]){let e=[];for(let o of t.filterTables||[]){const t=ti(o.range),i=e.findIndex((e=>di(e,t)));-1!==i?e[i]=t:e.push(t)}t.filterTables=e.map((e=>({range:ii(e)})))}return e}function YE(e,t){return{id:e,name:t,colNumber:26,rowNumber:100,cells:{},cols:{},rows:{},merges:[],conditionalFormats:[],figures:[],filterTables:[],isVisible:!0}}function jE(e="Sheet1"){return{version:zE,sheets:[YE(HE,e)],entities:{},styles:{},formats:{},borders:{},revisionId:te,uniqueFigureIds:!0,settings:{locale:eo}}}function XE(e,t){return{...YE(e,t),charts:[],images:[]}}class KE{static getters=[];history;dispatch;constructor(e,t){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 o of e){let e=o.call(this,t);Array.isArray(e)||(e=[e]);const i=e.filter((e=>0!==e));if(i.length)return i}return 0}}checkValidations(e,...t){return this.batchValidations(...t)(e)}}class QE extends KE{getters;uuidGenerator;constructor({getters:e,stateObserver:t,range:o,dispatch:i,uuidGenerator:s}){super(t,i),o.addRangeProvider(this.adaptRanges.bind(this)),this.getters=e,this.uuidGenerator=s}import(e){}export(e){}adaptRanges(e,t){}garbageCollectExternalResources(){}}class JE{id;compiledFormula;format;style;dependencies;sheetId;buildFormulaContent;isFormula=!0;constructor(e,t,o,i,s,r,n){this.id=e,this.compiledFormula=t,this.format=o,this.style=i,this.dependencies=s,this.sheetId=r,this.buildFormulaContent=n}get content(){return this.buildFormulaContent(this.sheetId,{dependencies:this.dependencies,compiledFormula:this.compiledFormula})}}function ew(e){return""===e?NaN:Number(e)}class tw{id;zone;filters;constructor(e){this.filters=[],this.zone=e;const t=new Bi;this.id=t.uuidv4();for(const o of ye(e.left,e.right+1)){const e={...this.zone,left:o,right:o};this.filters.push(new ow(t.uuidv4(),e))}}get contentZone(){if(this.zone.bottom!==this.zone.top)return{...this.zone,top:this.zone.top+1}}getFilterId(e){return this.filters.find((t=>t.col===e))?.id}clone(){return new tw(this.zone)}}class ow{id;zoneWithHeaders;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}}}function iw(e){return Object.entries(e).map((([e,t])=>t?sw(parseInt(e,10),t):void 0)).filter(ke).map((e=>xt(e.left,e.top)+":"+xt(e.right,e.bottom)))}function sw(e,t){return{...t.zone,topLeft:{col:t.zone.left,row:t.zone.top},id:e}}class rw{getters;providers=[];constructor(e){this.getters=e}static getters=["getRangeString","getRangeFromSheetXC","createAdaptedRanges","getRangeDataFromXc","getRangeDataFromZone","getRangeFromRangeData","getRangeFromZone"];allowDispatch(e){return"MOVE_RANGES"===e.type?1===e.target.length?0:27:0}beforeHandle(e){}handle(e){switch(e.type){case"REMOVE_COLUMNS_ROWS":{let t="COL"===e.dimension?"left":"top",o="COL"===e.dimension?"right":"bottom",i="COL"===e.dimension?"columns":"rows";const s=[...e.elements];s.sort(((e,t)=>t-e));const r=Ie(s);this.executeOnAllRanges((s=>{if(s.sheetId!==e.sheetId)return{changeType:"NONE"};let n=s,a="NONE";for(let e of r){const r=tt(e),l=et(e);if(s.zone[t]<=r&&r<=s.zone[o]){const e=Math.min(s.zone[o],l)-r+1;a="RESIZE",n=this.createAdaptedRange(n,i,a,-e)}else if(s.zone[t]>=r&&s.zone[o]<=l)a="REMOVE",n=s.clone({...this.getInvalidRange()});else if(s.zone[t]<=l&&s.zone[o]>=l){const e=l-s.zone[t]+1;a="RESIZE",n=this.createAdaptedRange(n,i,a,-e),n=this.createAdaptedRange(n,i,"MOVE",-(s.zone[t]-r))}else r<s.zone[t]&&(a="MOVE",n=this.createAdaptedRange(n,i,a,-(l-r+1)))}return"NONE"!==a?{changeType:a,range:n}:{changeType:"NONE"}}),e.sheetId);break}case"ADD_COLUMNS_ROWS":{let t="COL"===e.dimension?"left":"top",o="COL"===e.dimension?"right":"bottom",i="COL"===e.dimension?"columns":"rows";this.executeOnAllRanges((s=>{if(s.sheetId!==e.sheetId)return{changeType:"NONE"};if("after"===e.position){if(s.zone[t]<=e.base&&e.base<s.zone[o])return{changeType:"RESIZE",range:this.createAdaptedRange(s,i,"RESIZE",e.quantity)};if(e.base<s.zone[t])return{changeType:"MOVE",range:this.createAdaptedRange(s,i,"MOVE",e.quantity)}}else{if(s.zone[t]<e.base&&e.base<=s.zone[o])return{changeType:"RESIZE",range:this.createAdaptedRange(s,i,"RESIZE",e.quantity)};if(e.base<=s.zone[t])return{changeType:"MOVE",range:this.createAdaptedRange(s,i,"MOVE",e.quantity)}}return{changeType:"NONE"}}),e.sheetId);break}case"DELETE_SHEET":this.executeOnAllRanges((t=>{if(t.sheetId!==e.sheetId)return{changeType:"NONE"};const o=this.getters.getSheetName(e.sheetId);return{changeType:"REMOVE",range:t=t.clone({...this.getInvalidRange(),invalidSheetName:o})}}),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 o=void 0,i=e.sheetId;return{changeType:"CHANGE",range:t.clone({sheetId:i,invalidSheetName:o})}}return{changeType:"NONE"}}));break;case"MOVE_RANGES":{const t=e.target[0];this.executeOnAllRanges((o=>{if(o.sheetId!==e.sheetId||!gi(o.zone,t))return{changeType:"NONE"};const i=e.targetSheetId,s=e.col-t.left,r=e.row-t.top,n=this.createAdaptedRange(o,"both","MOVE",[s,r]),a=e.sheetId!==i||n.prefixSheet;return{changeType:"MOVE",range:n.clone({sheetId:i,prefixSheet:a})}}));break}}}finalize(){}verifyRangeRemoved(e){return t=>{const o=e(t);return"NONE"===o.changeType||oi(o.range.zone)?o:{range:o.range,changeType:"REMOVE"}}}createAdaptedRange(e,t,o,i){const s=Si(e.unboundedZone,t,o,i);return e.clone({zone:s})}executeOnAllRanges(e,t){const o=this.verifyRangeRemoved(e);for(const e of this.providers)e(o,t)}addRangeProvider(e){this.providers.push(e)}createAdaptedRanges(e,t,o,i){const s=e.map((e=>Ri.fromRange(e,this.getters)));return s.map((e=>{if(!oi(e.zone))return e;const s=e.prefixSheet?e.sheetId:i,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:o),bottom:e.isFullCol?e.unboundedZone.bottom:e.unboundedZone.bottom+((e.parts[1]||e.parts[0]).rowFixed?0:o)};return e.clone({sheetId:s,zone:r}).orderZone()}))}getRangeFromSheetXC(e,t){if(!Zo.test(t))return new Ri({sheetId:"",zone:{left:-1,top:-1,right:-1,bottom:-1},parts:[],invalidXc:t,prefixSheet:!1},this.getters.getSheetSize);let o,i=t,s=!1;t.includes("!")&&(({xc:i,sheetName:o}=Jo(t)),o&&(s=!0));const r=ei(i),n=Ri.getRangeParts(i,r),a=o&&!this.getters.getSheetIdByName(o)?o:void 0,l=this.getters.getSheetIdByName(o)||e;return new Ri({prefixSheet:s,zone:r,sheetId:l,invalidSheetName:a,parts:n},this.getters.getSheetSize).orderZone()}getRangeString(e,t,o=!1){if(!e)return ee;if(e.invalidXc)return e.invalidXc;if(e.zone.bottom-e.zone.top<0||e.zone.right-e.zone.left<0)return ee;if(e.zone.left<0||e.zone.top<0)return ee;const i=Ri.fromRange(e,this.getters);let s=i.sheetId!==t||i.invalidSheetName||i.prefixSheet,r="";if(s&&(r=i.invalidSheetName?i.invalidSheetName:we(this.getters.getSheetName(i.sheetId))),s&&!r)return ee;let n=this.getRangePartString(i,0,o);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)&&(n+=":",n+=this.getRangePartString(i,1,o)),`${s?r+"!":""}${n}`}getRangeDataFromXc(e,t){return this.getters.getRangeFromSheetXC(e,t).rangeData}getRangeDataFromZone(e,t){return{_sheetId:e,_zone:t}}getRangeFromZone(e,t){return new Ri({sheetId:e,zone:t,parts:[{colFixed:!1,rowFixed:!1},{colFixed:!1,rowFixed:!1}],prefixSheet:!1},this.getters.getSheetSize)}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 Ri(t,this.getters.getSheetSize)}getRangePartString(e,t,o=!1){const i=e.parts&&e.parts[t]?.colFixed?"$":"",s=bt(0===t?e.zone.left:e.zone.right),r=e.parts&&e.parts[t]?.rowFixed?"$":"",n=String(0===t?e.zone.top+1:e.zone.bottom+1);let a="";return a=e.isFullCol&&!o?0===t&&e.unboundedZone.hasHeader?i+s+r+n:i+s:e.isFullRow&&!o?0===t&&e.unboundedZone.hasHeader?i+s+r+n:r+n:i+s+r+n,a}getInvalidRange(){return{parts:[],prefixSheet:!1,zone:{left:-1,top:-1,right:-1,bottom:-1},sheetId:"",invalidXc:ee}}}class nw extends KE{static layers=[];getters;ui;selection;constructor({getters:e,stateObserver:t,dispatch:o,uiActions:i,selection:s}){super(t,o),this.getters=e,this.ui=i,this.selection=s}drawGrid(e,t){}}const aw=fu.mapping;function lw(e,t,o){return new cw(e,t,o).getParameters()}class cw{getters;computeCell;evalContext;rangeCache={};constructor(e,t,o){this.getters=t,this.computeCell=o,this.evalContext=Object.assign(Object.create(aw),e,{getters:this.getters,locale:this.getters.getLocale()})}getParameters(){return[this.refFn.bind(this),this.range.bind(this),this.evalContext]}refFn(e,t,o,i){if(this.assertRangeValid(e),t)return{value:ii(e.zone)};if(e.zone.bottom!==e.zone.top||e.zone.left!==e.zone.right)throw new Error(i?r("Function %s expects the parameter %s to be a single value or a single cell reference, not a range.",o.toString(),i.toString()):r("Function %s expects its parameters to be single values or single cell references, not ranges.",o.toString()));return this.readCell(e)}readCell(e){if(!this.getters.tryGetSheet(e.sheetId))throw new Error(r("Invalid sheet name"));const t={sheetId:e.sheetId,col:e.zone.left,row:e.zone.top},o=this.getEvaluatedCellIfNotEmpty(t);if(void 0===o)return{value:null,format:this.getters.getCell(t)?.format};if(o.type===ls.error)throw o.error;return o}getEvaluatedCellIfNotEmpty(e){const t=this.computeCell(e);if(t.type===ls.empty){const t=this.getters.getCell(e);if(!t||!t.isFormula&&""===t.content)return}return t}range(e){this.assertRangeValid(e);const t=e.sheetId,o=e.zone,i=ci(o,this.getters.getSheetZone(t));if(!i)return{value:[[]],format:[[]]};const{top:s,left:r,bottom:n,right:a}=o,l=`${t}-${s}-${r}-${n}-${a}`;if(l in this.rangeCache){const e=this.rangeCache[l];if(e instanceof c)throw e;return e}const h=i.bottom-i.top+1,d=i.right-i.left+1,u=new Array(d),g=new Array(d);for(let e=i.left;e<=i.right;e++){const o=e-i.left;u[o]=new Array(h),g[o]=new Array(h);for(let s=i.top;s<=i.bottom;s++){const r=this.getEvaluatedCellIfNotEmpty({sheetId:t,col:e,row:s});if(r?.type===ls.error)throw this.rangeCache[l]=r.error,r.error;const n=s-i.top;u[o][n]=r?.value,void 0!==r?.format&&(g[o][n]=r.format)}}const p={value:u,format:g};return this.rangeCache[l]=p,p}assertRangeValid(e){if(!oi(e.zone))throw new u;if(e.invalidSheetName)throw new Error(r("Invalid sheet name: %s",e.invalidSheetName))}}function hw(e,t,o,i,s){dw(e,t,o||0,i||e.length-1,s||gw)}function dw(e,t,o,i,s){for(;i>o;){if(i-o>600){var r=i-o+1,n=t-o+1,a=Math.log(r),l=.5*Math.exp(2*a/3),c=.5*Math.sqrt(a*l*(r-l)/r)*(n-r/2<0?-1:1);dw(e,t,Math.max(o,Math.floor(t-n*l/r+c)),Math.min(i,Math.floor(t+(r-n)*l/r+c)),s)}var h=e[t],d=o,u=i;for(uw(e,o,t),s(e[i],h)>0&&uw(e,o,i);d<u;){for(uw(e,d,u),d++,u--;s(e[d],h)<0;)d++;for(;s(e[u],h)>0;)u--}0===s(e[o],h)?uw(e,o,u):uw(e,++u,i),u<=t&&(o=u+1),t<=u&&(i=u-1)}}function uw(e,t,o){var i=e[t];e[t]=e[o],e[o]=i}function gw(e,t){return e<t?-1:e>t?1:0}class pw{constructor(e=9){this._maxEntries=Math.max(4,e),this._minEntries=Math.max(2,Math.ceil(.4*this._maxEntries)),this.clear()}all(){return this._all(this.data,[])}search(e){let t=this.data;const o=[];if(!Iw(e,t))return o;const i=this.toBBox,s=[];for(;t;){for(let r=0;r<t.children.length;r++){const n=t.children[r],a=t.leaf?i(n):n;Iw(e,a)&&(t.leaf?o.push(n):yw(e,a)?this._all(n,o):s.push(n))}t=s.pop()}return o}collides(e){let t=this.data;if(!Iw(e,t))return!1;const o=[];for(;t;){for(let i=0;i<t.children.length;i++){const s=t.children[i],r=t.leaf?this.toBBox(s):s;if(Iw(e,r)){if(t.leaf||yw(e,r))return!0;o.push(s)}}t=o.pop()}return!1}load(e){if(!e||!e.length)return this;if(e.length<this._minEntries){for(let t=0;t<e.length;t++)this.insert(e[t]);return this}let t=this._build(e.slice(),0,e.length-1,0);if(this.data.children.length)if(this.data.height===t.height)this._splitRoot(this.data,t);else{if(this.data.height<t.height){const e=this.data;this.data=t,t=e}this._insert(t,this.data.height-t.height-1,!0)}else this.data=t;return this}insert(e){return e&&this._insert(e,this.data.height-1),this}clear(){return this.data=Rw([]),this}remove(e,t){if(!e)return this;let o=this.data;const i=this.toBBox(e),s=[],r=[];let n,a,l;for(;o||s.length;){if(o||(o=s.pop(),a=s[s.length-1],n=r.pop(),l=!0),o.leaf){const i=mw(e,o.children,t);if(-1!==i)return o.children.splice(i,1),s.push(o),this._condense(s),this}l||o.leaf||!yw(o,i)?a?(n++,o=a.children[n],l=!1):o=null:(s.push(o),r.push(n),n=0,a=o,o=o.children[0])}return this}toBBox(e){return e}compareMinX(e,t){return e.minX-t.minX}compareMinY(e,t){return e.minY-t.minY}toJSON(){return this.data}fromJSON(e){return this.data=e,this}_all(e,t){const o=[];for(;e;)e.leaf?t.push(...e.children):o.push(...e.children),e=o.pop();return t}_build(e,t,o,i){const s=o-t+1;let r,n=this._maxEntries;if(s<=n)return r=Rw(e.slice(t,o+1)),fw(r,this.toBBox),r;i||(i=Math.ceil(Math.log(s)/Math.log(n)),n=Math.ceil(s/Math.pow(n,i-1))),r=Rw([]),r.leaf=!1,r.height=i;const a=Math.ceil(s/n),l=a*Math.ceil(Math.sqrt(n));Tw(e,t,o,l,this.compareMinX);for(let s=t;s<=o;s+=l){const t=Math.min(s+l-1,o);Tw(e,s,t,a,this.compareMinY);for(let o=s;o<=t;o+=a){const s=Math.min(o+a-1,t);r.children.push(this._build(e,o,s,i-1))}}return fw(r,this.toBBox),r}_chooseSubtree(e,t,o,i){for(;i.push(t),!t.leaf&&i.length-1!==o;){let o,i=1/0,n=1/0;for(let a=0;a<t.children.length;a++){const l=t.children[a],c=Ew(l),h=(s=e,r=l,(Math.max(r.maxX,s.maxX)-Math.min(r.minX,s.minX))*(Math.max(r.maxY,s.maxY)-Math.min(r.minY,s.minY))-c);h<n?(n=h,i=c<i?c:i,o=l):h===n&&c<i&&(i=c,o=l)}t=o||t.children[0]}var s,r;return t}_insert(e,t,o){const i=o?e:this.toBBox(e),s=[],r=this._chooseSubtree(i,this.data,t,s);for(r.children.push(e),vw(r,i);t>=0&&s[t].children.length>this._maxEntries;)this._split(s,t),t--;this._adjustParentBBoxes(i,s,t)}_split(e,t){const o=e[t],i=o.children.length,s=this._minEntries;this._chooseSplitAxis(o,s,i);const r=this._chooseSplitIndex(o,s,i),n=Rw(o.children.splice(r,o.children.length-r));n.height=o.height,n.leaf=o.leaf,fw(o,this.toBBox),fw(n,this.toBBox),t?e[t-1].children.push(n):this._splitRoot(o,n)}_splitRoot(e,t){this.data=Rw([e,t]),this.data.height=e.height+1,this.data.leaf=!1,fw(this.data,this.toBBox)}_chooseSplitIndex(e,t,o){let i,s=1/0,r=1/0;for(let n=t;n<=o-t;n++){const t=bw(e,0,n,this.toBBox),a=bw(e,n,o,this.toBBox),l=xw(t,a),c=Ew(t)+Ew(a);l<s?(s=l,i=n,r=c<r?c:r):l===s&&c<r&&(r=c,i=n)}return i||o-t}_chooseSplitAxis(e,t,o){const i=e.leaf?this.compareMinX:Sw,s=e.leaf?this.compareMinY:Cw;this._allDistMargin(e,t,o,i)<this._allDistMargin(e,t,o,s)&&e.children.sort(i)}_allDistMargin(e,t,o,i){e.children.sort(i);const s=this.toBBox,r=bw(e,0,t,s),n=bw(e,o-t,o,s);let a=ww(r)+ww(n);for(let i=t;i<o-t;i++){const t=e.children[i];vw(r,e.leaf?s(t):t),a+=ww(r)}for(let i=o-t-1;i>=t;i--){const t=e.children[i];vw(n,e.leaf?s(t):t),a+=ww(n)}return a}_adjustParentBBoxes(e,t,o){for(let i=o;i>=0;i--)vw(t[i],e)}_condense(e){for(let t,o=e.length-1;o>=0;o--)0===e[o].children.length?o>0?(t=e[o-1].children,t.splice(t.indexOf(e[o]),1)):this.clear():fw(e[o],this.toBBox)}}function mw(e,t,o){if(!o)return t.indexOf(e);for(let i=0;i<t.length;i++)if(o(e,t[i]))return i;return-1}function fw(e,t){bw(e,0,e.children.length,t,e)}function bw(e,t,o,i,s){s||(s=Rw(null)),s.minX=1/0,s.minY=1/0,s.maxX=-1/0,s.maxY=-1/0;for(let r=t;r<o;r++){const t=e.children[r];vw(s,e.leaf?i(t):t)}return s}function vw(e,t){return e.minX=Math.min(e.minX,t.minX),e.minY=Math.min(e.minY,t.minY),e.maxX=Math.max(e.maxX,t.maxX),e.maxY=Math.max(e.maxY,t.maxY),e}function Sw(e,t){return e.minX-t.minX}function Cw(e,t){return e.minY-t.minY}function Ew(e){return(e.maxX-e.minX)*(e.maxY-e.minY)}function ww(e){return e.maxX-e.minX+(e.maxY-e.minY)}function xw(e,t){const o=Math.max(e.minX,t.minX),i=Math.max(e.minY,t.minY),s=Math.min(e.maxX,t.maxX),r=Math.min(e.maxY,t.maxY);return Math.max(0,s-o)*Math.max(0,r-i)}function yw(e,t){return e.minX<=t.minX&&e.minY<=t.minY&&t.maxX<=e.maxX&&t.maxY<=e.maxY}function Iw(e,t){return t.minX<=e.maxX&&t.minY<=e.maxY&&t.maxX>=e.minX&&t.maxY>=e.minY}function Rw(e){return{children:e,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function Tw(e,t,o,i,s){const r=[t,o];for(;r.length;){if((o=r.pop())-(t=r.pop())<=i)continue;const n=t+Math.ceil((o-t)/i/2)*i;hw(e,n,t,o,s),r.push(t,n,n,o)}}class Aw{rTrees={};constructor(e=[]){const t={};for(const o of e){const e=o.boundingBox.sheetId;t[e]||(t[e]=[]),t[e].push(o)}for(const e in t)this.rTrees[e]=new Ow,this.rTrees[e].load(t[e])}insert(e){const t=e.boundingBox.sheetId;this.rTrees[t]||(this.rTrees[t]=new Ow),this.rTrees[t].insert(e)}search({zone:e,sheetId:t}){return this.rTrees[t]?this.rTrees[t].search({minX:e.left,minY:e.top,maxX:e.right,maxY:e.bottom}):[]}remove(e){const t=e.boundingBox.sheetId;this.rTrees[t]&&this.rTrees[t].remove(e,this.rtreeItemComparer)}rtreeItemComparer(e,t){return e.data==t.data&&e.boundingBox.sheetId===t.boundingBox.sheetId&&e.boundingBox?.zone.left===t.boundingBox.zone.left&&e.boundingBox?.zone.top===t.boundingBox.zone.top&&e.boundingBox?.zone.right===t.boundingBox.zone.right&&e.boundingBox?.zone.bottom===t.boundingBox.zone.bottom}}class Ow extends pw{toBBox({boundingBox:e}){const t=e.zone;return{minX:t.left,minY:t.top,maxX:t.right,maxY:t.bottom}}compareMinX(e,t){return e.boundingBox.zone.left-t.boundingBox.zone.left}compareMinY(e,t){return e.boundingBox.zone.top-t.boundingBox.zone.top}}class Mw{encoder;dependencies=new Map;rTree;constructor(e,t=[]){this.encoder=e,this.rTree=new Aw(t)}removeAllDependencies(e){const t=this.dependencies.get(e);if(t){for(const e of t)this.rTree.remove(e);this.dependencies.delete(e)}}addDependencies(e,t){const o=t.map((({sheetId:t,zone:o})=>({data:e,boundingBox:{zone:o,sheetId:t}})));for(const e of o)this.rTree.insert(e);const i=this.dependencies.get(e);i?i.push(...o):this.dependencies.set(e,o)}getCellsDependingOn(e){const t=new Ke,o=Array.from(e).reverse();for(;o.length>0;){const e=o.pop();t.addMany(this.encoder.encodeBoundingBox(e));const i=this.rTree.search(e).map((e=>e.data));for(const e of i)t.has(e)||o.push(this.encoder.decodeToBoundingBox(e))}return t.deleteMany(e.flatMap((e=>this.encoder.encodeBoundingBox(e)))),t}}class Nw{resultsToArrayFormulas=new Map;arrayFormulasToResults=new Map;getFormulaPositionsSpreadingOn(e){return this.resultsToArrayFormulas.get(e)||_w}getArrayResultPositionIds(e){return this.arrayFormulasToResults.get(e)||_w}removeNode(e){this.resultsToArrayFormulas.delete(e),this.arrayFormulasToResults.delete(e)}addRelation({arrayFormulaPositionId:e,resultPositionId:t}){this.resultsToArrayFormulas.has(t)||this.resultsToArrayFormulas.set(t,new Set),this.resultsToArrayFormulas.get(t)?.add(e),this.arrayFormulasToResults.has(e)||this.arrayFormulasToResults.set(e,new Set),this.arrayFormulasToResults.get(e)?.add(t)}hasArrayFormulaResult(e){return this.resultsToArrayFormulas.has(e)}isArrayFormula(e){return this.arrayFormulasToResults.has(e)}}const _w=[];class Fw{context;getters;compilationParams;encoder=new Pw;evaluatedCells=new Map;formulaDependencies=ze(new Mw(this.encoder));blockedArrayFormulas=new Set;spreadingRelations=new Nw;constructor(e,t){this.context=e,this.getters=t,this.compilationParams=lw(this.context,this.getters,this.computeAndSave.bind(this))}getEvaluatedCell(e){return this.evaluatedCells.get(this.encoder.encode(e))||sr("",{locale:this.getters.getLocale()})}getArrayFormulaSpreadingOn(e){const t=this.encoder.encode(e),o=this.getArrayFormulaSpreadingOnId(t);return void 0!==o?this.encoder.decode(o):void 0}getEvaluatedPositions(){return[...this.evaluatedCells.keys()].map((e=>this.encoder.decode(e)))}getArrayFormulaSpreadingOnId(e){if(!this.spreadingRelations.hasArrayFormulaResult(e))return;const t=this.spreadingRelations.getFormulaPositionsSpreadingOn(e);return Array.from(t).find((e=>!this.blockedArrayFormulas.has(e)))}updateDependencies(e){const t=this.encoder.encode(e);this.formulaDependencies().removeAllDependencies(t);const o=this.getDirectDependencies(t);this.formulaDependencies().addDependencies(t,o)}updateCompilationParameters(){this.compilationParams=lw(this.context,this.getters,this.computeAndSave.bind(this))}evaluateCells(e){const t=e.map((e=>this.encoder.encode(e))),o=new Ke(t),i=this.getArrayFormulasImpactedByChangesOf(t);o.addMany(this.getCellsDependingOn(t)),o.addMany(i),o.addMany(this.getCellsDependingOn(i)),this.evaluate(o)}getArrayFormulasImpactedByChangesOf(e){const t=new Ke;for(const o of e){const e=this.getCell(o)?.content,i=this.getArrayFormulaSpreadingOnId(o);void 0!==i&&t.add(i),e||t.addMany(this.getArrayFormulasBlockedByOrSpreadingOn(o))}return t}buildDependencyGraph(){this.blockedArrayFormulas=new Set,this.spreadingRelations=new Nw,this.formulaDependencies=ze((()=>{const e=[...this.getAllCells()].flatMap((e=>this.getDirectDependencies(e).map((t=>({data:e,boundingBox:{zone:t.zone,sheetId:t.sheetId}})))));return new Mw(this.encoder,e)}))}evaluateAllCells(){this.evaluatedCells=new Map,this.evaluate(this.getAllCells())}evaluateFormula(e,t){const o=hg(t),i=[];for(let t of o.dependencies)i.push(this.getters.getRangeFromSheetXC(e,t));return this.updateCompilationParameters(),o.execute(i,...this.compilationParams).value}getAllCells(){const e=new Ke;for(const t of this.getters.getSheetIds()){const o=this.getters.getCells(t);for(const t in o)e.add(this.encoder.encode(this.getters.getCellPosition(t)))}return e}getArrayFormulasBlockedByOrSpreadingOn(e){if(!this.spreadingRelations.hasArrayFormulaResult(e))return[];const t=this.spreadingRelations.getFormulaPositionsSpreadingOn(e),o=new Ke(t);return o.addMany(this.getCellsDependingOn(t)),o}nextPositionsToUpdate=new Ke;cellsBeingComputed=new Set;evaluate(e){this.cellsBeingComputed=new Set,this.nextPositionsToUpdate=e;let t=0;for(;this.nextPositionsToUpdate.size&&t++<30;){this.updateCompilationParameters();const e=Array.from(this.nextPositionsToUpdate);this.nextPositionsToUpdate.clear();for(let t=0;t<e.length;++t){const o=e[t];this.evaluatedCells.delete(o)}for(let t=0;t<e.length;++t){const o=e[t];this.setEvaluatedCell(o,this.computeCell(o))}}}setEvaluatedCell(e,t){this.evaluatedCells.set(e,t)}computeCell(e){const t=this.evaluatedCells.get(e);if(t)return t;this.blockedArrayFormulas.has(e)||this.invalidateSpreading(e);const o=this.getCell(e);if(void 0===o)return sr("",{locale:this.getters.getLocale()});const i=o.id;try{if(this.cellsBeingComputed.has(i))throw new d;return this.cellsBeingComputed.add(i),o.isFormula?this.computeFormulaCell(o):or(o.content,{format:o.format,locale:this.getters.getLocale()})}catch(e){return this.handleError(e,o)}finally{this.cellsBeingComputed.delete(i)}}computeAndSave(e){const t=this.encoder.encode(e),o=this.computeCell(t);return this.evaluatedCells.has(t)||this.setEvaluatedCell(t,o),o}handleError(e,t){e instanceof c||(e=new c(a.GenericError,e.message));const o=this.compilationParams[2].__lastFnCalled||"";return e.message=e.message.replace("[[FUNCTION_NAME]]",o),lr(e)}computeFormulaCell(e){const t=e.id;this.compilationParams[2].__originCellXC=()=>{const e=this.compilationParams[2].getters.getCellPosition(t);return xt(e.col,e.row)};const o=e.compiledFormula.execute(e.dependencies,...this.compilationParams);!function(e){const{value:t,format:o}=e;if(!Ss(t)){if(Ss(o))throw new Error("A format matrix should never be associated with a scalar value");return}if(Ss(o)){if(!(t.length===o.length&&t[0].length===o[0].length))throw new Error("Formats and values should have the same dimensions!")}}(o);const{value:i,format:s}=o;if(!Ss(i))return sr(i,{format:e.format||s,locale:this.getters.getLocale()});const r=this.getters.getCellPosition(t);this.assertSheetHasEnoughSpaceToSpreadFormulaResult(r,i),Dw(i,this.updateSpreadRelation(r)),Dw(i,this.checkCollision(r)),Dw(i,this.spreadValues(r,o));const n=Lw(s);return sr(i[0][0],{format:e.format||n(0,0),locale:this.getters.getLocale()})}assertSheetHasEnoughSpaceToSpreadFormulaResult({sheetId:e,col:t,row:o},i){const s=this.getters.getNumberCols(e),n=this.getters.getNumberRows(e),a=t+i.length<=s,l=o+i[0].length<=n;if(!a||!l){if(a)throw new Error(r("Result couldn't be automatically expanded. Please insert more rows."));if(l)throw new Error(r("Result couldn't be automatically expanded. Please insert more columns."));throw new Error(r("Result couldn't be automatically expanded. Please insert more columns and rows."))}}updateSpreadRelation({sheetId:e,col:t,row:o}){const i=this.encoder.encode({sheetId:e,col:t,row:o});return(s,r)=>{const n={sheetId:e,col:s+t,row:r+o},a=this.encoder.encode(n);this.spreadingRelations.addRelation({resultPositionId:a,arrayFormulaPositionId:i})}}checkCollision({sheetId:e,col:t,row:o}){const i=this.encoder.encode({sheetId:e,col:t,row:o});return(s,n)=>{const a={sheetId:e,col:s+t,row:n+o};if(this.getters.getCell(a)?.content||this.getters.getEvaluatedCell(a).type!==ls.empty)throw this.blockedArrayFormulas.add(i),new Error(r("Array result was not expanded because it would overwrite data in %s.",xt(a.col,a.row)));this.blockedArrayFormulas.delete(i)}}spreadValues({sheetId:e,col:t,row:o},i){const s=Lw(i.format);return(r,n)=>{const a={sheetId:e,col:r+t,row:n+o},l=this.getters.getCell(a)?.format,c=sr(i.value[r][n],{format:l||s(r,n),locale:this.getters.getLocale()}),h=this.encoder.encode(a);this.setEvaluatedCell(h,c),this.nextPositionsToUpdate.addMany(this.getCellsDependingOn([h]))}}invalidateSpreading(e){if(this.spreadingRelations.isArrayFormula(e)){for(const t of this.spreadingRelations.getArrayResultPositionIds(e)){const e=this.getCell(t)?.content;e||(this.evaluatedCells.delete(t),this.nextPositionsToUpdate.addMany(this.getCellsDependingOn([t])),this.nextPositionsToUpdate.addMany(this.getArrayFormulasBlockedByOrSpreadingOn(t)))}this.spreadingRelations.removeNode(e)}}getDirectDependencies(e){const t=this.getCell(e);return t?.isFormula?t.dependencies:[]}getCellsDependingOn(e){const t=[];for(const o of e)t.push(this.encoder.decodeToBoundingBox(o));return this.formulaDependencies().getCellsDependingOn(t)}getCell(e){return this.getters.getCell(this.encoder.decode(e))}}function Dw(e,t){for(let o=0;o<e.length;++o)for(let i=0;i<e[o].length;++i)0===o&&0===i||t(o,i)}function Lw(e){return Ss(e)?(t,o)=>e[t][o]:()=>e}class Pw{sheetMapping={};inverseSheetMapping=new Map;constructor(){try{o_spreadsheet.__DEBUG__=o_spreadsheet.__DEBUG__||{},o_spreadsheet.__DEBUG__.decodePosition=this.decode.bind(this),o_spreadsheet.__DEBUG__.encodePosition=this.encode.bind(this)}catch(e){}}encode({sheetId:e,col:t,row:o}){return this.encodeSheet(e)<<42n|BigInt(t)<<21n|BigInt(o)}encodeBoundingBox({sheetId:e,zone:t}){const o=[];return function(e,t){const{left:o,right:i,top:s,bottom:r}=e;for(let e=o;e<=i;e++)for(let o=s;o<=r;o++)t(e,o)}(t,((t,i)=>{o.push(this.encode({sheetId:e,col:t,row:i}))})),o}decode(e){const t=Number(2097151n&e),o=Number(e>>21n&2097151n);return{sheetId:this.decodeSheet(e>>42n),col:o,row:t}}decodeToBoundingBox(e){const{sheetId:t,col:o,row:i}=this.decode(e);return{sheetId:t,zone:{left:o,top:i,right:o,bottom:i}}}encodeSheet(e){const t=this.sheetMapping[e];if(void 0===t){const t=BigInt(Object.keys(this.sheetMapping).length);return this.sheetMapping[e]=t,this.inverseSheetMapping.set(t,e),t}return t}decodeSheet(e){const t=this.inverseSheetMapping.get(e);if(void 0===t)throw new Error("Sheet id not found");return t}}class kw{cells;getters;index=0;direction;constructor(e,t,o){this.cells=e,this.getters=t,this.direction=o}next(){const e=this.cells[this.index++%this.cells.length],t=e.rule,{cellData:o,tooltip:i}=hr.get(t.type).apply(t,e.data,this.getters,this.direction);return{cellData:o,tooltip:i,origin:{col:e.data.col,row:e.data.row}}}}class Uw{subscriptions={};on(e,t,o){if(!o)throw new Error("Missing callback");this.subscriptions[e]||(this.subscriptions[e]=[]),this.subscriptions[e].push({owner:t,callback:o})}trigger(e,t){const o=this.subscriptions[e]||[];for(let e=0,i=o.length;e<i;e++){const i=o[e];i.callback.call(i.owner,t)}}off(e,t){const o=this.subscriptions[e];o&&(this.subscriptions[e]=o.filter((e=>e.owner!==t)))}clear(){this.subscriptions={}}}function Vw(e,t){return{...e,definition:hm(e.definition,t)}}function Bw(e,t){if(e.sheetId!==t.sheetId)return e;if(("FREEZE_COLUMNS"===e.type?"COL":"ROW")!==t.dimension)return e;let o=e.quantity;if("REMOVE_COLUMNS_ROWS"===t.type){const e=[...t.elements].sort(((e,t)=>t-e));for(let t of e)o>t&&o--}if("ADD_COLUMNS_ROWS"===t.type){o=o>("before"===t.position?t.base-1:t.base)?o+t.quantity:o}return o>0?{...e,quantity:o}:void 0}Kb.addTransformation("ADD_COLUMNS_ROWS",["CREATE_CHART","UPDATE_CHART"],Vw),Kb.addTransformation("REMOVE_COLUMNS_ROWS",["CREATE_CHART","UPDATE_CHART"],Vw),Kb.addTransformation("DELETE_SHEET",["MOVE_RANGES"],(function(e,t){const o=t.sheetId;if(e.targetSheetId===o||e.sheetId===o)return;return e})),Kb.addTransformation("DELETE_FIGURE",["UPDATE_FIGURE","UPDATE_CHART"],(function(e,t){if(e.id===t.id)return;return e})),Kb.addTransformation("CREATE_SHEET",["CREATE_SHEET"],(function(e,t){if(e.name===t.name)return{...e,name:e.name?.match(/\d+/)?e.name.replace(/\d+/,(e=>(parseInt(e)+1).toString())):`${e.name}~`,position:e.position+1};return e})),Kb.addTransformation("ADD_MERGE",["ADD_MERGE","REMOVE_MERGE","CREATE_FILTER_TABLE"],(function(e,t){if(e.sheetId!==t.sheetId)return e;const o=[];for(const i of e.target)for(const e of t.target)di(i,e)||o.push({...i});if(o.length)return{...e,target:o};return})),Kb.addTransformation("ADD_COLUMNS_ROWS",["FREEZE_COLUMNS","FREEZE_ROWS"],Bw),Kb.addTransformation("REMOVE_COLUMNS_ROWS",["FREEZE_COLUMNS","FREEZE_ROWS"],Bw),Kb.addTransformation("CREATE_FILTER_TABLE",["CREATE_FILTER_TABLE","ADD_MERGE"],(function(e,t){if(e.sheetId!==t.sheetId)return e;for(const o of e.target)for(const e of t.target)if(di(e,o))return;return e}));const zw=[{match:function(e){return"sheetId"in e},fn:Ww},{match:function(e){return"target"in e&&"sheetId"in e},fn:function(e,t){const o=Ww(e,t);if("SKIP_TRANSFORMATION"!==o)return"IGNORE_COMMAND"===o?"IGNORE_COMMAND":e;const i=[];for(const o of e.target){const e=Gg(o,t);e&&i.push(e)}if(!i.length)return"IGNORE_COMMAND";return{...e,target:i}}},{match:function(e){return"col"in e&&"row"in e&&"sheetId"in e},fn:function(e,t){const o=Ww(e,t);if("SKIP_TRANSFORMATION"!==o)return"IGNORE_COMMAND"===o?"IGNORE_COMMAND":e;if("ADD_COLUMNS_ROWS"===t.type||"REMOVE_COLUMNS_ROWS"===t.type)return function(e,t){const o="COL"===t.dimension?"col":"row";let i=e[o];if("REMOVE_COLUMNS_ROWS"===t.type){const e=[...t.elements].sort(((e,t)=>t-e));if(e.includes(i))return"IGNORE_COMMAND";for(let t of e)i>=t&&i--}"ADD_COLUMNS_ROWS"===t.type&&(i>t.base||i===t.base&&"before"===t.position)&&(i+=t.quantity);return{...e,[o]:i}}(e,t);if("ADD_MERGE"===t.type)return function(e,t){for(const o of t.target){if(!(e.col===o.left&&e.row===o.top)&&ui(e.col,e.row,o))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 o=Ww(e,t);if("SKIP_TRANSFORMATION"!==o)return"IGNORE_COMMAND"===o?"IGNORE_COMMAND":e;if("ADD_COLUMNS_ROWS"===t.type||"REMOVE_COLUMNS_ROWS"===t.type){if(t.dimension!==e.dimension)return e;const o="ADD_COLUMNS_ROWS"===e.type,i=o?"base":"elements";let s=o?[e[i]]:e[i];if("REMOVE_COLUMNS_ROWS"===t.type&&(s=s.map((e=>{if(t.elements.includes(e))return;const o=t.elements.sort(((e,t)=>t-e));for(let t of o)e>t&&e--;return e})).filter(ke)),"ADD_COLUMNS_ROWS"===t.type){const e="before"===t.position?t.base-1:t.base;s=s.map((o=>o>e?o+t.quantity:o))}if(s.length){let t=s;return o&&(t=s[0]),{...e,[i]:t}}return"IGNORE_COMMAND"}return"SKIP_TRANSFORMATION"}},{match:function(e){return"ranges"in e},fn:function(e,t){if(!("sheetId"in t))return e;const o=[],i="DELETE_SHEET"===t.type&&t.sheetId;for(const s of e.ranges)if(s._sheetId!==t.sheetId)o.push({...s,_zone:s._zone});else{const e=Gg(s._zone,t);e&&i!==s._sheetId&&o.push({...s,_zone:e})}if(!o.length)return"IGNORE_COMMAND";return{...e,ranges:o}}}];function Hw(e,t){const o=Kb.getTransformation(e.type,t.type);return o?o(e,t):function(e,t){for(const{match:o,fn:i}of zw)if(o(e)){const o=i(e,t);if("SKIP_TRANSFORMATION"===o)continue;if("IGNORE_COMMAND"===o)return;e=o}return e}(e,t)}function $w(e,t){let o=[...e];for(const e of t)o=o.map((t=>Hw(t,e))).filter(ke);return o}function Ww(e,t){if(!("sheetId"in t))return e;const o="DELETE_SHEET"===t.type&&t.sheetId;return e.sheetId===o?"IGNORE_COMMAND":"CREATE_SHEET"===e.type||"CREATE_SHEET"===t.type||e.sheetId!==t.sheetId?e:"SKIP_TRANSFORMATION"}class Gw{rootCommand;timestamp;id;clientId;_commands=[];_changes=[];constructor(e,t,o,i,s,r){this.rootCommand=i,this.timestamp=r,this.id=e,this.clientId=t,this._commands=[...o],this._changes=s?[...s]:[]}setChanges(e){this._changes=e}get commands(){return this._commands}get changes(){return this._changes}}class qw extends Error{}class Zw extends Uw{revisions;transportService;serverRevisionId;clients={};clientId="local";debouncedMove;pendingMessages=[];waitingAck=!1;waitingUndoRedoAck=!1;isReplayingInitialRevisions=!1;processedRevisions=new Set;uuidGenerator=new Bi;constructor(e,t,o=te){super(),this.revisions=e,this.transportService=t,this.serverRevisionId=o,this.debouncedMove=function(e,t,o){let i;return function(){const s=this,r=arguments,n=o&&!i;clearTimeout(i),i=setTimeout((function(){i=null,o||e.apply(s,r)}),t),n&&e.apply(s,r)}}(this._move.bind(this),200)}canApplyOptimisticUpdate(){return!this.waitingUndoRedoAck}save(e,t,o){if(!t.length||!o.length||!this.canApplyOptimisticUpdate())return;const i=new Gw(this.uuidGenerator.uuidv4(),this.clientId,t,e,o,Date.now());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 qw("The client left the session");return e}getConnectedClients(){return new Set(Object.values(this.clients).filter(ke))}getRevisionId(){return this.serverRevisionId}isFullySynchronized(){return 0===this.pendingMessages.length}getLastLocalNonEmptyRevision(e){const t=this.revisions.getRevertedExecution();for(const o of t){if("SNAPSHOT"===o.rootCommand)return;if(o.rootCommand&&"REMOTE"!==o.rootCommand&&(!e.includes(o.rootCommand?.type)&&o.commands.length))return o}}_move(e){if(!this.clients[this.clientId])return;const t=this.clients[this.clientId]?.position;if(t?.col===e.col&&t.row===e.row&&t.sheetId===e.sheetId)return;const o=t?"CLIENT_MOVED":"CLIENT_JOINED",i=this.getClient();this.clients[this.clientId]={...i,position:e},this.transportService.sendMessage({type:o,version:1,client:{...i,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:o,timestamp:i}=e,s=new Gw(e.nextRevisionId,t,o,"REMOTE",void 0,i);if(s.clientId!==this.clientId){this.revisions.insert(s.id,s,e.serverRevisionId);const t=this.pendingMessages.filter((e=>"REMOTE_REVISION"===e.type)).map((e=>e.commands)).flat();this.trigger("remote-revision-received",{commands:$w(o,t)})}break;case"SNAPSHOT_CREATED":{const t=new Gw(e.nextRevisionId,"server",[],"SNAPSHOT",void 0,Date.now());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 Yw=["#ff851b","#0074d9","#7fdbff","#b10dc9","#39cccc","#f012be","#3d9970","#111111","#ff4136","#aaaaaa","#85144b","#001f3f"];var jw;!function(e){e[e.previous=-1]="previous",e[e.current=0]="current",e[e.next=1]="next"}(jw||(jw={}));class Xw extends nw{inputHasSingleRange;static layers=[1];static getters=[];ranges=[];focusedRangeIndex=null;activeSheet;willAddNewRange=!1;constructor(e,t,o){if(o&&t.length>1)throw new Error("Input with a single range cannot be instantiated with several range references.");super(e),this.inputHasSingleRange=o,this.insertNewRange(0,t),this.activeSheet=this.getters.getActiveSheetId(),0===this.ranges.length&&(this.insertNewRange(this.ranges.length,[""]),this.focusLast())}handleEvent(e){const t=this.activeSheet,o=this.getters.getActiveSheetId(),i=e.anchor.zone,s=this.getters.getRangeFromZone(o,e.options.unbounded?this.getters.getUnboundedZone(o,i):i);this.add([this.getters.getSelectionRangeString(s,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 o=e.value.replace(/^,+/,"").split(",").map((e=>e.trim()));this.setRange(t,o)}break}case"ADD_EMPTY_RANGE":this.insertNewRange(this.ranges.length,[""]),this.focusLast();break;case"ADD_RANGE":this.insertNewRange(this.ranges.length,[e.value]),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:o}=this.getters.getNextVisibleCellPosition({sheetId:e.sheetIdTo,col:0,row:0}),i=this.getters.expandZone(e.sheetIdTo,wi({col:t,row:o}));this.selection.resetAnchor(this,{cell:{col:t,row:o},zone:i})}}}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],xc:t}}insertNewRange(e,t){const o=Math.max(0,...this.ranges.map((e=>Number(e.id))));this.ranges.splice(e,0,...t.map(((e,t)=>({xc:e,id:o+t+1,color:st[(o+t)%st.length]}))))}setRange(e,t){const[,...o]=t;this.setContent(e,t[0]),this.insertNewRange(e+1,o),o.length&&this.focus(e+o.length)}removeRange(e){this.ranges.splice(e,1),null!==this.focusedRangeIndex&&this.focusLast()}inputToHighlights({xc:e,color:t}){const o=this.cleanInputs([e]).filter((e=>this.getters.isRangeValid(e))).filter((e=>this.shouldBeHighlighted(this.activeSheet,e)));return o.map((e=>{const{sheetName:o}=Jo(e);return{zone:this.getters.getRangeFromSheetXC(this.activeSheet,e).zone,sheetId:o&&this.getters.getSheetIdByName(o)||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:o}=Jo(t),i=this.getters.getSheetIdByName(o),s=this.getters.getActiveSheet().id;return this.getters.isRangeValid(t)&&(i===s||void 0===i&&s===e)}getIndex(e){const t=this.ranges.findIndex((t=>t.id===e));return t>=0?t:null}}const Kw=[Qw,function(e,t){return"target"in t&&Array.isArray(t.target)?{...Ce(t),target:e.getSelectedZones()}:t},function(e,t){if(!("row"in t)||!("col"in t))return t;const{col:o,row:i}=e.getActivePosition();return{...Ce(t),col:o,row:i}}];function Qw(e,t){return"sheetId"in t?{...Ce(t),sheetId:e.getActiveSheetId()}:t}const Jw=new Bi;function ex(e,t){const o=e.getSelectedZone();return{...Qw(e,t),elements:"COL"===t.dimension?ye(o.left,o.right+1):ye(o.top,o.bottom+1)}}function tx(e,t){const o=e.getSelectedZone();return{...Ce(t),zone:o}}function ox(e,t){const o=Ce(t),i=e.getSelectedZone(),{top:s,bottom:r,left:n,right:a}=i;return"cols"in o?o.cols=ye(n,a+1):"rows"in o&&(o.rows=ye(s,r+1)),o}const ix=new Ji;ix.add("UPDATE_CELL",rx),ix.add("CLEAR_CELL",rx),ix.add("DELETE_CONTENT",rx),ix.add("ADD_MERGE",rx),ix.add("REMOVE_MERGE",rx),ix.add("SET_FORMATTING",rx),ix.add("CLEAR_FORMATTING",rx),ix.add("SET_BORDER",rx),ix.add("CREATE_FILTER_TABLE",rx),ix.add("REMOVE_FILTER_TABLE",rx),ix.add("HIDE_SHEET",rx),ix.add("ADD_COLUMNS_ROWS",(function(e,t){const o=e.getActivePosition();return{...Qw(e,t),base:"COL"===t.dimension?o.col:o.row}})),ix.add("REMOVE_COLUMNS_ROWS",ex),ix.add("HIDE_COLUMNS_ROWS",ex),ix.add("RESIZE_COLUMNS_ROWS",ex),ix.add("CREATE_SHEET",(function(e,t){const o=Ce(t);o.sheetId=Jw.uuidv4();const i=t.name||e.getSheet(e.getActiveSheetId()).name,s=i.match(/(.+?)\d*$/)?.[1]||i;return o.name=e.getNextSheetName(s),o})),ix.add("CREATE_FIGURE",(function(e,t){const o=Qw(e,t);return o.figure.id=Jw.uuidv4(),o})),ix.add("CREATE_CHART",(function(e,t){return{...Qw(e,t),id:Jw.uuidv4()}})),ix.add("CREATE_IMAGE",(function(e,t){return{...Qw(e,t),figureId:Jw.uuidv4()}}));const sx=new Ji;function rx(e,t){let o=Ce(t);for(const t of Kw)o=t(e,o);return o}function nx(e,t){if(!t)return;if(!ix.contains(t.type))return;return ix.get(t.type)(e,t)}function ax(e,t){if(e.rootCommand&&"object"==typeof e.rootCommand)return ms(e.rootCommand)?nx(t,e.rootCommand):function(e,t,o){if(!sx.contains(t.type))return;return sx.get(t.type)(e,t,o)}(t,e.rootCommand,e.commands)}sx.add("STOP_EDITION",(function(e,t,o){return o.map((t=>nx(e,t))).filter(ke)})),sx.add("PASTE",(function(e,t){return{type:"REPEAT_PASTE",pasteOption:Ce(t.pasteOption),target:e.getSelectedZones()}})),sx.add("INSERT_CELL",tx),sx.add("DELETE_CELL",tx),sx.add("AUTORESIZE_COLUMNS",ox),sx.add("AUTORESIZE_ROWS",ox),sx.add("SORT_CELLS",(function(e,t){const o=e.getSelectedZone();return{...Qw(e,t),col:o.left,row:o.top,zone:o}})),sx.add("SUM_SELECTION",rx),sx.add("SET_DECIMAL",rx);class lx{getters;dispatch;selection;operation;sheetId;constructor(e,t,o,i){this.getters=t,this.dispatch=o,this.selection=i,this.operation=e,this.sheetId=t.getActiveSheetId()}isCutAllowed(e){return 0}isPasteAllowed(e,t){return 0}addMissingDimensions(e,t,o,i){const s=this.getters.getActiveSheetId(),r=t+i-this.getters.getNumberRows(s);r>0&&this.dispatch("ADD_COLUMNS_ROWS",{dimension:"ROW",base:this.getters.getNumberRows(s)-1,sheetId:s,quantity:r,position:"after"});const n=e+o-this.getters.getNumberCols(s);n>0&&this.dispatch("ADD_COLUMNS_ROWS",{dimension:"COL",base:this.getters.getNumberCols(s)-1,sheetId:s,quantity:n,position:"after"})}isColRowDirtyingClipboard(e,t){return!1}drawClipboard(e){}}class cx extends lx{cells;copiedTables;zones;uuidGenerator=new Bi;constructor(e,t,o,i,s){if(super(t,o,i,s),!e.length)return this.cells=[[]],this.zones=[],void(this.copiedTables=[]);const r=new Set(e.map((e=>e.left))),n=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===n.size?function(e){return e.reduce(((e,t)=>{const o=e.length;for(let i=0;i<o;i++)if(di(e[i],t))return e[i]=li(e[i],t),e;return e[o]=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=o.getActiveSheetId();for(let e of u){let t=[];for(let i of d){const s={col:i,row:e,sheetId:p};t.push({cell:o.getCell(s),style:o.getCellComputedStyle(s),evaluatedCell:o.getEvaluatedCell(s),border:o.getCellBorder(s)||void 0,position:s})}g.push(t)}const m=[];for(const t of e)for(const e of this.getters.getFilterTablesInZone(p,t)){const t=[];for(const o of ye(e.zone.left,e.zone.right+1))t.push(this.getters.getFilterValues({sheetId:p,col:o,row: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?20:0}isPasteAllowed(e,t){const o=this.getters.getActiveSheetId();if("CUT"===this.operation&&void 0!==t?.pasteOption)return 22;if(e.length>1&&(this.cells.length>1||this.cells[0].length>1))return 21;const i=this.cells.length,s=this.cells[0].length;for(let t of this.getPasteZones(e))if(this.getters.doesIntersectMerge(o,t)&&(e.length>1||!this.getters.isSingleCellOrMerge(o,e[0])||i*s!=1))return 2;const{xSplit:r,ySplit:n}=this.getters.getPaneDivisions(o);for(const t of this.getPasteZones(e))if(t.left<r&&t.right>=r||t.top<n&&t.bottom>=n)return 78;return 0}paste(e,t){"COPY"===this.operation?this.pasteFromCopy(e,t):this.pasteFromCut(e,t);const o=this.cells.length,i=this.cells[0].length,s="CUT"===this.operation;t?.selectTarget&&this.selectPastedZone(i,o,s,e)}pasteFromCopy(e,t){if(1===e.length){const o=this.cells.length,i=this.cells[0].length,s=this.pastedZones(e,i,o);for(const e of s)this.pasteZone(e.left,e.top,t)}else for(const o of e)for(let e=o.left;e<=o.right;e++)for(let i=o.top;i<=o.bottom;i++)this.pasteZone(e,i,t);void 0===t?.pasteOption&&this.pasteCopiedTables(e)}pasteFromCut(e,t){this.clearClippedZones();const o=e[0];this.pasteZone(o.left,o.top,t),this.dispatch("MOVE_RANGES",{target:this.zones,sheetId:this.sheetId,targetSheetId:this.getters.getActiveSheetId(),col:o.left,row:o.top});for(const e of this.copiedTables)this.dispatch("REMOVE_FILTER_TABLE",{sheetId:this.sheetId,target:[e.zone]});this.pasteCopiedTables(e),this.cells.forEach((e=>{e.forEach((e=>{e.cell&&(e.cell=void 0)}))}))}pastedZones(e,t,o){const i=e[0],s=Math.max(1,Math.floor((i.right+1-i.left)/t)),r=Math.max(1,Math.floor((i.bottom+1-i.top)/o)),n=[];for(let e=0;e<s;e++)for(let s=0;s<r;s++){const r=i.top+s*o,a=i.left+e*t;n.push({left:a,top:r,bottom:r+o-1,right:a+t-1})}return n}getPasteZones(e){const t=this.cells;if(!t.length||!t[0].length)return e;const o=[],i=t.length,s=t[0].length,r=e[e.length-1],n=r.left,a=r.top,l=Math.max(1,Math.floor((r.right+1-n)/s)),c=Math.max(1,Math.floor((r.bottom+1-a)/i));for(let e=1;e<=l;e++)for(let t=1;t<=c;t++)o.push({left:n,top:a,right:n-1+e*s,bottom:a-1+t*i});return o}selectPastedZone(e,t,o,i){const s=i[0],r=s.left,n=s.top;if(t>1||e>1||o){const s=this.pastedZones(i,e,t),a=o?s[0]:li(...s);this.selection.selectZone({cell:{col:r,row:n},zone:a},{scrollIntoView:!1})}}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,o){const i=this.cells.length,s=this.cells[0].length,r="onlyValue"!==o?.pasteOption&&o?.shouldPasteCF,n=this.getters.getActiveSheetId();this.addMissingDimensions(s,i,e,t);for(let a=0;a<i;a++){const i=this.cells[a];for(let l=0;l<s;l++){const s=i[l],c={col:e+l,row:t+a,sheetId:n};"CUT"!==this.operation&&this.pasteMergeIfExist(s.position,c),this.pasteCell(s,c,this.operation,o),r&&this.pasteCf(s.position,c)}}}pasteCell(e,t,o,i){const{sheetId:s,col:r,row:n}=t,a=this.getters.getEvaluatedCell(t);if("onlyValue"!==i?.pasteOption){const o=this.getters.getCellBorder(t),i=e.border,a={top:o?.top||i?.top,bottom:o?.bottom||i?.bottom,left:o?.left||i?.left,right:o?.right||i?.right};this.dispatch("SET_BORDER",{sheetId:s,col:r,row:n,border:a})}if(e.cell){if("onlyFormat"===i?.pasteOption)return void this.dispatch("UPDATE_CELL",{...t,style:e.cell.style,format:e.evaluatedCell.format});if("onlyValue"===i?.pasteOption){const o=this.getters.getLocale(),i=fo(e.evaluatedCell.value,{locale:o});return void this.dispatch("UPDATE_CELL",{...t,content:i})}let a=e.cell.content;if(e.cell.isFormula&&"COPY"===o){const t=r-e.position.col,i=n-e.position.row;a=this.getUpdatedContent(s,e.cell,t,i,o)}this.dispatch("UPDATE_CELL",{...t,content:a,style:e.cell.style||null,format:e.cell.format})}else a&&("onlyValue"===i?.pasteOption?this.dispatch("UPDATE_CELL",{...t,content:""}):"onlyFormat"===i?.pasteOption?this.dispatch("UPDATE_CELL",{...t,style:null,format:""}):this.dispatch("CLEAR_CELL",t))}getUpdatedContent(e,t,o,i,s){const r=this.getters.createAdaptedRanges(t.dependencies,o,i,e);return this.getters.buildFormulaContent(e,t,r)}pasteMergeIfExist(e,t){let{sheetId:o,col:i,row:s}=e;const{col:r,row:n}=this.getters.getMainCellPosition(e);if(r===i&&n===s){const r=this.getters.getMerge(e);if(!r)return;({sheetId:o,col:i,row:s}=t),this.dispatch("ADD_MERGE",{sheetId:o,force:!0,target:[{left:i,top:s,right:i+r.right-r.left,bottom:s+r.bottom-r.top}]})}}pasteCopiedTables(e){const t=this.getters.getActiveSheetId(),o=e[0],i=this.zones[0],s=[o.left-i.left,o.top-i.top];for(const e of this.copiedTables){const o=Si(e.zone,"both","MOVE",s);this.dispatch("CREATE_FILTER_TABLE",{sheetId:t,target:[o]});for(const i of ye(0,e.filtersValues.length))this.dispatch("UPDATE_FILTER",{sheetId:t,col:o.left+i,row:o.top,values:e.filtersValues[i]})}}getClipboardContent(){return{[cs.PlainText]:this.getPlainTextContent(),[cs.Html]:this.getHTMLContent()}}getPlainTextContent(){return this.cells.map((e=>e.map((e=>this.getters.shouldShowFormulas()&&e.cell?.isFormula?e.cell?.content||"":e.evaluatedCell?.formattedValue||"")).join("\t"))).join("\n")||"\t"}getHTMLContent(){if(1===this.cells.length&&1===this.cells[0].length)return this.getters.getCellText(this.cells[0][0].position);let e='<table border="1" style="border-collapse:collapse">';for(const t of this.cells){e+="<tr>";for(const o of t){e+=`<td style="${Yi(qi(o.style))}">`+vE(this.getters.getCellText(o.position))+"</td>"}e+="</tr>"}return e+="</table>",e}isColRowDirtyingClipboard(e,t){if(!this.zones)return!1;for(let o of this.zones){if("COL"===t&&e<=o.right)return!0;if("ROW"===t&&e<=o.bottom)return!0}return!1}drawClipboard(e){const{ctx:t,thinLineWidth:o}=e;if(this.sheetId===this.getters.getActiveSheetId()&&this.zones&&this.zones.length){t.setLineDash([8,5]),t.strokeStyle=E,t.lineWidth=3.3*o;for(const e of this.zones){const{x:o,y:i,width:s,height:r}=this.getters.getVisibleRect(e);s>0&&r>0&&t.strokeRect(o,i,s,r)}}}pasteCf(e,t){const o=xt(t.col,t.row);for(let i of this.getters.getConditionalFormats(e.sheetId))for(let s of i.ranges)if(ui(e.col,e.row,this.getters.getRangeFromSheetXC(e.sheetId,s).zone)){const s=i,r=[];if("CUT"===this.operation&&r.push(xt(e.col,e.row)),e.sheetId===t.sheetId)this.adaptCFRules(e.sheetId,s,[o],r);else{this.adaptCFRules(e.sheetId,s,[],r);const i=this.getCFToCopyTo(t.sheetId,s);this.adaptCFRules(t.sheetId,i,[o],[])}}}adaptCFRules(e,t,o,i){const s=this.getters.getAdaptedCfRanges(e,t,o,i);s&&(0!==s.length?this.dispatch("ADD_CONDITIONAL_FORMAT",{cf:{id:t.id,rule:t.rule,stopIfTrue:t.stopIfTrue},ranges:s.map((t=>this.getters.getRangeDataFromXc(e,t))),sheetId:e}):this.dispatch("REMOVE_CONDITIONAL_FORMAT",{id:t.id,sheetId:e}))}getCFToCopyTo(e,t){const o=this.getters.getConditionalFormats(e).find((e=>e.stopIfTrue===t.stopIfTrue&&We(e.rule,t.rule)));return o||{...t,id:this.uuidGenerator.uuidv4(),ranges:[]}}}class hx{operation;getters;dispatch;sheetId;copiedFigure;copiedFigureContent;constructor(e,t,o){this.operation=e,this.getters=t,this.dispatch=o,this.sheetId=t.getActiveSheetId();const i=t.getSelectedFigureId();if(!i)throw new Error("No figure selected");const s=t.getFigure(this.sheetId,i);if(!s)throw new Error(`No figure for the given id: ${i}`);switch(this.copiedFigure={...s},s.tag){case"chart":this.copiedFigureContent=new dx(o,t,this.sheetId,i);break;case"image":this.copiedFigureContent=new ux(o,t,this.sheetId,i);break;default:throw new Error(`Unknow tag '${s.tag}' for the given figure id: ${i}`)}}isCutAllowed(e){return 0}isPasteAllowed(e,t){return 0===e.length?76:void 0!==t?.pasteOption?23:0}paste(e){const t=this.getters.getActiveSheetId(),{width:o,height:i}=this.copiedFigure,s=this.getters.getNumberCols(t),r=this.getters.getNumberRows(t),n=this.getters.getColDimensions(t,e[0].left).start,a=this.getters.getRowDimensions(t,e[0].top).start,l=this.getters.getColDimensions(t,s-1).end,c=this.getters.getRowDimensions(t,r-1).end,h={x:l<o?0:Math.min(n,l-o),y:c<i?0:Math.min(a,c-i)},d=(new Bi).uuidv4();this.copiedFigureContent.paste(t,d,h,{height:i,width:o}),"CUT"===this.operation&&this.dispatch("DELETE_FIGURE",{sheetId:this.copiedFigureContent.sheetId,id:this.copiedFigure.id}),this.dispatch("SELECT_FIGURE",{id:d})}getClipboardContent(){return{[cs.PlainText]:"\t"}}isColRowDirtyingClipboard(e,t){return!1}drawClipboard(e){}}class dx{dispatch;sheetId;copiedChart;constructor(e,t,o,i){this.dispatch=e,this.sheetId=o;const s=t.getChart(i);if(!s)throw new Error(`No chart for the given id: ${i}`);this.copiedChart=s.copyInSheetId(o)}paste(e,t,o,i){const s=this.copiedChart.copyInSheetId(e);this.dispatch("CREATE_CHART",{id:t,sheetId:e,position:o,size:i,definition:s.getDefinition()})}}class ux{dispatch;sheetId;copiedImage;constructor(e,t,o,i){this.dispatch=e,this.sheetId=o;const s=t.getImage(i);this.copiedImage=Ce(s)}paste(e,t,o,i){const s=Ce(this.copiedImage);this.dispatch("CREATE_IMAGE",{figureId:t,sheetId:e,position:o,size:i,definition:s})}}function gx(e,t){return e.startsWith("=")?function(e,t){return function(e,t,o){if(t.formulaArgSeparator===o.formulaArgSeparator&&t.decimalSeparator===o.decimalSeparator)return e;const i=xu(e,t);let s="";for(const e of i)"NUMBER"===e.type?s+=e.value.replace(t.decimalSeparator,o.decimalSeparator):"ARG_SEPARATOR"===e.type?s+=o.formulaArgSeparator:s+=e.value;return s}(e,t,eo)}(e,t):xg(e,t)}class px extends lx{values;constructor(e,t,o,i){super("COPY",t,o,i),this.values=e.replace(/\r/g,"").split("\n").map((e=>e.split("\t")))}isPasteAllowed(e,t){const o=this.getters.getActiveSheetId(),i=this.getPasteZone(e);return this.getters.doesIntersectMerge(o,i)?2:0}paste(e,t){if("onlyFormat"===t?.pasteOption)return;const o=this.values,i=this.getPasteZone(e),{left:s,top:r}=i,{numberOfCols:n,numberOfRows:a}=fi(i),l=this.getters.getActiveSheetId(),c=this.getters.getLocale();this.addMissingDimensions(n,a,s,r);for(let e=0;e<o.length;e++)for(let t=0;t<o[e].length;t++)this.dispatch("UPDATE_CELL",{row:r+e,col:s+t,content:gx(o[e][t],c),sheetId:l});const h={left:s,top:r,right:s+n-1,bottom:r+a-1};this.selection.selectZone({cell:{col:s,row:r},zone:h},{scrollIntoView:!1})}getClipboardContent(){return{[cs.PlainText]:this.values.map((e=>e.join("\t"))).join("\n")}}getPasteZone(e){const t=this.values.length,o=et(this.values.map((e=>e.length))),{left:i,top:s}=e[0];return{top:s,left:i,bottom:s+t-1,right:i+o-1}}}function mx(e){if("REFERENCE"!==e.type)return e;const{xc:t,sheetName:o}=Jo(e.value),[i,s]=t.split(":"),r=o?`${we(o)}!`:"",n=fx(i),a=s?`:${fx(s)}`:"";return{...e,value:r+n+a}}function fx(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=bx(e,"colrow");break;case"colrow":e=bx(e,"row");break;case"row":e=bx(e,"col");break;case"col":e=bx(e,"none")}return e}function bx(e,t){let o;switch(e=e.replace(/\$/g,""),t){case"col":return"$"+e;case"row":return o=e.search(/[0-9]/),e.slice(0,o)+"$"+e.slice(o);case"colrow":return o=e.search(/[0-9]/),-1===o||0===o?"$"+e:"$"+(e=e.slice(0,o)+"$"+e.slice(o));case"none":return e}}const vx=r("The cell you are trying to edit has been deleted.");const Sx=[{name:r("Sum"),types:[ls.number],compute:(e,t)=>Ia.compute.bind({locale:t})([e])},{name:r("Avg"),types:[ls.number],compute:(e,t)=>Pa.compute.bind({locale:t})([e])},{name:r("Min"),types:[ls.number],compute:(e,t)=>Ja.compute.bind({locale:t})([e])},{name:r("Max"),types:[ls.number],compute:(e,t)=>ja.compute.bind({locale:t})([e])},{name:r("Count"),types:[ls.number,ls.text,ls.boolean,ls.error],compute:(e,t)=>Wa.compute.bind({locale:t})([e])},{name:r("Count Numbers"),types:[ls.number,ls.text,ls.boolean,ls.error],compute:(e,t)=>$a.compute.bind({locale:t})([e])}];class Cx{getters;sheetId;boundaries;top;bottom;left;right;offsetX;offsetY;offsetScrollbarX;offsetScrollbarY;canScrollVertically;canScrollHorizontally;viewportWidth;viewportHeight;offsetCorrectionX;offsetCorrectionY;constructor(e,t,o,i,s,r){this.getters=e,this.sheetId=t,this.boundaries=o,this.viewportWidth=i.width,this.viewportHeight=i.height,this.offsetScrollbarX=r.x,this.offsetScrollbarY=r.y,this.canScrollVertically=s.canScrollVertically,this.canScrollHorizontally=s.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:o,size:i}=this.getters.getColDimensions(this.sheetId,e),{end:s,size:r}=this.getters.getRowDimensions(this.sheetId,t),n=this.searchHeaderIndex("COL",o-this.viewportWidth,0),a=this.getters.getColSize(this.sheetId,n),l=this.searchHeaderIndex("ROW",s-this.viewportHeight,0),c=this.getters.getRowSize(this.sheetId,l);let h=o-this.offsetCorrectionX;this.canScrollHorizontally&&(h+=Math.max(L,Math.min(a,this.viewportWidth-i)),h=Math.max(h,this.viewportWidth));let d=s-this.offsetCorrectionY;return this.canScrollVertically&&(d+=Math.max(P+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 o=this.getters.getMainCellPosition({sheetId:t,...e}),{col:i,row:s}=this.getters.getNextVisibleCellPosition(o);ui(i,this.boundaries.top,this.boundaries)&&this.adjustPositionX(i),ui(this.boundaries.left,s,this.boundaries)&&this.adjustPositionY(s)}adjustPositionX(e){const t=this.sheetId,{end:o}=this.getters.getColDimensions(t,e),i=this.getters.getNumberCols(t);if(this.offsetX+this.offsetCorrectionX+this.viewportWidth<o){let o=e;for(;this.getters.isColHidden(t,o)&&e<i;)o++;const s=this.getters.getColDimensions(t,o).end,r=this.searchHeaderIndex("COL",s-this.viewportWidth-this.offsetCorrectionX,this.boundaries.left,!0);this.offsetX=this.getters.getColDimensions(t,r).end-this.offsetCorrectionX,this.offsetScrollbarX=this.offsetX,this.adjustViewportZoneX()}else if(this.left>e){let o=e;for(;this.getters.isColHidden(t,o)&&e>0;)o--;this.offsetX=this.getters.getColDimensions(t,o).start-this.offsetCorrectionX,this.offsetScrollbarX=this.offsetX,this.adjustViewportZoneX()}}adjustPositionY(e){const t=this.sheetId,{end:o}=this.getters.getRowDimensions(t,e),i=this.getters.getNumberRows(t);if(this.offsetY+this.viewportHeight+this.offsetCorrectionY<o){let o=e;for(;this.getters.isRowHidden(t,o)&&e<i;)o++;const s=this.getters.getRowDimensions(t,o).end,r=this.searchHeaderIndex("ROW",s-this.viewportHeight-this.offsetCorrectionY,this.boundaries.top,!0);this.offsetY=this.getters.getRowDimensions(t,r).end-this.offsetCorrectionY,this.offsetScrollbarY=this.offsetY,this.adjustViewportZoneY()}else if(this.top>e){let o=e;for(;this.getters.isRowHidden(t,o)&&e>0;)o--;this.offsetY=this.getters.getRowDimensions(t,o).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=ci(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,o=0,i=!1){let s=0;const r=this.sheetId,n=this.getters.getNumberHeaders(r,e);for(let a=o;a<=n-1;a++){const o=i||"COL"!==e?a<this.top&&a>this.bottom:a<this.left&&a>this.right;if(!this.getters.isHeaderHidden(r,e,a)&&!o&&(s+="COL"===e?this.getters.getColSize(r,a):this.getters.getRowSize(r,a),s>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}}const Ex=(new Ji).add("settings",class extends QE{static getters=["getLocale"];locale=eo;allowDispatch(e){return"UPDATE_LOCALE"===e.type?fg(e.locale)?0:96:0}handle(e){if("UPDATE_LOCALE"===e.type)this.history.update("locale",e.locale)}getLocale(){return this.locale}import(e){this.locale=e.settings?.locale??eo}export(e){e.settings={locale:this.locale}}}).add("sheet",class extends QE{static getters=["getSheetName","tryGetSheetName","getSheet","tryGetSheet","getSheetIdByName","getSheetIds","getVisibleSheetIds","isSheetVisible","getEvaluationSheets","doesHeaderExist","getCell","getCellPosition","getColsZone","getRowCells","getRowsZone","getNumberCols","getNumberRows","getNumberHeaders","getGridLinesVisibility","getNextSheetName","getSheetSize","getSheetZone","getPaneDivisions","checkZonesExistInSheet","getCommandZones","getUnboundedZone","checkElementsIncludeAllNonFrozenHeaders"];sheetIdsMapName={};orderedSheetIds=[];sheets={};cellPosition={};allowDispatch(e){const t=this.chainValidations(this.checkSheetExists,this.checkZonesAreInSheet)(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":try{const t=this.orderedSheetIds.findIndex((t=>t===e.sheetId));return this.findIndexOfTargetSheet(t,e.delta),0}catch(e){return 15}case"RENAME_SHEET":return this.isRenameAllowed(e);case"DELETE_SHEET":return this.orderedSheetIds.length>1?0:9;case"ADD_COLUMNS_ROWS":const t="COL"===e.dimension?this.getNumberCols(e.sheetId):this.getNumberRows(e.sheetId);return e.base<0||e.base>=t?89:e.quantity<=0?90:0;case"REMOVE_COLUMNS_ROWS":{const t="COL"===e.dimension?this.getNumberCols(e.sheetId):this.getNumberRows(e.sheetId);return tt(e.elements)<0||et(e.elements)>t?89: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.delta);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){for(let t of e.sheets)this.sheetIdsMapName[t.name]=t.id;for(let t of e.sheets){const e=t.name||s("Sheet")+(Object.keys(this.sheets).length+1),{colNumber:o,rowNumber:i}=this.getImportedSheetSize(t),r={id:t.id,name:e,numberOfCols:o,rows:Mi(i),areGridLinesVisible:void 0===t.areGridLinesVisible||t.areGridLinesVisible,isVisible:t.isVisible,panes:{xSplit:t.panes?.xSplit||0,ySplit:t.panes?.ySplit||0}};this.orderedSheetIds.push(r.id),this.sheets[r.id]=r}}exportSheets(e){e.sheets=this.orderedSheetIds.filter(ke).map((e=>{const t=this.sheets[e],o={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)&&(o.panes=t.panes),o}))}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}tryGetSheetName(e){return this.tryGetSheet(e)?.name}getSheetIdByName(e){if(e){const t=Ee(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,o){return"COL"===t?o>=0&&o<this.getNumberCols(e):o>=0&&o<this.getNumberRows(e)}getRow(e,t){const o=this.getSheet(e).rows[t];if(!o)throw new Error(`Row ${o} not found.`);return o}getCell({sheetId:e,col:t,row:o}){const i=this.tryGetSheet(e)?.rows[o]?.cells[t];if(void 0!==i)return this.getters.getCellById(i)}getColsZone(e,t,o){return{top:0,bottom:this.getNumberRows(e)-1,left:t,right:o}}getRowCells(e,t){return Object.values(this.getSheet(e).rows[t]?.cells).filter(ke)}getRowsZone(e,t,o){return{top:t,bottom:o,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 o=this.orderedSheetIds.map(this.getSheetName.bind(this));let i=`${e}${t}`;for(;o.includes(i);)i=`${e}${t}`,t++;return i}getSheetSize(e){return{numberOfRows:this.getNumberRows(e),numberOfCols:this.getNumberCols(e)}}getSheetZone(e){return{top:0,left:0,bottom:this.getNumberRows(e)-1,right:this.getNumberCols(e)-1}}getUnboundedZone(e,t){const o=0===t.left&&t.right===this.getNumberCols(e)-1,i=0===t.top&&t.bottom===this.getNumberRows(e)-1;return{...t,bottom:i?void 0:t.bottom,right:o&&!i?void 0:t.right}}getPaneDivisions(e){return this.getSheet(e).panes}setPaneDivisions(e,t,o){const i={...this.getPaneDivisions(e)};"COL"===o?i.xSplit=t:"ROW"===o&&(i.ySplit=t),this.history.update("sheets",e,"panes",i)}checkElementsIncludeAllNonFrozenHeaders(e,t,o){const i=this.getters.getPaneDivisions(e),s="ROW"===t?i.ySplit:i.xSplit,r=this.getters.getNumberHeaders(e,t);if(!s)return!1;return Ge(o,ye(s,r))}getCommandZones(e){const t=[];return"zone"in e&&t.push(e.zone),"target"in e&&t.push(...e.target),"ranges"in e&&t.push(...e.ranges.map((e=>this.getters.getRangeFromRangeData(e).zone))),"col"in e&&"row"in e&&t.push({top:e.row,left:e.col,bottom:e.row,right:e.col}),t}checkZonesExistInSheet(e,t){if(!t.every(oi))return 26;if(t.length){const o=this.getSheetZone(e);return t.every((e=>gi(e,o)))?0:19}return 0}updateCellPosition(e){const{sheetId:t,cellId:o,col:i,row:s}=e;o?this.setNewPosition(o,t,i,s):this.clearPosition(t,i,s)}setNewPosition(e,t,o,i){const s=this.cellPosition[e];s&&this.clearPosition(t,s.col,s.row),this.history.update("cellPosition",e,{row:i,col:o,sheetId:t}),this.history.update("sheets",t,"rows",i,"cells",o,e)}clearPosition(e,t,o){const i=this.sheets[e]?.rows[o].cells[t];i&&(this.history.update("cellPosition",i,void 0),this.history.update("sheets",e,"rows",o,"cells",t,void 0))}setGridLinesVisibility(e,t){this.history.update("sheets",e,"areGridLinesVisible",t)}clearZones(e,t){for(let o of t)for(let t=o.left;t<=o.right;t++)for(let i=o.top;i<=o.bottom;i++){this.sheets[e].rows[i].cells[t]&&this.dispatch("UPDATE_CELL",{sheetId:e,content:"",col:t,row:i})}}createSheet(e,t,o,i,s){const r={id:e,name:t,numberOfCols:o,rows:Mi(i),areGridLinesVisible:!0,isVisible:!0,panes:{xSplit:0,ySplit:0}},n=this.orderedSheetIds.slice();n.splice(s,0,r.id);const a=this.sheets;return this.history.update("orderedSheetIds",n),this.history.update("sheets",Object.assign({},a,{[r.id]:r})),r}moveSheet(e,t){const o=this.orderedSheetIds.slice(),i=o.findIndex((t=>t===e)),s=o.splice(i,1);let r=this.findIndexOfTargetSheet(i,t);o.splice(r,0,s[0]),this.history.update("orderedSheetIds",o)}findIndexOfTargetSheet(e,t){for(;0!=t&&0<=e&&e<=this.orderedSheetIds.length;)t>0?(e++,this.isSheetVisible(this.orderedSheetIds[e])&&t--):t<0&&(e--,this.isSheetVisible(this.orderedSheetIds[e])&&t++);if(0===t)return e;throw new Error(r("There is not enough visible sheets"))}checkSheetName(e){const t=this.getters.tryGetSheetName(e.sheetId);if(void 0!==t&&e.name===t)return 11;const{orderedSheetIds:o,sheets:i}=this,s=e.name&&e.name.trim().toLowerCase();return o.find((t=>i[t]?.name.toLowerCase()===s&&t!==e.sheetId))?12:he.test(s)?14:0}checkSheetPosition(e){const{orderedSheetIds:t}=this;return e.position>t.length||e.position<0?16:0}checkRowFreezeQuantity(e){return e.quantity>=1&&e.quantity<this.getNumberRows(e.sheetId)?0:77}checkColFreezeQuantity(e){return e.quantity>=1&&e.quantity<this.getNumberCols(e.sheetId)?0:77}checkRowFreezeOverlapMerge(e){const t=this.getters.getMerges(e.sheetId);for(let o of t)if(o.top<e.quantity&&e.quantity<=o.bottom)return 68;return 0}checkColFreezeOverlapMerge(e){const t=this.getters.getMerges(e.sheetId);for(let o of t)if(o.left<e.quantity&&e.quantity<=o.right)return 68;return 0}isRenameAllowed(e){return e.name&&e.name.trim().toLowerCase()?this.checkSheetName(e):10}renameSheet(e,t){const o=e.name;this.history.update("sheets",e.id,"name",t.trim());const i=Object.assign({},this.sheetIdsMapName);delete i[o],i[t]=e.id,this.history.update("sheetIdsMapName",i)}hideSheet(e){this.history.update("sheets",e,"isVisible",!1)}showSheet(e){this.history.update("sheets",e,"isVisible",!0)}duplicateSheet(e,t){const o=this.getSheet(e),i=this.getDuplicateSheetName(o.name),s=Ce(o);s.id=t,s.name=i;for(let e=0;e<=s.numberOfCols;e++)for(let t=0;t<=s.rows.length;t++)s.rows[t]&&(s.rows[t].cells[e]=void 0);const r=this.orderedSheetIds.slice(),n=r.indexOf(e);r.splice(n+1,0,s.id),this.history.update("orderedSheetIds",r),this.history.update("sheets",Object.assign({},this.sheets,{[s.id]:s}));for(const t of Object.values(this.getters.getCells(e))){const{col:e,row:o}=this.getCellPosition(t.id);this.dispatch("UPDATE_CELL",{sheetId:s.id,col:e,row:o,content:t.content,format:t.format,style:t.style})}const a=Object.assign({},this.sheetIdsMapName);a[s.name]=s.id,this.history.update("sheetIdsMapName",a)}getDuplicateSheetName(e){let t=1;const o=this.orderedSheetIds.map(this.getSheetName.bind(this)),i=r("Copy of %s",e);let s=i.toString();for(;o.includes(s);)s=`${i} (${t})`,t++;return s}deleteSheet(e){const t=e.name,o=Object.assign({},this.sheets);delete o[e.id],this.history.update("sheets",o);const i=this.orderedSheetIds.slice(),s=i.indexOf(e.id);i.splice(s,1),this.history.update("orderedSheetIds",i);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 o of t)this.moveCellOnColumnsDeletion(e,o);const o=this.sheets[e.id].numberOfCols;this.history.update("sheets",e.id,"numberOfCols",o-t.length);const i=t.filter((t=>t<e.panes.xSplit)).length;i&&this.setPaneDivisions(e.id,e.panes.xSplit-i,"COL")}removeRows(e,t){t.sort(((e,t)=>t-e));for(let o of Ie(t)){const t=o[o.length-1],i=o[0];this.moveCellOnRowsDeletion(e,t,i),this.updateRowsStructureOnDeletion(e,t,i)}const o=t.filter((t=>t<e.panes.ySplit)).length;o&&this.setPaneDivisions(e.id,e.panes.ySplit-o,"ROW")}addColumns(e,t,o,i){const s="before"===o?t:t+1;this.moveCellsOnAddition(e,s,i,"columns");const r=this.sheets[e.id].numberOfCols;this.history.update("sheets",e.id,"numberOfCols",r+i),s<e.panes.xSplit&&this.setPaneDivisions(e.id,e.panes.xSplit+i,"COL")}addRows(e,t,o,i){const s="before"===o?t:t+1;this.addEmptyRows(e,i),this.moveCellsOnAddition(e,s,i,"rows"),s<e.panes.ySplit&&this.setPaneDivisions(e.id,e.panes.ySplit+i,"ROW")}moveCellOnColumnsDeletion(e,t){for(let o=0;o<e.rows.length;o++){const i=e.rows[o];for(let s in i.cells){const r=Number(s),n=i.cells[s];n&&(r===t&&this.dispatch("CLEAR_CELL",{sheetId:e.id,col:r,row:o}),r>t&&this.dispatch("UPDATE_CELL_POSITION",{sheetId:e.id,cellId:n,col:r-1,row:o}))}}}moveCellsOnAddition(e,t,o,i){const s=[];for(let r=0;r<e.rows.length;r++){const n=e.rows[r];if("rows"!==i||r>=t)for(let a in n.cells){const l=Number(a),c=n.cells[a];c&&("rows"===i||l>=t)&&s.push({type:"UPDATE_CELL_POSITION",sheetId:e.id,cellId:c,col:l+("columns"===i?o:0),row:r+("rows"===i?o:0)})}}for(let e of s.reverse())this.dispatch(e.type,e)}moveCellOnRowsDeletion(e,t,o){const i=o-t+1;for(let s=0;s<e.rows.length;s++){const r=e.rows[s];if(s>=t&&s<=o)for(let t in r.cells){const o=Number(t);r.cells[t]&&this.dispatch("CLEAR_CELL",{sheetId:e.id,col:o,row:s})}if(s>o)for(let t in r.cells){const o=Number(t),n=r.cells[t];n&&this.dispatch("UPDATE_CELL_POSITION",{sheetId:e.id,cellId:n,col:o,row:s-i})}}}updateRowsStructureOnDeletion(e,t,o){const i=[],s=e.rows.map((e=>e.cells)).reverse();for(let r in e.rows){const e=Number(r);e>=t&&e<=o||i.push({cells:s.pop()})}this.history.update("sheets",e.id,"rows",i)}addEmptyRows(e,t){const o=e.rows.slice();for(let e=0;e<t;e++)o.push({cells:{}});this.history.update("sheets",e.id,"rows",o)}getImportedSheetSize(e){const t=Object.keys(e.cells).map(wt);let o=e.rowNumber,i=e.colNumber;for(let{col:e,row:s}of t)o=Math.max(o,s+1),i=Math.max(i,e+1);return{rowNumber:o,colNumber:i}}checkSheetExists(e){return"CREATE_SHEET"!==e.type&&"sheetId"in e&&void 0===this.sheets[e.sheetId]?28:"CREATE_SHEET"===e.type&&void 0!==this.sheets[e.sheetId]?13:0}checkZonesAreInSheet(e){return"sheetId"in e?this.checkZonesExistInSheet(e.sheetId,this.getCommandZones(e)):0}}).add("header visibility",class extends QE{static getters=["checkElementsIncludeAllVisibleHeaders","getHiddenColsGroups","getHiddenRowsGroups","isRowHiddenByUser","isColHiddenByUser"];hiddenHeaders={};allowDispatch(e){switch(e.type){case"HIDE_COLUMNS_ROWS":{if(!this.getters.tryGetSheet(e.sheetId))return 28;const t="COL"===e.dimension?this.getHiddenColsGroups(e.sheetId):this.getHiddenRowsGroups(e.sheetId),o="COL"===e.dimension?this.getters.getNumberCols(e.sheetId):this.getters.getNumberRows(e.sheetId);return new Set((t||[]).flat().concat(e.elements)).size>=o?69:tt(e.elements)<0||et(e.elements)>o?89:0}case"REMOVE_COLUMNS_ROWS":return this.getters.tryGetSheet(e.sheetId)?this.checkElementsIncludeAllVisibleHeaders(e.sheetId,e.dimension,e.elements)?8:0:28}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,Ce(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 o of[...e.elements].sort(((e,t)=>t-e)))t.splice(o,1);this.history.update("hiddenHeaders",e.sheetId,e.dimension,t);break}case"ADD_COLUMNS_ROWS":{const t=[...this.hiddenHeaders[e.sheetId][e.dimension]],o=$e(e.position,e.base);t.splice(o,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,o){return Ge(o,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=[[]],o=this.hiddenHeaders[e].COL;for(let e=0;e<o.length;e++){o[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=[[]],o=this.hiddenHeaders[e].ROW;for(let e=0;e<o.length;e++){o[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 ye(0,this.hiddenHeaders[e][t].length).filter((o=>!this.hiddenHeaders[e][t][o]))}import(e){for(let t of e.sheets){this.hiddenHeaders[t.id]={COL:[],ROW:[]};for(let e=0;e<t.rowNumber;e++)this.hiddenHeaders[t.id].ROW[e]=Boolean(t.rows[e]?.isHidden);for(let e=0;e<t.colNumber;e++)this.hiddenHeaders[t.id].COL[e]=Boolean(t.cols[e]?.isHidden)}}exportForExcel(e){this.exportData(e,!0)}export(e){this.exportData(e)}exportData(e,t=!1){for(let o of e.sheets){void 0===o.rows&&(o.rows={});for(let e=0;e<this.getters.getNumberRows(o.id);e++)(t||this.hiddenHeaders[o.id].ROW[e])&&(void 0===o.rows[e]&&(o.rows[e]={}),o.rows[e].isHidden=this.hiddenHeaders[o.id].ROW[e]);void 0===o.cols&&(o.cols={});for(let e=0;e<this.getters.getNumberCols(o.id);e++)(t||this.hiddenHeaders[o.id].COL[e])&&(void 0===o.cols[e]&&(o.cols[e]={}),o.cols[e].isHidden=this.hiddenHeaders[o.id].COL[e])}}}).add("filters",class extends QE{static getters=["doesZonesContainFilter","getFilter","getFilters","getFilterTable","getFilterTables","getFilterTablesInZone","getFilterId","getFilterHeaders","isFilterHeader"];tables={};allowDispatch(e){switch(e.type){case"CREATE_FILTER_TABLE":if(!Ii(...e.target))return 84;const t=li(...e.target),o=()=>this.getFilterTables(e.sheetId).some((e=>di(e.zone,t)))?81:0,i=()=>{const o=this.getters.getMergesInZone(e.sheetId,t);for(let e of o)if(di(t,e))return 83;return 0};return this.checkValidations(e,o,i);case"ADD_MERGE":for(let t of e.target)for(let o of this.getFilterTables(e.sheetId))if(di(o.zone,t))return 83}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 o={};for(const t of Object.values(this.tables[e.sheetId]||{}))if(t){const e=Ce(t);o[e.id]=e}this.history.update("tables",e.sheetIdTo,o);break;case"ADD_COLUMNS_ROWS":this.onAddColumnsRows(e);break;case"REMOVE_COLUMNS_ROWS":this.onDeleteColumnsRows(e);break;case"CREATE_FILTER_TABLE":{const t=li(...e.target),o=this.createFilterTable(t);this.history.update("tables",e.sheetId,o.id,o);break}case"REMOVE_FILTER_TABLE":{const t={};for(const o of this.getFilterTables(e.sheetId))e.target.every((e=>!ci(e,o.zone)))&&(t[o.id]=o);this.history.update("tables",e.sheetId,t);break}case"UPDATE_CELL":{const t=e.sheetId;for(let o of this.getFilterTables(t))this.canUpdateCellCmdExtendTable(e,o)&&this.extendTableDown(t,o);break}}}getFilters(e){return this.getFilterTables(e).map((e=>e.filters)).flat()}getFilterTables(e){return this.tables[e]?Object.values(this.tables[e]).filter(ke):[]}getFilter(e){return this.getFilterTable(e)?.filters.find((t=>t.col===e.col))}getFilterId(e){return this.getFilter(e)?.id}getFilterTable({sheetId:e,col:t,row:o}){return this.getFilterTables(e).find((e=>ui(t,o,e.zone)))}getFilterTablesInZone(e,t){return this.getFilterTables(e).filter((e=>gi(e.zone,t)))}doesZonesContainFilter(e,t){for(const o of t)for(const t of this.getFilterTables(e))if(ci(o,t.zone))return!0;return!1}getFilterHeaders(e){const t=[];for(let o of this.getFilterTables(e)){const e=o.zone,i=e.top;for(let o=e.left;o<=e.right;o++)t.push({col:o,row:i})}return t}isFilterHeader({sheetId:e,col:t,row:o}){return this.getFilterHeaders(e).some((e=>e.col===t&&e.row===o))}onAddColumnsRows(e){for(const t of this.getFilterTables(e.sheetId)){const o=si(t.zone,"COL"===e.dimension?"left":"top",e.base,e.position,e.quantity),i=[];for(const o of t.filters){const t=si(o.zoneWithHeaders,"COL"===e.dimension?"left":"top",e.base,e.position,e.quantity);i.push(new ow(o.id,t))}if(i.length<fi(o).numberOfCols){for(let e=o.left;e<=o.right;e++)i.find((t=>t.col===e))||i.push(new ow(this.uuidGenerator.uuidv4(),{...o,left:e,right:e}));i.sort(((e,t)=>e.col-t.col))}this.history.update("tables",e.sheetId,t.id,"zone",o),this.history.update("tables",e.sheetId,t.id,"filters",i)}}onDeleteColumnsRows(e){for(const t of this.getFilterTables(e.sheetId)){if("ROW"===e.dimension&&e.elements.includes(t.zone.top)){const o={...this.tables[e.sheetId]};delete o[t.id],this.history.update("tables",e.sheetId,o);continue}const o=ai(t.zone,"COL"===e.dimension?"left":"top",e.elements);if(o){if(ii(o)!==ii(t.zone)){const i=[];for(const o of t.filters){const t=ai(o.zoneWithHeaders,"COL"===e.dimension?"left":"top",e.elements);t&&i.push(new ow(o.id,t))}this.history.update("tables",e.sheetId,t.id,"zone",o),this.history.update("tables",e.sheetId,t.id,"filters",i)}}else{const o={...this.tables[e.sheetId]};delete o[t.id],this.history.update("tables",e.sheetId,o)}}}createFilterTable(e){return new tw(e)}extendTableDown(e,t){const o={...t.zone,bottom:t.zone.bottom+1};this.history.update("tables",e,t.id,"zone",o);for(let o=0;o<t.filters.length;o++){const i=t.filters[o],s={...i.zoneWithHeaders,bottom:i.zoneWithHeaders.bottom+1};this.history.update("tables",e,t.id,"filters",o,"zoneWithHeaders",s)}}canUpdateCellCmdExtendTable({content:e,sheetId:t,col:o,row:i},s){if(!e)return;const r=s.zone;if(!(r.bottom+1===i&&o>=r.left&&o<=r.right))return!1;for(const e of ye(r.left,r.right+1)){const o={sheetId:t,col:e,row:i},s=this.getters.getCell(o)?.content;if(s)return!1;if(this.getters.getFilter(o))return!1;if(this.getters.isInMerge(o))return!1}return!0}import(e){for(const t of e.sheets)for(const e of t.filterTables||[]){const o=this.createFilterTable(ti(e.range));this.history.update("tables",t.id,o.id,o)}}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)}}).add("cell",class extends QE{static getters=["zoneToXC","getCells","getFormulaCellContent","getCellStyle","buildFormulaContent","getCellById"];nextId=1;cells={};adaptRanges(e,t){for(const o of Object.keys(this.cells))for(const i of Object.values(this.cells[o]||{}))if(i.isFormula)for(const s of i.dependencies)if(!t||s.sheetId===t){const t=e(s);"NONE"!==t.changeType&&this.history.update("cells",o,i.id,"dependencies",i.dependencies.indexOf(s),t.range)}}allowDispatch(e){switch(e.type){case"UPDATE_CELL":return this.checkValidations(e,this.checkCellOutOfSheet,this.checkUselessUpdateCell);case"CLEAR_CELL":return this.checkValidations(e,this.checkCellOutOfSheet,this.checkUselessClearCell);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,o){for(let i of t)for(let t=i.top;t<=i.bottom;t++)for(let s=i.left;s<=i.right;s++)this.dispatch("UPDATE_CELL",{sheetId:e,col:s,row:t,format:o})}clearFormatting(e,t){for(let o of t)for(let t=o.left;t<=o.right;t++)for(let i=o.top;i<=o.bottom;i++)this.dispatch("UPDATE_CELL",{sheetId:e,col:t,row:i,style:null,format:""})}handleAddColumnsRows(e,t){let o,i;"before"===e.position?(o=ye(e.base,e.base+e.quantity),i=e.base+e.quantity):(o=ye(e.base+1,e.base+e.quantity+1),i=e.base),t(e.sheetId,i,o)}import(e){for(let t of e.sheets)for(let o in t.cells){const i=t.cells[o],{col:s,row:r}=wt(o);if(i?.content||i?.format||i?.style){const o=this.importCell(t.id,i,e.styles,e.formats);this.history.update("cells",t.id,o.id,o),this.dispatch("UPDATE_CELL_POSITION",{cellId:o.id,col:s,row:r,sheetId:t.id})}}}export(e){const t={},o={};for(let i of e.sheets){const e={},s=Object.keys(this.cells[i.id]||{}).map((e=>this.getters.getCellPosition(e))).sort(((e,t)=>e.col===t.col?e.row-t.row:e.col-t.col));for(const i of s){const s=this.getters.getCell(i);e[xt(i.col,i.row)]={style:s.style?Ve(s.style,t):void 0,format:s.format?Ve(s.format,o):void 0,content:s.content||void 0}}i.cells=e}e.styles=t,e.formats=o}importCell(e,t,o,i){const s=t.style&&o[t.style]||void 0,r=t.format&&i[t.format]||void 0,n=this.getNextUid();return this.createCell(n,t?.content||"",r,s,e)}exportForExcel(e){this.export(e)}getCells(e){return this.cells[e]||{}}getCellById(e){const t=this.getters.getCellPosition(e);return this.cells[t.sheetId][e]}buildFormulaContent(e,t,o,i=!1){const s=o||t.dependencies;let r=0;return Be(t.compiledFormula.tokens.map((t=>{if("REFERENCE"===t.type){const t=s[r++];return this.getters.getRangeString(t,e,i)}return t.value})))}getFormulaCellContent(e,t){return this.buildFormulaContent(e,t)}getCellStyle(e){return this.getters.getCell(e)?.style||{}}zoneToXC(e,t,o=[{colFixed:!1,rowFixed:!1}]){const i=xt((t=this.getters.expandZone(e,t)).left,t.top,o[0]),s=xt(t.right,t.bottom,o.length>1?o[1]:o[0]),r=this.getters.getMainCellPosition({sheetId:e,col:t.left,row:t.top}),n=this.getters.getMainCellPosition({sheetId:e,col:t.right,row:t.bottom}),a=r.col===n.col&&r.row===n.row;return i==s||a?i:i+":"+s}setStyle(e,t,o){for(let i of t)for(let t=i.left;t<=i.right;t++)for(let s=i.top;s<=i.bottom;s++){const i=this.getters.getCell({sheetId:e,col:t,row:s});this.dispatch("UPDATE_CELL",{sheetId:e,col:t,row:s,style:o?{...i?.style,...o}:void 0})}}copyColumnStyle(e,t,o){for(let i=0;i<this.getters.getNumberRows(e);i++){const s=this.getFormat(e,t,i);if(s.style||s.format)for(let t of o)this.dispatch("UPDATE_CELL",{sheetId:e,col:t,row:i,...s})}}copyRowStyle(e,t,o){for(let i=0;i<this.getters.getNumberCols(e);i++){const s=this.getFormat(e,i,t);if(s.style||s.format)for(let t of o)this.dispatch("UPDATE_CELL",{sheetId:e,col:i,row:t,...s})}}getFormat(e,t,o){const i={},s=this.getters.getMainCellPosition({sheetId:e,col:t,row:o}),r=this.getters.getCell(s);return r&&(r.style&&(i.style=r.style),r.format&&(i.format=r.format)),i}getNextUid(){const e=this.nextId.toString();return this.history.update("nextId",this.nextId+1),e}updateCell(e,t,o,i){const s=this.getters.getCell({sheetId:e,col:t,row:o}),r="content"in i||"formula"in i,n=r?Xe(i?.content):s?.content||"";let a;a=void 0!==i.style?i.style||void 0:s?s.style:void 0;const l="format"in i?i.format:s&&s.format;if((r&&!n&&!i.formula||!r&&(!s||""===s.content))&&!a&&!l)return void(s&&(this.history.update("cells",e,s.id,void 0),this.dispatch("UPDATE_CELL_POSITION",{cellId:void 0,col:t,row:o,sheetId:e})));const c=s?.id||this.getNextUid(),h=this.createCell(c,n,l,a,e);this.history.update("cells",e,h.id,h),this.dispatch("UPDATE_CELL_POSITION",{cellId:h.id,col:t,row:o,sheetId:e})}createCell(e,t,o,i,s){if(!t.startsWith("="))return this.createLiteralCell(e,t,o,i);try{return this.createFormulaCell(e,t,o,i,s)}catch(s){return this.createErrorFormula(e,t,o,i,s)}}createLiteralCell(e,t,o,i){const s=this.getters.getLocale();return{id:e,content:ir(t,s).toString(),style:i,format:o||Mo(t,s)||No(t),isFormula:!1}}createFormulaCell(e,t,o,i,s){const r=hg(t);return r.dependencies.length?this.createFormulaCellWithDependencies(e,r,o,i,s):{id:e,content:t,style:i,format:o,isFormula:!0,compiledFormula:r,dependencies:[]}}createFormulaCellWithDependencies(e,t,o,i,s){const r=t.dependencies.map((e=>this.getters.getRangeFromSheetXC(s,e)));return new JE(e,t,o,i,r,s,this.buildFormulaContent.bind(this))}createErrorFormula(e,t,o,i,s){return{id:e,content:t,style:i,format:o,isFormula:!0,compiledFormula:{dependencies:[],tokens:xu(t),execute:function(){throw s}},dependencies:[]}}checkCellOutOfSheet(e){const{sheetId:t,col:o,row:i}=e;if(!this.getters.tryGetSheet(t))return 28;return ui(o,i,this.getters.getSheetZone(t))?0:19}checkUselessClearCell(e){const t=this.getters.getCell(e);return t&&(t.content||t.style||t.format)?0:98}checkUselessUpdateCell(e){const t=this.getters.getCell(e),o="style"in e,i="format"in e;return("content"in e||"formula"in e)&&t?.content!==e.content||o&&!We(t?.style,e.style)||i&&t?.format!==e.format?0:98}}).add("merge",class extends QE{static getters=["isInMerge","isInSameMerge","isMergeHidden","getMainCellPosition","getBottomLeftCell","expandZone","doesIntersectMerge","doesColumnsHaveCommonMerges","doesRowsHaveCommonMerges","getMerges","getMerge","getMergesInZone","isSingleCellOrMerge","getSelectionRangeString"];nextId=1;merges={};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 o of Object.values(t).filter(ke))this.addMerge(e.sheetIdTo,o.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 o=t?[t]:Object.keys(this.merges);for(const t of o)this.applyRangeChangeOnSheet(t,e)}getMerges(e){return Object.keys(this.merges[e]||{}).map((t=>this.getMergeById(e,parseInt(t,10)))).filter(ke)}getMerge({sheetId:e,col:t,row:o}){const i=this.mergeCellMap[e],s=i?t in i&&i[t]?.[o]:void 0;return s?this.getMergeById(e,s):void 0}getMergesInZone(e,t){const o=this.mergeCellMap[e];if(!o)return[];const i=new Set;for(const{col:e,row:s}of vi(t)){const t=o[e]?.[s];t&&i.add(t)}return Array.from(i).map((t=>this.getMergeById(e,t))).filter(ke)}getSelectionRangeString(e,t){const o=Ri.fromRange(e,this.getters),i=this.getters.expandZone(o.sheetId,o.zone),s=o.clone({zone:{...i,bottom:o.isFullCol?void 0:i.bottom,right:o.isFullRow?void 0:i.right}}),r=this.getters.getRangeString(s,t);if(this.isSingleCellOrMerge(o.sheetId,o.zone)){const{sheetName:e,xc:t}=Jo(r);return`${void 0!==e?we(e)+"!":""}${t.split(":")[0]}`}return r}doesIntersectMerge(e,t){return vi(t).some((({col:t,row:o})=>void 0!==this.getMerge({sheetId:e,col:t,row:o})))}doesColumnsHaveCommonMerges(e,t,o){const i=this.getters.getSheet(e);for(let s=0;s<this.getters.getNumberRows(e);s++)if(this.isInSameMerge(i.id,t,s,o,s))return!0;return!1}doesRowsHaveCommonMerges(e,t,o){const i=this.getters.getSheet(e);for(let s=0;s<=this.getters.getNumberCols(e);s++)if(this.isInSameMerge(i.id,s,t,s,o))return!0;return!1}expandZone(e,t){let{left:o,right:i,top:s,bottom:r}=t,n={left:o,right:i,top:s,bottom:r};for(let t in this.merges[e]){const o=this.getMergeById(e,parseInt(t));o&&di(o,n)&&(n=li(o,n))}return hi(n,t)?n:this.expandZone(e,n)}isInSameMerge(e,t,o,i,s){const r=this.getMerge({sheetId:e,col:t,row:o}),n=this.getMerge({sheetId:e,col:i,row:s});return!(!r||!n)&&hi(r,n)}isInMerge({sheetId:e,col:t,row:o}){const i=this.mergeCellMap[e];return!!i&&(t in i&&Boolean(i[t]?.[o]))}getMainCellPosition(e){if(!this.isInMerge(e))return e;const t=this.getMerge(e).topLeft;return{sheetId:e.sheetId,col:t.col,row:t.row}}getBottomLeftCell(e){if(!this.isInMerge(e))return e;const{bottom:t,left:o}=this.getMerge(e);return{sheetId:e.sheetId,col:o,row:t}}isMergeHidden(e,t){const o=this.getters.getHiddenColsGroups(e),i=this.getters.getHiddenRowsGroups(e);for(let e of o)if(t.left>=e[0]&&t.right<=e[e.length-1])return!0;for(let e of i)if(t.top>=e[0]&&t.bottom<=e[e.length-1])return!0;return!1}isSingleCellOrMerge(e,t){const o=this.getMerge({sheetId:e,col:t.left,row:t.top});if(o)return hi(t,o);const{numberOfCols:i,numberOfRows:s}=fi(t);return 1===i&&1===s}isMergeDestructive(e,t){let{left:o,right:i,top:s,bottom:r}=t;i=xe(i,0,this.getters.getNumberCols(e)-1),r=xe(r,0,this.getters.getNumberRows(e)-1);for(let t=s;t<=r;t++)for(let r=o;r<=i;r++)if(r!==o||t!==s){const o=this.getters.getCell({sheetId:e,col:r,row:t});if(o&&""!==o.content)return!0}return!1}getMergeById(e,t){const o=this.merges[e]?.[t];return void 0!==o?sw(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 o of e)if(t!==o&&di(t,o))return 68;return 0}checkFrozenPanes({sheetId:e,target:t}){if(!this.getters.tryGetSheet(e))return 0;const{xSplit:o,ySplit:i}=this.getters.getPaneDivisions(e);for(const e of t)if(e.left<o&&e.right>=o||e.top<i&&e.bottom>=i)return 78;return 0}checkMergedContentUpdate(e){const{col:t,row:o,content:i}=e;if(void 0===i)return 0;const{col:s,row:r}=this.getMainCellPosition(e);return s===t&&r===o?0:4}checkMergeExists(e){const{sheetId:t,target:o}=e;for(const e of o){const{left:o,top:i}=e,s=this.getMerge({sheetId:t,col:o,row:i});if(void 0===s||!hi(e,s))return 5}return 0}addMerge(e,t){let{left:o,right:i,top:s,bottom:r}=t;i=xe(i,0,this.getters.getNumberCols(e)-1),r=xe(r,0,this.getters.getNumberRows(e)-1);if(xt(o,s)===xt(i,r))return;const n=this.getters.getCell({sheetId:e,col:o,row:s});let a=this.nextId++;this.history.update("merges",e,a,this.getters.getRangeFromSheetXC(e,ii({left:o,top:s,right:i,bottom:r})));let l=new Set;for(let t=s;t<=r;t++)for(let r=o;r<=i;r++){r===o&&t===s||this.dispatch("UPDATE_CELL",{sheetId:e,col:r,row:t,style:n?n.style:null,content:""});const i=this.getMerge({sheetId:e,col:r,row:t});i&&l.add(i.id),this.history.update("mergeCellMap",e,r,t,a)}for(let t of l){const{top:o,bottom:i,left:s,right:r}=this.getMergeById(e,t);for(let t=o;t<=i;t++)for(let o=s;o<=r;o++){const i={sheetId:e,col:o,row:t},s=this.getMerge(i);s&&s.id===a||(this.history.update("mergeCellMap",e,o,t,void 0),this.dispatch("CLEAR_CELL",i))}this.history.update("merges",e,t,void 0)}}removeMerge(e,t){const{left:o,top:i,bottom:s,right:r}=t,n=this.getMerge({sheetId:e,col:o,row:i});if(void 0!==n&&hi(t,n)){this.history.update("merges",e,n.id,void 0);for(let t=i;t<=s;t++)for(let i=o;i<=r;i++)this.history.update("mergeCellMap",e,i,t,void 0)}}applyRangeChangeOnSheet(e,t){const o=Object.entries(this.merges[e]||{});for(const[i,s]of o)if(s){const o=s.zone,r=t(s);switch(r.changeType){case"NONE":break;case"REMOVE":this.removeMerge(e,o);break;default:const{numberOfCols:t,numberOfRows:s}=fi(r.range.zone);1===t&&1===s?this.removeMerge(e,o):this.history.update("merges",e,parseInt(i,10),r.range)}}this.history.update("mergeCellMap",e,{});for(const t of this.getMerges(e))for(const{col:o,row:i}of vi(t))this.history.update("mergeCellMap",e,o,i,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 o of t)this.addMerge(e,ti(o))}export(e){for(let t of e.sheets){const e=this.merges[t.id];e&&t.merges.push(...iw(e))}}exportForExcel(e){this.export(e)}}).add("headerSize",class extends QE{static getters=["getUserRowSize","getColSize"];sizes={};handle(e){switch(e.type){case"CREATE_SHEET":this.history.update("sizes",e.sheetId,{COL:[],ROW:[]});break;case"DUPLICATE_SHEET":this.history.update("sizes",e.sheetIdTo,Ce(this.sizes[e.sheetId]));break;case"DELETE_SHEET":const t={...this.sizes};delete t[e.sheetId],this.history.update("sizes",t);break;case"REMOVE_COLUMNS_ROWS":{const t=Je(this.sizes[e.sheetId][e.dimension],e.elements);this.history.update("sizes",e.sheetId,e.dimension,t);break}case"ADD_COLUMNS_ROWS":{let t=[...this.sizes[e.sheetId][e.dimension]];const o=$e(e.position,e.base),i=t[e.base];t.splice(o,0,...Array(e.quantity).fill(i)),this.history.update("sizes",e.sheetId,e.dimension,t);break}case"RESIZE_COLUMNS_ROWS":if("ROW"===e.dimension)for(const t of e.elements)this.history.update("sizes",e.sheetId,e.dimension,t,e.size||void 0);else for(const t of e.elements)this.history.update("sizes",e.sheetId,e.dimension,t,e.size||void 0)}}getColSize(e,t){return Math.round(this.sizes[e]?.COL[t]||L)}getUserRowSize(e,t){const o=this.sizes[e]?.ROW[t];return o?Math.round(o):void 0}import(e){for(let t of e.sheets){const e={COL:Array(t.colNumber).fill(void 0),ROW:Array(t.rowNumber).fill(void 0)};for(let[o,i]of Object.entries(t.rows))i.size&&(e.ROW[o]=i.size);for(let[o,i]of Object.entries(t.cols))i.size&&(e.COL[o]=i.size);this.sizes[t.id]=e}}exportForExcel(e){this.exportData(e,!0)}export(e){this.exportData(e)}exportData(e,t=!1){for(let o of e.sheets){void 0===o.rows&&(o.rows={});for(const e of ye(0,this.getters.getNumberRows(o.id)))(t||this.sizes[o.id].ROW[e])&&(o.rows[e]={...o.rows[e],size:this.getUserRowSize(o.id,e)??P});void 0===o.cols&&(o.cols={});for(let e of ye(0,this.getters.getNumberCols(o.id)))(t||this.sizes[o.id].COL[e])&&(o.cols[e]={...o.cols[e],size:this.getColSize(o.id,e)})}}}).add("borders",class extends QE{static getters=["getCellBorder","getBordersColors"];borders={};allowDispatch(e){return"SET_BORDER"===e.type?this.checkBordersUnchanged(e):0}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 o=t.slice().map((e=>e?.slice().map((e=>({...e})))));this.history.update("borders",e.sheetIdTo,o)}break;case"DELETE_SHEET":const o={...this.borders};delete o[e.sheetId],this.history.update("borders",o);break;case"SET_BORDER":this.setBorder(e.sheetId,e.col,e.row,e.border);break;case"SET_ZONE_BORDERS":if(e.border){const t=e.target.map((t=>this.getters.expandZone(e.sheetId,t)));this.setBorders(e.sheetId,t,e.border.position,""===e.border.color?void 0:{style:e.border.style||K,color:e.border.color||Q})}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,o;"before"===e.position?(this.shiftBordersHorizontally(e.sheetId,e.base,e.quantity,{moveFirstLeftBorder:!0}),t=e.base-1,o=e.base+e.quantity):(this.shiftBordersHorizontally(e.sheetId,e.base+1,e.quantity,{moveFirstLeftBorder:!1}),t=e.base,o=e.base+e.quantity+1),this.ensureColumnBorderContinuity(e.sheetId,t,o)}handleAddRows(e){let t,o;"before"===e.position?(this.shiftBordersVertically(e.sheetId,e.base,e.quantity,{moveFirstTopBorder:!0}),t=e.base-1,o=e.base+e.quantity):(this.shiftBordersVertically(e.sheetId,e.base+1,e.quantity,{moveFirstTopBorder:!1}),t=e.base,o=e.base+e.quantity+1),this.ensureRowBorderContinuity(e.sheetId,t,o)}getCellBorder({sheetId:e,col:t,row:o}){const i={top:this.borders[e]?.[t]?.[o]?.horizontal,bottom:this.borders[e]?.[t]?.[o+1]?.horizontal,left:this.borders[e]?.[t]?.[o]?.vertical,right:this.borders[e]?.[t+1]?.[o]?.vertical};return i.bottom||i.left||i.right||i.top?i:null}getBordersColors(e){const t=[],o=this.borders[e];if(o)for(const e of o.filter(ke))for(const o of e)o?.horizontal&&t.push(o.horizontal.color),o?.vertical&&t.push(o.vertical.color);return t}ensureColumnBorderContinuity(e,t,o){const i=ye(t+1,o);for(let s=0;s<this.getters.getNumberRows(e);s++){const r=this.getCellBorder({sheetId:e,col:t,row:s}),n=this.getCellBorder({sheetId:e,col:o,row:s});if(r&&n){const t=this.getCommonSides(r,n);for(let o of i)this.addBorder(e,o,s,t)}}}ensureRowBorderContinuity(e,t,o){const i=ye(t+1,o);for(let s=0;s<this.getters.getNumberCols(e);s++){const r=this.getCellBorder({sheetId:e,col:s,row:t}),n=this.getCellBorder({sheetId:e,col:s,row:o});if(r&&n){const t=this.getCommonSides(r,n);for(let o of i)this.addBorder(e,s,o,t)}}}getCommonSides(e,t){const o={};for(let i of["top","bottom","left","right"])e[i]&&e[i]===t[i]&&(o[i]=e[i]);return o}getColumnsWithBorders(e){const t=this.borders[e];return t?Object.keys(t).map((e=>parseInt(e,10))):[]}getRowsRange(e){return this.borders[e]?ye(0,this.getters.getNumberRows(e)+1):[]}shiftBordersHorizontally(e,t,o,{moveFirstLeftBorder:i}={}){this.borders[e]&&(o<0&&this.moveBordersOfColumn(e,t,o,"vertical",{destructive:!1}),this.getColumnsWithBorders(e).filter((e=>e>=t)).sort(((e,t)=>o<0?e-t:t-e)).forEach((s=>{(s===t&&i||s!==t)&&this.moveBordersOfColumn(e,s,o,"vertical"),this.moveBordersOfColumn(e,s,o,"horizontal")})))}shiftBordersVertically(e,t,o,{moveFirstTopBorder:i}={}){this.borders[e]&&(o<0&&this.moveBordersOfRow(e,t,o,"horizontal",{destructive:!1}),this.getRowsRange(e).filter((e=>e>=t)).sort(((e,t)=>o<0?e-t:t-e)).forEach((s=>{(s===t&&i||s!==t)&&this.moveBordersOfRow(e,s,o,"horizontal"),this.moveBordersOfRow(e,s,o,"vertical")})))}moveBordersOfRow(e,t,o,i,{destructive:s}={destructive:!0}){const r=this.borders[e];r&&this.getColumnsWithBorders(e).forEach((n=>{const a=r[n]?.[t+o]?.[i],l=r[n]?.[t]?.[i];this.history.update("borders",e,n,t+o,i,s?l:l||a),this.history.update("borders",e,n,t,i,void 0)}))}moveBordersOfColumn(e,t,o,i,{destructive:s}={destructive:!0}){const r=this.borders[e];r&&this.getRowsRange(e).forEach((n=>{const a=r[t+o]?.[n]?.[i],l=r[t]?.[n]?.[i];this.history.update("borders",e,t+o,n,i,s?l:l||a),this.history.update("borders",e,t,n,i,void 0)}))}setBorder(e,t,o,i,s=!0){!s&&this.borders?.[e]?.[t]?.[o]?.vertical||this.history.update("borders",e,t,o,"vertical",i?.left),!s&&this.borders?.[e]?.[t]?.[o]?.horizontal||this.history.update("borders",e,t,o,"horizontal",i?.top),!s&&this.borders?.[e]?.[t+1]?.[o]?.vertical||this.history.update("borders",e,t+1,o,"vertical",i?.right),!s&&this.borders?.[e]?.[t]?.[o+1]?.horizontal||this.history.update("borders",e,t,o+1,"horizontal",i?.bottom)}clearBorders(e,t){for(let o of t){for(let t=o.top;t<=o.bottom;t++){this.history.update("borders",e,o.right+1,t,"vertical",void 0);for(let i=o.left;i<=o.right;i++)this.history.update("borders",e,i,t,void 0)}for(let t=o.left;t<=o.right;t++)this.history.update("borders",e,t,o.bottom+1,"horizontal",void 0)}}addBorder(e,t,o,i){this.setBorder(e,t,o,{...this.getCellBorder({sheetId:e,col:t,row:o}),...i})}setBorders(e,t,o,i){if("clear"===o)return this.clearBorders(e,t);for(let s of t){if("h"===o||"hv"===o||"all"===o)for(let t=s.top+1;t<=s.bottom;t++)for(let o=s.left;o<=s.right;o++)this.addBorder(e,o,t,{top:i});if("v"===o||"hv"===o||"all"===o)for(let t=s.top;t<=s.bottom;t++)for(let o=s.left+1;o<=s.right;o++)this.addBorder(e,o,t,{left:i});if("left"===o||"all"===o||"external"===o)for(let t=s.top;t<=s.bottom;t++)this.addBorder(e,s.left,t,{left:i});if("right"===o||"all"===o||"external"===o)for(let t=s.top;t<=s.bottom;t++)this.addBorder(e,s.right+1,t,{left:i});if("top"===o||"all"===o||"external"===o)for(let t=s.left;t<=s.right;t++)this.addBorder(e,t,s.top,{top:i});if("bottom"===o||"all"===o||"external"===o)for(let t=s.left;t<=s.right;t++)this.addBorder(e,t,s.bottom+1,{top:i})}}addBordersToMerge(e,t){const{left:o,right:i,top:s,bottom:r}=t,n=this.getCellBorder({sheetId:e,col:o,row:s}),a=this.getCellBorder({sheetId:e,col:i,row:r});this.clearBorders(e,[t]),n?.top&&this.setBorders(e,[{...t,bottom:s}],"top",n.top),n?.left&&this.setBorders(e,[{...t,right:o}],"left",n.left),a?.bottom?this.setBorders(e,[{...t,top:r}],"bottom",a.bottom):n?.bottom&&this.setBorders(e,[{...t,top:r}],"bottom",n.bottom),a?.right?this.setBorders(e,[{...t,left:i}],"right",a.right):n?.right&&this.setBorders(e,[{...t,left:i}],"right",n.right)}checkBordersUnchanged(e){const t=this.getCellBorder(e),o=!(e.border?.bottom||e.border?.left||e.border?.right||e.border?.top);return!t&&o||We(t,e.border)?98:0}import(e){if(Object.keys(e.borders||{}).length)for(let t of e.sheets)for(const o in t.cells){const i=t.cells[o];if(i?.border){const s=e.borders[i.border],{col:r,row:n}=wt(o);this.setBorder(t.id,r,n,s,!1)}}for(let t of e.sheets)if(t.merges)for(let e of t.merges)this.addBordersToMerge(t.id,ti(e))}export(e){let t=0;const o={};function i(e){for(let[t,i]of Object.entries(o))if(We(i,e))return parseInt(t,10);return o[++t]=e,t}for(let t of e.sheets)for(let e=0;e<t.colNumber;e++)for(let o=0;o<t.rowNumber;o++){const s=this.getCellBorder({sheetId:t.id,col:e,row:o});if(s){const r=xt(e,o),n=t.cells[r],a=i(s);n?n.border=a:t.cells[r]={border:a}}}e.borders=o}exportForExcel(e){this.export(e)}}).add("conditional formatting",class extends QE{static getters=["getConditionalFormats","getRulesSelection","getRulesByCell","getAdaptedCfRanges"];cfRules={};loopThroughRangesOfSheet(e,t){for(const o of this.cfRules[e])for(const i of o.ranges){const s=t(i);switch(s.changeType){case"REMOVE":let t=o.ranges.slice();t.splice(o.ranges.indexOf(i),1),t.length>=1?this.history.update("cfRules",e,this.cfRules[e].indexOf(o),"ranges",t):this.removeConditionalFormatting(o.id,e);break;case"RESIZE":case"MOVE":case"CHANGE":this.history.update("cfRules",e,this.cfRules[e].indexOf(o),"ranges",o.ranges.indexOf(i),s.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 o={...e.cf,ranges:e.ranges.map((t=>this.getters.getRangeString(this.getters.getRangeFromRangeData(t),e.sheetId)))};this.addConditionalFormatting(o,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){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,{useFixedReference:!0}))))}getConditionalFormats(e){return this.cfRules[e]?.map((t=>this.mapToConditionalFormat(e,t)))||[]}getRulesSelection(e,t){const o=new Set;return t.forEach((t=>{this.getRulesByZone(e,t).forEach((e=>{o.add(e)}))})),Array.from(o)}getRulesByZone(e,t){const o=new Set;for(let i=t.top;i<=t.bottom;i++)for(let s=t.left;s<=t.right;s++){this.getRulesByCell(e,s,i).forEach((e=>{o.add(e.id)}))}return o}getRulesByCell(e,t,o){const i=[];for(let s of this.cfRules[e])for(let e of s.ranges)ui(t,o,e.zone)&&i.push(s);return new Set(i.map((t=>this.mapToConditionalFormat(e,t))))}getAdaptedCfRanges(e,t,o,i){if(0===o.length&&0===i.length)return;const s=this.getters.getConditionalFormats(e),r=s.findIndex((e=>e.id===t.id));let n=[];return r>-1&&(n=s[r].ranges),n=n.concat(o),pi(n,i)}mapToConditionalFormat(e,t,o={useFixedReference:!1}){return{...t,ranges:t.ranges.map((t=>this.getters.getRangeString(t,e,o.useFixedReference)))}}mapToConditionalFormatInternal(e,t){const o={...t,ranges:t.ranges.map((t=>this.getters.getRangeFromSheetXC(e,t)))};return o}addConditionalFormatting(e,t){const o=this.cfRules[t].slice(),i=o.findIndex((t=>t.id===e.id)),s=this.mapToConditionalFormatInternal(t,e);i>-1?o.splice(i,1,s):o.push(s),this.history.update("cfRules",t,o)}checkValidReordering(e,t,o){if(!this.cfRules[o])return 28;const i=this.cfRules[o].findIndex((t=>t.id===e));if(-1===i)return 74;const s="up"===t?i-1:i+1;return s<0||s>=this.cfRules[o].length?74:0}checkEmptyRange(e){return e.ranges.length?0:25}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 o=>{if(t.includes(o.operator)){const t=[],i=e=>void 0===e||""===e;return e>=1&&i(o.values[0])&&t.push(54),e>=2&&i(o.values[1])&&t.push(55),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 56;case"max":return 58;case"mid":return 57;case"upperInflectionPoint":return 59;case"lowerInflectionPoint":return 60}return 0}checkFormulaCompilation(e,t){if("formula"!==e.type)return 0;try{hg(e.value||"")}catch(e){switch(t){case"min":return 61;case"max":return 63;case"mid":return 62;case"upperInflectionPoint":return 64;case"lowerInflectionPoint":return 65}}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,o=e.upperInflectionPoint.value;return["number","percentage","percentile"].includes(e.lowerInflectionPoint.type)&&e.lowerInflectionPoint.type===e.upperInflectionPoint.type&&Number(t)>Number(o)?51:0}checkMinBiggerThanMax(e){const t=e.minimum.value,o=e.maximum.value;return["number","percentage","percentile"].includes(e.minimum.type)&&e.minimum.type===e.maximum.type&&ew(t)>=ew(o)?50:0}checkMidBiggerThanMax(e){const t=e.midpoint?.value,o=e.maximum.value;return e.midpoint&&["number","percentage","percentile"].includes(e.midpoint.type)&&e.midpoint.type===e.maximum.type&&ew(t)>=ew(o)?52:0}checkMinBiggerThanMid(e){const t=e.minimum.value,o=e.midpoint?.value;return e.midpoint&&["number","percentage","percentile"].includes(e.midpoint.type)&&e.minimum.type===e.midpoint.type&&ew(t)>=ew(o)?53:0}removeConditionalFormatting(e,t){const o=this.cfRules[t].findIndex((t=>t.id===e));if(-1!==o){const e=this.cfRules[t].slice();e.splice(o,1),this.history.update("cfRules",t,e)}}reorderConditionalFormatting(e,t,o){const i=this.cfRules[o].findIndex((t=>t.id===e)),s="up"===t?i-1:i+1;if(!(s<0||s>=this.cfRules[o].length)&&-1!==i&&-1!==s){const e=[...this.cfRules[o]],t=e[i];e[i]=e[s],e[s]=t,this.history.update("cfRules",o,e)}}}).add("figures",class extends QE{static getters=["getFigures","getFigure","getFigureSheetId"];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}}beforeHandle(e){if("DELETE_SHEET"===e.type)this.getters.getFigures(e.sheetId).forEach((t=>{this.dispatch("DELETE_FIGURE",{id:t.id,sheetId:e.sheetId})}))}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:o,...i}=e,s=i;this.updateFigure(o,s);break;case"DELETE_FIGURE":this.removeFigure(e.id,e.sheetId);break;case"REMOVE_COLUMNS_ROWS":this.onRowColDelete(e.sheetId,e.dimension)}}onRowColDelete(e,t){"ROW"===t?this.onRowDeletion(e):this.onColDeletion(e)}onRowDeletion(e){const t=this.getters.getNumberRows(e);let o=0;for(let i=0;i<t;i++)o+=this.getters.getUserRowSize(e,i)||P;const i=this.getters.getFigures(e);for(const t of i){const i=Math.min(t.y,o-t.height);i!==t.y&&this.dispatch("UPDATE_FIGURE",{sheetId:e,id:t.id,y:i})}}onColDeletion(e){const t=this.getters.getNumberCols(e);let o=0;for(let i=0;i<t;i++)o+=this.getters.getColSize(e,i);const i=this.getters.getFigures(e);for(const t of i){const i=Math.min(t.x,o-t.width);i!==t.x&&this.dispatch("UPDATE_FIGURE",{sheetId:e,id:t.id,x:i})}}updateFigure(e,t){if("id"in t)for(const[o,i]of Object.entries(t))switch(o){case"x":case"y":void 0!==i&&this.history.update("figures",e,t.id,o,Math.max(i,0));break;case"width":case"height":void 0!==i&&this.history.update("figures",e,t.id,o,i)}}addFigure(e,t){this.history.update("figures",t,e.id,e)}deleteSheet(e){this.history.update("figures",e,void 0)}removeFigure(e,t){this.history.update("figures",t,e,void 0)}checkFigureExists(e,t){return void 0===this.figures[e]?.[t]?73:0}checkFigureDuplicate(e){return Object.values(this.figures).find((t=>t?.[e]))?85:0}getFigures(e){return Object.values(this.figures[e]||{}).filter(ke)}getFigure(e,t){return this.figures[e]?.[t]}getFigureSheetId(e){return Object.keys(this.figures).find((t=>void 0!==this.figures[t]?.[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 o=void 0;t.figures.push({...e,data:o})}}exportForExcel(e){this.export(e)}}).add("chart",class extends QE{static getters=["isChartDefined","getChartDefinition","getChartType","getChartIds","getChart","getContextCreationChart"];charts={};createChart=function(e){const t=qp.getAll().sort(((e,t)=>e.sequence-t.sequence));return function(o,i,s){const r=t.find((e=>e.match(i.type)));if(!r)throw new Error(`No builder for this chart: ${i.type}`);return r.createChart(i,s,e)}}(this.getters);validateChartDefinition=e=>function(e,t){const o=qp.getAll().find((e=>e.match(t.type)));if(!o)throw new Error("Unknown chart type.");return o.validateChartDefinition(e,t)}(this,e.definition);adaptRanges(e){for(const[t,o]of Object.entries(this.charts))this.history.update("charts",t,o?.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){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 t=this.getters.getFigures(e.sheetId);for(const o of t)if("chart"===o.tag){const t=o.id.split(se).pop(),i=`${e.sheetIdTo}${se}${t}`,s=this.charts[o.id]?.copyForSheetId(e.sheetIdTo);s&&this.dispatch("CREATE_CHART",{id:i,position:{x:o.x,y:o.y},size:{width:o.width,height:o.height},definition:s.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){return this.charts[e]?.getContextCreation()}getChart(e){return this.charts[e]}getChartType(e){const t=this.charts[e]?.type;if(!t)throw new Error("Chart not defined.");return t}isChartDefined(e){return e in this.charts&&void 0!==this.charts}getChartIds(e){return Object.entries(this.charts).filter((([,t])=>t?.sheetId===e)).map((([e])=>e))}getChartDefinition(e){const t=this.charts[e]?.getDefinition();if(!t)throw new Error(`There is no chart with the given figureId: ${e}`);return t}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){if(e.sheets)for(let t of e.sheets){const e=this.getters.getFigures(t.id),o=[];for(let t of e){const e=t;if(e&&"chart"===e.tag){const t=this.charts[e.id]?.getDefinition();t&&(e.data=t,o.push(e))}else o.push(e)}t.figures=o}}exportForExcel(e){for(let t of e.sheets){const e=this.getters.getFigures(t.id),o=[];for(let t of e)if(t&&"chart"===t.tag){const e=this.charts[t.id]?.getDefinitionForExcel();e&&o.push({...t,data:e})}t.charts=o}}addFigure(e,t,o={x:0,y:0},i={width:536,height:335}){if(this.getters.getFigure(t,e))return;const s={id:e,x:o.x,y:o.y,width:i.width,height:i.height,tag:"chart"};this.dispatch("CREATE_FIGURE",{sheetId:t,figure:s})}addChart(e,t){const o=this.getters.getFigureSheetId(e);o&&this.history.update("charts",e,this.createChart(e,t,o))}checkChartDuplicate(e){return this.getters.getFigureSheetId(e.id)?87:0}checkChartExists(e){return this.getters.getFigureSheetId(e.id)?0:88}}).add("image",class extends QE{static getters=["getImage","getImagePath","getImageSize"];fileStore;images={};syncedImages=new Set;constructor(e){super(e),this.fileStore=e.external.fileStore}allowDispatch(e){return"CREATE_IMAGE"===e.type&&this.getters.getFigure(e.sheetId,e.figureId)?29:0}handle(e){switch(e.type){case"CREATE_IMAGE":this.addImage(e.figureId,e.sheetId,e.position,e.size),this.history.update("images",e.sheetId,e.figureId,e.definition),this.syncedImages.add(e.definition.path);break;case"DUPLICATE_SHEET":{const t=this.getters.getFigures(e.sheetId);for(const o of t)if("image"===o.tag){const t=o.id.split(se).pop(),i=`${e.sheetIdTo}${se}${t}`,s=this.getImage(o.id);if(s){const t={width:o.width,height:o.height};this.dispatch("CREATE_IMAGE",{sheetId:e.sheetIdTo,figureId:i,position:{x:o.x,y:o.y},size:t,definition:Ce(s)})}}break}case"DELETE_FIGURE":this.history.update("images",e.sheetId,e.id,void 0);break;case"DELETE_SHEET":this.history.update("images",e.sheetId,void 0)}}garbageCollectExternalResources(){const e=new Set(this.getAllImages().map((e=>e.path)));for(const t of this.syncedImages)e.has(t)||this.fileStore?.delete(t)}getImage(e){for(const t of Object.values(this.images))if(t&&t[e])return t[e];throw new Error(`There is no image with the given figureId: ${e}`)}getImagePath(e){return this.getImage(e).path}getImageSize(e){return this.getImage(e).size}addImage(e,t,o,i){const s={id:e,x:o.x,y:o.y,width:i.width,height:i.height,tag:"image"};this.dispatch("CREATE_FIGURE",{sheetId:t,figure:s})}import(e){for(const t of e.sheets){const e=(t.figures||[]).filter((e=>"image"===e.tag));for(const o of e)this.history.update("images",t.id,o.id,o.data),this.syncedImages.add(o.data.path)}}export(e){for(const t of e.sheets){const e=t.figures.filter((e=>"image"===e.tag));for(const o of e)o.data=this.images[t.id]?.[o.id]}}exportForExcel(e){for(const t of e.sheets){const e=this.getters.getFigures(t.id),o=[];for(const t of e)if("image"===t?.tag){const e=this.getImage(t.id);e&&o.push({...t,data:Ce(e)})}t.images=o}}getAllImages(){const e=[];for(const t in this.images)e.push(...Object.values(this.images[t]||{}).filter(ke));return e}}),wx=(new Ji).add("ui_sheet",class extends nw{static getters=["getCellWidth","getTextWidth","getCellText","getCellMultiLineText","getColDimensions","getRowDimensions","getColRowOffset"];ctx=document.createElement("canvas").getContext("2d");allowDispatch(e){return this.chainValidations(this.checkSheetExists,this.checkZonesAreInSheet)(e)}handle(e){switch(e.type){case"AUTORESIZE_COLUMNS":for(let t of e.cols){const o=this.getColMaxWidth(e.sheetId,t);0!==o&&this.dispatch("RESIZE_COLUMNS_ROWS",{elements:[t],dimension:"COL",size:o,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){const t=this.getters.getCellComputedStyle(e);let o=0;const i=this.getters.getEvaluatedCell(e).formattedValue;if(i){const e=Ui(this.ctx,i,t,void 0);o+=Math.max(...e.map((e=>Fi(this.ctx,e,t))))}this.getters.getConditionalIcon(e)&&(o+=function(e){return Pi(e)+2*B}(t));if(this.getters.isFilterHeader(e)&&(o+=20),0===o)return 0;if(o+=2*$,"wrap"===t.wrapping){const t=this.getters.getColSize(this.getters.getActiveSheetId(),e.col);return Math.min(t,o)}return o}getTextWidth(e,t){return Fi(this.ctx,e,t)}getCellText(e,t=!1){const o=this.getters.getCell(e);return t&&o?.isFormula?Eg(o.content,this.getters.getLocale()):this.getters.getEvaluatedCell(e).formattedValue}getCellMultiLineText(e,t){const o=this.getters.getCellStyle(e),i=this.getters.getCellText(e,this.getters.shouldShowFormulas());return Ui(this.ctx,i,o,t)}getColDimensions(e,t){const o=this.getColRowOffset("COL",0,t,e),i=this.getters.getColSize(e,t);return{start:o,size:i,end:o+(this.getters.isColHidden(e,t)?0:i)}}getRowDimensions(e,t){const o=this.getColRowOffset("ROW",0,t,e),i=this.getters.getRowSize(e,t);return{start:o,size:i,end:o+(this.getters.isRowHidden(e,t)?0:i)}}getColRowOffset(e,t,o,i=this.getters.getActiveSheetId()){if(o<t)return-this.getColRowOffset(e,o,t);let s=0;for(let r=t;r<o;r++)this.getters.isHeaderHidden(i,e,r)||(s+="COL"===e?this.getters.getColSize(i,r):this.getters.getRowSize(i,r));return s}getColMaxWidth(e,t){const o=vi(this.getters.getColsZone(e,t,t)).map((t=>this.getCellWidth({sheetId:e,...t})));return Math.max(0,et(o))}checkSheetExists(e){return"sheetId"in e&&void 0===this.getters.tryGetSheet(e.sheetId)?28:0}checkZonesAreInSheet(e){const t="sheetId"in e?e.sheetId:this.getters.tryGetActiveSheetId(),o=this.getters.getCommandZones(e);return!t&&o.length>0?95:t&&o.length>0?this.getters.checkZonesExistInSheet(t,o):0}}).add("header_visibility_ui",class extends nw{static getters=["getNextVisibleCellPosition","findVisibleHeader","findLastVisibleColRowIndex","findFirstVisibleColRowIndex","isRowHidden","isColHidden","isHeaderHidden"];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,o){return"COL"===t?this.isColHidden(e,o):this.isRowHidden(e,o)}getNextVisibleCellPosition({sheetId:e,col:t,row:o}){return{sheetId:e,col:this.findVisibleHeader(e,"COL",t,this.getters.getNumberCols(e)-1),row:this.findVisibleHeader(e,"ROW",o,this.getters.getNumberRows(e)-1)}}findVisibleHeader(e,t,o,i){if(o<=i)for(let s=o;s<=i;s++)if(this.getters.doesHeaderExist(e,t,s)&&!this.isHeaderHidden(e,t,s))return s;if(o>i)for(let s=o;s>=i;s--)if(this.getters.doesHeaderExist(e,t,s)&&!this.isHeaderHidden(e,t,s))return s}findLastVisibleColRowIndex(e,t,{last:o,first:i}){return ye(o,i,-1).find((o=>!this.isHeaderHidden(e,t,o)))||i}findFirstVisibleColRowIndex(e,t){const o=this.getters.getNumberHeaders(e,t);for(let i=0;i<o;i++){if("COL"===t&&!this.isColHidden(e,i))return i;if("ROW"===t&&!this.isRowHidden(e,i))return i}}exportForExcel(e){for(const t of e.sheets)for(const[e,o]of Object.entries(t.rows)){const i=this.isRowHidden(t.id,Number(e));o.isHidden=i}}}).add("ui_options",class extends nw{static getters=["shouldShowFormulas"];showFormulas=!1;handle(e){if("SET_FORMULA_VISIBILITY"===e.type)this.showFormulas=e.show}shouldShowFormulas(){return this.showFormulas}}).add("selectionInputManager",class extends nw{config;static layers=[1];static getters=["getSelectionInput","getSelectionInputValue","isRangeValid","getSelectionInputHighlights"];inputs={};focusedInputId=null;get currentInput(){return this.focusedInputId?this.inputs[this.focusedInputId]:null}constructor(e){super(e),this.config=e}allowDispatch(e){switch(e.type){case"FOCUS_RANGE":case"CHANGE_RANGE":case"ADD_EMPTY_RANGE":case"REMOVE_RANGE":if(!this.inputs[e.id])return 33}switch(e.type){case"FOCUS_RANGE":const t=this.currentInput?.getIndex(e.rangeId);if(this.focusedInputId===e.id&&this.currentInput?.focusedRangeIndex===t)return 30;break;case"ADD_RANGE":case"ADD_EMPTY_RANGE":const o=this.inputs[e.id];if(o.inputHasSingleRange&&1===o.ranges.length)return 31;break;case"REMOVE_RANGE":if(1===this.inputs[e.id].ranges.length)return 32;break;case"CHANGE_RANGE":if(this.inputs[e.id].inputHasSingleRange&&e.value.split(",").length>1)return 31;break}return 0}handle(e){switch(e.type){case"ENABLE_NEW_SELECTION_INPUT":this.initInput(e.id,e.initialRanges||[],e.hasSingleRange);break;case"DISABLE_SELECTION_INPUT":this.focusedInputId===e.id&&this.unfocus(),delete this.inputs[e.id];break;case"UNFOCUS_SELECTION_INPUT":this.unfocus();break;case"ADD_RANGE":case"ADD_EMPTY_RANGE":case"REMOVE_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}break;case"FOCUS_RANGE":case"CHANGE_RANGE":const t=this.inputs[e.id],o=t.ranges.find((t=>t.id===e.rangeId));if(o){const i=this.getters.getActiveSheetId(),s=this.getters.getRangeFromSheetXC(i,o?.xc||"A1").zone;this.selection.capture(t,{cell:{col:s.left,row:s.top},zone:s},{handleEvent:t.handleEvent.bind(t)}),this.focusedInputId=e.id}}this.currentInput?.handle(e)}getSelectionInput(e){return this.inputs[e]?this.inputs[e].ranges.map(((t,o)=>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===o}))):[]}isRangeValid(e){if(!e)return!1;const{xc:t,sheetName:o}=Jo(e);return null!==t.match(Zo)&&(!o||void 0!==this.getters.getSheetIdByName(o))}getSelectionInputValue(e){return this.inputs[e].getSelectionInputValue()}getSelectionInputHighlights(){return this.focusedInputId?this.inputs[this.focusedInputId].getSelectionInputHighlights():[]}initInput(e,t,o=!1){if(this.inputs[e]&&this.unfocus(),this.inputs[e]=new Xw(this.config,t,o),0===t.length){const t=this.inputs[e],o={zone:wi({col:0,row:0}),cell:{col:0,row:0}};this.selection.capture(t,o,{handleEvent:t.handleEvent.bind(t)}),this.focusedInputId=e}}unfocus(){this.selection.release(this.currentInput),this.focusedInputId=null}}).add("highlight",class extends nw{static layers=[1];static getters=["getHighlights"];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{numberOfRows:t,numberOfCols:o}=fi(e.zone),i=t*o==1?this.getters.expandZone(e.sheetId,e.zone):e.zone;return{...e,zone:i}}))}drawGrid(e){const{ctx:t,thinLineWidth:o}=e,i=this.getters.getActiveSheetId(),s=3*o;t.lineWidth=s;const r=this.getHighlights();for(let e of r.filter(((e,t)=>r.findIndex((t=>hi(t.zone,e.zone)&&t.sheetId===i))===t))){const{x:o,y:i,width:r,height:n}=this.getters.getVisibleRect(e.zone);r>0&&n>0&&(t.strokeStyle=e.color,t.strokeRect(o+s/2,i+s/2,r-s,n-s),t.globalCompositeOperation="source-over",t.fillStyle=e.color+"20",t.fillRect(o+s,i+s,r-2*s,n-2*s))}}}).add("grid renderer",class extends nw{static layers=[0,7];static getters=["getColDimensionsInViewport","getRowDimensionsInViewport"];boxes=[];getColDimensionsInViewport(e,t){const o=tt(this.getters.getSheetViewVisibleCols()),i=this.getters.getColRowOffsetInViewport("COL",o,t),s=this.getters.getColSize(e,t);return{start:i,size:s,end:i+(this.getters.isColHidden(e,t)?0:s)}}getRowDimensionsInViewport(e,t){const o=tt(this.getters.getSheetViewVisibleRows()),i=this.getters.getColRowOffsetInViewport("ROW",o,t),s=this.getters.getRowSize(e,t);return{start:i,size:s,end:i+(this.getters.isRowHidden(e,t)?0:s)}}getHeaderOffset(e,t,o){let i=this.getters.getColRowOffsetInViewport(e,t,o);return this.getters.isDashboard()||(i+="ROW"===e?F:D),i}drawGrid(e,t){switch(t){case 0:this.boxes=this.getGridBoxes(),this.drawBackground(e),this.drawOverflowingCellBackground(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:o}=e,{width:i,height:s}=this.getters.getSheetViewDimensionWithHeaders();t.fillStyle="#ffffff",t.fillRect(0,0,i+m,s+m);const r=!this.getters.isDashboard()&&this.getters.getGridLinesVisibility(this.getters.getActiveSheetId()),n=r?.1*o:0;if(r)for(const e of this.boxes)t.strokeStyle="#E2E3E3",t.lineWidth=o,t.strokeRect(e.x+n,e.y+n,e.width-2*n,e.height-2*n)}drawCellBackground(e){const{ctx:t}=e;for(const e of this.boxes){let o=e.style;o.fillColor&&"#ffffff"!==o.fillColor&&(t.fillStyle=o.fillColor||"#ffffff",t.fillRect(e.x,e.y,e.width,e.height)),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())}}drawOverflowingCellBackground(e){const{ctx:t,thinLineWidth:o}=e;for(const e of this.boxes)if(e.content&&e.isOverflow){const i=e.content.align||"left";let s,r;const n=e.y+o/2,a=e.height-o,l=Math.min(e.clipRect?.width||1/0,e.content.width);"left"===i?(s=e.x+o/2,r=l-2*o):"right"===i?(s=e.x+e.width-o/2,r=2*o-l):(s=(e.clipRect?.x||e.x+e.width/2-e.content.width/2)+o/2,r=l-2*o),t.fillStyle="#ffffff",t.fillRect(s,n,r,a)}}drawBorders(e){const{ctx:t}=e;for(let e of this.boxes){const t=e.border;if(t){const{x:i,y:s,width:r,height:n}=e;t.left&&o(t.left,i,s,i,s+n),t.top&&o(t.top,i,s,i+r,s),t.right&&o(t.right,i+r,s,i+r,s+n),t.bottom&&o(t.bottom,i,s+n,i+r,s+n)}}function o({style:e,color:o},i,s,r,n){switch(t.strokeStyle=o,e){case"medium":t.lineWidth=2,s+=(i+=s===n?-.5:.5)===(r+=s===n?1.5:.5)?-.5:.5,n+=i===r?1.5:.5;break;case"thick":t.lineWidth=3,s===n&&(i--,r++),i===r&&(s--,n++);break;case"dashed":t.lineWidth=1,t.setLineDash([1,3]);break;case"dotted":t.lineWidth=1,s===n&&(i+=.5,r+=.5),i===r&&(s+=.5,n+=.5),t.setLineDash([1,1]);break;default:t.lineWidth=1}t.beginPath(),t.moveTo(i,s),t.lineTo(r,n),t.stroke(),t.lineWidth=1,t.setLineDash([])}}drawTexts(e){const{ctx:t,thinLineWidth:o}=e;let i;t.textBaseline="top";for(let e of this.boxes)if(e.content){const s=e.style||{},r=e.content.align||"left",n=Li(s);n!==i&&(i=n,t.font=n),t.fillStyle=s.textColor||"#000";let a=e.x;if(a+="left"===r?z+(e.image?e.image.size+B:0):"right"===r?e.width-z-(e.isFilterHeader?20:0):e.width/2,t.textAlign=r,e.clipRect){t.save(),t.beginPath();const{x:o,y:i,width:s,height:r}=e.clipRect;t.rect(o,i,s,r),t.clip()}const l=Pi(s),c=e.content.textLines.length;let h=this.computeTextYCoordinate(e,l,c);for(let i of e.content.textLines){if(t.fillText(i,Math.round(a),Math.round(h)),s.strikethrough||s.underline){const e=Fi(t,i,s);let n=a;"right"===r?n-=e:"center"===r&&(n-=e/2),s.strikethrough&&t.fillRect(n,h+l/2,e,2.6*o),s.underline&&t.fillRect(n,h+l+1,e,1.3*o)}h+=z+l}e.clipRect&&t.restore()}}drawIcon(e){const{ctx:t}=e;for(const e of this.boxes)if(e.image){const o=e.image.image;if(e.image.clipIcon){t.save(),t.beginPath();const{x:o,y:i,width:s,height:r}=e.image.clipIcon;t.rect(o,i,s,r),t.clip()}const i=e.image.size,s=this.computeTextYCoordinate(e,i);t.drawImage(o,e.x+B,s,i,i),e.image.clipIcon&&t.restore()}}computeTextYCoordinate(e,t,o=1){const i=e.y+1,s=Ni(t,o),r=e.height>s+2*z,n=e.verticalAlign||j;if(r){if("middle"===n)return i+(e.height-s)/2;if("bottom"===n)return i+e.height-s-z}return i+z}drawHeaders(e){const{ctx:t,thinLineWidth:o}=e,i=this.getters.getSheetViewVisibleCols(),s=i[0],r=i[i.length-1],n=this.getters.getSheetViewVisibleRows(),a=n[0],l=n[n.length-1],{width:c,height:h}=this.getters.getSheetViewDimensionWithHeaders(),d=this.getters.getSelectedZones(),u=function(e){const t=new Set;for(let o of e)for(let e of ye(o.left,o.right+1))t.add(e);return t}(d),g=function(e){const t=new Set;for(let o of e)for(let e of ye(o.top,o.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 ${Y}`,t.textAlign="center",t.textBaseline="middle",t.lineWidth=o,t.strokeStyle="#333";for(let e=s;e<=r;e++){const o={left:e,right:e,top:0,bottom:f-1},{x:i,width:s}=this.getters.getVisibleRect(o),r=this.getters.doesZonesContainFilter(p,[o]),n=E.has(e),a=u.has(e);t.fillStyle=n?r?T:S:a?r?O:v:r?A:b,t.fillRect(i,0,s,F)}for(let e=a;e<=l;e++){const o={top:e,bottom:e,left:0,right:m-1},{y:i,height:s}=this.getters.getVisibleRect(o),r=this.getters.doesZonesContainFilter(p,[o]),n=w.has(e),a=g.has(e);t.fillStyle=n?r?T:S:a?r?O:v:r?A:b,t.fillRect(0,i,D,s)}t.beginPath(),t.moveTo(D,0),t.lineTo(D,h),t.moveTo(0,F),t.lineTo(c,F),t.strokeStyle="#C0C0C0",t.stroke(),t.beginPath();for(const e of i){const o=this.getters.getColSize(p,e),i=bt(e);t.fillStyle=E.has(e)?"#fff":C;let r=this.getHeaderOffset("COL",s,e);t.fillText(i,r+o/2,13),t.moveTo(r+o,0),t.lineTo(r+o,F)}for(const e of n){const o=this.getters.getRowSize(p,e);t.fillStyle=w.has(e)?"#fff":C;let i=this.getHeaderOffset("ROW",a,e);t.fillText(String(e+1),24,i+o/2),t.moveTo(0,i+o),t.lineTo(D,i+o)}t.stroke()}drawFrozenPanesHeaders(e){const{ctx:t,thinLineWidth:o}=e,{x:i,y:s}=this.getters.getMainViewportCoordinates(),r=this.getters.isDashboard()?0:D,n=this.getters.isDashboard()?0:F;t.lineWidth=6*o,t.strokeStyle="#BCBCBC",t.beginPath(),i&&(t.moveTo(r+i,0),t.lineTo(r+i,n)),s&&(t.moveTo(0,n+s),t.lineTo(r,n+s)),t.stroke()}drawFrozenPanes(e){const{ctx:t,thinLineWidth:o}=e,{x:i,y:s}=this.getters.getMainViewportCoordinates(),r=this.getters.getSheetViewVisibleCols(),n=r[0],a=r[r.length-1],l=this.getters.getSheetViewVisibleRows(),c={left:n,right:a,top:l[0],bottom:l[l.length-1]},h=this.getters.getVisibleRect(c),d=this.getters.isDashboard()?0:D,u=this.getters.isDashboard()?0:F;t.lineWidth=6*o,t.strokeStyle="#DADFE8",t.beginPath(),i&&(t.moveTo(d+i,u),t.lineTo(d+i,h.height+u)),s&&(t.moveTo(d,u+s),t.lineTo(h.width+d,u+s)),t.stroke()}findNextEmptyCol(e,t,o){const i=this.getters.getActiveSheetId();let s=e;for(;s<t;){const e={sheetId:i,col:s+1,row:o},t=this.getters.getEvaluatedCell(e),r=this.getters.getCellBorderWithFilterBorder(e);if(t.type!==ls.empty||this.getters.isInMerge(e)||r?.left)return s;s++}return s}findPreviousEmptyCol(e,t,o){const i=this.getters.getActiveSheetId();let s=e;for(;s>t;){const e={sheetId:i,col:s-1,row:o},t=this.getters.getEvaluatedCell(e),r=this.getters.getCellBorderWithFilterBorder(e);if(t.type!==ls.empty||this.getters.isInMerge(e)||r?.right)return s;s--}return s}computeCellAlignment(e,t){if(this.getters.getCell(e)?.isFormula&&this.getters.shouldShowFormulas())return"left";const{align:o}=this.getters.getCellStyle(e),i=this.getters.getEvaluatedCell(e);return t&&i.type===ls.number?"center"!==o?"left":o:o||i.defaultAlign}createZoneBox(e,t,o){const{left:i,right:s}=o,r=t.left,n=t.top,a={sheetId:e,col:r,row:n},c=this.getters.getEvaluatedCell(a),h=this.getters.shouldShowFormulas(),{x:d,y:u,width:g,height:p}=this.getters.getVisibleRect(t),{verticalAlign:m}=this.getters.getCellStyle(a),f={x:d,y:u,width:g,height:p,border:this.getters.getCellBorderWithFilterBorder(a)||void 0,style:this.getters.getCellComputedStyle(a),verticalAlign:m};if(c.type===ls.empty)return f;const b=this.getters.getConditionalIcon(a),v=Pi(f.style),S=b?B+v:0;b&&(f.image={type:"icon",size:v,clipIcon:{x:f.x,y:f.y,width:Math.min(S,g),height:p},image:Cv[b].img}),f.isFilterHeader=this.getters.isFilterHeader(a);const C=f.isFilterHeader?19:0,E=this.getters.getCellComputedStyle(a),w=E.wrapping||"overflow",x="wrap"!==w||h?void 0:g-2*z,y=this.getters.getCellMultiLineText(a,x),I=Math.max(...y.map((e=>this.getters.getTextWidth(e,E)+z))),R=S+I+C,T=this.computeCellAlignment(a,R>g);f.content={textLines:y,width:"overflow"===w?I:g,align:T},c.type===ls.error&&c.error.logLevel>l.silent&&(f.error=c.error.message);const A=R>g||v>p;if(b||f.isFilterHeader)f.clipRect={x:f.x+S,y:f.y,width:Math.max(0,g-S-C),height:p};else if(A&&"overflow"===w){let e,o;switch(this.getters.isInMerge(a)?(e=this.getters.getMerge(a).right,o=r):(e=this.findNextEmptyCol(r,s,n),o=this.findPreviousEmptyCol(r,i,n),f.isOverflow=!0),T){case"left":{const o=wi({col:e,row:n}),{x:i,y:s,width:r,height:a}=this.getters.getVisibleRect(li(t,o));(r<R||v>a||y.length>1)&&(f.clipRect={x:i,y:s,width:r,height:a});break}case"right":{const e=wi({col:o,row:n}),{x:i,y:s,width:r,height:a}=this.getters.getVisibleRect(li(t,e));(r<R||v>a||y.length>1)&&(f.clipRect={x:i,y:s,width:r,height:a});break}case"center":{const i={...t,left:o,right:e},{x:s,y:r,height:n,width:a}=this.getters.getVisibleRect(i),l=R/2,c=f.x+f.width/2;if(s+a<c+l||s>c-l||v>n||y.length>1){const e=s>c-l?s:c-l,t=s+a-e;f.clipRect={x:e,y:r,width:t,height:n}}break}}}else("clip"===w||"wrap"===w||y.length>1)&&(f.clipRect={x:f.x,y:f.y,width:g,height:p});return f}getGridBoxes(){const e=[],t=this.getters.getSheetViewVisibleCols(),o=t[0],i=t[t.length-1],s=this.getters.getSheetViewVisibleRows(),r={left:o,right:i,top:s[0],bottom:s[s.length-1]},n=this.getters.getActiveSheetId();for(const o of s)for(const i of t){const t={sheetId:n,col:i,row:o};this.getters.isInMerge(t)||e.push(this.createZoneBox(n,wi(t),r))}for(const t of this.getters.getMerges(n))if(!this.getters.isMergeHidden(n,t)&&di(t,r)){const o=this.createZoneBox(n,t,r),i=this.getters.getCellBorder({sheetId:n,col:t.right,row:t.bottom});o.border={...o.border,bottom:i?i.bottom:void 0,right:i?i.right:void 0},o.isMerge=!0,e.push(o)}return e}}).add("autofill",class extends nw{static layers=[5];static getters=["getAutofillTooltip"];autofillZone;steps;lastCellSelected={};direction;tooltip;allowDispatch(e){switch(e.type){case"AUTOFILL_SELECT":const t=this.getters.getActiveSheetId();return this.lastCellSelected.col=-1===e.col?this.lastCellSelected.col:xe(e.col,0,this.getters.getNumberCols(t)),this.lastCellSelected.row=-1===e.row?this.lastCellSelected.row:xe(e.row,0,this.getters.getNumberRows(t)),void 0!==this.lastCellSelected.col&&void 0!==this.lastCellSelected.row?0:48;case"AUTOFILL_AUTO":const o=this.getters.getSelectedZone();return o.top===o.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}),this.autofillCF(e.originCol,e.originRow,e.col,e.row)}}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(),o=this.autofillZone;switch(this.direction){case"down":for(let i=t.left;i<=t.right;i++){const s=[];for(let e=t.top;e<=t.bottom;e++)s.push(xt(i,e));const r=this.createGenerator(s);for(let t=o.top;t<=o.bottom;t++)this.computeNewCell(r,i,t,e)}break;case"up":for(let i=t.left;i<=t.right;i++){const s=[];for(let e=t.bottom;e>=t.top;e--)s.push(xt(i,e));const r=this.createGenerator(s);for(let t=o.bottom;t>=o.top;t--)this.computeNewCell(r,i,t,e)}break;case"left":for(let i=t.top;i<=t.bottom;i++){const s=[];for(let e=t.right;e>=t.left;e--)s.push(xt(e,i));const r=this.createGenerator(s);for(let t=o.right;t>=o.left;t--)this.computeNewCell(r,t,i,e)}break;case"right":for(let i=t.top;i<=t.bottom;i++){const s=[];for(let e=t.left;e<=t.right;e++)s.push(xt(e,i));const r=this.createGenerator(s);for(let t=o.left;t<=o.right;t++)this.computeNewCell(r,t,i,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 o=this.getters.getSelectedZone();if(ui(e,t,o))this.autofillZone=void 0;else{switch(this.direction=this.getDirection(e,t),this.direction){case"up":this.saveZone(t,o.top-1,o.left,o.right),this.steps=o.top-t;break;case"down":this.saveZone(o.bottom+1,t,o.left,o.right),this.steps=t-o.bottom;break;case"left":this.saveZone(o.top,o.bottom,e,o.left-1),this.steps=o.left-e;break;case"right":this.saveZone(o.top,o.bottom,o.right+1,e),this.steps=e-o.right}this.autofill(!1)}}autofillAuto(){const e=this.getters.getSelectedZone(),t=this.getters.getActiveSheetId();let o=e.left,i=e.bottom;if(o>0){let e={sheetId:t,col:o-1,row:i};for(;this.getters.getCorrespondingFormulaCell(e)||this.getters.getCell(e)?.content;)i+=1,e={sheetId:t,col:o-1,row:i}}if(i===e.bottom&&(o=e.right,o<=this.getters.getNumberCols(t))){let e={sheetId:t,col:o+1,row:i};for(;this.getters.getCorrespondingFormulaCell(e)||this.getters.getCell(e)?.content;)i+=1,e={sheetId:t,col:o+1,row:i}}i!==e.bottom&&(this.select(e.left,i-1),this.autofill(!0))}computeNewCell(e,t,o,i){const{cellData:s,tooltip:r,origin:n}=e.next(),{content:a,style:l,border:c,format:h}=s;this.tooltip=r,i&&this.dispatch("AUTOFILL_CELL",{originCol:n.col,originRow:n.row,col:t,row:o,content:a,style:l,border:c,format:h})}getRule(e,t){const o=dr.getAll().sort(((e,t)=>e.sequence-t.sequence)).find((o=>o.condition(e,t)));return o&&o.generateRule(e,t)}createGenerator(e){const t=[],o=[],i=this.getters.getActiveSheetId();for(let t of e){const{col:e,row:s}=wt(t),r=this.getters.getCell({sheetId:i,col:e,row:s});o.push({col:e,row:s,cell:r,sheetId:i})}const s=o.map((e=>e.cell));for(let e of o){let o={type:"COPY_MODIFIER"};if(e&&e.cell){o=this.getRule(e.cell,s)||o}const i=this.getters.getCellBorder(e)||void 0;t.push({data:{...e,border:i},rule:o})}return new kw(t,this.getters,this.direction)}saveZone(e,t,o,i){this.autofillZone={top:e,bottom:t,left:o,right:i}}getDirection(e,t){const o=this.getters.getSelectedZone(),i={up:{number:o.top-t,value:"up"},down:{number:t-o.bottom,value:"down"},left:{number:o.left-e,value:"left"},right:{number:e-o.right,value:"right"}};if(1===Object.values(i).map((e=>e.number>0?1:0)).reduce(((e,t)=>e+t)))return Object.values(i).find((e=>e.number>0?1:0)).value;const s=i.up.number>0?"up":"down",r=i.left.number>0?"left":"right";return Math.abs(i[s].number)>=Math.abs(i[r].number)?i[s].value:i[r].value}autoFillMerge(e,t,o,i){const s=this.getters.getActiveSheetId(),r={sheetId:s,col:o,row:i},n={sheetId:s,col:e,row:t};if(this.getters.isInMerge(r)&&!this.getters.isInMerge(n)){const e=this.getters.getMerge(r);e&&this.dispatch("REMOVE_MERGE",{sheetId:s,target:[e]})}const a=this.getters.getMerge(n);a?.topLeft.col===e&&a?.topLeft.row===t&&this.dispatch("ADD_MERGE",{sheetId:s,target:[{top:i,bottom:i+a.bottom-a.top,left:o,right:o+a.right-a.left}]})}autofillCF(e,t,o,i){const s=this.getters.getActiveSheetId(),r=this.getters.getRulesByCell(s,e,t);for(const e of r){const t=this.getters.getAdaptedCfRanges(s,e,[xt(o,i)],[]);t&&this.dispatch("ADD_CONDITIONAL_FORMAT",{cf:Ce(e),ranges:t.map((e=>this.getters.getRangeDataFromXc(s,e))),sheetId:s})}}drawGrid(e){if(!this.autofillZone)return;const{ctx:t,thinLineWidth:o}=e,{x:i,y:s,width:r,height:n}=this.getters.getVisibleRect(this.autofillZone);r>0&&n>0&&(t.strokeStyle="black",t.lineWidth=o,t.setLineDash([3]),t.strokeRect(i,s,r,n),t.setLineDash([]))}}).add("find_and_replace",class extends nw{static layers=[3];static getters=["getSearchMatches","getCurrentSelectedMatchIndex"];searchMatches=[];selectedMatchIndex=null;currentSearchRegex=null;searchOptions={matchCase:!1,exactMatch:!1,searchFormulas:!1};toSearch="";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(jw.previous);break;case"SELECT_SEARCH_NEXT_MATCH":this.selectNextCell(jw.next);break;case"REPLACE_SEARCH":this.replace(e.replaceWith);break;case"REPLACE_ALL_SEARCH":this.replaceAll(e.replaceWith);break;case"UNDO":case"REDO":case"REMOVE_FILTER_TABLE":case"UPDATE_FILTER":case"REMOVE_COLUMNS_ROWS":case"HIDE_COLUMNS_ROWS":case"UNHIDE_COLUMNS_ROWS":case"ADD_COLUMNS_ROWS":case"EVALUATE_CELLS":case"UPDATE_CELL":this.isSearchDirty=!0;break;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(jw.current)}updateRegex(){let e=Se(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),o=[];if(this.toSearch)for(const i of Object.values(t)){const{col:t,row:s}=this.getters.getCellPosition(i.id),r=this.getters.isColHidden(e,t),n=this.getters.isRowHidden(e,s);if(!r&&!n&&(i&&this.currentSearchRegex&&this.currentSearchRegex.test(this.getSearchableString({sheetId:e,col:t,row:s})))){const e={col:t,row:s,selected:!1};o.push(e)}}return o.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 o;o=null===this.selectedMatchIndex?0:this.selectedMatchIndex+e,o=(o%t.length+t.length)%t.length,this.selectedMatchIndex=o,this.selection.selectCell(t[o].col,t[o].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}}replaceMatch(e,t){if(!this.currentSearchRegex)return;const o=this.getters.getActiveSheetId(),i=this.getters.getCell({sheetId:o,...e}),{col:s,row:r}=e;if(i?.isFormula&&!this.searchOptions.searchFormulas)return;const n=new RegExp(this.currentSearchRegex.source,this.currentSearchRegex.flags+"g"),a=bg(this.getSearchableString({sheetId:o,col:s,row:r}).replace(n,t),this.getters.getLocale());this.dispatch("UPDATE_CELL",{sheetId:o,col:s,row:r,content:a})}replace(e){if(null===this.selectedMatchIndex)return;const t=this.searchMatches[this.selectedMatchIndex];this.replaceMatch(t,e),this.selectNextCell(jw.next)}replaceAll(e){const t=this.searchMatches.length;for(let o=0;o<t;o++)this.replaceMatch(this.searchMatches[o],e)}getSearchableString(e){return this.getters.getCellText(e,this.searchOptions.searchFormulas)}drawGrid(e){const{ctx:t}=e,o=this.getters.getActiveSheetId();for(const e of this.searchMatches){const i=this.getters.getMerge({sheetId:o,col:e.col,row:e.row}),s=i?i.left:e.col,r=i?i.right:e.col,n=i?i.top:e.row,a=i?i.bottom:e.row,{x:l,y:c,width:h,height:d}=this.getters.getVisibleRect({top:n,left:s,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)))}}}).add("sort",class extends nw{static getters=["getContiguousZone"];allowDispatch(e){if("SORT_CELLS"===e.type){if(!ui(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;return vi(t).some((({col:t,row:o})=>!this.getters.isInMerge({sheetId:e,col:t,row:o})))?66:0}checkMergeSizes({sheetId:e,zone:t}){if(!this.getters.doesIntersectMerge(e,t))return 0;const o=this.getters.getMerges(e).filter((e=>di(e,t))),i=fi(o[0]);let[s,r]=[i.numberOfCols,i.numberOfRows];return o.every((e=>{let[t,o]=[e.right-e.left+1,e.bottom-e.top+1];return t===s&&o===r}))?0:66}expand(e,t){const{left:o,right:i,top:s,bottom:r}=this.getters.expandZone(e,t);return{left:Math.max(0,o),right:Math.min(this.getters.getNumberCols(e)-1,i),top:Math.max(0,s),bottom:Math.min(this.getters.getNumberRows(e)-1,r)}}checkExpandedValues(e,t){const o=this.expand(e,t);let i;if(this.getters.doesIntersectMerge(e,o)){const{left:t,right:s,top:r,bottom:n}=o;for(let o=t;o<=s;o++)for(let t=r;t<=n;t++){const{col:s,row:r}=this.getters.getMainCellPosition({sheetId:e,col:o,row:t});if(i=this.getters.getEvaluatedCell({sheetId:e,col:s,row:r}),i.formattedValue)return!0}}else for(let t of this.getters.getEvaluatedCellsInZone(e,o))if(t.formattedValue)return!0;return!1}getContiguousZone(e,t){let o,{top:i,bottom:s,left:r,right:n}=t,a=!1;for(;!a;)a=!0,i>0&&(o=this.checkExpandedValues(e,{left:r-1,right:n+1,top:i-1,bottom:i-1}),o&&(a=!1,i--)),r>0&&(o=this.checkExpandedValues(e,{left:r-1,right:r-1,top:i-1,bottom:s+1}),o&&(a=!1,r--)),n<this.getters.getNumberCols(e)-1&&(o=this.checkExpandedValues(e,{left:n+1,right:n+1,top:i-1,bottom:s+1}),o&&(a=!1,n++)),s<this.getters.getNumberRows(e)-1&&(o=this.checkExpandedValues(e,{left:r-1,right:n+1,top:s+1,bottom:s+1}),o&&(a=!1,s++));return{left:r,right:n,top:i,bottom:s}}hasHeader(e,t){if(1===t[0].length)return!1;let o=t.map((t=>t.map((({col:t,row:o})=>this.getters.getEvaluatedCell({sheetId:e,col:t,row:o}).type))));return o[0][0]===ls.empty&&(o=o.slice(1)),!o.some((e=>e[0]===ls.empty))&&!!o.some((e=>e[1]!==ls.empty&&e[0]!==e[1]))}sortZone(e,t,o,i,s){const[r,n]=this.mainCellsSteps(e,o);let a=this.getters.getMainCellPosition({sheetId:e,col:t.col,row:t.row}).col,l=Object.assign({},o),c=this.mainCells(e,o);!s.sortHeaders&&this.hasHeader(e,c)&&(l.top+=n),c=this.mainCells(e,l);const h=function(e,t,o){const i=e.map(((e,t)=>({index:t,type:e.type,value:e.value})));let s=i.filter((e=>e.type===ls.empty)),r=i.filter((e=>e.type!==ls.empty));o&&(r.push(...s.map((e=>({...e,type:ls.number,value:0})))),s=[]);const n="descending"===t?-1:1;return r.sort(((e,t)=>{let o=Rf.indexOf(e.type)-Rf.indexOf(t.type);return 0===o&&(o=e.type===ls.text||e.type===ls.error?e.value.localeCompare(t.value):e.value-t.value),n*o})).concat(s)}(c[a-l.left].map((e=>this.getters.getEvaluatedCell(e))),i,Boolean(s.emptyCellAsZero)),d=h.map((e=>e.index)),[u,g]=[c.length,c[0].length],p=[];for(let e=0;e<u;e++)for(let t=0;t<g;t++){let{col:o,row:i,sheetId:s}=c[e][d[t]];const a=this.getters.getCell({sheetId:s,col:o,row:i});let h=l.left+e*r,u=l.top+t*n,g={sheetId:s,col:h,row:u,content:""};if(a){let e=a.content;if(a.isFormula){const t=u-this.getters.getCellPosition(a.id).row,o=this.getters.createAdaptedRanges(a.dependencies,0,t,s);e=this.getters.buildFormulaContent(s,a,o)}g.style=a.style,g.content=e,g.format=a.format}p.push(g)}p.forEach((e=>this.dispatch("UPDATE_CELL",e)))}mainCellsSteps(e,t){const o=this.getters.getMerge({sheetId:e,col:t.left,row:t.top});return[o?o.right-o.left+1:1,o?o.bottom-o.top+1:1]}mainCells(e,t){const[o,i]=this.mainCellsSteps(e,t),s=[],r=ye(t.left,t.right+1,o),n=ye(t.top,t.bottom+1,i);for(const t of r){const o=[];s.push(o);for(const i of n)o.push({sheetId:e,col:t,row:i})}return s}}).add("automatic_sum",class extends nw{static getters=["getAutomaticSums"];handle(e){if("SUM_SELECTION"===e.type){const e=this.getters.getActiveSheetId(),{zones:t,anchor:o}=this.getters.getSelection();for(const i of t){const t=this.getAutomaticSums(e,i,o.cell);this.dispatchCellUpdates(e,t)}}}getAutomaticSums(e,t,o){return this.shouldFindData(e,t)?this.sumAdjacentData(e,t,o):this.sumData(e,t)}sumData(e,t){const o=this.dimensionsToSum(e,t),i=this.sumDimensions(e,t,o).filter((({zone:t})=>!this.getters.isEmpty(e,t)));return o.has("ROW")&&o.has("COL")&&i.push(this.sumTotal(t)),i}sumAdjacentData(e,t,o){const{col:i,row:s}=ui(o.col,o.row,t)?o:{col:t.left,row:t.top},r=this.findAdjacentData(e,i,s);return r?this.getters.isSingleCellOrMerge(e,t)||bi(li(r,t))?[{position:{col:i,row:s},zone:r}]:this.sumDimensions(e,li(r,t),this.transpose(this.dimensionsToSum(e,t))):[]}findAdjacentData(e,t,o){const i=this.getters.getSheet(e),s=this.getters.getMainCellPosition({sheetId:e,col:t,row:o}),r=this.findSuitableZoneToSum(i,s.col,s.row);if(r)return this.getters.expandZone(e,r)}findSuitableZoneToSum(e,t,o){const i=this.getters.getEvaluatedCell({sheetId:e.id,col:t,row:o-1}),s=this.getters.getEvaluatedCell({sheetId:e.id,col:t-1,row:o});if(this.isNumber(s)&&!this.isNumber(i))return this.findHorizontalZone(e,t,o);const r=this.findVerticalZone(e,t,o);if(this.isZoneValid(r))return r;const n=this.findHorizontalZone(e,t,o);return this.isZoneValid(n)?n:void 0}findVerticalZone(e,t,o){const i={top:0,bottom:o-1,left:t,right:t},s=this.reduceZoneStart(e,i,i.bottom);return{...i,top:s}}findHorizontalZone(e,t,o){const i={top:o,bottom:o,left:0,right:t-1},s=this.reduceZoneStart(e,i,i.right);return{...i,left:s}}reduceZoneStart(e,t,o){const i=this.getters.getEvaluatedCellsInZone(e.id,t),s=ye(o,-1,-1),r=et(s.filter((e=>i[e]&&!i[e].isAutoSummable))),n=Ie(s.filter((e=>this.isNumber(i[e]))))[0]||[];return et(n)<r?1/0:tt(n)}shouldFindData(e,t){return this.getters.isEmpty(e,t)||this.getters.isSingleCellOrMerge(e,t)}isNumber(e){return e.type===ls.number&&!(e.format&&xo(e.format))}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 o=new Set;return bi(t)?(o.add(1===fi(t).numberOfCols?"COL":"ROW"),o):(this.lastColIsEmpty(e,t)&&o.add("ROW"),this.lastRowIsEmpty(e,t)&&o.add("COL"),0===o.size&&o.add("COL"),o)}sumDimensions(e,t,o){return[...o.has("COL")?this.sumColumns(t,e):[],...o.has("ROW")?this.sumRows(t,e):[]]}sumTotal(e){const{bottom:t,right:o}=e;return{position:{col:o,row:t},zone:{...e,top:t,right:o-1}}}sumColumns(e,t){const o=this.nextEmptyRow(t,{...e,bottom:e.bottom-1});return e={...e,bottom:Math.min(e.bottom,o.bottom-1)},vi(o).map((t=>({position:t,zone:{...e,right:t.col,left:t.col}})))}sumRows(e,t){const o=this.nextEmptyCol(t,{...e,right:e.right-1});return e={...e,right:Math.min(e.right,o.right-1)},vi(o).map((t=>({position:t,zone:{...e,top:t.row,bottom:t.row}})))}dispatchCellUpdates(e,t){for(const o of t){const{col:t,row:i}=o.position;this.dispatch("UPDATE_CELL",{sheetId:e,col:t,row:i,content:`=SUM(${this.getters.zoneToXC(e,o.zone)})`})}}nextEmptyRow(e,t){let o=t.bottom+1;const{left:i,right:s}=t;for(;!this.getters.isEmpty(e,{bottom:o,top:o,left:i,right:s});)o++;return{...t,top:o,bottom:o}}nextEmptyCol(e,t){let o=t.right+1;const{top:i,bottom:s}=t;for(;!this.getters.isEmpty(e,{left:o,right:o,top:i,bottom:s});)o++;return{...t,left:o,right:o}}transpose(e){return new Set([...e.values()].map((e=>"COL"===e?"ROW":"COL")))}}).add("format",class extends nw{handle(e){if("SET_DECIMAL"===e.type)this.setDecimal(e.sheetId,e.target,e.step)}setDecimal(e,t,o){for(const i of t)for(const t of vi(i)){const i=this.getCellNumberFormat({sheetId:e,...t});if(void 0!==i){this.getters.getLocale();const s=Lo(i,o);this.dispatch("SET_FORMATTING",{sheetId:e,target:[wi(t)],format:s})}}}getCellNumberFormat(e){for(const t of[e]){const e=this.getters.getEvaluatedCell(t);if(!(e.type!==ls.number||e.format&&xo(e.format)))return e.format||Oo(e.value)}}}).add("split_to_columns",class extends nw{static getters=["getAutomaticSeparator"];allowDispatch(e){return"SPLIT_TEXT_INTO_COLUMNS"===e.type?this.chainValidations(this.batchValidations(this.checkSingleColSelected,this.checkNonEmptySelector),this.batchValidations(this.checkNotOverwritingContent,this.checkSeparatorInSelection))(e):0}handle(e){if("SPLIT_TEXT_INTO_COLUMNS"===e.type)this.splitIntoColumns(e)}getAutomaticSeparator(){const e=this.getters.getSelectedCells();for(const t of e)if(t.value&&t.type===ls.text){const e=this.getAutoSeparatorForString(t.value);if(e)return e}return" "}getAutoSeparatorForString(e){const t=[fe,";",","," ","."];for(const o of t)if(e.includes(o))return o}splitIntoColumns({separator:e,addNewColumns:t}){const o=this.getters.getSelectedZone(),i=this.getters.getActiveSheetId(),s=this.getSplittedCols(o,e);t&&this.addColsToAvoidCollisions(o,s),this.removeMergesInSplitZone(o,s),this.addColumnsToNotOverflowSheet(o,s);for(let e=0;e<s.length;e++){const t=o.top+e,r=s[e],n=o.left,a=this.getters.getCell({sheetId:i,col:n,row:t});if(1!==r.length||r[0]!==a?.content)for(const[e,o]of r.entries())this.dispatch("UPDATE_CELL",{sheetId:i,col:n+e,row:t,content:bg(o,this.getters.getLocale()),format:"",style:a?.style||null})}}getSplittedCols(e,t){if(!t)throw new Error("Separator cannot be empty");const o=this.getters.getActiveSheetId(),i=[];for(const s of ye(e.top,e.bottom+1)){const r=this.getters.getEvaluatedCell({sheetId:o,col:e.left,row:s}).formattedValue;i.push(this.splitAndRemoveTrailingEmpty(r,t))}return i}splitAndRemoveTrailingEmpty(e,t){const o=e.split(t);for(;o.length>1&&""===o[o.length-1];)o.pop();return o}willSplittedColsOverwriteContent(e,t){const o=this.getters.getActiveSheetId();for(const i of ye(e.top,e.bottom+1)){const s=t[i-e.top];for(let t=1;t<s.length;t++){const s=this.getters.getCell({sheetId:o,col:e.left+t,row:i});if(s&&s.content)return!0}}return!1}removeMergesInSplitZone(e,t){const o=this.getters.getActiveSheetId(),i=Math.max(...t.map((e=>e.length))),s={...e,right:e.left+i-1},r=this.getters.getMergesInZone(o,s);this.dispatch("REMOVE_MERGE",{sheetId:o,target:r})}addColsToAvoidCollisions(e,t){const o=this.getters.getActiveSheetId();let i=0;for(const s of ye(e.top,e.bottom+1)){const r={sheetId:o,col:e.left,row:s},n=t[s-e.top],a=this.getColsToAddToAvoidCollision(r,n);i=Math.max(i,a)}i&&this.dispatch("ADD_COLUMNS_ROWS",{dimension:"COL",base:e.left,sheetId:o,quantity:i,position:"after"})}getColsToAddToAvoidCollision(e,t){const o=t.length;for(let t=1;t<o;t++){const i=e.col+t,s=this.getters.getCell({...e,col:i});if(s&&s.content)return o-t}return 0}addColumnsToNotOverflowSheet(e,t){const o=this.getters.getActiveSheetId(),i=Math.max(...t.map((e=>e.length-1))),s=this.getters.getNumberCols(o)-1;e.left+i>s&&this.dispatch("ADD_COLUMNS_ROWS",{dimension:"COL",base:s,sheetId:o,quantity:e.left+i-s,position:"after"})}checkSingleColSelected(){return this.getters.isSingleColSelected()?0:91}checkNonEmptySelector(e){return""===e.separator?92:0}checkNotOverwritingContent(e){if(e.addNewColumns||e.force)return 0;const t=this.getters.getSelectedZones()[0],o=this.getSplittedCols(t,e.separator);return this.willSplittedColsOverwriteContent(t,o)?93:0}checkSeparatorInSelection({separator:e}){const t=this.getters.getSelectedCells();for(const o of t)if(o.formattedValue.includes(e))return 0;return 94}}).add("cell_popovers",class extends nw{static getters=["getCellPopover","getPersistentPopoverTypeAtPosition","hasOpenedPopover"];persistentPopover;allowDispatch(e){if("OPEN_CELL_POPOVER"===e.type){try{Hg.get(e.popoverType)}catch(e){return 75}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,sheetId:this.getters.getActiveSheetId(),type:e.popoverType}}}getCellPopover({col:e,row:t}){const o=this.getters.getActiveSheetId();if(this.persistentPopover&&this.getters.isVisibleInViewport(this.persistentPopover)){const e=this.getters.getMainCellPosition(this.persistentPopover),t=Hg.get(this.persistentPopover.type).onOpen?.(e,this.getters);return t?.isOpen?{...t,anchorRect:this.computePopoverAnchorRect(this.persistentPopover)}:{isOpen:!1}}if(void 0===e||void 0===t||!this.getters.isVisibleInViewport({sheetId:o,col:e,row:t}))return{isOpen:!1};const i=this.getters.getMainCellPosition({sheetId:o,col:e,row:t}),s=Hg.getAll().map((e=>e.onHover?.(i,this.getters))).find((e=>e?.isOpen));return s?.isOpen?{...s,anchorRect:this.computePopoverAnchorRect(i)}:{isOpen:!1}}hasOpenedPopover(){return void 0!==this.persistentPopover}getPersistentPopoverTypeAtPosition({col:e,row:t}){if(this.persistentPopover&&this.persistentPopover.col===e&&this.persistentPopover.row===t)return this.persistentPopover.type}computePopoverAnchorRect({col:e,row:t}){const o=this.getters.getActiveSheetId(),i=this.getters.getMerge({sheetId:o,col:e,row:t});return i?this.getters.getVisibleRect(i):this.getters.getVisibleRect(wi({col:e,row:t}))}}).add("collaborative",class extends nw{static getters=["getClientsToDisplay","getClient","getConnectedClients","isFullySynchronized"];static layers=[6];availableColors=new Set(Yw);colors={};session;constructor(e){super(e),this.session=e.session}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(Yw));const e=(t=[...this.availableColors.values()])[Math.floor(Math.random()*t.length)];var t;return this.availableColors.delete(e),e}getClient(){return this.session.getClient()}getConnectedClients(){return this.session.getConnectedClients()}isFullySynchronized(){return this.session.isFullySynchronized()}getClientsToDisplay(){try{this.getters.getClient()}catch(e){if(e instanceof qw)return[];throw e}const e=this.getters.getActiveSheetId(),t=[];for(const o of this.getters.getConnectedClients())if(o.id!==this.getters.getClient().id&&o.position&&o.position.sheetId===e&&this.isPositionValid(o.position)){const e=o.position;this.colors[o.id]||(this.colors[o.id]=this.chooseNewColor());const i=this.colors[o.id];t.push({...o,position:e,color:i})}return t}drawGrid(e){if(this.getters.isDashboard())return;const{ctx:t,thinLineWidth:o}=e,i=this.getters.getActiveSheetId();for(const e of this.getClientsToDisplay()){const{row:s,col:r}=e.position,n=this.getters.expandZone(i,{top:s,bottom:s,left:r,right:r}),{x:a,y:l,width:c,height:h}=this.getters.getVisibleRect(n);if(c<=0||h<=0)continue;const d=e.color,u=`${d}10`;t.fillStyle=u,t.lineWidth=4*o,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 ${Z+1}px ${Y}`}}}).add("history",class extends nw{static getters=["canUndo","canRedo"];undoStack=[];redoStack=[];session;constructor(e){super(e),this.session=e.session,this.session.on("new-local-state-update",this,this.onNewLocalStateUpdate),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}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();if(t)"UNDO"===e?(this.session.undo(t),this.redoStack.push(t)):(this.session.redo(t),this.undoStack.push(t));else{const e=this.getPossibleRevisionToRepeat();if(!e)return;const t=ax(e,this.getters);if(!t)return;if(!Array.isArray(t))return void this.dispatch(t.type,t);for(const e of t)this.dispatch(e.type,e)}}canUndo(){return this.undoStack.length>0}canRedo(){if(this.redoStack.length>0)return!0;const e=this.getPossibleRevisionToRepeat();return!(!(t=e)||!t.rootCommand||"object"!=typeof t.rootCommand)&&(ms(t.rootCommand)?ix.contains(t.rootCommand.type):sx.contains(t.rootCommand.type));var t}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()}getPossibleRevisionToRepeat(){return this.session.getLastLocalNonEmptyRevision(["REQUEST_REDO"])}}),xx=(new Ji).add("selection",class extends nw{static layers=[6];static getters=["getActiveSheet","getActiveSheetId","getActiveCell","getActiveCols","getActiveRows","getCurrentStyle","getSelectedZones","getSelectedZone","getSelectedCells","getStatisticFnResults","getAggregate","getSelectedFigureId","getSelection","getActivePosition","getSheetPosition","isSelected","isSingleColSelected","getElementsFromSelection","tryGetActiveSheetId","isGridSelectionActive"];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}]};selectedFigureId=null;sheetsData={};moveClient;activeSheet=null;constructor(e){super(e),this.moveClient=e.moveClient}allowDispatch(e){switch(e.type){case"ACTIVATE_SHEET":try{this.getters.getSheet(e.sheetIdTo);break}catch(e){return 28}case"MOVE_COLUMNS_ROWS":return this.isMoveElementAllowed(e)}return 0}handleEvent(e){const t=e.anchor;let o=[];switch(e.mode){case"overrideSelection":o=[t.zone];break;case"updateAnchor":o=[...this.gridSelection.zones];const i=o.findIndex((t=>hi(t,e.previousAnchor.zone)));i>=0&&(o[i]=t.zone);break;case"newAnchor":o=[...this.gridSelection.zones,t.zone]}this.setSelectionMixin(e.anchor,o),this.selection.resetDefaultAnchor(this,Ce(this.gridSelection.anchor));const{col:i,row:s}=this.gridSelection.anchor.cell;this.moveClient({sheetId:this.getters.getActiveSheetId(),col:i,row:s}),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:o,row:i}=this.getters.getNextVisibleCellPosition({sheetId:t,col:0,row:0});this.selectCell(o,i),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:Ce(this.gridSelection)},e.sheetIdTo in this.sheetsData)Object.assign(this,this.sheetsData[e.sheetIdTo]),this.selection.resetDefaultAnchor(this,Ce(this.gridSelection.anchor));else{const{col:t,row:o}=this.getters.getNextVisibleCellPosition({sheetId:e.sheetIdTo,col:0,row:0});this.selectCell(t,o)}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:o,row:i}=this.gridSelection.anchor.cell;this.moveClient({sheetId:t,col:o,row:i})}break}case"ADD_COLUMNS_ROWS":{const t=this.getters.getActiveSheetId();if(e.sheetId===t){this.onAddElements(e);const{col:o,row:i}=this.gridSelection.anchor.cell;this.moveClient({sheetId:t,col:o,row:i})}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 s=Object.keys(this.sheetsData).filter((e=>!this.getters.tryGetSheet(e)));for(const e of s)delete this.sheetsData[e];for(const e in this.sheetsData){const t=this.clipSelection(e,this.sheetsData[e].gridSelection);this.sheetsData[e]={gridSelection:Ce(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:o}=this.gridSelection.anchor.cell;this.moveClient({sheetId:this.getters.getActiveSheetId(),col:t,row:o})}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.selectedFigureId=null}this.selection.resetDefaultAnchor(this,Ce(this.gridSelection.anchor))}isGridSelectionActive(){return this.selection.isListening(this)}getActiveSheet(){return this.activeSheet}getActiveSheetId(){return this.activeSheet.id}tryGetActiveSheetId(){return this.activeSheet?.id}getActiveCell(){return this.getters.getEvaluatedCell(this.getActivePosition())}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 o=t.left;o<=t.right;o++)e.add(o);return e}getActiveRows(){const e=new Set,t=this.getters.getActiveSheetId();for(let o of this.gridSelection.zones)if(0===o.left&&o.right===this.getters.getNumberCols(t)-1)for(let t=o.top;t<=o.bottom;t++)e.add(t);return e}getCurrentStyle(){const e=this.getters.getSelectedZone(),t=this.getters.getActiveSheetId();return this.getters.getCellStyle({sheetId:t,col:e.left,row:e.top})}getSelectedZones(){return Ce(this.gridSelection.zones)}getSelectedZone(){return Ce(this.gridSelection.anchor.zone)}getSelection(){return Ce(this.gridSelection)}getSelectedCells(){const e=this.getters.getActiveSheetId(),t=[];for(const o of this.gridSelection.zones)t.push(...this.getters.getEvaluatedCellsInZone(e,o));return t}getSelectedFigureId(){return this.selectedFigureId}getActivePosition(){return this.getters.getMainCellPosition({sheetId:this.getActiveSheetId(),col:this.gridSelection.anchor.cell.col,row:this.gridSelection.anchor.cell.row})}getSheetPosition(e){if(e===this.getters.getActiveSheetId())return this.getActivePosition();{const t=this.sheetsData[e];return t?{sheetId:e,col:t.gridSelection.anchor.cell.col,row:t.gridSelection.anchor.cell.row}:this.getters.getNextVisibleCellPosition({sheetId:e,col:0,row:0})}}getStatisticFnResults(){const e=this.getters.getActiveSheetId(),t=new Set;for(const o of this.gridSelection.zones)for(const{col:i,row:s}of vi(o)){if(this.getters.isRowHidden(e,s)||this.getters.isColHidden(e,i))continue;const o=this.getters.getEvaluatedCell({sheetId:e,col:i,row:s});o.type!==ls.empty&&t.add(o)}let o=new Set,i=[];for(let e of t)o.add(e.type),i.push(e.value);const s=this.getters.getLocale();let r={};for(let e of Sx){let t;e.types.some((e=>o.has(e)))&&(t=e.compute(i,s)),r[e.name]=t}return r}getAggregate(){let e=0,t=0;const o=this.getters.getActiveSheetId(),i=this.gridSelection.zones.map(vi).flat();for(const{col:s,row:r}of i){const i=this.getters.getEvaluatedCell({sheetId:o,col:s,row:r});i.type===ls.number&&(t++,e+=i.value)}const s=this.getters.getLocale();return t<2?null:fo(e,{locale:s})}isSelected(e){return!!this.getters.getSelectedZones().find((t=>hi(t,e)))}isSingleColSelected(){const e=this.getters.getSelectedZones();return 1===e.length&&e[0].left===e[0].right}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 o=[];const i="COL"===e?"left":"top",s="COL"===e?"right":"bottom";for(const e of t){const t=Array.from({length:e[s]-e[i]+1},((t,o)=>e[i]+o));o=o.concat(t)}return[...new Set(o)].sort()}setSelectionMixin(e,t){const{anchor:o,zones:i}=this.clipSelection(this.getters.getActiveSheetId(),{anchor:e,zones:t});this.gridSelection.anchor=o,this.gridSelection.zones=function(e){return e.reverse().filter(((e,t,o)=>t===o.findIndex((t=>t.top===e.top&&t.bottom===e.bottom&&t.left===e.left&&t.right===e.right)))).reverse()}(i)}selectCell(e,t){const o=this.getters.getActiveSheetId(),i=this.getters.expandZone(o,{left:e,right:e,top:t,bottom:t});this.setSelectionMixin({zone:i,cell:{col:e,row:t}},[i])}setActiveSheet(e){const t=this.getters.getSheet(e);this.activeSheet=t}activateNextSheet(e){const t=this.getters.getSheetIds(),o=(t.findIndex((e=>e===this.activeSheet.id))+("left"===e?t.length-1:1))%t.length;this.dispatch("ACTIVATE_SHEET",{sheetIdFrom:this.getActiveSheetId(),sheetIdTo:t[o]})}onColumnsRemoved(e){const{cell:t,zone:o}=this.gridSelection.anchor,i=ni(o,"left",[...e.elements]);let s={left:t.col,right:t.col,top:t.row,bottom:t.row};s=ni(s,"left",[...e.elements]);const r={cell:{col:s.left,row:s.top},zone:i},n=this.gridSelection.zones.map((t=>ni(t,"left",[...e.elements])));this.setSelectionMixin(r,n)}onRowsRemoved(e){const{cell:t,zone:o}=this.gridSelection.anchor,i=ni(o,"top",[...e.elements]);let s={left:t.col,right:t.col,top:t.row,bottom:t.row};s=ni(s,"top",[...e.elements]);const r={cell:{col:s.left,row:s.top},zone:i},n=this.gridSelection.zones.map((t=>ni(t,"top",[...e.elements])));this.setSelectionMixin(r,n)}onAddElements(e){const t="COL"===e.dimension?"left":"top",o=ri(this.gridSelection.anchor.zone,t,e.base,e.position,e.quantity),i=this.gridSelection.zones.map((o=>ri(o,t,e.base,e.position,e.quantity))),s={cell:{col:o.left,row:o.top},zone:o};this.setSelectionMixin(s,i)}onMoveElements(e){const t=e.elements.length;this.dispatch("ADD_COLUMNS_ROWS",{dimension:e.dimension,sheetId:e.sheetId,base:e.base,quantity:t,position:e.position});const o="COL"===e.dimension,i=e.elements[0],s=e.elements[t-1],r=e.base<i,n=r&&o?t:0,a=r&&!o?t:0,l=[{left:o?i+n:0,right:o?s+n:this.getters.getNumberCols(e.sheetId)-1,top:o?0:i+a,bottom:o?this.getters.getNumberRows(e.sheetId)-1:s+a}],c=new cx(l,"CUT",this.getters,this.dispatch,this.selection),h=r?e.base:e.base+1,d=[{left:o?h:0,right:o?h+t-1:this.getters.getNumberCols(e.sheetId)-1,top:o?0:h,bottom:o?this.getters.getNumberRows(e.sheetId)-1:h+t-1}];c.paste(d,{selectTarget:!0});const u=r?e.elements.map((e=>e+t)):e.elements;let g=e.base;for(const t of u){const o="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:o,elements:[g]}),g+=1}this.dispatch("REMOVE_COLUMNS_ROWS",{dimension:e.dimension,sheetId:e.sheetId,elements:u})}isMoveElementAllowed(e){const t="COL"===e.dimension,o=e.elements[0],i=e.elements[e.elements.length-1],s=e.sheetId,r=t?this.getters.doesColumnsHaveCommonMerges:this.getters.doesRowsHaveCommonMerges;if(r(s,o-1,o)||r(s,i,i+1)||r(s,e.base-1,e.base))return 2;const n=[e.base,...e.elements],a=t?this.getters.getNumberCols(s):this.getters.getNumberRows(s);return n.some((e=>e<0||e>=a))?89:0}clipSelection(e,t){const o=this.getters.getNumberCols(e)-1,i=this.getters.getNumberRows(e)-1;return{zones:t.zones.map((e=>({left:xe(e.left,0,o),right:xe(e.right,0,o),top:xe(e.top,0,i),bottom:xe(e.bottom,0,i)}))),anchor:{cell:{col:xe(t.anchor.cell.col,0,o),row:xe(t.anchor.cell.row,0,i)},zone:{left:xe(t.anchor.zone.left,0,o),right:xe(t.anchor.zone.right,0,o),top:xe(t.anchor.zone.top,0,i),bottom:xe(t.anchor.zone.bottom,0,i)}}}}drawGrid(e){if(this.getters.isDashboard())return;const{ctx:t,thinLineWidth:o}=e,i=this.getSelectedZones();t.fillStyle="#f3f7fe";const s=1===i.length&&i[0].left===i[0].right&&i[0].top===i[0].bottom;t.fillStyle=s?"#f3f7fe":"#e9f0ff",t.strokeStyle=E,t.lineWidth=1.5*o;for(const e of i){const{x:o,y:i,width:s,height:r}=this.getters.getVisibleRect(e);t.globalCompositeOperation="multiply",t.fillRect(o,i,s,r),t.globalCompositeOperation="source-over",t.strokeRect(o,i,s,r)}t.globalCompositeOperation="source-over";const r=this.getActivePosition();let n;t.strokeStyle=E,t.lineWidth=3*o,n=this.getters.isInMerge(r)?this.getters.getMerge(r):wi(r);const{x:a,y:l,width:c,height:h}=this.getters.getVisibleRect(n);c>0&&h>0&&t.strokeRect(a,l,c,h)}}).add("evaluation_filter",class extends nw{static getters=["getCellBorderWithFilterBorder","getFilterValues","isRowFiltered","isFilterActive"];filterValues={};hiddenRows=new Set;isEvaluationDirty=!1;allowDispatch(e){if("UPDATE_FILTER"===e.type)if(!this.getters.getFilterId(e))return 82;return 0}handle(e){switch(e.type){case"UNDO":case"REDO":case"UPDATE_CELL":case"EVALUATE_CELLS":case"ACTIVATE_SHEET":case"REMOVE_FILTER_TABLE":case"ADD_COLUMNS_ROWS":case"REMOVE_COLUMNS_ROWS":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 o of this.getters.getFilters(e.sheetIdTo)){const i=o.zoneWithHeaders;t[o.id]=this.getFilterValues({sheetId:e.sheetId,col:i.left,row:i.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){const{sheetId:t,col:o,row:i}=e;let s;for(let e of this.getters.getFilterTables(t)){const r=e.zone;if(ui(o,i,r)){const e=this.intersectZoneWithViewport(t,r);s={top:i===e.top?J:void 0,bottom:i===e.bottom?J:void 0,left:o===e.left?J:void 0,right:o===e.right?J:void 0}}}const r=this.getters.getCellBorder(e),n={...s,...qe(r||{})};return Ue(n)?null:n}getFilterValues(e){const t=this.getters.getFilterId(e),o=e.sheetId;return t&&this.filterValues[o]&&this.filterValues[o][t]||[]}isFilterActive(e){const t=this.getters.getFilterId(e),o=e.sheetId;return Boolean(t&&this.filterValues[o]?.[t]?.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:o,sheetId:i}){const s=this.getters.getFilterId({sheetId:i,col:e,row:t});s&&(this.filterValues[i]||(this.filterValues[i]={}),this.filterValues[i][s]=o)}updateHiddenRows(){const e=this.getters.getActiveSheetId(),t=this.getters.getFilters(e).sort(((e,t)=>e.zoneWithHeaders.top-t.zoneWithHeaders.top)),o=new Set;for(let i of t){if(this.getters.isRowHiddenByUser(e,i.zoneWithHeaders.top))continue;if(o.has(i.zoneWithHeaders.top))continue;const t=this.filterValues[e]?.[i.id]?.map(Vi);if(t&&i.filteredZone)for(let s=i.filteredZone.top;s<=i.filteredZone.bottom;s++){const r=this.getCellValueAsString(e,i.col,s);t.includes(r)&&o.add(s)}}this.hiddenRows=o}getCellValueAsString(e,t,o){return this.getters.getEvaluatedCell({sheetId:e,col:t,row:o}).formattedValue.toLowerCase()}exportForExcel(e){for(const t of e.sheets){const e=t.id;for(const o of t.filterTables){const i=ti(o.range),s=[],r=[];for(const o of ye(0,fi(i).numberOfCols)){const n={sheetId:t.id,col:i.left+o,row:i.top},a=this.getFilterValues(n),l=this.getters.getFilter(n);if(!l)continue;const c=l.filteredZone?vi(l.filteredZone).map((t=>this.getters.getEvaluatedCell({sheetId:e,...t}).formattedValue)):[];if(a.length){const e=c.filter((e=>e)).filter((e=>!a.includes(e)));s.push({colId:o,displayedValues:[...new Set(e)],displayBlanks:!a.includes("")&&c.some((e=>!e))})}const h={col:l.col,row:l.zoneWithHeaders.top,sheetId:e},d=this.getters.getEvaluatedCell(h).formattedValue,u=this.getUniqueColNameForExcel(o,d,r);r.push(u),t.cells[xt(h.col,h.row)]={...t.cells[xt(h.col,h.row)],content:u,value:u,isFormula:!1}}o.filters=s}}}getUniqueColNameForExcel(e,t,o){t||(t=`Column${e}`);let i=t,s=2;for(;o.includes(i);)i=t+String(s),s++;return i}}).add("viewport",class extends nw{static getters=["getColIndex","getRowIndex","getActiveMainViewport","getSheetViewDimension","getSheetViewDimensionWithHeaders","getMainViewportRect","isVisibleInViewport","getEdgeScrollCol","getEdgeScrollRow","getVisibleFigures","getVisibleRect","getColRowOffsetInViewport","getMainViewportCoordinates","getActiveSheetScrollInfo","getActiveSheetDOMScrollInfo","getSheetViewVisibleCols","getSheetViewVisibleRows","getFrozenSheetViewRatio","isPositionVisible"];viewports={};sheetViewWidth=me();sheetViewHeight=me();gridOffsetX=0;gridOffsetY=0;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){if(e.options.scrollIntoView){let{col:t,row:o}=Ci(e.previousAnchor.zone,e.anchor.zone);if("updateAnchor"===e.mode){const i=e.previousAnchor.zone,s=e.anchor.zone,{top:r,bottom:n,left:a,right:l}=this.getters.getActiveMainViewport();i.left===s.left&&i.right===s.right&&(t=a>t||t>l?a:t),i.top===s.top&&i.bottom===s.bottom&&(o=r>o||o>n?r:o)}const i=this.getters.getActiveSheetId();t=Math.min(t,this.getters.getNumberCols(i)-1),o=Math.min(o,this.getters.getNumberRows(i)-1),this.refreshViewport(this.getters.getActiveSheetId(),{col:t,row:o})}}handle(e){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:t}=this.getActiveMainViewport(),o=this.getters.getActiveSheetId(),i=this.clipOffsetY(this.getters.getRowDimensions(o,t).start+this.sheetViewHeight);this.shiftVertically(i);break;case"SHIFT_VIEWPORT_UP":{const{top:e}=this.getActiveMainViewport(),t=this.getters.getActiveSheetId(),o=this.clipOffsetY(this.getters.getRowDimensions(t,e).end-this.sheetViewHeight);this.shiftVertically(o);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!==e.style?.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"DELETE_SHEET":this.sheetsWithDirtyViewports.delete(e.sheetId);break;case"START_EDITION":const{col:s,row:r}=this.getters.getActivePosition();this.refreshViewport(this.getters.getActiveSheetId(),{col:s,row:r})}}finalize(){for(const e of this.sheetsWithDirtyViewports)this.resetViewports(e);this.sheetsWithDirtyViewports=new Set,this.setViewports()}setViewports(){const e=this.getters.getSheetIds();for(const t of e)this.viewports[t]?.bottomRight||this.resetViewports(t)}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=>ye(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=>ye(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:o,ySplit:i}=this.getters.getPaneDivisions(e);let{width:s,height:r}=t.getMaxSize();return{x:this.getters.getColDimensions(e,o).start,y:this.getters.getRowDimensions(e,i).start,width:s,height:r}}getMaximumSheetOffset(){const e=this.getters.getActiveSheetId(),{width:t,height:o}=this.getMainViewportRect(),i=this.getMainInternalViewport(e);return{maxOffsetX:Math.max(0,t-i.viewportWidth+1),maxOffsetY:Math.max(0,o-i.viewportHeight+1)}}getColRowOffsetInViewport(e,t,o){const i=this.getters.getActiveSheetId(),s=this.getters.getSheetViewVisibleCols(),r=this.getters.getSheetViewVisibleRows();if(o<t)return-this.getColRowOffsetInViewport(e,o,t);let n=0;const a="COL"===e?s:r;for(let s=t;s<o;s++)a.includes(s)&&(n+="COL"===e?this.getters.getColSize(i,s):this.getters.getRowSize(i,s));return n}isVisibleInViewport({sheetId:e,col:t,row:o}){return this.getSubViewports(e).some((e=>e.isVisible(t,o)))}getEdgeScrollCol(e,t,o){let i=!1,s=0,r=0;const{xSplit:n}=this.getters.getPaneDivisions(this.getters.getActiveSheetId()),{width:a}=this.getSheetViewDimension(),{x:l}=this.getMainViewportCoordinates(),c=this.getActiveSheetScrollInfo().scrollX;return e>a?(i=!0,r=Qt(e-a),s=1):e<l&&o>=l&&c>0?(i=!0,r=Qt(l-e),s=-1):n&&t<l&&e>l&&(i=!0,r=Qt(e),s="reset"),{canEdgeScroll:i,direction:s,delay:r}}getEdgeScrollRow(e,t,o){let i=!1,s=0,r=0;const{ySplit:n}=this.getters.getPaneDivisions(this.getters.getActiveSheetId()),{height:a}=this.getSheetViewDimension(),{y:l}=this.getMainViewportCoordinates(),c=this.getActiveSheetScrollInfo().scrollY;return e>a?(i=!0,r=Qt(e-a),s=1):e<l&&o>=l&&c>0?(i=!0,r=Qt(l-e),s=-1):n&&t<l&&e>l&&(i=!0,r=Qt(e),s="reset"),{canEdgeScroll:i,direction:s,delay:r}}getVisibleRect(e){const t=this.getters.getActiveSheetId(),o=this.getSubViewports(t).map((t=>t.getRect(e))).filter(ke);if(0===o.length)return{x:0,y:0,width:0,height:0};const i=Math.min(...o.map((e=>e.x))),s=Math.min(...o.map((e=>e.y))),r=Math.max(...o.map((e=>e.x+e.width)))-i,n=Math.max(...o.map((e=>e.y+e.height)))-s;return{x:i+this.gridOffsetX,y:s+this.gridOffsetY,width:r,height:n}}getMainViewportCoordinates(){const e=this.getters.getActiveSheetId(),{xSplit:t,ySplit:o}=this.getters.getPaneDivisions(e);return{x:this.getters.getColDimensions(e,t).start,y:this.getters.getRowDimensions(e,o).start}}ensureMainViewportExist(e){this.viewports[e]||this.resetViewports(e)}getSubViewports(e){return this.ensureMainViewportExist(e),Object.values(this.viewports[e]).filter(ke)}checkPositiveDimension(e){return e.width<0||e.height<0?71:0}checkValuesAreDifferent(e){const{height:t,width:o}=this.getSheetViewDimension();return e.gridOffsetX===this.gridOffsetX&&e.gridOffsetY===this.gridOffsetY&&e.width===o&&e.height===t?79:0}checkScrollingDirection({offsetX:e,offsetY:t}){const o=this.getMainInternalViewport(this.getters.getActiveSheetId());return!o.canScrollHorizontally&&e>0||!o.canScrollVertically&&t>0?72: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 o=this.getSubViewports(e);Object.values(o).forEach((e=>{e.adjustPosition(t)}))}}resizeSheetView(e,t,o=0,i=0){this.sheetViewHeight=e,this.sheetViewWidth=t,this.gridOffsetX=o,this.gridOffsetY=i,this.recomputeViewports()}recomputeViewports(){for(let e of Object.keys(this.viewports))this.resetViewports(e)}setSheetViewOffset(e,t){const o=this.getters.getActiveSheetId(),{maxOffsetX:i,maxOffsetY:s}=this.getMaximumSheetOffset();Object.values(this.getSubViewports(o)).forEach((o=>o.setViewportOffset(xe(e,0,i),xe(t,0,s))))}clipOffsetY(e){const{height:t}=this.getMainViewportRect(),o=t-this.sheetViewHeight;return e=Math.min(e,o),e=Math.max(e,0)}getViewportOffset(e){return{x:this.viewports[e]?.bottomRight.offsetScrollbarX||0,y:this.viewports[e]?.bottomRight.offsetScrollbarY||0}}resetViewports(e){if(!this.getters.tryGetSheet(e))return;const{xSplit:t,ySplit:o}=this.getters.getPaneDivisions(e),i=this.getters.getNumberCols(e),s=this.getters.getNumberRows(e),r=this.getters.getColRowOffset("COL",0,t,e),n=this.getters.getColRowOffset("ROW",0,o,e),{xRatio:a,yRatio:l}=this.getFrozenSheetViewRatio(e),c=a<1,h=l<1,d=this.getViewportOffset(e),u={topLeft:o&&t&&new Cx(this.getters,e,{left:0,right:t-1,top:0,bottom:o-1},{width:r,height:n},{canScrollHorizontally:!1,canScrollVertically:!1},{x:0,y:0})||void 0,topRight:o&&new Cx(this.getters,e,{left:t,right:i-1,top:0,bottom:o-1},{width:this.sheetViewWidth-r,height:n},{canScrollHorizontally:c,canScrollVertically:!1},{x:c?d.x:0,y:0})||void 0,bottomLeft:t&&new Cx(this.getters,e,{left:0,right:t-1,top:o,bottom:s-1},{width:r,height:this.sheetViewHeight-n},{canScrollHorizontally:!1,canScrollVertically:h},{x:0,y:h?d.y:0})||void 0,bottomRight:new Cx(this.getters,e,{left:t,right:i-1,top:o,bottom:s-1},{width:this.sheetViewWidth-r,height:this.sheetViewHeight-n},{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:o}=this.getActiveSheetScrollInfo();this.setSheetViewOffset(o,e);const{anchor:i}=this.getters.getSelection(),s=this.getActiveMainViewport().top-t;this.selection.selectCell(i.cell.col,i.cell.row+s)}getVisibleFigures(){const e=this.getters.getActiveSheetId(),t=[],o=this.getters.getFigures(e),{scrollX:i,scrollY:s}=this.getActiveSheetScrollInfo(),{x:r,y:n}=this.getters.getMainViewportCoordinates(),{width:a,height:l}=this.getters.getSheetViewDimensionWithHeaders();for(const e of o)e.x>=r&&(e.x+e.width<=r+i||e.x>=a+i+r)||e.y>=n&&(e.y+e.height<=n+s||e.y>=l+s+n)||t.push(e);return t}isPositionVisible(e){const{scrollX:t,scrollY:o}=this.getters.getActiveSheetScrollInfo(),{x:i,y:s}=this.getters.getMainViewportCoordinates(),{width:r,height:n}=this.getters.getSheetViewDimension();return!(e.x>=i&&(e.x<i+t||e.x>r+t+i))&&!(e.y>=s&&(e.y<s+o||e.y>n+o+s))}getFrozenSheetViewRatio(e){const{xSplit:t,ySplit:o}=this.getters.getPaneDivisions(e),i=this.getters.getColDimensions(e,t).start,s=this.getters.getRowDimensions(e,o).start;return{xRatio:i/(this.sheetViewWidth+this.gridOffsetX),yRatio:s/(this.sheetViewHeight+this.gridOffsetY)}}}).add("clipboard",class extends nw{static layers=[2];static getters=["getClipboardContent","getClipboardTextContent","isCutOperation","isPaintingFormat"];status="invisible";state;lastPasteState;paintFormatStatus="inactive";originSheetId;allowDispatch(e){switch(e.type){case"CUT":const t=this.getters.getSelectedZones();return this.getClipboardState(t,e.type).isCutAllowed(t);case"PASTE":if(!this.state)return 24;const o=e.pasteOption||("inactive"!==this.paintFormatStatus?"onlyFormat":void 0);return this.state.isPasteAllowed(e.target,{pasteOption:o});case"PASTE_FROM_OS_CLIPBOARD":return new px(e.text,this.getters,this.dispatch,this.selection).isPasteAllowed(e.target,{pasteOption:e.pasteOption});case"INSERT_CELL":{const{cut:t,paste:o}=this.getInsertCellsTargets(e.zone,e.shiftDimension);return this.getClipboardStateForCopyCells(t,"CUT").isPasteAllowed(o)}case"DELETE_CELL":{const{cut:t,paste:o}=this.getDeleteCellsTargets(e.zone,e.shiftDimension);return this.getClipboardStateForCopyCells(t,"CUT").isPasteAllowed(o)}case"ACTIVATE_PAINT_FORMAT":if("inactive"!==this.paintFormatStatus)return 97}return 0}handle(e){switch(e.type){case"COPY":case"CUT":const t=this.getters.getSelectedZones();this.state=this.getClipboardState(t,e.type),this.status="visible",this.originSheetId=this.getters.getActiveSheetId();break;case"PASTE":if(!this.state)break;const o=e.pasteOption||("inactive"!==this.paintFormatStatus?"onlyFormat":void 0);this.state.paste(e.target,{pasteOption:o,shouldPasteCF:!0,selectTarget:!0}),this.lastPasteState=this.state,"oneOff"===this.paintFormatStatus&&(this.paintFormatStatus="inactive"),this.status="invisible";break;case"CLEAN_CLIPBOARD_HIGHLIGHT":this.status="invisible";break;case"DELETE_CELL":{const{cut:t,paste:o}=this.getDeleteCellsTargets(e.zone,e.shiftDimension);if(!oi(t[0])){for(const{col:t,row:o}of vi(e.zone))this.dispatch("CLEAR_CELL",{col:t,row:o,sheetId:this.getters.getActiveSheetId()});break}this.getClipboardStateForCopyCells(t,"CUT").paste(o);break}case"INSERT_CELL":{const{cut:t,paste:o}=this.getInsertCellsTargets(e.zone,e.shiftDimension);this.getClipboardStateForCopyCells(t,"CUT").paste(o);break}case"ADD_COLUMNS_ROWS":if(this.status="invisible","CUT"!==this.state?.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"!==this.state?.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":this.state=new px(e.text,this.getters,this.dispatch,this.selection),this.state.paste(e.target,{pasteOption:e.pasteOption}),this.lastPasteState=this.state,this.status="invisible";break;case"REPEAT_PASTE":this.lastPasteState?.paste(e.target,{pasteOption:e.pasteOption,shouldPasteCF:!0,selectTarget:!0});break;case"ACTIVATE_PAINT_FORMAT":{const t=this.getters.getSelectedZones();this.state=this.getClipboardStateForCopyCells(t,"COPY"),this.status="visible",e.persistent?this.paintFormatStatus="persistent":this.paintFormatStatus="oneOff";break}case"DELETE_SHEET":if("CUT"!==this.state?.operation)return;this.originSheetId===e.sheetId&&(this.state=void 0,this.status="invisible");break;case"CANCEL_PAINT_FORMAT":this.paintFormatStatus="inactive",this.status="invisible";break;default:ms(e)&&(this.status="invisible")}}getClipboardContent(){return this.state?.getClipboardContent()||{[cs.PlainText]:"\t"}}getClipboardTextContent(){return this.state?.getClipboardContent()[cs.PlainText]||"\t"}isCutOperation(){return!!this.state&&"CUT"===this.state.operation}isPaintingFormat(){return"inactive"!==this.paintFormatStatus}getDeleteCellsTargets(e,t){const o=this.getters.getActiveSheetId();let i;return i="COL"===t?{...e,left:e.right+1,right:this.getters.getNumberCols(o)-1}:{...e,top:e.bottom+1,bottom:this.getters.getNumberRows(o)-1},{cut:[i],paste:[e]}}getInsertCellsTargets(e,t){const o=this.getters.getActiveSheetId();let i,s;return"COL"===t?(i={...e,right:this.getters.getNumberCols(o)-1},s={...e,left:e.right+1,right:e.right+1}):(i={...e,bottom:this.getters.getNumberRows(o)-1},s={...e,top:e.bottom+1,bottom:this.getters.getNumberRows(o)-1}),{cut:[i],paste:[s]}}getClipboardStateForCopyCells(e,t){return new cx(e,t,this.getters,this.dispatch,this.selection)}getClipboardState(e,t){return this.getters.getSelectedFigureId()?new hx(t,this.getters,this.dispatch):new cx(e,t,this.getters,this.dispatch,this.selection)}drawGrid(e){"visible"===this.status&&this.state&&this.state.drawClipboard(e)}}).add("edition",class extends nw{static getters=["getEditionMode","isSelectingForComposer","showSelectionIndicator","getCurrentContent","getComposerSelection","getCurrentTokens","getTokenAtCursor","getComposerHighlights","getCurrentEditedCell"];col=0;row=0;mode="inactive";sheetId="";currentContent="";currentTokens=[];selectionStart=0;selectionEnd=0;selectionInitialStart=0;initialContent="";previousRef="";previousRange=void 0;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=e.text||this.getComposerContent(this.getters.getActivePosition());return this.validateSelection(t.length,e.selection.start,e.selection.end)}return 0;default:return 0}}handleEvent(e){if("selecting"!==this.mode)return;const t=this.getters.getActiveSheetId();let o;if(o=e.options.unbounded?this.getters.getUnboundedZone(t,e.anchor.zone):e.anchor.zone,"newAnchor"===e.mode)this.insertSelectedRange(o);else this.replaceSelectedRanges(o)}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":"inactive"!==this.mode&&e.text?this.setContent(e.text,e.selection):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),o=this.currentTokens.filter((e=>"REFERENCE"===e.type)).find((e=>{const{xc:o,sheetName:i}=Jo(e.value),s=i||this.getters.getSheetName(this.sheetId),r=this.getters.getActiveSheetId();if(this.getters.getSheetName(r)!==s)return!1;const n=this.getters.getRangeFromSheetXC(r,o);return hi(this.getters.expandZone(r,n.zone),t.zone)}));this.previousRef=o.value,this.previousRange=this.getters.getRangeFromSheetXC(this.getters.getActiveSheetId(),this.previousRef),this.selectionInitialStart=o.start;break;case"CHANGE_HIGHLIGHT":const i=this.getters.getRangeFromRangeData(e.range),s=this.getRangeReference(i,this.previousRange.parts);this.selectionStart=this.selectionInitialStart,this.selectionEnd=this.selectionInitialStart+this.previousRef.length,this.replaceSelection(s),this.previousRef=s,this.selectionStart=this.currentContent.length,this.selectionEnd=this.currentContent.length;break;case"ACTIVATE_SHEET":if(this.currentContent.startsWith("=")||(this.cancelEdition(),this.resetContent()),e.sheetIdFrom!==e.sheetIdTo){const t=this.getters.getActivePosition(),{col:o,row:i}=this.getters.getNextVisibleCellPosition({sheetId:e.sheetIdTo,col:t.col,row:t.row}),s=this.getters.expandZone(e.sheetIdTo,wi({col:o,row:i}));this.selection.resetAnchor(this,{cell:{col:o,row:i},zone:s})}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:vx}));break;case"CYCLE_EDITION_REFERENCES":this.cycleReferences()}}getEditionMode(){return this.mode}getCurrentContent(){return"inactive"===this.mode?this.getComposerContent(this.getters.getActivePosition()):this.currentContent}getComposerSelection(){return{start:this.selectionStart,end:this.selectionEnd}}getCurrentEditedCell(){return{sheetId:this.sheetId,col:this.col,row:this.row}}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((o=>o.start<=e&&o.end>=t))}cycleReferences(){const e=this.getTokensInSelection(),t=e.filter((e=>"REFERENCE"===e.type));if(0===t.length)return;const o=e.map(mx).map((e=>e.value)).join(""),i=this.currentContent,s=e[0].start,r=e[e.length-1].end,n=i.slice(0,s)+o+i.slice(r),a=n.length-i.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:n,selection:l})}validateSelection(e,t,o){return t>=0&&t<=e&&o>=0&&o<=e?0:49}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:vx});const{top:t,left:o}=ni({left:this.col,right:this.col,top:this.row,bottom:this.row},"left",[...e.elements]);this.col=o,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:vx});const{top:t,left:o}=ni({left:this.col,right:this.col,top:this.row,bottom:this.row},"top",[...e.elements]);this.col=o,this.row=t}onAddElements(e){const{top:t,left:o}=ri({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=o,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){const o=this.getters.getActiveCell(),i=this.getters.getLocale();e&&o.format?.includes("%")&&io(e,i)&&(t=t||{start:e.length,end:e.length},e=`${e}%`);const{col:s,row:r,sheetId:n}=this.getters.getActivePosition();this.col=s,this.sheetId=n,this.row=r,this.initialContent=this.getComposerContent({sheetId:n,col:s,row:r}),this.mode="editing",this.setContent(e||this.initialContent,t),this.colorIndexByRange={};const a=wi({col:this.col,row:this.row});this.selection.capture(this,{cell:{col:this.col,row:this.row},zone:a},{handleEvent:this.handleEvent.bind(this),release:()=>{this.stopEdition()}})}stopEdition(){if("inactive"!==this.mode){this.cancelEditionAndActivateSheet();const e=this.col,t=this.row;let o=this.currentContent;if(!(this.initialContent!==o))return;if(o){const i=this.getters.getActiveSheetId(),s=this.getters.getEvaluatedCell({sheetId:i,col:this.col,row:this.row});if(o=bg(o,this.getters.getLocale()),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+=Be(new Array(i).fill(")")))}else s.link&&(o=Ne(o,s.link.url));this.dispatch("UPDATE_CELL",{sheetId:this.sheetId,col:e,row:t,content:o})}else this.dispatch("UPDATE_CELL",{sheetId:this.sheetId,content:"",col:e,row:t});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})}getComposerContent(e){const t=this.getters.getLocale(),o=this.getters.getCell(e);if(o?.isFormula)return Eg(o.content,t);const{format:i,value:s,type:r,formattedValue:n}=this.getters.getEvaluatedCell(e);switch(r){case ls.text:case ls.empty:return s;case ls.boolean:return n;case ls.error:return o?.content||"";case ls.number:return i&&xo(i)?n:this.numberComposerContent(s,i,t)}}numberComposerContent(e,t,o){return t?.includes("%")?`${wo(100*e,o.decimalSeparator)}%`:wo(e,o.decimalSeparator)}cancelEdition(){"inactive"!==this.mode&&(this.mode="inactive",this.selection.release(this))}resetContent(){this.setContent(this.initialContent||"")}setContent(e,t,o){const i=this.currentContent!==e;if(this.currentContent=e,t?(this.selectionStart=t.start,this.selectionEnd=t.end):this.selectionStart=this.selectionEnd=e.length,i||"inactive"!==this.mode){const t=this.getters.getLocale();this.currentTokens=e.startsWith("=")?gg(e,t):[],this.currentTokens.length>100&&o&&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),o=this.getZoneReference(e);this.canStartComposerRangeSelection()?(this.insertText(o,t),this.selectionInitialStart=t):(this.insertText(","+o,t),this.selectionInitialStart=t+1)}replaceSelectedRanges(e){const t=this.getZoneReference(e);this.replaceText(t,this.selectionInitialStart,this.selectionEnd)}getZoneReference(e){const t=this.getters.getCurrentEditedCell()?.sheetId||this.getters.getActiveSheetId(),o=this.getters.getActiveSheetId(),i=this.getters.getRangeFromZone(o,e);return this.getters.getSelectionRangeString(i,t)}getRangeReference(e,t=[{colFixed:!1,rowFixed:!1}]){let o=[...t];1===t.length&&yi(e.zone)>1?o.push({...t[0]}):2===t.length&&1===yi(e.zone)&&o.pop();const i=e.clone({parts:o});return this.getters.getSelectionRangeString(i,this.getters.getCurrentEditedCell()?.sheetId||this.getters.getActiveSheetId())}replaceSelection(e){const t=Math.min(this.selectionStart,this.selectionEnd),o=Math.max(this.selectionStart,this.selectionEnd);this.replaceText(e,t,o)}replaceText(e,t,o){this.currentContent=this.currentContent.slice(0,t)+this.currentContent.slice(o,this.currentContent.length),this.insertText(e,t)}insertText(e,t){const o=this.currentContent.slice(0,t)+e+this.currentContent.slice(t),i=t+e.length;this.dispatch("SET_CURRENT_CONTENT",{content:o,selection:{start:i,end:i}})}updateRangeColor(){if(!this.currentContent.startsWith("=")||"inactive"===this.mode)return;const e=this.getters.getCurrentEditedCell()?.sheetId||this.getters.getActiveSheetId(),t=this.getReferencedRanges().map((t=>this.getters.getRangeString(t,e))),o={};for(const e of t)void 0!==this.colorIndexByRange[e]&&(o[e]=this.colorIndexByRange[e]);const i=new Set(Object.values(o));let s=0;const r=()=>{for(;i.has(s);)s++;return i.add(s),s};for(const e of t){const t=e in o?o[e]:r();o[e]=t}this.colorIndexByRange=o}getComposerHighlights(){if(!this.currentContent.startsWith("=")||"inactive"===this.mode)return[];const e=this.getters.getCurrentEditedCell()?.sheetId||this.getters.getActiveSheetId(),t=e=>{const t=this.colorIndexByRange[e];return st[t%st.length]};return this.getReferencedRanges().map((o=>{const i=this.getters.getRangeString(o,e);return{zone:o.zone,color:t(i),sheetId:o.sheetId}}))}getReferencedRanges(){const e=this.getters.getCurrentEditedCell()?.sheetId||this.getters.getActiveSheetId();return this.currentTokens.filter((e=>"REFERENCE"===e.type)).map((t=>this.getters.getRangeFromSheetXC(e,t.value))).filter((e=>!e.invalidSheetName&&!e.invalidXc))}canStartComposerRangeSelection(){if(this.currentContent.startsWith("=")){const e=this.getTokenAtCursor();if(!e)return!1;const t=this.currentTokens.map((e=>e.start)).indexOf(e.start);let o=t,i=e;for(;!["ARG_SEPARATOR","LEFT_PAREN","OPERATOR"].includes(i.type)||Eu.includes(i.value);){if("SPACE"!==i.type||o<1)return!1;o--,i=this.currentTokens[o]}for(o=t+1,i=this.currentTokens[o];i&&!["ARG_SEPARATOR","RIGHT_PAREN","OPERATOR"].includes(i.type);){if("SPACE"!==i.type)return!1;o++,i=this.currentTokens[o]}return!0}return!1}getTokensInSelection(){const e=Math.min(this.selectionStart,this.selectionEnd),t=Math.max(this.selectionStart,this.selectionEnd);return this.currentTokens.filter((o=>o.start<=e&&o.end>=e||o.start>=e&&o.start<t))}}),yx=(new Ji).add("evaluation",class extends nw{static getters=["evaluateFormula","getCorrespondingFormulaCell","getRangeFormattedValues","getRangeValues","getRangeFormats","getEvaluatedCell","getEvaluatedCells","getEvaluatedCellsInZone","isEmpty"];shouldRebuildDependenciesGraph=!0;evaluator;positionsToUpdate=[];constructor(e){super(e),this.evaluator=new Fw(e.custom,this.getters)}beforeHandle(e){ds.has(e.type)&&(this.shouldRebuildDependenciesGraph=!0)}handle(e){switch(e.type){case"UPDATE_CELL":if(!("content"in e)&&!("format"in e)||this.shouldRebuildDependenciesGraph)return;this.positionsToUpdate.push(e),"content"in e&&this.evaluator.updateDependencies(e);break;case"EVALUATE_CELLS":this.evaluator.evaluateAllCells()}}finalize(){this.shouldRebuildDependenciesGraph?(this.evaluator.buildDependencyGraph(),this.evaluator.evaluateAllCells(),this.shouldRebuildDependenciesGraph=!1):this.positionsToUpdate.length&&this.evaluator.evaluateCells(this.positionsToUpdate),this.positionsToUpdate=[]}evaluateFormula(e,t){try{return this.evaluator.evaluateFormula(e,t)}catch(e){return e instanceof c?e.errorType:a.GenericError}}getRangeFormattedValues(e){const t=this.getters.tryGetSheet(e.sheetId);return void 0===t?[]:this.getters.getEvaluatedCellsInZone(t.id,e.zone).map((e=>e.formattedValue))}getRangeValues(e){const t=this.getters.tryGetSheet(e.sheetId);return void 0===t?[]:this.getters.getEvaluatedCellsInZone(t.id,e.zone).map((e=>e.value))}getRangeFormats(e){const t=this.getters.tryGetSheet(e.sheetId);return void 0===t?[]:this.getters.getEvaluatedCellsInZone(t.id,e.zone).map((e=>e.format))}getEvaluatedCell(e){return this.evaluator.getEvaluatedCell(e)}getEvaluatedCells(e){const t=this.getters.getCells(e)||{},o={};for(let e of Object.keys(t)){const t=this.getters.getCellPosition(e);o[e]=this.getEvaluatedCell(t)}return o}getEvaluatedCellsInZone(e,t){return vi(t).map((({col:t,row:o})=>this.getters.getEvaluatedCell({sheetId:e,col:t,row:o})))}isEmpty(e,t){return vi(t).map((({col:t,row:o})=>this.getEvaluatedCell({sheetId:e,col:t,row:o}))).every((e=>e.type===ls.empty))}exportForExcel(e){for(const t of this.evaluator.getEvaluatedPositions()){const o=this.evaluator.getEvaluatedCell(t),i=xt(t.col,t.row),s=o.value;let r,n,a=!1,l=!0;const c=this.getCorrespondingFormulaCell(t);c&&(l=mg(c.compiledFormula.tokens),a=l,l||(r=s.toString(),n=o.format));const h=e.sheets.find((e=>e.id===t.sheetId)),d=h.cells[i]||{},u=n?Ve(n,e.formats):d.format;let g;g=c instanceof JE?this.getters.buildFormulaContent(h.id,c,c.dependencies,!0):l?d.content:r,h.cells[i]={...d,value:s,isFormula:a,content:g,format:u}}}getCorrespondingFormulaCell(e){const t=this.getters.getCell(e);if(t&&t.content)return t.isFormula&&!function(e){try{return hg(e),!1}catch(e){return!0}}(t.content)?t:void 0;const o=this.evaluator.getArrayFormulaSpreadingOn(e);if(void 0===o)return;const i=this.getters.getCell(o);return i?.isFormula?i:void 0}}).add("evaluation_chart",class extends nw{static getters=["getChartRuntime","getStyleOfSingleCellChart"];charts={};createRuntimeChart=function(e){const t=qp.getAll().sort(((e,t)=>e.sequence-t.sequence));return function(o){const i=t.find((e=>e.match(o.type)));if(!i)throw new Error("No runtime builder for this chart.");return i.getChartRuntime(o,e)}}(this.getters);handle(e){if(hs.has(e.type)||us.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]}getStyleOfSingleCellChart(e,t){if(e)return{background:e,fontColor:ip(e)};if(!t)return{background:w,fontColor:ip(w)};const o=t.zone.left,i=t.zone.top,s=t.sheetId,r=this.getters.getCellComputedStyle({sheetId:s,col:o,row:i}),n=r.fillColor||w;return{background:n,fontColor:r.textColor||ip(n)}}}).add("evaluation_cf",class extends nw{static getters=["getConditionalIcon","getCellComputedStyle"];isStale=!0;computedStyles={};computedIcons={};handle(e){(us.has(e.type)||"UPDATE_CELL"===e.type&&"content"in e)&&(this.isStale=!0)}finalize(){if(this.isStale){for(const e of this.getters.getSheetIds())this.computedStyles[e]=ze((()=>this.getComputedStyles(e))),this.computedIcons[e]=ze((()=>this.getComputedIcons(e)));this.isStale=!1}}getCellComputedStyle(e){const{sheetId:t,col:o,row:i}=e,s=this.getters.getCell(e),r=this.computedStyles[t](),n=r&&r[o]?.[i],a={...s?.style,...n};return this.getters.getEvaluatedCell(e).link&&!a.textColor&&(a.textColor=R),this.getters.isFilterHeader(e)&&(a.bold=!0),a}getConditionalIcon({sheetId:e,col:t,row:o}){const i=this.computedIcons[e]();return i&&i[t]?.[o]}getComputedStyles(e){const t={};for(let o of this.getters.getConditionalFormats(e).reverse())switch(o.rule.type){case"ColorScaleRule":for(let i of o.ranges)this.applyColorScale(e,i,o.rule,t);break;case"CellIsRule":for(let i of o.ranges){const s=this.getters.getRangeFromSheetXC(e,i).zone;for(let i=s.top;i<=s.bottom;i++)for(let r=s.left;r<=s.right;r++){const s=this.rulePredicate[o.rule.type];let n=this.getters.getEvaluatedCell({sheetId:e,col:r,row:i});s&&s(n,o.rule)&&(t[r]||(t[r]=[]),t[r][i]=Object.assign(t[r]?.[i]||{},o.rule.style))}}}return t}getComputedIcons(e){const t={};for(let o of this.getters.getConditionalFormats(e).reverse())if("IconSetRule"===o.rule.type)for(let i of o.ranges)this.applyIcon(e,i,o.rule,t);return t}parsePoint(e,t,o,i){const s=this.getters.getEvaluatedCellsInZone(e,this.getters.getRangeFromSheetXC(e,t).zone).filter((e=>e.type===ls.number)).map((e=>e.value));switch(o.type){case"value":return"max"===i?et(s):tt(s);case"number":return Number(o.value);case"percentage":const t=tt(s);return t+(et(s)-t)*Number(o.value)/100;case"percentile":return no(s,Number(o.value)/100,!0);case"formula":const r=o.value&&this.getters.evaluateFormula(e,o.value);return"number"==typeof r?r:null;default:return null}}applyIcon(e,t,o,i){const s=this.parsePoint(e,t,o.lowerInflectionPoint),r=this.parsePoint(e,t,o.upperInflectionPoint);if(null===s||null===r||s>r)return;const n=this.getters.getRangeFromSheetXC(e,t).zone,a=[o.icons.upper,o.icons.middle,o.icons.lower];for(let t=n.top;t<=n.bottom;t++)for(let l=n.left;l<=n.right;l++){const n=this.getters.getEvaluatedCell({sheetId:e,col:l,row:t});if(n.type!==ls.number)continue;const c=this.computeIcon(n.value,r,o.upperInflectionPoint.operator,s,o.lowerInflectionPoint.operator,a);i[l]||(i[l]=[]),i[l][t]=c}}computeIcon(e,t,o,i,s,r){return"ge"===o&&e>=t||"gt"===o&&e>t?r[0]:"ge"===s&&e>=i||"gt"===s&&e>i?r[1]:r[2]}applyColorScale(e,t,o,i){const s=this.parsePoint(e,t,o.minimum,"min"),r=o.midpoint?this.parsePoint(e,t,o.midpoint):null,n=this.parsePoint(e,t,o.maximum,"max");if(null===s||null===n||s>=n||r&&(s>=r||r>=n))return;const a=this.getters.getRangeFromSheetXC(e,t).zone,l=[];o.midpoint&&r?(l.push({minValue:s,minColor:o.minimum.color,colorDiffUnit:this.computeColorDiffUnits(s,r,o.minimum.color,o.midpoint.color)}),l.push({minValue:r,minColor:o.midpoint.color,colorDiffUnit:this.computeColorDiffUnits(r,n,o.midpoint.color,o.maximum.color)})):l.push({minValue:s,minColor:o.minimum.color,colorDiffUnit:this.computeColorDiffUnits(s,n,o.minimum.color,o.maximum.color)});for(let t=a.top;t<=a.bottom;t++)for(let o=a.left;o<=a.right;o++){const a=this.getters.getEvaluatedCell({sheetId:e,col:o,row:t});if(a.type===ls.number){const e=xe(a.value,s,n);let c;c=2===l.length&&r?e<=r?this.colorCell(e,l[0].minValue,l[0].minColor,l[0].colorDiffUnit):this.colorCell(e,l[1].minValue,l[1].minColor,l[1].colorDiffUnit):this.colorCell(e,l[0].minValue,l[0].minColor,l[0].colorDiffUnit),i[o]||(i[o]=[]),i[o][t]=i[o]?.[t]||{},i[o][t].fillColor=rt(c)}}}computeColorDiffUnits(e,t,o,i){const s=t-e;return[((o>>16)%256-(i>>16)%256)/s,((o>>8)%256-(i>>8)%256)/s,(o%256-i%256)/s]}colorCell(e,t,o,i){const[s,r,n]=i;return Math.round((o>>16)%256-s*(e-t))<<16|Math.round((o>>8)%256-r*(e-t))<<8|Math.round(o%256-n*(e-t))}rulePredicate={CellIsRule:(e,t)=>{if(e.type===ls.error)return!1;const o=t.values.map((e=>ir(e,eo)));switch(t.operator){case"IsEmpty":return""===e.value.toString().trim();case"IsNotEmpty":return""!==e.value.toString().trim();case"BeginsWith":return""!==o[0]&&e.value.toString().startsWith(o[0].toString());case"EndsWith":return""!==o[0]&&e.value.toString().endsWith(o[0].toString());case"Between":return e.value>=o[0]&&e.value<=o[1];case"NotBetween":return!(e.value>=o[0]&&e.value<=o[1]);case"ContainsText":return e.value.toString().indexOf(o[0].toString())>-1;case"NotContains":return!e.value||-1===e.value.toString().indexOf(o[0].toString());case"GreaterThan":return e.value>o[0];case"GreaterThanOrEqual":return e.value>=o[0];case"LessThan":return e.value<o[0];case"LessThanOrEqual":return e.value<=o[0];case"NotEqual":return""!==o[0]&&e.value!==o[0];case"Equal":return""===o[0]||e.value===o[0];default:console.warn(r("Not implemented operator %s for kind of conditional formatting: %s",t.operator,t.type))}return!1}}}).add("row_size",class extends nw{static getters=["getRowSize"];tallestCellInRow={};ctx=document.createElement("canvas").getContext("2d");handle(e){switch(e.type){case"START":for(const e of this.getters.getSheetIds())this.initializeSheet(e);break;case"CREATE_SHEET":this.initializeSheet(e.sheetId);break;case"DUPLICATE_SHEET":{const t=Ce(this.tallestCellInRow[e.sheetId]);this.history.update("tallestCellInRow",e.sheetIdTo,t);break}case"DELETE_SHEET":const t={...this.tallestCellInRow};delete t[e.sheetId],this.history.update("tallestCellInRow",t);break;case"REMOVE_COLUMNS_ROWS":{if("COL"===e.dimension)return;const t=Je(this.tallestCellInRow[e.sheetId],e.elements);this.history.update("tallestCellInRow",e.sheetId,t);break}case"ADD_COLUMNS_ROWS":{if("COL"===e.dimension)return;const t=$e(e.position,e.base),o=Array(e.quantity).fill(void 0),i=function(e,t,o){const i=[...e];return i.splice(o,0,...t),i}(this.tallestCellInRow[e.sheetId],o,t);this.history.update("tallestCellInRow",e.sheetId,i);break}case"RESIZE_COLUMNS_ROWS":{const t=e.sheetId;if("ROW"===e.dimension)for(const o of e.elements){const e=this.getRowTallestCell(t,o);this.history.update("tallestCellInRow",t,o,e)}else for(const o of ye(0,this.getters.getNumberRows(t)))for(const i of e.elements)this.updateRowSizeForCellChange(t,o,i)}break;case"UPDATE_CELL":this.updateRowSizeForCellChange(e.sheetId,e.row,e.col);break;case"ADD_MERGE":case"REMOVE_MERGE":for(const t of e.target)for(const o of vi(t))this.updateRowSizeForCellChange(e.sheetId,o.row,o.col)}}getRowSize(e,t){return Math.round(this.getters.getUserRowSize(e,t)??this.tallestCellInRow[e][t]?.size??P)}updateRowSizeForCellChange(e,t,o){const i=this.tallestCellInRow[e]?.[t];if(i?.cell.col===o){const o=this.getRowTallestCell(e,t);this.history.update("tallestCellInRow",e,t,o)}const s=this.getCellHeight({sheetId:e,col:o,row:t});if(!(s<=P)&&(!i&&s>P||i&&s>i.size)){const i={cell:{sheetId:e,col:o,row:t},size:s};this.history.update("tallestCellInRow",e,t,i)}}initializeSheet(e){const t=[];for(let o=0;o<this.getters.getNumberRows(e);o++){const i=this.getRowTallestCell(e,o);t.push(i)}this.history.update("tallestCellInRow",e,t)}getCellHeight(e){if(this.isInMultiRowMerge(e))return P;const t=this.getters.getCell(e),o=this.getters.getColSize(e.sheetId,e.col);return function(e,t,o){if(!t||!t.content)return P;const i=t.style?.wrapping?o-2*z:void 0,s=t.isFormula?1:Ui(e,t.content,t.style,i).length;return Ni(Pi(t.style),s)+2*H}(this.ctx,t,o)}isInMultiRowMerge(e){const t=this.getters.getMerge(e);return!!t&&t.bottom!==t.top}getRowTallestCell(e,t){if(void 0!==this.getters.getUserRowSize(e,t))return;const o=this.getters.getRowCells(e,t);let i,s=0;for(let e=0;e<o.length;e++){const t=this.getters.getCellById(o[e]);if(!t)continue;const r=this.getters.getCellPosition(t.id),n=this.getCellHeight(r);n>s&&n>P&&(s=n,i={cell:r,size:n})}return i&&i.size>P?i:void 0}}).add("custom_colors",class extends nw{customColors={};shouldUpdateColors=!1;static getters=["getCustomColors"];handle(e){switch(e.type){case"UPDATE_CELL":case"UPDATE_CHART":case"CREATE_CHART":case"ADD_CONDITIONAL_FORMAT":case"SET_BORDER":case"SET_ZONE_BORDERS":case"SET_FORMATTING":this.history.update("shouldUpdateColors",!0)}}finalize(){if(this.shouldUpdateColors){this.history.update("shouldUpdateColors",!1);for(const e of this.getCustomColors())this.tryToAddColor(e)}}getCustomColors(){let e=[];for(const t of this.getters.getSheetIds())e=e.concat(this.getColorsFromCells(t),this.getFormattingColors(t),this.getChartColors(t));return function(e){const t=[{leadColor:ct(255,0,0),colors:[]},{leadColor:ct(255,128,0),colors:[]},{leadColor:ct(128,128,0),colors:[]},{leadColor:ct(128,255,0),colors:[]},{leadColor:ct(0,255,0),colors:[]},{leadColor:ct(0,255,128),colors:[]},{leadColor:ct(0,255,255),colors:[]},{leadColor:ct(0,127,255),colors:[]},{leadColor:ct(0,0,255),colors:[]},{leadColor:ct(127,0,255),colors:[]},{leadColor:ct(128,0,128),colors:[]},{leadColor:ct(255,0,128),colors:[]}];for(const o of e.map(ut)){let e=500,i=0;t.forEach(((t,s)=>{const r=(n=o,a=t.leadColor,Math.sqrt(Math.pow(n.r-a.r,2)+Math.pow(n.g-a.g,2)+Math.pow(n.b-a.b,2)));var n,a;e>r&&(e=r,i=s)})),t[i].colors.push(o)}return t.map((e=>e.colors.sort(((e,t)=>pt(e).s-pt(t).s)))).flat().map(dt)}([...new Set([...new Set([...e,...Object.keys(this.customColors)])].filter(at).map(nt))]).filter((e=>!_.includes(e)))}getColorsFromCells(e){const t=Object.values(this.getters.getCells(e)),o=new Set;for(const e of t)e.style?.textColor&&o.add(e.style.textColor),e.style?.fillColor&&o.add(e.style.fillColor);for(const t of this.getters.getBordersColors(e))o.add(t);return[...o]}getFormattingColors(e){const t=this.getters.getConditionalFormats(e),o=[];for(const e of t){const t=e.rule;"CellIsRule"===t.type?(o.push(t.style.textColor),o.push(t.style.fillColor)):"ColorScaleRule"===t.type&&(o.push(rt(t.minimum.color)),o.push(t.midpoint?rt(t.midpoint.color):void 0),o.push(rt(t.maximum.color)))}return o.filter(ke)}getChartColors(e){const t=this.getters.getChartIds(e).map((e=>this.getters.getChart(e)));let o=new Set;for(let e of t){if(void 0===e)continue;const t=e.getDefinition().background;switch(void 0!==t&&o.add(t),e.type){case"gauge":const t=e.sectionRule.colors;o.add(t.lowerColor),o.add(t.middleColor),o.add(t.upperColor);break;case"scorecard":const i=e;o.add(i.baselineColorDown),o.add(i.baselineColorUp)}}return[...o]}tryToAddColor(e){const t=nt(e);e&&!_.includes(t)&&this.history.update("customColors",t,!0)}}),Ix=new Ji;Ix.add("link",{condition:(e,t)=>!!t.model.getters.getEvaluatedCell(e).link,execute:(e,t)=>ns(t.model.getters.getEvaluatedCell(e).link,t),sequence:5});class Rx{fileStore;constructor(e){this.fileStore=e}async requestImage(){const e=await this.getImageFromUser(),t=await this.fileStore.upload(e);return{path:t,size:await this.getImageOriginalSize(t),mimetype:e.type}}getImageFromUser(){return new Promise(((e,t)=>{const o=document.createElement("input");o.setAttribute("type","file"),o.setAttribute("accept","image/*"),o.addEventListener("change",(async()=>{null===o.files||1!=o.files.length?t():e(o.files[0])})),o.click()}))}getImageOriginalSize(e){return new Promise(((t,o)=>{const i=new Image;i.src=e,i.addEventListener("load",(()=>{const e={width:i.width,height:i.height};t(e)})),i.addEventListener("error",o)}))}}class Tx{focusableElement=void 0;setFocusableElement(e){this.focusableElement=e}focus(){this.focusableElement?.focus()}}const Ax=[{transform:"scale(0)"},{transform:"scale(0.8)",offset:.33},{opacity:"0",transform:"scale(1)",offset:1}];Wi`
|
|
1469
|
+
`}function CE(e){return new IS(e.join("\n"))}function EE(e,...t){let o=[e[0]];for(let i=0;i<t.length;i++){const s=t[i]instanceof IS?t[i]:mE(t[i]);o.push(s+e[i+1])}return new IS(Be(o))}function wE(e){return e.replace(/NAMESPACE.*NAMESPACE(.*)/,"$1")}function xE(e){return e.replaceAll(/([a-zA-Z0-9]+):([a-zA-Z0-9]+)/g,"NAMESPACE$1NAMESPACE$2")}class yE{value;constructor(e){this.value=e}asString(){return SC(String(this.value))}asBool(){return"true"===this.value||"false"!==this.value&&Boolean(Number(this.value))}asNum(){return Number(this.value)}}class IE{rootFile;xlsxFileStructure;warningManager;relationships;currentFile=void 0;constructor(e,t,o){this.rootFile=e,this.currentFile=e.file.fileName,this.xlsxFileStructure=t,this.warningManager=o,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()})))}getListOfXMLFiles(){return Object.entries(this.xlsxFileStructure).filter((([e])=>"images"!==e)).map((([e,t])=>t)).flat().filter(ke)}mapOnElements(e,t){const o=[],i=this.currentFile;let s;if(e.children){const t=this.querySelector(e.parent,e.query)?.children;s=t||[]}else s=this.querySelectorAll(e.parent,e.query);if(s)for(let e of s)try{o.push(t(e))}catch(t){this.catchErrorOnElement(t,e)}return this.currentFile=i,o}catchErrorOnElement(e,t){const o=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([o,e.message].join("\n"))}extractAttr(e,t,o){const i=e.attributes[t];i||this.handleMissingValue(e,`attribute "${t}"`,o);const s=i?.value?i.value:o?.default;return void 0===s?void 0:new yE(s)}extractTextContent(e,t){if(void 0!==t?.default&&"string"!=typeof t.default)throw new Error("extractTextContent default value should be a string");const o="preserve"===e?.attributes["xml:space"]?.value;let i=e?.textContent;return e&&null!==i||this.handleMissingValue(e,"text content",t),i&&(i=o?i:i.trim()),i?SC(i):t?.default}extractChildAttr(e,t,o,i){let s;s="number"==typeof t?e.children[t]:this.querySelector(e,t),s||this.handleMissingValue(e,"number"==typeof t?`child at index ${t}`:`child <${t}>`,i);const r=s?this.extractAttr(s,o,i)?.asString():i?.default;return void 0!==r?new yE(r):void 0}extractChildTextContent(e,t,o){if(void 0!==o?.default&&"string"!=typeof o.default)throw new Error("extractTextContent default value should be a string");let i=this.querySelector(e,t);return i||this.handleMissingValue(e,`child <${t}>`,o),i?this.extractTextContent(i,o):o?.default}handleMissingValue(e,t,o){if(o?.required){if(!o?.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 ${o.default}`)}}extractColor(e,t,o){if(!e)return o?{rgb:o}:void 0;const i=this.extractAttr(e,"theme")?.asString();let s;if(void 0!==i){if(!t||!t.clrScheme)throw new Error("Color referencing a theme but no theme was provided");s=this.getThemeColor(i,t.clrScheme)}else s=this.extractAttr(e,"rgb")?.asString();return{rgb:s,auto:this.extractAttr(e,"auto")?.asBool(),indexed:this.extractAttr(e,"indexed")?.asNum(),tint:this.extractAttr(e,"tint")?.asNum()}}getTargetXmlFile(e){if(!e)throw new Error("Undefined target file");const t=this.processRelationshipTargetName(e.target),o=this.getListOfXMLFiles().find((e=>e.file.fileName.endsWith(t)));if(!o||!o.file)throw new Error("Cannot find target file");return o}getTargetImageFile(e){if(!e)throw new Error("Undefined target file");const t=this.processRelationshipTargetName(e.target),o=this.xlsxFileStructure.images.find((e=>e.fileName.endsWith(t)));if(!o)throw new Error("Cannot find target file");return o}querySelector(e,t){const o=xE(t);return e.querySelector(o)}querySelectorAll(e,t){const o=xE(t);return e.querySelectorAll(o)}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}}processRelationshipTargetName(e){return e.replace(/\.+\//,"")}}class RE extends IE{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:TS}).asString(),lastClr:this.extractChildAttr(e,0,"lastClr",{default:TS}).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 TE extends IE{theme;constructor(e,t,o,i){super(e,t,o),this.theme=i}extractConditionalFormattings(){const e=this.mapOnElements({parent:this.rootFile.file.xml,query:"worksheet > conditionalFormatting"},(e=>({sqref:this.extractAttr(e,"sqref",{required:!0}).asString().split(" "),pivot:this.extractAttr(e,"pivot")?.asBool(),cfRules:this.extractCFRules(e,this.theme)})));return e.push(...this.mapOnElements({parent:this.rootFile.file.xml,query:"extLst x14:conditionalFormatting"},(e=>({sqref:this.extractChildTextContent(e,"xm:sqref",{required:!0}).split(" "),pivot:this.extractAttr(e,"xm:pivot")?.asBool(),cfRules:this.extractCFRules(e,this.theme)})))),e}extractCFRules(e,t){return this.mapOnElements({parent:e,query:"cfRule, x14:cfRule"},(e=>{const o=this.extractAttr(e,"type",{required:!0}).asString();if("dataBar"===o)throw new Error("Databars conditional formats are not supported.");return{type:o,priority:this.extractAttr(e,"priority",{required:!0}).asNum(),colorScale:this.extractCfColorScale(e,t),formula:this.extractCfFormula(e),iconSet:this.extractCfIconSet(e),dxfId:this.extractAttr(e,"dxfId")?.asNum(),stopIfTrue:this.extractAttr(e,"stopIfTrue")?.asBool(),aboveAverage:this.extractAttr(e,"aboveAverage")?.asBool(),percent:this.extractAttr(e,"percent")?.asBool(),bottom:this.extractAttr(e,"bottom")?.asBool(),operator:this.extractAttr(e,"operator")?.asString(),text:this.extractAttr(e,"text")?.asString(),timePeriod:this.extractAttr(e,"timePeriod")?.asString(),rank:this.extractAttr(e,"rank")?.asNum(),stdDev:this.extractAttr(e,"stdDev")?.asNum(),equalAverage:this.extractAttr(e,"equalAverage")?.asBool()}}))}extractCfFormula(e){return this.mapOnElements({parent:e,query:"formula"},(e=>this.extractTextContent(e,{required:!0})))}extractCfColorScale(e,t){const o=this.querySelector(e,"colorScale");if(o)return{colors:this.mapOnElements({parent:o,query:"color"},(e=>this.extractColor(e,t,"ffffff"))),cfvos:this.extractCFVos(o)}}extractCfIconSet(e){const t=this.querySelector(e,"iconSet, x14:iconSet");if(t)return{iconSet:this.extractAttr(t,"iconSet",{default:"3TrafficLights1"}).asString(),showValue:this.extractAttr(t,"showValue",{default:!0}).asBool(),percent:this.extractAttr(t,"percent",{default:!0}).asBool(),reverse:this.extractAttr(t,"reverse")?.asBool(),custom:this.extractAttr(t,"custom")?.asBool(),cfvos:this.extractCFVos(t),cfIcons:this.extractCfIcons(t)}}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=>({type:this.extractAttr(e,"type",{required:!0}).asString(),gte:this.extractAttr(e,"gte",{default:!0})?.asBool(),value:e.attributes.val?this.extractAttr(e,"val")?.asString():this.extractChildTextContent(e,"f, xm:f")})))}}class AE extends IE{extractChart(){return this.mapOnElements({parent:this.rootFile.file.xml,query:"c:chartSpace"},(e=>{const t=this.getChartType(e);if(!lC[t])throw new Error(`Unsupported chart type ${t}`);const o=this.mapOnElements({parent:e,query:"c:title a:t"},(e=>e.textContent||"")).join(""),i=this.extractChildAttr(e,"c:grouping","val",{default:"clustered"}).asString();return{title:o,type:lC[t],dataSets:this.extractChartDatasets(this.querySelector(e,`c:${t}`)),labelRange:this.extractChildTextContent(e,"c:ser c:cat c:f"),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:aC[this.extractChildAttr(e,"c:legendPos","val",{default:"b"}).asString()],stacked:"stacked"===i,fontColor:"000000"}}))[0]}extractChartDatasets(e){return this.mapOnElements({parent:e,query:"c:ser"},(e=>({label:this.extractChildTextContent(e,"c:tx 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=wE(e.tagName);if(RS.some((e=>e===t)))return t}throw new Error("Unknown chart type")}}class OE extends IE{extractFigures(){return this.mapOnElements({parent:this.rootFile.file.xml,query:"xdr:wsDr",children:!0},(e=>{if("twoCellAnchor"!==wE(e.tagName))throw new Error("Only twoCellAnchor are supported for xlsx drawings.");const t=this.querySelector(e,"c:chart"),o=this.querySelector(e,"a:blip");if(!t&&!o)throw new Error("Only chart and image figures are currently supported.");return{anchors:[this.extractFigureAnchor("xdr:from",e),this.extractFigureAnchor("xdr:to",e)],data:t?this.extractChart(t):this.extractImage(e)}}))}extractFigureAnchor(e,t){const o=this.querySelector(t,e);if(!o)throw new Error(`Missing anchor element ${e}`);return{col:Number(this.extractChildTextContent(o,"xdr:col",{required:!0})),colOffset:Number(this.extractChildTextContent(o,"xdr:colOff",{required:!0})),row:Number(this.extractChildTextContent(o,"xdr:row",{required:!0})),rowOffset:Number(this.extractChildTextContent(o,"xdr:rowOff",{required:!0}))}}extractChart(e){const t=this.extractAttr(e,"r:id",{required:!0}).asString(),o=this.getTargetXmlFile(this.relationships[t]),i=new AE(o,this.xlsxFileStructure,this.warningManager).extractChart();if(!i)throw new Error("Unable to extract chart definition");return i}extractImage(e){const t=this.querySelector(e,"a:blip"),o=this.extractAttr(t,"r:embed",{required:!0}).asString(),i=this.getTargetImageFile(this.relationships[o]);if(!i)throw new Error("Unable to extract image");const s=this.querySelector(e,"a:xfrm"),r=i.fileName.split(".").at(-1);return{imageSrc:i.imageSrc,mimetype:r?pC[r]:void 0,size:{cx:this.extractChildAttr(s,"a:ext","cx",{required:!0}).asNum(),cy:this.extractChildAttr(s,"a:ext","cy",{required:!0}).asNum()}}}}class ME extends IE{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 NE extends IE{getTable(){return this.mapOnElements({query:"table",parent:this.rootFile.file.xml},(e=>({displayName:this.extractAttr(e,"displayName",{required:!0}).asString(),name:this.extractAttr(e,"name")?.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=>({name:this.extractAttr(e,"name")?.asString(),showFirstColumn:this.extractAttr(e,"showFirstColumn")?.asBool(),showLastColumn:this.extractAttr(e,"showLastColumn")?.asBool(),showRowStripes:this.extractAttr(e,"showRowStripes")?.asBool(),showColumnStripes:this.extractAttr(e,"showColumnStripes")?.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 _E extends IE{theme;constructor(e,t,o,i){super(e,t,o),this.theme=i}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=fC(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=fC(this.xlsxFileStructure.workbook.file.fileName,this.rootFile.file.fileName),t=this.extractRelationships(this.xlsxFileStructure.workbook.rels).find((t=>t.target===e)).id,o=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(!o)throw new Error("Cannot find corresponding workbook sheet");return o}extractConditionalFormats(){return new TE(this.rootFile,this.xlsxFileStructure,this.warningManager,this.theme).extractConditionalFormattings()}extractFigures(e){return this.mapOnElements({parent:e,query:"drawing"},(e=>{const t=this.extractAttr(e,"r:id",{required:!0})?.asString(),o=this.getTargetXmlFile(this.relationships[t]);return new OE(o,this.xlsxFileStructure,this.warningManager).extractFigures()}))[0]||[]}extractTables(e){return this.mapOnElements({query:"tablePart",parent:e},(e=>{const t=this.extractAttr(e,"r:id",{required:!0})?.asString(),o=this.getTargetXmlFile(this.relationships[t]);return new NE(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 ME(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:kS.toString()}).asNum(),defaultRowHeight:this.extractAttr(t,"defaultRowHeight",{default:US.toString()}).asNum()}}extractCols(e){return this.mapOnElements({parent:e,query:"cols col"},(e=>({width:this.extractAttr(e,"width")?.asNum(),customWidth:this.extractAttr(e,"customWidth")?.asBool(),bestFit:this.extractAttr(e,"bestFit")?.asBool(),hidden:this.extractAttr(e,"hidden")?.asBool(),min:this.extractAttr(e,"min",{required:!0})?.asNum(),max:this.extractAttr(e,"max",{required:!0})?.asNum(),styleIndex:this.extractAttr(e,"style")?.asNum()})))}extractRows(e){return this.mapOnElements({parent:e,query:"sheetData row"},(e=>({index:this.extractAttr(e,"r",{required:!0})?.asNum(),cells:this.extractCells(e),height:this.extractAttr(e,"ht")?.asNum(),customHeight:this.extractAttr(e,"customHeight")?.asBool(),hidden:this.extractAttr(e,"hidden")?.asBool(),styleIndex:this.extractAttr(e,"s")?.asNum()})))}extractCells(e){return this.mapOnElements({parent:e,query:"c"},(e=>({xc:this.extractAttr(e,"r",{required:!0})?.asString(),styleIndex:this.extractAttr(e,"s")?.asNum(),type:JS[this.extractAttr(e,"t",{default:"n"})?.asString()],value:this.extractChildTextContent(e,"v"),formula:this.extractCellFormula(e)})))}extractCellFormula(e){const t=this.querySelector(e,"f");if(t)return{content:this.extractTextContent(t),sharedIndex:this.extractAttr(t,"si")?.asNum(),ref:this.extractAttr(t,"ref")?.asString()}}extractHyperLinks(e){return this.mapOnElements({parent:e,query:"hyperlink"},(e=>{const t=this.extractAttr(e,"r:id")?.asString();return{xc:this.extractAttr(e,"ref",{required:!0})?.asString(),location:this.extractAttr(e,"location")?.asString(),display:this.extractAttr(e,"display")?.asString(),relTarget:t?this.relationships[t].target:void 0}}))}extractSharedFormulas(e){const t=this.querySelectorAll(e,"f[si][ref]"),o={};for(let e of t){const t=this.extractAttr(e,"si",{required:!0}).asNum(),i=this.extractTextContent(e,{required:!0});o[t]=i}const i=[];for(let e=0;e<Object.keys(o).length;e++)o[e]?i.push(o[e]):(this.warningManager.addParsingWarning(`Missing shared formula ${e}, replacing it by empty formula`),i.push(""));return i}}class FE extends IE{theme;constructor(e,t,o){super(e.styles,e,t),this.theme=o}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){const t=this.extractChildAttr(e,"name","val",{default:"Arial"}).asString(),o=this.extractChildAttr(e,"sz","val",{default:Z.toString()}).asNum(),i=this.extractColor(this.querySelector(e,"color"),this.theme),s=this.querySelector(e,"i")||void 0,r=s&&"0"!==s.attributes.val?.value,n=this.querySelector(e,"b")||void 0,a=n&&"0"!==n.attributes.val?.value,l=this.querySelector(e,"strike")||void 0,c=l&&"0"!==l.attributes.val?.value,h=this.querySelector(e,"u")||void 0;return{name:t,size:o,color:i,italic:r,bold:a,underline:h&&"none"!==h.attributes.val?.value,strike:c}}getFills(){return this.mapOnElements({parent:this.rootFile.file.xml,query:"fill"},(e=>this.extractFill(e)))}extractFill(e){const t=e.children[0];return"patternFill"===t.tagName?{patternType:t.attributes.patternType?.value,bgColor:this.extractColor(this.querySelector(t,"bgColor"),this.theme),fgColor:this.extractColor(this.querySelector(t,"fgColor"),this.theme)}:{patternType:"solid",fgColor:this.extractColor(this.querySelectorAll(t,"color")[1],this.theme)}}getBorders(){return this.mapOnElements({parent:this.rootFile.file.xml,query:"border"},(e=>this.extractBorder(e)))}extractBorder(e){const t={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 t.diagonal&&(t.diagonalUp=this.extractAttr(e,"diagonalUp")?.asBool(),t.diagonalDown=this.extractAttr(e,"diagonalDown")?.asBool()),t}extractSingleBorder(e,t,o){const i=this.querySelector(e,t);if(i&&i.attributes.style)return{style:this.extractAttr(i,"style",{required:!0,default:"thin"}).asString(),color:this.extractColor(i.children[0],o,"000000")}}extractAlignment(e){return{horizontal:this.extractAttr(e,"horizontal",{default:"general"}).asString(),vertical:this.extractAttr(e,"vertical",{default:"bottom"}).asString(),textRotation:this.extractAttr(e,"textRotation")?.asNum(),wrapText:this.extractAttr(e,"wrapText")?.asBool(),indent:this.extractAttr(e,"indent")?.asNum(),relativeIndent:this.extractAttr(e,"relativeIndent")?.asNum(),justifyLastLine:this.extractAttr(e,"justifyLastLine")?.asBool(),shrinkToFit:this.extractAttr(e,"shrinkToFit")?.asBool(),readingOrder:this.extractAttr(e,"readingOrder")?.asNum()}}getDxfs(){return this.mapOnElements({query:"dxf",parent:this.rootFile.file.xml},(e=>{const t=this.querySelector(e,"font"),o=this.querySelector(e,"fill"),i=this.querySelector(e,"border"),s=this.querySelector(e,"numFmt"),r=this.querySelector(e,"alignment");return{font:t?this.extractFont(t):void 0,fill:o?this.extractFill(o):void 0,numFmt:s?this.extractNumFormats(s):void 0,alignment:r?this.extractAlignment(r):void 0,border:i?this.extractBorder(i):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 DE extends IE{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})}))),o={};for(let e of t)o[e.xc]=e.value;return{sheetId:this.extractAttr(e,"sheetId",{required:!0}).asNum(),data:o}}))}}function LE(e,t){const o=function(e,t){const o=t[WS],i=o.querySelectorAll(`Override[ContentType="${e}"]`),s=[];for(let e of i){const t=e?.attributes.PartName.value;s.push(t.substring(1))}return s}(e,t);return function(e,t){const o=[];for(let i of e){const e=PE(i,t);o.push({file:{fileName:i,xml:t[i]},rels:e?{fileName:e,xml:t[e]}:void 0})}return o}(o,t)}function PE(e,t){if(e===WS)return"_rels/.rels";let o="";const i=e.split("/");for(let e=0;e<i.length-1;e++)o+=i[e]+"/";return o+="_rels/",o+=i[i.length-1]+".rels",t[o]||(o=void 0),o}class kE{warningManager;xmls;images;constructor(e){this.warningManager=new qS,this.xmls={},this.images=[];for(let t of Object.keys(e))if(t.endsWith(".xml")||t.endsWith(".rels")){const o=e[t].replaceAll(/(<\/?)([a-zA-Z0-9]+):([a-zA-Z0-9]+)/g,"$1NAMESPACE$2NAMESPACE$3");this.xmls[t]=bE(new IS(o))}else t.includes("media/image")&&this.images.push({fileName:t,imageSrc:e[t].imageSrc})}convertXlsx(){const e=this.getXlsxData();return this.convertImportedData(e)}getXlsxData(){const e=this.buildXlsxFileStructure(),t=e.theme?new RE(e.theme,e,this.warningManager).getTheme():void 0,o=e.sharedStrings?new RE(e.sharedStrings,e,this.warningManager).getSharedStrings():[],i=e.sheets.sort(((e,t)=>e.file.fileName.localeCompare(t.file.fileName,void 0,{numeric:!0}))).map((o=>new _E(o,e,this.warningManager,t).getSheet())),s=e.externalLinks.map((t=>new DE(t,e,this.warningManager).getExternalBook())),r=new FE(e,this.warningManager,t);return{fonts:r.getFonts(),fills:r.getFills(),borders:r.getBorders(),dxfs:r.getDxfs(),numFmts:r.getNumFormats(),styles:r.getStyles(),sheets:i,sharedStrings:o,externalBooks:s}}buildXlsxFileStructure(){const e={sheets:LE(_S.sheet,this.xmls),workbook:LE(_S.workbook,this.xmls)[0],styles:LE(_S.styles,this.xmls)[0],sharedStrings:LE(_S.sharedStrings,this.xmls)[0],theme:LE(_S.themes,this.xmls)[0],charts:LE(_S.chart,this.xmls),figures:LE(_S.drawing,this.xmls),tables:LE(_S.table,this.xmls),pivots:LE(_S.pivot,this.xmls),externalLinks:LE(_S.externalLink,this.xmls),images:this.images};if(!e.workbook.rels)throw Error(r("Cannot find workbook relations file"));return e}convertImportedData(e){const t={version:12,sheets:iE(e,this.warningManager),styles:yC(e,this.warningManager),formats:RC(e,this.warningManager),borders:wC(e,this.warningManager),entities:{},revisionId:te};return dE(t,e),Object.keys(e.styles).map((t=>{e.styles[t]=qe(e.styles[t])})),t}}function UE(e){const t=rg(e);let o=[];return{text:"".concat(...t.map((e=>{if("REFERENCE"===e.type&&zo.test(e.value)){const t=e.value.trim();return o.includes(t)||o.push(t),`${de}${o.indexOf(t)}${de}`}return e.value}))),dependencies:o}}const VE=14,BE="Sheet1";function zE(e,t){if(!e)return ZE();if(e["[Content_Types].xml"]){const o=new kE(e);if(e=o.convertXlsx(),t)for(let e of o.warningManager.warnings.sort())console.warn(e)}return"version"in e&&e.version<VE&&(e=function(e){for(let t=HE.findIndex((t=>t.from===e.version));t<HE.length;t++)e=HE[t].applyMigration(e);return e}(e)),e=function(e){return e=function(e){if(e.uniqueFigureIds)return e;const t=new Set,o=new Bi;for(const i of e.sheets||[])for(const e of i.figures||[])t.has(e.id)&&(e.id+=o.uuidv4()),t.add(e.id);return e.uniqueFigureIds=!0,e}(e),e=function(e){const t=Object.assign(ZE(),e,{version:VE});t.sheets=t.sheets?t.sheets.map(((e,t)=>Object.assign(qE(`Sheet${t+1}`,`Sheet${t+1}`),e))):[],0===t.sheets.length&&t.sheets.push(qE(BE,"Sheet1"));fg(t.settings.locale)||(t.settings.locale=eo);return t}(e),e}(e),e}const HE=[{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 o=t.cells[e];o.content&&o.content.startsWith("=")&&(o.formula=UE(o.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:o,...i}=t.figures[e].data,s=[];for(let e of o)if(e.labelCell){const t=ti(e.dataRange),o=e.labelCell+":"+xt(t.right,t.bottom);s.push(o)}else s.push(e.dataRange);i.dataSetsHaveTitle=Boolean(o[0].labelCell),i.dataSets=s,t.figures[e].data=i}return e}},{description:"remove single quotes in sheet names",from:7,to:8,applyMigration(e){const t=[],o=new RegExp(he,"g");for(let i of e.sheets||[]){if(!i.name)continue;const e=i.name,s=e.replace(o,"_");let r=1,n=s;for(;t.includes(n);)n=`${s}${r}`,r++;i.name=n,t.push(n);const a=t=>{if(void 0===t)return t;let o=t.replace(e,n),i=t;for(;i!==o;)i=o,o=i.replace(e,n);return i};for(let e in i.cells){const t=i.cells[e];t.formula&&(t.formula.dependencies=t.formula.dependencies.map(a))}for(let e of i.figures||[])if("chart"===e.type){const t=e.data.dataSets.map(a),o=a(e.data.labelRange);e.data={...e.data,dataSets:t,labelRange:o}}for(let e of i.conditionalFormats||[]){e.ranges=e.ranges.map(a);for(const t of["minimum","maximum","midpoint","upperInflectionPoint","lowerInflectionPoint"])"formula"===e.rule[t]?.type&&(e.rule[t].value=a(e.rule[t].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 o=t.cells[e];if(o.formula){let{text:e,dependencies:t}=o.formula;for(let[o,i]of Object.entries(t)){const t=`\\${de}${o}\\${de}`;e=e.replace(new RegExp(t,"g"),i)}o.content=e,delete o.formula}}return e}},{description:"normalize the formats of the cells",from:10,to:11,applyMigration(e){const t={};for(let o of e.sheets||[])for(let e in o.cells||[]){const i=o.cells[e];i.format&&(i.format=Ve(i.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}},{description:"Fix datafilter duplication",from:12,to:12.5,applyMigration:e=>GE(e)},{description:"Change Border description structure",from:12.5,to:13,applyMigration(e){for(const t in e.borders){const o=e.borders[t];for(const e in o)Array.isArray(o[e])&&(o[e]={style:o[e][0],color:o[e][1]})}return e}},{description:"Add locale to spreadsheet settings",from:13,to:14,applyMigration:e=>(e.settings||(e.settings={}),e.settings.locale||(e.settings.locale=eo),e)},{description:"Fix datafilter duplication (post saas-16.4)",from:14,to:14.5,applyMigration:e=>GE(e)}];function $E(e,t){return t=function(e,t){if(0!==Object.keys(e).length)return t;const o=[],i=[],s=e=>{if("CREATE_SHEET"===e.type)o.push(e.sheetId);else if("sheetId"in e&&!o.includes(e.sheetId))return{...e,sheetId:BE};return e};for(const e of t)"REMOTE_REVISION"===e.type?i.push({...e,commands:e.commands.map(s)}):i.push(e);return i}(e,t),t=WE(t,"SORT_CELLS"),t=function(e,t){const o=[],i={};for(const t of e.sheets||[])t.figures?.forEach((e=>{"chart"===e.tag&&(i[e.id]=e.data)}));for(const e of t)if("REMOTE_REVISION"===e.type){const t=[];for(const o of e.commands){let e=o;switch(o.type){case"CREATE_CHART":i[o.id]=o.definition;break;case"UPDATE_CHART":if(!i[o.id]){console.log(`Fix chart definition: chart with id ${o.id} not found.`);continue}const t={...i[o.id],...o.definition};e={...o,definition:t},i[o.id]=t}t.push(e)}o.push({...e,commands:t})}else o.push(e);return o}(e,t=WE(t,"SET_DECIMAL")),t}function WE(e,t){const o=[];for(const i of e)"REMOTE_REVISION"===i.type?o.push({...i,commands:i.commands.filter((e=>e.type!==t))}):o.push(i);return o}function GE(e){for(let t of e.sheets||[]){let e=[];for(let o of t.filterTables||[]){const t=ti(o.range),i=e.findIndex((e=>di(e,t)));-1!==i?e[i]=t:e.push(t)}t.filterTables=e.map((e=>({range:ii(e)})))}return e}function qE(e,t){return{id:e,name:t,colNumber:26,rowNumber:100,cells:{},cols:{},rows:{},merges:[],conditionalFormats:[],figures:[],filterTables:[],isVisible:!0}}function ZE(e="Sheet1"){return{version:VE,sheets:[qE(BE,e)],entities:{},styles:{},formats:{},borders:{},revisionId:te,uniqueFigureIds:!0,settings:{locale:eo}}}function YE(e,t){return{...qE(e,t),charts:[],images:[]}}class jE{static getters=[];history;dispatch;constructor(e,t){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 o of e){let e=o.call(this,t);Array.isArray(e)||(e=[e]);const i=e.filter((e=>0!==e));if(i.length)return i}return 0}}checkValidations(e,...t){return this.batchValidations(...t)(e)}}class XE extends jE{getters;uuidGenerator;constructor({getters:e,stateObserver:t,range:o,dispatch:i,uuidGenerator:s}){super(t,i),o.addRangeProvider(this.adaptRanges.bind(this)),this.getters=e,this.uuidGenerator=s}import(e){}export(e){}adaptRanges(e,t){}garbageCollectExternalResources(){}}class KE{id;compiledFormula;format;style;dependencies;sheetId;buildFormulaContent;isFormula=!0;constructor(e,t,o,i,s,r,n){this.id=e,this.compiledFormula=t,this.format=o,this.style=i,this.dependencies=s,this.sheetId=r,this.buildFormulaContent=n}get content(){return this.buildFormulaContent(this.sheetId,{dependencies:this.dependencies,compiledFormula:this.compiledFormula})}}function QE(e){return""===e?NaN:Number(e)}class JE{id;zone;filters;constructor(e){this.filters=[],this.zone=e;const t=new Bi;this.id=t.uuidv4();for(const o of ye(e.left,e.right+1)){const e={...this.zone,left:o,right:o};this.filters.push(new ew(t.uuidv4(),e))}}get contentZone(){if(this.zone.bottom!==this.zone.top)return{...this.zone,top:this.zone.top+1}}getFilterId(e){return this.filters.find((t=>t.col===e))?.id}clone(){return new JE(this.zone)}}class ew{id;zoneWithHeaders;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}}}function tw(e){return Object.entries(e).map((([e,t])=>t?ow(parseInt(e,10),t):void 0)).filter(ke).map((e=>xt(e.left,e.top)+":"+xt(e.right,e.bottom)))}function ow(e,t){return{...t.zone,topLeft:{col:t.zone.left,row:t.zone.top},id:e}}class iw{getters;providers=[];constructor(e){this.getters=e}static getters=["getRangeString","getRangeFromSheetXC","createAdaptedRanges","getRangeDataFromXc","getRangeDataFromZone","getRangeFromRangeData","getRangeFromZone"];allowDispatch(e){return"MOVE_RANGES"===e.type?1===e.target.length?0:27:0}beforeHandle(e){}handle(e){switch(e.type){case"REMOVE_COLUMNS_ROWS":{let t="COL"===e.dimension?"left":"top",o="COL"===e.dimension?"right":"bottom",i="COL"===e.dimension?"columns":"rows";const s=[...e.elements];s.sort(((e,t)=>t-e));const r=Ie(s);this.executeOnAllRanges((s=>{if(s.sheetId!==e.sheetId)return{changeType:"NONE"};let n=s,a="NONE";for(let e of r){const r=tt(e),l=et(e);if(s.zone[t]<=r&&r<=s.zone[o]){const e=Math.min(s.zone[o],l)-r+1;a="RESIZE",n=this.createAdaptedRange(n,i,a,-e)}else if(s.zone[t]>=r&&s.zone[o]<=l)a="REMOVE",n=s.clone({...this.getInvalidRange()});else if(s.zone[t]<=l&&s.zone[o]>=l){const e=l-s.zone[t]+1;a="RESIZE",n=this.createAdaptedRange(n,i,a,-e),n=this.createAdaptedRange(n,i,"MOVE",-(s.zone[t]-r))}else r<s.zone[t]&&(a="MOVE",n=this.createAdaptedRange(n,i,a,-(l-r+1)))}return"NONE"!==a?{changeType:a,range:n}:{changeType:"NONE"}}),e.sheetId);break}case"ADD_COLUMNS_ROWS":{let t="COL"===e.dimension?"left":"top",o="COL"===e.dimension?"right":"bottom",i="COL"===e.dimension?"columns":"rows";this.executeOnAllRanges((s=>{if(s.sheetId!==e.sheetId)return{changeType:"NONE"};if("after"===e.position){if(s.zone[t]<=e.base&&e.base<s.zone[o])return{changeType:"RESIZE",range:this.createAdaptedRange(s,i,"RESIZE",e.quantity)};if(e.base<s.zone[t])return{changeType:"MOVE",range:this.createAdaptedRange(s,i,"MOVE",e.quantity)}}else{if(s.zone[t]<e.base&&e.base<=s.zone[o])return{changeType:"RESIZE",range:this.createAdaptedRange(s,i,"RESIZE",e.quantity)};if(e.base<=s.zone[t])return{changeType:"MOVE",range:this.createAdaptedRange(s,i,"MOVE",e.quantity)}}return{changeType:"NONE"}}),e.sheetId);break}case"DELETE_SHEET":this.executeOnAllRanges((t=>{if(t.sheetId!==e.sheetId)return{changeType:"NONE"};const o=this.getters.getSheetName(e.sheetId);return{changeType:"REMOVE",range:t=t.clone({...this.getInvalidRange(),invalidSheetName:o})}}),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 o=void 0,i=e.sheetId;return{changeType:"CHANGE",range:t.clone({sheetId:i,invalidSheetName:o})}}return{changeType:"NONE"}}));break;case"MOVE_RANGES":{const t=e.target[0];this.executeOnAllRanges((o=>{if(o.sheetId!==e.sheetId||!gi(o.zone,t))return{changeType:"NONE"};const i=e.targetSheetId,s=e.col-t.left,r=e.row-t.top,n=this.createAdaptedRange(o,"both","MOVE",[s,r]),a=e.sheetId!==i||n.prefixSheet;return{changeType:"MOVE",range:n.clone({sheetId:i,prefixSheet:a})}}));break}}}finalize(){}verifyRangeRemoved(e){return t=>{const o=e(t);return"NONE"===o.changeType||oi(o.range.zone)?o:{range:o.range,changeType:"REMOVE"}}}createAdaptedRange(e,t,o,i){const s=Si(e.unboundedZone,t,o,i);return e.clone({zone:s})}executeOnAllRanges(e,t){const o=this.verifyRangeRemoved(e);for(const e of this.providers)e(o,t)}addRangeProvider(e){this.providers.push(e)}createAdaptedRanges(e,t,o,i){const s=e.map((e=>Ri.fromRange(e,this.getters)));return s.map((e=>{if(!oi(e.zone))return e;const s=e.prefixSheet?e.sheetId:i,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:o),bottom:e.isFullCol?e.unboundedZone.bottom:e.unboundedZone.bottom+((e.parts[1]||e.parts[0]).rowFixed?0:o)};return e.clone({sheetId:s,zone:r}).orderZone()}))}getRangeFromSheetXC(e,t){if(!Zo.test(t))return new Ri({sheetId:"",zone:{left:-1,top:-1,right:-1,bottom:-1},parts:[],invalidXc:t,prefixSheet:!1},this.getters.getSheetSize);let o,i=t,s=!1;t.includes("!")&&(({xc:i,sheetName:o}=Jo(t)),o&&(s=!0));const r=ei(i),n=Ri.getRangeParts(i,r),a=o&&!this.getters.getSheetIdByName(o)?o:void 0,l=this.getters.getSheetIdByName(o)||e;return new Ri({prefixSheet:s,zone:r,sheetId:l,invalidSheetName:a,parts:n},this.getters.getSheetSize).orderZone()}getRangeString(e,t,o=!1){if(!e)return ee;if(e.invalidXc)return e.invalidXc;if(e.zone.bottom-e.zone.top<0||e.zone.right-e.zone.left<0)return ee;if(e.zone.left<0||e.zone.top<0)return ee;const i=Ri.fromRange(e,this.getters);let s=i.sheetId!==t||i.invalidSheetName||i.prefixSheet,r="";if(s&&(r=i.invalidSheetName?i.invalidSheetName:we(this.getters.getSheetName(i.sheetId))),s&&!r)return ee;let n=this.getRangePartString(i,0,o);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)&&(n+=":",n+=this.getRangePartString(i,1,o)),`${s?r+"!":""}${n}`}getRangeDataFromXc(e,t){return this.getters.getRangeFromSheetXC(e,t).rangeData}getRangeDataFromZone(e,t){return{_sheetId:e,_zone:t}}getRangeFromZone(e,t){return new Ri({sheetId:e,zone:t,parts:[{colFixed:!1,rowFixed:!1},{colFixed:!1,rowFixed:!1}],prefixSheet:!1},this.getters.getSheetSize)}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 Ri(t,this.getters.getSheetSize)}getRangePartString(e,t,o=!1){const i=e.parts&&e.parts[t]?.colFixed?"$":"",s=bt(0===t?e.zone.left:e.zone.right),r=e.parts&&e.parts[t]?.rowFixed?"$":"",n=String(0===t?e.zone.top+1:e.zone.bottom+1);let a="";return a=e.isFullCol&&!o?0===t&&e.unboundedZone.hasHeader?i+s+r+n:i+s:e.isFullRow&&!o?0===t&&e.unboundedZone.hasHeader?i+s+r+n:r+n:i+s+r+n,a}getInvalidRange(){return{parts:[],prefixSheet:!1,zone:{left:-1,top:-1,right:-1,bottom:-1},sheetId:"",invalidXc:ee}}}class sw extends jE{static layers=[];getters;ui;selection;constructor({getters:e,stateObserver:t,dispatch:o,uiActions:i,selection:s}){super(t,o),this.getters=e,this.ui=i,this.selection=s}drawGrid(e,t){}}const rw=fu.mapping;function nw(e,t,o){return new aw(e,t,o).getParameters()}class aw{getters;computeCell;evalContext;rangeCache={};constructor(e,t,o){this.getters=t,this.computeCell=o,this.evalContext=Object.assign(Object.create(rw),e,{getters:this.getters,locale:this.getters.getLocale()})}getParameters(){return[this.refFn.bind(this),this.range.bind(this),this.evalContext]}refFn(e,t,o,i){if(this.assertRangeValid(e),t)return{value:ii(e.zone)};if(e.zone.bottom!==e.zone.top||e.zone.left!==e.zone.right)throw new Error(i?r("Function %s expects the parameter %s to be a single value or a single cell reference, not a range.",o.toString(),i.toString()):r("Function %s expects its parameters to be single values or single cell references, not ranges.",o.toString()));return this.readCell(e)}readCell(e){if(!this.getters.tryGetSheet(e.sheetId))throw new Error(r("Invalid sheet name"));const t={sheetId:e.sheetId,col:e.zone.left,row:e.zone.top},o=this.getEvaluatedCellIfNotEmpty(t);if(void 0===o)return{value:null,format:this.getters.getCell(t)?.format};if(o.type===ls.error)throw o.error;return o}getEvaluatedCellIfNotEmpty(e){const t=this.computeCell(e);if(t.type===ls.empty){const t=this.getters.getCell(e);if(!t||!t.isFormula&&""===t.content)return}return t}range(e){this.assertRangeValid(e);const t=e.sheetId,o=e.zone,i=ci(o,this.getters.getSheetZone(t));if(!i)return{value:[[]],format:[[]]};const{top:s,left:r,bottom:n,right:a}=o,l=`${t}-${s}-${r}-${n}-${a}`;if(l in this.rangeCache){const e=this.rangeCache[l];if(e instanceof c)throw e;return e}const h=i.bottom-i.top+1,d=i.right-i.left+1,u=new Array(d),g=new Array(d);for(let e=i.left;e<=i.right;e++){const o=e-i.left;u[o]=new Array(h),g[o]=new Array(h);for(let s=i.top;s<=i.bottom;s++){const r=this.getEvaluatedCellIfNotEmpty({sheetId:t,col:e,row:s});if(r?.type===ls.error)throw this.rangeCache[l]=r.error,r.error;const n=s-i.top;u[o][n]=r?.value,void 0!==r?.format&&(g[o][n]=r.format)}}const p={value:u,format:g};return this.rangeCache[l]=p,p}assertRangeValid(e){if(!oi(e.zone))throw new u;if(e.invalidSheetName)throw new Error(r("Invalid sheet name: %s",e.invalidSheetName))}}function lw(e,t,o,i,s){cw(e,t,o||0,i||e.length-1,s||dw)}function cw(e,t,o,i,s){for(;i>o;){if(i-o>600){var r=i-o+1,n=t-o+1,a=Math.log(r),l=.5*Math.exp(2*a/3),c=.5*Math.sqrt(a*l*(r-l)/r)*(n-r/2<0?-1:1);cw(e,t,Math.max(o,Math.floor(t-n*l/r+c)),Math.min(i,Math.floor(t+(r-n)*l/r+c)),s)}var h=e[t],d=o,u=i;for(hw(e,o,t),s(e[i],h)>0&&hw(e,o,i);d<u;){for(hw(e,d,u),d++,u--;s(e[d],h)<0;)d++;for(;s(e[u],h)>0;)u--}0===s(e[o],h)?hw(e,o,u):hw(e,++u,i),u<=t&&(o=u+1),t<=u&&(i=u-1)}}function hw(e,t,o){var i=e[t];e[t]=e[o],e[o]=i}function dw(e,t){return e<t?-1:e>t?1:0}class uw{constructor(e=9){this._maxEntries=Math.max(4,e),this._minEntries=Math.max(2,Math.ceil(.4*this._maxEntries)),this.clear()}all(){return this._all(this.data,[])}search(e){let t=this.data;const o=[];if(!xw(e,t))return o;const i=this.toBBox,s=[];for(;t;){for(let r=0;r<t.children.length;r++){const n=t.children[r],a=t.leaf?i(n):n;xw(e,a)&&(t.leaf?o.push(n):ww(e,a)?this._all(n,o):s.push(n))}t=s.pop()}return o}collides(e){let t=this.data;if(!xw(e,t))return!1;const o=[];for(;t;){for(let i=0;i<t.children.length;i++){const s=t.children[i],r=t.leaf?this.toBBox(s):s;if(xw(e,r)){if(t.leaf||ww(e,r))return!0;o.push(s)}}t=o.pop()}return!1}load(e){if(!e||!e.length)return this;if(e.length<this._minEntries){for(let t=0;t<e.length;t++)this.insert(e[t]);return this}let t=this._build(e.slice(),0,e.length-1,0);if(this.data.children.length)if(this.data.height===t.height)this._splitRoot(this.data,t);else{if(this.data.height<t.height){const e=this.data;this.data=t,t=e}this._insert(t,this.data.height-t.height-1,!0)}else this.data=t;return this}insert(e){return e&&this._insert(e,this.data.height-1),this}clear(){return this.data=yw([]),this}remove(e,t){if(!e)return this;let o=this.data;const i=this.toBBox(e),s=[],r=[];let n,a,l;for(;o||s.length;){if(o||(o=s.pop(),a=s[s.length-1],n=r.pop(),l=!0),o.leaf){const i=gw(e,o.children,t);if(-1!==i)return o.children.splice(i,1),s.push(o),this._condense(s),this}l||o.leaf||!ww(o,i)?a?(n++,o=a.children[n],l=!1):o=null:(s.push(o),r.push(n),n=0,a=o,o=o.children[0])}return this}toBBox(e){return e}compareMinX(e,t){return e.minX-t.minX}compareMinY(e,t){return e.minY-t.minY}toJSON(){return this.data}fromJSON(e){return this.data=e,this}_all(e,t){const o=[];for(;e;)e.leaf?t.push(...e.children):o.push(...e.children),e=o.pop();return t}_build(e,t,o,i){const s=o-t+1;let r,n=this._maxEntries;if(s<=n)return r=yw(e.slice(t,o+1)),pw(r,this.toBBox),r;i||(i=Math.ceil(Math.log(s)/Math.log(n)),n=Math.ceil(s/Math.pow(n,i-1))),r=yw([]),r.leaf=!1,r.height=i;const a=Math.ceil(s/n),l=a*Math.ceil(Math.sqrt(n));Iw(e,t,o,l,this.compareMinX);for(let s=t;s<=o;s+=l){const t=Math.min(s+l-1,o);Iw(e,s,t,a,this.compareMinY);for(let o=s;o<=t;o+=a){const s=Math.min(o+a-1,t);r.children.push(this._build(e,o,s,i-1))}}return pw(r,this.toBBox),r}_chooseSubtree(e,t,o,i){for(;i.push(t),!t.leaf&&i.length-1!==o;){let o,i=1/0,n=1/0;for(let a=0;a<t.children.length;a++){const l=t.children[a],c=Sw(l),h=(s=e,r=l,(Math.max(r.maxX,s.maxX)-Math.min(r.minX,s.minX))*(Math.max(r.maxY,s.maxY)-Math.min(r.minY,s.minY))-c);h<n?(n=h,i=c<i?c:i,o=l):h===n&&c<i&&(i=c,o=l)}t=o||t.children[0]}var s,r;return t}_insert(e,t,o){const i=o?e:this.toBBox(e),s=[],r=this._chooseSubtree(i,this.data,t,s);for(r.children.push(e),fw(r,i);t>=0&&s[t].children.length>this._maxEntries;)this._split(s,t),t--;this._adjustParentBBoxes(i,s,t)}_split(e,t){const o=e[t],i=o.children.length,s=this._minEntries;this._chooseSplitAxis(o,s,i);const r=this._chooseSplitIndex(o,s,i),n=yw(o.children.splice(r,o.children.length-r));n.height=o.height,n.leaf=o.leaf,pw(o,this.toBBox),pw(n,this.toBBox),t?e[t-1].children.push(n):this._splitRoot(o,n)}_splitRoot(e,t){this.data=yw([e,t]),this.data.height=e.height+1,this.data.leaf=!1,pw(this.data,this.toBBox)}_chooseSplitIndex(e,t,o){let i,s=1/0,r=1/0;for(let n=t;n<=o-t;n++){const t=mw(e,0,n,this.toBBox),a=mw(e,n,o,this.toBBox),l=Ew(t,a),c=Sw(t)+Sw(a);l<s?(s=l,i=n,r=c<r?c:r):l===s&&c<r&&(r=c,i=n)}return i||o-t}_chooseSplitAxis(e,t,o){const i=e.leaf?this.compareMinX:bw,s=e.leaf?this.compareMinY:vw;this._allDistMargin(e,t,o,i)<this._allDistMargin(e,t,o,s)&&e.children.sort(i)}_allDistMargin(e,t,o,i){e.children.sort(i);const s=this.toBBox,r=mw(e,0,t,s),n=mw(e,o-t,o,s);let a=Cw(r)+Cw(n);for(let i=t;i<o-t;i++){const t=e.children[i];fw(r,e.leaf?s(t):t),a+=Cw(r)}for(let i=o-t-1;i>=t;i--){const t=e.children[i];fw(n,e.leaf?s(t):t),a+=Cw(n)}return a}_adjustParentBBoxes(e,t,o){for(let i=o;i>=0;i--)fw(t[i],e)}_condense(e){for(let t,o=e.length-1;o>=0;o--)0===e[o].children.length?o>0?(t=e[o-1].children,t.splice(t.indexOf(e[o]),1)):this.clear():pw(e[o],this.toBBox)}}function gw(e,t,o){if(!o)return t.indexOf(e);for(let i=0;i<t.length;i++)if(o(e,t[i]))return i;return-1}function pw(e,t){mw(e,0,e.children.length,t,e)}function mw(e,t,o,i,s){s||(s=yw(null)),s.minX=1/0,s.minY=1/0,s.maxX=-1/0,s.maxY=-1/0;for(let r=t;r<o;r++){const t=e.children[r];fw(s,e.leaf?i(t):t)}return s}function fw(e,t){return e.minX=Math.min(e.minX,t.minX),e.minY=Math.min(e.minY,t.minY),e.maxX=Math.max(e.maxX,t.maxX),e.maxY=Math.max(e.maxY,t.maxY),e}function bw(e,t){return e.minX-t.minX}function vw(e,t){return e.minY-t.minY}function Sw(e){return(e.maxX-e.minX)*(e.maxY-e.minY)}function Cw(e){return e.maxX-e.minX+(e.maxY-e.minY)}function Ew(e,t){const o=Math.max(e.minX,t.minX),i=Math.max(e.minY,t.minY),s=Math.min(e.maxX,t.maxX),r=Math.min(e.maxY,t.maxY);return Math.max(0,s-o)*Math.max(0,r-i)}function ww(e,t){return e.minX<=t.minX&&e.minY<=t.minY&&t.maxX<=e.maxX&&t.maxY<=e.maxY}function xw(e,t){return t.minX<=e.maxX&&t.minY<=e.maxY&&t.maxX>=e.minX&&t.maxY>=e.minY}function yw(e){return{children:e,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function Iw(e,t,o,i,s){const r=[t,o];for(;r.length;){if((o=r.pop())-(t=r.pop())<=i)continue;const n=t+Math.ceil((o-t)/i/2)*i;lw(e,n,t,o,s),r.push(t,n,n,o)}}class Rw{rTrees={};constructor(e=[]){const t={};for(const o of e){const e=o.boundingBox.sheetId;t[e]||(t[e]=[]),t[e].push(o)}for(const e in t)this.rTrees[e]=new Tw,this.rTrees[e].load(t[e])}insert(e){const t=e.boundingBox.sheetId;this.rTrees[t]||(this.rTrees[t]=new Tw),this.rTrees[t].insert(e)}search({zone:e,sheetId:t}){return this.rTrees[t]?this.rTrees[t].search({minX:e.left,minY:e.top,maxX:e.right,maxY:e.bottom}):[]}remove(e){const t=e.boundingBox.sheetId;this.rTrees[t]&&this.rTrees[t].remove(e,this.rtreeItemComparer)}rtreeItemComparer(e,t){return e.data==t.data&&e.boundingBox.sheetId===t.boundingBox.sheetId&&e.boundingBox?.zone.left===t.boundingBox.zone.left&&e.boundingBox?.zone.top===t.boundingBox.zone.top&&e.boundingBox?.zone.right===t.boundingBox.zone.right&&e.boundingBox?.zone.bottom===t.boundingBox.zone.bottom}}class Tw extends uw{toBBox({boundingBox:e}){const t=e.zone;return{minX:t.left,minY:t.top,maxX:t.right,maxY:t.bottom}}compareMinX(e,t){return e.boundingBox.zone.left-t.boundingBox.zone.left}compareMinY(e,t){return e.boundingBox.zone.top-t.boundingBox.zone.top}}class Aw{encoder;dependencies=new Map;rTree;constructor(e,t=[]){this.encoder=e,this.rTree=new Rw(t)}removeAllDependencies(e){const t=this.dependencies.get(e);if(t){for(const e of t)this.rTree.remove(e);this.dependencies.delete(e)}}addDependencies(e,t){const o=t.map((({sheetId:t,zone:o})=>({data:e,boundingBox:{zone:o,sheetId:t}})));for(const e of o)this.rTree.insert(e);const i=this.dependencies.get(e);i?i.push(...o):this.dependencies.set(e,o)}getCellsDependingOn(e){const t=new Ke,o=Array.from(e).reverse();for(;o.length>0;){const e=o.pop();t.addMany(this.encoder.encodeBoundingBox(e));const i=this.rTree.search(e).map((e=>e.data));for(const e of i)t.has(e)||o.push(this.encoder.decodeToBoundingBox(e))}return t.deleteMany(e.flatMap((e=>this.encoder.encodeBoundingBox(e)))),t}}class Ow{resultsToArrayFormulas=new Map;arrayFormulasToResults=new Map;getFormulaPositionsSpreadingOn(e){return this.resultsToArrayFormulas.get(e)||Mw}getArrayResultPositionIds(e){return this.arrayFormulasToResults.get(e)||Mw}removeNode(e){this.resultsToArrayFormulas.delete(e),this.arrayFormulasToResults.delete(e)}addRelation({arrayFormulaPositionId:e,resultPositionId:t}){this.resultsToArrayFormulas.has(t)||this.resultsToArrayFormulas.set(t,new Set),this.resultsToArrayFormulas.get(t)?.add(e),this.arrayFormulasToResults.has(e)||this.arrayFormulasToResults.set(e,new Set),this.arrayFormulasToResults.get(e)?.add(t)}hasArrayFormulaResult(e){return this.resultsToArrayFormulas.has(e)}isArrayFormula(e){return this.arrayFormulasToResults.has(e)}}const Mw=[];class Nw{context;getters;compilationParams;encoder=new Dw;evaluatedCells=new Map;formulaDependencies=ze(new Aw(this.encoder));blockedArrayFormulas=new Set;spreadingRelations=new Ow;constructor(e,t){this.context=e,this.getters=t,this.compilationParams=nw(this.context,this.getters,this.computeAndSave.bind(this))}getEvaluatedCell(e){return this.evaluatedCells.get(this.encoder.encode(e))||sr("",{locale:this.getters.getLocale()})}getArrayFormulaSpreadingOn(e){const t=this.encoder.encode(e),o=this.getArrayFormulaSpreadingOnId(t);return void 0!==o?this.encoder.decode(o):void 0}getEvaluatedPositions(){return[...this.evaluatedCells.keys()].map((e=>this.encoder.decode(e)))}getArrayFormulaSpreadingOnId(e){if(!this.spreadingRelations.hasArrayFormulaResult(e))return;const t=this.spreadingRelations.getFormulaPositionsSpreadingOn(e);return Array.from(t).find((e=>!this.blockedArrayFormulas.has(e)))}updateDependencies(e){const t=this.encoder.encode(e);this.formulaDependencies().removeAllDependencies(t);const o=this.getDirectDependencies(t);this.formulaDependencies().addDependencies(t,o)}updateCompilationParameters(){this.compilationParams=nw(this.context,this.getters,this.computeAndSave.bind(this))}evaluateCells(e){const t=e.map((e=>this.encoder.encode(e))),o=new Ke(t),i=this.getArrayFormulasImpactedByChangesOf(t);o.addMany(this.getCellsDependingOn(t)),o.addMany(i),o.addMany(this.getCellsDependingOn(i)),this.evaluate(o)}getArrayFormulasImpactedByChangesOf(e){const t=new Ke;for(const o of e){const e=this.getCell(o)?.content,i=this.getArrayFormulaSpreadingOnId(o);void 0!==i&&t.add(i),e||t.addMany(this.getArrayFormulasBlockedByOrSpreadingOn(o))}return t}buildDependencyGraph(){this.blockedArrayFormulas=new Set,this.spreadingRelations=new Ow,this.formulaDependencies=ze((()=>{const e=[...this.getAllCells()].flatMap((e=>this.getDirectDependencies(e).filter((e=>!e.invalidSheetName&&!e.invalidXc)).map((t=>({data:e,boundingBox:{zone:t.zone,sheetId:t.sheetId}})))));return new Aw(this.encoder,e)}))}evaluateAllCells(){this.evaluatedCells=new Map,this.evaluate(this.getAllCells())}evaluateFormula(e,t){const o=hg(t),i=[];for(let t of o.dependencies)i.push(this.getters.getRangeFromSheetXC(e,t));return this.updateCompilationParameters(),o.execute(i,...this.compilationParams).value}getAllCells(){const e=new Ke;for(const t of this.getters.getSheetIds()){const o=this.getters.getCells(t);for(const t in o)e.add(this.encoder.encode(this.getters.getCellPosition(t)))}return e}getArrayFormulasBlockedByOrSpreadingOn(e){if(!this.spreadingRelations.hasArrayFormulaResult(e))return[];const t=this.spreadingRelations.getFormulaPositionsSpreadingOn(e),o=new Ke(t);return o.addMany(this.getCellsDependingOn(t)),o}nextPositionsToUpdate=new Ke;cellsBeingComputed=new Set;evaluate(e){this.cellsBeingComputed=new Set,this.nextPositionsToUpdate=e;let t=0;for(;this.nextPositionsToUpdate.size&&t++<30;){this.updateCompilationParameters();const e=Array.from(this.nextPositionsToUpdate);this.nextPositionsToUpdate.clear();for(let t=0;t<e.length;++t){const o=e[t];this.evaluatedCells.delete(o)}for(let t=0;t<e.length;++t){const o=e[t];this.setEvaluatedCell(o,this.computeCell(o))}}}setEvaluatedCell(e,t){this.evaluatedCells.set(e,t)}computeCell(e){const t=this.evaluatedCells.get(e);if(t)return t;this.blockedArrayFormulas.has(e)||this.invalidateSpreading(e);const o=this.getCell(e);if(void 0===o)return sr("",{locale:this.getters.getLocale()});const i=o.id;try{if(this.cellsBeingComputed.has(i))throw new d;return this.cellsBeingComputed.add(i),o.isFormula?this.computeFormulaCell(o):or(o.content,{format:o.format,locale:this.getters.getLocale()})}catch(e){return this.handleError(e,o)}finally{this.cellsBeingComputed.delete(i)}}computeAndSave(e){const t=this.encoder.encode(e),o=this.computeCell(t);return this.evaluatedCells.has(t)||this.setEvaluatedCell(t,o),o}handleError(e,t){e instanceof c||(e=new c(a.GenericError,e.message));const o=this.compilationParams[2].__lastFnCalled||"";return e.message=e.message.replace("[[FUNCTION_NAME]]",o),lr(e)}computeFormulaCell(e){const t=e.id;this.compilationParams[2].__originCellXC=()=>{const e=this.compilationParams[2].getters.getCellPosition(t);return xt(e.col,e.row)};const o=e.compiledFormula.execute(e.dependencies,...this.compilationParams);!function(e){const{value:t,format:o}=e;if(!Ss(t)){if(Ss(o))throw new Error("A format matrix should never be associated with a scalar value");return}if(Ss(o)){if(!(t.length===o.length&&t[0].length===o[0].length))throw new Error("Formats and values should have the same dimensions!")}}(o);const{value:i,format:s}=o;if(!Ss(i))return sr(i,{format:e.format||s,locale:this.getters.getLocale()});const r=this.getters.getCellPosition(t);this.assertSheetHasEnoughSpaceToSpreadFormulaResult(r,i),_w(i,this.updateSpreadRelation(r)),_w(i,this.checkCollision(r)),_w(i,this.spreadValues(r,o));const n=Fw(s);return sr(i[0][0],{format:e.format||n(0,0),locale:this.getters.getLocale()})}assertSheetHasEnoughSpaceToSpreadFormulaResult({sheetId:e,col:t,row:o},i){const s=this.getters.getNumberCols(e),n=this.getters.getNumberRows(e),a=t+i.length<=s,l=o+i[0].length<=n;if(!a||!l){if(a)throw new Error(r("Result couldn't be automatically expanded. Please insert more rows."));if(l)throw new Error(r("Result couldn't be automatically expanded. Please insert more columns."));throw new Error(r("Result couldn't be automatically expanded. Please insert more columns and rows."))}}updateSpreadRelation({sheetId:e,col:t,row:o}){const i=this.encoder.encode({sheetId:e,col:t,row:o});return(s,r)=>{const n={sheetId:e,col:s+t,row:r+o},a=this.encoder.encode(n);this.spreadingRelations.addRelation({resultPositionId:a,arrayFormulaPositionId:i})}}checkCollision({sheetId:e,col:t,row:o}){const i=this.encoder.encode({sheetId:e,col:t,row:o});return(s,n)=>{const a={sheetId:e,col:s+t,row:n+o};if(this.getters.getCell(a)?.content||this.getters.getEvaluatedCell(a).type!==ls.empty)throw this.blockedArrayFormulas.add(i),new Error(r("Array result was not expanded because it would overwrite data in %s.",xt(a.col,a.row)));this.blockedArrayFormulas.delete(i)}}spreadValues({sheetId:e,col:t,row:o},i){const s=Fw(i.format);return(r,n)=>{const a={sheetId:e,col:r+t,row:n+o},l=this.getters.getCell(a)?.format,c=sr(i.value[r][n],{format:l||s(r,n),locale:this.getters.getLocale()}),h=this.encoder.encode(a);this.setEvaluatedCell(h,c),this.nextPositionsToUpdate.addMany(this.getCellsDependingOn([h]))}}invalidateSpreading(e){if(this.spreadingRelations.isArrayFormula(e)){for(const t of this.spreadingRelations.getArrayResultPositionIds(e)){const e=this.getCell(t)?.content;e||(this.evaluatedCells.delete(t),this.nextPositionsToUpdate.addMany(this.getCellsDependingOn([t])),this.nextPositionsToUpdate.addMany(this.getArrayFormulasBlockedByOrSpreadingOn(t)))}this.spreadingRelations.removeNode(e)}}getDirectDependencies(e){const t=this.getCell(e);return t?.isFormula?t.dependencies:[]}getCellsDependingOn(e){const t=[];for(const o of e)t.push(this.encoder.decodeToBoundingBox(o));return this.formulaDependencies().getCellsDependingOn(t)}getCell(e){return this.getters.getCell(this.encoder.decode(e))}}function _w(e,t){for(let o=0;o<e.length;++o)for(let i=0;i<e[o].length;++i)0===o&&0===i||t(o,i)}function Fw(e){return Ss(e)?(t,o)=>e[t][o]:()=>e}class Dw{sheetMapping={};inverseSheetMapping=new Map;constructor(){try{o_spreadsheet.__DEBUG__=o_spreadsheet.__DEBUG__||{},o_spreadsheet.__DEBUG__.decodePosition=this.decode.bind(this),o_spreadsheet.__DEBUG__.encodePosition=this.encode.bind(this)}catch(e){}}encode({sheetId:e,col:t,row:o}){return this.encodeSheet(e)<<42n|BigInt(t)<<21n|BigInt(o)}encodeBoundingBox({sheetId:e,zone:t}){const o=[];return function(e,t){const{left:o,right:i,top:s,bottom:r}=e;for(let e=o;e<=i;e++)for(let o=s;o<=r;o++)t(e,o)}(t,((t,i)=>{o.push(this.encode({sheetId:e,col:t,row:i}))})),o}decode(e){const t=Number(2097151n&e),o=Number(e>>21n&2097151n);return{sheetId:this.decodeSheet(e>>42n),col:o,row:t}}decodeToBoundingBox(e){const{sheetId:t,col:o,row:i}=this.decode(e);return{sheetId:t,zone:{left:o,top:i,right:o,bottom:i}}}encodeSheet(e){const t=this.sheetMapping[e];if(void 0===t){const t=BigInt(Object.keys(this.sheetMapping).length);return this.sheetMapping[e]=t,this.inverseSheetMapping.set(t,e),t}return t}decodeSheet(e){const t=this.inverseSheetMapping.get(e);if(void 0===t)throw new Error("Sheet id not found");return t}}class Lw{cells;getters;index=0;direction;constructor(e,t,o){this.cells=e,this.getters=t,this.direction=o}next(){const e=this.cells[this.index++%this.cells.length],t=e.rule,{cellData:o,tooltip:i}=hr.get(t.type).apply(t,e.data,this.getters,this.direction);return{cellData:o,tooltip:i,origin:{col:e.data.col,row:e.data.row}}}}class Pw{subscriptions={};on(e,t,o){if(!o)throw new Error("Missing callback");this.subscriptions[e]||(this.subscriptions[e]=[]),this.subscriptions[e].push({owner:t,callback:o})}trigger(e,t){const o=this.subscriptions[e]||[];for(let e=0,i=o.length;e<i;e++){const i=o[e];i.callback.call(i.owner,t)}}off(e,t){const o=this.subscriptions[e];o&&(this.subscriptions[e]=o.filter((e=>e.owner!==t)))}clear(){this.subscriptions={}}}function kw(e,t){return{...e,definition:hm(e.definition,t)}}function Uw(e,t){if(e.sheetId!==t.sheetId)return e;if(("FREEZE_COLUMNS"===e.type?"COL":"ROW")!==t.dimension)return e;let o=e.quantity;if("REMOVE_COLUMNS_ROWS"===t.type){const e=[...t.elements].sort(((e,t)=>t-e));for(let t of e)o>t&&o--}if("ADD_COLUMNS_ROWS"===t.type){o=o>("before"===t.position?t.base-1:t.base)?o+t.quantity:o}return o>0?{...e,quantity:o}:void 0}jb.addTransformation("ADD_COLUMNS_ROWS",["CREATE_CHART","UPDATE_CHART"],kw),jb.addTransformation("REMOVE_COLUMNS_ROWS",["CREATE_CHART","UPDATE_CHART"],kw),jb.addTransformation("DELETE_SHEET",["MOVE_RANGES"],(function(e,t){const o=t.sheetId;if(e.targetSheetId===o||e.sheetId===o)return;return e})),jb.addTransformation("DELETE_FIGURE",["UPDATE_FIGURE","UPDATE_CHART"],(function(e,t){if(e.id===t.id)return;return e})),jb.addTransformation("CREATE_SHEET",["CREATE_SHEET"],(function(e,t){if(e.name===t.name)return{...e,name:e.name?.match(/\d+/)?e.name.replace(/\d+/,(e=>(parseInt(e)+1).toString())):`${e.name}~`,position:e.position+1};return e})),jb.addTransformation("ADD_MERGE",["ADD_MERGE","REMOVE_MERGE","CREATE_FILTER_TABLE"],(function(e,t){if(e.sheetId!==t.sheetId)return e;const o=[];for(const i of e.target)for(const e of t.target)di(i,e)||o.push({...i});if(o.length)return{...e,target:o};return})),jb.addTransformation("ADD_COLUMNS_ROWS",["FREEZE_COLUMNS","FREEZE_ROWS"],Uw),jb.addTransformation("REMOVE_COLUMNS_ROWS",["FREEZE_COLUMNS","FREEZE_ROWS"],Uw),jb.addTransformation("CREATE_FILTER_TABLE",["CREATE_FILTER_TABLE","ADD_MERGE"],(function(e,t){if(e.sheetId!==t.sheetId)return e;for(const o of e.target)for(const e of t.target)if(di(e,o))return;return e}));const Vw=[{match:function(e){return"sheetId"in e},fn:Hw},{match:function(e){return"target"in e&&"sheetId"in e},fn:function(e,t){const o=Hw(e,t);if("SKIP_TRANSFORMATION"!==o)return"IGNORE_COMMAND"===o?"IGNORE_COMMAND":e;const i=[];for(const o of e.target){const e=Gg(o,t);e&&i.push(e)}if(!i.length)return"IGNORE_COMMAND";return{...e,target:i}}},{match:function(e){return"col"in e&&"row"in e&&"sheetId"in e},fn:function(e,t){const o=Hw(e,t);if("SKIP_TRANSFORMATION"!==o)return"IGNORE_COMMAND"===o?"IGNORE_COMMAND":e;if("ADD_COLUMNS_ROWS"===t.type||"REMOVE_COLUMNS_ROWS"===t.type)return function(e,t){const o="COL"===t.dimension?"col":"row";let i=e[o];if("REMOVE_COLUMNS_ROWS"===t.type){const e=[...t.elements].sort(((e,t)=>t-e));if(e.includes(i))return"IGNORE_COMMAND";for(let t of e)i>=t&&i--}"ADD_COLUMNS_ROWS"===t.type&&(i>t.base||i===t.base&&"before"===t.position)&&(i+=t.quantity);return{...e,[o]:i}}(e,t);if("ADD_MERGE"===t.type)return function(e,t){for(const o of t.target){if(!(e.col===o.left&&e.row===o.top)&&ui(e.col,e.row,o))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 o=Hw(e,t);if("SKIP_TRANSFORMATION"!==o)return"IGNORE_COMMAND"===o?"IGNORE_COMMAND":e;if("ADD_COLUMNS_ROWS"===t.type||"REMOVE_COLUMNS_ROWS"===t.type){if(t.dimension!==e.dimension)return e;const o="ADD_COLUMNS_ROWS"===e.type,i=o?"base":"elements";let s=o?[e[i]]:e[i];if("REMOVE_COLUMNS_ROWS"===t.type&&(s=s.map((e=>{if(t.elements.includes(e))return;const o=t.elements.sort(((e,t)=>t-e));for(let t of o)e>t&&e--;return e})).filter(ke)),"ADD_COLUMNS_ROWS"===t.type){const e="before"===t.position?t.base-1:t.base;s=s.map((o=>o>e?o+t.quantity:o))}if(s.length){let t=s;return o&&(t=s[0]),{...e,[i]:t}}return"IGNORE_COMMAND"}return"SKIP_TRANSFORMATION"}},{match:function(e){return"ranges"in e},fn:function(e,t){if(!("sheetId"in t))return e;const o=[],i="DELETE_SHEET"===t.type&&t.sheetId;for(const s of e.ranges)if(s._sheetId!==t.sheetId)o.push({...s,_zone:s._zone});else{const e=Gg(s._zone,t);e&&i!==s._sheetId&&o.push({...s,_zone:e})}if(!o.length)return"IGNORE_COMMAND";return{...e,ranges:o}}}];function Bw(e,t){const o=jb.getTransformation(e.type,t.type);return o?o(e,t):function(e,t){for(const{match:o,fn:i}of Vw)if(o(e)){const o=i(e,t);if("SKIP_TRANSFORMATION"===o)continue;if("IGNORE_COMMAND"===o)return;e=o}return e}(e,t)}function zw(e,t){let o=[...e];for(const e of t)o=o.map((t=>Bw(t,e))).filter(ke);return o}function Hw(e,t){if(!("sheetId"in t))return e;const o="DELETE_SHEET"===t.type&&t.sheetId;return e.sheetId===o?"IGNORE_COMMAND":"CREATE_SHEET"===e.type||"CREATE_SHEET"===t.type||e.sheetId!==t.sheetId?e:"SKIP_TRANSFORMATION"}class $w{rootCommand;timestamp;id;clientId;_commands=[];_changes=[];constructor(e,t,o,i,s,r){this.rootCommand=i,this.timestamp=r,this.id=e,this.clientId=t,this._commands=[...o],this._changes=s?[...s]:[]}setChanges(e){this._changes=e}get commands(){return this._commands}get changes(){return this._changes}}class Ww extends Error{}class Gw extends Pw{revisions;transportService;serverRevisionId;clients={};clientId="local";debouncedMove;pendingMessages=[];waitingAck=!1;waitingUndoRedoAck=!1;isReplayingInitialRevisions=!1;processedRevisions=new Set;uuidGenerator=new Bi;constructor(e,t,o=te){super(),this.revisions=e,this.transportService=t,this.serverRevisionId=o,this.debouncedMove=function(e,t,o){let i;return function(){const s=this,r=arguments,n=o&&!i;clearTimeout(i),i=setTimeout((function(){i=null,o||e.apply(s,r)}),t),n&&e.apply(s,r)}}(this._move.bind(this),200)}canApplyOptimisticUpdate(){return!this.waitingUndoRedoAck}save(e,t,o){if(!t.length||!o.length||!this.canApplyOptimisticUpdate())return;const i=new $w(this.uuidGenerator.uuidv4(),this.clientId,t,e,o,Date.now());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 Ww("The client left the session");return e}getConnectedClients(){return new Set(Object.values(this.clients).filter(ke))}getRevisionId(){return this.serverRevisionId}isFullySynchronized(){return 0===this.pendingMessages.length}getLastLocalNonEmptyRevision(e){const t=this.revisions.getRevertedExecution();for(const o of t){if("SNAPSHOT"===o.rootCommand)return;if(o.rootCommand&&"REMOTE"!==o.rootCommand&&(!e.includes(o.rootCommand?.type)&&o.commands.length))return o}}_move(e){if(!this.clients[this.clientId])return;const t=this.clients[this.clientId]?.position;if(t?.col===e.col&&t.row===e.row&&t.sheetId===e.sheetId)return;const o=t?"CLIENT_MOVED":"CLIENT_JOINED",i=this.getClient();this.clients[this.clientId]={...i,position:e},this.transportService.sendMessage({type:o,version:1,client:{...i,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:o,timestamp:i}=e,s=new $w(e.nextRevisionId,t,o,"REMOTE",void 0,i);if(s.clientId!==this.clientId){this.revisions.insert(s.id,s,e.serverRevisionId);const t=this.pendingMessages.filter((e=>"REMOTE_REVISION"===e.type)).map((e=>e.commands)).flat();this.trigger("remote-revision-received",{commands:zw(o,t)})}break;case"SNAPSHOT_CREATED":{const t=new $w(e.nextRevisionId,"server",[],"SNAPSHOT",void 0,Date.now());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 qw=["#ff851b","#0074d9","#7fdbff","#b10dc9","#39cccc","#f012be","#3d9970","#111111","#ff4136","#aaaaaa","#85144b","#001f3f"];var Zw;!function(e){e[e.previous=-1]="previous",e[e.current=0]="current",e[e.next=1]="next"}(Zw||(Zw={}));class Yw extends sw{inputHasSingleRange;static layers=[1];static getters=[];ranges=[];focusedRangeIndex=null;activeSheet;willAddNewRange=!1;constructor(e,t,o){if(o&&t.length>1)throw new Error("Input with a single range cannot be instantiated with several range references.");super(e),this.inputHasSingleRange=o,this.insertNewRange(0,t),this.activeSheet=this.getters.getActiveSheetId(),0===this.ranges.length&&(this.insertNewRange(this.ranges.length,[""]),this.focusLast())}handleEvent(e){const t=this.activeSheet,o=this.getters.getActiveSheetId(),i=e.anchor.zone,s=this.getters.getRangeFromZone(o,e.options.unbounded?this.getters.getUnboundedZone(o,i):i);this.add([this.getters.getSelectionRangeString(s,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 o=e.value.replace(/^,+/,"").split(",").map((e=>e.trim()));this.setRange(t,o)}break}case"ADD_EMPTY_RANGE":this.insertNewRange(this.ranges.length,[""]),this.focusLast();break;case"ADD_RANGE":this.insertNewRange(this.ranges.length,[e.value]),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:o}=this.getters.getNextVisibleCellPosition({sheetId:e.sheetIdTo,col:0,row:0}),i=this.getters.expandZone(e.sheetIdTo,wi({col:t,row:o}));this.selection.resetAnchor(this,{cell:{col:t,row:o},zone:i})}}}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],xc:t}}insertNewRange(e,t){const o=Math.max(0,...this.ranges.map((e=>Number(e.id))));this.ranges.splice(e,0,...t.map(((e,t)=>({xc:e,id:o+t+1,color:st[(o+t)%st.length]}))))}setRange(e,t){const[,...o]=t;this.setContent(e,t[0]),this.insertNewRange(e+1,o),o.length&&this.focus(e+o.length)}removeRange(e){this.ranges.splice(e,1),null!==this.focusedRangeIndex&&this.focusLast()}inputToHighlights({xc:e,color:t}){const o=this.cleanInputs([e]).filter((e=>this.getters.isRangeValid(e))).filter((e=>this.shouldBeHighlighted(this.activeSheet,e)));return o.map((e=>{const{sheetName:o}=Jo(e);return{zone:this.getters.getRangeFromSheetXC(this.activeSheet,e).zone,sheetId:o&&this.getters.getSheetIdByName(o)||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:o}=Jo(t),i=this.getters.getSheetIdByName(o),s=this.getters.getActiveSheet().id;return this.getters.isRangeValid(t)&&(i===s||void 0===i&&s===e)}getIndex(e){const t=this.ranges.findIndex((t=>t.id===e));return t>=0?t:null}}const jw=[Xw,function(e,t){return"target"in t&&Array.isArray(t.target)?{...Ce(t),target:e.getSelectedZones()}:t},function(e,t){if(!("row"in t)||!("col"in t))return t;const{col:o,row:i}=e.getActivePosition();return{...Ce(t),col:o,row:i}}];function Xw(e,t){return"sheetId"in t?{...Ce(t),sheetId:e.getActiveSheetId()}:t}const Kw=new Bi;function Qw(e,t){const o=e.getSelectedZone();return{...Xw(e,t),elements:"COL"===t.dimension?ye(o.left,o.right+1):ye(o.top,o.bottom+1)}}function Jw(e,t){const o=e.getSelectedZone();return{...Ce(t),zone:o}}function ex(e,t){const o=Ce(t),i=e.getSelectedZone(),{top:s,bottom:r,left:n,right:a}=i;return"cols"in o?o.cols=ye(n,a+1):"rows"in o&&(o.rows=ye(s,r+1)),o}const tx=new Ji;tx.add("UPDATE_CELL",ix),tx.add("CLEAR_CELL",ix),tx.add("DELETE_CONTENT",ix),tx.add("ADD_MERGE",ix),tx.add("REMOVE_MERGE",ix),tx.add("SET_FORMATTING",ix),tx.add("CLEAR_FORMATTING",ix),tx.add("SET_BORDER",ix),tx.add("CREATE_FILTER_TABLE",ix),tx.add("REMOVE_FILTER_TABLE",ix),tx.add("HIDE_SHEET",ix),tx.add("ADD_COLUMNS_ROWS",(function(e,t){const o=e.getActivePosition();return{...Xw(e,t),base:"COL"===t.dimension?o.col:o.row}})),tx.add("REMOVE_COLUMNS_ROWS",Qw),tx.add("HIDE_COLUMNS_ROWS",Qw),tx.add("RESIZE_COLUMNS_ROWS",Qw),tx.add("CREATE_SHEET",(function(e,t){const o=Ce(t);o.sheetId=Kw.uuidv4();const i=t.name||e.getSheet(e.getActiveSheetId()).name,s=i.match(/(.+?)\d*$/)?.[1]||i;return o.name=e.getNextSheetName(s),o})),tx.add("CREATE_FIGURE",(function(e,t){const o=Xw(e,t);return o.figure.id=Kw.uuidv4(),o})),tx.add("CREATE_CHART",(function(e,t){return{...Xw(e,t),id:Kw.uuidv4()}})),tx.add("CREATE_IMAGE",(function(e,t){return{...Xw(e,t),figureId:Kw.uuidv4()}}));const ox=new Ji;function ix(e,t){let o=Ce(t);for(const t of jw)o=t(e,o);return o}function sx(e,t){if(!t)return;if(!tx.contains(t.type))return;return tx.get(t.type)(e,t)}function rx(e,t){if(e.rootCommand&&"object"==typeof e.rootCommand)return ms(e.rootCommand)?sx(t,e.rootCommand):function(e,t,o){if(!ox.contains(t.type))return;return ox.get(t.type)(e,t,o)}(t,e.rootCommand,e.commands)}ox.add("STOP_EDITION",(function(e,t,o){return o.map((t=>sx(e,t))).filter(ke)})),ox.add("PASTE",(function(e,t){return{type:"REPEAT_PASTE",pasteOption:Ce(t.pasteOption),target:e.getSelectedZones()}})),ox.add("INSERT_CELL",Jw),ox.add("DELETE_CELL",Jw),ox.add("AUTORESIZE_COLUMNS",ex),ox.add("AUTORESIZE_ROWS",ex),ox.add("SORT_CELLS",(function(e,t){const o=e.getSelectedZone();return{...Xw(e,t),col:o.left,row:o.top,zone:o}})),ox.add("SUM_SELECTION",ix),ox.add("SET_DECIMAL",ix);class nx{getters;dispatch;selection;operation;sheetId;constructor(e,t,o,i){this.getters=t,this.dispatch=o,this.selection=i,this.operation=e,this.sheetId=t.getActiveSheetId()}isCutAllowed(e){return 0}isPasteAllowed(e,t){return 0}addMissingDimensions(e,t,o,i){const s=this.getters.getActiveSheetId(),r=t+i-this.getters.getNumberRows(s);r>0&&this.dispatch("ADD_COLUMNS_ROWS",{dimension:"ROW",base:this.getters.getNumberRows(s)-1,sheetId:s,quantity:r,position:"after"});const n=e+o-this.getters.getNumberCols(s);n>0&&this.dispatch("ADD_COLUMNS_ROWS",{dimension:"COL",base:this.getters.getNumberCols(s)-1,sheetId:s,quantity:n,position:"after"})}isColRowDirtyingClipboard(e,t){return!1}drawClipboard(e){}}class ax extends nx{cells;copiedTables;zones;uuidGenerator=new Bi;constructor(e,t,o,i,s){if(super(t,o,i,s),!e.length)return this.cells=[[]],this.zones=[],void(this.copiedTables=[]);const r=new Set(e.map((e=>e.left))),n=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===n.size?function(e){return e.reduce(((e,t)=>{const o=e.length;for(let i=0;i<o;i++)if(di(e[i],t))return e[i]=li(e[i],t),e;return e[o]=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=o.getActiveSheetId();for(let e of u){let t=[];for(let i of d){const s={col:i,row:e,sheetId:p};t.push({cell:o.getCell(s),style:o.getCellComputedStyle(s),evaluatedCell:o.getEvaluatedCell(s),border:o.getCellBorder(s)||void 0,position:s})}g.push(t)}const m=[];for(const t of e)for(const e of this.getters.getFilterTablesInZone(p,t)){const t=[];for(const o of ye(e.zone.left,e.zone.right+1))t.push(this.getters.getFilterValues({sheetId:p,col:o,row: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?20:0}isPasteAllowed(e,t){const o=this.getters.getActiveSheetId();if("CUT"===this.operation&&void 0!==t?.pasteOption)return 22;if(e.length>1&&(this.cells.length>1||this.cells[0].length>1))return 21;const i=this.cells.length,s=this.cells[0].length;for(let t of this.getPasteZones(e))if(this.getters.doesIntersectMerge(o,t)&&(e.length>1||!this.getters.isSingleCellOrMerge(o,e[0])||i*s!=1))return 2;const{xSplit:r,ySplit:n}=this.getters.getPaneDivisions(o);for(const t of this.getPasteZones(e))if(t.left<r&&t.right>=r||t.top<n&&t.bottom>=n)return 78;return 0}paste(e,t){"COPY"===this.operation?this.pasteFromCopy(e,t):this.pasteFromCut(e,t);const o=this.cells.length,i=this.cells[0].length,s="CUT"===this.operation;t?.selectTarget&&this.selectPastedZone(i,o,s,e)}pasteFromCopy(e,t){if(1===e.length){const o=this.cells.length,i=this.cells[0].length,s=this.pastedZones(e,i,o);for(const e of s)this.pasteZone(e.left,e.top,t)}else for(const o of e)for(let e=o.left;e<=o.right;e++)for(let i=o.top;i<=o.bottom;i++)this.pasteZone(e,i,t);void 0===t?.pasteOption&&this.pasteCopiedTables(e)}pasteFromCut(e,t){this.clearClippedZones();const o=e[0];this.pasteZone(o.left,o.top,t),this.dispatch("MOVE_RANGES",{target:this.zones,sheetId:this.sheetId,targetSheetId:this.getters.getActiveSheetId(),col:o.left,row:o.top});for(const e of this.copiedTables)this.dispatch("REMOVE_FILTER_TABLE",{sheetId:this.sheetId,target:[e.zone]});this.pasteCopiedTables(e),this.cells.forEach((e=>{e.forEach((e=>{e.cell&&(e.cell=void 0)}))}))}pastedZones(e,t,o){const i=e[0],s=Math.max(1,Math.floor((i.right+1-i.left)/t)),r=Math.max(1,Math.floor((i.bottom+1-i.top)/o)),n=[];for(let e=0;e<s;e++)for(let s=0;s<r;s++){const r=i.top+s*o,a=i.left+e*t;n.push({left:a,top:r,bottom:r+o-1,right:a+t-1})}return n}getPasteZones(e){const t=this.cells;if(!t.length||!t[0].length)return e;const o=[],i=t.length,s=t[0].length,r=e[e.length-1],n=r.left,a=r.top,l=Math.max(1,Math.floor((r.right+1-n)/s)),c=Math.max(1,Math.floor((r.bottom+1-a)/i));for(let e=1;e<=l;e++)for(let t=1;t<=c;t++)o.push({left:n,top:a,right:n-1+e*s,bottom:a-1+t*i});return o}selectPastedZone(e,t,o,i){const s=i[0],r=s.left,n=s.top;if(t>1||e>1||o){const s=this.pastedZones(i,e,t),a=o?s[0]:li(...s);this.selection.selectZone({cell:{col:r,row:n},zone:a},{scrollIntoView:!1})}}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,o){const i=this.cells.length,s=this.cells[0].length,r="onlyValue"!==o?.pasteOption&&o?.shouldPasteCF,n=this.getters.getActiveSheetId();this.addMissingDimensions(s,i,e,t);for(let a=0;a<i;a++){const i=this.cells[a];for(let l=0;l<s;l++){const s=i[l],c={col:e+l,row:t+a,sheetId:n};"CUT"!==this.operation&&this.pasteMergeIfExist(s.position,c),this.pasteCell(s,c,this.operation,o),r&&this.pasteCf(s.position,c)}}}pasteCell(e,t,o,i){const{sheetId:s,col:r,row:n}=t,a=this.getters.getEvaluatedCell(t);if("onlyValue"!==i?.pasteOption){const o=this.getters.getCellBorder(t),i=e.border,a={top:o?.top||i?.top,bottom:o?.bottom||i?.bottom,left:o?.left||i?.left,right:o?.right||i?.right};this.dispatch("SET_BORDER",{sheetId:s,col:r,row:n,border:a})}if(e.cell){if("onlyFormat"===i?.pasteOption)return void this.dispatch("UPDATE_CELL",{...t,style:e.cell.style,format:e.evaluatedCell.format});if("onlyValue"===i?.pasteOption){const o=this.getters.getLocale(),i=fo(e.evaluatedCell.value,{locale:o});return void this.dispatch("UPDATE_CELL",{...t,content:i})}let a=e.cell.content;if(e.cell.isFormula&&"COPY"===o){const t=r-e.position.col,i=n-e.position.row;a=this.getUpdatedContent(s,e.cell,t,i,o)}this.dispatch("UPDATE_CELL",{...t,content:a,style:e.cell.style||null,format:e.cell.format})}else a&&("onlyValue"===i?.pasteOption?this.dispatch("UPDATE_CELL",{...t,content:""}):"onlyFormat"===i?.pasteOption?this.dispatch("UPDATE_CELL",{...t,style:null,format:""}):this.dispatch("CLEAR_CELL",t))}getUpdatedContent(e,t,o,i,s){const r=this.getters.createAdaptedRanges(t.dependencies,o,i,e);return this.getters.buildFormulaContent(e,t,r)}pasteMergeIfExist(e,t){let{sheetId:o,col:i,row:s}=e;const{col:r,row:n}=this.getters.getMainCellPosition(e);if(r===i&&n===s){const r=this.getters.getMerge(e);if(!r)return;({sheetId:o,col:i,row:s}=t),this.dispatch("ADD_MERGE",{sheetId:o,force:!0,target:[{left:i,top:s,right:i+r.right-r.left,bottom:s+r.bottom-r.top}]})}}pasteCopiedTables(e){const t=this.getters.getActiveSheetId(),o=e[0],i=this.zones[0],s=[o.left-i.left,o.top-i.top];for(const e of this.copiedTables){const o=Si(e.zone,"both","MOVE",s);this.dispatch("CREATE_FILTER_TABLE",{sheetId:t,target:[o]});for(const i of ye(0,e.filtersValues.length))this.dispatch("UPDATE_FILTER",{sheetId:t,col:o.left+i,row:o.top,values:e.filtersValues[i]})}}getClipboardContent(){return{[cs.PlainText]:this.getPlainTextContent(),[cs.Html]:this.getHTMLContent()}}getPlainTextContent(){return this.cells.map((e=>e.map((e=>this.getters.shouldShowFormulas()&&e.cell?.isFormula?e.cell?.content||"":e.evaluatedCell?.formattedValue||"")).join("\t"))).join("\n")||"\t"}getHTMLContent(){if(1===this.cells.length&&1===this.cells[0].length)return this.getters.getCellText(this.cells[0][0].position);let e='<table border="1" style="border-collapse:collapse">';for(const t of this.cells){e+="<tr>";for(const o of t){e+=`<td style="${Yi(qi(o.style))}">`+mE(this.getters.getCellText(o.position))+"</td>"}e+="</tr>"}return e+="</table>",e}isColRowDirtyingClipboard(e,t){if(!this.zones)return!1;for(let o of this.zones){if("COL"===t&&e<=o.right)return!0;if("ROW"===t&&e<=o.bottom)return!0}return!1}drawClipboard(e){const{ctx:t,thinLineWidth:o}=e;if(this.sheetId===this.getters.getActiveSheetId()&&this.zones&&this.zones.length){t.setLineDash([8,5]),t.strokeStyle=E,t.lineWidth=3.3*o;for(const e of this.zones){const{x:o,y:i,width:s,height:r}=this.getters.getVisibleRect(e);s>0&&r>0&&t.strokeRect(o,i,s,r)}}}pasteCf(e,t){const o=xt(t.col,t.row);for(let i of this.getters.getConditionalFormats(e.sheetId))for(let s of i.ranges)if(ui(e.col,e.row,this.getters.getRangeFromSheetXC(e.sheetId,s).zone)){const s=i,r=[];if("CUT"===this.operation&&r.push(xt(e.col,e.row)),e.sheetId===t.sheetId)this.adaptCFRules(e.sheetId,s,[o],r);else{this.adaptCFRules(e.sheetId,s,[],r);const i=this.getCFToCopyTo(t.sheetId,s);this.adaptCFRules(t.sheetId,i,[o],[])}}}adaptCFRules(e,t,o,i){const s=this.getters.getAdaptedCfRanges(e,t,o,i);s&&(0!==s.length?this.dispatch("ADD_CONDITIONAL_FORMAT",{cf:{id:t.id,rule:t.rule,stopIfTrue:t.stopIfTrue},ranges:s.map((t=>this.getters.getRangeDataFromXc(e,t))),sheetId:e}):this.dispatch("REMOVE_CONDITIONAL_FORMAT",{id:t.id,sheetId:e}))}getCFToCopyTo(e,t){const o=this.getters.getConditionalFormats(e).find((e=>e.stopIfTrue===t.stopIfTrue&&We(e.rule,t.rule)));return o||{...t,id:this.uuidGenerator.uuidv4(),ranges:[]}}}class lx{operation;getters;dispatch;sheetId;copiedFigure;copiedFigureContent;constructor(e,t,o){this.operation=e,this.getters=t,this.dispatch=o,this.sheetId=t.getActiveSheetId();const i=t.getSelectedFigureId();if(!i)throw new Error("No figure selected");const s=t.getFigure(this.sheetId,i);if(!s)throw new Error(`No figure for the given id: ${i}`);switch(this.copiedFigure={...s},s.tag){case"chart":this.copiedFigureContent=new cx(o,t,this.sheetId,i);break;case"image":this.copiedFigureContent=new hx(o,t,this.sheetId,i);break;default:throw new Error(`Unknow tag '${s.tag}' for the given figure id: ${i}`)}}isCutAllowed(e){return 0}isPasteAllowed(e,t){return 0===e.length?76:void 0!==t?.pasteOption?23:0}paste(e){const t=this.getters.getActiveSheetId(),{width:o,height:i}=this.copiedFigure,s=this.getters.getNumberCols(t),r=this.getters.getNumberRows(t),n=this.getters.getColDimensions(t,e[0].left).start,a=this.getters.getRowDimensions(t,e[0].top).start,l=this.getters.getColDimensions(t,s-1).end,c=this.getters.getRowDimensions(t,r-1).end,h={x:l<o?0:Math.min(n,l-o),y:c<i?0:Math.min(a,c-i)},d=(new Bi).uuidv4();this.copiedFigureContent.paste(t,d,h,{height:i,width:o}),"CUT"===this.operation&&this.dispatch("DELETE_FIGURE",{sheetId:this.copiedFigureContent.sheetId,id:this.copiedFigure.id}),this.dispatch("SELECT_FIGURE",{id:d})}getClipboardContent(){return{[cs.PlainText]:"\t"}}isColRowDirtyingClipboard(e,t){return!1}drawClipboard(e){}}class cx{dispatch;sheetId;copiedChart;constructor(e,t,o,i){this.dispatch=e,this.sheetId=o;const s=t.getChart(i);if(!s)throw new Error(`No chart for the given id: ${i}`);this.copiedChart=s.copyInSheetId(o)}paste(e,t,o,i){const s=this.copiedChart.copyInSheetId(e);this.dispatch("CREATE_CHART",{id:t,sheetId:e,position:o,size:i,definition:s.getDefinition()})}}class hx{dispatch;sheetId;copiedImage;constructor(e,t,o,i){this.dispatch=e,this.sheetId=o;const s=t.getImage(i);this.copiedImage=Ce(s)}paste(e,t,o,i){const s=Ce(this.copiedImage);this.dispatch("CREATE_IMAGE",{figureId:t,sheetId:e,position:o,size:i,definition:s})}}function dx(e,t){return e.startsWith("=")?function(e,t){return function(e,t,o){if(t.formulaArgSeparator===o.formulaArgSeparator&&t.decimalSeparator===o.decimalSeparator)return e;const i=xu(e,t);let s="";for(const e of i)"NUMBER"===e.type?s+=e.value.replace(t.decimalSeparator,o.decimalSeparator):"ARG_SEPARATOR"===e.type?s+=o.formulaArgSeparator:s+=e.value;return s}(e,t,eo)}(e,t):xg(e,t)}class ux extends nx{values;constructor(e,t,o,i){super("COPY",t,o,i),this.values=e.replace(/\r/g,"").split("\n").map((e=>e.split("\t")))}isPasteAllowed(e,t){const o=this.getters.getActiveSheetId(),i=this.getPasteZone(e);return this.getters.doesIntersectMerge(o,i)?2:0}paste(e,t){if("onlyFormat"===t?.pasteOption)return;const o=this.values,i=this.getPasteZone(e),{left:s,top:r}=i,{numberOfCols:n,numberOfRows:a}=fi(i),l=this.getters.getActiveSheetId(),c=this.getters.getLocale();this.addMissingDimensions(n,a,s,r);for(let e=0;e<o.length;e++)for(let t=0;t<o[e].length;t++)this.dispatch("UPDATE_CELL",{row:r+e,col:s+t,content:dx(o[e][t],c),sheetId:l});const h={left:s,top:r,right:s+n-1,bottom:r+a-1};this.selection.selectZone({cell:{col:s,row:r},zone:h},{scrollIntoView:!1})}getClipboardContent(){return{[cs.PlainText]:this.values.map((e=>e.join("\t"))).join("\n")}}getPasteZone(e){const t=this.values.length,o=et(this.values.map((e=>e.length))),{left:i,top:s}=e[0];return{top:s,left:i,bottom:s+t-1,right:i+o-1}}}function gx(e){if("REFERENCE"!==e.type)return e;const{xc:t,sheetName:o}=Jo(e.value),[i,s]=t.split(":"),r=o?`${we(o)}!`:"",n=px(i),a=s?`:${px(s)}`:"";return{...e,value:r+n+a}}function px(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=mx(e,"colrow");break;case"colrow":e=mx(e,"row");break;case"row":e=mx(e,"col");break;case"col":e=mx(e,"none")}return e}function mx(e,t){let o;switch(e=e.replace(/\$/g,""),t){case"col":return"$"+e;case"row":return o=e.search(/[0-9]/),e.slice(0,o)+"$"+e.slice(o);case"colrow":return o=e.search(/[0-9]/),-1===o||0===o?"$"+e:"$"+(e=e.slice(0,o)+"$"+e.slice(o));case"none":return e}}const fx=r("The cell you are trying to edit has been deleted.");const bx=[{name:r("Sum"),types:[ls.number],compute:(e,t)=>Ia.compute.bind({locale:t})([e])},{name:r("Avg"),types:[ls.number],compute:(e,t)=>Pa.compute.bind({locale:t})([e])},{name:r("Min"),types:[ls.number],compute:(e,t)=>Ja.compute.bind({locale:t})([e])},{name:r("Max"),types:[ls.number],compute:(e,t)=>ja.compute.bind({locale:t})([e])},{name:r("Count"),types:[ls.number,ls.text,ls.boolean,ls.error],compute:(e,t)=>Wa.compute.bind({locale:t})([e])},{name:r("Count Numbers"),types:[ls.number,ls.text,ls.boolean,ls.error],compute:(e,t)=>$a.compute.bind({locale:t})([e])}];class vx{getters;sheetId;boundaries;top;bottom;left;right;offsetX;offsetY;offsetScrollbarX;offsetScrollbarY;canScrollVertically;canScrollHorizontally;viewportWidth;viewportHeight;offsetCorrectionX;offsetCorrectionY;constructor(e,t,o,i,s,r){this.getters=e,this.sheetId=t,this.boundaries=o,this.viewportWidth=i.width,this.viewportHeight=i.height,this.offsetScrollbarX=r.x,this.offsetScrollbarY=r.y,this.canScrollVertically=s.canScrollVertically,this.canScrollHorizontally=s.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:o,size:i}=this.getters.getColDimensions(this.sheetId,e),{end:s,size:r}=this.getters.getRowDimensions(this.sheetId,t),n=this.searchHeaderIndex("COL",o-this.viewportWidth,0),a=this.getters.getColSize(this.sheetId,n),l=this.searchHeaderIndex("ROW",s-this.viewportHeight,0),c=this.getters.getRowSize(this.sheetId,l);let h=o-this.offsetCorrectionX;this.canScrollHorizontally&&(h+=Math.max(L,Math.min(a,this.viewportWidth-i)),h=Math.max(h,this.viewportWidth));let d=s-this.offsetCorrectionY;return this.canScrollVertically&&(d+=Math.max(P+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 o=this.getters.getMainCellPosition({sheetId:t,...e}),{col:i,row:s}=this.getters.getNextVisibleCellPosition(o);ui(i,this.boundaries.top,this.boundaries)&&this.adjustPositionX(i),ui(this.boundaries.left,s,this.boundaries)&&this.adjustPositionY(s)}adjustPositionX(e){const t=this.sheetId,{end:o}=this.getters.getColDimensions(t,e),i=this.getters.getNumberCols(t);if(this.offsetX+this.offsetCorrectionX+this.viewportWidth<o){let o=e;for(;this.getters.isColHidden(t,o)&&e<i;)o++;const s=this.getters.getColDimensions(t,o).end,r=this.searchHeaderIndex("COL",s-this.viewportWidth-this.offsetCorrectionX,this.boundaries.left,!0);this.offsetX=this.getters.getColDimensions(t,r).end-this.offsetCorrectionX,this.offsetScrollbarX=this.offsetX,this.adjustViewportZoneX()}else if(this.left>e){let o=e;for(;this.getters.isColHidden(t,o)&&e>0;)o--;this.offsetX=this.getters.getColDimensions(t,o).start-this.offsetCorrectionX,this.offsetScrollbarX=this.offsetX,this.adjustViewportZoneX()}}adjustPositionY(e){const t=this.sheetId,{end:o}=this.getters.getRowDimensions(t,e),i=this.getters.getNumberRows(t);if(this.offsetY+this.viewportHeight+this.offsetCorrectionY<o){let o=e;for(;this.getters.isRowHidden(t,o)&&e<i;)o++;const s=this.getters.getRowDimensions(t,o).end,r=this.searchHeaderIndex("ROW",s-this.viewportHeight-this.offsetCorrectionY,this.boundaries.top,!0);this.offsetY=this.getters.getRowDimensions(t,r).end-this.offsetCorrectionY,this.offsetScrollbarY=this.offsetY,this.adjustViewportZoneY()}else if(this.top>e){let o=e;for(;this.getters.isRowHidden(t,o)&&e>0;)o--;this.offsetY=this.getters.getRowDimensions(t,o).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=ci(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,o=0,i=!1){let s=0;const r=this.sheetId,n=this.getters.getNumberHeaders(r,e);for(let a=o;a<=n-1;a++){const o=i||"COL"!==e?a<this.top&&a>this.bottom:a<this.left&&a>this.right;if(!this.getters.isHeaderHidden(r,e,a)&&!o&&(s+="COL"===e?this.getters.getColSize(r,a):this.getters.getRowSize(r,a),s>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}}const Sx=(new Ji).add("settings",class extends XE{static getters=["getLocale"];locale=eo;allowDispatch(e){return"UPDATE_LOCALE"===e.type?fg(e.locale)?0:96:0}handle(e){if("UPDATE_LOCALE"===e.type)this.history.update("locale",e.locale)}getLocale(){return this.locale}import(e){this.locale=e.settings?.locale??eo}export(e){e.settings={locale:this.locale}}}).add("sheet",class extends XE{static getters=["getSheetName","tryGetSheetName","getSheet","tryGetSheet","getSheetIdByName","getSheetIds","getVisibleSheetIds","isSheetVisible","getEvaluationSheets","doesHeaderExist","getCell","getCellPosition","getColsZone","getRowCells","getRowsZone","getNumberCols","getNumberRows","getNumberHeaders","getGridLinesVisibility","getNextSheetName","getSheetSize","getSheetZone","getPaneDivisions","checkZonesExistInSheet","getCommandZones","getUnboundedZone","checkElementsIncludeAllNonFrozenHeaders"];sheetIdsMapName={};orderedSheetIds=[];sheets={};cellPosition={};allowDispatch(e){const t=this.chainValidations(this.checkSheetExists,this.checkZonesAreInSheet)(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":try{const t=this.orderedSheetIds.findIndex((t=>t===e.sheetId));return this.findIndexOfTargetSheet(t,e.delta),0}catch(e){return 15}case"RENAME_SHEET":return this.isRenameAllowed(e);case"DELETE_SHEET":return this.orderedSheetIds.length>1?0:9;case"ADD_COLUMNS_ROWS":const t="COL"===e.dimension?this.getNumberCols(e.sheetId):this.getNumberRows(e.sheetId);return e.base<0||e.base>=t?89:e.quantity<=0?90:0;case"REMOVE_COLUMNS_ROWS":{const t="COL"===e.dimension?this.getNumberCols(e.sheetId):this.getNumberRows(e.sheetId);return tt(e.elements)<0||et(e.elements)>t?89: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.delta);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){for(let t of e.sheets)this.sheetIdsMapName[t.name]=t.id;for(let t of e.sheets){const e=t.name||s("Sheet")+(Object.keys(this.sheets).length+1),{colNumber:o,rowNumber:i}=this.getImportedSheetSize(t),r={id:t.id,name:e,numberOfCols:o,rows:Mi(i),areGridLinesVisible:void 0===t.areGridLinesVisible||t.areGridLinesVisible,isVisible:t.isVisible,panes:{xSplit:t.panes?.xSplit||0,ySplit:t.panes?.ySplit||0}};this.orderedSheetIds.push(r.id),this.sheets[r.id]=r}}exportSheets(e){e.sheets=this.orderedSheetIds.filter(ke).map((e=>{const t=this.sheets[e],o={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)&&(o.panes=t.panes),o}))}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}tryGetSheetName(e){return this.tryGetSheet(e)?.name}getSheetIdByName(e){if(e){const t=Ee(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,o){return"COL"===t?o>=0&&o<this.getNumberCols(e):o>=0&&o<this.getNumberRows(e)}getRow(e,t){const o=this.getSheet(e).rows[t];if(!o)throw new Error(`Row ${o} not found.`);return o}getCell({sheetId:e,col:t,row:o}){const i=this.tryGetSheet(e)?.rows[o]?.cells[t];if(void 0!==i)return this.getters.getCellById(i)}getColsZone(e,t,o){return{top:0,bottom:this.getNumberRows(e)-1,left:t,right:o}}getRowCells(e,t){return Object.values(this.getSheet(e).rows[t]?.cells).filter(ke)}getRowsZone(e,t,o){return{top:t,bottom:o,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 o=this.orderedSheetIds.map(this.getSheetName.bind(this));let i=`${e}${t}`;for(;o.includes(i);)i=`${e}${t}`,t++;return i}getSheetSize(e){return{numberOfRows:this.getNumberRows(e),numberOfCols:this.getNumberCols(e)}}getSheetZone(e){return{top:0,left:0,bottom:this.getNumberRows(e)-1,right:this.getNumberCols(e)-1}}getUnboundedZone(e,t){const o=0===t.left&&t.right===this.getNumberCols(e)-1,i=0===t.top&&t.bottom===this.getNumberRows(e)-1;return{...t,bottom:i?void 0:t.bottom,right:o&&!i?void 0:t.right}}getPaneDivisions(e){return this.getSheet(e).panes}setPaneDivisions(e,t,o){const i={...this.getPaneDivisions(e)};"COL"===o?i.xSplit=t:"ROW"===o&&(i.ySplit=t),this.history.update("sheets",e,"panes",i)}checkElementsIncludeAllNonFrozenHeaders(e,t,o){const i=this.getters.getPaneDivisions(e),s="ROW"===t?i.ySplit:i.xSplit,r=this.getters.getNumberHeaders(e,t);if(!s)return!1;return Ge(o,ye(s,r))}getCommandZones(e){const t=[];return"zone"in e&&t.push(e.zone),"target"in e&&t.push(...e.target),"ranges"in e&&t.push(...e.ranges.map((e=>this.getters.getRangeFromRangeData(e).zone))),"col"in e&&"row"in e&&t.push({top:e.row,left:e.col,bottom:e.row,right:e.col}),t}checkZonesExistInSheet(e,t){if(!t.every(oi))return 26;if(t.length){const o=this.getSheetZone(e);return t.every((e=>gi(e,o)))?0:19}return 0}updateCellPosition(e){const{sheetId:t,cellId:o,col:i,row:s}=e;o?this.setNewPosition(o,t,i,s):this.clearPosition(t,i,s)}setNewPosition(e,t,o,i){const s=this.cellPosition[e];s&&this.clearPosition(t,s.col,s.row),this.history.update("cellPosition",e,{row:i,col:o,sheetId:t}),this.history.update("sheets",t,"rows",i,"cells",o,e)}clearPosition(e,t,o){const i=this.sheets[e]?.rows[o].cells[t];i&&(this.history.update("cellPosition",i,void 0),this.history.update("sheets",e,"rows",o,"cells",t,void 0))}setGridLinesVisibility(e,t){this.history.update("sheets",e,"areGridLinesVisible",t)}clearZones(e,t){for(let o of t)for(let t=o.left;t<=o.right;t++)for(let i=o.top;i<=o.bottom;i++){this.sheets[e].rows[i].cells[t]&&this.dispatch("UPDATE_CELL",{sheetId:e,content:"",col:t,row:i})}}createSheet(e,t,o,i,s){const r={id:e,name:t,numberOfCols:o,rows:Mi(i),areGridLinesVisible:!0,isVisible:!0,panes:{xSplit:0,ySplit:0}},n=this.orderedSheetIds.slice();n.splice(s,0,r.id);const a=this.sheets;return this.history.update("orderedSheetIds",n),this.history.update("sheets",Object.assign({},a,{[r.id]:r})),r}moveSheet(e,t){const o=this.orderedSheetIds.slice(),i=o.findIndex((t=>t===e)),s=o.splice(i,1);let r=this.findIndexOfTargetSheet(i,t);o.splice(r,0,s[0]),this.history.update("orderedSheetIds",o)}findIndexOfTargetSheet(e,t){for(;0!=t&&0<=e&&e<=this.orderedSheetIds.length;)t>0?(e++,this.isSheetVisible(this.orderedSheetIds[e])&&t--):t<0&&(e--,this.isSheetVisible(this.orderedSheetIds[e])&&t++);if(0===t)return e;throw new Error(r("There is not enough visible sheets"))}checkSheetName(e){const t=this.getters.tryGetSheetName(e.sheetId);if(void 0!==t&&e.name===t)return 11;const{orderedSheetIds:o,sheets:i}=this,s=e.name&&e.name.trim().toLowerCase();return o.find((t=>i[t]?.name.toLowerCase()===s&&t!==e.sheetId))?12:he.test(s)?14:0}checkSheetPosition(e){const{orderedSheetIds:t}=this;return e.position>t.length||e.position<0?16:0}checkRowFreezeQuantity(e){return e.quantity>=1&&e.quantity<this.getNumberRows(e.sheetId)?0:77}checkColFreezeQuantity(e){return e.quantity>=1&&e.quantity<this.getNumberCols(e.sheetId)?0:77}checkRowFreezeOverlapMerge(e){const t=this.getters.getMerges(e.sheetId);for(let o of t)if(o.top<e.quantity&&e.quantity<=o.bottom)return 68;return 0}checkColFreezeOverlapMerge(e){const t=this.getters.getMerges(e.sheetId);for(let o of t)if(o.left<e.quantity&&e.quantity<=o.right)return 68;return 0}isRenameAllowed(e){return e.name&&e.name.trim().toLowerCase()?this.checkSheetName(e):10}renameSheet(e,t){const o=e.name;this.history.update("sheets",e.id,"name",t.trim());const i=Object.assign({},this.sheetIdsMapName);delete i[o],i[t]=e.id,this.history.update("sheetIdsMapName",i)}hideSheet(e){this.history.update("sheets",e,"isVisible",!1)}showSheet(e){this.history.update("sheets",e,"isVisible",!0)}duplicateSheet(e,t){const o=this.getSheet(e),i=this.getDuplicateSheetName(o.name),s=Ce(o);s.id=t,s.name=i;for(let e=0;e<=s.numberOfCols;e++)for(let t=0;t<=s.rows.length;t++)s.rows[t]&&(s.rows[t].cells[e]=void 0);const r=this.orderedSheetIds.slice(),n=r.indexOf(e);r.splice(n+1,0,s.id),this.history.update("orderedSheetIds",r),this.history.update("sheets",Object.assign({},this.sheets,{[s.id]:s}));for(const t of Object.values(this.getters.getCells(e))){const{col:e,row:o}=this.getCellPosition(t.id);this.dispatch("UPDATE_CELL",{sheetId:s.id,col:e,row:o,content:t.content,format:t.format,style:t.style})}const a=Object.assign({},this.sheetIdsMapName);a[s.name]=s.id,this.history.update("sheetIdsMapName",a)}getDuplicateSheetName(e){let t=1;const o=this.orderedSheetIds.map(this.getSheetName.bind(this)),i=r("Copy of %s",e);let s=i.toString();for(;o.includes(s);)s=`${i} (${t})`,t++;return s}deleteSheet(e){const t=e.name,o=Object.assign({},this.sheets);delete o[e.id],this.history.update("sheets",o);const i=this.orderedSheetIds.slice(),s=i.indexOf(e.id);i.splice(s,1),this.history.update("orderedSheetIds",i);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 o of t)this.moveCellOnColumnsDeletion(e,o);const o=this.sheets[e.id].numberOfCols;this.history.update("sheets",e.id,"numberOfCols",o-t.length);const i=t.filter((t=>t<e.panes.xSplit)).length;i&&this.setPaneDivisions(e.id,e.panes.xSplit-i,"COL")}removeRows(e,t){t.sort(((e,t)=>t-e));for(let o of Ie(t)){const t=o[o.length-1],i=o[0];this.moveCellOnRowsDeletion(e,t,i),this.updateRowsStructureOnDeletion(e,t,i)}const o=t.filter((t=>t<e.panes.ySplit)).length;o&&this.setPaneDivisions(e.id,e.panes.ySplit-o,"ROW")}addColumns(e,t,o,i){const s="before"===o?t:t+1;this.moveCellsOnAddition(e,s,i,"columns");const r=this.sheets[e.id].numberOfCols;this.history.update("sheets",e.id,"numberOfCols",r+i),s<e.panes.xSplit&&this.setPaneDivisions(e.id,e.panes.xSplit+i,"COL")}addRows(e,t,o,i){const s="before"===o?t:t+1;this.addEmptyRows(e,i),this.moveCellsOnAddition(e,s,i,"rows"),s<e.panes.ySplit&&this.setPaneDivisions(e.id,e.panes.ySplit+i,"ROW")}moveCellOnColumnsDeletion(e,t){for(let o=0;o<e.rows.length;o++){const i=e.rows[o];for(let s in i.cells){const r=Number(s),n=i.cells[s];n&&(r===t&&this.dispatch("CLEAR_CELL",{sheetId:e.id,col:r,row:o}),r>t&&this.dispatch("UPDATE_CELL_POSITION",{sheetId:e.id,cellId:n,col:r-1,row:o}))}}}moveCellsOnAddition(e,t,o,i){const s=[];for(let r=0;r<e.rows.length;r++){const n=e.rows[r];if("rows"!==i||r>=t)for(let a in n.cells){const l=Number(a),c=n.cells[a];c&&("rows"===i||l>=t)&&s.push({type:"UPDATE_CELL_POSITION",sheetId:e.id,cellId:c,col:l+("columns"===i?o:0),row:r+("rows"===i?o:0)})}}for(let e of s.reverse())this.dispatch(e.type,e)}moveCellOnRowsDeletion(e,t,o){const i=o-t+1;for(let s=0;s<e.rows.length;s++){const r=e.rows[s];if(s>=t&&s<=o)for(let t in r.cells){const o=Number(t);r.cells[t]&&this.dispatch("CLEAR_CELL",{sheetId:e.id,col:o,row:s})}if(s>o)for(let t in r.cells){const o=Number(t),n=r.cells[t];n&&this.dispatch("UPDATE_CELL_POSITION",{sheetId:e.id,cellId:n,col:o,row:s-i})}}}updateRowsStructureOnDeletion(e,t,o){const i=[],s=e.rows.map((e=>e.cells)).reverse();for(let r in e.rows){const e=Number(r);e>=t&&e<=o||i.push({cells:s.pop()})}this.history.update("sheets",e.id,"rows",i)}addEmptyRows(e,t){const o=e.rows.slice();for(let e=0;e<t;e++)o.push({cells:{}});this.history.update("sheets",e.id,"rows",o)}getImportedSheetSize(e){const t=Object.keys(e.cells).map(wt);let o=e.rowNumber,i=e.colNumber;for(let{col:e,row:s}of t)o=Math.max(o,s+1),i=Math.max(i,e+1);return{rowNumber:o,colNumber:i}}checkSheetExists(e){return"CREATE_SHEET"!==e.type&&"sheetId"in e&&void 0===this.sheets[e.sheetId]?28:"CREATE_SHEET"===e.type&&void 0!==this.sheets[e.sheetId]?13:0}checkZonesAreInSheet(e){return"sheetId"in e?this.checkZonesExistInSheet(e.sheetId,this.getCommandZones(e)):0}}).add("header visibility",class extends XE{static getters=["checkElementsIncludeAllVisibleHeaders","getHiddenColsGroups","getHiddenRowsGroups","isRowHiddenByUser","isColHiddenByUser"];hiddenHeaders={};allowDispatch(e){switch(e.type){case"HIDE_COLUMNS_ROWS":{if(!this.getters.tryGetSheet(e.sheetId))return 28;const t="COL"===e.dimension?this.getHiddenColsGroups(e.sheetId):this.getHiddenRowsGroups(e.sheetId),o="COL"===e.dimension?this.getters.getNumberCols(e.sheetId):this.getters.getNumberRows(e.sheetId);return new Set((t||[]).flat().concat(e.elements)).size>=o?69:tt(e.elements)<0||et(e.elements)>o?89:0}case"REMOVE_COLUMNS_ROWS":return this.getters.tryGetSheet(e.sheetId)?this.checkElementsIncludeAllVisibleHeaders(e.sheetId,e.dimension,e.elements)?8:0:28}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,Ce(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 o of[...e.elements].sort(((e,t)=>t-e)))t.splice(o,1);this.history.update("hiddenHeaders",e.sheetId,e.dimension,t);break}case"ADD_COLUMNS_ROWS":{const t=[...this.hiddenHeaders[e.sheetId][e.dimension]],o=$e(e.position,e.base);t.splice(o,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,o){return Ge(o,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=[[]],o=this.hiddenHeaders[e].COL;for(let e=0;e<o.length;e++){o[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=[[]],o=this.hiddenHeaders[e].ROW;for(let e=0;e<o.length;e++){o[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 ye(0,this.hiddenHeaders[e][t].length).filter((o=>!this.hiddenHeaders[e][t][o]))}import(e){for(let t of e.sheets){this.hiddenHeaders[t.id]={COL:[],ROW:[]};for(let e=0;e<t.rowNumber;e++)this.hiddenHeaders[t.id].ROW[e]=Boolean(t.rows[e]?.isHidden);for(let e=0;e<t.colNumber;e++)this.hiddenHeaders[t.id].COL[e]=Boolean(t.cols[e]?.isHidden)}}exportForExcel(e){this.exportData(e,!0)}export(e){this.exportData(e)}exportData(e,t=!1){for(let o of e.sheets){void 0===o.rows&&(o.rows={});for(let e=0;e<this.getters.getNumberRows(o.id);e++)(t||this.hiddenHeaders[o.id].ROW[e])&&(void 0===o.rows[e]&&(o.rows[e]={}),o.rows[e].isHidden=this.hiddenHeaders[o.id].ROW[e]);void 0===o.cols&&(o.cols={});for(let e=0;e<this.getters.getNumberCols(o.id);e++)(t||this.hiddenHeaders[o.id].COL[e])&&(void 0===o.cols[e]&&(o.cols[e]={}),o.cols[e].isHidden=this.hiddenHeaders[o.id].COL[e])}}}).add("filters",class extends XE{static getters=["doesZonesContainFilter","getFilter","getFilters","getFilterTable","getFilterTables","getFilterTablesInZone","getFilterId","getFilterHeaders","isFilterHeader"];tables={};allowDispatch(e){switch(e.type){case"CREATE_FILTER_TABLE":if(!Ii(...e.target))return 84;const t=li(...e.target),o=()=>this.getFilterTables(e.sheetId).some((e=>di(e.zone,t)))?81:0,i=()=>{const o=this.getters.getMergesInZone(e.sheetId,t);for(let e of o)if(di(t,e))return 83;return 0};return this.checkValidations(e,o,i);case"ADD_MERGE":for(let t of e.target)for(let o of this.getFilterTables(e.sheetId))if(di(o.zone,t))return 83}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 o={};for(const t of Object.values(this.tables[e.sheetId]||{}))if(t){const e=Ce(t);o[e.id]=e}this.history.update("tables",e.sheetIdTo,o);break;case"ADD_COLUMNS_ROWS":this.onAddColumnsRows(e);break;case"REMOVE_COLUMNS_ROWS":this.onDeleteColumnsRows(e);break;case"CREATE_FILTER_TABLE":{const t=li(...e.target),o=this.createFilterTable(t);this.history.update("tables",e.sheetId,o.id,o);break}case"REMOVE_FILTER_TABLE":{const t={};for(const o of this.getFilterTables(e.sheetId))e.target.every((e=>!ci(e,o.zone)))&&(t[o.id]=o);this.history.update("tables",e.sheetId,t);break}case"UPDATE_CELL":{const t=e.sheetId;for(let o of this.getFilterTables(t))this.canUpdateCellCmdExtendTable(e,o)&&this.extendTableDown(t,o);break}}}getFilters(e){return this.getFilterTables(e).map((e=>e.filters)).flat()}getFilterTables(e){return this.tables[e]?Object.values(this.tables[e]).filter(ke):[]}getFilter(e){return this.getFilterTable(e)?.filters.find((t=>t.col===e.col))}getFilterId(e){return this.getFilter(e)?.id}getFilterTable({sheetId:e,col:t,row:o}){return this.getFilterTables(e).find((e=>ui(t,o,e.zone)))}getFilterTablesInZone(e,t){return this.getFilterTables(e).filter((e=>gi(e.zone,t)))}doesZonesContainFilter(e,t){for(const o of t)for(const t of this.getFilterTables(e))if(ci(o,t.zone))return!0;return!1}getFilterHeaders(e){const t=[];for(let o of this.getFilterTables(e)){const e=o.zone,i=e.top;for(let o=e.left;o<=e.right;o++)t.push({col:o,row:i})}return t}isFilterHeader({sheetId:e,col:t,row:o}){return this.getFilterHeaders(e).some((e=>e.col===t&&e.row===o))}onAddColumnsRows(e){for(const t of this.getFilterTables(e.sheetId)){const o=si(t.zone,"COL"===e.dimension?"left":"top",e.base,e.position,e.quantity),i=[];for(const o of t.filters){const t=si(o.zoneWithHeaders,"COL"===e.dimension?"left":"top",e.base,e.position,e.quantity);i.push(new ew(o.id,t))}if(i.length<fi(o).numberOfCols){for(let e=o.left;e<=o.right;e++)i.find((t=>t.col===e))||i.push(new ew(this.uuidGenerator.uuidv4(),{...o,left:e,right:e}));i.sort(((e,t)=>e.col-t.col))}this.history.update("tables",e.sheetId,t.id,"zone",o),this.history.update("tables",e.sheetId,t.id,"filters",i)}}onDeleteColumnsRows(e){for(const t of this.getFilterTables(e.sheetId)){if("ROW"===e.dimension&&e.elements.includes(t.zone.top)){const o={...this.tables[e.sheetId]};delete o[t.id],this.history.update("tables",e.sheetId,o);continue}const o=ai(t.zone,"COL"===e.dimension?"left":"top",e.elements);if(o){if(ii(o)!==ii(t.zone)){const i=[];for(const o of t.filters){const t=ai(o.zoneWithHeaders,"COL"===e.dimension?"left":"top",e.elements);t&&i.push(new ew(o.id,t))}this.history.update("tables",e.sheetId,t.id,"zone",o),this.history.update("tables",e.sheetId,t.id,"filters",i)}}else{const o={...this.tables[e.sheetId]};delete o[t.id],this.history.update("tables",e.sheetId,o)}}}createFilterTable(e){return new JE(e)}extendTableDown(e,t){const o={...t.zone,bottom:t.zone.bottom+1};this.history.update("tables",e,t.id,"zone",o);for(let o=0;o<t.filters.length;o++){const i=t.filters[o],s={...i.zoneWithHeaders,bottom:i.zoneWithHeaders.bottom+1};this.history.update("tables",e,t.id,"filters",o,"zoneWithHeaders",s)}}canUpdateCellCmdExtendTable({content:e,sheetId:t,col:o,row:i},s){if(!e)return;const r=s.zone;if(!(r.bottom+1===i&&o>=r.left&&o<=r.right))return!1;for(const e of ye(r.left,r.right+1)){const o={sheetId:t,col:e,row:i},s=this.getters.getCell(o)?.content;if(s)return!1;if(this.getters.getFilter(o))return!1;if(this.getters.isInMerge(o))return!1}return!0}import(e){for(const t of e.sheets)for(const e of t.filterTables||[]){const o=this.createFilterTable(ti(e.range));this.history.update("tables",t.id,o.id,o)}}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){for(const t of e.sheets)for(const e of this.getFilterTables(t.id))1!==fi(e.zone).numberOfRows&&t.filterTables.push({range:ii(e.zone),filters:[]})}}).add("cell",class extends XE{static getters=["zoneToXC","getCells","getFormulaCellContent","getCellStyle","buildFormulaContent","getCellById"];nextId=1;cells={};adaptRanges(e,t){for(const o of Object.keys(this.cells))for(const i of Object.values(this.cells[o]||{}))if(i.isFormula)for(const s of i.dependencies)if(!t||s.sheetId===t){const t=e(s);"NONE"!==t.changeType&&this.history.update("cells",o,i.id,"dependencies",i.dependencies.indexOf(s),t.range)}}allowDispatch(e){switch(e.type){case"UPDATE_CELL":return this.checkValidations(e,this.checkCellOutOfSheet,this.checkUselessUpdateCell);case"CLEAR_CELL":return this.checkValidations(e,this.checkCellOutOfSheet,this.checkUselessClearCell);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,o){for(let i of t)for(let t=i.top;t<=i.bottom;t++)for(let s=i.left;s<=i.right;s++)this.dispatch("UPDATE_CELL",{sheetId:e,col:s,row:t,format:o})}clearFormatting(e,t){for(let o of t)for(let t=o.left;t<=o.right;t++)for(let i=o.top;i<=o.bottom;i++)this.dispatch("UPDATE_CELL",{sheetId:e,col:t,row:i,style:null,format:""})}handleAddColumnsRows(e,t){let o,i;"before"===e.position?(o=ye(e.base,e.base+e.quantity),i=e.base+e.quantity):(o=ye(e.base+1,e.base+e.quantity+1),i=e.base),t(e.sheetId,i,o)}import(e){for(let t of e.sheets)for(let o in t.cells){const i=t.cells[o],{col:s,row:r}=wt(o);if(i?.content||i?.format||i?.style){const o=this.importCell(t.id,i,e.styles,e.formats);this.history.update("cells",t.id,o.id,o),this.dispatch("UPDATE_CELL_POSITION",{cellId:o.id,col:s,row:r,sheetId:t.id})}}}export(e){const t={},o={};for(let i of e.sheets){const e={},s=Object.keys(this.cells[i.id]||{}).map((e=>this.getters.getCellPosition(e))).sort(((e,t)=>e.col===t.col?e.row-t.row:e.col-t.col));for(const i of s){const s=this.getters.getCell(i);e[xt(i.col,i.row)]={style:s.style?Ve(s.style,t):void 0,format:s.format?Ve(s.format,o):void 0,content:s.content||void 0}}i.cells=e}e.styles=t,e.formats=o}importCell(e,t,o,i){const s=t.style&&o[t.style]||void 0,r=t.format&&i[t.format]||void 0,n=this.getNextUid();return this.createCell(n,t?.content||"",r,s,e)}exportForExcel(e){this.export(e)}getCells(e){return this.cells[e]||{}}getCellById(e){const t=this.getters.getCellPosition(e);return this.cells[t.sheetId][e]}buildFormulaContent(e,t,o,i=!1){const s=o||t.dependencies;let r=0;return Be(t.compiledFormula.tokens.map((t=>{if("REFERENCE"===t.type){const t=s[r++];return this.getters.getRangeString(t,e,i)}return t.value})))}getFormulaCellContent(e,t){return this.buildFormulaContent(e,t)}getCellStyle(e){return this.getters.getCell(e)?.style||{}}zoneToXC(e,t,o=[{colFixed:!1,rowFixed:!1}]){const i=xt((t=this.getters.expandZone(e,t)).left,t.top,o[0]),s=xt(t.right,t.bottom,o.length>1?o[1]:o[0]),r=this.getters.getMainCellPosition({sheetId:e,col:t.left,row:t.top}),n=this.getters.getMainCellPosition({sheetId:e,col:t.right,row:t.bottom}),a=r.col===n.col&&r.row===n.row;return i==s||a?i:i+":"+s}setStyle(e,t,o){for(let i of t)for(let t=i.left;t<=i.right;t++)for(let s=i.top;s<=i.bottom;s++){const i=this.getters.getCell({sheetId:e,col:t,row:s});this.dispatch("UPDATE_CELL",{sheetId:e,col:t,row:s,style:o?{...i?.style,...o}:void 0})}}copyColumnStyle(e,t,o){for(let i=0;i<this.getters.getNumberRows(e);i++){const s=this.getFormat(e,t,i);if(s.style||s.format)for(let t of o)this.dispatch("UPDATE_CELL",{sheetId:e,col:t,row:i,...s})}}copyRowStyle(e,t,o){for(let i=0;i<this.getters.getNumberCols(e);i++){const s=this.getFormat(e,i,t);if(s.style||s.format)for(let t of o)this.dispatch("UPDATE_CELL",{sheetId:e,col:i,row:t,...s})}}getFormat(e,t,o){const i={},s=this.getters.getMainCellPosition({sheetId:e,col:t,row:o}),r=this.getters.getCell(s);return r&&(r.style&&(i.style=r.style),r.format&&(i.format=r.format)),i}getNextUid(){const e=this.nextId.toString();return this.history.update("nextId",this.nextId+1),e}updateCell(e,t,o,i){const s=this.getters.getCell({sheetId:e,col:t,row:o}),r="content"in i||"formula"in i,n=r?Xe(i?.content):s?.content||"";let a;a=void 0!==i.style?i.style||void 0:s?s.style:void 0;const l="format"in i?i.format:s&&s.format;if((r&&!n&&!i.formula||!r&&(!s||""===s.content))&&!a&&!l)return void(s&&(this.history.update("cells",e,s.id,void 0),this.dispatch("UPDATE_CELL_POSITION",{cellId:void 0,col:t,row:o,sheetId:e})));const c=s?.id||this.getNextUid(),h=this.createCell(c,n,l,a,e);this.history.update("cells",e,h.id,h),this.dispatch("UPDATE_CELL_POSITION",{cellId:h.id,col:t,row:o,sheetId:e})}createCell(e,t,o,i,s){if(!t.startsWith("="))return this.createLiteralCell(e,t,o,i);try{return this.createFormulaCell(e,t,o,i,s)}catch(s){return this.createErrorFormula(e,t,o,i,s)}}createLiteralCell(e,t,o,i){const s=this.getters.getLocale();return{id:e,content:ir(t,s).toString(),style:i,format:o||Mo(t,s)||No(t),isFormula:!1}}createFormulaCell(e,t,o,i,s){const r=hg(t);return r.dependencies.length?this.createFormulaCellWithDependencies(e,r,o,i,s):{id:e,content:t,style:i,format:o,isFormula:!0,compiledFormula:r,dependencies:[]}}createFormulaCellWithDependencies(e,t,o,i,s){const r=t.dependencies.map((e=>this.getters.getRangeFromSheetXC(s,e)));return new KE(e,t,o,i,r,s,this.buildFormulaContent.bind(this))}createErrorFormula(e,t,o,i,s){return{id:e,content:t,style:i,format:o,isFormula:!0,compiledFormula:{dependencies:[],tokens:xu(t),execute:function(){throw s}},dependencies:[]}}checkCellOutOfSheet(e){const{sheetId:t,col:o,row:i}=e;if(!this.getters.tryGetSheet(t))return 28;return ui(o,i,this.getters.getSheetZone(t))?0:19}checkUselessClearCell(e){const t=this.getters.getCell(e);return t&&(t.content||t.style||t.format)?0:98}checkUselessUpdateCell(e){const t=this.getters.getCell(e),o="style"in e,i="format"in e;return("content"in e||"formula"in e)&&t?.content!==e.content||o&&!We(t?.style,e.style)||i&&t?.format!==e.format?0:98}}).add("merge",class extends XE{static getters=["isInMerge","isInSameMerge","isMergeHidden","getMainCellPosition","getBottomLeftCell","expandZone","doesIntersectMerge","doesColumnsHaveCommonMerges","doesRowsHaveCommonMerges","getMerges","getMerge","getMergesInZone","isSingleCellOrMerge","getSelectionRangeString"];nextId=1;merges={};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 o of Object.values(t).filter(ke))this.addMerge(e.sheetIdTo,o.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 o=t?[t]:Object.keys(this.merges);for(const t of o)this.applyRangeChangeOnSheet(t,e)}getMerges(e){return Object.keys(this.merges[e]||{}).map((t=>this.getMergeById(e,parseInt(t,10)))).filter(ke)}getMerge({sheetId:e,col:t,row:o}){const i=this.mergeCellMap[e],s=i?t in i&&i[t]?.[o]:void 0;return s?this.getMergeById(e,s):void 0}getMergesInZone(e,t){const o=this.mergeCellMap[e];if(!o)return[];const i=new Set;for(const{col:e,row:s}of vi(t)){const t=o[e]?.[s];t&&i.add(t)}return Array.from(i).map((t=>this.getMergeById(e,t))).filter(ke)}getSelectionRangeString(e,t){const o=Ri.fromRange(e,this.getters),i=this.getters.expandZone(o.sheetId,o.zone),s=o.clone({zone:{...i,bottom:o.isFullCol?void 0:i.bottom,right:o.isFullRow?void 0:i.right}}),r=this.getters.getRangeString(s,t);if(this.isSingleCellOrMerge(o.sheetId,o.zone)){const{sheetName:e,xc:t}=Jo(r);return`${void 0!==e?we(e)+"!":""}${t.split(":")[0]}`}return r}doesIntersectMerge(e,t){return vi(t).some((({col:t,row:o})=>void 0!==this.getMerge({sheetId:e,col:t,row:o})))}doesColumnsHaveCommonMerges(e,t,o){const i=this.getters.getSheet(e);for(let s=0;s<this.getters.getNumberRows(e);s++)if(this.isInSameMerge(i.id,t,s,o,s))return!0;return!1}doesRowsHaveCommonMerges(e,t,o){const i=this.getters.getSheet(e);for(let s=0;s<=this.getters.getNumberCols(e);s++)if(this.isInSameMerge(i.id,s,t,s,o))return!0;return!1}expandZone(e,t){let{left:o,right:i,top:s,bottom:r}=t,n={left:o,right:i,top:s,bottom:r};for(let t in this.merges[e]){const o=this.getMergeById(e,parseInt(t));o&&di(o,n)&&(n=li(o,n))}return hi(n,t)?n:this.expandZone(e,n)}isInSameMerge(e,t,o,i,s){const r=this.getMerge({sheetId:e,col:t,row:o}),n=this.getMerge({sheetId:e,col:i,row:s});return!(!r||!n)&&hi(r,n)}isInMerge({sheetId:e,col:t,row:o}){const i=this.mergeCellMap[e];return!!i&&(t in i&&Boolean(i[t]?.[o]))}getMainCellPosition(e){if(!this.isInMerge(e))return e;const t=this.getMerge(e).topLeft;return{sheetId:e.sheetId,col:t.col,row:t.row}}getBottomLeftCell(e){if(!this.isInMerge(e))return e;const{bottom:t,left:o}=this.getMerge(e);return{sheetId:e.sheetId,col:o,row:t}}isMergeHidden(e,t){const o=this.getters.getHiddenColsGroups(e),i=this.getters.getHiddenRowsGroups(e);for(let e of o)if(t.left>=e[0]&&t.right<=e[e.length-1])return!0;for(let e of i)if(t.top>=e[0]&&t.bottom<=e[e.length-1])return!0;return!1}isSingleCellOrMerge(e,t){const o=this.getMerge({sheetId:e,col:t.left,row:t.top});if(o)return hi(t,o);const{numberOfCols:i,numberOfRows:s}=fi(t);return 1===i&&1===s}isMergeDestructive(e,t){let{left:o,right:i,top:s,bottom:r}=t;i=xe(i,0,this.getters.getNumberCols(e)-1),r=xe(r,0,this.getters.getNumberRows(e)-1);for(let t=s;t<=r;t++)for(let r=o;r<=i;r++)if(r!==o||t!==s){const o=this.getters.getCell({sheetId:e,col:r,row:t});if(o&&""!==o.content)return!0}return!1}getMergeById(e,t){const o=this.merges[e]?.[t];return void 0!==o?ow(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 o of e)if(t!==o&&di(t,o))return 68;return 0}checkFrozenPanes({sheetId:e,target:t}){if(!this.getters.tryGetSheet(e))return 0;const{xSplit:o,ySplit:i}=this.getters.getPaneDivisions(e);for(const e of t)if(e.left<o&&e.right>=o||e.top<i&&e.bottom>=i)return 78;return 0}checkMergedContentUpdate(e){const{col:t,row:o,content:i}=e;if(void 0===i)return 0;const{col:s,row:r}=this.getMainCellPosition(e);return s===t&&r===o?0:4}checkMergeExists(e){const{sheetId:t,target:o}=e;for(const e of o){const{left:o,top:i}=e,s=this.getMerge({sheetId:t,col:o,row:i});if(void 0===s||!hi(e,s))return 5}return 0}addMerge(e,t){let{left:o,right:i,top:s,bottom:r}=t;i=xe(i,0,this.getters.getNumberCols(e)-1),r=xe(r,0,this.getters.getNumberRows(e)-1);if(xt(o,s)===xt(i,r))return;const n=this.getters.getCell({sheetId:e,col:o,row:s});let a=this.nextId++;this.history.update("merges",e,a,this.getters.getRangeFromSheetXC(e,ii({left:o,top:s,right:i,bottom:r})));let l=new Set;for(let t=s;t<=r;t++)for(let r=o;r<=i;r++){r===o&&t===s||this.dispatch("UPDATE_CELL",{sheetId:e,col:r,row:t,style:n?n.style:null,content:""});const i=this.getMerge({sheetId:e,col:r,row:t});i&&l.add(i.id),this.history.update("mergeCellMap",e,r,t,a)}for(let t of l){const{top:o,bottom:i,left:s,right:r}=this.getMergeById(e,t);for(let t=o;t<=i;t++)for(let o=s;o<=r;o++){const i={sheetId:e,col:o,row:t},s=this.getMerge(i);s&&s.id===a||(this.history.update("mergeCellMap",e,o,t,void 0),this.dispatch("CLEAR_CELL",i))}this.history.update("merges",e,t,void 0)}}removeMerge(e,t){const{left:o,top:i,bottom:s,right:r}=t,n=this.getMerge({sheetId:e,col:o,row:i});if(void 0!==n&&hi(t,n)){this.history.update("merges",e,n.id,void 0);for(let t=i;t<=s;t++)for(let i=o;i<=r;i++)this.history.update("mergeCellMap",e,i,t,void 0)}}applyRangeChangeOnSheet(e,t){const o=Object.entries(this.merges[e]||{});for(const[i,s]of o)if(s){const o=s.zone,r=t(s);switch(r.changeType){case"NONE":break;case"REMOVE":this.removeMerge(e,o);break;default:const{numberOfCols:t,numberOfRows:s}=fi(r.range.zone);1===t&&1===s?this.removeMerge(e,o):this.history.update("merges",e,parseInt(i,10),r.range)}}this.history.update("mergeCellMap",e,{});for(const t of this.getMerges(e))for(const{col:o,row:i}of vi(t))this.history.update("mergeCellMap",e,o,i,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 o of t)this.addMerge(e,ti(o))}export(e){for(let t of e.sheets){const e=this.merges[t.id];e&&t.merges.push(...tw(e))}}exportForExcel(e){this.export(e)}}).add("headerSize",class extends XE{static getters=["getUserRowSize","getColSize"];sizes={};handle(e){switch(e.type){case"CREATE_SHEET":this.history.update("sizes",e.sheetId,{COL:[],ROW:[]});break;case"DUPLICATE_SHEET":this.history.update("sizes",e.sheetIdTo,Ce(this.sizes[e.sheetId]));break;case"DELETE_SHEET":const t={...this.sizes};delete t[e.sheetId],this.history.update("sizes",t);break;case"REMOVE_COLUMNS_ROWS":{const t=Je(this.sizes[e.sheetId][e.dimension],e.elements);this.history.update("sizes",e.sheetId,e.dimension,t);break}case"ADD_COLUMNS_ROWS":{let t=[...this.sizes[e.sheetId][e.dimension]];const o=$e(e.position,e.base),i=t[e.base];t.splice(o,0,...Array(e.quantity).fill(i)),this.history.update("sizes",e.sheetId,e.dimension,t);break}case"RESIZE_COLUMNS_ROWS":if("ROW"===e.dimension)for(const t of e.elements)this.history.update("sizes",e.sheetId,e.dimension,t,e.size||void 0);else for(const t of e.elements)this.history.update("sizes",e.sheetId,e.dimension,t,e.size||void 0)}}getColSize(e,t){return Math.round(this.sizes[e]?.COL[t]||L)}getUserRowSize(e,t){const o=this.sizes[e]?.ROW[t];return o?Math.round(o):void 0}import(e){for(let t of e.sheets){const e={COL:Array(t.colNumber).fill(void 0),ROW:Array(t.rowNumber).fill(void 0)};for(let[o,i]of Object.entries(t.rows))i.size&&(e.ROW[o]=i.size);for(let[o,i]of Object.entries(t.cols))i.size&&(e.COL[o]=i.size);this.sizes[t.id]=e}}exportForExcel(e){this.exportData(e,!0)}export(e){this.exportData(e)}exportData(e,t=!1){for(let o of e.sheets){void 0===o.rows&&(o.rows={});for(const e of ye(0,this.getters.getNumberRows(o.id)))(t||this.sizes[o.id].ROW[e])&&(o.rows[e]={...o.rows[e],size:this.getUserRowSize(o.id,e)??P});void 0===o.cols&&(o.cols={});for(let e of ye(0,this.getters.getNumberCols(o.id)))(t||this.sizes[o.id].COL[e])&&(o.cols[e]={...o.cols[e],size:this.getColSize(o.id,e)})}}}).add("borders",class extends XE{static getters=["getCellBorder","getBordersColors"];borders={};allowDispatch(e){return"SET_BORDER"===e.type?this.checkBordersUnchanged(e):0}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 o=t.slice().map((e=>e?.slice().map((e=>({...e})))));this.history.update("borders",e.sheetIdTo,o)}break;case"DELETE_SHEET":const o={...this.borders};delete o[e.sheetId],this.history.update("borders",o);break;case"SET_BORDER":this.setBorder(e.sheetId,e.col,e.row,e.border);break;case"SET_ZONE_BORDERS":if(e.border){const t=e.target.map((t=>this.getters.expandZone(e.sheetId,t)));this.setBorders(e.sheetId,t,e.border.position,""===e.border.color?void 0:{style:e.border.style||K,color:e.border.color||Q})}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,o;"before"===e.position?(this.shiftBordersHorizontally(e.sheetId,e.base,e.quantity,{moveFirstLeftBorder:!0}),t=e.base-1,o=e.base+e.quantity):(this.shiftBordersHorizontally(e.sheetId,e.base+1,e.quantity,{moveFirstLeftBorder:!1}),t=e.base,o=e.base+e.quantity+1),this.ensureColumnBorderContinuity(e.sheetId,t,o)}handleAddRows(e){let t,o;"before"===e.position?(this.shiftBordersVertically(e.sheetId,e.base,e.quantity,{moveFirstTopBorder:!0}),t=e.base-1,o=e.base+e.quantity):(this.shiftBordersVertically(e.sheetId,e.base+1,e.quantity,{moveFirstTopBorder:!1}),t=e.base,o=e.base+e.quantity+1),this.ensureRowBorderContinuity(e.sheetId,t,o)}getCellBorder({sheetId:e,col:t,row:o}){const i={top:this.borders[e]?.[t]?.[o]?.horizontal,bottom:this.borders[e]?.[t]?.[o+1]?.horizontal,left:this.borders[e]?.[t]?.[o]?.vertical,right:this.borders[e]?.[t+1]?.[o]?.vertical};return i.bottom||i.left||i.right||i.top?i:null}getBordersColors(e){const t=[],o=this.borders[e];if(o)for(const e of o.filter(ke))for(const o of e)o?.horizontal&&t.push(o.horizontal.color),o?.vertical&&t.push(o.vertical.color);return t}ensureColumnBorderContinuity(e,t,o){const i=ye(t+1,o);for(let s=0;s<this.getters.getNumberRows(e);s++){const r=this.getCellBorder({sheetId:e,col:t,row:s}),n=this.getCellBorder({sheetId:e,col:o,row:s});if(r&&n){const t=this.getCommonSides(r,n);for(let o of i)this.addBorder(e,o,s,t)}}}ensureRowBorderContinuity(e,t,o){const i=ye(t+1,o);for(let s=0;s<this.getters.getNumberCols(e);s++){const r=this.getCellBorder({sheetId:e,col:s,row:t}),n=this.getCellBorder({sheetId:e,col:s,row:o});if(r&&n){const t=this.getCommonSides(r,n);for(let o of i)this.addBorder(e,s,o,t)}}}getCommonSides(e,t){const o={};for(let i of["top","bottom","left","right"])e[i]&&e[i]===t[i]&&(o[i]=e[i]);return o}getColumnsWithBorders(e){const t=this.borders[e];return t?Object.keys(t).map((e=>parseInt(e,10))):[]}getRowsRange(e){return this.borders[e]?ye(0,this.getters.getNumberRows(e)+1):[]}shiftBordersHorizontally(e,t,o,{moveFirstLeftBorder:i}={}){this.borders[e]&&(o<0&&this.moveBordersOfColumn(e,t,o,"vertical",{destructive:!1}),this.getColumnsWithBorders(e).filter((e=>e>=t)).sort(((e,t)=>o<0?e-t:t-e)).forEach((s=>{(s===t&&i||s!==t)&&this.moveBordersOfColumn(e,s,o,"vertical"),this.moveBordersOfColumn(e,s,o,"horizontal")})))}shiftBordersVertically(e,t,o,{moveFirstTopBorder:i}={}){this.borders[e]&&(o<0&&this.moveBordersOfRow(e,t,o,"horizontal",{destructive:!1}),this.getRowsRange(e).filter((e=>e>=t)).sort(((e,t)=>o<0?e-t:t-e)).forEach((s=>{(s===t&&i||s!==t)&&this.moveBordersOfRow(e,s,o,"horizontal"),this.moveBordersOfRow(e,s,o,"vertical")})))}moveBordersOfRow(e,t,o,i,{destructive:s}={destructive:!0}){const r=this.borders[e];r&&this.getColumnsWithBorders(e).forEach((n=>{const a=r[n]?.[t+o]?.[i],l=r[n]?.[t]?.[i];this.history.update("borders",e,n,t+o,i,s?l:l||a),this.history.update("borders",e,n,t,i,void 0)}))}moveBordersOfColumn(e,t,o,i,{destructive:s}={destructive:!0}){const r=this.borders[e];r&&this.getRowsRange(e).forEach((n=>{const a=r[t+o]?.[n]?.[i],l=r[t]?.[n]?.[i];this.history.update("borders",e,t+o,n,i,s?l:l||a),this.history.update("borders",e,t,n,i,void 0)}))}setBorder(e,t,o,i,s=!0){!s&&this.borders?.[e]?.[t]?.[o]?.vertical||this.history.update("borders",e,t,o,"vertical",i?.left),!s&&this.borders?.[e]?.[t]?.[o]?.horizontal||this.history.update("borders",e,t,o,"horizontal",i?.top),!s&&this.borders?.[e]?.[t+1]?.[o]?.vertical||this.history.update("borders",e,t+1,o,"vertical",i?.right),!s&&this.borders?.[e]?.[t]?.[o+1]?.horizontal||this.history.update("borders",e,t,o+1,"horizontal",i?.bottom)}clearBorders(e,t){for(let o of t){for(let t=o.top;t<=o.bottom;t++){this.history.update("borders",e,o.right+1,t,"vertical",void 0);for(let i=o.left;i<=o.right;i++)this.history.update("borders",e,i,t,void 0)}for(let t=o.left;t<=o.right;t++)this.history.update("borders",e,t,o.bottom+1,"horizontal",void 0)}}addBorder(e,t,o,i){this.setBorder(e,t,o,{...this.getCellBorder({sheetId:e,col:t,row:o}),...i})}setBorders(e,t,o,i){if("clear"===o)return this.clearBorders(e,t);for(let s of t){if("h"===o||"hv"===o||"all"===o)for(let t=s.top+1;t<=s.bottom;t++)for(let o=s.left;o<=s.right;o++)this.addBorder(e,o,t,{top:i});if("v"===o||"hv"===o||"all"===o)for(let t=s.top;t<=s.bottom;t++)for(let o=s.left+1;o<=s.right;o++)this.addBorder(e,o,t,{left:i});if("left"===o||"all"===o||"external"===o)for(let t=s.top;t<=s.bottom;t++)this.addBorder(e,s.left,t,{left:i});if("right"===o||"all"===o||"external"===o)for(let t=s.top;t<=s.bottom;t++)this.addBorder(e,s.right+1,t,{left:i});if("top"===o||"all"===o||"external"===o)for(let t=s.left;t<=s.right;t++)this.addBorder(e,t,s.top,{top:i});if("bottom"===o||"all"===o||"external"===o)for(let t=s.left;t<=s.right;t++)this.addBorder(e,t,s.bottom+1,{top:i})}}addBordersToMerge(e,t){const{left:o,right:i,top:s,bottom:r}=t,n=this.getCellBorder({sheetId:e,col:o,row:s}),a=this.getCellBorder({sheetId:e,col:i,row:r});this.clearBorders(e,[t]),n?.top&&this.setBorders(e,[{...t,bottom:s}],"top",n.top),n?.left&&this.setBorders(e,[{...t,right:o}],"left",n.left),a?.bottom?this.setBorders(e,[{...t,top:r}],"bottom",a.bottom):n?.bottom&&this.setBorders(e,[{...t,top:r}],"bottom",n.bottom),a?.right?this.setBorders(e,[{...t,left:i}],"right",a.right):n?.right&&this.setBorders(e,[{...t,left:i}],"right",n.right)}checkBordersUnchanged(e){const t=this.getCellBorder(e),o=!(e.border?.bottom||e.border?.left||e.border?.right||e.border?.top);return!t&&o||We(t,e.border)?98:0}import(e){if(Object.keys(e.borders||{}).length)for(let t of e.sheets)for(const o in t.cells){const i=t.cells[o];if(i?.border){const s=e.borders[i.border],{col:r,row:n}=wt(o);this.setBorder(t.id,r,n,s,!1)}}for(let t of e.sheets)if(t.merges)for(let e of t.merges)this.addBordersToMerge(t.id,ti(e))}export(e){let t=0;const o={};function i(e){for(let[t,i]of Object.entries(o))if(We(i,e))return parseInt(t,10);return o[++t]=e,t}for(let t of e.sheets)for(let e=0;e<t.colNumber;e++)for(let o=0;o<t.rowNumber;o++){const s=this.getCellBorder({sheetId:t.id,col:e,row:o});if(s){const r=xt(e,o),n=t.cells[r],a=i(s);n?n.border=a:t.cells[r]={border:a}}}e.borders=o}exportForExcel(e){this.export(e)}}).add("conditional formatting",class extends XE{static getters=["getConditionalFormats","getRulesSelection","getRulesByCell","getAdaptedCfRanges"];cfRules={};loopThroughRangesOfSheet(e,t){for(const o of this.cfRules[e])for(const i of o.ranges){const s=t(i);switch(s.changeType){case"REMOVE":let t=o.ranges.slice();t.splice(o.ranges.indexOf(i),1),t.length>=1?this.history.update("cfRules",e,this.cfRules[e].indexOf(o),"ranges",t):this.removeConditionalFormatting(o.id,e);break;case"RESIZE":case"MOVE":case"CHANGE":this.history.update("cfRules",e,this.cfRules[e].indexOf(o),"ranges",o.ranges.indexOf(i),s.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 o={...e.cf,ranges:e.ranges.map((t=>this.getters.getRangeString(this.getters.getRangeFromRangeData(t),e.sheetId)))};this.addConditionalFormatting(o,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){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,{useFixedReference:!0}))))}getConditionalFormats(e){return this.cfRules[e]?.map((t=>this.mapToConditionalFormat(e,t)))||[]}getRulesSelection(e,t){const o=new Set;return t.forEach((t=>{this.getRulesByZone(e,t).forEach((e=>{o.add(e)}))})),Array.from(o)}getRulesByZone(e,t){const o=new Set;for(let i=t.top;i<=t.bottom;i++)for(let s=t.left;s<=t.right;s++){this.getRulesByCell(e,s,i).forEach((e=>{o.add(e.id)}))}return o}getRulesByCell(e,t,o){const i=[];for(let s of this.cfRules[e])for(let e of s.ranges)ui(t,o,e.zone)&&i.push(s);return new Set(i.map((t=>this.mapToConditionalFormat(e,t))))}getAdaptedCfRanges(e,t,o,i){if(0===o.length&&0===i.length)return;const s=this.getters.getConditionalFormats(e),r=s.findIndex((e=>e.id===t.id));let n=[];return r>-1&&(n=s[r].ranges),n=n.concat(o),pi(n,i)}mapToConditionalFormat(e,t,o={useFixedReference:!1}){return{...t,ranges:t.ranges.map((t=>this.getters.getRangeString(t,e,o.useFixedReference)))}}mapToConditionalFormatInternal(e,t){const o={...t,ranges:t.ranges.map((t=>this.getters.getRangeFromSheetXC(e,t)))};return o}addConditionalFormatting(e,t){const o=this.cfRules[t].slice(),i=o.findIndex((t=>t.id===e.id)),s=this.mapToConditionalFormatInternal(t,e);i>-1?o.splice(i,1,s):o.push(s),this.history.update("cfRules",t,o)}checkValidReordering(e,t,o){if(!this.cfRules[o])return 28;const i=this.cfRules[o].findIndex((t=>t.id===e));if(-1===i)return 74;const s="up"===t?i-1:i+1;return s<0||s>=this.cfRules[o].length?74:0}checkEmptyRange(e){return e.ranges.length?0:25}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 o=>{if(t.includes(o.operator)){const t=[],i=e=>void 0===e||""===e;return e>=1&&i(o.values[0])&&t.push(54),e>=2&&i(o.values[1])&&t.push(55),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 56;case"max":return 58;case"mid":return 57;case"upperInflectionPoint":return 59;case"lowerInflectionPoint":return 60}return 0}checkFormulaCompilation(e,t){if("formula"!==e.type)return 0;try{hg(e.value||"")}catch(e){switch(t){case"min":return 61;case"max":return 63;case"mid":return 62;case"upperInflectionPoint":return 64;case"lowerInflectionPoint":return 65}}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,o=e.upperInflectionPoint.value;return["number","percentage","percentile"].includes(e.lowerInflectionPoint.type)&&e.lowerInflectionPoint.type===e.upperInflectionPoint.type&&Number(t)>Number(o)?51:0}checkMinBiggerThanMax(e){const t=e.minimum.value,o=e.maximum.value;return["number","percentage","percentile"].includes(e.minimum.type)&&e.minimum.type===e.maximum.type&&QE(t)>=QE(o)?50:0}checkMidBiggerThanMax(e){const t=e.midpoint?.value,o=e.maximum.value;return e.midpoint&&["number","percentage","percentile"].includes(e.midpoint.type)&&e.midpoint.type===e.maximum.type&&QE(t)>=QE(o)?52:0}checkMinBiggerThanMid(e){const t=e.minimum.value,o=e.midpoint?.value;return e.midpoint&&["number","percentage","percentile"].includes(e.midpoint.type)&&e.minimum.type===e.midpoint.type&&QE(t)>=QE(o)?53:0}removeConditionalFormatting(e,t){const o=this.cfRules[t].findIndex((t=>t.id===e));if(-1!==o){const e=this.cfRules[t].slice();e.splice(o,1),this.history.update("cfRules",t,e)}}reorderConditionalFormatting(e,t,o){const i=this.cfRules[o].findIndex((t=>t.id===e)),s="up"===t?i-1:i+1;if(!(s<0||s>=this.cfRules[o].length)&&-1!==i&&-1!==s){const e=[...this.cfRules[o]],t=e[i];e[i]=e[s],e[s]=t,this.history.update("cfRules",o,e)}}}).add("figures",class extends XE{static getters=["getFigures","getFigure","getFigureSheetId"];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}}beforeHandle(e){if("DELETE_SHEET"===e.type)this.getters.getFigures(e.sheetId).forEach((t=>{this.dispatch("DELETE_FIGURE",{id:t.id,sheetId:e.sheetId})}))}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:o,...i}=e,s=i;this.updateFigure(o,s);break;case"DELETE_FIGURE":this.removeFigure(e.id,e.sheetId);break;case"REMOVE_COLUMNS_ROWS":this.onRowColDelete(e.sheetId,e.dimension)}}onRowColDelete(e,t){"ROW"===t?this.onRowDeletion(e):this.onColDeletion(e)}onRowDeletion(e){const t=this.getters.getNumberRows(e);let o=0;for(let i=0;i<t;i++)o+=this.getters.getUserRowSize(e,i)||P;const i=this.getters.getFigures(e);for(const t of i){const i=Math.min(t.y,o-t.height);i!==t.y&&this.dispatch("UPDATE_FIGURE",{sheetId:e,id:t.id,y:i})}}onColDeletion(e){const t=this.getters.getNumberCols(e);let o=0;for(let i=0;i<t;i++)o+=this.getters.getColSize(e,i);const i=this.getters.getFigures(e);for(const t of i){const i=Math.min(t.x,o-t.width);i!==t.x&&this.dispatch("UPDATE_FIGURE",{sheetId:e,id:t.id,x:i})}}updateFigure(e,t){if("id"in t)for(const[o,i]of Object.entries(t))switch(o){case"x":case"y":void 0!==i&&this.history.update("figures",e,t.id,o,Math.max(i,0));break;case"width":case"height":void 0!==i&&this.history.update("figures",e,t.id,o,i)}}addFigure(e,t){this.history.update("figures",t,e.id,e)}deleteSheet(e){this.history.update("figures",e,void 0)}removeFigure(e,t){this.history.update("figures",t,e,void 0)}checkFigureExists(e,t){return void 0===this.figures[e]?.[t]?73:0}checkFigureDuplicate(e){return Object.values(this.figures).find((t=>t?.[e]))?85:0}getFigures(e){return Object.values(this.figures[e]||{}).filter(ke)}getFigure(e,t){return this.figures[e]?.[t]}getFigureSheetId(e){return Object.keys(this.figures).find((t=>void 0!==this.figures[t]?.[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 o=void 0;t.figures.push({...e,data:o})}}exportForExcel(e){this.export(e)}}).add("chart",class extends XE{static getters=["isChartDefined","getChartDefinition","getChartType","getChartIds","getChart","getContextCreationChart"];charts={};createChart=function(e){const t=qp.getAll().sort(((e,t)=>e.sequence-t.sequence));return function(o,i,s){const r=t.find((e=>e.match(i.type)));if(!r)throw new Error(`No builder for this chart: ${i.type}`);return r.createChart(i,s,e)}}(this.getters);validateChartDefinition=e=>function(e,t){const o=qp.getAll().find((e=>e.match(t.type)));if(!o)throw new Error("Unknown chart type.");return o.validateChartDefinition(e,t)}(this,e.definition);adaptRanges(e){for(const[t,o]of Object.entries(this.charts))this.history.update("charts",t,o?.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){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 t=this.getters.getFigures(e.sheetId);for(const o of t)if("chart"===o.tag){const t=o.id.split(se).pop(),i=`${e.sheetIdTo}${se}${t}`,s=this.charts[o.id]?.copyForSheetId(e.sheetIdTo);s&&this.dispatch("CREATE_CHART",{id:i,position:{x:o.x,y:o.y},size:{width:o.width,height:o.height},definition:s.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){return this.charts[e]?.getContextCreation()}getChart(e){return this.charts[e]}getChartType(e){const t=this.charts[e]?.type;if(!t)throw new Error("Chart not defined.");return t}isChartDefined(e){return e in this.charts&&void 0!==this.charts}getChartIds(e){return Object.entries(this.charts).filter((([,t])=>t?.sheetId===e)).map((([e])=>e))}getChartDefinition(e){const t=this.charts[e]?.getDefinition();if(!t)throw new Error(`There is no chart with the given figureId: ${e}`);return t}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){if(e.sheets)for(let t of e.sheets){const e=this.getters.getFigures(t.id),o=[];for(let t of e){const e=t;if(e&&"chart"===e.tag){const t=this.charts[e.id]?.getDefinition();t&&(e.data=t,o.push(e))}else o.push(e)}t.figures=o}}exportForExcel(e){for(let t of e.sheets){const e=this.getters.getFigures(t.id),o=[];for(let t of e)if(t&&"chart"===t.tag){const e=this.charts[t.id]?.getDefinitionForExcel();e&&o.push({...t,data:e})}t.charts=o}}addFigure(e,t,o={x:0,y:0},i={width:536,height:335}){if(this.getters.getFigure(t,e))return;const s={id:e,x:o.x,y:o.y,width:i.width,height:i.height,tag:"chart"};this.dispatch("CREATE_FIGURE",{sheetId:t,figure:s})}addChart(e,t){const o=this.getters.getFigureSheetId(e);o&&this.history.update("charts",e,this.createChart(e,t,o))}checkChartDuplicate(e){return this.getters.getFigureSheetId(e.id)?87:0}checkChartExists(e){return this.getters.getFigureSheetId(e.id)?0:88}}).add("image",class extends XE{static getters=["getImage","getImagePath","getImageSize"];fileStore;images={};syncedImages=new Set;constructor(e){super(e),this.fileStore=e.external.fileStore}allowDispatch(e){return"CREATE_IMAGE"===e.type&&this.getters.getFigure(e.sheetId,e.figureId)?29:0}handle(e){switch(e.type){case"CREATE_IMAGE":this.addImage(e.figureId,e.sheetId,e.position,e.size),this.history.update("images",e.sheetId,e.figureId,e.definition),this.syncedImages.add(e.definition.path);break;case"DUPLICATE_SHEET":{const t=this.getters.getFigures(e.sheetId);for(const o of t)if("image"===o.tag){const t=o.id.split(se).pop(),i=`${e.sheetIdTo}${se}${t}`,s=this.getImage(o.id);if(s){const t={width:o.width,height:o.height};this.dispatch("CREATE_IMAGE",{sheetId:e.sheetIdTo,figureId:i,position:{x:o.x,y:o.y},size:t,definition:Ce(s)})}}break}case"DELETE_FIGURE":this.history.update("images",e.sheetId,e.id,void 0);break;case"DELETE_SHEET":this.history.update("images",e.sheetId,void 0)}}garbageCollectExternalResources(){const e=new Set(this.getAllImages().map((e=>e.path)));for(const t of this.syncedImages)e.has(t)||this.fileStore?.delete(t)}getImage(e){for(const t of Object.values(this.images))if(t&&t[e])return t[e];throw new Error(`There is no image with the given figureId: ${e}`)}getImagePath(e){return this.getImage(e).path}getImageSize(e){return this.getImage(e).size}addImage(e,t,o,i){const s={id:e,x:o.x,y:o.y,width:i.width,height:i.height,tag:"image"};this.dispatch("CREATE_FIGURE",{sheetId:t,figure:s})}import(e){for(const t of e.sheets){const e=(t.figures||[]).filter((e=>"image"===e.tag));for(const o of e)this.history.update("images",t.id,o.id,o.data),this.syncedImages.add(o.data.path)}}export(e){for(const t of e.sheets){const e=t.figures.filter((e=>"image"===e.tag));for(const o of e)o.data=this.images[t.id]?.[o.id]}}exportForExcel(e){for(const t of e.sheets){const e=this.getters.getFigures(t.id),o=[];for(const t of e)if("image"===t?.tag){const e=this.getImage(t.id);e&&o.push({...t,data:Ce(e)})}t.images=o}}getAllImages(){const e=[];for(const t in this.images)e.push(...Object.values(this.images[t]||{}).filter(ke));return e}}),Cx=(new Ji).add("ui_sheet",class extends sw{static getters=["getCellWidth","getTextWidth","getCellText","getCellMultiLineText","getColDimensions","getRowDimensions","getColRowOffset"];ctx=document.createElement("canvas").getContext("2d");allowDispatch(e){return this.chainValidations(this.checkSheetExists,this.checkZonesAreInSheet)(e)}handle(e){switch(e.type){case"AUTORESIZE_COLUMNS":for(let t of e.cols){const o=this.getColMaxWidth(e.sheetId,t);0!==o&&this.dispatch("RESIZE_COLUMNS_ROWS",{elements:[t],dimension:"COL",size:o,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){const t=this.getters.getCellComputedStyle(e);let o=0;const i=this.getters.getEvaluatedCell(e).formattedValue;if(i){const e=Ui(this.ctx,i,t,void 0);o+=Math.max(...e.map((e=>Fi(this.ctx,e,t))))}this.getters.getConditionalIcon(e)&&(o+=function(e){return Pi(e)+2*B}(t));if(this.getters.isFilterHeader(e)&&(o+=20),0===o)return 0;if(o+=2*$,"wrap"===t.wrapping){const t=this.getters.getColSize(this.getters.getActiveSheetId(),e.col);return Math.min(t,o)}return o}getTextWidth(e,t){return Fi(this.ctx,e,t)}getCellText(e,t=!1){const o=this.getters.getCell(e);return t&&o?.isFormula?Eg(o.content,this.getters.getLocale()):this.getters.getEvaluatedCell(e).formattedValue}getCellMultiLineText(e,t){const o=this.getters.getCellStyle(e),i=this.getters.getCellText(e,this.getters.shouldShowFormulas());return Ui(this.ctx,i,o,t)}getColDimensions(e,t){const o=this.getColRowOffset("COL",0,t,e),i=this.getters.getColSize(e,t);return{start:o,size:i,end:o+(this.getters.isColHidden(e,t)?0:i)}}getRowDimensions(e,t){const o=this.getColRowOffset("ROW",0,t,e),i=this.getters.getRowSize(e,t);return{start:o,size:i,end:o+(this.getters.isRowHidden(e,t)?0:i)}}getColRowOffset(e,t,o,i=this.getters.getActiveSheetId()){if(o<t)return-this.getColRowOffset(e,o,t);let s=0;for(let r=t;r<o;r++)this.getters.isHeaderHidden(i,e,r)||(s+="COL"===e?this.getters.getColSize(i,r):this.getters.getRowSize(i,r));return s}getColMaxWidth(e,t){const o=vi(this.getters.getColsZone(e,t,t)).map((t=>this.getCellWidth({sheetId:e,...t})));return Math.max(0,et(o))}checkSheetExists(e){return"sheetId"in e&&void 0===this.getters.tryGetSheet(e.sheetId)?28:0}checkZonesAreInSheet(e){const t="sheetId"in e?e.sheetId:this.getters.tryGetActiveSheetId(),o=this.getters.getCommandZones(e);return!t&&o.length>0?95:t&&o.length>0?this.getters.checkZonesExistInSheet(t,o):0}}).add("header_visibility_ui",class extends sw{static getters=["getNextVisibleCellPosition","findVisibleHeader","findLastVisibleColRowIndex","findFirstVisibleColRowIndex","isRowHidden","isColHidden","isHeaderHidden"];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,o){return"COL"===t?this.isColHidden(e,o):this.isRowHidden(e,o)}getNextVisibleCellPosition({sheetId:e,col:t,row:o}){return{sheetId:e,col:this.findVisibleHeader(e,"COL",t,this.getters.getNumberCols(e)-1),row:this.findVisibleHeader(e,"ROW",o,this.getters.getNumberRows(e)-1)}}findVisibleHeader(e,t,o,i){if(o<=i)for(let s=o;s<=i;s++)if(this.getters.doesHeaderExist(e,t,s)&&!this.isHeaderHidden(e,t,s))return s;if(o>i)for(let s=o;s>=i;s--)if(this.getters.doesHeaderExist(e,t,s)&&!this.isHeaderHidden(e,t,s))return s}findLastVisibleColRowIndex(e,t,{last:o,first:i}){return ye(o,i,-1).find((o=>!this.isHeaderHidden(e,t,o)))||i}findFirstVisibleColRowIndex(e,t){const o=this.getters.getNumberHeaders(e,t);for(let i=0;i<o;i++){if("COL"===t&&!this.isColHidden(e,i))return i;if("ROW"===t&&!this.isRowHidden(e,i))return i}}exportForExcel(e){for(const t of e.sheets)for(const[e,o]of Object.entries(t.rows)){const i=this.isRowHidden(t.id,Number(e));o.isHidden=i}}}).add("ui_options",class extends sw{static getters=["shouldShowFormulas"];showFormulas=!1;handle(e){if("SET_FORMULA_VISIBILITY"===e.type)this.showFormulas=e.show}shouldShowFormulas(){return this.showFormulas}}).add("selectionInputManager",class extends sw{config;static layers=[1];static getters=["getSelectionInput","getSelectionInputValue","isRangeValid","getSelectionInputHighlights"];inputs={};focusedInputId=null;get currentInput(){return this.focusedInputId?this.inputs[this.focusedInputId]:null}constructor(e){super(e),this.config=e}allowDispatch(e){switch(e.type){case"FOCUS_RANGE":case"CHANGE_RANGE":case"ADD_EMPTY_RANGE":case"REMOVE_RANGE":if(!this.inputs[e.id])return 33}switch(e.type){case"FOCUS_RANGE":const t=this.currentInput?.getIndex(e.rangeId);if(this.focusedInputId===e.id&&this.currentInput?.focusedRangeIndex===t)return 30;break;case"ADD_RANGE":case"ADD_EMPTY_RANGE":const o=this.inputs[e.id];if(o.inputHasSingleRange&&1===o.ranges.length)return 31;break;case"REMOVE_RANGE":if(1===this.inputs[e.id].ranges.length)return 32;break;case"CHANGE_RANGE":if(this.inputs[e.id].inputHasSingleRange&&e.value.split(",").length>1)return 31;break}return 0}handle(e){switch(e.type){case"ENABLE_NEW_SELECTION_INPUT":this.initInput(e.id,e.initialRanges||[],e.hasSingleRange);break;case"DISABLE_SELECTION_INPUT":this.focusedInputId===e.id&&this.unfocus(),delete this.inputs[e.id];break;case"UNFOCUS_SELECTION_INPUT":this.unfocus();break;case"ADD_RANGE":case"ADD_EMPTY_RANGE":case"REMOVE_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}break;case"FOCUS_RANGE":case"CHANGE_RANGE":const t=this.inputs[e.id],o=t.ranges.find((t=>t.id===e.rangeId));if(o){const i=this.getters.getActiveSheetId(),s=this.getters.getRangeFromSheetXC(i,o?.xc||"A1").zone;this.selection.capture(t,{cell:{col:s.left,row:s.top},zone:s},{handleEvent:t.handleEvent.bind(t)}),this.focusedInputId=e.id}}this.currentInput?.handle(e)}getSelectionInput(e){return this.inputs[e]?this.inputs[e].ranges.map(((t,o)=>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===o}))):[]}isRangeValid(e){if(!e)return!1;const{xc:t,sheetName:o}=Jo(e);return null!==t.match(Zo)&&(!o||void 0!==this.getters.getSheetIdByName(o))}getSelectionInputValue(e){return this.inputs[e].getSelectionInputValue()}getSelectionInputHighlights(){return this.focusedInputId?this.inputs[this.focusedInputId].getSelectionInputHighlights():[]}initInput(e,t,o=!1){if(this.inputs[e]&&this.unfocus(),this.inputs[e]=new Yw(this.config,t,o),0===t.length){const t=this.inputs[e],o={zone:wi({col:0,row:0}),cell:{col:0,row:0}};this.selection.capture(t,o,{handleEvent:t.handleEvent.bind(t)}),this.focusedInputId=e}}unfocus(){this.selection.release(this.currentInput),this.focusedInputId=null}}).add("highlight",class extends sw{static layers=[1];static getters=["getHighlights"];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{numberOfRows:t,numberOfCols:o}=fi(e.zone),i=t*o==1?this.getters.expandZone(e.sheetId,e.zone):e.zone;return{...e,zone:i}}))}drawGrid(e){const{ctx:t,thinLineWidth:o}=e,i=this.getters.getActiveSheetId(),s=3*o;t.lineWidth=s;const r=this.getHighlights();for(let e of r.filter(((e,t)=>r.findIndex((t=>hi(t.zone,e.zone)&&t.sheetId===i))===t))){const{x:o,y:i,width:r,height:n}=this.getters.getVisibleRect(e.zone);r>0&&n>0&&(t.strokeStyle=e.color,t.strokeRect(o+s/2,i+s/2,r-s,n-s),t.globalCompositeOperation="source-over",t.fillStyle=e.color+"20",t.fillRect(o+s,i+s,r-2*s,n-2*s))}}}).add("grid renderer",class extends sw{static layers=[0,7];static getters=["getColDimensionsInViewport","getRowDimensionsInViewport"];boxes=[];getColDimensionsInViewport(e,t){const o=tt(this.getters.getSheetViewVisibleCols()),i=this.getters.getColRowOffsetInViewport("COL",o,t),s=this.getters.getColSize(e,t);return{start:i,size:s,end:i+(this.getters.isColHidden(e,t)?0:s)}}getRowDimensionsInViewport(e,t){const o=tt(this.getters.getSheetViewVisibleRows()),i=this.getters.getColRowOffsetInViewport("ROW",o,t),s=this.getters.getRowSize(e,t);return{start:i,size:s,end:i+(this.getters.isRowHidden(e,t)?0:s)}}getHeaderOffset(e,t,o){let i=this.getters.getColRowOffsetInViewport(e,t,o);return this.getters.isDashboard()||(i+="ROW"===e?F:D),i}drawGrid(e,t){switch(t){case 0:this.boxes=this.getGridBoxes(),this.drawBackground(e),this.drawOverflowingCellBackground(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:o}=e,{width:i,height:s}=this.getters.getSheetViewDimensionWithHeaders();t.fillStyle="#ffffff",t.fillRect(0,0,i+m,s+m);const r=!this.getters.isDashboard()&&this.getters.getGridLinesVisibility(this.getters.getActiveSheetId()),n=r?.1*o:0;if(r)for(const e of this.boxes)t.strokeStyle="#E2E3E3",t.lineWidth=o,t.strokeRect(e.x+n,e.y+n,e.width-2*n,e.height-2*n)}drawCellBackground(e){const{ctx:t}=e;for(const e of this.boxes){let o=e.style;o.fillColor&&"#ffffff"!==o.fillColor&&(t.fillStyle=o.fillColor||"#ffffff",t.fillRect(e.x,e.y,e.width,e.height)),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())}}drawOverflowingCellBackground(e){const{ctx:t,thinLineWidth:o}=e;for(const e of this.boxes)if(e.content&&e.isOverflow){const i=e.content.align||"left";let s,r;const n=e.y+o/2,a=e.height-o,l=Math.min(e.clipRect?.width||1/0,e.content.width);"left"===i?(s=e.x+o/2,r=l-2*o):"right"===i?(s=e.x+e.width-o/2,r=2*o-l):(s=(e.clipRect?.x||e.x+e.width/2-e.content.width/2)+o/2,r=l-2*o),t.fillStyle="#ffffff",t.fillRect(s,n,r,a)}}drawBorders(e){const{ctx:t}=e;for(let e of this.boxes){const t=e.border;if(t){const{x:i,y:s,width:r,height:n}=e;t.left&&o(t.left,i,s,i,s+n),t.top&&o(t.top,i,s,i+r,s),t.right&&o(t.right,i+r,s,i+r,s+n),t.bottom&&o(t.bottom,i,s+n,i+r,s+n)}}function o({style:e,color:o},i,s,r,n){switch(t.strokeStyle=o,e){case"medium":t.lineWidth=2,s+=(i+=s===n?-.5:.5)===(r+=s===n?1.5:.5)?-.5:.5,n+=i===r?1.5:.5;break;case"thick":t.lineWidth=3,s===n&&(i--,r++),i===r&&(s--,n++);break;case"dashed":t.lineWidth=1,t.setLineDash([1,3]);break;case"dotted":t.lineWidth=1,s===n&&(i+=.5,r+=.5),i===r&&(s+=.5,n+=.5),t.setLineDash([1,1]);break;default:t.lineWidth=1}t.beginPath(),t.moveTo(i,s),t.lineTo(r,n),t.stroke(),t.lineWidth=1,t.setLineDash([])}}drawTexts(e){const{ctx:t,thinLineWidth:o}=e;let i;t.textBaseline="top";for(let e of this.boxes)if(e.content){const s=e.style||{},r=e.content.align||"left",n=Li(s);n!==i&&(i=n,t.font=n),t.fillStyle=s.textColor||"#000";let a=e.x;if(a+="left"===r?z+(e.image?e.image.size+B:0):"right"===r?e.width-z-(e.isFilterHeader?20:0):e.width/2,t.textAlign=r,e.clipRect){t.save(),t.beginPath();const{x:o,y:i,width:s,height:r}=e.clipRect;t.rect(o,i,s,r),t.clip()}const l=Pi(s),c=e.content.textLines.length;let h=this.computeTextYCoordinate(e,l,c);for(let i of e.content.textLines){if(t.fillText(i,Math.round(a),Math.round(h)),s.strikethrough||s.underline){const e=Fi(t,i,s);let n=a;"right"===r?n-=e:"center"===r&&(n-=e/2),s.strikethrough&&t.fillRect(n,h+l/2,e,2.6*o),s.underline&&t.fillRect(n,h+l+1,e,1.3*o)}h+=z+l}e.clipRect&&t.restore()}}drawIcon(e){const{ctx:t}=e;for(const e of this.boxes)if(e.image){const o=e.image.image;if(e.image.clipIcon){t.save(),t.beginPath();const{x:o,y:i,width:s,height:r}=e.image.clipIcon;t.rect(o,i,s,r),t.clip()}const i=e.image.size,s=this.computeTextYCoordinate(e,i);t.drawImage(o,e.x+B,s,i,i),e.image.clipIcon&&t.restore()}}computeTextYCoordinate(e,t,o=1){const i=e.y+1,s=Ni(t,o),r=e.height>s+2*z,n=e.verticalAlign||j;if(r){if("middle"===n)return i+(e.height-s)/2;if("bottom"===n)return i+e.height-s-z}return i+z}drawHeaders(e){const{ctx:t,thinLineWidth:o}=e,i=this.getters.getSheetViewVisibleCols(),s=i[0],r=i[i.length-1],n=this.getters.getSheetViewVisibleRows(),a=n[0],l=n[n.length-1],{width:c,height:h}=this.getters.getSheetViewDimensionWithHeaders(),d=this.getters.getSelectedZones(),u=function(e){const t=new Set;for(let o of e)for(let e of ye(o.left,o.right+1))t.add(e);return t}(d),g=function(e){const t=new Set;for(let o of e)for(let e of ye(o.top,o.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 ${Y}`,t.textAlign="center",t.textBaseline="middle",t.lineWidth=o,t.strokeStyle="#333";for(let e=s;e<=r;e++){const o={left:e,right:e,top:0,bottom:f-1},{x:i,width:s}=this.getters.getVisibleRect(o),r=this.getters.doesZonesContainFilter(p,[o]),n=E.has(e),a=u.has(e);t.fillStyle=n?r?T:S:a?r?O:v:r?A:b,t.fillRect(i,0,s,F)}for(let e=a;e<=l;e++){const o={top:e,bottom:e,left:0,right:m-1},{y:i,height:s}=this.getters.getVisibleRect(o),r=this.getters.doesZonesContainFilter(p,[o]),n=w.has(e),a=g.has(e);t.fillStyle=n?r?T:S:a?r?O:v:r?A:b,t.fillRect(0,i,D,s)}t.beginPath(),t.moveTo(D,0),t.lineTo(D,h),t.moveTo(0,F),t.lineTo(c,F),t.strokeStyle="#C0C0C0",t.stroke(),t.beginPath();for(const e of i){const o=this.getters.getColSize(p,e),i=bt(e);t.fillStyle=E.has(e)?"#fff":C;let r=this.getHeaderOffset("COL",s,e);t.fillText(i,r+o/2,13),t.moveTo(r+o,0),t.lineTo(r+o,F)}for(const e of n){const o=this.getters.getRowSize(p,e);t.fillStyle=w.has(e)?"#fff":C;let i=this.getHeaderOffset("ROW",a,e);t.fillText(String(e+1),24,i+o/2),t.moveTo(0,i+o),t.lineTo(D,i+o)}t.stroke()}drawFrozenPanesHeaders(e){const{ctx:t,thinLineWidth:o}=e,{x:i,y:s}=this.getters.getMainViewportCoordinates(),r=this.getters.isDashboard()?0:D,n=this.getters.isDashboard()?0:F;t.lineWidth=6*o,t.strokeStyle="#BCBCBC",t.beginPath(),i&&(t.moveTo(r+i,0),t.lineTo(r+i,n)),s&&(t.moveTo(0,n+s),t.lineTo(r,n+s)),t.stroke()}drawFrozenPanes(e){const{ctx:t,thinLineWidth:o}=e,{x:i,y:s}=this.getters.getMainViewportCoordinates(),r=this.getters.getSheetViewVisibleCols(),n=r[0],a=r[r.length-1],l=this.getters.getSheetViewVisibleRows(),c={left:n,right:a,top:l[0],bottom:l[l.length-1]},h=this.getters.getVisibleRect(c),d=this.getters.isDashboard()?0:D,u=this.getters.isDashboard()?0:F;t.lineWidth=6*o,t.strokeStyle="#DADFE8",t.beginPath(),i&&(t.moveTo(d+i,u),t.lineTo(d+i,h.height+u)),s&&(t.moveTo(d,u+s),t.lineTo(h.width+d,u+s)),t.stroke()}findNextEmptyCol(e,t,o){const i=this.getters.getActiveSheetId();let s=e;for(;s<t;){const e={sheetId:i,col:s+1,row:o},t=this.getters.getEvaluatedCell(e),r=this.getters.getCellBorderWithFilterBorder(e);if(t.type!==ls.empty||this.getters.isInMerge(e)||r?.left)return s;s++}return s}findPreviousEmptyCol(e,t,o){const i=this.getters.getActiveSheetId();let s=e;for(;s>t;){const e={sheetId:i,col:s-1,row:o},t=this.getters.getEvaluatedCell(e),r=this.getters.getCellBorderWithFilterBorder(e);if(t.type!==ls.empty||this.getters.isInMerge(e)||r?.right)return s;s--}return s}computeCellAlignment(e,t){if(this.getters.getCell(e)?.isFormula&&this.getters.shouldShowFormulas())return"left";const{align:o}=this.getters.getCellStyle(e),i=this.getters.getEvaluatedCell(e);return t&&i.type===ls.number?"center"!==o?"left":o:o||i.defaultAlign}createZoneBox(e,t,o){const{left:i,right:s}=o,r=t.left,n=t.top,a={sheetId:e,col:r,row:n},c=this.getters.getEvaluatedCell(a),h=this.getters.shouldShowFormulas(),{x:d,y:u,width:g,height:p}=this.getters.getVisibleRect(t),{verticalAlign:m}=this.getters.getCellStyle(a),f={x:d,y:u,width:g,height:p,border:this.getters.getCellBorderWithFilterBorder(a)||void 0,style:this.getters.getCellComputedStyle(a),verticalAlign:m};if(c.type===ls.empty)return f;const b=this.getters.getConditionalIcon(a),v=Pi(f.style),S=b?B+v:0;b&&(f.image={type:"icon",size:v,clipIcon:{x:f.x,y:f.y,width:Math.min(S,g),height:p},image:vv[b].img}),f.isFilterHeader=this.getters.isFilterHeader(a);const C=f.isFilterHeader?19:0,E=this.getters.getCellComputedStyle(a),w=E.wrapping||"overflow",x="wrap"!==w||h?void 0:g-2*z,y=this.getters.getCellMultiLineText(a,x),I=Math.max(...y.map((e=>this.getters.getTextWidth(e,E)+z))),R=S+I+C,T=this.computeCellAlignment(a,R>g);f.content={textLines:y,width:"overflow"===w?I:g,align:T},c.type===ls.error&&c.error.logLevel>l.silent&&(f.error=c.error.message);const A=R>g||v>p;if(b||f.isFilterHeader)f.clipRect={x:f.x+S,y:f.y,width:Math.max(0,g-S-C),height:p};else if(A&&"overflow"===w){let e,o;switch(this.getters.isInMerge(a)?(e=this.getters.getMerge(a).right,o=r):(e=this.findNextEmptyCol(r,s,n),o=this.findPreviousEmptyCol(r,i,n),f.isOverflow=!0),T){case"left":{const o=wi({col:e,row:n}),{x:i,y:s,width:r,height:a}=this.getters.getVisibleRect(li(t,o));(r<R||v>a||y.length>1)&&(f.clipRect={x:i,y:s,width:r,height:a});break}case"right":{const e=wi({col:o,row:n}),{x:i,y:s,width:r,height:a}=this.getters.getVisibleRect(li(t,e));(r<R||v>a||y.length>1)&&(f.clipRect={x:i,y:s,width:r,height:a});break}case"center":{const i={...t,left:o,right:e},{x:s,y:r,height:n,width:a}=this.getters.getVisibleRect(i),l=R/2,c=f.x+f.width/2;if(s+a<c+l||s>c-l||v>n||y.length>1){const e=s>c-l?s:c-l,t=s+a-e;f.clipRect={x:e,y:r,width:t,height:n}}break}}}else("clip"===w||"wrap"===w||y.length>1)&&(f.clipRect={x:f.x,y:f.y,width:g,height:p});return f}getGridBoxes(){const e=[],t=this.getters.getSheetViewVisibleCols(),o=t[0],i=t[t.length-1],s=this.getters.getSheetViewVisibleRows(),r={left:o,right:i,top:s[0],bottom:s[s.length-1]},n=this.getters.getActiveSheetId();for(const o of s)for(const i of t){const t={sheetId:n,col:i,row:o};this.getters.isInMerge(t)||e.push(this.createZoneBox(n,wi(t),r))}for(const t of this.getters.getMerges(n))if(!this.getters.isMergeHidden(n,t)&&di(t,r)){const o=this.createZoneBox(n,t,r),i=this.getters.getCellBorder({sheetId:n,col:t.right,row:t.bottom});o.border={...o.border,bottom:i?i.bottom:void 0,right:i?i.right:void 0},o.isMerge=!0,e.push(o)}return e}}).add("autofill",class extends sw{static layers=[5];static getters=["getAutofillTooltip"];autofillZone;steps;lastCellSelected={};direction;tooltip;allowDispatch(e){switch(e.type){case"AUTOFILL_SELECT":const t=this.getters.getActiveSheetId();return this.lastCellSelected.col=-1===e.col?this.lastCellSelected.col:xe(e.col,0,this.getters.getNumberCols(t)),this.lastCellSelected.row=-1===e.row?this.lastCellSelected.row:xe(e.row,0,this.getters.getNumberRows(t)),void 0!==this.lastCellSelected.col&&void 0!==this.lastCellSelected.row?0:48;case"AUTOFILL_AUTO":const o=this.getters.getSelectedZone();return o.top===o.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}),this.autofillCF(e.originCol,e.originRow,e.col,e.row)}}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(),o=this.autofillZone;switch(this.direction){case"down":for(let i=t.left;i<=t.right;i++){const s=[];for(let e=t.top;e<=t.bottom;e++)s.push(xt(i,e));const r=this.createGenerator(s);for(let t=o.top;t<=o.bottom;t++)this.computeNewCell(r,i,t,e)}break;case"up":for(let i=t.left;i<=t.right;i++){const s=[];for(let e=t.bottom;e>=t.top;e--)s.push(xt(i,e));const r=this.createGenerator(s);for(let t=o.bottom;t>=o.top;t--)this.computeNewCell(r,i,t,e)}break;case"left":for(let i=t.top;i<=t.bottom;i++){const s=[];for(let e=t.right;e>=t.left;e--)s.push(xt(e,i));const r=this.createGenerator(s);for(let t=o.right;t>=o.left;t--)this.computeNewCell(r,t,i,e)}break;case"right":for(let i=t.top;i<=t.bottom;i++){const s=[];for(let e=t.left;e<=t.right;e++)s.push(xt(e,i));const r=this.createGenerator(s);for(let t=o.left;t<=o.right;t++)this.computeNewCell(r,t,i,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 o=this.getters.getSelectedZone();if(ui(e,t,o))this.autofillZone=void 0;else{switch(this.direction=this.getDirection(e,t),this.direction){case"up":this.saveZone(t,o.top-1,o.left,o.right),this.steps=o.top-t;break;case"down":this.saveZone(o.bottom+1,t,o.left,o.right),this.steps=t-o.bottom;break;case"left":this.saveZone(o.top,o.bottom,e,o.left-1),this.steps=o.left-e;break;case"right":this.saveZone(o.top,o.bottom,o.right+1,e),this.steps=e-o.right}this.autofill(!1)}}autofillAuto(){const e=this.getters.getSelectedZone(),t=this.getters.getActiveSheetId();let o=e.left,i=e.bottom;if(o>0){let e={sheetId:t,col:o-1,row:i};for(;this.getters.getCorrespondingFormulaCell(e)||this.getters.getCell(e)?.content;)i+=1,e={sheetId:t,col:o-1,row:i}}if(i===e.bottom&&(o=e.right,o<=this.getters.getNumberCols(t))){let e={sheetId:t,col:o+1,row:i};for(;this.getters.getCorrespondingFormulaCell(e)||this.getters.getCell(e)?.content;)i+=1,e={sheetId:t,col:o+1,row:i}}i!==e.bottom&&(this.select(e.left,i-1),this.autofill(!0))}computeNewCell(e,t,o,i){const{cellData:s,tooltip:r,origin:n}=e.next(),{content:a,style:l,border:c,format:h}=s;this.tooltip=r,i&&this.dispatch("AUTOFILL_CELL",{originCol:n.col,originRow:n.row,col:t,row:o,content:a,style:l,border:c,format:h})}getRule(e,t){const o=dr.getAll().sort(((e,t)=>e.sequence-t.sequence)).find((o=>o.condition(e,t)));return o&&o.generateRule(e,t)}createGenerator(e){const t=[],o=[],i=this.getters.getActiveSheetId();for(let t of e){const{col:e,row:s}=wt(t),r=this.getters.getCell({sheetId:i,col:e,row:s});o.push({col:e,row:s,cell:r,sheetId:i})}const s=o.map((e=>e.cell));for(let e of o){let o={type:"COPY_MODIFIER"};if(e&&e.cell){o=this.getRule(e.cell,s)||o}const i=this.getters.getCellBorder(e)||void 0;t.push({data:{...e,border:i},rule:o})}return new Lw(t,this.getters,this.direction)}saveZone(e,t,o,i){this.autofillZone={top:e,bottom:t,left:o,right:i}}getDirection(e,t){const o=this.getters.getSelectedZone(),i={up:{number:o.top-t,value:"up"},down:{number:t-o.bottom,value:"down"},left:{number:o.left-e,value:"left"},right:{number:e-o.right,value:"right"}};if(1===Object.values(i).map((e=>e.number>0?1:0)).reduce(((e,t)=>e+t)))return Object.values(i).find((e=>e.number>0?1:0)).value;const s=i.up.number>0?"up":"down",r=i.left.number>0?"left":"right";return Math.abs(i[s].number)>=Math.abs(i[r].number)?i[s].value:i[r].value}autoFillMerge(e,t,o,i){const s=this.getters.getActiveSheetId(),r={sheetId:s,col:o,row:i},n={sheetId:s,col:e,row:t};if(this.getters.isInMerge(r)&&!this.getters.isInMerge(n)){const e=this.getters.getMerge(r);e&&this.dispatch("REMOVE_MERGE",{sheetId:s,target:[e]})}const a=this.getters.getMerge(n);a?.topLeft.col===e&&a?.topLeft.row===t&&this.dispatch("ADD_MERGE",{sheetId:s,target:[{top:i,bottom:i+a.bottom-a.top,left:o,right:o+a.right-a.left}]})}autofillCF(e,t,o,i){const s=this.getters.getActiveSheetId(),r=this.getters.getRulesByCell(s,e,t);for(const e of r){const t=this.getters.getAdaptedCfRanges(s,e,[xt(o,i)],[]);t&&this.dispatch("ADD_CONDITIONAL_FORMAT",{cf:Ce(e),ranges:t.map((e=>this.getters.getRangeDataFromXc(s,e))),sheetId:s})}}drawGrid(e){if(!this.autofillZone)return;const{ctx:t,thinLineWidth:o}=e,{x:i,y:s,width:r,height:n}=this.getters.getVisibleRect(this.autofillZone);r>0&&n>0&&(t.strokeStyle="black",t.lineWidth=o,t.setLineDash([3]),t.strokeRect(i,s,r,n),t.setLineDash([]))}}).add("find_and_replace",class extends sw{static layers=[3];static getters=["getSearchMatches","getCurrentSelectedMatchIndex"];searchMatches=[];selectedMatchIndex=null;currentSearchRegex=null;searchOptions={matchCase:!1,exactMatch:!1,searchFormulas:!1};toSearch="";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(Zw.previous);break;case"SELECT_SEARCH_NEXT_MATCH":this.selectNextCell(Zw.next);break;case"REPLACE_SEARCH":this.replace(e.replaceWith);break;case"REPLACE_ALL_SEARCH":this.replaceAll(e.replaceWith);break;case"UNDO":case"REDO":case"REMOVE_FILTER_TABLE":case"UPDATE_FILTER":case"REMOVE_COLUMNS_ROWS":case"HIDE_COLUMNS_ROWS":case"UNHIDE_COLUMNS_ROWS":case"ADD_COLUMNS_ROWS":case"EVALUATE_CELLS":case"UPDATE_CELL":this.isSearchDirty=!0;break;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(Zw.current)}updateRegex(){let e=Se(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),o=[];if(this.toSearch)for(const i of Object.values(t)){const{col:t,row:s}=this.getters.getCellPosition(i.id),r=this.getters.isColHidden(e,t),n=this.getters.isRowHidden(e,s);if(!r&&!n&&(i&&this.currentSearchRegex&&this.currentSearchRegex.test(this.getSearchableString({sheetId:e,col:t,row:s})))){const e={col:t,row:s,selected:!1};o.push(e)}}return o.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 o;o=null===this.selectedMatchIndex?0:this.selectedMatchIndex+e,o=(o%t.length+t.length)%t.length,this.selectedMatchIndex=o,this.selection.selectCell(t[o].col,t[o].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}}replaceMatch(e,t){if(!this.currentSearchRegex)return;const o=this.getters.getActiveSheetId(),i=this.getters.getCell({sheetId:o,...e}),{col:s,row:r}=e;if(i?.isFormula&&!this.searchOptions.searchFormulas)return;const n=new RegExp(this.currentSearchRegex.source,this.currentSearchRegex.flags+"g"),a=bg(this.getSearchableString({sheetId:o,col:s,row:r}).replace(n,t),this.getters.getLocale());this.dispatch("UPDATE_CELL",{sheetId:o,col:s,row:r,content:a})}replace(e){if(null===this.selectedMatchIndex)return;const t=this.searchMatches[this.selectedMatchIndex];this.replaceMatch(t,e),this.selectNextCell(Zw.next)}replaceAll(e){const t=this.searchMatches.length;for(let o=0;o<t;o++)this.replaceMatch(this.searchMatches[o],e)}getSearchableString(e){return this.getters.getCellText(e,this.searchOptions.searchFormulas)}drawGrid(e){const{ctx:t}=e,o=this.getters.getActiveSheetId();for(const e of this.searchMatches){const i=this.getters.getMerge({sheetId:o,col:e.col,row:e.row}),s=i?i.left:e.col,r=i?i.right:e.col,n=i?i.top:e.row,a=i?i.bottom:e.row,{x:l,y:c,width:h,height:d}=this.getters.getVisibleRect({top:n,left:s,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)))}}}).add("sort",class extends sw{static getters=["getContiguousZone"];allowDispatch(e){if("SORT_CELLS"===e.type){if(!ui(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;return vi(t).some((({col:t,row:o})=>!this.getters.isInMerge({sheetId:e,col:t,row:o})))?66:0}checkMergeSizes({sheetId:e,zone:t}){if(!this.getters.doesIntersectMerge(e,t))return 0;const o=this.getters.getMerges(e).filter((e=>di(e,t))),i=fi(o[0]);let[s,r]=[i.numberOfCols,i.numberOfRows];return o.every((e=>{let[t,o]=[e.right-e.left+1,e.bottom-e.top+1];return t===s&&o===r}))?0:66}expand(e,t){const{left:o,right:i,top:s,bottom:r}=this.getters.expandZone(e,t);return{left:Math.max(0,o),right:Math.min(this.getters.getNumberCols(e)-1,i),top:Math.max(0,s),bottom:Math.min(this.getters.getNumberRows(e)-1,r)}}checkExpandedValues(e,t){const o=this.expand(e,t);let i;if(this.getters.doesIntersectMerge(e,o)){const{left:t,right:s,top:r,bottom:n}=o;for(let o=t;o<=s;o++)for(let t=r;t<=n;t++){const{col:s,row:r}=this.getters.getMainCellPosition({sheetId:e,col:o,row:t});if(i=this.getters.getEvaluatedCell({sheetId:e,col:s,row:r}),i.formattedValue)return!0}}else for(let t of this.getters.getEvaluatedCellsInZone(e,o))if(t.formattedValue)return!0;return!1}getContiguousZone(e,t){let o,{top:i,bottom:s,left:r,right:n}=t,a=!1;for(;!a;)a=!0,i>0&&(o=this.checkExpandedValues(e,{left:r-1,right:n+1,top:i-1,bottom:i-1}),o&&(a=!1,i--)),r>0&&(o=this.checkExpandedValues(e,{left:r-1,right:r-1,top:i-1,bottom:s+1}),o&&(a=!1,r--)),n<this.getters.getNumberCols(e)-1&&(o=this.checkExpandedValues(e,{left:n+1,right:n+1,top:i-1,bottom:s+1}),o&&(a=!1,n++)),s<this.getters.getNumberRows(e)-1&&(o=this.checkExpandedValues(e,{left:r-1,right:n+1,top:s+1,bottom:s+1}),o&&(a=!1,s++));return{left:r,right:n,top:i,bottom:s}}hasHeader(e,t){if(1===t[0].length)return!1;let o=t.map((t=>t.map((({col:t,row:o})=>this.getters.getEvaluatedCell({sheetId:e,col:t,row:o}).type))));return o[0][0]===ls.empty&&(o=o.slice(1)),!o.some((e=>e[0]===ls.empty))&&!!o.some((e=>e[1]!==ls.empty&&e[0]!==e[1]))}sortZone(e,t,o,i,s){const[r,n]=this.mainCellsSteps(e,o);let a=this.getters.getMainCellPosition({sheetId:e,col:t.col,row:t.row}).col,l=Object.assign({},o),c=this.mainCells(e,o);!s.sortHeaders&&this.hasHeader(e,c)&&(l.top+=n),c=this.mainCells(e,l);const h=function(e,t,o){const i=e.map(((e,t)=>({index:t,type:e.type,value:e.value})));let s=i.filter((e=>e.type===ls.empty)),r=i.filter((e=>e.type!==ls.empty));o&&(r.push(...s.map((e=>({...e,type:ls.number,value:0})))),s=[]);const n="descending"===t?-1:1;return r.sort(((e,t)=>{let o=If.indexOf(e.type)-If.indexOf(t.type);return 0===o&&(o=e.type===ls.text||e.type===ls.error?e.value.localeCompare(t.value):e.value-t.value),n*o})).concat(s)}(c[a-l.left].map((e=>this.getters.getEvaluatedCell(e))),i,Boolean(s.emptyCellAsZero)),d=h.map((e=>e.index)),[u,g]=[c.length,c[0].length],p=[];for(let e=0;e<u;e++)for(let t=0;t<g;t++){let{col:o,row:i,sheetId:s}=c[e][d[t]];const a=this.getters.getCell({sheetId:s,col:o,row:i});let h=l.left+e*r,u=l.top+t*n,g={sheetId:s,col:h,row:u,content:""};if(a){let e=a.content;if(a.isFormula){const t=u-this.getters.getCellPosition(a.id).row,o=this.getters.createAdaptedRanges(a.dependencies,0,t,s);e=this.getters.buildFormulaContent(s,a,o)}g.style=a.style,g.content=e,g.format=a.format}p.push(g)}p.forEach((e=>this.dispatch("UPDATE_CELL",e)))}mainCellsSteps(e,t){const o=this.getters.getMerge({sheetId:e,col:t.left,row:t.top});return[o?o.right-o.left+1:1,o?o.bottom-o.top+1:1]}mainCells(e,t){const[o,i]=this.mainCellsSteps(e,t),s=[],r=ye(t.left,t.right+1,o),n=ye(t.top,t.bottom+1,i);for(const t of r){const o=[];s.push(o);for(const i of n)o.push({sheetId:e,col:t,row:i})}return s}}).add("automatic_sum",class extends sw{static getters=["getAutomaticSums"];handle(e){if("SUM_SELECTION"===e.type){const e=this.getters.getActiveSheetId(),{zones:t,anchor:o}=this.getters.getSelection();for(const i of t){const t=this.getAutomaticSums(e,i,o.cell);this.dispatchCellUpdates(e,t)}}}getAutomaticSums(e,t,o){return this.shouldFindData(e,t)?this.sumAdjacentData(e,t,o):this.sumData(e,t)}sumData(e,t){const o=this.dimensionsToSum(e,t),i=this.sumDimensions(e,t,o).filter((({zone:t})=>!this.getters.isEmpty(e,t)));return o.has("ROW")&&o.has("COL")&&i.push(this.sumTotal(t)),i}sumAdjacentData(e,t,o){const{col:i,row:s}=ui(o.col,o.row,t)?o:{col:t.left,row:t.top},r=this.findAdjacentData(e,i,s);return r?this.getters.isSingleCellOrMerge(e,t)||bi(li(r,t))?[{position:{col:i,row:s},zone:r}]:this.sumDimensions(e,li(r,t),this.transpose(this.dimensionsToSum(e,t))):[]}findAdjacentData(e,t,o){const i=this.getters.getSheet(e),s=this.getters.getMainCellPosition({sheetId:e,col:t,row:o}),r=this.findSuitableZoneToSum(i,s.col,s.row);if(r)return this.getters.expandZone(e,r)}findSuitableZoneToSum(e,t,o){const i=this.getters.getEvaluatedCell({sheetId:e.id,col:t,row:o-1}),s=this.getters.getEvaluatedCell({sheetId:e.id,col:t-1,row:o});if(this.isNumber(s)&&!this.isNumber(i))return this.findHorizontalZone(e,t,o);const r=this.findVerticalZone(e,t,o);if(this.isZoneValid(r))return r;const n=this.findHorizontalZone(e,t,o);return this.isZoneValid(n)?n:void 0}findVerticalZone(e,t,o){const i={top:0,bottom:o-1,left:t,right:t},s=this.reduceZoneStart(e,i,i.bottom);return{...i,top:s}}findHorizontalZone(e,t,o){const i={top:o,bottom:o,left:0,right:t-1},s=this.reduceZoneStart(e,i,i.right);return{...i,left:s}}reduceZoneStart(e,t,o){const i=this.getters.getEvaluatedCellsInZone(e.id,t),s=ye(o,-1,-1),r=et(s.filter((e=>i[e]&&!i[e].isAutoSummable))),n=Ie(s.filter((e=>this.isNumber(i[e]))))[0]||[];return et(n)<r?1/0:tt(n)}shouldFindData(e,t){return this.getters.isEmpty(e,t)||this.getters.isSingleCellOrMerge(e,t)}isNumber(e){return e.type===ls.number&&!(e.format&&xo(e.format))}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 o=new Set;return bi(t)?(o.add(1===fi(t).numberOfCols?"COL":"ROW"),o):(this.lastColIsEmpty(e,t)&&o.add("ROW"),this.lastRowIsEmpty(e,t)&&o.add("COL"),0===o.size&&o.add("COL"),o)}sumDimensions(e,t,o){return[...o.has("COL")?this.sumColumns(t,e):[],...o.has("ROW")?this.sumRows(t,e):[]]}sumTotal(e){const{bottom:t,right:o}=e;return{position:{col:o,row:t},zone:{...e,top:t,right:o-1}}}sumColumns(e,t){const o=this.nextEmptyRow(t,{...e,bottom:e.bottom-1});return e={...e,bottom:Math.min(e.bottom,o.bottom-1)},vi(o).map((t=>({position:t,zone:{...e,right:t.col,left:t.col}})))}sumRows(e,t){const o=this.nextEmptyCol(t,{...e,right:e.right-1});return e={...e,right:Math.min(e.right,o.right-1)},vi(o).map((t=>({position:t,zone:{...e,top:t.row,bottom:t.row}})))}dispatchCellUpdates(e,t){for(const o of t){const{col:t,row:i}=o.position;this.dispatch("UPDATE_CELL",{sheetId:e,col:t,row:i,content:`=SUM(${this.getters.zoneToXC(e,o.zone)})`})}}nextEmptyRow(e,t){let o=t.bottom+1;const{left:i,right:s}=t;for(;!this.getters.isEmpty(e,{bottom:o,top:o,left:i,right:s});)o++;return{...t,top:o,bottom:o}}nextEmptyCol(e,t){let o=t.right+1;const{top:i,bottom:s}=t;for(;!this.getters.isEmpty(e,{left:o,right:o,top:i,bottom:s});)o++;return{...t,left:o,right:o}}transpose(e){return new Set([...e.values()].map((e=>"COL"===e?"ROW":"COL")))}}).add("format",class extends sw{handle(e){if("SET_DECIMAL"===e.type)this.setDecimal(e.sheetId,e.target,e.step)}setDecimal(e,t,o){for(const i of t)for(const t of vi(i)){const i=this.getCellNumberFormat({sheetId:e,...t});if(void 0!==i){this.getters.getLocale();const s=Lo(i,o);this.dispatch("SET_FORMATTING",{sheetId:e,target:[wi(t)],format:s})}}}getCellNumberFormat(e){for(const t of[e]){const e=this.getters.getEvaluatedCell(t);if(!(e.type!==ls.number||e.format&&xo(e.format)))return e.format||Oo(e.value)}}}).add("split_to_columns",class extends sw{static getters=["getAutomaticSeparator"];allowDispatch(e){return"SPLIT_TEXT_INTO_COLUMNS"===e.type?this.chainValidations(this.batchValidations(this.checkSingleColSelected,this.checkNonEmptySelector),this.batchValidations(this.checkNotOverwritingContent,this.checkSeparatorInSelection))(e):0}handle(e){if("SPLIT_TEXT_INTO_COLUMNS"===e.type)this.splitIntoColumns(e)}getAutomaticSeparator(){const e=this.getters.getSelectedCells();for(const t of e)if(t.value&&t.type===ls.text){const e=this.getAutoSeparatorForString(t.value);if(e)return e}return" "}getAutoSeparatorForString(e){const t=[fe,";",","," ","."];for(const o of t)if(e.includes(o))return o}splitIntoColumns({separator:e,addNewColumns:t}){const o=this.getters.getSelectedZone(),i=this.getters.getActiveSheetId(),s=this.getSplittedCols(o,e);t&&this.addColsToAvoidCollisions(o,s),this.removeMergesInSplitZone(o,s),this.addColumnsToNotOverflowSheet(o,s);for(let e=0;e<s.length;e++){const t=o.top+e,r=s[e],n=o.left,a=this.getters.getCell({sheetId:i,col:n,row:t});if(1!==r.length||r[0]!==a?.content)for(const[e,o]of r.entries())this.dispatch("UPDATE_CELL",{sheetId:i,col:n+e,row:t,content:bg(o,this.getters.getLocale()),format:"",style:a?.style||null})}}getSplittedCols(e,t){if(!t)throw new Error("Separator cannot be empty");const o=this.getters.getActiveSheetId(),i=[];for(const s of ye(e.top,e.bottom+1)){const r=this.getters.getEvaluatedCell({sheetId:o,col:e.left,row:s}).formattedValue;i.push(this.splitAndRemoveTrailingEmpty(r,t))}return i}splitAndRemoveTrailingEmpty(e,t){const o=e.split(t);for(;o.length>1&&""===o[o.length-1];)o.pop();return o}willSplittedColsOverwriteContent(e,t){const o=this.getters.getActiveSheetId();for(const i of ye(e.top,e.bottom+1)){const s=t[i-e.top];for(let t=1;t<s.length;t++){const s=this.getters.getCell({sheetId:o,col:e.left+t,row:i});if(s&&s.content)return!0}}return!1}removeMergesInSplitZone(e,t){const o=this.getters.getActiveSheetId(),i=Math.max(...t.map((e=>e.length))),s={...e,right:e.left+i-1},r=this.getters.getMergesInZone(o,s);this.dispatch("REMOVE_MERGE",{sheetId:o,target:r})}addColsToAvoidCollisions(e,t){const o=this.getters.getActiveSheetId();let i=0;for(const s of ye(e.top,e.bottom+1)){const r={sheetId:o,col:e.left,row:s},n=t[s-e.top],a=this.getColsToAddToAvoidCollision(r,n);i=Math.max(i,a)}i&&this.dispatch("ADD_COLUMNS_ROWS",{dimension:"COL",base:e.left,sheetId:o,quantity:i,position:"after"})}getColsToAddToAvoidCollision(e,t){const o=t.length;for(let t=1;t<o;t++){const i=e.col+t,s=this.getters.getCell({...e,col:i});if(s&&s.content)return o-t}return 0}addColumnsToNotOverflowSheet(e,t){const o=this.getters.getActiveSheetId(),i=Math.max(...t.map((e=>e.length-1))),s=this.getters.getNumberCols(o)-1;e.left+i>s&&this.dispatch("ADD_COLUMNS_ROWS",{dimension:"COL",base:s,sheetId:o,quantity:e.left+i-s,position:"after"})}checkSingleColSelected(){return this.getters.isSingleColSelected()?0:91}checkNonEmptySelector(e){return""===e.separator?92:0}checkNotOverwritingContent(e){if(e.addNewColumns||e.force)return 0;const t=this.getters.getSelectedZones()[0],o=this.getSplittedCols(t,e.separator);return this.willSplittedColsOverwriteContent(t,o)?93:0}checkSeparatorInSelection({separator:e}){const t=this.getters.getSelectedCells();for(const o of t)if(o.formattedValue.includes(e))return 0;return 94}}).add("cell_popovers",class extends sw{static getters=["getCellPopover","getPersistentPopoverTypeAtPosition","hasOpenedPopover"];persistentPopover;allowDispatch(e){if("OPEN_CELL_POPOVER"===e.type){try{Hg.get(e.popoverType)}catch(e){return 75}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,sheetId:this.getters.getActiveSheetId(),type:e.popoverType}}}getCellPopover({col:e,row:t}){const o=this.getters.getActiveSheetId();if(this.persistentPopover&&this.getters.isVisibleInViewport(this.persistentPopover)){const e=this.getters.getMainCellPosition(this.persistentPopover),t=Hg.get(this.persistentPopover.type).onOpen?.(e,this.getters);return t?.isOpen?{...t,anchorRect:this.computePopoverAnchorRect(this.persistentPopover)}:{isOpen:!1}}if(void 0===e||void 0===t||!this.getters.isVisibleInViewport({sheetId:o,col:e,row:t}))return{isOpen:!1};const i=this.getters.getMainCellPosition({sheetId:o,col:e,row:t}),s=Hg.getAll().map((e=>e.onHover?.(i,this.getters))).find((e=>e?.isOpen));return s?.isOpen?{...s,anchorRect:this.computePopoverAnchorRect(i)}:{isOpen:!1}}hasOpenedPopover(){return void 0!==this.persistentPopover}getPersistentPopoverTypeAtPosition({col:e,row:t}){if(this.persistentPopover&&this.persistentPopover.col===e&&this.persistentPopover.row===t)return this.persistentPopover.type}computePopoverAnchorRect({col:e,row:t}){const o=this.getters.getActiveSheetId(),i=this.getters.getMerge({sheetId:o,col:e,row:t});return i?this.getters.getVisibleRect(i):this.getters.getVisibleRect(wi({col:e,row:t}))}}).add("collaborative",class extends sw{static getters=["getClientsToDisplay","getClient","getConnectedClients","isFullySynchronized"];static layers=[6];availableColors=new Set(qw);colors={};session;constructor(e){super(e),this.session=e.session}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(qw));const e=(t=[...this.availableColors.values()])[Math.floor(Math.random()*t.length)];var t;return this.availableColors.delete(e),e}getClient(){return this.session.getClient()}getConnectedClients(){return this.session.getConnectedClients()}isFullySynchronized(){return this.session.isFullySynchronized()}getClientsToDisplay(){try{this.getters.getClient()}catch(e){if(e instanceof Ww)return[];throw e}const e=this.getters.getActiveSheetId(),t=[];for(const o of this.getters.getConnectedClients())if(o.id!==this.getters.getClient().id&&o.position&&o.position.sheetId===e&&this.isPositionValid(o.position)){const e=o.position;this.colors[o.id]||(this.colors[o.id]=this.chooseNewColor());const i=this.colors[o.id];t.push({...o,position:e,color:i})}return t}drawGrid(e){if(this.getters.isDashboard())return;const{ctx:t,thinLineWidth:o}=e,i=this.getters.getActiveSheetId();for(const e of this.getClientsToDisplay()){const{row:s,col:r}=e.position,n=this.getters.expandZone(i,{top:s,bottom:s,left:r,right:r}),{x:a,y:l,width:c,height:h}=this.getters.getVisibleRect(n);if(c<=0||h<=0)continue;const d=e.color,u=`${d}10`;t.fillStyle=u,t.lineWidth=4*o,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 ${Z+1}px ${Y}`}}}).add("history",class extends sw{static getters=["canUndo","canRedo"];undoStack=[];redoStack=[];session;constructor(e){super(e),this.session=e.session,this.session.on("new-local-state-update",this,this.onNewLocalStateUpdate),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}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();if(t)"UNDO"===e?(this.session.undo(t),this.redoStack.push(t)):(this.session.redo(t),this.undoStack.push(t));else{const e=this.getPossibleRevisionToRepeat();if(!e)return;const t=rx(e,this.getters);if(!t)return;if(!Array.isArray(t))return void this.dispatch(t.type,t);for(const e of t)this.dispatch(e.type,e)}}canUndo(){return this.undoStack.length>0}canRedo(){if(this.redoStack.length>0)return!0;const e=this.getPossibleRevisionToRepeat();return!(!(t=e)||!t.rootCommand||"object"!=typeof t.rootCommand)&&(ms(t.rootCommand)?tx.contains(t.rootCommand.type):ox.contains(t.rootCommand.type));var t}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()}getPossibleRevisionToRepeat(){return this.session.getLastLocalNonEmptyRevision(["REQUEST_REDO"])}}),Ex=(new Ji).add("selection",class extends sw{static layers=[6];static getters=["getActiveSheet","getActiveSheetId","getActiveCell","getActiveCols","getActiveRows","getCurrentStyle","getSelectedZones","getSelectedZone","getSelectedCells","getStatisticFnResults","getAggregate","getSelectedFigureId","getSelection","getActivePosition","getSheetPosition","isSelected","isSingleColSelected","getElementsFromSelection","tryGetActiveSheetId","isGridSelectionActive"];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}]};selectedFigureId=null;sheetsData={};moveClient;activeSheet=null;constructor(e){super(e),this.moveClient=e.moveClient}allowDispatch(e){switch(e.type){case"ACTIVATE_SHEET":try{this.getters.getSheet(e.sheetIdTo);break}catch(e){return 28}case"MOVE_COLUMNS_ROWS":return this.isMoveElementAllowed(e)}return 0}handleEvent(e){const t=e.anchor;let o=[];switch(e.mode){case"overrideSelection":o=[t.zone];break;case"updateAnchor":o=[...this.gridSelection.zones];const i=o.findIndex((t=>hi(t,e.previousAnchor.zone)));i>=0&&(o[i]=t.zone);break;case"newAnchor":o=[...this.gridSelection.zones,t.zone]}this.setSelectionMixin(e.anchor,o),this.selection.resetDefaultAnchor(this,Ce(this.gridSelection.anchor));const{col:i,row:s}=this.gridSelection.anchor.cell;this.moveClient({sheetId:this.getters.getActiveSheetId(),col:i,row:s}),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:o,row:i}=this.getters.getNextVisibleCellPosition({sheetId:t,col:0,row:0});this.selectCell(o,i),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:Ce(this.gridSelection)},e.sheetIdTo in this.sheetsData)Object.assign(this,this.sheetsData[e.sheetIdTo]),this.selection.resetDefaultAnchor(this,Ce(this.gridSelection.anchor));else{const{col:t,row:o}=this.getters.getNextVisibleCellPosition({sheetId:e.sheetIdTo,col:0,row:0});this.selectCell(t,o)}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:o,row:i}=this.gridSelection.anchor.cell;this.moveClient({sheetId:t,col:o,row:i})}break}case"ADD_COLUMNS_ROWS":{const t=this.getters.getActiveSheetId();if(e.sheetId===t){this.onAddElements(e);const{col:o,row:i}=this.gridSelection.anchor.cell;this.moveClient({sheetId:t,col:o,row:i})}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 s=Object.keys(this.sheetsData).filter((e=>!this.getters.tryGetSheet(e)));for(const e of s)delete this.sheetsData[e];for(const e in this.sheetsData){const t=this.clipSelection(e,this.sheetsData[e].gridSelection);this.sheetsData[e]={gridSelection:Ce(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:o}=this.gridSelection.anchor.cell;this.moveClient({sheetId:this.getters.getActiveSheetId(),col:t,row:o})}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.selectedFigureId=null}this.selection.resetDefaultAnchor(this,Ce(this.gridSelection.anchor))}isGridSelectionActive(){return this.selection.isListening(this)}getActiveSheet(){return this.activeSheet}getActiveSheetId(){return this.activeSheet.id}tryGetActiveSheetId(){return this.activeSheet?.id}getActiveCell(){return this.getters.getEvaluatedCell(this.getActivePosition())}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 o=t.left;o<=t.right;o++)e.add(o);return e}getActiveRows(){const e=new Set,t=this.getters.getActiveSheetId();for(let o of this.gridSelection.zones)if(0===o.left&&o.right===this.getters.getNumberCols(t)-1)for(let t=o.top;t<=o.bottom;t++)e.add(t);return e}getCurrentStyle(){const e=this.getters.getSelectedZone(),t=this.getters.getActiveSheetId();return this.getters.getCellStyle({sheetId:t,col:e.left,row:e.top})}getSelectedZones(){return Ce(this.gridSelection.zones)}getSelectedZone(){return Ce(this.gridSelection.anchor.zone)}getSelection(){return Ce(this.gridSelection)}getSelectedCells(){const e=this.getters.getActiveSheetId(),t=[];for(const o of this.gridSelection.zones)t.push(...this.getters.getEvaluatedCellsInZone(e,o));return t}getSelectedFigureId(){return this.selectedFigureId}getActivePosition(){return this.getters.getMainCellPosition({sheetId:this.getActiveSheetId(),col:this.gridSelection.anchor.cell.col,row:this.gridSelection.anchor.cell.row})}getSheetPosition(e){if(e===this.getters.getActiveSheetId())return this.getActivePosition();{const t=this.sheetsData[e];return t?{sheetId:e,col:t.gridSelection.anchor.cell.col,row:t.gridSelection.anchor.cell.row}:this.getters.getNextVisibleCellPosition({sheetId:e,col:0,row:0})}}getStatisticFnResults(){const e=this.getters.getActiveSheetId(),t=new Set;for(const o of this.gridSelection.zones)for(const{col:i,row:s}of vi(o)){if(this.getters.isRowHidden(e,s)||this.getters.isColHidden(e,i))continue;const o=this.getters.getEvaluatedCell({sheetId:e,col:i,row:s});o.type!==ls.empty&&t.add(o)}let o=new Set,i=[];for(let e of t)o.add(e.type),i.push(e.value);const s=this.getters.getLocale();let r={};for(let e of bx){let t;e.types.some((e=>o.has(e)))&&(t=e.compute(i,s)),r[e.name]=t}return r}getAggregate(){let e=0,t=0;const o=this.getters.getActiveSheetId(),i=this.gridSelection.zones.map(vi).flat();for(const{col:s,row:r}of i){const i=this.getters.getEvaluatedCell({sheetId:o,col:s,row:r});i.type===ls.number&&(t++,e+=i.value)}const s=this.getters.getLocale();return t<2?null:fo(e,{locale:s})}isSelected(e){return!!this.getters.getSelectedZones().find((t=>hi(t,e)))}isSingleColSelected(){const e=this.getters.getSelectedZones();return 1===e.length&&e[0].left===e[0].right}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 o=[];const i="COL"===e?"left":"top",s="COL"===e?"right":"bottom";for(const e of t){const t=Array.from({length:e[s]-e[i]+1},((t,o)=>e[i]+o));o=o.concat(t)}return[...new Set(o)].sort()}setSelectionMixin(e,t){const{anchor:o,zones:i}=this.clipSelection(this.getters.getActiveSheetId(),{anchor:e,zones:t});this.gridSelection.anchor=o,this.gridSelection.zones=function(e){return e.reverse().filter(((e,t,o)=>t===o.findIndex((t=>t.top===e.top&&t.bottom===e.bottom&&t.left===e.left&&t.right===e.right)))).reverse()}(i)}selectCell(e,t){const o=this.getters.getActiveSheetId(),i=this.getters.expandZone(o,{left:e,right:e,top:t,bottom:t});this.setSelectionMixin({zone:i,cell:{col:e,row:t}},[i])}setActiveSheet(e){const t=this.getters.getSheet(e);this.activeSheet=t}activateNextSheet(e){const t=this.getters.getSheetIds(),o=(t.findIndex((e=>e===this.activeSheet.id))+("left"===e?t.length-1:1))%t.length;this.dispatch("ACTIVATE_SHEET",{sheetIdFrom:this.getActiveSheetId(),sheetIdTo:t[o]})}onColumnsRemoved(e){const{cell:t,zone:o}=this.gridSelection.anchor,i=ni(o,"left",[...e.elements]);let s={left:t.col,right:t.col,top:t.row,bottom:t.row};s=ni(s,"left",[...e.elements]);const r={cell:{col:s.left,row:s.top},zone:i},n=this.gridSelection.zones.map((t=>ni(t,"left",[...e.elements])));this.setSelectionMixin(r,n)}onRowsRemoved(e){const{cell:t,zone:o}=this.gridSelection.anchor,i=ni(o,"top",[...e.elements]);let s={left:t.col,right:t.col,top:t.row,bottom:t.row};s=ni(s,"top",[...e.elements]);const r={cell:{col:s.left,row:s.top},zone:i},n=this.gridSelection.zones.map((t=>ni(t,"top",[...e.elements])));this.setSelectionMixin(r,n)}onAddElements(e){const t="COL"===e.dimension?"left":"top",o=ri(this.gridSelection.anchor.zone,t,e.base,e.position,e.quantity),i=this.gridSelection.zones.map((o=>ri(o,t,e.base,e.position,e.quantity))),s={cell:{col:o.left,row:o.top},zone:o};this.setSelectionMixin(s,i)}onMoveElements(e){const t=e.elements.length;this.dispatch("ADD_COLUMNS_ROWS",{dimension:e.dimension,sheetId:e.sheetId,base:e.base,quantity:t,position:e.position});const o="COL"===e.dimension,i=e.elements[0],s=e.elements[t-1],r=e.base<i,n=r&&o?t:0,a=r&&!o?t:0,l=[{left:o?i+n:0,right:o?s+n:this.getters.getNumberCols(e.sheetId)-1,top:o?0:i+a,bottom:o?this.getters.getNumberRows(e.sheetId)-1:s+a}],c=new ax(l,"CUT",this.getters,this.dispatch,this.selection),h=r?e.base:e.base+1,d=[{left:o?h:0,right:o?h+t-1:this.getters.getNumberCols(e.sheetId)-1,top:o?0:h,bottom:o?this.getters.getNumberRows(e.sheetId)-1:h+t-1}];c.paste(d,{selectTarget:!0});const u=r?e.elements.map((e=>e+t)):e.elements;let g=e.base;for(const t of u){const o="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:o,elements:[g]}),g+=1}this.dispatch("REMOVE_COLUMNS_ROWS",{dimension:e.dimension,sheetId:e.sheetId,elements:u})}isMoveElementAllowed(e){const t="COL"===e.dimension,o=e.elements[0],i=e.elements[e.elements.length-1],s=e.sheetId,r=t?this.getters.doesColumnsHaveCommonMerges:this.getters.doesRowsHaveCommonMerges;if(r(s,o-1,o)||r(s,i,i+1)||r(s,e.base-1,e.base))return 2;const n=[e.base,...e.elements],a=t?this.getters.getNumberCols(s):this.getters.getNumberRows(s);return n.some((e=>e<0||e>=a))?89:0}clipSelection(e,t){const o=this.getters.getNumberCols(e)-1,i=this.getters.getNumberRows(e)-1;return{zones:t.zones.map((e=>({left:xe(e.left,0,o),right:xe(e.right,0,o),top:xe(e.top,0,i),bottom:xe(e.bottom,0,i)}))),anchor:{cell:{col:xe(t.anchor.cell.col,0,o),row:xe(t.anchor.cell.row,0,i)},zone:{left:xe(t.anchor.zone.left,0,o),right:xe(t.anchor.zone.right,0,o),top:xe(t.anchor.zone.top,0,i),bottom:xe(t.anchor.zone.bottom,0,i)}}}}drawGrid(e){if(this.getters.isDashboard())return;const{ctx:t,thinLineWidth:o}=e,i=this.getSelectedZones();t.fillStyle="#f3f7fe";const s=1===i.length&&i[0].left===i[0].right&&i[0].top===i[0].bottom;t.fillStyle=s?"#f3f7fe":"#e9f0ff",t.strokeStyle=E,t.lineWidth=1.5*o;for(const e of i){const{x:o,y:i,width:s,height:r}=this.getters.getVisibleRect(e);t.globalCompositeOperation="multiply",t.fillRect(o,i,s,r),t.globalCompositeOperation="source-over",t.strokeRect(o,i,s,r)}t.globalCompositeOperation="source-over";const r=this.getActivePosition();let n;t.strokeStyle=E,t.lineWidth=3*o,n=this.getters.isInMerge(r)?this.getters.getMerge(r):wi(r);const{x:a,y:l,width:c,height:h}=this.getters.getVisibleRect(n);c>0&&h>0&&t.strokeRect(a,l,c,h)}}).add("evaluation_filter",class extends sw{static getters=["getCellBorderWithFilterBorder","getFilterValues","isRowFiltered","isFilterActive"];filterValues={};hiddenRows=new Set;isEvaluationDirty=!1;allowDispatch(e){if("UPDATE_FILTER"===e.type)if(!this.getters.getFilterId(e))return 82;return 0}handle(e){switch(e.type){case"UNDO":case"REDO":case"UPDATE_CELL":case"EVALUATE_CELLS":case"ACTIVATE_SHEET":case"REMOVE_FILTER_TABLE":case"ADD_COLUMNS_ROWS":case"REMOVE_COLUMNS_ROWS":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 o of this.getters.getFilters(e.sheetIdTo)){const i=o.zoneWithHeaders;t[o.id]=this.getFilterValues({sheetId:e.sheetId,col:i.left,row:i.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){const{sheetId:t,col:o,row:i}=e;let s;for(let e of this.getters.getFilterTables(t)){const r=e.zone;if(ui(o,i,r)){const e=this.intersectZoneWithViewport(t,r);s={top:i===e.top?J:void 0,bottom:i===e.bottom?J:void 0,left:o===e.left?J:void 0,right:o===e.right?J:void 0}}}const r=this.getters.getCellBorder(e),n={...s,...qe(r||{})};return Ue(n)?null:n}getFilterValues(e){const t=this.getters.getFilterId(e),o=e.sheetId;return t&&this.filterValues[o]&&this.filterValues[o][t]||[]}isFilterActive(e){const t=this.getters.getFilterId(e),o=e.sheetId;return Boolean(t&&this.filterValues[o]?.[t]?.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:o,sheetId:i}){const s=this.getters.getFilterId({sheetId:i,col:e,row:t});s&&(this.filterValues[i]||(this.filterValues[i]={}),this.filterValues[i][s]=o)}updateHiddenRows(){const e=this.getters.getActiveSheetId(),t=this.getters.getFilters(e).sort(((e,t)=>e.zoneWithHeaders.top-t.zoneWithHeaders.top)),o=new Set;for(let i of t){if(this.getters.isRowHiddenByUser(e,i.zoneWithHeaders.top))continue;if(o.has(i.zoneWithHeaders.top))continue;const t=this.filterValues[e]?.[i.id]?.map(Vi);if(t&&i.filteredZone)for(let s=i.filteredZone.top;s<=i.filteredZone.bottom;s++){const r=this.getCellValueAsString(e,i.col,s);t.includes(r)&&o.add(s)}}this.hiddenRows=o}getCellValueAsString(e,t,o){return this.getters.getEvaluatedCell({sheetId:e,col:t,row:o}).formattedValue.toLowerCase()}exportForExcel(e){for(const t of e.sheets){const e=t.id;for(const o of t.filterTables){const i=ti(o.range),s=[],r=[];for(const o of ye(0,fi(i).numberOfCols)){const n={sheetId:t.id,col:i.left+o,row:i.top},a=this.getFilterValues(n),l=this.getters.getFilter(n);if(!l)continue;const c=l.filteredZone?vi(l.filteredZone).map((t=>this.getters.getEvaluatedCell({sheetId:e,...t}).formattedValue)):[];if(a.length){const e=c.filter((e=>e)).filter((e=>!a.includes(e)));s.push({colId:o,displayedValues:[...new Set(e)],displayBlanks:!a.includes("")&&c.some((e=>!e))})}const h={col:l.col,row:l.zoneWithHeaders.top,sheetId:e},d=this.getters.getEvaluatedCell(h).formattedValue,u=this.getUniqueColNameForExcel(o,d,r);r.push(u),t.cells[xt(h.col,h.row)]={...t.cells[xt(h.col,h.row)],content:u,value:u,isFormula:!1}}o.filters=s}}}getUniqueColNameForExcel(e,t,o){t||(t=`Column${e}`);let i=t,s=2;for(;o.includes(i);)i=t+String(s),s++;return i}}).add("viewport",class extends sw{static getters=["getColIndex","getRowIndex","getActiveMainViewport","getSheetViewDimension","getSheetViewDimensionWithHeaders","getMainViewportRect","isVisibleInViewport","getEdgeScrollCol","getEdgeScrollRow","getVisibleFigures","getVisibleRect","getColRowOffsetInViewport","getMainViewportCoordinates","getActiveSheetScrollInfo","getActiveSheetDOMScrollInfo","getSheetViewVisibleCols","getSheetViewVisibleRows","getFrozenSheetViewRatio","isPositionVisible"];viewports={};sheetViewWidth=me();sheetViewHeight=me();gridOffsetX=0;gridOffsetY=0;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){const t=this.getters.getActiveSheetId();if(e.options.scrollIntoView){let{col:o,row:i}=Ci(e.previousAnchor.zone,e.anchor.zone);if("updateAnchor"===e.mode){const s=e.previousAnchor.zone,r=e.anchor.zone,{top:n,bottom:a,left:l,right:c}=this.getMainInternalViewport(t);s.left===r.left&&s.right===r.right&&(o=l>o||o>c?l:o),s.top===r.top&&s.bottom===r.bottom&&(i=n>i||i>a?n:i)}o=Math.min(o,this.getters.getNumberCols(t)-1),i=Math.min(i,this.getters.getNumberRows(t)-1),this.refreshViewport(this.getters.getActiveSheetId(),{col:o,row:i})}}handle(e){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 t=this.getters.getActiveSheetId(),{top:o,viewportHeight:i,offsetCorrectionY:s}=this.getMainInternalViewport(t),r=this.getters.getRowDimensions(t,o);this.shiftVertically(r.start+i-s);break;case"SHIFT_VIEWPORT_UP":{const e=this.getters.getActiveSheetId(),{top:t,viewportHeight:o,offsetCorrectionY:i}=this.getMainInternalViewport(e),s=this.getters.getRowDimensions(e,t);this.shiftVertically(s.end-i-o);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!==e.style?.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"DELETE_SHEET":this.sheetsWithDirtyViewports.delete(e.sheetId);break;case"START_EDITION":const{col:n,row:a}=this.getters.getActivePosition();this.refreshViewport(this.getters.getActiveSheetId(),{col:n,row:a})}}finalize(){for(const e of this.sheetsWithDirtyViewports)this.resetViewports(e);this.sheetsWithDirtyViewports=new Set,this.setViewports()}setViewports(){const e=this.getters.getSheetIds();for(const t of e)this.viewports[t]?.bottomRight||this.resetViewports(t)}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=>ye(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=>ye(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:o,ySplit:i}=this.getters.getPaneDivisions(e);let{width:s,height:r}=t.getMaxSize();return{x:this.getters.getColDimensions(e,o).start,y:this.getters.getRowDimensions(e,i).start,width:s,height:r}}getMaximumSheetOffset(){const e=this.getters.getActiveSheetId(),{width:t,height:o}=this.getMainViewportRect(),i=this.getMainInternalViewport(e);return{maxOffsetX:Math.max(0,t-i.viewportWidth+1),maxOffsetY:Math.max(0,o-i.viewportHeight+1)}}getColRowOffsetInViewport(e,t,o){const i=this.getters.getActiveSheetId(),s=this.getters.getSheetViewVisibleCols(),r=this.getters.getSheetViewVisibleRows();if(o<t)return-this.getColRowOffsetInViewport(e,o,t);let n=0;const a="COL"===e?s:r;for(let s=t;s<o;s++)a.includes(s)&&(n+="COL"===e?this.getters.getColSize(i,s):this.getters.getRowSize(i,s));return n}isVisibleInViewport({sheetId:e,col:t,row:o}){return this.getSubViewports(e).some((e=>e.isVisible(t,o)))}getEdgeScrollCol(e,t,o){let i=!1,s=0,r=0;const{xSplit:n}=this.getters.getPaneDivisions(this.getters.getActiveSheetId()),{width:a}=this.getSheetViewDimension(),{x:l}=this.getMainViewportCoordinates(),c=this.getActiveSheetScrollInfo().scrollX;return e>a?(i=!0,r=Qt(e-a),s=1):e<l&&o>=l&&c>0?(i=!0,r=Qt(l-e),s=-1):n&&t<l&&e>l&&(i=!0,r=Qt(e),s="reset"),{canEdgeScroll:i,direction:s,delay:r}}getEdgeScrollRow(e,t,o){let i=!1,s=0,r=0;const{ySplit:n}=this.getters.getPaneDivisions(this.getters.getActiveSheetId()),{height:a}=this.getSheetViewDimension(),{y:l}=this.getMainViewportCoordinates(),c=this.getActiveSheetScrollInfo().scrollY;return e>a?(i=!0,r=Qt(e-a),s=1):e<l&&o>=l&&c>0?(i=!0,r=Qt(l-e),s=-1):n&&t<l&&e>l&&(i=!0,r=Qt(e),s="reset"),{canEdgeScroll:i,direction:s,delay:r}}getVisibleRect(e){const t=this.getters.getActiveSheetId(),o=this.getSubViewports(t).map((t=>t.getRect(e))).filter(ke);if(0===o.length)return{x:0,y:0,width:0,height:0};const i=Math.min(...o.map((e=>e.x))),s=Math.min(...o.map((e=>e.y))),r=Math.max(...o.map((e=>e.x+e.width)))-i,n=Math.max(...o.map((e=>e.y+e.height)))-s;return{x:i+this.gridOffsetX,y:s+this.gridOffsetY,width:r,height:n}}getMainViewportCoordinates(){const e=this.getters.getActiveSheetId(),{xSplit:t,ySplit:o}=this.getters.getPaneDivisions(e);return{x:this.getters.getColDimensions(e,t).start,y:this.getters.getRowDimensions(e,o).start}}ensureMainViewportExist(e){this.viewports[e]||this.resetViewports(e)}getSubViewports(e){return this.ensureMainViewportExist(e),Object.values(this.viewports[e]).filter(ke)}checkPositiveDimension(e){return e.width<0||e.height<0?71:0}checkValuesAreDifferent(e){const{height:t,width:o}=this.getSheetViewDimension();return e.gridOffsetX===this.gridOffsetX&&e.gridOffsetY===this.gridOffsetY&&e.width===o&&e.height===t?79:0}checkScrollingDirection({offsetX:e,offsetY:t}){const o=this.getMainInternalViewport(this.getters.getActiveSheetId());return!o.canScrollHorizontally&&e>0||!o.canScrollVertically&&t>0?72: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 o=this.getSubViewports(e);Object.values(o).forEach((e=>{e.adjustPosition(t)}))}}resizeSheetView(e,t,o=0,i=0){this.sheetViewHeight=e,this.sheetViewWidth=t,this.gridOffsetX=o,this.gridOffsetY=i,this.recomputeViewports()}recomputeViewports(){for(let e of Object.keys(this.viewports))this.resetViewports(e)}setSheetViewOffset(e,t){const o=this.getters.getActiveSheetId(),{maxOffsetX:i,maxOffsetY:s}=this.getMaximumSheetOffset();Object.values(this.getSubViewports(o)).forEach((o=>o.setViewportOffset(xe(e,0,i),xe(t,0,s))))}getViewportOffset(e){return{x:this.viewports[e]?.bottomRight.offsetScrollbarX||0,y:this.viewports[e]?.bottomRight.offsetScrollbarY||0}}resetViewports(e){if(!this.getters.tryGetSheet(e))return;const{xSplit:t,ySplit:o}=this.getters.getPaneDivisions(e),i=this.getters.getNumberCols(e),s=this.getters.getNumberRows(e),r=this.getters.getColRowOffset("COL",0,t,e),n=this.getters.getColRowOffset("ROW",0,o,e),{xRatio:a,yRatio:l}=this.getFrozenSheetViewRatio(e),c=a<1,h=l<1,d=this.getViewportOffset(e),u={topLeft:o&&t&&new vx(this.getters,e,{left:0,right:t-1,top:0,bottom:o-1},{width:r,height:n},{canScrollHorizontally:!1,canScrollVertically:!1},{x:0,y:0})||void 0,topRight:o&&new vx(this.getters,e,{left:t,right:i-1,top:0,bottom:o-1},{width:this.sheetViewWidth-r,height:n},{canScrollHorizontally:c,canScrollVertically:!1},{x:c?d.x:0,y:0})||void 0,bottomLeft:t&&new vx(this.getters,e,{left:0,right:t-1,top:o,bottom:s-1},{width:r,height:this.sheetViewHeight-n},{canScrollHorizontally:!1,canScrollVertically:h},{x:0,y:h?d.y:0})||void 0,bottomRight:new vx(this.getters,e,{left:t,right:i-1,top:o,bottom:s-1},{width:this.sheetViewWidth-r,height:this.sheetViewHeight-n},{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 t=this.getters.getActiveSheetId(),{top:o}=this.getMainInternalViewport(t),{scrollX:i}=this.getActiveSheetScrollInfo();this.setSheetViewOffset(i,e);const{anchor:s}=this.getters.getSelection();if(s.cell.row>=this.getters.getPaneDivisions(t).ySplit){const e=this.getMainInternalViewport(t).top-o;this.selection.selectCell(s.cell.col,s.cell.row+e)}}getVisibleFigures(){const e=this.getters.getActiveSheetId(),t=[],o=this.getters.getFigures(e),{scrollX:i,scrollY:s}=this.getActiveSheetScrollInfo(),{x:r,y:n}=this.getters.getMainViewportCoordinates(),{width:a,height:l}=this.getters.getSheetViewDimensionWithHeaders();for(const e of o)e.x>=r&&(e.x+e.width<=r+i||e.x>=a+i+r)||e.y>=n&&(e.y+e.height<=n+s||e.y>=l+s+n)||t.push(e);return t}isPositionVisible(e){const{scrollX:t,scrollY:o}=this.getters.getActiveSheetScrollInfo(),{x:i,y:s}=this.getters.getMainViewportCoordinates(),{width:r,height:n}=this.getters.getSheetViewDimension();return!(e.x>=i&&(e.x<i+t||e.x>r+t+i))&&!(e.y>=s&&(e.y<s+o||e.y>n+o+s))}getFrozenSheetViewRatio(e){const{xSplit:t,ySplit:o}=this.getters.getPaneDivisions(e),i=this.getters.getColDimensions(e,t).start,s=this.getters.getRowDimensions(e,o).start;return{xRatio:i/(this.sheetViewWidth+this.gridOffsetX),yRatio:s/(this.sheetViewHeight+this.gridOffsetY)}}}).add("clipboard",class extends sw{static layers=[2];static getters=["getClipboardContent","getClipboardTextContent","isCutOperation","isPaintingFormat"];status="invisible";state;lastPasteState;paintFormatStatus="inactive";originSheetId;allowDispatch(e){switch(e.type){case"CUT":const t=this.getters.getSelectedZones();return this.getClipboardState(t,e.type).isCutAllowed(t);case"PASTE":if(!this.state)return 24;const o=e.pasteOption||("inactive"!==this.paintFormatStatus?"onlyFormat":void 0);return this.state.isPasteAllowed(e.target,{pasteOption:o});case"PASTE_FROM_OS_CLIPBOARD":return new ux(e.text,this.getters,this.dispatch,this.selection).isPasteAllowed(e.target,{pasteOption:e.pasteOption});case"INSERT_CELL":{const{cut:t,paste:o}=this.getInsertCellsTargets(e.zone,e.shiftDimension);return this.getClipboardStateForCopyCells(t,"CUT").isPasteAllowed(o)}case"DELETE_CELL":{const{cut:t,paste:o}=this.getDeleteCellsTargets(e.zone,e.shiftDimension);return this.getClipboardStateForCopyCells(t,"CUT").isPasteAllowed(o)}case"ACTIVATE_PAINT_FORMAT":if("inactive"!==this.paintFormatStatus)return 97}return 0}handle(e){switch(e.type){case"COPY":case"CUT":const t=this.getters.getSelectedZones();this.state=this.getClipboardState(t,e.type),this.status="visible",this.originSheetId=this.getters.getActiveSheetId();break;case"PASTE":if(!this.state)break;const o=e.pasteOption||("inactive"!==this.paintFormatStatus?"onlyFormat":void 0);this.state.paste(e.target,{pasteOption:o,shouldPasteCF:!0,selectTarget:!0}),this.lastPasteState=this.state,"oneOff"===this.paintFormatStatus&&(this.paintFormatStatus="inactive"),this.status="invisible";break;case"CLEAN_CLIPBOARD_HIGHLIGHT":this.status="invisible";break;case"DELETE_CELL":{const{cut:t,paste:o}=this.getDeleteCellsTargets(e.zone,e.shiftDimension);if(!oi(t[0])){for(const{col:t,row:o}of vi(e.zone))this.dispatch("CLEAR_CELL",{col:t,row:o,sheetId:this.getters.getActiveSheetId()});break}this.getClipboardStateForCopyCells(t,"CUT").paste(o);break}case"INSERT_CELL":{const{cut:t,paste:o}=this.getInsertCellsTargets(e.zone,e.shiftDimension);this.getClipboardStateForCopyCells(t,"CUT").paste(o);break}case"ADD_COLUMNS_ROWS":if(this.status="invisible","CUT"!==this.state?.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"!==this.state?.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":this.state=new ux(e.text,this.getters,this.dispatch,this.selection),this.state.paste(e.target,{pasteOption:e.pasteOption}),this.lastPasteState=this.state,this.status="invisible";break;case"REPEAT_PASTE":this.lastPasteState?.paste(e.target,{pasteOption:e.pasteOption,shouldPasteCF:!0,selectTarget:!0});break;case"ACTIVATE_PAINT_FORMAT":{const t=this.getters.getSelectedZones();this.state=this.getClipboardStateForCopyCells(t,"COPY"),this.status="visible",e.persistent?this.paintFormatStatus="persistent":this.paintFormatStatus="oneOff";break}case"DELETE_SHEET":if("CUT"!==this.state?.operation)return;this.originSheetId===e.sheetId&&(this.state=void 0,this.status="invisible");break;case"CANCEL_PAINT_FORMAT":this.paintFormatStatus="inactive",this.status="invisible";break;default:ms(e)&&(this.status="invisible")}}getClipboardContent(){return this.state?.getClipboardContent()||{[cs.PlainText]:"\t"}}getClipboardTextContent(){return this.state?.getClipboardContent()[cs.PlainText]||"\t"}isCutOperation(){return!!this.state&&"CUT"===this.state.operation}isPaintingFormat(){return"inactive"!==this.paintFormatStatus}getDeleteCellsTargets(e,t){const o=this.getters.getActiveSheetId();let i;return i="COL"===t?{...e,left:e.right+1,right:this.getters.getNumberCols(o)-1}:{...e,top:e.bottom+1,bottom:this.getters.getNumberRows(o)-1},{cut:[i],paste:[e]}}getInsertCellsTargets(e,t){const o=this.getters.getActiveSheetId();let i,s;return"COL"===t?(i={...e,right:this.getters.getNumberCols(o)-1},s={...e,left:e.right+1,right:e.right+1}):(i={...e,bottom:this.getters.getNumberRows(o)-1},s={...e,top:e.bottom+1,bottom:this.getters.getNumberRows(o)-1}),{cut:[i],paste:[s]}}getClipboardStateForCopyCells(e,t){return new ax(e,t,this.getters,this.dispatch,this.selection)}getClipboardState(e,t){return this.getters.getSelectedFigureId()?new lx(t,this.getters,this.dispatch):new ax(e,t,this.getters,this.dispatch,this.selection)}drawGrid(e){"visible"===this.status&&this.state&&this.state.drawClipboard(e)}}).add("edition",class extends sw{static getters=["getEditionMode","isSelectingForComposer","showSelectionIndicator","getCurrentContent","getComposerSelection","getCurrentTokens","getTokenAtCursor","getComposerHighlights","getCurrentEditedCell"];col=0;row=0;mode="inactive";sheetId="";currentContent="";currentTokens=[];selectionStart=0;selectionEnd=0;selectionInitialStart=0;initialContent="";previousRef="";previousRange=void 0;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=e.text||this.getComposerContent(this.getters.getActivePosition());return this.validateSelection(t.length,e.selection.start,e.selection.end)}return 0;default:return 0}}handleEvent(e){if("selecting"!==this.mode)return;const t=this.getters.getActiveSheetId();let o;if(o=e.options.unbounded?this.getters.getUnboundedZone(t,e.anchor.zone):e.anchor.zone,"newAnchor"===e.mode)this.insertSelectedRange(o);else this.replaceSelectedRanges(o)}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":"inactive"!==this.mode&&e.text?this.setContent(e.text,e.selection):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),o=this.currentTokens.filter((e=>"REFERENCE"===e.type)).find((e=>{const{xc:o,sheetName:i}=Jo(e.value),s=i||this.getters.getSheetName(this.sheetId),r=this.getters.getActiveSheetId();if(this.getters.getSheetName(r)!==s)return!1;const n=this.getters.getRangeFromSheetXC(r,o);return hi(this.getters.expandZone(r,n.zone),t.zone)}));this.previousRef=o.value,this.previousRange=this.getters.getRangeFromSheetXC(this.getters.getActiveSheetId(),this.previousRef),this.selectionInitialStart=o.start;break;case"CHANGE_HIGHLIGHT":const i=this.getters.getRangeFromRangeData(e.range),s=this.getRangeReference(i,this.previousRange.parts);this.selectionStart=this.selectionInitialStart,this.selectionEnd=this.selectionInitialStart+this.previousRef.length,this.replaceSelection(s),this.previousRef=s,this.selectionStart=this.currentContent.length,this.selectionEnd=this.currentContent.length;break;case"ACTIVATE_SHEET":if(this.currentContent.startsWith("=")||(this.cancelEdition(),this.resetContent()),e.sheetIdFrom!==e.sheetIdTo){const t=this.getters.getActivePosition(),{col:o,row:i}=this.getters.getNextVisibleCellPosition({sheetId:e.sheetIdTo,col:t.col,row:t.row}),s=this.getters.expandZone(e.sheetIdTo,wi({col:o,row:i}));this.selection.resetAnchor(this,{cell:{col:o,row:i},zone:s})}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:fx}));break;case"CYCLE_EDITION_REFERENCES":this.cycleReferences()}}getEditionMode(){return this.mode}getCurrentContent(){return"inactive"===this.mode?this.getComposerContent(this.getters.getActivePosition()):this.currentContent}getComposerSelection(){return{start:this.selectionStart,end:this.selectionEnd}}getCurrentEditedCell(){return{sheetId:this.sheetId,col:this.col,row:this.row}}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((o=>o.start<=e&&o.end>=t))}cycleReferences(){const e=this.getTokensInSelection(),t=e.filter((e=>"REFERENCE"===e.type));if(0===t.length)return;const o=e.map(gx).map((e=>e.value)).join(""),i=this.currentContent,s=e[0].start,r=e[e.length-1].end,n=i.slice(0,s)+o+i.slice(r),a=n.length-i.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:n,selection:l})}validateSelection(e,t,o){return t>=0&&t<=e&&o>=0&&o<=e?0:49}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:fx});const{top:t,left:o}=ni({left:this.col,right:this.col,top:this.row,bottom:this.row},"left",[...e.elements]);this.col=o,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:fx});const{top:t,left:o}=ni({left:this.col,right:this.col,top:this.row,bottom:this.row},"top",[...e.elements]);this.col=o,this.row=t}onAddElements(e){const{top:t,left:o}=ri({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=o,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){const o=this.getters.getActiveCell(),i=this.getters.getLocale();e&&o.format?.includes("%")&&io(e,i)&&(t=t||{start:e.length,end:e.length},e=`${e}%`);const{col:s,row:r,sheetId:n}=this.getters.getActivePosition();this.col=s,this.sheetId=n,this.row=r,this.initialContent=this.getComposerContent({sheetId:n,col:s,row:r}),this.mode="editing",this.setContent(e||this.initialContent,t),this.colorIndexByRange={};const a=wi({col:this.col,row:this.row});this.selection.capture(this,{cell:{col:this.col,row:this.row},zone:a},{handleEvent:this.handleEvent.bind(this),release:()=>{this.stopEdition()}})}stopEdition(){if("inactive"!==this.mode){this.cancelEditionAndActivateSheet();const e=this.col,t=this.row;let o=this.currentContent;if(!(this.initialContent!==o))return;if(o){const i=this.getters.getActiveSheetId(),s=this.getters.getEvaluatedCell({sheetId:i,col:this.col,row:this.row});if(o=bg(o,this.getters.getLocale()),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+=Be(new Array(i).fill(")")))}else s.link&&(o=Ne(o,s.link.url));this.dispatch("UPDATE_CELL",{sheetId:this.sheetId,col:e,row:t,content:o})}else this.dispatch("UPDATE_CELL",{sheetId:this.sheetId,content:"",col:e,row:t});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})}getComposerContent(e){const t=this.getters.getLocale(),o=this.getters.getCell(e);if(o?.isFormula)return Eg(o.content,t);const{format:i,value:s,type:r,formattedValue:n}=this.getters.getEvaluatedCell(e);switch(r){case ls.text:case ls.empty:return s;case ls.boolean:return n;case ls.error:return o?.content||"";case ls.number:return i&&xo(i)?n:this.numberComposerContent(s,i,t)}}numberComposerContent(e,t,o){return t?.includes("%")?`${wo(100*e,o.decimalSeparator)}%`:wo(e,o.decimalSeparator)}cancelEdition(){"inactive"!==this.mode&&(this.mode="inactive",this.selection.release(this))}resetContent(){this.setContent(this.initialContent||"")}setContent(e,t,o){const i=this.currentContent!==e;if(this.currentContent=e,t?(this.selectionStart=t.start,this.selectionEnd=t.end):this.selectionStart=this.selectionEnd=e.length,i||"inactive"!==this.mode){const t=this.getters.getLocale();this.currentTokens=e.startsWith("=")?gg(e,t):[],this.currentTokens.length>100&&o&&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),o=this.getZoneReference(e);this.canStartComposerRangeSelection()?(this.insertText(o,t),this.selectionInitialStart=t):(this.insertText(","+o,t),this.selectionInitialStart=t+1)}replaceSelectedRanges(e){const t=this.getZoneReference(e);this.replaceText(t,this.selectionInitialStart,this.selectionEnd)}getZoneReference(e){const t=this.getters.getCurrentEditedCell()?.sheetId||this.getters.getActiveSheetId(),o=this.getters.getActiveSheetId(),i=this.getters.getRangeFromZone(o,e);return this.getters.getSelectionRangeString(i,t)}getRangeReference(e,t=[{colFixed:!1,rowFixed:!1}]){let o=[...t];1===t.length&&yi(e.zone)>1?o.push({...t[0]}):2===t.length&&1===yi(e.zone)&&o.pop();const i=e.clone({parts:o});return this.getters.getSelectionRangeString(i,this.getters.getCurrentEditedCell()?.sheetId||this.getters.getActiveSheetId())}replaceSelection(e){const t=Math.min(this.selectionStart,this.selectionEnd),o=Math.max(this.selectionStart,this.selectionEnd);this.replaceText(e,t,o)}replaceText(e,t,o){this.currentContent=this.currentContent.slice(0,t)+this.currentContent.slice(o,this.currentContent.length),this.insertText(e,t)}insertText(e,t){const o=this.currentContent.slice(0,t)+e+this.currentContent.slice(t),i=t+e.length;this.dispatch("SET_CURRENT_CONTENT",{content:o,selection:{start:i,end:i}})}updateRangeColor(){if(!this.currentContent.startsWith("=")||"inactive"===this.mode)return;const e=this.getters.getCurrentEditedCell()?.sheetId||this.getters.getActiveSheetId(),t=this.getReferencedRanges().map((t=>this.getters.getRangeString(t,e))),o={};for(const e of t)void 0!==this.colorIndexByRange[e]&&(o[e]=this.colorIndexByRange[e]);const i=new Set(Object.values(o));let s=0;const r=()=>{for(;i.has(s);)s++;return i.add(s),s};for(const e of t){const t=e in o?o[e]:r();o[e]=t}this.colorIndexByRange=o}getComposerHighlights(){if(!this.currentContent.startsWith("=")||"inactive"===this.mode)return[];const e=this.getters.getCurrentEditedCell()?.sheetId||this.getters.getActiveSheetId(),t=e=>{const t=this.colorIndexByRange[e];return st[t%st.length]};return this.getReferencedRanges().map((o=>{const i=this.getters.getRangeString(o,e);return{zone:o.zone,color:t(i),sheetId:o.sheetId}}))}getReferencedRanges(){const e=this.getters.getCurrentEditedCell()?.sheetId||this.getters.getActiveSheetId();return this.currentTokens.filter((e=>"REFERENCE"===e.type)).map((t=>this.getters.getRangeFromSheetXC(e,t.value))).filter((e=>!e.invalidSheetName&&!e.invalidXc))}canStartComposerRangeSelection(){if(this.currentContent.startsWith("=")){const e=this.getTokenAtCursor();if(!e)return!1;const t=this.currentTokens.map((e=>e.start)).indexOf(e.start);let o=t,i=e;for(;!["ARG_SEPARATOR","LEFT_PAREN","OPERATOR"].includes(i.type)||Eu.includes(i.value);){if("SPACE"!==i.type||o<1)return!1;o--,i=this.currentTokens[o]}for(o=t+1,i=this.currentTokens[o];i&&!["ARG_SEPARATOR","RIGHT_PAREN","OPERATOR"].includes(i.type);){if("SPACE"!==i.type)return!1;o++,i=this.currentTokens[o]}return!0}return!1}getTokensInSelection(){const e=Math.min(this.selectionStart,this.selectionEnd),t=Math.max(this.selectionStart,this.selectionEnd);return this.currentTokens.filter((o=>o.start<=e&&o.end>=e||o.start>=e&&o.start<t))}}),wx=(new Ji).add("evaluation",class extends sw{static getters=["evaluateFormula","getCorrespondingFormulaCell","getRangeFormattedValues","getRangeValues","getRangeFormats","getEvaluatedCell","getEvaluatedCells","getEvaluatedCellsInZone","isEmpty"];shouldRebuildDependenciesGraph=!0;evaluator;positionsToUpdate=[];constructor(e){super(e),this.evaluator=new Nw(e.custom,this.getters)}beforeHandle(e){ds.has(e.type)&&(this.shouldRebuildDependenciesGraph=!0)}handle(e){switch(e.type){case"UPDATE_CELL":if(!("content"in e)&&!("format"in e)||this.shouldRebuildDependenciesGraph)return;this.positionsToUpdate.push(e),"content"in e&&this.evaluator.updateDependencies(e);break;case"EVALUATE_CELLS":this.evaluator.evaluateAllCells()}}finalize(){this.shouldRebuildDependenciesGraph?(this.evaluator.buildDependencyGraph(),this.evaluator.evaluateAllCells(),this.shouldRebuildDependenciesGraph=!1):this.positionsToUpdate.length&&this.evaluator.evaluateCells(this.positionsToUpdate),this.positionsToUpdate=[]}evaluateFormula(e,t){try{return this.evaluator.evaluateFormula(e,t)}catch(e){return e instanceof c?e.errorType:a.GenericError}}getRangeFormattedValues(e){const t=this.getters.tryGetSheet(e.sheetId);return void 0===t?[]:this.getters.getEvaluatedCellsInZone(t.id,e.zone).map((e=>e.formattedValue))}getRangeValues(e){const t=this.getters.tryGetSheet(e.sheetId);return void 0===t?[]:this.getters.getEvaluatedCellsInZone(t.id,e.zone).map((e=>e.value))}getRangeFormats(e){const t=this.getters.tryGetSheet(e.sheetId);return void 0===t?[]:this.getters.getEvaluatedCellsInZone(t.id,e.zone).map((e=>e.format))}getEvaluatedCell(e){return this.evaluator.getEvaluatedCell(e)}getEvaluatedCells(e){const t=this.getters.getCells(e)||{},o={};for(let e of Object.keys(t)){const t=this.getters.getCellPosition(e);o[e]=this.getEvaluatedCell(t)}return o}getEvaluatedCellsInZone(e,t){return vi(t).map((({col:t,row:o})=>this.getters.getEvaluatedCell({sheetId:e,col:t,row:o})))}isEmpty(e,t){return vi(t).map((({col:t,row:o})=>this.getEvaluatedCell({sheetId:e,col:t,row:o}))).every((e=>e.type===ls.empty))}exportForExcel(e){for(const t of this.evaluator.getEvaluatedPositions()){const o=this.evaluator.getEvaluatedCell(t),i=xt(t.col,t.row),s=o.value;let r,n,a=!1,l=!0;const c=this.getCorrespondingFormulaCell(t);c&&(l=mg(c.compiledFormula.tokens),a=l,l||(r=s.toString(),n=o.format));const h=e.sheets.find((e=>e.id===t.sheetId)),d=h.cells[i]||{},u=n?Ve(n,e.formats):d.format;let g;g=c instanceof KE?this.getters.buildFormulaContent(h.id,c,c.dependencies,!0):l?d.content:r,h.cells[i]={...d,value:s,isFormula:a,content:g,format:u}}}getCorrespondingFormulaCell(e){const t=this.getters.getCell(e);if(t&&t.content)return t.isFormula&&!function(e){try{return hg(e),!1}catch(e){return!0}}(t.content)?t:void 0;const o=this.evaluator.getArrayFormulaSpreadingOn(e);if(void 0===o)return;const i=this.getters.getCell(o);return i?.isFormula?i:void 0}}).add("evaluation_chart",class extends sw{static getters=["getChartRuntime","getStyleOfSingleCellChart"];charts={};createRuntimeChart=function(e){const t=qp.getAll().sort(((e,t)=>e.sequence-t.sequence));return function(o){const i=t.find((e=>e.match(o.type)));if(!i)throw new Error("No runtime builder for this chart.");return i.getChartRuntime(o,e)}}(this.getters);handle(e){if(hs.has(e.type)||us.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]}getStyleOfSingleCellChart(e,t){if(e)return{background:e,fontColor:ip(e)};if(!t)return{background:w,fontColor:ip(w)};const o=t.zone.left,i=t.zone.top,s=t.sheetId,r=this.getters.getCellComputedStyle({sheetId:s,col:o,row:i}),n=r.fillColor||w;return{background:n,fontColor:r.textColor||ip(n)}}}).add("evaluation_cf",class extends sw{static getters=["getConditionalIcon","getCellComputedStyle"];isStale=!0;computedStyles={};computedIcons={};handle(e){(us.has(e.type)||"UPDATE_CELL"===e.type&&"content"in e)&&(this.isStale=!0)}finalize(){if(this.isStale){for(const e of this.getters.getSheetIds())this.computedStyles[e]=ze((()=>this.getComputedStyles(e))),this.computedIcons[e]=ze((()=>this.getComputedIcons(e)));this.isStale=!1}}getCellComputedStyle(e){const{sheetId:t,col:o,row:i}=e,s=this.getters.getCell(e),r=this.computedStyles[t](),n=r&&r[o]?.[i],a={...s?.style,...n};return this.getters.getEvaluatedCell(e).link&&!a.textColor&&(a.textColor=R),this.getters.isFilterHeader(e)&&(a.bold=!0),a}getConditionalIcon({sheetId:e,col:t,row:o}){const i=this.computedIcons[e]();return i&&i[t]?.[o]}getComputedStyles(e){const t={};for(let o of this.getters.getConditionalFormats(e).reverse())switch(o.rule.type){case"ColorScaleRule":for(let i of o.ranges)this.applyColorScale(e,i,o.rule,t);break;case"CellIsRule":for(let i of o.ranges){const s=this.getters.getRangeFromSheetXC(e,i).zone;for(let i=s.top;i<=s.bottom;i++)for(let r=s.left;r<=s.right;r++){const s=this.rulePredicate[o.rule.type];let n=this.getters.getEvaluatedCell({sheetId:e,col:r,row:i});s&&s(n,o.rule)&&(t[r]||(t[r]=[]),t[r][i]=Object.assign(t[r]?.[i]||{},o.rule.style))}}}return t}getComputedIcons(e){const t={};for(let o of this.getters.getConditionalFormats(e).reverse())if("IconSetRule"===o.rule.type)for(let i of o.ranges)this.applyIcon(e,i,o.rule,t);return t}parsePoint(e,t,o,i){const s=this.getters.getEvaluatedCellsInZone(e,this.getters.getRangeFromSheetXC(e,t).zone).filter((e=>e.type===ls.number)).map((e=>e.value));switch(o.type){case"value":return"max"===i?et(s):tt(s);case"number":return Number(o.value);case"percentage":const t=tt(s);return t+(et(s)-t)*Number(o.value)/100;case"percentile":return no(s,Number(o.value)/100,!0);case"formula":const r=o.value&&this.getters.evaluateFormula(e,o.value);return"number"==typeof r?r:null;default:return null}}applyIcon(e,t,o,i){const s=this.parsePoint(e,t,o.lowerInflectionPoint),r=this.parsePoint(e,t,o.upperInflectionPoint);if(null===s||null===r||s>r)return;const n=this.getters.getRangeFromSheetXC(e,t).zone,a=[o.icons.upper,o.icons.middle,o.icons.lower];for(let t=n.top;t<=n.bottom;t++)for(let l=n.left;l<=n.right;l++){const n=this.getters.getEvaluatedCell({sheetId:e,col:l,row:t});if(n.type!==ls.number)continue;const c=this.computeIcon(n.value,r,o.upperInflectionPoint.operator,s,o.lowerInflectionPoint.operator,a);i[l]||(i[l]=[]),i[l][t]=c}}computeIcon(e,t,o,i,s,r){return"ge"===o&&e>=t||"gt"===o&&e>t?r[0]:"ge"===s&&e>=i||"gt"===s&&e>i?r[1]:r[2]}applyColorScale(e,t,o,i){const s=this.parsePoint(e,t,o.minimum,"min"),r=o.midpoint?this.parsePoint(e,t,o.midpoint):null,n=this.parsePoint(e,t,o.maximum,"max");if(null===s||null===n||s>=n||r&&(s>=r||r>=n))return;const a=this.getters.getRangeFromSheetXC(e,t).zone,l=[];o.midpoint&&r?(l.push({minValue:s,minColor:o.minimum.color,colorDiffUnit:this.computeColorDiffUnits(s,r,o.minimum.color,o.midpoint.color)}),l.push({minValue:r,minColor:o.midpoint.color,colorDiffUnit:this.computeColorDiffUnits(r,n,o.midpoint.color,o.maximum.color)})):l.push({minValue:s,minColor:o.minimum.color,colorDiffUnit:this.computeColorDiffUnits(s,n,o.minimum.color,o.maximum.color)});for(let t=a.top;t<=a.bottom;t++)for(let o=a.left;o<=a.right;o++){const a=this.getters.getEvaluatedCell({sheetId:e,col:o,row:t});if(a.type===ls.number){const e=xe(a.value,s,n);let c;c=2===l.length&&r?e<=r?this.colorCell(e,l[0].minValue,l[0].minColor,l[0].colorDiffUnit):this.colorCell(e,l[1].minValue,l[1].minColor,l[1].colorDiffUnit):this.colorCell(e,l[0].minValue,l[0].minColor,l[0].colorDiffUnit),i[o]||(i[o]=[]),i[o][t]=i[o]?.[t]||{},i[o][t].fillColor=rt(c)}}}computeColorDiffUnits(e,t,o,i){const s=t-e;return[((o>>16)%256-(i>>16)%256)/s,((o>>8)%256-(i>>8)%256)/s,(o%256-i%256)/s]}colorCell(e,t,o,i){const[s,r,n]=i;return Math.round((o>>16)%256-s*(e-t))<<16|Math.round((o>>8)%256-r*(e-t))<<8|Math.round(o%256-n*(e-t))}rulePredicate={CellIsRule:(e,t)=>{if(e.type===ls.error)return!1;const o=t.values.map((e=>ir(e,eo)));switch(t.operator){case"IsEmpty":return""===e.value.toString().trim();case"IsNotEmpty":return""!==e.value.toString().trim();case"BeginsWith":return""!==o[0]&&e.value.toString().startsWith(o[0].toString());case"EndsWith":return""!==o[0]&&e.value.toString().endsWith(o[0].toString());case"Between":return e.value>=o[0]&&e.value<=o[1];case"NotBetween":return!(e.value>=o[0]&&e.value<=o[1]);case"ContainsText":return e.value.toString().indexOf(o[0].toString())>-1;case"NotContains":return!e.value||-1===e.value.toString().indexOf(o[0].toString());case"GreaterThan":return e.value>o[0];case"GreaterThanOrEqual":return e.value>=o[0];case"LessThan":return e.value<o[0];case"LessThanOrEqual":return e.value<=o[0];case"NotEqual":return""!==o[0]&&e.value!==o[0];case"Equal":return""===o[0]||e.value===o[0];default:console.warn(r("Not implemented operator %s for kind of conditional formatting: %s",t.operator,t.type))}return!1}}}).add("row_size",class extends sw{static getters=["getRowSize"];tallestCellInRow={};ctx=document.createElement("canvas").getContext("2d");handle(e){switch(e.type){case"START":for(const e of this.getters.getSheetIds())this.initializeSheet(e);break;case"CREATE_SHEET":this.initializeSheet(e.sheetId);break;case"DUPLICATE_SHEET":{const t=Ce(this.tallestCellInRow[e.sheetId]);this.history.update("tallestCellInRow",e.sheetIdTo,t);break}case"DELETE_SHEET":const t={...this.tallestCellInRow};delete t[e.sheetId],this.history.update("tallestCellInRow",t);break;case"REMOVE_COLUMNS_ROWS":{if("COL"===e.dimension)return;const t=Je(this.tallestCellInRow[e.sheetId],e.elements);this.history.update("tallestCellInRow",e.sheetId,t);break}case"ADD_COLUMNS_ROWS":{if("COL"===e.dimension)return;const t=$e(e.position,e.base),o=Array(e.quantity).fill(void 0),i=function(e,t,o){const i=[...e];return i.splice(o,0,...t),i}(this.tallestCellInRow[e.sheetId],o,t);this.history.update("tallestCellInRow",e.sheetId,i);break}case"RESIZE_COLUMNS_ROWS":{const t=e.sheetId;if("ROW"===e.dimension)for(const o of e.elements){const e=this.getRowTallestCell(t,o);this.history.update("tallestCellInRow",t,o,e)}else for(const o of ye(0,this.getters.getNumberRows(t)))for(const i of e.elements)this.updateRowSizeForCellChange(t,o,i)}break;case"UPDATE_CELL":this.updateRowSizeForCellChange(e.sheetId,e.row,e.col);break;case"ADD_MERGE":case"REMOVE_MERGE":for(const t of e.target)for(const o of vi(t))this.updateRowSizeForCellChange(e.sheetId,o.row,o.col)}}getRowSize(e,t){return Math.round(this.getters.getUserRowSize(e,t)??this.tallestCellInRow[e][t]?.size??P)}updateRowSizeForCellChange(e,t,o){const i=this.tallestCellInRow[e]?.[t];if(i?.cell.col===o){const o=this.getRowTallestCell(e,t);this.history.update("tallestCellInRow",e,t,o)}const s=this.getCellHeight({sheetId:e,col:o,row:t});if(!(s<=P)&&(!i&&s>P||i&&s>i.size)){const i={cell:{sheetId:e,col:o,row:t},size:s};this.history.update("tallestCellInRow",e,t,i)}}initializeSheet(e){const t=[];for(let o=0;o<this.getters.getNumberRows(e);o++){const i=this.getRowTallestCell(e,o);t.push(i)}this.history.update("tallestCellInRow",e,t)}getCellHeight(e){if(this.isInMultiRowMerge(e))return P;const t=this.getters.getCell(e),o=this.getters.getColSize(e.sheetId,e.col);return function(e,t,o){if(!t||!t.content)return P;const i=t.style?.wrapping?o-2*z:void 0,s=t.isFormula?1:Ui(e,t.content,t.style,i).length;return Ni(Pi(t.style),s)+2*H}(this.ctx,t,o)}isInMultiRowMerge(e){const t=this.getters.getMerge(e);return!!t&&t.bottom!==t.top}getRowTallestCell(e,t){if(void 0!==this.getters.getUserRowSize(e,t))return;const o=this.getters.getRowCells(e,t);let i,s=0;for(let e=0;e<o.length;e++){const t=this.getters.getCellById(o[e]);if(!t)continue;const r=this.getters.getCellPosition(t.id),n=this.getCellHeight(r);n>s&&n>P&&(s=n,i={cell:r,size:n})}return i&&i.size>P?i:void 0}}).add("custom_colors",class extends sw{customColors={};shouldUpdateColors=!1;static getters=["getCustomColors"];handle(e){switch(e.type){case"UPDATE_CELL":case"UPDATE_CHART":case"CREATE_CHART":case"ADD_CONDITIONAL_FORMAT":case"SET_BORDER":case"SET_ZONE_BORDERS":case"SET_FORMATTING":this.history.update("shouldUpdateColors",!0)}}finalize(){if(this.shouldUpdateColors){this.history.update("shouldUpdateColors",!1);for(const e of this.getCustomColors())this.tryToAddColor(e)}}getCustomColors(){let e=[];for(const t of this.getters.getSheetIds())e=e.concat(this.getColorsFromCells(t),this.getFormattingColors(t),this.getChartColors(t));return function(e){const t=[{leadColor:ct(255,0,0),colors:[]},{leadColor:ct(255,128,0),colors:[]},{leadColor:ct(128,128,0),colors:[]},{leadColor:ct(128,255,0),colors:[]},{leadColor:ct(0,255,0),colors:[]},{leadColor:ct(0,255,128),colors:[]},{leadColor:ct(0,255,255),colors:[]},{leadColor:ct(0,127,255),colors:[]},{leadColor:ct(0,0,255),colors:[]},{leadColor:ct(127,0,255),colors:[]},{leadColor:ct(128,0,128),colors:[]},{leadColor:ct(255,0,128),colors:[]}];for(const o of e.map(ut)){let e=500,i=0;t.forEach(((t,s)=>{const r=(n=o,a=t.leadColor,Math.sqrt(Math.pow(n.r-a.r,2)+Math.pow(n.g-a.g,2)+Math.pow(n.b-a.b,2)));var n,a;e>r&&(e=r,i=s)})),t[i].colors.push(o)}return t.map((e=>e.colors.sort(((e,t)=>pt(e).s-pt(t).s)))).flat().map(dt)}([...new Set([...new Set([...e,...Object.keys(this.customColors)])].filter(at).map(nt))]).filter((e=>!_.includes(e)))}getColorsFromCells(e){const t=Object.values(this.getters.getCells(e)),o=new Set;for(const e of t)e.style?.textColor&&o.add(e.style.textColor),e.style?.fillColor&&o.add(e.style.fillColor);for(const t of this.getters.getBordersColors(e))o.add(t);return[...o]}getFormattingColors(e){const t=this.getters.getConditionalFormats(e),o=[];for(const e of t){const t=e.rule;"CellIsRule"===t.type?(o.push(t.style.textColor),o.push(t.style.fillColor)):"ColorScaleRule"===t.type&&(o.push(rt(t.minimum.color)),o.push(t.midpoint?rt(t.midpoint.color):void 0),o.push(rt(t.maximum.color)))}return o.filter(ke)}getChartColors(e){const t=this.getters.getChartIds(e).map((e=>this.getters.getChart(e)));let o=new Set;for(let e of t){if(void 0===e)continue;const t=e.getDefinition().background;switch(void 0!==t&&o.add(t),e.type){case"gauge":const t=e.sectionRule.colors;o.add(t.lowerColor),o.add(t.middleColor),o.add(t.upperColor);break;case"scorecard":const i=e;o.add(i.baselineColorDown),o.add(i.baselineColorUp)}}return[...o]}tryToAddColor(e){const t=nt(e);e&&!_.includes(t)&&this.history.update("customColors",t,!0)}}),xx=new Ji;xx.add("link",{condition:(e,t)=>!!t.model.getters.getEvaluatedCell(e).link,execute:(e,t)=>ns(t.model.getters.getEvaluatedCell(e).link,t),sequence:5});class yx{fileStore;constructor(e){this.fileStore=e}async requestImage(){const e=await this.getImageFromUser(),t=await this.fileStore.upload(e);return{path:t,size:await this.getImageOriginalSize(t),mimetype:e.type}}getImageFromUser(){return new Promise(((e,t)=>{const o=document.createElement("input");o.setAttribute("type","file"),o.setAttribute("accept","image/*"),o.addEventListener("change",(async()=>{null===o.files||1!=o.files.length?t():e(o.files[0])})),o.click()}))}getImageOriginalSize(e){return new Promise(((t,o)=>{const i=new Image;i.src=e,i.addEventListener("load",(()=>{const e={width:i.width,height:i.height};t(e)})),i.addEventListener("error",o)}))}}class Ix{focusableElement=void 0;setFocusableElement(e){this.focusableElement=e}focus(){this.focusableElement?.focus()}}const Rx=[{transform:"scale(0)"},{transform:"scale(0.8)",offset:.33},{opacity:"0",transform:"scale(1)",offset:1}];Wi`
|
|
1470
1470
|
.o-ripple {
|
|
1471
1471
|
z-index: 1;
|
|
1472
1472
|
}
|
|
1473
|
-
`;class
|
|
1473
|
+
`;class Tx extends t.Component{static template="o-spreadsheet-RippleEffect";rippleRef=t.useRef("ripple");setup(){let e;t.onMounted((()=>{const t=this.rippleRef.el;t&&t.animate&&(e=t.animate(Rx,{duration:this.props.duration,easing:"ease-out"}),e.addEventListener("finish",this.props.onAnimationEnd))})),t.onWillUnmount((()=>{e?.removeEventListener("finish",this.props.onAnimationEnd)}))}get rippleStyle(){const{x:e,y:t,width:o,height:i}=this.props;return Yi({transform:"scale(0)",left:e,top:t,"margin-left":`${-o/2+(this.props.offsetX||0)}px`,"margin-top":`${-i/2+(this.props.offsetY||0)}px`,width:`${o}px`,height:`${i}px`,background:this.props.color,"border-radius":"100%",opacity:`${this.props.opacity}`})}}Tx.props={x:String,y:String,color:String,opacity:Number,duration:Number,width:Number,height:Number,offsetY:Number,offsetX:Number,allowOverflow:Boolean,onAnimationEnd:Function,style:String};class Ax extends t.Component{static template="o-spreadsheet-Ripple";static components={RippleEffect:Tx};static defaultProps={color:"#aaaaaa",opacity:.4,duration:800,enabled:!0,onAnimationEnd:()=>{},class:""};childContainer=t.useRef("childContainer");state=t.useState({ripples:[]});currentId=1;onClick(e){if(!this.props.enabled)return;if(!this.childContainer.el)return;const t=this.getRippleChildRectInfo(),{x:o,y:i,width:s,height:r}=t,n=Math.max(s,r),a={x:e.clientX-o,y:e.clientY-i,width:this.props.width||2.85*n,height:this.props.height||2.85*n};this.state.ripples.push({rippleRect:a,id:this.currentId++})}getRippleStyle(){const e=this.childContainer.el;if(!e||1!==e.childElementCount||!e.firstElementChild)return"";const t=this.getRippleChildRectInfo();return Yi({top:t.marginTop+"px",left:t.marginLeft+"px",width:t.width+"px",height:t.height+"px"})}getRippleChildRectInfo(){const e=this.childContainer.el;if(!e)throw new Error("No child container element found");if(1!==e.childElementCount||!e.firstElementChild){return{...Rr(e),marginLeft:0,marginTop:0}}const t=e.firstElementChild,o=function(e){const t=window.getComputedStyle(e);return{top:parseInt(t.marginTop,10)||0,bottom:parseInt(t.marginBottom,10)||0,left:parseInt(t.marginLeft,10)||0,right:parseInt(t.marginRight,10)||0}}(t);return{...Rr(t),marginLeft:o.left,marginTop:o.top}}removeRipple(e){const t=this.state.ripples.findIndex((t=>t.id===e));-1!==t&&this.state.ripples.splice(t,1)}getRippleEffectProps(e){const t=this.state.ripples.find((t=>t.id===e))?.rippleRect;if(!t)throw new Error("Cannot find a ripple with the id "+e);return{color:this.props.color,opacity:this.props.opacity,duration:this.props.duration,x:this.props.ignoreClickPosition?"50%":t.x+"px",y:this.props.ignoreClickPosition?"50%":t.y+"px",width:t.width,height:t.height,offsetX:this.props.offsetX||0,offsetY:this.props.offsetY||0,allowOverflow:this.props.allowOverflow||!1,style:this.getRippleStyle(),onAnimationEnd:()=>this.removeRipple(e)}}}Ax.props={color:{type:String,optional:!0},opacity:{type:Number,optional:!0},duration:{type:Number,optional:!0},ignoreClickPosition:{type:Boolean,optional:!0},width:{type:Number,optional:!0},height:{type:Number,optional:!0},offsetY:{type:Number,optional:!0},offsetX:{type:Number,optional:!0},allowOverflow:{type:Boolean,optional:!0},enabled:{type:Boolean,optional:!0},onAnimationEnd:{type:Function,optional:!0},slots:Object,class:{type:String,optional:!0}},Wi`
|
|
1474
1474
|
.o-sheet {
|
|
1475
1475
|
padding: 0 15px;
|
|
1476
1476
|
padding-right: 10px;
|
|
@@ -1510,7 +1510,7 @@
|
|
|
1510
1510
|
}
|
|
1511
1511
|
}
|
|
1512
1512
|
}
|
|
1513
|
-
`;class
|
|
1513
|
+
`;class Ox extends t.Component{static template="o-spreadsheet-BottomBarSheet";static components={Ripple:Ax};static defaultProps={onMouseDown:()=>{},style:""};state=t.useState({isEditing:!1});sheetDivRef=t.useRef("sheetDiv");sheetNameRef=t.useRef("sheetNameSpan");editionState="initializing";setup(){t.onMounted((()=>{this.isSheetActive&&this.scrollToSheet()})),t.onPatched((()=>{this.sheetNameRef.el&&this.state.isEditing&&"initializing"===this.editionState&&(this.editionState="editing",this.focusInputAndSelectContent())}))}focusInputAndSelectContent(){if(!this.state.isEditing||!this.sheetNameRef.el)return;this.sheetNameRef.el.focus();const e=window.getSelection();e&&this.sheetNameRef.el.firstChild&&e.setBaseAndExtent(this.sheetNameRef.el.firstChild,0,this.sheetNameRef.el.firstChild,this.sheetNameRef.el.textContent?.length||0)}scrollToSheet(){this.sheetDivRef.el?.scrollIntoView?.()}onFocusOut(){this.state.isEditing&&"initializing"!==this.editionState&&this.stopEdition()}onMouseDown(e){this.activateSheet(),this.props.onMouseDown(e)}activateSheet(){this.env.model.dispatch("ACTIVATE_SHEET",{sheetIdFrom:this.env.model.getters.getActiveSheetId(),sheetIdTo:this.props.sheetId}),this.scrollToSheet()}onDblClick(){this.env.model.getters.isReadonly()||this.startEdition()}onKeyDown(e){this.state.isEditing&&("Enter"===e.key&&(e.preventDefault(),this.stopEdition()),"Escape"===e.key&&this.cancelEdition())}onClickSheetName(e){this.state.isEditing&&e.stopPropagation()}startEdition(){this.state.isEditing=!0,this.editionState="initializing"}stopEdition(){const e=this.sheetNameRef.el;if(!this.state.isEditing||!e)return;this.state.isEditing=!1,this.editionState="initializing",e.blur();const t=this.getInputContent()||"";e.innerText=t,function(e,t,o,i){const s=e.model.dispatch("RENAME_SHEET",{sheetId:t,name:o});s.reasons.includes(10)?e.raiseError(r("The sheet name cannot be empty."),i):s.reasons.includes(12)?e.raiseError(r("A sheet with the name %s already exists. Please select another name.",o),i):s.reasons.includes(14)&&e.raiseError(r("Some used characters are not allowed in a sheet name (Forbidden characters are %s).",ce.join(" ")),i)}(this.env,this.props.sheetId,t,(()=>this.startEdition()))}cancelEdition(){this.state.isEditing=!1,this.editionState="initializing",this.sheetNameRef.el?.blur(),this.setInputContent(this.sheetName)}onIconClick(e){this.isSheetActive||this.activateSheet(),this.props.openContextMenu(this.contextMenuRegistry,e)}onContextMenu(e){this.isSheetActive||this.activateSheet(),this.props.openContextMenu(this.contextMenuRegistry,e)}getInputContent(){return this.sheetNameRef.el?.textContent}setInputContent(e){this.sheetNameRef.el&&(this.sheetNameRef.el.textContent=e)}get contextMenuRegistry(){return function(e){const t=new Ug;return t.add("delete",{...Og,sequence:10}).add("duplicate",{...Mg,sequence:20}).add("rename",{...Ng(e),sequence:30}).add("move_right",{..._g,sequence:40}).add("move_left",{...Fg,sequence:50}).add("hide_sheet",{...Dg,sequence:60}),t}({renameSheetCallback:()=>{this.scrollToSheet(),this.startEdition()}})}get isSheetActive(){return this.env.model.getters.getActiveSheetId()===this.props.sheetId}get sheetName(){return this.env.model.getters.getSheetName(this.props.sheetId)}}Ox.props={sheetId:String,openContextMenu:Function,style:{type:String,optional:!0},onMouseDown:{type:Function,optional:!0}},Wi`
|
|
1514
1514
|
.o-selection-statistic {
|
|
1515
1515
|
margin-right: 20px;
|
|
1516
1516
|
padding: 4px 4px 4px 8px;
|
|
@@ -1520,7 +1520,7 @@
|
|
|
1520
1520
|
background-color: rgba(0, 0, 0, 0.08) !important;
|
|
1521
1521
|
}
|
|
1522
1522
|
}
|
|
1523
|
-
`;class
|
|
1523
|
+
`;class Mx extends t.Component{static template="o-spreadsheet-BottomBarStatisic";static components={Ripple:Ax};selectedStatisticFn="";statisticFnResults={};setup(){this.statisticFnResults=this.env.model.getters.getStatisticFnResults(),t.onWillUpdateProps((()=>{const e=this.env.model.getters.getStatisticFnResults();We(e,this.statisticFnResults)||this.props.closeContextMenu(),this.statisticFnResults=e}))}getSelectedStatistic(){if(!Object.values(this.statisticFnResults).every((e=>void 0===e)))return""===this.selectedStatisticFn&&(this.selectedStatisticFn=Object.keys(this.statisticFnResults)[0]),this.getComposedFnName(this.selectedStatisticFn,this.statisticFnResults[this.selectedStatisticFn])}listSelectionStatistics(e){const t=new Ug;let o=0;for(let[e,i]of Object.entries(this.statisticFnResults))t.add(e,{name:this.getComposedFnName(e,i),sequence:o,isReadonlyAllowed:!0,execute:()=>{this.selectedStatisticFn=e}}),o++;const i=e.currentTarget,{top:s,left:r,width:n}=i.getBoundingClientRect();this.props.openContextMenu(r+n,s,t)}getComposedFnName(e,t){const o=this.env.model.getters.getLocale();return e+": "+(void 0!==t?fo(t,{locale:o}):"__")}}Mx.props={openContextMenu:Function,closeContextMenu:Function};class Nx{draggedItemId;items;containerEl;initialMousePosition;currentMousePosition;minPosition;maxPosition;edgeScrollIntervalId;edgeScrollOffset=0;onChange;onCancel;onDragEnd;deadZone;constructor(e){this.items=e.items.map((e=>({...e,positionAtStart:e.position}))),this.draggedItemId=e.draggedItemId,this.containerEl=e.containerEl,this.onChange=e.onChange,this.onCancel=e.onCancel,this.onDragEnd=e.onDragEnd,this.initialMousePosition=e.mouseX,this.currentMousePosition=e.mouseX,this.minPosition=this.items[0].position,this.maxPosition=this.items[this.items.length-1].position+this.items[this.items.length-1].size,iv(this.onMouseMove.bind(this),this.onMouseUp.bind(this))}onMouseMove(e){if(0!==e.button)return void this.onCancel();const t=e.clientX;t<this.containerRect.left||t>this.containerRect.right?this.startEdgeScroll(t<this.containerRect.left?-1:1):(this.stopEdgeScroll(),this.moveDraggedItemToPosition(t+this.edgeScrollOffset))}moveDraggedItemToPosition(e){this.currentMousePosition=e;const t=this.getHoveredItemIndex(e,this.items),o=this.items.findIndex((e=>e.id===this.draggedItemId)),i=this.items[o];if(this.deadZone&&this.isInZone(e,this.deadZone))return void this.onChange(this.getItemsPositions());if(this.isInZone(e,{start:i.position,end:i.position+i.size})&&(this.deadZone=void 0),o===t)return void this.onChange(this.getItemsPositions());const s=Math.min(o,t),r=Math.max(o,t),n=Math.sign(t-o);let a=0;for(let e=s;e<=r;e++)e!==o&&(this.items[e].position-=n*i.size,a+=this.items[e].size);i.position+=n*a,this.items.sort(((e,t)=>e.position-t.position)),this.deadZone=n>0?{start:e,end:i.position}:{start:i.position+i.size,end:e},this.onChange(this.getItemsPositions())}onMouseUp(e){0!==e.button&&this.onCancel();const t=this.items.findIndex((e=>e.id===this.draggedItemId));this.onDragEnd(this.draggedItemId,t),this.stopEdgeScroll()}startEdgeScroll(e){this.edgeScrollIntervalId||(this.edgeScrollIntervalId=window.setInterval((()=>{const t=3*e;let o=this.currentMousePosition+t;o<this.minPosition?o=this.minPosition:o>this.maxPosition&&(o=this.maxPosition),this.edgeScrollOffset+=o-this.currentMousePosition,this.moveDraggedItemToPosition(o),this.containerEl.scrollLeft+=t}),5))}stopEdgeScroll(){window.clearInterval(this.edgeScrollIntervalId),this.edgeScrollIntervalId=void 0}getHoveredItemIndex(e,t){return e<=this.minPosition?0:e>=this.maxPosition?t.length-1:t.findIndex((t=>t.position+t.size>=e))}getItemsPositions(){const e={};for(let t of this.items){if(t.id!==this.draggedItemId){e[t.id]=t.position-t.positionAtStart;continue}let o=this.currentMousePosition-this.initialMousePosition;o=Math.max(this.minPosition-t.positionAtStart,o),o=Math.min(this.maxPosition-t.positionAtStart-t.size,o),e[t.id]=o}return e}get containerRect(){return this.containerEl.getBoundingClientRect()}isInZone(e,t){return e>=t.start&&e<=t.end}destroy(){this.stopEdgeScroll()}}Wi`
|
|
1524
1524
|
.o-spreadsheet-bottom-bar {
|
|
1525
1525
|
color: ${C};
|
|
1526
1526
|
background-color: ${f};
|
|
@@ -1562,12 +1562,12 @@
|
|
|
1562
1562
|
}
|
|
1563
1563
|
}
|
|
1564
1564
|
}
|
|
1565
|
-
`;class
|
|
1565
|
+
`;class _x extends t.Component{static template="o-spreadsheet-BottomBar";static components={Menu:Vr,Ripple:Ax,BottomBarSheet:Ox,BottomBarStatistic:Mx};bottomBarRef=t.useRef("bottomBar");sheetListRef=t.useRef("sheetList");dndHelper;targetScroll=void 0;state=t.useState({isSheetListScrollableLeft:!1,isSheetListScrollableRight:!1});menuMaxHeight=250;menuState=t.useState({isOpen:!1,menuId:void 0,position:null,menuItems:[]});sheetState=t.useState({sheetList:this.getVisibleSheets(),isDnd:!1,sheetDndPositions:void 0});setup(){t.onWillUpdateProps((()=>{this.updateScrollState();const e=this.getVisibleSheets();this.sheetState.isDnd&&!We(this.sheetState.sheetList,e)&&this.stopDragging(),this.sheetState.sheetList=e})),t.onWillUnmount((()=>{this.dndHelper?.destroy()}))}isDragged(e){return this.sheetState.isDnd&&this.dndHelper?.draggedItemId===e}clickAddSheet(e){const t=this.env.model.getters.getActiveSheetId(),o=this.env.model.getters.getSheetIds().findIndex((e=>e===t))+1,i=this.env.model.uuidGenerator.uuidv4(),s=this.env.model.getters.getNextSheetName(this.env._t("Sheet"));this.env.model.dispatch("CREATE_SHEET",{sheetId:i,position:o,name:s}),this.env.model.dispatch("ACTIVATE_SHEET",{sheetIdFrom:t,sheetIdTo:i})}getVisibleSheets(){return this.env.model.getters.getVisibleSheetIds().map((e=>{const t=this.env.model.getters.getSheet(e);return{id:t.id,name:t.name}}))}getSheets(){return this.sheetState.sheetList}clickListSheets(e){const t=new Ug,o=this.env.model.getters.getActiveSheetId();let i=0;for(const e of this.env.model.getters.getSheetIds()){const s=this.env.model.getters.getSheet(e);t.add(e,{name:s.name,sequence:i,isReadonlyAllowed:!0,textColor:s.isVisible?void 0:"grey",execute:t=>{t.model.dispatch("ACTIVATE_SHEET",{sheetIdFrom:o,sheetIdTo:e})}}),i++}const s=e.currentTarget,{left:r}=s.getBoundingClientRect(),n=this.bottomBarRef.el.getBoundingClientRect().top;this.openContextMenu(r,n,"listSheets",t)}openContextMenu(e,t,o,i){this.menuState.isOpen=!0,this.menuState.menuId=o,this.menuState.menuItems=i.getMenuItems(),this.menuState.position={x:e,y:t}}onSheetContextMenu(e,t,o){const i=o.currentTarget,{top:s,left:r}=i.getBoundingClientRect();o.closedMenuId!==e?this.openContextMenu(r,s,e,t):this.closeMenu()}closeMenu(){this.menuState.isOpen=!1,this.menuState.menuId=void 0,this.menuState.menuItems=[],this.menuState.position=null}closeContextMenuWithId(e){this.menuState.menuId===e&&this.closeMenu()}onWheel(e){this.targetScroll=void 0;e.currentTarget.scrollLeft+=.5*e.deltaY}onScroll(){this.updateScrollState(),this.targetScroll===this.sheetListCurrentScroll&&(this.targetScroll=void 0)}onArrowLeft(e){if(!this.state.isSheetListScrollableLeft)return;this.targetScroll||(this.targetScroll=this.sheetListCurrentScroll);const t=this.targetScroll-this.sheetListWidth;this.scrollSheetListTo(Math.max(0,t))}onArrowRight(e){if(!this.state.isSheetListScrollableRight)return;this.targetScroll||(this.targetScroll=this.sheetListCurrentScroll);const t=this.targetScroll+this.sheetListWidth;this.scrollSheetListTo(Math.min(this.sheetListMaxScroll,t))}updateScrollState(){this.state.isSheetListScrollableLeft=this.sheetListCurrentScroll>0,this.state.isSheetListScrollableRight=this.sheetListCurrentScroll<this.sheetListMaxScroll}scrollSheetListTo(e){this.sheetListRef.el&&(this.targetScroll=e,this.sheetListRef.el.scrollTo({top:0,left:e,behavior:"smooth"}))}onSheetMouseDown(e,t){if(0!==t.button||this.env.model.getters.isReadonly())return;this.closeMenu();const o=t.clientX;document.body.style.cursor="move";const i=this.getVisibleSheets(),s=this.getSheetItemRects(),r=i.map(((e,t)=>({id:e.id,size:s[t].width,position:s[t].x})));this.dndHelper=new Nx({draggedItemId:e,mouseX:o,items:r,containerEl:this.sheetListRef.el,onChange:e=>{this.sheetState.isDnd=!0,this.sheetState.sheetDndPositions=e},onCancel:()=>this.stopDragging(),onDragEnd:(e,t)=>this.onDragEnd(e,t)})}onDragEnd(e,t){const o=t-this.sheetState.sheetList.findIndex((t=>t.id===e));e&&0!==o&&this.env.model.dispatch("MOVE_SHEET",{sheetId:e,delta:o}),this.stopDragging()}getSheetStyle(e){const t={};return this.sheetState.isDnd&&(t.position="relative",t.left=(this.sheetState.sheetDndPositions?.[e]||0)+"px",t.transition="left 0.5s",t.cursor="move"),this.isDragged(e)&&(t.transition="left 0s",t["z-index"]="1000"),Yi(t)}stopDragging(){document.body.style.cursor="",this.sheetState.sheetList=this.getVisibleSheets(),this.sheetState.isDnd=!1,this.sheetState.sheetDndPositions=void 0,this.dndHelper=void 0}getSheetItemRects(){return Array.from(this.bottomBarRef.el.querySelectorAll(".o-sheet")).map((e=>e.getBoundingClientRect())).map((e=>({x:e.x,width:e.width-1,y:e.y,height:e.height})))}getSheetClasses(e){let t="";return this.isDragged(e)&&(t+="dragged "),this.sheetState.isDnd&&(t+="dragging "),t}get sheetListCurrentScroll(){return this.sheetListRef.el?this.sheetListRef.el.scrollLeft:0}get sheetListWidth(){return this.sheetListRef.el?this.sheetListRef.el.clientWidth:0}get sheetListMaxScroll(){return this.sheetListRef.el?this.sheetListRef.el.scrollWidth-this.sheetListRef.el.clientWidth:0}}_x.props={onClick:Function},Wi`
|
|
1566
1566
|
.o-dashboard-clickable-cell {
|
|
1567
1567
|
position: absolute;
|
|
1568
1568
|
cursor: pointer;
|
|
1569
1569
|
}
|
|
1570
|
-
`;
|
|
1570
|
+
`;class Fx extends t.Component{static template="o-spreadsheet-SpreadsheetDashboard";static components={GridOverlay:lS,GridPopover:cS,Popover:Lr,VerticalScrollBar:wS,HorizontalScrollBar:ES,FilterIconsOverlay:jv};onMouseWheel;canvasPosition;hoveredCell;setup(){const e=t.useRef("grid");this.canvasPosition=Nr(e),this.hoveredCell=t.useState({col:void 0,row:void 0}),t.useChildSubEnv({getPopoverContainerRect:()=>this.getGridRect()}),pS("canvas",this.env.model,(()=>this.env.model.getters.getSheetViewDimension())),this.onMouseWheel=mS(((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:o}=this.env.model.getters.getColDimensions(e,t);return Yi({"max-width":`${o}px`})}get gridOverlayDimensions(){return Yi({height:"100%",width:"100%"})}getCellClickableStyle(e){return Yi({top:`${e.y}px`,left:`${e.x}px`,width:`${e.width}px`,height:`${e.height}px`})}getClickableCells(){const e=[],t=this.env.model.getters.getActiveSheetId();for(const o of this.env.model.getters.getSheetViewVisibleCols())for(const i of this.env.model.getters.getSheetViewVisibleRows()){const s={sheetId:t,col:o,row:i},r=this.getClickableAction(s);if(!r)continue;let n;n=this.env.model.getters.isInMerge(s)?this.env.model.getters.getMerge(s):wi({col:o,row:i});const a=this.env.model.getters.getVisibleRect(n);e.push({coordinates:a,position:{col:o,row:i},action:r})}return e}getClickableAction(e){for(const t of xx.getAll().sort(((e,t)=>e.sequence-t.sequence)))if(t.condition(e,this.env))return t.execute;return!1}selectClickableCell(e){const{position:t,action:o}=e;o({...t,sheetId:this.env.model.getters.getActiveSheetId()},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:o,scrollY:i}=this.env.model.getters.getActiveSheetDOMScrollInfo();this.env.model.dispatch("SET_VIEWPORT_OFFSET",{offsetX:o+e,offsetY:i+t})}getGridRect(){return{...this.canvasPosition,...this.env.model.getters.getSheetViewDimensionWithHeaders()}}}Fx.props={},Wi`
|
|
1571
1571
|
.o-sidePanel {
|
|
1572
1572
|
display: flex;
|
|
1573
1573
|
flex-direction: column;
|
|
@@ -1741,7 +1741,7 @@
|
|
|
1741
1741
|
}
|
|
1742
1742
|
}
|
|
1743
1743
|
}
|
|
1744
|
-
`;class
|
|
1744
|
+
`;class Dx extends t.Component{static template="o-spreadsheet-SidePanel";state;setup(){this.state=t.useState({panel:Av.get(this.props.component)}),t.onWillUpdateProps((e=>this.state.panel=Av.get(e.component)))}getTitle(){return"function"==typeof this.state.panel.title?this.state.panel.title(this.env):this.state.panel.title}}Dx.props={component:String,panelProps:{type:Object,optional:!0},onCloseSidePanel:Function},Wi`
|
|
1745
1745
|
.o-menu-item-button {
|
|
1746
1746
|
display: flex;
|
|
1747
1747
|
justify-content: center;
|
|
@@ -1754,7 +1754,7 @@
|
|
|
1754
1754
|
opacity: 0.6;
|
|
1755
1755
|
cursor: default;
|
|
1756
1756
|
}
|
|
1757
|
-
`;class
|
|
1757
|
+
`;class Lx extends t.Component{static template="o-spreadsheet-ActionButton";actionButton=kg(this.props.action);setup(){t.onWillUpdateProps((()=>this.actionButton=kg(this.props.action)))}get isVisible(){return this.actionButton.isVisible(this.env)}get isEnabled(){return this.actionButton.isEnabled(this.env)}get isActive(){return this.actionButton.isActive?.(this.env)}get title(){const e=this.actionButton.name(this.env),t=this.actionButton.description(this.env);return e+(t?` (${t})`:"")}get iconTitle(){return this.actionButton.icon(this.env)}onClick(e){this.isEnabled&&(this.props.onClick?.(e),this.actionButton.execute?.(this.env))}get buttonStyle(){return this.props.selectedColor?Yi({"border-bottom":`4px solid ${this.props.selectedColor}`,height:"16px","margin-top":"2px"}):""}}Lx.props={action:Object,hasTriangleDownIcon:{type:Boolean,optional:!0},selectedColor:{type:String,optional:!0},class:{type:String,optional:!0},onClick:{type:Function,optional:!0}};const Px=[[["all","o-spreadsheet-Icon.BORDERS"],["hv","o-spreadsheet-Icon.BORDER_HV"],["h","o-spreadsheet-Icon.BORDER_H"],["v","o-spreadsheet-Icon.BORDER_V"],["external","o-spreadsheet-Icon.BORDER_EXTERNAL"]],[["left","o-spreadsheet-Icon.BORDER_LEFT"],["top","o-spreadsheet-Icon.BORDER_TOP"],["right","o-spreadsheet-Icon.BORDER_RIGHT"],["bottom","o-spreadsheet-Icon.BORDER_BOTTOM"],["clear","o-spreadsheet-Icon.BORDER_CLEAR"]]];Wi`
|
|
1758
1758
|
.o-border-selector {
|
|
1759
1759
|
padding: 4px;
|
|
1760
1760
|
background-color: white;
|
|
@@ -1822,7 +1822,7 @@
|
|
|
1822
1822
|
margin: 5px 0px 0px 0px !important;
|
|
1823
1823
|
height: 25px !important;
|
|
1824
1824
|
}
|
|
1825
|
-
`;class
|
|
1825
|
+
`;class kx extends t.Component{static template="o-spreadsheet-BorderEditor";static components={ColorPickerWidget:lv,Popover:Lr};BORDER_POSITIONS=Px;lineStyleButtonRef=t.useRef("lineStyleButton");borderStyles=vs;state=t.useState({activeTool:void 0});toggleDropdownTool(e){const t=this.state.activeTool===e;this.state.activeTool=t?void 0:e}closeDropdown(){this.state.activeTool=void 0}setBorderPosition(e){this.props.onBorderPositionPicked(e),this.closeDropdown()}setBorderColor(e){this.props.onBorderColorPicked(e),this.closeDropdown()}setBorderStyle(e){this.props.onBorderStylePicked(e),this.closeDropdown()}get lineStylePickerPopoverProps(){return{anchorRect:this.lineStylePickerAnchorRect,positioning:"BottomLeft",verticalOffset:0}}get popoverProps(){return{anchorRect:this.props.anchorRect,maxHeight:this.props.maxHeight,positioning:"BottomLeft",verticalOffset:0}}get lineStylePickerAnchorRect(){const e=this.lineStyleButtonRef.el;if(null===e)return{x:0,y:0,width:0,height:0};const t=e.getBoundingClientRect();return{x:t.x,y:t.y,width:t.width,height:t.height}}}kx.props={class:{type:String,optional:!0},currentBorderColor:{type:String,optional:!1},currentBorderStyle:{type:String,optional:!1},currentBorderPosition:{type:String,optional:!0},onBorderColorPicked:Function,onBorderStylePicked:Function,onBorderPositionPicked:Function,maxHeight:{type:Number,optional:!0},anchorRect:Object};class Ux extends t.Component{static template="o-spreadsheet-BorderEditorWidget";static components={BorderEditor:kx};borderEditorButtonRef=t.useRef("borderEditorButton");state=t.useState({currentColor:Q,currentStyle:K,currentPosition:void 0});get borderEditorAnchorRect(){const e=this.borderEditorButtonRef.el.getBoundingClientRect();return{x:e.x,y:e.y,width:e.width,height:e.height}}onBorderPositionPicked(e){this.state.currentPosition=e,this.updateBorder()}onBorderColorPicked(e){this.state.currentColor=e,this.updateBorder()}onBorderStylePicked(e){this.state.currentStyle=e,this.updateBorder()}updateBorder(){void 0!==this.state.currentPosition&&this.env.model.dispatch("SET_ZONE_BORDERS",{sheetId:this.env.model.getters.getActiveSheetId(),target:this.env.model.getters.getSelectedZones(),border:{position:this.state.currentPosition,color:this.state.currentColor,style:this.state.currentStyle}})}}Ux.props={toggleBorderEditor:Function,showBorderEditor:Boolean,disabled:{type:Boolean,optional:!0},dropdownMaxHeight:{type:Number,optional:!0},class:{type:String,optional:!0}};Wi`
|
|
1826
1826
|
.o-topbar-composer {
|
|
1827
1827
|
height: fit-content;
|
|
1828
1828
|
margin-top: -1px;
|
|
@@ -1839,7 +1839,7 @@
|
|
|
1839
1839
|
.user-select-text {
|
|
1840
1840
|
user-select: text;
|
|
1841
1841
|
}
|
|
1842
|
-
`;class
|
|
1842
|
+
`;class Vx extends t.Component{static template="o-spreadsheet-TopBarComposer";static components={Composer:$v};get composerStyle(){const e={padding:"5px 0px 5px 8px","max-height":"100px","line-height":"24px"};return e.height="inactive"===this.props.focus?"34px":"fit-content",Yi(e)}get containerStyle(){return"inactive"===this.props.focus?Yi({"border-color":M,"border-right":"none"}):Yi({"border-color":E})}}Vx.props={focus:{validate:e=>["inactive","cellFocus","contentFocus"].includes(e)},onComposerContentFocused:Function},Wi`
|
|
1843
1843
|
.o-font-size-editor {
|
|
1844
1844
|
height: calc(100% - 4px);
|
|
1845
1845
|
input.o-font-size {
|
|
@@ -1863,7 +1863,7 @@
|
|
|
1863
1863
|
background-color: rgba(0, 0, 0, 0.08);
|
|
1864
1864
|
}
|
|
1865
1865
|
}
|
|
1866
|
-
`;class
|
|
1866
|
+
`;class Bx extends t.Component{static template="o-spreadsheet-FontSizeEditor";static components={};fontSizes=be;dropdown=t.useState({isOpen:!1});inputRef=t.useRef("inputFontSize");rootEditorRef=t.useRef("FontSizeEditor");setup(){t.useExternalListener(window,"click",this.onExternalClick,{capture:!0})}onExternalClick(e){yr(this.rootEditorRef.el,e)||this.closeFontList()}get currentFontSize(){return this.env.model.getters.getCurrentStyle().fontSize||Z}toggleFontList(){this.dropdown.isOpen?this.closeFontList():(this.props.onToggle(),this.inputRef.el.focus())}closeFontList(){this.dropdown.isOpen=!1}setSize(e){const t=xe(Math.floor(parseFloat(e)),1,400);gm(this.env,{fontSize:t}),this.closeFontList()}setSizeFromInput(e){this.setSize(e.target.value)}setSizeFromList(e){this.setSize(e)}onInputFocused(e){this.dropdown.isOpen=!0,e.target.select()}onInputKeydown(e){if("Enter"===e.key||"Escape"===e.key){this.closeFontList();const t=e.target;"Escape"===e.key&&(t.value=`${this.currentFontSize}`),this.props.onToggle()}}}Bx.props={onToggle:Function,dropdownStyle:String,class:String};class zx extends t.Component{static template="o-spreadsheet-PaintFormatButton";get isActive(){return this.env.model.getters.isPaintingFormat()}onDblClick(){this.env.model.dispatch("ACTIVATE_PAINT_FORMAT",{persistent:!0})}togglePaintFormat(){this.isActive?this.env.model.dispatch("CANCEL_PAINT_FORMAT"):this.env.model.dispatch("ACTIVATE_PAINT_FORMAT",{persistent:!1})}}zx.props={class:{type:String,optional:!0}},Wi`
|
|
1867
1867
|
.o-spreadsheet-topbar {
|
|
1868
1868
|
line-height: 1.2;
|
|
1869
1869
|
font-size: 13px;
|
|
@@ -1948,7 +1948,7 @@
|
|
|
1948
1948
|
}
|
|
1949
1949
|
}
|
|
1950
1950
|
}
|
|
1951
|
-
`;class
|
|
1951
|
+
`;class Hx extends t.Component{static template="o-spreadsheet-TopBar";get dropdownStyle(){return`max-height:${this.props.dropdownMaxHeight}px`}static components={ColorPickerWidget:lv,ColorPicker:av,Menu:Vr,TopBarComposer:Vx,FontSizeEditor:Bx,ActionButton:Lx,PaintFormatButton:zx,BorderEditorWidget:Ux};state=t.useState({menuState:{isOpen:!1,position:null,menuItems:[]},activeTool:"",fillColor:"#ffffff",textColor:"#000000"});isSelectingMenu=!1;openedEl=null;menus=[];EDIT=Zm;FORMAT=$b;VIEW=Kf;formatNumberMenuItemSpec=qb;isntToolbarMenu=!1;setup(){t.useExternalListener(window,"click",this.onExternalClick),t.onWillStart((()=>this.updateCellState())),t.onWillUpdateProps((()=>this.updateCellState()))}get topbarComponents(){return Ov.getAll().filter((e=>!e.isVisible||e.isVisible(this.env)))}onExternalClick(e){this.openedEl!==e.target&&this.closeMenus()}onClick(){this.props.onClick(),this.closeMenus()}onMenuMouseOver(e,t){this.isSelectingMenu&&this.isntToolbarMenu&&this.openMenu(e,t)}toggleDropdownTool(e,t){const o=this.state.activeTool===e;this.closeMenus(),this.state.activeTool=o?"":e,this.openedEl=o?null:t.target}toggleContextMenu(e,t){this.state.menuState.isOpen&&this.isntToolbarMenu?this.closeMenus():(this.openMenu(e,t),this.isntToolbarMenu=!0)}toggleToolbarContextMenu(e,t){if(this.state.menuState.isOpen&&!this.isntToolbarMenu)this.closeMenus();else{const o=kg(e);this.openMenu(o,t),this.isntToolbarMenu=!1}}openMenu(e,t){const{left:o,top:i,height:s}=t.currentTarget.getBoundingClientRect();this.state.activeTool="",this.state.menuState.isOpen=!0,this.state.menuState.position={x:o,y:i+s},this.state.menuState.menuItems=e.children(this.env).sort(((e,t)=>e.sequence-t.sequence)),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.getCurrentStyle();this.state.fillColor=e.fillColor||"#ffffff",this.state.textColor=e.textColor||"#000000",this.menus=Yb.getMenuItems()}getMenuName(e){return e.name(this.env)}setColor(e,t){gm(this.env,{[e]:t}),this.onClick()}}Hx.props={onClick:Function,focusComposer:String,onComposerContentFocused:Function,dropdownMaxHeight:Number};class $x{clipboard;constructor(e){this.clipboard=e}async write(e){try{this.clipboard?.write(this.getClipboardItems(e))}catch(e){}}async writeText(e){try{this.clipboard?.writeText(e)}catch(e){}}async readText(){let e;try{e=await navigator.permissions.query({name:"clipboard-read"})}catch(e){}try{return{status:"ok",content:await this.clipboard.readText()}}catch(t){return{status:"denied"===e?.state?"permissionDenied":"notImplemented"}}}getClipboardItems(e){return[new ClipboardItem({[cs.PlainText]:this.getBlob(e,cs.PlainText),[cs.Html]:this.getBlob(e,cs.Html)})]}getBlob(e,t){return new Blob([e[t]||""],{type:t})}}const Wx="#000";Wi`
|
|
1952
1952
|
.o-spreadsheet {
|
|
1953
1953
|
position: relative;
|
|
1954
1954
|
display: grid;
|
|
@@ -1988,9 +1988,9 @@
|
|
|
1988
1988
|
}
|
|
1989
1989
|
&:not(.o-disabled):not(.active):hover {
|
|
1990
1990
|
background-color: ${x};
|
|
1991
|
-
color: ${
|
|
1991
|
+
color: ${Wx};
|
|
1992
1992
|
.o-icon {
|
|
1993
|
-
color: ${
|
|
1993
|
+
color: ${Wx};
|
|
1994
1994
|
}
|
|
1995
1995
|
}
|
|
1996
1996
|
&.active {
|
|
@@ -2051,23 +2051,23 @@
|
|
|
2051
2051
|
outline: none;
|
|
2052
2052
|
}
|
|
2053
2053
|
}
|
|
2054
|
-
`;const Yx=e=>e;class jx extends t.Component{static template="o-spreadsheet-Spreadsheet";static components={TopBar:Gx,Grid:RS,BottomBar:Dx,SidePanel:kx,SpreadsheetDashboard:Px};static _t=Yx;sidePanel;composer;_focusGrid;keyDownMapping;isViewportTooSmall=!1;get model(){return this.props.model}getStyle(){return this.env.isDashboard()?"grid-template-rows: auto;":"grid-template-rows: 63px auto 37px"}setup(){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",{})};const e=this.model.config.external.fileStore;t.useSubEnv({model:this.model,imageProvider:e?new Rx(e):void 0,loadCurrencies:this.model.config.external.loadCurrencies,loadLocales:this.model.config.external.loadLocales,isDashboard:()=>this.model.getters.isDashboard(),openSidePanel:this.openSidePanel.bind(this),toggleSidePanel:this.toggleSidePanel.bind(this),_t:jx._t,clipboard:this.env.clipboard||new qx(navigator.clipboard),startCellEdition:e=>this.onGridComposerCellFocused(e),focusableElement:new Tx}),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(isFinite(e)&&isFinite(t))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.isOpen&&e!==this.sidePanel.component&&this.sidePanel.panelProps?.onCloseSidePanel?.(),this.sidePanel.component=e,this.sidePanel.panelProps=t,this.sidePanel.isOpen=!0}closeSidePanel(){this.sidePanel.isOpen=!1,this.focusGrid(),this.sidePanel.panelProps?.onCloseSidePanel?.()}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()}onKeydown(e){let t="";Or(e)&&(t+="CTRL+"),t+=e.key.toUpperCase();let o=this.keyDownMapping[t];if(o)return e.preventDefault(),e.stopPropagation(),void o()}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(e){this.model.getters.isReadonly()||(this.model.dispatch("UNFOCUS_SELECTION_INPUT"),this.composer.topBarFocus="inactive",this.composer.gridFocusMode="contentFocus",this.setComposerContent({selection:e}))}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}}jx.props={model:Object};class Xx{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 Kx(e){return om.get(e.type)(e)}function Qx(e){if("string"==typeof e)return{};if("number"==typeof e)return[];throw new Error("Cannot create new node")}class Jx{buildTransformation;operations;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(){return this.operations[this.operations.length-1]?.id}getFirstOperationAmong(e,t){for(const o of this.operations){if(o.id===e)return e;if(o.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 o=this.buildTransformation.with(e.data),{before:i,operation:s,after:r}=this.locateOperation(t);this.operations=[...i,s,e,...r.map((e=>e.transformed(o)))]}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 Jx(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:o}=this.locateOperation(e);this.operations=t.concat([o])}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 ey{id;data;constructor(e,t){this.id=e,this.data=t}transformed(e){return new ty(this.id,ze((()=>e(this.data))))}}class ty{id;lazyData;constructor(e,t){this.id=e,this.lazyData=t}get data(){return this.lazyData()}transformed(e){return new ty(this.id,this.lazyData.map(e))}}class oy{operations;constructor(e){this.operations=e}[Symbol.iterator](){return this.operations[Symbol.iterator]()}stopWith(e){return new oy(function*(e,t){for(const o of e)if(yield o,o.operation.id===t)return}(this.operations,e))}stopBefore(e){return new oy(function*(e,t){for(const o of e){if(o.operation.id===t)return;yield o}}(this.operations,e))}startAfter(e){return new oy(function*(e,t){let o=!0;for(const i of e)o||(yield i),i.operation.id===t&&(o=!1)}(this.operations,e))}}class iy{buildTransformation;branches;branchingOperationIds=new Map;constructor(e,t){this.buildTransformation=e,this.branches=[t]}getLastBranch(){return this.branches[this.branches.length-1]}execution(e){return new oy(Re(this._execution(e),this._execution(e)))}revertedExecution(e){return new oy(Re(this._revertedExecution(e),this._revertedExecution(e)))}insertOperationLast(e,t){const o=e.getLastOperationId()||this.previousBranch(e)?.getLastOperationId();e.append(t),o&&this.insertPrevious(e,t,o)}insertOperationAfter(e,t,o){e.insert(t,o),this.updateNextWith(e,t,o),this.insertPrevious(e,t,o)}undo(e,t){const o=this.buildTransformation.without(t.data),i=this.branchingOperationIds.get(e);this.branchingOperationIds.set(e,t.id);const s=e.fork(t.id);i&&this.branchingOperationIds.set(s,i),this.insertBranchAfter(e,s),this.transform(s,o)}redo(e){const t=this.nextBranch(e);if(!t)return;const o=this.nextBranch(t);this.removeBranchFromTree(t);const i=this.branchingOperationIds.get(t);i?this.branchingOperationIds.set(e,i):this.branchingOperationIds.delete(e),o&&this.rebaseUp(o)}drop(e){for(const t of this.branches)t.contains(e)&&t.cutBefore(e)}findOperation(e,t){for(const o of this.revertedExecution(e))if(o.operation.id===t)return o;throw new Error(`Operation ${t} not found`)}rebaseUp(e){const{previousBranch:t,branchingOperation:o}=this.findPreviousBranchingOperation(e);if(!t||!o)return;const i=this.buildTransformation.without(o.data),s=t.fork(o.id);this.branchingOperationIds.set(s,this.branchingOperationIds.get(e)),this.removeBranchFromTree(e),this.insertBranchAfter(t,s),s.transform(i);const r=this.nextBranch(s);r&&this.rebaseUp(r)}removeBranchFromTree(e){const t=this.branches.findIndex((t=>t===e));this.branches.splice(t,1)}insertBranchAfter(e,t){const o=this.branches.findIndex((t=>t===e));this.branches.splice(o+1,0,t)}updateNextWith(e,t,o){const i=this.branchingOperationIds.get(e),s=this.nextBranch(e);if(i&&s)if(e.getFirstOperationAmong(o,i)===i){const r=this.addToNextBranch(e,s,i,t,o);this.updateNextWith(s,r,o)}else{const e=this.buildTransformation.with(t.data);this.transform(s,e)}}addToNextBranch(e,t,o,i,s){let r=i;return s===o?(r=this.getTransformedOperation(e,o,i),t.prepend(r)):t.contains(s)?(r=this.getTransformedOperation(e,o,i),t.insert(r,s)):t.append(i),r}getTransformedOperation(e,t,o){const i=e.getOperation(t),s=this.buildTransformation.without(i.data);return o.transformed(s)}shouldExecute(e,t){return t.id!==this.branchingOperationIds.get(e)}transform(e,t){e.transform(t);const o=this.nextBranch(e);o&&this.transform(o,t)}insertPrevious(e,t,o){const{previousBranch:i,branchingOperation:s}=this.findPreviousBranchingOperation(e);if(!i||!s)return;const r=this.buildTransformation.with(s.data),n=e.fork(o);n.transform(r),i.cutAfter(o),i.appendBranch(n);const a=t.transformed(r);this.insertPrevious(i,a,o)}findPreviousBranchingOperation(e){const t=this.previousBranch(e);if(!t)return{previousBranch:void 0,branchingOperation:void 0};const o=this.branchingOperationIds.get(t);return o?{previousBranch:t,branchingOperation:t.getOperation(o)}:{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 o=!!t;const i=e.getOperations();for(let s=i.length-1;s>=0;s--){const r=i[s];r.id===t&&(o=!1),o||(yield{operation:r,branch:e,isCancelled:!this.shouldExecute(e,r)})}const s=this.previousBranch(e);yield*s?this._revertedExecution(s):[]}*_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 sy{HEAD_BRANCH;HEAD_OPERATION;tree;applyOperation;revertOperation;buildEmpty;buildTransformation;constructor(e){this.applyOperation=e.applyOperation,this.revertOperation=e.revertOperation,this.buildEmpty=e.buildEmpty,this.buildTransformation=e.buildTransformation,this.HEAD_BRANCH=new Jx(this.buildTransformation),this.tree=new iy(this.buildTransformation,this.HEAD_BRANCH);const t=e.initialOperationId,o=new ey(t,this.buildEmpty(t));this.tree.insertOperationLast(this.HEAD_BRANCH,o),this.HEAD_OPERATION=o}get(e){return this.tree.findOperation(this.HEAD_BRANCH,e).operation.data}append(e,t){const o=new ey(e,t),i=this.tree.getLastBranch();this.tree.insertOperationLast(i,o),this.HEAD_BRANCH=i,this.HEAD_OPERATION=o}insert(e,t,o){const i=new ey(e,t);this.revertTo(o),this.tree.insertOperationAfter(this.HEAD_BRANCH,i,o),this.fastForward()}undo(e,t,o){const{branch:i,operation:s}=this.tree.findOperation(this.HEAD_BRANCH,e);this.revertBefore(e),this.tree.undo(i,s),this.fastForward(),this.insert(t,this.buildEmpty(t),o)}redo(e,t,o){const{branch:i}=this.tree.findOperation(this.HEAD_BRANCH,e);this.revertBefore(e),this.tree.redo(i),this.fastForward(),this.insert(t,this.buildEmpty(t),o)}drop(e){this.revertBefore(e),this.tree.drop(e)}getRevertedExecution(){const e=[],t=this.tree.revertedExecution(this.HEAD_BRANCH);for(const{operation:o}of t)e.push(o.data);return 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:o,isCancelled:i}of e)i||this.revertOperation(o.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:o,isCancelled:i}of e)i||this.applyOperation(t.data),this.HEAD_OPERATION=t,this.HEAD_BRANCH=o}}function ry(e){return new sy({initialOperationId:e.initialRevisionId,applyOperation:t=>{const o=t.commands.slice(),{changes:i}=e.recordChanges((()=>{for(const t of o)e.dispatch(t)}));t.setChanges(i)},revertOperation:e=>function(e){for(const t of e.slice().reverse())for(let e=t.changes.length-1;e>=0;e--){ny(t.changes[e],"before")}}([e]),buildEmpty:e=>new Gw(e,"empty",[]),buildTransformation:{with:e=>t=>new Gw(t.id,t.clientId,$w(t.commands,e.commands),t.rootCommand,void 0,t.timestamp),without:e=>t=>new Gw(t.id,t.clientId,$w(t.commands,e.commands.map(Kx).flat()),t.rootCommand,void 0,t.timestamp)}})}function ny(e,t){let o=e.path[0];const i=e.path[e.path.length-1];for(let t=1;t<e.path.slice(0,-1).length;t++){const i=e.path[t];if(void 0===o[i]){const s=e.path[t+1];o[i]=Qx(s)}o=o[i]}void 0===e[t]?delete o[i]:o[i]=e[t]}class ay{observers=[];defaultSubscription;mainSubscription;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){if(this.observers.find((t=>t.owner===e)))throw new Error("You are already subscribed forever");this.mainSubscription?.owner&&this.mainSubscription.owner!==e&&this.mainSubscription.callbacks.release?.(),this.mainSubscription={owner:e,callbacks:t}}release(e){this.mainSubscription?.owner!==e||this.observers.find((t=>t.owner===e))||(this.mainSubscription=this.defaultSubscription)}getBackToDefault(){this.mainSubscription!==this.defaultSubscription&&(this.mainSubscription?.callbacks.release?.(),this.mainSubscription=this.defaultSubscription)}isListening(e){return this.mainSubscription?.owner===e}send(e){this.mainSubscription?.callbacks.handleEvent(e),[...this.observers].forEach((t=>t.callbacks.handleEvent(e)))}}class ly{getters;stream;anchor;defaultAnchor;constructor(e){this.getters=e,this.stream=new ay,this.anchor={cell:{col:0,row:0},zone:wi({col:0,row:0})},this.defaultAnchor=this.anchor}capture(e,t,o){this.stream.capture(e,o),this.anchor=t}registerAsDefault(e,t,o){this.checkAnchorZoneOrThrow(t),this.stream.registerAsDefault(e,o),this.defaultAnchor=t,this.capture(e,t,o)}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()}modifyAnchor(e,t,o){const i=this.getters.getActiveSheetId();return e={...e,zone:this.getters.expandZone(i,e.zone)},this.processEvent({options:o,anchor:e,mode:t})}selectZone(e,t={scrollIntoView:!0}){return this.modifyAnchor(e,"overrideSelection",t)}selectCell(e,t){const o=wi({col:e,row:t});return this.selectZone({zone:o,cell:{col:e,row:t}},{scrollIntoView:!0})}moveAnchorCell(e,t=1){if("end"!==t&&t<=0)return new fs(86);const{col:o,row:i}=this.getNextAvailablePosition(e,t);return this.selectCell(o,i)}setAnchorCorner(e,t){const o=this.getters.getActiveSheetId(),{col:i,row:s}=this.anchor.cell,r={left:Math.min(i,e),top:Math.min(s,t),right:Math.max(i,e),bottom:Math.max(s,t)},n={zone:this.getters.expandZone(o,r),cell:{col:i,row:s}};return this.processEvent({mode:"updateAnchor",anchor:n,options:{scrollIntoView:!1}})}addCellToSelection(e,t){const o=this.getters.getActiveSheetId();({col:e,row:t}=this.getters.getMainCellPosition({sheetId:o,col:e,row:t}));const i=this.getters.expandZone(o,wi({col:e,row:t}));return this.processEvent({options:{scrollIntoView:!0},anchor:{zone:i,cell:{col:e,row:t}},mode:"newAnchor"})}resizeAnchorZone(e,t=1){if("end"!==t&&t<=0)return new fs(86);const o=this.getters.getActiveSheetId(),i=this.anchor,{col:s,row:r}=i.cell,{left:n,right:a,top:l,bottom:c}=i.zone,h=this.getStartingPosition(e);let[d,u]=this.deltaToTarget(h,e,t);if(0===d&&0===u)return fs.Success;let g=i.zone;const p=e=>{e=Ei(e);const{left:t,right:i,top:s,bottom:r}=this.getters.expandZone(o,e);return{left:Math.max(0,t),right:Math.min(this.getters.getNumberCols(o)-1,i),top:Math.max(0,s),bottom:Math.min(this.getters.getNumberRows(o)-1,r)}},{col:m,row:f}=this.getReferencePosition();let b=0;for(;null!==g;){if(b++,d<0){const e=this.getNextAvailableCol(d,a-(b-1),f);g=m<=a-b?p({top:l,left:n,bottom:c,right:e}):null}if(d>0){const e=this.getNextAvailableCol(d,n+(b-1),f);g=n+b<=m?p({top:l,left:e,bottom:c,right:a}):null}if(u<0){const e=this.getNextAvailableRow(u,m,c-(b-1));g=f<=c-b?p({top:l,left:n,bottom:e,right:a}):null}if(u>0){const e=this.getNextAvailableRow(u,m,l+(b-1));g=l+b<=f?p({top:e,left:n,bottom:c,right:a}):null}if(g=g?Ei(g):g,g&&!hi(g,i.zone))return this.processEvent({options:{scrollIntoView:!0},mode:"updateAnchor",anchor:{zone:g,cell:{col:s,row:r}}})}g=p(li({top:r,bottom:r,left:s,right:s},Ei({top:this.getNextAvailableRow(u,m,l),left:this.getNextAvailableCol(d,n,f),bottom:this.getNextAvailableRow(u,m,c),right:this.getNextAvailableCol(d,a,f)})));const v={zone:g,cell:{col:s,row:r}};return this.processEvent({anchor:v,mode:"updateAnchor",options:{scrollIntoView:!0}})}selectColumn(e,t){const o=this.getters.getActiveSheetId(),i=this.getters.getNumberRows(o)-1;let s={left:e,right:e,top:0,bottom:i};const r=this.getters.findFirstVisibleColRowIndex(o,"ROW");let n,a;switch(t){case"overrideSelection":case"newAnchor":n=e,a=r;break;case"updateAnchor":({col:n,row:a}=this.anchor.cell),s=li(s,{left:n,right:n,top:r,bottom:i})}return this.processEvent({options:{scrollIntoView:!1,unbounded:!0},anchor:{zone:s,cell:{col:n,row:a}},mode:t})}selectRow(e,t){const o=this.getters.getActiveSheetId(),i=this.getters.getNumberCols(o)-1;let s={top:e,bottom:e,left:0,right:i};const r=this.getters.findFirstVisibleColRowIndex(o,"COL");let n,a;switch(t){case"overrideSelection":case"newAnchor":n=r,a=e;break;case"updateAnchor":({col:n,row:a}=this.anchor.cell),s=li(s,{left:r,right:i,top:a,bottom:a})}return this.processEvent({options:{scrollIntoView:!1,unbounded:!0},anchor:{zone:s,cell:{col:n,row:a}},mode:t})}loopSelection(){const e=this.getters.getActiveSheetId(),t=this.anchor;if(hi(this.anchor.zone,this.getters.getSheetZone(e)))return this.modifyAnchor({...t,zone:wi(t.cell)},"updateAnchor",{scrollIntoView:!1});const o=this.expandZoneToTable(t.zone);return We(o,t.zone)?this.selectAll():this.modifyAnchor({...t,zone:o},"updateAnchor",{scrollIntoView:!1})}selectTableAroundSelection(){const e=this.expandZoneToTable(this.anchor.zone);return this.modifyAnchor({...this.anchor,zone:e},"updateAnchor",{scrollIntoView:!1})}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({mode:"overrideSelection",anchor:{zone:t,cell:this.anchor.cell},options:{scrollIntoView:!1}})}isListening(e){return this.stream.isListening(e)}processEvent(e){const t={...e,previousAnchor:Ce(this.anchor)},o=this.checkEventAnchorZone(t);return 0!==o?new fs(o):(this.anchor=t.anchor,this.stream.send(t),fs.Success)}checkEventAnchorZone(e){return this.checkAnchorZone(e.anchor)}checkAnchorZone(e){const{cell:t,zone:o}=e;if(!ui(t.col,t.row,o))return 17;const{left:i,right:s,top:r,bottom:n}=o,a=this.getters.getActiveSheetId(),l=this.getters.findVisibleHeader(a,"COL",i,s);return void 0===this.getters.findVisibleHeader(a,"ROW",r,n)||void 0===l?18:0}checkAnchorZoneOrThrow(e){if(17===this.checkAnchorZone(e))throw new Error(s("The provided anchor is invalid. The cell must be part of the zone."))}getNextAvailablePosition(e,t=1){const{col:o,row:i}=this.anchor.cell,s=this.deltaToTarget({col:o,row:i},e,t);return{col:this.getNextAvailableCol(s[0],o,i),row:this.getNextAvailableRow(s[1],o,i)}}getNextAvailableCol(e,t,o){const i=this.getters.getActiveSheetId(),s={col:t,row:o};return this.getNextAvailableHeader(e,"COL",t,s,(e=>this.getters.isInSameMerge(i,t,o,e,o)))}getNextAvailableRow(e,t,o){const i=this.getters.getActiveSheetId(),s={col:t,row:o};return this.getNextAvailableHeader(e,"ROW",o,s,(e=>this.getters.isInSameMerge(i,t,o,t,e)))}getNextAvailableHeader(e,t,o,i,s){const r=this.getters.getActiveSheetId();if(0===e)return o;const n=Math.sign(e);let a=o+e;for(;s(a);)a+=n;for(;this.getters.isHeaderHidden(r,t,a);)a+=n;return a<0||a>this.getters.getNumberHeaders(r,t)-1?this.getters.isHeaderHidden(r,t,o)?this.getNextAvailableHeader(-n,t,o,i,s):o:a}getReferencePosition(){const e=this.getters.getActiveSheetId(),t=this.anchor,{left:o,right:i,top:s,bottom:r}=t.zone,{col:n,row:a}=t.cell;return{col:this.getters.isColHidden(e,n)&&this.getters.findVisibleHeader(e,"COL",o,i)||n,row:this.getters.isRowHidden(e,a)&&this.getters.findVisibleHeader(e,"ROW",s,r)||a}}deltaToTarget(e,t,o){switch(t){case"up":return"end"!==o?[0,-o]:[0,this.getEndOfCluster(e,"rows",-1)-e.row];case"down":return"end"!==o?[0,o]:[0,this.getEndOfCluster(e,"rows",1)-e.row];case"left":return"end"!==o?[-o,0]:[this.getEndOfCluster(e,"cols",-1)-e.col,0];case"right":return"end"!==o?[o,0]:[this.getEndOfCluster(e,"cols",1)-e.col,0]}}getStartingPosition(e){let{col:t,row:o}=this.getPosition();const i=this.anchor.zone;switch(e){case"down":case"up":o=o===i.top?i.bottom:i.top;break;case"left":case"right":t=t===i.right?i.left:i.right}return{col:t,row:o}}getEndOfCluster(e,t,o){let i=e;const s=this.getNextCellPosition(e,t,o);let r=this.isEvaluatedCellEmpty(i)||this.isEvaluatedCellEmpty(s)?"nextCluster":"endOfCluster";for(;;){const e=this.getNextCellPosition(i,t,o);if(i.col===e.col&&i.row===e.row)break;const s=this.isEvaluatedCellEmpty(e);if("endOfCluster"===r&&s)break;if("nextCluster"===r&&!s){i=e;break}i=e}return"cols"===t?i.col:i.row}isCellEmpty({col:e,row:t}){const o=this.getters.getActiveSheetId(),i=this.getters.getMainCellPosition({sheetId:o,col:e,row:t});return!(this.getters.getCorrespondingFormulaCell(i)||this.getters.getCell(i)?.content)}isEvaluatedCellEmpty({col:e,row:t}){const o=this.getters.getActiveSheetId(),i=this.getters.getMainCellPosition({sheetId:o,col:e,row:t});return this.getters.getEvaluatedCell(i).type===ls.empty}getNextCellPosition(e,t,o){const i="cols"===t?"col":"row",s={...e},r="cols"===t?this.getNextAvailableCol(o,s.col,s.row):this.getNextAvailableRow(o,s.col,s.row);return s[i]=r,{col:s.col,row:s.row}}getPosition(){return{...this.anchor.cell}}expandZoneToTable(e){const t=e=>{for(const t of ye(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 ye(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};let o=!1,i=e;do{o=!1;const e=t(i);hi(i,e)||(o=!0,i=e)}while(o);return i}}class cy{changes=[];commands=[];recordChanges(e){return this.changes=[],this.commands=[],e(),{changes:this.changes,commands:this.commands}}addCommand(e){this.commands.push(e)}addChange(...e){const t=e.pop();let o=e[0],i=e[e.length-1];const s=e.length-2;for(let t=1;t<=s;t++){const i=e[t];if(void 0===o[i]){const s=e[t+1];o[i]=Qx(s)}o=o[i]}o[i]!==t&&(this.changes.push({path:e,before:o[i],after:t}),void 0===t?delete o[i]:o[i]=t)}}const hy=17781237,dy=88853993;function uy(e,t,o){const i=[["xmlns:r",PS],["xmlns:a",_S],["xmlns:c",FS]],s=gy({backgroundColor:e.data.backgroundColor,line:{color:"000000"}});let r=xE``;e.data.title&&(r=xE`
|
|
2054
|
+
`;const Gx=e=>e;class qx extends t.Component{static template="o-spreadsheet-Spreadsheet";static components={TopBar:Hx,Grid:yS,BottomBar:_x,SidePanel:Dx,SpreadsheetDashboard:Fx};static _t=Gx;sidePanel;composer;_focusGrid;keyDownMapping;isViewportTooSmall=!1;get model(){return this.props.model}getStyle(){return this.env.isDashboard()?"grid-template-rows: auto;":"grid-template-rows: 63px auto 37px"}setup(){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",{})};const e=this.model.config.external.fileStore;t.useSubEnv({model:this.model,imageProvider:e?new yx(e):void 0,loadCurrencies:this.model.config.external.loadCurrencies,loadLocales:this.model.config.external.loadLocales,isDashboard:()=>this.model.getters.isDashboard(),openSidePanel:this.openSidePanel.bind(this),toggleSidePanel:this.toggleSidePanel.bind(this),_t:qx._t,clipboard:this.env.clipboard||new $x(navigator.clipboard),startCellEdition:e=>this.onGridComposerCellFocused(e),focusableElement:new Ix}),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(isFinite(e)&&isFinite(t))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.isOpen&&e!==this.sidePanel.component&&this.sidePanel.panelProps?.onCloseSidePanel?.(),this.sidePanel.component=e,this.sidePanel.panelProps=t,this.sidePanel.isOpen=!0}closeSidePanel(){this.sidePanel.isOpen=!1,this.focusGrid(),this.sidePanel.panelProps?.onCloseSidePanel?.()}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()}onKeydown(e){let t="";Or(e)&&(t+="CTRL+"),t+=e.key.toUpperCase();let o=this.keyDownMapping[t];if(o)return e.preventDefault(),e.stopPropagation(),void o()}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(e){this.model.getters.isReadonly()||(this.model.dispatch("UNFOCUS_SELECTION_INPUT"),this.composer.topBarFocus="inactive",this.composer.gridFocusMode="contentFocus",this.setComposerContent({selection:e}))}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}}qx.props={model:Object};class Zx{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 Yx(e){return om.get(e.type)(e)}function jx(e){if("string"==typeof e)return{};if("number"==typeof e)return[];throw new Error("Cannot create new node")}class Xx{buildTransformation;operations;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(){return this.operations[this.operations.length-1]?.id}getFirstOperationAmong(e,t){for(const o of this.operations){if(o.id===e)return e;if(o.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 o=this.buildTransformation.with(e.data),{before:i,operation:s,after:r}=this.locateOperation(t);this.operations=[...i,s,e,...r.map((e=>e.transformed(o)))]}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 Xx(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:o}=this.locateOperation(e);this.operations=t.concat([o])}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 Kx{id;data;constructor(e,t){this.id=e,this.data=t}transformed(e){return new Qx(this.id,ze((()=>e(this.data))))}}class Qx{id;lazyData;constructor(e,t){this.id=e,this.lazyData=t}get data(){return this.lazyData()}transformed(e){return new Qx(this.id,this.lazyData.map(e))}}class Jx{operations;constructor(e){this.operations=e}[Symbol.iterator](){return this.operations[Symbol.iterator]()}stopWith(e){return new Jx(function*(e,t){for(const o of e)if(yield o,o.operation.id===t)return}(this.operations,e))}stopBefore(e){return new Jx(function*(e,t){for(const o of e){if(o.operation.id===t)return;yield o}}(this.operations,e))}startAfter(e){return new Jx(function*(e,t){let o=!0;for(const i of e)o||(yield i),i.operation.id===t&&(o=!1)}(this.operations,e))}}class ey{buildTransformation;branches;branchingOperationIds=new Map;constructor(e,t){this.buildTransformation=e,this.branches=[t]}getLastBranch(){return this.branches[this.branches.length-1]}execution(e){return new Jx(Re(this._execution(e),this._execution(e)))}revertedExecution(e){return new Jx(Re(this._revertedExecution(e),this._revertedExecution(e)))}insertOperationLast(e,t){const o=e.getLastOperationId()||this.previousBranch(e)?.getLastOperationId();e.append(t),o&&this.insertPrevious(e,t,o)}insertOperationAfter(e,t,o){e.insert(t,o),this.updateNextWith(e,t,o),this.insertPrevious(e,t,o)}undo(e,t){const o=this.buildTransformation.without(t.data),i=this.branchingOperationIds.get(e);this.branchingOperationIds.set(e,t.id);const s=e.fork(t.id);i&&this.branchingOperationIds.set(s,i),this.insertBranchAfter(e,s),this.transform(s,o)}redo(e){const t=this.nextBranch(e);if(!t)return;const o=this.nextBranch(t);this.removeBranchFromTree(t);const i=this.branchingOperationIds.get(t);i?this.branchingOperationIds.set(e,i):this.branchingOperationIds.delete(e),o&&this.rebaseUp(o)}drop(e){for(const t of this.branches)t.contains(e)&&t.cutBefore(e)}findOperation(e,t){for(const o of this.revertedExecution(e))if(o.operation.id===t)return o;throw new Error(`Operation ${t} not found`)}rebaseUp(e){const{previousBranch:t,branchingOperation:o}=this.findPreviousBranchingOperation(e);if(!t||!o)return;const i=this.buildTransformation.without(o.data),s=t.fork(o.id);this.branchingOperationIds.set(s,this.branchingOperationIds.get(e)),this.removeBranchFromTree(e),this.insertBranchAfter(t,s),s.transform(i);const r=this.nextBranch(s);r&&this.rebaseUp(r)}removeBranchFromTree(e){const t=this.branches.findIndex((t=>t===e));this.branches.splice(t,1)}insertBranchAfter(e,t){const o=this.branches.findIndex((t=>t===e));this.branches.splice(o+1,0,t)}updateNextWith(e,t,o){const i=this.branchingOperationIds.get(e),s=this.nextBranch(e);if(i&&s)if(e.getFirstOperationAmong(o,i)===i){const r=this.addToNextBranch(e,s,i,t,o);this.updateNextWith(s,r,o)}else{const e=this.buildTransformation.with(t.data);this.transform(s,e)}}addToNextBranch(e,t,o,i,s){let r=i;return s===o?(r=this.getTransformedOperation(e,o,i),t.prepend(r)):t.contains(s)?(r=this.getTransformedOperation(e,o,i),t.insert(r,s)):t.append(i),r}getTransformedOperation(e,t,o){const i=e.getOperation(t),s=this.buildTransformation.without(i.data);return o.transformed(s)}shouldExecute(e,t){return t.id!==this.branchingOperationIds.get(e)}transform(e,t){e.transform(t);const o=this.nextBranch(e);o&&this.transform(o,t)}insertPrevious(e,t,o){const{previousBranch:i,branchingOperation:s}=this.findPreviousBranchingOperation(e);if(!i||!s)return;const r=this.buildTransformation.with(s.data),n=e.fork(o);n.transform(r),i.cutAfter(o),i.appendBranch(n);const a=t.transformed(r);this.insertPrevious(i,a,o)}findPreviousBranchingOperation(e){const t=this.previousBranch(e);if(!t)return{previousBranch:void 0,branchingOperation:void 0};const o=this.branchingOperationIds.get(t);return o?{previousBranch:t,branchingOperation:t.getOperation(o)}:{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 o=!!t;const i=e.getOperations();for(let s=i.length-1;s>=0;s--){const r=i[s];r.id===t&&(o=!1),o||(yield{operation:r,branch:e,isCancelled:!this.shouldExecute(e,r)})}const s=this.previousBranch(e);yield*s?this._revertedExecution(s):[]}*_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 ty{HEAD_BRANCH;HEAD_OPERATION;tree;applyOperation;revertOperation;buildEmpty;buildTransformation;constructor(e){this.applyOperation=e.applyOperation,this.revertOperation=e.revertOperation,this.buildEmpty=e.buildEmpty,this.buildTransformation=e.buildTransformation,this.HEAD_BRANCH=new Xx(this.buildTransformation),this.tree=new ey(this.buildTransformation,this.HEAD_BRANCH);const t=e.initialOperationId,o=new Kx(t,this.buildEmpty(t));this.tree.insertOperationLast(this.HEAD_BRANCH,o),this.HEAD_OPERATION=o}get(e){return this.tree.findOperation(this.HEAD_BRANCH,e).operation.data}append(e,t){const o=new Kx(e,t),i=this.tree.getLastBranch();this.tree.insertOperationLast(i,o),this.HEAD_BRANCH=i,this.HEAD_OPERATION=o}insert(e,t,o){const i=new Kx(e,t);this.revertTo(o),this.tree.insertOperationAfter(this.HEAD_BRANCH,i,o),this.fastForward()}undo(e,t,o){const{branch:i,operation:s}=this.tree.findOperation(this.HEAD_BRANCH,e);this.revertBefore(e),this.tree.undo(i,s),this.fastForward(),this.insert(t,this.buildEmpty(t),o)}redo(e,t,o){const{branch:i}=this.tree.findOperation(this.HEAD_BRANCH,e);this.revertBefore(e),this.tree.redo(i),this.fastForward(),this.insert(t,this.buildEmpty(t),o)}drop(e){this.revertBefore(e),this.tree.drop(e)}getRevertedExecution(){const e=[],t=this.tree.revertedExecution(this.HEAD_BRANCH);for(const{operation:o}of t)e.push(o.data);return 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:o,isCancelled:i}of e)i||this.revertOperation(o.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:o,isCancelled:i}of e)i||this.applyOperation(t.data),this.HEAD_OPERATION=t,this.HEAD_BRANCH=o}}function oy(e){return new ty({initialOperationId:e.initialRevisionId,applyOperation:t=>{const o=t.commands.slice(),{changes:i}=e.recordChanges((()=>{for(const t of o)e.dispatch(t)}));t.setChanges(i)},revertOperation:e=>function(e){for(const t of e.slice().reverse())for(let e=t.changes.length-1;e>=0;e--){iy(t.changes[e],"before")}}([e]),buildEmpty:e=>new $w(e,"empty",[]),buildTransformation:{with:e=>t=>new $w(t.id,t.clientId,zw(t.commands,e.commands),t.rootCommand,void 0,t.timestamp),without:e=>t=>new $w(t.id,t.clientId,zw(t.commands,e.commands.map(Yx).flat()),t.rootCommand,void 0,t.timestamp)}})}function iy(e,t){let o=e.path[0];const i=e.path[e.path.length-1];for(let t=1;t<e.path.slice(0,-1).length;t++){const i=e.path[t];if(void 0===o[i]){const s=e.path[t+1];o[i]=jx(s)}o=o[i]}void 0===e[t]?delete o[i]:o[i]=e[t]}class sy{observers=[];defaultSubscription;mainSubscription;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){if(this.observers.find((t=>t.owner===e)))throw new Error("You are already subscribed forever");this.mainSubscription?.owner&&this.mainSubscription.owner!==e&&this.mainSubscription.callbacks.release?.(),this.mainSubscription={owner:e,callbacks:t}}release(e){this.mainSubscription?.owner!==e||this.observers.find((t=>t.owner===e))||(this.mainSubscription=this.defaultSubscription)}getBackToDefault(){this.mainSubscription!==this.defaultSubscription&&(this.mainSubscription?.callbacks.release?.(),this.mainSubscription=this.defaultSubscription)}isListening(e){return this.mainSubscription?.owner===e}send(e){this.mainSubscription?.callbacks.handleEvent(e),[...this.observers].forEach((t=>t.callbacks.handleEvent(e)))}}class ry{getters;stream;anchor;defaultAnchor;constructor(e){this.getters=e,this.stream=new sy,this.anchor={cell:{col:0,row:0},zone:wi({col:0,row:0})},this.defaultAnchor=this.anchor}capture(e,t,o){this.stream.capture(e,o),this.anchor=t}registerAsDefault(e,t,o){this.checkAnchorZoneOrThrow(t),this.stream.registerAsDefault(e,o),this.defaultAnchor=t,this.capture(e,t,o)}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()}modifyAnchor(e,t,o){const i=this.getters.getActiveSheetId();return e={...e,zone:this.getters.expandZone(i,e.zone)},this.processEvent({options:o,anchor:e,mode:t})}selectZone(e,t={scrollIntoView:!0}){return this.modifyAnchor(e,"overrideSelection",t)}selectCell(e,t){const o=wi({col:e,row:t});return this.selectZone({zone:o,cell:{col:e,row:t}},{scrollIntoView:!0})}moveAnchorCell(e,t=1){if("end"!==t&&t<=0)return new fs(86);const{col:o,row:i}=this.getNextAvailablePosition(e,t);return this.selectCell(o,i)}setAnchorCorner(e,t){const o=this.getters.getActiveSheetId(),{col:i,row:s}=this.anchor.cell,r={left:Math.min(i,e),top:Math.min(s,t),right:Math.max(i,e),bottom:Math.max(s,t)},n={zone:this.getters.expandZone(o,r),cell:{col:i,row:s}};return this.processEvent({mode:"updateAnchor",anchor:n,options:{scrollIntoView:!1}})}addCellToSelection(e,t){const o=this.getters.getActiveSheetId();({col:e,row:t}=this.getters.getMainCellPosition({sheetId:o,col:e,row:t}));const i=this.getters.expandZone(o,wi({col:e,row:t}));return this.processEvent({options:{scrollIntoView:!0},anchor:{zone:i,cell:{col:e,row:t}},mode:"newAnchor"})}resizeAnchorZone(e,t=1){if("end"!==t&&t<=0)return new fs(86);const o=this.getters.getActiveSheetId(),i=this.anchor,{col:s,row:r}=i.cell,{left:n,right:a,top:l,bottom:c}=i.zone,h=this.getStartingPosition(e);let[d,u]=this.deltaToTarget(h,e,t);if(0===d&&0===u)return fs.Success;let g=i.zone;const p=e=>{e=Ei(e);const{left:t,right:i,top:s,bottom:r}=this.getters.expandZone(o,e);return{left:Math.max(0,t),right:Math.min(this.getters.getNumberCols(o)-1,i),top:Math.max(0,s),bottom:Math.min(this.getters.getNumberRows(o)-1,r)}},{col:m,row:f}=this.getReferencePosition();let b=0;for(;null!==g;){if(b++,d<0){const e=this.getNextAvailableCol(d,a-(b-1),f);g=m<=a-b?p({top:l,left:n,bottom:c,right:e}):null}if(d>0){const e=this.getNextAvailableCol(d,n+(b-1),f);g=n+b<=m?p({top:l,left:e,bottom:c,right:a}):null}if(u<0){const e=this.getNextAvailableRow(u,m,c-(b-1));g=f<=c-b?p({top:l,left:n,bottom:e,right:a}):null}if(u>0){const e=this.getNextAvailableRow(u,m,l+(b-1));g=l+b<=f?p({top:e,left:n,bottom:c,right:a}):null}if(g=g?Ei(g):g,g&&!hi(g,i.zone))return this.processEvent({options:{scrollIntoView:!0},mode:"updateAnchor",anchor:{zone:g,cell:{col:s,row:r}}})}g=p(li({top:r,bottom:r,left:s,right:s},Ei({top:this.getNextAvailableRow(u,m,l),left:this.getNextAvailableCol(d,n,f),bottom:this.getNextAvailableRow(u,m,c),right:this.getNextAvailableCol(d,a,f)})));const v={zone:g,cell:{col:s,row:r}};return this.processEvent({anchor:v,mode:"updateAnchor",options:{scrollIntoView:!0}})}selectColumn(e,t){const o=this.getters.getActiveSheetId(),i=this.getters.getNumberRows(o)-1;let s={left:e,right:e,top:0,bottom:i};const r=this.getters.findFirstVisibleColRowIndex(o,"ROW");let n,a;switch(t){case"overrideSelection":case"newAnchor":n=e,a=r;break;case"updateAnchor":({col:n,row:a}=this.anchor.cell),s=li(s,{left:n,right:n,top:r,bottom:i})}return this.processEvent({options:{scrollIntoView:!1,unbounded:!0},anchor:{zone:s,cell:{col:n,row:a}},mode:t})}selectRow(e,t){const o=this.getters.getActiveSheetId(),i=this.getters.getNumberCols(o)-1;let s={top:e,bottom:e,left:0,right:i};const r=this.getters.findFirstVisibleColRowIndex(o,"COL");let n,a;switch(t){case"overrideSelection":case"newAnchor":n=r,a=e;break;case"updateAnchor":({col:n,row:a}=this.anchor.cell),s=li(s,{left:r,right:i,top:a,bottom:a})}return this.processEvent({options:{scrollIntoView:!1,unbounded:!0},anchor:{zone:s,cell:{col:n,row:a}},mode:t})}loopSelection(){const e=this.getters.getActiveSheetId(),t=this.anchor;if(hi(this.anchor.zone,this.getters.getSheetZone(e)))return this.modifyAnchor({...t,zone:wi(t.cell)},"updateAnchor",{scrollIntoView:!1});const o=this.expandZoneToTable(t.zone);return We(o,t.zone)?this.selectAll():this.modifyAnchor({...t,zone:o},"updateAnchor",{scrollIntoView:!1})}selectTableAroundSelection(){const e=this.expandZoneToTable(this.anchor.zone);return this.modifyAnchor({...this.anchor,zone:e},"updateAnchor",{scrollIntoView:!1})}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({mode:"overrideSelection",anchor:{zone:t,cell:this.anchor.cell},options:{scrollIntoView:!1}})}isListening(e){return this.stream.isListening(e)}processEvent(e){const t={...e,previousAnchor:Ce(this.anchor)},o=this.checkEventAnchorZone(t);return 0!==o?new fs(o):(this.anchor=t.anchor,this.stream.send(t),fs.Success)}checkEventAnchorZone(e){return this.checkAnchorZone(e.anchor)}checkAnchorZone(e){const{cell:t,zone:o}=e;if(!ui(t.col,t.row,o))return 17;const{left:i,right:s,top:r,bottom:n}=o,a=this.getters.getActiveSheetId(),l=this.getters.findVisibleHeader(a,"COL",i,s);return void 0===this.getters.findVisibleHeader(a,"ROW",r,n)||void 0===l?18:0}checkAnchorZoneOrThrow(e){if(17===this.checkAnchorZone(e))throw new Error(s("The provided anchor is invalid. The cell must be part of the zone."))}getNextAvailablePosition(e,t=1){const{col:o,row:i}=this.anchor.cell,s=this.deltaToTarget({col:o,row:i},e,t);return{col:this.getNextAvailableCol(s[0],o,i),row:this.getNextAvailableRow(s[1],o,i)}}getNextAvailableCol(e,t,o){const i=this.getters.getActiveSheetId(),s={col:t,row:o};return this.getNextAvailableHeader(e,"COL",t,s,(e=>this.getters.isInSameMerge(i,t,o,e,o)))}getNextAvailableRow(e,t,o){const i=this.getters.getActiveSheetId(),s={col:t,row:o};return this.getNextAvailableHeader(e,"ROW",o,s,(e=>this.getters.isInSameMerge(i,t,o,t,e)))}getNextAvailableHeader(e,t,o,i,s){const r=this.getters.getActiveSheetId();if(0===e)return o;const n=Math.sign(e);let a=o+e;for(;s(a);)a+=n;for(;this.getters.isHeaderHidden(r,t,a);)a+=n;return a<0||a>this.getters.getNumberHeaders(r,t)-1?this.getters.isHeaderHidden(r,t,o)?this.getNextAvailableHeader(-n,t,o,i,s):o:a}getReferencePosition(){const e=this.getters.getActiveSheetId(),t=this.anchor,{left:o,right:i,top:s,bottom:r}=t.zone,{col:n,row:a}=t.cell;return{col:this.getters.isColHidden(e,n)&&this.getters.findVisibleHeader(e,"COL",o,i)||n,row:this.getters.isRowHidden(e,a)&&this.getters.findVisibleHeader(e,"ROW",s,r)||a}}deltaToTarget(e,t,o){switch(t){case"up":return"end"!==o?[0,-o]:[0,this.getEndOfCluster(e,"rows",-1)-e.row];case"down":return"end"!==o?[0,o]:[0,this.getEndOfCluster(e,"rows",1)-e.row];case"left":return"end"!==o?[-o,0]:[this.getEndOfCluster(e,"cols",-1)-e.col,0];case"right":return"end"!==o?[o,0]:[this.getEndOfCluster(e,"cols",1)-e.col,0]}}getStartingPosition(e){let{col:t,row:o}=this.getPosition();const i=this.anchor.zone;switch(e){case"down":case"up":o=o===i.top?i.bottom:i.top;break;case"left":case"right":t=t===i.right?i.left:i.right}return{col:t,row:o}}getEndOfCluster(e,t,o){let i=e;const s=this.getNextCellPosition(e,t,o);let r=this.isEvaluatedCellEmpty(i)||this.isEvaluatedCellEmpty(s)?"nextCluster":"endOfCluster";for(;;){const e=this.getNextCellPosition(i,t,o);if(i.col===e.col&&i.row===e.row)break;const s=this.isEvaluatedCellEmpty(e);if("endOfCluster"===r&&s)break;if("nextCluster"===r&&!s){i=e;break}i=e}return"cols"===t?i.col:i.row}isCellEmpty({col:e,row:t}){const o=this.getters.getActiveSheetId(),i=this.getters.getMainCellPosition({sheetId:o,col:e,row:t});return!(this.getters.getCorrespondingFormulaCell(i)||this.getters.getCell(i)?.content)}isEvaluatedCellEmpty({col:e,row:t}){const o=this.getters.getActiveSheetId(),i=this.getters.getMainCellPosition({sheetId:o,col:e,row:t});return this.getters.getEvaluatedCell(i).type===ls.empty}getNextCellPosition(e,t,o){const i="cols"===t?"col":"row",s={...e},r="cols"===t?this.getNextAvailableCol(o,s.col,s.row):this.getNextAvailableRow(o,s.col,s.row);return s[i]=r,{col:s.col,row:s.row}}getPosition(){return{...this.anchor.cell}}expandZoneToTable(e){const t=e=>{for(const t of ye(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 ye(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};let o=!1,i=e;do{o=!1;const e=t(i);hi(i,e)||(o=!0,i=e)}while(o);return i}}class ny{changes=[];commands=[];recordChanges(e){return this.changes=[],this.commands=[],e(),{changes:this.changes,commands:this.commands}}addCommand(e){this.commands.push(e)}addChange(...e){const t=e.pop();let o=e[0],i=e[e.length-1];const s=e.length-2;for(let t=1;t<=s;t++){const i=e[t];if(void 0===o[i]){const s=e[t+1];o[i]=jx(s)}o=o[i]}o[i]!==t&&(this.changes.push({path:e,before:o[i],after:t}),void 0===t?delete o[i]:o[i]=t)}}const ay=17781237,ly=88853993;function cy(e,t,o){const i=[["xmlns:r",DS],["xmlns:a",MS],["xmlns:c",NS]],s=hy({backgroundColor:e.data.backgroundColor,line:{color:"000000"}});let r=EE``;e.data.title&&(r=EE`
|
|
2055
2055
|
<c:title>
|
|
2056
|
-
${
|
|
2056
|
+
${uy(e.data.title,e.data.fontColor)}
|
|
2057
2057
|
<c:overlay val="0" />
|
|
2058
2058
|
</c:title>
|
|
2059
|
-
`);let n=
|
|
2059
|
+
`);let n=EE``;switch(e.data.type){case"bar":n=function(e){const t=new op,o=[];for(const[i,s]of Object.entries(e.dataSets)){const r=$g(t.next()),n=hy({backgroundColor:r,line:{color:r}});o.push(EE`
|
|
2060
2060
|
<c:ser>
|
|
2061
2061
|
<c:idx val="${i}"/>
|
|
2062
2062
|
<c:order val="${i}"/>
|
|
2063
|
-
${s.label?
|
|
2063
|
+
${s.label?EE`<c:tx>${fy(s.label)}</c:tx>`:""}
|
|
2064
2064
|
${n}
|
|
2065
|
-
${e.labelRange?
|
|
2065
|
+
${e.labelRange?EE`<c:cat>${fy(e.labelRange)}</c:cat>`:""} <!-- x-coordinate values -->
|
|
2066
2066
|
<c:val> <!-- x-coordinate values -->
|
|
2067
|
-
${
|
|
2067
|
+
${by(s.range)}
|
|
2068
2068
|
</c:val>
|
|
2069
2069
|
</c:ser>
|
|
2070
|
-
`)}const i="left"===e.verticalAxisPosition?"l":"r",s=e.stacked?"stacked":"clustered",r=e.stacked?100:-20;return
|
|
2070
|
+
`)}const i="left"===e.verticalAxisPosition?"l":"r",s=e.stacked?"stacked":"clustered",r=e.stacked?100:-20;return EE`
|
|
2071
2071
|
<c:barChart>
|
|
2072
2072
|
<c:barDir val="col"/>
|
|
2073
2073
|
<c:grouping val="${s}"/>
|
|
@@ -2075,13 +2075,13 @@
|
|
|
2075
2075
|
<c:gapWidth val="70"/>
|
|
2076
2076
|
<!-- each data marker in the series does not have a different color -->
|
|
2077
2077
|
<c:varyColors val="0"/>
|
|
2078
|
-
${
|
|
2079
|
-
<c:axId val="${
|
|
2080
|
-
<c:axId val="${
|
|
2078
|
+
${CE(o)}
|
|
2079
|
+
<c:axId val="${ay}" />
|
|
2080
|
+
<c:axId val="${ly}" />
|
|
2081
2081
|
</c:barChart>
|
|
2082
|
-
${
|
|
2083
|
-
${
|
|
2084
|
-
`}(e.data);break;case"line":n=function(e){const t=new op,o=[];for(const[i,s]of Object.entries(e.dataSets)){const r=
|
|
2082
|
+
${my("b","c:catAx",ay,ly,{fontColor:e.fontColor})}
|
|
2083
|
+
${my(i,"c:valAx",ly,ay,{fontColor:e.fontColor})}
|
|
2084
|
+
`}(e.data);break;case"line":n=function(e){const t=new op,o=[];for(const[i,s]of Object.entries(e.dataSets)){const r=hy({line:{width:2.5,style:"solid",color:$g(t.next())}});o.push(EE`
|
|
2085
2085
|
<c:ser>
|
|
2086
2086
|
<c:idx val="${i}"/>
|
|
2087
2087
|
<c:order val="${i}"/>
|
|
@@ -2090,50 +2090,50 @@
|
|
|
2090
2090
|
<c:symbol val="circle" />
|
|
2091
2091
|
<c:size val="5"/>
|
|
2092
2092
|
</c:marker>
|
|
2093
|
-
${s.label?
|
|
2093
|
+
${s.label?EE`<c:tx>${fy(s.label)}</c:tx>`:""}
|
|
2094
2094
|
${r}
|
|
2095
|
-
${e.labelRange?
|
|
2095
|
+
${e.labelRange?EE`<c:cat>${fy(e.labelRange)}</c:cat>`:""} <!-- x-coordinate values -->
|
|
2096
2096
|
<c:val> <!-- x-coordinate values -->
|
|
2097
|
-
${
|
|
2097
|
+
${by(s.range)}
|
|
2098
2098
|
</c:val>
|
|
2099
2099
|
</c:ser>
|
|
2100
|
-
`)}const i="left"===e.verticalAxisPosition?"l":"r",s=e.stacked?"stacked":"standard";return
|
|
2100
|
+
`)}const i="left"===e.verticalAxisPosition?"l":"r",s=e.stacked?"stacked":"standard";return EE`
|
|
2101
2101
|
<c:lineChart>
|
|
2102
2102
|
<c:grouping val="${s}"/>
|
|
2103
2103
|
<!-- each data marker in the series does not have a different color -->
|
|
2104
2104
|
<c:varyColors val="0"/>
|
|
2105
|
-
${
|
|
2106
|
-
<c:axId val="${
|
|
2107
|
-
<c:axId val="${
|
|
2105
|
+
${CE(o)}
|
|
2106
|
+
<c:axId val="${ay}" />
|
|
2107
|
+
<c:axId val="${ly}" />
|
|
2108
2108
|
</c:lineChart>
|
|
2109
|
-
${
|
|
2110
|
-
${
|
|
2111
|
-
`}(e.data);break;case"pie":n=function(e,t,o,{holeSize:i}={holeSize:50}){const s=new op,r=et(e.dataSets.map((e=>
|
|
2109
|
+
${my("b","c:catAx",ay,ly,{fontColor:e.fontColor})}
|
|
2110
|
+
${my(i,"c:valAx",ly,ay,{fontColor:e.fontColor})}
|
|
2111
|
+
`}(e.data);break;case"pie":n=function(e,t,o,{holeSize:i}={holeSize:50}){const s=new op,r=et(e.dataSets.map((e=>WC(e.range,t,o)))),n=ye(0,r).map((()=>$g(s.next()))),a=[];for(const[i,s]of Object.entries(e.dataSets).reverse()){const r=WC(s.range,t,o),l=[];for(const e of ye(0,r)){const t=hy({backgroundColor:n[e],line:{color:"FFFFFF",width:1.5}});l.push(EE`
|
|
2112
2112
|
<c:dPt>
|
|
2113
2113
|
<c:idx val="${e}"/>
|
|
2114
2114
|
${t}
|
|
2115
2115
|
</c:dPt>
|
|
2116
|
-
`)}a.push(
|
|
2116
|
+
`)}a.push(EE`
|
|
2117
2117
|
<c:ser>
|
|
2118
2118
|
<c:idx val="${i}"/>
|
|
2119
2119
|
<c:order val="${i}"/>
|
|
2120
|
-
${s.label?
|
|
2121
|
-
${
|
|
2122
|
-
${
|
|
2123
|
-
${e.labelRange?
|
|
2120
|
+
${s.label?EE`<c:tx>${fy(s.label)}</c:tx>`:""}
|
|
2121
|
+
${CE(l)}
|
|
2122
|
+
${py({showLeaderLines:!0})}
|
|
2123
|
+
${e.labelRange?EE`<c:cat>${fy(e.labelRange)}</c:cat>`:""}
|
|
2124
2124
|
<c:val>
|
|
2125
|
-
${
|
|
2125
|
+
${by(s.range)}
|
|
2126
2126
|
</c:val>
|
|
2127
2127
|
</c:ser>
|
|
2128
|
-
`)}return
|
|
2128
|
+
`)}return EE`
|
|
2129
2129
|
<c:doughnutChart>
|
|
2130
2130
|
<c:varyColors val="1" />
|
|
2131
2131
|
<c:holeSize val="${i}" />
|
|
2132
|
-
${
|
|
2133
|
-
${
|
|
2132
|
+
${py()}
|
|
2133
|
+
${CE(a)}
|
|
2134
2134
|
</c:doughnutChart>
|
|
2135
|
-
`}(e.data,t,o,{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=
|
|
2136
|
-
<c:chartSpace ${
|
|
2135
|
+
`}(e.data,t,o,{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=EE`
|
|
2136
|
+
<c:chartSpace ${fE(i)}>
|
|
2137
2137
|
<c:roundedCorners val="0" />
|
|
2138
2138
|
<!-- <manualLayout/> to manually position the chart in the figure container -->
|
|
2139
2139
|
${s}
|
|
@@ -2144,32 +2144,32 @@
|
|
|
2144
2144
|
<!-- how the chart element is placed on the chart -->
|
|
2145
2145
|
<c:layout />
|
|
2146
2146
|
${n}
|
|
2147
|
-
${
|
|
2147
|
+
${hy({backgroundColor:e.data.backgroundColor})}
|
|
2148
2148
|
</c:plotArea>
|
|
2149
|
-
${function(e,t){return
|
|
2149
|
+
${function(e,t){return EE`
|
|
2150
2150
|
<c:legend>
|
|
2151
2151
|
<c:legendPos val="${e}"/>
|
|
2152
2152
|
<c:overlay val="0"/>
|
|
2153
|
-
${
|
|
2153
|
+
${gy(10,t)}
|
|
2154
2154
|
</c:legend>
|
|
2155
2155
|
`}(a,l)}
|
|
2156
2156
|
</c:chart>
|
|
2157
2157
|
</c:chartSpace>
|
|
2158
|
-
`;return
|
|
2158
|
+
`;return bE(c)}function hy(e){return EE`
|
|
2159
2159
|
<c:spPr>
|
|
2160
|
-
${e.backgroundColor?
|
|
2161
|
-
${e.line?function(e){const t=[["cmpd","sng"]];e.width&&t.push(["w"
|
|
2162
|
-
<a:ln ${
|
|
2163
|
-
${
|
|
2160
|
+
${e.backgroundColor?dy(e.backgroundColor):""}
|
|
2161
|
+
${e.line?function(e){const t=[["cmpd","sng"]];e.width&&t.push(["w",$C(e.width)]);const o=e.style?EE`<a:prstDash val="${e.style}"/>`:"";return EE`
|
|
2162
|
+
<a:ln ${fE(t)}>
|
|
2163
|
+
${dy(e.color)}
|
|
2164
2164
|
${o}
|
|
2165
2165
|
</a:ln>
|
|
2166
2166
|
`}(e.line):""}
|
|
2167
2167
|
</c:spPr>
|
|
2168
|
-
`}function
|
|
2168
|
+
`}function dy(e){return EE`
|
|
2169
2169
|
<a:solidFill>
|
|
2170
2170
|
<a:srgbClr val="${e}"/>
|
|
2171
2171
|
</a:solidFill>
|
|
2172
|
-
`}function
|
|
2172
|
+
`}function uy(e,t="000000",o=22){return EE`
|
|
2173
2173
|
<c:tx>
|
|
2174
2174
|
<c:rich>
|
|
2175
2175
|
<a:bodyPr />
|
|
@@ -2177,7 +2177,7 @@
|
|
|
2177
2177
|
<a:p>
|
|
2178
2178
|
<a:pPr lvl="0">
|
|
2179
2179
|
<a:defRPr b="0">
|
|
2180
|
-
${
|
|
2180
|
+
${dy(t)}
|
|
2181
2181
|
<a:latin typeface="+mn-lt"/>
|
|
2182
2182
|
</a:defRPr>
|
|
2183
2183
|
</a:pPr>
|
|
@@ -2188,20 +2188,20 @@
|
|
|
2188
2188
|
</a:p>
|
|
2189
2189
|
</c:rich>
|
|
2190
2190
|
</c:tx>
|
|
2191
|
-
`}function
|
|
2191
|
+
`}function gy(e=12,t="000000",o=!1,i=!1){return EE`
|
|
2192
2192
|
<c:txPr>
|
|
2193
2193
|
<a:bodyPr/>
|
|
2194
2194
|
<a:lstStyle/>
|
|
2195
2195
|
<a:p>
|
|
2196
2196
|
<a:pPr lvl="0">
|
|
2197
|
-
<a:defRPr ${
|
|
2198
|
-
${
|
|
2197
|
+
<a:defRPr ${fE([["b",o?"1":"0"],["i",i?"1":"0"],["sz",100*e]])}>
|
|
2198
|
+
${dy(t)}
|
|
2199
2199
|
<a:latin typeface="+mn-lt"/>
|
|
2200
2200
|
</a:defRPr>
|
|
2201
2201
|
</a:pPr>
|
|
2202
2202
|
</a:p>
|
|
2203
2203
|
</c:txPr>
|
|
2204
|
-
`}function
|
|
2204
|
+
`}function py({showLeaderLines:e}={showLeaderLines:!1}){return EE`
|
|
2205
2205
|
<dLbls>
|
|
2206
2206
|
<c:showLegendKey val="0"/>
|
|
2207
2207
|
<c:showVal val="0"/>
|
|
@@ -2211,7 +2211,7 @@
|
|
|
2211
2211
|
<c:showBubbleSize val="0"/>
|
|
2212
2212
|
<c:showLeaderLines val="${e?"1":"0"}"/>
|
|
2213
2213
|
</dLbls>
|
|
2214
|
-
`}function
|
|
2214
|
+
`}function my(e,t,o,i,{fontColor:s}){return EE`
|
|
2215
2215
|
<${t}>
|
|
2216
2216
|
<c:axId val="${o}"/>
|
|
2217
2217
|
<c:crossAx val="${i}"/> <!-- reference to the other axe of the chart -->
|
|
@@ -2220,57 +2220,57 @@
|
|
|
2220
2220
|
<c:orientation val="minMax" />
|
|
2221
2221
|
</c:scaling>
|
|
2222
2222
|
<c:axPos val="${e}" />
|
|
2223
|
-
${function(e="B7B7B7"){return
|
|
2223
|
+
${function(e="B7B7B7"){return EE`
|
|
2224
2224
|
<c:majorGridlines>
|
|
2225
|
-
${
|
|
2225
|
+
${hy({line:{color:e}})}
|
|
2226
2226
|
</c:majorGridlines>
|
|
2227
2227
|
`}()}
|
|
2228
2228
|
<c:majorTickMark val="out" />
|
|
2229
2229
|
<c:minorTickMark val="none" />
|
|
2230
2230
|
<c:numFmt formatCode="General" sourceLinked="1" />
|
|
2231
2231
|
<c:title>
|
|
2232
|
-
${
|
|
2232
|
+
${uy("")}
|
|
2233
2233
|
</c:title>
|
|
2234
|
-
${
|
|
2234
|
+
${gy(10,s)}
|
|
2235
2235
|
</${t}>
|
|
2236
2236
|
<!-- <tickLblPos/> omitted -->
|
|
2237
|
-
`}function
|
|
2237
|
+
`}function fy(e){return EE`
|
|
2238
2238
|
<c:strRef>
|
|
2239
2239
|
<c:f>${e}</c:f>
|
|
2240
2240
|
</c:strRef>
|
|
2241
|
-
`}function
|
|
2241
|
+
`}function by(e){return EE`
|
|
2242
2242
|
<c:numRef>
|
|
2243
2243
|
<c:f>${e}</c:f>
|
|
2244
2244
|
<c:numCache />
|
|
2245
2245
|
</c:numRef>
|
|
2246
|
-
`}function
|
|
2246
|
+
`}function vy(e){const t=e.content;if(!t)return{attrs:[],node:EE``};const o=[];let i=EE``,s=EE``;const r=Cy(t);return e.value===a.CircularDependency&&(o.push(["t","str"]),s=EE`<v>${e.value}</v>`),i=EE` <f> ${r} </f> ${s} `,{attrs:o,node:i}}function Sy(e,t,o=!1){let i=e;const s=[],r=i.trim().toUpperCase();return!o&&["TRUE","FALSE"].includes(r)?(i="TRUE"===r?"1":"0",s.push(["t","b"])):!o&&io(i,eo)||(i=UC(e,t),s.push(["t","s"])),{attrs:s,node:EE`<v>${i}</v>`}}function Cy(e){let t;"="===e[0]&&(e=e.slice(1));try{t=Gu(e)}catch(t){return e}return t=Zu(t,"STRING",Ey),t=Zu(t,"FUNCALL",(e=>e=function(e){const t=e.value.toUpperCase(),o=e.args,i=HS[t];if(i){const s=fu.content[t].args.filter((e=>!e.optional)),r=s.length-e.args.length;if(r)for(let t=e.args.length;t<s.length;t++){const e=i[t-r];o.push({type:e.type,value:e.value})}}return{...e,args:o}}(e=function(e){const t=e.value.toUpperCase();return{...e,value:$S.includes(t)?`_xlfn.${t}`:t}}(e={...e,value:e.value.toUpperCase()})))),t?Ku(t):e}function Ey(e){const t=e.value.replace(new RegExp('"',"g"),""),o=Ut(t,eo);if(o){let i=[];return(Nt.test(t)||_t.test(t))&&i.push("yyyy-mm-dd"),Lt.test(t)&&i.push("hh:mm:ss"),{...e,value:fo(o.value,{format:i.join(" "),locale:eo})}}return{...e,value:e.value.replace(/\\"/g,'""')}}function wy(e,t){const o=[];for(const i of t)switch(i.rule.type){case"CellIsRule":o.push(xy(i,i.rule,e));break;case"ColorScaleRule":o.push(yy(i,i.rule));break;case"IconSetRule":o.push(Iy(i,i.rule));break;default:console.warn(`Conditional formatting ${i.rule.type} not implemented`)}return o}function xy(e,t,o){const i=Ry(e),s=_C(t.operator);i.push(...function(e){const t=_C(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",s]);const r=function(e,t){const o=e[0].split(":")[0],i=t.values;switch(t.operator){case"ContainsText":return[`NOT(ISERROR(SEARCH("${i[0]}",${o})))`];case"NotContains":return[`ISERROR(SEARCH("${i[0]}",${o}))`];case"BeginsWith":return[`LEFT(${o},LEN("${i[0]}"))="${i[0]}"`];case"EndsWith":return[`RIGHT(${o},LEN("${i[0]}"))="${i[0]}"`];case"IsEmpty":return[`LEN(TRIM(${o}))=0`];case"IsNotEmpty":return[`LEN(TRIM(${o}))>0`];case"Equal":case"NotEqual":case"GreaterThan":case"GreaterThanOrEqual":case"LessThan":case"LessThanOrEqual":return[i[0]];case"Between":case"NotBetween":return[i[0],i[1]]}}(e.ranges,t).map((e=>EE`<formula>${e}</formula>`)),n={font:{color:{rgb:t.style.textColor},bold:t.style.bold,italic:t.style.italic,strike:t.style.strikethrough,underline:t.style.underline}};return t.style.fillColor&&(n.fill={fgColor:{rgb:t.style.fillColor}}),i.push(["dxfId",UC(n,o)]),EE`
|
|
2247
2247
|
<conditionalFormatting sqref="${e.ranges.join(" ")}">
|
|
2248
|
-
<cfRule ${
|
|
2249
|
-
${
|
|
2248
|
+
<cfRule ${fE(i)}>
|
|
2249
|
+
${CE(r)}
|
|
2250
2250
|
</cfRule>
|
|
2251
2251
|
</conditionalFormatting>
|
|
2252
|
-
`}function
|
|
2252
|
+
`}function yy(e,t){const o=Ry(e);o.push(["type","colorScale"]);const i=[];for(const s of e.ranges){const e=[],r=[];let n=!0;for(let o of["minimum","midpoint","maximum"]){const i=t[o];i&&("formula"!==i.type?(e.push(Ay(i,o)),r.push([["rgb",$g(rt(i.color))]])):n=!1)}if(!n){console.warn("Conditional formats with formula rules are not supported at the moment. The rule is therefore skipped.");continue}const a=e.map((e=>EE`<cfvo ${fE(e)}/>`)),l=r.map((e=>EE`<color ${fE(e)}/>`));i.push(EE`
|
|
2253
2253
|
<conditionalFormatting sqref="${s}">
|
|
2254
|
-
<cfRule ${
|
|
2254
|
+
<cfRule ${fE(o)}>
|
|
2255
2255
|
<colorScale>
|
|
2256
|
-
${
|
|
2257
|
-
${
|
|
2256
|
+
${CE(a)}
|
|
2257
|
+
${CE(l)}
|
|
2258
2258
|
</colorScale>
|
|
2259
2259
|
</cfRule>
|
|
2260
2260
|
</conditionalFormatting>
|
|
2261
|
-
`)}return
|
|
2261
|
+
`)}return CE(i)}function Iy(e,t){const o=Ry(e);o.push(["type","iconSet"]);const i=[];for(const s of e.ranges){const e=[[["type","percent"],["val",0]]];let r=!0;for(let o of["lowerInflectionPoint","upperInflectionPoint"]){if("formula"===t[o].type){r=!1;continue}const i=t[o];e.push([...Ay(i,o),["gte","ge"===i.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 n=e.map((e=>EE`<cfvo ${fE(e)} />`));i.push(EE`
|
|
2262
2262
|
<conditionalFormatting sqref="${s}">
|
|
2263
|
-
<cfRule ${
|
|
2264
|
-
<iconSet iconSet="${
|
|
2265
|
-
${
|
|
2263
|
+
<cfRule ${fE(o)}>
|
|
2264
|
+
<iconSet iconSet="${Ty(t.icons)}">
|
|
2265
|
+
${CE(n)}
|
|
2266
2266
|
</iconSet>
|
|
2267
2267
|
</cfRule>
|
|
2268
2268
|
</conditionalFormatting>
|
|
2269
|
-
`)}return
|
|
2270
|
-
<xdr:wsDr ${
|
|
2271
|
-
${
|
|
2269
|
+
`)}return CE(i)}function Ry(e){return[["priority",1],["stopIfTrue",e.stopIfTrue?1:0]]}function Ty(e){return AS[Object.keys(AS).find((t=>e.upper.toLowerCase().startsWith(t)))||"dots"]}function Ay(e,t){const o=function(e,t){switch(e){case"value":return"minimum"===t?"min":"max";case"number":return"num";case"percentage":return"percent";default:return e}}(e.type,t),i=[["type",o]];if("min"!==o&&"max"!==o){let t=e.value;if("formula"===o)try{t=Cy(e.value)}catch(o){t=e.value}i.push(["val",t])}return i}function Oy(e,t,o){const i=[["xmlns:xdr",OS.drawing],["xmlns:r",DS],["xmlns:a",MS],["xmlns:c",NS]],s=[];for(const[i,r]of Object.entries(o))switch(r?.tag){case"chart":s.push(_y(r,t,e[i]));break;case"image":s.push(Fy(r,t,e[i]))}return bE(EE`
|
|
2270
|
+
<xdr:wsDr ${fE(i)}>
|
|
2271
|
+
${CE(s)}
|
|
2272
2272
|
</xdr:wsDr>
|
|
2273
|
-
`)}function
|
|
2273
|
+
`)}function My(e,t){const{x:o,y:i,height:s,width:r}=e,n=Object.values(t.cols),a=Object.values(t.rows),{index:l,offset:c}=Ny(n,o),{index:h,offset:d}=Ny(n,o+r),{index:u,offset:g}=Ny(a,i),{index:p,offset:m}=Ny(a,i+s);return{from:{col:l,colOff:c,row:u,rowOff:g},to:{col:h,colOff:d,row:p,rowOff:m}}}function Ny(e,t){let o=0;for(const[i,s]of e.entries()){if(o<=t&&t<o+s.size)return{index:i,offset:$C(t-o+oe)};i<e.length-1&&(o+=s.size)}return{index:e.length-1,offset:$C(t-o+oe)}}function _y(e,t,o){const{from:i,to:s}=My(e,t),r=BC(e.id),n=[["id",r],["name",`Chart ${r}`],["title","Chart"]];return EE`
|
|
2274
2274
|
<xdr:twoCellAnchor>
|
|
2275
2275
|
<xdr:from>
|
|
2276
2276
|
<xdr:col>${i.col}</xdr:col>
|
|
@@ -2286,7 +2286,7 @@
|
|
|
2286
2286
|
</xdr:to>
|
|
2287
2287
|
<xdr:graphicFrame>
|
|
2288
2288
|
<xdr:nvGraphicFramePr>
|
|
2289
|
-
<xdr:cNvPr ${
|
|
2289
|
+
<xdr:cNvPr ${fE(n)} />
|
|
2290
2290
|
<xdr:cNvGraphicFramePr />
|
|
2291
2291
|
</xdr:nvGraphicFramePr>
|
|
2292
2292
|
<xdr:xfrm>
|
|
@@ -2294,14 +2294,14 @@
|
|
|
2294
2294
|
<a:ext cx="0" cy="0"/>
|
|
2295
2295
|
</xdr:xfrm>
|
|
2296
2296
|
<a:graphic>
|
|
2297
|
-
<a:graphicData uri="${
|
|
2297
|
+
<a:graphicData uri="${NS}">
|
|
2298
2298
|
<c:chart r:id="${o}" />
|
|
2299
2299
|
</a:graphicData>
|
|
2300
2300
|
</a:graphic>
|
|
2301
2301
|
</xdr:graphicFrame>
|
|
2302
2302
|
<xdr:clientData fLocksWithSheet="0"/>
|
|
2303
2303
|
</xdr:twoCellAnchor>
|
|
2304
|
-
`}function
|
|
2304
|
+
`}function Fy(e,t,o){const{from:i,to:s}=My(e,t),r=HC(e.id),n=[["id",r],["name",`Image ${r}`],["title","Image"]],a=$C(e.width),l=$C(e.height);return EE`
|
|
2305
2305
|
<xdr:twoCellAnchor editAs="oneCell">
|
|
2306
2306
|
<xdr:from>
|
|
2307
2307
|
<xdr:col>${i.col}</xdr:col>
|
|
@@ -2317,7 +2317,7 @@
|
|
|
2317
2317
|
</xdr:to>
|
|
2318
2318
|
<xdr:pic>
|
|
2319
2319
|
<xdr:nvPicPr>
|
|
2320
|
-
<xdr:cNvPr ${
|
|
2320
|
+
<xdr:cNvPr ${fE(n)}/>
|
|
2321
2321
|
<xdr:cNvPicPr preferRelativeResize="0"/>
|
|
2322
2322
|
</xdr:nvPicPr>
|
|
2323
2323
|
<xdr:blipFill>
|
|
@@ -2338,69 +2338,69 @@
|
|
|
2338
2338
|
</xdr:pic>
|
|
2339
2339
|
<xdr:clientData fLocksWithSheet="0"/>
|
|
2340
2340
|
</xdr:twoCellAnchor>
|
|
2341
|
-
`}function
|
|
2341
|
+
`}function Dy(e){return Ue(e)?EE``:EE`
|
|
2342
2342
|
<font>
|
|
2343
|
-
${e.bold?
|
|
2344
|
-
${e.italic?
|
|
2345
|
-
${e.underline?
|
|
2346
|
-
${e.strike?
|
|
2347
|
-
${e.size?
|
|
2348
|
-
${e.color&&e.color.rgb?
|
|
2349
|
-
${e.name?
|
|
2343
|
+
${e.bold?EE`<b />`:""}
|
|
2344
|
+
${e.italic?EE`<i />`:""}
|
|
2345
|
+
${e.underline?EE`<u />`:""}
|
|
2346
|
+
${e.strike?EE`<strike />`:""}
|
|
2347
|
+
${e.size?EE`<sz val="${e.size}" />`:""}
|
|
2348
|
+
${e.color&&e.color.rgb?EE`<color rgb="${$g(e.color.rgb)}" />`:""}
|
|
2349
|
+
${e.name?EE`<name val="${e.name}" />`:""}
|
|
2350
2350
|
</font>
|
|
2351
|
-
`}function
|
|
2352
|
-
<color ${
|
|
2353
|
-
`:
|
|
2354
|
-
<table ${
|
|
2355
|
-
${function(e){const t=[["ref",e.range]];return
|
|
2356
|
-
<autoFilter ${
|
|
2357
|
-
${
|
|
2358
|
-
<filterColumn ${
|
|
2359
|
-
${
|
|
2351
|
+
`}function Ly(e){return e?fE([["style",e.style]]):EE``}function Py(e){return e?EE`
|
|
2352
|
+
<color ${fE([["rgb",$g(e.color.rgb)]])}/>
|
|
2353
|
+
`:EE``}const ky=EE`<tableStyleInfo ${fE([["name","TableStyleLight8"],["showFirstColumn","0"],["showLastColumn","0"],["showRowStripes","0"],["showColumnStripes","0"]])}/>`;function Uy(e,t,o){const i=EE`
|
|
2354
|
+
<table ${fE([["id",t],["name",`Table${t}`],["displayName",`Table${t}`],["ref",e.range],["xmlns",OS.table],["xmlns:xr",OS.revision],["xmlns:xr3",OS.revision3],["xmlns:mc",OS.markupCompatibility]])}>
|
|
2355
|
+
${function(e){const t=[["ref",e.range]];return EE`
|
|
2356
|
+
<autoFilter ${fE(t)}>
|
|
2357
|
+
${CE(function(e){const t=[];for(const o of e.filters){const e=EE`
|
|
2358
|
+
<filterColumn ${fE([["colId",o.colId]])}>
|
|
2359
|
+
${Vy(o)}
|
|
2360
2360
|
</filterColumn>
|
|
2361
2361
|
`;t.push(e)}return t}(e))}
|
|
2362
2362
|
</autoFilter>
|
|
2363
2363
|
`}(e)}
|
|
2364
|
-
${function(e,t){const o=ti(e.range),i=[];for(const e of ye(0,fi(o).numberOfCols)){const s=xt(o.left+e,o.top),r=[["id",e+1],["name",t.cells[s]?.content||`col${e}`]];i.push(
|
|
2365
|
-
<tableColumns ${
|
|
2366
|
-
${
|
|
2364
|
+
${function(e,t){const o=ti(e.range),i=[];for(const e of ye(0,fi(o).numberOfCols)){const s=xt(o.left+e,o.top),r=[["id",e+1],["name",t.cells[s]?.content||`col${e}`]];i.push(EE`<tableColumn ${fE(r)}/>`)}return EE`
|
|
2365
|
+
<tableColumns ${fE([["count",i.length]])}>
|
|
2366
|
+
${CE(i)}
|
|
2367
2367
|
</tableColumns>
|
|
2368
2368
|
`}(e,o)}
|
|
2369
|
-
${
|
|
2369
|
+
${ky}
|
|
2370
2370
|
</table>
|
|
2371
|
-
`;return
|
|
2372
|
-
<filters ${
|
|
2373
|
-
${
|
|
2371
|
+
`;return bE(i)}function Vy(e){const t=e.displayedValues.map((e=>EE`<filter ${fE([["val",e]])}/>`));return EE`
|
|
2372
|
+
<filters ${fE(e.displayBlanks?[["blank",1]]:[])}>
|
|
2373
|
+
${CE(t)}
|
|
2374
2374
|
</filters>
|
|
2375
|
-
`}function
|
|
2376
|
-
<col ${
|
|
2377
|
-
`)}return
|
|
2375
|
+
`}function By(e){if(!Object.values(e).length)return EE``;const t=[];for(let[o,i]of Object.entries(e)){const e=[["min",parseInt(o)+1],["max",parseInt(o)+1],["width",DC(i.size||L)],["customWidth",1],["hidden",i.isHidden?1:0]];t.push(EE`
|
|
2376
|
+
<col ${fE(e)}/>
|
|
2377
|
+
`)}return EE`
|
|
2378
2378
|
<cols>
|
|
2379
|
-
${
|
|
2379
|
+
${CE(t)}
|
|
2380
2380
|
</cols>
|
|
2381
|
-
`}function
|
|
2381
|
+
`}function zy(e,t,o){const i=[];for(let s=0;s<o.rowNumber;s++){const r=[["r",s+1]],n=o.rows[s]||{};r.push(["ht",FC(n.size||P)],["customHeight",1],["hidden",n.isHidden?1:0]);const a=[];for(let i=0;i<o.colNumber;i++){const r=xt(i,s),n=o.cells[r];if(n){const l=[["r",r]],c=PC(e,LC(n,t));l.push(["s",c]);let h=[],d=EE``;if(n.isFormula)({attrs:h,node:d}=vy(n));else if(n.content&&Oe(n.content)){const{label:t}=_e(n.content);({attrs:h,node:d}=Sy(t,e.sharedStrings))}else if(n.content&&""!==n.content){const t=Hy(i,s,o);({attrs:h,node:d}=Sy(n.content,e.sharedStrings,t))}l.push(...h),a.push(EE`<c ${fE(l)}>
|
|
2382
2382
|
${d}
|
|
2383
|
-
</c>`)}}(a.length||n.size!==P||n.isHidden)&&i.push(
|
|
2384
|
-
<row ${
|
|
2385
|
-
${
|
|
2383
|
+
</c>`)}}(a.length||n.size!==P||n.isHidden)&&i.push(EE`
|
|
2384
|
+
<row ${fE(r)}>
|
|
2385
|
+
${CE(a)}
|
|
2386
2386
|
</row>
|
|
2387
|
-
`)}return
|
|
2387
|
+
`)}return EE`
|
|
2388
2388
|
<sheetData>
|
|
2389
|
-
${
|
|
2389
|
+
${CE(i)}
|
|
2390
2390
|
</sheetData>
|
|
2391
|
-
`}function
|
|
2392
|
-
<hyperlink ${
|
|
2393
|
-
`)}else{const t=[["r:id",
|
|
2394
|
-
<hyperlink ${
|
|
2395
|
-
`)}}}return s.length?
|
|
2391
|
+
`}function Hy(e,t,o){return o.filterTables.some((o=>{const i=ti(o.range),s={...i,bottom:i.top};return ui(e,t,s)}))}function $y(e,t,o){const i=t.sheets[o].cells,s=[];for(const r in i){const n=i[r]?.content;if(n&&Oe(n)){const{label:i,url:a}=_e(n);if(De(a)){const e=Pe(a),o=t.sheets.find((t=>t.id===e)),n=[["display",i],["location",o?`${o.name}!A1`:ee],["ref",r]];s.push(EE`
|
|
2392
|
+
<hyperlink ${fE(n)}/>
|
|
2393
|
+
`)}else{const t=[["r:id",kC(e.relsFiles,`xl/worksheets/_rels/sheet${o}.xml.rels`,{target:es(a),type:FS.hyperlink,targetMode:"External"})],["ref",r]];s.push(EE`
|
|
2394
|
+
<hyperlink ${fE(t)}/>
|
|
2395
|
+
`)}}}return s.length?EE`
|
|
2396
2396
|
<hyperlinks>
|
|
2397
|
-
${
|
|
2397
|
+
${CE(s)}
|
|
2398
2398
|
</hyperlinks>
|
|
2399
|
-
`:
|
|
2399
|
+
`:EE``}function Wy(e){if(e.length){const t=e.map((e=>EE`<mergeCell ref="${e}" />`));return EE`
|
|
2400
2400
|
<mergeCells count="${e.length}">
|
|
2401
|
-
${
|
|
2401
|
+
${CE(t)}
|
|
2402
2402
|
</mergeCells>
|
|
2403
|
-
`}return
|
|
2403
|
+
`}return EE``}function Gy(e){const t=e.panes;let o=EE``;if(t&&(t.xSplit||t.ySplit)){const e=xt(t.xSplit,t.ySplit),i=t.xSplit?EE`xSplit="${t.xSplit}"`:"",s=t.ySplit?EE`ySplit="${t.ySplit}"`:"",r=t.xSplit?EE`<selection pane="topRight"/>`:"",n=t.ySplit?EE`<selection pane="bottomLeft"/>`:"",a=t.xSplit&&t.ySplit?EE`<selection pane="bottomRight"/>`:"";o=EE`
|
|
2404
2404
|
<pane
|
|
2405
2405
|
${i}
|
|
2406
2406
|
${s}
|
|
@@ -2410,132 +2410,132 @@
|
|
|
2410
2410
|
${r}
|
|
2411
2411
|
${n}
|
|
2412
2412
|
${a}
|
|
2413
|
-
`}return
|
|
2413
|
+
`}return EE`
|
|
2414
2414
|
<sheetViews>
|
|
2415
|
-
<sheetView ${
|
|
2415
|
+
<sheetView ${fE([["showGridLines",e.areGridLinesVisible?1:0],["workbookViewId",0]])}>
|
|
2416
2416
|
${o}
|
|
2417
2417
|
</sheetView>
|
|
2418
2418
|
</sheetViews>
|
|
2419
|
-
`}function
|
|
2420
|
-
<sheet ${
|
|
2421
|
-
`),
|
|
2422
|
-
<workbook ${
|
|
2419
|
+
`}function qy(e){const t=[],o=function(e){const t=[{},...Object.values(e.borders).map((e=>({left:vE(e.left),right:vE(e.right),bottom:vE(e.bottom),top:vE(e.top)})))];return{relsFiles:[],sharedStrings:[],styles:[{fontId:0,fillId:0,numFmtId:0,borderId:0,alignment:{vertical:"bottom"}}],fonts:[{size:Z,family:2,color:{rgb:"000000"},name:"Calibri"}],fills:[{reservedAttribute:"none"},{reservedAttribute:"gray125"}],borders:t,numFmts:[],dxfs:[]}}(e);return t.push(function(e,t){const o=[["xmlns",OS.workbook],["xmlns:r",DS]],i=[];for(const[o,s]of Object.entries(e.sheets)){const e=[["state",s.isVisible?"visible":"hidden"],["name",s.name],["sheetId",parseInt(o)+1],["r:id",`rId${parseInt(o)+1}`]];i.push(EE`
|
|
2420
|
+
<sheet ${fE(e)} />
|
|
2421
|
+
`),kC(t.relsFiles,"xl/_rels/workbook.xml.rels",{type:FS.sheet,target:`worksheets/sheet${o}.xml`})}return pE(bE(EE`
|
|
2422
|
+
<workbook ${fE(o)}>
|
|
2423
2423
|
<sheets>
|
|
2424
|
-
${
|
|
2424
|
+
${CE(i)}
|
|
2425
2425
|
</sheets>
|
|
2426
2426
|
</workbook>
|
|
2427
|
-
`),"xl/workbook.xml","workbook")}(e,o)),t.push(...function(e,t){const o=[];let i=1;for(const[s,r]of Object.entries(e.sheets)){const n=[["xmlns",
|
|
2428
|
-
<worksheet ${
|
|
2429
|
-
${
|
|
2430
|
-
<sheetFormatPr ${
|
|
2431
|
-
${
|
|
2432
|
-
${
|
|
2433
|
-
${
|
|
2434
|
-
${
|
|
2435
|
-
${
|
|
2427
|
+
`),"xl/workbook.xml","workbook")}(e,o)),t.push(...function(e,t){const o=[];let i=1;for(const[s,r]of Object.entries(e.sheets)){const n=[["xmlns",OS.worksheet],["xmlns:r",DS]],a=[["defaultRowHeight",FC(P)],["defaultColWidth",DC(L)]],l=Zy(r,s,i,t,o);i+=r.filterTables.length;let c=EE``;const h=[];for(const i of r.charts){const r=BC(i.id),n=kC(t.relsFiles,`xl/drawings/_rels/drawing${s}.xml.rels`,{target:`../charts/chart${r}.xml`,type:FS.chart});h.push(n),o.push(pE(cy(i,s,e),`xl/charts/chart${r}.xml`,"chart"))}for(const e of r.images){const i=e.data.mimetype;if(void 0===i)continue;const r=gC[i];if(void 0===r)continue;let n=`image${HC(e.id)}.${r}`;const a=kC(t.relsFiles,`xl/drawings/_rels/drawing${s}.xml.rels`,{target:`../media/${n}`,type:FS.image});h.push(a),o.push({path:`xl/media/${n}`,imageSrc:e.data.path})}const d=[...r.charts,...r.images];if(d.length){const e=kC(t.relsFiles,`xl/worksheets/_rels/sheet${s}.xml.rels`,{target:`../drawings/drawing${s}.xml`,type:FS.drawing});o.push(pE(Oy(h,r,d),`xl/drawings/drawing${s}.xml`,"drawing")),c=EE`<drawing r:id="${e}" />`}const u=EE`
|
|
2428
|
+
<worksheet ${fE(n)}>
|
|
2429
|
+
${Gy(r)}
|
|
2430
|
+
<sheetFormatPr ${fE(a)} />
|
|
2431
|
+
${By(r.cols)}
|
|
2432
|
+
${zy(t,e,r)}
|
|
2433
|
+
${Wy(r.merges)}
|
|
2434
|
+
${CE(wy(t.dxfs,r.conditionalFormats))}
|
|
2435
|
+
${$y(t,e,s)}
|
|
2436
2436
|
${c}
|
|
2437
2437
|
${l}
|
|
2438
2438
|
</worksheet>
|
|
2439
|
-
`;o.push(bE(
|
|
2440
|
-
<styleSheet ${
|
|
2441
|
-
${function(e){const t=[];for(let[o,i]of Object.entries(e)){const e=[["numFmtId",parseInt(o)
|
|
2442
|
-
<numFmt ${
|
|
2443
|
-
`)}return
|
|
2439
|
+
`;o.push(pE(bE(u),`xl/worksheets/sheet${s}.xml`,"sheet"))}return kC(t.relsFiles,"xl/_rels/workbook.xml.rels",{type:FS.sharedStrings,target:"sharedStrings.xml"}),kC(t.relsFiles,"xl/_rels/workbook.xml.rels",{type:FS.styles,target:"styles.xml"}),o}(e,o)),t.push(function(e){const t=EE`
|
|
2440
|
+
<styleSheet ${fE([["xmlns",OS.styleSheet],["xmlns:r",DS]])}>
|
|
2441
|
+
${function(e){const t=[];for(let[o,i]of Object.entries(e)){const e=[["numFmtId",parseInt(o)+zS],["formatCode",i.format]];t.push(EE`
|
|
2442
|
+
<numFmt ${fE(e)}/>
|
|
2443
|
+
`)}return EE`
|
|
2444
2444
|
<numFmts count="${e.length}">
|
|
2445
|
-
${
|
|
2445
|
+
${CE(t)}
|
|
2446
2446
|
</numFmts>
|
|
2447
2447
|
`}(e.numFmts)}
|
|
2448
|
-
${o=e.fonts,
|
|
2448
|
+
${o=e.fonts,EE`
|
|
2449
2449
|
<fonts count="${o.length}">
|
|
2450
|
-
${
|
|
2450
|
+
${CE(Object.values(o).map(Dy))}
|
|
2451
2451
|
</fonts>
|
|
2452
2452
|
`}
|
|
2453
|
-
${function(e){const t=[];for(let o of Object.values(e))void 0!==o.reservedAttribute?t.push(
|
|
2453
|
+
${function(e){const t=[];for(let o of Object.values(e))void 0!==o.reservedAttribute?t.push(EE`
|
|
2454
2454
|
<fill>
|
|
2455
2455
|
<patternFill patternType="${o.reservedAttribute}" />
|
|
2456
2456
|
</fill>
|
|
2457
|
-
`):t.push(
|
|
2457
|
+
`):t.push(EE`
|
|
2458
2458
|
<fill>
|
|
2459
2459
|
<patternFill patternType="solid">
|
|
2460
2460
|
<fgColor rgb="${$g(o.fgColor.rgb)}" />
|
|
2461
2461
|
<bgColor indexed="64" />
|
|
2462
2462
|
</patternFill>
|
|
2463
2463
|
</fill>
|
|
2464
|
-
`);return
|
|
2464
|
+
`);return EE`
|
|
2465
2465
|
<fills count="${e.length}">
|
|
2466
|
-
${
|
|
2466
|
+
${CE(t)}
|
|
2467
2467
|
</fills>
|
|
2468
2468
|
`}(e.fills)}
|
|
2469
|
-
${function(e){const t=[];for(let o of Object.values(e))t.push(
|
|
2469
|
+
${function(e){const t=[];for(let o of Object.values(e))t.push(EE`
|
|
2470
2470
|
<border>
|
|
2471
|
-
<left ${
|
|
2472
|
-
${
|
|
2471
|
+
<left ${Ly(o.left)}>
|
|
2472
|
+
${Py(o.left)}
|
|
2473
2473
|
</left>
|
|
2474
|
-
<right ${
|
|
2475
|
-
${
|
|
2474
|
+
<right ${Ly(o.right)}>
|
|
2475
|
+
${Py(o.right)}
|
|
2476
2476
|
</right>
|
|
2477
|
-
<top ${
|
|
2478
|
-
${
|
|
2477
|
+
<top ${Ly(o.top)}>
|
|
2478
|
+
${Py(o.top)}
|
|
2479
2479
|
</top>
|
|
2480
|
-
<bottom ${
|
|
2481
|
-
${
|
|
2480
|
+
<bottom ${Ly(o.bottom)}>
|
|
2481
|
+
${Py(o.bottom)}
|
|
2482
2482
|
</bottom>
|
|
2483
|
-
<diagonal ${
|
|
2484
|
-
${
|
|
2483
|
+
<diagonal ${Ly(o.diagonal)}>
|
|
2484
|
+
${Py(o.diagonal)}
|
|
2485
2485
|
</diagonal>
|
|
2486
2486
|
</border>
|
|
2487
|
-
`);return
|
|
2487
|
+
`);return EE`
|
|
2488
2488
|
<borders count="${e.length}">
|
|
2489
|
-
${
|
|
2489
|
+
${CE(t)}
|
|
2490
2490
|
</borders>
|
|
2491
2491
|
`}(e.borders)}
|
|
2492
|
-
${function(e){const t=[];for(let o of e){const e=[["numFmtId",o.numFmtId],["fillId",o.fillId],["fontId",o.fontId],["borderId",o.borderId]],i=[];o.alignment&&o.alignment.vertical&&i.push(["vertical",o.alignment.vertical]),o.alignment&&o.alignment.horizontal&&i.push(["horizontal",o.alignment.horizontal]),o.alignment&&o.alignment.wrapText&&i.push(["wrapText","1"]),i.length>0?(e.push(["applyAlignment","1"]),t.push(
|
|
2492
|
+
${function(e){const t=[];for(let o of e){const e=[["numFmtId",o.numFmtId],["fillId",o.fillId],["fontId",o.fontId],["borderId",o.borderId]],i=[];o.alignment&&o.alignment.vertical&&i.push(["vertical",o.alignment.vertical]),o.alignment&&o.alignment.horizontal&&i.push(["horizontal",o.alignment.horizontal]),o.alignment&&o.alignment.wrapText&&i.push(["wrapText","1"]),i.length>0?(e.push(["applyAlignment","1"]),t.push(EE`<xf ${fE(e)}>${EE`<alignment ${fE(i)} />`}</xf> `)):t.push(EE`<xf ${fE(e)} />`)}return EE`
|
|
2493
2493
|
<cellXfs count="${e.length}">
|
|
2494
|
-
${
|
|
2494
|
+
${CE(t)}
|
|
2495
2495
|
</cellXfs>
|
|
2496
2496
|
`}(e.styles)}
|
|
2497
|
-
${function(e){const t=[];for(const o of e){let e=
|
|
2497
|
+
${function(e){const t=[];for(const o of e){let e=EE``;o.font&&(e=Dy(o.font));let i=EE``;o.fill&&(i=EE`
|
|
2498
2498
|
<fill>
|
|
2499
2499
|
<patternFill>
|
|
2500
2500
|
<bgColor rgb="${$g(o.fill.fgColor.rgb)}" />
|
|
2501
2501
|
</patternFill>
|
|
2502
2502
|
</fill>
|
|
2503
|
-
`),t.push(
|
|
2503
|
+
`),t.push(EE`
|
|
2504
2504
|
<dxf>
|
|
2505
2505
|
${e}
|
|
2506
2506
|
${i}
|
|
2507
2507
|
</dxf>
|
|
2508
|
-
`)}return
|
|
2508
|
+
`)}return EE`
|
|
2509
2509
|
<dxfs count="${e.length}">
|
|
2510
|
-
${
|
|
2510
|
+
${CE(t)}
|
|
2511
2511
|
</dxfs>
|
|
2512
2512
|
`}(e.dxfs)}
|
|
2513
2513
|
</styleSheet>
|
|
2514
|
-
`;var o;return bE(
|
|
2515
|
-
<sst ${
|
|
2516
|
-
${
|
|
2514
|
+
`;var o;return pE(bE(t),"xl/styles.xml","styles")}(o)),t.push(function(e){const t=[["xmlns",OS.sst],["count",e.length],["uniqueCount",e.length]],o=e.map((e=>EE`<si><t>${e}</t></si>`));return pE(bE(EE`
|
|
2515
|
+
<sst ${fE(t)}>
|
|
2516
|
+
${CE(o)}
|
|
2517
2517
|
</sst>
|
|
2518
|
-
`),"xl/sharedStrings.xml","sharedStrings")}(o.sharedStrings)),t.push(...function(e){const t=[];for(const o of e){const e=[];for(const t of o.rels){const o=[["Id",t.id],["Target",t.target],["Type",t.type]];t.targetMode&&o.push(["TargetMode",t.targetMode]),e.push(
|
|
2519
|
-
<Relationship ${
|
|
2520
|
-
`)}const i=
|
|
2521
|
-
<Relationships xmlns="${
|
|
2522
|
-
${
|
|
2518
|
+
`),"xl/sharedStrings.xml","sharedStrings")}(o.sharedStrings)),t.push(...function(e){const t=[];for(const o of e){const e=[];for(const t of o.rels){const o=[["Id",t.id],["Target",t.target],["Type",t.type]];t.targetMode&&o.push(["TargetMode",t.targetMode]),e.push(EE`
|
|
2519
|
+
<Relationship ${fE(o)} />
|
|
2520
|
+
`)}const i=EE`
|
|
2521
|
+
<Relationships xmlns="${OS.Relationships}">
|
|
2522
|
+
${CE(e)}
|
|
2523
2523
|
</Relationships>
|
|
2524
|
-
`;t.push(bE(
|
|
2524
|
+
`;t.push(pE(bE(i),o.path))}return t}(o.relsFiles)),t.push(function(e){const t=[],o=Object.entries(gC).map((([e,t])=>function(e,t){return EE`
|
|
2525
2525
|
<Default Extension="${e}" ContentType="${t}" />
|
|
2526
|
-
`}(t,e)));for(const o of e)"contentType"in o&&o.contentType&&t.push(
|
|
2527
|
-
<Types xmlns="${
|
|
2528
|
-
${
|
|
2529
|
-
<Default ${
|
|
2530
|
-
<Default ${
|
|
2531
|
-
${
|
|
2526
|
+
`}(t,e)));for(const o of e)"contentType"in o&&o.contentType&&t.push(SE("/"+o.path,_S[o.contentType]));const i=[["Extension","rels"],["ContentType","application/vnd.openxmlformats-package.relationships+xml"]],s=[["Extension","xml"],["ContentType","application/xml"]];return pE(bE(EE`
|
|
2527
|
+
<Types xmlns="${OS.Types}">
|
|
2528
|
+
${CE(Object.values(o))}
|
|
2529
|
+
<Default ${fE(i)} />
|
|
2530
|
+
<Default ${fE(s)} />
|
|
2531
|
+
${CE(t)}
|
|
2532
2532
|
</Types>
|
|
2533
|
-
`),"[Content_Types].xml")}(t)),t.push(function(){const e=[["Id","rId1"],["Type",
|
|
2534
|
-
<Relationships xmlns="${
|
|
2535
|
-
<Relationship ${
|
|
2533
|
+
`),"[Content_Types].xml")}(t)),t.push(function(){const e=[["Id","rId1"],["Type",FS.document],["Target","xl/workbook.xml"]];return pE(bE(EE`
|
|
2534
|
+
<Relationships xmlns="${OS.Relationships}">
|
|
2535
|
+
<Relationship ${fE(e)} />
|
|
2536
2536
|
</Relationships>
|
|
2537
|
-
`),"_rels/.rels")}()),{name:"my_spreadsheet.xlsx",files:t}}function
|
|
2537
|
+
`),"_rels/.rels")}()),{name:"my_spreadsheet.xlsx",files:t}}function Zy(e,t,o,i,s){let r=o;if(!e.filterTables.length)return new IS("");const n=`xl/worksheets/_rels/sheet${t}.xml.rels`,a=[];for(const t of e.filterTables){const o=kC(i.relsFiles,n,{target:`../tables/table${r}.xml`,type:FS.table});s.push(pE(Uy(t,r,e),`xl/tables/table${r}.xml`,"table")),a.push(EE`<tablePart r:id="${o}" />`),r++}return EE`
|
|
2538
2538
|
<tableParts count="${e.filterTables.length}">
|
|
2539
|
-
${
|
|
2539
|
+
${CE(a)}
|
|
2540
2540
|
</tableParts>
|
|
2541
|
-
`}var Ky;!function(e){e[e.Ready=0]="Ready",e[e.Running=1]="Running",e[e.RunningCore=2]="RunningCore",e[e.Finalizing=3]="Finalizing"}(Ky||(Ky={}));function Qy(e,t={}){const o=Ce(t);return o.type=e,o}const Jy={},eI={MIN_ROW_HEIGHT:10,MIN_COL_WIDTH:5,HEADER_HEIGHT:F,HEADER_WIDTH:D,TOPBAR_HEIGHT:63,BOTTOMBAR_HEIGHT:36,DEFAULT_CELL_WIDTH:L,DEFAULT_CELL_HEIGHT:P,SCROLLBAR_WIDTH:k},tI={autofillModifiersRegistry:hr,autofillRulesRegistry:dr,cellMenuRegistry:If,colMenuRegistry:qb,linkMenuRegistry:Vg,functionRegistry:fu,featurePluginRegistry:wx,statefulUIPluginRegistry:xx,coreViewsPluginRegistry:yx,corePluginRegistry:Ex,rowMenuRegistry:jb,sidePanelRegistry:Mv,figureRegistry:Qp,chartSidePanelComponentRegistry:bv,chartComponentRegistry:Zp,chartRegistry:qp,topbarMenuRegistry:Xb,topbarComponentRegistry:Nv,clickableCellRegistry:Ix,otRegistry:Kb,inverseCommandRegistry:om,urlRegistry:ts,cellPopoverRegistry:Hg,numberFormatMenuRegistry:Zb,repeatLocalCommandTransformRegistry:sx,repeatCommandTransformRegistry:ix},oI={arg:Wr,toBoolean:Ds,toJsDate:Ls,toNumber:Is,toString:Ms,toXC:xt,toZone:ti,toCartesian:wt,numberToLetters:bt,UuidGenerator:Bi,formatValue:fo,createCurrencyFormat:_o,computeTextWidth:Fi,createEmptyWorkbookData:jE,createEmptySheet:YE,createEmptyExcelSheet:XE,getDefaultChartJsRuntime:Cp,chartFontColor:ip,ChartColors:op,EvaluationError:c,CellErrorLevel:l,getFillingMode:yp,rgbaToHex:dt,colorToRGBA:ut,positionToZone:wi,isDefined:ke,lazy:ze,genericRepeat:rx},iI={isMarkdownLink:Oe,parseMarkdownLink:_e,markdownLink:Ne,openLink:ns,urlRepresentation:rs},sI={ChartPanel:vv,ChartFigure:jp,ChartJsComponent:zi,Grid:RS,GridOverlay:hS,ScorecardChart:Xi,LineConfigPanel:pv,LineBarPieDesignPanel:dv,BarConfigPanel:sv,LineBarPieConfigPanel:iv,GaugeChartConfigPanel:uv,GaugeChartDesignPanel:gv,ScorecardChartConfigPanel:mv,ScorecardChartDesignPanel:fv,FigureComponent:_v};const rI={DEFAULT_LOCALE:eo};e.AbstractChart=Wg,e.CorePlugin=QE,e.DispatchResult=fs,e.EvaluationError=c,e.Model=class extends Uw{corePlugins=[];featurePlugins=[];statefulUIPlugins=[];coreViewsPlugins=[];range;session;isReplayingCommand=!1;renderers=[];status=0;config;corePluginConfig;uiPluginConfig;state;selection;getters;coreGetters;uuidGenerator;handlers=[];uiHandlers=[];coreHandlers=[];constructor(e={},o={},i=[],s=new Bi,r=!0){super(),i=GE(e,i);const n=$E(e,r);this.state=new cy,this.uuidGenerator=s,this.config=this.setupConfig(o),this.session=this.setupSession(n.revisionId),this.coreGetters={},this.range=new rw(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.getRangeFromZone=this.range.getRangeFromZone.bind(this.range),this.getters={isReadonly:()=>"readonly"===this.config.mode||"dashboard"===this.config.mode,isDashboard:()=>"dashboard"===this.config.mode},this.uuidGenerator.setIsFastStrategy(!0),this.selection=new ly(this.getters),this.coreHandlers.push(this.range),this.handlers.push(this.range),this.corePluginConfig=this.setupCorePluginConfig(),this.uiPluginConfig=this.setupUiPluginConfig();for(let e of Ex.getAll())this.setupCorePlugin(e,n);Object.assign(this.getters,this.coreGetters),this.session.loadInitialMessages(i);for(let e of yx.getAll()){const t=this.setupUiPlugin(e);this.coreViewsPlugins.push(t),this.handlers.push(t),this.uiHandlers.push(t),this.coreHandlers.push(t)}for(let e of xx.getAll()){const t=this.setupUiPlugin(e);this.statefulUIPlugins.push(t),this.handlers.push(t),this.uiHandlers.push(t)}for(let e of wx.getAll()){const t=this.setupUiPlugin(e);this.featurePlugins.push(t),this.handlers.push(t),this.uiHandlers.push(t)}this.uuidGenerator.setIsFastStrategy(!1),this.dispatch("START"),this.selection.observe(this,{handleEvent:()=>this.trigger("update")}),this.setupSessionEvents(),this.joinSession(),o.snapshotRequested&&(this.session.snapshot(this.exportData()),this.garbageCollectExternalResources()),t.markRaw(this)}joinSession(){this.session.join(this.config.client)}leaveSession(){this.session.leave()}setupUiPlugin(e){const t=new e(this.uiPluginConfig);for(let o of e.getters){if(!(o in t))throw new Error(`Invalid getter name: ${o} for plugin ${t.constructor}`);if(o in this.getters)throw new Error(`Getter "${o}" is already defined.`);this.getters[o]=t[o].bind(t)}const o=e.layers.map((e=>[t,e]));return this.renderers.push(...o),this.renderers.sort(((e,t)=>e[1]-t[1])),t}setupCorePlugin(e,t){const o=new e(this.corePluginConfig);for(let t of e.getters){if(!(t in o))throw new Error(`Invalid getter name: ${t} for plugin ${o.constructor}`);if(t in this.coreGetters)throw new Error(`Getter "${t}" is already defined.`);this.coreGetters[t]=o[t].bind(o)}o.import(t),this.corePlugins.push(o),this.coreHandlers.push(o),this.handlers.push(o)}onRemoteRevisionReceived({commands:e}){for(let t of e){const e=this.status;this.status=2,this.dispatchToHandlers(this.statefulUIPlugins,t),this.status=e}this.finalize()}setupSession(e){return new Zw(ry({initialRevisionId:e,recordChanges:this.state.recordChanges.bind(this.state),dispatch: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-undone",this,(({commands:e})=>{this.dispatchFromCorePlugin("UNDO",{commands:e}),this.finalize()})),this.session.on("revision-redone",this,(({commands:e})=>{this.dispatchFromCorePlugin("REDO",{commands:e}),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()},o=e.transportService||new Xx;return{...e,mode:e.mode||"normal",custom:e.custom||{},defaultCurrencyFormat:e.defaultCurrencyFormat||"[$$]#,##0.00",external:this.setupExternalConfig(e.external||{}),transportService:o,client:t,moveClient:()=>{},snapshotRequested:!1,notifyUI:e=>this.trigger("notify-ui",e)}}setupExternalConfig(e){const t=e.loadLocales||(()=>Promise.resolve(Jt));return{...e,loadLocales:t}}setupCorePluginConfig(){return{getters:this.coreGetters,stateObserver:this.state,range:this.range,dispatch:this.dispatchFromCorePlugin,uuidGenerator:this.uuidGenerator,custom:this.config.custom,external:this.config.external}}setupUiPluginConfig(){return{getters:this.getters,stateObserver:this.state,dispatch:this.dispatch,selection:this.selection,moveClient:this.session.move.bind(this.session),custom:this.config.custom,uiActions:this.config,session:this.session}}checkDispatchAllowed(e){const t=ms(e)?this.checkDispatchAllowedCoreCommand(e):this.checkDispatchAllowedLocalCommand(e);return t.some((e=>0!==e))?new fs(t.flat()):fs.Success}checkDispatchAllowedCoreCommand(e){const t=this.corePlugins.map((t=>t.allowDispatch(e)));return t.push(this.range.allowDispatch(e)),t}checkDispatchAllowedLocalCommand(e){return this.uiHandlers.map((t=>t.allowDispatch(e)))}finalize(){this.status=3;for(const e of this.handlers)e.finalize();this.status=0}canDispatch=(e,t)=>this.checkDispatchAllowed(Qy(e,t));dispatch=(e,t)=>{const o=Qy(e,t);let i=this.status;if(this.getters.isReadonly()&&(s=o,!gs.has(s.type)))return new fs(70);var s;if(!this.session.canApplyOptimisticUpdate())return new fs(67);switch(i){case 0:const t=this.checkDispatchAllowed(o);if(!t.isSuccessful)return t;this.status=1;const{changes:i,commands:s}=this.state.recordChanges((()=>{ms(o)&&this.state.addCommand(o),this.dispatchToHandlers(this.handlers,o),this.finalize()}));this.session.save(o,s,i),this.status=0,this.trigger("update");break;case 1:if(ms(o)){const e=this.checkDispatchAllowed(o);if(!e.isSuccessful)return e;this.state.addCommand(o)}this.dispatchToHandlers(this.handlers,o);break;case 3:throw new Error("Cannot dispatch commands in the finalize state");case 2:if(ms(o))throw new Error(`A UI plugin cannot dispatch ${e} while handling a core command`);this.dispatchToHandlers(this.handlers,o)}return fs.Success};dispatchFromCorePlugin=(e,t)=>{const o=Qy(e,t),i=this.status;this.status=2;const s=this.isReplayingCommand?this.coreHandlers:this.handlers;return this.dispatchToHandlers(s,o),this.status=i,fs.Success};dispatchToHandlers(e,t){for(const o of e)o.beforeHandle(t);for(const o of e)o.handle(t)}drawGrid(e){for(let[t,o]of this.renderers)e.ctx.save(),t.drawGrid(e,o),e.ctx.restore()}exportData(){let e=jE();for(let t of this.handlers)t instanceof QE&&t.export(e);return e.revisionId=this.session.getRevisionId()||te,e=Ce(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={...jE(),sheets:[XE(HE,"Sheet1")]};for(let t of this.handlers)t instanceof KE&&t.exportForExcel(e);return e=Ce(e),jy(e)}garbageCollectExternalResources(){for(const e of this.corePlugins)e.garbageCollectExternalResources()}},e.Registry=Ji,e.Revision=Gw,e.SPREADSHEET_DIMENSIONS=eI,e.Spreadsheet=jx,e.UIPlugin=nw,e.__info__=Jy,e.addFunction=function(e,t){fu.add(e,t)},e.astToFormula=Ku,e.compile=hg,e.components=sI,e.constants=rI,e.convertAstNodes=Zu,e.coreTypes=ps,e.findCellInNewZone=Ci,e.functionCache=cg,e.helpers=oI,e.invalidateCFEvaluationCommands=us,e.invalidateDependenciesCommands=ds,e.invalidateEvaluationCommands=hs,e.iterateAstNodes=Yu,e.links=iI,e.load=$E,e.parse=Gu,e.readonlyAllowedCommands=gs,e.registries=tI,e.setDefaultSheetViewSize=function(e){pe=e},e.setTranslationMethod=function(e){o=e},e.tokenize=xu,Object.defineProperty(e,"__esModule",{value:!0}),Jy.version="16.4.28",Jy.date="2024-04-05T13:59:39.997Z",Jy.hash="7127826"}(this.o_spreadsheet=this.o_spreadsheet||{},owl);
|
|
2541
|
+
`}var Yy;!function(e){e[e.Ready=0]="Ready",e[e.Running=1]="Running",e[e.RunningCore=2]="RunningCore",e[e.Finalizing=3]="Finalizing"}(Yy||(Yy={}));function jy(e,t={}){const o=Ce(t);return o.type=e,o}const Xy={},Ky={MIN_ROW_HEIGHT:10,MIN_COL_WIDTH:5,HEADER_HEIGHT:F,HEADER_WIDTH:D,TOPBAR_HEIGHT:63,BOTTOMBAR_HEIGHT:36,DEFAULT_CELL_WIDTH:L,DEFAULT_CELL_HEIGHT:P,SCROLLBAR_WIDTH:k},Qy={autofillModifiersRegistry:hr,autofillRulesRegistry:dr,cellMenuRegistry:yf,colMenuRegistry:Wb,linkMenuRegistry:Vg,functionRegistry:fu,featurePluginRegistry:Cx,statefulUIPluginRegistry:Ex,coreViewsPluginRegistry:wx,corePluginRegistry:Sx,rowMenuRegistry:Zb,sidePanelRegistry:Av,figureRegistry:Qp,chartSidePanelComponentRegistry:mv,chartComponentRegistry:Zp,chartRegistry:qp,topbarMenuRegistry:Yb,topbarComponentRegistry:Ov,clickableCellRegistry:xx,otRegistry:jb,inverseCommandRegistry:om,urlRegistry:ts,cellPopoverRegistry:Hg,numberFormatMenuRegistry:Gb,repeatLocalCommandTransformRegistry:ox,repeatCommandTransformRegistry:tx},Jy={arg:Wr,toBoolean:Ds,toJsDate:Ls,toNumber:Is,toString:Ms,toXC:xt,toZone:ti,toCartesian:wt,numberToLetters:bt,UuidGenerator:Bi,formatValue:fo,createCurrencyFormat:_o,computeTextWidth:Fi,createEmptyWorkbookData:ZE,createEmptySheet:qE,createEmptyExcelSheet:YE,getDefaultChartJsRuntime:Cp,chartFontColor:ip,ChartColors:op,EvaluationError:c,CellErrorLevel:l,getFillingMode:yp,rgbaToHex:dt,colorToRGBA:ut,positionToZone:wi,isDefined:ke,lazy:ze,genericRepeat:ix},eI={isMarkdownLink:Oe,parseMarkdownLink:_e,markdownLink:Ne,openLink:ns,urlRepresentation:rs},tI={ChartPanel:fv,ChartFigure:jp,ChartJsComponent:zi,Grid:yS,GridOverlay:lS,ScorecardChart:Xi,LineConfigPanel:uv,LineBarPieDesignPanel:cv,BarConfigPanel:ov,LineBarPieConfigPanel:tv,GaugeChartConfigPanel:hv,GaugeChartDesignPanel:dv,ScorecardChartConfigPanel:gv,ScorecardChartDesignPanel:pv,FigureComponent:Mv};const oI={DEFAULT_LOCALE:eo};e.AbstractChart=Wg,e.CorePlugin=XE,e.DispatchResult=fs,e.EvaluationError=c,e.Model=class extends Pw{corePlugins=[];featurePlugins=[];statefulUIPlugins=[];coreViewsPlugins=[];range;session;isReplayingCommand=!1;renderers=[];status=0;config;corePluginConfig;uiPluginConfig;state;selection;getters;coreGetters;uuidGenerator;handlers=[];uiHandlers=[];coreHandlers=[];constructor(e={},o={},i=[],s=new Bi,r=!0){super(),i=$E(e,i);const n=zE(e,r);this.state=new ny,this.uuidGenerator=s,this.config=this.setupConfig(o),this.session=this.setupSession(n.revisionId),this.coreGetters={},this.range=new iw(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.getRangeFromZone=this.range.getRangeFromZone.bind(this.range),this.getters={isReadonly:()=>"readonly"===this.config.mode||"dashboard"===this.config.mode,isDashboard:()=>"dashboard"===this.config.mode},this.uuidGenerator.setIsFastStrategy(!0),this.selection=new ry(this.getters),this.coreHandlers.push(this.range),this.handlers.push(this.range),this.corePluginConfig=this.setupCorePluginConfig(),this.uiPluginConfig=this.setupUiPluginConfig();for(let e of Sx.getAll())this.setupCorePlugin(e,n);Object.assign(this.getters,this.coreGetters),this.session.loadInitialMessages(i);for(let e of wx.getAll()){const t=this.setupUiPlugin(e);this.coreViewsPlugins.push(t),this.handlers.push(t),this.uiHandlers.push(t),this.coreHandlers.push(t)}for(let e of Ex.getAll()){const t=this.setupUiPlugin(e);this.statefulUIPlugins.push(t),this.handlers.push(t),this.uiHandlers.push(t)}for(let e of Cx.getAll()){const t=this.setupUiPlugin(e);this.featurePlugins.push(t),this.handlers.push(t),this.uiHandlers.push(t)}this.uuidGenerator.setIsFastStrategy(!1),this.dispatch("START"),this.selection.observe(this,{handleEvent:()=>this.trigger("update")}),this.setupSessionEvents(),this.joinSession(),o.snapshotRequested&&(this.session.snapshot(this.exportData()),this.garbageCollectExternalResources()),t.markRaw(this)}joinSession(){this.session.join(this.config.client)}leaveSession(){this.session.leave()}setupUiPlugin(e){const t=new e(this.uiPluginConfig);for(let o of e.getters){if(!(o in t))throw new Error(`Invalid getter name: ${o} for plugin ${t.constructor}`);if(o in this.getters)throw new Error(`Getter "${o}" is already defined.`);this.getters[o]=t[o].bind(t)}const o=e.layers.map((e=>[t,e]));return this.renderers.push(...o),this.renderers.sort(((e,t)=>e[1]-t[1])),t}setupCorePlugin(e,t){const o=new e(this.corePluginConfig);for(let t of e.getters){if(!(t in o))throw new Error(`Invalid getter name: ${t} for plugin ${o.constructor}`);if(t in this.coreGetters)throw new Error(`Getter "${t}" is already defined.`);this.coreGetters[t]=o[t].bind(o)}o.import(t),this.corePlugins.push(o),this.coreHandlers.push(o),this.handlers.push(o)}onRemoteRevisionReceived({commands:e}){for(let t of e){const e=this.status;this.status=2,this.dispatchToHandlers(this.statefulUIPlugins,t),this.status=e}this.finalize()}setupSession(e){return new Gw(oy({initialRevisionId:e,recordChanges:this.state.recordChanges.bind(this.state),dispatch: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-undone",this,(({commands:e})=>{this.dispatchFromCorePlugin("UNDO",{commands:e}),this.finalize()})),this.session.on("revision-redone",this,(({commands:e})=>{this.dispatchFromCorePlugin("REDO",{commands:e}),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()},o=e.transportService||new Zx;return{...e,mode:e.mode||"normal",custom:e.custom||{},defaultCurrencyFormat:e.defaultCurrencyFormat||"[$$]#,##0.00",external:this.setupExternalConfig(e.external||{}),transportService:o,client:t,moveClient:()=>{},snapshotRequested:!1,notifyUI:e=>this.trigger("notify-ui",e)}}setupExternalConfig(e){const t=e.loadLocales||(()=>Promise.resolve(Jt));return{...e,loadLocales:t}}setupCorePluginConfig(){return{getters:this.coreGetters,stateObserver:this.state,range:this.range,dispatch:this.dispatchFromCorePlugin,uuidGenerator:this.uuidGenerator,custom:this.config.custom,external:this.config.external}}setupUiPluginConfig(){return{getters:this.getters,stateObserver:this.state,dispatch:this.dispatch,selection:this.selection,moveClient:this.session.move.bind(this.session),custom:this.config.custom,uiActions:this.config,session:this.session}}checkDispatchAllowed(e){const t=ms(e)?this.checkDispatchAllowedCoreCommand(e):this.checkDispatchAllowedLocalCommand(e);return t.some((e=>0!==e))?new fs(t.flat()):fs.Success}checkDispatchAllowedCoreCommand(e){const t=this.corePlugins.map((t=>t.allowDispatch(e)));return t.push(this.range.allowDispatch(e)),t}checkDispatchAllowedLocalCommand(e){return this.uiHandlers.map((t=>t.allowDispatch(e)))}finalize(){this.status=3;for(const e of this.handlers)e.finalize();this.status=0}canDispatch=(e,t)=>this.checkDispatchAllowed(jy(e,t));dispatch=(e,t)=>{const o=jy(e,t);let i=this.status;if(this.getters.isReadonly()&&(s=o,!gs.has(s.type)))return new fs(70);var s;if(!this.session.canApplyOptimisticUpdate())return new fs(67);switch(i){case 0:const t=this.checkDispatchAllowed(o);if(!t.isSuccessful)return t;this.status=1;const{changes:i,commands:s}=this.state.recordChanges((()=>{ms(o)&&this.state.addCommand(o),this.dispatchToHandlers(this.handlers,o),this.finalize()}));this.session.save(o,s,i),this.status=0,this.trigger("update");break;case 1:if(ms(o)){const e=this.checkDispatchAllowed(o);if(!e.isSuccessful)return e;this.state.addCommand(o)}this.dispatchToHandlers(this.handlers,o);break;case 3:throw new Error("Cannot dispatch commands in the finalize state");case 2:if(ms(o))throw new Error(`A UI plugin cannot dispatch ${e} while handling a core command`);this.dispatchToHandlers(this.handlers,o)}return fs.Success};dispatchFromCorePlugin=(e,t)=>{const o=jy(e,t),i=this.status;this.status=2;const s=this.isReplayingCommand?this.coreHandlers:this.handlers;return this.dispatchToHandlers(s,o),this.status=i,fs.Success};dispatchToHandlers(e,t){for(const o of e)o.beforeHandle(t);for(const o of e)o.handle(t)}drawGrid(e){for(let[t,o]of this.renderers)e.ctx.save(),t.drawGrid(e,o),e.ctx.restore()}exportData(){let e=ZE();for(let t of this.handlers)t instanceof XE&&t.export(e);return e.revisionId=this.session.getRevisionId()||te,e=Ce(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={...ZE(),sheets:[YE(BE,"Sheet1")]};for(let t of this.handlers)t instanceof jE&&t.exportForExcel(e);return e=Ce(e),qy(e)}garbageCollectExternalResources(){for(const e of this.corePlugins)e.garbageCollectExternalResources()}},e.Registry=Ji,e.Revision=$w,e.SPREADSHEET_DIMENSIONS=Ky,e.Spreadsheet=qx,e.UIPlugin=sw,e.__info__=Xy,e.addFunction=function(e,t){fu.add(e,t)},e.astToFormula=Ku,e.compile=hg,e.components=tI,e.constants=oI,e.convertAstNodes=Zu,e.coreTypes=ps,e.findCellInNewZone=Ci,e.functionCache=cg,e.helpers=Jy,e.invalidateCFEvaluationCommands=us,e.invalidateDependenciesCommands=ds,e.invalidateEvaluationCommands=hs,e.iterateAstNodes=Yu,e.links=eI,e.load=zE,e.parse=Gu,e.readonlyAllowedCommands=gs,e.registries=Qy,e.setDefaultSheetViewSize=function(e){pe=e},e.setTranslationMethod=function(e){o=e},e.tokenize=xu,Object.defineProperty(e,"__esModule",{value:!0}),Xy.version="16.4.30",Xy.date="2024-04-18T16:39:04.255Z",Xy.hash="39b015c"}(this.o_spreadsheet=this.o_spreadsheet||{},owl);
|