@odoo/o-spreadsheet 19.0.45 → 19.0.46

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,7 @@
1
1
  (function(e,t){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var n=Object.create,r=Object.defineProperty,i=Object.getOwnPropertyDescriptor,a=Object.getOwnPropertyNames,o=Object.getPrototypeOf,s=Object.prototype.hasOwnProperty,c=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),l=(e,t)=>{let n={};for(var i in e)r(n,i,{get:e[i],enumerable:!0});return t||r(n,Symbol.toStringTag,{value:`Module`}),n},u=(e,t,n,o)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var c=a(t),l=0,u=c.length,d;l<u;l++)d=c[l],!s.call(e,d)&&d!==n&&r(e,d,{get:(e=>t[e]).bind(null,d),enumerable:!(o=i(t,d))||o.enumerable});return e},d=(e,t,i)=>(i=e==null?{}:n(o(e)),u(t||!e||!e.__esModule?r(i,`default`,{value:e,enumerable:!0}):i,e));function f(e){return e.map(m).sort((e,t)=>e.sequence-t.sequence)}let p=1;function m(e){let t=e.name,n=e.children,r=e.description,i=e.icon,a=e.secondaryIcon,o=e.id||p++,s=e.isEnabled?e.isEnabled:()=>!0;return{id:o.toString(),name:typeof t==`function`?t:()=>t,isVisible:e.isVisible?e.isVisible:()=>!0,isEnabled:s,isActive:e.isActive,execute:e.execute?(t,n)=>{if(s(t))return e.execute(t,n)}:void 0,children:n?e=>n.map(t=>typeof t==`function`?t(e):t).flat().map(m).sort((e,t)=>e.sequence-t.sequence):()=>[],isReadonlyAllowed:e.isReadonlyAllowed||!1,separator:e.separator||!1,icon:typeof i==`function`?i:()=>i||``,iconColor:e.iconColor,secondaryIcon:typeof a==`function`?a:()=>a||``,description:typeof r==`function`?r:()=>r||``,textColor:e.textColor,sequence:e.sequence||0,onStartHover:e.onStartHover,onStopHover:e.onStopHover}}function h(e,t){let n=[];for(let r=0;r<t.length;r++){let i=t[r];i.isVisible(e)&&n.push(i),i.separator&&r!==t.length-1&&n[n.length-1]!==`separator`&&n.push(`separator`)}return n[n.length-1]===`separator`&&n.pop(),n.length===1&&n[0]===`separator`?[]:n}var g=class{content={};add(e,t){if(e in this.content)throw Error(`${e} is already present in this registry!`);return this.replace(e,t)}replace(e,t){return this.content[e]=t,this}get(e){let t=this.content[e];if(!t&&!(e in this.content))throw Error(`Cannot find ${e} in this registry!`);return t}contains(e){return e in this.content}getAll(){return Object.values(this.content)}getKeys(){return Object.keys(this.content)}remove(e){delete this.content[e]}};let _=.5,v=`#017E84`,y=`#f5f5f5`,ee=`#F8F9FA`,te=`#E8EAED`,ne=`#595959`,re=`#666666`,ie=`#c9ccd2`,ae=`#3266ca`,oe=`#FFFFFF`,se=`#CACACA`,ce=11982760,le=v,ue=`#188038`,de=`#E0E2E4`,fe=`#4A4F59`,pe=`#999`,me=`#E2E3E3`,he=`#BCBCBC`,ge=`#9B359B`,_e=`#00000000`,ve=`#111827`,ye=`#D8DADD`,be=`#E7E9ED`,xe=`#F9FAFB`,Se=`#374151`,Ce=`#374151C2`,we=`#111827`,Te=`#714B67`,Ee=ye,De=`#111827`,Oe=`#e6f2f3`,ke=`#111827`,Ae=v,je=`#D44C591A`,Me=`#C34A41`,Ne=`#98DBE2`,Pe=`#E6F2F3`,Fe=`#F28C28`,Ie=`#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`.split(`.`),Le={align:`left`,verticalAlign:`bottom`,wrapping:`overflow`,bold:!1,italic:!1,strikethrough:!1,underline:!1,fontSize:10,fillColor:``,textColor:``},Re={...Le,align:`right`},ze=Le.verticalAlign,Be=Le.wrapping,Ve=Le.fontSize,He=`'Roboto', arial, 'Liberation Sans'`,Ue={style:`thin`,color:`#000000`},We=`START_REVISION`,Ge=`difference`,Ke=`#43C5B1`,qe=`#EA6175`,Je=.4,Ye=[`'`,`*`,`?`,`/`,`\\`,`[`,`]`],Xe=/'|\*|\?|\/|\\|\[|\]/,Ze=0;function Qe(){return Ze}function $e(e){Ze=e}let et=[6,7,8,9,10,11,12,14,18,24,36],tt={hasFilters:!1,totalRow:!1,firstColumn:!0,lastColumn:!1,numberOfHeaders:1,bandedRows:!0,bandedColumns:!1,styleId:`TableStyleMedium5`,automaticAutofill:!1},nt={symbol:`$`,position:`before`,decimalPlaces:2,code:``,name:`Dollar`},rt={fontSize:16,color:Se},it=`#000000`,at=`#3da4ab`,ot={OPERATOR:at,NUMBER:`#02c39a`,STRING:`#00a82d`,FUNCTION:it,DEBUGGER:at,LEFT_PAREN:it,RIGHT_PAREN:it,ARG_SEPARATOR:it,ORPHAN_RIGHT_PAREN:`#ff0000`},st=new RegExp(Xe,`g`);function ct(e){return e[0]===`"`&&(e=e.slice(1)),e[e.length-1]===`"`&&e[e.length-2]!==`\\`?e.slice(0,e.length-1):e}function lt(e){return`clone`in e&&e.clone instanceof Function}function ut(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function b(e){switch(typeof e){case`object`:{if(e===null)return e;if(lt(e))return e.clone();if(!(dt(e)||e instanceof Array))throw Error(`Unsupported type: only objects and arrays are supported`);let t=Array.isArray(e)?Array(e.length):{};if(Array.isArray(e))for(let n=0,r=e.length;n<r;n++)n in e&&(t[n]=b(e[n]));else for(let n in e)t[n]=b(e[n]);return t}case`number`:case`string`:case`boolean`:case`function`:case`undefined`:return e;default:throw Error(`Unsupported type: ${typeof e}`)}}function dt(e){return typeof e==`object`&&!!e&&(e?.constructor===Object||e?.constructor===void 0)}function ft(e){return pt(e,`'`)}function pt(e,t=`"`){return e.startsWith(t)&&(e=e.slice(1)),e.endsWith(t)&&(e=e.slice(0,-1)),e}function mt(e){return e.match(/\w/g)?.length!==e.length&&(e=`'${e}'`),e}function ht(e,t=` `){return e.replace(st,t)}function x(e,t,n){return e<t?t:e>n?n:e}function S(e,t,n=1){if(t<=e&&n>0)return[];if(n===0)throw Error(`range() step must not be zero`);let r=Math.ceil(Math.abs((t-e)/n)),i=Array(r);for(let t=0;t<r;t++)i[t]=e+t*n;return i}function gt(e){return e.reduce((e,t,n,r)=>(Math.abs(t-r[n-1])===1?e[e.length-1].push(t):e.push([t]),e),[])}function*_t(e,t){t.next();for(let n of e){let e=t.next();yield{...n,next:e.done?void 0:e.value}}}function vt(e){let t=e.toUpperCase();return t===`TRUE`||t===`FALSE`}let yt=/^\[(.+)\]\((.+)\)$/,bt=/^https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,4}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)$/;function xt(e){return yt.test(e)}function St(e){return bt.test(e)}function Ct(e,t){return`[${e}](${t})`}function wt(e){let t=e.match(yt)||[],n=t[1],r=t[2];if(!n||!r)throw Error(`Could not parse markdown link ${e}.`);return{label:n,url:r}}let Tt=`o-spreadsheet://`;function Et(e){return e.startsWith(Tt)}function Dt(e){return`${Tt}${e}`}function Ot(e){if(e.startsWith(Tt))return e.slice(16);throw Error(`${e} is not a valid sheet link`)}function C(e){return e!==void 0}function kt(e){return e===void 0?!0:Object.values(e).every(e=>typeof e==`object`?kt(e):!e)}function At(e,t,n){let r,i=function(){let i=this,a=Array.from(arguments);function o(){r=void 0,n||e.apply(i,a)}let s=n&&!r;clearTimeout(r),r=setTimeout(o,t),s&&e.apply(i,a)};return i.isDebouncePending=()=>r!==void 0,i.stopDebounce=()=>{clearTimeout(r)},i}function jt(e){let t=!1;return async(...n)=>{t||(t=!0,await Promise.resolve(),t=!1,e(...n))}}function Mt(e){let t=``;for(let n=0,r=e.length;n<r;n++)t+=e[n];return t}function Nt(e){let t=!1,n,r=()=>(t||=(n=e instanceof Function?e():e,!0),n);return r.map=e=>Nt(()=>e(r())),r}function Pt(e,t){let n=e.slice(t).find(e=>e);return n||=e.slice(0,t).reverse().find(e=>e),n||``}function Ft(e,t){return e===`after`?t+1:t}function w(...e){if(e.length<=1)return!0;for(let t=1;t<e.length;t++)if(!It(e[0],e[t]))return!1;return!0}function It(e,t){if(e===t)return!0;if(e&&!t||t&&!e||typeof e!=typeof t||typeof e!=`object`)return!1;for(let n in t)if(!(n in e)&&t[n]!==void 0)return!1;for(let n in e){if(typeof e[n]!=typeof t[n])return!1;if(typeof e[n]==`object`){if(!It(e[n],t[n]))return!1}else if(e[n]!==t[n])return!1}return!0}function Lt(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!w(e[n],t[n]))return!1;return!0}function Rt(e,t){if(e.length<t.length)return!1;let n=new Set(e);return t.every(e=>n.has(e))}function zt(e){if(!e)return e;let t={...e};return Object.keys(t).forEach(e=>!t[e]&&delete t[e]),t}let Bt=[` `,`\f`,`\v`,`\xA0`,` `,` `,` `,`\u2028`,`\u2029`,` `,` `,` `,``],Vt=new RegExp(Bt.join(`|`),`g`),Ht=/(\r\n|\r)/g,Ut=Bt.concat([` `]);function Wt(e){return e?e.replace(Ht,`
2
2
  `):``}function Gt(e){let 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}function Kt(e){let t=new Map,n=e.name?e.name+` (memoized)`:`memoized`;return{[n](...n){return t.has(n[0])||t.set(n[0],e(...n)),t.get(n[0])}}[n]}function qt(e,t){let n=new Set(t),r=[];for(let t=0;t<e.length;t++)n.has(t)||r.push(e[t]);return r}function Jt(e,t,n){return e.slice(0,n).concat(t).concat(e.slice(n))}function Yt(e,t,n){let r=[...e];return r[n]=t,r}function Xt(e){return e.split(`
3
3
  `).map(e=>e.replace(/\s+/g,` `).trim()).join(`
4
- `)}function Zt(e,t,n){return t>n?Zt(e,n,t):e>=t&&e<=n}function Qt(e,t){let n=ut(e),r=t.matchCase?``:`i`;return t.exactMatch&&(n=`^${n}$`),RegExp(n,r)}function $t(e){let t=e.length;if(t<1e5)return Math.max(...e);let n=-1/0;for(;t--;)n=e[t]>n?e[t]:n;return n}function en(e){let t=e.length;if(t<1e5)return Math.min(...e);let n=1/0;for(;t--;)n=e[t]<n?e[t]:n;return n}var tn=class{text;currentIndex=0;current;constructor(e){this.text=e,this.current=e[0]}shift(){let e=this.current,t=this.text[++this.currentIndex];return this.current=t,e}advanceBy(e){this.currentIndex+=e,this.current=this.text[this.currentIndex]}isOver(){return this.currentIndex>=this.text.length}remaining(){return this.text.substring(this.currentIndex)}currentStartsWith(e){if(this.current!==e[0])return!1;for(let t=1;t<e.length;t++)if(this.text[this.currentIndex+t]!==e[t])return!1;return!0}};function nn(e,t=e=>e){let n=new Set;return e.filter(e=>{let r=t(e);return n.has(r)?!1:(n.add(r),!0)})}function rn(e){let t={};for(let n in e)for(let r in e[n])t[r]||(t[r]={}),t[r][n]=e[n][r];return t}function an(e,t,n={}){let r=n.compute??((e,t)=>`${e} (${t})`),i=n.computeFirstOne??!1,a=n.start??1,o=i?r(e,a):e;for(;t.includes(o);)o=r(e,a++);return o}function on(e){return e.startsWith(`=`)||e.startsWith(`+`)}function sn(e){return{bold:e.bold,italic:e.italic,fontSize:e.fontSize,textColor:e.color,align:e.align}}let cn=/rgba?\(|\s+|\)/gi,ln=/^#([A-F\d]{2}){3,4}$/,un=[`#eb6d00`,`#0074d9`,`#ad8e00`,`#169ed4`,`#b10dc9`,`#00a82d`,`#00a3a3`,`#f012be`,`#3d9970`,`#111111`,`#62A300`,`#ff4136`,`#949494`,`#85144b`,`#001f3f`];function dn(e,t=1){let n=t===1?``:Math.round(t*255).toString(16).padStart(2,`0`);return pn(e.toString(16).padStart(6,`0`))+n}function fn(e){return typeof e==`number`?e:Number.parseInt(pn(e).slice(1,7),16)}function pn(e){let t=e;if(e.startsWith(`rgb`)?t=yn(e):(t=e.replace(`#`,``).toUpperCase(),(t.length===3||t.length===4)&&(t=t.split(``).reduce((e,t)=>e+t+t,``)),t=`#${t}`),!ln.test(t))throw Error(`invalid color input: ${e}`);return t}function mn(e){try{return pn(e),!0}catch{return!1}}function hn(e){try{return wn(e),!0}catch{return!1}}let gn=e=>e>=0&&e<=255;function _n(e,t,n,r=1){if(!gn(e)||!gn(t)||!gn(n)||r<0||r>1)throw Error(`Invalid RGBA values ${[e,t,n,r]}`);return{a:r,b:n,g:t,r:e}}function vn(e){let{r:t,g:n,b:r}=xn(e);t/=255,n/=255,r/=255;let i=e=>e<=.03928?e/12.92:((e+.055)/1.055)**2.4,a=i(t),o=i(n),s=i(r);return .2126*a+.7152*o+.0722*s}function yn(e){let t=e.replace(cn,``).split(`,`),n=255;if(t.length!==3&&t.length!==4)throw Error(`invalid color`);if(t.length===4){let e=parseFloat(t.pop()||`1`);if(isNaN(e))throw Error(`invalid alpha value`);n=Math.round(e*255)}let r=t.map(e=>parseInt(e,10));return n!==255&&r.push(n),`#`+Mt(r.map(e=>e.toString(16).padStart(2,`0`))).toUpperCase()}function bn(e){let t=e.r.toString(16),n=e.g.toString(16),r=e.b.toString(16),i=Math.round(e.a*255).toString(16);return t.length===1&&(t=`0`+t),n.length===1&&(n=`0`+n),r.length===1&&(r=`0`+r),i.length===1&&(i=`0`+i),i===`ff`&&(i=``),(`#`+t+n+r+i).toUpperCase()}function xn(e){e=pn(e);let t,n,r,i;if(e.length===7)t=parseInt(e[1]+e[2],16),n=parseInt(e[3]+e[4],16),r=parseInt(e[5]+e[6],16),i=255;else if(e.length===9)t=parseInt(e[1]+e[2],16),n=parseInt(e[3]+e[4],16),r=parseInt(e[5]+e[6],16),i=parseInt(e[7]+e[8],16);else throw Error(`Invalid color`);return i=+(i/255).toFixed(3),{a:i,r:t,g:n,b:r}}function Sn(e){e={...e},e.s/=100,e.l/=100;let t=(1-Math.abs(2*e.l-1))*e.s,n=t*(1-Math.abs(e.h/60%2-1)),r=e.l-t/2,i=0,a=0,o=0;return 0<=e.h&&e.h<60?(i=t,a=n,o=0):60<=e.h&&e.h<120?(i=n,a=t,o=0):120<=e.h&&e.h<180?(i=0,a=t,o=n):180<=e.h&&e.h<240?(i=0,a=n,o=t):240<=e.h&&e.h<300?(i=n,a=0,o=t):300<=e.h&&e.h<360&&(i=t,a=0,o=n),i=Math.round((i+r)*255),a=Math.round((a+r)*255),o=Math.round((o+r)*255),{a:e.a,r:i,g:a,b:o}}function Cn(e){let t=e.r/255,n=e.g/255,r=e.b/255,i=Math.min(t,n,r),a=Math.max(t,n,r),o=a-i,s=0,c=0,l=0;return s=o===0?0:a===t?(n-r)/o%6:a===n?(r-t)/o+2:(t-n)/o+4,s=Math.round(s*60),s<0&&(s+=360),l=(a+i)/2,c=o===0?0:o/(1-Math.abs(2*l-1)),c=+(c*100).toFixed(1),l=+(l*100).toFixed(1),{a:e.a,h:s,s:c,l}}function wn(e){return bn(Sn(e))}function Tn(e){return Cn(xn(e))}function En(e,t){let n=xn(t),r=xn(e),i=n.a+r.a*(1-n.a);return bn({r:Math.round((n.r*n.a+r.r*r.a*(1-n.a))/i),g:Math.round((n.g*n.a+r.g*r.a*(1-n.a))/i),b:Math.round((n.b*n.a+r.b*r.a*(1-n.a))/i),a:i})}function Dn(e){return xn(typeof e==`number`?dn(e):e)}function On(e,t,n=0){if(!(mn(e)&&mn(t)))return!1;let r=xn(e),i=xn(t);return r.a===i.a?Math.sqrt(((r.r-i.r)/255)**2+((r.g-i.g)/255)**2+((r.b-i.b)/255)**2)<=n:!1}function kn(e,t){return t===1?pn(e).slice(0,7):bn({...xn(e),a:t})}function An(e,t){let n=Tn(e);return t===1?`#fff`:(n.l=t*(100-n.l)+n.l,wn(n))}function jn(e,t){let n=Tn(e);return t===1?`#000`:(n.s=Math.min(100,t*n.s+n.s),n.l-=t*n.l,wn(n))}function Mn(e){return vn(e)<.6?An(e,.9):jn(e,.75)}let Nn=[`#4EA7F2`,`#EA6175`,`#43C5B1`,`#F4A261`,`#8481DD`,`#FFD86D`],Pn=[`#4EA7F2`,`#3188E6`,`#43C5B1`,`#00A78D`,`#EA6175`,`#CE4257`,`#F4A261`,`#F48935`,`#8481DD`,`#5752D1`,`#FFD86D`,`#FFBC2C`],Fn=[`#4EA7F2`,`#3188E6`,`#056BD9`,`#A76DBC`,`#7F4295`,`#6D2387`,`#EA6175`,`#CE4257`,`#982738`,`#43C5B1`,`#00A78D`,`#0E8270`,`#F4A261`,`#F48935`,`#BE5D10`,`#8481DD`,`#5752D1`,`#3A3580`,`#A4A8B6`,`#7E8290`,`#545B70`,`#FFD86D`,`#FFBC2C`,`#C08A16`],In=`#4EA7F2.#3188E6.#056BD9.#155193.#A76DBC.#7F4295.#6D2387.#4F1565.#EA6175.#CE4257.#982738.#791B29.#43C5B1.#00A78D.#0E8270.#105F53.#F4A261.#F48935.#BE5D10.#7D380D.#8481DD.#5752D1.#3A3580.#26235F.#A4A8B6.#7E8290.#545B70.#3F4250.#FFD86D.#FFBC2C.#C08A16.#936A12`.split(`.`),Ln=[`#4EA7F2`,`#43C5B1`,`#EA6175`,`#F4A261`,`#8481DD`,`#FFD86D`,`#3188E6`,`#00A78D`,`#CE4257`,`#F48935`,`#5752D1`,`#FFBC2C`],Rn=[`#4EA7F2`,`#A76DBC`,`#EA6175`,`#43C5B1`,`#F4A261`,`#8481DD`,`#A4A8B6`,`#FFD86D`,`#3188E6`,`#7F4295`,`#CE4257`,`#00A78D`,`#F48935`,`#5752D1`,`#7E8290`,`#FFBC2C`,`#056BD9`,`#6D2387`,`#982738`,`#0E8270`,`#BE5D10`,`#3A3580`,`#545B70`,`#C08A16`],zn=`#4EA7F2.#A76DBC.#EA6175.#43C5B1.#F4A261.#8481DD.#A4A8B6.#FFD86D.#3188E6.#7F4295.#CE4257.#00A78D.#F48935.#5752D1.#7E8290.#FFBC2C.#056BD9.#6D2387.#982738.#0E8270.#BE5D10.#3A3580.#545B70.#C08A16.#155193.#4F1565.#791B29.#105F53.#7D380D.#26235F.#3F4250.#936A12`.split(`.`);function Bn(e,t){return t[e%t.length]}function Vn(e){return e<=6?Nn:e<=12?Pn:e<=24?Fn:In}function Hn(e){return e<=6?Nn:e<=12?Ln:e<=24?Rn:zn}var Un=class{preferredColors;currentColorIndex=0;palette;constructor(e,t=[]){this.preferredColors=t,this.palette=Vn(e).filter(e=>!t.includes(e))}next(){return this.preferredColors?.[this.currentColorIndex]?this.preferredColors[this.currentColorIndex++]:Bn(this.currentColorIndex++,this.palette)}},Wn=class extends Un{constructor(e,t=[]){super(e,t),this.palette=Hn(e).filter(e=>!t.includes(e))}},Gn=class{availableColors;colors={};constructor(e=12){this.availableColors=new Wn(e)}get(e){return this.colors[e]||(this.colors[e]=this.availableColors.next()),this.colors[e]}};function Kn(e){if(e.length<2)throw Error(`Color scale must have at least 2 points`);let t=[...e.sort((e,t)=>e.value-t.value)],n=[];for(let e=1;e<t.length;e++){let r=Dn(t[e-1].color).a,i=Dn(t[e].color).a,a=fn(t[e-1].color),o=fn(t[e].color);n.push({min:t[e-1].value,max:t[e].value,minColor:a,maxColor:o,minColorAlpha:r,maxColorAlpha:i,colorDiff:qn(t[e-1].value,t[e].value,a,o)})}return e=>{if(e<n[0].min)return dn(n[0].minColor,n[0].minColorAlpha);for(let t of n)if(e>=t.min&&e<=t.max)return dn(Jn(e,t.min,t.minColor,t.colorDiff),t.maxColorAlpha);return dn(n[n.length-1].maxColor,n[n.length-1].maxColorAlpha)}}function qn(e,t,n,r){let i=t-e,a=(n>>16)%256-(r>>16)%256,o=(n>>8)%256-(r>>8)%256,s=n%256-r%256;return[a/i,o/i,s/i]}function Jn(e,t,n,r){let[i,a,o]=r,s=Math.round((n>>16)%256-i*(e-t)),c=Math.round((n>>8)%256-a*(e-t)),l=Math.round(n%256-o*(e-t));return s<<16|c<<8|l}function Yn(e){if(e<0)throw Error(`number must be positive. Got ${e}`);return e<26?String.fromCharCode(65+e):Yn(Math.floor(e/26)-1)+Yn(e%26)}function Xn(e){let t=0,n=e.length;for(let r=0;r<n;r++){let n=Zn(e[r]);t=t*26+n}return t-1}function Zn(e){let t=e.charCodeAt(0);return t>=65&&t<=90?t-64:t-96}function Qn(e){return e>=`A`&&e<=`Z`||e>=`a`&&e<=`z`}function $n(e){return e>=`0`&&e<=`9`}let er=Xn(`ZZZ`);function tr(e){for(;e.current===` `;)e.advanceBy(1)}function nr(e){if(e.current===`$`&&e.advanceBy(1),!e.current||!Qn(e.current))return-1;let t=0;for(;e.current&&Qn(e.current);)t=t*26+Zn(e.shift());return t}function rr(e){if(e.current===`$`&&e.advanceBy(1),!e.current||!$n(e.current))return-1;let t=0;for(;e.current&&$n(e.current);)t=t*10+Number(e.shift());return t}function ir(e){let t=new tn(e);tr(t);let n=nr(t);if(n===-1||!t.current)throw Error(`Invalid cell description: ${e}`);let r=rr(t);tr(t);let i=n-1,a=r-1;if(!t.isOver()||i>er||a>9999998)throw Error(`Invalid cell description: ${e}`);return{col:i,row:a}}function T(e,t,n={colFixed:!1,rowFixed:!1}){return(n.colFixed?`$`:``)+Yn(e)+(n.rowFixed?`$`:``)+String(t+1)}let ar=e=>e,or=()=>!1,sr=ar,cr=or;function lr(e,...t){if(t.length===1&&typeof t[0]==`object`&&!(t[0]instanceof String)){let n=t[0];e=e.replace(/\%\(([^\)]+)\)s/g,(e,t)=>n[t])}else t.length>0&&(e=e.replace(/\%s/g,()=>t.shift()));return e}function ur(e,t=()=>!0){sr=e,cr=t}function dr(){sr===ar&&cr===or&&(cr=()=>!0)}let E=function(e,...t){return cr()?lr(sr(e),...t):new fr(e,t)};var fr=class extends String{values;constructor(e,t){super(e),this.values=t}valueOf(){let e=super.valueOf();return cr()?lr(sr(e),...this.values):lr(e,...this.values)}toString(){return this.valueOf()}};function pr(e){return`sheetId`in e}function mr(e){return`dimension`in e&&`sheetId`in e&&`elements`in e}function hr(e){return`target`in e&&`sheetId`in e}function gr(e){return`ranges`in e}function _r(e){return`col`in e&&`row`in e&&`sheetId`in e}function vr(e){return`sheetId`in e&&`zone`in e}let yr=new Set([`RENAME_SHEET`,`DELETE_SHEET`,`CREATE_SHEET`,`DUPLICATE_SHEET`,`ADD_COLUMNS_ROWS`,`REMOVE_COLUMNS_ROWS`,`UNDO`,`REDO`,`ADD_MERGE`,`REMOVE_MERGE`,`UPDATE_LOCALE`,`ADD_PIVOT`,`UPDATE_PIVOT`,`INSERT_PIVOT`,`RENAME_PIVOT`,`REMOVE_PIVOT`,`DUPLICATE_PIVOT`]),br=new Set([`EVALUATE_CELLS`,`EVALUATE_CHARTS`,`UPDATE_CELL`,`UNHIDE_COLUMNS_ROWS`,`HIDE_COLUMNS_ROWS`,`GROUP_HEADERS`,`UNGROUP_HEADERS`,`FOLD_ALL_HEADER_GROUPS`,`FOLD_HEADER_GROUP`,`FOLD_HEADER_GROUPS_IN_ZONE`,`UNFOLD_ALL_HEADER_GROUPS`,`UNFOLD_HEADER_GROUP`,`UNFOLD_HEADER_GROUPS_IN_ZONE`,`UPDATE_TABLE`,`UPDATE_FILTER`,`UNDO`,`REDO`]),xr=new Set([`MOVE_RANGES`]),Sr=new Set([`EVALUATE_CELLS`,`ADD_CONDITIONAL_FORMAT`,`REMOVE_CONDITIONAL_FORMAT`,`CHANGE_CONDITIONAL_FORMAT_PRIORITY`]),Cr=new Set([`AUTOFILL_CELL`,`SET_BORDER`,`SET_ZONE_BORDERS`,`SET_BORDERS_ON_TARGET`]),wr=new Set([`UNHIDE_COLUMNS_ROWS`,`HIDE_COLUMNS_ROWS`,`GROUP_HEADERS`,`UNGROUP_HEADERS`,`FOLD_ALL_HEADER_GROUPS`,`FOLD_HEADER_GROUP`,`FOLD_HEADER_GROUPS_IN_ZONE`,`UNFOLD_ALL_HEADER_GROUPS`,`UNFOLD_HEADER_GROUP`,`UNFOLD_HEADER_GROUPS_IN_ZONE`,`UPDATE_TABLE`,`UPDATE_FILTER`]),Tr=new Set([`START`,`ACTIVATE_SHEET`,`COPY`,`RESIZE_SHEETVIEW`,`SET_VIEWPORT_OFFSET`,`EVALUATE_CELLS`,`EVALUATE_CHARTS`,`SET_FORMULA_VISIBILITY`,`UPDATE_FILTER`,`UPDATE_CHART`,`UPDATE_CAROUSEL_ACTIVE_ITEM`,`UPDATE_PIVOT`]),Er=new Set(`UPDATE_CELL.UPDATE_CELL_POSITION.CLEAR_CELL.CLEAR_CELLS.DELETE_CONTENT.ADD_COLUMNS_ROWS.REMOVE_COLUMNS_ROWS.RESIZE_COLUMNS_ROWS.HIDE_COLUMNS_ROWS.UNHIDE_COLUMNS_ROWS.SET_GRID_LINES_VISIBILITY.UNFREEZE_COLUMNS.UNFREEZE_ROWS.FREEZE_COLUMNS.FREEZE_ROWS.UNFREEZE_COLUMNS_ROWS.ADD_MERGE.REMOVE_MERGE.CREATE_SHEET.DELETE_SHEET.DUPLICATE_SHEET.MOVE_SHEET.RENAME_SHEET.COLOR_SHEET.HIDE_SHEET.SHOW_SHEET.MOVE_RANGES.ADD_CONDITIONAL_FORMAT.REMOVE_CONDITIONAL_FORMAT.CHANGE_CONDITIONAL_FORMAT_PRIORITY.CREATE_FIGURE.DELETE_FIGURE.UPDATE_FIGURE.CREATE_CAROUSEL.UPDATE_CAROUSEL.SET_FORMATTING.CLEAR_FORMATTING.SET_BORDER.SET_ZONE_BORDERS.SET_BORDERS_ON_TARGET.CREATE_CHART.UPDATE_CHART.DELETE_CHART.CREATE_TABLE.REMOVE_TABLE.UPDATE_TABLE.CREATE_TABLE_STYLE.REMOVE_TABLE_STYLE.CREATE_IMAGE.GROUP_HEADERS.UNGROUP_HEADERS.UNFOLD_HEADER_GROUP.FOLD_HEADER_GROUP.FOLD_ALL_HEADER_GROUPS.UNFOLD_ALL_HEADER_GROUPS.UNFOLD_HEADER_GROUPS_IN_ZONE.FOLD_HEADER_GROUPS_IN_ZONE.ADD_DATA_VALIDATION_RULE.REMOVE_DATA_VALIDATION_RULE.UPDATE_LOCALE.ADD_PIVOT.UPDATE_PIVOT.INSERT_PIVOT.RENAME_PIVOT.REMOVE_PIVOT.DUPLICATE_PIVOT`.split(`.`));function Dr(e){return Er.has(e.type)}function Or(e){return Tr.has(e.type)}var kr=class{reasons;constructor(e=[]){Array.isArray(e)||(e=[e]),e=[...new Set(e)],this.reasons=e.filter(e=>e!==`Success`)}static get Success(){return Ar}get isSuccessful(){return this.reasons.length===0}isCancelledBecause(e){return this.reasons.includes(e)}};let Ar=new kr,jr=function(e){return e.Success=`Success`,e.CancelledForUnknownReason=`CancelledForUnknownReason`,e.WillRemoveExistingMerge=`WillRemoveExistingMerge`,e.CannotMoveTableHeader=`CannotMoveTableHeader`,e.MergeIsDestructive=`MergeIsDestructive`,e.CellIsMerged=`CellIsMerged`,e.InvalidTarget=`InvalidTarget`,e.EmptyUndoStack=`EmptyUndoStack`,e.EmptyRedoStack=`EmptyRedoStack`,e.NotEnoughElements=`NotEnoughElements`,e.NotEnoughSheets=`NotEnoughSheets`,e.MissingSheetName=`MissingSheetName`,e.UnchangedSheetName=`UnchangedSheetName`,e.DuplicatedSheetName=`DuplicatedSheetName`,e.DuplicatedSheetId=`DuplicatedSheetId`,e.ForbiddenCharactersInSheetName=`ForbiddenCharactersInSheetName`,e.WrongSheetMove=`WrongSheetMove`,e.WrongSheetPosition=`WrongSheetPosition`,e.InvalidAnchorZone=`InvalidAnchorZone`,e.SelectionOutOfBound=`SelectionOutOfBound`,e.TargetOutOfSheet=`TargetOutOfSheet`,e.WrongCutSelection=`WrongCutSelection`,e.WrongPasteSelection=`WrongPasteSelection`,e.WrongPasteOption=`WrongPasteOption`,e.WrongFigurePasteOption=`WrongFigurePasteOption`,e.EmptyClipboard=`EmptyClipboard`,e.EmptyRange=`EmptyRange`,e.InvalidRange=`InvalidRange`,e.InvalidZones=`InvalidZones`,e.InvalidSheetId=`InvalidSheetId`,e.InvalidCellId=`InvalidCellId`,e.InvalidFigureId=`InvalidFigureId`,e.InputAlreadyFocused=`InputAlreadyFocused`,e.MaximumRangesReached=`MaximumRangesReached`,e.MinimumRangesReached=`MinimumRangesReached`,e.InvalidChartDefinition=`InvalidChartDefinition`,e.InvalidDataSet=`InvalidDataSet`,e.InvalidLabelRange=`InvalidLabelRange`,e.InvalidScorecardKeyValue=`InvalidScorecardKeyValue`,e.InvalidScorecardBaseline=`InvalidScorecardBaseline`,e.InvalidGaugeDataRange=`InvalidGaugeDataRange`,e.EmptyGaugeRangeMin=`EmptyGaugeRangeMin`,e.GaugeRangeMinNaN=`GaugeRangeMinNaN`,e.EmptyGaugeRangeMax=`EmptyGaugeRangeMax`,e.GaugeRangeMaxNaN=`GaugeRangeMaxNaN`,e.GaugeLowerInflectionPointNaN=`GaugeLowerInflectionPointNaN`,e.GaugeUpperInflectionPointNaN=`GaugeUpperInflectionPointNaN`,e.InvalidAutofillSelection=`InvalidAutofillSelection`,e.MinBiggerThanMax=`MinBiggerThanMax`,e.LowerBiggerThanUpper=`LowerBiggerThanUpper`,e.MidBiggerThanMax=`MidBiggerThanMax`,e.MinBiggerThanMid=`MinBiggerThanMid`,e.FirstArgMissing=`FirstArgMissing`,e.SecondArgMissing=`SecondArgMissing`,e.MinNaN=`MinNaN`,e.MidNaN=`MidNaN`,e.MaxNaN=`MaxNaN`,e.ValueUpperInflectionNaN=`ValueUpperInflectionNaN`,e.ValueLowerInflectionNaN=`ValueLowerInflectionNaN`,e.MinInvalidFormula=`MinInvalidFormula`,e.MidInvalidFormula=`MidInvalidFormula`,e.MaxInvalidFormula=`MaxInvalidFormula`,e.ValueUpperInvalidFormula=`ValueUpperInvalidFormula`,e.ValueLowerInvalidFormula=`ValueLowerInvalidFormula`,e.InvalidSortAnchor=`InvalidSortAnchor`,e.InvalidSortZone=`InvalidSortZone`,e.SortZoneWithArrayFormulas=`SortZoneWithArrayFormulas`,e.WaitingSessionConfirmation=`WaitingSessionConfirmation`,e.MergeOverlap=`MergeOverlap`,e.TooManyHiddenElements=`TooManyHiddenElements`,e.Readonly=`Readonly`,e.InvalidViewportSize=`InvalidViewportSize`,e.InvalidScrollingDirection=`InvalidScrollingDirection`,e.ViewportScrollLimitsReached=`ViewportScrollLimitsReached`,e.FigureDoesNotExist=`FigureDoesNotExist`,e.InvalidConditionalFormatId=`InvalidConditionalFormatId`,e.InvalidConditionalFormatType=`InvalidConditionalFormatType`,e.InvalidCellPopover=`InvalidCellPopover`,e.EmptyTarget=`EmptyTarget`,e.InvalidFreezeQuantity=`InvalidFreezeQuantity`,e.FrozenPaneOverlap=`FrozenPaneOverlap`,e.ValuesNotChanged=`ValuesNotChanged`,e.InvalidFilterZone=`InvalidFilterZone`,e.TableNotFound=`TableNotFound`,e.TableOverlap=`TableOverlap`,e.InvalidTableConfig=`InvalidTableConfig`,e.InvalidTableStyle=`InvalidTableStyle`,e.FilterNotFound=`FilterNotFound`,e.MergeInTable=`MergeInTable`,e.NonContinuousTargets=`NonContinuousTargets`,e.DuplicatedFigureId=`DuplicatedFigureId`,e.InvalidSelectionStep=`InvalidSelectionStep`,e.DuplicatedChartId=`DuplicatedChartId`,e.ChartDoesNotExist=`ChartDoesNotExist`,e.InvalidHeaderIndex=`InvalidHeaderIndex`,e.InvalidQuantity=`InvalidQuantity`,e.MoreThanOneColumnSelected=`MoreThanOneColumnSelected`,e.EmptySplitSeparator=`EmptySplitSeparator`,e.SplitWillOverwriteContent=`SplitWillOverwriteContent`,e.NoSplitSeparatorInSelection=`NoSplitSeparatorInSelection`,e.NoActiveSheet=`NoActiveSheet`,e.InvalidLocale=`InvalidLocale`,e.MoreThanOneRangeSelected=`MoreThanOneRangeSelected`,e.NoColumnsProvided=`NoColumnsProvided`,e.ColumnsNotIncludedInZone=`ColumnsNotIncludedInZone`,e.DuplicatesColumnsSelected=`DuplicatesColumnsSelected`,e.InvalidHeaderGroupStartEnd=`InvalidHeaderGroupStartEnd`,e.HeaderGroupAlreadyExists=`HeaderGroupAlreadyExists`,e.UnknownHeaderGroup=`UnknownHeaderGroup`,e.UnknownDataValidationRule=`UnknownDataValidationRule`,e.UnknownDataValidationCriterionType=`UnknownDataValidationCriterionType`,e.InvalidDataValidationCriterionValue=`InvalidDataValidationCriterionValue`,e.InvalidNumberOfCriterionValues=`InvalidNumberOfCriterionValues`,e.InvalidCopyPasteSelection=`InvalidCopyPasteSelection`,e.NoChanges=`NoChanges`,e.InvalidInputId=`InvalidInputId`,e.SheetIsHidden=`SheetIsHidden`,e.InvalidTableResize=`InvalidTableResize`,e.PivotIdNotFound=`PivotIdNotFound`,e.PivotInError=`PivotInError`,e.EmptyName=`EmptyName`,e.ValueCellIsInvalidFormula=`ValueCellIsInvalidFormula`,e.InvalidDefinition=`InvalidDefinition`,e.InvalidColor=`InvalidColor`,e.InvalidPivotDataSet=`InvalidPivotDataSet`,e.InvalidPivotCustomField=`InvalidPivotCustomField`,e.MissingFigureArguments=`MissingFigureArguments`,e.InvalidCarouselItem=`InvalidCarouselItem`,e}({}),Mr=new Set([`containsText`,`notContainsText`,`isGreaterThan`,`isGreaterOrEqualTo`,`isLessThan`,`isLessOrEqualTo`,`isBetween`,`isNotBetween`,`beginsWithText`,`endsWithText`,`isNotEmpty`,`isEmpty`,`isNotEqual`,`isEqual`,`customFormula`]),Nr=new Set([`containsText`,`notContainsText`,`isEqualText`,`isEmail`,`isLink`,`dateIs`,`dateIsBefore`,`dateIsOnOrBefore`,`dateIsAfter`,`dateIsOnOrAfter`,`dateIsBetween`,`dateIsNotBetween`,`dateIsValid`,`isEqual`,`isNotEqual`,`isGreaterThan`,`isGreaterOrEqualTo`,`isLessThan`,`isLessOrEqualTo`,`isBetween`,`isNotBetween`,`isBoolean`,`isValueInList`,`isValueInRange`,`customFormula`]),Pr=[{name:`English (US)`,code:`en_US`,thousandsSeparator:`,`,decimalSeparator:`.`,weekStart:7,dateFormat:`m/d/yyyy`,timeFormat:`hh:mm:ss a`,formulaArgSeparator:`,`},{name:`French`,code:`fr_FR`,thousandsSeparator:` `,decimalSeparator:`,`,weekStart:1,dateFormat:`dd/mm/yyyy`,timeFormat:`hh:mm:ss`,formulaArgSeparator:`;`}],D=Pr[0],Fr=[`thin`,`medium`,`thick`,`dashed`,`dotted`];function Ir(e){return Array.isArray(e)&&Array.isArray(e[0])}let Lr={Background:0,Highlights:1,Clipboard:2,Chart:4,Autofill:5,Selection:6,Headers:100},Rr=Kt(()=>Object.keys(Lr).sort((e,t)=>Lr[e]-Lr[t]));function zr(e,t){if(Lr[e])throw Error(`Layer ${e} already exists`);Lr[e]=t}let Br=[`containsText`,`notContainsText`,`isEqualText`,`isEmpty`,`isNotEmpty`,`beginsWithText`,`endsWithText`],Vr=[`isEqual`,`isNotEqual`,`isGreaterThan`,`isGreaterOrEqualTo`,`isLessThan`,`isLessOrEqualTo`,`isBetween`,`isNotBetween`,`isEmpty`,`isNotEmpty`],Hr=[`dateIs`,`dateIsBefore`,`dateIsOnOrBefore`,`dateIsAfter`,`dateIsOnOrAfter`,`dateIsBetween`,`dateIsNotBetween`,`isEmpty`,`isNotEmpty`];function Ur(e){return/^https?:\/\//i.test(e)?e:`https://${e}`}let Wr=new g;function Gr(e,t){return e=Ur(e),{url:e,label:t||e,isExternal:!0,isUrlEditable:!0}}Wr.add(`sheet_URL`,{match:e=>Et(e),createLink:(e,t)=>({label:t,url:e,isExternal:!1,isUrlEditable:!1}),urlRepresentation(e,t){let n=Ot(e);return t.tryGetSheetName(n)||E(`Invalid sheet`)},open(e,t){let n=Ot(e);t.model.dispatch(`ACTIVATE_SHEET`,{sheetIdFrom:t.model.getters.getActiveSheetId(),sheetIdTo:n}).isCancelledBecause(`SheetIsHidden`)&&t.notifyUser({type:`warning`,sticky:!1,text:E(`Cannot open the link because the linked sheet is hidden.`)})},sequence:0});let Kr={createLink:Gr,match:e=>St(e),open:e=>window.open(e,`_blank`),urlRepresentation:e=>e,sequence:0};function qr(e){return Wr.getAll().sort((e,t)=>e.sequence-t.sequence).find(t=>t.match(e))||Kr}function Jr(e,t){return qr(e.url).urlRepresentation(e.url,t)}function Yr(e,t,n){qr(e.url).open(e.url,t,n)}function Xr(e){if(typeof e==`string`){if(xt(e)){let{label:t,url:n}=wt(e);return qr(n).createLink(n,t)}else if(St(e))return Gr(e)}}var O=class e{jsDate;constructor(e,t,n,r=0,i=0,a=0){this.jsDate=new Date(Date.UTC(e,t,n,r,i,a,0))}static fromTimestamp(t){let n=new Date(t);return new e(n.getUTCFullYear(),n.getUTCMonth(),n.getUTCDate(),n.getUTCHours(),n.getUTCMinutes(),n.getUTCSeconds())}static now(){let t=new Date;return new e(t.getFullYear(),t.getMonth(),t.getDate(),t.getHours(),t.getMinutes(),t.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()}getQuarter(){return Math.floor(this.getMonth()/3)+1}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()}getIsoWeek(){let e=new Date(this.jsDate.getTime()),t=e.getUTCDay()||7;e.setUTCDate(e.getUTCDate()+4-t);let n=new Date(Date.UTC(e.getUTCFullYear(),0,1));return Math.ceil(((e.getTime()-n.getTime())/864e5+1)/7)}setFullYear(e){return this.jsDate.setUTCFullYear(e)}setMonth(e){return this.jsDate.setUTCMonth(e)}setDate(e){return this.jsDate.setUTCDate(e)}setHours(e){return this.jsDate.setUTCHours(e)}setMinutes(e){return this.jsDate.setUTCMinutes(e)}setSeconds(e){return this.jsDate.setUTCSeconds(e)}};let Zr=new O(1899,11,30),Qr=1440*60*1e3,$r=2e3,ei=O.now().getFullYear(),ti=O.now().getMonth(),ni=O.fromTimestamp(0).getTime()-Zr.getTime(),ri=/^\d{1,2}(\/|-|\s)\d{1,2}((\/|-|\s)\d{1,4})?$/,ii=/^\d{3,4}(\/|-|\s)\d{1,2}(\/|-|\s)\d{1,2}$/,ai=Ut.join(``),oi=RegExp(`\/|-|${Ut.join(`|`)}`),si=RegExp(`^(\\d{1,4})[\/${ai}\-](\\d{1,4})([\/${ai}\-](\\d{1,4}))?$`),ci=/((\d+(:\d+)?(:\d+)?\s*(AM|PM))|(\d+:\d+(:\d+)?))$/;function li(e,t){switch(typeof e){case`number`:return e;case`string`:return ui(e,t)?fi(e,t)?.value:!e||isNaN(Number(e))?void 0:Number(e);default:return}}function ui(e,t){return fi(e,t)!==null}let di=new Map;function fi(e,t){return di.has(t)||di.set(t,new Map),di.get(t).has(e)||di.get(t).set(e,pi(e,t)),di.get(t).get(e)}function pi(e,t){e=e.trim();let n=null,r=e.match(ci);if(r){if(n=xi(r[0]),n===null)return null;e=e.replace(r[0],``).trim()}let i=null,a=mi(e,t);if(a){let t=a.dateString.match(oi)[0];if(i=gi(a,t),i===null)return null;e=e.replace(a.dateString,``).trim()}return e!==``||!(i||n)?null:i&&i.jsDate&&n&&n.jsDate?{value:i.value+n.value,format:i.format+` `+(n.format===`hhhh:mm:ss`?`hh:mm:ss`:n.format),jsDate:new O(i.jsDate.getFullYear()+n.jsDate.getFullYear()-1899,i.jsDate.getMonth()+n.jsDate.getMonth()-11,i.jsDate.getDate()+n.jsDate.getDate()-30,i.jsDate.getHours()+n.jsDate.getHours(),i.jsDate.getMinutes()+n.jsDate.getMinutes(),i.jsDate.getSeconds()+n.jsDate.getSeconds())}:i||n}function mi(e,t){let n=e.match(si);if(!n)return null;let[,r,i,,a]=n;if(r.length>2&&a&&a.length>2)return null;if(r.length>2)return{year:r,month:i,day:a,dateString:e,type:`ymd`};let o=hi(t);return a?a.length>2?o===`mdy`?{month:r,day:i,year:a,dateString:e,type:`mdy`}:{day:r,month:i,year:a,dateString:e,type:`dmy`}:o===`mdy`?{month:r,day:i,year:a,dateString:e,type:`mdy`}:o===`ymd`?{year:r,month:i,day:a,dateString:e,type:`ymd`}:o===`dmy`?{day:r,month:i,year:a,dateString:e,type:`dmy`}:null:i.length>2?{month:r,year:i,day:void 0,dateString:e,type:o}:o===`dmy`?{day:r,month:i,year:a,dateString:e,type:`dmy`}:{month:r,day:i,year:a,dateString:e,type:`mdy`}}function hi(e){switch(e.dateFormat[0]){case`d`:return`dmy`;case`m`:return`mdy`;case`y`:return`ymd`}throw Error(`Invalid date format in locale`)}function gi(e,t){let{year:n,month:r,day:i}=e,a=yi(r),o=bi(i),s=vi(n);if(s===null||a===null||o===null)return null;let c=r?.length===2&&a+1<10||i?.length===2&&o<10,l=n?.length!==2,u=new O(s,a,o);if(u.getMonth()!==a||u.getDate()!==o)return null;let d=u.getTime()-Zr.getTime(),f=_i(e,t,c,l);return{value:Math.round(d/Qr),format:f,jsDate:u}}function _i(e,t,n,r){let i=e.year?r?`yyyy`:`yy`:void 0,a=e.month?n?`mm`:`m`:void 0,o=e.day?n?`dd`:`d`:void 0;switch(e.type){case`mdy`:return[a,o,i].filter(C).join(t);case`ymd`:return[i,a,o].filter(C).join(t);case`dmy`:return[o,a,i].filter(C).join(t)}}function vi(e){if(!e)return ei;let t=Number(e);switch(e.length){case 1:return $r+t;case 2:return $r+($r+t>ei+10?-100:0)+t;case 3:case 4:return t}return null}function yi(e){if(!e)return ti;let t=Number(e);return t>=1&&t<=12?t-1:null}function bi(e){if(!e)return 1;let t=Number(e);return t>=0&&t<=31?t:null}function xi(e){if(e=e.trim(),ci.test(e)){let t=/AM/i.test(e),n=/PM/i.test(e),r=(t||n?e.substring(0,e.length-2).trim():e).split(/:/),i=r.length>=2,a=r.length===3,o=Number(r[0]),s=i?Number(r[1]):0,c=a?Number(r[2]):0,l=a?`hh:mm:ss`:`hh:mm`;if(t||n)l+=` a`;else if(!i)return null;o>=12&&t?o-=12:o<12&&n&&(o+=12),s+=Math.floor(c/60),c%=60,o+=Math.floor(s/60),s%=60,o>=24&&(l=`hhhh:mm:ss`);let u=new O(1899,11,30,o,s,c);return{value:o/24+s/1440+c/86400,format:l,jsDate:u}}return null}function Si(e){let t=Math.trunc(e),n=O.fromTimestamp(t*Qr-ni),r=e-t;r=r<0?1+r:r;let i=Math.round(r*24),a=Math.round((r-i/24)*24*60),o=Math.round((r-i/24-a/24/60)*24*60*60);return n.setHours(i),n.setMinutes(a),n.setSeconds(o),n}function Ci(e){return Math.round(wi(e))}function wi(e){return(e.getTime()-Zr.getTime())/Qr}function Ti(e){return new O(e.getFullYear(),e.getMonth()+1,0).getDate()}function Ei(e){return Ti(e)===e.getDate()}function Di(e,t,n){let r=e.getFullYear(),i=e.getMonth(),a=e.getDate(),o=new O(r,i+t,1);return n&&a===Ti(e)||a>Ti(o)?o.setDate(Ti(o)):o.setDate(a),o}function Oi(e){let t=Math.trunc(e);return t%4==0&&t%100!=0||t%400==0}function ki(e,t,n){if(e===t)return 0;if(e>t){let n=t;t=e,e=n}let r=Si(e),i=Si(t),a=r.getDate(),o=i.getDate(),s=r.getMonth(),c=i.getMonth(),l=r.getFullYear(),u=i.getFullYear(),d=0,f=0;switch(n){case 0:a===31&&(a=30),a===30&&o===31&&(o=30),s===1&&a===(Oi(l)?29:28)&&(a=30,c===1&&o===(Oi(u)?29:28)&&(o=30)),d=l+(s*30+a)/360,f=u+(c*30+o)/360;break;case 1:let n=365,r=l===u,i=l+1===u;if(!r&&!i||!r&&s<c||!r&&s===c&&a<o){let e=0,t=0;for(let n=l;n<=u;n++)e++,t+=Oi(n)?366:365;n=t/e}else r?Oi(l)&&(n=366):(Oi(l)&&s<2&&(n=366),Oi(u)&&(c>1||c===1&&o===29)&&(n=366));d=e/n,f=t/n;break;case 2:d=e/360,f=t/360;break;case 3:d=e/365,f=t/365;break;case 4:a===31&&(a=30),o===31&&(o=30),d=l+(s*30+a)/360,f=u+(c*30+o)/360;break}return f-d}function Ai(e,t){let n=(t.getFullYear()-e.getFullYear())*12+t.getMonth()-e.getMonth();return e.getDate()>t.getDate()?n-1:n}function ji(e,t){let n=e.getTime(),r=t.getTime();return Math.floor((r-n)/Qr)}function Mi(e,t){let n=t.getFullYear()-e.getFullYear(),r=e.getMonth(),i=t.getMonth(),a=e.getDate(),o=t.getDate();return i>r||i===r&&o>=a?n:n-1}function Ni(e,t){return ki(e,t,1)<1}function Pi(e,t){return Math.trunc(e)===Math.trunc(t)}function Fi(e,t,n){return t>n?Fi(e,n,t):(e=Math.trunc(e),t=Math.trunc(t),n=Math.trunc(n),e>=t&&e<=n)}function Ii(e,t){return Math.trunc(e)<Math.trunc(t)}function Li(e,t){return Math.trunc(e)<=Math.trunc(t)}function Ri(e,t){return Math.trunc(e)>Math.trunc(t)}function zi(e,t){return Math.trunc(e)>=Math.trunc(t)}let Bi=Kt(function(e){return e=ut(e),RegExp(`(?:^-?\\d+(?:${e}?\\d*(?:e(\\+|-)?\\d+)?)?|^-?${e}\\d+)(?!\\w|!)`)}),Vi=Kt(function(e){let t=ut(e.decimalSeparator),n=`(?:\\d+(?:${ut(e.thousandsSeparator||``)}\\d{3,})*(?:${t}\\d*)?)`,r=`(?:${t}\\d+)`,i=`(?:\\s*`+n+`|`+r+`)(?:e(?:\\+|-)?\\d+)?(?:\\s*%)?`,a=`^(?:(?:`+[`(?:\\s*-)?(?:\\s*[\\$€])?`+i,`(?:\\s*-)?`+i+`(?:\\s*[\\$€])?`,`(?:\\s*[\\$€])?(?:\\s*-)?`+i].join(`)|(?:`)+`))$`;return new RegExp(a,`i`)});function Hi(e,t){return e?Vi(t).test(e.trim()):!1}let Ui=Kt(function(e){return RegExp(`[\$€${ut(e.thousandsSeparator||``)}]`,`g`)});function Wi(e,t){e=e.replace(Ui(t),``),t.decimalSeparator!==`.`&&(e=e.replace(t.decimalSeparator,`.`));let n=Number(e);return isNaN(n)&&e.includes(`%`)&&(n=Number(e.split(`%`)[0]),!isNaN(n))?n/100:n}function Gi(e,t,n){let r=[...e].sort((e,t)=>e-t),i=(r.length+(n?-1:1))*t;if(n||i--,Number.isInteger(i))return r[i];let a=Math.ceil(i),o=Math.floor(i);return r[a]*(i-o)+r[o]*(a-i)}let k={NotAvailable:`#N/A`,InvalidReference:`#REF`,BadExpression:`#BAD_EXPR`,CircularDependency:`#CYCLE`,UnknownFunction:`#NAME?`,DivisionByZero:`#DIV/0!`,SpilledBlocked:`#SPILL!`,GenericError:`#ERROR`,NullError:`#NULL!`},Ki=new Set(Object.values(k));var A=class{message;value;constructor(e=E(`Error`),t=k.GenericError){this.message=e,this.value=t,this.message=e.toString()}},qi=class extends A{constructor(e=E(`Invalid expression`)){super(e,k.BadExpression)}},Ji=class extends A{constructor(e=E(`Circular reference`)){super(e,k.CircularDependency)}},Yi=class extends A{constructor(e=E(`Invalid reference`)){super(e,k.InvalidReference)}},Xi=class extends A{constructor(e=E(`Data not available`)){super(e,k.NotAvailable)}},Zi=class extends A{constructor(e=E(`Unknown function`)){super(e,k.UnknownFunction)}},Qi=class extends A{errorOriginPosition;constructor(e=E(`Spill range is not empty`),t){super(e,k.SpilledBlocked),this.errorOriginPosition=t}},$i=class extends A{constructor(e=E(`Division by zero`)){super(e,k.DivisionByZero)}};let ea=[`number`,`string`,`boolean`,`undefined`];function ta(e){if(e!==void 0)return Ir(e)?e[0][0]?.format:e.format}function j(e){return typeof e==`string`&&Ki.has(e)}function na(e){return{value:k.NotAvailable,message:E(`Did not find value '%s' in [[FUNCTION_NAME]] evaluation.`,N(e))}}let ra=e=>E(`The function [[FUNCTION_NAME]] expects a number value, but '%s' is a string, and cannot be coerced to a number.`,e),ia=(e,t,n)=>E(`The function [[FUNCTION_NAME]] expects a number value between %s and %s inclusive, but receives %s.`,e.toString(),t.toString(),n.toString()),aa=(e,t)=>E(`The function [[FUNCTION_NAME]] has an argument with value '%s'. It should be one of: %s.`,t,e.map(e=>`'${e}'`).join(`, `));function M(e,t){let n=ma(e);switch(typeof n){case`number`:return n;case`boolean`:return+!!n;case`string`:if(Hi(n,t)||n===``)return Wi(n,t);let e=fi(n,t);if(e)return e.value;throw new A(ra(n));default:return 0}}function oa(e,t){try{return M(e,t)}catch{return}}function sa(e,t){return I(e).map(e=>e.map(e=>{if(typeof e.value!=`number`){let n=``;throw typeof e==`object`?n=E(`Function [[FUNCTION_NAME]] expects number values for %s, but got an empty value.`,t):typeof e==`string`?n=E(`Function [[FUNCTION_NAME]] expects number values for %s, but got a string.`,t):typeof e==`boolean`&&(n=E(`Function [[FUNCTION_NAME]] expects number values for %s, but got a boolean.`,t)),new A(n)}return e.value}))}function ca(e,t){let n=ma(e);if(n===``)throw new A(ra(n));return M(n,t)}function la(e,t){return Math.trunc(M(e,t))}function ua(e,t){return Math.trunc(ca(e,t))}function N(e){let t=ma(e);switch(typeof t){case`string`:return t;case`number`:return t.toString();case`boolean`:return t?`TRUE`:`FALSE`;default:return``}}let da=Kt(function(e){return e.toLowerCase().normalize(`NFD`).replace(/[\u0300-\u036f]/g,``)}),fa=e=>E(`The function [[FUNCTION_NAME]] expects a boolean value, but '%s' is a text, and cannot be coerced to a boolean.`,e);function P(e){let t=ma(e);switch(typeof t){case`boolean`:return t;case`string`:if(t){let e=t.toUpperCase();if(e===`TRUE`)return!0;if(e===`FALSE`)return!1;throw new A(fa(t))}else return!1;case`number`:return!!t;default:return!1}}function pa(e){let t=ma(e);if(t===``)throw new A(fa(t));return P(t)}function F(e,t){return Si(M(ma(e),t))}function ma(e){if(typeof e==`object`&&e&&`value`in e){if(j(e.value))throw e;return e.value}if(j(e))throw new A(``,e);return e}function ha(e,t,n){for(let r of e)if(Ir(r)){let e=r.length,n=r[0].length;for(let i=0;i<n;i++)for(let n=0;n<e;n++)t(r[n][i])}else n(r)}function ga(e,t){ha(e,e=>{if(j(e.value))throw e;t(e)},e=>{if(j(e?.value))throw e;t(e)})}function _a(e,t,n){ha(e,e=>{if(typeof e?.value==`number`&&t(e),j(e?.value))throw e},e=>{t({value:ca(e,n),format:e?.format})})}function va(e,t,n,r,i=`rowFirst`){let a=r;for(let r of e)if(Ir(r)){let e=r.length,n=r[0].length;if(i===`rowFirst`)for(let i=0;i<n;i++)for(let n=0;n<e;n++)a=t(a,r[n][i]);else for(let i=0;i<e;i++)for(let e=0;e<n;e++)a=t(a,r[i][e])}else a=n(a,r);return a}function ya(e,t,n,r=`rowFirst`){return va(e,t,t,n,r)}function ba(e,t,n,r){return va(e,(e,n)=>{let r=n?.value;if(typeof r==`number`)return t(e,r);if(j(r))throw n;return e},(e,n)=>t(e,ca(n,r)),n)}function xa(e,t,n,r){return va(e,(e,n)=>{let i=n?.value;if(i!=null){if(typeof i==`number`)return t(e,i);if(typeof i==`boolean`)return t(e,M(i,r));if(j(i))throw n;return t(e,0)}return e},(e,n)=>t(e,M(n,r)),n)}function Sa(e,t,n){let r=Array(e);for(let i=0;i<e;i++){r[i]=Array(t);for(let e=0;e<t;e++)r[i][e]=n(i,e)}return r}function Ca(e,t){return e.length===0?[]:Sa(e.length,e[0].length,(n,r)=>t(e[n][r]))}function wa(e,t){let n=e.length,r=e[0]?.length??0;for(let i=0;i<n;i++)for(let n=0;n<r;n++)t(e[i][n])}function Ta(e){return e.length?Sa(e[0].length,e.length,(t,n)=>e[n][t]):[]}function Ea(e,t,n=void 0){let r=1,i=1,a=1/0,o=1/0,s;for(let e=0;e<t.length;e++){let c=t[e];if(Ir(c)&&(n===void 0||n[e])){let n=c.length,l=c[0].length;n!==1||l!==1?(s??=Array(t.length),n!==1&&l!==1?(s[e]=`matrix`,r=Math.max(r,n),i=Math.max(i,l),a=Math.min(a,n),o=Math.min(o,l)):n===1?l!==1&&(s[e]=`vertical`,i=Math.max(i,l),o=Math.min(o,l)):(s[e]=`horizontal`,r=Math.max(r,n),a=Math.min(a,n))):t[e]=c[0][0]}}if(r===1&&i===1)return e(...t);let c=(e,n)=>t.map((t,r)=>{switch(s?.[r]){case`matrix`:return t[e][n];case`horizontal`:return t[e][0];case`vertical`:return t[0][n];case void 0:return t}});return Sa(r,i,(t,n)=>{if(t>a-1||n>o-1)return new Xi(E(`Array arguments to [[FUNCTION_NAME]] are of different size.`));let r=e(...c(t,n));return Ir(r)?r[0][0]:r})}function Da(e,t,n){for(let r of e)if(Ir(r)){let e=r.length,n=r[0].length;for(let i=0;i<n;i++)for(let n=0;n<e;n++)if(!t(r[n][i]??void 0))return}else if(!n(r))return}function Oa(e,t){return Da(e,e=>{let n=e?.value;if(typeof n==`boolean`)return t(n);if(typeof n==`number`)return t(!!n);if(j(n))throw e;return!0},e=>e!==void 0&&e.value!==null?t(pa(e)):!0)}function ka(e,t){let n,r,i=e.substring(0,2);return i===`<=`||i===`>=`||i===`<>`?(n=i,r=e.substring(2)):(i=e.substring(0,1),i===`<`||i===`>`||i===`=`?(n=i,r=e.substring(1)):(n=`=`,r=e)),Hi(r,t)||ui(r,t)?r=M(r,t):(r===`TRUE`||r===`FALSE`)&&(r=P(r)),{operator:n,operand:r}}let Aa=Kt(function(e){if(e===`*`)return/.+/;let t=``,n=``;for(let r of e)r===`?`&&n!==`~`?t+=`.`:r===`*`&&n!==`~`?t+=`.*`:((r===`*`||r===`?`)&&(t=t.slice(0,-1)),[`^`,`.`,`[`,`]`,`$`,`(`,`)`,`*`,`+`,`?`,`|`,`{`,`}`,`\\`].includes(r)&&(t+=`\\`),t+=r),n=r;return RegExp(`^`+t+`$`,`i`)});function ja(e=``,t,n){let{operator:r,operand:i}=t;if(i===void 0||e===null||i===null)return!1;if(typeof i==`number`&&r===`=`)return typeof e==`string`&&(Hi(e,n)||ui(e,n))?M(e,n)===i:e===i;if(r===`<>`||r===`=`){let t;return t=typeof e==typeof i?e===``&&i===``?!0:typeof e==`string`&&typeof i==`string`?Aa(i).test(e):e===i:!1,r===`=`?t:!t}if(typeof e==typeof i)switch(r){case`<`:return e<i;case`>`:return e>i;case`<=`:return e<=i;case`>=`:return e>=i}return!1}function Ma(e,t,n,r=!1){let i=e.length;if(i%2==1)throw new A(E(`Function [[FUNCTION_NAME]] expects criteria_range and criterion to be in pairs.`));let a=I(e[0]),o=a.length,s=a[0].length,c=[];for(let t=0;t<i-1;t+=2){let i=I(e[t]);if(i.length!==o||i[0].length!==s)throw new A(E(`Function [[FUNCTION_NAME]] expects criteria_range to have the same dimension`));let a=ka(N(e[t+1]),n);r&&typeof a.operand==`string`&&(a.operand+=`*`),c.push(a)}for(let r=0;r<o;r++)for(let a=0;a<s;a++){let o=!0;for(let t=0;t<i-1;t+=2){let i=I(e[t])[r][a].value,s=c[t/2];if(o=ja(i??void 0,s,n),!o)break}o&&t(r,a)}}function Na(e,t,n,r,i,a){if(t===void 0||t.value===null)return-1;if(j(t.value))throw t;let o=Ia(t.value),s=typeof o,c,l,u=0,d=i-1,f,p,m,h,g=r===`desc`?t=>Ia(a(e,i-t-1)):t=>Ia(a(e,t));for(;d-u>=0;){for(f=Math.floor((u+d)/2),p=f,m=g(p),h=typeof m;u<p&&s!==h;)p--,m=g(p),h=typeof m;if(h!==s||m==null){u=f+1;continue}n===`strict`&&m===o?(c=m,l=p):n===`nextSmaller`&&m<=o?(c==null||c<m||c===m&&l<p)&&(c=m,l=p):n===`nextGreater`&&m>=o&&(c===void 0||c>m||c===m&&l<p)&&(c=m,l=p),m>o||n===`strict`&&m===o?d=p-1:u=f+1}return l===void 0?-1:r===`desc`?i-l-1:l}function Pa(e,t,n,r,i,a,o=!1){if(t===void 0||t.value===null)return-1;if(j(t.value))throw t;let s=Ia(t.value),c=o?(e,t)=>Ia(i(e,r-t-1)):(e,t)=>Ia(i(e,t)),l=n!==`wildcard`||typeof s!=`string`||!(s.includes(`*`)||s.includes(`?`));if(a&&l){let t=o?`reverseSearch`:`forwardSearch`,i=a[t].get(e);if(i===void 0){i=new Map;for(let t=0;t<r;t++){let n=c(e,t)??null;i.has(n)||i.set(n,t)}a[t].set(e,i)}if(i.has(s)){let e=i.get(s);return o?r-e-1:e}if(n===`strict`||n===`wildcard`)return-1}let u=Fa(e,s,n,r,c);return o&&u!==-1?r-u-1:u}function Fa(e,t,n,r,i){let a=n=>i(e,n)===t;if(n===`wildcard`&&typeof t==`string`&&(t.includes(`*`)||t.includes(`?`))){let n=Aa(t);a=t=>{let r=i(e,t);return typeof r==`string`?n.test(r):!1}}let o,s=-1;n===`nextSmaller`&&(a=n=>{let r=i(e,n);return(!o&&La(t,r)>=0||La(t,r)>=0&&La(r,o)>0)&&(o=r,s=n),r===t}),n===`nextGreater`&&(a=n=>{let r=i(e,n);return(!o&&La(t,r)<=0||La(t,r)<=0&&La(r,o)<0)&&(o=r,s=n),r===t});for(let e=0;e<r;e++)if(a(e))return e;return s}function Ia(e){return typeof e==`string`?da(e):e}function La(e,t){let n=ea.indexOf(typeof e)-ea.indexOf(typeof t);return n===0&&(typeof e==`string`&&typeof t==`string`?n=e.localeCompare(t):typeof e==`number`&&typeof t==`number`?n=e-t:typeof e==`boolean`&&typeof t==`boolean`&&(n=Number(e)-Number(t))),n}function I(e){return e===void 0?[[]]:Ir(e)?e:[[e]]}function Ra(e,t){return ya(e,(e,n)=>(e.push(t(n)),e),[],`rowFirst`)}function za(e){if(e===void 0)return!1;let{value:t}=e;return!(t===null||t===``)}let Ba=E(`[[FUNCTION_NAME]] has no valid input data.`);function Va(e){return E(`[[FUNCTION_NAME]] expects the provided values of %(argName)s to be a non-empty matrix.`,{argName:e})}function Ha(e){e=e.replace(/\s/g,` `);let t=new tn(e),n=[],r=[];for(n.push(r);!t.isOver();){if(t.current===`;`){r=[],n.push(r),t.shift();continue}let e=Xa(t)||Ua(t)||Ga(t)||Ka(t)||Ja(t)||Ya(t)||Qa(t)||qa(t)||$a(t);if(!e)throw Error(`Unknown token at `+t.remaining());r.push(e)}return n}function Ua(e){let t;if(e.current===`"`?(e.shift(),t=`"`):e.currentStartsWith(`[$`)&&(e.advanceBy(2),t=`]`),!t)return null;let n=``;for(;e.current&&e.current!==t;)n+=e.shift();if(e.current===t)e.shift();else throw Error(`Unterminated string in format`);return{type:`STRING`,value:n}}let Wa=new Set(`$+-/():!^&~{}<>= `);function Ga(e){if(e.current===`\\`){e.shift();let t=e.shift();if(!t)throw Error(`Unexpected end of format string`);return{type:`CHAR`,value:t}}return Wa.has(e.current)?{type:`CHAR`,value:e.shift()}:null}function Ka(e){return e.current===`,`?(e.shift(),{type:`THOUSANDS_SEPARATOR`,value:`,`}):null}function qa(e){return e.current===`@`?(e.shift(),{type:`TEXT_PLACEHOLDER`,value:`@`}):null}function Ja(e){return e.current===`.`?(e.shift(),{type:`DECIMAL_POINT`,value:`.`}):null}function Ya(e){return e.current===`%`?(e.shift(),{type:`PERCENT`,value:`%`}):null}function Xa(e){if(e.current===`0`||e.current===`#`){let t=e.current;return e.shift(),{type:`DIGIT`,value:t}}return null}let Za=new Set(`dmqyhsa`);function Qa(e){if(!Za.has(e.current))return null;let t=e.current,n=``;for(;e.current===t;)n+=e.shift();return{type:`DATE_PART`,value:n}}function $a(e){if(e.current!==`*`)return null;e.shift();let t=e.shift();if(!t)throw Error(`Unexpected end of format string`);return{type:`REPEATED_CHAR`,value:t}}let eo={};function to(e){let t=eo[e];return t===void 0&&(t=no(e),eo[e]=t),t}function no(e){let t=Ha(e);for(let e of t){let t=e.filter(e=>e.type===`REPEATED_CHAR`);for(let e of t.slice(1))e.type=`CHAR`}let n=so(t[0])||oo(t[0])||co(t[0]);if(!n)throw Error(`Invalid first format part of: `+e);if(t.length>1&&n.type===`text`)throw Error(`The first format in a multi-part format must be a number format: `+e);let r=so(t[1])||oo(t[1]);if(t[1]?.length&&!r)throw Error(`Invalid second format part of: `+e);let i=so(t[2])||oo(t[2]);if(t[2]?.length&&!i)throw Error(`Invalid third format part of: `+e);let a=co(t[3]);if(t[3]?.length&&!a)throw Error(`Invalid fourth format part of: `+e);return{positive:n,negative:r,zero:i,text:a}}function ro(e){return e.every(e=>e.type===`DATE_PART`||e.type===`DECIMAL_POINT`||e.type===`THOUSANDS_SEPARATOR`||e.type===`STRING`||e.type===`CHAR`||e.type===`REPEATED_CHAR`)}function io(e){return e.every(e=>e.type===`DIGIT`||e.type===`DECIMAL_POINT`||e.type===`THOUSANDS_SEPARATOR`||e.type===`PERCENT`||e.type===`STRING`||e.type===`CHAR`||e.type===`REPEATED_CHAR`)}function ao(e){return e.every(e=>e.type===`STRING`||e.type===`TEXT_PLACEHOLDER`||e.type===`CHAR`||e.type===`REPEATED_CHAR`)}function oo(e){if(!e||!io(e))return;let t=[],n,r=t,i=0,a=0,o=e.findLastIndex(e=>e.type===`DIGIT`),s=!1,c=0;for(let l=0;l<e.length;l++){let u=e[l];switch(u.type){case`DIGIT`:r===t?r.push(u):c<20&&(r.push(u),c++);break;case`DECIMAL_POINT`:if(r===t)n=[],r=n;else throw Error(`Multiple decimal points in a number format`);break;case`REPEATED_CHAR`:case`CHAR`:case`STRING`:r.push(u);break;case`PERCENT`:i++,r.push(u);break;case`THOUSANDS_SEPARATOR`:l-1===o?(a+=1,o++,r.push(u)):e[l+1]?.type===`DIGIT`&&e[l-1]?.type===`DIGIT`?(r===t&&(s=!0),r.push(u)):r.push({type:`CHAR`,value:`,`});break}}return{type:`number`,integerPart:t,decimalPart:n,percentSymbols:i,thousandsSeparator:s,magnitude:a}}function so(e){let t=e&&ro(e)?{type:`date`,tokens:e}:void 0;if(t){if(t.tokens.length&&t.tokens.every(e=>e.type===`DATE_PART`&&e.value===`a`))throw Error(`Invalid date format`);return{type:`date`,tokens:lo(t.tokens.map(e=>e.type===`THOUSANDS_SEPARATOR`||e.type===`DECIMAL_POINT`?{type:`CHAR`,value:e.value}:e))}}}function co(e){return e&&ao(e)?{type:`text`,tokens:e}:void 0}function lo(e){let t=e.filter(e=>e.type===`DATE_PART`);for(let e=0;e<t.length;e++)!t[e].value.startsWith(`m`)||t[e].value.length>2||(t[e-1]?.value.startsWith(`h`)||t[e+1]?.value.startsWith(`s`))&&(t[e].value=t[e].value.replaceAll(`m`,`M`));return e}function uo(e){return[fo(e.positive),fo(e.negative),fo(e.zero),fo(e.text)].filter(C).join(`;`)}function fo(e){if(!e)return;let t=``,n=e.type===`number`?po(e):e.tokens;for(let e of n)switch(e.type){case`STRING`:t+=`[$${e.value}]`;break;case`CHAR`:t+=mo(e.value)?`\\${e.value}`:e.value;break;case`REPEATED_CHAR`:t+=`*`+e.value;break;case`DATE_PART`:t+=e.value===`MM`?`mm`:e.value;break;default:t+=e.value}return t}function po(e){let t=[...e.integerPart];return e.decimalPart&&(t.push({type:`DECIMAL_POINT`,value:`.`}),t.push(...e.decimalPart)),t}function mo(e){return!Wa.has(e)}let ho=`REPEATED_CHAR_PLACEHOLDER_`,go={0:E(`January`),1:E(`February`),2:E(`March`),3:E(`April`),4:E(`May`),5:E(`June`),6:E(`July`),7:E(`August`),8:E(`September`),9:E(`October`),10:E(`November`),11:E(`December`)},_o={0:E(`Sunday`),1:E(`Monday`),2:E(`Tuesday`),3:E(`Wednesday`),4:E(`Thursday`),5:E(`Friday`),6:E(`Saturday`)};function vo(e,t,n,r=!1){return r?Wo({value:e,format:t},n):L(e,{format:t,locale:n})}function L(e,{format:t,locale:n,formatWidth:r}){switch(typeof e==`boolean`&&(e=e?`TRUE`:`FALSE`),typeof e){case`string`:{if(e.includes(`\\"`)&&(e=e.replaceAll(/\\"/g,`"`)),!t)return e;let n=to(t),i=n.text||n.positive;return!i||i.type!==`text`?e:yo(e,i,r)}case`number`:t||=Fo(e);let i=to(t);if(i.positive.type===`text`)return yo(e.toString(),i.positive,r);let a=i.positive;if(e<0&&i.negative?(a=i.negative,e=-e):e===0&&i.zero&&(a=i.zero),a.type===`date`)return bo(Mo(e,a),r);let o=e<0,s=bo(xo(Math.abs(e),a,n),r);return o?`-`+s:s;case`object`:return``}}function yo(e,t,n){let r=``;for(let n of t.tokens)switch(n.type){case`TEXT_PLACEHOLDER`:r+=e;break;case`CHAR`:case`STRING`:r+=n.value;break;case`REPEATED_CHAR`:r+=ho+n.value;break}return bo(r,n)}function bo(e,t){let n=e.indexOf(ho);if(n===-1)return e;let r=e.slice(0,n),i=e.slice(n+26+1),a=e[n+26];function o(){if(!t)return{timesToRepeat:0,padding:``};let e=t.measureText(r+i),n=t.measureText(a),o=t.availableWidth-e;if(o<=0)return{timesToRepeat:0,padding:``};let s=Math.floor(o/n),c=o-s*n,l=t.measureText(` `);return{timesToRepeat:s,padding:` `.repeat(Math.floor(c/l))}}let{timesToRepeat:s,padding:c}=o();return r+a.repeat(s)+c+i}function xo(e,t,n){if(e===1/0)return`∞`+(t.percentSymbols?`%`:``);let r=t.percentSymbols*2-t.magnitude*3;e*=10**r;let i=0;t.decimalPart!==void 0&&(i=t.decimalPart.filter(e=>e.type===`DIGIT`).length);let{integerDigits:a,decimalDigits:o}=To(Math.abs(e),i),s=So(a,t,t.thousandsSeparator?n.thousandsSeparator:void 0);return t.decimalPart!==void 0&&(s+=n.decimalSeparator+Co(o||``,t)),s}function So(e,t,n){let r=t.integerPart;r.some(e=>e.type===`DIGIT`)||(r=[...r,{type:`DIGIT`,value:`#`}]),e===`0`&&(e=``);let i=``,a=r.findIndex(e=>e.type===`DIGIT`),o=e.length-1;function s(t,r){if(r===`0`&&(t||=`0`),!t)return;let a=e.length-1-o;i=n&&a>0&&a%3==0?t+n+i:t+i}for(let t=r.length-1;t>=0;t--){let n=r[t];switch(n.type){case`DIGIT`:let r=e[o];if(s(r,n.value),o--,a===t)for(;o>=0;)s(e[o],`0`),o--;break;case`THOUSANDS_SEPARATOR`:break;case`REPEATED_CHAR`:i=ho+n.value+i;break;default:i=n.value+i;break}}return i}function Co(e,t){if(!t.decimalPart)return``;let n=``,r=0;for(let i of t.decimalPart)switch(i.type){case`DIGIT`:let t=i.value===`#`?e[r]||``:e[r]||`0`;n+=t,r++;break;case`THOUSANDS_SEPARATOR`:break;case`REPEATED_CHAR`:n+=ho+i.value;break;default:n+=i.value;break}return n}let wo=[];function To(e,t=20){let n=e.toString();if(n.includes(`e`))return ko(e,t);if(Number.isInteger(e))return{integerDigits:n,decimalDigits:void 0};let r=n.indexOf(`.`),i=n.substring(0,r),a=n.substring(r+1);if(t===0)return Number(a[0])>=5&&(i=(Number(i)+1).toString()),{integerDigits:i,decimalDigits:void 0};if(a.length>t){let{integerDigits:e,decimalDigits:n}=Oo(a,t);a=n,e!==`0`&&(i=(Number(i)+Number(e)).toString())}return{integerDigits:i,decimalDigits:Eo(a||``)}}function Eo(e){let t=e.length-1;for(;t>=0&&e[t]===`0`;)t--;return e.slice(0,t+1)||void 0}let Do=/^0+/;function Oo(e,t){let n=`0`,r=e,i=e.slice(0,t);if(Number(e[t])<5)return{integerDigits:n,decimalDigits:i};let a=i.match(Do)?.[0]||``,o=(Number(i)+1).toString(),s=i.slice(a.length),c=o.length>s.length;return c&&!a?(n=`1`,r=void 0):r=c?a.slice(0,-1)+o:a+o,{integerDigits:n,decimalDigits:r}}function ko(e,t=20){let n=wo[t];n||(n=new Intl.NumberFormat(`en-US`,{maximumFractionDigits:t,useGrouping:!1}),wo[t]=n);let[r,i]=n.format(e).split(`.`);return{integerDigits:r,decimalDigits:i}}function Ao(e,t){let{integerDigits:n,decimalDigits:r}=To(e,20);return r?n+t+r:n}let jo=Kt(function(e){if(!e)return!1;try{return to(e).positive.type===`date`}catch{return!1}});function Mo(e,t){let n=Si(e);if(isNaN(n.getTime()))return e.toString();let r=t.tokens.some(e=>e.type===`DATE_PART`&&e.value===`a`),i=``;for(let e of t.tokens)switch(e.type){case`DATE_PART`:i+=No(n,e.value,r);break;case`REPEATED_CHAR`:i+=ho+e.value;break;default:i+=e.value;break}return i}function No(e,t,n){switch(t){case`d`:return e.getDate();case`dd`:return e.getDate().toString().padStart(2,`0`);case`ddd`:return _o[e.getDay()].slice(0,3);case`dddd`:return _o[e.getDay()].toString();case`m`:return e.getMonth()+1;case`mm`:return String(e.getMonth()+1).padStart(2,`0`);case`mmm`:return go[e.getMonth()].slice(0,3);case`mmmm`:return go[e.getMonth()].toString();case`mmmmm`:return go[e.getMonth()].slice(0,1);case`qq`:return E(`Q%(quarter)s`,{quarter:e.getQuarter()}).toString();case`qqqq`:return E(`Quarter %(quarter)s`,{quarter:e.getQuarter()}).toString();case`yy`:let r=String(e.getFullYear()).replace(`-`,``).padStart(2,`0`);return r.slice(r.length-2);case`yyyy`:return String(e.getFullYear()).replace(`-`,``).padStart(4,`0`);case`hhhh`:return Math.floor((e.getTime()-Zr.getTime())/(3600*1e3)).toString();case`hh`:let i=e.getHours();return n&&(i=i===0?12:i>12?i-12:i),i.toString().padStart(2,`0`);case`MM`:return e.getMinutes().toString().padStart(2,`0`);case`ss`:return e.getSeconds().toString().padStart(2,`0`);case`a`:return e.getHours()>=12?`PM`:`AM`;default:throw Error(`invalid date format token: ${t}`)}}let Po=Kt(function(e){return RegExp(`[0-9]+${ut(e.decimalSeparator)}[0-9]`)});function Fo(e){let{integerDigits:t,decimalDigits:n}=To(e);if(!n)return`0`;let r=t.replace(`-`,``).length;if(r+2>11)return`0`;let i=11-r-1;return{decimalDigits:n}=To(e,Math.min(i,n.length)),n?`0.`+`0`.repeat(n.length):`0`}function Io(e,t){if(ui(e,t))return fi(e,t).format}function Lo(e){let t=e.includes(`.`)?`0.00`:`0`,n=e.match(/[\$€]/);if(n){let r=e.match(/[\d]/),i=`[$`+n.values().next().value+`]`;return r.index<n.index?`#,##`+t+i:i+`#,##`+t}if(e.includes(`%`))return t+`%`}function Ro(e){let t=e.decimalPlaces??2,n=e.position??`before`,r=e.code??``,i=e.symbol??``,a=`#,##0`+(t?`.`+`0`.repeat(t):``),o=`${r} ${i}`.trim();return n===`after`&&r&&(o=` `+o),Vo(o,n,a)}function zo(e){let t=e.decimalPlaces??2,n=e.position??`before`,r=e.code??``,i=e.symbol??``,a=`#,##0`+(t?`.`+`0`.repeat(t):``),o=`${r} ${i}`.trim();return n===`after`&&r&&(o=` `+o),[Bo(o,n,` ${a} `),Bo(o,n,`(${a})`),Bo(o,n,` - `)].join(`;`)}function Bo(e,t,n){let r=`[$${e}]`;return t===`before`?r+`* `+n:n+`* `+r}function Vo(e,t,n){let r=`[$${e}]`;return t===`before`?r+n:n+r}function Ho(e){let t=to(e);return uo({positive:Uo(t.positive),negative:t.negative?Uo(t.negative):void 0,zero:t.zero?Uo(t.zero):void 0,text:t.text})}function Uo(e){if(e.type!==`number`||!e.decimalPart)return e;let t=e.decimalPart.filter(e=>e.type!==`DIGIT`);return{...e,decimalPart:void 0,integerPart:[...e.integerPart,...t]}}function Wo({value:e,format:t},n){let r=oa(e,n);if(r===void 0)return``;let i=t;if(Math.abs(r)<1e3){let e=r%1!=0;i=!t&&e?`0.####`:t}else i=Go({value:e,format:t},void 0,n);return L(e,{format:i,locale:n})}function Go(e,t,n){let r=0;try{r=Math.abs(M(e?.value,n))}catch{return``}let i=e?.format;if(t!==void 0)switch(t?.value){case`k`:return Ko(i,1,`k`,n);case`m`:return Ko(i,2,`m`,n);case`b`:return Ko(i,3,`b`,n);default:throw new A(E(`The formatting unit should be 'k', 'm' or 'b'.`))}return r<1e5?Ko(i,0,``,n):r<1e8?Ko(i,1,`k`,n):r<1e11?Ko(i,2,`m`,n):Ko(i,3,`b`,n)}function Ko(e,t,n,r){let i=to(e||`#,##0`);return uo({positive:qo(i.positive,t,n),negative:i.negative?qo(i.negative,t,n):void 0,zero:i.zero?qo(i.zero,t,n):void 0,text:i.text})}function qo(e,t,n){if(e.type!==`number`)return e;let r=Uo(e),i={type:`STRING`,value:n},a=[...r.integerPart],o=a.findLastIndex(e=>e.type===`DIGIT`);if(o===-1)throw Error(`Cannot create a large number format from a format with no digit.`);for(;a[o+1]?.type===`THOUSANDS_SEPARATOR`;)a=qt(a,[o+1]);let s=a[o+1];a=s?.type===`STRING`&&[`m`,`k`,`b`].includes(s.value)?Yt(a,i,o+1):Jt(a,[i],o+1),t>0&&(a=Jt(a,Array(t).fill({type:`THOUSANDS_SEPARATOR`,value:`,`}),o+1));let c=r.percentSymbols-a.filter(e=>e.type===`PERCENT`).length;return a.push(...Array(c).fill({type:`PERCENT`,value:`%`})),{...r,integerPart:a,magnitude:t}}function Jo(e,t){let n=to(e);return uo(to(uo({positive:Yo(n.positive,t),negative:n.negative?Yo(n.negative,t):void 0,zero:n.zero?Yo(n.zero,t):void 0,text:n.text})))}function Yo(e,t){return e.type===`number`?t>0?Zo(e,t):Xo(e,Math.abs(t)):e}function Xo(e,t){let n=e.decimalPart;if(!n)return e;let r=[],i=0;for(let e=n.length-1;e>=0&&!(i>=Math.abs(t));e--)n[e].type===`DIGIT`&&(i++,r.push(e));return n=qt(n,r),n.some(e=>e.type===`DIGIT`)?{...e,decimalPart:n}:{...e,decimalPart:void 0,integerPart:[...e.integerPart,...n]}}function Zo(e,t){let n=e.integerPart,r=e.decimalPart;if(!r){let e=n.findLastIndex(e=>e.type===`DIGIT`);r=n.slice(e+1),n=n.slice(0,e+1)}let i=S(0,t).map(()=>({type:`DIGIT`,value:`0`})),a=r.findLastIndex(e=>e.type===`DIGIT`);return r=a===-1?[...i,...r]:Jt(r,i,a+1),{...e,decimalPart:r,integerPart:n}}function Qo(e){let t=to(e);for(let e of[t.positive,t.negative,t.zero])if(e&&e.type===`date`&&e.tokens.some(e=>e.type===`DATE_PART`&&e.value.includes(`q`)))return!1;return!0}function $o(e){if(!e)return!1;try{return to(e).positive.type===`text`}catch{return!1}}function es(e,t,n){return ns({value:$o(t.format)&&e.parsedValue!==null?e.content:e.parsedValue,format:t.format,origin:n},t.locale)}function ts(e,t){if(e.startsWith(`=`))throw Error(`Cannot parse "${e}" because it's not a literal value. It's a formula`);if(e===``)return null;if(e.includes(`
4
+ `)}function Zt(e,t,n){return t>n?Zt(e,n,t):e>=t&&e<=n}function Qt(e,t){let n=ut(e),r=t.matchCase?``:`i`;return t.exactMatch&&(n=`^${n}$`),RegExp(n,r)}function $t(e){let t=e.length;if(t<1e5)return Math.max(...e);let n=-1/0;for(;t--;)n=e[t]>n?e[t]:n;return n}function en(e){let t=e.length;if(t<1e5)return Math.min(...e);let n=1/0;for(;t--;)n=e[t]<n?e[t]:n;return n}var tn=class{text;currentIndex=0;current;constructor(e){this.text=e,this.current=e[0]}shift(){let e=this.current,t=this.text[++this.currentIndex];return this.current=t,e}advanceBy(e){this.currentIndex+=e,this.current=this.text[this.currentIndex]}isOver(){return this.currentIndex>=this.text.length}remaining(){return this.text.substring(this.currentIndex)}currentStartsWith(e){if(this.current!==e[0])return!1;for(let t=1;t<e.length;t++)if(this.text[this.currentIndex+t]!==e[t])return!1;return!0}};function nn(e,t=e=>e){let n=new Set;return e.filter(e=>{let r=t(e);return n.has(r)?!1:(n.add(r),!0)})}function rn(e){let t={};for(let n in e)for(let r in e[n])t[r]||(t[r]={}),t[r][n]=e[n][r];return t}function an(e,t,n={}){let r=n.compute??((e,t)=>`${e} (${t})`),i=n.computeFirstOne??!1,a=n.start??1,o=i?r(e,a):e;for(;t.includes(o);)o=r(e,a++);return o}function on(e){return e.startsWith(`=`)||e.startsWith(`+`)}function sn(e){return{bold:e.bold,italic:e.italic,fontSize:e.fontSize,textColor:e.color,align:e.align}}let cn=/rgba?\(|\s+|\)/gi,ln=/^#([A-F\d]{2}){3,4}$/,un=[`#eb6d00`,`#0074d9`,`#ad8e00`,`#169ed4`,`#b10dc9`,`#00a82d`,`#00a3a3`,`#f012be`,`#3d9970`,`#111111`,`#62A300`,`#ff4136`,`#949494`,`#85144b`,`#001f3f`];function dn(e,t=1){let n=t===1?``:Math.round(t*255).toString(16).padStart(2,`0`);return pn(e.toString(16).padStart(6,`0`))+n}function fn(e){return typeof e==`number`?e:Number.parseInt(pn(e).slice(1,7),16)}function pn(e){let t=e;if(e.startsWith(`rgb`)?t=yn(e):(t=e.replace(`#`,``).toUpperCase(),(t.length===3||t.length===4)&&(t=t.split(``).reduce((e,t)=>e+t+t,``)),t=`#${t}`),!ln.test(t))throw Error(`invalid color input: ${e}`);return t}function mn(e){try{return pn(e),!0}catch{return!1}}function hn(e){try{return wn(e),!0}catch{return!1}}let gn=e=>e>=0&&e<=255;function _n(e,t,n,r=1){if(!gn(e)||!gn(t)||!gn(n)||r<0||r>1)throw Error(`Invalid RGBA values ${[e,t,n,r]}`);return{a:r,b:n,g:t,r:e}}function vn(e){let{r:t,g:n,b:r}=xn(e);t/=255,n/=255,r/=255;let i=e=>e<=.03928?e/12.92:((e+.055)/1.055)**2.4,a=i(t),o=i(n),s=i(r);return .2126*a+.7152*o+.0722*s}function yn(e){let t=e.replace(cn,``).split(`,`),n=255;if(t.length!==3&&t.length!==4)throw Error(`invalid color`);if(t.length===4){let e=parseFloat(t.pop()||`1`);if(isNaN(e))throw Error(`invalid alpha value`);n=Math.round(e*255)}let r=t.map(e=>parseInt(e,10));return n!==255&&r.push(n),`#`+Mt(r.map(e=>e.toString(16).padStart(2,`0`))).toUpperCase()}function bn(e){let t=e.r.toString(16),n=e.g.toString(16),r=e.b.toString(16),i=Math.round(e.a*255).toString(16);return t.length===1&&(t=`0`+t),n.length===1&&(n=`0`+n),r.length===1&&(r=`0`+r),i.length===1&&(i=`0`+i),i===`ff`&&(i=``),(`#`+t+n+r+i).toUpperCase()}function xn(e){e=pn(e);let t,n,r,i;if(e.length===7)t=parseInt(e[1]+e[2],16),n=parseInt(e[3]+e[4],16),r=parseInt(e[5]+e[6],16),i=255;else if(e.length===9)t=parseInt(e[1]+e[2],16),n=parseInt(e[3]+e[4],16),r=parseInt(e[5]+e[6],16),i=parseInt(e[7]+e[8],16);else throw Error(`Invalid color`);return i=+(i/255).toFixed(3),{a:i,r:t,g:n,b:r}}function Sn(e){e={...e},e.s/=100,e.l/=100;let t=(1-Math.abs(2*e.l-1))*e.s,n=t*(1-Math.abs(e.h/60%2-1)),r=e.l-t/2,i=0,a=0,o=0;return 0<=e.h&&e.h<60?(i=t,a=n,o=0):60<=e.h&&e.h<120?(i=n,a=t,o=0):120<=e.h&&e.h<180?(i=0,a=t,o=n):180<=e.h&&e.h<240?(i=0,a=n,o=t):240<=e.h&&e.h<300?(i=n,a=0,o=t):300<=e.h&&e.h<360&&(i=t,a=0,o=n),i=Math.round((i+r)*255),a=Math.round((a+r)*255),o=Math.round((o+r)*255),{a:e.a,r:i,g:a,b:o}}function Cn(e){let t=e.r/255,n=e.g/255,r=e.b/255,i=Math.min(t,n,r),a=Math.max(t,n,r),o=a-i,s=0,c=0,l=0;return s=o===0?0:a===t?(n-r)/o%6:a===n?(r-t)/o+2:(t-n)/o+4,s=Math.round(s*60),s<0&&(s+=360),l=(a+i)/2,c=o===0?0:o/(1-Math.abs(2*l-1)),c=+(c*100).toFixed(1),l=+(l*100).toFixed(1),{a:e.a,h:s,s:c,l}}function wn(e){return bn(Sn(e))}function Tn(e){return Cn(xn(e))}function En(e,t){let n=xn(t),r=xn(e),i=n.a+r.a*(1-n.a);return bn({r:Math.round((n.r*n.a+r.r*r.a*(1-n.a))/i),g:Math.round((n.g*n.a+r.g*r.a*(1-n.a))/i),b:Math.round((n.b*n.a+r.b*r.a*(1-n.a))/i),a:i})}function Dn(e){return xn(typeof e==`number`?dn(e):e)}function On(e,t,n=0){if(!(mn(e)&&mn(t)))return!1;let r=xn(e),i=xn(t);return r.a===i.a?Math.sqrt(((r.r-i.r)/255)**2+((r.g-i.g)/255)**2+((r.b-i.b)/255)**2)<=n:!1}function kn(e,t){return t===1?pn(e).slice(0,7):bn({...xn(e),a:t})}function An(e,t){let n=Tn(e);return t===1?`#fff`:(n.l=t*(100-n.l)+n.l,wn(n))}function jn(e,t){let n=Tn(e);return t===1?`#000`:(n.s=Math.min(100,t*n.s+n.s),n.l-=t*n.l,wn(n))}function Mn(e){return vn(e)<.6?An(e,.9):jn(e,.75)}let Nn=[`#4EA7F2`,`#EA6175`,`#43C5B1`,`#F4A261`,`#8481DD`,`#FFD86D`],Pn=[`#4EA7F2`,`#3188E6`,`#43C5B1`,`#00A78D`,`#EA6175`,`#CE4257`,`#F4A261`,`#F48935`,`#8481DD`,`#5752D1`,`#FFD86D`,`#FFBC2C`],Fn=[`#4EA7F2`,`#3188E6`,`#056BD9`,`#A76DBC`,`#7F4295`,`#6D2387`,`#EA6175`,`#CE4257`,`#982738`,`#43C5B1`,`#00A78D`,`#0E8270`,`#F4A261`,`#F48935`,`#BE5D10`,`#8481DD`,`#5752D1`,`#3A3580`,`#A4A8B6`,`#7E8290`,`#545B70`,`#FFD86D`,`#FFBC2C`,`#C08A16`],In=`#4EA7F2.#3188E6.#056BD9.#155193.#A76DBC.#7F4295.#6D2387.#4F1565.#EA6175.#CE4257.#982738.#791B29.#43C5B1.#00A78D.#0E8270.#105F53.#F4A261.#F48935.#BE5D10.#7D380D.#8481DD.#5752D1.#3A3580.#26235F.#A4A8B6.#7E8290.#545B70.#3F4250.#FFD86D.#FFBC2C.#C08A16.#936A12`.split(`.`),Ln=[`#4EA7F2`,`#43C5B1`,`#EA6175`,`#F4A261`,`#8481DD`,`#FFD86D`,`#3188E6`,`#00A78D`,`#CE4257`,`#F48935`,`#5752D1`,`#FFBC2C`],Rn=[`#4EA7F2`,`#A76DBC`,`#EA6175`,`#43C5B1`,`#F4A261`,`#8481DD`,`#A4A8B6`,`#FFD86D`,`#3188E6`,`#7F4295`,`#CE4257`,`#00A78D`,`#F48935`,`#5752D1`,`#7E8290`,`#FFBC2C`,`#056BD9`,`#6D2387`,`#982738`,`#0E8270`,`#BE5D10`,`#3A3580`,`#545B70`,`#C08A16`],zn=`#4EA7F2.#A76DBC.#EA6175.#43C5B1.#F4A261.#8481DD.#A4A8B6.#FFD86D.#3188E6.#7F4295.#CE4257.#00A78D.#F48935.#5752D1.#7E8290.#FFBC2C.#056BD9.#6D2387.#982738.#0E8270.#BE5D10.#3A3580.#545B70.#C08A16.#155193.#4F1565.#791B29.#105F53.#7D380D.#26235F.#3F4250.#936A12`.split(`.`);function Bn(e,t){return t[e%t.length]}function Vn(e){return e<=6?Nn:e<=12?Pn:e<=24?Fn:In}function Hn(e){return e<=6?Nn:e<=12?Ln:e<=24?Rn:zn}var Un=class{preferredColors;currentColorIndex=0;palette;constructor(e,t=[]){this.preferredColors=t,this.palette=Vn(e).filter(e=>!t.includes(e))}next(){return this.preferredColors?.[this.currentColorIndex]?this.preferredColors[this.currentColorIndex++]:Bn(this.currentColorIndex++,this.palette)}},Wn=class extends Un{constructor(e,t=[]){super(e,t),this.palette=Hn(e).filter(e=>!t.includes(e))}},Gn=class{availableColors;colors={};constructor(e=12){this.availableColors=new Wn(e)}get(e){return this.colors[e]||(this.colors[e]=this.availableColors.next()),this.colors[e]}};function Kn(e){if(e.length<2)throw Error(`Color scale must have at least 2 points`);let t=[...e.sort((e,t)=>e.value-t.value)],n=[];for(let e=1;e<t.length;e++){let r=Dn(t[e-1].color).a,i=Dn(t[e].color).a,a=fn(t[e-1].color),o=fn(t[e].color);n.push({min:t[e-1].value,max:t[e].value,minColor:a,maxColor:o,minColorAlpha:r,maxColorAlpha:i,colorDiff:qn(t[e-1].value,t[e].value,a,o)})}return e=>{if(e<n[0].min)return dn(n[0].minColor,n[0].minColorAlpha);for(let t of n)if(e>=t.min&&e<=t.max)return dn(Jn(e,t.min,t.minColor,t.colorDiff),t.maxColorAlpha);return dn(n[n.length-1].maxColor,n[n.length-1].maxColorAlpha)}}function qn(e,t,n,r){let i=t-e,a=(n>>16)%256-(r>>16)%256,o=(n>>8)%256-(r>>8)%256,s=n%256-r%256;return[a/i,o/i,s/i]}function Jn(e,t,n,r){let[i,a,o]=r,s=Math.round((n>>16)%256-i*(e-t)),c=Math.round((n>>8)%256-a*(e-t)),l=Math.round(n%256-o*(e-t));return s<<16|c<<8|l}function Yn(e){if(e<0)throw Error(`number must be positive. Got ${e}`);return e<26?String.fromCharCode(65+e):Yn(Math.floor(e/26)-1)+Yn(e%26)}function Xn(e){let t=0,n=e.length;for(let r=0;r<n;r++){let n=Zn(e[r]);t=t*26+n}return t-1}function Zn(e){let t=e.charCodeAt(0);return t>=65&&t<=90?t-64:t-96}function Qn(e){return e>=`A`&&e<=`Z`||e>=`a`&&e<=`z`}function $n(e){return e>=`0`&&e<=`9`}let er=Xn(`ZZZ`);function tr(e){for(;e.current===` `;)e.advanceBy(1)}function nr(e){if(e.current===`$`&&e.advanceBy(1),!e.current||!Qn(e.current))return-1;let t=0;for(;e.current&&Qn(e.current);)t=t*26+Zn(e.shift());return t}function rr(e){if(e.current===`$`&&e.advanceBy(1),!e.current||!$n(e.current))return-1;let t=0;for(;e.current&&$n(e.current);)t=t*10+Number(e.shift());return t}function ir(e){let t=new tn(e);tr(t);let n=nr(t);if(n===-1||!t.current)throw Error(`Invalid cell description: ${e}`);let r=rr(t);tr(t);let i=n-1,a=r-1;if(!t.isOver()||i>er||a>9999998)throw Error(`Invalid cell description: ${e}`);return{col:i,row:a}}function T(e,t,n={colFixed:!1,rowFixed:!1}){return(n.colFixed?`$`:``)+Yn(e)+(n.rowFixed?`$`:``)+String(t+1)}let ar=e=>e,or=()=>!1,sr=ar,cr=or;function lr(e,...t){if(t.length===1&&typeof t[0]==`object`&&!(t[0]instanceof String)){let n=t[0];e=e.replace(/\%\(([^\)]+)\)s/g,(e,t)=>n[t])}else t.length>0&&(e=e.replace(/\%s/g,()=>t.shift()));return e}function ur(e,t=()=>!0){sr=e,cr=t}function dr(){sr===ar&&cr===or&&(cr=()=>!0)}let E=function(e,...t){return cr()?lr(sr(e),...t):new fr(e,t)};var fr=class extends String{values;constructor(e,t){super(e),this.values=t}valueOf(){let e=super.valueOf();return cr()?lr(sr(e),...this.values):lr(e,...this.values)}toString(){return this.valueOf()}};function pr(e){return`sheetId`in e}function mr(e){return`dimension`in e&&`sheetId`in e&&`elements`in e}function hr(e){return`target`in e&&`sheetId`in e}function gr(e){return`ranges`in e}function _r(e){return`col`in e&&`row`in e&&`sheetId`in e}function vr(e){return`sheetId`in e&&`zone`in e}let yr=new Set([`RENAME_SHEET`,`DELETE_SHEET`,`CREATE_SHEET`,`DUPLICATE_SHEET`,`ADD_COLUMNS_ROWS`,`REMOVE_COLUMNS_ROWS`,`UNDO`,`REDO`,`ADD_MERGE`,`REMOVE_MERGE`,`UPDATE_LOCALE`,`ADD_PIVOT`,`UPDATE_PIVOT`,`INSERT_PIVOT`,`RENAME_PIVOT`,`REMOVE_PIVOT`,`DUPLICATE_PIVOT`]),br=new Set([`EVALUATE_CELLS`,`EVALUATE_CHARTS`,`UPDATE_CELL`,`UNHIDE_COLUMNS_ROWS`,`HIDE_COLUMNS_ROWS`,`GROUP_HEADERS`,`UNGROUP_HEADERS`,`FOLD_ALL_HEADER_GROUPS`,`FOLD_HEADER_GROUP`,`FOLD_HEADER_GROUPS_IN_ZONE`,`UNFOLD_ALL_HEADER_GROUPS`,`UNFOLD_HEADER_GROUP`,`UNFOLD_HEADER_GROUPS_IN_ZONE`,`UPDATE_TABLE`,`UPDATE_FILTER`,`UNDO`,`REDO`]),xr=new Set([`MOVE_RANGES`]),Sr=new Set([`EVALUATE_CELLS`,`ADD_CONDITIONAL_FORMAT`,`REMOVE_CONDITIONAL_FORMAT`,`CHANGE_CONDITIONAL_FORMAT_PRIORITY`]),Cr=new Set([`AUTOFILL_CELL`,`SET_BORDER`,`SET_ZONE_BORDERS`,`SET_BORDERS_ON_TARGET`]),wr=new Set([`UNHIDE_COLUMNS_ROWS`,`HIDE_COLUMNS_ROWS`,`GROUP_HEADERS`,`UNGROUP_HEADERS`,`FOLD_ALL_HEADER_GROUPS`,`FOLD_HEADER_GROUP`,`FOLD_HEADER_GROUPS_IN_ZONE`,`UNFOLD_ALL_HEADER_GROUPS`,`UNFOLD_HEADER_GROUP`,`UNFOLD_HEADER_GROUPS_IN_ZONE`,`UPDATE_TABLE`,`UPDATE_FILTER`]),Tr=new Set([`START`,`ACTIVATE_SHEET`,`COPY`,`RESIZE_SHEETVIEW`,`SET_VIEWPORT_OFFSET`,`EVALUATE_CELLS`,`EVALUATE_CHARTS`,`SET_FORMULA_VISIBILITY`,`UPDATE_FILTER`,`UPDATE_CHART`,`UPDATE_CAROUSEL_ACTIVE_ITEM`,`UPDATE_PIVOT`]),Er=new Set(`UPDATE_CELL.UPDATE_CELL_POSITION.CLEAR_CELL.CLEAR_CELLS.DELETE_CONTENT.ADD_COLUMNS_ROWS.REMOVE_COLUMNS_ROWS.RESIZE_COLUMNS_ROWS.HIDE_COLUMNS_ROWS.UNHIDE_COLUMNS_ROWS.SET_GRID_LINES_VISIBILITY.UNFREEZE_COLUMNS.UNFREEZE_ROWS.FREEZE_COLUMNS.FREEZE_ROWS.UNFREEZE_COLUMNS_ROWS.ADD_MERGE.REMOVE_MERGE.CREATE_SHEET.DELETE_SHEET.DUPLICATE_SHEET.MOVE_SHEET.RENAME_SHEET.COLOR_SHEET.HIDE_SHEET.SHOW_SHEET.MOVE_RANGES.ADD_CONDITIONAL_FORMAT.REMOVE_CONDITIONAL_FORMAT.CHANGE_CONDITIONAL_FORMAT_PRIORITY.CREATE_FIGURE.DELETE_FIGURE.UPDATE_FIGURE.CREATE_CAROUSEL.UPDATE_CAROUSEL.SET_FORMATTING.CLEAR_FORMATTING.SET_BORDER.SET_ZONE_BORDERS.SET_BORDERS_ON_TARGET.CREATE_CHART.UPDATE_CHART.DELETE_CHART.CREATE_TABLE.REMOVE_TABLE.UPDATE_TABLE.CREATE_TABLE_STYLE.REMOVE_TABLE_STYLE.CREATE_IMAGE.GROUP_HEADERS.UNGROUP_HEADERS.UNFOLD_HEADER_GROUP.FOLD_HEADER_GROUP.FOLD_ALL_HEADER_GROUPS.UNFOLD_ALL_HEADER_GROUPS.UNFOLD_HEADER_GROUPS_IN_ZONE.FOLD_HEADER_GROUPS_IN_ZONE.ADD_DATA_VALIDATION_RULE.REMOVE_DATA_VALIDATION_RULE.UPDATE_LOCALE.ADD_PIVOT.UPDATE_PIVOT.INSERT_PIVOT.RENAME_PIVOT.REMOVE_PIVOT.DUPLICATE_PIVOT`.split(`.`));function Dr(e){return Er.has(e.type)}function Or(e){return Tr.has(e.type)}var kr=class{reasons;constructor(e=[]){Array.isArray(e)||(e=[e]),e=[...new Set(e)],this.reasons=e.filter(e=>e!==`Success`)}static get Success(){return Ar}get isSuccessful(){return this.reasons.length===0}isCancelledBecause(e){return this.reasons.includes(e)}};let Ar=new kr,jr=function(e){return e.Success=`Success`,e.CancelledForUnknownReason=`CancelledForUnknownReason`,e.WillRemoveExistingMerge=`WillRemoveExistingMerge`,e.CannotMoveTableHeader=`CannotMoveTableHeader`,e.MergeIsDestructive=`MergeIsDestructive`,e.CellIsMerged=`CellIsMerged`,e.InvalidTarget=`InvalidTarget`,e.EmptyUndoStack=`EmptyUndoStack`,e.EmptyRedoStack=`EmptyRedoStack`,e.NotEnoughElements=`NotEnoughElements`,e.NotEnoughSheets=`NotEnoughSheets`,e.MissingSheetName=`MissingSheetName`,e.UnchangedSheetName=`UnchangedSheetName`,e.DuplicatedSheetName=`DuplicatedSheetName`,e.DuplicatedSheetId=`DuplicatedSheetId`,e.ForbiddenCharactersInSheetName=`ForbiddenCharactersInSheetName`,e.WrongSheetMove=`WrongSheetMove`,e.WrongSheetPosition=`WrongSheetPosition`,e.InvalidAnchorZone=`InvalidAnchorZone`,e.SelectionOutOfBound=`SelectionOutOfBound`,e.TargetOutOfSheet=`TargetOutOfSheet`,e.WrongCutSelection=`WrongCutSelection`,e.WrongPasteSelection=`WrongPasteSelection`,e.WrongPasteOption=`WrongPasteOption`,e.WrongFigurePasteOption=`WrongFigurePasteOption`,e.EmptyClipboard=`EmptyClipboard`,e.EmptyRange=`EmptyRange`,e.InvalidRange=`InvalidRange`,e.InvalidZones=`InvalidZones`,e.InvalidSheetId=`InvalidSheetId`,e.InvalidCellId=`InvalidCellId`,e.InvalidFigureId=`InvalidFigureId`,e.InputAlreadyFocused=`InputAlreadyFocused`,e.MaximumRangesReached=`MaximumRangesReached`,e.MinimumRangesReached=`MinimumRangesReached`,e.InvalidChartDefinition=`InvalidChartDefinition`,e.InvalidDataSet=`InvalidDataSet`,e.InvalidLabelRange=`InvalidLabelRange`,e.InvalidScorecardKeyValue=`InvalidScorecardKeyValue`,e.InvalidScorecardBaseline=`InvalidScorecardBaseline`,e.InvalidGaugeDataRange=`InvalidGaugeDataRange`,e.EmptyGaugeRangeMin=`EmptyGaugeRangeMin`,e.GaugeRangeMinNaN=`GaugeRangeMinNaN`,e.EmptyGaugeRangeMax=`EmptyGaugeRangeMax`,e.GaugeRangeMaxNaN=`GaugeRangeMaxNaN`,e.GaugeLowerInflectionPointNaN=`GaugeLowerInflectionPointNaN`,e.GaugeUpperInflectionPointNaN=`GaugeUpperInflectionPointNaN`,e.InvalidAutofillSelection=`InvalidAutofillSelection`,e.MinBiggerThanMax=`MinBiggerThanMax`,e.LowerBiggerThanUpper=`LowerBiggerThanUpper`,e.MidBiggerThanMax=`MidBiggerThanMax`,e.MinBiggerThanMid=`MinBiggerThanMid`,e.FirstArgMissing=`FirstArgMissing`,e.SecondArgMissing=`SecondArgMissing`,e.MinNaN=`MinNaN`,e.MidNaN=`MidNaN`,e.MaxNaN=`MaxNaN`,e.ValueUpperInflectionNaN=`ValueUpperInflectionNaN`,e.ValueLowerInflectionNaN=`ValueLowerInflectionNaN`,e.MinInvalidFormula=`MinInvalidFormula`,e.MidInvalidFormula=`MidInvalidFormula`,e.MaxInvalidFormula=`MaxInvalidFormula`,e.ValueUpperInvalidFormula=`ValueUpperInvalidFormula`,e.ValueLowerInvalidFormula=`ValueLowerInvalidFormula`,e.InvalidSortAnchor=`InvalidSortAnchor`,e.InvalidSortZone=`InvalidSortZone`,e.SortZoneWithArrayFormulas=`SortZoneWithArrayFormulas`,e.WaitingSessionConfirmation=`WaitingSessionConfirmation`,e.MergeOverlap=`MergeOverlap`,e.TooManyHiddenElements=`TooManyHiddenElements`,e.Readonly=`Readonly`,e.InvalidViewportSize=`InvalidViewportSize`,e.InvalidScrollingDirection=`InvalidScrollingDirection`,e.ViewportScrollLimitsReached=`ViewportScrollLimitsReached`,e.FigureDoesNotExist=`FigureDoesNotExist`,e.InvalidConditionalFormatId=`InvalidConditionalFormatId`,e.InvalidConditionalFormatType=`InvalidConditionalFormatType`,e.InvalidCellPopover=`InvalidCellPopover`,e.EmptyTarget=`EmptyTarget`,e.InvalidFreezeQuantity=`InvalidFreezeQuantity`,e.FrozenPaneOverlap=`FrozenPaneOverlap`,e.ValuesNotChanged=`ValuesNotChanged`,e.InvalidFilterZone=`InvalidFilterZone`,e.TableNotFound=`TableNotFound`,e.TableOverlap=`TableOverlap`,e.InvalidTableConfig=`InvalidTableConfig`,e.InvalidTableStyle=`InvalidTableStyle`,e.FilterNotFound=`FilterNotFound`,e.MergeInTable=`MergeInTable`,e.NonContinuousTargets=`NonContinuousTargets`,e.DuplicatedFigureId=`DuplicatedFigureId`,e.InvalidSelectionStep=`InvalidSelectionStep`,e.DuplicatedChartId=`DuplicatedChartId`,e.ChartDoesNotExist=`ChartDoesNotExist`,e.InvalidHeaderIndex=`InvalidHeaderIndex`,e.InvalidQuantity=`InvalidQuantity`,e.MoreThanOneColumnSelected=`MoreThanOneColumnSelected`,e.EmptySplitSeparator=`EmptySplitSeparator`,e.SplitWillOverwriteContent=`SplitWillOverwriteContent`,e.NoSplitSeparatorInSelection=`NoSplitSeparatorInSelection`,e.NoActiveSheet=`NoActiveSheet`,e.InvalidLocale=`InvalidLocale`,e.MoreThanOneRangeSelected=`MoreThanOneRangeSelected`,e.NoColumnsProvided=`NoColumnsProvided`,e.ColumnsNotIncludedInZone=`ColumnsNotIncludedInZone`,e.DuplicatesColumnsSelected=`DuplicatesColumnsSelected`,e.InvalidHeaderGroupStartEnd=`InvalidHeaderGroupStartEnd`,e.HeaderGroupAlreadyExists=`HeaderGroupAlreadyExists`,e.UnknownHeaderGroup=`UnknownHeaderGroup`,e.UnknownDataValidationRule=`UnknownDataValidationRule`,e.UnknownDataValidationCriterionType=`UnknownDataValidationCriterionType`,e.InvalidDataValidationCriterionValue=`InvalidDataValidationCriterionValue`,e.InvalidNumberOfCriterionValues=`InvalidNumberOfCriterionValues`,e.InvalidCopyPasteSelection=`InvalidCopyPasteSelection`,e.NoChanges=`NoChanges`,e.InvalidInputId=`InvalidInputId`,e.SheetIsHidden=`SheetIsHidden`,e.InvalidTableResize=`InvalidTableResize`,e.PivotIdNotFound=`PivotIdNotFound`,e.PivotInError=`PivotInError`,e.EmptyName=`EmptyName`,e.ValueCellIsInvalidFormula=`ValueCellIsInvalidFormula`,e.InvalidDefinition=`InvalidDefinition`,e.InvalidColor=`InvalidColor`,e.InvalidPivotDataSet=`InvalidPivotDataSet`,e.InvalidPivotCustomField=`InvalidPivotCustomField`,e.MissingFigureArguments=`MissingFigureArguments`,e.InvalidCarouselItem=`InvalidCarouselItem`,e}({}),Mr=new Set([`containsText`,`notContainsText`,`isGreaterThan`,`isGreaterOrEqualTo`,`isLessThan`,`isLessOrEqualTo`,`isBetween`,`isNotBetween`,`beginsWithText`,`endsWithText`,`isNotEmpty`,`isEmpty`,`isNotEqual`,`isEqual`,`customFormula`]),Nr=new Set([`containsText`,`notContainsText`,`isEqualText`,`isEmail`,`isLink`,`dateIs`,`dateIsBefore`,`dateIsOnOrBefore`,`dateIsAfter`,`dateIsOnOrAfter`,`dateIsBetween`,`dateIsNotBetween`,`dateIsValid`,`isEqual`,`isNotEqual`,`isGreaterThan`,`isGreaterOrEqualTo`,`isLessThan`,`isLessOrEqualTo`,`isBetween`,`isNotBetween`,`isBoolean`,`isValueInList`,`isValueInRange`,`customFormula`]),Pr=[{name:`English (US)`,code:`en_US`,thousandsSeparator:`,`,decimalSeparator:`.`,weekStart:7,dateFormat:`m/d/yyyy`,timeFormat:`hh:mm:ss a`,formulaArgSeparator:`,`},{name:`French`,code:`fr_FR`,thousandsSeparator:` `,decimalSeparator:`,`,weekStart:1,dateFormat:`dd/mm/yyyy`,timeFormat:`hh:mm:ss`,formulaArgSeparator:`;`}],D=Pr[0],Fr=[`thin`,`medium`,`thick`,`dashed`,`dotted`];function Ir(e){return Array.isArray(e)&&Array.isArray(e[0])}let Lr={Background:0,Highlights:1,Clipboard:2,Chart:4,Autofill:5,Selection:6,Headers:100},Rr=Kt(()=>Object.keys(Lr).sort((e,t)=>Lr[e]-Lr[t]));function zr(e,t){if(Lr[e])throw Error(`Layer ${e} already exists`);Lr[e]=t}let Br=[`containsText`,`notContainsText`,`isEqualText`,`isEmpty`,`isNotEmpty`,`beginsWithText`,`endsWithText`],Vr=[`isEqual`,`isNotEqual`,`isGreaterThan`,`isGreaterOrEqualTo`,`isLessThan`,`isLessOrEqualTo`,`isBetween`,`isNotBetween`,`isEmpty`,`isNotEmpty`],Hr=[`dateIs`,`dateIsBefore`,`dateIsOnOrBefore`,`dateIsAfter`,`dateIsOnOrAfter`,`dateIsBetween`,`dateIsNotBetween`,`isEmpty`,`isNotEmpty`];function Ur(e){return/^https?:\/\//i.test(e)?e:`https://${e}`}let Wr=new g;function Gr(e,t){return e=Ur(e),{url:e,label:t||e,isExternal:!0,isUrlEditable:!0}}Wr.add(`sheet_URL`,{match:e=>Et(e),createLink:(e,t)=>({label:t,url:e,isExternal:!1,isUrlEditable:!1}),urlRepresentation(e,t){let n=Ot(e);return t.tryGetSheetName(n)||E(`Invalid sheet`)},open(e,t){let n=Ot(e);t.model.dispatch(`ACTIVATE_SHEET`,{sheetIdFrom:t.model.getters.getActiveSheetId(),sheetIdTo:n}).isCancelledBecause(`SheetIsHidden`)&&t.notifyUser({type:`warning`,sticky:!1,text:E(`Cannot open the link because the linked sheet is hidden.`)})},sequence:0});let Kr={createLink:Gr,match:e=>St(e),open:e=>window.open(e,`_blank`),urlRepresentation:e=>e,sequence:0};function qr(e){return Wr.getAll().sort((e,t)=>e.sequence-t.sequence).find(t=>t.match(e))||Kr}function Jr(e,t){return qr(e.url).urlRepresentation(e.url,t)}function Yr(e,t,n){qr(e.url).open(e.url,t,n)}function Xr(e){if(typeof e==`string`){if(xt(e)){let{label:t,url:n}=wt(e);return qr(n).createLink(n,t)}else if(St(e))return Gr(e)}}var O=class e{jsDate;constructor(e,t,n,r=0,i=0,a=0){this.jsDate=new Date(Date.UTC(e,t,n,r,i,a,0))}static fromTimestamp(t){let n=new Date(t);return new e(n.getUTCFullYear(),n.getUTCMonth(),n.getUTCDate(),n.getUTCHours(),n.getUTCMinutes(),n.getUTCSeconds())}static now(){let t=new Date;return new e(t.getFullYear(),t.getMonth(),t.getDate(),t.getHours(),t.getMinutes(),t.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()}getQuarter(){return Math.floor(this.getMonth()/3)+1}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()}getIsoWeek(){let e=new Date(this.jsDate.getTime()),t=e.getUTCDay()||7;e.setUTCDate(e.getUTCDate()+4-t);let n=new Date(Date.UTC(e.getUTCFullYear(),0,1));return Math.ceil(((e.getTime()-n.getTime())/864e5+1)/7)}setFullYear(e){return this.jsDate.setUTCFullYear(e)}setMonth(e){return this.jsDate.setUTCMonth(e)}setDate(e){return this.jsDate.setUTCDate(e)}setHours(e){return this.jsDate.setUTCHours(e)}setMinutes(e){return this.jsDate.setUTCMinutes(e)}setSeconds(e){return this.jsDate.setUTCSeconds(e)}};let Zr=new O(1899,11,30),Qr=1440*60*1e3,$r=2e3,ei=O.now().getFullYear(),ti=O.now().getMonth(),ni=O.fromTimestamp(0).getTime()-Zr.getTime(),ri=/^\d{1,2}(\/|-|\s)\d{1,2}((\/|-|\s)\d{1,4})?$/,ii=/^\d{3,4}(\/|-|\s)\d{1,2}(\/|-|\s)\d{1,2}$/,ai=Ut.join(``),oi=RegExp(`\/|-|${Ut.join(`|`)}`),si=RegExp(`^(\\d{1,4})[\/${ai}\-](\\d{1,4})([\/${ai}\-](\\d{1,4}))?$`),ci=/((\d+(:\d+)?(:\d+)?\s*(AM|PM))|(\d+:\d+(:\d+)?))$/;function li(e,t){switch(typeof e){case`number`:return e;case`string`:return ui(e,t)?fi(e,t)?.value:!e||isNaN(Number(e))?void 0:Number(e);default:return}}function ui(e,t){return fi(e,t)!==null}let di=new Map;function fi(e,t){return di.has(t)||di.set(t,new Map),di.get(t).has(e)||di.get(t).set(e,pi(e,t)),di.get(t).get(e)}function pi(e,t){e=e.trim();let n=null,r=e.match(ci);if(r){if(n=xi(r[0]),n===null)return null;e=e.replace(r[0],``).trim()}let i=null,a=mi(e,t);if(a){let t=a.dateString.match(oi)[0];if(i=gi(a,t),i===null)return null;e=e.replace(a.dateString,``).trim()}return e!==``||!(i||n)?null:i&&i.jsDate&&n&&n.jsDate?{value:i.value+n.value,format:i.format+` `+(n.format===`hhhh:mm:ss`?`hh:mm:ss`:n.format),jsDate:new O(i.jsDate.getFullYear()+n.jsDate.getFullYear()-1899,i.jsDate.getMonth()+n.jsDate.getMonth()-11,i.jsDate.getDate()+n.jsDate.getDate()-30,i.jsDate.getHours()+n.jsDate.getHours(),i.jsDate.getMinutes()+n.jsDate.getMinutes(),i.jsDate.getSeconds()+n.jsDate.getSeconds())}:i||n}function mi(e,t){let n=e.match(si);if(!n)return null;let[,r,i,,a]=n;if(r.length>2&&a&&a.length>2)return null;if(r.length>2)return{year:r,month:i,day:a,dateString:e,type:`ymd`};let o=hi(t);return a?a.length>2?o===`mdy`?{month:r,day:i,year:a,dateString:e,type:`mdy`}:{day:r,month:i,year:a,dateString:e,type:`dmy`}:o===`mdy`?{month:r,day:i,year:a,dateString:e,type:`mdy`}:o===`ymd`?{year:r,month:i,day:a,dateString:e,type:`ymd`}:o===`dmy`?{day:r,month:i,year:a,dateString:e,type:`dmy`}:null:i.length>2?{month:r,year:i,day:void 0,dateString:e,type:o}:o===`dmy`?{day:r,month:i,year:a,dateString:e,type:`dmy`}:{month:r,day:i,year:a,dateString:e,type:`mdy`}}function hi(e){switch(e.dateFormat[0]){case`d`:return`dmy`;case`m`:return`mdy`;case`y`:return`ymd`}throw Error(`Invalid date format in locale`)}function gi(e,t){let{year:n,month:r,day:i}=e,a=yi(r),o=bi(i),s=vi(n);if(s===null||a===null||o===null)return null;let c=r?.length===2&&a+1<10||i?.length===2&&o<10,l=n?.length!==2,u=new O(s,a,o);if(u.getMonth()!==a||u.getDate()!==o)return null;let d=u.getTime()-Zr.getTime(),f=_i(e,t,c,l);return{value:Math.round(d/Qr),format:f,jsDate:u}}function _i(e,t,n,r){let i=e.year?r?`yyyy`:`yy`:void 0,a=e.month?n?`mm`:`m`:void 0,o=e.day?n?`dd`:`d`:void 0;switch(e.type){case`mdy`:return[a,o,i].filter(C).join(t);case`ymd`:return[i,a,o].filter(C).join(t);case`dmy`:return[o,a,i].filter(C).join(t)}}function vi(e){if(!e)return ei;let t=Number(e);switch(e.length){case 1:return $r+t;case 2:return $r+($r+t>ei+10?-100:0)+t;case 3:case 4:return t}return null}function yi(e){if(!e)return ti;let t=Number(e);return t>=1&&t<=12?t-1:null}function bi(e){if(!e)return 1;let t=Number(e);return t>=0&&t<=31?t:null}function xi(e){if(e=e.trim(),ci.test(e)){let t=/AM/i.test(e),n=/PM/i.test(e),r=(t||n?e.substring(0,e.length-2).trim():e).split(/:/),i=r.length>=2,a=r.length===3,o=Number(r[0]),s=i?Number(r[1]):0,c=a?Number(r[2]):0,l=a?`hh:mm:ss`:`hh:mm`;if(t||n)l+=` a`;else if(!i)return null;o>=12&&t?o-=12:o<12&&n&&(o+=12),s+=Math.floor(c/60),c%=60,o+=Math.floor(s/60),s%=60,o>=24&&(l=`hhhh:mm:ss`);let u=new O(1899,11,30,o,s,c);return{value:o/24+s/1440+c/86400,format:l,jsDate:u}}return null}function Si(e){let t=Math.trunc(e),n=O.fromTimestamp(t*Qr-ni),r=e-t;r=r<0?1+r:r;let i=Math.round(r*24),a=Math.round((r-i/24)*24*60),o=Math.round((r-i/24-a/24/60)*24*60*60);return n.setHours(i),n.setMinutes(a),n.setSeconds(o),n}function Ci(e){return Math.round(wi(e))}function wi(e){return(e.getTime()-Zr.getTime())/Qr}function Ti(e){return new O(e.getFullYear(),e.getMonth()+1,0).getDate()}function Ei(e){return Ti(e)===e.getDate()}function Di(e,t,n){let r=e.getFullYear(),i=e.getMonth(),a=e.getDate(),o=new O(r,i+t,1);return n&&a===Ti(e)||a>Ti(o)?o.setDate(Ti(o)):o.setDate(a),o}function Oi(e){let t=Math.trunc(e);return t%4==0&&t%100!=0||t%400==0}function ki(e,t,n){if(e===t)return 0;if(e>t){let n=t;t=e,e=n}let r=Si(e),i=Si(t),a=r.getDate(),o=i.getDate(),s=r.getMonth(),c=i.getMonth(),l=r.getFullYear(),u=i.getFullYear(),d=0,f=0;switch(n){case 0:a===31&&(a=30),a===30&&o===31&&(o=30),s===1&&a===(Oi(l)?29:28)&&(a=30,c===1&&o===(Oi(u)?29:28)&&(o=30)),d=l+(s*30+a)/360,f=u+(c*30+o)/360;break;case 1:let n=365,r=l===u,i=l+1===u;if(!r&&!i||!r&&s<c||!r&&s===c&&a<o){let e=0,t=0;for(let n=l;n<=u;n++)e++,t+=Oi(n)?366:365;n=t/e}else r?Oi(l)&&(n=366):(Oi(l)&&s<2&&(n=366),Oi(u)&&(c>1||c===1&&o===29)&&(n=366));d=e/n,f=t/n;break;case 2:d=e/360,f=t/360;break;case 3:d=e/365,f=t/365;break;case 4:a===31&&(a=30),o===31&&(o=30),d=l+(s*30+a)/360,f=u+(c*30+o)/360;break}return f-d}function Ai(e,t){let n=(t.getFullYear()-e.getFullYear())*12+t.getMonth()-e.getMonth();return e.getDate()>t.getDate()?n-1:n}function ji(e,t){let n=e.getTime(),r=t.getTime();return Math.floor((r-n)/Qr)}function Mi(e,t){let n=t.getFullYear()-e.getFullYear(),r=e.getMonth(),i=t.getMonth(),a=e.getDate(),o=t.getDate();return i>r||i===r&&o>=a?n:n-1}function Ni(e,t){return ki(e,t,1)<1}function Pi(e,t){return Math.trunc(e)===Math.trunc(t)}function Fi(e,t,n){return t>n?Fi(e,n,t):(e=Math.trunc(e),t=Math.trunc(t),n=Math.trunc(n),e>=t&&e<=n)}function Ii(e,t){return Math.trunc(e)<Math.trunc(t)}function Li(e,t){return Math.trunc(e)<=Math.trunc(t)}function Ri(e,t){return Math.trunc(e)>Math.trunc(t)}function zi(e,t){return Math.trunc(e)>=Math.trunc(t)}let Bi=Kt(function(e){return e=ut(e),RegExp(`(?:^-?\\d+(?:${e}?\\d*(?:e(\\+|-)?\\d+)?)?|^-?${e}\\d+)(?!\\w|!)`)}),Vi=Kt(function(e){let t=ut(e.decimalSeparator),n=`(?:\\d+(?:${ut(e.thousandsSeparator||``)}\\d{3,})*(?:${t}\\d*)?)`,r=`(?:${t}\\d+)`,i=`(?:\\s*`+n+`|`+r+`)(?:e(?:\\+|-)?\\d+)?(?:\\s*%)?`,a=`^(?:(?:`+[`(?:\\s*-)?(?:\\s*[\\$€])?`+i,`(?:\\s*-)?`+i+`(?:\\s*[\\$€])?`,`(?:\\s*[\\$€])?(?:\\s*-)?`+i].join(`)|(?:`)+`))$`;return new RegExp(a,`i`)});function Hi(e,t){return e?Vi(t).test(e.trim()):!1}let Ui=Kt(function(e){return RegExp(`[\$€${ut(e.thousandsSeparator||``)}]`,`g`)});function Wi(e,t){e=e.replace(Ui(t),``),t.decimalSeparator!==`.`&&(e=e.replace(t.decimalSeparator,`.`));let n=Number(e);return isNaN(n)&&e.includes(`%`)&&(n=Number(e.split(`%`)[0]),!isNaN(n))?n/100:n}function Gi(e,t,n){let r=[...e].sort((e,t)=>e-t),i=(r.length+(n?-1:1))*t;if(n||i--,Number.isInteger(i))return r[i];let a=Math.ceil(i),o=Math.floor(i);return r[a]*(i-o)+r[o]*(a-i)}let k={NotAvailable:`#N/A`,InvalidReference:`#REF`,BadExpression:`#BAD_EXPR`,CircularDependency:`#CYCLE`,UnknownFunction:`#NAME?`,DivisionByZero:`#DIV/0!`,SpilledBlocked:`#SPILL!`,GenericError:`#ERROR`,NullError:`#NULL!`},Ki=new Set(Object.values(k));var A=class{message;value;constructor(e=E(`Error`),t=k.GenericError){this.message=e,this.value=t,this.message=e.toString()}},qi=class extends A{constructor(e=E(`Invalid expression`)){super(e,k.BadExpression)}},Ji=class extends A{constructor(e=E(`Circular reference`)){super(e,k.CircularDependency)}},Yi=class extends A{constructor(e=E(`Invalid reference`)){super(e,k.InvalidReference)}},Xi=class extends A{constructor(e=E(`Data not available`)){super(e,k.NotAvailable)}},Zi=class extends A{constructor(e=E(`Unknown function`)){super(e,k.UnknownFunction)}},Qi=class extends A{errorOriginPosition;constructor(e=E(`Spill range is not empty`),t){super(e,k.SpilledBlocked),this.errorOriginPosition=t}},$i=class extends A{constructor(e=E(`Division by zero`)){super(e,k.DivisionByZero)}};let ea=[`number`,`string`,`boolean`,`undefined`];function ta(e){if(e!==void 0)return Ir(e)?e[0][0]?.format:e.format}function j(e){return typeof e==`string`&&Ki.has(e)}function na(e){return{value:k.NotAvailable,message:E(`Did not find value '%s' in [[FUNCTION_NAME]] evaluation.`,N(e))}}let ra=e=>E(`The function [[FUNCTION_NAME]] expects a number value, but '%s' is a string, and cannot be coerced to a number.`,e),ia=(e,t,n)=>E(`The function [[FUNCTION_NAME]] expects a number value between %s and %s inclusive, but receives %s.`,e.toString(),t.toString(),n.toString()),aa=(e,t)=>E(`The function [[FUNCTION_NAME]] has an argument with value '%s'. It should be one of: %s.`,t,e.map(e=>`'${e}'`).join(`, `));function M(e,t){let n=ma(e);switch(typeof n){case`number`:return n;case`boolean`:return+!!n;case`string`:if(Hi(n,t)||n===``)return Wi(n,t);let e=fi(n,t);if(e)return e.value;throw new A(ra(n));default:return 0}}function oa(e,t){try{return M(e,t)}catch{return}}function sa(e,t){return I(e).map(e=>e.map(e=>{if(typeof e.value!=`number`){let n=``;throw typeof e==`object`?n=E(`Function [[FUNCTION_NAME]] expects number values for %s, but got an empty value.`,t):typeof e==`string`?n=E(`Function [[FUNCTION_NAME]] expects number values for %s, but got a string.`,t):typeof e==`boolean`&&(n=E(`Function [[FUNCTION_NAME]] expects number values for %s, but got a boolean.`,t)),new A(n)}return e.value}))}function ca(e,t){let n=ma(e);if(n===``)throw new A(ra(n));return M(n,t)}function la(e,t){return Math.trunc(M(e,t))}function ua(e,t){return Math.trunc(ca(e,t))}function N(e){let t=ma(e);switch(typeof t){case`string`:return t;case`number`:return t.toString();case`boolean`:return t?`TRUE`:`FALSE`;default:return``}}let da=Kt(function(e){return e.toLowerCase().normalize(`NFD`).replace(/[\u0300-\u036f]/g,``)}),fa=e=>E(`The function [[FUNCTION_NAME]] expects a boolean value, but '%s' is a text, and cannot be coerced to a boolean.`,e);function P(e){let t=ma(e);switch(typeof t){case`boolean`:return t;case`string`:if(t){let e=t.toUpperCase();if(e===`TRUE`)return!0;if(e===`FALSE`)return!1;throw new A(fa(t))}else return!1;case`number`:return!!t;default:return!1}}function pa(e){let t=ma(e);if(t===``)throw new A(fa(t));return P(t)}function F(e,t){return Si(M(ma(e),t))}function ma(e){if(typeof e==`object`&&e&&`value`in e){if(j(e.value))throw e;return e.value}if(j(e))throw new A(``,e);return e}function ha(e,t,n){for(let r of e)if(Ir(r)){let e=r.length,n=r[0].length;for(let i=0;i<n;i++)for(let n=0;n<e;n++)t(r[n][i])}else n(r)}function ga(e,t){ha(e,e=>{if(j(e.value))throw e;t(e)},e=>{if(j(e?.value))throw e;t(e)})}function _a(e,t,n){ha(e,e=>{if(typeof e?.value==`number`&&t(e),j(e?.value))throw e},e=>{t({value:ca(e,n),format:e?.format})})}function va(e,t,n,r,i=`rowFirst`){let a=r;for(let r of e)if(Ir(r)){let e=r.length,n=r[0].length;if(i===`rowFirst`)for(let i=0;i<n;i++)for(let n=0;n<e;n++)a=t(a,r[n][i]);else for(let i=0;i<e;i++)for(let e=0;e<n;e++)a=t(a,r[i][e])}else a=n(a,r);return a}function ya(e,t,n,r=`rowFirst`){return va(e,t,t,n,r)}function ba(e,t,n,r){return va(e,(e,n)=>{let r=n?.value;if(typeof r==`number`)return t(e,r);if(j(r))throw n;return e},(e,n)=>t(e,ca(n,r)),n)}function xa(e,t,n,r){return va(e,(e,n)=>{let i=n?.value;if(i!=null){if(typeof i==`number`)return t(e,i);if(typeof i==`boolean`)return t(e,M(i,r));if(j(i))throw n;return t(e,0)}return e},(e,n)=>t(e,M(n,r)),n)}function Sa(e,t,n){let r=Array(e);for(let i=0;i<e;i++){r[i]=Array(t);for(let e=0;e<t;e++)r[i][e]=n(i,e)}return r}function Ca(e,t){return e.length===0?[]:Sa(e.length,e[0].length,(n,r)=>t(e[n][r]))}function wa(e,t){let n=e.length,r=e[0]?.length??0;for(let i=0;i<n;i++)for(let n=0;n<r;n++)t(e[i][n])}function Ta(e){return e.length?Sa(e[0].length,e.length,(t,n)=>e[n][t]):[]}function Ea(e,t,n=void 0){let r=1,i=1,a=1/0,o=1/0,s;for(let e=0;e<t.length;e++){let c=t[e];if(Ir(c)&&(n===void 0||n[e])){let n=c.length,l=c[0].length;n!==1||l!==1?(s??=Array(t.length),n!==1&&l!==1?(s[e]=`matrix`,r=Math.max(r,n),i=Math.max(i,l),a=Math.min(a,n),o=Math.min(o,l)):n===1?l!==1&&(s[e]=`vertical`,i=Math.max(i,l),o=Math.min(o,l)):(s[e]=`horizontal`,r=Math.max(r,n),a=Math.min(a,n))):t[e]=c[0][0]}}if(r===1&&i===1)return e(...t);let c=Array(t.length),l=[],u=[];for(let e=0;e<t.length;e++){let n=t[e];switch(s?.[e]){case`matrix`:l.push((e,t)=>n[e][t]),u.push(e);break;case`horizontal`:l.push(e=>n[e][0]),u.push(e);break;case`vertical`:l.push((e,t)=>n[0][t]),u.push(e);break;case void 0:c[e]=n;break}}let d=u.length,f;switch(c.length){case 1:f=()=>e(c[0]);break;case 2:f=()=>e(c[0],c[1]);break;case 3:f=()=>e(c[0],c[1],c[2]);break;default:f=()=>e(...c)}let p=Array(r);for(let e=0;e<r;e++){let t=Array(i);p[e]=t;for(let n=0;n<i;n++){if(e>a-1||n>o-1){t[n]=new Xi(E(`Array arguments to [[FUNCTION_NAME]] are of different size.`));continue}for(let t=0;t<d;t++)c[u[t]]=l[t](e,n);let r=f();t[n]=Ir(r)?r[0][0]:r}}return p}function Da(e,t,n){for(let r of e)if(Ir(r)){let e=r.length,n=r[0].length;for(let i=0;i<n;i++)for(let n=0;n<e;n++)if(!t(r[n][i]??void 0))return}else if(!n(r))return}function Oa(e,t){return Da(e,e=>{let n=e?.value;if(typeof n==`boolean`)return t(n);if(typeof n==`number`)return t(!!n);if(j(n))throw e;return!0},e=>e!==void 0&&e.value!==null?t(pa(e)):!0)}function ka(e,t){let n,r,i=e.substring(0,2);return i===`<=`||i===`>=`||i===`<>`?(n=i,r=e.substring(2)):(i=e.substring(0,1),i===`<`||i===`>`||i===`=`?(n=i,r=e.substring(1)):(n=`=`,r=e)),Hi(r,t)||ui(r,t)?r=M(r,t):(r===`TRUE`||r===`FALSE`)&&(r=P(r)),{operator:n,operand:r}}let Aa=Kt(function(e){if(e===`*`)return/.+/;let t=``,n=``;for(let r of e)r===`?`&&n!==`~`?t+=`.`:r===`*`&&n!==`~`?t+=`.*`:((r===`*`||r===`?`)&&(t=t.slice(0,-1)),[`^`,`.`,`[`,`]`,`$`,`(`,`)`,`*`,`+`,`?`,`|`,`{`,`}`,`\\`].includes(r)&&(t+=`\\`),t+=r),n=r;return RegExp(`^`+t+`$`,`i`)});function ja(e=``,t,n){let{operator:r,operand:i}=t;if(i===void 0||e===null||i===null)return!1;if(typeof i==`number`&&r===`=`)return typeof e==`string`&&(Hi(e,n)||ui(e,n))?M(e,n)===i:e===i;if(r===`<>`||r===`=`){let t;return t=typeof e==typeof i?e===``&&i===``?!0:typeof e==`string`&&typeof i==`string`?Aa(i).test(e):e===i:!1,r===`=`?t:!t}if(typeof e==typeof i)switch(r){case`<`:return e<i;case`>`:return e>i;case`<=`:return e<=i;case`>=`:return e>=i}return!1}function Ma(e,t,n,r=!1){let i=e.length;if(i%2==1)throw new A(E(`Function [[FUNCTION_NAME]] expects criteria_range and criterion to be in pairs.`));let a=I(e[0]),o=a.length,s=a[0].length,c=[];for(let t=0;t<i-1;t+=2){let i=I(e[t]);if(i.length!==o||i[0].length!==s)throw new A(E(`Function [[FUNCTION_NAME]] expects criteria_range to have the same dimension`));let a=ka(N(e[t+1]),n);r&&typeof a.operand==`string`&&(a.operand+=`*`),c.push(a)}for(let r=0;r<o;r++)for(let a=0;a<s;a++){let o=!0;for(let t=0;t<i-1;t+=2){let i=I(e[t])[r][a].value,s=c[t/2];if(o=ja(i??void 0,s,n),!o)break}o&&t(r,a)}}function Na(e,t,n,r,i,a){if(t===void 0||t.value===null)return-1;if(j(t.value))throw t;let o=Ia(t.value),s=typeof o,c,l,u=0,d=i-1,f,p,m,h,g=r===`desc`?t=>Ia(a(e,i-t-1)):t=>Ia(a(e,t));for(;d-u>=0;){for(f=Math.floor((u+d)/2),p=f,m=g(p),h=typeof m;u<p&&s!==h;)p--,m=g(p),h=typeof m;if(h!==s||m==null){u=f+1;continue}n===`strict`&&m===o?(c=m,l=p):n===`nextSmaller`&&m<=o?(c==null||c<m||c===m&&l<p)&&(c=m,l=p):n===`nextGreater`&&m>=o&&(c===void 0||c>m||c===m&&l<p)&&(c=m,l=p),m>o||n===`strict`&&m===o?d=p-1:u=f+1}return l===void 0?-1:r===`desc`?i-l-1:l}function Pa(e,t,n,r,i,a,o=!1){if(t===void 0||t.value===null)return-1;if(j(t.value))throw t;let s=Ia(t.value),c=o?(e,t)=>Ia(i(e,r-t-1)):(e,t)=>Ia(i(e,t)),l=n!==`wildcard`||typeof s!=`string`||!(s.includes(`*`)||s.includes(`?`));if(a&&l){let t=o?`reverseSearch`:`forwardSearch`,i=a[t].get(e);if(i===void 0){i=new Map;for(let t=0;t<r;t++){let n=c(e,t)??null;i.has(n)||i.set(n,t)}a[t].set(e,i)}if(i.has(s)){let e=i.get(s);return o?r-e-1:e}if(n===`strict`||n===`wildcard`)return-1}let u=Fa(e,s,n,r,c);return o&&u!==-1?r-u-1:u}function Fa(e,t,n,r,i){let a=n=>i(e,n)===t;if(n===`wildcard`&&typeof t==`string`&&(t.includes(`*`)||t.includes(`?`))){let n=Aa(t);a=t=>{let r=i(e,t);return typeof r==`string`?n.test(r):!1}}let o,s=-1;n===`nextSmaller`&&(a=n=>{let r=i(e,n);return(!o&&La(t,r)>=0||La(t,r)>=0&&La(r,o)>0)&&(o=r,s=n),r===t}),n===`nextGreater`&&(a=n=>{let r=i(e,n);return(!o&&La(t,r)<=0||La(t,r)<=0&&La(r,o)<0)&&(o=r,s=n),r===t});for(let e=0;e<r;e++)if(a(e))return e;return s}function Ia(e){return typeof e==`string`?da(e):e}function La(e,t){let n=ea.indexOf(typeof e)-ea.indexOf(typeof t);return n===0&&(typeof e==`string`&&typeof t==`string`?n=e.localeCompare(t):typeof e==`number`&&typeof t==`number`?n=e-t:typeof e==`boolean`&&typeof t==`boolean`&&(n=Number(e)-Number(t))),n}function I(e){return e===void 0?[[]]:Ir(e)?e:[[e]]}function Ra(e,t){return ya(e,(e,n)=>(e.push(t(n)),e),[],`rowFirst`)}function za(e){if(e===void 0)return!1;let{value:t}=e;return!(t===null||t===``)}let Ba=E(`[[FUNCTION_NAME]] has no valid input data.`);function Va(e){return E(`[[FUNCTION_NAME]] expects the provided values of %(argName)s to be a non-empty matrix.`,{argName:e})}function Ha(e){e=e.replace(/\s/g,` `);let t=new tn(e),n=[],r=[];for(n.push(r);!t.isOver();){if(t.current===`;`){r=[],n.push(r),t.shift();continue}let e=Xa(t)||Ua(t)||Ga(t)||Ka(t)||Ja(t)||Ya(t)||Qa(t)||qa(t)||$a(t);if(!e)throw Error(`Unknown token at `+t.remaining());r.push(e)}return n}function Ua(e){let t;if(e.current===`"`?(e.shift(),t=`"`):e.currentStartsWith(`[$`)&&(e.advanceBy(2),t=`]`),!t)return null;let n=``;for(;e.current&&e.current!==t;)n+=e.shift();if(e.current===t)e.shift();else throw Error(`Unterminated string in format`);return{type:`STRING`,value:n}}let Wa=new Set(`$+-/():!^&~{}<>= `);function Ga(e){if(e.current===`\\`){e.shift();let t=e.shift();if(!t)throw Error(`Unexpected end of format string`);return{type:`CHAR`,value:t}}return Wa.has(e.current)?{type:`CHAR`,value:e.shift()}:null}function Ka(e){return e.current===`,`?(e.shift(),{type:`THOUSANDS_SEPARATOR`,value:`,`}):null}function qa(e){return e.current===`@`?(e.shift(),{type:`TEXT_PLACEHOLDER`,value:`@`}):null}function Ja(e){return e.current===`.`?(e.shift(),{type:`DECIMAL_POINT`,value:`.`}):null}function Ya(e){return e.current===`%`?(e.shift(),{type:`PERCENT`,value:`%`}):null}function Xa(e){if(e.current===`0`||e.current===`#`){let t=e.current;return e.shift(),{type:`DIGIT`,value:t}}return null}let Za=new Set(`dmqyhsa`);function Qa(e){if(!Za.has(e.current))return null;let t=e.current,n=``;for(;e.current===t;)n+=e.shift();return{type:`DATE_PART`,value:n}}function $a(e){if(e.current!==`*`)return null;e.shift();let t=e.shift();if(!t)throw Error(`Unexpected end of format string`);return{type:`REPEATED_CHAR`,value:t}}let eo={};function to(e){let t=eo[e];return t===void 0&&(t=no(e),eo[e]=t),t}function no(e){let t=Ha(e);for(let e of t){let t=e.filter(e=>e.type===`REPEATED_CHAR`);for(let e of t.slice(1))e.type=`CHAR`}let n=so(t[0])||oo(t[0])||co(t[0]);if(!n)throw Error(`Invalid first format part of: `+e);if(t.length>1&&n.type===`text`)throw Error(`The first format in a multi-part format must be a number format: `+e);let r=so(t[1])||oo(t[1]);if(t[1]?.length&&!r)throw Error(`Invalid second format part of: `+e);let i=so(t[2])||oo(t[2]);if(t[2]?.length&&!i)throw Error(`Invalid third format part of: `+e);let a=co(t[3]);if(t[3]?.length&&!a)throw Error(`Invalid fourth format part of: `+e);return{positive:n,negative:r,zero:i,text:a}}function ro(e){return e.every(e=>e.type===`DATE_PART`||e.type===`DECIMAL_POINT`||e.type===`THOUSANDS_SEPARATOR`||e.type===`STRING`||e.type===`CHAR`||e.type===`REPEATED_CHAR`)}function io(e){return e.every(e=>e.type===`DIGIT`||e.type===`DECIMAL_POINT`||e.type===`THOUSANDS_SEPARATOR`||e.type===`PERCENT`||e.type===`STRING`||e.type===`CHAR`||e.type===`REPEATED_CHAR`)}function ao(e){return e.every(e=>e.type===`STRING`||e.type===`TEXT_PLACEHOLDER`||e.type===`CHAR`||e.type===`REPEATED_CHAR`)}function oo(e){if(!e||!io(e))return;let t=[],n,r=t,i=0,a=0,o=e.findLastIndex(e=>e.type===`DIGIT`),s=!1,c=0;for(let l=0;l<e.length;l++){let u=e[l];switch(u.type){case`DIGIT`:r===t?r.push(u):c<20&&(r.push(u),c++);break;case`DECIMAL_POINT`:if(r===t)n=[],r=n;else throw Error(`Multiple decimal points in a number format`);break;case`REPEATED_CHAR`:case`CHAR`:case`STRING`:r.push(u);break;case`PERCENT`:i++,r.push(u);break;case`THOUSANDS_SEPARATOR`:l-1===o?(a+=1,o++,r.push(u)):e[l+1]?.type===`DIGIT`&&e[l-1]?.type===`DIGIT`?(r===t&&(s=!0),r.push(u)):r.push({type:`CHAR`,value:`,`});break}}return{type:`number`,integerPart:t,decimalPart:n,percentSymbols:i,thousandsSeparator:s,magnitude:a}}function so(e){let t=e&&ro(e)?{type:`date`,tokens:e}:void 0;if(t){if(t.tokens.length&&t.tokens.every(e=>e.type===`DATE_PART`&&e.value===`a`))throw Error(`Invalid date format`);return{type:`date`,tokens:lo(t.tokens.map(e=>e.type===`THOUSANDS_SEPARATOR`||e.type===`DECIMAL_POINT`?{type:`CHAR`,value:e.value}:e))}}}function co(e){return e&&ao(e)?{type:`text`,tokens:e}:void 0}function lo(e){let t=e.filter(e=>e.type===`DATE_PART`);for(let e=0;e<t.length;e++)!t[e].value.startsWith(`m`)||t[e].value.length>2||(t[e-1]?.value.startsWith(`h`)||t[e+1]?.value.startsWith(`s`))&&(t[e].value=t[e].value.replaceAll(`m`,`M`));return e}function uo(e){return[fo(e.positive),fo(e.negative),fo(e.zero),fo(e.text)].filter(C).join(`;`)}function fo(e){if(!e)return;let t=``,n=e.type===`number`?po(e):e.tokens;for(let e of n)switch(e.type){case`STRING`:t+=`[$${e.value}]`;break;case`CHAR`:t+=mo(e.value)?`\\${e.value}`:e.value;break;case`REPEATED_CHAR`:t+=`*`+e.value;break;case`DATE_PART`:t+=e.value===`MM`?`mm`:e.value;break;default:t+=e.value}return t}function po(e){let t=[...e.integerPart];return e.decimalPart&&(t.push({type:`DECIMAL_POINT`,value:`.`}),t.push(...e.decimalPart)),t}function mo(e){return!Wa.has(e)}let ho=`REPEATED_CHAR_PLACEHOLDER_`,go={0:E(`January`),1:E(`February`),2:E(`March`),3:E(`April`),4:E(`May`),5:E(`June`),6:E(`July`),7:E(`August`),8:E(`September`),9:E(`October`),10:E(`November`),11:E(`December`)},_o={0:E(`Sunday`),1:E(`Monday`),2:E(`Tuesday`),3:E(`Wednesday`),4:E(`Thursday`),5:E(`Friday`),6:E(`Saturday`)};function vo(e,t,n,r=!1){return r?Wo({value:e,format:t},n):L(e,{format:t,locale:n})}function L(e,{format:t,locale:n,formatWidth:r}){switch(typeof e==`boolean`&&(e=e?`TRUE`:`FALSE`),typeof e){case`string`:{if(e.includes(`\\"`)&&(e=e.replaceAll(/\\"/g,`"`)),!t)return e;let n=to(t),i=n.text||n.positive;return!i||i.type!==`text`?e:yo(e,i,r)}case`number`:t||=Fo(e);let i=to(t);if(i.positive.type===`text`)return yo(e.toString(),i.positive,r);let a=i.positive;if(e<0&&i.negative?(a=i.negative,e=-e):e===0&&i.zero&&(a=i.zero),a.type===`date`)return bo(Mo(e,a),r);let o=e<0,s=bo(xo(Math.abs(e),a,n),r);return o?`-`+s:s;case`object`:return``}}function yo(e,t,n){let r=``;for(let n of t.tokens)switch(n.type){case`TEXT_PLACEHOLDER`:r+=e;break;case`CHAR`:case`STRING`:r+=n.value;break;case`REPEATED_CHAR`:r+=ho+n.value;break}return bo(r,n)}function bo(e,t){let n=e.indexOf(ho);if(n===-1)return e;let r=e.slice(0,n),i=e.slice(n+26+1),a=e[n+26];function o(){if(!t)return{timesToRepeat:0,padding:``};let e=t.measureText(r+i),n=t.measureText(a),o=t.availableWidth-e;if(o<=0)return{timesToRepeat:0,padding:``};let s=Math.floor(o/n),c=o-s*n,l=t.measureText(` `);return{timesToRepeat:s,padding:` `.repeat(Math.floor(c/l))}}let{timesToRepeat:s,padding:c}=o();return r+a.repeat(s)+c+i}function xo(e,t,n){if(e===1/0)return`∞`+(t.percentSymbols?`%`:``);let r=t.percentSymbols*2-t.magnitude*3;e*=10**r;let i=0;t.decimalPart!==void 0&&(i=t.decimalPart.filter(e=>e.type===`DIGIT`).length);let{integerDigits:a,decimalDigits:o}=To(Math.abs(e),i),s=So(a,t,t.thousandsSeparator?n.thousandsSeparator:void 0);return t.decimalPart!==void 0&&(s+=n.decimalSeparator+Co(o||``,t)),s}function So(e,t,n){let r=t.integerPart;r.some(e=>e.type===`DIGIT`)||(r=[...r,{type:`DIGIT`,value:`#`}]),e===`0`&&(e=``);let i=``,a=r.findIndex(e=>e.type===`DIGIT`),o=e.length-1;function s(t,r){if(r===`0`&&(t||=`0`),!t)return;let a=e.length-1-o;i=n&&a>0&&a%3==0?t+n+i:t+i}for(let t=r.length-1;t>=0;t--){let n=r[t];switch(n.type){case`DIGIT`:let r=e[o];if(s(r,n.value),o--,a===t)for(;o>=0;)s(e[o],`0`),o--;break;case`THOUSANDS_SEPARATOR`:break;case`REPEATED_CHAR`:i=ho+n.value+i;break;default:i=n.value+i;break}}return i}function Co(e,t){if(!t.decimalPart)return``;let n=``,r=0;for(let i of t.decimalPart)switch(i.type){case`DIGIT`:let t=i.value===`#`?e[r]||``:e[r]||`0`;n+=t,r++;break;case`THOUSANDS_SEPARATOR`:break;case`REPEATED_CHAR`:n+=ho+i.value;break;default:n+=i.value;break}return n}let wo=[];function To(e,t=20){let n=e.toString();if(n.includes(`e`))return ko(e,t);if(Number.isInteger(e))return{integerDigits:n,decimalDigits:void 0};let r=n.indexOf(`.`),i=n.substring(0,r),a=n.substring(r+1);if(t===0)return Number(a[0])>=5&&(i=(Number(i)+1).toString()),{integerDigits:i,decimalDigits:void 0};if(a.length>t){let{integerDigits:e,decimalDigits:n}=Oo(a,t);a=n,e!==`0`&&(i=(Number(i)+Number(e)).toString())}return{integerDigits:i,decimalDigits:Eo(a||``)}}function Eo(e){let t=e.length-1;for(;t>=0&&e[t]===`0`;)t--;return e.slice(0,t+1)||void 0}let Do=/^0+/;function Oo(e,t){let n=`0`,r=e,i=e.slice(0,t);if(Number(e[t])<5)return{integerDigits:n,decimalDigits:i};let a=i.match(Do)?.[0]||``,o=(Number(i)+1).toString(),s=i.slice(a.length),c=o.length>s.length;return c&&!a?(n=`1`,r=void 0):r=c?a.slice(0,-1)+o:a+o,{integerDigits:n,decimalDigits:r}}function ko(e,t=20){let n=wo[t];n||(n=new Intl.NumberFormat(`en-US`,{maximumFractionDigits:t,useGrouping:!1}),wo[t]=n);let[r,i]=n.format(e).split(`.`);return{integerDigits:r,decimalDigits:i}}function Ao(e,t){let{integerDigits:n,decimalDigits:r}=To(e,20);return r?n+t+r:n}let jo=Kt(function(e){if(!e)return!1;try{return to(e).positive.type===`date`}catch{return!1}});function Mo(e,t){let n=Si(e);if(isNaN(n.getTime()))return e.toString();let r=t.tokens.some(e=>e.type===`DATE_PART`&&e.value===`a`),i=``;for(let e of t.tokens)switch(e.type){case`DATE_PART`:i+=No(n,e.value,r);break;case`REPEATED_CHAR`:i+=ho+e.value;break;default:i+=e.value;break}return i}function No(e,t,n){switch(t){case`d`:return e.getDate();case`dd`:return e.getDate().toString().padStart(2,`0`);case`ddd`:return _o[e.getDay()].slice(0,3);case`dddd`:return _o[e.getDay()].toString();case`m`:return e.getMonth()+1;case`mm`:return String(e.getMonth()+1).padStart(2,`0`);case`mmm`:return go[e.getMonth()].slice(0,3);case`mmmm`:return go[e.getMonth()].toString();case`mmmmm`:return go[e.getMonth()].slice(0,1);case`qq`:return E(`Q%(quarter)s`,{quarter:e.getQuarter()}).toString();case`qqqq`:return E(`Quarter %(quarter)s`,{quarter:e.getQuarter()}).toString();case`yy`:let r=String(e.getFullYear()).replace(`-`,``).padStart(2,`0`);return r.slice(r.length-2);case`yyyy`:return String(e.getFullYear()).replace(`-`,``).padStart(4,`0`);case`hhhh`:return Math.floor((e.getTime()-Zr.getTime())/(3600*1e3)).toString();case`hh`:let i=e.getHours();return n&&(i=i===0?12:i>12?i-12:i),i.toString().padStart(2,`0`);case`MM`:return e.getMinutes().toString().padStart(2,`0`);case`ss`:return e.getSeconds().toString().padStart(2,`0`);case`a`:return e.getHours()>=12?`PM`:`AM`;default:throw Error(`invalid date format token: ${t}`)}}let Po=Kt(function(e){return RegExp(`[0-9]+${ut(e.decimalSeparator)}[0-9]`)});function Fo(e){let{integerDigits:t,decimalDigits:n}=To(e);if(!n)return`0`;let r=t.replace(`-`,``).length;if(r+2>11)return`0`;let i=11-r-1;return{decimalDigits:n}=To(e,Math.min(i,n.length)),n?`0.`+`0`.repeat(n.length):`0`}function Io(e,t){if(ui(e,t))return fi(e,t).format}function Lo(e){let t=e.includes(`.`)?`0.00`:`0`,n=e.match(/[\$€]/);if(n){let r=e.match(/[\d]/),i=`[$`+n.values().next().value+`]`;return r.index<n.index?`#,##`+t+i:i+`#,##`+t}if(e.includes(`%`))return t+`%`}function Ro(e){let t=e.decimalPlaces??2,n=e.position??`before`,r=e.code??``,i=e.symbol??``,a=`#,##0`+(t?`.`+`0`.repeat(t):``),o=`${r} ${i}`.trim();return n===`after`&&r&&(o=` `+o),Vo(o,n,a)}function zo(e){let t=e.decimalPlaces??2,n=e.position??`before`,r=e.code??``,i=e.symbol??``,a=`#,##0`+(t?`.`+`0`.repeat(t):``),o=`${r} ${i}`.trim();return n===`after`&&r&&(o=` `+o),[Bo(o,n,` ${a} `),Bo(o,n,`(${a})`),Bo(o,n,` - `)].join(`;`)}function Bo(e,t,n){let r=`[$${e}]`;return t===`before`?r+`* `+n:n+`* `+r}function Vo(e,t,n){let r=`[$${e}]`;return t===`before`?r+n:n+r}function Ho(e){let t=to(e);return uo({positive:Uo(t.positive),negative:t.negative?Uo(t.negative):void 0,zero:t.zero?Uo(t.zero):void 0,text:t.text})}function Uo(e){if(e.type!==`number`||!e.decimalPart)return e;let t=e.decimalPart.filter(e=>e.type!==`DIGIT`);return{...e,decimalPart:void 0,integerPart:[...e.integerPart,...t]}}function Wo({value:e,format:t},n){let r=oa(e,n);if(r===void 0)return``;let i=t;if(Math.abs(r)<1e3){let e=r%1!=0;i=!t&&e?`0.####`:t}else i=Go({value:e,format:t},void 0,n);return L(e,{format:i,locale:n})}function Go(e,t,n){let r=0;try{r=Math.abs(M(e?.value,n))}catch{return``}let i=e?.format;if(t!==void 0)switch(t?.value){case`k`:return Ko(i,1,`k`,n);case`m`:return Ko(i,2,`m`,n);case`b`:return Ko(i,3,`b`,n);default:throw new A(E(`The formatting unit should be 'k', 'm' or 'b'.`))}return r<1e5?Ko(i,0,``,n):r<1e8?Ko(i,1,`k`,n):r<1e11?Ko(i,2,`m`,n):Ko(i,3,`b`,n)}function Ko(e,t,n,r){let i=to(e||`#,##0`);return uo({positive:qo(i.positive,t,n),negative:i.negative?qo(i.negative,t,n):void 0,zero:i.zero?qo(i.zero,t,n):void 0,text:i.text})}function qo(e,t,n){if(e.type!==`number`)return e;let r=Uo(e),i={type:`STRING`,value:n},a=[...r.integerPart],o=a.findLastIndex(e=>e.type===`DIGIT`);if(o===-1)throw Error(`Cannot create a large number format from a format with no digit.`);for(;a[o+1]?.type===`THOUSANDS_SEPARATOR`;)a=qt(a,[o+1]);let s=a[o+1];a=s?.type===`STRING`&&[`m`,`k`,`b`].includes(s.value)?Yt(a,i,o+1):Jt(a,[i],o+1),t>0&&(a=Jt(a,Array(t).fill({type:`THOUSANDS_SEPARATOR`,value:`,`}),o+1));let c=r.percentSymbols-a.filter(e=>e.type===`PERCENT`).length;return a.push(...Array(c).fill({type:`PERCENT`,value:`%`})),{...r,integerPart:a,magnitude:t}}function Jo(e,t){let n=to(e);return uo(to(uo({positive:Yo(n.positive,t),negative:n.negative?Yo(n.negative,t):void 0,zero:n.zero?Yo(n.zero,t):void 0,text:n.text})))}function Yo(e,t){return e.type===`number`?t>0?Zo(e,t):Xo(e,Math.abs(t)):e}function Xo(e,t){let n=e.decimalPart;if(!n)return e;let r=[],i=0;for(let e=n.length-1;e>=0&&!(i>=Math.abs(t));e--)n[e].type===`DIGIT`&&(i++,r.push(e));return n=qt(n,r),n.some(e=>e.type===`DIGIT`)?{...e,decimalPart:n}:{...e,decimalPart:void 0,integerPart:[...e.integerPart,...n]}}function Zo(e,t){let n=e.integerPart,r=e.decimalPart;if(!r){let e=n.findLastIndex(e=>e.type===`DIGIT`);r=n.slice(e+1),n=n.slice(0,e+1)}let i=S(0,t).map(()=>({type:`DIGIT`,value:`0`})),a=r.findLastIndex(e=>e.type===`DIGIT`);return r=a===-1?[...i,...r]:Jt(r,i,a+1),{...e,decimalPart:r,integerPart:n}}function Qo(e){let t=to(e);for(let e of[t.positive,t.negative,t.zero])if(e&&e.type===`date`&&e.tokens.some(e=>e.type===`DATE_PART`&&e.value.includes(`q`)))return!1;return!0}function $o(e){if(!e)return!1;try{return to(e).positive.type===`text`}catch{return!1}}function es(e,t,n){return ns({value:$o(t.format)&&e.parsedValue!==null?e.content:e.parsedValue,format:t.format,origin:n},t.locale)}function ts(e,t){if(e.startsWith(`=`))throw Error(`Cannot parse "${e}" because it's not a literal value. It's a formula`);if(e===``)return null;if(e.includes(`
5
5
  `))return e;if(Hi(e,D))return Wi(e,D);let n=fi(e,t);return n?n.value:vt(e)?e.toUpperCase()===`TRUE`:e}function ns(e,t=D,n,r){let i=Xr(e.value);if(!i)return us(rs(e,t,n),e.origin??r);let a=ts(i.label,t);return us({...rs({value:a,format:e.format||(typeof a==`number`?Io(i.label,t)||Lo(i.label):void 0)},t,n),link:i},e.origin??r)}function rs(e,t,n){let{value:r,format:i,message:a,errorOriginPosition:o}=e;i=n?.format||i;let s=L(r,{format:i,locale:t});return j(r)?ls(r,a,o):r===null?os(i):$o(i)?is(N(r),i,s):typeof r==`number`?jo(i||``)?ss(r,i,s):as(r,i,s):typeof r==`boolean`?cs(r,i,s):is(r,i,s)}function is(e,t,n){return{value:e,format:t,formattedValue:n,type:`text`,isAutoSummable:!0,defaultAlign:`left`}}function as(e,t,n){return{value:e||0,format:t,formattedValue:n,type:`number`,isAutoSummable:!0,defaultAlign:`right`}}let os=Kt(function(e){return{value:null,format:e,formattedValue:``,type:`empty`,isAutoSummable:!0,defaultAlign:`left`}});function ss(e,t,n){return{value:e,format:t,formattedValue:n,type:`number`,isAutoSummable:!1,defaultAlign:`right`}}function cs(e,t,n){return{value:e,format:t,formattedValue:n,type:`boolean`,isAutoSummable:!1,defaultAlign:`center`}}function ls(e,t,n){return{value:e,formattedValue:e,message:t,type:`error`,isAutoSummable:!1,defaultAlign:`center`,errorOriginPosition:n}}function us(e,t){return e.value===null||`origin`in e||(e.origin=t),e}function ds(e){let t=O.now();switch(e){case`today`:return Math.floor(wi(t));case`yesterday`:return t.setDate(t.getDate()-1),Math.floor(wi(t));case`tomorrow`:return t.setDate(t.getDate()+1),Math.floor(wi(t));case`lastWeek`:return t.setDate(t.getDate()-6),Math.floor(wi(t));case`lastMonth`:{let e=t.getMonth()===0?11:t.getMonth()-1,n=new O(t.getFullYear(),e,1);return t.getDate()>Ti(n)?t.setDate(1):(t.setDate(t.getDate()+1),t.setMonth(t.getMonth()-1)),Math.floor(wi(t))}case`lastYear`:return t.getMonth()===1&&t.getDate()===29?(t.setDate(28),t.setFullYear(t.getFullYear()-1)):(t.setDate(t.getDate()+1),t.setFullYear(t.getFullYear()-1)),Math.floor(wi(t))}}function fs(e,t){return`dateValue`in e&&e.dateValue!==`exactDate`?[ds(e.dateValue)]:e.values.map(e=>li(e,t))}function ps(e,t){return e.map(e=>{if(e.startsWith(`=`))return e;let n=ts(e,t);return typeof n==`number`?L(n,{format:t.dateFormat,locale:t}):``})}function ms(e,t=[]){if(e.length<=1&&t.length===0)return e;let n=[0],r=new Map([[0,[]]]);return hs(n,r,e,!1),hs(n,r,t,!0),bs(n,r)}function hs(e,t,n,r=!1){for(let i of n){let n=i.left,a=i.right===void 0?void 0:i.right+1,o=_s(e,t,n,!0,0),s=_s(e,t,a,!1,o);for(let n=o;n<=s;n++)vs(t.get(e[n]),i,r);ys(e,t,o,s)}}function gs(e,t,n){let r=n.left,i=n.right,a=xs(e,r,0),o=i===void 0?e.length-1:xs(e,i,a),s=n.top,c=n.bottom===void 0?void 0:n.bottom+1;for(let n=a;n<=o;n++){let r=t.get(e[n]),i=xs(r,s,0);if(i===-1||i%2!=0)return!1;let a=c===void 0?r.length:Ss(r,c,0);if(i+1!==a)return!1}return!0}function _s(e,t,n,r,i){if(n===void 0)return e.length-1;let a=xs(e,n,i);return n===e[a]?r?a:a-1:(e.splice(a+1,0,n),t.set(n,[...t.get(e[a])]),r?a+1:a)}function vs(e,t,n=!1){let r=t.top,i=t.bottom===void 0?void 0:t.bottom+1,a=[],o=xs(e,r,0,!1);if((o%2!=0&&!n||o%2==0&&n)&&a.push(r),i===void 0){e.splice(o+1),e.push(...a);return}let s=Ss(e,i,0,!1);(s%2==0&&!n||s%2!=0&&n)&&a.push(i);let c=s-o-1,l=a.length,u=o+1;u===e.length-1&&c===1&&l===1?e[u]=a[0]??a[1]:e.splice(u,c,...a)}function ys(e,t,n,r){let i=n-1==-1?0:n-1,a=r===e.length-1?r:r+1;for(let n=a;n>i;n--)Lt(t.get(e[n]),t.get(e[n-1]))&&(t.delete(e[n]),e.splice(n,1))}function bs(e,t){let n=[],r=[];for(let i=0;i<e.length;i++){let a=e[i],o=t.get(a);if(!o||o.length===0){n.push(...r),r=[];continue}let s=e[i+1];s!==void 0&&s--;let c=[];for(let e=0;e<o.length;e+=2){let t=o[e],n=o[e+1];n!==void 0&&n--;let i={top:t,left:a,bottom:n,right:s};(n===void 0&&t!==0||s===void 0&&a!==0)&&(i.hasHeader=!0);let l=!1;for(let e=r.length-1;e>=0;e--){let t=r[e];if(t.top===i.top&&t.bottom===i.bottom){t.right=i.right,r.splice(e,1),c.push(t),l=!0;break}}l||c.push(i)}n.push(...r),r=c}return n.push(...r),n}function xs(e,t,n=0,r=!0){let i=e.length-1,a=-1;for(;n<=i;){let o=n+(i-n>>1);if(e[o]===t&&r)return o;e[o]<t?(a=o,n=o+1):i=o-1}return a}function Ss(e,t,n=0,r=!0){let i=e.length-1,a=e.length;for(;n<=i;){let o=n+(i-n>>1);if(e[o]===t&&r)return o;e[o]>t?(a=o,i=o-1):n=o+1}return a}function Cs(e){let t=new tn(e);tr(t);let n=e.indexOf(`!`);n!==-1&&t.advanceBy(n+1);let r=nr(t),i=rr(t),a,o,s,c,l=!1,u=!1,d=!1;if(i===-1?(s=c=r-1,a=o=0,l=!0):r===-1?(a=o=i-1,s=c=0,u=!0):(s=c=r-1,a=o=i-1,d=!0),tr(t),t.current===`:`){t.advanceBy(1),tr(t);let e=nr(t),n=rr(t);n===-1?(c=e-1,l=!0):e===-1?(o=n-1,u=!0):(c=e-1,o=n-1,a=l?o:a,s=u?c:s,d=!0)}let f={top:a,left:s,bottom:l?void 0:o,right:u?void 0:c};return d&&=u||l,d&&(f.hasHeader=d),f}function ws(e){let t=Js(Cs(e)),n=t.bottom,r=t.right;if(n!==void 0&&n>9999998||r!==void 0&&r>er)throw Error(`Range string out of bounds: ${e}`);if(n===void 0&&r===void 0)throw Error(`Wrong zone xc. The zone cannot be at the same time a full column and a full row`);return t}function Ts(e){let t=ws(e);if(t.bottom===void 0||t.right===void 0)throw Error(`This does not support unbounded ranges`);return t}function Es(e){return Os(ws(e))}function Ds(e){try{return Es(e)}catch{return!1}}function Os(e){let{bottom:t,top:n,left:r,right:i}=e;return t!==void 0&&isNaN(t)||isNaN(n)||isNaN(r)||i!==void 0&&isNaN(i)?!1:ks(e)&&e.top>=0&&e.left>=0}function ks(e){return(e.bottom===void 0||e.bottom>=e.top&&e.bottom>=0)&&(e.right===void 0||e.right>=e.left&&e.right>=0)}function As(e){let{top:t,bottom:n,left:r,right:i}=e,a=`hasHeader`in e?e.hasHeader:!1,o=t===n&&r===i;if(n===void 0&&i!==void 0)return t===0&&!a?`${Yn(r)}:${Yn(i)}`:`${T(r,t)}:${Yn(i)}`;if(i===void 0&&n!==void 0)return r===0&&!a?`${t+1}:${n+1}`:`${T(r,t)}:${n+1}`;if(n!==void 0&&i!==void 0)return o?T(r,t):`${T(r,t)}:${T(i,n)}`;throw Error(`Bad zone format`)}function js(e,t,n,r,i){let a=t===`left`?`columns`:`rows`,o=r===`before`?n-1:n,s=e[t===`left`?`right`:`bottom`];return e[t]<=o&&s&&s>o?Ys(e,a,`RESIZE`,i):o<e[t]?Ys(e,a,`MOVE`,i):{...e}}function Ms(e,t,n,r,i){let a=t===`left`?`columns`:`rows`,o=r===`before`?n-1:n,s=t===`left`?`right`:`bottom`;return e[t]<=o&&e[s]>o?Ys(e,a,`RESIZE`,i):o<e[t]?Ys(e,a,`MOVE`,i):{...e}}function Ns(e,t,n){let r=t===`left`?`right`:`bottom`,i=e[t],a=e[r];for(let o of n.sort((e,t)=>t-e))e[t]>o&&(i--,a--),e[t]<o&&e[r]>=o&&a--;return{...e,[t]:i,[r]:a}}function Ps(e,t,n){let r=t===`left`?`right`:`bottom`,i=e[t],a=e[r],o=e[r];for(let r of n.sort((e,t)=>t-e))e[t]>r&&(i--,a!==void 0&&a--),o!==void 0&&a!==void 0&&e[t]<=r&&o>=r&&a--;if(!(a!==void 0&&i>a))return{...e,[t]:i,[r]:a}}function Fs(...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 Is(...e){return{top:Math.min(...e.map(e=>e.top)),left:Math.min(...e.map(e=>e.left)),bottom:e.some(e=>e.bottom===void 0)?void 0:Math.max(...e.map(e=>e.bottom)),right:e.some(e=>e.right===void 0)?void 0:Math.max(...e.map(e=>e.right))}}function Ls(e,t){if(zs(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 Rs(e,t){return e.left===t.left&&e.right===t.right&&e.top===t.top&&e.bottom===t.bottom}function zs(e,t){return!(e.bottom<t.top||t.bottom<e.top||e.right<t.left||t.right<e.left)}function Bs(e){for(let t=0;t<e.length-1;t++)for(let n=t+1;n<e.length;n++)if(zs(e[t],e[n]))return!0;return!1}function Vs(e,t,n){let{left:r,right:i,top:a,bottom:o}=n;return e>=r&&e<=i&&t>=a&&t<=o}function Hs(e,t){return e.left>=t.left&&e.right<=t.right&&e.top>=t.top&&e.bottom<=t.bottom}function Us(e){return{numberOfRows:e.bottom-e.top+1,numberOfCols:e.right-e.left+1}}function Ws(e){let{numberOfCols:t,numberOfRows:n}=Us(e);return t===1||n===1}function Gs(e){let{top:t,left:n,bottom:r,right:i}=e;if(nc(e)===1)return[];let a={top:t+1,bottom:r,left:n,right:n};if(i===n)return[a];let o={top:t,bottom:r,left:n+1,right:i};return t===r?[o]:[a,o]}function Ks(e){let t=[],{left:n,right:r,top:i,bottom:a}=Js(e);for(let e of S(n,r+1))for(let n of S(i,a+1))t.push({col:e,row:n});return t}function qs(e,t){let n=[],{left:r,right:i,top:a,bottom:o}=Js(t);for(let t of S(r,i+1))for(let r of S(a,o+1))n.push({sheetId:e,col:t,row:r});return n}function Js(e){return e.right!==void 0&&e.left>e.right&&(e={...e,left:e.right,right:e.left}),e.bottom!==void 0&&e.top>e.bottom&&(e={...e,top:e.bottom,bottom:e.top}),e}function Ys(e,t,n,r){let i=t===`both`?r[0]:t===`columns`?r:0,a=t===`both`?r[1]:t===`rows`?r:0,o=`hasHeader`in e?e.hasHeader:!1,s;s=tc(e)&&!o?t!==`rows`:ec(e)&&!o?t!==`columns`:!0;let c={...e};return s&&n===`MOVE`&&(c.left+=i,c.top+=a),c.right!==void 0&&(c.right+=i),c.bottom!==void 0&&(c.bottom+=a),c}function Xs(e){return e.reverse().filter((e,t,n)=>t===n.findIndex(t=>t.top===e.top&&t.bottom===e.bottom&&t.left===e.left&&t.right===e.right)).reverse()}function Zs(e){return e.reduce((e,t)=>{let n=e.length;for(let r=0;r<n;r++)if(zs(e[r],t))return e[r]=Fs(e[r],t),e;return e[n]=t,e},[])}function Qs(e,t){let n,r,{left:i,right:a,top:o,bottom:s}=e,{left:c,right:l,top:u,bottom:d}=t;return n=c===i?l===a?c:l:c,r=u===o?d===s?u:d:u,{col:n,row:r}}function R(e){return{left:e.col,right:e.col,top:e.row,bottom:e.row}}function $s(e){return{...e,right:e.left,bottom:e.top}}function ec(e){return e.right===void 0}function tc(e){return e.bottom===void 0}function nc(e){return(e.bottom-e.top+1)*(e.right-e.left+1)}function rc(e,t,n){return e.left<t&&t<=e.right||e.top<n&&n<=e.bottom}function ic(e,t,n){return e.some(e=>rc(e,t,n))}function ac(e,t){let{left:n,top:r,bottom:i,right:a}=e;if(a!==void 0&&i!==void 0)return e;if(i===void 0&&a!==void 0)return{right:a,top:r,left:n,bottom:t.numberOfRows-1};if(a===void 0&&i!==void 0)return{bottom:i,left:n,top:r,right:t.numberOfCols-1};throw Error(`Bad zone format`)}function oc(e){return e.length<2?!0:ms(e).length===1}function sc(e){let t=new Set;for(let n of ms(e))for(let e of S(n.left,n.right+1))t.add(e);return t}function cc(e){let t=new Map;for(let n of e)for(let e=n.left;e<=n.right;e++){let r=t.get(e);r?(r.top=Math.min(r.top,n.top),r.bottom=Math.max(r.bottom,n.bottom)):t.set(e,{left:e,right:e,top:n.top,bottom:n.bottom})}return Array.from(t.values())}function lc(e){let t=new Set;for(let n of ms(e))for(let e of S(n.top,n.bottom+1))t.add(e);return t}function uc(e,t){return e.right+1===t.left||e.left===t.right+1?e.top<=t.bottom&&e.top>=t.top||t.top<=e.bottom&&t.top>=e.top:e.bottom+1===t.top||e.top===t.bottom+1?e.left<=t.right&&e.left>=t.left||t.left<=e.right&&t.left>=e.left:!1}function dc(e){let t=[...e],n=!0;for(;n;){n=!1;for(let e=0;e<t.length;e++){let r=t[e],i=t.findIndex((t,n)=>e!==n&&(uc(t,r)||zs(t,r)));if(i!==-1){t[e]=Fs(t[i],r),t.splice(i,1),n=!0;break}}}return t}let fc=new WeakMap,pc=new WeakMap;function mc(e,t){fc.has(t)||(fc.set(t,new Map),pc.set(t,0));let n=fc.get(t),r=_c(e);if(n.has(r)){let i=n.get(r);return t[i]=e,i}let i=pc.get(t)+1;return n.set(r,i),pc.set(t,i),t[i]=e,i}function hc(e){let t={};for(let n in e){let r=ms(e[n].map(R));for(let e of r)t[As(e)]=Number(n)}return t}function*gc(e,t){for(let n in t){let r=Ts(n),i=t[n];for(let t=r.top;t<=r.bottom;t++)for(let n=r.left;n<=r.right;n++)yield[{sheetId:e,col:n,row:t},i]}}function _c(e){if(e===null)return`null`;if(e===void 0)return`undefined`;if(typeof e!=`object`)return String(e);if(Array.isArray(e)){let t=e.length,n=`[`;for(let r=0;r<t;r++)r>0&&(n+=`,`),n+=_c(e[r]);return n+`]`}let t=Object.keys(e).sort(),n=`{`;for(let r of t)e[r]!==void 0&&(n+=`"${r}":${_c(e[r])},`);return n+=`}`,n}function vc(e){return 20+120*Math.exp(-.035*(e-1))}let yc=new RegExp(/\$?([A-Z]{1,3})\$?([0-9]{1,7})/,`i`),bc=new RegExp(/^\$?([A-Z]{1,3})\$?([0-9]{1,7})$/,`i`),xc=new RegExp(/^\$?([A-Z]{1,3})+$/,`i`),Sc=new RegExp(/^\$?([0-9]{1,7})+$/,`i`),Cc=new RegExp(/^\s*('.+'!|[^']+!)?\$?([A-Z]{1,3})$/,`i`),wc=new RegExp(/^\s*('.+'!|[^']+!)?\$?([0-9]{1,7})$/,`i`),Tc=RegExp(`^\\s*('.+'!|[^']+!)?(`+[yc.source,`(\\$?[A-Z]{1,3})?\\$?[0-9]{1,7}\\s*:\\s*(\\$?[A-Z]{1,3})?\\$?[0-9]{1,7}\\s*`,`\\$?[A-Z]{1,3}(\\$?[0-9]{1,7})?\\s*:\\s*\\$?[A-Z]{1,3}(\\$?[0-9]{1,7})?\\s*`].join(`|`)+`)$`,`i`);function Ec(e){return Cc.test(e)}function Dc(e){return wc.test(e)}function Oc(e){return xc.test(e)}function kc(e){return Sc.test(e)}function Ac(e){return bc.test(e)}function jc(e){if(!e.includes(`!`))return{xc:e};let t=e.split(`!`),n=t.pop();return{sheetName:ft(t.join(`!`))||void 0,xc:n}}function Mc(e,t){return e===void 0?t:`${mt(e)}!${t}`}function Nc(e,t){let n=e.zone,r=ac(n,t(e.sheetId)),i=e.parts;return e.parts.length===1&&nc(r)>1?i=[e.parts[0],e.parts[0]]:e.parts.length===2&&nc(r)===1&&(i=[e.parts[0]]),{unboundedZone:n,zone:r,parts:i,prefixSheet:e.prefixSheet,invalidSheetName:e.invalidSheetName,sheetId:e.sheetId}}function Pc(e,t){let n=e.xc,{xc:r,sheetName:i}=jc(n),a=ws(r);return Nc({zone:a,parts:Hc(r,a),sheetId:e.sheetId,prefixSheet:!!i,invalidSheetName:e.invalidSheetName},t)}function Fc(e){let t={left:-1,top:-1,right:-1,bottom:-1};return{sheetId:``,zone:t,unboundedZone:t,parts:[],invalidXc:e,prefixSheet:!1}}function Ic(e){return tc(e.unboundedZone)}function Lc(e){return ec(e.unboundedZone)}function Rc(e,t,n,r={useBoundedReference:!1,useFixedReference:!1}){if(e.invalidXc)return e.invalidXc;if(e.zone.bottom-e.zone.top<0||e.zone.right-e.zone.left<0||e.zone.left<0||e.zone.top<0)return k.InvalidReference;let i=e.sheetId!==t||e.invalidSheetName||e.prefixSheet,a=``;if(i&&(a=e.invalidSheetName?mt(e.invalidSheetName):mt(n(e.sheetId))),i&&!a)return k.InvalidReference;let o=$c(e,0,r);return e.parts&&e.parts.length===2&&(e.zone.top!==e.zone.bottom||e.zone.left!==e.zone.right||e.parts[0].rowFixed||e.parts[0].colFixed||e.parts[1].rowFixed||e.parts[1].colFixed)&&(o+=`:`,o+=$c(e,1,r)),`${i?a+`!`:``}${o}`}function zc(e,t,n){let r=n.sheetId===e?t:n.sheetId;return{...n,sheetId:r}}function Bc(e,t,n){if(!n)return;let r=e.getRangeFromSheetXC(t,n);return r.invalidSheetName||r.invalidXc?void 0:r}function Vc(e){let t=[];for(let n of e)for(let e of Ks(n.zone))t.push({...e,sheetId:n.sheetId});return t}function Hc(e,t){let n=e.split(`:`).map(e=>{let t=Dc(e);return{colFixed:t?!1:e.startsWith(`$`),rowFixed:t?e.startsWith(`$`):e.includes(`$`,1)}}),r=t.bottom===void 0,i=t.right===void 0;return r&&(n[0].rowFixed=n[0].rowFixed||n[1].rowFixed,n[1].rowFixed=n[0].rowFixed||n[1].rowFixed),i&&(n[0].colFixed=n[0].colFixed||n[1].colFixed,n[1].colFixed=n[0].colFixed||n[1].colFixed),n}function Uc(e){let t={left:e.col,top:e.row,right:e.col,bottom:e.row};return{sheetId:e.sheetId,zone:t}}function Wc(e){if(ks(e.zone))return e;let t={...e.unboundedZone},n={...e.zone},r=e.parts;if(t.right!==void 0&&t.right<t.left){let e=t.right;t.right=t.left,t.left=e,n.right=n.left,n.left=e,r=[{colFixed:r[1]?.colFixed||!1,rowFixed:r[0]?.rowFixed||!1},{colFixed:r[0]?.colFixed||!1,rowFixed:r[1]?.rowFixed||!1}]}if(t.bottom!==void 0&&t.bottom<t.top){let e=t.bottom;t.bottom=t.top,t.top=e,n.bottom=n.top,n.top=e,r=[{colFixed:r[0]?.colFixed||!1,rowFixed:r[1]?.rowFixed||!1},{colFixed:r[1]?.colFixed||!1,rowFixed:r[0]?.rowFixed||!1}]}return{unboundedZone:t,zone:n,parts:r,invalidXc:e.invalidXc,prefixSheet:e.prefixSheet,invalidSheetName:e.invalidSheetName,sheetId:e.sheetId}}function Gc(e){return Kc.get(e.type)?.(e)}let Kc=new class extends g{add(e,t){return super.add(e,t),this}get(e){return this.content[e]}};Kc.add(`REMOVE_COLUMNS_ROWS`,e=>({applyChange:qc(e),sheetId:e.sheetId,sheetName:{old:e.sheetName,current:e.sheetName}})).add(`ADD_COLUMNS_ROWS`,e=>({applyChange:Jc(e),sheetId:e.sheetId,sheetName:{old:e.sheetName,current:e.sheetName}})).add(`DELETE_SHEET`,e=>({applyChange:Yc(e),sheetId:e.sheetId,sheetName:{old:e.sheetName,current:e.sheetName}})).add(`RENAME_SHEET`,e=>({applyChange:Xc(e),sheetId:e.sheetId,sheetName:{old:e.oldName,current:e.newName}})).add(`MOVE_RANGES`,e=>({applyChange:Zc(e),sheetId:e.sheetId,sheetName:{old:e.sheetName,current:e.sheetName}}));function qc(e){let t=e.dimension===`COL`?`left`:`top`,n=e.dimension===`COL`?`right`:`bottom`,r=e.dimension===`COL`?`columns`:`rows`,i=[...e.elements];i.sort((e,t)=>t-e);let a=gt(i);return i=>{if(i.sheetId!==e.sheetId)return{changeType:`NONE`,range:i};let o=i,s=`NONE`;for(let e of a){let a=en(e),c=$t(e);if(i.zone[t]<=a&&a<=i.zone[n]){let e=Math.min(i.zone[n],c)-a+1;s=`RESIZE`,o=Qc(o,r,s,-e)}else if(i.zone[t]>=a&&i.zone[n]<=c)s=`REMOVE`,o=Fc(k.InvalidReference);else if(i.zone[t]<=c&&i.zone[n]>=c){let e=c-i.zone[t]+1;s=`RESIZE`,o=Qc(o,r,s,-e),o=Qc(o,r,`MOVE`,-(i.zone[t]-a))}else a<i.zone[t]&&(s=`MOVE`,o=Qc(o,r,s,-(c-a+1)))}return{changeType:s,range:o}}}function Jc(e){let t=e.dimension===`COL`?`left`:`top`,n=e.dimension===`COL`?`right`:`bottom`,r=e.dimension===`COL`?`columns`:`rows`;return i=>{if(i.sheetId!==e.sheetId)return{changeType:`NONE`,range:i};let a=i.unboundedZone[n]===void 0;if(a&&!i.unboundedZone.hasHeader)return{changeType:`RESIZE`,range:Qc(i,r,`RESIZE`,e.quantity)};if(e.position===`after`){if(i.zone[t]<=e.base&&(e.base<i.zone[n]||a))return{changeType:`RESIZE`,range:Qc(i,r,`RESIZE`,e.quantity)};if(e.base<i.zone[t])return{changeType:`MOVE`,range:Qc(i,r,`MOVE`,e.quantity)}}else{if(i.zone[t]<e.base&&e.base<=i.zone[n])return{changeType:`RESIZE`,range:Qc(i,r,`RESIZE`,e.quantity)};if(e.base<=i.zone[t])return{changeType:`MOVE`,range:Qc(i,r,`MOVE`,e.quantity)}}return{changeType:`NONE`,range:i}}}function Yc(e){return t=>{if(t.sheetId!==e.sheetId&&t.invalidSheetName!==e.sheetName)return{changeType:`NONE`,range:t};let n=e.sheetName;return t={...Fc(k.InvalidReference),invalidSheetName:n},{changeType:`REMOVE`,range:t}}}function Xc(e){return t=>{if(t.sheetId===e.sheetId)return{changeType:`CHANGE`,range:t};if(e.newName&&t.invalidSheetName===e.newName){let n=e.sheetId;return{changeType:`CHANGE`,range:{...t,sheetId:n,invalidSheetName:void 0}}}if(e.oldName&&t.invalidSheetName===e.oldName){let n=e.sheetId;return{changeType:`CHANGE`,range:{...t,sheetId:n,invalidSheetName:void 0}}}return{changeType:`NONE`,range:t}}}function Zc(e){let t=e.target[0];return n=>{if(n.sheetId!==e.sheetId||!Hs(n.zone,t))return{changeType:`NONE`,range:n};let r=e.targetSheetId,i=Qc(n,`both`,`MOVE`,[e.col-t.left,e.row-t.top]),a=e.sheetId===r?i.prefixSheet:!0;return{changeType:`MOVE`,range:{...i,sheetId:r,prefixSheet:a}}}}function Qc(e,t,n,r){return{...e,unboundedZone:Ys(e.unboundedZone,t,n,r),zone:Ys(e.zone,t,n,r)}}function $c(e,t,n={useBoundedReference:!1,useFixedReference:!1}){let r=e.parts[t]?.colFixed||n.useFixedReference?`$`:``,i=Yn(t===0?e.zone.left:e.zone.right),a=e.parts[t]?.rowFixed||n.useFixedReference?`$`:``,o=String(t===0?e.zone.top+1:e.zone.bottom+1),s=``;return s=tc(e.unboundedZone)&&!n.useBoundedReference?t===0&&e.unboundedZone.hasHeader?r+i+a+o:r+i:ec(e.unboundedZone)&&!n.useBoundedReference?t===0&&e.unboundedZone.hasHeader?r+i+a+o:a+o:r+i+a+o,s}function el(e,t){e=e.toLocaleLowerCase(),t=t.toLocaleLowerCase();let n=0,r=0,i=t.length,a=0;for(let o=0;o<i;o++)t[o]===e[a]?(a++,r+=100+r-o/200):r=0,n+=r;return a===e.length?n:0}function tl(e,t,n){let r=[];return t.forEach(t=>{let i=el(e,n(t));i>0&&r.push({score:i,elem:t})}),r.sort((e,t)=>t.score-e.score),r.map(e=>e.elem)}function nl(e){let t=[];for(let n=0;n<e;n++)t.push({cells:{}});return t}function rl(e,t,n){return n.map(n=>n>=e?n+t:n)}function il(e,t){return e=[...e].sort((e,t)=>t-e),t.map(t=>{for(let n of e)if(t>n)t--;else if(t===n)return;return t}).filter(C)}function al(e,t=`Sheet`){let n=1,r=`${t}${n}`;for(;e.includes(r);)r=`${t}${n}`,n++;return r}function ol(e,t){let n=1,r=E(`Copy of %s`,e),i=r.toString();for(;t.includes(i);)i=`${r} (${n})`,n++;return i}let sl=Kt(function(e){return ft(e.trim().toUpperCase())});function cl(e,t){return e===void 0||t===void 0?!1:sl(e)===sl(t)}function ll(e,t=1){return t*(e+4)-4}function ul(e,t,n,r){if(!t||!t.isFormula&&!t.content)return 23;let i=``;try{if(!t.isFormula){let e={format:t.format,locale:n};i=L(ts(t.content,n),e)}}catch{i=k.GenericError}return dl(e,i,t.style,r)}function dl(e,t,n,r){let i=Cl(e,t,n,n?.wrapping===`wrap`?r-8:void 0).length;return ll(xl(n),i)+6}function fl(e,t=!1,n=!1){return`${n?`italic`:``} ${t?`bold`:``} ${e}px ${He}`}let pl={};function ml(e,t,n,r=`pt`){return hl(e,t,bl(n,r))}function hl(e,t,n){if(pl[n]||(pl[n]={}),pl[n][t]===void 0){let r=e.font;e.font=n,pl[n][t]=e.measureText(t).width,e.font=r}return pl[n][t]}let gl={};function _l(e,t,n,r=`pt`){let i=bl(n,r);e.save(),e.font=i;let a=vl(e,t);return e.restore(),a}function vl(e,t){let n=e.font;if(gl[n]||(gl[n]={}),gl[n][t]===void 0){let r=e.measureText(t),i=r.width,a=r.fontBoundingBoxAscent+r.fontBoundingBoxDescent;gl[n][t]={width:i,height:a}}return gl[n][t]}function yl(e){return Math.round(e*96/72)}function bl(e,t=`pt`){return`${e.italic?`italic `:``}${e.bold?`bold`:`400`} ${(t===`pt`?xl(e):e.fontSize)??Ve}px ${He}`}function xl(e){return yl(e?.fontSize||Ve)}function Sl(e,t,n,r){if(ml(e,t,r)<=n)return[t];let i=[],a=``;for(let o of t)ml(e,a+o,r)>n?(i.push(a),a=o):a+=o;return i.push(a),i}function Cl(e,t,n,r){n||={},xt(t)&&(t=wt(t).label);let i=[],a=t.includes(`
6
6
  `)?t.split(`
7
7
  `):[t];for(let t of a){let a=t.includes(` `)?t.split(` `):[t];if(!r){i.push(t);continue}let o=``,s=r;for(let t of a){let a=Sl(e,t,r,n),c=a.pop(),l=ml(e,c,n);if(a.length)o!==``&&(i.push(o),o=``,s=r),a.forEach(e=>{i.push(e)}),o=c,s=r-l;else{let t=o===``?c:` `+c,a=ml(e,t,n);a<=s?(o+=t,s-=a):(i.push(o),o=c,s=r-l)}}o!==``&&i.push(o)}return i}function wl(e,t,n,r=.25){let i=1;if(n(i)>e)return i;if(n(t)<e)return t;let a=(i+t)/2,o=n(a),s=0;for(;Math.abs(o-e)>r&&s<20;)o>=e?t=(i+t)/2:i=(i+t)/2,a=(i+t)/2,o=n(a),s++;return a}function Tl(e){return e?e.toLowerCase():``}let El=/([0-9\.]*)px/;function Dl(e){return Number(e.match(El)?.[1])}function Ol(e,t,n){let r=hl(e,t,e.font);if(r<=n)return t;let i=hl(e,`…`,e.font);if(r<=i)return t;let a=t.length;for(;r>=n-i&&a-->0;)t=t.substring(0,a),r=hl(e,t,e.font);return t+`…`}function kl(e,t,n,r=!1,i=!1,a=Dl(e.font)/10){if(e.fillText(t,n.x,n.y),!r&&!i)return;let o=e.measureText(t),s=o.width,c=o.actualBoundingBoxAscent+o.actualBoundingBoxDescent,l=o.fontBoundingBoxAscent+o.fontBoundingBoxDescent,{x:u,y:d}=n,f=d,p=d;switch(e.textAlign){case`center`:u-=s/2;break;case`right`:u-=s;break}switch(e.textBaseline){case`top`:p+=l-2*a,f+=l/2-a;break;case`middle`:p+=l/2-a;break;case`alphabetic`:p+=2*a,f-=3*a;break;case`bottom`:p=d,f-=c/2-a/2;break}r&&(e.lineWidth=a,e.strokeStyle=e.fillStyle,e.beginPath(),e.moveTo(u,p),e.lineTo(u+s,p),e.stroke()),i&&(e.lineWidth=a,e.strokeStyle=e.fillStyle,e.beginPath(),e.moveTo(u,f),e.lineTo(u+s,f),e.stroke())}function Al(e,t,n,r,i=`pt`){if(ml(e,n,r,i)<=t)return n;let a=ml(e,`...`,r,i);if(a>=t)return``;let o=1,s=n.length,c;for(;o<=s;){let l=Math.floor((o+s)/2);c=ml(e,n.slice(0,l),r,i),c+a>t?s=l-1:o=l+1}let l=n.slice(0,Math.max(0,o-1));return l?l+`...`:``}var jl=class{smallUuid(){return window.crypto?`10000000-1000`.replace(/[01]/g,e=>{let t=Number(e);return(t^crypto.getRandomValues(new Uint8Array(1))[0]&15>>t/4).toString(16)}):`xxxxxxxx-xxxx`.replace(/[xy]/g,function(e){let t=Math.random()*16|0;return(e===`x`?t:t&3|8).toString(16)})}uuidv4(){return window.crypto?`10000000-1000-4000-8000-100000000000`.replace(/[018]/g,e=>{let t=Number(e);return(t^crypto.getRandomValues(new Uint8Array(1))[0]&15>>t/4).toString(16)}):`xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx`.replace(/[xy]/g,function(e){let t=Math.random()*16|0;return(e===`x`?t:t&3|8).toString(16)})}};let Ml=[`image/avif`,`image/bmp`,`image/gif`,`image/vnd.microsoft.icon`,`image/jpeg`,`image/png`,`image/tiff`,`image/webp`];function Nl(e,t){let n=new Set(t.map(e=>e.left)),r=new Set(t.map(e=>e.right)),i=new Set(t.map(e=>e.top)),a=new Set(t.map(e=>e.bottom)),o=i.size===1&&a.size===1||n.size===1&&r.size===1?Zs(t):[t[t.length-1]],s=o.map(e=>Ks(e)).flat();return{sheetId:e,zones:t,clippedZones:o,columnsIndexes:[...new Set(s.map(e=>e.col))].sort((e,t)=>e-t),rowsIndexes:[...new Set(s.map(e=>e.row))].sort((e,t)=>e-t)}}function Pl(e,t,n){let r=Math.max(e.right-t+1,e.left),i=Math.max(e.bottom-n+1,e.top),a=[];for(let o=e.left;o<=r;o+=t)for(let r=e.top;r<=i;r+=n)a.push({left:o,top:r,bottom:r+n-1,right:o+t-1});return a}function Fl(e,t){if(!t.length||!t[0].length)return e;let n=t[0].length,r=t.length;return e.map(e=>Pl(e,n,r)).flat()}function Il(e){let t;e[`text/html`]&&(t=Ll(new DOMParser().parseFromString(e[`text/html`],`text/html`)));let n=e[`text/plain`]||``,r;if(!n.trim()){for(let t of Ml)if(e[t]){r=e[t];break}}return{text:n,data:t,imageBlob:r}}function Ll(e){if([...e.documentElement.attributes].some(e=>e.value.includes(`microsoft`)))return;let t=e.querySelector(`div`)?.getAttribute(`data-osheet-clipboard`);return t&&JSON.parse(t)}let Rl=(e,t,n,r)=>{e.forEach(({handlerName:e,handler:i})=>{let a=t[e];a&&i.paste(n,a,r)})};function zl(e,t,n,r,i){let a,o=[],s={sheetId:e,zones:t};for(let{handlerName:c,handler:l}of r){let r=n[c];if(!r)continue;let u=l.getPasteTarget(e,t,r,i);u.figureId&&(s.figureId=u.figureId);for(let e of u.zones){if(o.push(e),a===void 0){a=e;continue}a=Fs(a,e)}}return{target:s,zone:a,selectedZones:o}}let Bl=(e,t,n)=>{let r={col:t[0].left,row:t[0].top};e.getBackToDefault(),e.selectZone({cell:r,zone:Fs(...n)},{scrollIntoView:!1})};var Vl=class{getters;dispatch;constructor(e,t){this.getters=e,this.dispatch=t}copy(e,t,n=`copyPaste`){}paste(e,t,n){}isPasteAllowed(e,t,n,r){return`Success`}isCutAllowed(e){return`Success`}getPasteTarget(e,t,n,r){return{zones:[],sheetId:e}}convertTextToClipboardData(e){}},Hl=class extends Vl{copy(e,t,n=`copyPaste`){}pasteFromCopy(e,t,n,r){if(t.length===1)for(let i of Fl(t,n))this.pasteZone(e,i.left,i.top,n,r);else for(let i of ms(t))for(let t=i.left;t<=i.right;t++)for(let a=i.top;a<=i.bottom;a++)this.pasteZone(e,t,a,n,r)}pasteZone(e,t,n,r,i){}},Ul=class extends Hl{queuedBordersToAdd={};copy(e){let t=e.sheetId;if(e.zones.length===0)return;let{rowsIndexes:n,columnsIndexes:r}=e,i=[];for(let e of n){let n=[];for(let i of r){let r={col:i,row:e,sheetId:t};n.push(this.getters.getCellBorder(r))}i.push(n)}return{borders:i}}paste(e,t,n){let r=e.sheetId;if(n.pasteOption===`asValue`)return;let i=e.zones;if(!n.isCutOperation)this.pasteFromCopy(r,i,t.borders);else{let{left:e,top:n}=i[0];this.pasteZone(r,e,n,t.borders)}this.executeQueuedChanges(r)}pasteZone(e,t,n,r){for(let[i,a]of r.entries())for(let[r,o]of a.entries()){let a={col:t+r,row:n+i,sheetId:e};this.pasteBorder(o,a)}}pasteBorder(e,t){let n={...this.getters.getCellBorder(t),...e},r=JSON.stringify(n);this.queuedBordersToAdd[r]||(this.queuedBordersToAdd[r]=[]),this.queuedBordersToAdd[r].push(R(t))}executeQueuedChanges(e){for(let t in this.queuedBordersToAdd){let n=this.queuedBordersToAdd[t],r=JSON.parse(t),i=ms(n,[]);this.dispatch(`SET_BORDERS_ON_TARGET`,{sheetId:e,target:i,border:r})}this.queuedBordersToAdd={}}},Wl=class extends Vl{copy(e){}},Gl=class extends Wl{copy(e){let t=e.sheetId,n=this.getters.getFigure(t,e.figureId);if(!n)throw Error(`No figure for the given id: ${e.figureId}`);if(n.tag!==`carousel`)return;let r={...n},i=this.getters.getCarousel(e.figureId),a={};for(let e of i.items)if(e.type===`chart`){let n=this.getters.getChart(e.chartId);if(!n)throw Error(`No chart for the given id: ${e.chartId}`);a[e.chartId]=n.copyInSheetId(t)}return{figureId:e.figureId,copiedFigure:r,copiedCarousel:i,copiedCharts:a,copiedSheetId:t}}getPasteTarget(e){return{zones:[],figureId:new jl().smallUuid(),sheetId:e}}paste(e,t,n){if(!e.figureId)return;let{zones:r,figureId:i}=e,a=e.sheetId,{width:o,height:s}=t.copiedFigure,c=this.getters.getMaxAnchorOffset(a,s,o),{left:l,top:u}=r[0],d={x:0,y:0};l>c.col&&(l=c.col,d.x=c.offset.x),u>c.row&&(u=c.row,d.y=c.offset.y),this.dispatch(`CREATE_CAROUSEL`,{figureId:i,sheetId:a,definition:{items:[]},col:l,row:u,offset:d,size:{height:s,width:o}});let f=new jl,p=b(t.copiedCarousel.items);for(let e of p){if(e.type!==`chart`)continue;let n=t.copiedCharts[e.chartId],r=f.smallUuid(),o=n.copyInSheetId(a).getDefinition();this.dispatch(`CREATE_CHART`,{figureId:i,chartId:r,sheetId:a,definition:o}),e.chartId=r}this.dispatch(`UPDATE_CAROUSEL`,{sheetId:a,figureId:i,definition:{...t.copiedCarousel,items:p}}),n.isCutOperation&&this.dispatch(`DELETE_FIGURE`,{sheetId:t.copiedSheetId,figureId:t.copiedFigure.id}),this.dispatch(`SELECT_FIGURE`,{figureId:i})}isPasteAllowed(e,t,n,r){return t.length===0?`EmptyTarget`:r?.pasteOption===void 0?`Success`:`WrongFigurePasteOption`}};let Kl=[`%`],ql=`+,-,*,/,:,=,<>,>=,>,<=,<,^,&`.split(`,`).concat(Kl);function Jl(e,t=D){e=Wt(e);let n=new tn(e),r=[],i=Vt.test(e)?ou:su;for(;!n.isOver();){let e=cu(n)||i(n)||Ql(n,t)||Zl(n)||$l(n)||nu(n)||Yl(n)||lu(n)||tu(n,t)||au(n);e||={type:`UNKNOWN`,value:n.shift()},r.push(e)}return r}function Yl(e){return e.current===`?`?(e.shift(),{type:`DEBUGGER`,value:`?`}):null}let Xl={"(":{type:`LEFT_PAREN`,value:`(`},")":{type:`RIGHT_PAREN`,value:`)`}};function Zl(e){return e.current===`(`||e.current===`)`?Xl[e.shift()]:null}function Ql(e,t){return e.current===t.formulaArgSeparator?{type:`ARG_SEPARATOR`,value:e.shift()}:null}function $l(e){for(let t of ql)if(e.currentStartsWith(t))return e.advanceBy(t.length),{type:`OPERATOR`,value:t};return null}let eu=new Set(`0123456789`);function tu(e,t){if(!eu.has(e.current)&&e.current!==t.decimalSeparator)return null;let n=e.remaining().match(Bi(t.decimalSeparator));return n?(e.advanceBy(n[0].length),{type:`NUMBER`,value:n[0]}):null}function nu(e){if(e.current===`"`){let t=e.shift(),n=t;for(;e.current&&(e.current!==t||n[n.length-1]===`\\`);)n+=e.shift();return e.current===`"`&&(n+=e.shift()),{type:`STRING`,value:n}}return null}let ru=/\p{L}|\p{N}|_|\.|!|\$/u,iu=new Set(`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_.!$`);function au(e){let t=``;if(e.current===`'`){let n=e.shift();for(t+=n;e.current;)if(n=e.shift(),t+=n,n===`'`)if(e.current&&e.current===`'`)n=e.shift(),t+=n;else break;if(n!==`'`)return{type:`UNKNOWN`,value:t}}for(;e.current&&(iu.has(e.current)||e.current.match(ru));)t+=e.shift();if(t.length){let e=t;return Tc.test(e)?{type:`REFERENCE`,value:e}:{type:`SYMBOL`,value:e}}return null}function ou(e){let t=``;for(;e.current===` `||e.current&&e.current.match(Vt);)t+=e.shift();return t?{type:`SPACE`,value:t}:null}function su(e){let t=``;for(;e.current===` `;)t+=e.shift();return t?{type:`SPACE`,value:t}:null}function cu(e){let t=0;for(;e.current===`
@@ -17,7 +17,7 @@ stores.inject(MyMetaStore, storeInstance);
17
17
  (value for the item) / (value for the parent item on rows)`),"%_of_parent_col_total":E(`Calculates values as follows:
18
18
  (value for the item) / (value for the parent item on columns)`),"%_of_parent_total":E(`Calculates values as follows:
19
19
  (value for the item) / (value for the parent item of the selected Base field)`),difference_from:E(`Displays values as the difference from the value of the Base item in the Base field.`),"%_difference_from":E(`Displays values as the percentage difference from the value of the Base item in the Base field.`),running_total:E(`Displays the value for successive items in the Base field as a running total.`),"%_running_total":E(`Calculates the value as a percentage for successive items in the Base field that are displayed as a running total.`),rank_asc:E(`Displays the rank of selected values in a specific field, listing the smallest item in the field as 1, and each larger value with a higher rank value.`),rank_desc:E(`Displays the rank of selected values in a specific field, listing the largest item in the field as 1, and each smaller value with a higher rank value.`),index:E(`Calculates values as follows:
20
- ((value in cell) x (Grand Total of Grand Totals)) / ((Grand Row Total) x (Grand Column Total))`)}};function Zb(e,t){return E(`Oops—this pivot table is quite large (%s cells). Try simplifying it using the side panel.`,L(e,{format:`0,00`,locale:t}))}function Qb(e,t){let n=t.getPivotId(e);if(!n)throw new A(E(`There is no pivot with id "%s"`,e));return n}function $b(e,t,n){let{measures:r}=n.getPivotCoreDefinition(e);if(!r.find(e=>e.id===t))throw new A(E(`The argument %s is not a valid measure. Here are the measures: %s`,t,`(${r.map(e=>e.id).join(`, `)})`))}function ex(e){if(e.length%2!=0)throw new A(E(`Function PIVOT takes an even number of arguments.`))}function tx(e,t,n){let r=[],i=e.getters.getPivotCoreDefinition(t);if(i.type===`SPREADSHEET`&&i.dataSet){let{sheetId:t,zone:n}=i.dataSet,a=As(n),o=e.getters.getRangeFromSheetXC(t,a);if(o===void 0||o.invalidXc||o.invalidSheetName)throw new Yi;if(e.__originCellPosition&&o.sheetId===e.__originSheetId&&Hs(R(e.__originCellPosition),n))throw new Ji;r.push(o)}for(let i of n)i.computedBy&&r.push(...e.getters.getMeasureFullDependencies(t,i));let a=e.__originCellPosition;a&&r.length&&(e.updateDependencies?.(a),e.addDependencies?.(a,r))}var nx=l({ADDRESS:()=>ax,COLUMN:()=>ox,COLUMNS:()=>sx,HLOOKUP:()=>cx,INDEX:()=>lx,INDIRECT:()=>ux,LOOKUP:()=>dx,MATCH:()=>fx,OFFSET:()=>xx,PIVOT:()=>bx,PIVOT_HEADER:()=>yx,PIVOT_VALUE:()=>vx,ROW:()=>px,ROWS:()=>mx,VLOOKUP:()=>hx,XLOOKUP:()=>_x});let rx=[{value:!0,label:E(`A1 style (default)`)},{value:!1,label:E(`R1C1 style`)}],ix=[{value:!0,label:E(`Approximate match (default)`)},{value:!1,label:E(`Exact match`)}],ax={description:E(`Returns a cell reference as a string. `),args:[H(`row (number)`,E(`The row number of the cell reference. `)),H(`column (number)`,E(`The column number (not name) of the cell reference. A is column number 1. `)),H(`absolute_relative_mode (number, default=1)`,E(`An indicator of whether the reference is row/column absolute.`),[{value:1,label:E(`Absolute row and column (e.g. $A$1)`)},{value:2,label:E(`Absolute row, relative column (e.g. A$1)`)},{value:3,label:E(`Relative row, absolute column (e.g. $A1)`)},{value:4,label:E(`Relative row and column (e.g. A1)`)}]),H(`use_a1_notation (boolean, default=TRUE)`,E(`A boolean indicating whether to use A1 style notation or R1C1 style notation.`),rx),H(`sheet (string, optional)`,E(`A string indicating the name of the sheet into which the address points.`))],compute:function(e,t,n={value:1},r={value:!0},i){let a=ua(e,this.locale),o=ua(t,this.locale);if(a<1)return new A(Lu(a));if(o<1)return new A(Lu(o));let s=ua(n,this.locale);if(![1,2,3,4].includes(s))return new A(ia(1,4,s));let c=P(r),l;if(c){let e={rowFixed:[1,2].includes(s),colFixed:[1,3].includes(s)};l=T(o-1,a-1,e)}else l=([1,2].includes(s)?`R${a}`:`R[${a}]`)+([1,3].includes(s)?`C${o}`:`C[${o}]`);return i===void 0?l:Mc(N(i),l)},isExported:!0},ox={description:E(`Column number of a specified cell.`),args:[H(`cell_reference (meta, range<meta>, default='this cell')`,E(`The cell whose column number will be returned. Column A corresponds to 1. By default, the function use the cell in which the formula is entered.`))],compute:function(e){if(e===void 0)return this.__originCellPosition?.col===void 0?new A(E(`In this context, the function [[FUNCTION_NAME]] needs to have a cell or range in parameter.`)):this.__originCellPosition.col+1;if(e[0][0]===void 0)return new A(E(`The range is out of bounds.`));if(e[0][0].value===k.InvalidReference)return e[0][0];let t=this.getters.getRangeFromSheetXC(this.getters.getActiveSheetId(),e[0][0].value).zone.left;return e.length===1?t+1:Sa(e.length,1,(e,n)=>({value:t+e+1}))},isExported:!0},sx={description:E(`Number of columns in a specified array or range.`),args:[H(`range (any, range<any>)`,E(`The range whose column count will be returned.`))],compute:function(e){let t=I(e);return t[0][0]===void 0?new A(E(`The range is out of bounds.`)):t[0][0].value===k.InvalidReference?t[0][0]:t.length},isExported:!0},cx={description:E(`Horizontal lookup`),args:[H(`search_key (string, number, boolean)`,E(`The value to search for. For example, 42, 'Cats', or I24.`)),H(`range (any, range)`,E(`The range to consider for the search. The first row in the range is searched for the key specified in search_key.`)),H(`index (number)`,E(`The row index of the value to be returned, where the first row in range is numbered 1.`)),H(`is_sorted (boolean, default=true)`,E(`Indicates whether the row to be searched (the first row of the specified range) is sorted, in which case the closest match for search_key will be returned.`),ix)],compute:function(e,t,n,r={value:!0}){let i=Math.trunc(M(n?.value,this.locale)),a=I(t);if(1>i||i>a[0].length)return new A(E(`[[FUNCTION_NAME]] evaluates to an out of bounds range.`));let o=(e,t)=>e[t][0].value,s=a[P(r.value)?Na(a,e,`nextSmaller`,`asc`,a.length,o):Pa(a,e,`wildcard`,a.length,o,this.lookupCaches)];return s===void 0?na(e):s[i-1]},isExported:!0},lx={description:E(`Returns the content of a cell, specified by row and column offset.`),args:[H(`reference (any, range)`,E(`The range of cells from which the values are returned.`)),H(`row (number, default=0)`,E(`The index of the row to be returned from within the reference range of cells.`)),H(`column (number, default=0)`,E(`The index of the column to be returned from within the reference range of cells.`))],compute:function(e,t={value:0},n={value:0}){let r=I(e),i=M(t.value,this.locale),a=M(n.value,this.locale);return a<0||a-1>=r.length||i<0||i-1>=r[0].length?new A(E(`Index out of range.`)):i===0&&a===0?r:i===0?[r[a-1]]:a===0?r.map(e=>[e[i-1]]):r[a-1][i-1]},isExported:!0},ux={description:E(`Returns the content of a cell, specified by a string.`),args:[H(`reference (string)`,E(`The range of cells from which the values are returned.`)),H(`use_a1_notation (boolean, default=TRUE)`,E(`A boolean indicating whether to use A1 style notation (TRUE) or R1C1 style notation (FALSE).`),rx)],compute:function(e,t={value:!0}){let n=e?.value?.toString();if(!n)return new Yi(E(`Reference should be defined.`));if(!P(t))return new A(E(`R1C1 notation is not supported.`));let r=this.__originSheetId,i=this.__originCellPosition;i&&this.updateDependencies?.(i);let a=this.getters.getRangeFromSheetXC(r,n);if(a===void 0||a.invalidXc||a.invalidSheetName)return new Yi;i&&this.addDependencies?.(i,[a]);let o=[];for(let e=a.zone.left;e<=a.zone.right;e++){let t=[];for(let n=a.zone.top;n<=a.zone.bottom;n++){let r={sheetId:a.sheetId,col:e,row:n};t.push(this.getters.getEvaluatedCell(r))}o.push(t)}return o.length===1&&o[0].length===1?o[0][0]:o},isExported:!0},dx={description:E(`Look up a value.`),args:[H(`search_key (string, number, boolean)`,E(`The value to search for. For example, 42, 'Cats', or I24.`)),H(`search_array (any, range)`,E(`One method of using this function is to provide a single sorted row or column search_array to look through for the search_key with a second argument result_range. The other way is to combine these two arguments into one search_array where the first row or column is searched and a value is returned from the last row or column in the array. If search_key is not found, a non-exact match may be returned.`)),H(`result_range (any, range, optional)`,E(`The range from which to return a result. The value returned corresponds to the location where search_key is found in search_range. This range must be only a single row or column and should not be used if using the search_result_array method.`))],compute:function(e,t,n){let r=I(t),i=I(n),a=r.length,o=r[0].length,s=o>=a,c=Na(r,e,`nextSmaller`,`asc`,s?o:a,s?(e,t)=>e[0][t].value:(e,t)=>e[t][0].value);return c===-1||s&&r[0][c]===void 0||!s&&r[c][o-1]===void 0?na(e):i[0].length===0?s?r[a-1][c]:r[c][o-1]:(a=i.length,o=i[0].length,a!==1&&o!==1?new A(E(`The result_range must be a single row or a single column.`)):a>1?c>a-1?new A(E(`[[FUNCTION_NAME]] evaluates to an out of range row value %s.`,c+1)):i[c][0]:c>o-1?new A(E(`[[FUNCTION_NAME]] evaluates to an out of range column value %s.`,c+1)):i[0][c])},isExported:!0},fx={description:E(`Position of item in range that matches value.`),args:[H(`search_key (string, number, boolean)`,E(`The value to search for. For example, 42, 'Cats', or I24.`)),H(`range (any, range)`,E(`The one-dimensional array to be searched.`)),H(`search_type (number, default=1)`,E(`The search method is a number 1, 0 or -1 indicating which value to return. 1 finds the largest value less than or equal to search_key when range is sorted in ascending order. 0 finds the exact value when range is unsorted. -1 finds the smallest value greater than or equal to search_key when range is sorted in descending order.`),[{value:1,label:E(`Ascending order (default)`)},{value:0,label:E(`Exact match`)},{value:-1,label:E(`Descending order`)}])],compute:function(e,t,n={value:1}){let r=M(n,this.locale),i=I(t),a=i.length,o=i[0].length;if(a!==1&&o!==1)return new A(E(`The range must be a single row or a single column.`));let s=-1,c=a===1?(e,t)=>e[0][t].value:(e,t)=>e[t][0].value,l=a===1?i[0].length:i.length;switch(r=Math.sign(r),r){case 1:s=Na(i,e,`nextSmaller`,`asc`,l,c);break;case 0:s=Pa(i,e,`wildcard`,l,c,this.lookupCaches);break;case-1:s=Na(i,e,`nextGreater`,`desc`,l,c);break}return a===1&&i[0][s]===void 0||a!==1&&i[s]===void 0?na(e):s+1},isExported:!0},px={description:E(`Row number of a specified cell.`),args:[H(`cell_reference (meta, range<meta>, default='this cell')`,E(`The cell whose row number will be returned. By default, this function uses the cell in which the formula is entered.`))],compute:function(e){if(e===void 0)return this.__originCellPosition?.row===void 0?new A(E(`In this context, the function [[FUNCTION_NAME]] needs to have a cell or range in parameter.`)):this.__originCellPosition.row+1;if(e[0][0]===void 0)return new A(E(`The range is out of bounds.`));if(e[0][0].value===k.InvalidReference)return e[0][0];let t=this.getters.getRangeFromSheetXC(this.getters.getActiveSheetId(),e[0][0].value).zone.top;return e[0].length===1?t+1:Sa(1,e[0].length,(e,n)=>({value:t+n+1}))},isExported:!0},mx={description:E(`Number of rows in a specified array or range.`),args:[H(`range (any, range<any>)`,E(`The range whose row count will be returned.`))],compute:function(e){let t=I(e);return t[0][0]===void 0?new A(E(`The range is out of bounds.`)):t[0][0].value===k.InvalidReference?t[0][0]:t[0].length},isExported:!0},hx={description:E(`Vertical lookup.`),args:[H(`search_key (string, number, boolean)`,E(`The value to search for. For example, 42, 'Cats', or I24.`)),H(`range (any, range)`,E(`The range to consider for the search. The first column in the range is searched for the key specified in search_key.`)),H(`index (number)`,E(`The column index of the value to be returned, where the first column in range is numbered 1.`)),H(`is_sorted (boolean, default=true)`,E(`Indicates whether the column to be searched (the first column of the specified range) is sorted, in which case the closest match for search_key will be returned.`),ix)],compute:function(e,t,n,r={value:!0}){let i=Math.trunc(M(n?.value,this.locale)),a=I(t);if(1>i||i>a.length)return new A(E(`[[FUNCTION_NAME]] evaluates to an out of bounds range.`));let o=(e,t)=>e[0][t].value,s=P(r.value)?Na(a,e,`nextSmaller`,`asc`,a[0].length,o):Pa(a,e,`wildcard`,a[0].length,o,this.lookupCaches),c=a[i-1][s];return c===void 0?na(e):c},isExported:!0},gx={0:`strict`,1:`nextGreater`,"-1":`nextSmaller`,2:`wildcard`},_x={description:E(`Search a range for a match and return the corresponding item from a second range.`),args:[H(`search_key (string,number,boolean)`,E(`The value to search for.`)),H(`lookup_range (any, range)`,E(`The range to consider for the search. Should be a single column or a single row.`)),H(`return_range (any, range)`,E(`The range containing the return value. Should have the same dimensions as lookup_range.`)),H(`if_not_found (any, optional)`,E(`If a valid match is not found, return this value.`)),H(`match_mode (any, default=0)`,E(`Specifies how to match search_key with the items in lookup_range. `),[{value:0,label:E(`Exact match (default)`)},{value:-1,label:E(`Exact match or next smaller item`)},{value:1,label:E(`Exact match or next larger item`)},{value:2,label:E(`Wildcard character match`)}]),H(`search_mode (any, default=1)`,E(`Specifies the search mode to use. By default, a first to last search will be used.`),[{value:1,label:E(`Search first to last (default)`)},{value:-1,label:E(`Search last to first`)},{value:2,label:E(`Binary search (sorted ascending order)`)},{value:-2,label:E(`Binary search (sorted descending order)`)}])],compute:function(e,t,n,r,i={value:0},a={value:1}){let o=Math.trunc(M(i.value,this.locale)),s=Math.trunc(M(a.value,this.locale)),c=I(t),l=I(n);if(c.length!==1&&c[0].length!==1)return new A(E(`lookup_range should be either a single row or single column.`));if(![1,-1,2,-2].includes(s))return new A(E(`search_mode should be a value in [-1, 1, -2, 2].`));if(![-1,0,1,2].includes(o))return new A(E(`match_mode should be a value in [-1, 0, 1, 2].`));let u=c.length===1?`col`:`row`;if(o===2&&[-2,2].includes(s))return new A(E(`The search and match mode combination is not supported for XLOOKUP evaluation.`));if(u===`col`?l[0].length!==c[0].length:l.length!==c.length)return new A(E(`return_range should have the same dimensions as lookup_range.`));let d=u===`col`?(e,t)=>e[0][t].value:(e,t)=>e[t][0].value,f=u===`col`?c[0].length:c.length,p=gx[o],m=s===-1,h=s===2||s===-2?Na(c,e,p,s===2?`asc`:`desc`,f,d):Pa(c,e,p,f,d,this.lookupCaches,m);return h===-1?r===void 0?na(e):[[r]]:u===`col`?l.map(e=>[e[h]]):[l[h]]},isExported:!0},vx={description:E(`Get the value from a pivot.`),args:[H(`pivot_id (number,string)`,E(`ID of the pivot.`)),H(`measure_name (string)`,E(`Name of the measure.`)),H(`domain_field_name (string,repeating)`,E(`Field name.`)),H(`domain_value (number,string,boolean,repeating)`,E(`Value.`))],compute:function(e,t,...n){let r=N(e),i=N(t),a=Qb(r,this.getters);$b(a,i,this.getters),ex(n);let o=this.getters.getPivot(a),s=this.getters.getPivotCoreDefinition(a);tx(this,a,s.measures.filter(e=>e.id===i)),o.init({reload:o.needsReevaluation});let c=o.assertIsValid({throwOnError:!1});if(c)return c;if(!o.areDomainArgsFieldsValid(n)){let e=E(`Consider using a dynamic pivot formula: %s. Or re-insert the static pivot from the Data menu.`,`=PIVOT(${r})`);return{value:k.GenericError,message:E(`Dimensions don't match the pivot definition`)+`. `+e}}let l=o.parseArgsToPivotDomain(n);return this.getters.getActiveSheetId()===this.__originSheetId&&this.getters.getPivotPresenceTracker(a)?.trackValue(i,l),o.getPivotCellValueAndFormat(i,l)}},yx={description:E(`Get the header of a pivot.`),args:[H(`pivot_id (number,string)`,E(`ID of the pivot.`)),H(`domain_field_name (string,repeating)`,E(`Field name.`)),H(`domain_value (number,string,value,repeating)`,E(`Value.`))],compute:function(e,...t){let n=N(e),r=Qb(n,this.getters);ex(t);let i=this.getters.getPivot(r);tx(this,r,[]),i.init({reload:i.needsReevaluation});let a=i.assertIsValid({throwOnError:!1});if(a)return a;if(!i.areDomainArgsFieldsValid(t)){let e=E(`Consider using a dynamic pivot formula: %s. Or re-insert the static pivot from the Data menu.`,`=PIVOT(${n})`);return{value:k.GenericError,message:E(`Dimensions don't match the pivot definition`)+`. `+e}}let o=i.parseArgsToPivotDomain(t);this.getters.getActiveSheetId()===this.__originSheetId&&this.getters.getPivotPresenceTracker(r)?.trackHeader(o);let s=o.at(-1);if(s?.field===`measure`)return i.getPivotMeasureValue(N(s.value),o);let{value:c,format:l}=i.getPivotHeaderValueAndFormat(o);return{value:c,format:!s||s.field===`measure`||s.value===`false`?void 0:l}}},bx={description:E(`Get a pivot table.`),args:[H(`pivot_id (string)`,E(`ID of the pivot.`)),H(`row_count (number, optional)`,E(`number of rows`)),H(`include_total (boolean, default=TRUE)`,E(`Whether to include total/sub-totals or not.`)),H(`include_column_titles (boolean, default=TRUE)`,E(`Whether to include the column titles or not.`)),H(`column_count (number, optional)`,E(`number of columns`)),H(`include_measure_titles (boolean, default=TRUE)`,E(`Whether to include the measure titles row or not.`))],compute:function(e,t={value:1e4},n={value:!0},r={value:!0},i={value:Number.MAX_VALUE},a={value:!0}){let o=N(e),s=M(t,this.locale);if(s<0)return new A(E(`The number of rows must be positive.`));let c=M(i,this.locale);if(c<0)return new A(E(`The number of columns must be positive.`));let l={displayColumnHeaders:P(r),displayTotals:P(n),displayMeasuresRow:P(a)},u=Qb(o,this.getters),d=this.getters.getPivot(u),f=this.getters.getPivotCoreDefinition(u);tx(this,u,f.measures),d.init({reload:d.needsReevaluation});let p=d.assertIsValid({throwOnError:!1});if(p)return p;let m=d.getCollapsedTableStructure();if(m.numberOfCells>5e5)return new A(Zb(m.numberOfCells,this.locale));let h=m.getPivotCells(l),g=0;l.displayColumnHeaders&&(g=m.columns.length-1),l.displayMeasuresRow&&g++;let _=this.getters.getPivotName(u),v=Math.min(g+s,h[0].length);if(v===0)return[[{value:_}]];let y=Math.min(1+c,h.length),ee=[];for(let e of S(0,y)){ee[e]=[];for(let t of S(0,v)){let n=h[e][t];switch(n.type){case`EMPTY`:ee[e].push({value:``});break;case`HEADER`:let t=d.getPivotHeaderValueAndFormat(n.domain);ee[e].push(Bd(n.domain,t));break;case`MEASURE_HEADER`:ee[e].push(d.getPivotMeasureValue(n.measure,n.domain));break;case`VALUE`:ee[e].push(d.getPivotCellValueAndFormat(n.measure,n.domain));break}}}return(l.displayColumnHeaders||l.displayMeasuresRow)&&(ee[0][0]={value:_}),ee}},xx={description:E(`Returns a range reference shifted by a specified number of rows and columns from a starting cell reference.`),args:[H(`cell_reference (meta, range<meta>)`,E(`The starting point from which to count the offset rows and columns.`)),H(`offset_rows (number)`,E(`The number of rows to offset by.`)),H(`offset_columns (number)`,E(`The number of columns to offset by.`)),H(`height (number, default='height of cell_reference')`,E(`The number of rows of the range to return starting at the offset target.`)),H(`width (number, default='width of cell_reference')`,E(`The number of columns of the range to return starting at the offset target.`))],compute:function(e,t,n,r,i){if(j(e[0][0].value))return e[0][0];let a=e[0][0].value;if(!a)return new A(`In this context, the function OFFSET needs to have a cell or range in parameter.`);let o=Ts(a),s=e[0].length,c=e.length;if(r){let e=M(r,this.locale);if(e<1)return new A(E(`Height value is %(_height)s. It should be greater than or equal to 1.`,{_height:e}));s=e}if(i){let e=M(i,this.locale);if(e<1)return new A(E(`Width value is %(_width)s. It should be greater than or equal to 1.`,{_width:e}));c=e}let{sheetName:l}=jc(a),u=l&&this.getters.getSheetIdByName(l)||this.getters.getActiveSheetId(),d=M(t,this.locale),f=M(n,this.locale),p=this.__originCellPosition;p&&this.updateDependencies?.(p);let m=o.left+f,h=o.top+d;if(m<0||h<0)return new Yi(E(`OFFSET evaluates to an out of bounds range.`));let g={left:m,top:h,right:m+c-1,bottom:h+s-1},_=this.getters.getRangeFromZone(u,g);return _.invalidXc||_.invalidSheetName?new Yi:(p&&this.addDependencies?.(p,[_]),Sa(c,s,(e,t)=>this.getters.getEvaluatedCell({sheetId:u,col:m+e,row:h+t})))}};var Sx=l({ADD:()=>Cx,CONCAT:()=>wx,DIVIDE:()=>Tx,EQ:()=>kx,GT:()=>jx,GTE:()=>Mx,LT:()=>Nx,LTE:()=>Px,MINUS:()=>Fx,MULTIPLY:()=>Ix,NE:()=>Lx,POW:()=>Rx,UMINUS:()=>zx,UNARY_PERCENT:()=>Bx,UPLUS:()=>Vx});let Cx={description:E(`Sum of two numbers.`),args:[H(`value1 (number)`,E(`The first addend.`)),H(`value2 (number)`,E(`The second addend.`))],compute:function(e,t){return{value:M(e,this.locale)+M(t,this.locale),format:e?.format||t?.format}}},wx={description:E(`Concatenation of two values.`),args:[H(`value1 (string)`,E(`The value to which value2 will be appended.`)),H(`value2 (string)`,E(`The value to append to value1.`))],compute:function(e,t){return N(e)+N(t)},isExported:!0},Tx={description:E(`One number divided by another.`),args:[H(`dividend (number)`,E(`The number to be divided.`)),H(`divisor (number)`,E(`The number to divide by.`))],compute:function(e,t){let n=M(t,this.locale);return n===0?new $i(E(`The divisor must be different from zero.`)):{value:M(e,this.locale)/n,format:e?.format||t?.format}}};function Ex(e){return e===void 0||e.value===null}let Dx={number:0,string:``,boolean:!1};function Ox(e,t,n=2e-16){return Math.abs(e-t)<n}let kx={description:E(`Equal.`),args:[H(`value1 (string, number, boolean)`,E(`The first value.`)),H(`value2 (string, number, boolean)`,E(`The value to test against value1 for equality.`))],compute:function(e,t){if(j(e?.value))return e;if(j(t?.value))return t;let n=Ex(e)?Dx[typeof t?.value]:e?.value,r=Ex(t)?Dx[typeof e?.value]:t?.value;return typeof n==`string`&&(n=n.toUpperCase()),typeof r==`string`&&(r=r.toUpperCase()),typeof n==`number`&&typeof r==`number`?{value:Ox(n,r)}:{value:n===r}}};function Ax(e,t,n){if(j(e?.value))return e;if(j(t?.value))return t;let r=Ex(e)?Dx[typeof t?.value]:e?.value,i=Ex(t)?Dx[typeof e?.value]:t?.value;typeof r!=`number`&&(r=N(r).toUpperCase()),typeof i!=`number`&&(i=N(i).toUpperCase());let a=typeof r,o=typeof i;return a===`string`&&o===`number`?{value:!0}:o===`string`&&a===`number`?{value:!1}:{value:n(r,i)}}let jx={description:E(`Strictly greater than.`),args:[H(`value1 (number, string, boolean)`,E(`The value to test as being greater than value2.`)),H(`value2 (number, string, boolean)`,E(`The second value.`))],compute:function(e,t){return Ax(e,t,(e,t)=>typeof e==`number`&&typeof t==`number`?!Ox(e,t)&&e>t:e>t)}},Mx={description:E(`Greater than or equal to.`),args:[H(`value1 (number, string, boolean)`,E(`The value to test as being greater than or equal to value2.`)),H(`value2 (number, string, boolean)`,E(`The second value.`))],compute:function(e,t){return Ax(e,t,(e,t)=>typeof e==`number`&&typeof t==`number`?Ox(e,t)||e>t:e>=t)}},Nx={description:E(`Less than.`),args:[H(`value1 (number, string, boolean)`,E(`The value to test as being less than value2.`)),H(`value2 (number, string, boolean)`,E(`The second value.`))],compute:function(e,t){let n=Mx.compute.bind(this)(e,t);return j(n.value)?n:{value:!n.value}}},Px={description:E(`Less than or equal to.`),args:[H(`value1 (number, string, boolean)`,E(`The value to test as being less than or equal to value2.`)),H(`value2 (number, string, boolean)`,E(`The second value.`))],compute:function(e,t){let n=jx.compute.bind(this)(e,t);return j(n.value)?n:{value:!n.value}}},Fx={description:E(`Difference of two numbers.`),args:[H(`value1 (number)`,E(`The minuend, or number to be subtracted from.`)),H(`value2 (number)`,E(`The subtrahend, or number to subtract from value1.`))],compute:function(e,t){return{value:M(e,this.locale)-M(t,this.locale),format:e?.format||t?.format}}},Ix={description:E(`Product of two numbers`),args:[H(`factor1 (number)`,E(`The first multiplicand.`)),H(`factor2 (number)`,E(`The second multiplicand.`))],compute:function(e,t){return{value:M(e,this.locale)*M(t,this.locale),format:e?.format||t?.format}}},Lx={description:E(`Not equal.`),args:[H(`value1 (string, number, boolean)`,E(`The first value.`)),H(`value2 (string, number, boolean)`,E(`The value to test against value1 for inequality.`))],compute:function(e,t){let n=kx.compute.bind(this)(e,t);return j(n.value)?n:{value:!n.value}}},Rx={description:E(`A number raised to a power.`),args:[H(`base (number)`,E(`The number to raise to the exponent power.`)),H(`exponent (number)`,E(`The exponent to raise base to.`))],compute:function(e,t){return jm.compute.bind(this)(e,t)}},zx={description:E(`A number with the sign reversed.`),args:[H(`value (number)`,E(`The number to have its sign reversed. Equivalently, the number to multiply by -1.`))],compute:function(e){return{value:-M(e,this.locale),format:e?.format}}},Bx={description:E(`Value interpreted as a percentage.`),args:[H(`percentage (number)`,E(`The value to interpret as a percentage.`))],compute:function(e){return M(e,this.locale)/100}},Vx={description:E(`A specified number, unchanged.`),args:[H(`value (any)`,E(`The number to return.`))],compute:function(e={value:null}){return e}},W=e=>({transform:t=>t*e,inverseTransform:t=>t/e}),Hx={transform:e=>e,inverseTransform:e=>e},Ux=1e-10,Wx=.0254,Gx=Wx/72,Kx=.3048,qx=.9144,Jx=1609.34,Yx=1852,Xx=946073047258e4,Zx={g:{...Hx,category:`weight`},u:{...W(166053e-29),category:`weight`},grain:{...W(.0647989),category:`weight`},ozm:{...W(28.3495),category:`weight`},lbm:{...W(453.592),category:`weight`},stone:{...W(6350.29),category:`weight`},sg:{...W(14593.90294),category:`weight`},cwt:{...W(45359.237),category:`weight`},uk_cwt:{...W(50802.3),category:`weight`},ton:{...W(907184.74),category:`weight`},uk_ton:{...W(1016046.9),category:`weight`},m:{...Hx,category:`distance`},km:{...W(1e3),category:`distance`},ang:{...W(Ux),category:`distance`},Picapt:{...W(Gx),category:`distance`},pica:{...W(Wx/6),category:`distance`},in:{...W(Wx),category:`distance`},ft:{...W(Kx),category:`distance`},yd:{...W(qx),category:`distance`},ell:{...W(1.143),category:`distance`},mi:{...W(Jx),category:`distance`},survey_mi:{...W(1609.34),category:`distance`},Nmi:{...W(Yx),category:`distance`},ly:{...W(Xx),category:`distance`},parsec:{...W(0x6da012f95c9fd0),category:`distance`},sec:{...Hx,category:`time`},min:{...W(60),category:`time`},hr:{...W(3600),category:`time`},day:{...W(86400),category:`time`},yr:{...W(31556952),category:`time`},Pa:{...Hx,category:`pressure`},bar:{...W(1e5),category:`pressure`},mmHg:{...W(133.322),category:`pressure`},Torr:{...W(133.322),category:`pressure`},psi:{...W(6894.76),category:`pressure`},atm:{...W(101325),category:`pressure`},N:{...Hx,category:`force`},dyn:{...W(1e-5),category:`force`},pond:{...W(.00980665),category:`force`},lbf:{...W(4.44822),category:`force`},J:{...Hx,category:`energy`},eV:{...W(160218e-24),category:`energy`},e:{...W(1e-7),category:`energy`},flb:{...W(1.3558179483),category:`energy`},c:{...W(4.184),category:`energy`},cal:{...W(4.1868),category:`energy`},BTU:{...W(1055.06),category:`energy`},Wh:{...W(3600),category:`energy`},HPh:{...W(2684520),category:`energy`},W:{...Hx,category:`power`},PS:{...W(735.499),category:`power`},HP:{...W(745.7),category:`power`},T:{...Hx,category:`magnetism`},ga:{...W(1e-4),category:`magnetism`},K:{...Hx,category:`temperature`},C:{transform:e=>e+273.15,inverseTransform:e=>e-273.15,category:`temperature`},F:{transform:e=>(e-32)*5/9+273.15,inverseTransform:e=>(e-273.15)*9/5+32,category:`temperature`},Rank:{...W(5/9),category:`temperature`},Reau:{transform:e=>e*1.25+273.15,inverseTransform:e=>(e-273.15)/1.25,category:`temperature`},"m^3":{...Hx,category:`volume`,order:3},"ang^3":{...W(Ux**3),category:`volume`,order:3},"Picapt^3":{...W(Gx**3),category:`volume`,order:3},tsp:{...W(492892e-11),category:`volume`},tspm:{...W(5e-6),category:`volume`},tbs:{...W(14786764825785619e-21),category:`volume`},"in^3":{...W(Wx**3),category:`volume`,order:3},oz:{...W(295735295625e-16),category:`volume`},cup:{...W(237e-6),category:`volume`},pt:{...W(.0004731765),category:`volume`},uk_pt:{...W(568261e-9),category:`volume`},qt:{...W(.0009463529),category:`volume`},l:{...W(.001),category:`volume`},uk_qt:{...W(.0011365225),category:`volume`},gal:{...W(.0037854118),category:`volume`},uk_gal:{...W(.00454609),category:`volume`},"ft^3":{...W(Kx**3),category:`volume`,order:3},bushel:{...W(.0352390704),category:`volume`},barrel:{...W(.158987295),category:`volume`},"yd^3":{...W(qx**3),category:`volume`,order:3},MTON:{...W(1.13267386368),category:`volume`},GRT:{...W(2.83168),category:`volume`},"mi^3":{...W(Jx**3),category:`volume`,order:3},"Nmi^3":{...W(Yx**3),category:`volume`,order:3},"ly^3":{...W(Xx**3),category:`volume`,order:3},"m^2":{...Hx,category:`area`,order:2},"ang^2":{...W(Ux**2),category:`area`,order:2},"Picapt^2":{...W(Gx**2),category:`area`,order:2},"in^2":{...W(Wx**2),category:`area`,order:2},"ft^2":{...W(Kx**2),category:`area`,order:2},"yd^2":{...W(qx**2),category:`area`,order:2},ar:{...W(100),category:`area`},Morgen:{...W(2500),category:`area`},uk_acre:{...W(4046.8564224),category:`area`},us_acre:{...W(4046.8726098743),category:`area`},ha:{...W(1e4),category:`area`},"mi^2":{...W(Jx**2),category:`area`,order:2},"Nmi^2":{...W(Yx**2),category:`area`,order:2},"ly^2":{...W(Xx**2),category:`area`,order:2},bit:{...Hx,category:`information`},byte:{...W(8),category:`information`},"m/s":{...Hx,category:`speed`},"m/hr":{...W(1/3600),category:`speed`},"km/hr":{...W(1/3.6),category:`speed`},mph:{...W(.44704),category:`speed`},kn:{...W(.5144444444),category:`speed`},admkn:{...W(.5147733333),category:`speed`}},Qx={shweight:`cwt`,lcwt:`uk_cwt`,hweight:`uk_cwt`,LTON:`uk_ton`,brton:`uk_ton`,pc:`parsec`,Pica:`Picapt`,d:`day`,mn:`min`,s:`sec`,p:`Pa`,at:`atm`,dy:`dyn`,ev:`eV`,hh:`HPh`,wh:`Wh`,btu:`BTU`,h:`HP`,cel:`C`,fah:`F`,kel:`K`,us_pt:`pt`,L:`l`,lt:`l`,ang3:`ang^3`,ft3:`ft^3`,in3:`in^3`,ly3:`ly^3`,m3:`m^3`,mi3:`mi^3`,yd3:`yd^3`,Nmi3:`Nmi^3`,Picapt3:`Picapt^3`,"Pica^3":`Picapt^3`,Pica3:`Picapt^3`,regton:`GRT`,ang2:`ang^2`,ft2:`ft^2`,in2:`in^2`,ly2:`ly^2`,m2:`m^2`,mi2:`mi^2`,Nmi2:`Nmi^2`,Picapt2:`Picapt^2`,"Pica^2":`Picapt^2`,Pica2:`Picapt^2`,yd2:`yd^2`,"m/h":`m/hr`,"m/sec":`m/s`},$x={"":1,Y:1e24,Z:1e21,E:0xde0b6b3a7640000,P:0x38d7ea4c68000,T:0xe8d4a51000,G:1e9,M:1e6,k:1e3,h:100,da:10,e:10,d:.1,c:.01,m:.001,u:1e-6,n:1e-9,p:1e-12,f:1e-15,a:1e-18,z:1e-21,y:1e-21,Yi:2**80,Zi:2**70,Ei:2**60,Pi:2**50,Ti:2**40,Gi:2**30,Mi:2**20,ki:2**10},eS={weight:E(`Weight`),distance:E(`Distance`),time:E(`Time`),pressure:E(`Pressure`),force:E(`Force`),energy:E(`Energy`),power:E(`Power`),magnetism:E(`Magnetism`),temperature:E(`Temperature`),volume:E(`Volume`),area:E(`Area`),information:E(`Information`),speed:E(`Speed`)},tS=Object.entries(Zx).map(([e,t])=>({value:e,label:nS(t.category)}));function nS(e){return eS[e]??``}function rS(e){for(let[t,n]of Object.entries($x)){if(t&&!e.startsWith(t))continue;let r=e.slice(t.length),i=Zx[r];if(!i&&Qx[r]&&(i=Zx[Qx[r]]),i)return{...i,factor:i.order?n**+i.order:n}}}var iS=l({CONVERT:()=>aS});let aS={description:E(`Converts a numeric value to a different unit of measure.`),args:[H(`value (number)`,E(`the numeric value in start_unit to convert to end_unit`)),H(`start_unit (string)`,E(`The starting unit, the unit currently assigned to value`),tS),H(`end_unit (string)`,E(`The unit of measure into which to convert value`),tS)],compute:function(e,t,n){let r=M(e,this.locale),i=N(t),a=N(n),o=rS(i),s=rS(a);return o?s?o.category===s.category?{value:s.inverseTransform(o.factor*o.transform(r))/s.factor,format:e?.format}:{value:k.GenericError,message:E(`Incompatible units of measure ('%s' vs '%s')`,nS(o.category),nS(s.category))}:{value:k.GenericError,message:E(`Invalid units of measure ('%s')`,a)}:{value:k.GenericError,message:E(`Invalid units of measure ('%s')`,i)}},isExported:!0};var oS=l({CHAR:()=>uS,CLEAN:()=>dS,CONCATENATE:()=>fS,EXACT:()=>pS,FIND:()=>mS,JOIN:()=>hS,LEFT:()=>gS,LEN:()=>_S,LOWER:()=>vS,MID:()=>yS,PROPER:()=>bS,REGEXEXTRACT:()=>xS,REPLACE:()=>SS,RIGHT:()=>CS,SEARCH:()=>wS,SPLIT:()=>TS,SUBSTITUTE:()=>ES,TEXT:()=>jS,TEXTAFTER:()=>NS,TEXTBEFORE:()=>PS,TEXTJOIN:()=>DS,TEXTSPLIT:()=>OS,TRIM:()=>kS,UPPER:()=>AS,VALUE:()=>MS});let sS=/[A-Za-zÀ-ÖØ-öø-ÿ]+/g,cS=[{value:0,label:E(`Case-sensitive (default)`)},{value:1,label:E(`Case-insensitive`)}],lS=[{value:0,label:E(`Don't match to end (default)`)},{value:1,label:E(`Match to end`)}],uS={description:E(`Gets character associated with number.`),args:[H(`table_number (number)`,E(`The number of the character to look up from the current Unicode table in decimal format.`))],compute:function(e){let t=Math.trunc(M(e,this.locale));return t<1?new A(E(`The table_number (%s) is out of range.`,t)):String.fromCharCode(t)},isExported:!0},dS={description:E(`Remove non-printable characters from a piece of text.`),args:[H(`text (string)`,E(`The text whose non-printable characters are to be removed.`))],compute:function(e){let t=N(e),n=``;for(let e of t)e&&e.charCodeAt(0)>31&&(n+=e);return n},isExported:!0},fS={description:E(`Appends strings to one another.`),args:[H(`string1 (string, range<string>)`,E(`The initial string.`)),H(`string2 (string, range<string>, repeating)`,E(`More strings to append in sequence.`))],compute:function(...e){return ya(e,(e,t)=>e+N(t),``)},isExported:!0},pS={description:E(`Tests whether two strings are identical.`),args:[H(`string1 (string)`,E(`The first string to compare.`)),H(`string2 (string)`,E(`The second string to compare.`))],compute:function(e,t){return N(e)===N(t)},isExported:!0},mS={description:E(`First position of string found in text, case-sensitive.`),args:[H(`search_for (string)`,E(`The string to look for within text_to_search.`)),H(`text_to_search (string)`,E(`The text to search for the first occurrence of search_for.`)),H(`starting_at (number, default=1)`,E(`The character within text_to_search at which to start the search.`))],compute:function(e,t,n={value:1}){let r=N(e),i=N(t),a=M(n,this.locale);if(i===``)return new A(E(`The text_to_search must be non-empty.`));if(a<1)return new A(E(`The starting_at (%s) must be greater than or equal to 1.`,a));let o=i.indexOf(r,a-1);return o===-1?new A(E(`In [[FUNCTION_NAME]] evaluation, cannot find '%s' within '%s'.`,r,i)):o+1},isExported:!0},hS={description:E(`Concatenates elements of arrays with delimiter.`),args:[H(`delimiter (string)`,E(`The character or string to place between each concatenated value.`)),H(`value_or_array1 (string, range<string>)`,E(`The value or values to be appended using delimiter.`)),H(`value_or_array2 (string, range<string>, repeating)`,E(`More values to be appended using delimiter.`))],compute:function(e,...t){let n=N(e);return ya(t,(e,t)=>(e?e+n:``)+N(t),``)}},gS={description:E(`Substring from beginning of specified string.`),args:[H(`text (string)`,E(`The string from which the left portion will be returned.`)),H(`number_of_characters (number, optional)`,E(`The number of characters to return from the left side of string.`))],compute:function(e,...t){let n=t.length?M(t[0],this.locale):1;return n<0?new A(E(`The number_of_characters (%s) must be positive or null.`,n)):N(e).substring(0,n)},isExported:!0},_S={description:E(`Length of a string.`),args:[H(`text (string)`,E(`The string whose length will be returned.`))],compute:function(e){return N(e).length},isExported:!0},vS={description:E(`Converts a specified string to lowercase.`),args:[H(`text (string)`,E(`The string to convert to lowercase.`))],compute:function(e){return N(e).toLowerCase()},isExported:!0},yS={description:E(`A segment of a string.`),args:[H(`text (string)`,E(`The string to extract a segment from.`)),H(`starting_at (number)`,E(`The index from the left of string from which to begin extracting. The first character in string has the index 1.`)),H(`extract_length (number)`,E(`The length of the segment to extract.`))],compute:function(e,t,n){let r=N(e),i=M(t,this.locale),a=M(n,this.locale);return i<1?new A(E(`The starting_at argument (%s) must be positive greater than one.`,i.toString())):a<0?new A(E(`The extract_length argument (%s) must be positive or null.`,a)):r.slice(i-1,i+a-1)},isExported:!0},bS={description:E(`Capitalizes each word in a specified string.`),args:[H(`text_to_capitalize (string)`,E(`The text which will be returned with the first letter of each word in uppercase and all other letters in lowercase.`))],compute:function(e){return N(e).replace(sS,e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase())},isExported:!0},xS={description:E(`Extract text from a string based on the supplied regular expression.`),args:[H(`text (string)`,E(`The string on which you want to extract text.`)),H(`pattern (string)`,E(`The regular expression pattern to match against the text.`)),H(`return_mode (number, default=0)`,E(`0 = first match, 1 = all matches as an array, 2 = capturing groups from the first match as an array.`),[{value:0,label:E(`First match`)},{value:1,label:E(`All matches`)},{value:2,label:E(`Capture groups of first match`)}]),H(`case_sensitivity (number, default=0)`,E(`Whether the match is case-sensitive.`),[{value:0,label:E(`Case-sensitive`)},{value:1,label:E(`Case-insensitive`)}])],compute:function(e,t,n={value:0},r={value:0}){let i=N(e),a=N(t),o=M(n,this.locale),s=M(r,this.locale);if(i===``||a===``)return{value:``};if(o<0||o>2)return new A(E(`The return_mode (%s) must be 0, 1 or 2.`,o));if(s!==0&&s!==1)return new A(E(`The case_sensitivity (%s) must be 0 or 1.`,s));let c=s===1?`gi`:`g`,l;try{l=new RegExp(a,c)}catch{return new A(E(`Invalid regular expression`))}let u=[...i.matchAll(l)];return u.length===0?{value:k.NotAvailable,message:E(`No matches found.`)}:o===0?u[0][0]:o===1?u.map(e=>[e[0]]):u[0].length<2?new A(E(`No capturing groups found.`)):u[0].slice(1).map(e=>[e])},isExported:!0},SS={description:E(`Replaces part of a text string with different text.`),args:[H(`text (string)`,E(`The text, a part of which will be replaced.`)),H(`position (number)`,E(`The position where the replacement will begin (starting from 1).`)),H(`length (number)`,E(`The number of characters in the text to be replaced.`)),H(`new_text (string)`,E(`The text which will be inserted into the original text.`))],compute:function(e,t,n,r){let i=M(t,this.locale);if(i<1)return new A(E(`The position (%s) must be greater than or equal to 1.`,i));let a=N(e),o=M(n,this.locale),s=N(r);return a.substring(0,i-1)+s+a.substring(i-1+o)},isExported:!0},CS={description:E(`A substring from the end of a specified string.`),args:[H(`text (string)`,E(`The string from which the right portion will be returned.`)),H(`number_of_characters (number, optional)`,E(`The number of characters to return from the right side of string.`))],compute:function(e,...t){let n=t.length?M(t[0],this.locale):1;if(n<0)return new A(E(`The number_of_characters (%s) must be positive or null.`,n));let r=N(e),i=r.length;return r.substring(i-n,i)},isExported:!0},wS={description:E(`First position of string found in text, ignoring case.`),args:[H(`search_for (string)`,E(`The string to look for within text_to_search.`)),H(`text_to_search (string)`,E(`The text to search for the first occurrence of search_for.`)),H(`starting_at (number, default=1)`,E(`The character within text_to_search at which to start the search.`))],compute:function(e,t,n={value:1}){let r=N(e).toLowerCase(),i=N(t).toLowerCase(),a=M(n,this.locale);if(i===``)return{value:k.GenericError,message:E(`The text_to_search must be non-empty.`)};if(a<1)return{value:k.GenericError,message:E(`The starting_at (%s) must be greater than or equal to 1.`,a)};let o=i.indexOf(r,a-1);return o===-1?{value:k.GenericError,message:E(`In [[FUNCTION_NAME]] evaluation, cannot find '%s' within '%s'.`,r,i)}:{value:o+1}},isExported:!0},TS={description:E(`Split text by specific character delimiter(s).`),args:[H(`text (string)`,E(`The text to divide.`)),H(`delimiter (string)`,E(`The character or characters to use to split text.`)),H(`split_by_each (boolean, default=true})`,E(`Whether or not to divide text around each character contained in delimiter.`)),H(`remove_empty_text (boolean, default=true)`,E(`Whether or not to remove empty text messages from the split results. The default behavior is to treat consecutive delimiters as one (if TRUE). If FALSE, empty cells values are added between consecutive delimiters.`))],compute:function(e,t,n={value:!0},r={value:!0}){let i=N(e),a=ut(N(t)),o=P(n),s=P(r);if(a.length<=0)return new A(E(`The delimiter (%s) must be not be empty.`,a));let c=o?RegExp(`[${a}]`,`g`):new RegExp(a,`g`),l=i.split(c);return s&&(l=l.filter(e=>e!==``)),Ta([l])},isExported:!1},ES={description:E(`Replaces existing text with new text in a string.`),args:[H(`text_to_search (string)`,E(`The text within which to search and replace.`)),H(`search_for (string)`,E(`The string to search for within text_to_search.`)),H(`replace_with (string)`,E(`The string that will replace search_for.`)),H(`occurrence_number (number, optional)`,E(`The instance of search_for within text_to_search to replace with replace_with. By default, all occurrences of search_for are replaced; however, if occurrence_number is specified, only the indicated instance of search_for is replaced.`))],compute:function(e,t,n,r){let i=M(r,this.locale);if(i<0)return new A(E(`The occurrenceNumber (%s) must be positive or null.`,i));let a=N(e),o=N(t);if(o===``)return a;let s=N(n),c=new RegExp(ut(o),`g`);if(i===0)return a.replace(c,s);let l=0;return a.replace(c,e=>++l===i?s:e)},isExported:!0},DS={description:E(`Combines text from multiple strings and/or arrays.`),args:[H(`delimiter (string)`,E(` A string, possible empty, or a reference to a valid string. If empty, the text will be simply concatenated.`)),H(`ignore_empty (boolean)`,E(`A boolean; if TRUE, empty cells selected in the text arguments won't be included in the result.`),[{value:!0,label:E(`Ignore empty cells`)},{value:!1,label:E(`Include empty cells (default)`)}]),H(`text1 (string, range<string>)`,E(`Any text item. This could be a string, or an array of strings in a range.`)),H(`text2 (string, range<string>, repeating)`,E(`Additional text item(s).`))],compute:function(e,t={value:!0},...n){let r=N(e),i=P(t),a=0;return ya(n,(e,t)=>i&&N(t)===``?e:(a++?e+r:``)+N(t),``)},isExported:!0},OS={description:E(`Splits text into rows or columns using specified column and row delimiters.`),args:[H(`text (string)`,E(`The text to split.`)),H(`col_delimiter (string, range<string>)`,E(`Character or string to split columns by.`)),H(`row_delimiter (string, range<string>, optional)`,E(`Character or string to split rows by.`)),H(`ignore_empty (boolean, default=false)`,E(`Whether to ignore empty cells.`),[{value:!1,label:E(`Include empty cells (default)`)},{value:!0,label:E(`Ignore empty cells`)}]),H(`match_mode (number, default=0)`,E(`Searches the text for a delimiter match. By default, a case-sensitive match is done.`),cS),H(`pad_with (string, default="${k.NotAvailable}")`,E(`The value to use for padding empty cells.`))],compute:function(e,t,n,r={value:!1},i={value:0},a=new Xi){let o=N(e);if(o.length<=0)return new A(E(`No text to split.`));if(t===void 0&&n===void 0)return new A(E(`At least one delimiter must be provided.`));let s=I(t).flat().map(e=>ut(N(e))),c=I(n).flat().map(e=>ut(N(e)));if(s.some(e=>e===``)||c.some(e=>e===``))return new A(E(`The delimiters cannot be empty values.`));let l=P(r),u=M(i,this.locale);if(![0,1].includes(u))return new A(E(`match_mode should be a value of 0 or 1.`));let d=[],f=u===1?`gi`:`g`,p=c.filter(e=>!s.includes(e)),m=p.length?o.split(new RegExp(p.join(`|`),f)):[o];l&&(m=m.filter(e=>e!==``));let h=new RegExp(s.join(`|`),f);for(let e of m){let t=s.length?e.split(h):[e];l&&(t=t.filter(e=>e!==``)),d.push(t.map(e=>({value:e})))}let g=Math.max(...d.map(e=>e.length));for(let e of d)for(;e.length<g;)e.push(a);return Ta(d)},isExported:!0},kS={description:E(`Removes space characters.`),args:[H(`text (string)`,E(`The text or reference to a cell containing text to be trimmed.`))],compute:function(e){return Xt(N(e))},isExported:!0},AS={description:E(`Converts a specified string to uppercase.`),args:[H(`text (string)`,E(`The string to convert to uppercase.`))],compute:function(e){return N(e).toUpperCase()},isExported:!0},jS={description:E(`Converts a number to text according to a specified format.`),args:[H(`number (number)`,E(`The number, date or time to format.`)),H(`format (string)`,E(`The case-sensitive format of the result, enclosed in quotation marks. Examples: "0.00" rounded to 2 decimal places, "hh:mm:ss" for hour:minutes:seconds.`))],compute:function(e,t){return L(M(e,this.locale),{format:N(t),locale:this.locale})},isExported:!0},MS={description:E(`Converts a string to a numeric value.`),args:[H(`value (number)`,E(`the string to be converted`))],compute:function(e){return M(e,this.locale)},isExported:!0},NS={description:E(`Returns text that occurs after a given substring or delimiter.`),args:[H(`text (string)`,E(`The source text.`)),H(`delimiter (string)`,E(`The substring after which text will be returned.`)),H(`instance_num (number, default=1)`,E(`The desired instance of the delimiter after which we extract the text. A negative number searches from the end.`)),H(`match_mode (number, default=0)`,E(`Searches the text for a delimiter match. By default, a case-sensitive match is done.`),cS),H(`match_end (number, default=0))`,E(`Whether to treat the end of text as a delimiter.`),lS),H(`if_not_found (string, default="${k.NotAvailable}")`,E(`Value to return if the delimiter is not found.`))],compute:function(e,t,n={value:1},r={value:0},i={value:0},a=new Xi){let o=N(e),s=M(n,this.locale),c=M(r,this.locale),l=M(i,this.locale);if(s===0)return new A(E(`The instance_num (%s) must not be zero.`,s));if(c!==0&&c!==1)return new A(E(`match_mode should have a value of 0 or 1.`));if(l!==0&&l!==1)return new A(E(`match_end should have a value of 0 or 1.`));let u=N(t);if(u===``)return Math.sign(s)>0?{value:o}:{value:``};let d=c===1?`gi`:`g`,f=ut(u),p=new RegExp(f,d),m=[...o.matchAll(p)].map(e=>e.index+f.length);if(s<0&&(m=m.reverse()),l&&Math.abs(s)===m.length+1)return Math.sign(s)>0?{value:``}:{value:o};let h=m[Math.abs(s)-1];return h===void 0?a:{value:o.substring(h)}},isExported:!0},PS={description:E(`Returns text that occurs before a given substring or delimiter.`),args:[H(`text (string)`,E(`The source text.`)),H(`delimiter (string)`,E(`The substring after which text will be returned.`)),H(`instance_num (number, default=1)`,E(`The desired instance of the delimiter before which we extract the text. A negative number searches from the end.`)),H(`match_mode (number, default=0)`,E(`Searches the text for a delimiter match. By default, a case-sensitive match is done.`),cS),H(`match_end (number, default=0))`,E(`Whether to match a delimiter against the end of the text.`),lS),H(`if_not_found (string, default="${k.NotAvailable}")`,E(`Value to return if the delimiter is not found.`))],compute:function(e,t,n={value:1},r={value:0},i={value:0},a=new Xi){let o=N(e),s=M(n,this.locale),c=M(r,this.locale),l=M(i,this.locale);if(s===0)return new A(E(`The instance_num (%s) must not be zero.`,s));if(c!==0&&c!==1)return new A(E(`match_mode should have a value of 0 or 1.`));if(l!==0&&l!==1)return new A(E(`match_end should have a value of 0 or 1.`));let u=N(t);if(u===``)return Math.sign(s)>0?{value:``}:{value:o};let d=c===1?`gi`:`g`,f=ut(u),p=new RegExp(f,d),m=[...o.matchAll(p)].map(e=>e.index+f.length);if(s<0&&(m=m.reverse()),l&&Math.abs(s)===m.length+1)return Math.sign(s)>0?{value:o}:{value:``};let h=m[Math.abs(s)-1];return h===void 0?a:{value:o.substring(0,h-u.length)}},isExported:!0};var FS=l({HYPERLINK:()=>IS});let IS={description:E(`Creates a hyperlink in a cell.`),args:[H(`url (string)`,E(`The full URL of the link enclosed in quotation marks.`)),H(`link_label (string, optional)`,E(`The text to display in the cell, enclosed in quotation marks.`))],compute:function(e,t){let n=N(e).trim(),r=N(t)||n;return n===``?r:Ct(r,n)},isExported:!0},LS=[{name:E(`Array`),functions:dp},{name:E(`Database`),functions:gg},{name:E(`Date`),functions:M_},{name:E(`Filter`),functions:xv},{name:E(`Financial`),functions:Dv},{name:E(`Info`),functions:_b},{name:E(`Lookup`),functions:nx},{name:E(`Logical`),functions:Ab},{name:E(`Math`),functions:Vp},{name:E(`Misc`),functions:Fp},{name:E(`Operator`),functions:Sx},{name:E(`Statistical`),functions:rh},{name:E(`Text`),functions:oS},{name:E(`Engineering`),functions:mv},{name:E(`Web`),functions:FS},{name:E(`Parser`),functions:iS}],RS=/^[A-Z0-9\_\.]+$/,zS=new class extends g{mapping={};add(e,t){if(e=e.toUpperCase(),e in this.content)throw Error(`${e} is already present in this registry!`);return this.replace(e,t)}replace(e,t){if(e=e.toUpperCase(),!RS.test(e))throw Error(E(`Invalid function name %s. Function names can exclusively contain alphanumerical values separated by dots (.) or underscore (_)`,e));let n=ip(e,t);return lp(n),this.mapping[e]=BS(n),super.replace(e,n),this}};for(let e of LS){let t=e.functions;for(let n in t){let r=t[n];r.category=r.category||e.name,n=n.replace(/_/g,`.`),zS.add(n,{isExported:!1,...r}),KS(n,r.args)}}function BS(e){function t(...t){let i=[],a=op(e,t.length);for(let n=0;n<t.length;n++){let r=a(n)??-1,o=e.args[r],s=t[n];if(!Ir(s)&&o.acceptMatrixOnly)throw new qi(E(`Function %s expects the parameter '%s' to be reference to a cell or range.`,e.name,(n+1).toString()));i.push(!o.acceptMatrix)}return n(Ea(r.bind(this),t,i))}function n(t){return Ir(t)?wa(t,t=>US(t,e.name)):US(t,e.name),t}function r(...t){for(let n=0;n<t.length;n++){let r=t[n],i=op(e,t.length);if(!e.args[i(n)||n].acceptErrors&&!Ir(r)&&j(r?.value))return r}try{return i.apply(this,t)}catch(t){return VS(t,e.name)}}function i(...t){this.debug&&=!1;let n=e.compute.apply(this,t);return Ir(n)?typeof n[0][0]==`object`&&n[0][0]!==null&&`value`in n[0][0]?n:Ca(n,e=>({value:e})):typeof n==`object`&&n&&`value`in n?n:(e.name,{value:n})}return t}function VS(e,t){return HS(e)&&j(e.value)?(GS(e)&&US(e,t),e):(console.error(e),new A(WS+(GS(e)?` `+e.message:``)))}function HS(e){return e?.value!==void 0&&typeof e.value==`string`}function US(e,t){e.message?.includes(`[[FUNCTION_NAME]]`)&&(e.message=e.message.replace(`[[FUNCTION_NAME]]`,t))}let WS=E(`An unexpected error occurred. Submit a support ticket at odoo.com/help.`);function GS(e){return e?.message!==void 0&&typeof e.message==`string`}function KS(e,t){for(let n=0;n<t.length;n++){let r=t[n].proposalValues;r===void 0||r.length===0||up.add(`${e}_function_${t[n].name}_argument_proposals`,{sequence:50,autoSelectFirstProposal:!0,selectProposal:qS,getProposals:t=>{let i=t.functionContext;if(!i||i.parent.toUpperCase()!==e.toUpperCase()||i.argPosition!==n)return;let a=[],o=``;for(let{value:e,label:t}of r){switch(typeof e){case`string`:o=`"${e}"`;break;case`number`:o=e.toString();break;case`boolean`:o=e?`TRUE`:`FALSE`;break;default:}a.push({text:o,description:t,htmlContent:[{value:o,color:typeof e==`string`?ot.STRING:ot.NUMBER}],fuzzySearchKey:o,alwaysExpanded:!0})}return a}})}}function qS(e,t){let n=e.end,r=e.end;[`LEFT_PAREN`,`ARG_SEPARATOR`].includes(e.type)||(n=e.start),this.composer.stopComposerRangeSelection(),this.composer.changeComposerCursorSelection(n,r),this.composer.replaceComposerCursorSelection(t)}var JS=class{scope;code=``;constructor(e=new XS){this.scope=e}append(...e){this.code+=e.map(e=>e.toString()).join(`
20
+ ((value in cell) x (Grand Total of Grand Totals)) / ((Grand Row Total) x (Grand Column Total))`)}};function Zb(e,t){return E(`Oops—this pivot table is quite large (%s cells). Try simplifying it using the side panel.`,L(e,{format:`0,00`,locale:t}))}function Qb(e,t){let n=t.getPivotId(e);if(!n)throw new A(E(`There is no pivot with id "%s"`,e));return n}function $b(e,t,n){let{measures:r}=n.getPivotCoreDefinition(e);if(!r.find(e=>e.id===t))throw new A(E(`The argument %s is not a valid measure. Here are the measures: %s`,t,`(${r.map(e=>e.id).join(`, `)})`))}function ex(e){if(e.length%2!=0)throw new A(E(`Function PIVOT takes an even number of arguments.`))}function tx(e,t,n){let r=[],i=e.getters.getPivotCoreDefinition(t);if(i.type===`SPREADSHEET`&&i.dataSet){let{sheetId:t,zone:n}=i.dataSet,a=As(n),o=e.getters.getRangeFromSheetXC(t,a);if(o===void 0||o.invalidXc||o.invalidSheetName)throw new Yi;if(e.__originCellPosition&&o.sheetId===e.__originSheetId&&Hs(R(e.__originCellPosition),n))throw new Ji;r.push(o)}for(let i of n)i.computedBy&&r.push(...e.getters.getMeasureFullDependencies(t,i));let a=e.__originCellPosition;a&&r.length&&(e.updateDependencies?.(a),e.addDependencies?.(a,r))}var nx=l({ADDRESS:()=>ax,COLUMN:()=>ox,COLUMNS:()=>sx,HLOOKUP:()=>cx,INDEX:()=>lx,INDIRECT:()=>ux,LOOKUP:()=>dx,MATCH:()=>fx,OFFSET:()=>xx,PIVOT:()=>bx,PIVOT_HEADER:()=>yx,PIVOT_VALUE:()=>vx,ROW:()=>px,ROWS:()=>mx,VLOOKUP:()=>hx,XLOOKUP:()=>_x});let rx=[{value:!0,label:E(`A1 style (default)`)},{value:!1,label:E(`R1C1 style`)}],ix=[{value:!0,label:E(`Approximate match (default)`)},{value:!1,label:E(`Exact match`)}],ax={description:E(`Returns a cell reference as a string. `),args:[H(`row (number)`,E(`The row number of the cell reference. `)),H(`column (number)`,E(`The column number (not name) of the cell reference. A is column number 1. `)),H(`absolute_relative_mode (number, default=1)`,E(`An indicator of whether the reference is row/column absolute.`),[{value:1,label:E(`Absolute row and column (e.g. $A$1)`)},{value:2,label:E(`Absolute row, relative column (e.g. A$1)`)},{value:3,label:E(`Relative row, absolute column (e.g. $A1)`)},{value:4,label:E(`Relative row and column (e.g. A1)`)}]),H(`use_a1_notation (boolean, default=TRUE)`,E(`A boolean indicating whether to use A1 style notation or R1C1 style notation.`),rx),H(`sheet (string, optional)`,E(`A string indicating the name of the sheet into which the address points.`))],compute:function(e,t,n={value:1},r={value:!0},i){let a=ua(e,this.locale),o=ua(t,this.locale);if(a<1)return new A(Lu(a));if(o<1)return new A(Lu(o));let s=ua(n,this.locale);if(![1,2,3,4].includes(s))return new A(ia(1,4,s));let c=P(r),l;if(c){let e={rowFixed:[1,2].includes(s),colFixed:[1,3].includes(s)};l=T(o-1,a-1,e)}else l=([1,2].includes(s)?`R${a}`:`R[${a}]`)+([1,3].includes(s)?`C${o}`:`C[${o}]`);return i===void 0?l:Mc(N(i),l)},isExported:!0},ox={description:E(`Column number of a specified cell.`),args:[H(`cell_reference (meta, range<meta>, default='this cell')`,E(`The cell whose column number will be returned. Column A corresponds to 1. By default, the function use the cell in which the formula is entered.`))],compute:function(e){if(e===void 0)return this.__originCellPosition?.col===void 0?new A(E(`In this context, the function [[FUNCTION_NAME]] needs to have a cell or range in parameter.`)):this.__originCellPosition.col+1;if(e[0][0]===void 0)return new A(E(`The range is out of bounds.`));if(e[0][0].value===k.InvalidReference)return e[0][0];let t=this.getters.getRangeFromSheetXC(this.getters.getActiveSheetId(),e[0][0].value).zone.left;return e.length===1?t+1:Sa(e.length,1,(e,n)=>({value:t+e+1}))},isExported:!0},sx={description:E(`Number of columns in a specified array or range.`),args:[H(`range (any, range<any>)`,E(`The range whose column count will be returned.`))],compute:function(e){let t=I(e);return t[0][0]===void 0?new A(E(`The range is out of bounds.`)):t[0][0].value===k.InvalidReference?t[0][0]:t.length},isExported:!0},cx={description:E(`Horizontal lookup`),args:[H(`search_key (string, number, boolean)`,E(`The value to search for. For example, 42, 'Cats', or I24.`)),H(`range (any, range)`,E(`The range to consider for the search. The first row in the range is searched for the key specified in search_key.`)),H(`index (number)`,E(`The row index of the value to be returned, where the first row in range is numbered 1.`)),H(`is_sorted (boolean, default=true)`,E(`Indicates whether the row to be searched (the first row of the specified range) is sorted, in which case the closest match for search_key will be returned.`),ix)],compute:function(e,t,n,r={value:!0}){let i=Math.trunc(M(n?.value,this.locale)),a=I(t);if(1>i||i>a[0].length)return new A(E(`[[FUNCTION_NAME]] evaluates to an out of bounds range.`));let o=(e,t)=>e[t][0].value,s=a[P(r.value)?Na(a,e,`nextSmaller`,`asc`,a.length,o):Pa(a,e,`wildcard`,a.length,o,this.lookupCaches)];return s===void 0?na(e):s[i-1]},isExported:!0},lx={description:E(`Returns the content of a cell, specified by row and column offset.`),args:[H(`reference (any, range)`,E(`The range of cells from which the values are returned.`)),H(`row (number, default=0)`,E(`The index of the row to be returned from within the reference range of cells.`)),H(`column (number, default=0)`,E(`The index of the column to be returned from within the reference range of cells.`))],compute:function(e,t={value:0},n={value:0}){let r=I(e),i=M(t.value,this.locale),a=M(n.value,this.locale);return a<0||a-1>=r.length||i<0||i-1>=r[0].length?new A(E(`Index out of range.`)):i===0&&a===0?r:i===0?[r[a-1]]:a===0?r.map(e=>[e[i-1]]):r[a-1][i-1]},isExported:!0},ux={description:E(`Returns the content of a cell, specified by a string.`),args:[H(`reference (string)`,E(`The range of cells from which the values are returned.`)),H(`use_a1_notation (boolean, default=TRUE)`,E(`A boolean indicating whether to use A1 style notation (TRUE) or R1C1 style notation (FALSE).`),rx)],compute:function(e,t={value:!0}){let n=e?.value?.toString();if(!n)return new Yi(E(`Reference should be defined.`));if(!P(t))return new A(E(`R1C1 notation is not supported.`));let r=this.__originSheetId,i=this.__originCellPosition;i&&this.updateDependencies?.(i);let a=this.getters.getRangeFromSheetXC(r,n);if(a===void 0||a.invalidXc||a.invalidSheetName)return new Yi;i&&this.addDependencies?.(i,[a]);let o=[];for(let e=a.zone.left;e<=a.zone.right;e++){let t=[];for(let n=a.zone.top;n<=a.zone.bottom;n++){let r={sheetId:a.sheetId,col:e,row:n};t.push(this.getters.getEvaluatedCell(r))}o.push(t)}return o.length===1&&o[0].length===1?o[0][0]:o},isExported:!0},dx={description:E(`Look up a value.`),args:[H(`search_key (string, number, boolean)`,E(`The value to search for. For example, 42, 'Cats', or I24.`)),H(`search_array (any, range)`,E(`One method of using this function is to provide a single sorted row or column search_array to look through for the search_key with a second argument result_range. The other way is to combine these two arguments into one search_array where the first row or column is searched and a value is returned from the last row or column in the array. If search_key is not found, a non-exact match may be returned.`)),H(`result_range (any, range, optional)`,E(`The range from which to return a result. The value returned corresponds to the location where search_key is found in search_range. This range must be only a single row or column and should not be used if using the search_result_array method.`))],compute:function(e,t,n){let r=I(t),i=I(n),a=r.length,o=r[0].length,s=o>=a,c=Na(r,e,`nextSmaller`,`asc`,s?o:a,s?(e,t)=>e[0][t].value:(e,t)=>e[t][0].value);return c===-1||s&&r[0][c]===void 0||!s&&r[c][o-1]===void 0?na(e):i[0].length===0?s?r[a-1][c]:r[c][o-1]:(a=i.length,o=i[0].length,a!==1&&o!==1?new A(E(`The result_range must be a single row or a single column.`)):a>1?c>a-1?new A(E(`[[FUNCTION_NAME]] evaluates to an out of range row value %s.`,c+1)):i[c][0]:c>o-1?new A(E(`[[FUNCTION_NAME]] evaluates to an out of range column value %s.`,c+1)):i[0][c])},isExported:!0},fx={description:E(`Position of item in range that matches value.`),args:[H(`search_key (string, number, boolean)`,E(`The value to search for. For example, 42, 'Cats', or I24.`)),H(`range (any, range)`,E(`The one-dimensional array to be searched.`)),H(`search_type (number, default=1)`,E(`The search method is a number 1, 0 or -1 indicating which value to return. 1 finds the largest value less than or equal to search_key when range is sorted in ascending order. 0 finds the exact value when range is unsorted. -1 finds the smallest value greater than or equal to search_key when range is sorted in descending order.`),[{value:1,label:E(`Ascending order (default)`)},{value:0,label:E(`Exact match`)},{value:-1,label:E(`Descending order`)}])],compute:function(e,t,n={value:1}){let r=M(n,this.locale),i=I(t),a=i.length,o=i[0].length;if(a!==1&&o!==1)return new A(E(`The range must be a single row or a single column.`));let s=-1,c=a===1?(e,t)=>e[0][t].value:(e,t)=>e[t][0].value,l=a===1?i[0].length:i.length;switch(r=Math.sign(r),r){case 1:s=Na(i,e,`nextSmaller`,`asc`,l,c);break;case 0:s=Pa(i,e,`wildcard`,l,c,this.lookupCaches);break;case-1:s=Na(i,e,`nextGreater`,`desc`,l,c);break}return a===1&&i[0][s]===void 0||a!==1&&i[s]===void 0?na(e):s+1},isExported:!0},px={description:E(`Row number of a specified cell.`),args:[H(`cell_reference (meta, range<meta>, default='this cell')`,E(`The cell whose row number will be returned. By default, this function uses the cell in which the formula is entered.`))],compute:function(e){if(e===void 0)return this.__originCellPosition?.row===void 0?new A(E(`In this context, the function [[FUNCTION_NAME]] needs to have a cell or range in parameter.`)):this.__originCellPosition.row+1;if(e[0][0]===void 0)return new A(E(`The range is out of bounds.`));if(e[0][0].value===k.InvalidReference)return e[0][0];let t=this.getters.getRangeFromSheetXC(this.getters.getActiveSheetId(),e[0][0].value).zone.top;return e[0].length===1?t+1:Sa(1,e[0].length,(e,n)=>({value:t+n+1}))},isExported:!0},mx={description:E(`Number of rows in a specified array or range.`),args:[H(`range (any, range<any>)`,E(`The range whose row count will be returned.`))],compute:function(e){let t=I(e);return t[0][0]===void 0?new A(E(`The range is out of bounds.`)):t[0][0].value===k.InvalidReference?t[0][0]:t[0].length},isExported:!0},hx={description:E(`Vertical lookup.`),args:[H(`search_key (string, number, boolean)`,E(`The value to search for. For example, 42, 'Cats', or I24.`)),H(`range (any, range)`,E(`The range to consider for the search. The first column in the range is searched for the key specified in search_key.`)),H(`index (number)`,E(`The column index of the value to be returned, where the first column in range is numbered 1.`)),H(`is_sorted (boolean, default=true)`,E(`Indicates whether the column to be searched (the first column of the specified range) is sorted, in which case the closest match for search_key will be returned.`),ix)],compute:function(e,t,n,r={value:!0}){let i=Math.trunc(M(n?.value,this.locale)),a=I(t);if(1>i||i>a.length)return new A(E(`[[FUNCTION_NAME]] evaluates to an out of bounds range.`));let o=(e,t)=>e[0][t].value,s=P(r.value)?Na(a,e,`nextSmaller`,`asc`,a[0].length,o):Pa(a,e,`wildcard`,a[0].length,o,this.lookupCaches),c=a[i-1][s];return c===void 0?na(e):c},isExported:!0},gx={0:`strict`,1:`nextGreater`,"-1":`nextSmaller`,2:`wildcard`},_x={description:E(`Search a range for a match and return the corresponding item from a second range.`),args:[H(`search_key (string,number,boolean)`,E(`The value to search for.`)),H(`lookup_range (any, range)`,E(`The range to consider for the search. Should be a single column or a single row.`)),H(`return_range (any, range)`,E(`The range containing the return value. Should have the same dimensions as lookup_range.`)),H(`if_not_found (any, optional)`,E(`If a valid match is not found, return this value.`)),H(`match_mode (any, default=0)`,E(`Specifies how to match search_key with the items in lookup_range. `),[{value:0,label:E(`Exact match (default)`)},{value:-1,label:E(`Exact match or next smaller item`)},{value:1,label:E(`Exact match or next larger item`)},{value:2,label:E(`Wildcard character match`)}]),H(`search_mode (any, default=1)`,E(`Specifies the search mode to use. By default, a first to last search will be used.`),[{value:1,label:E(`Search first to last (default)`)},{value:-1,label:E(`Search last to first`)},{value:2,label:E(`Binary search (sorted ascending order)`)},{value:-2,label:E(`Binary search (sorted descending order)`)}])],compute:function(e,t,n,r,i={value:0},a={value:1}){let o=Math.trunc(M(i.value,this.locale)),s=Math.trunc(M(a.value,this.locale)),c=I(t),l=I(n);if(c.length!==1&&c[0].length!==1)return new A(E(`lookup_range should be either a single row or single column.`));if(![1,-1,2,-2].includes(s))return new A(E(`search_mode should be a value in [-1, 1, -2, 2].`));if(![-1,0,1,2].includes(o))return new A(E(`match_mode should be a value in [-1, 0, 1, 2].`));let u=c.length===1?`col`:`row`;if(o===2&&[-2,2].includes(s))return new A(E(`The search and match mode combination is not supported for XLOOKUP evaluation.`));if(u===`col`?l[0].length!==c[0].length:l.length!==c.length)return new A(E(`return_range should have the same dimensions as lookup_range.`));let d=u===`col`?(e,t)=>e[0][t].value:(e,t)=>e[t][0].value,f=u===`col`?c[0].length:c.length,p=gx[o],m=s===-1,h=s===2||s===-2?Na(c,e,p,s===2?`asc`:`desc`,f,d):Pa(c,e,p,f,d,this.lookupCaches,m);return h===-1?r===void 0?na(e):[[r]]:u===`col`?l.map(e=>[e[h]]):[l[h]]},isExported:!0},vx={description:E(`Get the value from a pivot.`),args:[H(`pivot_id (number,string)`,E(`ID of the pivot.`)),H(`measure_name (string)`,E(`Name of the measure.`)),H(`domain_field_name (string,repeating)`,E(`Field name.`)),H(`domain_value (number,string,boolean,repeating)`,E(`Value.`))],compute:function(e,t,...n){let r=N(e),i=N(t),a=Qb(r,this.getters);$b(a,i,this.getters),ex(n);let o=this.getters.getPivot(a),s=this.getters.getPivotCoreDefinition(a);tx(this,a,s.measures.filter(e=>e.id===i)),o.init({reload:o.needsReevaluation});let c=o.assertIsValid({throwOnError:!1});if(c)return c;if(!o.areDomainArgsFieldsValid(n)){let e=E(`Consider using a dynamic pivot formula: %s. Or re-insert the static pivot from the Data menu.`,`=PIVOT(${r})`);return{value:k.GenericError,message:E(`Dimensions don't match the pivot definition`)+`. `+e}}let l=o.parseArgsToPivotDomain(n);return this.getters.getActiveSheetId()===this.__originSheetId&&this.getters.getPivotPresenceTracker(a)?.trackValue(i,l),o.getPivotCellValueAndFormat(i,l)}},yx={description:E(`Get the header of a pivot.`),args:[H(`pivot_id (number,string)`,E(`ID of the pivot.`)),H(`domain_field_name (string,repeating)`,E(`Field name.`)),H(`domain_value (number,string,value,repeating)`,E(`Value.`))],compute:function(e,...t){let n=N(e),r=Qb(n,this.getters);ex(t);let i=this.getters.getPivot(r);tx(this,r,[]),i.init({reload:i.needsReevaluation});let a=i.assertIsValid({throwOnError:!1});if(a)return a;if(!i.areDomainArgsFieldsValid(t)){let e=E(`Consider using a dynamic pivot formula: %s. Or re-insert the static pivot from the Data menu.`,`=PIVOT(${n})`);return{value:k.GenericError,message:E(`Dimensions don't match the pivot definition`)+`. `+e}}let o=i.parseArgsToPivotDomain(t);this.getters.getActiveSheetId()===this.__originSheetId&&this.getters.getPivotPresenceTracker(r)?.trackHeader(o);let s=o.at(-1);if(s?.field===`measure`)return i.getPivotMeasureValue(N(s.value),o);let{value:c,format:l}=i.getPivotHeaderValueAndFormat(o);return{value:c,format:!s||s.field===`measure`||s.value===`false`?void 0:l}}},bx={description:E(`Get a pivot table.`),args:[H(`pivot_id (string)`,E(`ID of the pivot.`)),H(`row_count (number, optional)`,E(`number of rows`)),H(`include_total (boolean, default=TRUE)`,E(`Whether to include total/sub-totals or not.`)),H(`include_column_titles (boolean, default=TRUE)`,E(`Whether to include the column titles or not.`)),H(`column_count (number, optional)`,E(`number of columns`)),H(`include_measure_titles (boolean, default=TRUE)`,E(`Whether to include the measure titles row or not.`))],compute:function(e,t={value:1e4},n={value:!0},r={value:!0},i={value:Number.MAX_VALUE},a={value:!0}){let o=N(e),s=M(t,this.locale);if(s<0)return new A(E(`The number of rows must be positive.`));let c=M(i,this.locale);if(c<0)return new A(E(`The number of columns must be positive.`));let l={displayColumnHeaders:P(r),displayTotals:P(n),displayMeasuresRow:P(a)},u=Qb(o,this.getters),d=this.getters.getPivot(u),f=this.getters.getPivotCoreDefinition(u);tx(this,u,f.measures),d.init({reload:d.needsReevaluation});let p=d.assertIsValid({throwOnError:!1});if(p)return p;let m=d.getCollapsedTableStructure();if(m.numberOfCells>5e5)return new A(Zb(m.numberOfCells,this.locale));let h=m.getPivotCells(l),g=0;l.displayColumnHeaders&&(g=m.columns.length-1),l.displayMeasuresRow&&g++;let _=this.getters.getPivotName(u),v=Math.min(g+s,h[0].length);if(v===0)return[[{value:_}]];let y=Math.min(1+c,h.length),ee=[];for(let e of S(0,y)){ee[e]=[];for(let t of S(0,v)){let n=h[e][t];switch(n.type){case`EMPTY`:ee[e].push({value:``});break;case`HEADER`:let t=d.getPivotHeaderValueAndFormat(n.domain);ee[e].push(Bd(n.domain,t));break;case`MEASURE_HEADER`:ee[e].push(d.getPivotMeasureValue(n.measure,n.domain));break;case`VALUE`:ee[e].push(d.getPivotCellValueAndFormat(n.measure,n.domain));break}}}return(l.displayColumnHeaders||l.displayMeasuresRow)&&(ee[0][0]={value:_}),ee}},xx={description:E(`Returns a range reference shifted by a specified number of rows and columns from a starting cell reference.`),args:[H(`cell_reference (meta, range<meta>)`,E(`The starting point from which to count the offset rows and columns.`)),H(`offset_rows (number)`,E(`The number of rows to offset by.`)),H(`offset_columns (number)`,E(`The number of columns to offset by.`)),H(`height (number, default='height of cell_reference')`,E(`The number of rows of the range to return starting at the offset target.`)),H(`width (number, default='width of cell_reference')`,E(`The number of columns of the range to return starting at the offset target.`))],compute:function(e,t,n,r,i){if(j(e[0][0].value))return e[0][0];let a=e[0][0].value;if(!a)return new A(`In this context, the function OFFSET needs to have a cell or range in parameter.`);let o=Ts(a),s=e[0].length,c=e.length;if(r){let e=M(r,this.locale);if(e<1)return new A(E(`Height value is %(_height)s. It should be greater than or equal to 1.`,{_height:e}));s=e}if(i){let e=M(i,this.locale);if(e<1)return new A(E(`Width value is %(_width)s. It should be greater than or equal to 1.`,{_width:e}));c=e}let{sheetName:l}=jc(a),u=l&&this.getters.getSheetIdByName(l)||this.getters.getActiveSheetId(),d=M(t,this.locale),f=M(n,this.locale),p=this.__originCellPosition;p&&this.updateDependencies?.(p);let m=o.left+f,h=o.top+d;if(m<0||h<0)return new Yi(E(`OFFSET evaluates to an out of bounds range.`));let g={left:m,top:h,right:m+c-1,bottom:h+s-1},_=this.getters.getRangeFromZone(u,g);return _.invalidXc||_.invalidSheetName?new Yi:(p&&this.addDependencies?.(p,[_]),Sa(c,s,(e,t)=>this.getters.getEvaluatedCell({sheetId:u,col:m+e,row:h+t})))}};var Sx=l({ADD:()=>Cx,CONCAT:()=>wx,DIVIDE:()=>Tx,EQ:()=>kx,GT:()=>jx,GTE:()=>Mx,LT:()=>Nx,LTE:()=>Px,MINUS:()=>Fx,MULTIPLY:()=>Ix,NE:()=>Lx,POW:()=>Rx,UMINUS:()=>zx,UNARY_PERCENT:()=>Bx,UPLUS:()=>Vx});let Cx={description:E(`Sum of two numbers.`),args:[H(`value1 (number)`,E(`The first addend.`)),H(`value2 (number)`,E(`The second addend.`))],compute:function(e,t){return{value:M(e,this.locale)+M(t,this.locale),format:e?.format||t?.format}}},wx={description:E(`Concatenation of two values.`),args:[H(`value1 (string)`,E(`The value to which value2 will be appended.`)),H(`value2 (string)`,E(`The value to append to value1.`))],compute:function(e,t){return N(e)+N(t)},isExported:!0},Tx={description:E(`One number divided by another.`),args:[H(`dividend (number)`,E(`The number to be divided.`)),H(`divisor (number)`,E(`The number to divide by.`))],compute:function(e,t){let n=M(t,this.locale);return n===0?new $i(E(`The divisor must be different from zero.`)):{value:M(e,this.locale)/n,format:e?.format||t?.format}}};function Ex(e){return e===void 0||e.value===null}let Dx={number:0,string:``,boolean:!1};function Ox(e,t,n=2e-16){return Math.abs(e-t)<n}let kx={description:E(`Equal.`),args:[H(`value1 (string, number, boolean)`,E(`The first value.`)),H(`value2 (string, number, boolean)`,E(`The value to test against value1 for equality.`))],compute:function(e,t){if(j(e?.value))return e;if(j(t?.value))return t;let n=Ex(e)?Dx[typeof t?.value]:e?.value,r=Ex(t)?Dx[typeof e?.value]:t?.value;return typeof n==`string`&&(n=n.toUpperCase()),typeof r==`string`&&(r=r.toUpperCase()),typeof n==`number`&&typeof r==`number`?{value:Ox(n,r)}:{value:n===r}}};function Ax(e,t,n){if(j(e?.value))return e;if(j(t?.value))return t;let r=Ex(e)?Dx[typeof t?.value]:e?.value,i=Ex(t)?Dx[typeof e?.value]:t?.value;typeof r!=`number`&&(r=N(r).toUpperCase()),typeof i!=`number`&&(i=N(i).toUpperCase());let a=typeof r,o=typeof i;return a===`string`&&o===`number`?{value:!0}:o===`string`&&a===`number`?{value:!1}:{value:n(r,i)}}let jx={description:E(`Strictly greater than.`),args:[H(`value1 (number, string, boolean)`,E(`The value to test as being greater than value2.`)),H(`value2 (number, string, boolean)`,E(`The second value.`))],compute:function(e,t){return Ax(e,t,(e,t)=>typeof e==`number`&&typeof t==`number`?!Ox(e,t)&&e>t:e>t)}},Mx={description:E(`Greater than or equal to.`),args:[H(`value1 (number, string, boolean)`,E(`The value to test as being greater than or equal to value2.`)),H(`value2 (number, string, boolean)`,E(`The second value.`))],compute:function(e,t){return Ax(e,t,(e,t)=>typeof e==`number`&&typeof t==`number`?Ox(e,t)||e>t:e>=t)}},Nx={description:E(`Less than.`),args:[H(`value1 (number, string, boolean)`,E(`The value to test as being less than value2.`)),H(`value2 (number, string, boolean)`,E(`The second value.`))],compute:function(e,t){let n=Mx.compute.bind(this)(e,t);return j(n.value)?n:{value:!n.value}}},Px={description:E(`Less than or equal to.`),args:[H(`value1 (number, string, boolean)`,E(`The value to test as being less than or equal to value2.`)),H(`value2 (number, string, boolean)`,E(`The second value.`))],compute:function(e,t){let n=jx.compute.bind(this)(e,t);return j(n.value)?n:{value:!n.value}}},Fx={description:E(`Difference of two numbers.`),args:[H(`value1 (number)`,E(`The minuend, or number to be subtracted from.`)),H(`value2 (number)`,E(`The subtrahend, or number to subtract from value1.`))],compute:function(e,t){return{value:M(e,this.locale)-M(t,this.locale),format:e?.format||t?.format}}},Ix={description:E(`Product of two numbers`),args:[H(`factor1 (number)`,E(`The first multiplicand.`)),H(`factor2 (number)`,E(`The second multiplicand.`))],compute:function(e,t){return{value:M(e,this.locale)*M(t,this.locale),format:e?.format||t?.format}}},Lx={description:E(`Not equal.`),args:[H(`value1 (string, number, boolean)`,E(`The first value.`)),H(`value2 (string, number, boolean)`,E(`The value to test against value1 for inequality.`))],compute:function(e,t){let n=kx.compute.bind(this)(e,t);return j(n.value)?n:{value:!n.value}}},Rx={description:E(`A number raised to a power.`),args:[H(`base (number)`,E(`The number to raise to the exponent power.`)),H(`exponent (number)`,E(`The exponent to raise base to.`))],compute:function(e,t){return jm.compute.bind(this)(e,t)}},zx={description:E(`A number with the sign reversed.`),args:[H(`value (number)`,E(`The number to have its sign reversed. Equivalently, the number to multiply by -1.`))],compute:function(e){return{value:-M(e,this.locale),format:e?.format}}},Bx={description:E(`Value interpreted as a percentage.`),args:[H(`percentage (number)`,E(`The value to interpret as a percentage.`))],compute:function(e){return M(e,this.locale)/100}},Vx={description:E(`A specified number, unchanged.`),args:[H(`value (any)`,E(`The number to return.`))],compute:function(e={value:null}){return e}},W=e=>({transform:t=>t*e,inverseTransform:t=>t/e}),Hx={transform:e=>e,inverseTransform:e=>e},Ux=1e-10,Wx=.0254,Gx=Wx/72,Kx=.3048,qx=.9144,Jx=1609.34,Yx=1852,Xx=946073047258e4,Zx={g:{...Hx,category:`weight`},u:{...W(166053e-29),category:`weight`},grain:{...W(.0647989),category:`weight`},ozm:{...W(28.3495),category:`weight`},lbm:{...W(453.592),category:`weight`},stone:{...W(6350.29),category:`weight`},sg:{...W(14593.90294),category:`weight`},cwt:{...W(45359.237),category:`weight`},uk_cwt:{...W(50802.3),category:`weight`},ton:{...W(907184.74),category:`weight`},uk_ton:{...W(1016046.9),category:`weight`},m:{...Hx,category:`distance`},km:{...W(1e3),category:`distance`},ang:{...W(Ux),category:`distance`},Picapt:{...W(Gx),category:`distance`},pica:{...W(Wx/6),category:`distance`},in:{...W(Wx),category:`distance`},ft:{...W(Kx),category:`distance`},yd:{...W(qx),category:`distance`},ell:{...W(1.143),category:`distance`},mi:{...W(Jx),category:`distance`},survey_mi:{...W(1609.34),category:`distance`},Nmi:{...W(Yx),category:`distance`},ly:{...W(Xx),category:`distance`},parsec:{...W(0x6da012f95c9fd0),category:`distance`},sec:{...Hx,category:`time`},min:{...W(60),category:`time`},hr:{...W(3600),category:`time`},day:{...W(86400),category:`time`},yr:{...W(31556952),category:`time`},Pa:{...Hx,category:`pressure`},bar:{...W(1e5),category:`pressure`},mmHg:{...W(133.322),category:`pressure`},Torr:{...W(133.322),category:`pressure`},psi:{...W(6894.76),category:`pressure`},atm:{...W(101325),category:`pressure`},N:{...Hx,category:`force`},dyn:{...W(1e-5),category:`force`},pond:{...W(.00980665),category:`force`},lbf:{...W(4.44822),category:`force`},J:{...Hx,category:`energy`},eV:{...W(160218e-24),category:`energy`},e:{...W(1e-7),category:`energy`},flb:{...W(1.3558179483),category:`energy`},c:{...W(4.184),category:`energy`},cal:{...W(4.1868),category:`energy`},BTU:{...W(1055.06),category:`energy`},Wh:{...W(3600),category:`energy`},HPh:{...W(2684520),category:`energy`},W:{...Hx,category:`power`},PS:{...W(735.499),category:`power`},HP:{...W(745.7),category:`power`},T:{...Hx,category:`magnetism`},ga:{...W(1e-4),category:`magnetism`},K:{...Hx,category:`temperature`},C:{transform:e=>e+273.15,inverseTransform:e=>e-273.15,category:`temperature`},F:{transform:e=>(e-32)*5/9+273.15,inverseTransform:e=>(e-273.15)*9/5+32,category:`temperature`},Rank:{...W(5/9),category:`temperature`},Reau:{transform:e=>e*1.25+273.15,inverseTransform:e=>(e-273.15)/1.25,category:`temperature`},"m^3":{...Hx,category:`volume`,order:3},"ang^3":{...W(Ux**3),category:`volume`,order:3},"Picapt^3":{...W(Gx**3),category:`volume`,order:3},tsp:{...W(492892e-11),category:`volume`},tspm:{...W(5e-6),category:`volume`},tbs:{...W(14786764825785619e-21),category:`volume`},"in^3":{...W(Wx**3),category:`volume`,order:3},oz:{...W(295735295625e-16),category:`volume`},cup:{...W(237e-6),category:`volume`},pt:{...W(.0004731765),category:`volume`},uk_pt:{...W(568261e-9),category:`volume`},qt:{...W(.0009463529),category:`volume`},l:{...W(.001),category:`volume`},uk_qt:{...W(.0011365225),category:`volume`},gal:{...W(.0037854118),category:`volume`},uk_gal:{...W(.00454609),category:`volume`},"ft^3":{...W(Kx**3),category:`volume`,order:3},bushel:{...W(.0352390704),category:`volume`},barrel:{...W(.158987295),category:`volume`},"yd^3":{...W(qx**3),category:`volume`,order:3},MTON:{...W(1.13267386368),category:`volume`},GRT:{...W(2.83168),category:`volume`},"mi^3":{...W(Jx**3),category:`volume`,order:3},"Nmi^3":{...W(Yx**3),category:`volume`,order:3},"ly^3":{...W(Xx**3),category:`volume`,order:3},"m^2":{...Hx,category:`area`,order:2},"ang^2":{...W(Ux**2),category:`area`,order:2},"Picapt^2":{...W(Gx**2),category:`area`,order:2},"in^2":{...W(Wx**2),category:`area`,order:2},"ft^2":{...W(Kx**2),category:`area`,order:2},"yd^2":{...W(qx**2),category:`area`,order:2},ar:{...W(100),category:`area`},Morgen:{...W(2500),category:`area`},uk_acre:{...W(4046.8564224),category:`area`},us_acre:{...W(4046.8726098743),category:`area`},ha:{...W(1e4),category:`area`},"mi^2":{...W(Jx**2),category:`area`,order:2},"Nmi^2":{...W(Yx**2),category:`area`,order:2},"ly^2":{...W(Xx**2),category:`area`,order:2},bit:{...Hx,category:`information`},byte:{...W(8),category:`information`},"m/s":{...Hx,category:`speed`},"m/hr":{...W(1/3600),category:`speed`},"km/hr":{...W(1/3.6),category:`speed`},mph:{...W(.44704),category:`speed`},kn:{...W(.5144444444),category:`speed`},admkn:{...W(.5147733333),category:`speed`}},Qx={shweight:`cwt`,lcwt:`uk_cwt`,hweight:`uk_cwt`,LTON:`uk_ton`,brton:`uk_ton`,pc:`parsec`,Pica:`Picapt`,d:`day`,mn:`min`,s:`sec`,p:`Pa`,at:`atm`,dy:`dyn`,ev:`eV`,hh:`HPh`,wh:`Wh`,btu:`BTU`,h:`HP`,cel:`C`,fah:`F`,kel:`K`,us_pt:`pt`,L:`l`,lt:`l`,ang3:`ang^3`,ft3:`ft^3`,in3:`in^3`,ly3:`ly^3`,m3:`m^3`,mi3:`mi^3`,yd3:`yd^3`,Nmi3:`Nmi^3`,Picapt3:`Picapt^3`,"Pica^3":`Picapt^3`,Pica3:`Picapt^3`,regton:`GRT`,ang2:`ang^2`,ft2:`ft^2`,in2:`in^2`,ly2:`ly^2`,m2:`m^2`,mi2:`mi^2`,Nmi2:`Nmi^2`,Picapt2:`Picapt^2`,"Pica^2":`Picapt^2`,Pica2:`Picapt^2`,yd2:`yd^2`,"m/h":`m/hr`,"m/sec":`m/s`},$x={"":1,Y:1e24,Z:1e21,E:0xde0b6b3a7640000,P:0x38d7ea4c68000,T:0xe8d4a51000,G:1e9,M:1e6,k:1e3,h:100,da:10,e:10,d:.1,c:.01,m:.001,u:1e-6,n:1e-9,p:1e-12,f:1e-15,a:1e-18,z:1e-21,y:1e-21,Yi:2**80,Zi:2**70,Ei:2**60,Pi:2**50,Ti:2**40,Gi:2**30,Mi:2**20,ki:2**10},eS={weight:E(`Weight`),distance:E(`Distance`),time:E(`Time`),pressure:E(`Pressure`),force:E(`Force`),energy:E(`Energy`),power:E(`Power`),magnetism:E(`Magnetism`),temperature:E(`Temperature`),volume:E(`Volume`),area:E(`Area`),information:E(`Information`),speed:E(`Speed`)},tS=Object.entries(Zx).map(([e,t])=>({value:e,label:nS(t.category)}));function nS(e){return eS[e]??``}function rS(e){for(let[t,n]of Object.entries($x)){if(t&&!e.startsWith(t))continue;let r=e.slice(t.length),i=Zx[r];if(!i&&Qx[r]&&(i=Zx[Qx[r]]),i)return{...i,factor:i.order?n**+i.order:n}}}var iS=l({CONVERT:()=>aS});let aS={description:E(`Converts a numeric value to a different unit of measure.`),args:[H(`value (number)`,E(`the numeric value in start_unit to convert to end_unit`)),H(`start_unit (string)`,E(`The starting unit, the unit currently assigned to value`),tS),H(`end_unit (string)`,E(`The unit of measure into which to convert value`),tS)],compute:function(e,t,n){let r=M(e,this.locale),i=N(t),a=N(n),o=rS(i),s=rS(a);return o?s?o.category===s.category?{value:s.inverseTransform(o.factor*o.transform(r))/s.factor,format:e?.format}:{value:k.GenericError,message:E(`Incompatible units of measure ('%s' vs '%s')`,nS(o.category),nS(s.category))}:{value:k.GenericError,message:E(`Invalid units of measure ('%s')`,a)}:{value:k.GenericError,message:E(`Invalid units of measure ('%s')`,i)}},isExported:!0};var oS=l({CHAR:()=>uS,CLEAN:()=>dS,CONCATENATE:()=>fS,EXACT:()=>pS,FIND:()=>mS,JOIN:()=>hS,LEFT:()=>gS,LEN:()=>_S,LOWER:()=>vS,MID:()=>yS,PROPER:()=>bS,REGEXEXTRACT:()=>xS,REPLACE:()=>SS,RIGHT:()=>CS,SEARCH:()=>wS,SPLIT:()=>TS,SUBSTITUTE:()=>ES,TEXT:()=>jS,TEXTAFTER:()=>NS,TEXTBEFORE:()=>PS,TEXTJOIN:()=>DS,TEXTSPLIT:()=>OS,TRIM:()=>kS,UPPER:()=>AS,VALUE:()=>MS});let sS=/[A-Za-zÀ-ÖØ-öø-ÿ]+/g,cS=[{value:0,label:E(`Case-sensitive (default)`)},{value:1,label:E(`Case-insensitive`)}],lS=[{value:0,label:E(`Don't match to end (default)`)},{value:1,label:E(`Match to end`)}],uS={description:E(`Gets character associated with number.`),args:[H(`table_number (number)`,E(`The number of the character to look up from the current Unicode table in decimal format.`))],compute:function(e){let t=Math.trunc(M(e,this.locale));return t<1?new A(E(`The table_number (%s) is out of range.`,t)):String.fromCharCode(t)},isExported:!0},dS={description:E(`Remove non-printable characters from a piece of text.`),args:[H(`text (string)`,E(`The text whose non-printable characters are to be removed.`))],compute:function(e){let t=N(e),n=``;for(let e of t)e&&e.charCodeAt(0)>31&&(n+=e);return n},isExported:!0},fS={description:E(`Appends strings to one another.`),args:[H(`string1 (string, range<string>)`,E(`The initial string.`)),H(`string2 (string, range<string>, repeating)`,E(`More strings to append in sequence.`))],compute:function(...e){return ya(e,(e,t)=>e+N(t),``)},isExported:!0},pS={description:E(`Tests whether two strings are identical.`),args:[H(`string1 (string)`,E(`The first string to compare.`)),H(`string2 (string)`,E(`The second string to compare.`))],compute:function(e,t){return N(e)===N(t)},isExported:!0},mS={description:E(`First position of string found in text, case-sensitive.`),args:[H(`search_for (string)`,E(`The string to look for within text_to_search.`)),H(`text_to_search (string)`,E(`The text to search for the first occurrence of search_for.`)),H(`starting_at (number, default=1)`,E(`The character within text_to_search at which to start the search.`))],compute:function(e,t,n={value:1}){let r=N(e),i=N(t),a=M(n,this.locale);if(i===``)return new A(E(`The text_to_search must be non-empty.`));if(a<1)return new A(E(`The starting_at (%s) must be greater than or equal to 1.`,a));let o=i.indexOf(r,a-1);return o===-1?new A(E(`In [[FUNCTION_NAME]] evaluation, cannot find '%s' within '%s'.`,r,i)):o+1},isExported:!0},hS={description:E(`Concatenates elements of arrays with delimiter.`),args:[H(`delimiter (string)`,E(`The character or string to place between each concatenated value.`)),H(`value_or_array1 (string, range<string>)`,E(`The value or values to be appended using delimiter.`)),H(`value_or_array2 (string, range<string>, repeating)`,E(`More values to be appended using delimiter.`))],compute:function(e,...t){let n=N(e);return ya(t,(e,t)=>(e?e+n:``)+N(t),``)}},gS={description:E(`Substring from beginning of specified string.`),args:[H(`text (string)`,E(`The string from which the left portion will be returned.`)),H(`number_of_characters (number, optional)`,E(`The number of characters to return from the left side of string.`))],compute:function(e,...t){let n=t.length?M(t[0],this.locale):1;return n<0?new A(E(`The number_of_characters (%s) must be positive or null.`,n)):N(e).substring(0,n)},isExported:!0},_S={description:E(`Length of a string.`),args:[H(`text (string)`,E(`The string whose length will be returned.`))],compute:function(e){return N(e).length},isExported:!0},vS={description:E(`Converts a specified string to lowercase.`),args:[H(`text (string)`,E(`The string to convert to lowercase.`))],compute:function(e){return N(e).toLowerCase()},isExported:!0},yS={description:E(`A segment of a string.`),args:[H(`text (string)`,E(`The string to extract a segment from.`)),H(`starting_at (number)`,E(`The index from the left of string from which to begin extracting. The first character in string has the index 1.`)),H(`extract_length (number)`,E(`The length of the segment to extract.`))],compute:function(e,t,n){let r=N(e),i=M(t,this.locale),a=M(n,this.locale);return i<1?new A(E(`The starting_at argument (%s) must be positive greater than one.`,i.toString())):a<0?new A(E(`The extract_length argument (%s) must be positive or null.`,a)):r.slice(i-1,i+a-1)},isExported:!0},bS={description:E(`Capitalizes each word in a specified string.`),args:[H(`text_to_capitalize (string)`,E(`The text which will be returned with the first letter of each word in uppercase and all other letters in lowercase.`))],compute:function(e){return N(e).replace(sS,e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase())},isExported:!0},xS={description:E(`Extract text from a string based on the supplied regular expression.`),args:[H(`text (string)`,E(`The string on which you want to extract text.`)),H(`pattern (string)`,E(`The regular expression pattern to match against the text.`)),H(`return_mode (number, default=0)`,E(`0 = first match, 1 = all matches as an array, 2 = capturing groups from the first match as an array.`),[{value:0,label:E(`First match`)},{value:1,label:E(`All matches`)},{value:2,label:E(`Capture groups of first match`)}]),H(`case_sensitivity (number, default=0)`,E(`Whether the match is case-sensitive.`),[{value:0,label:E(`Case-sensitive`)},{value:1,label:E(`Case-insensitive`)}])],compute:function(e,t,n={value:0},r={value:0}){let i=N(e),a=N(t),o=M(n,this.locale),s=M(r,this.locale);if(i===``||a===``)return{value:``};if(o<0||o>2)return new A(E(`The return_mode (%s) must be 0, 1 or 2.`,o));if(s!==0&&s!==1)return new A(E(`The case_sensitivity (%s) must be 0 or 1.`,s));let c=s===1?`gi`:`g`,l;try{l=new RegExp(a,c)}catch{return new A(E(`Invalid regular expression`))}let u=[...i.matchAll(l)];return u.length===0?{value:k.NotAvailable,message:E(`No matches found.`)}:o===0?u[0][0]:o===1?u.map(e=>[e[0]]):u[0].length<2?new A(E(`No capturing groups found.`)):u[0].slice(1).map(e=>[e])},isExported:!0},SS={description:E(`Replaces part of a text string with different text.`),args:[H(`text (string)`,E(`The text, a part of which will be replaced.`)),H(`position (number)`,E(`The position where the replacement will begin (starting from 1).`)),H(`length (number)`,E(`The number of characters in the text to be replaced.`)),H(`new_text (string)`,E(`The text which will be inserted into the original text.`))],compute:function(e,t,n,r){let i=M(t,this.locale);if(i<1)return new A(E(`The position (%s) must be greater than or equal to 1.`,i));let a=N(e),o=M(n,this.locale),s=N(r);return a.substring(0,i-1)+s+a.substring(i-1+o)},isExported:!0},CS={description:E(`A substring from the end of a specified string.`),args:[H(`text (string)`,E(`The string from which the right portion will be returned.`)),H(`number_of_characters (number, optional)`,E(`The number of characters to return from the right side of string.`))],compute:function(e,...t){let n=t.length?M(t[0],this.locale):1;if(n<0)return new A(E(`The number_of_characters (%s) must be positive or null.`,n));let r=N(e),i=r.length;return r.substring(i-n,i)},isExported:!0},wS={description:E(`First position of string found in text, ignoring case.`),args:[H(`search_for (string)`,E(`The string to look for within text_to_search.`)),H(`text_to_search (string)`,E(`The text to search for the first occurrence of search_for.`)),H(`starting_at (number, default=1)`,E(`The character within text_to_search at which to start the search.`))],compute:function(e,t,n={value:1}){let r=N(e).toLowerCase(),i=N(t).toLowerCase(),a=M(n,this.locale);if(i===``)return{value:k.GenericError,message:E(`The text_to_search must be non-empty.`)};if(a<1)return{value:k.GenericError,message:E(`The starting_at (%s) must be greater than or equal to 1.`,a)};let o=i.indexOf(r,a-1);return o===-1?{value:k.GenericError,message:E(`In [[FUNCTION_NAME]] evaluation, cannot find '%s' within '%s'.`,r,i)}:{value:o+1}},isExported:!0},TS={description:E(`Split text by specific character delimiter(s).`),args:[H(`text (string)`,E(`The text to divide.`)),H(`delimiter (string)`,E(`The character or characters to use to split text.`)),H(`split_by_each (boolean, default=true})`,E(`Whether or not to divide text around each character contained in delimiter.`)),H(`remove_empty_text (boolean, default=true)`,E(`Whether or not to remove empty text messages from the split results. The default behavior is to treat consecutive delimiters as one (if TRUE). If FALSE, empty cells values are added between consecutive delimiters.`))],compute:function(e,t,n={value:!0},r={value:!0}){let i=N(e),a=ut(N(t)),o=P(n),s=P(r);if(a.length<=0)return new A(E(`The delimiter (%s) must be not be empty.`,a));let c=o?RegExp(`[${a}]`,`g`):new RegExp(a,`g`),l=i.split(c);return s&&(l=l.filter(e=>e!==``)),Ta([l])},isExported:!1},ES={description:E(`Replaces existing text with new text in a string.`),args:[H(`text_to_search (string)`,E(`The text within which to search and replace.`)),H(`search_for (string)`,E(`The string to search for within text_to_search.`)),H(`replace_with (string)`,E(`The string that will replace search_for.`)),H(`occurrence_number (number, optional)`,E(`The instance of search_for within text_to_search to replace with replace_with. By default, all occurrences of search_for are replaced; however, if occurrence_number is specified, only the indicated instance of search_for is replaced.`))],compute:function(e,t,n,r){let i=M(r,this.locale);if(i<0)return new A(E(`The occurrenceNumber (%s) must be positive or null.`,i));let a=N(e),o=N(t);if(o===``)return a;let s=N(n),c=new RegExp(ut(o),`g`);if(i===0)return a.replace(c,s);let l=0;return a.replace(c,e=>++l===i?s:e)},isExported:!0},DS={description:E(`Combines text from multiple strings and/or arrays.`),args:[H(`delimiter (string)`,E(` A string, possible empty, or a reference to a valid string. If empty, the text will be simply concatenated.`)),H(`ignore_empty (boolean)`,E(`A boolean; if TRUE, empty cells selected in the text arguments won't be included in the result.`),[{value:!0,label:E(`Ignore empty cells`)},{value:!1,label:E(`Include empty cells (default)`)}]),H(`text1 (string, range<string>)`,E(`Any text item. This could be a string, or an array of strings in a range.`)),H(`text2 (string, range<string>, repeating)`,E(`Additional text item(s).`))],compute:function(e,t={value:!0},...n){let r=N(e),i=P(t),a=0;return ya(n,(e,t)=>i&&N(t)===``?e:(a++?e+r:``)+N(t),``)},isExported:!0},OS={description:E(`Splits text into rows or columns using specified column and row delimiters.`),args:[H(`text (string)`,E(`The text to split.`)),H(`col_delimiter (string, range<string>)`,E(`Character or string to split columns by.`)),H(`row_delimiter (string, range<string>, optional)`,E(`Character or string to split rows by.`)),H(`ignore_empty (boolean, default=false)`,E(`Whether to ignore empty cells.`),[{value:!1,label:E(`Include empty cells (default)`)},{value:!0,label:E(`Ignore empty cells`)}]),H(`match_mode (number, default=0)`,E(`Searches the text for a delimiter match. By default, a case-sensitive match is done.`),cS),H(`pad_with (string, default="${k.NotAvailable}")`,E(`The value to use for padding empty cells.`))],compute:function(e,t,n,r={value:!1},i={value:0},a=new Xi){let o=N(e);if(o.length<=0)return new A(E(`No text to split.`));if(t===void 0&&n===void 0)return new A(E(`At least one delimiter must be provided.`));let s=I(t).flat().map(e=>ut(N(e))),c=I(n).flat().map(e=>ut(N(e)));if(s.some(e=>e===``)||c.some(e=>e===``))return new A(E(`The delimiters cannot be empty values.`));let l=P(r),u=M(i,this.locale);if(![0,1].includes(u))return new A(E(`match_mode should be a value of 0 or 1.`));let d=[],f=u===1?`gi`:`g`,p=c.filter(e=>!s.includes(e)),m=p.length?o.split(new RegExp(p.join(`|`),f)):[o];l&&(m=m.filter(e=>e!==``));let h=new RegExp(s.join(`|`),f);for(let e of m){let t=s.length?e.split(h):[e];l&&(t=t.filter(e=>e!==``)),d.push(t.map(e=>({value:e})))}let g=Math.max(...d.map(e=>e.length));for(let e of d)for(;e.length<g;)e.push(a);return Ta(d)},isExported:!0},kS={description:E(`Removes space characters.`),args:[H(`text (string)`,E(`The text or reference to a cell containing text to be trimmed.`))],compute:function(e){return Xt(N(e))},isExported:!0},AS={description:E(`Converts a specified string to uppercase.`),args:[H(`text (string)`,E(`The string to convert to uppercase.`))],compute:function(e){return N(e).toUpperCase()},isExported:!0},jS={description:E(`Converts a number to text according to a specified format.`),args:[H(`number (number)`,E(`The number, date or time to format.`)),H(`format (string)`,E(`The case-sensitive format of the result, enclosed in quotation marks. Examples: "0.00" rounded to 2 decimal places, "hh:mm:ss" for hour:minutes:seconds.`))],compute:function(e,t){return L(M(e,this.locale),{format:N(t),locale:this.locale})},isExported:!0},MS={description:E(`Converts a string to a numeric value.`),args:[H(`value (number)`,E(`the string to be converted`))],compute:function(e){return M(e,this.locale)},isExported:!0},NS={description:E(`Returns text that occurs after a given substring or delimiter.`),args:[H(`text (string)`,E(`The source text.`)),H(`delimiter (string)`,E(`The substring after which text will be returned.`)),H(`instance_num (number, default=1)`,E(`The desired instance of the delimiter after which we extract the text. A negative number searches from the end.`)),H(`match_mode (number, default=0)`,E(`Searches the text for a delimiter match. By default, a case-sensitive match is done.`),cS),H(`match_end (number, default=0))`,E(`Whether to treat the end of text as a delimiter.`),lS),H(`if_not_found (string, default="${k.NotAvailable}")`,E(`Value to return if the delimiter is not found.`))],compute:function(e,t,n={value:1},r={value:0},i={value:0},a=new Xi){let o=N(e),s=M(n,this.locale),c=M(r,this.locale),l=M(i,this.locale);if(s===0)return new A(E(`The instance_num (%s) must not be zero.`,s));if(c!==0&&c!==1)return new A(E(`match_mode should have a value of 0 or 1.`));if(l!==0&&l!==1)return new A(E(`match_end should have a value of 0 or 1.`));let u=N(t);if(u===``)return Math.sign(s)>0?{value:o}:{value:``};let d=c===1?`gi`:`g`,f=ut(u),p=new RegExp(f,d),m=[...o.matchAll(p)].map(e=>e.index+f.length);if(s<0&&(m=m.reverse()),l&&Math.abs(s)===m.length+1)return Math.sign(s)>0?{value:``}:{value:o};let h=m[Math.abs(s)-1];return h===void 0?a:{value:o.substring(h)}},isExported:!0},PS={description:E(`Returns text that occurs before a given substring or delimiter.`),args:[H(`text (string)`,E(`The source text.`)),H(`delimiter (string)`,E(`The substring after which text will be returned.`)),H(`instance_num (number, default=1)`,E(`The desired instance of the delimiter before which we extract the text. A negative number searches from the end.`)),H(`match_mode (number, default=0)`,E(`Searches the text for a delimiter match. By default, a case-sensitive match is done.`),cS),H(`match_end (number, default=0))`,E(`Whether to match a delimiter against the end of the text.`),lS),H(`if_not_found (string, default="${k.NotAvailable}")`,E(`Value to return if the delimiter is not found.`))],compute:function(e,t,n={value:1},r={value:0},i={value:0},a=new Xi){let o=N(e),s=M(n,this.locale),c=M(r,this.locale),l=M(i,this.locale);if(s===0)return new A(E(`The instance_num (%s) must not be zero.`,s));if(c!==0&&c!==1)return new A(E(`match_mode should have a value of 0 or 1.`));if(l!==0&&l!==1)return new A(E(`match_end should have a value of 0 or 1.`));let u=N(t);if(u===``)return Math.sign(s)>0?{value:``}:{value:o};let d=c===1?`gi`:`g`,f=ut(u),p=new RegExp(f,d),m=[...o.matchAll(p)].map(e=>e.index+f.length);if(s<0&&(m=m.reverse()),l&&Math.abs(s)===m.length+1)return Math.sign(s)>0?{value:o}:{value:``};let h=m[Math.abs(s)-1];return h===void 0?a:{value:o.substring(0,h-u.length)}},isExported:!0};var FS=l({HYPERLINK:()=>IS});let IS={description:E(`Creates a hyperlink in a cell.`),args:[H(`url (string)`,E(`The full URL of the link enclosed in quotation marks.`)),H(`link_label (string, optional)`,E(`The text to display in the cell, enclosed in quotation marks.`))],compute:function(e,t){let n=N(e).trim(),r=N(t)||n;return n===``?r:Ct(r,n)},isExported:!0},LS=[{name:E(`Array`),functions:dp},{name:E(`Database`),functions:gg},{name:E(`Date`),functions:M_},{name:E(`Filter`),functions:xv},{name:E(`Financial`),functions:Dv},{name:E(`Info`),functions:_b},{name:E(`Lookup`),functions:nx},{name:E(`Logical`),functions:Ab},{name:E(`Math`),functions:Vp},{name:E(`Misc`),functions:Fp},{name:E(`Operator`),functions:Sx},{name:E(`Statistical`),functions:rh},{name:E(`Text`),functions:oS},{name:E(`Engineering`),functions:mv},{name:E(`Web`),functions:FS},{name:E(`Parser`),functions:iS}],RS=/^[A-Z0-9\_\.]+$/,zS=new class extends g{mapping={};add(e,t){if(e=e.toUpperCase(),e in this.content)throw Error(`${e} is already present in this registry!`);return this.replace(e,t)}replace(e,t){if(e=e.toUpperCase(),!RS.test(e))throw Error(E(`Invalid function name %s. Function names can exclusively contain alphanumerical values separated by dots (.) or underscore (_)`,e));let n=ip(e,t);return lp(n),this.mapping[e]=BS(n),super.replace(e,n),this}};for(let e of LS){let t=e.functions;for(let n in t){let r=t[n];r.category=r.category||e.name,n=n.replace(/_/g,`.`),zS.add(n,{isExported:!1,...r}),KS(n,r.args)}}function BS(e){let t=[];function n(...n){let a=[];t=Array(n.length);let o=op(e,n.length);for(let r=0;r<n.length;r++){let i=o(r)??-1,s=e.args[i];t[r]=s;let c=n[r];if(!Ir(c)&&s.acceptMatrixOnly)throw new qi(E(`Function %s expects the parameter '%s' to be reference to a cell or range.`,e.name,(r+1).toString()));a.push(!s.acceptMatrix)}return r(Ea(i.bind(this),n,a))}function r(t){return Ir(t)?wa(t,t=>US(t,e.name)):US(t,e.name),t}function i(...n){for(let e=0;e<n.length;e++){let r=n[e];if(!t[e].acceptErrors&&!Ir(r)&&j(r?.value))return r}try{return a.apply(this,n)}catch(t){return VS(t,e.name)}}function a(...t){this.debug&&=!1;let n=e.compute.apply(this,t);return Ir(n)?typeof n[0][0]==`object`&&n[0][0]!==null&&`value`in n[0][0]?n:Ca(n,e=>({value:e})):typeof n==`object`&&n&&`value`in n?n:(e.name,{value:n})}return n}function VS(e,t){return HS(e)&&j(e.value)?(GS(e)&&US(e,t),e):(console.error(e),new A(WS+(GS(e)?` `+e.message:``)))}function HS(e){return e?.value!==void 0&&typeof e.value==`string`}function US(e,t){e.message?.includes(`[[FUNCTION_NAME]]`)&&(e.message=e.message.replace(`[[FUNCTION_NAME]]`,t))}let WS=E(`An unexpected error occurred. Submit a support ticket at odoo.com/help.`);function GS(e){return e?.message!==void 0&&typeof e.message==`string`}function KS(e,t){for(let n=0;n<t.length;n++){let r=t[n].proposalValues;r===void 0||r.length===0||up.add(`${e}_function_${t[n].name}_argument_proposals`,{sequence:50,autoSelectFirstProposal:!0,selectProposal:qS,getProposals:t=>{let i=t.functionContext;if(!i||i.parent.toUpperCase()!==e.toUpperCase()||i.argPosition!==n)return;let a=[],o=``;for(let{value:e,label:t}of r){switch(typeof e){case`string`:o=`"${e}"`;break;case`number`:o=e.toString();break;case`boolean`:o=e?`TRUE`:`FALSE`;break;default:}a.push({text:o,description:t,htmlContent:[{value:o,color:typeof e==`string`?ot.STRING:ot.NUMBER}],fuzzySearchKey:o,alwaysExpanded:!0})}return a}})}}function qS(e,t){let n=e.end,r=e.end;[`LEFT_PAREN`,`ARG_SEPARATOR`].includes(e.type)||(n=e.start),this.composer.stopComposerRangeSelection(),this.composer.changeComposerCursorSelection(n,r),this.composer.replaceComposerCursorSelection(t)}var JS=class{scope;code=``;constructor(e=new XS){this.scope=e}append(...e){this.code+=e.map(e=>e.toString()).join(`
21
21
  `)+`
22
22
  `}return(e){return new YS(this.scope,this.code,e)}toString(){return QS(this.code)}},YS=class{scope;returnExpression;code;constructor(e,t,n){this.scope=e,this.returnExpression=n,this.code=QS(t)}toString(){return this.code}assignResultToVariable(){if(this.scope.isAlreadyDeclared(this.returnExpression))return this;let e=this.scope.nextVariableName(),t=new JS(this.scope);return t.append(this.code),t.append(`const ${e} = ${this.returnExpression};`),t.return(e)}},XS=class{nextId=1;declaredVariables=new Set;nextVariableName(){let e=`_${this.nextId++}`;return this.declaredVariables.add(e),e}isAlreadyDeclared(e){return this.declaredVariables.has(e)}};function ZS(e){return e.split(`
23
23
  `).map(e=>e.trim()).filter(e=>e!==``)}function QS(e){let t=``,n=0,r=ZS(e);for(let e of r)e.startsWith(`}`)&&n--,t+=` `.repeat(n)+e+`
@@ -224,7 +224,7 @@ stores.inject(MyMetaStore, storeInstance);
224
224
  }
225
225
  }
226
226
  }
227
- `;var mk=class extends t.Component{static template=`o-spreadsheet-FigureComponent`;static props={figureUI:Object,style:{type:String,optional:!0},class:{type:String,optional:!0},onMouseDown:{type:Function,optional:!0},onClickAnchor:{type:Function,optional:!0}};static components={MenuPopover:ck};static defaultProps={onMouseDown:()=>{},onClickAnchor:()=>{}};menuState=(0,t.useState)({isOpen:!1,anchorRect:null,menuItems:[]});figureRef=(0,t.useRef)(`figure`);figureWrapperRef=(0,t.useRef)(`figureWrapper`);menuButtonRef=(0,t.useRef)(`menuButton`);borderWidth;get isSelected(){return this.env.model.getters.getSelectedFigureId()===this.props.figureUI.id}get figureRegistry(){return pk}getBorderWidth(){return this.env.isDashboard()?0:this.isSelected?2:this.borderWidth}getBorderStyle(e){return`border-${e}: ${this.getBorderWidth()}px solid ${this.isSelected?ae:ie};`}get wrapperStyle(){let{x:e,y:t,width:n,height:r}=this.props.figureUI;return V({left:`${e}px`,top:`${t}px`,width:`${n}px`,height:`${r}px`,"z-index":String(10+ +!!this.isSelected)})}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)`,V(t)}setup(){let e=pk.get(this.props.figureUI.tag).borderWidth;this.borderWidth=e===void 0?1:e,(0,t.useEffect)((e,t,n)=>{e===t&&n?.focus({preventScroll:!0})},()=>[this.env.model.getters.getSelectedFigureId(),this.props.figureUI.id,this.figureRef.el])}clickAnchor(e,t,n){this.props.onClickAnchor(e,t,n)}onMouseDown(e){this.env.isMobile()||this.props.onMouseDown(e)}onClick(e){this.env.isMobile()&&this.props.onMouseDown(e)}onKeyDown(e){let t=nT(e);switch(t){case`Delete`:case`Backspace`:this.env.model.dispatch(`DELETE_FIGURE`,{sheetId:this.env.model.getters.getActiveSheetId(),figureId:this.props.figureUI.id}),e.preventDefault(),e.stopPropagation();break;case`ArrowDown`:case`ArrowLeft`:case`ArrowRight`:case`ArrowUp`:let{col:n,row:r,offset:i}=this.postionInBoundary(this.props.figureUI,e.key);this.env.model.dispatch(`UPDATE_FIGURE`,{sheetId:this.env.model.getters.getActiveSheetId(),figureId:this.props.figureUI.id,offset:i,col:n,row:r}),e.preventDefault(),e.stopPropagation();break;case`Ctrl+A`:e.preventDefault(),e.stopPropagation();break;case`Ctrl+Y`:case`Ctrl+Z`:t===`Ctrl+Y`?this.env.model.dispatch(`REQUEST_REDO`):t===`Ctrl+Z`&&this.env.model.dispatch(`REQUEST_UNDO`),e.preventDefault(),e.stopPropagation();break}}postionInBoundary(e,t){let n=this.env.model.getters.getActiveSheetId(),{col:r,row:i,offset:a}=e;switch(a={...a},t){case`ArrowUp`:a.y===0?(i--,a.y=this.env.model.getters.getRowSize(n,i)-1):a.y--;break;case`ArrowLeft`:a.x===0?(r--,a.x=this.env.model.getters.getColSize(n,r)-1):a.x--;break;case`ArrowDown`:a.y===this.env.model.getters.getRowSize(n,i)?(i++,a.y=0):a.y++;break;case`ArrowRight`:a.x===this.env.model.getters.getColSize(n,i)?(r++,a.x=0):a.x++}return{col:r,row:i,offset:a}}onContextMenu(e){this.env.isDashboard()||this.openContextMenu({x:e.clientX,y:e.clientY,width:0,height:0})}showMenu(){this.openContextMenu(Jw(this.menuButtonRef))}openContextMenu(e){this.menuState.isOpen=!0,this.menuState.anchorRect=e,this.menuState.menuItems=pk.get(this.props.figureUI.tag).menuBuilder(this.props.figureUI.id,this.env)}editWrapperStyle(e){if(this.figureWrapperRef.el)for(let t in e)this.figureWrapperRef.el.style.setProperty(t,e[t]||null)}},hk=class extends bf{mutators=[`clear`,`hover`];col;row;handle(e){switch(e.type){case`ACTIVATE_SHEET`:this.clear()}}hover(e){if(e.col===this.col&&e.row===this.row)return`noStateChange`;this.col=e.col,this.row=e.row}clear(){if(this.col===void 0&&this.row===void 0)return`noStateChange`;this.col=void 0,this.row=void 0}};let gk=new g;B`
227
+ `;var mk=class extends t.Component{static template=`o-spreadsheet-FigureComponent`;static props={figureUI:Object,style:{type:String,optional:!0},class:{type:String,optional:!0},onMouseDown:{type:Function,optional:!0},onClickAnchor:{type:Function,optional:!0}};static components={MenuPopover:ck};static defaultProps={onMouseDown:()=>{},onClickAnchor:()=>{}};menuState=(0,t.useState)({isOpen:!1,anchorRect:null,menuItems:[]});figureRef=(0,t.useRef)(`figure`);figureWrapperRef=(0,t.useRef)(`figureWrapper`);menuButtonRef=(0,t.useRef)(`menuButton`);borderWidth;get isSelected(){return this.env.model.getters.getSelectedFigureId()===this.props.figureUI.id}get figureRegistry(){return pk}getBorderWidth(){return this.env.isDashboard()?0:this.isSelected?2:this.borderWidth}getBorderStyle(e){return`border-${e}: ${this.getBorderWidth()}px solid ${this.isSelected?ae:ie};`}get wrapperStyle(){let{x:e,y:t,width:n,height:r}=this.props.figureUI;return V({left:`${e}px`,top:`${t}px`,width:`${n}px`,height:`${r}px`,"z-index":String(10+ +!!this.isSelected)})}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)`,V(t)}setup(){let e=pk.get(this.props.figureUI.tag).borderWidth;this.borderWidth=e===void 0?1:e,(0,t.useEffect)((e,t,n)=>{e===t&&n?.focus({preventScroll:!0})},()=>[this.env.model.getters.getSelectedFigureId(),this.props.figureUI.id,this.figureRef.el])}clickAnchor(e,t,n){this.props.onClickAnchor(e,t,n)}onMouseDown(e){this.env.isMobile()||this.props.onMouseDown(e)}onClick(e){this.env.isMobile()&&this.props.onMouseDown(e)}onKeyDown(e){let t=nT(e);switch(t){case`Delete`:case`Backspace`:this.env.model.dispatch(`DELETE_FIGURE`,{sheetId:this.env.model.getters.getActiveSheetId(),figureId:this.props.figureUI.id}),e.preventDefault(),e.stopPropagation();break;case`ArrowDown`:case`ArrowLeft`:case`ArrowRight`:case`ArrowUp`:let{col:n,row:r,offset:i}=this.postionInBoundary(this.env.model.getters.getActiveSheetId(),this.props.figureUI,e.key);this.env.model.dispatch(`UPDATE_FIGURE`,{sheetId:this.env.model.getters.getActiveSheetId(),figureId:this.props.figureUI.id,offset:i,col:n,row:r}),e.preventDefault(),e.stopPropagation();break;case`Ctrl+A`:e.preventDefault(),e.stopPropagation();break;case`Ctrl+Y`:case`Ctrl+Z`:t===`Ctrl+Y`?this.env.model.dispatch(`REQUEST_REDO`):t===`Ctrl+Z`&&this.env.model.dispatch(`REQUEST_UNDO`),e.preventDefault(),e.stopPropagation();break}}postionInBoundary(e,t,n){let{col:r,row:i,offset:a}=t;a={...a};let o=this.env.model.getters.getMaxAnchorOffset(e,t.height,t.width);switch(n){case`ArrowUp`:if(a.y===0){for(i--;i>0&&this.env.model.getters.isRowHiddenByUser(e,i);)i--;a.y=this.env.model.getters.getRowSize(e,i)-1}else a.y--;break;case`ArrowLeft`:if(a.x===0){for(r--;r>0&&this.env.model.getters.isColHiddenByUser(e,r);)r--;a.x=this.env.model.getters.getColSize(e,r)-1}else a.x--;break;case`ArrowDown`:if(a.y===this.env.model.getters.getRowSize(e,i)){for(i++;i<=o.row&&this.env.model.getters.isRowHiddenByUser(e,i);)i++;a.y=0}else a.y++;break;case`ArrowRight`:if(a.x===this.env.model.getters.getColSize(e,i)){for(r++;r<=o.col&&this.env.model.getters.isColHiddenByUser(e,r);)r++;a.x=0}else a.x++}return r<0?(r=0,a.x=0):(r>o.col||r===o.col&&a.x>o.offset.x)&&(r=o.col,a.x=o.offset.x),i<0?(i=0,a.y=0):(i>o.row||i===o.row&&a.y>o.offset.y)&&(i=o.row,a.y=o.offset.y),{col:r,row:i,offset:a}}onContextMenu(e){this.env.isDashboard()||this.openContextMenu({x:e.clientX,y:e.clientY,width:0,height:0})}showMenu(){this.openContextMenu(Jw(this.menuButtonRef))}openContextMenu(e){this.menuState.isOpen=!0,this.menuState.anchorRect=e,this.menuState.menuItems=pk.get(this.props.figureUI.tag).menuBuilder(this.props.figureUI.id,this.env)}editWrapperStyle(e){if(this.figureWrapperRef.el)for(let t in e)this.figureWrapperRef.el.style.setProperty(t,e[t]||null)}},hk=class extends bf{mutators=[`clear`,`hover`];col;row;handle(e){switch(e.type){case`ACTIVATE_SHEET`:this.clear()}}hover(e){if(e.col===this.col&&e.row===this.row)return`noStateChange`;this.col=e.col,this.row=e.row}clear(){if(this.col===void 0&&this.row===void 0)return`noStateChange`;this.col=void 0,this.row=void 0}};let gk=new g;B`
228
228
  .o-error-tooltip {
229
229
  font-size: 13px;
230
230
  background-color: white;
@@ -1930,7 +1930,7 @@ stores.inject(MyMetaStore, storeInstance);
1930
1930
  `,`;`,`,`,` `,`.`])if(e.includes(t))return t}splitIntoColumns({separator:e,addNewColumns:t}){let n=this.getters.getSelectedZone(),r=this.getters.getActiveSheetId(),i=this.getSplittedCols(n,e);t&&this.addColsToAvoidCollisions(n,i),this.removeMergesInSplitZone(n,i),this.addColumnsToNotOverflowSheet(n,i);for(let e=0;e<i.length;e++){let t=n.top+e,a=i[e],o=n.left,s=this.getters.getCell({sheetId:r,col:o,row:t});if(!(a.length===1&&a[0]===s?.content))for(let[e,n]of a.entries())this.dispatch(`UPDATE_CELL`,{sheetId:r,col:o+e,row:t,content:du(n,this.getters.getLocale()),format:``,style:s?.style||null})}}getSplittedCols(e,t){if(!t)throw Error(`Separator cannot be empty`);let n=this.getters.getActiveSheetId(),r=[];for(let i of S(e.top,e.bottom+1)){let a=this.getters.getEvaluatedCell({sheetId:n,col:e.left,row:i}).formattedValue;r.push(this.splitAndRemoveTrailingEmpty(a,t))}return r}splitAndRemoveTrailingEmpty(e,t){let n=e.split(t);for(;n.length>1&&n[n.length-1]===``;)n.pop();return n}willSplittedColsOverwriteContent(e,t){let n=this.getters.getActiveSheetId();for(let r of S(e.top,e.bottom+1)){let i=t[r-e.top];for(let t=1;t<i.length;t++){let i=this.getters.getCell({sheetId:n,col:e.left+t,row:r});if(i&&i.content)return!0}}return!1}removeMergesInSplitZone(e,t){let n=this.getters.getActiveSheetId(),r=Math.max(...t.map(e=>e.length)),i={...e,right:e.left+r-1},a=this.getters.getMergesInZone(n,i);this.dispatch(`REMOVE_MERGE`,{sheetId:n,target:a})}addColsToAvoidCollisions(e,t){let n=this.getters.getActiveSheetId(),r=0;for(let i of S(e.top,e.bottom+1)){let a={sheetId:n,col:e.left,row:i},o=t[i-e.top],s=this.getColsToAddToAvoidCollision(a,o);r=Math.max(r,s)}r&&this.dispatch(`ADD_COLUMNS_ROWS`,{dimension:`COL`,base:e.left,sheetId:n,sheetName:this.getters.getSheetName(n),quantity:r,position:`after`})}getColsToAddToAvoidCollision(e,t){let n=t.length;for(let t=1;t<n;t++){let r=e.col+t,i=this.getters.getCell({...e,col:r});if(i&&i.content)return n-t}return 0}addColumnsToNotOverflowSheet(e,t){let n=this.getters.getActiveSheetId(),r=Math.max(...t.map(e=>e.length-1)),i=this.getters.getNumberCols(n)-1;e.left+r>i&&this.dispatch(`ADD_COLUMNS_ROWS`,{dimension:`COL`,base:i,sheetId:n,sheetName:this.getters.getSheetName(n),quantity:e.left+r-i,position:`after`})}checkSingleColSelected(){return this.getters.isSingleColSelected()?`Success`:`MoreThanOneColumnSelected`}checkNonEmptySelector(e){return e.separator===``?`EmptySplitSeparator`:`Success`}checkNotOverwritingContent(e){if(e.addNewColumns||e.force)return`Success`;let t=this.getters.getSelectedZones()[0],n=this.getSplittedCols(t,e.separator);return this.willSplittedColsOverwriteContent(t,n)?`SplitWillOverwriteContent`:`Success`}checkSeparatorInSelection({separator:e}){let t=this.getters.getSelectedCells();for(let n of t)if(n.formattedValue.includes(e))return`Success`;return`NoSplitSeparatorInSelection`}},$K=class extends Rp{handle(e){switch(e.type){case`AUTOFILL_TABLE_COLUMN`:let t=this.getters.getCoreTable(e),n=this.getters.getCell(e);if(!t?.config.automaticAutofill||t.type===`dynamic`||!n?.isFormula)return;let{col:r,row:i}=e,a=mI(t.range.zone,t.config);if(a&&Vs(r,i,a)){let t=e.autofillRowStart??a.top,n=e.autofillRowEnd??a.bottom,r={...a,top:t,bottom:n};this.autofillTableZone(e,r)}break}}autofillTableZone(e,t){if(t.top===t.bottom)return;let{col:n,row:r,sheetId:i}=e;for(let e=t.top;e<=t.bottom;e++)if(e!==r&&this.getters.getEvaluatedCell({col:n,row:e,sheetId:i}).type!==`empty`)return;let a={zone:this.getters.getSelectedZone(),cell:this.getters.getActivePosition()};this.selection.selectCell(n,r),this.dispatch(`AUTOFILL_SELECT`,{col:n,row:t.bottom}),this.dispatch(`AUTOFILL`),this.selection.selectCell(n,r),this.dispatch(`AUTOFILL_SELECT`,{col:n,row:t.top}),this.dispatch(`AUTOFILL`),this.selection.selectZone(a)}},eq=class extends Rp{allowDispatch(e){switch(e.type){case`RESIZE_TABLE`:let t=this.getters.getCoreTableMatchingTopLeft(e.sheetId,e.zone);if(!t)return`TableNotFound`;let n=t.range.zone,r=this.getters.getRangeFromRangeData(e.newTableRange).zone;return r.top!==n.top||r.left!==n.left?`InvalidTableResize`:this.canDispatch(`UPDATE_TABLE`,{...e}).reasons}return`Success`}handle(e){switch(e.type){case`RESIZE_TABLE`:{let t=this.getters.getCoreTableMatchingTopLeft(e.sheetId,e.zone);if(this.dispatch(`UPDATE_TABLE`,{...e}),!t)return;let n=this.getters.getRangeFromRangeData(e.newTableRange).zone;if(this.selection.selectCell(n.right,n.bottom),!t.config.automaticAutofill)return;let r=t.range.zone;if(n.bottom>=r.bottom){for(let t=n.left;t<=n.right;t++){let i={col:t,row:r.bottom,sheetId:e.sheetId};this.getters.getCell(i)?.content.startsWith(`=`)&&this.dispatch(`AUTOFILL_TABLE_COLUMN`,{...i,autofillRowStart:r.bottom,autofillRowEnd:n.bottom})}break}}}}},tq=class extends Rp{static layers=[`Clipboard`];static getters=[`getClipboardTextAndImageContent`,`getClipboardId`,`getClipboardTextContent`,`isCutOperation`];status=`invisible`;originSheetId;copiedData;_isCutOperation=!1;clipboardId=new jl().uuidv4();fileStore;uuidGenerator;constructor(e){super(e),this.fileStore=e.external.fileStore,this.uuidGenerator=new jl}allowDispatch(e){switch(e.type){case`CUT`:let t=this.getters.getSelectedZones();return this.isCutAllowedOn(t);case`PASTE_FROM_OS_CLIPBOARD`:{let t=this.convertTextToClipboardData(e.clipboardContent.text??``),n=e.pasteOption;return this.isPasteAllowed(e.target,t,{pasteOption:n,isCutOperation:!1})}case`PASTE`:{if(!this.copiedData)return`EmptyClipboard`;let t=e.pasteOption;return this.isPasteAllowed(e.target,this.copiedData,{pasteOption:t,isCutOperation:this._isCutOperation})}case`COPY_PASTE_CELLS_ABOVE`:{let e=this.getters.getSelectedZones();if(e.length>1||e[0].top===0&&e[0].bottom===0)return`InvalidCopyPasteSelection`;break}case`COPY_PASTE_CELLS_ON_LEFT`:{let e=this.getters.getSelectedZones();if(e.length>1||e[0].left===0&&e[0].right===0)return`InvalidCopyPasteSelection`;break}case`INSERT_CELL`:{let{cut:t,paste:n}=this.getInsertCellsTargets(e.zone,e.shiftDimension),r=this.copy(t,`shiftCells`);return this.isPasteAllowed(n,r,{isCutOperation:!0})}case`DELETE_CELL`:{let{cut:t,paste:n}=this.getDeleteCellsTargets(e.zone,e.shiftDimension),r=this.copy(t,`shiftCells`);return this.isPasteAllowed(n,r,{isCutOperation:!0})}}return`Success`}handle(e){switch(e.type){case`COPY`:case`CUT`:let t=this.getters.getSelectedZones();this.status=`visible`,this.originSheetId=this.getters.getActiveSheetId(),this._isCutOperation=e.type===`CUT`,this.copiedData=this.copy(t);break;case`PASTE_FROM_OS_CLIPBOARD`:{this._isCutOperation=!1;let t=e.clipboardContent;if(t.data?.version!==bP()&&(t={...t},delete t.data),t.imageData){let n=this.getters.getActiveSheetId(),r=this.uuidGenerator.uuidv4(),i=t.imageData,a=CO(this.getters,i.size);this.dispatch(`CREATE_IMAGE`,{definition:i,size:a,col:e.target[0].left,row:e.target[0].top,offset:{x:0,y:0},sheetId:n,figureId:r})}t.data?this.copiedData=t.data:this.copiedData=this.convertTextToClipboardData(t.text??``);let n=e.pasteOption;this.paste(e.target,this.copiedData,{pasteOption:n,selectTarget:!0,isCutOperation:!1}),this.status=`invisible`,this.copiedData=void 0;break}case`PASTE`:{let t=e.pasteOption;this.paste(e.target,this.copiedData,{pasteOption:t,selectTarget:!0,isCutOperation:this._isCutOperation}),this.status=`invisible`,this._isCutOperation&&=(this.copiedData=void 0,!1);break}case`COPY_PASTE_CELLS_ABOVE`:{let e=this.getters.getSelectedZone(),t=e.top!==e.bottom,n={...e,bottom:t?e.top:e.top-1,top:t?e.top:e.top-1};this.originSheetId=this.getters.getActiveSheetId();let r=this.copy([n]);this.paste([e],r,{isCutOperation:!1,selectTarget:!0})}break;case`COPY_PASTE_CELLS_ON_LEFT`:{let e=this.getters.getSelectedZone(),t=e.left!==e.right,n={...e,right:t?e.left:e.left-1,left:t?e.left:e.left-1};this.originSheetId=this.getters.getActiveSheetId();let r=this.copy([n]);this.paste([e],r,{isCutOperation:!1,selectTarget:!0})}break;case`CLEAN_CLIPBOARD_HIGHLIGHT`:this.status=`invisible`;break;case`DELETE_CELL`:{let{cut:t,paste:n}=this.getDeleteCellsTargets(e.zone,e.shiftDimension);if(!Os(t[0])){this.dispatch(`CLEAR_CELLS`,{target:[e.zone],sheetId:this.getters.getActiveSheetId()});break}let r=this.copy(t,`shiftCells`);this.paste(n,r,{isCutOperation:!0});break}case`INSERT_CELL`:{let{cut:t,paste:n}=this.getInsertCellsTargets(e.zone,e.shiftDimension),r=this.copy(t,`shiftCells`);this.paste(n,r,{isCutOperation:!0});break}case`ADD_COLUMNS_ROWS`:if(this.status=`invisible`,!this._isCutOperation||e.sheetId!==this.copiedData?.sheetId)return;this.isColRowDirtyingClipboard(e.position===`before`?e.base:e.base+1,e.dimension)&&(this.copiedData=void 0);break;case`REMOVE_COLUMNS_ROWS`:if(this.status=`invisible`,!this._isCutOperation||e.sheetId!==this.copiedData?.sheetId)return;for(let t of e.elements)if(this.isColRowDirtyingClipboard(t,e.dimension)){this.copiedData=void 0;break}this.status=`invisible`;break;case`REPEAT_PASTE`:this.paste(e.target,this.copiedData,{isCutOperation:!1,pasteOption:e.pasteOption,selectTarget:!0});break;case`DELETE_SHEET`:if(!this._isCutOperation)return;this.originSheetId===e.sheetId&&(this.copiedData=void 0,this.status=`invisible`);break;default:Dr(e)&&(this.status=`invisible`)}}convertTextToClipboardData(e){let t=this.selectClipboardHandlers({figureId:!0}).concat(this.selectClipboardHandlers({})),n={};for(let{handlerName:r,handler:i}of t){let t=i.convertTextToClipboardData(e);n[r]=t;for(let e of[`sheetId`,`cells`,`zones`,`figureId`])t&&e in t&&(n[e]=t[e])}return n}selectClipboardHandlers(e){let t=`figureId`in e?af.figureHandlers:af.cellHandlers;return t.getKeys().map(e=>({handlerName:e,handler:new(t.get(e))(this.getters,this.dispatch)}))}isCutAllowedOn(e){let t=this.getClipboardData(e);for(let{handler:e}of this.selectClipboardHandlers(t)){let n=e.isCutAllowed(t);if(n!==`Success`)return n}return`Success`}isPasteAllowed(e,t,n){for(let{handler:r}of this.selectClipboardHandlers(t)){let i=r.isPasteAllowed(this.getters.getActiveSheetId(),e,t,{...n});if(i!==`Success`)return i}return`Success`}isColRowDirtyingClipboard(e,t){if(!this.copiedData||!this.copiedData.zones)return!1;let{zones:n}=this.copiedData;for(let r of n)if(t===`COL`&&e<=r.right||t===`ROW`&&e<=r.bottom)return!0;return!1}copy(e,t=`copyPaste`){let n={},r=this.getClipboardData(e);for(let{handlerName:e,handler:i}of this.selectClipboardHandlers(r)){let a=i.copy(r,this._isCutOperation,t);n[e]=a;for(let e of[`sheetId`,`cells`,`zones`,`figureId`])a&&e in a&&(n[e]=a[e])}return n}paste(e,t,n){if(!t)return;let r=this.getters.getActiveSheetId(),i=this.selectClipboardHandlers(t),{target:a,zone:o,selectedZones:s}=zl(r,e,t,i,n);o!==void 0&&this.addMissingDimensions(r,o.right-o.left+1,o.bottom-o.top+1,o.left,o.top),Rl(i,t,a,n),n?.selectTarget&&Bl(this.selection,e,s)}addMissingDimensions(e,t,n,r,i){let a=n+i-this.getters.getNumberRows(e);a>0&&this.dispatch(`ADD_COLUMNS_ROWS`,{dimension:`ROW`,base:this.getters.getNumberRows(e)-1,sheetId:e,sheetName:this.getters.getSheetName(e),quantity:a,position:`after`});let o=t+r-this.getters.getNumberCols(e);o>0&&this.dispatch(`ADD_COLUMNS_ROWS`,{dimension:`COL`,base:this.getters.getNumberCols(e)-1,sheetId:e,sheetName:this.getters.getSheetName(e),quantity:o,position:`after`})}getClipboardTextContent(){return this.getPlainTextContent()}getClipboardId(){return this.clipboardId}async getClipboardTextAndImageContent(){let e=await this.getImageContent(),t=e?.type,n={"text/plain":this.getPlainTextContent(),"text/html":await this.getHTMLContent()};return t&&e&&(n[t]=e),n}getSheetData(){let e={version:bP(),clipboardId:this.clipboardId};return this.copiedData&&`figureId`in this.copiedData?e:{...e,...this.copiedData}}getPlainTextContent(){return this.copiedData?.cells&&this.copiedData.cells.map(e=>e.map(e=>this.getters.shouldShowFormulas()&&e?.tokens?.length?e?.content||``:e.evaluatedCell?.formattedValue||``).join(` `)).join(`
1931
1931
  `)||` `}async getHTMLContent(){let e=``,t=this.copiedData?.cells;if(!t)if(this.copiedData?.figureId){let t=this.copiedData.figureId,n=this.getters.getFigureSheetId(t);e=this.getters.getFigure(n,t).tag===`image`?await this.craftImageHTML(t):` `}else e=` `;else if(t.length===1&&t[0].length===1)e=`${this.getters.getCellText(t[0][0].position)}`;else if(t[0][0]){let n=`<table border="1" style="border-collapse:collapse">`;for(let e of t){n+=`<tr>`;for(let t of e){if(!t)continue;let e=V(kf(this.getters.getCellComputedStyle(t.position))),r=this.getters.getCellText(t.position);n+=`<td style="${e}">`+DO(r)+`</td>`}n+=`</tr>`}n+=`</table>`,e=n}else return``;return`<div data-osheet-clipboard='${DO(JSON.stringify(this.getSheetData()))}'>${e}</div>`}readFileAsDataURL(e){return new Promise(t=>{let n=new FileReader;n.onload=()=>t(n.result),n.readAsDataURL(e)})}async craftImageHTML(e){if(!this.fileStore)return` `;let t=this.getters.getImage(e).path,n=await this.fileStore?.getFile(t)||null;return n?`<img src="${DO(await this.readFileAsDataURL(n))}" />`:` `}async getImageContent(){let e=this.copiedData?.figureId;if(!e)return;let t=this.getters.getFigureSheetId(e),n=this.getters.getFigure(t,e),r;if(n.tag===`image`){if(!this.fileStore)return;let t=this.getters.getImage(e).path;if(r=await this.fileStore?.getFile(t),r.type!==`image/png`){if(r.size>5242880){this.ui.notifyUI({text:E(`The file you are trying to copy is too large (>%sMB).
1932
1932
  It will not be added to your OS clipboard.
1933
- You can download it directly instead.`,5),sticky:!1,type:`warning`});return}r=await oT(t)}}if(r)return r instanceof File?r:new File([r],`image.png`,{type:`image/png`})}isCutOperation(){return this._isCutOperation??!1}getDeleteCellsTargets(e,t){let n=this.getters.getActiveSheetId(),r;return r=t===`COL`?{...e,left:e.right+1,right:this.getters.getNumberCols(n)-1}:{...e,top:e.bottom+1,bottom:this.getters.getNumberRows(n)-1},{cut:[r],paste:[e]}}getInsertCellsTargets(e,t){let n=this.getters.getActiveSheetId(),r,i;return t===`COL`?(r={...e,right:this.getters.getNumberCols(n)-1},i={...e,left:e.right+1,right:e.right+1}):(r={...e,bottom:this.getters.getNumberRows(n)-1},i={...e,top:e.bottom+1,bottom:this.getters.getNumberRows(n)-1}),{cut:[r],paste:[i]}}getClipboardData(e){let t=this.getters.getActiveSheetId(),n=this.getters.getSelectedFigureId();if(n)return{figureId:n,sheetId:t};let r=Nl(t,e);return this._isCutOperation||(r.rowsIndexes=r.rowsIndexes.filter(e=>!this.getters.isRowFiltered(t,e))),r}drawLayer(e){if(this.status!==`visible`||!this.copiedData)return;let{sheetId:t,zones:n}=this.copiedData;if(t!==this.getters.getActiveSheetId()||!n||!n.length)return;let{ctx:r,thinLineWidth:i}=e;r.setLineDash([8,5]),r.strokeStyle=ae,r.lineWidth=3.3*i;for(let e of n){let{x:t,y:n,width:i,height:a}=this.getters.getVisibleRect(e);i>0&&a>0&&r.strokeRect(t,n,i,a)}}};let nq={filterType:`criterion`,type:`none`,values:[]};var rq=class extends Rp{static getters=[`getFilterValue`,`getFilterHiddenValues`,`getFilterCriterionValue`,`getFirstTableInSelection`,`isRowFiltered`,`isFilterActive`];filterValues={};hiddenRows={};isEvaluationDirty=!1;allowDispatch(e){switch(e.type){case`UPDATE_FILTER`:if(!this.getters.getFilterId(e))return`FilterNotFound`;break}return`Success`}handle(e){switch(e.type){case`UNDO`:case`REDO`:case`UPDATE_CELL`:case`EVALUATE_CELLS`:case`ACTIVATE_SHEET`:case`REMOVE_TABLE`:case`ADD_COLUMNS_ROWS`:case`REMOVE_COLUMNS_ROWS`:case`UPDATE_TABLE`:this.isEvaluationDirty=!0;break;case`START`:for(let e of this.getters.getSheetIds())this.filterValues[e]={};break;case`CREATE_SHEET`:this.filterValues[e.sheetId]={};break;case`HIDE_COLUMNS_ROWS`:case`UNHIDE_COLUMNS_ROWS`:case`GROUP_HEADERS`:case`UNGROUP_HEADERS`:case`FOLD_HEADER_GROUP`:case`UNFOLD_HEADER_GROUP`:case`FOLD_ALL_HEADER_GROUPS`:case`UNFOLD_ALL_HEADER_GROUPS`:case`FOLD_HEADER_GROUPS_IN_ZONE`:case`UNFOLD_HEADER_GROUPS_IN_ZONE`:this.updateHiddenRows(e.sheetId);break;case`UPDATE_FILTER`:this.updateFilter(e),this.updateHiddenRows(e.sheetId);break;case`DUPLICATE_SHEET`:this.filterValues[e.sheetIdTo]=b(this.filterValues[e.sheetId]);break}}finalize(){if(this.isEvaluationDirty){for(let e of this.getters.getSheetIds())this.updateHiddenRows(e);this.isEvaluationDirty=!1}}isRowFiltered(e,t){return!!this.hiddenRows[e]?.has(t)}getFilterValue(e){let t=this.getters.getFilterId(e),n=e.sheetId;return t?this.filterValues[n]?.[t]:void 0}getFilterHiddenValues(e){let t=this.getters.getFilterId(e),n=e.sheetId;if(!t||!this.filterValues[n])return[];let r=this.filterValues[n][t]||[];return r.filterType===`values`?r.hiddenValues:[]}getFilterCriterionValue(e){let t=this.getters.getFilterId(e),n=e.sheetId;if(!t||!this.filterValues[n])return nq;let r=this.filterValues[n][t];return r&&r.filterType===`criterion`?r:nq}isFilterActive(e){let t=this.getters.getFilterId(e);if(!t)return!1;let n=e.sheetId,r=this.filterValues[n]?.[t];return r?r.filterType===`values`?r.hiddenValues.length>0:r.type!==`none`:!1}getFirstTableInSelection(){let e=this.getters.getActiveSheetId(),t=this.getters.getSelectedZones();return this.getters.getTablesOverlappingZones(e,t)[0]}updateFilter({col:e,row:t,value:n,sheetId:r}){let i=this.getters.getFilterId({sheetId:r,col:e,row:t});i&&(this.filterValues[r]||(this.filterValues[r]={}),this.filterValues[r][i]=n)}updateHiddenRows(e){let t=this.getters.getFilters(e).sort((e,t)=>e.rangeWithHeaders.zone.top-t.rangeWithHeaders.zone.top),n=new Set;for(let r of t){let t=this.filterValues[e]?.[r.id],i=r.filteredRange?.zone;if(!(!t||!i||n.has(r.rangeWithHeaders.zone.top)||this.getters.isRowHiddenByUser(e,r.rangeWithHeaders.zone.top)))if(t.filterType===`values`){let a=t.hiddenValues?.map(Tl);if(!a)continue;let o=new Set(a);for(let t=i.top;t<=i.bottom;t++){let i=this.getCellValueAsString(e,r.col,t);o.has(i)&&n.add(t)}}else{if(t.type===`none`)continue;let a=Y.get(t.type),o=t.values.map(t=>t.startsWith(`=`)?this.getters.evaluateFormula(e,t)??``:ts(t,D));if(o.some(Wu))continue;let s={type:t.type,values:o.map(Hu),dateValue:t.dateValue};for(let t=i.top;t<=i.bottom;t++){let i={sheetId:e,col:r.col,row:t},o=this.getters.getEvaluatedCell(i).value??``;a.isValueValid(o,s,this.getters,e)||n.add(t)}}}this.hiddenRows[e]=n}getCellValueAsString(e,t,n){return this.getters.getEvaluatedCell({sheetId:e,col:t,row:n}).formattedValue.toLowerCase()}exportForExcel(e){for(let t of e.sheets){let e=t.id;for(let n of t.tables){let r=Ts(n.range),i=[],a=[];for(let n of S(0,Us(r).numberOfCols)){let o={sheetId:t.id,col:r.left+n,row:r.top},s=this.getFilterHiddenValues(o),c=this.getters.getFilter(o),l=c?.filteredRange?Ks(c.filteredRange.zone).map(t=>this.getters.getEvaluatedCell({sheetId:e,...t}).formattedValue):[];if(s.length){let e=l.filter(e=>e).filter(e=>!s.includes(e));i.push({colId:n,displayedValues:[...new Set(e)],displayBlanks:!s.includes(``)&&l.some(e=>!e)})}let u=this.getters.getEvaluatedCell(o).formattedValue,d=this.getUniqueColNameForExcel(n,u,a);a.push(d);let f=T(o.col,o.row);t.cells[f]=d,t.cellValues[f]=d}n.filters=i}}}getUniqueColNameForExcel(e,t,n){return t||=`Column${e}`,an(t,n,{compute:(e,n)=>t+String(n),start:2})}},iq=class extends Rp{static layers=[`Selection`];static getters=[`getActiveSheet`,`getActiveSheetId`,`getActiveSheetName`,`getActiveCell`,`getActiveCols`,`getActiveRows`,`getCurrentStyle`,`getSelectedZones`,`getSelectedZone`,`getSelectedCells`,`getSelectedFigureId`,`getSelection`,`getActivePosition`,`getSheetPosition`,`isSingleColSelected`,`getElementsFromSelection`,`tryGetActiveSheetId`,`isGridSelectionActive`,`getSelectecUnboundedZone`];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;isUnbounded;activeSheet=null;constructor(e){super(e),this.moveClient=e.moveClient,this.isUnbounded=!1}allowDispatch(e){switch(e.type){case`ACTIVATE_SHEET`:try{if(!this.getters.getSheet(e.sheetIdTo).isVisible)return`SheetIsHidden`;break}catch{return`InvalidSheetId`}case`MOVE_COLUMNS_ROWS`:return this.isMoveElementAllowed(e)}return`Success`}handleEvent(e){let t=e.anchor,n=[];switch(this.isUnbounded=e.options?.unbounded||!1,e.mode){case`overrideSelection`:n=[t.zone];break;case`updateAnchor`:n=[...this.gridSelection.zones];let r=n.findIndex(t=>Rs(t,e.previousAnchor.zone));r>=0&&(n[r]=t.zone);break;case`newAnchor`:n=[...this.gridSelection.zones,t.zone];break}this.setSelectionMixin(e.anchor,n),this.selection.resetDefaultAnchor(this,b(this.gridSelection.anchor));let{col:r,row:i}=this.gridSelection.anchor.cell;this.moveClient({sheetId:this.getters.getActiveSheetId(),col:r,row:i}),this.selectedFigureId=null}handle(e){switch(e.type){case`ACTIVATE_SHEET`:this.selectedFigureId=null;break;case`DELETE_FIGURE`:this.selectedFigureId===e.figureId&&(this.selectedFigureId=null);break;case`DELETE_SHEET`:this.selectedFigureId&&this.getters.getFigure(e.sheetId,this.selectedFigureId)&&(this.selectedFigureId=null);break}switch(e.type){case`START`:let t=this.getters.getVisibleSheetIds()[0];this.activateSheet(t,t);let{col:n,row:r}=this.getters.getNextVisibleCellPosition({sheetId:t,col:0,row:0});this.selectCell(n,r),this.selection.registerAsDefault(this,this.gridSelection.anchor,{handleEvent:this.handleEvent.bind(this)}),this.moveClient({sheetId:t,col:0,row:0});break;case`ACTIVATE_SHEET`:this.activateSheet(e.sheetIdFrom,e.sheetIdTo);break;case`REMOVE_COLUMNS_ROWS`:{let t=this.getters.getActiveSheetId();if(e.sheetId===t){e.dimension===`COL`?this.onColumnsRemoved(e):this.onRowsRemoved(e);let{col:n,row:r}=this.gridSelection.anchor.cell;this.moveClient({sheetId:t,col:n,row:r})}break}case`ADD_COLUMNS_ROWS`:{let t=this.getters.getActiveSheetId();if(e.sheetId===t){this.onAddElements(e);let{col:n,row:r}=this.gridSelection.anchor.cell;this.moveClient({sheetId:t,col:n,row:r})}break}case`MOVE_COLUMNS_ROWS`:e.sheetId===this.getActiveSheetId()&&this.onMoveElements(e);break;case`SELECT_FIGURE`:this.selectedFigureId=e.figureId;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`:let i=Object.keys(this.sheetsData).filter(e=>!this.getters.tryGetSheet(e));for(let e of i)delete this.sheetsData[e];for(let e in this.sheetsData){let t=this.clipSelection(e,this.sheetsData[e].gridSelection);this.sheetsData[e]={gridSelection:b(t)}}this.fallbackToVisibleSheet();let a=this.getters.getActiveSheetId();this.gridSelection.zones=this.gridSelection.zones.map(e=>this.getters.expandZone(a,e)),this.gridSelection.anchor.zone=this.getters.expandZone(a,this.gridSelection.anchor.zone),this.setSelectionMixin(this.gridSelection.anchor,this.gridSelection.zones),this.selectedFigureId=null;break}}finalize(){this.fallbackToVisibleSheet(),this.selection.resetDefaultAnchor(this,b(this.gridSelection.anchor))}isGridSelectionActive(){return this.selection.isListening(this)}getActiveSheet(){return this.activeSheet}getActiveSheetId(){return this.activeSheet.id}getActiveSheetName(){return this.activeSheet.name}tryGetActiveSheetId(){return this.activeSheet?.id}getActiveCell(){return this.getters.getEvaluatedCell(this.getActivePosition())}getActiveCols(){let e=new Set;for(let t of this.gridSelection.zones)if(t.top===0&&t.bottom===this.getters.getNumberRows(this.getters.getActiveSheetId())-1)for(let n=t.left;n<=t.right;n++)e.add(n);return e}getActiveRows(){let e=new Set,t=this.getters.getActiveSheetId();for(let n of this.gridSelection.zones)if(n.left===0&&n.right===this.getters.getNumberCols(t)-1)for(let t=n.top;t<=n.bottom;t++)e.add(t);return e}getCurrentStyle(){let e=this.getters.getSelectedZone(),t=this.getters.getActiveSheetId();return this.getters.getCellStyle({sheetId:t,col:e.left,row:e.top})}getSelectedZones(){return b(this.gridSelection.zones)}getSelectedZone(){return b(this.gridSelection.anchor.zone)}getSelectecUnboundedZone(){return b(this.isUnbounded?this.getters.getUnboundedZone(this.activeSheet.id,this.gridSelection.anchor.zone):this.gridSelection.anchor.zone)}getSelection(){return b(this.gridSelection)}getSelectedCells(){let e=this.getters.getActiveSheetId(),t=[];for(let n of this.gridSelection.zones)t.push(...this.getters.getEvaluatedCellsInZone(e,n));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();{let 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})}}isSingleColSelected(){let e=this.getters.getSelectedZones();return!(e.length!==1||e[0].left!==e[0].right)}getElementsFromSelection(e){if(e===`COL`&&this.getters.getActiveCols().size===0||e===`ROW`&&this.getters.getActiveRows().size===0)return[];let t=this.getters.getSelectedZones(),n=[],r=e===`COL`?`left`:`top`,i=e===`COL`?`right`:`bottom`;for(let e of t){let t=Array.from({length:e[i]-e[r]+1},(t,n)=>e[r]+n);n=n.concat(t)}return[...new Set(n)].sort()}activateSheet(e,t){if(this.setActiveSheet(t),this.sheetsData[e]={gridSelection:b(this.gridSelection)},t in this.sheetsData)Object.assign(this,this.sheetsData[t]),this.selection.resetDefaultAnchor(this,b(this.gridSelection.anchor));else{let{col:e,row:n}=this.getters.getNextVisibleCellPosition({sheetId:t,col:0,row:0});this.selectCell(e,n)}let{col:n,row:r}=this.gridSelection.anchor.cell;this.moveClient({sheetId:this.activeSheet.id,col:n,row:r})}setSelectionMixin(e,t){let{anchor:n,zones:r}=this.clipSelection(this.getters.getActiveSheetId(),{anchor:e,zones:t});this.gridSelection.anchor=n,this.gridSelection.zones=Xs(r)}selectCell(e,t){let n=this.getters.getActiveSheetId(),r=this.getters.expandZone(n,{left:e,right:e,top:t,bottom:t});this.setSelectionMixin({zone:r,cell:{col:e,row:t}},[r])}setActiveSheet(e){this.activeSheet=this.getters.getSheet(e)}activateNextSheet(e){let t=this.getters.getSheetIds(),n=(t.findIndex(e=>e===this.activeSheet.id)+(e===`left`?t.length-1:1))%t.length;this.dispatch(`ACTIVATE_SHEET`,{sheetIdFrom:this.getActiveSheetId(),sheetIdTo:t[n]})}onColumnsRemoved(e){let{cell:t,zone:n}=this.gridSelection.anchor,r=Ns(n,`left`,[...e.elements]),i={left:t.col,right:t.col,top:t.row,bottom:t.row};i=Ns(i,`left`,[...e.elements]);let a={cell:{col:i.left,row:i.top},zone:r},o=this.gridSelection.zones.map(t=>Ns(t,`left`,[...e.elements]));this.setSelectionMixin(a,o)}onRowsRemoved(e){let{cell:t,zone:n}=this.gridSelection.anchor,r=Ns(n,`top`,[...e.elements]),i={left:t.col,right:t.col,top:t.row,bottom:t.row};i=Ns(i,`top`,[...e.elements]);let a={cell:{col:i.left,row:i.top},zone:r},o=this.gridSelection.zones.map(t=>Ns(t,`top`,[...e.elements]));this.setSelectionMixin(a,o)}onAddElements(e){let t=e.dimension===`COL`?`left`:`top`,n=Ms(this.gridSelection.anchor.zone,t,e.base,e.position,e.quantity),r=this.gridSelection.zones.map(n=>Ms(n,t,e.base,e.position,e.quantity)),i={cell:{col:n.left,row:n.top},zone:n};this.setSelectionMixin(i,r)}onMoveElements(e){let t=e.elements.length,n=this.getFiguresUpdates(e);this.dispatch(`ADD_COLUMNS_ROWS`,{dimension:e.dimension,sheetId:e.sheetId,sheetName:e.sheetName,base:e.base,quantity:t,position:e.position});let r=e.dimension===`COL`,i=e.elements[0],a=e.elements[t-1],o=e.base<i,s=o&&r?t:0,c=o&&!r?t:0,l=o?e.elements.map(e=>e+t):e.elements,u={};for(let t of l)u[t]=this.getters.getHeaderSize(e.sheetId,e.dimension,t);let d=[{left:r?i+s:0,right:r?a+s:this.getters.getNumberCols(e.sheetId)-1,top:r?0:i+c,bottom:r?this.getters.getNumberRows(e.sheetId)-1:a+c}],f=this.getActiveSheetId(),p=o?e.base:e.base+1,m=[{left:r?p:0,right:r?p+t-1:this.getters.getNumberCols(e.sheetId)-1,top:r?0:p,bottom:r?this.getters.getNumberRows(e.sheetId)-1:p+t-1}],h=af.cellHandlers.getKeys().map(e=>[e,new(af.cellHandlers.get(e))(this.getters,this.dispatch)]),g={};for(let[e,t]of h)g[e]=t.copy(Nl(f,d),!1,`shiftCells`);for(let[e,t]of h)g[e]&&t.paste({zones:m,sheetId:f},g[e],{isCutOperation:!0});let _=m[0],v=_.left,y=_.top;this.setSelectionMixin({zone:_,cell:{col:v,row:y}},[_]);let ee=o?e.base:e.base+1,te={};for(let t of l){let n=u[t];n!==this.getters.getHeaderSize(e.sheetId,e.dimension,ee)&&(te[n]??=[],te[n].push(ee)),ee+=1}for(let t in te)this.dispatch(`RESIZE_COLUMNS_ROWS`,{dimension:e.dimension,sheetId:e.sheetId,size:parseInt(t,10),elements:te[t]});this.dispatch(`REMOVE_COLUMNS_ROWS`,{dimension:e.dimension,sheetId:e.sheetId,sheetName:e.sheetName,elements:l}),this.applyFigureUpdates(n)}getFiguresUpdates(e){let t=[],n={},r=e.elements[0]<e.base?e.base-e.elements.length+1:e.base;for(let t=0;t<e.elements.length;t++)n[e.elements[t]]=r+t;for(let r of this.getters.getFigures(e.sheetId))e.dimension===`COL`&&r.col in n&&t.push({type:`UPDATE_FIGURE`,sheetId:e.sheetId,figureId:r.id,col:n[r.col],row:r.row}),e.dimension===`ROW`&&r.row in n&&t.push({type:`UPDATE_FIGURE`,sheetId:e.sheetId,figureId:r.id,row:n[r.row],col:r.col});return t}applyFigureUpdates(e){for(let t of e)this.dispatch(t.type,{...t})}isMoveElementAllowed(e){let t=e.dimension===`COL`,n=e.elements[0],r=e.elements[e.elements.length-1],i=e.sheetId,a=t?this.getters.doesColumnsHaveCommonMerges:this.getters.doesRowsHaveCommonMerges;if(a(i,n-1,n)||a(i,r,r+1)||a(i,e.base-1,e.base))return`WillRemoveExistingMerge`;let o=[e.base,...e.elements],s=t?this.getters.getNumberCols(i):this.getters.getNumberRows(i);return o.some(e=>e<0||e>=s)?`InvalidHeaderIndex`:!t&&!this.isTableRowMoveAllowed(i,e.elements)?`CannotMoveTableHeader`:`Success`}isTableRowMoveAllowed(e,t){let n=this.getters.getCoreTables(e);if(n.length===0)return!0;let r=new Set(t);return n.every(({range:{zone:e},config:n})=>{let{top:i,bottom:a}=e;if(n.numberOfHeaders===0)return!0;let o=i+n.numberOfHeaders-1;return t.some(e=>e>=i&&e<=o)?S(i,a+1).every(e=>r.has(e)):!0})}fallbackToVisibleSheet(){if(!this.getters.tryGetSheet(this.getters.getActiveSheetId())){let e=this.getters.getVisibleSheetIds();if(this.activeSheet=this.getters.getSheet(e[0]),this.activeSheet.id in this.sheetsData){let{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);let{col:t,row:n}=this.gridSelection.anchor.cell;this.moveClient({sheetId:this.getters.getActiveSheetId(),col:t,row:n})}}clipSelection(e,t){let n=this.getters.getNumberCols(e)-1,r=this.getters.getNumberRows(e)-1,i=t.zones.map(e=>({left:x(e.left,0,n),right:x(e.right,0,n),top:x(e.top,0,r),bottom:x(e.bottom,0,r)})),a=x(t.anchor.cell.col,0,n),o=x(t.anchor.cell.row,0,r),s={left:x(t.anchor.zone.left,0,n),right:x(t.anchor.zone.right,0,n),top:x(t.anchor.zone.top,0,r),bottom:x(t.anchor.zone.bottom,0,r)};return{zones:i,anchor:{cell:{col:a,row:o},zone:s}}}drawLayer(e){if(this.getters.isDashboard())return;let{ctx:t,thinLineWidth:n}=e,r=this.getSelectedZones();t.fillStyle=`#f3f7fe`,t.fillStyle=r.length===1&&r[0].left===r[0].right&&r[0].top===r[0].bottom?`#f3f7fe`:`#e9f0ff`,t.strokeStyle=ae,t.lineWidth=1.5*n;for(let e of r){let{x:n,y:r,width:i,height:a}=this.getters.getVisibleRect(e);t.globalCompositeOperation=`multiply`,t.fillRect(n,r,i,a),t.globalCompositeOperation=`source-over`,t.strokeRect(n,r,i,a)}t.globalCompositeOperation=`source-over`;let i=this.getActivePosition();t.strokeStyle=ae,t.lineWidth=3*n;let a;a=this.getters.isInMerge(i)?this.getters.getMerge(i):R(i);let{x:o,y:s,width:c,height:l}=this.getters.getVisibleRect(a);c>0&&l>0&&t.strokeRect(o,s,c,l)}},aq=class{getters;sheetId;boundaries;top;bottom;left;right;offsetX;offsetY;canScrollVertically;canScrollHorizontally;viewportWidth;viewportHeight;offsetCorrectionX;offsetCorrectionY;constructor(e,t,n,r,i,a){if(this.getters=e,this.sheetId=t,this.boundaries=n,r.width<0||r.height<0)throw Error(`Viewport size cannot be negative`);this.viewportWidth=r.height&&r.width,this.viewportHeight=r.width&&r.height,this.top=n.top,this.bottom=n.bottom,this.left=n.left,this.right=n.right,this.offsetX=a.x,this.offsetY=a.y,this.canScrollVertically=i.canScrollVertically,this.canScrollHorizontally=i.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(){let 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:n}=this.getters.getColDimensions(this.sheetId,e),{end:r}=this.getters.getRowDimensions(this.sheetId,t),i=n-this.offsetCorrectionX;this.canScrollHorizontally&&(i=Math.max(i,this.viewportWidth));let a=r-this.offsetCorrectionY;return this.canScrollVertically&&(a=Math.max(a,this.viewportHeight),r+46>a&&!this.getters.isReadonly()&&(a+=46)),{width:i,height:a}}getColIndex(e){return e<this.offsetCorrectionX||e>this.offsetCorrectionX+this.viewportWidth?-1:this.searchHeaderIndex(`COL`,e-this.offsetCorrectionX+this.snapCorrection.x,this.left)}getRowIndex(e){return e<this.offsetCorrectionY||e>this.offsetCorrectionY+this.viewportHeight?-1:this.searchHeaderIndex(`ROW`,e-this.offsetCorrectionY+this.snapCorrection.y,this.top)}adjustPosition(e){let t=this.sheetId,n=this.getters.getMainCellPosition({sheetId:t,...e}),{col:r,row:i}=this.getters.getNextVisibleCellPosition(n);Vs(r,this.boundaries.top,this.boundaries)&&this.adjustPositionX(r),Vs(this.boundaries.left,i,this.boundaries)&&this.adjustPositionY(i)}adjustPositionX(e){let t=this.sheetId,{start:n,end:r}=this.getters.getColDimensions(t,e);this.offsetX+this.viewportWidth+this.offsetCorrectionX<r?this.offsetX=r-this.viewportWidth-this.offsetCorrectionX:this.offsetX+this.offsetCorrectionX>n&&(this.offsetX=n-this.offsetCorrectionX),this.adjustViewportZoneX()}adjustPositionY(e){let t=this.sheetId,{start:n,end:r}=this.getters.getRowDimensions(t,e);this.offsetY+this.viewportHeight+this.offsetCorrectionY<r?this.offsetY=r-this.viewportHeight-this.offsetCorrectionY:this.offsetY+this.offsetCorrectionY>n&&(this.offsetY=n-this.offsetCorrectionY),this.adjustViewportZoneY()}willNewOffsetScrollViewport(e,t){return this.canScrollHorizontally&&this.offsetX!==e||this.canScrollVertically&&this.offsetY!==t}setViewportOffset(e,t){this.setViewportOffsetX(e),this.setViewportOffsetY(t)}adjustViewportZone(){this.adjustViewportZoneX(),this.adjustViewportZoneY()}getVisibleRect(e){let t=Ls(e,this),n=this.snapCorrection.x,r=this.snapCorrection.y;if(t)return{x:this.getters.getColRowOffset(`COL`,this.left,t.left)+this.offsetCorrectionX-(this.left===t.left?0:n),y:this.getters.getColRowOffset(`ROW`,this.top,t.top)+this.offsetCorrectionY-(this.top===t.top?0:r),width:Math.min(this.getters.getColRowOffset(`COL`,t.left,t.right+1)-(this.left===t.left?n:0),this.viewportWidth),height:Math.min(this.getters.getColRowOffset(`ROW`,t.top,t.bottom+1)-(this.top===t.top?r:0),this.viewportHeight)}}getFullRect(e){let t=Ls(e,this.boundaries),n=this.snapCorrection.x,r=this.snapCorrection.y;if(t){let t=this.getters.getColRowOffset(`COL`,this.left,e.left)+this.offsetCorrectionX,i=this.getters.getColRowOffset(`ROW`,this.top,e.top)+this.offsetCorrectionY,a=this.getters.getColRowOffset(`COL`,e.left,e.right+1),o=this.getters.getColRowOffset(`ROW`,e.top,e.bottom+1);return{x:t-n,y:i-r,width:a,height:o}}}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,n=0){if(this.viewportWidth<=0||this.viewportHeight<=0)return-1;let r=this.sheetId,i=this.getters.getNumberHeaders(r,e),a=n,o=i;for(;a<=o&&a!==i&&o!==-1;){let i=Math.floor((a+o)/2),s=this.getters.getColRowOffset(e,n,i),c=this.getters.getHeaderSize(r,e,i);if(t>=s&&t<s+c)return i;t>=s+c?a=i+1:o=i-1}return-1}setViewportOffsetX(e){this.canScrollHorizontally&&(this.offsetX=e,this.adjustViewportZoneX())}setViewportOffsetY(e){this.canScrollVertically&&(this.offsetY=e,this.adjustViewportZoneY())}adjustViewportOffsetX(){if(this.canScrollHorizontally){let{width:e}=this.getMaxSize();this.viewportWidth+this.offsetX>e&&(this.offsetX=Math.max(0,e-this.viewportWidth))}this.adjustViewportZoneX()}adjustViewportOffsetY(){if(this.canScrollVertically){let{height:e}=this.getMaxSize();this.viewportHeight+this.offsetY>e&&(this.offsetY=Math.max(0,e-this.viewportHeight))}this.adjustViewportZoneY()}adjustViewportZoneX(){this.left=this.searchHeaderIndex(`COL`,this.offsetX,this.boundaries.left),this.right=Math.min(this.boundaries.right,this.searchHeaderIndex(`COL`,Math.max(this.viewportWidth+this.snapCorrection.x-.1),this.left)),this.viewportWidth&&(this.left===-1&&(this.left=this.boundaries.left),this.right===-1&&(this.right=this.boundaries.right))}adjustViewportZoneY(){this.top=this.searchHeaderIndex(`ROW`,this.offsetY,this.boundaries.top),this.bottom=Math.min(this.boundaries.bottom,this.searchHeaderIndex(`ROW`,Math.max(this.viewportHeight+this.snapCorrection.y-.1,0),this.top)),this.viewportHeight&&(this.top===-1&&(this.top=this.boundaries.top),this.bottom===-1&&(this.bottom=this.boundaries.bottom))}get snapCorrection(){return{x:Math.abs(this.offsetX-this.getters.getColRowOffset(`COL`,this.boundaries.left,Math.max(0,this.left))),y:Math.abs(this.offsetY-this.getters.getColRowOffset(`ROW`,this.boundaries.top,Math.max(0,this.top)))}}},oq=class extends Rp{static getters=`getColIndex.getRowIndex.getActiveMainViewport.getSheetViewDimension.getSheetViewDimensionWithHeaders.getMainViewportRect.isVisibleInViewport.getEdgeScrollCol.getEdgeScrollRow.getVisibleFigures.getVisibleRect.getVisibleRectWithoutHeaders.getVisibleCellPositions.getColRowOffsetInViewport.getMainViewportCoordinates.getActiveSheetScrollInfo.getSheetViewVisibleCols.getSheetViewVisibleRows.getFrozenSheetViewRatio.isPixelPositionVisible.getColDimensionsInViewport.getRowDimensionsInViewport.getAllActiveViewportsZonesAndRect.getRect.getFigureUI.getPositionAnchorOffset.getGridOffset.getMaximumSheetOffset`.split(`.`);viewports={};sheetViewWidth=Qe();sheetViewHeight=Qe();gridOffsetX=0;gridOffsetY=0;sheetsWithDirtyViewports=new Set;shouldAdjustViewports=!1;allowDispatch(e){switch(e.type){case`SET_VIEWPORT_OFFSET`:return this.chainValidations(this.checkScrollingDirection,this.checkIfViewportsWillChange)(e);case`RESIZE_SHEETVIEW`:return this.chainValidations(this.checkValuesAreDifferent,this.checkPositiveDimension)(e);default:return`Success`}}handleEvent(e){let t=this.getters.getActiveSheetId();if(e.options.scrollIntoView){let{col:n,row:r}=Qs(e.previousAnchor.zone,e.anchor.zone);if(e.mode===`updateAnchor`){let i=e.previousAnchor.zone,a=e.anchor.zone,{top:o,bottom:s,left:c,right:l}=this.getMainInternalViewport(t);i.left===a.left&&i.right===a.right&&(n=c>n||n>l?c:n),i.top===a.top&&i.bottom===a.bottom&&(r=o>r||r>s?o:r)}n=Math.min(n,this.getters.getNumberCols(t)-1),r=Math.min(r,this.getters.getNumberRows(t)-1),this.sheetsWithDirtyViewports.has(t)||this.refreshViewport(this.getters.getActiveSheetId(),{col:n,row:r})}}handle(e){if(yr.has(e.type))for(let e of this.getters.getSheetIds())this.sheetsWithDirtyViewports.add(e);switch(e.type){case`START`:this.selection.observe(this,{handleEvent:this.handleEvent.bind(this)}),this.resetViewports(this.getters.getActiveSheetId());break;case`UNDO`:case`REDO`:this.cleanViewports();for(let e of this.getters.getSheetIds())this.sheetsWithDirtyViewports.add(e);this.shouldAdjustViewports=!0;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`:let t=this.getters.getActiveSheetId(),{top:n,viewportHeight:r,offsetCorrectionY:i}=this.getMainInternalViewport(t),a=this.getters.getRowDimensions(t,n);this.shiftVertically(a.start+r-i);break;case`SHIFT_VIEWPORT_UP`:{let e=this.getters.getActiveSheetId(),{top:t,viewportHeight:n,offsetCorrectionY:r}=this.getMainInternalViewport(e),i=this.getters.getRowDimensions(e,t);this.shiftVertically(i.end-r-n);break}case`REMOVE_TABLE`:case`UPDATE_TABLE`:case`UPDATE_FILTER`:case`UNFREEZE_ROWS`:case`UNFREEZE_COLUMNS`:case`FREEZE_COLUMNS`:case`FREEZE_ROWS`:case`UNFREEZE_COLUMNS_ROWS`:case`REMOVE_COLUMNS_ROWS`:case`RESIZE_COLUMNS_ROWS`:case`HIDE_COLUMNS_ROWS`:case`ADD_COLUMNS_ROWS`:case`UNHIDE_COLUMNS_ROWS`:case`UNGROUP_HEADERS`:case`GROUP_HEADERS`:case`FOLD_HEADER_GROUP`:case`UNFOLD_HEADER_GROUP`:case`FOLD_HEADER_GROUPS_IN_ZONE`:case`UNFOLD_HEADER_GROUPS_IN_ZONE`:case`UNFOLD_ALL_HEADER_GROUPS`:case`FOLD_ALL_HEADER_GROUPS`:this.sheetsWithDirtyViewports.add(e.sheetId);break;case`UPDATE_CELL`:for(let e of this.getters.getSheetIds())this.sheetsWithDirtyViewports.add(e);break;case`DELETE_SHEET`:this.cleanViewports(),this.sheetsWithDirtyViewports.delete(e.sheetId);break;case`ACTIVATE_SHEET`:this.sheetsWithDirtyViewports.add(e.sheetIdTo);break;case`SCROLL_TO_CELL`:this.refreshViewport(this.getters.getActiveSheetId(),{col:e.col,row:e.row});break}}finalize(){for(let e of this.sheetsWithDirtyViewports)if(this.resetViewports(e),this.shouldAdjustViewports){let t=this.getters.getSheetPosition(e);this.getSubViewports(e).forEach(e=>{e.adjustPosition(t)})}this.sheetsWithDirtyViewports=new Set,this.shouldAdjustViewports=!1,this.setViewports()}setViewports(){let e=this.getters.getSheetIds();for(let t of e)this.viewports[t]?.bottomRight||this.resetViewports(t)}getColIndex(e){let t=this.getters.getActiveSheetId();return Math.max(...this.getSubViewports(t).map(t=>t.getColIndex(e)))}getRowIndex(e){let 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}}getGridOffset(){return{x:this.gridOffsetX,y:this.gridOffsetY}}getActiveMainViewport(){let e=this.getters.getActiveSheetId();return this.getMainViewport(e)}getActiveSheetScrollInfo(){let e=this.getters.getActiveSheetId(),t=this.getMainInternalViewport(e);return{scrollX:t.offsetX,scrollY:t.offsetY}}getSheetViewVisibleCols(){let e=this.getters.getActiveSheetId(),t=this.getSubViewports(e);return[...new Set(t.map(e=>S(e.left,e.right+1)).flat())].filter(t=>t>=0&&!this.getters.isHeaderHidden(e,`COL`,t))}getSheetViewVisibleRows(){let e=this.getters.getActiveSheetId(),t=this.getSubViewports(e);return[...new Set(t.map(e=>S(e.top,e.bottom+1)).flat())].filter(t=>t>=0&&!this.getters.isHeaderHidden(e,`ROW`,t))}getVisibleCellPositions(){let e=this.getSheetViewVisibleCols(),t=this.getSheetViewVisibleRows(),n=this.getters.getActiveSheetId(),r=[];for(let i of e)for(let e of t){let t={sheetId:n,col:i,row:e},a=this.getters.getMainCellPosition(t);a.row!==e||a.col!==i||r.push(t)}return r}getMainViewportRect(){let e=this.getters.getActiveSheetId(),t=this.getMainInternalViewport(e),{xSplit:n,ySplit:r}=this.getters.getPaneDivisions(e),{width:i,height:a}=t.getMaxSize();return{x:this.getters.getColDimensions(e,n).start,y:this.getters.getRowDimensions(e,r).start,width:i,height:a}}getMaximumSheetOffset(){let e=this.getters.getActiveSheetId(),{width:t,height:n}=this.getMainViewportRect(),r=this.getMainInternalViewport(e);return{maxOffsetX:Math.max(0,t-r.viewportWidth),maxOffsetY:Math.max(0,n-r.viewportHeight)}}getColRowOffsetInViewport(e,t,n){if(n<t)return-this.getColRowOffsetInViewport(e,n,t);let r=this.getters.getActiveSheetId(),i=e===`COL`?this.getters.getSheetViewVisibleCols():this.getters.getSheetViewVisibleRows(),a=i.findIndex(e=>t>=e),o=i.findIndex(e=>n<=e);o=o===-1?i.length:o;let s=i.slice(a,o),c=0;for(let t of s)c+=this.getters.getHeaderSize(r,e,t);return c}isVisibleInViewport({sheetId:e,col:t,row:n}){return this.getSubViewports(e).some(e=>e.isVisible(t,n))}getEdgeScrollCol(e,t,n){let r=!1,i=0,a=0,{xSplit:o}=this.getters.getPaneDivisions(this.getters.getActiveSheetId()),{width:s}=this.getSheetViewDimension(),{x:c}=this.getMainViewportCoordinates(),l=this.getActiveSheetScrollInfo().scrollX;return e>s?(r=!0,a=vc(e-s),i=1):e<c&&n>=c&&l>0?(r=!0,a=vc(c-e),i=-1):o&&t<c&&e>c&&(r=!0,a=vc(e),i=`reset`),{canEdgeScroll:r,direction:i,delay:a}}getEdgeScrollRow(e,t,n){let r=!1,i=0,a=0,{ySplit:o}=this.getters.getPaneDivisions(this.getters.getActiveSheetId()),{height:s}=this.getSheetViewDimension(),{y:c}=this.getMainViewportCoordinates(),l=this.getActiveSheetScrollInfo().scrollY;return e>s?(r=!0,a=vc(e-s),i=1):e<c&&n>=c&&l>0?(r=!0,a=vc(c-e),i=-1):o&&t<c&&e>c&&(r=!0,a=vc(e),i=`reset`),{canEdgeScroll:r,direction:i,delay:a}}getVisibleRect(e){let t=this.getVisibleRectWithoutHeaders(e);return{...t,x:t.x+this.gridOffsetX,y:t.y+this.gridOffsetY}}getVisibleRectWithoutHeaders(e){let t=this.getters.getActiveSheetId();return this.mapViewportsToRect(t,t=>t.getVisibleRect(e))}getRect(e){let t=this.getters.getActiveSheetId(),n=this.mapViewportsToRect(t,t=>t.getFullRect(e));return{...n,x:n.x+this.gridOffsetX,y:n.y+this.gridOffsetY}}getRectWithoutHeaders(e){let t=this.getters.getActiveSheetId();return this.mapViewportsToRect(t,t=>t.getFullRect(e))}getMainViewportCoordinates(){let e=this.getters.getActiveSheetId(),{xSplit:t,ySplit:n}=this.getters.getPaneDivisions(e);return{x:this.getters.getColDimensions(e,t).start,y:this.getters.getRowDimensions(e,n).start}}getColDimensionsInViewport(e,t){let{top:n}=this.getMainInternalViewport(e),r={left:t,right:t,top:n,bottom:n},{x:i,width:a}=this.getVisibleRect(r),o=i-this.gridOffsetX;return{start:o,size:a,end:o+a}}getRowDimensionsInViewport(e,t){let{left:n}=this.getMainInternalViewport(e),r={left:0,right:n,top:t,bottom:t},{y:i,height:a}=this.getVisibleRect(r),o=i-this.gridOffsetY;return{start:o,size:a,end:o+a}}getAllActiveViewportsZonesAndRect(){let e=this.getters.getActiveSheetId();return this.getSubViewports(e).map(e=>({zone:e,rect:{x:e.offsetCorrectionX+this.gridOffsetX,y:e.offsetCorrectionY+this.gridOffsetY,...e.getMaxSize()}}))}ensureMainViewportExist(e){this.viewports[e]||this.resetViewports(e)}getSubViewports(e){return this.ensureMainViewportExist(e),Object.values(this.viewports[e]).filter(C)}checkPositiveDimension(e){return e.width<0||e.height<0?`InvalidViewportSize`:`Success`}checkValuesAreDifferent(e){let{height:t,width:n}=this.getSheetViewDimension();return e.gridOffsetX===this.gridOffsetX&&e.gridOffsetY===this.gridOffsetY&&e.width===n&&e.height===t?`ValuesNotChanged`:`Success`}checkScrollingDirection({offsetX:e,offsetY:t}){let n=this.getMainInternalViewport(this.getters.getActiveSheetId());return!n.canScrollHorizontally&&e>0||!n.canScrollVertically&&t>0?`InvalidScrollingDirection`:`Success`}checkIfViewportsWillChange({offsetX:e,offsetY:t}){let n=this.getters.getActiveSheetId(),{maxOffsetX:r,maxOffsetY:i}=this.getMaximumSheetOffset();return this.getSubViewports(n).some(n=>n.willNewOffsetScrollViewport(x(e,0,r),x(t,0,i)))?`Success`:`ViewportScrollLimitsReached`}getMainViewport(e){let 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(){let e={};for(let t of this.getters.getSheetIds())e[t]=this.viewports[t];this.viewports=e}resizeSheetView(e,t,n=0,r=0){this.sheetViewHeight=e,this.sheetViewWidth=t,this.gridOffsetX=n,this.gridOffsetY=r,this.recomputeViewports()}recomputeViewports(){for(let e of this.getters.getSheetIds())this.resetViewports(e)}setSheetViewOffset(e,t){let n=this.getters.getActiveSheetId(),{maxOffsetX:r,maxOffsetY:i}=this.getMaximumSheetOffset();this.getSubViewports(n).forEach(n=>n.setViewportOffset(x(e,0,r),x(t,0,i)))}getViewportOffset(e){return{x:this.viewports[e]?.bottomRight.offsetX||0,y:this.viewports[e]?.bottomRight.offsetY||0}}resetViewports(e){if(!this.getters.tryGetSheet(e))return;let{xSplit:t,ySplit:n}=this.getters.getPaneDivisions(e),r=this.getters.getNumberCols(e),i=this.getters.getNumberRows(e),a=Math.min(this.getters.getColRowOffset(`COL`,0,t,e),this.sheetViewWidth),o=Math.min(this.getters.getColRowOffset(`ROW`,0,n,e),this.sheetViewHeight),s=Math.max(this.sheetViewWidth-a,0),c=Math.max(this.sheetViewHeight-o,0),{xRatio:l,yRatio:u}=this.getFrozenSheetViewRatio(e),d=l<1,f=u<1,p=this.getViewportOffset(e),m={topLeft:n&&t&&new aq(this.getters,e,{left:0,right:t-1,top:0,bottom:n-1},{width:a,height:o},{canScrollHorizontally:!1,canScrollVertically:!1},{x:0,y:0})||void 0,topRight:n&&new aq(this.getters,e,{left:t,right:r-1,top:0,bottom:n-1},{width:s,height:o},{canScrollHorizontally:d,canScrollVertically:!1},{x:d?p.x:0,y:0})||void 0,bottomLeft:t&&new aq(this.getters,e,{left:0,right:t-1,top:n,bottom:i-1},{width:a,height:c},{canScrollHorizontally:!1,canScrollVertically:f},{x:0,y:f?p.y:0})||void 0,bottomRight:new aq(this.getters,e,{left:t,right:r-1,top:n,bottom:i-1},{width:s,height:c},{canScrollHorizontally:d,canScrollVertically:f},{x:d?p.x:0,y:f?p.y:0})};this.viewports[e]=m}refreshViewport(e,t){this.getSubViewports(e).forEach(e=>{e.adjustViewportZone(),e.adjustPosition(t)})}shiftVertically(e){let t=this.getters.getActiveSheetId(),{top:n}=this.getMainInternalViewport(t),{scrollX:r}=this.getActiveSheetScrollInfo();this.setSheetViewOffset(r,e);let{anchor:i}=this.getters.getSelection();if(i.cell.row>=this.getters.getPaneDivisions(t).ySplit){let e=this.getMainInternalViewport(t).top-n;this.selection.selectCell(i.cell.col,i.cell.row+e)}}getColIndexLeftOfMainViewport(e){if(e>=0)return-1;let t=this.getters.getActiveSheetId(),n=this.getActiveMainViewport().left,r=-this.getActiveSheetScrollInfo().scrollX-this.getters.getColRowOffset(`COL`,n,0);for(;e<r;n--)r-=this.getters.getColSize(t,n-1);return Math.max(n,0)}getRowIndexTopOfMainViewport(e){if(e>=0)return-1;let t=this.getters.getActiveSheetId(),n=this.getActiveMainViewport().top,r=-this.getActiveSheetScrollInfo().scrollY-this.getters.getColRowOffset(`ROW`,n,0);for(;e<r;n--)r-=this.getters.getRowSize(t,n-1);return Math.max(n,0)}getVisibleFigures(){let e=this.getters.getActiveSheetId(),t=[],n=this.getters.getFigures(e),{scrollX:r,scrollY:i}=this.getters.getActiveSheetScrollInfo(),{x:a,y:o}=this.getMainViewportCoordinates(),{width:s,height:c}=this.getters.getSheetViewDimensionWithHeaders();for(let l of n){let n=this.getFigureUI(e,l),{x:u,y:d}=n;u>=a&&(u+l.width<r+a||u>s+r+a)||d>=o&&(d+l.height<i+o||d>c+i+o)||t.push(n)}return t}getFigureUI(e,t){let n=t.offset.x+this.getters.getColDimensions(e,t.col).start,r=t.offset.y+this.getters.getRowDimensions(e,t.row).start;return{...t,x:n,y:r}}getPositionAnchorOffset(e){let{scrollX:t,scrollY:n}=this.getters.getActiveSheetScrollInfo(),r=e.x-t,i=e.y-n,a=r>=0?this.getColIndex(r):this.getColIndexLeftOfMainViewport(r),o=i>=0?this.getRowIndex(i):this.getRowIndexTopOfMainViewport(i),{x:s,y:c}=this.getRect(R({col:a,row:o}));return{col:a,row:o,offset:{x:Math.max(r-s+this.gridOffsetX,0),y:Math.max(i-c+this.gridOffsetY,0)}}}isPixelPositionVisible(e){let{scrollX:t,scrollY:n}=this.getters.getActiveSheetScrollInfo(),{x:r,y:i}=this.getters.getMainViewportCoordinates(),{width:a,height:o}=this.getters.getSheetViewDimension();return!(e.x>=r&&(e.x<r+t||e.x>a+t+r)||e.y>=i&&(e.y<i+n||e.y>o+n+i))}getFrozenSheetViewRatio(e){let{xSplit:t,ySplit:n}=this.getters.getPaneDivisions(e),r=this.getters.getColDimensions(e,t).start,i=this.getters.getRowDimensions(e,n).start,a=this.sheetViewWidth+this.gridOffsetX,o=this.sheetViewHeight+this.gridOffsetY;return{xRatio:r/a,yRatio:i/o}}mapViewportsToRect(e,t){let n=1/0,r=1/0,i=0,a=0,o=!1;for(let s of this.getSubViewports(e)){let e=t(s);e&&(o=!0,n=Math.min(n,e.x),r=Math.min(r,e.y),i=Math.max(i,e.x+e.width),a=Math.max(a,e.y+e.height))}return o?{x:n,y:r,width:i-n,height:a-r}:{x:0,y:0,width:0,height:0}}},sq=class extends Rp{static getters=[`getSelectedCarouselItem`,`getChartFromFigureId`,`getChartIdFromFigureId`];uuidGenerator=new jl;carouselStates={};allowDispatch(e){switch(e.type){case`ADD_FIGURE_CHART_TO_CAROUSEL`:return!this.getters.doesCarouselExist(e.carouselFigureId)||this.getters.getFigure(e.sheetId,e.chartFigureId)?.tag!==`chart`?`InvalidFigureId`:`Success`;case`ADD_NEW_CHART_TO_CAROUSEL`:return this.getters.doesCarouselExist(e.figureId)?`Success`:`InvalidFigureId`;case`UPDATE_CAROUSEL_ACTIVE_ITEM`:return this.getters.doesCarouselExist(e.figureId)?this.getters.getCarousel(e.figureId).items.some(t=>w(t,e.item))?`Success`:`InvalidCarouselItem`:`InvalidFigureId`}return`Success`}handle(e){switch(e.type){case`ADD_NEW_CHART_TO_CAROUSEL`:this.addNewChartToCarousel(e.figureId,e.sheetId);break;case`ADD_FIGURE_CHART_TO_CAROUSEL`:this.addFigureChartToCarousel(e.carouselFigureId,e.chartFigureId,e.sheetId);break;case`UPDATE_CAROUSEL_ACTIVE_ITEM`:this.carouselStates[e.figureId]=this.getCarouselItemId(e.item);break;case`POPOUT_CHART_FROM_CAROUSEL`:this.popOutChartFromCarousel(e.carouselId,e.chartId,e.sheetId);break;case`DELETE_FIGURE`:delete this.carouselStates[e.figureId];break;case`UPDATE_CAROUSEL`:this.fixWrongCarouselState(e.figureId);break;case`DELETE_CHART`:case`UNDO`:case`REDO`:case`DELETE_SHEET`:for(let e in this.carouselStates)this.fixWrongCarouselState(e);break}}popOutChartFromCarousel(e,t,n){let r=this.getters.getCarousel(e);if(!r)return;let i=this.getters.getFigure(n,e),a=this.getters.getChartDefinition(t);if(!a||!i)return;let o=this.getters.getFigureUI(n,i),s=this.getters.getPositionAnchorOffset({x:o.x+50,y:o.y+50}),c=this.uuidGenerator.smallUuid();this.dispatch(`CREATE_CHART`,{...s,chartId:this.uuidGenerator.smallUuid(),figureId:c,sheetId:n,size:{width:i.width,height:i.height},definition:{...a}});let l=r.items.filter(e=>e.type!==`chart`||e.chartId!==t);this.dispatch(`UPDATE_CAROUSEL`,{sheetId:n,figureId:e,definition:{...r,items:l}}),this.dispatch(`SELECT_FIGURE`,{figureId:c})}getSelectedCarouselItem(e){let t=this.getters.getCarousel(e);if(t.items.length)return this.carouselStates[e]?t.items.find(t=>this.getCarouselItemId(t)===this.carouselStates[e]):t.items[0]}getChartFromFigureId(e){if(!this.getters.getFigureSheetId(e))return;let t=this.getChartIdFromFigureId(e);return t?this.getters.getChart(t):void 0}getChartIdFromFigureId(e){let t=this.getters.getFigureSheetId(e);if(!t)return;let n=this.getters.getFigure(t,e);if(!(!n||n.tag!==`chart`&&n.tag!==`carousel`)){if(n.tag===`carousel`){let t=this.getSelectedCarouselItem(e);return t?.type===`chart`?t.chartId:void 0}return this.getters.getChartIds(t).find(t=>this.getters.getFigureIdFromChartId(t)===e)}}fixWrongCarouselState(e){if(!this.getters.doesCarouselExist(e)){delete this.carouselStates[e];return}let t=this.getters.getCarousel(e);t.items.length===0?delete this.carouselStates[e]:this.carouselStates[e]&&t.items.some(t=>this.getCarouselItemId(t)===this.carouselStates[e])||(this.carouselStates[e]=this.getCarouselItemId(t.items[0]))}addNewChartToCarousel(e,t){let n=this.getters.getCarousel(e),r=this.uuidGenerator.smallUuid();this.dispatch(`CREATE_CHART`,{chartId:r,figureId:e,sheetId:t,definition:WO});let i={...n,items:[...n.items,{type:`chart`,chartId:r}]};this.dispatch(`UPDATE_CAROUSEL`,{sheetId:t,figureId:e,definition:i})}addFigureChartToCarousel(e,t,n){let r=this.getChartIdFromFigureId(t);if(!r)return;let i=this.getters.getCarousel(e),a={...i,items:[...i.items,{type:`chart`,chartId:r}]};this.dispatch(`UPDATE_CAROUSEL`,{sheetId:n,figureId:e,definition:a}),this.dispatch(`UPDATE_CHART`,{sheetId:n,chartId:r,figureId:e,definition:this.getters.getChartDefinition(r)}),this.dispatch(`DELETE_FIGURE`,{sheetId:n,figureId:t})}getCarouselItemId(e){return e.type===`chart`?e.chartId:`carouselDataView`}},cq=class extends Rp{static getters=[`getColDimensions`,`getRowDimensions`,`getColRowOffset`];headerPositions={};isDirty=!0;handle(e){switch(yr.has(e.type)&&(this.headerPositions={},this.isDirty=!0),e.type){case`START`:for(let e of this.getters.getSheetIds())this.headerPositions[e]=this.computeHeaderPositionsOfSheet(e);break;case`UPDATE_CELL`:this.headerPositions={},this.isDirty=!0;break;case`UPDATE_FILTER`:case`UPDATE_TABLE`:case`REMOVE_TABLE`:this.headerPositions={},this.isDirty=!0;break;case`REMOVE_COLUMNS_ROWS`:case`RESIZE_COLUMNS_ROWS`:case`HIDE_COLUMNS_ROWS`:case`ADD_COLUMNS_ROWS`:case`UNHIDE_COLUMNS_ROWS`:case`FOLD_HEADER_GROUP`:case`UNFOLD_HEADER_GROUP`:case`FOLD_HEADER_GROUPS_IN_ZONE`:case`UNFOLD_HEADER_GROUPS_IN_ZONE`:case`UNFOLD_ALL_HEADER_GROUPS`:case`FOLD_ALL_HEADER_GROUPS`:case`UNGROUP_HEADERS`:case`GROUP_HEADERS`:case`CREATE_SHEET`:this.getters.tryGetSheet(e.sheetId)&&(this.headerPositions[e.sheetId]=this.computeHeaderPositionsOfSheet(e.sheetId));break;case`DUPLICATE_SHEET`:this.headerPositions[e.sheetIdTo]=b(this.headerPositions[e.sheetId]);break}}finalize(){for(let e of this.getters.getSheetIds())(this.isDirty||!this.headerPositions[e])&&(this.headerPositions[e]=this.computeHeaderPositionsOfSheet(e));this.isDirty=!1}getColDimensions(e,t){let n=this.headerPositions[e].COL[t],r=this.getters.getColSize(e,t);return{start:n,size:r,end:n+(this.getters.isColHidden(e,t)?0:r)}}getRowDimensions(e,t){let n=this.headerPositions[e].ROW[t],r=this.getters.getRowSize(e,t);return{start:n,size:r,end:n+(this.getters.isRowHidden(e,t)?0:r)}}getColRowOffset(e,t,n,r=this.getters.getActiveSheetId()){let i=this.headerPositions[r][e][t];return this.headerPositions[r][e][n]-i}computeHeaderPositionsOfSheet(e){return{COL:this.computePositions(e,`COL`),ROW:this.computePositions(e,`ROW`)}}computePositions(e,t){let n={},r=0;for(let i=0;i<this.getters.getNumberHeaders(e,t)+1;i++)n[i]=r,!this.getters.isHeaderHidden(e,t,i)&&(r+=this.getters.getHeaderSize(e,t,i));return n}};let lq=new g().add(`settings`,vW).add(`sheet`,pW).add(`header grouping`,gW).add(`header visibility`,sW).add(`tables`,mW).add(`dataValidation`,iW).add(`cell`,QU).add(`merge`,lW).add(`headerSize`,oW).add(`borders`,ZU).add(`conditional formatting`,rW).add(`figures`,aW).add(`chart`,tW).add(`carousel`,hW).add(`image`,cW).add(`pivot_core`,_W).add(`spreadsheet_pivot_core`,yW).add(`tableStyle`,bW),uq=new g().add(`ui_sheet`,gK).add(`ui_options`,hK).add(`autofill`,CG).add(`sort`,mK).add(`automatic_sum`,wG).add(`format`,uK).add(`insert_pivot`,pK).add(`pivot_presence`,ZK).add(`split_to_columns`,QK).add(`subtotal_evaluation`,zp).add(`collaborative`,cK).add(`history`,YK).add(`data_cleanup`,lK).add(`table_autofill`,$K).add(`table_ui_resize`,eq).add(`datavalidation_insert`,SK).add(`checkbox_toggle`,xK).add(`dynamic_translate`,CK).add(`geo_features`,dK),dq=new g().add(`selection`,iq).add(`evaluation_filter`,rq).add(`header_visibility_ui`,fK).add(`cell_computed_style`,bK).add(`table_computed_style`,_K).add(`header_positions`,cq).add(`viewport`,oq).add(`clipboard`,tq).add(`carousel_ui`,sq),fq=new g().add(`evaluation`,GW).add(`evaluation_chart`,XW).add(`evaluation_cf`,ZW).add(`row_size`,iG).add(`data_validation_ui`,$W).add(`dynamic_tables`,rG).add(`custom_colors`,YW).add(`pivot_ui`,lG).add(`cell_icon`,nG);up.add(`dataValidation`,{displayAllOnInitialContent:!0,canBeToggled:!1,getProposals(e,t){if(on(t)||!this.composer.currentEditedCell)return[];let n=this.composer.currentEditedCell,r=this.getters.getValidationRuleForCell(n);if(!r||r.criterion.type!==`isValueInList`&&r.criterion.type!==`isValueInRange`)return[];let i=this.composer.currentEditedCell.sheetId,a=r.criterion.type===`isValueInRange`?this.getters.getDataValidationRangeValues(i,r.criterion):r.criterion.values.map(e=>({label:e,value:e}));if(r.criterion.displayStyle!==`chip`)return a.map(e=>({text:e.value,fuzzySearchKey:e.label,htmlContent:[{value:e.label}]}));let o=r.criterion.colors;return a.map(e=>{let t=o?.[e.value];return{text:e.value,htmlContent:[{value:e.label,color:t?Mn(t):void 0,backgroundColor:t||`#E7E9ED`,classes:[`badge rounded-pill fs-6 fw-normal w-100 mt-1 text-start`]}],fuzzySearchKey:e.label}})},selectProposal(e,t){this.composer.setCurrentContent(t),this.composer.stopEdition()}}),up.add(`functions`,{sequence:100,autoSelectFirstProposal:!0,maxDisplayedProposals:10,getProposals(e){if(e.type!==`SYMBOL`)return[];let t=e.value;return on(this.composer.currentContent)?Object.entries(zS.content).filter(([e,{hidden:t}])=>!t).map(([e,{description:n}])=>({text:e,description:n,htmlContent:$H(t,e,ge,`o-semi-bold`)})).sort((e,t)=>e.text.length-t.text.length||e.text.localeCompare(t.text)):[]},selectProposal(e,t){let n=e.end,r=e.end;[`SYMBOL`,`FUNCTION`].includes(e.type)&&(n=e.start);let i=this.composer.currentTokens;t+=`(`;let a=i.map(e=>e.start).indexOf(e.start);a+1<i.length&&i[a+1]?.type===`LEFT_PAREN`&&r++,this.composer.changeComposerCursorSelection(n,r),this.composer.replaceComposerCursorSelection(t)}}),up.add(`pivot_ids`,{sequence:50,autoSelectFirstProposal:!0,getProposals(e){let t=e.functionContext;if(!t||![`PIVOT.VALUE`,`PIVOT.HEADER`,`PIVOT`].includes(t.parent.toUpperCase())||t.argPosition!==0)return;let n=this.getters.getPivotIds();if(!n.includes(e.value))return n.map(e=>{let t=this.getters.getPivotCoreDefinition(e),n=`${this.getters.getPivotFormulaId(e)}`;return{text:n,description:t.name,htmlContent:[{value:n,color:ot.NUMBER}],fuzzySearchKey:n+t.name,alwaysExpanded:!0}}).filter(C)},selectProposal:qS}),up.add(`pivot_measures`,{sequence:50,autoSelectFirstProposal:!0,getProposals(e){let t=e.functionContext;if(t?.parent.toUpperCase()!==`PIVOT.VALUE`||t.argPosition!==1)return[];let n=mU(e),r=this.getters.getPivotId(n);if(!r||!this.getters.isExistingPivot(r))return[];let i=this.getters.getPivot(r);return i.init(),i.isValid()?i.definition.measures.map(e=>{if(e.fieldName===`__count`){let e=`"__count"`;return{text:e,description:E(`Count`),htmlContent:[{value:e,color:ot.STRING}],fuzzySearchKey:E(`Count`)+e}}return dU(e)}).filter(C):[]},selectProposal:qS}),up.add(`pivot_group_fields`,{sequence:50,autoSelectFirstProposal:!0,getProposals(e){let t=e.functionContext;if(!t||!pq(e)&&!mq(e))return;let n=mU(e),r=this.getters.getPivotId(n);if(!r||!this.getters.isExistingPivot(r))return;let i=this.getters.getPivot(r);i.init();let a=i.getFields(),{columns:o,rows:s}=i.definition,c=t.args;t?.parent.toUpperCase()===`PIVOT.VALUE`?(c=c.filter((e,t)=>t%2==0),c=c.slice(1,t.argPosition)):c=c.filter((e,t)=>t%2==1);let l=c.map(e=>e?.value).filter(C),u=o.map(e=>e.nameWithGranularity),d=s.map(e=>e.nameWithGranularity),f=[],p=[`ARG_SEPARATOR`,`SPACE`].includes(e.type)?l.at(-1):l.at(-2),m=KU.get(i.type);if(m&&p?.startsWith(`#`)&&(p=p.slice(1)),p===void 0&&(f.push(u[0]),f.push(d[0])),d.includes(p)){let e=d[d.indexOf(p)+1];f.push(e),f.push(u[0])}if(u.includes(p)){let e=u[u.indexOf(p)+1];f.push(e)}let h=f.filter(C);return h.map(e=>{let[t,n]=e.split(`:`),r=a[t];return r?uU(r,n):void 0}).concat(h.map(e=>{if(!m)return;let t=a[e.split(`:`)[0]];if(!t)return;let n=`"#${e}"`;return{text:n,description:E(`%s (positional)`,t.string)+(t.help?` (${t.help})`:``),htmlContent:[{value:n,color:ot.STRING}],fuzzySearchKey:t.string+n}})).filter(C)},selectProposal:qS});function pq(e){let t=e.functionContext;return t?.parent.toUpperCase()===`PIVOT.VALUE`&&t.argPosition>=2&&t.argPosition%2==0}function mq(e){let t=e.functionContext;return t?.parent.toUpperCase()===`PIVOT.HEADER`&&t.argPosition>=1&&t.argPosition%2==1}up.add(`pivot_group_values`,{sequence:50,autoSelectFirstProposal:!0,getProposals(e){let t=e.functionContext;if(!t||!e||!hq(e)&&!gq(e))return;let n=mU(e),r=this.getters.getPivotId(n);if(!r||!this.getters.isExistingPivot(r))return;let i=this.getters.getPivot(r);if(!i.isValid())return;let a=t.argPosition,o=e.functionContext?.args[a-1]?.value;if(!o)return;let s;try{s=i.definition.getDimension(o)}catch{return}return s.granularity===`month_number`?Object.values(go).map((e,t)=>({text:`${t+1}`,fuzzySearchKey:e.toString(),description:e.toString(),htmlContent:[{value:`${t+1}`,color:ot.NUMBER}]})):s.granularity===`quarter_number`?[1,2,3,4].map(e=>({text:`${e}`,fuzzySearchKey:`${e}`,description:E(`Quarter %s`,e),htmlContent:[{value:`${e}`,color:ot.NUMBER}]})):s.granularity===`day_of_month`?S(1,32).map(e=>({text:`${e}`,fuzzySearchKey:`${e}`,description:``,htmlContent:[{value:`${e}`,color:ot.NUMBER}]})):s.granularity===`iso_week_number`?S(0,54).map(e=>({text:`${e}`,fuzzySearchKey:`${e}`,description:``,htmlContent:[{value:`${e}`,color:ot.NUMBER}]})):s.granularity===`day_of_week`?S(1,8).map(e=>({text:`${e}`,fuzzySearchKey:`${e}`,description:``,htmlContent:[{value:`${e}`,color:ot.NUMBER}]})):s.granularity===`hour_number`?S(0,24).map(e=>({text:`${e}`,fuzzySearchKey:`${e}`,description:``,htmlContent:[{value:`${e}`,color:ot.NUMBER}]})):s.granularity===`minute_number`?S(0,60).map(e=>({text:`${e}`,fuzzySearchKey:`${e}`,description:``,htmlContent:[{value:`${e}`,color:ot.NUMBER}]})):s.granularity===`second_number`?S(0,60).map(e=>({text:`${e}`,fuzzySearchKey:`${e}`,description:``,htmlContent:[{value:`${e}`,color:ot.NUMBER}]})):i.getPossibleFieldValues(s).map(({value:e,label:t})=>{let n=typeof e==`string`,r=n?`"${e}"`:e.toString(),i=n?ot.STRING:ot.NUMBER,a=t===e?``:t;return{text:r,description:a,htmlContent:[{value:r,color:i}],fuzzySearchKey:r+a}})},selectProposal:qS});function hq(e){let t=e.functionContext;return t?.parent.toUpperCase()===`PIVOT.VALUE`&&t.argPosition>=2&&t.argPosition%2==1}function gq(e){let t=e.functionContext;return t?.parent.toUpperCase()===`PIVOT.HEADER`&&t.argPosition>=1&&t.argPosition%2==0}up.add(`sheet_names`,{sequence:150,autoSelectFirstProposal:!0,getProposals(e){return e.type===`SYMBOL`||e.type===`UNKNOWN`&&e.value.startsWith(`'`)?this.getters.getSheetIds().map(e=>{let t=mt(this.getters.getSheetName(e));return{text:t,fuzzySearchKey:t.startsWith(`'`)?t:`'`+t}}):[]},selectProposal(e,t){let n=e.start,r=e.end;this.composer.changeComposerCursorSelection(n,r),this.composer.replaceComposerCursorSelection(t+`!`)}});let _q=new g;_q.add(`link`,{condition:(e,t)=>!!t.getEvaluatedCell(e).link,execute:(e,t,n)=>Yr(t.model.getters.getEvaluatedCell(e).link,t,n),title:(e,t)=>{let n=t.getEvaluatedCell(e).link;return n?n.isExternal?E(`Go to url: %(url)s`,{url:n.url}):E(`Go to %(label)s`,{label:n.label}):``},sequence:5}),_q.add(`dashboard_pivot_sorting`,{condition:(e,t)=>{if(!t.isDashboard())return!1;let n=t.getPivotCellFromPosition(e);return AR(t,e)&&n.type===`MEASURE_HEADER`},execute:(e,t)=>{jR(t,e,yq(t.model.getters,e))},component:qU,componentProps:(e,t)=>({position:e,sortDirection:t.getPivotCellSortDirection(e)}),sequence:2});let vq={none:`asc`,asc:`desc`,desc:`none`};function yq(e,t){return vq[e.getPivotCellSortDirection(t)??`none`]}let bq=new g().add(`ADD_COLUMNS_ROWS`,Cq).add(`REMOVE_COLUMNS_ROWS`,Oq).add(`ADD_MERGE`,wq).add(`REMOVE_MERGE`,Tq).add(`CREATE_SHEET`,Eq).add(`DELETE_SHEET`,kq).add(`DUPLICATE_SHEET`,Dq).add(`CREATE_FIGURE`,Aq).add(`CREATE_CHART`,jq).add(`HIDE_COLUMNS_ROWS`,Mq).add(`UNHIDE_COLUMNS_ROWS`,Nq).add(`CREATE_TABLE_STYLE`,Pq).add(`ADD_PIVOT`,Sq).add(`RENAME_SHEET`,Fq);for(let e of Er.values())bq.contains(e)||bq.add(e,xq);function xq(e){return[e]}function Sq(e){return[{type:`REMOVE_PIVOT`,pivotId:e.pivotId}]}function Cq(e){let t=[],n=e.base;e.position===`after`&&n++;for(let r=0;r<e.quantity;r++)t.push(r+n);return[{type:`REMOVE_COLUMNS_ROWS`,dimension:e.dimension,elements:t,sheetId:e.sheetId,sheetName:e.sheetName}]}function wq(e){return[{type:`REMOVE_MERGE`,sheetId:e.sheetId,target:e.target}]}function Tq(e){return[{type:`ADD_MERGE`,sheetId:e.sheetId,target:e.target}]}function Eq(e){return[{type:`DELETE_SHEET`,sheetId:e.sheetId,sheetName:e.name}]}function Dq(e){return[{type:`DELETE_SHEET`,sheetId:e.sheetIdTo,sheetName:``}]}function Oq(e){let t=[],n=[...e.elements].sort((e,t)=>e-t);for(let r of gt(n)){let n=r[0]===0?0:r[0]-1,i=r[0]===0?`before`:`after`;t.push({type:`ADD_COLUMNS_ROWS`,dimension:e.dimension,quantity:r.length,base:n,sheetId:e.sheetId,sheetName:e.sheetName,position:i})}return t}function kq(e){return[{type:`CREATE_SHEET`,sheetId:e.sheetId,position:1,name:e.sheetName}]}function Aq(e){return[{type:`DELETE_FIGURE`,figureId:e.figureId,sheetId:e.sheetId}]}function jq(e){return[{type:`DELETE_FIGURE`,figureId:e.figureId,sheetId:e.sheetId}]}function Mq(e){return[{type:`UNHIDE_COLUMNS_ROWS`,sheetId:e.sheetId,dimension:e.dimension,elements:e.elements}]}function Nq(e){return[{type:`HIDE_COLUMNS_ROWS`,sheetId:e.sheetId,dimension:e.dimension,elements:e.elements}]}function Pq(e){return[{type:`REMOVE_TABLE_STYLE`,tableStyleId:e.tableStyleId}]}function Fq(e){return[{type:`RENAME_SHEET`,sheetId:e.sheetId,oldName:e.newName,newName:e.oldName}]}let Iq=new g;Iq.add(`format_number_automatic`,{...QR,id:`format_number_automatic`,sequence:10}).add(`format_number_plain_text`,{...$R,id:`format_number_plain_text`,sequence:15,separator:!0}).add(`format_number_number`,{...ez,id:`format_number_number`,sequence:20}).add(`format_number_percent`,{...nz,id:`format_number_percent`,sequence:30,separator:!0}).add(`format_number_currency`,{...rz,id:`format_number_currency`,sequence:40}).add(`format_number_accounting`,{...az,id:`format_number_accounting`,sequence:45}).add(`format_number_currency_rounded`,{...iz,id:`format_number_currency_rounded`,sequence:50}).add(`format_custom_currency`,{...sz,id:`format_custom_currency`,sequence:60,separator:!0}).add(`format_number_date`,{...cz,id:`format_number_date`,sequence:70}).add(`format_number_time`,{...lz,id:`format_number_time`,sequence:80}).add(`format_number_date_time`,{...uz,id:`format_number_date_time`,sequence:90}).add(`format_number_duration`,{...dz,id:`format_number_duration`,sequence:100,separator:!0}).add(`more_formats`,{...mz,id:`more_formats`,sequence:120});function Lq(e){let t=new Set(Iq.getAll().map(t=>typeof t.format==`function`?t.format(e):t.format)),n=new Map;for(let r of e.model.getters.getSheetIds()){let i=e.model.getters.getEvaluatedCells(r);for(let e in i){let r=i[e];if(r.format&&!n.has(r.format)&&!t.has(r.format)){let e=Rq(r.format);(e===`date`||e===`currency`)&&n.set(r.format,ZR({descriptionValue:e===`currency`?1e3:oz,format:r.format,name:r.format}))}}}return[...n.values()]}let Rq=Kt(e=>jo(e)?`date`:e.includes(`[$`)?`currency`:`number`),zq={name:E(`More formats`),icon:`o-spreadsheet-Icon.NUMBER_FORMATS`,children:[e=>{let t=Lq(e).map(e=>({...e,sequence:110}));return t.length>0&&(t[t.length-1].separator=!0),f([...Iq.getAll(),...t])}]};function Bq(e){let t=new IA;return t.add(`delete`,{...kA,sequence:10}).add(`hide_sheet`,{...FA,sequence:20}).add(`duplicate`,{...AA,sequence:30,separator:!0}).add(`rename`,{...jA(e),sequence:40}).add(`change_color`,{...MA(e),sequence:50,separator:!0}).add(`move_right`,{...NA,sequence:60}).add(`move_left`,{...PA,sequence:70}),t}let Vq=new IA;Vq.add(`file`,{name:E(`File`),sequence:10,isReadonlyAllowed:!0}).addChild(`settings`,[`file`],{name:E(`Settings`),sequence:200,execute:e=>e.openSidePanel(`Settings`),isEnabled:e=>!e.isSmall,icon:`o-spreadsheet-Icon.COG`}).add(`edit`,{name:E(`Edit`),sequence:20,isReadonlyAllowed:!0}).addChild(`undo`,[`edit`],{...DI,sequence:10}).addChild(`redo`,[`edit`],{...OI,sequence:20,separator:!0}).addChild(`copy`,[`edit`],{...kI,sequence:30}).addChild(`cut`,[`edit`],{...AI,sequence:40}).addChild(`paste`,[`edit`],{...jI,sequence:50}).addChild(`paste_special`,[`edit`],{...MI,sequence:60,separator:!0}).addChild(`paste_special_value`,[`edit`,`paste_special`],{...NI,sequence:10}).addChild(`paste_special_format`,[`edit`,`paste_special`],{...PI,sequence:20}).addChild(`edit_table`,[`edit`],{...qI,isVisible:DF,sequence:60}).addChild(`find_and_replace`,[`edit`],{...FI,sequence:65,separator:!0}).addChild(`delete`,[`edit`],{name:E(`Delete`),icon:`o-spreadsheet-Icon.TRASH`,sequence:70}).addChild(`edit_delete_cell_values`,[`edit`,`delete`],{...II,sequence:10}).addChild(`edit_delete_row`,[`edit`,`delete`],{...LI,sequence:20}).addChild(`edit_delete_column`,[`edit`,`delete`],{...BI,sequence:30}).addChild(`edit_delete_cell_shift_up`,[`edit`,`delete`],{...WI,sequence:40}).addChild(`edit_delete_cell_shift_left`,[`edit`,`delete`],{...GI,sequence:50}).addChild(`edit_unhide_columns`,[`edit`],{...UF,sequence:80}).addChild(`edit_unhide_rows`,[`edit`],{...KF,sequence:80}).add(`view`,{name:E(`View`),sequence:30,isReadonlyAllowed:!0}).addChild(`unfreeze_panes`,[`view`],{...qF,sequence:4}).addChild(`freeze_panes`,[`view`],{...JF,sequence:5}).addChild(`unfreeze_rows`,[`view`,`freeze_panes`],{...YF,sequence:5}).addChild(`freeze_first_row`,[`view`,`freeze_panes`],{...XF,sequence:10}).addChild(`freeze_second_row`,[`view`,`freeze_panes`],{...ZF,sequence:15}).addChild(`freeze_current_row`,[`view`,`freeze_panes`],{...QF,sequence:20,separator:!0}).addChild(`unfreeze_columns`,[`view`,`freeze_panes`],{...$F,sequence:25}).addChild(`freeze_first_col`,[`view`,`freeze_panes`],{...eI,sequence:30}).addChild(`freeze_second_col`,[`view`,`freeze_panes`],{...tI,sequence:35}).addChild(`freeze_current_col`,[`view`,`freeze_panes`],{...nI,sequence:40}).addChild(`group_headers`,[`view`],{name:E(`Group`),sequence:15,separator:!0,icon:`o-spreadsheet-Icon.PLUS_IN_BOX`,isVisible:NF}).addChild(`group_columns`,[`view`,`group_headers`],{...oI,sequence:5}).addChild(`ungroup_columns`,[`view`,`group_headers`],{...cI,isVisible:e=>fI(e,`COL`),sequence:10}).addChild(`group_rows`,[`view`,`group_headers`],{...sI,sequence:15}).addChild(`ungroup_rows`,[`view`,`group_headers`],{...lI,isVisible:e=>fI(e,`ROW`),sequence:20}).addChild(`show`,[`view`],{name:E(`Show`),sequence:1,icon:`o-spreadsheet-Icon.SHOW`}).addChild(`view_gridlines`,[`view`,`show`],{...rI,sequence:5}).addChild(`view_formulas`,[`view`,`show`],{...aI,sequence:10}).addChild(`view_irregularity_map`,[`view`],{...iI,sequence:40,separator:!0}).add(`insert`,{name:E(`Insert`),sequence:40,isReadonlyAllowed:!0}).addChild(`insert_row`,[`insert`],{...QI,sequence:10}).addChild(`insert_row_before`,[`insert`,`insert_row`],{...eL,sequence:10}).addChild(`insert_row_after`,[`insert`,`insert_row`],{...rL,sequence:20}).addChild(`insert_column`,[`insert`],{...iL,sequence:20}).addChild(`insert_column_before`,[`insert`,`insert_column`],{...oL,sequence:10}).addChild(`insert_column_after`,[`insert`,`insert_column`],{...lL,sequence:20}).addChild(`insert_cell`,[`insert`],{...uL,sequence:30}).addChild(`insert_cell_down`,[`insert`,`insert_cell`],{...dL,name:E(`Shift down`),sequence:10}).addChild(`insert_cell_right`,[`insert`,`insert_cell`],{...fL,name:E(`Shift right`),sequence:20}).addChild(`insert_sheet`,[`insert`],{...AL,sequence:40,separator:!0}).addChild(`insert_chart`,[`insert`],{...pL,sequence:50}).addChild(`insert_carousel`,[`insert`],{...mL,sequence:51}).addChild(`insert_pivot`,[`insert`],{...hL,sequence:52}).addChild(`insert_image`,[`insert`],{...gL,sequence:55}).addChild(`insert_table`,[`insert`],{..._L,sequence:57}).addChild(`insert_function`,[`insert`],{...vL,sequence:60}).addChild(`insert_function_sum`,[`insert`,`insert_function`],{...yL,sequence:0}).addChild(`insert_function_average`,[`insert`,`insert_function`],{...bL,sequence:10}).addChild(`insert_function_count`,[`insert`,`insert_function`],{...xL,sequence:20}).addChild(`insert_function_max`,[`insert`,`insert_function`],{...SL,sequence:30}).addChild(`insert_function_min`,[`insert`,`insert_function`],{...CL,sequence:40,separator:!0}).addChild(`categorie_function_all`,[`insert`,`insert_function`],{...wL,sequence:50}).addChild(`categories_function_list`,[`insert`,`insert_function`],EL).addChild(`insert_link`,[`insert`],{...DL,separator:!0,sequence:70}).addChild(`insert_checkbox`,[`insert`],{...OL,sequence:80}).addChild(`insert_dropdown`,[`insert`],{...kL,separator:!0,sequence:90}).add(`format`,{name:E(`Format`),sequence:50,isReadonlyAllowed:!0}).addChild(`format_number`,[`format`],{...zq,name:E(`Number`),sequence:10,separator:!0}).addChild(`format_bold`,[`format`],{...Ez,sequence:20}).addChild(`format_italic`,[`format`],{...Dz,sequence:30}).addChild(`format_underline`,[`format`],{...Oz,sequence:40}).addChild(`format_strikethrough`,[`format`],{...kz,sequence:50,separator:!0}).addChild(`format_font_size`,[`format`],{...Az,sequence:60,separator:!0}).addChild(`format_alignment`,[`format`],{...jz,sequence:70}).addChild(`format_alignment_left`,[`format`,`format_alignment`],{...Nz,sequence:10}).addChild(`format_alignment_center`,[`format`,`format_alignment`],{...Pz,sequence:20}).addChild(`format_alignment_right`,[`format`,`format_alignment`],{...Fz,sequence:30,separator:!0}).addChild(`format_alignment_top`,[`format`,`format_alignment`],{...Lz,sequence:40}).addChild(`format_alignment_middle`,[`format`,`format_alignment`],{...Rz,sequence:50}).addChild(`format_alignment_bottom`,[`format`,`format_alignment`],{...zz,sequence:60,separator:!0}).addChild(`format_wrapping`,[`format`],{...Bz,sequence:80,separator:!0}).addChild(`format_wrapping_overflow`,[`format`,`format_wrapping`],{...Hz,sequence:10}).addChild(`format_wrapping_wrap`,[`format`,`format_wrapping`],{...Uz,sequence:20}).addChild(`format_wrapping_clip`,[`format`,`format_wrapping`],{...Wz,sequence:30}).addChild(`format_cf`,[`format`],{...Gz,sequence:90,separator:!0}).addChild(`format_clearFormat`,[`format`],{...Kz,sequence:100,separator:!0}).add(`data`,{name:E(`Data`),sequence:60,isReadonlyAllowed:!0}).addChild(`sort_range`,[`data`],{...BR,sequence:10,separator:!0}).addChild(`sort_ascending`,[`data`,`sort_range`],{...VR,sequence:10}).addChild(`sort_descending`,[`data`,`sort_range`],{...GR,sequence:20}).addChild(`data_cleanup`,[`data`],{...HR,sequence:15}).addChild(`remove_duplicates`,[`data`,`data_cleanup`],{...UR,sequence:10}).addChild(`trim_whitespace`,[`data`,`data_cleanup`],{...WR,sequence:20}).addChild(`split_to_columns`,[`data`],{...JR,sequence:20}).addChild(`data_validation`,[`data`],{name:E(`Data Validation`),execute:e=>{e.openSidePanel(`DataValidation`)},isEnabled:e=>!e.isSmall,icon:`o-spreadsheet-Icon.DATA_VALIDATION`,sequence:30,separator:!0}).addChild(`add_remove_data_filter`,[`data`],{...KR,sequence:40,separator:!0}).addChild(`pivot_data_sources`,[`data`],e=>{let t=e.model.getters.getPivotIds().length;return e.model.getters.getPivotIds().map((n,r)=>{let i={get highlights(){return YH(e.model.getters,n)}};return{id:`item_pivot_${e.model.getters.getPivotFormulaId(n)}`,name:e.model.getters.getPivotDisplayName(n),sequence:50+r/t,isReadonlyAllowed:!0,execute:e=>e.openSidePanel(`PivotSidePanel`,{pivotId:n}),isEnabled:e=>!e.isSmall,onStartHover:e=>e.getStore(Kk).register(i),onStopHover:e=>e.getStore(Kk).unRegister(i),icon:`o-spreadsheet-Icon.PIVOT`,separator:r===e.model.getters.getPivotIds().length-1,secondaryIcon:e=>e.model.getters.isPivotUnused(n)?`o-spreadsheet-Icon.UNUSED_PIVOT_WARNING`:void 0}})}).addChild(`reinsert_dynamic_pivot`,[`data`],YR).addChild(`reinsert_static_pivot`,[`data`],XR);let Hq=new class extends g{mapping={};uuidGenerator=new jl;replace(e,t){let n={...t,id:this.uuidGenerator.uuidv4()};return super.replace(e,n)}getAllOrdered(){return this.getAll().sort((e,t)=>e.sequence-t.sequence)}};var Uq=class{listeners=[];async sendMessage(e){for(let{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)}},Wq=class{fileStore;constructor(e){this.fileStore=e}async requestImage(){let e=await this.userImageUpload(),t=await this.fileStore.upload(e);return{path:t,size:await this.getImageOriginalSize(t),mimetype:e.type}}async uploadFile(e){let t=await this.fileStore.upload(e);return{path:t,size:await this.getImageOriginalSize(t),mimetype:e.type}}userImageUpload(){return new Promise((e,t)=>{let n=document.createElement(`input`);n.setAttribute(`type`,`file`),n.setAttribute(`accept`,`image/*`),n.addEventListener(`change`,async()=>{n.files===null||n.files.length!==1?t():e(n.files[0])}),n.click()})}getImageOriginalSize(e){return new Promise((t,n)=>{let r=new Image;r.addEventListener(`load`,()=>{t({width:r.width,height:r.height})}),r.addEventListener(`error`,n),r.src=e})}};let Gq=[{transform:`scale(0)`},{transform:`scale(0.8)`,offset:.33},{opacity:`0`,transform:`scale(1)`,offset:1}];B`
1933
+ You can download it directly instead.`,5),sticky:!1,type:`warning`});return}r=await oT(t)}}if(r)return r instanceof File?r:new File([r],`image.png`,{type:`image/png`})}isCutOperation(){return this._isCutOperation??!1}getDeleteCellsTargets(e,t){let n=this.getters.getActiveSheetId(),r;return r=t===`COL`?{...e,left:e.right+1,right:this.getters.getNumberCols(n)-1}:{...e,top:e.bottom+1,bottom:this.getters.getNumberRows(n)-1},{cut:[r],paste:[e]}}getInsertCellsTargets(e,t){let n=this.getters.getActiveSheetId(),r,i;return t===`COL`?(r={...e,right:this.getters.getNumberCols(n)-1},i={...e,left:e.right+1,right:e.right+1}):(r={...e,bottom:this.getters.getNumberRows(n)-1},i={...e,top:e.bottom+1,bottom:this.getters.getNumberRows(n)-1}),{cut:[r],paste:[i]}}getClipboardData(e){let t=this.getters.getActiveSheetId(),n=this.getters.getSelectedFigureId();if(n)return{figureId:n,sheetId:t};let r=Nl(t,e);return this._isCutOperation||(r.rowsIndexes=r.rowsIndexes.filter(e=>!this.getters.isRowFiltered(t,e))),r}drawLayer(e){if(this.status!==`visible`||!this.copiedData)return;let{sheetId:t,zones:n}=this.copiedData;if(t!==this.getters.getActiveSheetId()||!n||!n.length)return;let{ctx:r,thinLineWidth:i}=e;r.setLineDash([8,5]),r.strokeStyle=ae,r.lineWidth=3.3*i;for(let e of n){let{x:t,y:n,width:i,height:a}=this.getters.getVisibleRect(e);i>0&&a>0&&r.strokeRect(t,n,i,a)}}};let nq={filterType:`criterion`,type:`none`,values:[]};var rq=class extends Rp{static getters=[`getFilterValue`,`getFilterHiddenValues`,`getFilterCriterionValue`,`getFirstTableInSelection`,`isRowFiltered`,`isFilterActive`];filterValues={};hiddenRows={};isEvaluationDirty=!1;allowDispatch(e){switch(e.type){case`UPDATE_FILTER`:if(!this.getters.getFilterId(e))return`FilterNotFound`;break}return`Success`}handle(e){switch(e.type){case`UNDO`:case`REDO`:case`UPDATE_CELL`:case`EVALUATE_CELLS`:case`ACTIVATE_SHEET`:case`REMOVE_TABLE`:case`ADD_COLUMNS_ROWS`:case`REMOVE_COLUMNS_ROWS`:case`UPDATE_TABLE`:this.isEvaluationDirty=!0;break;case`START`:for(let e of this.getters.getSheetIds())this.filterValues[e]={};break;case`CREATE_SHEET`:this.filterValues[e.sheetId]={};break;case`HIDE_COLUMNS_ROWS`:case`UNHIDE_COLUMNS_ROWS`:case`GROUP_HEADERS`:case`UNGROUP_HEADERS`:case`FOLD_HEADER_GROUP`:case`UNFOLD_HEADER_GROUP`:case`FOLD_ALL_HEADER_GROUPS`:case`UNFOLD_ALL_HEADER_GROUPS`:case`FOLD_HEADER_GROUPS_IN_ZONE`:case`UNFOLD_HEADER_GROUPS_IN_ZONE`:this.updateHiddenRows(e.sheetId);break;case`UPDATE_FILTER`:this.updateFilter(e),this.updateHiddenRows(e.sheetId);break;case`DUPLICATE_SHEET`:this.filterValues[e.sheetIdTo]=b(this.filterValues[e.sheetId]);break}}finalize(){if(this.isEvaluationDirty){for(let e of this.getters.getSheetIds())this.updateHiddenRows(e);this.isEvaluationDirty=!1}}isRowFiltered(e,t){return!!this.hiddenRows[e]?.has(t)}getFilterValue(e){let t=this.getters.getFilterId(e),n=e.sheetId;return t?this.filterValues[n]?.[t]:void 0}getFilterHiddenValues(e){let t=this.getters.getFilterId(e),n=e.sheetId;if(!t||!this.filterValues[n])return[];let r=this.filterValues[n][t]||[];return r.filterType===`values`?r.hiddenValues:[]}getFilterCriterionValue(e){let t=this.getters.getFilterId(e),n=e.sheetId;if(!t||!this.filterValues[n])return nq;let r=this.filterValues[n][t];return r&&r.filterType===`criterion`?r:nq}isFilterActive(e){let t=this.getters.getFilterId(e);if(!t)return!1;let n=e.sheetId,r=this.filterValues[n]?.[t];return r?r.filterType===`values`?r.hiddenValues.length>0:r.type!==`none`:!1}getFirstTableInSelection(){let e=this.getters.getActiveSheetId(),t=this.getters.getSelectedZones();return this.getters.getTablesOverlappingZones(e,t)[0]}updateFilter({col:e,row:t,value:n,sheetId:r}){let i=this.getters.getFilterId({sheetId:r,col:e,row:t});i&&(this.filterValues[r]||(this.filterValues[r]={}),this.filterValues[r][i]=n)}updateHiddenRows(e){let t=this.getters.getFilters(e).sort((e,t)=>e.rangeWithHeaders.zone.top-t.rangeWithHeaders.zone.top),n=new Set;for(let r of t){let t=this.filterValues[e]?.[r.id],i=r.filteredRange?.zone;if(!(!t||!i||n.has(r.rangeWithHeaders.zone.top)||this.getters.isRowHiddenByUser(e,r.rangeWithHeaders.zone.top)))if(t.filterType===`values`){let a=t.hiddenValues?.map(Tl);if(!a)continue;let o=new Set(a);for(let t=i.top;t<=i.bottom;t++){let i=this.getCellValueAsString(e,r.col,t);o.has(i)&&n.add(t)}}else{if(t.type===`none`)continue;let a=Y.get(t.type),o=t.values.map(t=>t.startsWith(`=`)?this.getters.evaluateFormula(e,t)??``:ts(t,D));if(o.some(Wu))continue;let s={type:t.type,values:o.map(Hu),dateValue:t.dateValue};for(let t=i.top;t<=i.bottom;t++){let i={sheetId:e,col:r.col,row:t},o=this.getters.getEvaluatedCell(i).value??``;a.isValueValid(o,s,this.getters,e)||n.add(t)}}}this.hiddenRows[e]=n}getCellValueAsString(e,t,n){return this.getters.getEvaluatedCell({sheetId:e,col:t,row:n}).formattedValue.toLowerCase()}exportForExcel(e){for(let t of e.sheets){let e=t.id;for(let n of t.tables){let r=Ts(n.range),i=[],a=[];for(let n of S(0,Us(r).numberOfCols)){let o={sheetId:t.id,col:r.left+n,row:r.top},s=this.getFilterHiddenValues(o),c=this.getters.getFilter(o),l=c?.filteredRange?Ks(c.filteredRange.zone).map(t=>this.getters.getEvaluatedCell({sheetId:e,...t}).formattedValue):[];if(s.length){let e=l.filter(e=>e).filter(e=>!s.includes(e));i.push({colId:n,displayedValues:[...new Set(e)],displayBlanks:!s.includes(``)&&l.some(e=>!e)})}let u=this.getters.getEvaluatedCell(o).formattedValue,d=this.getUniqueColNameForExcel(n,u,a);a.push(d);let f=T(o.col,o.row);t.cells[f]=d,t.cellValues[f]=d}n.filters=i}}}getUniqueColNameForExcel(e,t,n){return t||=`Column${e}`,an(t,n,{compute:(e,n)=>t+String(n),start:2})}},iq=class extends Rp{static layers=[`Selection`];static getters=[`getActiveSheet`,`getActiveSheetId`,`getActiveSheetName`,`getActiveCell`,`getActiveCols`,`getActiveRows`,`getCurrentStyle`,`getSelectedZones`,`getSelectedZone`,`getSelectedCells`,`getSelectedFigureId`,`getSelection`,`getActivePosition`,`getSheetPosition`,`isSingleColSelected`,`getElementsFromSelection`,`tryGetActiveSheetId`,`isGridSelectionActive`,`getSelectecUnboundedZone`];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;isUnbounded;activeSheet=null;constructor(e){super(e),this.moveClient=e.moveClient,this.isUnbounded=!1}allowDispatch(e){switch(e.type){case`ACTIVATE_SHEET`:try{if(!this.getters.getSheet(e.sheetIdTo).isVisible)return`SheetIsHidden`;break}catch{return`InvalidSheetId`}case`MOVE_COLUMNS_ROWS`:return this.isMoveElementAllowed(e)}return`Success`}handleEvent(e){let t=e.anchor,n=[];switch(this.isUnbounded=e.options?.unbounded||!1,e.mode){case`overrideSelection`:n=[t.zone];break;case`updateAnchor`:n=[...this.gridSelection.zones];let r=n.findIndex(t=>Rs(t,e.previousAnchor.zone));r>=0&&(n[r]=t.zone);break;case`newAnchor`:n=[...this.gridSelection.zones,t.zone];break}this.setSelectionMixin(e.anchor,n),this.selection.resetDefaultAnchor(this,b(this.gridSelection.anchor));let{col:r,row:i}=this.gridSelection.anchor.cell;this.moveClient({sheetId:this.getters.getActiveSheetId(),col:r,row:i}),this.selectedFigureId=null}handle(e){switch(e.type){case`ACTIVATE_SHEET`:this.selectedFigureId=null;break;case`DELETE_FIGURE`:this.selectedFigureId===e.figureId&&(this.selectedFigureId=null);break;case`DELETE_SHEET`:this.selectedFigureId&&this.getters.getFigure(e.sheetId,this.selectedFigureId)&&(this.selectedFigureId=null);break}switch(e.type){case`START`:let t=this.getters.getVisibleSheetIds()[0];this.activateSheet(t,t);let{col:n,row:r}=this.getters.getNextVisibleCellPosition({sheetId:t,col:0,row:0});this.selectCell(n,r),this.selection.registerAsDefault(this,this.gridSelection.anchor,{handleEvent:this.handleEvent.bind(this)}),this.moveClient({sheetId:t,col:0,row:0});break;case`ACTIVATE_SHEET`:this.activateSheet(e.sheetIdFrom,e.sheetIdTo);break;case`REMOVE_COLUMNS_ROWS`:{let t=this.getters.getActiveSheetId();if(e.sheetId===t){e.dimension===`COL`?this.onColumnsRemoved(e):this.onRowsRemoved(e);let{col:n,row:r}=this.gridSelection.anchor.cell;this.moveClient({sheetId:t,col:n,row:r})}break}case`ADD_COLUMNS_ROWS`:{let t=this.getters.getActiveSheetId();if(e.sheetId===t){this.onAddElements(e);let{col:n,row:r}=this.gridSelection.anchor.cell;this.moveClient({sheetId:t,col:n,row:r})}break}case`MOVE_COLUMNS_ROWS`:e.sheetId===this.getActiveSheetId()&&this.onMoveElements(e);break;case`SELECT_FIGURE`:this.selectedFigureId=e.figureId;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`:let i=Object.keys(this.sheetsData).filter(e=>!this.getters.tryGetSheet(e));for(let e of i)delete this.sheetsData[e];for(let e in this.sheetsData){let t=this.clipSelection(e,this.sheetsData[e].gridSelection);this.sheetsData[e]={gridSelection:b(t)}}this.fallbackToVisibleSheet();let a=this.getters.getActiveSheetId();this.gridSelection.zones=this.gridSelection.zones.map(e=>this.getters.expandZone(a,e)),this.gridSelection.anchor.zone=this.getters.expandZone(a,this.gridSelection.anchor.zone),this.setSelectionMixin(this.gridSelection.anchor,this.gridSelection.zones),this.selectedFigureId=null;break}}finalize(){this.fallbackToVisibleSheet(),this.selection.resetDefaultAnchor(this,b(this.gridSelection.anchor))}isGridSelectionActive(){return this.selection.isListening(this)}getActiveSheet(){return this.activeSheet}getActiveSheetId(){return this.activeSheet.id}getActiveSheetName(){return this.activeSheet.name}tryGetActiveSheetId(){return this.activeSheet?.id}getActiveCell(){return this.getters.getEvaluatedCell(this.getActivePosition())}getActiveCols(){let e=new Set;for(let t of this.gridSelection.zones)if(t.top===0&&t.bottom===this.getters.getNumberRows(this.getters.getActiveSheetId())-1)for(let n=t.left;n<=t.right;n++)e.add(n);return e}getActiveRows(){let e=new Set,t=this.getters.getActiveSheetId();for(let n of this.gridSelection.zones)if(n.left===0&&n.right===this.getters.getNumberCols(t)-1)for(let t=n.top;t<=n.bottom;t++)e.add(t);return e}getCurrentStyle(){let e=this.getters.getSelectedZone(),t=this.getters.getActiveSheetId();return this.getters.getCellStyle({sheetId:t,col:e.left,row:e.top})}getSelectedZones(){return b(this.gridSelection.zones)}getSelectedZone(){return b(this.gridSelection.anchor.zone)}getSelectecUnboundedZone(){return b(this.isUnbounded?this.getters.getUnboundedZone(this.activeSheet.id,this.gridSelection.anchor.zone):this.gridSelection.anchor.zone)}getSelection(){return b(this.gridSelection)}getSelectedCells(){let e=this.getters.getActiveSheetId(),t=[];for(let n of this.gridSelection.zones)t.push(...this.getters.getEvaluatedCellsInZone(e,n));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();{let 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})}}isSingleColSelected(){let e=this.getters.getSelectedZones();return!(e.length!==1||e[0].left!==e[0].right)}getElementsFromSelection(e){if(e===`COL`&&this.getters.getActiveCols().size===0||e===`ROW`&&this.getters.getActiveRows().size===0)return[];let t=this.getters.getSelectedZones(),n=[],r=e===`COL`?`left`:`top`,i=e===`COL`?`right`:`bottom`;for(let e of t){let t=Array.from({length:e[i]-e[r]+1},(t,n)=>e[r]+n);n=n.concat(t)}return[...new Set(n)].sort()}activateSheet(e,t){if(this.setActiveSheet(t),this.sheetsData[e]={gridSelection:b(this.gridSelection)},t in this.sheetsData)Object.assign(this,this.sheetsData[t]),this.selection.resetDefaultAnchor(this,b(this.gridSelection.anchor));else{let{col:e,row:n}=this.getters.getNextVisibleCellPosition({sheetId:t,col:0,row:0});this.selectCell(e,n)}let{col:n,row:r}=this.gridSelection.anchor.cell;this.moveClient({sheetId:this.activeSheet.id,col:n,row:r})}setSelectionMixin(e,t){let{anchor:n,zones:r}=this.clipSelection(this.getters.getActiveSheetId(),{anchor:e,zones:t});this.gridSelection.anchor=n,this.gridSelection.zones=Xs(r)}selectCell(e,t){let n=this.getters.getActiveSheetId(),r=this.getters.expandZone(n,{left:e,right:e,top:t,bottom:t});this.setSelectionMixin({zone:r,cell:{col:e,row:t}},[r])}setActiveSheet(e){this.activeSheet=this.getters.getSheet(e)}activateNextSheet(e){let t=this.getters.getSheetIds(),n=(t.findIndex(e=>e===this.activeSheet.id)+(e===`left`?t.length-1:1))%t.length;this.dispatch(`ACTIVATE_SHEET`,{sheetIdFrom:this.getActiveSheetId(),sheetIdTo:t[n]})}onColumnsRemoved(e){let{cell:t,zone:n}=this.gridSelection.anchor,r=Ns(n,`left`,[...e.elements]),i={left:t.col,right:t.col,top:t.row,bottom:t.row};i=Ns(i,`left`,[...e.elements]);let a={cell:{col:i.left,row:i.top},zone:r},o=this.gridSelection.zones.map(t=>Ns(t,`left`,[...e.elements]));this.setSelectionMixin(a,o)}onRowsRemoved(e){let{cell:t,zone:n}=this.gridSelection.anchor,r=Ns(n,`top`,[...e.elements]),i={left:t.col,right:t.col,top:t.row,bottom:t.row};i=Ns(i,`top`,[...e.elements]);let a={cell:{col:i.left,row:i.top},zone:r},o=this.gridSelection.zones.map(t=>Ns(t,`top`,[...e.elements]));this.setSelectionMixin(a,o)}onAddElements(e){let t=e.dimension===`COL`?`left`:`top`,n=Ms(this.gridSelection.anchor.zone,t,e.base,e.position,e.quantity),r=this.gridSelection.zones.map(n=>Ms(n,t,e.base,e.position,e.quantity)),i={cell:{col:n.left,row:n.top},zone:n};this.setSelectionMixin(i,r)}onMoveElements(e){let t=e.elements.length,n=this.getFiguresUpdates(e);this.dispatch(`ADD_COLUMNS_ROWS`,{dimension:e.dimension,sheetId:e.sheetId,sheetName:e.sheetName,base:e.base,quantity:t,position:e.position});let r=e.dimension===`COL`,i=e.elements[0],a=e.elements[t-1],o=e.base<i,s=o&&r?t:0,c=o&&!r?t:0,l=o?e.elements.map(e=>e+t):e.elements,u={};for(let t of l)u[t]=this.getters.getHeaderSize(e.sheetId,e.dimension,t);let d=[{left:r?i+s:0,right:r?a+s:this.getters.getNumberCols(e.sheetId)-1,top:r?0:i+c,bottom:r?this.getters.getNumberRows(e.sheetId)-1:a+c}],f=this.getActiveSheetId(),p=o?e.base:e.base+1,m=[{left:r?p:0,right:r?p+t-1:this.getters.getNumberCols(e.sheetId)-1,top:r?0:p,bottom:r?this.getters.getNumberRows(e.sheetId)-1:p+t-1}],h=af.cellHandlers.getKeys().map(e=>[e,new(af.cellHandlers.get(e))(this.getters,this.dispatch)]),g={};for(let[e,t]of h)g[e]=t.copy(Nl(f,d),!1,`shiftCells`);for(let[e,t]of h)g[e]&&t.paste({zones:m,sheetId:f},g[e],{isCutOperation:!0});let _=m[0],v=_.left,y=_.top;this.setSelectionMixin({zone:_,cell:{col:v,row:y}},[_]);let ee=o?e.base:e.base+1,te={};for(let t of l){let n=u[t];n!==this.getters.getHeaderSize(e.sheetId,e.dimension,ee)&&(te[n]??=[],te[n].push(ee)),ee+=1}for(let t in te)this.dispatch(`RESIZE_COLUMNS_ROWS`,{dimension:e.dimension,sheetId:e.sheetId,size:parseInt(t,10),elements:te[t]});this.dispatch(`REMOVE_COLUMNS_ROWS`,{dimension:e.dimension,sheetId:e.sheetId,sheetName:e.sheetName,elements:l}),this.applyFigureUpdates(n)}getFiguresUpdates(e){let t=[],n={},r=e.elements[0]<e.base?e.base-e.elements.length+1:e.base;for(let t=0;t<e.elements.length;t++)n[e.elements[t]]=r+t;for(let r of this.getters.getFigures(e.sheetId))e.dimension===`COL`&&r.col in n&&t.push({type:`UPDATE_FIGURE`,sheetId:e.sheetId,figureId:r.id,col:n[r.col],row:r.row}),e.dimension===`ROW`&&r.row in n&&t.push({type:`UPDATE_FIGURE`,sheetId:e.sheetId,figureId:r.id,row:n[r.row],col:r.col});return t}applyFigureUpdates(e){for(let t of e)this.dispatch(t.type,{...t})}isMoveElementAllowed(e){let t=e.dimension===`COL`,n=e.elements[0],r=e.elements[e.elements.length-1],i=e.sheetId,a=t?this.getters.doesColumnsHaveCommonMerges:this.getters.doesRowsHaveCommonMerges;if(a(i,n-1,n)||a(i,r,r+1)||a(i,e.base-1,e.base))return`WillRemoveExistingMerge`;let o=[e.base,...e.elements],s=t?this.getters.getNumberCols(i):this.getters.getNumberRows(i);return o.some(e=>e<0||e>=s)?`InvalidHeaderIndex`:!t&&!this.isTableRowMoveAllowed(i,e.elements)?`CannotMoveTableHeader`:`Success`}isTableRowMoveAllowed(e,t){let n=this.getters.getCoreTables(e);if(n.length===0)return!0;let r=new Set(t);return n.every(({range:{zone:e},config:n})=>{let{top:i,bottom:a}=e;if(n.numberOfHeaders===0)return!0;let o=i+n.numberOfHeaders-1;return t.some(e=>e>=i&&e<=o)?S(i,a+1).every(e=>r.has(e)):!0})}fallbackToVisibleSheet(){if(!this.getters.tryGetSheet(this.getters.getActiveSheetId())){let e=this.getters.getVisibleSheetIds();if(this.activeSheet=this.getters.getSheet(e[0]),this.activeSheet.id in this.sheetsData){let{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);let{col:t,row:n}=this.gridSelection.anchor.cell;this.moveClient({sheetId:this.getters.getActiveSheetId(),col:t,row:n})}}clipSelection(e,t){let n=this.getters.getNumberCols(e)-1,r=this.getters.getNumberRows(e)-1,i=t.zones.map(e=>({left:x(e.left,0,n),right:x(e.right,0,n),top:x(e.top,0,r),bottom:x(e.bottom,0,r)})),a=x(t.anchor.cell.col,0,n),o=x(t.anchor.cell.row,0,r),s={left:x(t.anchor.zone.left,0,n),right:x(t.anchor.zone.right,0,n),top:x(t.anchor.zone.top,0,r),bottom:x(t.anchor.zone.bottom,0,r)};return{zones:i,anchor:{cell:{col:a,row:o},zone:s}}}drawLayer(e){if(this.getters.isDashboard())return;let{ctx:t,thinLineWidth:n}=e,r=this.getSelectedZones();t.fillStyle=`#f3f7fe`,t.fillStyle=r.length===1&&r[0].left===r[0].right&&r[0].top===r[0].bottom?`#f3f7fe`:`#e9f0ff`,t.strokeStyle=ae,t.lineWidth=1.5*n;for(let e of r){let{x:n,y:r,width:i,height:a}=this.getters.getVisibleRect(e);t.globalCompositeOperation=`multiply`,t.fillRect(n,r,i,a),t.globalCompositeOperation=`source-over`,t.strokeRect(n,r,i,a)}t.globalCompositeOperation=`source-over`;let i=this.getActivePosition();t.strokeStyle=ae,t.lineWidth=3*n;let a;a=this.getters.isInMerge(i)?this.getters.getMerge(i):R(i);let{x:o,y:s,width:c,height:l}=this.getters.getVisibleRect(a);c>0&&l>0&&t.strokeRect(o,s,c,l)}},aq=class{getters;sheetId;boundaries;top;bottom;left;right;offsetX;offsetY;canScrollVertically;canScrollHorizontally;viewportWidth;viewportHeight;offsetCorrectionX;offsetCorrectionY;constructor(e,t,n,r,i,a){if(this.getters=e,this.sheetId=t,this.boundaries=n,r.width<0||r.height<0)throw Error(`Viewport size cannot be negative`);this.viewportWidth=r.height&&r.width,this.viewportHeight=r.width&&r.height,this.top=n.top,this.bottom=n.bottom,this.left=n.left,this.right=n.right,this.offsetX=a.x,this.offsetY=a.y,this.canScrollVertically=i.canScrollVertically,this.canScrollHorizontally=i.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(){let 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:n}=this.getters.getColDimensions(this.sheetId,e),{end:r}=this.getters.getRowDimensions(this.sheetId,t),i=n-this.offsetCorrectionX;this.canScrollHorizontally&&(i=Math.max(i,this.viewportWidth));let a=r-this.offsetCorrectionY;return this.canScrollVertically&&(a=Math.max(a,this.viewportHeight),r+46>a&&!this.getters.isReadonly()&&(a+=46)),{width:i,height:a}}getColIndex(e){return e<this.offsetCorrectionX||e>this.offsetCorrectionX+this.viewportWidth?-1:this.searchHeaderIndex(`COL`,e-this.offsetCorrectionX+this.snapCorrection.x,this.left)}getRowIndex(e){return e<this.offsetCorrectionY||e>this.offsetCorrectionY+this.viewportHeight?-1:this.searchHeaderIndex(`ROW`,e-this.offsetCorrectionY+this.snapCorrection.y,this.top)}adjustPosition(e){let t=this.sheetId,n=this.getters.getMainCellPosition({sheetId:t,...e}),{col:r,row:i}=this.getters.getNextVisibleCellPosition(n);Vs(r,this.boundaries.top,this.boundaries)&&this.adjustPositionX(r),Vs(this.boundaries.left,i,this.boundaries)&&this.adjustPositionY(i)}adjustPositionX(e){let t=this.sheetId,{start:n,end:r}=this.getters.getColDimensions(t,e);this.offsetX+this.viewportWidth+this.offsetCorrectionX<r?this.offsetX=r-this.viewportWidth-this.offsetCorrectionX:this.offsetX+this.offsetCorrectionX>n&&(this.offsetX=n-this.offsetCorrectionX),this.adjustViewportZoneX()}adjustPositionY(e){let t=this.sheetId,{start:n,end:r}=this.getters.getRowDimensions(t,e);this.offsetY+this.viewportHeight+this.offsetCorrectionY<r?this.offsetY=r-this.viewportHeight-this.offsetCorrectionY:this.offsetY+this.offsetCorrectionY>n&&(this.offsetY=n-this.offsetCorrectionY),this.adjustViewportZoneY()}willNewOffsetScrollViewport(e,t){return this.canScrollHorizontally&&this.offsetX!==e||this.canScrollVertically&&this.offsetY!==t}setViewportOffset(e,t){this.setViewportOffsetX(e),this.setViewportOffsetY(t)}adjustViewportZone(){this.adjustViewportZoneX(),this.adjustViewportZoneY()}getVisibleRect(e){let t=Ls(e,this),n=this.snapCorrection.x,r=this.snapCorrection.y;if(t)return{x:this.getters.getColRowOffset(`COL`,this.left,t.left)+this.offsetCorrectionX-(this.left===t.left?0:n),y:this.getters.getColRowOffset(`ROW`,this.top,t.top)+this.offsetCorrectionY-(this.top===t.top?0:r),width:Math.min(this.getters.getColRowOffset(`COL`,t.left,t.right+1)-(this.left===t.left?n:0),this.viewportWidth),height:Math.min(this.getters.getColRowOffset(`ROW`,t.top,t.bottom+1)-(this.top===t.top?r:0),this.viewportHeight)}}getFullRect(e){let t=Ls(e,this.boundaries),n=this.snapCorrection.x,r=this.snapCorrection.y;if(t){let t=this.getters.getColRowOffset(`COL`,this.left,e.left)+this.offsetCorrectionX,i=this.getters.getColRowOffset(`ROW`,this.top,e.top)+this.offsetCorrectionY,a=this.getters.getColRowOffset(`COL`,e.left,e.right+1),o=this.getters.getColRowOffset(`ROW`,e.top,e.bottom+1);return{x:t-n,y:i-r,width:a,height:o}}}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,n=0){if(this.viewportWidth<=0||this.viewportHeight<=0)return-1;let r=this.sheetId,i=this.getters.getNumberHeaders(r,e),a=n,o=i;for(;a<=o&&a!==i&&o!==-1;){let i=Math.floor((a+o)/2),s=this.getters.getColRowOffset(e,n,i),c=this.getters.getHeaderSize(r,e,i);if(t>=s&&t<s+c)return i;t>=s+c?a=i+1:o=i-1}return-1}setViewportOffsetX(e){this.canScrollHorizontally&&(this.offsetX=e,this.adjustViewportZoneX())}setViewportOffsetY(e){this.canScrollVertically&&(this.offsetY=e,this.adjustViewportZoneY())}adjustViewportOffsetX(){if(this.canScrollHorizontally){let{width:e}=this.getMaxSize();this.viewportWidth+this.offsetX>e&&(this.offsetX=Math.max(0,e-this.viewportWidth))}this.adjustViewportZoneX()}adjustViewportOffsetY(){if(this.canScrollVertically){let{height:e}=this.getMaxSize();this.viewportHeight+this.offsetY>e&&(this.offsetY=Math.max(0,e-this.viewportHeight))}this.adjustViewportZoneY()}adjustViewportZoneX(){this.left=this.searchHeaderIndex(`COL`,this.offsetX,this.boundaries.left),this.right=Math.min(this.boundaries.right,this.searchHeaderIndex(`COL`,Math.max(this.viewportWidth+this.snapCorrection.x-.1),this.left)),this.viewportWidth&&(this.left===-1&&(this.left=this.boundaries.left),this.right===-1&&(this.right=this.boundaries.right))}adjustViewportZoneY(){this.top=this.searchHeaderIndex(`ROW`,this.offsetY,this.boundaries.top),this.bottom=Math.min(this.boundaries.bottom,this.searchHeaderIndex(`ROW`,Math.max(this.viewportHeight+this.snapCorrection.y-.1,0),this.top)),this.viewportHeight&&(this.top===-1&&(this.top=this.boundaries.top),this.bottom===-1&&(this.bottom=this.boundaries.bottom))}get snapCorrection(){return{x:Math.abs(this.offsetX-this.getters.getColRowOffset(`COL`,this.boundaries.left,Math.max(0,this.left))),y:Math.abs(this.offsetY-this.getters.getColRowOffset(`ROW`,this.boundaries.top,Math.max(0,this.top)))}}},oq=class extends Rp{static getters=`getColIndex.getRowIndex.getActiveMainViewport.getSheetViewDimension.getSheetViewDimensionWithHeaders.getMainViewportRect.isVisibleInViewport.getEdgeScrollCol.getEdgeScrollRow.getVisibleFigures.getVisibleRect.getVisibleRectWithoutHeaders.getVisibleCellPositions.getColRowOffsetInViewport.getMainViewportCoordinates.getActiveSheetScrollInfo.getSheetViewVisibleCols.getSheetViewVisibleRows.getFrozenSheetViewRatio.isPixelPositionVisible.getColDimensionsInViewport.getRowDimensionsInViewport.getAllActiveViewportsZonesAndRect.getRect.getFigureUI.getPositionAnchorOffset.getGridOffset.getMaximumSheetOffset`.split(`.`);viewports={};sheetViewWidth=Qe();sheetViewHeight=Qe();gridOffsetX=0;gridOffsetY=0;sheetsWithDirtyViewports=new Set;shouldAdjustViewports=!1;allowDispatch(e){switch(e.type){case`SET_VIEWPORT_OFFSET`:return this.chainValidations(this.checkScrollingDirection,this.checkIfViewportsWillChange)(e);case`RESIZE_SHEETVIEW`:return this.chainValidations(this.checkValuesAreDifferent,this.checkPositiveDimension)(e);default:return`Success`}}handleEvent(e){let t=this.getters.getActiveSheetId();if(e.options.scrollIntoView){let{col:n,row:r}=Qs(e.previousAnchor.zone,e.anchor.zone);if(e.mode===`updateAnchor`){let i=e.previousAnchor.zone,a=e.anchor.zone,{top:o,bottom:s,left:c,right:l}=this.getMainInternalViewport(t);i.left===a.left&&i.right===a.right&&(n=c>n||n>l?c:n),i.top===a.top&&i.bottom===a.bottom&&(r=o>r||r>s?o:r)}n=Math.min(n,this.getters.getNumberCols(t)-1),r=Math.min(r,this.getters.getNumberRows(t)-1),this.sheetsWithDirtyViewports.has(t)||this.refreshViewport(this.getters.getActiveSheetId(),{col:n,row:r})}}handle(e){if(yr.has(e.type))for(let e of this.getters.getSheetIds())this.sheetsWithDirtyViewports.add(e);switch(e.type){case`START`:this.selection.observe(this,{handleEvent:this.handleEvent.bind(this)}),this.resetViewports(this.getters.getActiveSheetId());break;case`UNDO`:case`REDO`:this.cleanViewports();for(let e of this.getters.getSheetIds())this.sheetsWithDirtyViewports.add(e);this.shouldAdjustViewports=!0;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`:let t=this.getters.getActiveSheetId(),{top:n,viewportHeight:r,offsetCorrectionY:i}=this.getMainInternalViewport(t),a=this.getters.getRowDimensions(t,n);this.shiftVertically(a.start+r-i);break;case`SHIFT_VIEWPORT_UP`:{let e=this.getters.getActiveSheetId(),{top:t,viewportHeight:n,offsetCorrectionY:r}=this.getMainInternalViewport(e),i=this.getters.getRowDimensions(e,t);this.shiftVertically(i.end-r-n);break}case`REMOVE_TABLE`:case`UPDATE_TABLE`:case`UPDATE_FILTER`:case`UNFREEZE_ROWS`:case`UNFREEZE_COLUMNS`:case`FREEZE_COLUMNS`:case`FREEZE_ROWS`:case`UNFREEZE_COLUMNS_ROWS`:case`REMOVE_COLUMNS_ROWS`:case`RESIZE_COLUMNS_ROWS`:case`HIDE_COLUMNS_ROWS`:case`ADD_COLUMNS_ROWS`:case`UNHIDE_COLUMNS_ROWS`:case`UNGROUP_HEADERS`:case`GROUP_HEADERS`:case`FOLD_HEADER_GROUP`:case`UNFOLD_HEADER_GROUP`:case`FOLD_HEADER_GROUPS_IN_ZONE`:case`UNFOLD_HEADER_GROUPS_IN_ZONE`:case`UNFOLD_ALL_HEADER_GROUPS`:case`FOLD_ALL_HEADER_GROUPS`:this.sheetsWithDirtyViewports.add(e.sheetId);break;case`UPDATE_CELL`:for(let e of this.getters.getSheetIds())this.sheetsWithDirtyViewports.add(e);break;case`DELETE_SHEET`:this.cleanViewports(),this.sheetsWithDirtyViewports.delete(e.sheetId);break;case`ACTIVATE_SHEET`:this.sheetsWithDirtyViewports.add(e.sheetIdTo);break;case`SCROLL_TO_CELL`:this.refreshViewport(this.getters.getActiveSheetId(),{col:e.col,row:e.row});break}}finalize(){for(let e of this.sheetsWithDirtyViewports)if(this.resetViewports(e),this.shouldAdjustViewports){let t=this.getters.getSheetPosition(e);this.getSubViewports(e).forEach(e=>{e.adjustPosition(t)})}this.sheetsWithDirtyViewports=new Set,this.shouldAdjustViewports=!1,this.setViewports()}setViewports(){let e=this.getters.getSheetIds();for(let t of e)this.viewports[t]?.bottomRight||this.resetViewports(t)}getColIndex(e){let t=this.getters.getActiveSheetId();return Math.max(...this.getSubViewports(t).map(t=>t.getColIndex(e)))}getRowIndex(e){let 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}}getGridOffset(){return{x:this.gridOffsetX,y:this.gridOffsetY}}getActiveMainViewport(){let e=this.getters.getActiveSheetId();return this.getMainViewport(e)}getActiveSheetScrollInfo(){let e=this.getters.getActiveSheetId(),t=this.getMainInternalViewport(e);return{scrollX:t.offsetX,scrollY:t.offsetY}}getSheetViewVisibleCols(){let e=this.getters.getActiveSheetId(),t=this.getSubViewports(e);return[...new Set(t.map(e=>S(e.left,e.right+1)).flat())].filter(t=>t>=0&&!this.getters.isHeaderHidden(e,`COL`,t))}getSheetViewVisibleRows(){let e=this.getters.getActiveSheetId(),t=this.getSubViewports(e);return[...new Set(t.map(e=>S(e.top,e.bottom+1)).flat())].filter(t=>t>=0&&!this.getters.isHeaderHidden(e,`ROW`,t))}getVisibleCellPositions(){let e=this.getSheetViewVisibleCols(),t=this.getSheetViewVisibleRows(),n=this.getters.getActiveSheetId(),r=[];for(let i of e)for(let e of t){let t={sheetId:n,col:i,row:e},a=this.getters.getMainCellPosition(t);a.row!==e||a.col!==i||r.push(t)}return r}getMainViewportRect(){let e=this.getters.getActiveSheetId(),t=this.getMainInternalViewport(e),{xSplit:n,ySplit:r}=this.getters.getPaneDivisions(e),{width:i,height:a}=t.getMaxSize();return{x:this.getters.getColDimensions(e,n).start,y:this.getters.getRowDimensions(e,r).start,width:i,height:a}}getMaximumSheetOffset(){let e=this.getters.getActiveSheetId(),{width:t,height:n}=this.getMainViewportRect(),r=this.getMainInternalViewport(e);return{maxOffsetX:Math.max(0,t-r.viewportWidth),maxOffsetY:Math.max(0,n-r.viewportHeight)}}getColRowOffsetInViewport(e,t,n){if(n<t)return-this.getColRowOffsetInViewport(e,n,t);let r=this.getters.getActiveSheetId(),i=e===`COL`?this.getters.getSheetViewVisibleCols():this.getters.getSheetViewVisibleRows(),a=i.findIndex(e=>t>=e),o=i.findIndex(e=>n<=e);o=o===-1?i.length:o;let s=i.slice(a,o),c=0;for(let t of s)c+=this.getters.getHeaderSize(r,e,t);return c}isVisibleInViewport({sheetId:e,col:t,row:n}){return this.getSubViewports(e).some(e=>e.isVisible(t,n))}getEdgeScrollCol(e,t,n){let r=!1,i=0,a=0,{xSplit:o}=this.getters.getPaneDivisions(this.getters.getActiveSheetId()),{width:s}=this.getSheetViewDimension(),{x:c}=this.getMainViewportCoordinates(),l=this.getActiveSheetScrollInfo().scrollX;return e>s?(r=!0,a=vc(e-s),i=1):e<c&&n>=c&&l>0?(r=!0,a=vc(c-e),i=-1):o&&t<c&&e>c&&(r=!0,a=vc(e),i=`reset`),{canEdgeScroll:r,direction:i,delay:a}}getEdgeScrollRow(e,t,n){let r=!1,i=0,a=0,{ySplit:o}=this.getters.getPaneDivisions(this.getters.getActiveSheetId()),{height:s}=this.getSheetViewDimension(),{y:c}=this.getMainViewportCoordinates(),l=this.getActiveSheetScrollInfo().scrollY;return e>s?(r=!0,a=vc(e-s),i=1):e<c&&n>=c&&l>0?(r=!0,a=vc(c-e),i=-1):o&&t<c&&e>c&&(r=!0,a=vc(e),i=`reset`),{canEdgeScroll:r,direction:i,delay:a}}getVisibleRect(e){let t=this.getVisibleRectWithoutHeaders(e);return{...t,x:t.x+this.gridOffsetX,y:t.y+this.gridOffsetY}}getVisibleRectWithoutHeaders(e){let t=this.getters.getActiveSheetId();return this.mapViewportsToRect(t,t=>t.getVisibleRect(e))}getRect(e){let t=this.getters.getActiveSheetId(),n=this.mapViewportsToRect(t,t=>t.getFullRect(e));return{...n,x:n.x+this.gridOffsetX,y:n.y+this.gridOffsetY}}getRectWithoutHeaders(e){let t=this.getters.getActiveSheetId();return this.mapViewportsToRect(t,t=>t.getFullRect(e))}getMainViewportCoordinates(){let e=this.getters.getActiveSheetId(),{xSplit:t,ySplit:n}=this.getters.getPaneDivisions(e);return{x:this.getters.getColDimensions(e,t).start,y:this.getters.getRowDimensions(e,n).start}}getColDimensionsInViewport(e,t){let{top:n}=this.getMainInternalViewport(e),r={left:t,right:t,top:n,bottom:n},{x:i,width:a}=this.getVisibleRect(r),o=i-this.gridOffsetX;return{start:o,size:a,end:o+a}}getRowDimensionsInViewport(e,t){let{left:n}=this.getMainInternalViewport(e),r={left:0,right:n,top:t,bottom:t},{y:i,height:a}=this.getVisibleRect(r),o=i-this.gridOffsetY;return{start:o,size:a,end:o+a}}getAllActiveViewportsZonesAndRect(){let e=this.getters.getActiveSheetId();return this.getSubViewports(e).map(e=>({zone:e,rect:{x:e.offsetCorrectionX+this.gridOffsetX,y:e.offsetCorrectionY+this.gridOffsetY,...e.getMaxSize()}}))}ensureMainViewportExist(e){this.viewports[e]||this.resetViewports(e)}getSubViewports(e){return this.ensureMainViewportExist(e),Object.values(this.viewports[e]).filter(C)}checkPositiveDimension(e){return e.width<0||e.height<0?`InvalidViewportSize`:`Success`}checkValuesAreDifferent(e){let{height:t,width:n}=this.getSheetViewDimension();return e.gridOffsetX===this.gridOffsetX&&e.gridOffsetY===this.gridOffsetY&&e.width===n&&e.height===t?`ValuesNotChanged`:`Success`}checkScrollingDirection({offsetX:e,offsetY:t}){let n=this.getMainInternalViewport(this.getters.getActiveSheetId());return!n.canScrollHorizontally&&e>0||!n.canScrollVertically&&t>0?`InvalidScrollingDirection`:`Success`}checkIfViewportsWillChange({offsetX:e,offsetY:t}){let n=this.getters.getActiveSheetId(),{maxOffsetX:r,maxOffsetY:i}=this.getMaximumSheetOffset();return this.getSubViewports(n).some(n=>n.willNewOffsetScrollViewport(x(e,0,r),x(t,0,i)))?`Success`:`ViewportScrollLimitsReached`}getMainViewport(e){let 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(){let e={};for(let t of this.getters.getSheetIds())e[t]=this.viewports[t];this.viewports=e}resizeSheetView(e,t,n=0,r=0){this.sheetViewHeight=e,this.sheetViewWidth=t,this.gridOffsetX=n,this.gridOffsetY=r,this.recomputeViewports()}recomputeViewports(){for(let e of this.getters.getSheetIds())this.resetViewports(e)}setSheetViewOffset(e,t){let n=this.getters.getActiveSheetId(),{maxOffsetX:r,maxOffsetY:i}=this.getMaximumSheetOffset();this.getSubViewports(n).forEach(n=>n.setViewportOffset(x(e,0,r),x(t,0,i)))}getViewportOffset(e){return{x:this.viewports[e]?.bottomRight.offsetX||0,y:this.viewports[e]?.bottomRight.offsetY||0}}resetViewports(e){if(!this.getters.tryGetSheet(e))return;let{xSplit:t,ySplit:n}=this.getters.getPaneDivisions(e),r=this.getters.getNumberCols(e),i=this.getters.getNumberRows(e),a=Math.min(this.getters.getColRowOffset(`COL`,0,t,e),this.sheetViewWidth),o=Math.min(this.getters.getColRowOffset(`ROW`,0,n,e),this.sheetViewHeight),s=Math.max(this.sheetViewWidth-a,0),c=Math.max(this.sheetViewHeight-o,0),{xRatio:l,yRatio:u}=this.getFrozenSheetViewRatio(e),d=l<1,f=u<1,p=this.getViewportOffset(e),m={topLeft:n&&t&&new aq(this.getters,e,{left:0,right:t-1,top:0,bottom:n-1},{width:a,height:o},{canScrollHorizontally:!1,canScrollVertically:!1},{x:0,y:0})||void 0,topRight:n&&new aq(this.getters,e,{left:t,right:r-1,top:0,bottom:n-1},{width:s,height:o},{canScrollHorizontally:d,canScrollVertically:!1},{x:d?p.x:0,y:0})||void 0,bottomLeft:t&&new aq(this.getters,e,{left:0,right:t-1,top:n,bottom:i-1},{width:a,height:c},{canScrollHorizontally:!1,canScrollVertically:f},{x:0,y:f?p.y:0})||void 0,bottomRight:new aq(this.getters,e,{left:t,right:r-1,top:n,bottom:i-1},{width:s,height:c},{canScrollHorizontally:d,canScrollVertically:f},{x:d?p.x:0,y:f?p.y:0})};this.viewports[e]=m}refreshViewport(e,t){this.getSubViewports(e).forEach(e=>{e.adjustViewportZone(),e.adjustPosition(t)})}shiftVertically(e){let t=this.getters.getActiveSheetId(),{top:n}=this.getMainInternalViewport(t),{scrollX:r}=this.getActiveSheetScrollInfo();this.setSheetViewOffset(r,e);let{anchor:i}=this.getters.getSelection();if(i.cell.row>=this.getters.getPaneDivisions(t).ySplit){let e=this.getMainInternalViewport(t).top-n;this.selection.selectCell(i.cell.col,i.cell.row+e)}}getColIndexLeftOfMainViewport(e){if(e>=0)return-1;let t=this.getters.getActiveSheetId(),n=this.getActiveMainViewport().left,r=-this.getActiveSheetScrollInfo().scrollX-this.getters.getColRowOffset(`COL`,n,0);for(;e<r;n--)r-=this.getters.getColSize(t,n-1);return Math.max(n,0)}getRowIndexTopOfMainViewport(e){if(e>=0)return-1;let t=this.getters.getActiveSheetId(),n=this.getActiveMainViewport().top,r=-this.getActiveSheetScrollInfo().scrollY-this.getters.getColRowOffset(`ROW`,n,0);for(;e<r;n--)r-=this.getters.getRowSize(t,n-1);return Math.max(n,0)}getVisibleFigures(){let e=this.getters.getActiveSheetId(),t=[],n=this.getters.getFigures(e),{scrollX:r,scrollY:i}=this.getters.getActiveSheetScrollInfo(),{x:a,y:o}=this.getMainViewportCoordinates(),{width:s,height:c}=this.getters.getSheetViewDimensionWithHeaders();for(let l of n){let n=this.getFigureUI(e,l),{x:u,y:d}=n;u>=a&&(u+l.width<r+a||u>s+r+a)||d>=o&&(d+l.height<i+o||d>c+i+o)||t.push(n)}return t}getFigureUI(e,t){let n=t.offset.x+this.getters.getColDimensions(e,t.col).start,r=t.offset.y+this.getters.getRowDimensions(e,t.row).start;return{...t,x:n,y:r}}getPositionAnchorOffset(e){let{scrollX:t,scrollY:n}=this.getters.getActiveSheetScrollInfo(),r=e.x-t,i=e.y-n,a=r>=0?this.getColIndex(r):this.getColIndexLeftOfMainViewport(r),o=i>=0?this.getRowIndex(i):this.getRowIndexTopOfMainViewport(i),{x:s,y:c}=this.getRect(R({col:a,row:o}));return{col:a,row:o,offset:{x:Math.max(r-s+this.gridOffsetX,0),y:Math.max(i-c+this.gridOffsetY,0)}}}isPixelPositionVisible(e){let{scrollX:t,scrollY:n}=this.getters.getActiveSheetScrollInfo(),{x:r,y:i}=this.getters.getMainViewportCoordinates(),{width:a,height:o}=this.getters.getSheetViewDimension();return!(e.x>=r&&(e.x<r+t||e.x>a+t+r)||e.y>=i&&(e.y<i+n||e.y>o+n+i))}getFrozenSheetViewRatio(e){let{xSplit:t,ySplit:n}=this.getters.getPaneDivisions(e),r=this.getters.getColDimensions(e,t).start,i=this.getters.getRowDimensions(e,n).start,a=this.sheetViewWidth+this.gridOffsetX,o=this.sheetViewHeight+this.gridOffsetY;return{xRatio:r/a,yRatio:i/o}}mapViewportsToRect(e,t){let n=1/0,r=1/0,i=0,a=0,o=!1;for(let s of this.getSubViewports(e)){let e=t(s);e&&(o=!0,n=Math.min(n,e.x),r=Math.min(r,e.y),i=Math.max(i,e.x+e.width),a=Math.max(a,e.y+e.height))}return o?{x:n,y:r,width:i-n,height:a-r}:{x:0,y:0,width:0,height:0}}},sq=class extends Rp{static getters=[`getSelectedCarouselItem`,`getChartFromFigureId`,`getChartIdFromFigureId`];uuidGenerator=new jl;carouselStates={};allowDispatch(e){switch(e.type){case`ADD_FIGURE_CHART_TO_CAROUSEL`:return!this.getters.doesCarouselExist(e.carouselFigureId)||this.getters.getFigure(e.sheetId,e.chartFigureId)?.tag!==`chart`?`InvalidFigureId`:`Success`;case`ADD_NEW_CHART_TO_CAROUSEL`:return this.getters.doesCarouselExist(e.figureId)?`Success`:`InvalidFigureId`;case`UPDATE_CAROUSEL_ACTIVE_ITEM`:return this.getters.doesCarouselExist(e.figureId)?this.getters.getCarousel(e.figureId).items.some(t=>w(t,e.item))?`Success`:`InvalidCarouselItem`:`InvalidFigureId`}return`Success`}handle(e){switch(e.type){case`ADD_NEW_CHART_TO_CAROUSEL`:this.addNewChartToCarousel(e.figureId,e.sheetId);break;case`ADD_FIGURE_CHART_TO_CAROUSEL`:this.addFigureChartToCarousel(e.carouselFigureId,e.chartFigureId,e.sheetId);break;case`UPDATE_CAROUSEL_ACTIVE_ITEM`:this.carouselStates[e.figureId]=this.getCarouselItemId(e.item);break;case`POPOUT_CHART_FROM_CAROUSEL`:this.popOutChartFromCarousel(e.carouselId,e.chartId,e.sheetId);break;case`DELETE_FIGURE`:delete this.carouselStates[e.figureId];break;case`UPDATE_CAROUSEL`:this.fixWrongCarouselState(e.figureId);break;case`DELETE_CHART`:case`UNDO`:case`REDO`:case`DELETE_SHEET`:for(let e in this.carouselStates)this.fixWrongCarouselState(e);break}}popOutChartFromCarousel(e,t,n){let r=this.getters.getCarousel(e);if(!r)return;let i=this.getters.getFigure(n,e),a=this.getters.getChartDefinition(t);if(!a||!i)return;let o=this.getters.getFigureUI(n,i),s=this.getters.getPositionAnchorOffset({x:o.x+50,y:o.y+50}),c=this.uuidGenerator.smallUuid();this.dispatch(`CREATE_CHART`,{...s,chartId:this.uuidGenerator.smallUuid(),figureId:c,sheetId:n,size:{width:i.width,height:i.height},definition:{...a}});let l=r.items.filter(e=>e.type!==`chart`||e.chartId!==t);this.dispatch(`UPDATE_CAROUSEL`,{sheetId:n,figureId:e,definition:{...r,items:l}}),this.dispatch(`SELECT_FIGURE`,{figureId:c})}getSelectedCarouselItem(e){let t=this.getters.getCarousel(e);if(t.items.length)return this.carouselStates[e]?t.items.find(t=>this.getCarouselItemId(t)===this.carouselStates[e]):t.items[0]}getChartFromFigureId(e){if(!this.getters.getFigureSheetId(e))return;let t=this.getChartIdFromFigureId(e);return t?this.getters.getChart(t):void 0}getChartIdFromFigureId(e){let t=this.getters.getFigureSheetId(e);if(!t)return;let n=this.getters.getFigure(t,e);if(!(!n||n.tag!==`chart`&&n.tag!==`carousel`)){if(n.tag===`carousel`){let t=this.getSelectedCarouselItem(e);return t?.type===`chart`?t.chartId:void 0}return this.getters.getChartIds(t).find(t=>this.getters.getFigureIdFromChartId(t)===e)}}fixWrongCarouselState(e){if(!this.getters.doesCarouselExist(e)){delete this.carouselStates[e];return}let t=this.getters.getCarousel(e);t.items.length===0?delete this.carouselStates[e]:this.carouselStates[e]&&t.items.some(t=>this.getCarouselItemId(t)===this.carouselStates[e])||(this.carouselStates[e]=this.getCarouselItemId(t.items[0]))}addNewChartToCarousel(e,t){let n=this.getters.getCarousel(e),r=this.uuidGenerator.smallUuid();this.dispatch(`CREATE_CHART`,{chartId:r,figureId:e,sheetId:t,definition:WO});let i={...n,items:[...n.items,{type:`chart`,chartId:r}]};this.dispatch(`UPDATE_CAROUSEL`,{sheetId:t,figureId:e,definition:i})}addFigureChartToCarousel(e,t,n){let r=this.getChartIdFromFigureId(t);if(!r)return;let i=this.getters.getCarousel(e),a={...i,items:[...i.items,{type:`chart`,chartId:r}]};this.dispatch(`UPDATE_CAROUSEL`,{sheetId:n,figureId:e,definition:a}),this.dispatch(`UPDATE_CHART`,{sheetId:n,chartId:r,figureId:e,definition:this.getters.getChartDefinition(r)}),this.dispatch(`DELETE_FIGURE`,{sheetId:n,figureId:t})}getCarouselItemId(e){return e.type===`chart`?e.chartId:`carouselDataView`}},cq=class extends Rp{static getters=[`getColDimensions`,`getRowDimensions`,`getColRowOffset`];headerPositions={};isDirty=!0;handle(e){switch(yr.has(e.type)&&(this.headerPositions={},this.isDirty=!0),e.type){case`START`:for(let e of this.getters.getSheetIds())this.headerPositions[e]=this.computeHeaderPositionsOfSheet(e);break;case`UPDATE_CELL`:this.headerPositions={},this.isDirty=!0;break;case`UPDATE_FILTER`:case`UPDATE_TABLE`:case`REMOVE_TABLE`:this.headerPositions={},this.isDirty=!0;break;case`REMOVE_COLUMNS_ROWS`:case`RESIZE_COLUMNS_ROWS`:case`HIDE_COLUMNS_ROWS`:case`ADD_COLUMNS_ROWS`:case`UNHIDE_COLUMNS_ROWS`:case`FOLD_HEADER_GROUP`:case`UNFOLD_HEADER_GROUP`:case`FOLD_HEADER_GROUPS_IN_ZONE`:case`UNFOLD_HEADER_GROUPS_IN_ZONE`:case`UNFOLD_ALL_HEADER_GROUPS`:case`FOLD_ALL_HEADER_GROUPS`:case`UNGROUP_HEADERS`:case`GROUP_HEADERS`:case`CREATE_SHEET`:this.getters.tryGetSheet(e.sheetId)&&(this.headerPositions[e.sheetId]=this.computeHeaderPositionsOfSheet(e.sheetId));break;case`DUPLICATE_SHEET`:this.headerPositions[e.sheetIdTo]=b(this.headerPositions[e.sheetId]);break}}finalize(){for(let e of this.getters.getSheetIds())(this.isDirty||!this.headerPositions[e])&&(this.headerPositions[e]=this.computeHeaderPositionsOfSheet(e));this.isDirty=!1}getColDimensions(e,t){let n=this.headerPositions[e].COL[t],r=this.getters.getColSize(e,t);return{start:n,size:r,end:n+(this.getters.isColHidden(e,t)?0:r)}}getRowDimensions(e,t){let n=this.headerPositions[e].ROW[t],r=this.getters.getRowSize(e,t);return{start:n,size:r,end:n+(this.getters.isRowHidden(e,t)?0:r)}}getColRowOffset(e,t,n,r=this.getters.getActiveSheetId()){let i=this.headerPositions[r][e][t];return this.headerPositions[r][e][n]-i}computeHeaderPositionsOfSheet(e){return{COL:this.computePositions(e,`COL`),ROW:this.computePositions(e,`ROW`)}}computePositions(e,t){let n={},r=0;for(let i=0;i<this.getters.getNumberHeaders(e,t)+1;i++)n[i]=r,!this.getters.isHeaderHidden(e,t,i)&&(r+=this.getters.getHeaderSize(e,t,i));return n}};let lq=new g().add(`settings`,vW).add(`sheet`,pW).add(`header grouping`,gW).add(`header visibility`,sW).add(`tables`,mW).add(`dataValidation`,iW).add(`cell`,QU).add(`merge`,lW).add(`headerSize`,oW).add(`borders`,ZU).add(`conditional formatting`,rW).add(`figures`,aW).add(`chart`,tW).add(`carousel`,hW).add(`image`,cW).add(`pivot_core`,_W).add(`spreadsheet_pivot_core`,yW).add(`tableStyle`,bW),uq=new g().add(`ui_sheet`,gK).add(`ui_options`,hK).add(`autofill`,CG).add(`sort`,mK).add(`automatic_sum`,wG).add(`format`,uK).add(`insert_pivot`,pK).add(`pivot_presence`,ZK).add(`split_to_columns`,QK).add(`subtotal_evaluation`,zp).add(`collaborative`,cK).add(`history`,YK).add(`data_cleanup`,lK).add(`table_autofill`,$K).add(`table_ui_resize`,eq).add(`datavalidation_insert`,SK).add(`checkbox_toggle`,xK).add(`dynamic_translate`,CK).add(`geo_features`,dK),dq=new g().add(`selection`,iq).add(`evaluation_filter`,rq).add(`header_visibility_ui`,fK).add(`cell_computed_style`,bK).add(`table_computed_style`,_K).add(`header_positions`,cq).add(`viewport`,oq).add(`clipboard`,tq).add(`carousel_ui`,sq),fq=new g().add(`evaluation`,GW).add(`evaluation_chart`,XW).add(`evaluation_cf`,ZW).add(`row_size`,iG).add(`data_validation_ui`,$W).add(`dynamic_tables`,rG).add(`custom_colors`,YW).add(`pivot_ui`,lG).add(`cell_icon`,nG);up.add(`dataValidation`,{displayAllOnInitialContent:!0,canBeToggled:!1,getProposals(e,t){if(on(t)||!this.composer.currentEditedCell)return[];let n=this.composer.currentEditedCell,r=this.getters.getValidationRuleForCell(n);if(!r||r.criterion.type!==`isValueInList`&&r.criterion.type!==`isValueInRange`)return[];let i=this.composer.currentEditedCell.sheetId,a=r.criterion.type===`isValueInRange`?this.getters.getDataValidationRangeValues(i,r.criterion):r.criterion.values.map(e=>({label:e,value:e}));if(r.criterion.displayStyle!==`chip`)return a.map(e=>({text:e.value,fuzzySearchKey:e.label,htmlContent:[{value:e.label}]}));let o=r.criterion.colors;return a.map(e=>{let t=o?.[e.value];return{text:e.value,htmlContent:[{value:e.label,color:t?Mn(t):void 0,backgroundColor:t||`#E7E9ED`,classes:[`badge rounded-pill fs-6 fw-normal w-100 mt-1 text-start`]}],fuzzySearchKey:e.label}})},selectProposal(e,t){this.composer.setCurrentContent(t),this.composer.stopEdition()}}),up.add(`functions`,{sequence:100,autoSelectFirstProposal:!0,maxDisplayedProposals:10,getProposals(e){if(e.type!==`SYMBOL`)return[];let t=e.value;return on(this.composer.currentContent)?Object.entries(zS.content).filter(([e,{hidden:t}])=>!t).map(([e,{description:n}])=>({text:e,description:n,htmlContent:$H(t,e,ge,`o-semi-bold`)})).sort((e,t)=>e.text.length-t.text.length||e.text.localeCompare(t.text)):[]},selectProposal(e,t){let n=e.end,r=e.end;[`SYMBOL`,`FUNCTION`].includes(e.type)&&(n=e.start);let i=this.composer.currentTokens;t+=`(`;let a=i.map(e=>e.start).indexOf(e.start);a+1<i.length&&i[a+1]?.type===`LEFT_PAREN`&&r++,this.composer.changeComposerCursorSelection(n,r),this.composer.replaceComposerCursorSelection(t)}}),up.add(`pivot_ids`,{sequence:50,autoSelectFirstProposal:!0,getProposals(e){let t=e.functionContext;if(!t||![`PIVOT.VALUE`,`PIVOT.HEADER`,`PIVOT`].includes(t.parent.toUpperCase())||t.argPosition!==0)return;let n=this.getters.getPivotIds();if(!n.includes(e.value))return n.map(e=>{let t=this.getters.getPivotCoreDefinition(e),n=`${this.getters.getPivotFormulaId(e)}`;return{text:n,description:t.name,htmlContent:[{value:n,color:ot.NUMBER}],fuzzySearchKey:n+t.name,alwaysExpanded:!0}}).filter(C)},selectProposal:qS}),up.add(`pivot_measures`,{sequence:50,autoSelectFirstProposal:!0,getProposals(e){let t=e.functionContext;if(t?.parent.toUpperCase()!==`PIVOT.VALUE`||t.argPosition!==1)return[];let n=mU(e),r=this.getters.getPivotId(n);if(!r||!this.getters.isExistingPivot(r))return[];let i=this.getters.getPivot(r);return i.init(),i.isValid()?i.definition.measures.map(e=>{if(e.fieldName===`__count`){let e=`"__count"`;return{text:e,description:E(`Count`),htmlContent:[{value:e,color:ot.STRING}],fuzzySearchKey:E(`Count`)+e}}return dU(e)}).filter(C):[]},selectProposal:qS}),up.add(`pivot_group_fields`,{sequence:50,autoSelectFirstProposal:!0,getProposals(e){let t=e.functionContext;if(!t||!pq(e)&&!mq(e))return;let n=mU(e),r=this.getters.getPivotId(n);if(!r||!this.getters.isExistingPivot(r))return;let i=this.getters.getPivot(r);i.init();let a=i.getFields(),{columns:o,rows:s}=i.definition,c=t.args;t?.parent.toUpperCase()===`PIVOT.VALUE`?(c=c.filter((e,t)=>t%2==0),c=c.slice(1,t.argPosition)):c=c.filter((e,t)=>t%2==1);let l=c.map(e=>e?.value).filter(C),u=o.map(e=>e.nameWithGranularity),d=s.map(e=>e.nameWithGranularity),f=[],p=[`ARG_SEPARATOR`,`SPACE`].includes(e.type)?l.at(-1):l.at(-2),m=KU.get(i.type);if(m&&p?.startsWith(`#`)&&(p=p.slice(1)),p===void 0&&(f.push(u[0]),f.push(d[0])),d.includes(p)){let e=d[d.indexOf(p)+1];f.push(e),f.push(u[0])}if(u.includes(p)){let e=u[u.indexOf(p)+1];f.push(e)}let h=f.filter(C);return h.map(e=>{let[t,n]=e.split(`:`),r=a[t];return r?uU(r,n):void 0}).concat(h.map(e=>{if(!m)return;let t=a[e.split(`:`)[0]];if(!t)return;let n=`"#${e}"`;return{text:n,description:E(`%s (positional)`,t.string)+(t.help?` (${t.help})`:``),htmlContent:[{value:n,color:ot.STRING}],fuzzySearchKey:t.string+n}})).filter(C)},selectProposal:qS});function pq(e){let t=e.functionContext;return t?.parent.toUpperCase()===`PIVOT.VALUE`&&t.argPosition>=2&&t.argPosition%2==0}function mq(e){let t=e.functionContext;return t?.parent.toUpperCase()===`PIVOT.HEADER`&&t.argPosition>=1&&t.argPosition%2==1}up.add(`pivot_group_values`,{sequence:50,autoSelectFirstProposal:!0,getProposals(e){let t=e.functionContext;if(!t||!e||!hq(e)&&!gq(e))return;let n=mU(e),r=this.getters.getPivotId(n);if(!r||!this.getters.isExistingPivot(r))return;let i=this.getters.getPivot(r);if(!i.isValid())return;let a=t.argPosition,o=e.functionContext?.args[a-1]?.value;if(!o)return;let s;try{s=i.definition.getDimension(o)}catch{return}return s.granularity===`month_number`?Object.values(go).map((e,t)=>({text:`${t+1}`,fuzzySearchKey:e.toString(),description:e.toString(),htmlContent:[{value:`${t+1}`,color:ot.NUMBER}]})):s.granularity===`quarter_number`?[1,2,3,4].map(e=>({text:`${e}`,fuzzySearchKey:`${e}`,description:E(`Quarter %s`,e),htmlContent:[{value:`${e}`,color:ot.NUMBER}]})):s.granularity===`day_of_month`?S(1,32).map(e=>({text:`${e}`,fuzzySearchKey:`${e}`,description:``,htmlContent:[{value:`${e}`,color:ot.NUMBER}]})):s.granularity===`iso_week_number`?S(0,54).map(e=>({text:`${e}`,fuzzySearchKey:`${e}`,description:``,htmlContent:[{value:`${e}`,color:ot.NUMBER}]})):s.granularity===`day_of_week`?S(1,8).map(e=>({text:`${e}`,fuzzySearchKey:`${e}`,description:``,htmlContent:[{value:`${e}`,color:ot.NUMBER}]})):s.granularity===`hour_number`?S(0,24).map(e=>({text:`${e}`,fuzzySearchKey:`${e}`,description:``,htmlContent:[{value:`${e}`,color:ot.NUMBER}]})):s.granularity===`minute_number`?S(0,60).map(e=>({text:`${e}`,fuzzySearchKey:`${e}`,description:``,htmlContent:[{value:`${e}`,color:ot.NUMBER}]})):s.granularity===`second_number`?S(0,60).map(e=>({text:`${e}`,fuzzySearchKey:`${e}`,description:``,htmlContent:[{value:`${e}`,color:ot.NUMBER}]})):i.getPossibleFieldValues(s).map(({value:e,label:t})=>{let n=typeof e==`string`,r=n?`"${e}"`:e.toString(),i=n?ot.STRING:ot.NUMBER,a=t===e?``:t;return{text:r,description:a,htmlContent:[{value:r,color:i}],fuzzySearchKey:r+a}})},selectProposal:qS});function hq(e){let t=e.functionContext;return t?.parent.toUpperCase()===`PIVOT.VALUE`&&t.argPosition>=2&&t.argPosition%2==1}function gq(e){let t=e.functionContext;return t?.parent.toUpperCase()===`PIVOT.HEADER`&&t.argPosition>=1&&t.argPosition%2==0}up.add(`sheet_names`,{sequence:150,autoSelectFirstProposal:!0,getProposals(e){return e.type===`SYMBOL`||e.type===`UNKNOWN`&&e.value.startsWith(`'`)?this.getters.getSheetIds().map(e=>{let t=mt(this.getters.getSheetName(e));return{text:t,fuzzySearchKey:t.startsWith(`'`)?t:`'`+t}}):[]},selectProposal(e,t){let n=e.start,r=e.end;this.composer.changeComposerCursorSelection(n,r),this.composer.replaceComposerCursorSelection(t+`!`)}});let _q=new g;_q.add(`link`,{condition:(e,t)=>!!t.getEvaluatedCell(e).link,execute:(e,t,n)=>Yr(t.model.getters.getEvaluatedCell(e).link,t,n),title:(e,t)=>{let n=t.getEvaluatedCell(e).link;return n?n.isExternal?E(`Go to url: %(url)s`,{url:n.url}):E(`Go to %(label)s`,{label:n.label}):``},sequence:5}),_q.add(`dashboard_pivot_sorting`,{condition:(e,t)=>{if(!t.isDashboard())return!1;let n=t.getPivotCellFromPosition(e);return AR(t,e)&&n.type===`MEASURE_HEADER`},execute:(e,t)=>{jR(t,e,yq(t.model.getters,e))},component:qU,componentProps:(e,t)=>({position:e,sortDirection:t.getPivotCellSortDirection(e)}),sequence:2});let vq={none:`asc`,asc:`desc`,desc:`none`};function yq(e,t){return vq[e.getPivotCellSortDirection(t)??`none`]}let bq=new g().add(`ADD_COLUMNS_ROWS`,Cq).add(`REMOVE_COLUMNS_ROWS`,Oq).add(`ADD_MERGE`,wq).add(`REMOVE_MERGE`,Tq).add(`CREATE_SHEET`,Eq).add(`DELETE_SHEET`,kq).add(`DUPLICATE_SHEET`,Dq).add(`CREATE_FIGURE`,Aq).add(`CREATE_CHART`,jq).add(`HIDE_COLUMNS_ROWS`,Mq).add(`UNHIDE_COLUMNS_ROWS`,Nq).add(`CREATE_TABLE_STYLE`,Pq).add(`ADD_PIVOT`,Sq).add(`RENAME_SHEET`,Fq);for(let e of Er.values())bq.contains(e)||bq.add(e,xq);function xq(e){return[e]}function Sq(e){return[{type:`REMOVE_PIVOT`,pivotId:e.pivotId}]}function Cq(e){let t=[],n=e.base;e.position===`after`&&n++;for(let r=0;r<e.quantity;r++)t.push(r+n);return[{type:`REMOVE_COLUMNS_ROWS`,dimension:e.dimension,elements:t,sheetId:e.sheetId,sheetName:e.sheetName}]}function wq(e){return[{type:`REMOVE_MERGE`,sheetId:e.sheetId,target:e.target}]}function Tq(e){return[{type:`ADD_MERGE`,sheetId:e.sheetId,target:e.target}]}function Eq(e){return[{type:`DELETE_SHEET`,sheetId:e.sheetId,sheetName:e.name}]}function Dq(e){return[{type:`DELETE_SHEET`,sheetId:e.sheetIdTo,sheetName:``}]}function Oq(e){let t=[],n=[...e.elements].sort((e,t)=>e-t);for(let r of gt(n)){let n=r[0]===0?0:r[0]-1,i=r[0]===0?`before`:`after`;t.push({type:`ADD_COLUMNS_ROWS`,dimension:e.dimension,quantity:r.length,base:n,sheetId:e.sheetId,sheetName:e.sheetName,position:i})}return t}function kq(e){return[{type:`CREATE_SHEET`,sheetId:e.sheetId,position:1,name:e.sheetName}]}function Aq(e){return[{type:`DELETE_FIGURE`,figureId:e.figureId,sheetId:e.sheetId}]}function jq(e){return[{type:`DELETE_CHART`,chartId:e.chartId,sheetId:e.sheetId},{type:`DELETE_FIGURE`,figureId:e.figureId,sheetId:e.sheetId}]}function Mq(e){return[{type:`UNHIDE_COLUMNS_ROWS`,sheetId:e.sheetId,dimension:e.dimension,elements:e.elements}]}function Nq(e){return[{type:`HIDE_COLUMNS_ROWS`,sheetId:e.sheetId,dimension:e.dimension,elements:e.elements}]}function Pq(e){return[{type:`REMOVE_TABLE_STYLE`,tableStyleId:e.tableStyleId}]}function Fq(e){return[{type:`RENAME_SHEET`,sheetId:e.sheetId,oldName:e.newName,newName:e.oldName}]}let Iq=new g;Iq.add(`format_number_automatic`,{...QR,id:`format_number_automatic`,sequence:10}).add(`format_number_plain_text`,{...$R,id:`format_number_plain_text`,sequence:15,separator:!0}).add(`format_number_number`,{...ez,id:`format_number_number`,sequence:20}).add(`format_number_percent`,{...nz,id:`format_number_percent`,sequence:30,separator:!0}).add(`format_number_currency`,{...rz,id:`format_number_currency`,sequence:40}).add(`format_number_accounting`,{...az,id:`format_number_accounting`,sequence:45}).add(`format_number_currency_rounded`,{...iz,id:`format_number_currency_rounded`,sequence:50}).add(`format_custom_currency`,{...sz,id:`format_custom_currency`,sequence:60,separator:!0}).add(`format_number_date`,{...cz,id:`format_number_date`,sequence:70}).add(`format_number_time`,{...lz,id:`format_number_time`,sequence:80}).add(`format_number_date_time`,{...uz,id:`format_number_date_time`,sequence:90}).add(`format_number_duration`,{...dz,id:`format_number_duration`,sequence:100,separator:!0}).add(`more_formats`,{...mz,id:`more_formats`,sequence:120});function Lq(e){let t=new Set(Iq.getAll().map(t=>typeof t.format==`function`?t.format(e):t.format)),n=new Map;for(let r of e.model.getters.getSheetIds()){let i=e.model.getters.getEvaluatedCells(r);for(let e in i){let r=i[e];if(r.format&&!n.has(r.format)&&!t.has(r.format)){let e=Rq(r.format);(e===`date`||e===`currency`)&&n.set(r.format,ZR({descriptionValue:e===`currency`?1e3:oz,format:r.format,name:r.format}))}}}return[...n.values()]}let Rq=Kt(e=>jo(e)?`date`:e.includes(`[$`)?`currency`:`number`),zq={name:E(`More formats`),icon:`o-spreadsheet-Icon.NUMBER_FORMATS`,children:[e=>{let t=Lq(e).map(e=>({...e,sequence:110}));return t.length>0&&(t[t.length-1].separator=!0),f([...Iq.getAll(),...t])}]};function Bq(e){let t=new IA;return t.add(`delete`,{...kA,sequence:10}).add(`hide_sheet`,{...FA,sequence:20}).add(`duplicate`,{...AA,sequence:30,separator:!0}).add(`rename`,{...jA(e),sequence:40}).add(`change_color`,{...MA(e),sequence:50,separator:!0}).add(`move_right`,{...NA,sequence:60}).add(`move_left`,{...PA,sequence:70}),t}let Vq=new IA;Vq.add(`file`,{name:E(`File`),sequence:10,isReadonlyAllowed:!0}).addChild(`settings`,[`file`],{name:E(`Settings`),sequence:200,execute:e=>e.openSidePanel(`Settings`),isEnabled:e=>!e.isSmall,icon:`o-spreadsheet-Icon.COG`}).add(`edit`,{name:E(`Edit`),sequence:20,isReadonlyAllowed:!0}).addChild(`undo`,[`edit`],{...DI,sequence:10}).addChild(`redo`,[`edit`],{...OI,sequence:20,separator:!0}).addChild(`copy`,[`edit`],{...kI,sequence:30}).addChild(`cut`,[`edit`],{...AI,sequence:40}).addChild(`paste`,[`edit`],{...jI,sequence:50}).addChild(`paste_special`,[`edit`],{...MI,sequence:60,separator:!0}).addChild(`paste_special_value`,[`edit`,`paste_special`],{...NI,sequence:10}).addChild(`paste_special_format`,[`edit`,`paste_special`],{...PI,sequence:20}).addChild(`edit_table`,[`edit`],{...qI,isVisible:DF,sequence:60}).addChild(`find_and_replace`,[`edit`],{...FI,sequence:65,separator:!0}).addChild(`delete`,[`edit`],{name:E(`Delete`),icon:`o-spreadsheet-Icon.TRASH`,sequence:70}).addChild(`edit_delete_cell_values`,[`edit`,`delete`],{...II,sequence:10}).addChild(`edit_delete_row`,[`edit`,`delete`],{...LI,sequence:20}).addChild(`edit_delete_column`,[`edit`,`delete`],{...BI,sequence:30}).addChild(`edit_delete_cell_shift_up`,[`edit`,`delete`],{...WI,sequence:40}).addChild(`edit_delete_cell_shift_left`,[`edit`,`delete`],{...GI,sequence:50}).addChild(`edit_unhide_columns`,[`edit`],{...UF,sequence:80}).addChild(`edit_unhide_rows`,[`edit`],{...KF,sequence:80}).add(`view`,{name:E(`View`),sequence:30,isReadonlyAllowed:!0}).addChild(`unfreeze_panes`,[`view`],{...qF,sequence:4}).addChild(`freeze_panes`,[`view`],{...JF,sequence:5}).addChild(`unfreeze_rows`,[`view`,`freeze_panes`],{...YF,sequence:5}).addChild(`freeze_first_row`,[`view`,`freeze_panes`],{...XF,sequence:10}).addChild(`freeze_second_row`,[`view`,`freeze_panes`],{...ZF,sequence:15}).addChild(`freeze_current_row`,[`view`,`freeze_panes`],{...QF,sequence:20,separator:!0}).addChild(`unfreeze_columns`,[`view`,`freeze_panes`],{...$F,sequence:25}).addChild(`freeze_first_col`,[`view`,`freeze_panes`],{...eI,sequence:30}).addChild(`freeze_second_col`,[`view`,`freeze_panes`],{...tI,sequence:35}).addChild(`freeze_current_col`,[`view`,`freeze_panes`],{...nI,sequence:40}).addChild(`group_headers`,[`view`],{name:E(`Group`),sequence:15,separator:!0,icon:`o-spreadsheet-Icon.PLUS_IN_BOX`,isVisible:NF}).addChild(`group_columns`,[`view`,`group_headers`],{...oI,sequence:5}).addChild(`ungroup_columns`,[`view`,`group_headers`],{...cI,isVisible:e=>fI(e,`COL`),sequence:10}).addChild(`group_rows`,[`view`,`group_headers`],{...sI,sequence:15}).addChild(`ungroup_rows`,[`view`,`group_headers`],{...lI,isVisible:e=>fI(e,`ROW`),sequence:20}).addChild(`show`,[`view`],{name:E(`Show`),sequence:1,icon:`o-spreadsheet-Icon.SHOW`}).addChild(`view_gridlines`,[`view`,`show`],{...rI,sequence:5}).addChild(`view_formulas`,[`view`,`show`],{...aI,sequence:10}).addChild(`view_irregularity_map`,[`view`],{...iI,sequence:40,separator:!0}).add(`insert`,{name:E(`Insert`),sequence:40,isReadonlyAllowed:!0}).addChild(`insert_row`,[`insert`],{...QI,sequence:10}).addChild(`insert_row_before`,[`insert`,`insert_row`],{...eL,sequence:10}).addChild(`insert_row_after`,[`insert`,`insert_row`],{...rL,sequence:20}).addChild(`insert_column`,[`insert`],{...iL,sequence:20}).addChild(`insert_column_before`,[`insert`,`insert_column`],{...oL,sequence:10}).addChild(`insert_column_after`,[`insert`,`insert_column`],{...lL,sequence:20}).addChild(`insert_cell`,[`insert`],{...uL,sequence:30}).addChild(`insert_cell_down`,[`insert`,`insert_cell`],{...dL,name:E(`Shift down`),sequence:10}).addChild(`insert_cell_right`,[`insert`,`insert_cell`],{...fL,name:E(`Shift right`),sequence:20}).addChild(`insert_sheet`,[`insert`],{...AL,sequence:40,separator:!0}).addChild(`insert_chart`,[`insert`],{...pL,sequence:50}).addChild(`insert_carousel`,[`insert`],{...mL,sequence:51}).addChild(`insert_pivot`,[`insert`],{...hL,sequence:52}).addChild(`insert_image`,[`insert`],{...gL,sequence:55}).addChild(`insert_table`,[`insert`],{..._L,sequence:57}).addChild(`insert_function`,[`insert`],{...vL,sequence:60}).addChild(`insert_function_sum`,[`insert`,`insert_function`],{...yL,sequence:0}).addChild(`insert_function_average`,[`insert`,`insert_function`],{...bL,sequence:10}).addChild(`insert_function_count`,[`insert`,`insert_function`],{...xL,sequence:20}).addChild(`insert_function_max`,[`insert`,`insert_function`],{...SL,sequence:30}).addChild(`insert_function_min`,[`insert`,`insert_function`],{...CL,sequence:40,separator:!0}).addChild(`categorie_function_all`,[`insert`,`insert_function`],{...wL,sequence:50}).addChild(`categories_function_list`,[`insert`,`insert_function`],EL).addChild(`insert_link`,[`insert`],{...DL,separator:!0,sequence:70}).addChild(`insert_checkbox`,[`insert`],{...OL,sequence:80}).addChild(`insert_dropdown`,[`insert`],{...kL,separator:!0,sequence:90}).add(`format`,{name:E(`Format`),sequence:50,isReadonlyAllowed:!0}).addChild(`format_number`,[`format`],{...zq,name:E(`Number`),sequence:10,separator:!0}).addChild(`format_bold`,[`format`],{...Ez,sequence:20}).addChild(`format_italic`,[`format`],{...Dz,sequence:30}).addChild(`format_underline`,[`format`],{...Oz,sequence:40}).addChild(`format_strikethrough`,[`format`],{...kz,sequence:50,separator:!0}).addChild(`format_font_size`,[`format`],{...Az,sequence:60,separator:!0}).addChild(`format_alignment`,[`format`],{...jz,sequence:70}).addChild(`format_alignment_left`,[`format`,`format_alignment`],{...Nz,sequence:10}).addChild(`format_alignment_center`,[`format`,`format_alignment`],{...Pz,sequence:20}).addChild(`format_alignment_right`,[`format`,`format_alignment`],{...Fz,sequence:30,separator:!0}).addChild(`format_alignment_top`,[`format`,`format_alignment`],{...Lz,sequence:40}).addChild(`format_alignment_middle`,[`format`,`format_alignment`],{...Rz,sequence:50}).addChild(`format_alignment_bottom`,[`format`,`format_alignment`],{...zz,sequence:60,separator:!0}).addChild(`format_wrapping`,[`format`],{...Bz,sequence:80,separator:!0}).addChild(`format_wrapping_overflow`,[`format`,`format_wrapping`],{...Hz,sequence:10}).addChild(`format_wrapping_wrap`,[`format`,`format_wrapping`],{...Uz,sequence:20}).addChild(`format_wrapping_clip`,[`format`,`format_wrapping`],{...Wz,sequence:30}).addChild(`format_cf`,[`format`],{...Gz,sequence:90,separator:!0}).addChild(`format_clearFormat`,[`format`],{...Kz,sequence:100,separator:!0}).add(`data`,{name:E(`Data`),sequence:60,isReadonlyAllowed:!0}).addChild(`sort_range`,[`data`],{...BR,sequence:10,separator:!0}).addChild(`sort_ascending`,[`data`,`sort_range`],{...VR,sequence:10}).addChild(`sort_descending`,[`data`,`sort_range`],{...GR,sequence:20}).addChild(`data_cleanup`,[`data`],{...HR,sequence:15}).addChild(`remove_duplicates`,[`data`,`data_cleanup`],{...UR,sequence:10}).addChild(`trim_whitespace`,[`data`,`data_cleanup`],{...WR,sequence:20}).addChild(`split_to_columns`,[`data`],{...JR,sequence:20}).addChild(`data_validation`,[`data`],{name:E(`Data Validation`),execute:e=>{e.openSidePanel(`DataValidation`)},isEnabled:e=>!e.isSmall,icon:`o-spreadsheet-Icon.DATA_VALIDATION`,sequence:30,separator:!0}).addChild(`add_remove_data_filter`,[`data`],{...KR,sequence:40,separator:!0}).addChild(`pivot_data_sources`,[`data`],e=>{let t=e.model.getters.getPivotIds().length;return e.model.getters.getPivotIds().map((n,r)=>{let i={get highlights(){return YH(e.model.getters,n)}};return{id:`item_pivot_${e.model.getters.getPivotFormulaId(n)}`,name:e.model.getters.getPivotDisplayName(n),sequence:50+r/t,isReadonlyAllowed:!0,execute:e=>e.openSidePanel(`PivotSidePanel`,{pivotId:n}),isEnabled:e=>!e.isSmall,onStartHover:e=>e.getStore(Kk).register(i),onStopHover:e=>e.getStore(Kk).unRegister(i),icon:`o-spreadsheet-Icon.PIVOT`,separator:r===e.model.getters.getPivotIds().length-1,secondaryIcon:e=>e.model.getters.isPivotUnused(n)?`o-spreadsheet-Icon.UNUSED_PIVOT_WARNING`:void 0}})}).addChild(`reinsert_dynamic_pivot`,[`data`],YR).addChild(`reinsert_static_pivot`,[`data`],XR);let Hq=new class extends g{mapping={};uuidGenerator=new jl;replace(e,t){let n={...t,id:this.uuidGenerator.uuidv4()};return super.replace(e,n)}getAllOrdered(){return this.getAll().sort((e,t)=>e.sequence-t.sequence)}};var Uq=class{listeners=[];async sendMessage(e){for(let{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)}},Wq=class{fileStore;constructor(e){this.fileStore=e}async requestImage(){let e=await this.userImageUpload(),t=await this.fileStore.upload(e);return{path:t,size:await this.getImageOriginalSize(t),mimetype:e.type}}async uploadFile(e){let t=await this.fileStore.upload(e);return{path:t,size:await this.getImageOriginalSize(t),mimetype:e.type}}userImageUpload(){return new Promise((e,t)=>{let n=document.createElement(`input`);n.setAttribute(`type`,`file`),n.setAttribute(`accept`,`image/*`),n.addEventListener(`change`,async()=>{n.files===null||n.files.length!==1?t():e(n.files[0])}),n.click()})}getImageOriginalSize(e){return new Promise((t,n)=>{let r=new Image;r.addEventListener(`load`,()=>{t({width:r.width,height:r.height})}),r.addEventListener(`error`,n),r.src=e})}};let Gq=[{transform:`scale(0)`},{transform:`scale(0.8)`,offset:.33},{opacity:`0`,transform:`scale(1)`,offset:1}];B`
1934
1934
  .o-ripple {
1935
1935
  z-index: 1;
1936
1936
  }
@@ -3444,4 +3444,4 @@ You can download it directly instead.`,5),sticky:!1,type:`warning`});return}r=aw
3444
3444
  <Relationships xmlns="${Uf.Relationships}">
3445
3445
  <Relationship ${K(e)} />
3446
3446
  </Relationships>
3447
- `),`_rels/.rels`)}function DX(e){let t={},n=[];for(let r of e.sheets){let e=r.name.slice(0,31);e=an(e,n,{compute:(e,t)=>e.slice(0,31-String(t).length)+t}),n.push(e),e!==r.name&&(t[r.name]=e,r.name=e)}if(!Object.keys(t).length)return e;let r=Object.keys(t).sort((e,t)=>t.length-e.length),i=JSON.stringify(e);for(let e of r){let n=RegExp(`'?${ut(e)}'?!`,`g`);i=i.replaceAll(n,n=>{let r=t[e];return n.replace(e,r)})}return JSON.parse(i)}function OX(e){for(let t of e.sheets)t.tables=t.tables.filter(e=>Us(Ts(e.range)).numberOfRows>1);return e}var kX=class extends cf{corePlugins=[];statefulUIPlugins=[];range;session;isReplayingCommand=!1;renderers={};status=0;config;corePluginConfig;coreViewPluginConfig;uiPluginConfig;state;selection;getters;coreGetters;uuidGenerator;handlers=[];uiHandlers=[];coreHandlers=[];constructor(e={},n={},r=[],i=new jl,a=!1){let o=performance.now();console.debug(`##### Model creation #####`),super(),dr(),r=jP(e,r);let s=CP(e,a);this.state=new UJ,this.uuidGenerator=i,this.config=this.setupConfig(n),this.session=this.setupSession(s.revisionId),this.coreGetters={},this.range=new fW(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.getRangeData=this.range.getRangeData.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.coreGetters.recomputeRanges=this.range.recomputeRanges.bind(this.range),this.coreGetters.isRangeValid=this.range.isRangeValid.bind(this.range),this.coreGetters.extendRange=this.range.extendRange.bind(this.range),this.coreGetters.getRangesUnion=this.range.getRangesUnion.bind(this.range),this.coreGetters.removeRangesSheetPrefix=this.range.removeRangesSheetPrefix.bind(this.range),this.coreGetters.copyFormulaStringForSheet=this.range.copyFormulaStringForSheet.bind(this.range),this.getters={isReadonly:()=>this.config.mode===`readonly`||this.config.mode===`dashboard`,isDashboard:()=>this.config.mode===`dashboard`},this.selection=new VJ(this.getters),this.coreHandlers.push(this.range),this.handlers.push(this.range),this.corePluginConfig=this.setupCorePluginConfig(),this.coreViewPluginConfig=this.setupCoreViewPluginConfig(),this.uiPluginConfig=this.setupUiPluginConfig();for(let e of lq.getAll())this.setupCorePlugin(e,s);Object.assign(this.getters,this.coreGetters),this.session.loadInitialMessages(r);for(let e of fq.getAll()){let t=this.setupCoreViewPlugin(e);this.handlers.push(t),this.uiHandlers.push(t),this.coreHandlers.push(t)}for(let e of dq.getAll()){let t=this.setupUiPlugin(e);this.statefulUIPlugins.push(t),this.handlers.push(t),this.uiHandlers.push(t)}for(let e of uq.getAll()){let t=this.setupUiPlugin(e);this.handlers.push(t),this.uiHandlers.push(t)}if(this.dispatch(`START`),this.selection.observe(this,{handleEvent:()=>this.trigger(`update`)}),this.setupSessionEvents(),this.joinSession(),n.snapshotRequested||e[`[Content_Types].xml`]&&!this.getters.isReadonly()){let e=performance.now();console.debug(`Snapshot requested`),this.session.snapshot(this.exportData()),this.garbageCollectExternalResources(),console.debug(`Snapshot taken in`,performance.now()-e,`ms`)}(0,t.markRaw)(this),console.debug(`Model created in`,performance.now()-o,`ms`),console.debug(`######`)}joinSession(){this.session.join(this.config.client)}async leaveSession(){let e=this.getters.isReadonly()?void 0:Nt(()=>this.exportData());await this.session.leave(e)}setupUiPlugin(e){let t=new e(this.uiPluginConfig);for(let n of e.getters){if(!(n in t))throw Error(`Invalid getter name: ${n} for plugin ${t.constructor}`);if(n in this.getters)throw Error(`Getter "${n}" is already defined.`);this.getters[n]=t[n].bind(t)}for(let n of e.layers)this.renderers[n]||(this.renderers[n]=[]),this.renderers[n].push(t);return t}setupCoreViewPlugin(e){let t=new e(this.coreViewPluginConfig);for(let n of e.getters){if(!(n in t))throw Error(`Invalid getter name: ${n} for plugin ${t.constructor}`);if(n in this.getters)throw Error(`Getter "${n}" is already defined.`);this.getters[n]=t[n].bind(t)}return t}setupCorePlugin(e,t){let n=new e(this.corePluginConfig);for(let t of e.getters){if(!(t in n))throw Error(`Invalid getter name: ${t} for plugin ${n.constructor}`);if(t in this.coreGetters)throw Error(`Getter "${t}" is already defined.`);this.coreGetters[t]=n[t].bind(n)}n.import(t),this.corePlugins.push(n),this.coreHandlers.push(n),this.handlers.push(n)}onRemoteRevisionReceived({commands:e}){for(let t of e){let e=this.status;this.status=2,this.dispatchToHandlers(this.statefulUIPlugins,t),this.status=e}this.finalize()}setupSession(e){return new sK(LJ({initialRevisionId:e,recordChanges:this.state.recordChanges.bind(this.state),dispatch:e=>{if(!this.checkDispatchAllowed(e).isSuccessful){this.dispatchToHandlers(this.coreHandlers,{type:`UNDO`,commands:[e]});return}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){let t=e.client||{id:this.uuidGenerator.smallUuid(),name:E(`Anonymous`).toString()},n=e.transportService||new Uq,r=e.mode===`readonly`||e.mode===`dashboard`;return{...e,mode:e.mode||`normal`,custom:e.custom||{},external:this.setupExternalConfig(e.external||{}),transportService:r?new kJ(n):n,client:t,moveClient:()=>{},snapshotRequested:!1,notifyUI:e=>this.trigger(`notify-ui`,e),raiseBlockingErrorUI:e=>this.trigger(`raise-error-ui`,{text:e}),customColors:e.customColors||[]}}setupExternalConfig(e){let t=e.loadLocales||(()=>Promise.resolve(Pr));return{...e,loadLocales:t}}setupCorePluginConfig(){return{getters:this.coreGetters,stateObserver:this.state,range:this.range,dispatch:this.dispatchFromCorePlugin,canDispatch:this.canDispatch,custom:this.config.custom,external:this.config.external}}setupCoreViewPluginConfig(){return{getters:this.getters,stateObserver:this.state,selection:this.selection,moveClient:this.session.move.bind(this.session),custom:this.config.custom,uiActions:this.config,session:this.session,defaultCurrency:this.config.defaultCurrency,customColors:this.config.customColors||[],external:this.config.external}}setupUiPluginConfig(){return{getters:this.getters,stateObserver:this.state,dispatch:this.dispatch,canDispatch:this.canDispatch,selection:this.selection,moveClient:this.session.move.bind(this.session),custom:this.config.custom,uiActions:this.config,session:this.session,defaultCurrency:this.config.defaultCurrency,customColors:this.config.customColors||[],external:this.config.external}}checkDispatchAllowed(e){let t=Dr(e)?this.checkDispatchAllowedCoreCommand(e):this.checkDispatchAllowedLocalCommand(e);return t.some(e=>e!==`Success`)?new kr(t.flat()):kr.Success}checkDispatchAllowedCoreCommand(e){let 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(let e of this.handlers)e.finalize();this.status=0,this.trigger(`command-finalized`)}canDispatch=(e,t)=>this.checkDispatchAllowed(AX(e,t));dispatch=(e,t)=>{let n=AX(e,t),r=this.status;if(this.getters.isReadonly()&&!Or(n))return new kr(`Readonly`);if(!this.session.canApplyOptimisticUpdate())return new kr(`WaitingSessionConfirmation`);switch(r){case 0:let t=this.checkDispatchAllowed(n);if(!t.isSuccessful)return this.trigger(`update`),t;this.status=1;let{changes:r,commands:i}=this.state.recordChanges(()=>{let t=performance.now();Dr(n)&&this.state.addCommand(n),this.dispatchToHandlers(this.handlers,n),this.finalize();let r=performance.now()-t;r>5&&console.debug(e,r,`ms`)});this.session.save(n,i,r),this.status=0,this.trigger(`update`);break;case 1:if(Dr(n)){let e=this.checkDispatchAllowed(n);if(!e.isSuccessful)return e;this.state.addCommand(n)}this.dispatchToHandlers(this.handlers,n);break;case 3:throw Error(`Cannot dispatch commands in the finalize state`);case 2:if(Dr(n))throw Error(`A UI plugin cannot dispatch ${e} while handling a core command`);this.dispatchToHandlers(this.handlers,n)}return kr.Success};dispatchFromCorePlugin=(e,t)=>{let n=AX(e,t),r=this.status;this.status=2;let i=this.isReplayingCommand?this.coreHandlers:this.handlers;return this.dispatchToHandlers(i,n),this.status=r,kr.Success};dispatchToHandlers(e,t){let n=Dr(t);for(let r of e)!n&&r instanceof XU||r.beforeHandle(t);for(let r of e)!n&&r instanceof XU||r.handle(t);this.trigger(`command-dispatched`,t)}drawLayer(e,t){let n=this.renderers[t];if(n)for(let r of n)e.ctx.save(),r.drawLayer(e,t),e.ctx.restore()}exportData(){let e=RP();for(let t of this.handlers)t instanceof XU&&t.export(e);return e.revisionId=this.session.getRevisionId()||`START_REVISION`,e=b(e),e}updateMode(e){this.config.mode=e,this.trigger(`update`)}exportXLSX(){this.dispatch(`EVALUATE_CELLS`);let e=BP();for(let t of this.handlers)t instanceof Lp&&t.exportForExcel(e);return e=b(e),vX(e)}garbageCollectExternalResources(){for(let e of this.corePlugins)e.garbageCollectExternalResources()}};function AX(e,t={}){let n=b(t);return n.type=e,n}let jX={},MX={MIN_ROW_HEIGHT:10,MIN_COL_WIDTH:5,HEADER_HEIGHT:26,HEADER_WIDTH:48,DESKTOP_BOTTOMBAR_HEIGHT:36,DEFAULT_CELL_WIDTH:96,DEFAULT_CELL_HEIGHT:23,SCROLLBAR_WIDTH:15},NX={autoCompleteProviders:up,autofillModifiersRegistry:uG,autofillRulesRegistry:dG,cellMenuRegistry:zR,colMenuRegistry:rB,errorTypes:Ki,linkMenuRegistry:LA,functionRegistry:zS,featurePluginRegistry:uq,iconsOnCellRegistry:eG,statefulUIPluginRegistry:dq,coreViewsPluginRegistry:fq,corePluginRegistry:lq,rowMenuRegistry:uB,sidePanelRegistry:zU,figureRegistry:pk,chartSidePanelComponentRegistry:EH,chartComponentRegistry:pO,chartRegistry:fO,chartSubtypeRegistry:hO,topbarMenuRegistry:Vq,topbarComponentRegistry:Hq,clickableCellRegistry:_q,otRegistry:TG,inverseCommandRegistry:bq,urlRegistry:Wr,cellPopoverRegistry:gk,numberFormatMenuRegistry:Iq,repeatLocalCommandTransformRegistry:UK,repeatCommandTransformRegistry:HK,clipboardHandlersRegistries:af,pivotRegistry:vR,pivotTimeAdapterRegistry:od,pivotSidePanelRegistry:bU,pivotNormalizationValueRegistry:Ld,supportedPivotPositionalFormulaRegistry:KU,pivotToFunctionValueRegistry:Rd,migrationStepRegistry:vP,chartJsExtensionRegistry:Mf},PX={arg:H,isEvaluationError:j,toBoolean:P,toJsDate:F,toNumber:M,toString:N,toNormalizedPivotValue:Nd,toFunctionPivotValue:Fd,toXC:T,toZone:Ts,toUnboundedZone:ws,toCartesian:ir,numberToLetters:Yn,lettersToNumber:Xn,UuidGenerator:jl,formatValue:L,createCurrencyFormat:Ro,ColorGenerator:Un,computeTextWidth:ml,createEmptyWorkbookData:RP,createEmptySheet:LP,createEmptyExcelSheet:zP,rgbaToHex:bn,colorToRGBA:xn,positionToZone:R,isDefined:C,isMatrix:Ir,lazy:Nt,genericRepeat:WK,createAction:m,createActions:f,transformRangeData:sf,deepEquals:w,overlap:zs,union:Fs,isInside:Vs,deepCopy:b,expandZoneOnInsertion:js,reduceZoneOnDeletion:Ps,unquote:pt,getMaxObjectId:Td,getFunctionsFromTokens:fC,getFirstPivotFunction:hU,getNumberOfPivotFunctions:_U,parseDimension:Od,isDateOrDatetimeField:kd,makeFieldProposal:uU,insertTokenAfterArgSeparator:fU,insertTokenAfterLeftParenthesis:pU,mergeContiguousZones:dc,getPivotHighlights:YH,pivotTimeAdapter:sd,UNDO_REDO_PIVOT_COMMANDS:sG,createPivotFormula:Md,areDomainArgsFieldsValid:jd,splitReference:jc,sanitizeSheetName:ht,getUniqueText:an,isNumber:Hi,isDateTime:ui,createCustomFields:Wd,PositionMap:LF},FX={isMarkdownLink:xt,parseMarkdownLink:wt,markdownLink:Ct,openLink:Yr,urlRepresentation:Jr},IX={Checkbox:bA,Section:X,RoundColorPicker:aA,ChartDataSeries:IV,ChartErrorSection:LV,ChartLabelRange:RV,ChartTitle:HV,ChartPanel:kH,ChartFigure:dk,ChartJsComponent:Ew,ClickableCellSortIcon:qU,ZoomableChartJsComponent:TD,Grid:GU,GridOverlay:oV,ScorecardChart:Uw,GaugeChartComponent:jD,LineConfigPanel:dH,BarConfigPanel:BV,PieChartDesignPanel:mH,GenericChartConfigPanel:zV,ChartWithAxisDesignPanel:ZV,GenericZoomableChartDesignPanel:QV,LineChartDesignPanel:fH,GaugeChartConfigPanel:iH,GaugeChartDesignPanel:aH,ScorecardChartConfigPanel:_H,ScorecardChartDesignPanel:vH,GeoChartDesignPanel:lH,RadarChartDesignPanel:hH,WaterfallChartDesignPanel:TH,ComboChartDesignPanel:tH,FunnelChartDesignPanel:rH,SunburstChartDesignPanel:yH,TreeMapChartDesignPanel:wH,ChartTypePicker:DH,FigureComponent:mk,MenuPopover:ck,Popover:ik,SelectionInput:mA,ValidationMessages:ZB,AddDimensionButton:eU,PivotDimensionGranularity:nU,PivotDimensionOrder:rU,PivotDimension:tU,PivotLayoutConfigurator:sU,PivotHTMLRenderer:YU,PivotDeferUpdate:ZH,PivotTitleSection:cU,CogWheelMenu:PV,TextInput:kV,SidePanelCollapsible:bk,RadioSelection:WV,GeoChartRegionSelectSection:oH,ChartDashboardMenu:lk,FullScreenFigure:JU},LX={useDragAndDropListItems:sA,useHighlights:MH,useHighlightsOnHover:jH},RX={useStoreProvider:pf,DependencyContainer:lf,CellPopoverStore:TA,ComposerFocusStore:Sf,CellComposerStore:RB,FindAndReplaceStore:UH,HighlightStore:Kk,DelayedHoveredCellStore:hk,HoveredTableStore:rV,ModelStore:vf,NotificationStore:qk,RendererStore:yf,SelectionInputStore:pA,SpreadsheetStore:bf,useStore:z,useLocalStore:mf,SidePanelStore:VU,PivotSidePanelStore:vU,PivotMeasureDisplayPanelStore:qH,ClientFocusStore:fB,GridRenderer:mV};function zX(e,t){return zS.add(e,t),{addFunction:(e,t)=>zX(e,t)}}let BX={DEFAULT_LOCALE:D,HIGHLIGHT_COLOR:v,PIVOT_TABLE_CONFIG:tt,ChartTerms:Ub,FIGURE_ID_SPLITTER:`??`,GRID_ICON_EDGE_LENGTH:17,GRID_ICON_MARGIN:2},VX={...xO,...vD};e.AbstractCellClipboardHandler=Hl,e.AbstractChart=Dw,e.AbstractFigureClipboardHandler=Wl,e.CellErrorType=k,e.ClientDisconnectedError=oK,e.CommandResult=jr,e.CorePlugin=XU,e.CoreViewPlugin=xW,e.DispatchResult=kr,e.EvaluationError=A,e.LocalTransportService=Uq,e.Model=kX,e.PivotRuntimeDefinition=eR,e.Registry=g,e.Revision=aK,e.SPREADSHEET_DIMENSIONS=MX,e.Spreadsheet=OJ,e.SpreadsheetPivotTable=nR,e.UIPlugin=Rp,e.__info__=jX,e.addFunction=zX,e.addRenderingLayer=zr,e.astToFormula=PB,e.chartHelpers=VX,e.compile=rC,e.compileTokens=iC,e.components=IX,e.constants=BX,e.convertAstNodes=$y,e.coreTypes=Er,e.findCellInNewZone=Qs,e.functionCache=nC,e.getCaretDownSvg=Tj,e.getCaretUpSvg=Ej,e.helpers=PX,e.hooks=LX,e.invalidateCFEvaluationCommands=Sr,e.invalidateChartEvaluationCommands=br,e.invalidateDependenciesCommands=xr,e.invalidateEvaluationCommands=yr,e.iterateAstNodes=eb,e.links=FX,e.load=CP,e.parse=Zy,e.parseTokens=Qy,e.readonlyAllowedCommands=Tr,e.registries=NX,e.setDefaultSheetViewSize=$e,e.setTranslationMethod=ur,e.stores=RX,e.tokenColors=ot,e.tokenize=Jl,jX.version=`19.0.45`,jX.date=`2026-07-30T06:52:43.792Z`,jX.hash=`eb4c9d3`})(this.o_spreadsheet=this.o_spreadsheet||{},owl);
3447
+ `),`_rels/.rels`)}function DX(e){let t={},n=[];for(let r of e.sheets){let e=r.name.slice(0,31);e=an(e,n,{compute:(e,t)=>e.slice(0,31-String(t).length)+t}),n.push(e),e!==r.name&&(t[r.name]=e,r.name=e)}if(!Object.keys(t).length)return e;let r=Object.keys(t).sort((e,t)=>t.length-e.length),i=JSON.stringify(e);for(let e of r){let n=RegExp(`'?${ut(e)}'?!`,`g`);i=i.replaceAll(n,n=>{let r=t[e];return n.replace(e,r)})}return JSON.parse(i)}function OX(e){for(let t of e.sheets)t.tables=t.tables.filter(e=>Us(Ts(e.range)).numberOfRows>1);return e}var kX=class extends cf{corePlugins=[];statefulUIPlugins=[];range;session;isReplayingCommand=!1;renderers={};status=0;config;corePluginConfig;coreViewPluginConfig;uiPluginConfig;state;selection;getters;coreGetters;uuidGenerator;handlers=[];uiHandlers=[];coreHandlers=[];constructor(e={},n={},r=[],i=new jl,a=!1){let o=performance.now();console.debug(`##### Model creation #####`),super(),dr(),r=jP(e,r);let s=CP(e,a);this.state=new UJ,this.uuidGenerator=i,this.config=this.setupConfig(n),this.session=this.setupSession(s.revisionId),this.coreGetters={},this.range=new fW(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.getRangeData=this.range.getRangeData.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.coreGetters.recomputeRanges=this.range.recomputeRanges.bind(this.range),this.coreGetters.isRangeValid=this.range.isRangeValid.bind(this.range),this.coreGetters.extendRange=this.range.extendRange.bind(this.range),this.coreGetters.getRangesUnion=this.range.getRangesUnion.bind(this.range),this.coreGetters.removeRangesSheetPrefix=this.range.removeRangesSheetPrefix.bind(this.range),this.coreGetters.copyFormulaStringForSheet=this.range.copyFormulaStringForSheet.bind(this.range),this.getters={isReadonly:()=>this.config.mode===`readonly`||this.config.mode===`dashboard`,isDashboard:()=>this.config.mode===`dashboard`},this.selection=new VJ(this.getters),this.coreHandlers.push(this.range),this.handlers.push(this.range),this.corePluginConfig=this.setupCorePluginConfig(),this.coreViewPluginConfig=this.setupCoreViewPluginConfig(),this.uiPluginConfig=this.setupUiPluginConfig();for(let e of lq.getAll())this.setupCorePlugin(e,s);Object.assign(this.getters,this.coreGetters),this.session.loadInitialMessages(r);for(let e of fq.getAll()){let t=this.setupCoreViewPlugin(e);this.handlers.push(t),this.uiHandlers.push(t),this.coreHandlers.push(t)}for(let e of dq.getAll()){let t=this.setupUiPlugin(e);this.statefulUIPlugins.push(t),this.handlers.push(t),this.uiHandlers.push(t)}for(let e of uq.getAll()){let t=this.setupUiPlugin(e);this.handlers.push(t),this.uiHandlers.push(t)}if(this.dispatch(`START`),this.selection.observe(this,{handleEvent:()=>this.trigger(`update`)}),this.setupSessionEvents(),this.joinSession(),n.snapshotRequested||e[`[Content_Types].xml`]&&!this.getters.isReadonly()){let e=performance.now();console.debug(`Snapshot requested`),this.session.snapshot(this.exportData()),this.garbageCollectExternalResources(),console.debug(`Snapshot taken in`,performance.now()-e,`ms`)}(0,t.markRaw)(this),console.debug(`Model created in`,performance.now()-o,`ms`),console.debug(`######`)}joinSession(){this.session.join(this.config.client)}async leaveSession(){let e=this.getters.isReadonly()?void 0:Nt(()=>this.exportData());await this.session.leave(e)}setupUiPlugin(e){let t=new e(this.uiPluginConfig);for(let n of e.getters){if(!(n in t))throw Error(`Invalid getter name: ${n} for plugin ${t.constructor}`);if(n in this.getters)throw Error(`Getter "${n}" is already defined.`);this.getters[n]=t[n].bind(t)}for(let n of e.layers)this.renderers[n]||(this.renderers[n]=[]),this.renderers[n].push(t);return t}setupCoreViewPlugin(e){let t=new e(this.coreViewPluginConfig);for(let n of e.getters){if(!(n in t))throw Error(`Invalid getter name: ${n} for plugin ${t.constructor}`);if(n in this.getters)throw Error(`Getter "${n}" is already defined.`);this.getters[n]=t[n].bind(t)}return t}setupCorePlugin(e,t){let n=new e(this.corePluginConfig);for(let t of e.getters){if(!(t in n))throw Error(`Invalid getter name: ${t} for plugin ${n.constructor}`);if(t in this.coreGetters)throw Error(`Getter "${t}" is already defined.`);this.coreGetters[t]=n[t].bind(n)}n.import(t),this.corePlugins.push(n),this.coreHandlers.push(n),this.handlers.push(n)}onRemoteRevisionReceived({commands:e}){for(let t of e){let e=this.status;this.status=2,this.dispatchToHandlers(this.statefulUIPlugins,t),this.status=e}this.finalize()}setupSession(e){return new sK(LJ({initialRevisionId:e,recordChanges:this.state.recordChanges.bind(this.state),dispatch:e=>{if(!this.checkDispatchAllowed(e).isSuccessful){this.dispatchToHandlers(this.coreHandlers,{type:`UNDO`,commands:[e]});return}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){let t=e.client||{id:this.uuidGenerator.smallUuid(),name:E(`Anonymous`).toString()},n=e.transportService||new Uq,r=e.mode===`readonly`||e.mode===`dashboard`;return{...e,mode:e.mode||`normal`,custom:e.custom||{},external:this.setupExternalConfig(e.external||{}),transportService:r?new kJ(n):n,client:t,moveClient:()=>{},snapshotRequested:!1,notifyUI:e=>this.trigger(`notify-ui`,e),raiseBlockingErrorUI:e=>this.trigger(`raise-error-ui`,{text:e}),customColors:e.customColors||[]}}setupExternalConfig(e){let t=e.loadLocales||(()=>Promise.resolve(Pr));return{...e,loadLocales:t}}setupCorePluginConfig(){return{getters:this.coreGetters,stateObserver:this.state,range:this.range,dispatch:this.dispatchFromCorePlugin,canDispatch:this.canDispatch,custom:this.config.custom,external:this.config.external}}setupCoreViewPluginConfig(){return{getters:this.getters,stateObserver:this.state,selection:this.selection,moveClient:this.session.move.bind(this.session),custom:this.config.custom,uiActions:this.config,session:this.session,defaultCurrency:this.config.defaultCurrency,customColors:this.config.customColors||[],external:this.config.external}}setupUiPluginConfig(){return{getters:this.getters,stateObserver:this.state,dispatch:this.dispatch,canDispatch:this.canDispatch,selection:this.selection,moveClient:this.session.move.bind(this.session),custom:this.config.custom,uiActions:this.config,session:this.session,defaultCurrency:this.config.defaultCurrency,customColors:this.config.customColors||[],external:this.config.external}}checkDispatchAllowed(e){let t=Dr(e)?this.checkDispatchAllowedCoreCommand(e):this.checkDispatchAllowedLocalCommand(e);return t.some(e=>e!==`Success`)?new kr(t.flat()):kr.Success}checkDispatchAllowedCoreCommand(e){let 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(let e of this.handlers)e.finalize();this.status=0,this.trigger(`command-finalized`)}canDispatch=(e,t)=>this.checkDispatchAllowed(AX(e,t));dispatch=(e,t)=>{let n=AX(e,t),r=this.status;if(this.getters.isReadonly()&&!Or(n))return new kr(`Readonly`);if(!this.session.canApplyOptimisticUpdate())return new kr(`WaitingSessionConfirmation`);switch(r){case 0:let t=this.checkDispatchAllowed(n);if(!t.isSuccessful)return this.trigger(`update`),t;this.status=1;let{changes:r,commands:i}=this.state.recordChanges(()=>{let t=performance.now();Dr(n)&&this.state.addCommand(n),this.dispatchToHandlers(this.handlers,n),this.finalize();let r=performance.now()-t;r>5&&console.debug(e,r,`ms`)});this.session.save(n,i,r),this.status=0,this.trigger(`update`);break;case 1:if(Dr(n)){let e=this.checkDispatchAllowed(n);if(!e.isSuccessful)return e;this.state.addCommand(n)}this.dispatchToHandlers(this.handlers,n);break;case 3:throw Error(`Cannot dispatch commands in the finalize state`);case 2:if(Dr(n))throw Error(`A UI plugin cannot dispatch ${e} while handling a core command`);this.dispatchToHandlers(this.handlers,n)}return kr.Success};dispatchFromCorePlugin=(e,t)=>{let n=AX(e,t),r=this.status;this.status=2;let i=this.isReplayingCommand?this.coreHandlers:this.handlers;return this.dispatchToHandlers(i,n),this.status=r,kr.Success};dispatchToHandlers(e,t){let n=Dr(t);for(let r of e)!n&&r instanceof XU||r.beforeHandle(t);for(let r of e)!n&&r instanceof XU||r.handle(t);this.trigger(`command-dispatched`,t)}drawLayer(e,t){let n=this.renderers[t];if(n)for(let r of n)e.ctx.save(),r.drawLayer(e,t),e.ctx.restore()}exportData(){let e=RP();for(let t of this.handlers)t instanceof XU&&t.export(e);return e.revisionId=this.session.getRevisionId()||`START_REVISION`,e=b(e),e}updateMode(e){this.config.mode=e,this.trigger(`update`)}exportXLSX(){this.dispatch(`EVALUATE_CELLS`);let e=BP();for(let t of this.handlers)t instanceof Lp&&t.exportForExcel(e);return e=b(e),vX(e)}garbageCollectExternalResources(){for(let e of this.corePlugins)e.garbageCollectExternalResources()}};function AX(e,t={}){let n=b(t);return n.type=e,n}let jX={},MX={MIN_ROW_HEIGHT:10,MIN_COL_WIDTH:5,HEADER_HEIGHT:26,HEADER_WIDTH:48,DESKTOP_BOTTOMBAR_HEIGHT:36,DEFAULT_CELL_WIDTH:96,DEFAULT_CELL_HEIGHT:23,SCROLLBAR_WIDTH:15},NX={autoCompleteProviders:up,autofillModifiersRegistry:uG,autofillRulesRegistry:dG,cellMenuRegistry:zR,colMenuRegistry:rB,errorTypes:Ki,linkMenuRegistry:LA,functionRegistry:zS,featurePluginRegistry:uq,iconsOnCellRegistry:eG,statefulUIPluginRegistry:dq,coreViewsPluginRegistry:fq,corePluginRegistry:lq,rowMenuRegistry:uB,sidePanelRegistry:zU,figureRegistry:pk,chartSidePanelComponentRegistry:EH,chartComponentRegistry:pO,chartRegistry:fO,chartSubtypeRegistry:hO,topbarMenuRegistry:Vq,topbarComponentRegistry:Hq,clickableCellRegistry:_q,otRegistry:TG,inverseCommandRegistry:bq,urlRegistry:Wr,cellPopoverRegistry:gk,numberFormatMenuRegistry:Iq,repeatLocalCommandTransformRegistry:UK,repeatCommandTransformRegistry:HK,clipboardHandlersRegistries:af,pivotRegistry:vR,pivotTimeAdapterRegistry:od,pivotSidePanelRegistry:bU,pivotNormalizationValueRegistry:Ld,supportedPivotPositionalFormulaRegistry:KU,pivotToFunctionValueRegistry:Rd,migrationStepRegistry:vP,chartJsExtensionRegistry:Mf},PX={arg:H,isEvaluationError:j,toBoolean:P,toJsDate:F,toNumber:M,toString:N,toNormalizedPivotValue:Nd,toFunctionPivotValue:Fd,toXC:T,toZone:Ts,toUnboundedZone:ws,toCartesian:ir,numberToLetters:Yn,lettersToNumber:Xn,UuidGenerator:jl,formatValue:L,createCurrencyFormat:Ro,ColorGenerator:Un,computeTextWidth:ml,createEmptyWorkbookData:RP,createEmptySheet:LP,createEmptyExcelSheet:zP,rgbaToHex:bn,colorToRGBA:xn,positionToZone:R,isDefined:C,isMatrix:Ir,lazy:Nt,genericRepeat:WK,createAction:m,createActions:f,transformRangeData:sf,deepEquals:w,overlap:zs,union:Fs,isInside:Vs,deepCopy:b,expandZoneOnInsertion:js,reduceZoneOnDeletion:Ps,unquote:pt,getMaxObjectId:Td,getFunctionsFromTokens:fC,getFirstPivotFunction:hU,getNumberOfPivotFunctions:_U,parseDimension:Od,isDateOrDatetimeField:kd,makeFieldProposal:uU,insertTokenAfterArgSeparator:fU,insertTokenAfterLeftParenthesis:pU,mergeContiguousZones:dc,getPivotHighlights:YH,pivotTimeAdapter:sd,UNDO_REDO_PIVOT_COMMANDS:sG,createPivotFormula:Md,areDomainArgsFieldsValid:jd,splitReference:jc,sanitizeSheetName:ht,getUniqueText:an,isNumber:Hi,isDateTime:ui,createCustomFields:Wd,PositionMap:LF},FX={isMarkdownLink:xt,parseMarkdownLink:wt,markdownLink:Ct,openLink:Yr,urlRepresentation:Jr},IX={Checkbox:bA,Section:X,RoundColorPicker:aA,ChartDataSeries:IV,ChartErrorSection:LV,ChartLabelRange:RV,ChartTitle:HV,ChartPanel:kH,ChartFigure:dk,ChartJsComponent:Ew,ClickableCellSortIcon:qU,ZoomableChartJsComponent:TD,Grid:GU,GridOverlay:oV,ScorecardChart:Uw,GaugeChartComponent:jD,LineConfigPanel:dH,BarConfigPanel:BV,PieChartDesignPanel:mH,GenericChartConfigPanel:zV,ChartWithAxisDesignPanel:ZV,GenericZoomableChartDesignPanel:QV,LineChartDesignPanel:fH,GaugeChartConfigPanel:iH,GaugeChartDesignPanel:aH,ScorecardChartConfigPanel:_H,ScorecardChartDesignPanel:vH,GeoChartDesignPanel:lH,RadarChartDesignPanel:hH,WaterfallChartDesignPanel:TH,ComboChartDesignPanel:tH,FunnelChartDesignPanel:rH,SunburstChartDesignPanel:yH,TreeMapChartDesignPanel:wH,ChartTypePicker:DH,FigureComponent:mk,MenuPopover:ck,Popover:ik,SelectionInput:mA,ValidationMessages:ZB,AddDimensionButton:eU,PivotDimensionGranularity:nU,PivotDimensionOrder:rU,PivotDimension:tU,PivotLayoutConfigurator:sU,PivotHTMLRenderer:YU,PivotDeferUpdate:ZH,PivotTitleSection:cU,CogWheelMenu:PV,TextInput:kV,SidePanelCollapsible:bk,RadioSelection:WV,GeoChartRegionSelectSection:oH,ChartDashboardMenu:lk,FullScreenFigure:JU},LX={useDragAndDropListItems:sA,useHighlights:MH,useHighlightsOnHover:jH},RX={useStoreProvider:pf,DependencyContainer:lf,CellPopoverStore:TA,ComposerFocusStore:Sf,CellComposerStore:RB,FindAndReplaceStore:UH,HighlightStore:Kk,DelayedHoveredCellStore:hk,HoveredTableStore:rV,ModelStore:vf,NotificationStore:qk,RendererStore:yf,SelectionInputStore:pA,SpreadsheetStore:bf,useStore:z,useLocalStore:mf,SidePanelStore:VU,PivotSidePanelStore:vU,PivotMeasureDisplayPanelStore:qH,ClientFocusStore:fB,GridRenderer:mV};function zX(e,t){return zS.add(e,t),{addFunction:(e,t)=>zX(e,t)}}let BX={DEFAULT_LOCALE:D,HIGHLIGHT_COLOR:v,PIVOT_TABLE_CONFIG:tt,ChartTerms:Ub,FIGURE_ID_SPLITTER:`??`,GRID_ICON_EDGE_LENGTH:17,GRID_ICON_MARGIN:2},VX={...xO,...vD};e.AbstractCellClipboardHandler=Hl,e.AbstractChart=Dw,e.AbstractFigureClipboardHandler=Wl,e.CellErrorType=k,e.ClientDisconnectedError=oK,e.CommandResult=jr,e.CorePlugin=XU,e.CoreViewPlugin=xW,e.DispatchResult=kr,e.EvaluationError=A,e.LocalTransportService=Uq,e.Model=kX,e.PivotRuntimeDefinition=eR,e.Registry=g,e.Revision=aK,e.SPREADSHEET_DIMENSIONS=MX,e.Spreadsheet=OJ,e.SpreadsheetPivotTable=nR,e.UIPlugin=Rp,e.__info__=jX,e.addFunction=zX,e.addRenderingLayer=zr,e.astToFormula=PB,e.chartHelpers=VX,e.compile=rC,e.compileTokens=iC,e.components=IX,e.constants=BX,e.convertAstNodes=$y,e.coreTypes=Er,e.findCellInNewZone=Qs,e.functionCache=nC,e.getCaretDownSvg=Tj,e.getCaretUpSvg=Ej,e.helpers=PX,e.hooks=LX,e.invalidateCFEvaluationCommands=Sr,e.invalidateChartEvaluationCommands=br,e.invalidateDependenciesCommands=xr,e.invalidateEvaluationCommands=yr,e.iterateAstNodes=eb,e.links=FX,e.load=CP,e.parse=Zy,e.parseTokens=Qy,e.readonlyAllowedCommands=Tr,e.registries=NX,e.setDefaultSheetViewSize=$e,e.setTranslationMethod=ur,e.stores=RX,e.tokenColors=ot,e.tokenize=Jl,jX.version=`19.0.46`,jX.date=`2026-08-10T12:30:49.160Z`,jX.hash=`b721d1f`})(this.o_spreadsheet=this.o_spreadsheet||{},owl);