@odoo/o-spreadsheet
Version:
A spreadsheet component
1 lines • 1.62 MB
JavaScript
!function(e,t){"use strict";const s=.5,o="#017E84",i="#F8F9FA",n="#E8EAED",r="#595959",a="#666666",l="#3266ca",c="#FFFFFF",h=11982760,d=o,u="#188038",g="#9B359B",p="#00000000",m="#4EA7F2",f="#EA6175",v="#AAAAAA",b="#111827",y="#D8DADD",S="#E7E9ED",C="#374151",I=C+"C2",w=o,E=20,x=10,R=15,T=16,A={minColor:"#FFF5EB",midColor:"#FD8D3C",maxColor:"#7F2704"},_="#F28C28",D=["#000000","#434343","#666666","#999999","#B7B7B7","#CCCCCC","#D9D9D9","#EFEFEF","#F3F3F3","#FFFFFF","#980000","#FF0000","#FF9900","#FFFF00","#00FF00","#00FFFF","#4A86E8","#0000FF","#9900FF","#FF00FF","#E6B8AF","#F4CCCC","#FCE5CD","#FFF2CC","#D9EAD3","#D0E0E3","#C9DAF8","#CFE2F3","#D9D2E9","#EAD1DC","#DD7E6B","#EA9999","#F9CB9C","#FFE599","#B6D7A8","#A2C4C9","#A4C2F4","#9FC5E8","#B4A7D6","#D5A6BD","#CC4125","#E06666","#F6B26B","#FFD966","#93C47D","#76A5AF","#6D9EEB","#6FA8DC","#8E7CC3","#C27BA0","#A61C00","#CC0000","#E69138","#F1C232","#6AA84F","#45818E","#3C78D8","#3D85C6","#674EA7","#A64D79","#85200C","#990000","#B45F06","#BF9000","#38761D","#134F5C","#1155CC","#0B5394","#351C75","#741B47","#5B0F00","#660000","#783F04","#7F6000","#274E13","#0C343D","#1C4587","#073763","#20124D","#4C1130"],O=26,F=48,P=23,M=21,N=[50,75,100,125,150,200],k=10,L=.001,V="bottom",z="overflow",H=k,U="'Roboto', arial",B="thin",G="#000000",W="START_REVISION",$="??",q="difference",Z="#43C5B1",j="#EA6175",Y=["'","*","?","/","\\","[","]"],X=/'|\*|\?|\/|\\|\[|\]/,K="|";let J=0;function Q(){return J}const ee="\n",te=[6,7,8,9,10,11,12,14,18,24,36],se={hasFilters:!1,totalRow:!1,firstColumn:!0,lastColumn:!1,numberOfHeaders:1,bandedRows:!0,bandedColumns:!1,styleId:"TableStyleMedium5",automaticAutofill:!1},oe=5e5,ie={symbol:"$",position:"before",decimalPlaces:2,code:"",name:"Dollar"},ne={fontSize:T,color:C},re="light-dark(#000000, #ffffff)",ae="#3da4ab",le={OPERATOR:ae,NUMBER:"#02c39a",STRING:"#00a82d",FUNCTION:re,DEBUGGER:ae,LEFT_PAREN:re,RIGHT_PAREN:re,ARG_SEPARATOR:re,ORPHAN_RIGHT_PAREN:"#ff0000"},ce=new RegExp(X,"g");function he(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function de(e){switch(typeof e){case"object":{if(null===e)return e;if(function(e){return"clone"in e&&e.clone instanceof Function}(e))return e.clone();if(!(function(e){return"object"==typeof e&&null!==e&&(e?.constructor===Object||void 0===e?.constructor)}(e)||e instanceof Array))throw new Error("Unsupported type: only objects and arrays are supported");const t=Array.isArray(e)?new Array(e.length):{};if(Array.isArray(e))for(let s=0,o=e.length;s<o;s++)s in e&&(t[s]=de(e[s]));else for(const s in e)t[s]=de(e[s]);return t}case"number":case"string":case"boolean":case"function":case"undefined":return e;default:throw new Error("Unsupported type: "+typeof e)}}function ue(e){return ge(e,"'")}function ge(e,t='"'){return e.startsWith(t)&&(e=e.slice(1)),e.endsWith(t)&&(e=e.slice(0,-1)),e}function pe(e){return e.match(/\w/g)?.length!==e.length&&(e=`'${e}'`),e}function me(e,t=" "){return e.replace(ce,t)}function fe(e,t,s){return e<t?t:e>s?s:e}function ve(e,t,s=1){if(t<=e&&s>0)return[];if(0===s)throw new Error("range() step must not be zero");const o=Math.ceil(Math.abs((t-e)/s)),i=Array(o);for(let t=0;t<o;t++)i[t]=e+t*s;return i}function be(e){return e.reduce((e,t,s,o)=>{if(1===Math.abs(t-o[s-1])){e[e.length-1].push(t)}else e.push([t]);return e},[])}function*ye(e,t){t.next();for(const s of e){const e=t.next();yield{...s,next:e.done?void 0:e.value}}}function Se(e){const t=e.toUpperCase();return"TRUE"===t||"FALSE"===t}const Ce=/^\[(.+)\]\((.+)\)$/,Ie=/^https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,4}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)$/;function we(e){return Ce.test(e)}function Ee(e){return Ie.test(e)}function xe(e,t){return`[${e}](${t})`}function Re(e){const t=e.match(Ce)||[],s=t[1],o=t[2];if(!s||!o)throw new Error(`Could not parse markdown link ${e}.`);return{label:s,url:o}}const Te="o-spreadsheet://";function Ae(e){return e.startsWith(Te)}function _e(e){return`${Te}${e}`}function De(e){if(e.startsWith(Te))return e.slice(16);throw new Error(`${e} is not a valid sheet link`)}function Oe(e){return void 0!==e}function Fe(e){return void 0===e||Object.values(e).every(e=>"object"==typeof e?Fe(e):!e)}function Pe(e,t,s){let o,i=!1;const n=function(){const n=this,r=Array.from(arguments);if(!i&&s)return i=!0,e.apply(n,r);clearTimeout(o),o=setTimeout(function(){o=void 0,i=!1,e.apply(n,r)},t)};return n.isDebouncePending=()=>void 0!==o,n.stopDebounce=()=>{clearTimeout(o)},n}function Me(e){let t="";for(let s=0,o=e.length;s<o;s++)t+=e[s];return t}function Ne(e){let t,s=!1;const o=()=>(s||(t=e instanceof Function?e():e,s=!0),t);return o.map=e=>Ne(()=>e(o())),o}function ke(e,t){let s=e.slice(t).find(e=>e);return s||(s=e.slice(0,t).reverse().find(e=>e)),s||""}function Le(e,t){return"after"===e?t+1:t}function Ve(...e){if(e.length<=1)return!0;for(let t=1;t<e.length;t++)if(!ze(e[0],e[t]))return!1;return!0}function ze(e,t){if(e===t)return!0;if(e&&!t||t&&!e)return!1;if(typeof e!=typeof t)return!1;if("object"!=typeof e)return!1;for(const s in t)if(!(s in e)&&void 0!==t[s])return!1;for(const s in e){if(typeof e[s]!=typeof t[s])return!1;if("object"==typeof e[s]){if(!ze(e[s],t[s]))return!1}else if(e[s]!==t[s])return!1}return!0}function He(e,t){if(e.length!==t.length)return!1;for(let s=0;s<e.length;s++)if(!Ve(e[s],t[s]))return!1;return!0}function Ue(e,t){if(e.length<t.length)return!1;const s=new Set(e);return t.every(e=>s.has(e))}function Be(e){if(!e)return e;const t={...e};return Object.keys(t).forEach(e=>!t[e]&&delete t[e]),t}const Ge=["\t","\f","\v",String.fromCharCode(parseInt("00a0",16)),String.fromCharCode(parseInt("1680",16)),String.fromCharCode(parseInt("2000",16)),String.fromCharCode(parseInt("200a",16)),String.fromCharCode(parseInt("2028",16)),String.fromCharCode(parseInt("2029",16)),String.fromCharCode(parseInt("202f",16)),String.fromCharCode(parseInt("205f",16)),String.fromCharCode(parseInt("3000",16)),String.fromCharCode(parseInt("feff",16))],We=new RegExp(Ge.join("|"),"g"),$e=/(\r\n|\r)/g,qe=Ge.concat([" "]);function Ze(e){return e?e.replace($e,ee):""}function je(e){const t=Array.from(e).sort((e,t)=>e-t);for(let e=1;e<t.length;e++)if(t[e]-t[e-1]!==1)return!1;return!0}function Ye(e){const t=new Map,s=e.name?e.name+" (memoized)":"memoized";return{[s]:(...s)=>(t.has(s[0])||t.set(s[0],e(...s)),t.get(s[0]))}[s]}function Xe(e,t){const s=new Set(t),o=[];for(let t=0;t<e.length;t++)s.has(t)||o.push(e[t]);return o}function Ke(e,t,s){return e.slice(0,s).concat(t).concat(e.slice(s))}function Je(e,t,s){const o=[...e];return o[s]=t,o}function Qe(e){return e.split("\n").map(e=>e.replace(/\s+/g," ").trim()).join("\n")}function et(e,t,s){return t>s?et(e,s,t):e>=t&&e<=s}function tt(e,t){let s=he(e);const o=t.matchCase?"":"i";return t.exactMatch&&(s=`^${s}$`),RegExp(s,o)}function st(e){let t=e.length;if(t<1e5)return Math.max(...e);let s=-1/0;for(;t--;)s=e[t]>s?e[t]:s;return s}function ot(e){let t=e.length;if(t<1e5)return Math.min(...e);let s=1/0;for(;t--;)s=e[t]<s?e[t]:s;return s}class it{text;currentIndex=0;current;constructor(e){this.text=e,this.current=e[0]}shift(){const 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 nt(e,t=e=>e){const s=new Set;return e.filter(e=>{const o=t(e);return!s.has(o)&&(s.add(o),!0)})}function rt(e){const t={};for(const s in e)for(const o in e[s])t[o]||(t[o]={}),t[o][s]=e[s][o];return t}function at(e,t,s={}){const o=s.compute??((e,t)=>`${e} (${t})`),i=s.computeFirstOne??!1;let n=s.start??1,r=i?o(e,n):e;for(;t.includes(r);)r=o(e,n++);return r}function lt(e){return e.startsWith("=")||e.startsWith("+")}function ct(e){if(e<0)throw new Error(`number must be positive. Got ${e}`);return e<26?String.fromCharCode(65+e):ct(Math.floor(e/26)-1)+ct(e%26)}function ht(e){let t=0;const s=e.length;for(let o=0;o<s;o++){t=26*t+dt(e[o])}return t-1}function dt(e){const t=e.charCodeAt(0);return t>=65&&t<=90?t-64:t-96}function ut(e){return e>="A"&&e<="Z"||e>="a"&&e<="z"}function gt(e){return e>="0"&&e<="9"}const pt=ht("ZZZ"),mt=9999998;function ft(e){for(;" "===e.current;)e.advanceBy(1)}function vt(e){if("$"===e.current&&e.advanceBy(1),!e.current||!ut(e.current))return-1;let t=0;for(;e.current&&ut(e.current);)t=26*t+dt(e.shift());return t}function bt(e){if("$"===e.current&&e.advanceBy(1),!e.current||!gt(e.current))return-1;let t=0;for(;e.current&>(e.current);)t=10*t+Number(e.shift());return t}function yt(e){const t=new it(e);ft(t);const s=vt(t);if(-1===s||!t.current)throw new Error(`Invalid cell description: ${e}`);const o=bt(t);ft(t);const i=s-1,n=o-1;if(!t.isOver()||i>pt||n>mt)throw new Error(`Invalid cell description: ${e}`);return{col:i,row:n}}function St(e,t,s={colFixed:!1,rowFixed:!1}){return(s.colFixed?"$":"")+ct(e)+(s.rowFixed?"$":"")+String(t+1)}function Ct(e,t=[]){if(e.length<=1&&0===t.length)return e;const s=[0],o=new Map([[0,[]]]);return It(s,o,e,!1),It(s,o,t,!0),Rt(s,o)}function It(e,t,s,o=!1){for(const i of s){const s=i.left,n=void 0===i.right?void 0:i.right+1,r=wt(e,t,s,!0,0),a=wt(e,t,n,!1,r);for(let s=r;s<=a;s++){Et(t.get(e[s]),i,o)}xt(e,t,r,a)}}function wt(e,t,s,o,i){if(void 0===s)return e.length-1;const n=Tt(e,s,i);return s!==e[n]?(e.splice(n+1,0,s),t.set(s,[...t.get(e[n])]),o?n+1:n):o?n:n-1}function Et(e,t,s=!1){const o=t.top,i=void 0===t.bottom?void 0:t.bottom+1,n=[],r=Tt(e,o,0,!1);if((r%2!=0&&!s||r%2==0&&s)&&n.push(o),void 0===i)return e.splice(r+1),void e.push(...n);const a=At(e,i,0,!1);(a%2==0&&!s||a%2!=0&&s)&&n.push(i);const l=a-r-1,c=n.length,h=r+1;h===e.length-1&&1===l&&1===c?e[h]=n[0]??n[1]:e.splice(h,l,...n)}function xt(e,t,s,o){const i=s-1==-1?0:s-1;for(let s=o===e.length-1?o:o+1;s>i;s--)He(t.get(e[s]),t.get(e[s-1]))&&(t.delete(e[s]),e.splice(s,1))}function Rt(e,t){const s=[];let o=[];for(let i=0;i<e.length;i++){const n=e[i],r=t.get(n);if(!r||0===r.length){s.push(...o),o=[];continue}let a=e[i+1];void 0!==a&&a--;const l=[];for(let e=0;e<r.length;e+=2){const t=r[e];let s=r[e+1];void 0!==s&&s--;const i={top:t,left:n,bottom:s,right:a};(void 0===s&&0!==t||void 0===a&&0!==n)&&(i.hasHeader=!0);let c=!1;for(let e=o.length-1;e>=0;e--){const t=o[e];if(t.top===i.top&&t.bottom===i.bottom){t.right=i.right,o.splice(e,1),l.push(t),c=!0;break}}c||l.push(i)}s.push(...o),o=l}return s.push(...o),s}function Tt(e,t,s=0,o=!0){let i=e.length-1,n=-1;for(;s<=i;){const r=Math.floor((s+i)/2);if(e[r]===t&&o)return r;e[r]<t?(n=r,s=r+1):i=r-1}return n}function At(e,t,s=0,o=!0){let i=e.length-1,n=e.length;for(;s<=i;){const r=Math.floor((s+i)/2);if(e[r]===t&&o)return r;e[r]>t?(n=r,i=r-1):s=r+1}return n}function _t(e){const t=function(e){const t=new it(e);ft(t);const s=e.indexOf("!");-1!==s&&t.advanceBy(s+1);const o=vt(t),i=bt(t);let n,r,a,l,c=!1,h=!1,d=!1;if(-1===i?(a=l=o-1,n=r=0,c=!0):-1===o?(n=r=i-1,a=l=0,h=!0):(a=l=o-1,n=r=i-1,d=!0),ft(t),":"===t.current){t.advanceBy(1),ft(t);const e=vt(t),s=bt(t);-1===s?(l=e-1,c=!0):-1===e?(r=s-1,h=!0):(l=e-1,r=s-1,n=c?r:n,a=h?l:a,d=!0)}const u={top:n,left:a,bottom:c?void 0:r,right:h?void 0:l};return d=d&&(h||c),d&&(u.hasHeader=d),u}(e),s=Xt(t),o=s.bottom,i=s.right;if(void 0!==o&&o>mt||void 0!==i&&i>pt)throw new Error(`Range string out of bounds: ${e}`);if(void 0===o&&void 0===i)throw new Error("Wrong zone xc. The zone cannot be at the same time a full column and a full row");return s}function Dt(e){const t=_t(e);if(void 0===t.bottom||void 0===t.right)throw new Error("This does not support unbounded ranges");return t}function Ot(e){try{return function(e){return Ft(_t(e))}(e)}catch(e){return!1}}function Ft(e){const{bottom:t,top:s,left:o,right:i}=e;return!(void 0!==t&&isNaN(t)||isNaN(s)||isNaN(o)||void 0!==i&&isNaN(i))&&(Pt(e)&&e.top>=0&&e.left>=0)}function Pt(e){return(void 0===e.bottom||e.bottom>=e.top&&e.bottom>=0)&&(void 0===e.right||e.right>=e.left&&e.right>=0)}function Mt(e){const{top:t,bottom:s,left:o,right:i}=e,n="hasHeader"in e&&e.hasHeader,r=t===s&&o===i;if(void 0===s&&void 0!==i)return 0!==t||n?`${St(o,t)}:${ct(i)}`:`${ct(o)}:${ct(i)}`;if(void 0===i&&void 0!==s)return 0!==o||n?`${St(o,t)}:${s+1}`:`${t+1}:${s+1}`;if(void 0!==s&&void 0!==i)return r?St(o,t):`${St(o,t)}:${St(i,s)}`;throw new Error("Bad zone format")}function Nt(e,t,s,o,i){const n="left"===t?"columns":"rows",r="before"===o?s-1:s,a=e["left"===t?"right":"bottom"];return e[t]<=r&&a&&a>r?Kt(e,n,"RESIZE",i):r<e[t]?Kt(e,n,"MOVE",i):{...e}}function kt(e,t,s,o,i){const n="left"===t?"columns":"rows",r="before"===o?s-1:s,a="left"===t?"right":"bottom";return e[t]<=r&&e[a]>r?Kt(e,n,"RESIZE",i):r<e[t]?Kt(e,n,"MOVE",i):{...e}}function Lt(e,t,s){const o="left"===t?"right":"bottom";let i=e[t],n=e[o];for(const r of s.sort((e,t)=>t-e))e[t]>r&&(i--,n--),e[t]<r&&e[o]>=r&&n--;return{...e,[t]:i,[o]:n}}function Vt(e,t,s){const o="left"===t?"right":"bottom";let i=e[t],n=e[o];const r=e[o];for(const o of s.sort((e,t)=>t-e))e[t]>o&&(i--,void 0!==n&&n--),void 0!==r&&void 0!==n&&e[t]<=o&&r>=o&&n--;if(!(void 0!==n&&i>n))return{...e,[t]:i,[o]:n}}function zt(...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 Ht(e,t){if(Gt(e,t))return{top:Math.max(e.top,t.top),left:Math.max(e.left,t.left),bottom:void 0!==e.bottom?Math.min(e.bottom,t.bottom):e.bottom??t.bottom,right:void 0!==e.right?Math.min(e.right,t.right):e.right??t.right}}function Ut(e,t){return e.left===t.left&&e.right===t.right&&e.top===t.top&&e.bottom===t.bottom&&e.hasHeader===t.hasHeader}function Bt(e,t){if(Ht(e,t))return;let s;return e.left===t.right+1&&(s={position:"left",start:Math.max(e.top,t.top),stop:void 0!==e.bottom?Math.min(e.bottom,t.bottom):t.bottom}),void 0!==e.right&&e.right+1===t.left&&(s={position:"right",start:Math.max(e.top,t.top),stop:void 0!==e.bottom?Math.min(e.bottom,t.bottom):t.bottom}),e.top===t.bottom+1&&(s={position:"top",start:Math.max(e.left,t.left),stop:void 0!==e.right?Math.min(e.right,t.right):t.right}),void 0!==e.bottom&&e.bottom+1===t.top&&(s={position:"bottom",start:Math.max(e.left,t.left),stop:void 0!==e.right?Math.min(e.right,t.right):t.right}),s&&s.start<=s.stop?s:void 0}function Gt(e,t){return!(void 0!==e.bottom&&e.bottom<t.top||void 0!==t.bottom&&t.bottom<e.top)&&!(void 0!==e.right&&e.right<t.left||void 0!==t.right&&t.right<e.left)}function Wt(e,t,s){const{left:o,right:i,top:n,bottom:r}=s;return e>=o&&(void 0===i||e<=i)&&t>=n&&(void 0===r||t<=r)}function $t(e,t){return e.left>=t.left&&e.right<=t.right&&e.top>=t.top&&e.bottom<=t.bottom}function qt(e){return{numberOfRows:e.bottom-e.top+1,numberOfCols:e.right-e.left+1}}function Zt(e){const{numberOfCols:t,numberOfRows:s}=qt(e);return 1===t||1===s}function jt(e){const t=[],{left:s,right:o,top:i,bottom:n}=Xt(e);for(const e of ve(s,o+1))for(const s of ve(i,n+1))t.push({col:e,row:s});return t}function Yt(e,t){const s=[],{left:o,right:i,top:n,bottom:r}=Xt(t);for(const t of ve(o,i+1))for(const o of ve(n,r+1))s.push({sheetId:e,col:t,row:o});return s}function Xt(e){return void 0!==e.right&&e.left>e.right&&(e={...e,left:e.right,right:e.left}),void 0!==e.bottom&&e.top>e.bottom&&(e={...e,top:e.bottom,bottom:e.top}),e}function Kt(e,t,s,o){const i="both"===t?o[0]:"columns"===t?o:0,n="both"===t?o[1]:"rows"===t?o:0,r="hasHeader"in e&&e.hasHeader;let a;a=ss(e)&&!r?"rows"!==t:!(ts(e)&&!r)||"columns"!==t;const l={...e};return a&&"MOVE"===s&&(l.left+=i,l.top+=n),void 0!==l.right&&(l.right+=i),void 0!==l.bottom&&(l.bottom+=n),l}function Jt(e,t){let s,o;const{left:i,right:n,top:r,bottom:a}=e,{left:l,right:c,top:h,bottom:d}=t;return s=l!==i?l:c!==n?c:l,o=h!==r?h:d!==a?d:h,{col:s,row:o}}function Qt(e){return{left:e.col,right:e.col,top:e.row,bottom:e.row}}function es(e){return{...e,right:e.left,bottom:e.top}}function ts(e){return void 0===e.right}function ss(e){return void 0===e.bottom}function os(e){return(e.bottom-e.top+1)*(e.right-e.left+1)}function is(e,t,s){return e.some(e=>function(e,t,s){return e.left<t&&t<=e.right||e.top<s&&s<=e.bottom}(e,t,s))}function ns(e){return e.length<2||1===Ct(e).length}function rs(e){const t=[...e];let s=!0;for(;s;){s=!1;for(let e=0;e<t.length;e++){const o=t[e],i=t.findIndex((t,s)=>{return e!==s&&(n=o,((i=t).right+1===n.left||i.left===n.right+1?i.top<=n.bottom&&i.top>=n.top||n.top<=i.bottom&&n.top>=i.top:(i.bottom+1===n.top||i.top===n.bottom+1)&&(i.left<=n.right&&i.left>=n.left||n.left<=i.right&&n.left>=i.left))||Gt(t,o));var i,n});if(-1!==i){t[e]=zt(t[i],o),t.splice(i,1),s=!0;break}}}return t}function as(e,t){const s=Bt(e,t);if(!s)return[e];const o=[];switch(s.position){case"bottom":case"top":return o.push({top:e.top,bottom:e.bottom,left:s.start,right:s.stop}),s.start>e.left&&o.push({top:e.top,bottom:e.bottom,left:e.left,right:s.start-1}),(void 0===e.right||s.stop<e.right)&&o.push({top:e.top,bottom:e.bottom,left:s.stop+1,right:e.right}),o;case"left":case"right":return o.push({top:s.start,bottom:s.stop,left:e.left,right:e.right}),s.start>e.top&&o.push({top:e.top,bottom:s.start-1,left:e.left,right:e.right}),(void 0===e.bottom||s.stop<e.bottom)&&o.push({top:s.stop+1,bottom:e.bottom,left:e.left,right:e.right}),o}}function ls(e,t){return"REMOVE_COLUMNS_ROWS"===t.type?Vt(e,"COL"===t.dimension?"left":"top",t.elements):"ADD_COLUMNS_ROWS"===t.type?Nt(e,"COL"===t.dimension?"left":"top",t.base,t.position,t.quantity):e}function cs(e,t){const s="DELETE_SHEET"===t.type&&t.sheetId;if("sheetId"in t&&e._sheetId!==t.sheetId)return e;{const o=ls(e._zone,t);if(o&&s!==e._sheetId)return{...e,_zone:o}}}let hs=class{content={};add(e,t){if(e in this.content)throw new Error(`${e} is already present in this registry!`);return this.replace(e,t)}replace(e,t){return this.content[e]=t,this}get(e){const t=this.content[e];if(!t&&!(e in this.content))throw new Error(`Cannot find ${e} in this registry!`);return t}contains(e){return e in this.content}getAll(){return Object.values(this.content)}getKeys(){return Object.keys(this.content)}remove(e){delete this.content[e]}};const ds=/(.*?)\((.*?)\)(.*)/,us=["ANY","BOOLEAN","DATE","NUMBER","STRING","RANGE","RANGE<BOOLEAN>","RANGE<DATE>","RANGE<NUMBER>","RANGE<STRING>","META","RANGE<META>"];function gs(e,t="",s){return function(e,t,s){const o=e.match(ds),i=o[1].trim();if(!i)throw new Error(`Function argument definition is missing a name: '${e}'.`);const n=[];let r,a=!1,l=!1;for(const e of o[2].split(",")){const t=e.trim().toUpperCase(),s=us.find(e=>t===e);s?n.push(s):"RANGE<ANY>"===t?n.push("RANGE"):"OPTIONAL"===t?a=!0:"REPEATING"===t?l=!0:t.startsWith("DEFAULT=")&&(r=e.trim().slice(8))}const c={name:i,description:t,type:n};(n.includes("ANY")||n.includes("RANGE"))&&(c.acceptErrors=!0);a&&(c.optional=!0);l&&(c.repeating=!0);void 0!==r&&(c.default=!0,c.defaultValue=r);n.some(e=>e.startsWith("RANGE"))&&(c.acceptMatrix=!0);n.every(e=>e.startsWith("RANGE"))&&(c.acceptMatrixOnly=!0);s&&s.length>0&&(c.proposalValues=s);return c}(e,t,s)}const ps={};function ms(e,t){const s=e.name,o=ps[s]?.[t];return o||(ps[s]||(ps[s]={}),ps[s][t]||(ps[s][t]=function(e,t){const s={},o=e.nbrArgRepeating?Math.floor((t-e.minArgRequired)/e.nbrArgRepeating):0,i=e.nbrArgRepeating*o,n=t-e.minArgRequired-i;let r=0,a=0;for(let t=0;t<e.args.length;t++){const i=e.args[t];if(!i.optional&&!i.default||i.repeating){if(i.repeating){const n=i.optional?0:1;for(let i=0;i<o+n;i++)for(let o=0;o<e.nbrArgRepeating;o++)s[r]={index:t+o,repeatingGroupIndex:i},r++;t+=e.nbrArgRepeating-1;continue}s[r]={index:t},r++}else a<n&&(s[r]={index:t},r++),a++}return e=>s[e]}(e,t)),ps[s][t])}const fs=["META","RANGE<META>"];const vs=e=>e,bs=()=>!1;let ys=vs,Ss=bs;function Cs(e,...t){if(1!==t.length||"object"!=typeof t[0]||t[0]instanceof String)t.length>0&&(e=e.replace(/\%s/g,()=>t.shift()));else{const s=t[0];e=e.replace(/\%\(([^\)]+)\)s/g,(e,t)=>s[t])}return e}const Is=function(e,...t){return Ss()?Cs(ys(e),...t):new ws(e,t)};class ws extends String{values;constructor(e,t){super(e),this.values=t}valueOf(){const e=super.valueOf();return Ss()?Cs(ys(e),...this.values):Cs(e,...this.values)}toString(){return this.valueOf()}}const Es={NotAvailable:"#N/A",InvalidReference:"#REF",BadExpression:"#BAD_EXPR",CircularDependency:"#CYCLE",UnknownFunction:"#NAME?",DivisionByZero:"#DIV/0!",InvalidNumber:"#NUM!",SpilledBlocked:"#SPILL!",GenericError:"#ERROR",NullError:"#NULL!"},xs=new Set(Object.values(Es));class Rs{message;value;constructor(e=Is("Error"),t=Es.GenericError){this.message=e,this.value=t,this.message=e.toString()}}class Ts extends Rs{constructor(e=Is("Invalid expression")){super(e,Es.BadExpression)}}class As extends Rs{constructor(e=Is("Circular reference")){super(e,Es.CircularDependency)}}class _s extends Rs{constructor(e=Is("Invalid reference")){super(e,Es.InvalidReference)}}class Ds extends Rs{constructor(e=Is("Data not available")){super(e,Es.NotAvailable)}}class Os extends Rs{constructor(e=Is("Unknown function")){super(e,Es.UnknownFunction)}}class Fs extends Rs{constructor(e=Is("Spill range is not empty")){super(e,Es.SpilledBlocked)}}class Ps extends Rs{constructor(e=Is("Division by zero")){super(e,Es.DivisionByZero)}}class Ms extends Rs{constructor(e=Is("Number too large")){super(e,Es.InvalidNumber)}}const Ns=["thin","medium","thick","dashed","dotted"];function ks(e){return Array.isArray(e)&&Array.isArray(e[0])}var Ls;!function(e){e.UP="up",e.DOWN="down",e.LEFT="left",e.RIGHT="right"}(Ls||(Ls={}));class Vs{jsDate;constructor(e,t,s,o=0,i=0,n=0){this.jsDate=new Date(Date.UTC(e,t,s,o,i,n,0))}static fromTimestamp(e){const t=new Date(e);return new Vs(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate(),t.getUTCHours(),t.getUTCMinutes(),t.getUTCSeconds())}static now(){const e=new Date;return new Vs(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds())}toString(){return this.jsDate.toString()}toLocaleDateString(){return this.jsDate.toLocaleDateString()}getTime(){return this.jsDate.getTime()}getFullYear(){return this.jsDate.getUTCFullYear()}getMonth(){return this.jsDate.getUTCMonth()}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(){const e=new Date(this.jsDate.getTime()),t=e.getUTCDay()||7;e.setUTCDate(e.getUTCDate()+4-t);const s=new Date(Date.UTC(e.getUTCFullYear(),0,1));return Math.ceil(((e.getTime()-s.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)}}const zs=new Vs(1899,11,30),Hs=864e5,Us=2e3,Bs=Vs.now().getFullYear(),Gs=Vs.now().getMonth(),Ws=Vs.fromTimestamp(0).getTime()-zs.getTime(),$s=/^\d{1,2}(\/|-|\s)\d{1,2}((\/|-|\s)\d{1,4})?$/,qs=/^\d{3,4}(\/|-|\s)\d{1,2}(\/|-|\s)\d{1,2}$/,Zs=qe.join(""),js=new RegExp(`/|-|${qe.join("|")}`),Ys=new RegExp(`^(\\d{1,4})[/${Zs}-](\\d{1,4})([/${Zs}-](\\d{1,4}))?$`),Xs=/((\d+(:\d+)?(:\d+)?\s*(AM|PM))|(\d+:\d+(:\d+)?))$/;function Ks(e,t){switch(typeof e){case"number":return e;case"string":return Js(e,t)?eo(e,t)?.value:!e||isNaN(Number(e))?void 0:Number(e);default:return}}function Js(e,t){return null!==eo(e,t)}const Qs=new Map;function eo(e,t){return Qs.has(t)||Qs.set(t,new Map),Qs.get(t).has(e)||Qs.get(t).set(e,function(e,t){e=e.trim();let s=null;const o=e.match(Xs);if(o){if(s=function(e){if(e=e.trim(),Xs.test(e)){const t=/AM/i.test(e),s=/PM/i.test(e),o=(t||s?e.substring(0,e.length-2).trim():e).split(/:/),i=o.length>=2,n=3===o.length;let r=Number(o[0]),a=i?Number(o[1]):0,l=n?Number(o[2]):0,c=n?"hh:mm:ss":"hh:mm";if(t||s)c+=" a";else if(!i)return null;r>=12&&t?r-=12:r<12&&s&&(r+=12),a+=Math.floor(l/60),l%=60,r+=Math.floor(a/60),a%=60,r>=24&&(c="hhhh:mm:ss");return{value:r/24+a/1440+l/86400,format:c,jsDate:new Vs(1899,11,30,r,a,l)}}return null}(o[0]),null===s)return null;e=e.replace(o[0],"").trim()}let i=null;const n=function(e,t){const s=e.match(Ys);if(!s)return null;const[,o,i,,n]=s;if(o.length>2&&n&&n.length>2)return null;if(o.length>2)return{year:o,month:i,day:n,dateString:e,type:"ymd"};const r=function(e){switch(e.dateFormat[0]){case"d":return"dmy";case"m":return"mdy";case"y":return"ymd"}throw new Error("Invalid date format in locale")}(t);if(!n)return i.length>2?{month:o,year:i,day:void 0,dateString:e,type:r}:"dmy"===r?{day:o,month:i,year:n,dateString:e,type:"dmy"}:{month:o,day:i,year:n,dateString:e,type:"mdy"};if(n.length>2)return"mdy"===r?{month:o,day:i,year:n,dateString:e,type:"mdy"}:{day:o,month:i,year:n,dateString:e,type:"dmy"};if("mdy"===r)return{month:o,day:i,year:n,dateString:e,type:"mdy"};if("ymd"===r)return{year:o,month:i,day:n,dateString:e,type:"ymd"};if("dmy"===r)return{day:o,month:i,year:n,dateString:e,type:"dmy"};return null}(e,t);if(n){const t=n.dateString.match(js)[0];if(i=function(e,t){const{year:s,month:o,day:i}=e,n=function(e){if(!e)return Gs;const t=Number(e);if(t>=1&&t<=12)return t-1;return null}(o),r=function(e){if(!e)return 1;const t=Number(e);if(t>=0&&t<=31)return t;return null}(i),a=function(e){if(!e)return Bs;const t=Number(e);switch(e.length){case 1:return Us+t;case 2:return Us+(Us+t>Bs+10?-100:0)+t;case 3:case 4:return t}return null}(s);if(null===a||null===n||null===r)return null;const l=2===o?.length&&n+1<10||2===i?.length&&r<10,c=2!==s?.length,h=new Vs(a,n,r);if(h.getMonth()!==n||h.getDate()!==r)return null;const d=h.getTime()-zs.getTime(),u=function(e,t,s,o){const i=e.year?o?"yyyy":"yy":void 0,n=e.month?s?"mm":"m":void 0,r=e.day?s?"dd":"d":void 0;switch(e.type){case"mdy":return[n,r,i].filter(Oe).join(t);case"ymd":return[i,n,r].filter(Oe).join(t);case"dmy":return[r,n,i].filter(Oe).join(t)}}(e,t,l,c);return{value:Math.round(d/Hs),format:u,jsDate:h}}(n,t),null===i)return null;e=e.replace(n.dateString,"").trim()}if(""!==e||!i&&!s)return null;if(i&&i.jsDate&&s&&s.jsDate)return{value:i.value+s.value,format:i.format+" "+("hhhh:mm:ss"===s.format?"hh:mm:ss":s.format),jsDate:new Vs(i.jsDate.getFullYear()+s.jsDate.getFullYear()-1899,i.jsDate.getMonth()+s.jsDate.getMonth()-11,i.jsDate.getDate()+s.jsDate.getDate()-30,i.jsDate.getHours()+s.jsDate.getHours(),i.jsDate.getMinutes()+s.jsDate.getMinutes(),i.jsDate.getSeconds()+s.jsDate.getSeconds())};return i||s}(e,t)),Qs.get(t).get(e)}function to(e){const t=Math.trunc(e),s=Vs.fromTimestamp(t*Hs-Ws);let o=e-t;o=o<0?1+o:o;const i=Math.round(24*o),n=Math.round(24*(o-i/24)*60),r=Math.round(24*(o-i/24-n/24/60)*60*60);return s.setHours(i),s.setMinutes(n),s.setSeconds(r),s}function so(e){return Math.round(oo(e))}function oo(e){return(e.getTime()-zs.getTime())/Hs}function io(e){return new Vs(e.getFullYear(),e.getMonth()+1,0).getDate()}function no(e){return io(e)===e.getDate()}function ro(e,t,s){const o=e.getFullYear(),i=e.getMonth(),n=e.getDate(),r=new Vs(o,i+t,1);return s&&n===io(e)||n>io(r)?r.setDate(io(r)):r.setDate(n),r}function ao(e){const t=Math.trunc(e);return t%4==0&&t%100!=0||t%400==0}function lo(e,t,s){if(e===t)return 0;if(e>t){const s=t;t=e,e=s}const o=to(e),i=to(t);let n=o.getDate(),r=i.getDate();const a=o.getMonth(),l=i.getMonth(),c=o.getFullYear(),h=i.getFullYear();let d=0,u=0;switch(s){case 0:31===n&&(n=30),30===n&&31===r&&(r=30),1===a&&n===(ao(c)?29:28)&&(n=30,1===l&&r===(ao(h)?29:28)&&(r=30)),d=c+(30*a+n)/360,u=h+(30*l+r)/360;break;case 1:let s=365;const o=c===h;if(!o&&!(c+1===h)||!o&&a<l||!o&&a===l&&n<r){let e=0,t=0;for(let s=c;s<=h;s++)e++,t+=ao(s)?366:365;s=t/e}else o?ao(c)&&(s=366):(ao(c)&&a<2&&(s=366),ao(h)&&(l>1||1===l&&29===r)&&(s=366));d=e/s,u=t/s;break;case 2:d=e/360,u=t/360;break;case 3:d=e/365,u=t/365;break;case 4:31===n&&(n=30),31===r&&(r=30),d=c+(30*a+n)/360,u=h+(30*l+r)/360}return u-d}function co(e,t){const s=12*(t.getFullYear()-e.getFullYear())+t.getMonth()-e.getMonth();return e.getDate()>t.getDate()?s-1:s}function ho(e,t){const s=e.getTime(),o=t.getTime();return Math.floor((o-s)/Hs)}function uo(e,t){const s=t.getFullYear()-e.getFullYear(),o=e.getMonth(),i=t.getMonth(),n=e.getDate(),r=t.getDate();return i>o||i===o&&r>=n?s:s-1}function go(e,t,s){return t>s?go(e,s,t):(e=Math.trunc(e),t=Math.trunc(t),s=Math.trunc(s),e>=t&&e<=s)}const po=Ye(function(e){return e=he(e),new RegExp(`(?:^-?\\d+(?:${e}?\\d*(?:(E|e)(\\+|-)?\\d+)?)?|^-?${e}\\d+)(?!\\w|!)`)}),mo=Ye(function(e){const t=he(e.decimalSeparator),s="(?:\\s*"+`(?:\\d+(?:${he(e.thousandsSeparator||"")}\\d{3,})*(?:${t}\\d*)?)`+"|"+`(?:${t}\\d+)`+")(?:(e|E)(?:\\+|-)?(?:[0-9]|[0-9][0-9]|[12][0-9]{2}|30[0-7]))?(?:\\s*%)?",o="(?:\\s*-)?",i="(?:\\s*[\\$€])?",n="^(?:(?:"+[o+i+s,o+s+i,i+o+s].join(")|(?:")+"))$";return new RegExp(n,"i")});function fo(e,t){return!!e&&mo(t).test(e.trim())}const vo=Ye(function(e){return new RegExp(`[$€${he(e.thousandsSeparator||"")}]`,"g")});function bo(e,t){e=e.replace(vo(t),""),"."!==t.decimalSeparator&&(e=e.replace(t.decimalSeparator,"."));let s=Number(e);return isNaN(s)&&e.includes("%")&&(s=Number(e.split("%")[0]),!isNaN(s))?s/100:s}function yo(e,t,s){const o=[...e].sort((e,t)=>e-t);let i=(o.length+(s?-1:1))*t;if(s||i--,Number.isInteger(i))return o[i];const n=Math.ceil(i),r=Math.floor(i);return o[n]*(i-r)+o[r]*(n-i)}const So=["number","string","boolean","undefined"];function Co(e){if(void 0!==e)return ks(e)?e[0][0]?.format:e.format}function Io(e){return"string"==typeof e&&xs.has(e)}function wo(e){return{value:Es.NotAvailable,message:Is("Did not find value '%s' in [[FUNCTION_NAME]] evaluation.",Oo(e))}}const Eo=e=>Is("The function [[FUNCTION_NAME]] expects a number value, but '%s' is a string, and cannot be coerced to a number.",e);function xo(e,t){const s=ko(e);switch(typeof s){case"number":return s;case"boolean":return s?1:0;case"string":if(fo(s,t)||""===s)return bo(s,t);const e=eo(s,t);if(e)return e.value;throw new Rs(Eo(s));default:return 0}}function Ro(e,t){try{return xo(e,t)}catch(e){return}}function To(e,t){return oi(e).map(e=>e.map(e=>{if("number"!=typeof e.value){let s="";throw"object"==typeof e?s=Is("Function [[FUNCTION_NAME]] expects number values for %s, but got an empty value.",t):"string"==typeof e?s=Is("Function [[FUNCTION_NAME]] expects number values for %s, but got a string.",t):"boolean"==typeof e&&(s=Is("Function [[FUNCTION_NAME]] expects number values for %s, but got a boolean.",t)),new Rs(s)}return e.value}))}function Ao(e,t){const s=ko(e);if(""===s)throw new Rs(Eo(s));return xo(s,t)}function _o(e,t){return Math.trunc(xo(e,t))}function Do(e,t){return Math.trunc(Ao(e,t))}function Oo(e){const t=ko(e);switch(typeof t){case"string":return t;case"number":return t.toString();case"boolean":return t?"TRUE":"FALSE";default:return""}}const Fo=Ye(function(e){return e.toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g,"")}),Po=e=>Is("The function [[FUNCTION_NAME]] expects a boolean value, but '%s' is a text, and cannot be coerced to a boolean.",e);function Mo(e){const t=ko(e);switch(typeof t){case"boolean":return t;case"string":if(t){const e=t.toUpperCase();if("TRUE"===e)return!0;if("FALSE"===e)return!1;throw new Rs(Po(t))}return!1;case"number":return!!t;default:return!1}}function No(e,t){return to(xo(ko(e),t))}function ko(e){if("object"==typeof e&&null!==e&&"value"in e){if(Io(e.value))throw e;return e.value}if(Io(e))throw new Rs("",e);return e}function Lo(e,t,s){for(const o of e)if(ks(o)){const e=o.length,s=o[0].length;for(let i=0;i<s;i++)for(let s=0;s<e;s++)t(o[s][i])}else s(o)}function Vo(e,t){Lo(e,e=>{if(Io(e.value))throw e;t(e)},e=>{if(Io(e?.value))throw e;t(e)})}function zo(e,t,s){Lo(e,e=>{if("number"==typeof e?.value&&t(e),Io(e?.value))throw e},e=>{t({value:Ao(e,s),format:e?.format})})}function Ho(e,t,s,o,i="rowFirst"){let n=o;for(const o of e)if(ks(o)){const e=o.length,s=o[0].length;if("rowFirst"===i)for(let i=0;i<s;i++)for(let s=0;s<e;s++)n=t(n,o[s][i]);else for(let i=0;i<e;i++)for(let e=0;e<s;e++)n=t(n,o[i][e])}else n=s(n,o);return n}function Uo(e,t,s,o="rowFirst"){return Ho(e,t,t,s,o)}function Bo(e,t,s,o){return Ho(e,(e,s)=>{const o=s?.value;if("number"==typeof o)return t(e,o);if(Io(o))throw s;return e},(e,s)=>t(e,Ao(s,o)),s)}function Go(e,t,s,o){return Ho(e,(e,s)=>{const i=s?.value;if(null!=i){if("number"==typeof i)return t(e,i);if("boolean"==typeof i)return t(e,xo(i,o));if(Io(i))throw s;return t(e,0)}return e},(e,s)=>t(e,xo(s,o)),s)}function Wo(e,t,s){const o=Array(e);for(let i=0;i<e;i++){o[i]=Array(t);for(let e=0;e<t;e++)o[i][e]=s(i,e)}return o}function $o(e,t){return 0===e.length?[]:Wo(e.length,e[0].length,(s,o)=>t(e[s][o]))}function qo(e){return e.length?Wo(e[0].length,e.length,(t,s)=>e[s][t]):[]}function Zo(e,t,s=void 0){let o,i=1,n=1,r=1/0,a=1/0;for(let e=0;e<t.length;e++){const l=t[e];if(ks(l)&&(void 0===s||s[e])){const s=l.length,c=l[0].length;1!==s||1!==c?(o??=new Array(t.length),1!==s&&1!==c?(o[e]="matrix",i=Math.max(i,s),n=Math.max(n,c),r=Math.min(r,s),a=Math.min(a,c)):1!==s?(o[e]="horizontal",i=Math.max(i,s),r=Math.min(r,s)):1!==c&&(o[e]="vertical",n=Math.max(n,c),a=Math.min(a,c))):t[e]=l[0][0]}}if(1===i&&1===n)return e(...t);return Wo(i,n,(s,i)=>{if(s>r-1||i>a-1)return new Ds(Is("Array arguments to [[FUNCTION_NAME]] are of different size."));const n=e(...(l=s,c=i,t.map((e,t)=>{switch(o?.[t]){case"matrix":return e[l][c];case"horizontal":return e[l][0];case"vertical":return e[0][c];case void 0:return e}})));var l,c;return ks(n)?n[0][0]:n})}function jo(e,t){return function(e,t,s){for(const o of e)if(ks(o)){const e=o.length,s=o[0].length;for(let i=0;i<s;i++)for(let s=0;s<e;s++)if(!t(o[s][i]??void 0))return}else if(!s(o))return}(e,e=>{const s=e?.value;if("boolean"==typeof s)return t(s);if("number"==typeof s)return t(!!s);if(Io(s))throw e;return!0},e=>void 0===e||null===e.value||t(function(e){const t=ko(e);if(""===t)throw new Rs(Po(t));return Mo(t)}(e)))}function Yo(e,t){let s,o,i=e.substring(0,2);return"<="===i||">="===i||"<>"===i?(s=i,o=e.substring(2)):(i=e.substring(0,1),"<"===i||">"===i||"="===i?(s=i,o=e.substring(1)):(s="=",o=e)),fo(o,t)||Js(o,t)?o=xo(o,t):"TRUE"!==o&&"FALSE"!==o||(o=Mo(o)),{operator:s,operand:o}}const Xo=Ye(function(e){if("*"===e)return/.+/;let t="",s="";for(const o of e)"?"===o&&"~"!==s?t+=".":"*"===o&&"~"!==s?t+=".*":("*"!==o&&"?"!==o||(t=t.slice(0,-1)),["^",".","[","]","$","(",")","*","+","?","|","{","}","\\"].includes(o)&&(t+="\\"),t+=o),s=o;return new RegExp("^"+t+"$","i")});function Ko(e="",t,s){const{operator:o,operand:i}=t;if(void 0===i||null===e||null===i)return!1;if("number"==typeof i&&"="===o)return"string"==typeof e&&(fo(e,s)||Js(e,s))?xo(e,s)===i:e===i;if("<>"===o||"="===o){let t;return t=typeof e==typeof i&&(""===e&&""===i||("string"==typeof e&&"string"==typeof i?Xo(i).test(e):e===i)),"="===o?t:!t}if(typeof e==typeof i)switch(o){case"<":return e<i;case">":return e>i;case"<=":return e<=i;case">=":return e>=i}return!1}function Jo(e,t,s,o=!1){const i=e.length;if(i%2==1)throw new Rs(Is("Function [[FUNCTION_NAME]] expects criteria_range and criterion to be in pairs."));const n=oi(e[0]),r=n.length,a=n[0].length,l=[];for(let t=0;t<i-1;t+=2){const i=oi(e[t]);if(i.length!==r||i[0].length!==a)throw new Rs(Is("Function [[FUNCTION_NAME]] expects criteria_range to have the same dimension"));const n=Yo(Oo(e[t+1]),s);o&&"string"==typeof n.operand&&(n.operand+="*"),l.push(n)}for(let o=0;o<r;o++)for(let n=0;n<a;n++){let r=!0;for(let t=0;t<i-1;t+=2){if(r=Ko(oi(e[t])[o][n].value??void 0,l[t/2],s),!r)break}r&&t(o,n)}}function Qo(e,t,s,o,i,n){if(void 0===t||null===t.value)return-1;if(Io(t.value))throw t;const r=ti(t.value),a=typeof r;let l,c,h,d,u,g,p=0,m=i-1;const f="desc"===o?t=>ti(n(e,i-t-1)):t=>ti(n(e,t));for(;m-p>=0;){for(h=Math.floor((p+m)/2),d=h,u=f(d),g=typeof u;p<d&&a!==g;)d--,u=f(d),g=typeof u;g===a&&null!=u?("strict"===s&&u===r?(l=u,c=d):"nextSmaller"===s&&u<=r?(null==l||l<u||l===u&&c<d)&&(l=u,c=d):"nextGreater"===s&&u>=r&&(void 0===l||l>u||l===u&&c<d)&&(l=u,c=d),u>r||"strict"===s&&u===r?m=d-1:p=h+1):p=h+1}return void 0===c?-1:"desc"===o?i-c-1:c}function ei(e,t,s,o,i,n,r=!1){if(void 0===t||null===t.value)return-1;if(Io(t.value))throw t;const a=ti(t.value),l=r?(e,t)=>ti(i(e,o-t-1)):(e,t)=>ti(i(e,t)),c="wildcard"!==s||"string"!=typeof a||!(a.includes("*")||a.includes("?"));if(n&&c){const t=r?"reverseSearch":"forwardSearch";let i=n[t].get(e);if(void 0===i){i=new Map;for(let t=0;t<o;t++){const s=l(e,t)??null;i.has(s)||i.set(s,t)}n[t].set(e,i)}if(i.has(a)){const e=i.get(a);return r?o-e-1:e}if("strict"===s)return-1}const h=function(e,t,s,o,i){let n=s=>i(e,s)===t;if("wildcard"===s&&"string"==typeof t&&(t.includes("*")||t.includes("?"))){const s=Xo(t);n=t=>{const o=i(e,t);return"string"==typeof o&&s.test(o)}}let r,a=-1;"nextSmaller"===s&&(n=s=>{const o=i(e,s);return(!r&&si(t,o)>=0||si(t,o)>=0&&si(o,r)>0)&&(r=o,a=s),o===t});"nextGreater"===s&&(n=s=>{const o=i(e,s);return(!r&&si(t,o)<=0||si(t,o)<=0&&si(o,r)<0)&&(r=o,a=s),o===t});for(let e=0;e<o;e++)if(n(e))return e;return a}(e,a,s,o,l);return r&&-1!==h?o-h-1:h}function ti(e){return"string"==typeof e?Fo(e):e}function si(e,t){let s=So.indexOf(typeof e)-So.indexOf(typeof t);return 0===s&&("string"==typeof e&&"string"==typeof t?s=e.localeCompare(t):"number"==typeof e&&"number"==typeof t?s=e-t:"boolean"==typeof e&&"boolean"==typeof t&&(s=Number(e)-Number(t))),s}function oi(e){return void 0===e?[[]]:ks(e)?e:[[e]]}function ii(e,t){return Uo(e,(e,s)=>(e.push(t(s)),e),[],"rowFirst")}function ni(e){if(void 0===e)return!1;const{value:t}=e;return null!==t&&""!==t}const ri=Is("[[FUNCTION_NAME]] has no valid input data.");function ai(e){return Is("[[FUNCTION_NAME]] expects the provided values of %(argName)s to be a non-empty matrix.",{argName:e})}function li(e){function t(...t){for(let s=0;s<t.length;s++){const o=t[s],i=ms(e,t.length);if(!e.args[i(s).index??s].acceptErrors&&!ks(o)&&Io(o?.value))return o}try{return s.apply(this,t)}catch(t){return ci(t,e.name)}}function s(...t){this.debug;const s=e.compute.apply(this,t);return ks(s)?"object"==typeof s[0][0]&&null!==s[0][0]&&"value"in s[0][0]?s:$o(s,e=>({value:e})):"object"==typeof s&&null!==s&&"value"in s?s:(e.name,{value:s})}return function(...s){const o=[],i=ms(e,s.length);for(let t=0;t<s.length;t++){const n=i(t).index??-1,r=e.args[n];if(!ks(s[t])&&r.acceptMatrixOnly)throw new Ts(Is("Function %s expects the parameter '%s' to be reference to a cell or range.",e.name,(t+1).toString()));o.push(!r.acceptMatrix)}return function(t){ks(t)?function(e,t){const s=e.length,o=e[0]?.length??0;for(let i=0;i<s;i++)for(let s=0;s<o;s++)t(e[i][s])}(t,t=>hi(t,e.name)):hi(t,e.name);return t}(Zo(t.bind(this),s,o))}}function ci(e,t){return s=e,void 0!==s?.value&&"string"==typeof s.value&&Io(e.value)?(ui(e)&&hi(e,t),e):(console.error(e),new Rs(di+(ui(e)?" "+e.message:"")));var s}function hi(e,t){e.message?.includes("[[FUNCTION_NAME]]")&&(e.message=e.message.replace("[[FUNCTION_NAME]]",t))}const di=Is("An unexpected error occurred. Submit a support ticket at odoo.com/help.");function ui(e){return void 0!==e?.message&&"string"==typeof e.message}const gi=[{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:";"}],pi=gi[0];function mi(e){const t=new it(e),s=[];let o=[];for(s.push(o);!t.isOver();){if(";"===t.current){o=[],s.push(o),t.shift();continue}const e=Ei(t)||fi(t)||bi(t)||yi(t)||Ci(t)||Ii(t)||wi(t)||Ri(t)||Si(t)||Ti(t);if(!e)throw new Error("Unknown token at "+t.remaining());o.push(e)}return s}function fi(e){let t;if('"'===e.current?(e.shift(),t='"'):e.currentStartsWith("[$")&&(e.advanceBy(2),t="]"),!t)return null;let s="";for(;e.current&&e.current!==t;)s+=e.shift();if(e.current!==t)throw new Error("Unterminated string in format");return e.shift(),{type:"STRING",value:s}}const vi=new Set("$+-/():!^&~{}<>= ");function bi(e){if("\\"===e.current){e.shift();const t=e.shift();if(!t)throw new Error("Unexpected end of format string");return{type:"CHAR",value:t}}return vi.has(e.current)?{type:"CHAR",value:e.shift()}:null}function yi(e){return","===e.current?(e.shift(),{type:"THOUSANDS_SEPARATOR",value:","}):null}function Si(e){return"@"===e.current?(e.shift(),{type:"TEXT_PLACEHOLDER",value:"@"}):null}function Ci(e){return"."===e.current?(e.shift(),{type:"DECIMAL_POINT",value:"."}):null}function Ii(e){return"%"===e.current?(e.shift(),{type:"PERCENT",value:"%"}):null}function wi(e){return"e"===e.current?(e.shift(),{type:"SCIENTIFIC",value:"e"}):null}function Ei(e){if("0"===e.current||"#"===e.current){const t=e.current;return e.shift(),{type:"DIGIT",value:t}}return null}const xi=new Set("dmqyhsa");function Ri(e){if(!xi.has(e.current))return null;const t=e.current;let s="";for(;e.current===t;)s+=e.shift();return{type:"DATE_PART",value:s}}function Ti(e){if("*"!==e.current)return null;e.shift();const t=e.shift();if(!t)throw new Error("Unexpected end of format string");return{type:"REPEATED_CHAR",value:t}}const Ai={};function _i(e){let t=Ai[e];return void 0===t&&(t=function(e){const t=mi(e);for(const e of t){const t=e.filter(e=>"REPEATED_CHAR"===e.type);for(const e of t.slice(1))e.type="CHAR"}const s=Oi(t[0])||Di(t[0])||Fi(t[0]);if(!s)throw new Error("Invalid first format part of: "+e);if(t.length>1&&"text"===s.type)throw new Error("The first format in a multi-part format must be a number format: "+e);const o=Oi(t[1])||Di(t[1]);if(t[1]?.length&&!o)throw new Error("Invalid second format part of: "+e);const i=Oi(t[2])||Di(t[2]);if(t[2]?.length&&!i)throw new Error("Invalid third format part of: "+e);const n=Fi(t[3]);if(t[3]?.length&&!n)throw new Error("Invalid fourth format part of: "+e);return{positive:s,negative:o,zero:i,text:n}}(e),Ai[e]=t),t}function Di(e){if(!e||!function(e){return e.every(e=>"DIGIT"===e.type||"DECIMAL_POINT"===e.type||"THOUSANDS_SEPARATOR"===e.type||"PERCENT"===e.type||"SCIENTIFIC"===e.type||"STRING"===e.type||"CHAR"===e.type||"REPEATED_CHAR"===e.type)}(e))return;const t=[];let s,o=t,i=0,n=!1,r=0,a=e.findLastIndex(e=>"DIGIT"===e.type),l=!1,c=0;for(let h=0;h<e.length;h++){const d=e[h];switch(d.type){case"DIGIT":o===t?o.push(d):c<20&&(o.push(d),c++);break;case"DECIMAL_POINT":if(o!==t)throw new Error("Multiple decimal points in a number format");s=[],o=s;break;case"SCIENTIFIC":n=!0;break;case"REPEATED_CHAR":case"CHAR":case"STRING":o.push(d);break;case"PERCENT":i++,o.push(d);break;case"THOUSANDS_SEPARATOR":h-1===a?(r+=1,a++,o.push(d)):"DIGIT"===e[h+1]?.type&&"DIGIT"===e[h-1]?.type?(o===t&&(l=!0),o.push(d)):o.push({type:"CHAR",value:","})}}return{type:"number",integerPart:t,decimalPart:s,percentSymbols:i,scientific:n,thousandsSeparator:l,magnitude:r}}function Oi(e){const t=e&&function(e){return e.every(e=>"DATE_PART"===e.type||"DECIMAL_POINT"===e.type||"THOUSANDS_SEPARATOR"===e.type||"STRING"===e.type||"CHAR"===e.type||"REPEATED_CHAR"===e.type)}(e)?{type:"date",tokens:e}:void 0;if(!t||!e?.some(e=>"DATE_PART"===e.type))return;if(t.tokens.length&&t.tokens.every(e=>"DATE_PART"===e.type&&"a"===e.value))throw new Error("Invalid date format");const s=function(e){const t=e.filter(e=>"DATE_PART"===e.type);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}(t.tokens.map(e=>"THOUSANDS_SEPARATOR"===e.type||"DECIMAL_POINT"===e.type?{type:"CHAR",value:e.value}:e));return{type:"date",tokens:s}}function Fi(e){return e&&function(e){return e.every(e=>"STRING"===e.type||"TEXT_PLACEHOLDER"===e.type||"CHAR"===e.type||"REPEATED_CHAR"===e.type)}(e)?{type:"text",tokens:e}:void 0}function Pi(e){return[Mi(e.positive),Mi(e.negative),Mi(e.zero),Mi(e.text)].filter(Oe).join(";")}function Mi(e){if(!e)return;let t="";const s="number"!==e.type?e.tokens:function(e){const t=[...e.integerPart];e.decimalPart&&(t.push({type:"DECIMAL_POINT",value:"."}),t.push(...e.decimalPart));e.scientific&&t.push({type:"SCIENTIFIC",value:"e"});return t}(e);for(const e of s)switch(e.type){case"STRING":t+=`[$${e.value}]`;break;case"CHAR":t+=Ni(e.value)?`\\${e.value}`:e.value;break;case"REPEATED_CHAR":t+="*"+e.value;break;case"DATE_PART":t+="MM"===e.value?"mm":e.value;break;default:t+=e.value}return t}function Ni(e){return!vi.has(e)}const ki="REPEATED_CHAR_PLACEHOLDER_",Li={0:Is("January"),1:Is("February"),2:Is("March"),3:Is("April"),4:Is("May"),5:Is("June"),6:Is("July"),7:Is("August"),8:Is("September"),9:Is("October"),10:Is("November"),11:Is("December")},Vi={0:Is("Sunday"),1:Is("Monday"),2:Is("Tuesday"),3:Is("Wednesday"),4:Is("Thursday"),5:Is("Friday"),6:Is("Saturday")};function zi(e,t,s,o=!1){return o?an({value:e,format:t},s):Hi(e,{format:t,locale:s})}function Hi(e,{format:t,locale:s,formatWidth:o}){switch("boolean"==typeof e&&(e=e?"TRUE":"FALSE"),typeof e){case"string":{if(e.includes('\\"')&&(e=e.replaceAll(/\\"/g,'"')),!t)return e;const s=Ui(e,_i(t)).format;return s&&"text"===s.type?Bi(e,s,o):e}case"number":t||(t=Ji(e));const i=_i(t),{format:n,isNegativeFormat:r}=Ui(e,i);if(!n)return e.toString();if("text"===n.type)return Bi(e.toString(),n,o);if(r&&(e=Math.abs(e)),"date"===n.type)return Gi(function(e,t){const s=to(e),o=t.tokens.some(e=>"DATE_PART"===e.type&&"a"===e.value);let i="";for(const e of t.tokens)switch(e.type){case"DATE_PART":i+=Xi(s,e.value,o);break;case"REPEATED_CHAR":i+=ki+e.value;break;default:i+=e.value}return i}(e,n),o);const a=e<0,l=Gi(function(e,t,s){if(!t.integerPart.length&&!t.decimalPart?.length)return"";if(e===1/0)return"∞"+(t.percentSymbols?"%":"");let o=Math.floor(Math.log10(Math.abs(e)));o===-1/0&&(o=0);t.scientific&&(e/=10**o);const i=2*t.percentSymbols-3*t.magnitude;e*=10**i;let n=0;void 0!==t.decimalPart&&(n=t.decimalPart.filter(e=>"DIGIT"===e.type).length);const{integerDigits:r,decimalDigits:a}=$i(Math.abs(e),n);let l=function(e,t,s){let o=t.integerPart;o.some(e=>"DIGIT"===e.type)||(o=[...o,{type:"DIGIT",value:"#"}]);"0"===e&&(e="");let i="";const n=o.findIndex(e=>"DIGIT"===e.type);let r=e.length-1;function a(t,o){if("0"===o&&(t=t||"0"),!t)return;const n=e.length-1-r;i=s&&n>0&&n%3==0?t+s+i:t+i}for(let t=o.length-1;t>=0;t--){const s=o[t];switch(s.type){case"DIGIT":if(a(e[r],s.value),r--,n===t)for(;r>=0;)a(e[r],"0"),r--;break;case"THOUSANDS_SEPARATOR":break;case"REPEATED_CHAR":i=ki+s.value+i;break;default:i=s.value+i}}return i}(r,t,t.thousandsSeparator?s.thousandsSeparator:void 0);void 0!==t.decimalPart&&(l+=s.decimalSeparator+function(e,t){if(!t.decimalPart)return"";let s="",o=0;for(const i of t.decimalPart)switch(i.type){case"DIGIT":s+="#"===i.value?e[o]||"":e[o]||"0",o++;break;case"THOUSANDS_SEPARATOR":break;case"REPEATED_CHAR":s+=ki+i.value;break;default:s+=i.value}return s}(a||"",t));if(t.scientific){l+="e"+(o>=0?"+":"-")+Math.abs(o).toString().padStart(2,"0")}return l}(Math.abs(e),n,s),o);return a?"-"+l:l;case"object":return""}}function Ui(e,t){let s,o=!1;switch(typeof e){case"number":e<0&&t.negative?(s=t.negative,o=!0):s=0===e&&t.zero?t.zero:t.positive;break;case"string":const i=t.text||t.positive;"text"===i.type&&(s=i)}return{format:s,isNegativeFormat:o}}function Bi(e,t,s){let o="";for(const s of t.tokens)switch(s.type){case"TEXT_PLACEHOLDER":o+=e;break;case"CHAR":case"STRING":o+=s.value;break;case"REPEATED_CHAR":o+=ki+s.value}return Gi(o,s)}function Gi(e,t){const s=e.indexOf(ki);if(-1===s)return e;const o=e.slice(0,s),i=e.slice(s+26+1),n=e[s+26];const{timesToRepeat:r,padding:a}=function(){if(!t)return{timesToRepeat:0,padding:""};const e=t.measureText(o+i),s=t.measureText(n),r=t.availableWidth-e;if(r<=0)return{timesToRepeat:0,padding:""};const a=Math.floor(r/s),l=r-a*s,c=t.measureText(" ");return{timesToRepeat:a,padding:" ".repeat(Math.floor(l/c))}}();return o+n.repeat(r)+a+i}const Wi=[];function $i(e,t=20){const s=e.toString();if(s.includes("e"))return function(e,t=20){let s=Wi[t];s||(s=new Intl.NumberFormat("en-US",{maximumFractionDigits:t,useGrouping:!1}),Wi[t]=s);const[o,i]=s.format(e).split(".");return{integerDigits:o,decimalDigits:i}}(e,t);if(Number.isInteger(e))return{integerDigits:s,decimalDigits:void 0};const o=s.indexOf(".");let i=s.substring(0,o),n=s.substring(o+1);if(0===t)return Number(n[0])>=5&&(i=(Number(i)+1).toString()),{integerDigits:i,decimalDigits:void 0};if(n.length>t){const{integerDigits:e,decimalDigits:s}=function(e,t){let s="0",o=e;const i=e.slice(0,t),n=t;if(Number(e[n])<5)return{integerDigits:s,decimalDigits:i};const r=i.match(Zi)?.[0]||"",a=(Number(i)+1).toString(),l=i.slice(r.length),c=a.length>l.length;c&&!r?(s="1",o=void 0):o=c?r.slice(0,-1)+a:r+a;return{integerDigits:s,decimalDigits:o}}(n,t);n=s,"0"!==e&&(i=(Number(i)+Number(e)).toString())}return{integerDigits:i,decimalDigits:qi(n||"")}}function qi(e){let t=e.length-1;for(;t>=0&&"0"===e[t];)t--;return e.slice(0,t+1)||void 0}const Zi=/^0+/;function ji(e,t){const{integerDigits:s,decimalDigits:o}=$i(e,20);return o?s+t+o:s}const Yi=Ye(function(e){if(!e)return!1;try{return"date"===_i(e).positive.type}catch(e){return!1}});function Xi(e,t,s){switch(t){case"d":return e.getDate();case"dd":return e.getDate().toString().padStart(2,"0");case"ddd":return Vi[e.getDay()].slice(0,3);case"dddd":return Vi[e.getDay()].toString();case"m":return e.getMonth()+1;case"mm":return String(e.getMonth()+1).padStart(2,"0");case"mmm":return Li[e.getMonth()].slice(0,3);case"mmmm":return Li[e.getMonth()].toString();case"mmmmm":return Li[e.getMonth()].slice(0,1);case"qq":return Is("Q%(quarter)s",{quarter:e.getQuarter()}).toString();case"qqqq":return Is("Quarter %(quarter)s",{quarter:e.getQuarter()}).toString();case"yy":const o=String(e.getFullYear()).replace("-","").padStart(2,"0");return o.slice(o.length-2);case"yyyy":return e.getFullYear();case"hhhh":return Math.floor((e.getTime()-zs.getTime())/36e5).toString();case"hh":let i=e.getHours();return s&&(i=0===i?12:i>12?i