@odoo/o-spreadsheet 17.0.73 → 17.0.74

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- !function(e,t){"use strict";const o=e=>e,s=()=>!1;let n=o,i=s;function r(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 o=t[0];e=e.replace(/\%\(([^\)]+)\)s/g,((e,t)=>o[t]))}return e}const a=function(e,...t){return i()?r(n(e),...t):new l(e,t)};class l extends String{values;constructor(e,t){super(e),this.values=t}valueOf(){const e=super.valueOf();return i()?r(n(e),...this.values):r(e,...this.values)}toString(){return this.valueOf()}}var c,h;!function(e){e.NotAvailable="#N/A",e.InvalidReference="#REF",e.BadExpression="#BAD_EXPR",e.CircularDependency="#CYCLE",e.UnknownFunction="#NAME?",e.GenericError="#ERROR"}(c||(c={})),function(e){e[e.silent=0]="silent",e[e.error=1]="error"}(h||(h={}));class d extends Error{errorType;logLevel;constructor(e,t,o=h.error){super(t),this.errorType=e,this.logLevel=o}get isVerbose(){return this.logLevel>h.silent}}class u extends d{constructor(e){super(c.BadExpression,e)}}class g extends d{constructor(){super(c.CircularDependency,a("Circular reference"))}}class p extends d{constructor(){super(c.InvalidReference,a("Invalid reference"))}}class m extends d{constructor(e=void 0){super(c.NotAvailable,e||a("Data not available"),e?h.error:h.silent)}}class f extends d{constructor(e){super(c.UnknownFunction,a('Unknown function: "%s"',e))}}const b=.5,v="#f5f5f5",S="#F8F9FA",C="#E8EAED",E="#595959",y="#666666",w="#c9ccd2",x="#3266ca",I="#FFFFFF",R="#EBEBEB",T="#CACACA",A=11982760,O="#01666b",_="#188038",M="#E6F4EA",N="#CEEAD6",F="#E0E2E4",D="#4A4F59",L="#999",P="#E2E3E3",V="#BCBCBC",k="#9B359B",U=["#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"],B=26,H=48,z=96,G=23,$=15,W=18,q=14,Z=4,Y=3,j=Z,X=21,K=17,Q=2*G,J=250,ee={align:"left",verticalAlign:"bottom",wrapping:"overflow",bold:!1,italic:!1,strikethrough:!1,underline:!1,fontSize:10,fillColor:"",textColor:""},te=ee.verticalAlign,oe=ee.wrapping,se="400",ne=ee.fontSize,ie="'Roboto', arial",re="thin",ae="#000000",le={style:"thin",color:_},ce=c.InvalidReference,he="START_REVISION",de=1,ue=20,ge="??",pe="difference",me="#00A04A",fe="#DC6965",be=["'","*","?","/","\\","[","]"],ve=/'|\*|\?|\/|\\|\[|\]/,Se="|",Ce=a("Invalid expression");var Ee;!function(e){e[e.Grid=0]="Grid",e[e.Highlight=5]="Highlight",e[e.HeaderGroupingButton=6]="HeaderGroupingButton",e[e.Figure=10]="Figure",e[e.ScrollBar=15]="ScrollBar",e[e.GridPopover=19]="GridPopover",e[e.GridComposer=20]="GridComposer",e[e.Dropdown=21]="Dropdown",e[e.IconPicker=25]="IconPicker",e[e.TopBarComposer=30]="TopBarComposer",e[e.Popover=35]="Popover",e[e.FigureAnchor=1e3]="FigureAnchor",e[e.FigureSnapLine=1001]="FigureSnapLine"}(Ee||(Ee={}));let ye=0;function we(){return ye}const xe="\n",Ie=[6,7,8,9,10,11,12,14,18,24,36];function Re(e){return'"'===e[0]&&(e=e.slice(1)),'"'===e[e.length-1]&&"\\"!==e[e.length-2]?e.slice(0,e.length-1):e}function Te(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Ae(e){const t=Array.isArray(e)?[]:{};switch(typeof e){case"object":if(null===e)return e;if(function(e){return"clone"in e&&e.clone instanceof Function}(e))return e.clone();if(!(function(e){return"object"==typeof e&&null!==e&&(e?.constructor===Object||void 0===e?.constructor)}(e)||e instanceof Array))throw new Error("Unsupported type: only objects and arrays are supported");for(const o in e)t[o]=Ae(e[o]);return t;case"number":case"string":case"boolean":case"function":case"undefined":return e;default:throw new Error("Unsupported type: "+typeof e)}}function Oe(e){return e.startsWith("'")&&(e=e.slice(1,-1).replace(/''/g,"'")),e}function _e(e){return e.match(/\w/g)?.length!==e.length&&(e=`'${e}'`),e}function Me(e,t,o){return e<t?t:e>o?o:e}function Ne(e,t,o=1){if(t<=e&&o>0)return[];if(0===o)throw new Error("range() step must not be zero");const s=Math.ceil(Math.abs((t-e)/o)),n=Array(s);for(let t=0;t<s;t++)n[t]=e+t*o;return n}function Fe(e){return e.reduce(((e,t,o,s)=>{if(1===Math.abs(t-s[o-1])){e[e.length-1].push(t)}else e.push([t]);return e}),[])}function*De(e,t){t.next();for(const o of e){const e=t.next();yield{...o,next:e.done?void 0:e.value}}}const Le=/^\[(.+)\]\((.+)\)$/,Pe=/^https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,4}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)$/;function Ve(e){return Le.test(e)}function ke(e){return Pe.test(e)}function Ue(e,t){return`[${e}](${t})`}function Be(e){const t=e.match(Le)||[],o=t[1],s=t[2];if(!o||!s)throw new Error(`Could not parse markdown link ${e}.`);return{label:o,url:s}}const He="o-spreadsheet://";function ze(e){return e.startsWith(He)}function Ge(e){return`${He}${e}`}function $e(e){if(e.startsWith(He))return e.substr(He.length);throw new Error(`${e} is not a valid sheet link`)}function We(e){return void 0!==e}function qe(e){return null!==e}function Ze(e){return void 0===e||Object.values(e).every((e=>"object"==typeof e?Ze(e):!e))}function Ye(e,t){for(const o in t)if(Je(t[o],e))return parseInt(o,10);const o=Object.keys(t),s=0===o.length?0:ut(o.map((e=>parseInt(e,10))));return t[s+1]=e,s+1}function je(e){let t="";for(let o=0,s=e.length;o<s;o++)t+=e[o];return t}function Xe(e){let t,o=!1;const s=()=>(o||(t=e instanceof Function?e():e,o=!0),t);return s.map=e=>Xe((()=>e(s()))),s}function Ke(e,t){let o=e.slice(t).find((e=>e));return o||(o=e.slice(0,t).reverse().find((e=>e))),o||""}function Qe(e,t){return"after"===e?t+1:t}function Je(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 o in t)if(!(o in e)&&void 0!==t[o])return!1;for(const o in e){if(typeof e[o]!=typeof t[o])return!1;if("object"==typeof e[o]){if(!Je(e[o],t[o]))return!1}else if(e[o]!==t[o])return!1}return!0}function et(e,t){if(e.length<t.length)return!1;const o=new Set(e);return t.every((e=>o.has(e)))}function tt(e){const t={...e};return Object.keys(t).forEach((e=>!t[e]&&delete t[e])),t}const ot=["\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))],st=new RegExp(ot.join("|"),"g"),nt=/(\r\n|\r)/g;function it(e){return e?e.replace(nt,xe):""}function rt(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}class at extends Set{addMany(e){for(const t of e)super.add(t);return this}deleteMany(e){for(const t of e)super.delete(t)}}function lt(e){const t=new Map,o=e.name?e.name+" (memoized)":"memoized";return{[o]:(...o)=>(t.has(o[0])||t.set(o[0],e(...o)),t.get(o[0]))}[o]}function ct(e,t){return e.filter(((e,o)=>!t.includes(o)))}function ht(e){return e.split("\n").map((e=>e.replace(/\s+/g," ").trim())).join("\n")}function dt(e,t,o){return t>o?dt(e,o,t):e>=t&&e<=o}function ut(e){let t=e.length;if(t<1e5)return Math.max(...e);let o=-1/0;for(;t--;)o=e[t]>o?e[t]:o;return o}function gt(e){let t=e.length;if(t<1e5)return Math.min(...e);let o=1/0;for(;t--;)o=e[t]<o?e[t]:o;return o}const pt=/rgba?\(|\s+|\)/gi,mt=/^#([A-F\d]{2}){3,4}$/,ft=["#eb6d00","#0074d9","#ad8e00","#169ed4","#b10dc9","#00a82d","#00a3a3","#f012be","#3d9970","#111111","#62A300","#ff4136","#949494","#85144b","#001f3f"];function bt(e){return vt(e.toString(16).padStart(6,"0"))}function vt(e){let t=e;if(e.startsWith("rgb")?t=function(e){const t=e.replace(pt,"").split(",");let o=255;if(3!==t.length&&4!==t.length)throw new Error("invalid color");if(4===t.length){const e=parseFloat(t.pop()||"1");if(isNaN(e))throw new Error("invalid alpha value");o=Math.round(255*e)}const s=t.map((e=>parseInt(e,10)));255!==o&&s.push(o);return"#"+je(s.map((e=>e.toString(16).padStart(2,"0")))).toUpperCase()}(e):(t=e.replace("#","").toUpperCase(),3!==t.length&&4!==t.length||(t=t.split("").reduce(((e,t)=>e+t+t),"")),t=`#${t}`),!mt.test(t))throw new Error(`invalid color input: ${e}`);return t}function St(e){try{return vt(e),!0}catch(e){return!1}}const Ct=e=>e>=0&&e<=255;function Et(e,t,o,s=1){if(!Ct(e)||!Ct(t)||!Ct(o)||s<0||s>1)throw new Error(`Invalid RGBA values ${[e,t,o,s]}`);return{a:s,b:o,g:t,r:e}}function yt(e){let{r:t,g:o,b:s}=xt(e);t/=255,o/=255,s/=255;const n=e=>e<=.03928?e/12.92:((e+.055)/1.055)**2.4;return.2126*n(t)+.7152*n(o)+.0722*n(s)}function wt(e){let t=e.r.toString(16),o=e.g.toString(16),s=e.b.toString(16),n=Math.round(255*e.a).toString(16);return 1===t.length&&(t="0"+t),1===o.length&&(o="0"+o),1===s.length&&(s="0"+s),1===n.length&&(n="0"+n),"ff"===n&&(n=""),("#"+t+o+s+n).toUpperCase()}function xt(e){let t,o,s,n;if(7===(e=vt(e)).length)t=parseInt(e[1]+e[2],16),o=parseInt(e[3]+e[4],16),s=parseInt(e[5]+e[6],16),n=255;else{if(9!==e.length)throw new Error("Invalid color");t=parseInt(e[1]+e[2],16),o=parseInt(e[3]+e[4],16),s=parseInt(e[5]+e[6],16),n=parseInt(e[7]+e[8],16)}return n=+(n/255).toFixed(3),{a:n,r:t,g:o,b:s}}function It(e){(e={...e}).s/=100,e.l/=100;let t=(1-Math.abs(2*e.l-1))*e.s,o=t*(1-Math.abs(e.h/60%2-1)),s=e.l-t/2,n=0,i=0,r=0;return 0<=e.h&&e.h<60?(n=t,i=o,r=0):60<=e.h&&e.h<120?(n=o,i=t,r=0):120<=e.h&&e.h<180?(n=0,i=t,r=o):180<=e.h&&e.h<240?(n=0,i=o,r=t):240<=e.h&&e.h<300?(n=o,i=0,r=t):300<=e.h&&e.h<360&&(n=t,i=0,r=o),n=Math.round(255*(n+s)),i=Math.round(255*(i+s)),r=Math.round(255*(r+s)),{a:e.a,r:n,g:i,b:r}}function Rt(e){const t=e.r/255,o=e.g/255,s=e.b/255;let n=Math.min(t,o,s),i=Math.max(t,o,s),r=i-n,a=0,l=0,c=0;return a=0===r?0:i===t?(o-s)/r%6:i===o?(s-t)/r+2:(t-o)/r+4,a=Math.round(60*a),a<0&&(a+=360),c=(i+n)/2,l=0===r?0:r/(1-Math.abs(2*c-1)),l=+(100*l).toFixed(1),c=+(100*c).toFixed(1),{a:e.a,h:a,s:l,l:c}}function Tt(e){return wt(It(e))}function At(e){return Rt(xt(e))}function Ot(e){if(e<0)throw new Error(`number must be positive. Got ${e}`);return e<26?String.fromCharCode(65+e):Ot(Math.floor(e/26)-1)+Ot(e%26)}const _t={};for(const rA of"ABCDEFGHIJKLMNOPQRSTUVWXYZ"){const aA=rA.charCodeAt(0)-64;_t[rA]=aA,_t[rA.toLowerCase()]=aA}function Mt(e){let t=-1;let o=1;for(let s=e.length-1;s>=0;s--){t+=_t[e[s]]*o,o*=26}return t}function Nt(e){return e>="A"&&e<="Z"||e>="a"&&e<="z"}function Ft(e){return e>="0"&&e<="9"}function Dt(e){let t;e=e.trim();for(let o=0;o<e.length;o++){const s=e[o];if(!t){if("$"===s&&0===o||Nt(s))continue;t=o}if(!Ft(s)){if("$"===s&&o===t)continue;throw new Error(`Invalid cell description: ${e}`)}}if(!t||t===e.length)throw new Error(`Invalid cell description: ${e}`);const o="$"===e[0]?e.slice(1,t):e.slice(0,t),s="$"===e[t]?e.slice(t+1):e.slice(t);if(o.length<1||o.length>3||s.length<1||s.length>7)throw new Error(`Invalid cell description: ${e}`);const n=Mt(o),i=Number(s)-1;if(isNaN(i))throw new Error(`Invalid cell description: ${e}`);return{col:n,row:i}}function Lt(e,t,o={colFixed:!1,rowFixed:!1}){return(o.colFixed?"$":"")+Ot(e)+(o.rowFixed?"$":"")+String(t+1)}class Pt{jsDate;constructor(e,t,o,s=0,n=0,i=0){this.jsDate=new Date(Date.UTC(e,t,o,s,n,i,0))}static fromTimestamp(e){const t=new Date(e);return new Pt(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate(),t.getUTCHours(),t.getUTCMinutes(),t.getUTCSeconds())}static now(){const e=new Date;return new Pt(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds())}toString(){return this.jsDate.toString()}toLocaleDateString(){return this.jsDate.toLocaleDateString()}getTime(){return this.jsDate.getTime()}getFullYear(){return this.jsDate.getUTCFullYear()}getMonth(){return this.jsDate.getUTCMonth()}getDate(){return this.jsDate.getUTCDate()}getDay(){return this.jsDate.getUTCDay()}getHours(){return this.jsDate.getUTCHours()}getMinutes(){return this.jsDate.getUTCMinutes()}getSeconds(){return this.jsDate.getUTCSeconds()}setFullYear(e){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 Vt=new Pt(1899,11,30),kt=864e5,Ut=2e3,Bt=Pt.now().getFullYear(),Ht=Pt.now().getMonth(),zt=Pt.fromTimestamp(0).getTime()-Vt.getTime(),Gt=/^\d{1,2}(\/|-|\s)\d{1,2}((\/|-|\s)\d{1,4})?$/,$t=/^\d{3,4}(\/|-|\s)\d{1,2}(\/|-|\s)\d{1,2}$/,Wt=/\/|-|\s/,qt=/^(\d{1,4})[\/-\s](\d{1,4})([\/-\s](\d{1,4}))?$/,Zt=/((\d+(:\d+)?(:\d+)?\s*(AM|PM))|(\d+:\d+(:\d+)?))$/;function Yt(e,t){switch(typeof e){case"number":return e;case"string":return jt(e,t)?Kt(e,t)?.value:!e||isNaN(Number(e))?void 0:Number(e);default:return}}function jt(e,t){return null!==Kt(e,t)}const Xt=new Map;function Kt(e,t){return Xt.has(t)||Xt.set(t,new Map),Xt.get(t).has(e)||Xt.get(t).set(e,function(e,t){e=e.trim();let o=null;const s=e.match(Zt);if(s){if(o=function(e){if(e=e.trim(),Zt.test(e)){const t=/AM/i.test(e),o=/PM/i.test(e),s=(t||o?e.substring(0,e.length-2).trim():e).split(/:/),n=s.length>=2,i=3===s.length;let r=Number(s[0]),a=n?Number(s[1]):0,l=i?Number(s[2]):0,c=i?"hh:mm:ss":"hh:mm";if(t||o)c+=" a";else if(!n)return null;r>=12&&t?r-=12:r<12&&o&&(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 Pt(1899,11,30,r,a,l)}}return null}(s[0]),null===o)return null;e=e.replace(s[0],"").trim()}let n=null;const i=function(e,t){const o=e.match(qt);if(!o)return null;const[,s,n,,i]=o;if(s.length>2&&i&&i.length>2)return null;if(s.length>2)return{year:s,month:n,day:i,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(!i)return n.length>2?{month:s,year:n,day:void 0,dateString:e,type:r}:"dmy"===r?{day:s,month:n,year:i,dateString:e,type:"dmy"}:{month:s,day:n,year:i,dateString:e,type:"mdy"};if(i.length>2)return"mdy"===r?{month:s,day:n,year:i,dateString:e,type:"mdy"}:{day:s,month:n,year:i,dateString:e,type:"dmy"};if("mdy"===r)return{month:s,day:n,year:i,dateString:e,type:"mdy"};if("ymd"===r)return{year:s,month:n,day:i,dateString:e,type:"ymd"};if("dmy"===r)return{day:s,month:n,year:i,dateString:e,type:"dmy"};return null}(e,t);if(i){const t=i.dateString.match(Wt)[0];if(n=function(e,t){let{year:o,month:s,day:n}=e;const i=function(e){if(!e)return Ht;const t=Number(e);if(t>=1&&t<=12)return t-1;return null}(s),r=function(e){if(!e)return 1;const t=Number(e);if(t>=0&&t<=31)return t;return null}(n),a=function(e){if(!e)return Bt;const t=Number(e);switch(e.length){case 1:return Ut+t;case 2:return Ut+(Ut+t>Bt+10?-100:0)+t;case 3:case 4:return t}return null}(o);if(null===a||null===i||null===r)return null;const l=2===s?.length&&i+1<10||2===n?.length&&r<10,c=2!==o?.length,h=new Pt(a,i,r);if(h.getMonth()!==i||h.getDate()!==r)return null;const d=h.getTime()-Vt.getTime(),u=function(e,t,o,s){const n=e.year?s?"yyyy":"yy":void 0,i=e.month?o?"mm":"m":void 0,r=e.day?o?"dd":"d":void 0;switch(e.type){case"mdy":return[i,r,n].filter(We).join(t);case"ymd":return[n,i,r].filter(We).join(t);case"dmy":return[r,i,n].filter(We).join(t)}}(e,t,l,c);return{value:Math.round(d/kt),format:u,jsDate:h}}(i,t),null===n)return null;e=e.replace(i.dateString,"").trim()}if(""!==e||!n&&!o)return null;if(n&&n.jsDate&&o&&o.jsDate)return{value:n.value+o.value,format:n.format+" "+("hhhh:mm:ss"===o.format?"hh:mm:ss":o.format),jsDate:new Pt(n.jsDate.getFullYear()+o.jsDate.getFullYear()-1899,n.jsDate.getMonth()+o.jsDate.getMonth()-11,n.jsDate.getDate()+o.jsDate.getDate()-30,n.jsDate.getHours()+o.jsDate.getHours(),n.jsDate.getMinutes()+o.jsDate.getMinutes(),n.jsDate.getSeconds()+o.jsDate.getSeconds())};return n||o}(e,t)),Xt.get(t).get(e)}function Qt(e){const t=Math.trunc(e);let o=Pt.fromTimestamp(t*kt-zt),s=e-t;s=s<0?1+s:s;const n=Math.round(24*s),i=Math.round(24*(s-n/24)*60),r=Math.round(24*(s-n/24-i/24/60)*60*60);return o.setHours(n),o.setMinutes(i),o.setSeconds(r),o}function Jt(e){return Math.round(eo(e))}function eo(e){return(e.getTime()-Vt.getTime())/kt}function to(e){return new Pt(e.getFullYear(),e.getMonth()+1,0).getDate()}function oo(e){return to(e)===e.getDate()}function so(e,t,o){const s=e.getFullYear(),n=e.getMonth(),i=e.getDate(),r=new Pt(s,n+t,1);return o&&i===to(e)||i>to(r)?r.setDate(to(r)):r.setDate(i),r}function no(e){const t=Math.trunc(e);return t%4==0&&t%100!=0||t%400==0}function io(e,t,o){if(e===t)return 0;if(e>t){const o=t;t=e,e=o}const s=Qt(e),n=Qt(t);let i=s.getDate(),r=n.getDate();const a=s.getMonth(),l=n.getMonth(),c=s.getFullYear(),h=n.getFullYear();let d=0,u=0;switch(o){case 0:31===i&&(i=30),30===i&&31===r&&(r=30),1===a&&i===(no(c)?29:28)&&(i=30,1===l&&r===(no(h)?29:28)&&(r=30)),d=c+(30*a+i)/360,u=h+(30*l+r)/360;break;case 1:let o=365;const s=c===h;if(!s&&!(c+1===h)||!s&&a<l||!s&&a===l&&i<r){let e=0,t=0;for(let o=c;o<=h;o++)e++,t+=no(o)?366:365;o=t/e}else s?no(c)&&(o=366):(no(c)&&a<2&&(o=366),no(h)&&(l>1||1===l&&29===r)&&(o=366));d=e/o,u=t/o;break;case 2:d=e/360,u=t/360;break;case 3:d=e/365,u=t/365;break;case 4:31===i&&(i=30),31===r&&(r=30),d=c+(30*a+i)/360,u=h+(30*l+r)/360}return u-d}function ro(e,t){const o=12*(t.getFullYear()-e.getFullYear())+t.getMonth()-e.getMonth();return e.getDate()>t.getDate()?o-1:o}function ao(e,t){const o=e.getTime(),s=t.getTime();return Math.floor((s-o)/kt)}function lo(e,t){const o=t.getFullYear()-e.getFullYear(),s=e.getMonth(),n=t.getMonth(),i=e.getDate(),r=t.getDate();return n>s||n===s&&r>=i?o:o-1}function co(e,t,o){return t>o?co(e,o,t):(e=Math.trunc(e),t=Math.trunc(t),o=Math.trunc(o),e>=t&&e<=o)}const ho=lt((function(e){return e=Te(e),new RegExp(`(^-?\\d+(${e}?\\d*(e(\\+|-)?\\d+)?)?|^-?${e}\\d+)(?!\\w|!)`)})),uo=lt((function(e){const t=Te(e.decimalSeparator),o="(\\s*"+`(\\d+(${Te(e.thousandsSeparator||"")}\\d{3,})*(${t}\\d*)?)`+"|"+`(${t}\\d+)`+")(e(\\+|-)?\\d+)?(\\s*%)?",s="(\\s*-)?",n="(\\s*[\\$€])?",i="^(("+[s+n+o,s+o+n,n+s+o].join(")|(")+"))$";return new RegExp(i,"i")}));function go(e,t){return!!e&&uo(t).test(e.trim())}const po=lt((function(e){return new RegExp(`[$€${Te(e.thousandsSeparator||"")}]`,"g")}));function mo(e,t){e=e.replace(po(t),""),"."!==t.decimalSeparator&&(e=e.replace(t.decimalSeparator,"."));let o=Number(e);return isNaN(o)&&e.includes("%")&&(o=Number(e.split("%")[0]),!isNaN(o))?o/100:o}function fo(e,t,o){const s=[...e].sort(((e,t)=>e-t));let n=(s.length+(o?-1:1))*t;if(o||n--,Number.isInteger(n))return s[n];const i=Math.ceil(n),r=Math.floor(n);return s[i]*(n-r)+s[r]*(i-n)}var bo,vo;!function(e){e.boolean="boolean",e.number="number",e.text="text",e.empty="empty",e.error="error"}(bo||(bo={})),function(e){e.PlainText="text/plain",e.Html="text/html"}(vo||(vo={}));const So=new Set(["RENAME_SHEET","DELETE_SHEET","CREATE_SHEET","ADD_COLUMNS_ROWS","REMOVE_COLUMNS_ROWS","UNDO","REDO","ADD_MERGE","DUPLICATE_SHEET","UPDATE_LOCALE"]),Co=new Set([...So,"MOVE_RANGES"]),Eo=new Set([...So,"EVALUATE_CELLS","ADD_CONDITIONAL_FORMAT","REMOVE_CONDITIONAL_FORMAT","CHANGE_CONDITIONAL_FORMAT_PRIORITY"]),yo=new Set(["START","ACTIVATE_SHEET","COPY","RESIZE_SHEETVIEW","SET_VIEWPORT_OFFSET","SELECT_SEARCH_NEXT_MATCH","SELECT_SEARCH_PREVIOUS_MATCH","UPDATE_SEARCH","CLEAR_SEARCH","EVALUATE_CELLS","SET_CURRENT_CONTENT","SET_FORMULA_VISIBILITY","OPEN_CELL_POPOVER","CLOSE_CELL_POPOVER","UPDATE_FILTER"]),wo=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","HIDE_SHEET","SHOW_SHEET","MOVE_RANGES","ADD_CONDITIONAL_FORMAT","REMOVE_CONDITIONAL_FORMAT","CHANGE_CONDITIONAL_FORMAT_PRIORITY","CREATE_FIGURE","DELETE_FIGURE","UPDATE_FIGURE","SET_FORMATTING","CLEAR_FORMATTING","SET_BORDER","SET_ZONE_BORDERS","SET_BORDERS_ON_TARGET","CREATE_CHART","UPDATE_CHART","CREATE_FILTER_TABLE","REMOVE_FILTER_TABLE","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"]);function xo(e){return wo.has(e.type)}class Io{reasons;constructor(e=[]){Array.isArray(e)||(e=[e]),e=[...new Set(e)],this.reasons=e.filter((e=>"Success"!==e))}static get Success(){return Ro}get isSuccessful(){return 0===this.reasons.length}isCancelledBecause(e){return this.reasons.includes(e)}}const Ro=new Io;var To;e.CommandResult=void 0,(To=e.CommandResult||(e.CommandResult={})).Success="Success",To.CancelledForUnknownReason="CancelledForUnknownReason",To.WillRemoveExistingMerge="WillRemoveExistingMerge",To.MergeIsDestructive="MergeIsDestructive",To.CellIsMerged="CellIsMerged",To.InvalidTarget="InvalidTarget",To.EmptyUndoStack="EmptyUndoStack",To.EmptyRedoStack="EmptyRedoStack",To.NotEnoughElements="NotEnoughElements",To.NotEnoughSheets="NotEnoughSheets",To.MissingSheetName="MissingSheetName",To.UnchangedSheetName="UnchangedSheetName",To.DuplicatedSheetName="DuplicatedSheetName",To.DuplicatedSheetId="DuplicatedSheetId",To.ForbiddenCharactersInSheetName="ForbiddenCharactersInSheetName",To.WrongSheetMove="WrongSheetMove",To.WrongSheetPosition="WrongSheetPosition",To.InvalidAnchorZone="InvalidAnchorZone",To.SelectionOutOfBound="SelectionOutOfBound",To.TargetOutOfSheet="TargetOutOfSheet",To.WrongCutSelection="WrongCutSelection",To.WrongPasteSelection="WrongPasteSelection",To.WrongPasteOption="WrongPasteOption",To.WrongFigurePasteOption="WrongFigurePasteOption",To.EmptyClipboard="EmptyClipboard",To.EmptyRange="EmptyRange",To.InvalidRange="InvalidRange",To.InvalidZones="InvalidZones",To.InvalidSheetId="InvalidSheetId",To.InvalidCellId="InvalidCellId",To.InvalidFigureId="InvalidFigureId",To.InputAlreadyFocused="InputAlreadyFocused",To.MaximumRangesReached="MaximumRangesReached",To.MinimumRangesReached="MinimumRangesReached",To.InvalidChartDefinition="InvalidChartDefinition",To.InvalidDataSet="InvalidDataSet",To.InvalidLabelRange="InvalidLabelRange",To.InvalidScorecardKeyValue="InvalidScorecardKeyValue",To.InvalidScorecardBaseline="InvalidScorecardBaseline",To.InvalidGaugeDataRange="InvalidGaugeDataRange",To.EmptyGaugeRangeMin="EmptyGaugeRangeMin",To.GaugeRangeMinNaN="GaugeRangeMinNaN",To.EmptyGaugeRangeMax="EmptyGaugeRangeMax",To.GaugeRangeMaxNaN="GaugeRangeMaxNaN",To.GaugeRangeMinBiggerThanRangeMax="GaugeRangeMinBiggerThanRangeMax",To.GaugeLowerInflectionPointNaN="GaugeLowerInflectionPointNaN",To.GaugeUpperInflectionPointNaN="GaugeUpperInflectionPointNaN",To.GaugeLowerBiggerThanUpper="GaugeLowerBiggerThanUpper",To.InvalidAutofillSelection="InvalidAutofillSelection",To.WrongComposerSelection="WrongComposerSelection",To.MinBiggerThanMax="MinBiggerThanMax",To.LowerBiggerThanUpper="LowerBiggerThanUpper",To.MidBiggerThanMax="MidBiggerThanMax",To.MinBiggerThanMid="MinBiggerThanMid",To.FirstArgMissing="FirstArgMissing",To.SecondArgMissing="SecondArgMissing",To.MinNaN="MinNaN",To.MidNaN="MidNaN",To.MaxNaN="MaxNaN",To.ValueUpperInflectionNaN="ValueUpperInflectionNaN",To.ValueLowerInflectionNaN="ValueLowerInflectionNaN",To.MinInvalidFormula="MinInvalidFormula",To.MidInvalidFormula="MidInvalidFormula",To.MaxInvalidFormula="MaxInvalidFormula",To.ValueUpperInvalidFormula="ValueUpperInvalidFormula",To.ValueLowerInvalidFormula="ValueLowerInvalidFormula",To.InvalidSortZone="InvalidSortZone",To.WaitingSessionConfirmation="WaitingSessionConfirmation",To.MergeOverlap="MergeOverlap",To.TooManyHiddenElements="TooManyHiddenElements",To.Readonly="Readonly",To.InvalidViewportSize="InvalidViewportSize",To.InvalidScrollingDirection="InvalidScrollingDirection",To.FigureDoesNotExist="FigureDoesNotExist",To.InvalidConditionalFormatId="InvalidConditionalFormatId",To.InvalidCellPopover="InvalidCellPopover",To.EmptyTarget="EmptyTarget",To.InvalidFreezeQuantity="InvalidFreezeQuantity",To.FrozenPaneOverlap="FrozenPaneOverlap",To.ValuesNotChanged="ValuesNotChanged",To.InvalidFilterZone="InvalidFilterZone",To.FilterOverlap="FilterOverlap",To.FilterNotFound="FilterNotFound",To.MergeInFilter="MergeInFilter",To.NonContinuousTargets="NonContinuousTargets",To.DuplicatedFigureId="DuplicatedFigureId",To.InvalidSelectionStep="InvalidSelectionStep",To.DuplicatedChartId="DuplicatedChartId",To.ChartDoesNotExist="ChartDoesNotExist",To.InvalidHeaderIndex="InvalidHeaderIndex",To.InvalidQuantity="InvalidQuantity",To.MoreThanOneColumnSelected="MoreThanOneColumnSelected",To.EmptySplitSeparator="EmptySplitSeparator",To.SplitWillOverwriteContent="SplitWillOverwriteContent",To.NoSplitSeparatorInSelection="NoSplitSeparatorInSelection",To.NoActiveSheet="NoActiveSheet",To.InvalidLocale="InvalidLocale",To.AlreadyInPaintingFormatMode="AlreadyInPaintingFormatMode",To.MoreThanOneRangeSelected="MoreThanOneRangeSelected",To.NoColumnsProvided="NoColumnsProvided",To.ColumnsNotIncludedInZone="ColumnsNotIncludedInZone",To.DuplicatesColumnsSelected="DuplicatesColumnsSelected",To.InvalidHeaderGroupStartEnd="InvalidHeaderGroupStartEnd",To.HeaderGroupAlreadyExists="HeaderGroupAlreadyExists",To.UnknownHeaderGroup="UnknownHeaderGroup",To.UnknownDataValidationRule="UnknownDataValidationRule",To.UnknownDataValidationCriterionType="UnknownDataValidationCriterionType",To.InvalidDataValidationCriterionValue="InvalidDataValidationCriterionValue",To.InvalidNumberOfCriterionValues="InvalidNumberOfCriterionValues",To.BlockingValidationRule="BlockingValidationRule",To.InvalidCopyPasteSelection="InvalidCopyPasteSelection",To.NoChanges="NoChanges",To.InvalidInputId="InvalidInputId";const Ao=[{name:"English (US)",code:"en_US",thousandsSeparator:",",decimalSeparator:".",dateFormat:"m/d/yyyy",timeFormat:"hh:mm:ss a",formulaArgSeparator:","},{name:"French",code:"fr_FR",thousandsSeparator:" ",decimalSeparator:",",dateFormat:"dd/mm/yyyy",timeFormat:"hh:mm:ss",formulaArgSeparator:";"}],Oo=Ao[0],_o=["thin","medium","thick","dashed","dotted"];function Mo(e){return Array.isArray(e)&&Array.isArray(e[0])}var No,Fo;!function(e){e.UP="up",e.DOWN="down",e.LEFT="left",e.RIGHT="right"}(No||(No={})),function(e){e[e.Background=0]="Background",e[e.Highlights=1]="Highlights",e[e.Clipboard=2]="Clipboard",e[e.Search=3]="Search",e[e.Chart=4]="Chart",e[e.Autofill=5]="Autofill",e[e.Selection=6]="Selection",e[e.Headers=7]="Headers"}(Fo||(Fo={}));const Do=["number","string","boolean","undefined"];function Lo(e,t){if(!e())throw new d(c.GenericError,t)}const Po=e=>a("The function [[FUNCTION_NAME]] expects a number value, but '%s' is a string, and cannot be coerced to a number.",e);function Vo(e,t){switch(typeof e){case"number":return e;case"boolean":return e?1:0;case"string":if(go(e,t)||""===e)return mo(e,t);const o=Kt(e,t);if(o)return o.value;throw new Error(Po(e));default:return 0}}function ko(e,t){try{return Vo(e,t)}catch(e){return}}function Uo(e,t){return e.forEach((e=>{e.forEach((e=>{if("number"!=typeof e)throw new Error(a("Function [[FUNCTION_NAME]] expects number values for %s, but got a %s.",typeof e,t))}))})),e}function Bo(e,t){if(""===e)throw new Error(Po(e));return Vo(e,t)}function Ho(e,t){return Math.trunc(Vo(e,t))}function zo(e,t){return Math.trunc(Bo(e,t))}function Go(e){Lo((()=>e>=1),a("The function [[FUNCTION_NAME]] expects a number value to be greater than or equal to 1, but receives %s.",e.toString()))}function $o(e){switch(typeof e){case"string":return e;case"number":return e.toString();case"boolean":return e?"TRUE":"FALSE";default:return""}}const Wo=lt((function(e){return e.toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g,"")})),qo=e=>a("The function [[FUNCTION_NAME]] expects a boolean value, but '%s' is a text, and cannot be coerced to a number.",e);function Zo(e){switch(typeof e){case"boolean":return e;case"string":if(e){let t=e.toUpperCase();if("TRUE"===t)return!0;if("FALSE"===t)return!1;throw new Error(qo(e))}return!1;case"number":return!!e;default:return!1}}function Yo(e,t){return Qt(Vo(e,t))}function jo(e,t,o){for(let s of e)if(Mo(s)){const e=s.length,o=s[0].length;for(let n=0;n<o;n++)for(let o=0;o<e;o++)t(s[o][n])}else o(s)}function Xo(e,t){jo(e,t,t)}function Ko(e,t,o){jo(e,(e=>{"number"==typeof e&&t(e)}),(e=>{t(Bo(e,o))}))}function Qo(e,t,o,s,n="rowFirst"){let i=s;for(let s of e)if(Mo(s)){const e=s.length,o=s[0].length;if("rowFirst"===n)for(let n=0;n<o;n++)for(let o=0;o<e;o++)i=t(i,s[o][n]);else for(let n=0;n<e;n++)for(let e=0;e<o;e++)i=t(i,s[n][e])}else i=o(i,s);return i}function Jo(e,t,o,s="rowFirst"){return Qo(e,t,t,o,s)}function es(e,t,o,s){return Qo(e,((e,o)=>"number"==typeof o?t(e,o):e),((e,o)=>t(e,Bo(o,s))),o)}function ts(e,t,o,s){return Qo(e,((e,o)=>null!=o?t(e,"number"==typeof o?o:"boolean"==typeof o?Vo(o,s):0):e),((e,o)=>t(e,Vo(o,s))),o)}function os(e,t,o){const s=Array(e);for(let n=0;n<e;n++){s[n]=Array(t);for(let e=0;e<t;e++)s[n][e]=o(n,e)}return s}function ss(e,t){return 0===e.length?[]:os(e.length,e[0].length,((o,s)=>t(e[o][s])))}function ns(e){return e.length?os(e[0].length,e.length,((t,o)=>e[o][t])):[]}function is(e,t){return function(e,t,o){for(let s of e)if(Mo(s)){const e=s.length,o=s[0].length;for(let n=0;n<o;n++)for(let o=0;o<e;o++)if(!t(s[o][n]??void 0))return}else if(!o(s))return}(e,(e=>"boolean"==typeof e?t(e):"number"!=typeof e||t(!!e)),(e=>null==e||t(function(e){if(""===e)throw new Error(qo(e));return Zo(e)}(e))))}function rs(e,t,o){let s,n,i=e.substring(0,2);"<="===i||">="===i||"<>"===i?(s=i,n=e.substring(2)):(i=e.substring(0,1),"<"===i||">"===i||"="===i?(s=i,n=e.substring(1)):(s="=",n=e)),go(n,o)||jt(n,o)?n=Vo(n,o):"TRUE"!==n&&"FALSE"!==n||(n=Zo(n));const r={operator:s,operand:n};return"string"==typeof n&&(t&&(n+="*"),r.regexp=function(e){if("*"===e)return/.+/;let t="",o="";for(let s of e)"?"===s&&"~"!==o?t+=".":"*"===s&&"~"!==o?t+=".*":("*"!==s&&"?"!==s||(t=t.slice(0,-1)),["^",".","[","]","$","(",")","*","+","?","|","{","}","\\"].includes(s)&&(t+="\\"),t+=s),o=s;return new RegExp("^"+t+"$","i")}(n)),r}function as(e="",t,o){const{operator:s,operand:n}=t;if(void 0===n||null===e||null===n)return!1;if("number"==typeof n&&"="===s)return"string"==typeof e&&(go(e,o)||jt(e,o))?Vo(e,o)===n:e===n;if("<>"===s||"="===s){let o;return o=typeof e==typeof n&&("string"==typeof e&&t.regexp?t.regexp.test(e):e===n),"="===s?o:!o}if(typeof e==typeof n)switch(s){case"<":return e<n;case">":return e>n;case"<=":return e<=n;case">=":return e>=n}return!1}function ls(e,t,o,s=!1){const n=e.length;if(n%2==1)throw new Error(a("Function [[FUNCTION_NAME]] expects criteria_range and criterion to be in pairs."));const i=e[0].length,r=e[0][0].length;let l=[];for(let t=0;t<n-1;t+=2){const n=e[t];if(!Mo(n)||n.length!==i||n[0].length!==r)throw new Error(a("Function [[FUNCTION_NAME]] expects criteria_range to have the same dimension"));const c=$o(e[t+1]);l.push(rs(c,s,o))}for(let s=0;s<i;s++)for(let i=0;i<r;i++){let r=!0;for(let t=0;t<n-1;t+=2){if(r=as(e[t][s][i]??void 0,l[t/2],o),!r)break}r&&t(s,i)}}function cs(e,t,o,s,n,i){if(null==t)return-1;const r=ds(t),a=typeof r;let l,c,h,d,u,g,p=0,m=n-1;const f="desc"===s?t=>ds(i(e,n-t-1)):t=>ds(i(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"===o&&u===r?(l=u,c=d):"nextSmaller"===o&&u<=r?(null==l||l<u||l===u&&c<d)&&(l=u,c=d):"nextGreater"===o&&u>=r&&(void 0===l||l>u||l===u&&c<d)&&(l=u,c=d),u>r||"strict"===o&&u===r?m=d-1:p=h+1):p=h+1}return void 0===c?-1:"desc"===s?n-c-1:c}function hs(e,t,o,s,n,i=!1){if(null==t)return-1;const r=ds(t),a=i?(e,t)=>n(e,s-t-1):n;let l,c=-1;for(let t=0;t<s;t++){const n=ds(a(e,t));if(n===r)return i?s-t-1:t;"nextSmaller"===o?(!l&&us(r,n)>=0||us(r,n)>=0&&us(n,l)>0)&&(l=n,c=t):"nextGreater"===o&&(!l&&us(r,n)<=0||us(r,n)<=0&&us(n,l)<0)&&(l=n,c=t)}return i&&-1!==c?s-c-1:c}function ds(e){return"string"==typeof e?Wo(e):e}function us(e,t){let o=Do.indexOf(typeof e)-Do.indexOf(typeof t);return 0===o&&("string"==typeof e&&"string"==typeof t?o=e.localeCompare(t):"number"==typeof e&&"number"==typeof t?o=e-t:"boolean"==typeof e&&"boolean"==typeof t&&(o=Number(e)-Number(t))),o}function gs(e){return void 0===e?[[]]:Mo(e)?e:[[e]]}function ps(e,t){return Jo(e,((e,o)=>(e.push(t(o)),e)),[],"rowFirst")}function ms(e){const t=Pt.now();switch(e){case"today":return eo(t);case"yesterday":return eo(Pt.fromTimestamp(t.setDate(t.getDate()-1)));case"tomorrow":return eo(Pt.fromTimestamp(t.setDate(t.getDate()+1)));case"lastWeek":return eo(Pt.fromTimestamp(t.setDate(t.getDate()-7)));case"lastMonth":return eo(Pt.fromTimestamp(t.setMonth(t.getMonth()-1)));case"lastYear":return eo(Pt.fromTimestamp(t.setFullYear(t.getFullYear()-1)))}}function fs(e,t){return"dateValue"in e&&"exactDate"!==e.dateValue?[ms(e.dateValue)]:e.values.map((e=>Yt(e,t)))}function bs(e,t){return e.values.map((e=>ko(e,t)))}function vs(e){return 20+120*Math.exp(-.035*(e-1))}const Ss=20,Cs=11,Es=/(\d+?)(?=(\d{3})+(?!\d)|$)/g,ys=/0/g,ws={0:a("January"),1:a("February"),2:a("March"),3:a("April"),4:a("May"),5:a("June"),6:a("July"),7:a("August"),8:a("September"),9:a("October"),10:a("November"),11:a("December")},xs={0:a("Sunday"),1:a("Monday"),2:a("Tuesday"),3:a("Wednesday"),4:a("Thursday"),5:a("Friday"),6:a("Saturday")},Is={};function Rs(e){let t=Is[e];return void 0===t&&(t=function(e){if(""===e)throw new Error("A format cannot be empty");let t=0,o=[];for(;t<e.length;){let s;if("["===e.charAt(t)){if("$"!==e.charAt(t+1))throw new Error(`Currency formats have to be prefixed by a $: ${e}`);if(s=e.substring(t+1).indexOf("]")+t+2,0===s)throw new Error(`Invalid currency brackets format: ${e}`);const n=e.substring(t+2,s-1);if(n.includes("["))throw new Error(`Invalid currency format: ${e}`);o.push({type:"STRING",format:n})}else{const n=e.substring(t).indexOf("[");s=n>-1?n+t:e.length;const i=e.substring(t,s);Ds(i)?o.push({type:"DATE",format:i}):o.push({type:"NUMBER",format:js(i)})}t=s}return o}(e),Is[e]=t),t}function Ts(e,{format:t,locale:o}){switch(typeof e){case"string":return e.includes('\\"')?e.replace(/\\"/g,'"'):e;case"boolean":return e?"TRUE":"FALSE";case"number":t||(t=Bs(e));return function(e,t,o){if("DATE"===t[0].type)return Ps(e,t[0].format);let s=e<0?"-":"";for(let n of t)switch(n.type){case"NUMBER":s+=As(Math.abs(e),n.format,o);break;case"STRING":s+=n.format}return s}(e,Rs(t),o);case"object":return"0"}}function As(e,t,o){t.isPercent&&(e*=100),e/=t.magnitude;let s=0;void 0!==t.decimalPart&&(s=t.decimalPart.length);const{integerDigits:n,decimalDigits:i}=_s(e,s);let r=function(e,t,o){const s="0"===e?"":e;let n=s;const i=t.length-s.length;if(i>0){const e=(t.substring(0,i).match(ys)||[]).length;n="0".repeat(e)+n}o&&(n=n.match(Es)?.join(o)||n);return n}(n,t.integerPart,t.thousandsSeparator?o.thousandsSeparator:void 0);return void 0!==t.decimalPart&&(r+=o.decimalSeparator+function(e,t){let o=e;if(t.length-e.length>0){const s=(t.substring(e.length,t.length+1).match(ys)||[]).length;o+="0".repeat(s)}return o}(i||"",t.decimalPart)),t.isPercent&&(r+="%"),r}const Os=[];function _s(e,t=Ss){const o=e.toString();if(o.includes("e"))return function(e,t=Ss){let o=Os[t];o||(o=new Intl.NumberFormat("en-US",{maximumFractionDigits:t,useGrouping:!1}),Os[t]=o);const[s,n]=o.format(e).split(".");return{integerDigits:s,decimalDigits:n}}(e,t);if(Number.isInteger(e))return{integerDigits:o,decimalDigits:void 0};const s=o.indexOf(".");let n=o.substring(0,s),i=o.substring(s+1);if(0===t)return Number(i[0])>=5&&(n=(Number(n)+1).toString()),{integerDigits:n,decimalDigits:void 0};if(i.length>t){const{integerDigits:e,decimalDigits:o}=function(e,t){let o="0",s=e,n=e.slice(0,t);const i=t;if(Number(e[i])<5)return{integerDigits:o,decimalDigits:n};const r=n.match(Ns)?.[0]||"",a=(Number(n)+1).toString(),l=n.slice(r.length),c=a.length>l.length;c&&!r?(o="1",s=void 0):s=c?r.slice(0,-1)+a:r+a;return{integerDigits:o,decimalDigits:s}}(i,t);i=o,"0"!==e&&(n=(Number(n)+Number(e)).toString())}return{integerDigits:n,decimalDigits:Ms(i||"")}}function Ms(e){let t=e.length-1;for(;t>=0&&"0"===e[t];)t--;return e.slice(0,t+1)||void 0}const Ns=/^0+/;function Fs(e,t){const{integerDigits:o,decimalDigits:s}=_s(e,20);return s?o+t+s:o}function Ds(e){if(!Ls.has(e[0]))return!1;try{return Ps(1,e),!0}catch(e){return!1}}const Ls=new Set(["h","m","y","d"]);function Ps(e,t){const o=Qt(e),s=t.indexOf("h");let n="",i="";return s>0?(n=Vs(o,t.substring(0,s-1)),i=ks(o,t.substring(s))):0===s?i=ks(o,t):s<0&&(n=Vs(o,t)),n+(n&&i?" ":"")+i}function Vs(e,t){const o=t.match(/\/|-|\s/)?.[0];return(o?t.split(o):[t]).map((o=>{switch(o){case"d":return e.getDate();case"dd":return e.getDate().toString().padStart(2,"0");case"ddd":return xs[e.getDay()].slice(0,3);case"dddd":return xs[e.getDay()];case"m":return e.getMonth()+1;case"mm":return String(e.getMonth()+1).padStart(2,"0");case"mmm":return ws[e.getMonth()].slice(0,3);case"mmmm":return ws[e.getMonth()];case"mmmmm":return ws[e.getMonth()].slice(0,1);case"yy":const o=String(e.getFullYear()).replace("-","").padStart(2,"0");return o.slice(o.length-2);case"yyyy":return e.getFullYear();default:throw new Error(`invalid format: ${t}`)}})).join(o)}function ks(e,t){let o=t.split(/:|\s/);const s=e.getHours(),n="a"===o[o.length-1];let i=s,r="";return n&&(i=0===i?12:i>12?i-12:i,r=s>=12?" PM":" AM",o.pop()),o.map((o=>{switch(o){case"hhhh":return Math.floor((e.getTime()-Vt.getTime())/36e5).toString();case"hh":return i.toString().padStart(2,"0");case"mm":return e.getMinutes().toString().padStart(2,"0");case"ss":return e.getSeconds().toString().padStart(2,"0");default:throw new Error(`invalid format: ${t}`)}})).join(":")+r}const Us=lt((function(e){return new RegExp(`[0-9]+${Te(e.decimalSeparator)}[0-9]`)}));function Bs(e){let{integerDigits:t,decimalDigits:o}=_s(e);if(!o)return"0";const s=t.replace("-","").length;if(s+2>Cs)return"0";const n=Cs-s-1;return({decimalDigits:o}=_s(e,Math.min(n,o.length))),o?"0."+"0".repeat(o.length):"0"}function Hs(e,t){if(!jt(e,t))return;return Kt(e,t).format}function zs(e){if(!go(e,Oo))return;const t=e.includes(".")?"0.00":"0",o=e.match(/[\$€]/);if(o){const s=e.match(/[\d]/),n="[$"+o.values().next().value+"]";return s.index<o.index?"#,##"+t+n:n+"#,##"+t}return e.includes("%")?t+"%":void 0}function Gs(e){const t=e.decimalPlaces??2,o=e.position??"before",s=e.code??"",n=e.symbol??"",i="#,##0"+(t?"."+"0".repeat(t):"");let r=`${s} ${n}`.trim();return"after"===o&&s&&(r=" "+r),function(e,t,o){const s=`[$${e}]`;return"before"===t?s+o:o+s}(r,o,i)}function $s(e){return Ks(Rs(e).map((e=>"NUMBER"===e.type?{type:e.type,format:{...e.format,decimalPart:void 0}}:e)))}function Ws(e,t,o,s){const n=Rs(e||"#,##0"),i=[];for(let e=0;e<n.length;e++){const s=n[e];if("NUMBER"!==s.type){i.push(s);continue}i.push({...s,format:{...s.format,magnitude:t,decimalPart:void 0}}),i.push({type:"STRING",format:o});const r=n[e+1];"STRING"===r?.type&&["k","m","b"].includes(r.format)&&e++}return Ks(i)}function qs(e,t,o){const s=Rs(e).map((e=>"NUMBER"===e.type?{...e,format:Zs(e.format,t)}:e)),n=Ks(s);return Is[n]=s,n}function Zs(e,t){const o={...e},s=Math.sign(t),n=o.decimalPart?.length||0,i=Math.min(Math.max(0,n+s),Ss);return o.decimalPart="0".repeat(i),""===o.decimalPart&&delete o.decimalPart,o}const Ys=/,*?$/;function js(e){if(function(e){return Boolean(e.replace(Xs,""))}(e=e.trim()))throw new Error(`Invalid number format: ${e}`);const t=e.includes("%"),o=e.match(Ys)?.[0]||"",s=o?1e3**o.length:1;let n=e.slice(0,e.length-(o.length||0));const i=n.includes(",");if(/\..*,/.test(n))throw new Error("A format can't contain ',' symbol in the decimal part");n=n.replace("%","").replace(",","");const r=n.match(/[\%|,]/);if(r)throw new Error(`A format can only contain a single '${r[0]}' symbol`);const[a,l]=n.split(".");if(l&&l.length>20)throw new Error("A format can't contain more than 20 decimal places");return void 0!==l?{integerPart:a,isPercent:t,thousandsSeparator:i,decimalPart:l,magnitude:s}:{integerPart:a,isPercent:t,thousandsSeparator:i,magnitude:s}}const Xs=/[,#0.%]/g;function Ks(e){let t="";for(let o of e){let e;switch(o.type){case"NUMBER":const t=o.format;e=t.integerPart,t.thousandsSeparator&&(e=e.slice(0,-3)+","+e.slice(-3)),void 0!==t.decimalPart&&(e+="."+t.decimalPart),t.isPercent&&(e+="%"),t.magnitude&&(e+=",".repeat(Math.log10(t.magnitude)/3));break;case"STRING":e=`[$${o.format}]`;break;case"DATE":e=o.format}t+=e}return t}const Qs=new RegExp(/\$?([A-Z]{1,3})\$?([0-9]{1,7})/,"i"),Js=new RegExp(/^\$?([A-Z]{1,3})\$?([0-9]{1,7})$/,"i"),en=new RegExp(/^\$?([A-Z]{1,3})+$/,"i"),tn=new RegExp(/^\$?([0-9]{1,7})+$/,"i"),on=new RegExp(/^\s*('.+'!|[^']+!)?\$?([A-Z]{1,3})$/,"i"),sn=new RegExp(/^\s*('.+'!|[^']+!)?\$?([0-9]{1,7})$/,"i"),nn=new RegExp(/^\s*('.+'!|[^']+!)?/.source+"("+[Qs.source,/(\$?[A-Z]{1,3})?\$?[0-9]{1,7}\s*:\s*(\$?[A-Z]{1,3})?\$?[0-9]{1,7}\s*/i.source,/\$?[A-Z]{1,3}(\$?[0-9]{1,7})?\s*:\s*\$?[A-Z]{1,3}(\$?[0-9]{1,7})?\s*/i.source].join("|")+")"+/$/.source,"i");function rn(e){return on.test(e)}function an(e){return sn.test(e)}function ln(e){return en.test(e)}function cn(e){return tn.test(e)}function hn(e){return Js.test(e)}function dn(e){const t=e.split("!"),o=t.pop();return{sheetName:Oe(t.join("!"))||void 0,xc:o}}function un(e){const t=function(e){e.includes("!")&&(e=e.split("!").at(-1)),e.includes("$")&&(e=e.replaceAll("$",""));let t,o,s,n,i,r="";e.includes(":")?([r,t]=e.split(":"),r=r.trim(),t=t.trim()):r=e.trim();let a=!1,l=!1,c=!1;if(rn(r))n=i=Mt(r),o=s=0,a=!0;else if(an(r))o=s=parseInt(r,10)-1,n=i=0,l=!0;else{const e=Dt(r);n=i=e.col,o=s=e.row,c=!0}if(t)if(rn(t))i=Mt(t),a=!0;else if(an(t))s=parseInt(t,10)-1,l=!0;else{const e=Dt(t);i=e.col,s=e.row,o=a?s:o,n=l?i:n,c=!0}if(a&&l)throw new Error("Wrong zone xc. The zone cannot be at the same time a full column and a full row");const h={top:o,left:n,bottom:a?void 0:s,right:l?void 0:i};return c=c&&(l||a),c&&(h.hasHeader=c),h}(e);return function(e){if(void 0!==e.right&&e.right<e.left){const t=e.left;e.left=e.right,e.right=t}if(void 0!==e.bottom&&e.bottom<e.top){const t=e.top;e.top=e.bottom,e.bottom=t}}(t),t}function gn(e){const t=un(e);if(void 0===t.bottom||void 0===t.right)throw new Error("This does not support unbounded ranges");return t}function pn(e){const{bottom:t,top:o,left:s,right:n}=e;return!(void 0!==t&&isNaN(t)||isNaN(o)||isNaN(s)||void 0!==n&&isNaN(n))&&(mn(e)&&e.top>=0&&e.left>=0)}function mn(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 fn(e){const{top:t,bottom:o,left:s,right:n}=e,i="hasHeader"in e&&e.hasHeader,r=t===o&&s===n;if(void 0===o&&void 0!==n)return 0!==t||i?`${Lt(s,t)}:${Ot(n)}`:`${Ot(s)}:${Ot(n)}`;if(void 0===n&&void 0!==o)return 0!==s||i?`${Lt(s,t)}:${o+1}`:`${t+1}:${o+1}`;if(void 0!==o&&void 0!==n)return r?Lt(s,t):`${Lt(s,t)}:${Lt(n,o)}`;throw new Error(a("Bad zone format"))}function bn(e,t,o,s,n){const i="left"===t?"columns":"rows",r="before"===s?o-1:o,a=e["left"===t?"right":"bottom"];return e[t]<=r&&a&&a>r?Nn(e,i,"RESIZE",n):r<e[t]?Nn(e,i,"MOVE",n):{...e}}function vn(e,t,o,s,n){const i="left"===t?"columns":"rows",r="before"===s?o-1:o,a="left"===t?"right":"bottom";return e[t]<=r&&e[a]>r?Nn(e,i,"RESIZE",n):r<e[t]?Nn(e,i,"MOVE",n):{...e}}function Sn(e,t,o){const s="left"===t?"right":"bottom";let n=e[t],i=e[s];for(let r of o.sort(((e,t)=>t-e)))e[t]>r&&(n--,i--),e[t]<r&&e[s]>=r&&i--;return{...e,[t]:n,[s]:i}}function Cn(e,t,o){const s="left"===t?"right":"bottom";let n=e[t],i=e[s];const r=e[s];for(let s of o.sort(((e,t)=>t-e)))e[t]>s&&(n--,void 0!==i&&i--),void 0!==r&&void 0!==i&&e[t]<=s&&r>=s&&i--;if(!(void 0!==i&&n>i))return{...e,[t]:n,[s]:i}}function En(...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 yn(e,t){if(xn(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 wn(e,t){return e.left===t.left&&e.right===t.right&&e.top===t.top&&e.bottom===t.bottom}function xn(e,t){return!(e.bottom<t.top||t.bottom<e.top)&&!(e.right<t.left||t.right<e.left)}function In(e,t,o){const{left:s,right:n,top:i,bottom:r}=o;return e>=s&&e<=n&&t>=i&&t<=r}function Rn(e,t){return wn(En(t,e),t)}function Tn(e,t){const o=e.map(un),s=t.map(un),n=Math.max(...o.concat(s).map((e=>e.bottom||0))),i=Math.max(...o.concat(s).map((e=>e.right||0))),r=o.map((e=>({...e,bottom:void 0===e.bottom?n+1:e.bottom,right:void 0===e.right?i+1:e.right}))),a=s.map((e=>({...e,bottom:void 0===e.bottom?n+1:e.bottom,right:void 0===e.right?i+1:e.right}))),l=function(e,t){const o=new Set(t.map((({col:e,row:t})=>`${e}-${t}`)));return e.filter((({col:e,row:t})=>!o.has(`${e}-${t}`)))}(r.map(Mn).flat(),a.map(Mn).flat()),c=function(e){if(0===e.length)return[];const[t,...o]=[...e].sort(((e,t)=>e.row-t.row)).sort(((e,t)=>e.col-t.col)),s=[];let n=Ln(t);for(const{col:e,row:t}of o)if(!In(e,t,n))if(e===n.left&&t===n.bottom+1){const e=n.bottom+1;n={...n,bottom:e}}else s.push(n),n=Ln({col:e,row:t});return[...s,n]}(l);return function(e){if(0===e.length)return[];if(e.some((e=>e.left!==e.right)))throw new Error("only columns can be merged");const t=[],o=An(e),s=(e,t)=>e.top===t.top&&e.bottom===t.bottom&&e.right+1===t.left;for(;o.length;){const e=o.reduce(((e,t)=>s(e,t)?En(e,t):e),o.shift());t.push(e)}return An(t)}(c).map((e=>({...e,bottom:e.bottom===n+1?void 0:e.bottom,right:e.right===i+1?void 0:e.right}))).map(fn)}function An(e){const t=[...e].sort(((e,t)=>t.right-e.right)).sort(((e,t)=>t.bottom-e.bottom)).sort(((e,t)=>e.top-t.top)).sort(((e,t)=>e.left-t.left)).reverse(),o=[];for(;0!==t.length;){const e=t.shift();t.some((t=>Rn(e,t)))||o.push(e)}return o.reverse()}function On(e){return{numberOfRows:e.bottom-e.top+1,numberOfCols:e.right-e.left+1}}function _n(e){const{numberOfCols:t,numberOfRows:o}=On(e);return 1===t||1===o}function Mn(e){const t=[],[o,s]=[e.right,e.left].sort(((e,t)=>e-t)),[n,i]=[e.top,e.bottom].sort(((e,t)=>e-t));for(const e of Ne(o,s+1))for(const o of Ne(n,i+1))t.push({col:e,row:o});return t}function Nn(e,t,o,s){const n="both"===t?s[0]:"columns"===t?s:0,i="both"===t?s[1]:"rows"===t?s:0,r="hasHeader"in e&&e.hasHeader;let a;a=!function(e){return void 0===e.bottom}(e)||r?!(Pn(e)&&!r)||"columns"!==t:"rows"!==t;const l={...e};return a&&"MOVE"===o&&(l.left+=n,l.top+=i),void 0!==l.right&&(l.right+=n),void 0!==l.bottom&&(l.bottom+=i),l}function Fn(e,t){let o,s;const{left:n,right:i,top:r,bottom:a}=e,{left:l,right:c,top:h,bottom:d}=t;return o=l!=n?l:c!=i?c:l,s=h!=r?h:d!=a?d:h,{col:o,row:s}}function Dn(e){return{top:Math.min(e.top,e.bottom),bottom:Math.max(e.top,e.bottom),left:Math.min(e.left,e.right),right:Math.max(e.left,e.right)}}function Ln(e){return{left:e.col,right:e.col,top:e.row,bottom:e.row}}function Pn(e){return void 0===e.right}function Vn(e){return(e.bottom-e.top+1)*(e.right-e.left+1)}function kn(...e){return e.length<2||1===Tn(e.map(fn),[]).length}class Un{getSheetSize;_zone;parts;invalidXc;prefixSheet=!1;sheetId;invalidSheetName;constructor(e,t){this.getSheetSize=t,this._zone=e.zone,this.prefixSheet=e.prefixSheet,this.invalidXc=e.invalidXc,this.sheetId=e.sheetId,this.invalidSheetName=e.invalidSheetName;let o=[...e.parts];1===e.parts.length&&Vn(this.zone)>1?o.push({...e.parts[0]}):2===e.parts.length&&1===Vn(this.zone)&&o.pop(),this.parts=o}static fromRange(e,t){return e instanceof Un?e:new Un(e,t.getSheetSize)}get unboundedZone(){return this._zone}get zone(){const{left:e,top:t,bottom:o,right:s}=this._zone;if(void 0!==s&&void 0!==o)return this._zone;if(void 0===o&&void 0!==s)return{right:s,top:t,left:e,bottom:this.getSheetSize(this.sheetId).numberOfRows-1};if(void 0===s&&void 0!==o)return{bottom:o,left:e,top:t,right:this.getSheetSize(this.sheetId).numberOfCols-1};throw new Error(a("Bad zone format"))}static getRangeParts(e,t){const o=e.split(":").map((e=>{const t=an(e);return{colFixed:!t&&e.startsWith("$"),rowFixed:t?e.startsWith("$"):e.includes("$",1)}})),s=void 0===t.bottom,n=void 0===t.right;return s&&(o[0].rowFixed=o[0].rowFixed||o[1].rowFixed,o[1].rowFixed=o[0].rowFixed||o[1].rowFixed),n&&(o[0].colFixed=o[0].colFixed||o[1].colFixed,o[1].colFixed=o[0].colFixed||o[1].colFixed),o}get isFullCol(){return void 0===this._zone.bottom}get isFullRow(){return void 0===this._zone.right}get rangeData(){return{_zone:this._zone,_sheetId:this.sheetId}}orderZone(){if(mn(this._zone))return this;const e={...this._zone};let t=this.parts;if(void 0!==e.right&&e.right<e.left){let o=e.right;e.right=e.left,e.left=o,t=[{colFixed:t[1]?.colFixed||!1,rowFixed:t[0]?.rowFixed||!1},{colFixed:t[0]?.colFixed||!1,rowFixed:t[1]?.rowFixed||!1}]}if(void 0!==e.bottom&&e.bottom<e.top){let o=e.bottom;e.bottom=e.top,e.top=o,t=[{colFixed:t[0]?.colFixed||!1,rowFixed:t[1]?.rowFixed||!1},{colFixed:t[1]?.colFixed||!1,rowFixed:t[0]?.rowFixed||!1}]}return this.clone({zone:e,parts:t})}clone(e){return new Un({zone:e?.zone?e.zone:{...this._zone},sheetId:e?.sheetId?e.sheetId:this.sheetId,invalidSheetName:e&&"invalidSheetName"in e?e.invalidSheetName:this.invalidSheetName,invalidXc:e&&"invalidXc"in e?e.invalidXc:this.invalidXc,parts:e?.parts?e.parts:this.parts.map((e=>({rowFixed:e.rowFixed,colFixed:e.colFixed}))),prefixSheet:e?.prefixSheet?e.prefixSheet:this.prefixSheet},this.getSheetSize)}}function Bn(e,t,o){const s=o.sheetId===e?t:o.sheetId;return o.clone({sheetId:s})}function Hn(e,t,o){if(!o)return;const s=e.getRangeFromSheetXC(t,o);return s.invalidSheetName||s.invalidXc?void 0:s}function zn(e){const t=[];for(const o of e)for(const e of Mn(o.zone))t.push({...e,sheetId:o.sheetId});return t}function Gn(e,t,o){const s=[];return t.forEach((t=>{const n=function(e,t){e=e.toLocaleLowerCase();let o=0,s=0,n=(t=t.toLocaleLowerCase()).length,i=0;for(let r=0;r<n;r++)t[r]===e[i]?(i++,s+=100+s-r/200):s=0,o+=s;return i===e.length?o:0}(e,o(t));n>0&&s.push({score:n,elem:t})})),s.sort(((e,t)=>t.score-e.score)),s.map((e=>e.elem))}function $n(e){const t=[];for(let o=0;o<e;o++){const e={cells:{}};t.push(e)}return t}function Wn(e,t,o){return o.map((o=>o>=e?o+t:o))}function qn(e,t){return e=[...e].sort(((e,t)=>t-e)),t.map((t=>{for(const o of e)if(t>o)t--;else if(t===o)return;return t})).filter(We)}function Zn(e,t="Sheet"){let o=1,s=`${t}${o}`;for(;e.includes(s);)s=`${t}${o}`,o++;return s}function Yn(e,t){let o=1;const s=a("Copy of %s",e);let n=s.toString();for(;t.includes(n);)n=`${s} (${o})`,o++;return n}function jn(e,t){return void 0!==e&&void 0!==t&&Oe(e.trim().toUpperCase())===Oe(t.trim().toUpperCase())}function Xn(e,t=1){return t*(e+Z)-Z}function Kn(e,t,o,s){const n=ni(e,t,o,"wrap"===o?.wrapping?s-2*Z:void 0).length;return Xn(oi(o),n)+2*Y}const Qn={};function Jn(e,t,o){const s=ti(o);if(Qn[s]||(Qn[s]={}),void 0===Qn[s][t]){e.save(),e.font=s;const o=e.measureText(t).width;e.restore(),Qn[s][t]=o}return Qn[s][t]}function ei(e){return Math.round(96*e/72)}function ti(e){return`${e.italic?"italic ":""}${e.bold?"bold":se} ${oi(e)}px ${ie}`}function oi(e){return ei(e?.fontSize||ne)}function si(e,t,o,s){if(Jn(e,t,s)<=o)return[t];const n=[];let i="";for(let r of t){Jn(e,i+r,s)>o?(n.push(i),i=r):i+=r}return n.push(i),n}function ni(e,t,o,s){o||(o={}),Ve(t)&&(t=Be(t).label);const n=[],i=t.includes(xe)?t.split(xe):[t];for(const t of i){const i=t.includes(" ")?t.split(" "):[t];if(!s){n.push(t);continue}let r="",a=s;for(let t of i){const i=si(e,t,s,o),l=i.pop(),c=Jn(e,l,o);if(i.length)""!==r&&(n.push(r),r="",a=s),i.forEach((e=>{n.push(e)})),r=l,a=s-c;else{const t=""===r?l:" "+l,i=Jn(e,t,o);i<=a?(r+=t,a-=i):(n.push(r),r=l,a=s-c)}}""!==r&&n.push(r)}return n}function ii(e){return e?e.toLowerCase():""}const ri=/([0-9\.]*)px/;function ai(e,t,o,s=!1,n=!1,i=function(e){return Number(e.match(ri)?.[1])}(e.font)/10){if(e.fillText(t,o.x,o.y),!s&&!n)return;const r=e.measureText(t),a=r.width,l=r.actualBoundingBoxAscent+r.actualBoundingBoxDescent,c=r.fontBoundingBoxAscent+r.fontBoundingBoxDescent;let{x:h,y:d}=o,u=d,g=d;switch(e.textAlign){case"center":h-=a/2;break;case"right":h-=a}switch(e.textBaseline){case"top":g+=c-2*i,u+=c/2-i;break;case"middle":g+=c/2-i;break;case"alphabetic":g+=2*i,u-=3*i;break;case"bottom":g=d,u-=l/2-i/2}s&&(e.lineWidth=i,e.strokeStyle=e.fillStyle,e.beginPath(),e.moveTo(h,g),e.lineTo(h+a,g),e.stroke()),n&&(e.lineWidth=i,e.strokeStyle=e.fillStyle,e.beginPath(),e.moveTo(h,u),e.lineTo(h+a,u),e.stroke())}class li{isFastIdStrategy=!1;fastIdStart=0;setIsFastStrategy(e){this.isFastIdStrategy=e}smallUuid(){return this.isFastIdStrategy?(this.fastIdStart++,String(this.fastIdStart)):window.crypto?"10000000-1000".replace(/[01]/g,(e=>{const t=Number(e);return(t^crypto.getRandomValues(new Uint8Array(1))[0]&15>>t/4).toString(16)})):"xxxxxxxx-xxxx".replace(/[xy]/g,(function(e){var t=16*Math.random()|0;return("x"==e?t:3&t|8).toString(16)}))}uuidv4(){return this.isFastIdStrategy?(this.fastIdStart++,String(this.fastIdStart)):window.crypto?"10000000-1000-4000-8000-100000000000".replace(/[018]/g,(e=>{const 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){var t=16*Math.random()|0;return("x"==e?t:3&t|8).toString(16)}))}}function ci(e){return e.map(di).sort(((e,t)=>e.sequence-t.sequence))}const hi=new li;function di(e){const t=e.name,o=e.children,s=e.description,n=e.icon;return{id:e.id||hi.uuidv4(),name:"function"==typeof t?t:()=>t,isVisible:e.isVisible?e.isVisible:()=>!0,isEnabled:e.isEnabled?e.isEnabled:()=>!0,isActive:e.isActive,execute:e.execute,children:o?e=>o.map((t=>"function"==typeof t?t(e):t)).flat().map(di):()=>[],isReadonlyAllowed:e.isReadonlyAllowed||!1,separator:e.separator||!1,icon:"function"==typeof n?n:()=>n||"",description:"function"==typeof s?s:()=>s||"",textColor:e.textColor,sequence:e.sequence||0}}function ui(e,t){return"REMOVE_COLUMNS_ROWS"===t.type?Cn(e,"COL"===t.dimension?"left":"top",t.elements):"ADD_COLUMNS_ROWS"===t.type?bn(e,"COL"===t.dimension?"left":"top",t.base,t.position,t.quantity):e}function gi(e,t){const o="DELETE_SHEET"===t.type&&t.sheetId;if("sheetId"in t&&e._sheetId!==t.sheetId)return e;{const s=ui(e._zone,t);if(s&&o!==e._sheetId)return{...e,_zone:s}}}class pi extends t.Component{static template="o-spreadsheet-ChartJsComponent";canvas=t.useRef("graphContainer");chart;get background(){return this.chartRuntime.background}get canvasStyle(){return`background-color: ${this.background}`}get chartRuntime(){const e=this.env.model.getters.getChartRuntime(this.props.figure.id);if(!("chartJsConfig"in e))throw new Error("Unsupported chart runtime");return e}setup(){t.onMounted((()=>{const e=this.chartRuntime;this.createChart(Ae(e.chartJsConfig))})),t.useEffect((()=>this.updateChartJs(Ae(this.chartRuntime))),(()=>[this.chartRuntime,window.devicePixelRatio]))}createChart(e){const t=this.canvas.el.getContext("2d");this.chart=new window.Chart(t,e)}updateChartJs(e){const t=e.chartJsConfig;t.data&&t.data.datasets?(this.chart.data=t.data,t.options?.plugins?.title&&(this.chart.config.options.plugins.title=t.options.plugins.title),t.options&&"valueLabel"in t.options&&t.options?.valueLabel&&(this.chart.config.options.valueLabel=t.options.valueLabel)):this.chart.data.datasets=[],this.chart.config.options.plugins.tooltip=t.options.plugins.tooltip,this.chart.config.options.plugins.legend=t.options.plugins.legend,this.chart.config.options.scales=t.options?.scales,this.chart.update()}}pi.props={figure:Object};class mi{sheetId;title;getters;constructor(e,t,o){this.title=e.title,this.sheetId=t,this.getters=o}static validateChartDefinition(e,t){throw new Error("This method should be implemented by sub class")}static transformDefinition(e,t){throw new Error("This method should be implemented by sub class")}static getDefinitionFromContextCreation(e){throw new Error("This method should be implemented by sub class")}}function fi(e,t,o,s){let n=!1;const i=[];for(let s in o){let r=o[s];if(r.labelCell){const e=Si(r.labelCell,t);r.labelCell!==e&&(n=!0,r={...r,labelCell:e})}const a=Si(r.dataRange,t);void 0===a||e.getRangeString(a,a.sheetId)===ce?(n=!0,r=void 0):a!==r.dataRange&&(n=!0,r={...r,dataRange:a}),i[s]=r}let r=s;const a=Si(r,t);a!==r&&(n=!0,r=a);return{isStale:n,dataSets:i.filter(We),labelRange:r}}function bi(e,t,o){return o.map((o=>({dataRange:Bn(e,t,o.dataRange),labelCell:o.labelCell?Bn(e,t,o.labelCell):void 0})))}function vi(e,t,o){return o?Bn(e,t,o):void 0}function Si(e,t){if(!e)return;const o=t(e);switch(o.changeType){case"NONE":return e;case"REMOVE":return;default:return o.range}}function Ci(e,t,o,s){const n=[];for(const i of t){const t=e.getRangeFromSheetXC(o,i),{unboundedZone:r,sheetId:a,invalidSheetName:l,invalidXc:c}=t;if(!l&&!c)if(r.left!==r.right&&r.top!==r.bottom){if(void 0===r.right)continue;for(let t=r.left;t<=r.right;t++){const o={...r,left:t,right:t};n.push(Ei(e,a,o,s?{top:o.top,bottom:o.top,left:o.left,right:o.left}:void 0))}}else n.push(Ei(e,a,r,s?{top:r.top,bottom:r.top,left:r.left,right:r.left}:void 0))}return n}function Ei(e,t,o,s){if(o.left!==o.right&&o.top!==o.bottom)throw new Error(`Zone should be a single column or row: ${fn(o)}`);if(s){const n=fn(o),i=fn(s);return{labelCell:e.getRangeFromSheetXC(t,i),dataRange:e.getRangeFromSheetXC(t,n)}}return{labelCell:void 0,dataRange:e.getRangeFromSheetXC(t,fn(o))}}function yi(e,t){const o=t.labelCell?.zone;let s=t.dataRange.zone;if(o){const{numberOfRows:e,numberOfCols:t}=On(s);1===e?s={...s,left:s.left+1}:1===t&&(s={...s,top:s.top+1})}const n=t.dataRange.clone({zone:s});return{label:t.labelCell?e.getRangeString(t.labelCell,"forceSheetReference",{useFixedReference:!0}):void 0,range:e.getRangeString(n,"forceSheetReference",{useFixedReference:!0})}}function wi(e,t,o){if(!t)return;let s={...t.zone};o&&t.zone.bottom>t.zone.top&&(s.top=s.top+1);const n=t.clone({zone:s});return e.getRangeString(n,"forceSheetReference",{useFixedReference:!0})}function xi(e,t){let o;if(e.labelRange){const s=ui(un(e.labelRange),t);o=s?fn(s):void 0}const s=e.dataSets.map(un).map((e=>ui(e,t))).filter(We).map(fn);return{...e,labelRange:o,dataSets:s}}const Ii=["rgb(31,119,180)","rgb(255,127,14)","rgb(174,199,232)","rgb(255,187,120)","rgb(44,160,44)","rgb(152,223,138)","rgb(214,39,40)","rgb(255,152,150)","rgb(148,103,189)","rgb(197,176,213)","rgb(140,86,75)","rgb(196,156,148)","rgb(227,119,194)","rgb(247,182,210)","rgb(127,127,127)","rgb(199,199,199)","rgb(188,189,34)","rgb(219,219,141)","rgb(23,190,207)","rgb(158,218,229)"];class Ri{graphColorIndex=0;next(){return Ii[this.graphColorIndex++%Ii.length]}}function Ti(e){return e&&yt(e)<.3?"#FFFFFF":"#000000"}function Ai(e){if(e.dataSets){const t=void 0!==e.dataSets.find((e=>!nn.test(e)));if(t)return"InvalidDataSet";if(e.dataSets.map(un).some((e=>e.top!==e.bottom&&Pn(e))))return"InvalidDataSet"}return"Success"}function Oi(e){if(e.labelRange){if(!nn.test(e.labelRange||""))return"InvalidLabelRange"}return"Success"}function _i(e,t,o){if(!o)return!1;if(!e)return!1;if(!t)return!0;const s=Vn(t.dataRange.zone);return!(Vn(e.zone)<s)}function Mi(e,t,o,s){if(e){if("text"===o||t?.type!==bo.number||e.type!==bo.number)return e.formattedValue;{let n=t.value-e.value;if("percentage"===o&&0!==n&&(n=n/e.value*100),"percentage"!==o&&e.format)return Ts(n,{format:e.format,locale:s});const i=Math.abs(parseFloat(n.toFixed(2))).toLocaleString();return"percentage"===o?i+"%":i}}return""}function Ni(e,t,o,s,n){if("text"===t||e?.type!==bo.number||o?.type!==bo.number)return;const i=o.value-e.value;return i>0?s:i<0?n:void 0}function Fi(e,t,o){if("text"===o||e?.type!==bo.number||t?.type!==bo.number)return"neutral";const s=t.value-e.value;return s>0?"up":s<0?"down":"neutral"}function Di(e){return e.keyValue&&!nn.test(e.keyValue)?"InvalidScorecardKeyValue":"Success"}function Li(e){return e.baseline&&!nn.test(e.baseline)?"InvalidScorecardBaseline":"Success"}const Pi=new window.Path2D("M8.6 4.8a.5.5 0 0 1 0 .75l-3.9 3.9a.5 .5 0 0 1 -.75 0l-3.8 -3.9a.5 .5 0 0 1 0 -.75l.4-.4a.5.5 0 0 1 .75 0l2.3 2.4v-5.7c0-.25.25-.5.5-.5h.6c.25 0 .5.25.5.5v5.8l2.3 -2.4a.5.5 0 0 1 .75 0z"),Vi=new window.Path2D("M8.7 5.5a.5.5 0 0 0 0-.75l-3.8-4a.5.5 0 0 0-.75 0l-3.8 4a.5.5 0 0 0 0 .75l.4.4a.5.5 0 0 0 .75 0l2.3-2.4v5.8c0 .25.25.5.5.5h.6c.25 0 .5-.25.5-.5v-5.8l2.2 2.4a.5.5 0 0 0 .75 0z");let ki=class e extends mi{keyValue;baseline;baselineMode;baselineDescr;background;baselineColorUp;baselineColorDown;fontColor;type="scorecard";constructor(e,t,o){super(e,t,o),this.keyValue=Hn(o,t,e.keyValue),this.baseline=Hn(o,t,e.baseline),this.baselineMode=e.baselineMode,this.baselineDescr=e.baselineDescr,this.background=e.background,this.baselineColorUp=e.baselineColorUp,this.baselineColorDown=e.baselineColorDown}static validateChartDefinition(e,t){return e.checkValidations(t,Di,Li)}static getDefinitionFromContextCreation(e){return{background:e.background,type:"scorecard",keyValue:e.range?e.range[0]:void 0,title:e.title||"",baselineMode:pe,baselineColorUp:me,baselineColorDown:fe,baseline:e.auxiliaryRange||""}}static transformDefinition(e,t){let o,s;return e.baseline&&(o=ui(un(e.baseline),t)),e.keyValue&&(s=ui(un(e.keyValue),t)),{...e,baseline:o?fn(o):void 0,keyValue:s?fn(s):void 0}}copyForSheetId(t){const o=vi(this.sheetId,t,this.baseline),s=vi(this.sheetId,t,this.keyValue),n=this.getDefinitionWithSpecificRanges(o,s,t);return new e(n,t,this.getters)}copyInSheetId(t){const o=this.getDefinitionWithSpecificRanges(this.baseline,this.keyValue,t);return new e(o,t,this.getters)}getDefinition(){return this.getDefinitionWithSpecificRanges(this.baseline,this.keyValue)}getContextCreation(){return{background:this.background,title:this.title,range:this.keyValue?[this.getters.getRangeString(this.keyValue,this.sheetId)]:void 0,auxiliaryRange:this.baseline?this.getters.getRangeString(this.baseline,this.sheetId):void 0}}getDefinitionWithSpecificRanges(e,t,o){return{baselineColorDown:this.baselineColorDown,baselineColorUp:this.baselineColorUp,baselineMode:this.baselineMode,title:this.title,type:"scorecard",background:this.background,baseline:e?this.getters.getRangeString(e,o||this.sheetId):void 0,baselineDescr:this.baselineDescr,keyValue:t?this.getters.getRangeString(t,o||this.sheetId):void 0}}getDefinitionForExcel(){}updateRanges(t){const o=Si(this.baseline,t),s=Si(this.keyValue,t);if(this.baseline===o&&this.keyValue===s)return this;const n=this.getDefinitionWithSpecificRanges(o,s);return new e(n,this.sheetId,this.getters)}};function Ui(e,t){const o=t.getContext("2d"),s=window.devicePixelRatio||1;if(t.width=e.canvas.width*s,t.height=e.canvas.height*s,o.scale(s,s),o.fillStyle=e.canvas.backgroundColor,o.fillRect(0,0,e.canvas.width,e.canvas.height),e.title&&(o.font=e.title.style.font,o.fillStyle=e.title.style.color,o.fillText(e.title.text,e.title.position.x,e.title.position.y)),e.baseline&&(o.font=e.baseline.style.font,o.fillStyle=e.baseline.style.color,ai(o,e.baseline.text,e.baseline.position,e.baseline.style.underline,e.baseline.style.strikethrough)),e.baselineArrow&&e.baselineArrow.style.size>0){o.save(),o.fillStyle=e.baselineArrow.style.color,o.translate(e.baselineArrow.position.x,e.baselineArrow.position.y);const t=e.baselineArrow.style.size/10;switch(o.scale(t,t),e.baselineArrow.direction){case"down":o.fill(Pi);break;case"up":o.fill(Vi)}o.restore()}e.baselineDescr&&(o.font=e.baselineDescr.style.font,o.fillStyle=e.baselineDescr.style.color,o.fillText(e.baselineDescr.text,e.baselineDescr.position.x,e.baselineDescr.position.y)),e.key&&(o.font=e.key.style.font,o.fillStyle=e.key.style.color,ai(o,e.key.text,e.key.position,e.key.style.underline,e.key.style.strikethrough))}function Bi(e,t=!1,o=!1){return`${o?"italic":""} ${t?"bold":""} ${e}px ${ie}`}function Hi({width:e,height:t},o){return new zi({width:e,height:t},o).computeDesign()}class zi{runtime;context;width;height;constructor({width:e,height:t},o){this.runtime=o;const s=document.createElement("canvas");this.width=s.width=e,this.height=s.height=t,this.context=s.getContext("2d")}computeDesign(){const e={canvas:{width:this.width,height:this.height,backgroundColor:this.backgroundColor}},t=this.getTextStyles(),{height:o}=this.getTextDimensions(this.title,t.title.font);this.title&&(e.title={text:this.title,style:t.title,position:{x:this.chartPadding,y:this.chartPadding+o}});const s=t.baselineArrow?.size??0,{height:n,width:i}=this.getTextDimensions(this.baseline,t.baselineValue.font),{width:r}=this.getTextDimensions(this.baselineDescr,t.baselineDescr.font);e.baseline={text:this.baseline,style:t.baselineValue,position:{x:(this.width-i-r+s)/2,y:this.keyValue?this.height-2*this.chartPadding:this.height-(this.height-o-n)/2-this.chartPadding}},t.baselineArrow&&(e.baselineArrow={direction:this.baselineArrow,style:t.baselineArrow,position:{x:e.baseline.position.x-s,y:e.baseline.position.y-(n+s)/2}}),this.baselineDescr&&(e.baselineDescr={text:this.baselineDescr,style:t.baselineDescr,position:{x:e.baseline.position.x+i,y:e.baseline.position.y}});const{height:a,width:l}=this.getTextDimensions(this.keyValue,t.keyValue.font);return this.keyValue&&(e.key={text:this.keyValue,style:t.keyValue,position:{x:(this.width-l)/2,y:(this.height-n+o+a)/2-this.chartPadding}}),e}get title(){return this.runtime.title}get keyValue(){return this.runtime.keyValue}get baseline(){return this.runtime.baselineDisplay}get baselineDescr(){return function(e,t){const o=e||"";return t&&o?" "+o:o}(this.runtime.baselineDescr,this.baseline)}get baselineArrow(){return this.runtime.baselineArrow}get backgroundColor(){return this.runtime.background}get secondaryFontColor(){return yt(this.backgroundColor)>.3?"#525252":"#C8C8C8"}get chartPadding(){return.02*this.width}getTextDimensions(e,t){this.context.font=t;const o=this.context.measureText(e);return{width:o.width,height:o.actualBoundingBoxAscent+o.actualBoundingBoxDescent}}getTextStyles(){const e=.96*this.width,t=this.getWidestElement(),o=t.getElementMaxFontSize(this.getDrawableHeight(),this);let s=function(e,t,o,s=.25){let n=1;if(o(n)>e)return n;if(o(t)<e)return t;let i=(n+t)/2,r=o(i),a=0;for(;Math.abs(r-e)>s&&a<20;)r>=e?t=(n+t)/2:n=(n+t)/2,i=(n+t)/2,r=o(i),a++;return i}(e,o,(e=>t.getElementWidth(e,this.context,this)))/o;const n=new Wi(this.runtime.keyValueStyle).getElementMaxFontSize(this.getDrawableHeight(),this)*s,i=new $i(this.runtime.baselineStyle).getElementMaxFontSize(this.getDrawableHeight(),this)*s;return{title:{font:Bi(18),color:this.secondaryFontColor},keyValue:{color:this.runtime.keyValueStyle?.textColor||this.runtime.fontColor,font:Bi(n,this.runtime.keyValueStyle?.bold,this.runtime.keyValueStyle?.italic),strikethrough:this.runtime.keyValueStyle?.strikethrough,underline:this.runtime.keyValueStyle?.underline},baselineValue:{font:Bi(i,this.runtime.baselineStyle?.bold,this.runtime.baselineStyle?.italic),strikethrough:this.runtime.baselineStyle?.strikethrough,underline:this.runtime.baselineStyle?.underline,color:this.runtime.baselineStyle?.textColor||this.runtime.baselineColor||this.secondaryFontColor},baselineDescr:{font:Bi(.9*i),color:this.secondaryFontColor},baselineArrow:"neutral"===this.baselineArrow?void 0:{size:this.keyValue?.8*i:0,color:this.runtime.baselineColor||this.secondaryFontColor}}}getDrawableHeight(){const e=2*this.chartPadding;let t=this.height-e;return t-=this.title?18*1.2:0,t}getWidestElement(){const e=new $i(this.runtime.baselineStyle),t=new Wi(this.runtime.keyValueStyle);return e.getElementWidth(.35,this.context,this)>t.getElementWidth(.65,this.context,this)?e:t}}class Gi{style;constructor(e={}){this.style=e}measureTextWidth(e,t,o){return e.font=Bi(o,this.style.bold,this.style.italic),e.measureText(t).width}}class $i extends Gi{getElementWidth(e,t,o){if(!o.runtime)return 0;const s=o.baseline,n="neutral"!==o.baselineArrow?"A "+s:s;let i=this.measureTextWidth(t,n,e);return i+=this.measureTextWidth(t,o.baselineDescr,.9*e),i}getElementMaxFontSize(e,t){if(!t.runtime)return 0;return(""!==t.baseline||t.baselineDescr?.35*e:0)/1.2}}class Wi extends Gi{getElementWidth(e,t,o){if(!o.runtime)return 0;const s=o.keyValue||"";return this.measureTextWidth(t,s,e)}getElementMaxFontSize(e,t){if(!t.runtime)return 0;return(""!==t.baseline||t.baselineDescr?.65*e:e)/1.2}}class qi extends t.Component{static template="o-spreadsheet-ScorecardChart";canvas=t.useRef("chartContainer");get runtime(){return this.env.model.getters.getChartRuntime(this.props.figure.id)}setup(){t.useEffect(this.createChart.bind(this),(()=>{const e=this.canvas.el.getBoundingClientRect();return[e.width,e.height,this.runtime,this.canvas.el,window.devicePixelRatio]}))}createChart(){const e=this.canvas.el;Ui(Hi(e.getBoundingClientRect(),this.runtime),e)}}qi.props={figure:Object};class Zi{content={};add(e,t){return this.content[e]=t,this}get(e){const t=this.content[e];if(!t&&!(e in this.content))throw new Error(`Cannot find ${e} in this registry!`);return t}contains(e){return e in this.content}getAll(){return Object.values(this.content)}getKeys(){return Object.keys(this.content)}remove(e){delete this.content[e]}}function Yi(e){return/^https?:\/\//i.test(e)?e:`https://${e}`}const ji=new Zi;function Xi(e,t){return{url:e=Yi(e),label:t||e,isExternal:!0,isUrlEditable:!0}}ji.add("sheet_URL",{match:e=>ze(e),createLink:(e,t)=>({label:t,url:e,isExternal:!1,isUrlEditable:!1}),urlRepresentation(e,t){const o=$e(e);return t.tryGetSheetName(o)||a("Invalid sheet")},open(e,t){const o=$e(e);t.model.dispatch("ACTIVATE_SHEET",{sheetIdFrom:t.model.getters.getActiveSheetId(),sheetIdTo:o})},sequence:0});const Ki={createLink:Xi,match:e=>ke(e),open:e=>window.open(e,"_blank"),urlRepresentation:e=>e,sequence:0};function Qi(e){return ji.getAll().sort(((e,t)=>e.sequence-t.sequence)).find((t=>t.match(e)))||Ki}function Ji(e,t){return Qi(e.url).urlRepresentation(e.url,t)}function er(e,t){Qi(e.url).open(e.url,t)}function tr(e){if("string"==typeof e){if(Ve(e)){const{label:t,url:o}=Be(e);return Qi(o).createLink(o,t)}return ke(e)?Xi(e):void 0}}function or(e,t){return nr(sr(e||"",t.locale),t)}function sr(e,t){if(e.startsWith("="))throw new Error(`Cannot parse "${e}" because it's not a literal value. It's a formula`);return go(e,Oo)?Vo(e,Oo):jt(e,t)?Vo(e,t):function(e){const t=e.toUpperCase();return"TRUE"===t||"FALSE"===t}(e)?"TRUE"===e.toUpperCase():e}function nr(e,t){const o=tr(e);return o?{...ir(sr(o.label,t.locale),{format:t.format||Hs(o.label,t.locale)||zs(o.label),locale:t.locale}),link:o}:ir(e,t)}function ir(e,t){try{for(const o of cr){const s=o(e,t);if(s)return s}return function(e,t){return{type:bo.text,value:e,format:t.format,isAutoSummable:!0,defaultAlign:"left",formattedValue:Ts(e,t)}}((e||"").toString(),t)}catch(e){return lr(new d(c.GenericError,e.message||Ce))}}function rr(e,t){return{type:bo.number,value:e||0,format:t.format,isAutoSummable:!0,defaultAlign:"right",formattedValue:Ts(e,t)}}const ar={type:bo.empty,value:"",format:void 0,isAutoSummable:!0,defaultAlign:"left",formattedValue:""};function lr(e){return{type:bo.error,value:e.errorType,error:e,isAutoSummable:!1,defaultAlign:"center",formattedValue:e.errorType}}const cr=[function(e,t){if(""===e)return function(e){return void 0===e.format?ar:{type:bo.empty,value:"",format:e.format,isAutoSummable:!0,defaultAlign:"left",formattedValue:""}}(t)},function(e,t){if(t.format&&"number"==typeof e&&Ds(t.format))return function(e,t){const o=Ts(e,t);return{type:bo.number,value:e,format:t.format,isAutoSummable:!1,defaultAlign:"right",formattedValue:o}}(e,t)},function(e,t){return"number"==typeof e?rr(e,t):null===e?rr(0,t):void 0},function(e,t){if("boolean"==typeof e)return function(e,t){const o=e?"TRUE":"FALSE";return{type:bo.boolean,value:e,format:t.format,isAutoSummable:!1,defaultAlign:"center",formattedValue:o}}(e,t)}],hr=new Zi;hr.add("ALPHANUMERIC_INCREMENT_MODIFIER",{apply:(e,t)=>{e.current+=e.increment;const o=`${e.prefix}${e.current.toString().padStart(e.numberPostfixLength||0,"0")}`;return{cellData:{border:t.border,style:t.cell&&t.cell.style,format:t.cell&&t.cell.format,content:o},tooltip:{props:{content:o}}}}}).add("INCREMENT_MODIFIER",{apply:(e,t,o)=>{e.current+=e.increment;const s=e.current.toString(),n=o.getLocale(),i=Ts(e.current,{format:t.cell?.format,locale:n});return{cellData:{border:t.border,style:t.cell&&t.cell.style,format:t.cell&&t.cell.format,content:s},tooltip:s?{props:{content:i}}:void 0}}}).add("COPY_MODIFIER",{apply:(e,t,o)=>{const s=t.cell?.content||"",n={locale:o.getLocale(),format:t.cell?.format};return{cellData:{border:t.border,style:t.cell&&t.cell.style,format:t.cell&&t.cell.format,content:s},tooltip:s?{props:{content:or(t.cell?.content,n).formattedValue}}:void 0}}}).add("FORMULA_MODIFIER",{apply:(e,t,o,s)=>{e.current+=e.increment;let n=0,i=0;switch(s){case"up":n=0,i=-e.current;break;case"down":n=0,i=e.current;break;case"left":n=-e.current,i=0;break;case"right":n=e.current,i=0}const r=t.cell;if(!r||!r.isFormula)return{cellData:{}};const a=t.sheetId,l=o.getTranslatedCellFormula(a,n,i,r.compiledFormula);return{cellData:{border:t.border,style:r.style,format:r.format,content:l},tooltip:l?{props:{content:l}}:void 0}}});const dr=new Zi,ur=/(\d+)$/,gr=/^(.*\D+)/,pr=/^(.*\D+)(\d+)$/;function mr(e,t,o){let s=[],n=!1;for(let i of t){i===e&&(n=!0);const t=i?.isFormula?void 0:or(i?.content,{locale:Oo});if(t&&o(t))s.push(t);else{if(n)return s;s=[]}}return s}function fr(e){let t=1;return e.length>=2&&(t=function(e){const t=[];let o=e[0];for(let s=1;s<e.length;s++){const n=e[s];t.push(n-o),o=n}return t.reduce(((e,t)=>e+t),0)/t.length}(e)*e.length),t}dr.add("simple_value_copy",{condition:(e,t)=>!(1!==t.length||e.isFormula||e.format&&Ds(e.format)),generateRule:()=>({type:"COPY_MODIFIER"}),sequence:10}).add("increment_alphanumeric_value",{condition:e=>!e.isFormula&&or(e.content,{locale:Oo}).type===bo.text&&pr.test(e.content),generateRule:(e,t,o)=>{const s=parseInt(e.content.match(ur)[0]),n=e.content.match(gr)[0],i=e.content.length-n.length,r=mr(e,t,(e=>e.type===bo.text&&pr.test(e.value))).filter((e=>n===e.value.toString().match(gr)[0])).map((e=>parseInt(e.value.toString().match(ur)[0])));let a=fr(r);return["up","left"].includes(o)&&1===r.length&&(a=-a),{type:"ALPHANUMERIC_INCREMENT_MODIFIER",prefix:n,current:s,increment:a,numberPostfixLength:i}},sequence:15}).add("copy_text",{condition:e=>!e.isFormula&&or(e.content,{locale:Oo}).type===bo.text,generateRule:()=>({type:"COPY_MODIFIER"}),sequence:20}).add("update_formula",{condition:e=>e.isFormula,generateRule:(e,t)=>({type:"FORMULA_MODIFIER",increment:t.length,current:0}),sequence:30}).add("increment_number",{condition:e=>!e.isFormula&&or(e.content,{locale:Oo}).type===bo.number,generateRule:(e,t,o)=>{const s=mr(e,t,(e=>e.type===bo.number)).map((e=>Number(e.value)));let n=fr(s);["up","left"].includes(o)&&1===s.length&&(n=-n);const i=or(e.content,{locale:Oo});return{type:"INCREMENT_MODIFIER",increment:n,current:i.type===bo.number?i.value:0}},sequence:40});const br={};let vr=0;function Sr(e,...t){const o="__sheet__"+vr++;return function(e,t){const o=document.createElement("style");o.textContent=function(e){const t=e.split(/(\{|\}|;)/).map((e=>e.trim())),o=[],s=[];let n=[];function i(e,t){const s=[];for(const n of o[e]){let r=t&&t+" "+n||n;r.includes("&")&&(r=n.replace(/&/g,t||"")),e<o.length-1&&(r=i(e+1,r)),s.push(r)}return s.join(", ")}function r(){n.length&&(s.push(i(0)+" {"),s.push(...n),s.push("}"),n=[])}for(;t.length;){let e=t.shift();"}"===e?(r(),o.pop()):("{"===t[0]&&(r(),o.push(e.split(/\s*,\s*/)),t.shift()),";"===t[0]&&n.push(" "+e+";"))}return s.join("\n")}(t),br[e]=o}(o,String.raw(e,...t)),function(e){const t=br[e];t.setAttribute("component",e),document.head.appendChild(t)}(o),o}function Cr({strikethrough:e,underline:t}){return e||t?`${e?"line-through":""} ${t?"underline":""}`:"none"}function Er(e){const t=function(e){const t={};if(!e)return t;e.bold&&(t["font-weight"]="bold");e.italic&&(t["font-style"]="italic");if(e.strikethrough||e.underline){let o=e.strikethrough?"line-through":"";o=e.underline?o+" underline":o,t["text-decoration"]=o}e.textColor&&(t.color=e.textColor);return t}(e);return e?(e.fillColor&&(t.background=e.fillColor),t):t}function yr(e){let t="";for(const o in e)e[o]&&(t+=`${o}:${e[o]}; `);return t}Sr`
1
+ !function(e,t){"use strict";const o=e=>e,s=()=>!1;let n=o,i=s;function r(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 o=t[0];e=e.replace(/\%\(([^\)]+)\)s/g,((e,t)=>o[t]))}return e}const a=function(e,...t){return i()?r(n(e),...t):new l(e,t)};class l extends String{values;constructor(e,t){super(e),this.values=t}valueOf(){const e=super.valueOf();return i()?r(n(e),...this.values):r(e,...this.values)}toString(){return this.valueOf()}}var c,h;!function(e){e.NotAvailable="#N/A",e.InvalidReference="#REF",e.BadExpression="#BAD_EXPR",e.CircularDependency="#CYCLE",e.UnknownFunction="#NAME?",e.GenericError="#ERROR"}(c||(c={})),function(e){e[e.silent=0]="silent",e[e.error=1]="error"}(h||(h={}));class d extends Error{errorType;logLevel;constructor(e,t,o=h.error){super(t),this.errorType=e,this.logLevel=o}get isVerbose(){return this.logLevel>h.silent}}class u extends d{constructor(e){super(c.BadExpression,e)}}class g extends d{constructor(){super(c.CircularDependency,a("Circular reference"))}}class p extends d{constructor(){super(c.InvalidReference,a("Invalid reference"))}}class m extends d{constructor(e=void 0){super(c.NotAvailable,e||a("Data not available"),e?h.error:h.silent)}}class f extends d{constructor(e){super(c.UnknownFunction,a('Unknown function: "%s"',e))}}const b=.5,v="#f5f5f5",S="#F8F9FA",C="#E8EAED",E="#595959",y="#666666",w="#c9ccd2",x="#3266ca",I="#FFFFFF",R="#EBEBEB",T="#CACACA",A=11982760,O="#01666b",_="#188038",M="#E6F4EA",N="#CEEAD6",F="#E0E2E4",D="#4A4F59",L="#999",P="#E2E3E3",V="#BCBCBC",k="#9B359B",U=["#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"],B=26,H=48,z=96,G=23,$=15,W=18,q=14,Z=4,Y=3,j=Z,X=21,K=17,Q=2*G,J=250,ee={align:"left",verticalAlign:"bottom",wrapping:"overflow",bold:!1,italic:!1,strikethrough:!1,underline:!1,fontSize:10,fillColor:"",textColor:""},te=ee.verticalAlign,oe=ee.wrapping,se="400",ne=ee.fontSize,ie="'Roboto', arial",re="thin",ae="#000000",le={style:"thin",color:_},ce=c.InvalidReference,he="START_REVISION",de=1,ue=20,ge="??",pe="difference",me="#00A04A",fe="#DC6965",be=["'","*","?","/","\\","[","]"],ve=/'|\*|\?|\/|\\|\[|\]/,Se="|",Ce=a("Invalid expression");var Ee;!function(e){e[e.Grid=0]="Grid",e[e.Highlight=5]="Highlight",e[e.HeaderGroupingButton=6]="HeaderGroupingButton",e[e.Figure=10]="Figure",e[e.ScrollBar=15]="ScrollBar",e[e.GridPopover=19]="GridPopover",e[e.GridComposer=20]="GridComposer",e[e.Dropdown=21]="Dropdown",e[e.IconPicker=25]="IconPicker",e[e.TopBarComposer=30]="TopBarComposer",e[e.Popover=35]="Popover",e[e.FigureAnchor=1e3]="FigureAnchor",e[e.FigureSnapLine=1001]="FigureSnapLine"}(Ee||(Ee={}));let ye=0;function we(){return ye}const xe="\n",Ie=[6,7,8,9,10,11,12,14,18,24,36];function Re(e){return'"'===e[0]&&(e=e.slice(1)),'"'===e[e.length-1]&&"\\"!==e[e.length-2]?e.slice(0,e.length-1):e}function Te(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Ae(e){const t=Array.isArray(e)?[]:{};switch(typeof e){case"object":if(null===e)return e;if(function(e){return"clone"in e&&e.clone instanceof Function}(e))return e.clone();if(!(function(e){return"object"==typeof e&&null!==e&&(e?.constructor===Object||void 0===e?.constructor)}(e)||e instanceof Array))throw new Error("Unsupported type: only objects and arrays are supported");for(const o in e)t[o]=Ae(e[o]);return t;case"number":case"string":case"boolean":case"function":case"undefined":return e;default:throw new Error("Unsupported type: "+typeof e)}}function Oe(e){return e.startsWith("'")&&(e=e.slice(1,-1).replace(/''/g,"'")),e}function _e(e){return e.match(/\w/g)?.length!==e.length&&(e=`'${e}'`),e}function Me(e,t,o){return e<t?t:e>o?o:e}function Ne(e,t,o=1){if(t<=e&&o>0)return[];if(0===o)throw new Error("range() step must not be zero");const s=Math.ceil(Math.abs((t-e)/o)),n=Array(s);for(let t=0;t<s;t++)n[t]=e+t*o;return n}function Fe(e){return e.reduce(((e,t,o,s)=>{if(1===Math.abs(t-s[o-1])){e[e.length-1].push(t)}else e.push([t]);return e}),[])}function*De(e,t){t.next();for(const o of e){const e=t.next();yield{...o,next:e.done?void 0:e.value}}}const Le=/^\[(.+)\]\((.+)\)$/,Pe=/^https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,4}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)$/;function Ve(e){return Le.test(e)}function ke(e){return Pe.test(e)}function Ue(e,t){return`[${e}](${t})`}function Be(e){const t=e.match(Le)||[],o=t[1],s=t[2];if(!o||!s)throw new Error(`Could not parse markdown link ${e}.`);return{label:o,url:s}}const He="o-spreadsheet://";function ze(e){return e.startsWith(He)}function Ge(e){return`${He}${e}`}function $e(e){if(e.startsWith(He))return e.substr(He.length);throw new Error(`${e} is not a valid sheet link`)}function We(e){return void 0!==e}function qe(e){return null!==e}function Ze(e){return void 0===e||Object.values(e).every((e=>"object"==typeof e?Ze(e):!e))}function Ye(e,t){for(const o in t)if(Je(t[o],e))return parseInt(o,10);const o=Object.keys(t),s=0===o.length?0:ut(o.map((e=>parseInt(e,10))));return t[s+1]=e,s+1}function je(e){let t="";for(let o=0,s=e.length;o<s;o++)t+=e[o];return t}function Xe(e){let t,o=!1;const s=()=>(o||(t=e instanceof Function?e():e,o=!0),t);return s.map=e=>Xe((()=>e(s()))),s}function Ke(e,t){let o=e.slice(t).find((e=>e));return o||(o=e.slice(0,t).reverse().find((e=>e))),o||""}function Qe(e,t){return"after"===e?t+1:t}function Je(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 o in t)if(!(o in e)&&void 0!==t[o])return!1;for(const o in e){if(typeof e[o]!=typeof t[o])return!1;if("object"==typeof e[o]){if(!Je(e[o],t[o]))return!1}else if(e[o]!==t[o])return!1}return!0}function et(e,t){if(e.length<t.length)return!1;const o=new Set(e);return t.every((e=>o.has(e)))}function tt(e){const t={...e};return Object.keys(t).forEach((e=>!t[e]&&delete t[e])),t}const ot=["\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))],st=new RegExp(ot.join("|"),"g"),nt=/(\r\n|\r)/g;function it(e){return e?e.replace(nt,xe):""}function rt(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}class at extends Set{addMany(e){for(const t of e)super.add(t);return this}deleteMany(e){for(const t of e)super.delete(t)}}function lt(e){const t=new Map,o=e.name?e.name+" (memoized)":"memoized";return{[o]:(...o)=>(t.has(o[0])||t.set(o[0],e(...o)),t.get(o[0]))}[o]}function ct(e,t){const o=new Set(t),s=[];for(let t=0;t<e.length;t++)o.has(t)||s.push(e[t]);return s}function ht(e){return e.split("\n").map((e=>e.replace(/\s+/g," ").trim())).join("\n")}function dt(e,t,o){return t>o?dt(e,o,t):e>=t&&e<=o}function ut(e){let t=e.length;if(t<1e5)return Math.max(...e);let o=-1/0;for(;t--;)o=e[t]>o?e[t]:o;return o}function gt(e){let t=e.length;if(t<1e5)return Math.min(...e);let o=1/0;for(;t--;)o=e[t]<o?e[t]:o;return o}const pt=/rgba?\(|\s+|\)/gi,mt=/^#([A-F\d]{2}){3,4}$/,ft=["#eb6d00","#0074d9","#ad8e00","#169ed4","#b10dc9","#00a82d","#00a3a3","#f012be","#3d9970","#111111","#62A300","#ff4136","#949494","#85144b","#001f3f"];function bt(e){return vt(e.toString(16).padStart(6,"0"))}function vt(e){let t=e;if(e.startsWith("rgb")?t=function(e){const t=e.replace(pt,"").split(",");let o=255;if(3!==t.length&&4!==t.length)throw new Error("invalid color");if(4===t.length){const e=parseFloat(t.pop()||"1");if(isNaN(e))throw new Error("invalid alpha value");o=Math.round(255*e)}const s=t.map((e=>parseInt(e,10)));255!==o&&s.push(o);return"#"+je(s.map((e=>e.toString(16).padStart(2,"0")))).toUpperCase()}(e):(t=e.replace("#","").toUpperCase(),3!==t.length&&4!==t.length||(t=t.split("").reduce(((e,t)=>e+t+t),"")),t=`#${t}`),!mt.test(t))throw new Error(`invalid color input: ${e}`);return t}function St(e){try{return vt(e),!0}catch(e){return!1}}const Ct=e=>e>=0&&e<=255;function Et(e,t,o,s=1){if(!Ct(e)||!Ct(t)||!Ct(o)||s<0||s>1)throw new Error(`Invalid RGBA values ${[e,t,o,s]}`);return{a:s,b:o,g:t,r:e}}function yt(e){let{r:t,g:o,b:s}=xt(e);t/=255,o/=255,s/=255;const n=e=>e<=.03928?e/12.92:((e+.055)/1.055)**2.4;return.2126*n(t)+.7152*n(o)+.0722*n(s)}function wt(e){let t=e.r.toString(16),o=e.g.toString(16),s=e.b.toString(16),n=Math.round(255*e.a).toString(16);return 1===t.length&&(t="0"+t),1===o.length&&(o="0"+o),1===s.length&&(s="0"+s),1===n.length&&(n="0"+n),"ff"===n&&(n=""),("#"+t+o+s+n).toUpperCase()}function xt(e){let t,o,s,n;if(7===(e=vt(e)).length)t=parseInt(e[1]+e[2],16),o=parseInt(e[3]+e[4],16),s=parseInt(e[5]+e[6],16),n=255;else{if(9!==e.length)throw new Error("Invalid color");t=parseInt(e[1]+e[2],16),o=parseInt(e[3]+e[4],16),s=parseInt(e[5]+e[6],16),n=parseInt(e[7]+e[8],16)}return n=+(n/255).toFixed(3),{a:n,r:t,g:o,b:s}}function It(e){(e={...e}).s/=100,e.l/=100;let t=(1-Math.abs(2*e.l-1))*e.s,o=t*(1-Math.abs(e.h/60%2-1)),s=e.l-t/2,n=0,i=0,r=0;return 0<=e.h&&e.h<60?(n=t,i=o,r=0):60<=e.h&&e.h<120?(n=o,i=t,r=0):120<=e.h&&e.h<180?(n=0,i=t,r=o):180<=e.h&&e.h<240?(n=0,i=o,r=t):240<=e.h&&e.h<300?(n=o,i=0,r=t):300<=e.h&&e.h<360&&(n=t,i=0,r=o),n=Math.round(255*(n+s)),i=Math.round(255*(i+s)),r=Math.round(255*(r+s)),{a:e.a,r:n,g:i,b:r}}function Rt(e){const t=e.r/255,o=e.g/255,s=e.b/255;let n=Math.min(t,o,s),i=Math.max(t,o,s),r=i-n,a=0,l=0,c=0;return a=0===r?0:i===t?(o-s)/r%6:i===o?(s-t)/r+2:(t-o)/r+4,a=Math.round(60*a),a<0&&(a+=360),c=(i+n)/2,l=0===r?0:r/(1-Math.abs(2*c-1)),l=+(100*l).toFixed(1),c=+(100*c).toFixed(1),{a:e.a,h:a,s:l,l:c}}function Tt(e){return wt(It(e))}function At(e){return Rt(xt(e))}function Ot(e){if(e<0)throw new Error(`number must be positive. Got ${e}`);return e<26?String.fromCharCode(65+e):Ot(Math.floor(e/26)-1)+Ot(e%26)}const _t={};for(const rA of"ABCDEFGHIJKLMNOPQRSTUVWXYZ"){const aA=rA.charCodeAt(0)-64;_t[rA]=aA,_t[rA.toLowerCase()]=aA}function Mt(e){let t=-1;let o=1;for(let s=e.length-1;s>=0;s--){t+=_t[e[s]]*o,o*=26}return t}function Nt(e){return e>="A"&&e<="Z"||e>="a"&&e<="z"}function Ft(e){return e>="0"&&e<="9"}function Dt(e){let t;e=e.trim();for(let o=0;o<e.length;o++){const s=e[o];if(!t){if("$"===s&&0===o||Nt(s))continue;t=o}if(!Ft(s)){if("$"===s&&o===t)continue;throw new Error(`Invalid cell description: ${e}`)}}if(!t||t===e.length)throw new Error(`Invalid cell description: ${e}`);const o="$"===e[0]?e.slice(1,t):e.slice(0,t),s="$"===e[t]?e.slice(t+1):e.slice(t);if(o.length<1||o.length>3||s.length<1||s.length>7)throw new Error(`Invalid cell description: ${e}`);const n=Mt(o),i=Number(s)-1;if(isNaN(i))throw new Error(`Invalid cell description: ${e}`);return{col:n,row:i}}function Lt(e,t,o={colFixed:!1,rowFixed:!1}){return(o.colFixed?"$":"")+Ot(e)+(o.rowFixed?"$":"")+String(t+1)}class Pt{jsDate;constructor(e,t,o,s=0,n=0,i=0){this.jsDate=new Date(Date.UTC(e,t,o,s,n,i,0))}static fromTimestamp(e){const t=new Date(e);return new Pt(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate(),t.getUTCHours(),t.getUTCMinutes(),t.getUTCSeconds())}static now(){const e=new Date;return new Pt(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds())}toString(){return this.jsDate.toString()}toLocaleDateString(){return this.jsDate.toLocaleDateString()}getTime(){return this.jsDate.getTime()}getFullYear(){return this.jsDate.getUTCFullYear()}getMonth(){return this.jsDate.getUTCMonth()}getDate(){return this.jsDate.getUTCDate()}getDay(){return this.jsDate.getUTCDay()}getHours(){return this.jsDate.getUTCHours()}getMinutes(){return this.jsDate.getUTCMinutes()}getSeconds(){return this.jsDate.getUTCSeconds()}setFullYear(e){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 Vt=new Pt(1899,11,30),kt=864e5,Ut=2e3,Bt=Pt.now().getFullYear(),Ht=Pt.now().getMonth(),zt=Pt.fromTimestamp(0).getTime()-Vt.getTime(),Gt=/^\d{1,2}(\/|-|\s)\d{1,2}((\/|-|\s)\d{1,4})?$/,$t=/^\d{3,4}(\/|-|\s)\d{1,2}(\/|-|\s)\d{1,2}$/,Wt=/\/|-|\s/,qt=/^(\d{1,4})[\/-\s](\d{1,4})([\/-\s](\d{1,4}))?$/,Zt=/((\d+(:\d+)?(:\d+)?\s*(AM|PM))|(\d+:\d+(:\d+)?))$/;function Yt(e,t){switch(typeof e){case"number":return e;case"string":return jt(e,t)?Kt(e,t)?.value:!e||isNaN(Number(e))?void 0:Number(e);default:return}}function jt(e,t){return null!==Kt(e,t)}const Xt=new Map;function Kt(e,t){return Xt.has(t)||Xt.set(t,new Map),Xt.get(t).has(e)||Xt.get(t).set(e,function(e,t){e=e.trim();let o=null;const s=e.match(Zt);if(s){if(o=function(e){if(e=e.trim(),Zt.test(e)){const t=/AM/i.test(e),o=/PM/i.test(e),s=(t||o?e.substring(0,e.length-2).trim():e).split(/:/),n=s.length>=2,i=3===s.length;let r=Number(s[0]),a=n?Number(s[1]):0,l=i?Number(s[2]):0,c=i?"hh:mm:ss":"hh:mm";if(t||o)c+=" a";else if(!n)return null;r>=12&&t?r-=12:r<12&&o&&(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 Pt(1899,11,30,r,a,l)}}return null}(s[0]),null===o)return null;e=e.replace(s[0],"").trim()}let n=null;const i=function(e,t){const o=e.match(qt);if(!o)return null;const[,s,n,,i]=o;if(s.length>2&&i&&i.length>2)return null;if(s.length>2)return{year:s,month:n,day:i,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(!i)return n.length>2?{month:s,year:n,day:void 0,dateString:e,type:r}:"dmy"===r?{day:s,month:n,year:i,dateString:e,type:"dmy"}:{month:s,day:n,year:i,dateString:e,type:"mdy"};if(i.length>2)return"mdy"===r?{month:s,day:n,year:i,dateString:e,type:"mdy"}:{day:s,month:n,year:i,dateString:e,type:"dmy"};if("mdy"===r)return{month:s,day:n,year:i,dateString:e,type:"mdy"};if("ymd"===r)return{year:s,month:n,day:i,dateString:e,type:"ymd"};if("dmy"===r)return{day:s,month:n,year:i,dateString:e,type:"dmy"};return null}(e,t);if(i){const t=i.dateString.match(Wt)[0];if(n=function(e,t){let{year:o,month:s,day:n}=e;const i=function(e){if(!e)return Ht;const t=Number(e);if(t>=1&&t<=12)return t-1;return null}(s),r=function(e){if(!e)return 1;const t=Number(e);if(t>=0&&t<=31)return t;return null}(n),a=function(e){if(!e)return Bt;const t=Number(e);switch(e.length){case 1:return Ut+t;case 2:return Ut+(Ut+t>Bt+10?-100:0)+t;case 3:case 4:return t}return null}(o);if(null===a||null===i||null===r)return null;const l=2===s?.length&&i+1<10||2===n?.length&&r<10,c=2!==o?.length,h=new Pt(a,i,r);if(h.getMonth()!==i||h.getDate()!==r)return null;const d=h.getTime()-Vt.getTime(),u=function(e,t,o,s){const n=e.year?s?"yyyy":"yy":void 0,i=e.month?o?"mm":"m":void 0,r=e.day?o?"dd":"d":void 0;switch(e.type){case"mdy":return[i,r,n].filter(We).join(t);case"ymd":return[n,i,r].filter(We).join(t);case"dmy":return[r,i,n].filter(We).join(t)}}(e,t,l,c);return{value:Math.round(d/kt),format:u,jsDate:h}}(i,t),null===n)return null;e=e.replace(i.dateString,"").trim()}if(""!==e||!n&&!o)return null;if(n&&n.jsDate&&o&&o.jsDate)return{value:n.value+o.value,format:n.format+" "+("hhhh:mm:ss"===o.format?"hh:mm:ss":o.format),jsDate:new Pt(n.jsDate.getFullYear()+o.jsDate.getFullYear()-1899,n.jsDate.getMonth()+o.jsDate.getMonth()-11,n.jsDate.getDate()+o.jsDate.getDate()-30,n.jsDate.getHours()+o.jsDate.getHours(),n.jsDate.getMinutes()+o.jsDate.getMinutes(),n.jsDate.getSeconds()+o.jsDate.getSeconds())};return n||o}(e,t)),Xt.get(t).get(e)}function Qt(e){const t=Math.trunc(e);let o=Pt.fromTimestamp(t*kt-zt),s=e-t;s=s<0?1+s:s;const n=Math.round(24*s),i=Math.round(24*(s-n/24)*60),r=Math.round(24*(s-n/24-i/24/60)*60*60);return o.setHours(n),o.setMinutes(i),o.setSeconds(r),o}function Jt(e){return Math.round(eo(e))}function eo(e){return(e.getTime()-Vt.getTime())/kt}function to(e){return new Pt(e.getFullYear(),e.getMonth()+1,0).getDate()}function oo(e){return to(e)===e.getDate()}function so(e,t,o){const s=e.getFullYear(),n=e.getMonth(),i=e.getDate(),r=new Pt(s,n+t,1);return o&&i===to(e)||i>to(r)?r.setDate(to(r)):r.setDate(i),r}function no(e){const t=Math.trunc(e);return t%4==0&&t%100!=0||t%400==0}function io(e,t,o){if(e===t)return 0;if(e>t){const o=t;t=e,e=o}const s=Qt(e),n=Qt(t);let i=s.getDate(),r=n.getDate();const a=s.getMonth(),l=n.getMonth(),c=s.getFullYear(),h=n.getFullYear();let d=0,u=0;switch(o){case 0:31===i&&(i=30),30===i&&31===r&&(r=30),1===a&&i===(no(c)?29:28)&&(i=30,1===l&&r===(no(h)?29:28)&&(r=30)),d=c+(30*a+i)/360,u=h+(30*l+r)/360;break;case 1:let o=365;const s=c===h;if(!s&&!(c+1===h)||!s&&a<l||!s&&a===l&&i<r){let e=0,t=0;for(let o=c;o<=h;o++)e++,t+=no(o)?366:365;o=t/e}else s?no(c)&&(o=366):(no(c)&&a<2&&(o=366),no(h)&&(l>1||1===l&&29===r)&&(o=366));d=e/o,u=t/o;break;case 2:d=e/360,u=t/360;break;case 3:d=e/365,u=t/365;break;case 4:31===i&&(i=30),31===r&&(r=30),d=c+(30*a+i)/360,u=h+(30*l+r)/360}return u-d}function ro(e,t){const o=12*(t.getFullYear()-e.getFullYear())+t.getMonth()-e.getMonth();return e.getDate()>t.getDate()?o-1:o}function ao(e,t){const o=e.getTime(),s=t.getTime();return Math.floor((s-o)/kt)}function lo(e,t){const o=t.getFullYear()-e.getFullYear(),s=e.getMonth(),n=t.getMonth(),i=e.getDate(),r=t.getDate();return n>s||n===s&&r>=i?o:o-1}function co(e,t,o){return t>o?co(e,o,t):(e=Math.trunc(e),t=Math.trunc(t),o=Math.trunc(o),e>=t&&e<=o)}const ho=lt((function(e){return e=Te(e),new RegExp(`(^-?\\d+(${e}?\\d*(e(\\+|-)?\\d+)?)?|^-?${e}\\d+)(?!\\w|!)`)})),uo=lt((function(e){const t=Te(e.decimalSeparator),o="(\\s*"+`(\\d+(${Te(e.thousandsSeparator||"")}\\d{3,})*(${t}\\d*)?)`+"|"+`(${t}\\d+)`+")(e(\\+|-)?\\d+)?(\\s*%)?",s="(\\s*-)?",n="(\\s*[\\$€])?",i="^(("+[s+n+o,s+o+n,n+s+o].join(")|(")+"))$";return new RegExp(i,"i")}));function go(e,t){return!!e&&uo(t).test(e.trim())}const po=lt((function(e){return new RegExp(`[$€${Te(e.thousandsSeparator||"")}]`,"g")}));function mo(e,t){e=e.replace(po(t),""),"."!==t.decimalSeparator&&(e=e.replace(t.decimalSeparator,"."));let o=Number(e);return isNaN(o)&&e.includes("%")&&(o=Number(e.split("%")[0]),!isNaN(o))?o/100:o}function fo(e,t,o){const s=[...e].sort(((e,t)=>e-t));let n=(s.length+(o?-1:1))*t;if(o||n--,Number.isInteger(n))return s[n];const i=Math.ceil(n),r=Math.floor(n);return s[i]*(n-r)+s[r]*(i-n)}var bo,vo;!function(e){e.boolean="boolean",e.number="number",e.text="text",e.empty="empty",e.error="error"}(bo||(bo={})),function(e){e.PlainText="text/plain",e.Html="text/html"}(vo||(vo={}));const So=new Set(["RENAME_SHEET","DELETE_SHEET","CREATE_SHEET","ADD_COLUMNS_ROWS","REMOVE_COLUMNS_ROWS","UNDO","REDO","ADD_MERGE","DUPLICATE_SHEET","UPDATE_LOCALE"]),Co=new Set([...So,"MOVE_RANGES"]),Eo=new Set([...So,"EVALUATE_CELLS","ADD_CONDITIONAL_FORMAT","REMOVE_CONDITIONAL_FORMAT","CHANGE_CONDITIONAL_FORMAT_PRIORITY"]),yo=new Set(["START","ACTIVATE_SHEET","COPY","RESIZE_SHEETVIEW","SET_VIEWPORT_OFFSET","SELECT_SEARCH_NEXT_MATCH","SELECT_SEARCH_PREVIOUS_MATCH","UPDATE_SEARCH","CLEAR_SEARCH","EVALUATE_CELLS","SET_CURRENT_CONTENT","SET_FORMULA_VISIBILITY","OPEN_CELL_POPOVER","CLOSE_CELL_POPOVER","UPDATE_FILTER"]),wo=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","HIDE_SHEET","SHOW_SHEET","MOVE_RANGES","ADD_CONDITIONAL_FORMAT","REMOVE_CONDITIONAL_FORMAT","CHANGE_CONDITIONAL_FORMAT_PRIORITY","CREATE_FIGURE","DELETE_FIGURE","UPDATE_FIGURE","SET_FORMATTING","CLEAR_FORMATTING","SET_BORDER","SET_ZONE_BORDERS","SET_BORDERS_ON_TARGET","CREATE_CHART","UPDATE_CHART","CREATE_FILTER_TABLE","REMOVE_FILTER_TABLE","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"]);function xo(e){return wo.has(e.type)}class Io{reasons;constructor(e=[]){Array.isArray(e)||(e=[e]),e=[...new Set(e)],this.reasons=e.filter((e=>"Success"!==e))}static get Success(){return Ro}get isSuccessful(){return 0===this.reasons.length}isCancelledBecause(e){return this.reasons.includes(e)}}const Ro=new Io;var To;e.CommandResult=void 0,(To=e.CommandResult||(e.CommandResult={})).Success="Success",To.CancelledForUnknownReason="CancelledForUnknownReason",To.WillRemoveExistingMerge="WillRemoveExistingMerge",To.MergeIsDestructive="MergeIsDestructive",To.CellIsMerged="CellIsMerged",To.InvalidTarget="InvalidTarget",To.EmptyUndoStack="EmptyUndoStack",To.EmptyRedoStack="EmptyRedoStack",To.NotEnoughElements="NotEnoughElements",To.NotEnoughSheets="NotEnoughSheets",To.MissingSheetName="MissingSheetName",To.UnchangedSheetName="UnchangedSheetName",To.DuplicatedSheetName="DuplicatedSheetName",To.DuplicatedSheetId="DuplicatedSheetId",To.ForbiddenCharactersInSheetName="ForbiddenCharactersInSheetName",To.WrongSheetMove="WrongSheetMove",To.WrongSheetPosition="WrongSheetPosition",To.InvalidAnchorZone="InvalidAnchorZone",To.SelectionOutOfBound="SelectionOutOfBound",To.TargetOutOfSheet="TargetOutOfSheet",To.WrongCutSelection="WrongCutSelection",To.WrongPasteSelection="WrongPasteSelection",To.WrongPasteOption="WrongPasteOption",To.WrongFigurePasteOption="WrongFigurePasteOption",To.EmptyClipboard="EmptyClipboard",To.EmptyRange="EmptyRange",To.InvalidRange="InvalidRange",To.InvalidZones="InvalidZones",To.InvalidSheetId="InvalidSheetId",To.InvalidCellId="InvalidCellId",To.InvalidFigureId="InvalidFigureId",To.InputAlreadyFocused="InputAlreadyFocused",To.MaximumRangesReached="MaximumRangesReached",To.MinimumRangesReached="MinimumRangesReached",To.InvalidChartDefinition="InvalidChartDefinition",To.InvalidDataSet="InvalidDataSet",To.InvalidLabelRange="InvalidLabelRange",To.InvalidScorecardKeyValue="InvalidScorecardKeyValue",To.InvalidScorecardBaseline="InvalidScorecardBaseline",To.InvalidGaugeDataRange="InvalidGaugeDataRange",To.EmptyGaugeRangeMin="EmptyGaugeRangeMin",To.GaugeRangeMinNaN="GaugeRangeMinNaN",To.EmptyGaugeRangeMax="EmptyGaugeRangeMax",To.GaugeRangeMaxNaN="GaugeRangeMaxNaN",To.GaugeRangeMinBiggerThanRangeMax="GaugeRangeMinBiggerThanRangeMax",To.GaugeLowerInflectionPointNaN="GaugeLowerInflectionPointNaN",To.GaugeUpperInflectionPointNaN="GaugeUpperInflectionPointNaN",To.GaugeLowerBiggerThanUpper="GaugeLowerBiggerThanUpper",To.InvalidAutofillSelection="InvalidAutofillSelection",To.WrongComposerSelection="WrongComposerSelection",To.MinBiggerThanMax="MinBiggerThanMax",To.LowerBiggerThanUpper="LowerBiggerThanUpper",To.MidBiggerThanMax="MidBiggerThanMax",To.MinBiggerThanMid="MinBiggerThanMid",To.FirstArgMissing="FirstArgMissing",To.SecondArgMissing="SecondArgMissing",To.MinNaN="MinNaN",To.MidNaN="MidNaN",To.MaxNaN="MaxNaN",To.ValueUpperInflectionNaN="ValueUpperInflectionNaN",To.ValueLowerInflectionNaN="ValueLowerInflectionNaN",To.MinInvalidFormula="MinInvalidFormula",To.MidInvalidFormula="MidInvalidFormula",To.MaxInvalidFormula="MaxInvalidFormula",To.ValueUpperInvalidFormula="ValueUpperInvalidFormula",To.ValueLowerInvalidFormula="ValueLowerInvalidFormula",To.InvalidSortZone="InvalidSortZone",To.WaitingSessionConfirmation="WaitingSessionConfirmation",To.MergeOverlap="MergeOverlap",To.TooManyHiddenElements="TooManyHiddenElements",To.Readonly="Readonly",To.InvalidViewportSize="InvalidViewportSize",To.InvalidScrollingDirection="InvalidScrollingDirection",To.FigureDoesNotExist="FigureDoesNotExist",To.InvalidConditionalFormatId="InvalidConditionalFormatId",To.InvalidCellPopover="InvalidCellPopover",To.EmptyTarget="EmptyTarget",To.InvalidFreezeQuantity="InvalidFreezeQuantity",To.FrozenPaneOverlap="FrozenPaneOverlap",To.ValuesNotChanged="ValuesNotChanged",To.InvalidFilterZone="InvalidFilterZone",To.FilterOverlap="FilterOverlap",To.FilterNotFound="FilterNotFound",To.MergeInFilter="MergeInFilter",To.NonContinuousTargets="NonContinuousTargets",To.DuplicatedFigureId="DuplicatedFigureId",To.InvalidSelectionStep="InvalidSelectionStep",To.DuplicatedChartId="DuplicatedChartId",To.ChartDoesNotExist="ChartDoesNotExist",To.InvalidHeaderIndex="InvalidHeaderIndex",To.InvalidQuantity="InvalidQuantity",To.MoreThanOneColumnSelected="MoreThanOneColumnSelected",To.EmptySplitSeparator="EmptySplitSeparator",To.SplitWillOverwriteContent="SplitWillOverwriteContent",To.NoSplitSeparatorInSelection="NoSplitSeparatorInSelection",To.NoActiveSheet="NoActiveSheet",To.InvalidLocale="InvalidLocale",To.AlreadyInPaintingFormatMode="AlreadyInPaintingFormatMode",To.MoreThanOneRangeSelected="MoreThanOneRangeSelected",To.NoColumnsProvided="NoColumnsProvided",To.ColumnsNotIncludedInZone="ColumnsNotIncludedInZone",To.DuplicatesColumnsSelected="DuplicatesColumnsSelected",To.InvalidHeaderGroupStartEnd="InvalidHeaderGroupStartEnd",To.HeaderGroupAlreadyExists="HeaderGroupAlreadyExists",To.UnknownHeaderGroup="UnknownHeaderGroup",To.UnknownDataValidationRule="UnknownDataValidationRule",To.UnknownDataValidationCriterionType="UnknownDataValidationCriterionType",To.InvalidDataValidationCriterionValue="InvalidDataValidationCriterionValue",To.InvalidNumberOfCriterionValues="InvalidNumberOfCriterionValues",To.BlockingValidationRule="BlockingValidationRule",To.InvalidCopyPasteSelection="InvalidCopyPasteSelection",To.NoChanges="NoChanges",To.InvalidInputId="InvalidInputId";const Ao=[{name:"English (US)",code:"en_US",thousandsSeparator:",",decimalSeparator:".",dateFormat:"m/d/yyyy",timeFormat:"hh:mm:ss a",formulaArgSeparator:","},{name:"French",code:"fr_FR",thousandsSeparator:" ",decimalSeparator:",",dateFormat:"dd/mm/yyyy",timeFormat:"hh:mm:ss",formulaArgSeparator:";"}],Oo=Ao[0],_o=["thin","medium","thick","dashed","dotted"];function Mo(e){return Array.isArray(e)&&Array.isArray(e[0])}var No,Fo;!function(e){e.UP="up",e.DOWN="down",e.LEFT="left",e.RIGHT="right"}(No||(No={})),function(e){e[e.Background=0]="Background",e[e.Highlights=1]="Highlights",e[e.Clipboard=2]="Clipboard",e[e.Search=3]="Search",e[e.Chart=4]="Chart",e[e.Autofill=5]="Autofill",e[e.Selection=6]="Selection",e[e.Headers=7]="Headers"}(Fo||(Fo={}));const Do=["number","string","boolean","undefined"];function Lo(e,t){if(!e())throw new d(c.GenericError,t)}const Po=e=>a("The function [[FUNCTION_NAME]] expects a number value, but '%s' is a string, and cannot be coerced to a number.",e);function Vo(e,t){switch(typeof e){case"number":return e;case"boolean":return e?1:0;case"string":if(go(e,t)||""===e)return mo(e,t);const o=Kt(e,t);if(o)return o.value;throw new Error(Po(e));default:return 0}}function ko(e,t){try{return Vo(e,t)}catch(e){return}}function Uo(e,t){return e.forEach((e=>{e.forEach((e=>{if("number"!=typeof e)throw new Error(a("Function [[FUNCTION_NAME]] expects number values for %s, but got a %s.",typeof e,t))}))})),e}function Bo(e,t){if(""===e)throw new Error(Po(e));return Vo(e,t)}function Ho(e,t){return Math.trunc(Vo(e,t))}function zo(e,t){return Math.trunc(Bo(e,t))}function Go(e){Lo((()=>e>=1),a("The function [[FUNCTION_NAME]] expects a number value to be greater than or equal to 1, but receives %s.",e.toString()))}function $o(e){switch(typeof e){case"string":return e;case"number":return e.toString();case"boolean":return e?"TRUE":"FALSE";default:return""}}const Wo=lt((function(e){return e.toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g,"")})),qo=e=>a("The function [[FUNCTION_NAME]] expects a boolean value, but '%s' is a text, and cannot be coerced to a number.",e);function Zo(e){switch(typeof e){case"boolean":return e;case"string":if(e){let t=e.toUpperCase();if("TRUE"===t)return!0;if("FALSE"===t)return!1;throw new Error(qo(e))}return!1;case"number":return!!e;default:return!1}}function Yo(e,t){return Qt(Vo(e,t))}function jo(e,t,o){for(let s of e)if(Mo(s)){const e=s.length,o=s[0].length;for(let n=0;n<o;n++)for(let o=0;o<e;o++)t(s[o][n])}else o(s)}function Xo(e,t){jo(e,t,t)}function Ko(e,t,o){jo(e,(e=>{"number"==typeof e&&t(e)}),(e=>{t(Bo(e,o))}))}function Qo(e,t,o,s,n="rowFirst"){let i=s;for(let s of e)if(Mo(s)){const e=s.length,o=s[0].length;if("rowFirst"===n)for(let n=0;n<o;n++)for(let o=0;o<e;o++)i=t(i,s[o][n]);else for(let n=0;n<e;n++)for(let e=0;e<o;e++)i=t(i,s[n][e])}else i=o(i,s);return i}function Jo(e,t,o,s="rowFirst"){return Qo(e,t,t,o,s)}function es(e,t,o,s){return Qo(e,((e,o)=>"number"==typeof o?t(e,o):e),((e,o)=>t(e,Bo(o,s))),o)}function ts(e,t,o,s){return Qo(e,((e,o)=>null!=o?t(e,"number"==typeof o?o:"boolean"==typeof o?Vo(o,s):0):e),((e,o)=>t(e,Vo(o,s))),o)}function os(e,t,o){const s=Array(e);for(let n=0;n<e;n++){s[n]=Array(t);for(let e=0;e<t;e++)s[n][e]=o(n,e)}return s}function ss(e,t){return 0===e.length?[]:os(e.length,e[0].length,((o,s)=>t(e[o][s])))}function ns(e){return e.length?os(e[0].length,e.length,((t,o)=>e[o][t])):[]}function is(e,t){return function(e,t,o){for(let s of e)if(Mo(s)){const e=s.length,o=s[0].length;for(let n=0;n<o;n++)for(let o=0;o<e;o++)if(!t(s[o][n]??void 0))return}else if(!o(s))return}(e,(e=>"boolean"==typeof e?t(e):"number"!=typeof e||t(!!e)),(e=>null==e||t(function(e){if(""===e)throw new Error(qo(e));return Zo(e)}(e))))}function rs(e,t,o){let s,n,i=e.substring(0,2);"<="===i||">="===i||"<>"===i?(s=i,n=e.substring(2)):(i=e.substring(0,1),"<"===i||">"===i||"="===i?(s=i,n=e.substring(1)):(s="=",n=e)),go(n,o)||jt(n,o)?n=Vo(n,o):"TRUE"!==n&&"FALSE"!==n||(n=Zo(n));const r={operator:s,operand:n};return"string"==typeof n&&(t&&(n+="*"),r.regexp=function(e){if("*"===e)return/.+/;let t="",o="";for(let s of e)"?"===s&&"~"!==o?t+=".":"*"===s&&"~"!==o?t+=".*":("*"!==s&&"?"!==s||(t=t.slice(0,-1)),["^",".","[","]","$","(",")","*","+","?","|","{","}","\\"].includes(s)&&(t+="\\"),t+=s),o=s;return new RegExp("^"+t+"$","i")}(n)),r}function as(e="",t,o){const{operator:s,operand:n}=t;if(void 0===n||null===e||null===n)return!1;if("number"==typeof n&&"="===s)return"string"==typeof e&&(go(e,o)||jt(e,o))?Vo(e,o)===n:e===n;if("<>"===s||"="===s){let o;return o=typeof e==typeof n&&("string"==typeof e&&t.regexp?t.regexp.test(e):e===n),"="===s?o:!o}if(typeof e==typeof n)switch(s){case"<":return e<n;case">":return e>n;case"<=":return e<=n;case">=":return e>=n}return!1}function ls(e,t,o,s=!1){const n=e.length;if(n%2==1)throw new Error(a("Function [[FUNCTION_NAME]] expects criteria_range and criterion to be in pairs."));const i=e[0].length,r=e[0][0].length;let l=[];for(let t=0;t<n-1;t+=2){const n=e[t];if(!Mo(n)||n.length!==i||n[0].length!==r)throw new Error(a("Function [[FUNCTION_NAME]] expects criteria_range to have the same dimension"));const c=$o(e[t+1]);l.push(rs(c,s,o))}for(let s=0;s<i;s++)for(let i=0;i<r;i++){let r=!0;for(let t=0;t<n-1;t+=2){if(r=as(e[t][s][i]??void 0,l[t/2],o),!r)break}r&&t(s,i)}}function cs(e,t,o,s,n,i){if(null==t)return-1;const r=ds(t),a=typeof r;let l,c,h,d,u,g,p=0,m=n-1;const f="desc"===s?t=>ds(i(e,n-t-1)):t=>ds(i(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"===o&&u===r?(l=u,c=d):"nextSmaller"===o&&u<=r?(null==l||l<u||l===u&&c<d)&&(l=u,c=d):"nextGreater"===o&&u>=r&&(void 0===l||l>u||l===u&&c<d)&&(l=u,c=d),u>r||"strict"===o&&u===r?m=d-1:p=h+1):p=h+1}return void 0===c?-1:"desc"===s?n-c-1:c}function hs(e,t,o,s,n,i=!1){if(null==t)return-1;const r=ds(t),a=i?(e,t)=>n(e,s-t-1):n;let l,c=-1;for(let t=0;t<s;t++){const n=ds(a(e,t));if(n===r)return i?s-t-1:t;"nextSmaller"===o?(!l&&us(r,n)>=0||us(r,n)>=0&&us(n,l)>0)&&(l=n,c=t):"nextGreater"===o&&(!l&&us(r,n)<=0||us(r,n)<=0&&us(n,l)<0)&&(l=n,c=t)}return i&&-1!==c?s-c-1:c}function ds(e){return"string"==typeof e?Wo(e):e}function us(e,t){let o=Do.indexOf(typeof e)-Do.indexOf(typeof t);return 0===o&&("string"==typeof e&&"string"==typeof t?o=e.localeCompare(t):"number"==typeof e&&"number"==typeof t?o=e-t:"boolean"==typeof e&&"boolean"==typeof t&&(o=Number(e)-Number(t))),o}function gs(e){return void 0===e?[[]]:Mo(e)?e:[[e]]}function ps(e,t){return Jo(e,((e,o)=>(e.push(t(o)),e)),[],"rowFirst")}function ms(e){const t=Pt.now();switch(e){case"today":return eo(t);case"yesterday":return eo(Pt.fromTimestamp(t.setDate(t.getDate()-1)));case"tomorrow":return eo(Pt.fromTimestamp(t.setDate(t.getDate()+1)));case"lastWeek":return eo(Pt.fromTimestamp(t.setDate(t.getDate()-7)));case"lastMonth":return eo(Pt.fromTimestamp(t.setMonth(t.getMonth()-1)));case"lastYear":return eo(Pt.fromTimestamp(t.setFullYear(t.getFullYear()-1)))}}function fs(e,t){return"dateValue"in e&&"exactDate"!==e.dateValue?[ms(e.dateValue)]:e.values.map((e=>Yt(e,t)))}function bs(e,t){return e.values.map((e=>ko(e,t)))}function vs(e){return 20+120*Math.exp(-.035*(e-1))}const Ss=20,Cs=11,Es=/(\d+?)(?=(\d{3})+(?!\d)|$)/g,ys=/0/g,ws={0:a("January"),1:a("February"),2:a("March"),3:a("April"),4:a("May"),5:a("June"),6:a("July"),7:a("August"),8:a("September"),9:a("October"),10:a("November"),11:a("December")},xs={0:a("Sunday"),1:a("Monday"),2:a("Tuesday"),3:a("Wednesday"),4:a("Thursday"),5:a("Friday"),6:a("Saturday")},Is={};function Rs(e){let t=Is[e];return void 0===t&&(t=function(e){if(""===e)throw new Error("A format cannot be empty");let t=0,o=[];for(;t<e.length;){let s;if("["===e.charAt(t)){if("$"!==e.charAt(t+1))throw new Error(`Currency formats have to be prefixed by a $: ${e}`);if(s=e.substring(t+1).indexOf("]")+t+2,0===s)throw new Error(`Invalid currency brackets format: ${e}`);const n=e.substring(t+2,s-1);if(n.includes("["))throw new Error(`Invalid currency format: ${e}`);o.push({type:"STRING",format:n})}else{const n=e.substring(t).indexOf("[");s=n>-1?n+t:e.length;const i=e.substring(t,s);Ds(i)?o.push({type:"DATE",format:i}):o.push({type:"NUMBER",format:js(i)})}t=s}return o}(e),Is[e]=t),t}function Ts(e,{format:t,locale:o}){switch(typeof e){case"string":return e.includes('\\"')?e.replace(/\\"/g,'"'):e;case"boolean":return e?"TRUE":"FALSE";case"number":t||(t=Bs(e));return function(e,t,o){if("DATE"===t[0].type)return Ps(e,t[0].format);let s=e<0?"-":"";for(let n of t)switch(n.type){case"NUMBER":s+=As(Math.abs(e),n.format,o);break;case"STRING":s+=n.format}return s}(e,Rs(t),o);case"object":return"0"}}function As(e,t,o){t.isPercent&&(e*=100),e/=t.magnitude;let s=0;void 0!==t.decimalPart&&(s=t.decimalPart.length);const{integerDigits:n,decimalDigits:i}=_s(e,s);let r=function(e,t,o){const s="0"===e?"":e;let n=s;const i=t.length-s.length;if(i>0){const e=(t.substring(0,i).match(ys)||[]).length;n="0".repeat(e)+n}o&&(n=n.match(Es)?.join(o)||n);return n}(n,t.integerPart,t.thousandsSeparator?o.thousandsSeparator:void 0);return void 0!==t.decimalPart&&(r+=o.decimalSeparator+function(e,t){let o=e;if(t.length-e.length>0){const s=(t.substring(e.length,t.length+1).match(ys)||[]).length;o+="0".repeat(s)}return o}(i||"",t.decimalPart)),t.isPercent&&(r+="%"),r}const Os=[];function _s(e,t=Ss){const o=e.toString();if(o.includes("e"))return function(e,t=Ss){let o=Os[t];o||(o=new Intl.NumberFormat("en-US",{maximumFractionDigits:t,useGrouping:!1}),Os[t]=o);const[s,n]=o.format(e).split(".");return{integerDigits:s,decimalDigits:n}}(e,t);if(Number.isInteger(e))return{integerDigits:o,decimalDigits:void 0};const s=o.indexOf(".");let n=o.substring(0,s),i=o.substring(s+1);if(0===t)return Number(i[0])>=5&&(n=(Number(n)+1).toString()),{integerDigits:n,decimalDigits:void 0};if(i.length>t){const{integerDigits:e,decimalDigits:o}=function(e,t){let o="0",s=e,n=e.slice(0,t);const i=t;if(Number(e[i])<5)return{integerDigits:o,decimalDigits:n};const r=n.match(Ns)?.[0]||"",a=(Number(n)+1).toString(),l=n.slice(r.length),c=a.length>l.length;c&&!r?(o="1",s=void 0):s=c?r.slice(0,-1)+a:r+a;return{integerDigits:o,decimalDigits:s}}(i,t);i=o,"0"!==e&&(n=(Number(n)+Number(e)).toString())}return{integerDigits:n,decimalDigits:Ms(i||"")}}function Ms(e){let t=e.length-1;for(;t>=0&&"0"===e[t];)t--;return e.slice(0,t+1)||void 0}const Ns=/^0+/;function Fs(e,t){const{integerDigits:o,decimalDigits:s}=_s(e,20);return s?o+t+s:o}function Ds(e){if(!Ls.has(e[0]))return!1;try{return Ps(1,e),!0}catch(e){return!1}}const Ls=new Set(["h","m","y","d"]);function Ps(e,t){const o=Qt(e),s=t.indexOf("h");let n="",i="";return s>0?(n=Vs(o,t.substring(0,s-1)),i=ks(o,t.substring(s))):0===s?i=ks(o,t):s<0&&(n=Vs(o,t)),n+(n&&i?" ":"")+i}function Vs(e,t){const o=t.match(/\/|-|\s/)?.[0];return(o?t.split(o):[t]).map((o=>{switch(o){case"d":return e.getDate();case"dd":return e.getDate().toString().padStart(2,"0");case"ddd":return xs[e.getDay()].slice(0,3);case"dddd":return xs[e.getDay()];case"m":return e.getMonth()+1;case"mm":return String(e.getMonth()+1).padStart(2,"0");case"mmm":return ws[e.getMonth()].slice(0,3);case"mmmm":return ws[e.getMonth()];case"mmmmm":return ws[e.getMonth()].slice(0,1);case"yy":const o=String(e.getFullYear()).replace("-","").padStart(2,"0");return o.slice(o.length-2);case"yyyy":return e.getFullYear();default:throw new Error(`invalid format: ${t}`)}})).join(o)}function ks(e,t){let o=t.split(/:|\s/);const s=e.getHours(),n="a"===o[o.length-1];let i=s,r="";return n&&(i=0===i?12:i>12?i-12:i,r=s>=12?" PM":" AM",o.pop()),o.map((o=>{switch(o){case"hhhh":return Math.floor((e.getTime()-Vt.getTime())/36e5).toString();case"hh":return i.toString().padStart(2,"0");case"mm":return e.getMinutes().toString().padStart(2,"0");case"ss":return e.getSeconds().toString().padStart(2,"0");default:throw new Error(`invalid format: ${t}`)}})).join(":")+r}const Us=lt((function(e){return new RegExp(`[0-9]+${Te(e.decimalSeparator)}[0-9]`)}));function Bs(e){let{integerDigits:t,decimalDigits:o}=_s(e);if(!o)return"0";const s=t.replace("-","").length;if(s+2>Cs)return"0";const n=Cs-s-1;return({decimalDigits:o}=_s(e,Math.min(n,o.length))),o?"0."+"0".repeat(o.length):"0"}function Hs(e,t){if(!jt(e,t))return;return Kt(e,t).format}function zs(e){if(!go(e,Oo))return;const t=e.includes(".")?"0.00":"0",o=e.match(/[\$€]/);if(o){const s=e.match(/[\d]/),n="[$"+o.values().next().value+"]";return s.index<o.index?"#,##"+t+n:n+"#,##"+t}return e.includes("%")?t+"%":void 0}function Gs(e){const t=e.decimalPlaces??2,o=e.position??"before",s=e.code??"",n=e.symbol??"",i="#,##0"+(t?"."+"0".repeat(t):"");let r=`${s} ${n}`.trim();return"after"===o&&s&&(r=" "+r),function(e,t,o){const s=`[$${e}]`;return"before"===t?s+o:o+s}(r,o,i)}function $s(e){return Ks(Rs(e).map((e=>"NUMBER"===e.type?{type:e.type,format:{...e.format,decimalPart:void 0}}:e)))}function Ws(e,t,o,s){const n=Rs(e||"#,##0"),i=[];for(let e=0;e<n.length;e++){const s=n[e];if("NUMBER"!==s.type){i.push(s);continue}i.push({...s,format:{...s.format,magnitude:t,decimalPart:void 0}}),i.push({type:"STRING",format:o});const r=n[e+1];"STRING"===r?.type&&["k","m","b"].includes(r.format)&&e++}return Ks(i)}function qs(e,t,o){const s=Rs(e).map((e=>"NUMBER"===e.type?{...e,format:Zs(e.format,t)}:e)),n=Ks(s);return Is[n]=s,n}function Zs(e,t){const o={...e},s=Math.sign(t),n=o.decimalPart?.length||0,i=Math.min(Math.max(0,n+s),Ss);return o.decimalPart="0".repeat(i),""===o.decimalPart&&delete o.decimalPart,o}const Ys=/,*?$/;function js(e){if(function(e){return Boolean(e.replace(Xs,""))}(e=e.trim()))throw new Error(`Invalid number format: ${e}`);const t=e.includes("%"),o=e.match(Ys)?.[0]||"",s=o?1e3**o.length:1;let n=e.slice(0,e.length-(o.length||0));const i=n.includes(",");if(/\..*,/.test(n))throw new Error("A format can't contain ',' symbol in the decimal part");n=n.replace("%","").replace(",","");const r=n.match(/[\%|,]/);if(r)throw new Error(`A format can only contain a single '${r[0]}' symbol`);const[a,l]=n.split(".");if(l&&l.length>20)throw new Error("A format can't contain more than 20 decimal places");return void 0!==l?{integerPart:a,isPercent:t,thousandsSeparator:i,decimalPart:l,magnitude:s}:{integerPart:a,isPercent:t,thousandsSeparator:i,magnitude:s}}const Xs=/[,#0.%]/g;function Ks(e){let t="";for(let o of e){let e;switch(o.type){case"NUMBER":const t=o.format;e=t.integerPart,t.thousandsSeparator&&(e=e.slice(0,-3)+","+e.slice(-3)),void 0!==t.decimalPart&&(e+="."+t.decimalPart),t.isPercent&&(e+="%"),t.magnitude&&(e+=",".repeat(Math.log10(t.magnitude)/3));break;case"STRING":e=`[$${o.format}]`;break;case"DATE":e=o.format}t+=e}return t}const Qs=new RegExp(/\$?([A-Z]{1,3})\$?([0-9]{1,7})/,"i"),Js=new RegExp(/^\$?([A-Z]{1,3})\$?([0-9]{1,7})$/,"i"),en=new RegExp(/^\$?([A-Z]{1,3})+$/,"i"),tn=new RegExp(/^\$?([0-9]{1,7})+$/,"i"),on=new RegExp(/^\s*('.+'!|[^']+!)?\$?([A-Z]{1,3})$/,"i"),sn=new RegExp(/^\s*('.+'!|[^']+!)?\$?([0-9]{1,7})$/,"i"),nn=new RegExp(/^\s*('.+'!|[^']+!)?/.source+"("+[Qs.source,/(\$?[A-Z]{1,3})?\$?[0-9]{1,7}\s*:\s*(\$?[A-Z]{1,3})?\$?[0-9]{1,7}\s*/i.source,/\$?[A-Z]{1,3}(\$?[0-9]{1,7})?\s*:\s*\$?[A-Z]{1,3}(\$?[0-9]{1,7})?\s*/i.source].join("|")+")"+/$/.source,"i");function rn(e){return on.test(e)}function an(e){return sn.test(e)}function ln(e){return en.test(e)}function cn(e){return tn.test(e)}function hn(e){return Js.test(e)}function dn(e){const t=e.split("!"),o=t.pop();return{sheetName:Oe(t.join("!"))||void 0,xc:o}}function un(e){const t=function(e){e.includes("!")&&(e=e.split("!").at(-1)),e.includes("$")&&(e=e.replaceAll("$",""));let t,o,s,n,i,r="";e.includes(":")?([r,t]=e.split(":"),r=r.trim(),t=t.trim()):r=e.trim();let a=!1,l=!1,c=!1;if(rn(r))n=i=Mt(r),o=s=0,a=!0;else if(an(r))o=s=parseInt(r,10)-1,n=i=0,l=!0;else{const e=Dt(r);n=i=e.col,o=s=e.row,c=!0}if(t)if(rn(t))i=Mt(t),a=!0;else if(an(t))s=parseInt(t,10)-1,l=!0;else{const e=Dt(t);i=e.col,s=e.row,o=a?s:o,n=l?i:n,c=!0}if(a&&l)throw new Error("Wrong zone xc. The zone cannot be at the same time a full column and a full row");const h={top:o,left:n,bottom:a?void 0:s,right:l?void 0:i};return c=c&&(l||a),c&&(h.hasHeader=c),h}(e);return function(e){if(void 0!==e.right&&e.right<e.left){const t=e.left;e.left=e.right,e.right=t}if(void 0!==e.bottom&&e.bottom<e.top){const t=e.top;e.top=e.bottom,e.bottom=t}}(t),t}function gn(e){const t=un(e);if(void 0===t.bottom||void 0===t.right)throw new Error("This does not support unbounded ranges");return t}function pn(e){const{bottom:t,top:o,left:s,right:n}=e;return!(void 0!==t&&isNaN(t)||isNaN(o)||isNaN(s)||void 0!==n&&isNaN(n))&&(mn(e)&&e.top>=0&&e.left>=0)}function mn(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 fn(e){const{top:t,bottom:o,left:s,right:n}=e,i="hasHeader"in e&&e.hasHeader,r=t===o&&s===n;if(void 0===o&&void 0!==n)return 0!==t||i?`${Lt(s,t)}:${Ot(n)}`:`${Ot(s)}:${Ot(n)}`;if(void 0===n&&void 0!==o)return 0!==s||i?`${Lt(s,t)}:${o+1}`:`${t+1}:${o+1}`;if(void 0!==o&&void 0!==n)return r?Lt(s,t):`${Lt(s,t)}:${Lt(n,o)}`;throw new Error(a("Bad zone format"))}function bn(e,t,o,s,n){const i="left"===t?"columns":"rows",r="before"===s?o-1:o,a=e["left"===t?"right":"bottom"];return e[t]<=r&&a&&a>r?Nn(e,i,"RESIZE",n):r<e[t]?Nn(e,i,"MOVE",n):{...e}}function vn(e,t,o,s,n){const i="left"===t?"columns":"rows",r="before"===s?o-1:o,a="left"===t?"right":"bottom";return e[t]<=r&&e[a]>r?Nn(e,i,"RESIZE",n):r<e[t]?Nn(e,i,"MOVE",n):{...e}}function Sn(e,t,o){const s="left"===t?"right":"bottom";let n=e[t],i=e[s];for(let r of o.sort(((e,t)=>t-e)))e[t]>r&&(n--,i--),e[t]<r&&e[s]>=r&&i--;return{...e,[t]:n,[s]:i}}function Cn(e,t,o){const s="left"===t?"right":"bottom";let n=e[t],i=e[s];const r=e[s];for(let s of o.sort(((e,t)=>t-e)))e[t]>s&&(n--,void 0!==i&&i--),void 0!==r&&void 0!==i&&e[t]<=s&&r>=s&&i--;if(!(void 0!==i&&n>i))return{...e,[t]:n,[s]:i}}function En(...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 yn(e,t){if(xn(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 wn(e,t){return e.left===t.left&&e.right===t.right&&e.top===t.top&&e.bottom===t.bottom}function xn(e,t){return!(e.bottom<t.top||t.bottom<e.top)&&!(e.right<t.left||t.right<e.left)}function In(e,t,o){const{left:s,right:n,top:i,bottom:r}=o;return e>=s&&e<=n&&t>=i&&t<=r}function Rn(e,t){return wn(En(t,e),t)}function Tn(e,t){const o=e.map(un),s=t.map(un),n=Math.max(...o.concat(s).map((e=>e.bottom||0))),i=Math.max(...o.concat(s).map((e=>e.right||0))),r=o.map((e=>({...e,bottom:void 0===e.bottom?n+1:e.bottom,right:void 0===e.right?i+1:e.right}))),a=s.map((e=>({...e,bottom:void 0===e.bottom?n+1:e.bottom,right:void 0===e.right?i+1:e.right}))),l=function(e,t){const o=new Set(t.map((({col:e,row:t})=>`${e}-${t}`)));return e.filter((({col:e,row:t})=>!o.has(`${e}-${t}`)))}(r.map(Mn).flat(),a.map(Mn).flat()),c=function(e){if(0===e.length)return[];const[t,...o]=[...e].sort(((e,t)=>e.row-t.row)).sort(((e,t)=>e.col-t.col)),s=[];let n=Ln(t);for(const{col:e,row:t}of o)if(!In(e,t,n))if(e===n.left&&t===n.bottom+1){const e=n.bottom+1;n={...n,bottom:e}}else s.push(n),n=Ln({col:e,row:t});return[...s,n]}(l);return function(e){if(0===e.length)return[];if(e.some((e=>e.left!==e.right)))throw new Error("only columns can be merged");const t=[],o=An(e),s=(e,t)=>e.top===t.top&&e.bottom===t.bottom&&e.right+1===t.left;for(;o.length;){const e=o.reduce(((e,t)=>s(e,t)?En(e,t):e),o.shift());t.push(e)}return An(t)}(c).map((e=>({...e,bottom:e.bottom===n+1?void 0:e.bottom,right:e.right===i+1?void 0:e.right}))).map(fn)}function An(e){const t=[...e].sort(((e,t)=>t.right-e.right)).sort(((e,t)=>t.bottom-e.bottom)).sort(((e,t)=>e.top-t.top)).sort(((e,t)=>e.left-t.left)).reverse(),o=[];for(;0!==t.length;){const e=t.shift();t.some((t=>Rn(e,t)))||o.push(e)}return o.reverse()}function On(e){return{numberOfRows:e.bottom-e.top+1,numberOfCols:e.right-e.left+1}}function _n(e){const{numberOfCols:t,numberOfRows:o}=On(e);return 1===t||1===o}function Mn(e){const t=[],[o,s]=[e.right,e.left].sort(((e,t)=>e-t)),[n,i]=[e.top,e.bottom].sort(((e,t)=>e-t));for(const e of Ne(o,s+1))for(const o of Ne(n,i+1))t.push({col:e,row:o});return t}function Nn(e,t,o,s){const n="both"===t?s[0]:"columns"===t?s:0,i="both"===t?s[1]:"rows"===t?s:0,r="hasHeader"in e&&e.hasHeader;let a;a=!function(e){return void 0===e.bottom}(e)||r?!(Pn(e)&&!r)||"columns"!==t:"rows"!==t;const l={...e};return a&&"MOVE"===o&&(l.left+=n,l.top+=i),void 0!==l.right&&(l.right+=n),void 0!==l.bottom&&(l.bottom+=i),l}function Fn(e,t){let o,s;const{left:n,right:i,top:r,bottom:a}=e,{left:l,right:c,top:h,bottom:d}=t;return o=l!=n?l:c!=i?c:l,s=h!=r?h:d!=a?d:h,{col:o,row:s}}function Dn(e){return{top:Math.min(e.top,e.bottom),bottom:Math.max(e.top,e.bottom),left:Math.min(e.left,e.right),right:Math.max(e.left,e.right)}}function Ln(e){return{left:e.col,right:e.col,top:e.row,bottom:e.row}}function Pn(e){return void 0===e.right}function Vn(e){return(e.bottom-e.top+1)*(e.right-e.left+1)}function kn(...e){return e.length<2||1===Tn(e.map(fn),[]).length}class Un{getSheetSize;_zone;parts;invalidXc;prefixSheet=!1;sheetId;invalidSheetName;constructor(e,t){this.getSheetSize=t,this._zone=e.zone,this.prefixSheet=e.prefixSheet,this.invalidXc=e.invalidXc,this.sheetId=e.sheetId,this.invalidSheetName=e.invalidSheetName;let o=[...e.parts];1===e.parts.length&&Vn(this.zone)>1?o.push({...e.parts[0]}):2===e.parts.length&&1===Vn(this.zone)&&o.pop(),this.parts=o}static fromRange(e,t){return e instanceof Un?e:new Un(e,t.getSheetSize)}get unboundedZone(){return this._zone}get zone(){const{left:e,top:t,bottom:o,right:s}=this._zone;if(void 0!==s&&void 0!==o)return this._zone;if(void 0===o&&void 0!==s)return{right:s,top:t,left:e,bottom:this.getSheetSize(this.sheetId).numberOfRows-1};if(void 0===s&&void 0!==o)return{bottom:o,left:e,top:t,right:this.getSheetSize(this.sheetId).numberOfCols-1};throw new Error(a("Bad zone format"))}static getRangeParts(e,t){const o=e.split(":").map((e=>{const t=an(e);return{colFixed:!t&&e.startsWith("$"),rowFixed:t?e.startsWith("$"):e.includes("$",1)}})),s=void 0===t.bottom,n=void 0===t.right;return s&&(o[0].rowFixed=o[0].rowFixed||o[1].rowFixed,o[1].rowFixed=o[0].rowFixed||o[1].rowFixed),n&&(o[0].colFixed=o[0].colFixed||o[1].colFixed,o[1].colFixed=o[0].colFixed||o[1].colFixed),o}get isFullCol(){return void 0===this._zone.bottom}get isFullRow(){return void 0===this._zone.right}get rangeData(){return{_zone:this._zone,_sheetId:this.sheetId}}orderZone(){if(mn(this._zone))return this;const e={...this._zone};let t=this.parts;if(void 0!==e.right&&e.right<e.left){let o=e.right;e.right=e.left,e.left=o,t=[{colFixed:t[1]?.colFixed||!1,rowFixed:t[0]?.rowFixed||!1},{colFixed:t[0]?.colFixed||!1,rowFixed:t[1]?.rowFixed||!1}]}if(void 0!==e.bottom&&e.bottom<e.top){let o=e.bottom;e.bottom=e.top,e.top=o,t=[{colFixed:t[0]?.colFixed||!1,rowFixed:t[1]?.rowFixed||!1},{colFixed:t[1]?.colFixed||!1,rowFixed:t[0]?.rowFixed||!1}]}return this.clone({zone:e,parts:t})}clone(e){return new Un({zone:e?.zone?e.zone:{...this._zone},sheetId:e?.sheetId?e.sheetId:this.sheetId,invalidSheetName:e&&"invalidSheetName"in e?e.invalidSheetName:this.invalidSheetName,invalidXc:e&&"invalidXc"in e?e.invalidXc:this.invalidXc,parts:e?.parts?e.parts:this.parts.map((e=>({rowFixed:e.rowFixed,colFixed:e.colFixed}))),prefixSheet:e?.prefixSheet?e.prefixSheet:this.prefixSheet},this.getSheetSize)}}function Bn(e,t,o){const s=o.sheetId===e?t:o.sheetId;return o.clone({sheetId:s})}function Hn(e,t,o){if(!o)return;const s=e.getRangeFromSheetXC(t,o);return s.invalidSheetName||s.invalidXc?void 0:s}function zn(e){const t=[];for(const o of e)for(const e of Mn(o.zone))t.push({...e,sheetId:o.sheetId});return t}function Gn(e,t,o){const s=[];return t.forEach((t=>{const n=function(e,t){e=e.toLocaleLowerCase();let o=0,s=0,n=(t=t.toLocaleLowerCase()).length,i=0;for(let r=0;r<n;r++)t[r]===e[i]?(i++,s+=100+s-r/200):s=0,o+=s;return i===e.length?o:0}(e,o(t));n>0&&s.push({score:n,elem:t})})),s.sort(((e,t)=>t.score-e.score)),s.map((e=>e.elem))}function $n(e){const t=[];for(let o=0;o<e;o++){const e={cells:{}};t.push(e)}return t}function Wn(e,t,o){return o.map((o=>o>=e?o+t:o))}function qn(e,t){return e=[...e].sort(((e,t)=>t-e)),t.map((t=>{for(const o of e)if(t>o)t--;else if(t===o)return;return t})).filter(We)}function Zn(e,t="Sheet"){let o=1,s=`${t}${o}`;for(;e.includes(s);)s=`${t}${o}`,o++;return s}function Yn(e,t){let o=1;const s=a("Copy of %s",e);let n=s.toString();for(;t.includes(n);)n=`${s} (${o})`,o++;return n}function jn(e,t){return void 0!==e&&void 0!==t&&Oe(e.trim().toUpperCase())===Oe(t.trim().toUpperCase())}function Xn(e,t=1){return t*(e+Z)-Z}function Kn(e,t,o,s){const n=ni(e,t,o,"wrap"===o?.wrapping?s-2*Z:void 0).length;return Xn(oi(o),n)+2*Y}const Qn={};function Jn(e,t,o){const s=ti(o);if(Qn[s]||(Qn[s]={}),void 0===Qn[s][t]){e.save(),e.font=s;const o=e.measureText(t).width;e.restore(),Qn[s][t]=o}return Qn[s][t]}function ei(e){return Math.round(96*e/72)}function ti(e){return`${e.italic?"italic ":""}${e.bold?"bold":se} ${oi(e)}px ${ie}`}function oi(e){return ei(e?.fontSize||ne)}function si(e,t,o,s){if(Jn(e,t,s)<=o)return[t];const n=[];let i="";for(let r of t){Jn(e,i+r,s)>o?(n.push(i),i=r):i+=r}return n.push(i),n}function ni(e,t,o,s){o||(o={}),Ve(t)&&(t=Be(t).label);const n=[],i=t.includes(xe)?t.split(xe):[t];for(const t of i){const i=t.includes(" ")?t.split(" "):[t];if(!s){n.push(t);continue}let r="",a=s;for(let t of i){const i=si(e,t,s,o),l=i.pop(),c=Jn(e,l,o);if(i.length)""!==r&&(n.push(r),r="",a=s),i.forEach((e=>{n.push(e)})),r=l,a=s-c;else{const t=""===r?l:" "+l,i=Jn(e,t,o);i<=a?(r+=t,a-=i):(n.push(r),r=l,a=s-c)}}""!==r&&n.push(r)}return n}function ii(e){return e?e.toLowerCase():""}const ri=/([0-9\.]*)px/;function ai(e,t,o,s=!1,n=!1,i=function(e){return Number(e.match(ri)?.[1])}(e.font)/10){if(e.fillText(t,o.x,o.y),!s&&!n)return;const r=e.measureText(t),a=r.width,l=r.actualBoundingBoxAscent+r.actualBoundingBoxDescent,c=r.fontBoundingBoxAscent+r.fontBoundingBoxDescent;let{x:h,y:d}=o,u=d,g=d;switch(e.textAlign){case"center":h-=a/2;break;case"right":h-=a}switch(e.textBaseline){case"top":g+=c-2*i,u+=c/2-i;break;case"middle":g+=c/2-i;break;case"alphabetic":g+=2*i,u-=3*i;break;case"bottom":g=d,u-=l/2-i/2}s&&(e.lineWidth=i,e.strokeStyle=e.fillStyle,e.beginPath(),e.moveTo(h,g),e.lineTo(h+a,g),e.stroke()),n&&(e.lineWidth=i,e.strokeStyle=e.fillStyle,e.beginPath(),e.moveTo(h,u),e.lineTo(h+a,u),e.stroke())}class li{isFastIdStrategy=!1;fastIdStart=0;setIsFastStrategy(e){this.isFastIdStrategy=e}smallUuid(){return this.isFastIdStrategy?(this.fastIdStart++,String(this.fastIdStart)):window.crypto?"10000000-1000".replace(/[01]/g,(e=>{const t=Number(e);return(t^crypto.getRandomValues(new Uint8Array(1))[0]&15>>t/4).toString(16)})):"xxxxxxxx-xxxx".replace(/[xy]/g,(function(e){var t=16*Math.random()|0;return("x"==e?t:3&t|8).toString(16)}))}uuidv4(){return this.isFastIdStrategy?(this.fastIdStart++,String(this.fastIdStart)):window.crypto?"10000000-1000-4000-8000-100000000000".replace(/[018]/g,(e=>{const 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){var t=16*Math.random()|0;return("x"==e?t:3&t|8).toString(16)}))}}function ci(e){return e.map(di).sort(((e,t)=>e.sequence-t.sequence))}const hi=new li;function di(e){const t=e.name,o=e.children,s=e.description,n=e.icon;return{id:e.id||hi.uuidv4(),name:"function"==typeof t?t:()=>t,isVisible:e.isVisible?e.isVisible:()=>!0,isEnabled:e.isEnabled?e.isEnabled:()=>!0,isActive:e.isActive,execute:e.execute,children:o?e=>o.map((t=>"function"==typeof t?t(e):t)).flat().map(di):()=>[],isReadonlyAllowed:e.isReadonlyAllowed||!1,separator:e.separator||!1,icon:"function"==typeof n?n:()=>n||"",description:"function"==typeof s?s:()=>s||"",textColor:e.textColor,sequence:e.sequence||0}}function ui(e,t){return"REMOVE_COLUMNS_ROWS"===t.type?Cn(e,"COL"===t.dimension?"left":"top",t.elements):"ADD_COLUMNS_ROWS"===t.type?bn(e,"COL"===t.dimension?"left":"top",t.base,t.position,t.quantity):e}function gi(e,t){const o="DELETE_SHEET"===t.type&&t.sheetId;if("sheetId"in t&&e._sheetId!==t.sheetId)return e;{const s=ui(e._zone,t);if(s&&o!==e._sheetId)return{...e,_zone:s}}}class pi extends t.Component{static template="o-spreadsheet-ChartJsComponent";canvas=t.useRef("graphContainer");chart;get background(){return this.chartRuntime.background}get canvasStyle(){return`background-color: ${this.background}`}get chartRuntime(){const e=this.env.model.getters.getChartRuntime(this.props.figure.id);if(!("chartJsConfig"in e))throw new Error("Unsupported chart runtime");return e}setup(){t.onMounted((()=>{const e=this.chartRuntime;this.createChart(Ae(e.chartJsConfig))})),t.useEffect((()=>this.updateChartJs(Ae(this.chartRuntime))),(()=>[this.chartRuntime,window.devicePixelRatio]))}createChart(e){const t=this.canvas.el.getContext("2d");this.chart=new window.Chart(t,e)}updateChartJs(e){const t=e.chartJsConfig;t.data&&t.data.datasets?(this.chart.data=t.data,t.options?.plugins?.title&&(this.chart.config.options.plugins.title=t.options.plugins.title),t.options&&"valueLabel"in t.options&&t.options?.valueLabel&&(this.chart.config.options.valueLabel=t.options.valueLabel)):this.chart.data.datasets=[],this.chart.config.options.plugins.tooltip=t.options.plugins.tooltip,this.chart.config.options.plugins.legend=t.options.plugins.legend,this.chart.config.options.scales=t.options?.scales,this.chart.update()}}pi.props={figure:Object};class mi{sheetId;title;getters;constructor(e,t,o){this.title=e.title,this.sheetId=t,this.getters=o}static validateChartDefinition(e,t){throw new Error("This method should be implemented by sub class")}static transformDefinition(e,t){throw new Error("This method should be implemented by sub class")}static getDefinitionFromContextCreation(e){throw new Error("This method should be implemented by sub class")}}function fi(e,t,o,s){let n=!1;const i=[];for(let s in o){let r=o[s];if(r.labelCell){const e=Si(r.labelCell,t);r.labelCell!==e&&(n=!0,r={...r,labelCell:e})}const a=Si(r.dataRange,t);void 0===a||e.getRangeString(a,a.sheetId)===ce?(n=!0,r=void 0):a!==r.dataRange&&(n=!0,r={...r,dataRange:a}),i[s]=r}let r=s;const a=Si(r,t);a!==r&&(n=!0,r=a);return{isStale:n,dataSets:i.filter(We),labelRange:r}}function bi(e,t,o){return o.map((o=>({dataRange:Bn(e,t,o.dataRange),labelCell:o.labelCell?Bn(e,t,o.labelCell):void 0})))}function vi(e,t,o){return o?Bn(e,t,o):void 0}function Si(e,t){if(!e)return;const o=t(e);switch(o.changeType){case"NONE":return e;case"REMOVE":return;default:return o.range}}function Ci(e,t,o,s){const n=[];for(const i of t){const t=e.getRangeFromSheetXC(o,i),{unboundedZone:r,sheetId:a,invalidSheetName:l,invalidXc:c}=t;if(!l&&!c)if(r.left!==r.right&&r.top!==r.bottom){if(void 0===r.right)continue;for(let t=r.left;t<=r.right;t++){const o={...r,left:t,right:t};n.push(Ei(e,a,o,s?{top:o.top,bottom:o.top,left:o.left,right:o.left}:void 0))}}else n.push(Ei(e,a,r,s?{top:r.top,bottom:r.top,left:r.left,right:r.left}:void 0))}return n}function Ei(e,t,o,s){if(o.left!==o.right&&o.top!==o.bottom)throw new Error(`Zone should be a single column or row: ${fn(o)}`);if(s){const n=fn(o),i=fn(s);return{labelCell:e.getRangeFromSheetXC(t,i),dataRange:e.getRangeFromSheetXC(t,n)}}return{labelCell:void 0,dataRange:e.getRangeFromSheetXC(t,fn(o))}}function yi(e,t){const o=t.labelCell?.zone;let s=t.dataRange.zone;if(o){const{numberOfRows:e,numberOfCols:t}=On(s);1===e?s={...s,left:s.left+1}:1===t&&(s={...s,top:s.top+1})}const n=t.dataRange.clone({zone:s});return{label:t.labelCell?e.getRangeString(t.labelCell,"forceSheetReference",{useFixedReference:!0}):void 0,range:e.getRangeString(n,"forceSheetReference",{useFixedReference:!0})}}function wi(e,t,o){if(!t)return;let s={...t.zone};o&&t.zone.bottom>t.zone.top&&(s.top=s.top+1);const n=t.clone({zone:s});return e.getRangeString(n,"forceSheetReference",{useFixedReference:!0})}function xi(e,t){let o;if(e.labelRange){const s=ui(un(e.labelRange),t);o=s?fn(s):void 0}const s=e.dataSets.map(un).map((e=>ui(e,t))).filter(We).map(fn);return{...e,labelRange:o,dataSets:s}}const Ii=["rgb(31,119,180)","rgb(255,127,14)","rgb(174,199,232)","rgb(255,187,120)","rgb(44,160,44)","rgb(152,223,138)","rgb(214,39,40)","rgb(255,152,150)","rgb(148,103,189)","rgb(197,176,213)","rgb(140,86,75)","rgb(196,156,148)","rgb(227,119,194)","rgb(247,182,210)","rgb(127,127,127)","rgb(199,199,199)","rgb(188,189,34)","rgb(219,219,141)","rgb(23,190,207)","rgb(158,218,229)"];class Ri{graphColorIndex=0;next(){return Ii[this.graphColorIndex++%Ii.length]}}function Ti(e){return e&&yt(e)<.3?"#FFFFFF":"#000000"}function Ai(e){if(e.dataSets){const t=void 0!==e.dataSets.find((e=>!nn.test(e)));if(t)return"InvalidDataSet";if(e.dataSets.map(un).some((e=>e.top!==e.bottom&&Pn(e))))return"InvalidDataSet"}return"Success"}function Oi(e){if(e.labelRange){if(!nn.test(e.labelRange||""))return"InvalidLabelRange"}return"Success"}function _i(e,t,o){if(!o)return!1;if(!e)return!1;if(!t)return!0;const s=Vn(t.dataRange.zone);return!(Vn(e.zone)<s)}function Mi(e,t,o,s){if(e){if("text"===o||t?.type!==bo.number||e.type!==bo.number)return e.formattedValue;{let n=t.value-e.value;if("percentage"===o&&0!==n&&(n=n/e.value*100),"percentage"!==o&&e.format)return Ts(n,{format:e.format,locale:s});const i=Math.abs(parseFloat(n.toFixed(2))).toLocaleString();return"percentage"===o?i+"%":i}}return""}function Ni(e,t,o,s,n){if("text"===t||e?.type!==bo.number||o?.type!==bo.number)return;const i=o.value-e.value;return i>0?s:i<0?n:void 0}function Fi(e,t,o){if("text"===o||e?.type!==bo.number||t?.type!==bo.number)return"neutral";const s=t.value-e.value;return s>0?"up":s<0?"down":"neutral"}function Di(e){return e.keyValue&&!nn.test(e.keyValue)?"InvalidScorecardKeyValue":"Success"}function Li(e){return e.baseline&&!nn.test(e.baseline)?"InvalidScorecardBaseline":"Success"}const Pi=new window.Path2D("M8.6 4.8a.5.5 0 0 1 0 .75l-3.9 3.9a.5 .5 0 0 1 -.75 0l-3.8 -3.9a.5 .5 0 0 1 0 -.75l.4-.4a.5.5 0 0 1 .75 0l2.3 2.4v-5.7c0-.25.25-.5.5-.5h.6c.25 0 .5.25.5.5v5.8l2.3 -2.4a.5.5 0 0 1 .75 0z"),Vi=new window.Path2D("M8.7 5.5a.5.5 0 0 0 0-.75l-3.8-4a.5.5 0 0 0-.75 0l-3.8 4a.5.5 0 0 0 0 .75l.4.4a.5.5 0 0 0 .75 0l2.3-2.4v5.8c0 .25.25.5.5.5h.6c.25 0 .5-.25.5-.5v-5.8l2.2 2.4a.5.5 0 0 0 .75 0z");let ki=class e extends mi{keyValue;baseline;baselineMode;baselineDescr;background;baselineColorUp;baselineColorDown;fontColor;type="scorecard";constructor(e,t,o){super(e,t,o),this.keyValue=Hn(o,t,e.keyValue),this.baseline=Hn(o,t,e.baseline),this.baselineMode=e.baselineMode,this.baselineDescr=e.baselineDescr,this.background=e.background,this.baselineColorUp=e.baselineColorUp,this.baselineColorDown=e.baselineColorDown}static validateChartDefinition(e,t){return e.checkValidations(t,Di,Li)}static getDefinitionFromContextCreation(e){return{background:e.background,type:"scorecard",keyValue:e.range?e.range[0]:void 0,title:e.title||"",baselineMode:pe,baselineColorUp:me,baselineColorDown:fe,baseline:e.auxiliaryRange||""}}static transformDefinition(e,t){let o,s;return e.baseline&&(o=ui(un(e.baseline),t)),e.keyValue&&(s=ui(un(e.keyValue),t)),{...e,baseline:o?fn(o):void 0,keyValue:s?fn(s):void 0}}copyForSheetId(t){const o=vi(this.sheetId,t,this.baseline),s=vi(this.sheetId,t,this.keyValue),n=this.getDefinitionWithSpecificRanges(o,s,t);return new e(n,t,this.getters)}copyInSheetId(t){const o=this.getDefinitionWithSpecificRanges(this.baseline,this.keyValue,t);return new e(o,t,this.getters)}getDefinition(){return this.getDefinitionWithSpecificRanges(this.baseline,this.keyValue)}getContextCreation(){return{background:this.background,title:this.title,range:this.keyValue?[this.getters.getRangeString(this.keyValue,this.sheetId)]:void 0,auxiliaryRange:this.baseline?this.getters.getRangeString(this.baseline,this.sheetId):void 0}}getDefinitionWithSpecificRanges(e,t,o){return{baselineColorDown:this.baselineColorDown,baselineColorUp:this.baselineColorUp,baselineMode:this.baselineMode,title:this.title,type:"scorecard",background:this.background,baseline:e?this.getters.getRangeString(e,o||this.sheetId):void 0,baselineDescr:this.baselineDescr,keyValue:t?this.getters.getRangeString(t,o||this.sheetId):void 0}}getDefinitionForExcel(){}updateRanges(t){const o=Si(this.baseline,t),s=Si(this.keyValue,t);if(this.baseline===o&&this.keyValue===s)return this;const n=this.getDefinitionWithSpecificRanges(o,s);return new e(n,this.sheetId,this.getters)}};function Ui(e,t){const o=t.getContext("2d"),s=window.devicePixelRatio||1;if(t.width=e.canvas.width*s,t.height=e.canvas.height*s,o.scale(s,s),o.fillStyle=e.canvas.backgroundColor,o.fillRect(0,0,e.canvas.width,e.canvas.height),e.title&&(o.font=e.title.style.font,o.fillStyle=e.title.style.color,o.fillText(e.title.text,e.title.position.x,e.title.position.y)),e.baseline&&(o.font=e.baseline.style.font,o.fillStyle=e.baseline.style.color,ai(o,e.baseline.text,e.baseline.position,e.baseline.style.underline,e.baseline.style.strikethrough)),e.baselineArrow&&e.baselineArrow.style.size>0){o.save(),o.fillStyle=e.baselineArrow.style.color,o.translate(e.baselineArrow.position.x,e.baselineArrow.position.y);const t=e.baselineArrow.style.size/10;switch(o.scale(t,t),e.baselineArrow.direction){case"down":o.fill(Pi);break;case"up":o.fill(Vi)}o.restore()}e.baselineDescr&&(o.font=e.baselineDescr.style.font,o.fillStyle=e.baselineDescr.style.color,o.fillText(e.baselineDescr.text,e.baselineDescr.position.x,e.baselineDescr.position.y)),e.key&&(o.font=e.key.style.font,o.fillStyle=e.key.style.color,ai(o,e.key.text,e.key.position,e.key.style.underline,e.key.style.strikethrough))}function Bi(e,t=!1,o=!1){return`${o?"italic":""} ${t?"bold":""} ${e}px ${ie}`}function Hi({width:e,height:t},o){return new zi({width:e,height:t},o).computeDesign()}class zi{runtime;context;width;height;constructor({width:e,height:t},o){this.runtime=o;const s=document.createElement("canvas");this.width=s.width=e,this.height=s.height=t,this.context=s.getContext("2d")}computeDesign(){const e={canvas:{width:this.width,height:this.height,backgroundColor:this.backgroundColor}},t=this.getTextStyles(),{height:o}=this.getTextDimensions(this.title,t.title.font);this.title&&(e.title={text:this.title,style:t.title,position:{x:this.chartPadding,y:this.chartPadding+o}});const s=t.baselineArrow?.size??0,{height:n,width:i}=this.getTextDimensions(this.baseline,t.baselineValue.font),{width:r}=this.getTextDimensions(this.baselineDescr,t.baselineDescr.font);e.baseline={text:this.baseline,style:t.baselineValue,position:{x:(this.width-i-r+s)/2,y:this.keyValue?this.height-2*this.chartPadding:this.height-(this.height-o-n)/2-this.chartPadding}},t.baselineArrow&&(e.baselineArrow={direction:this.baselineArrow,style:t.baselineArrow,position:{x:e.baseline.position.x-s,y:e.baseline.position.y-(n+s)/2}}),this.baselineDescr&&(e.baselineDescr={text:this.baselineDescr,style:t.baselineDescr,position:{x:e.baseline.position.x+i,y:e.baseline.position.y}});const{height:a,width:l}=this.getTextDimensions(this.keyValue,t.keyValue.font);return this.keyValue&&(e.key={text:this.keyValue,style:t.keyValue,position:{x:(this.width-l)/2,y:(this.height-n+o+a)/2-this.chartPadding}}),e}get title(){return this.runtime.title}get keyValue(){return this.runtime.keyValue}get baseline(){return this.runtime.baselineDisplay}get baselineDescr(){return function(e,t){const o=e||"";return t&&o?" "+o:o}(this.runtime.baselineDescr,this.baseline)}get baselineArrow(){return this.runtime.baselineArrow}get backgroundColor(){return this.runtime.background}get secondaryFontColor(){return yt(this.backgroundColor)>.3?"#525252":"#C8C8C8"}get chartPadding(){return.02*this.width}getTextDimensions(e,t){this.context.font=t;const o=this.context.measureText(e);return{width:o.width,height:o.actualBoundingBoxAscent+o.actualBoundingBoxDescent}}getTextStyles(){const e=.96*this.width,t=this.getWidestElement(),o=t.getElementMaxFontSize(this.getDrawableHeight(),this);let s=function(e,t,o,s=.25){let n=1;if(o(n)>e)return n;if(o(t)<e)return t;let i=(n+t)/2,r=o(i),a=0;for(;Math.abs(r-e)>s&&a<20;)r>=e?t=(n+t)/2:n=(n+t)/2,i=(n+t)/2,r=o(i),a++;return i}(e,o,(e=>t.getElementWidth(e,this.context,this)))/o;const n=new Wi(this.runtime.keyValueStyle).getElementMaxFontSize(this.getDrawableHeight(),this)*s,i=new $i(this.runtime.baselineStyle).getElementMaxFontSize(this.getDrawableHeight(),this)*s;return{title:{font:Bi(18),color:this.secondaryFontColor},keyValue:{color:this.runtime.keyValueStyle?.textColor||this.runtime.fontColor,font:Bi(n,this.runtime.keyValueStyle?.bold,this.runtime.keyValueStyle?.italic),strikethrough:this.runtime.keyValueStyle?.strikethrough,underline:this.runtime.keyValueStyle?.underline},baselineValue:{font:Bi(i,this.runtime.baselineStyle?.bold,this.runtime.baselineStyle?.italic),strikethrough:this.runtime.baselineStyle?.strikethrough,underline:this.runtime.baselineStyle?.underline,color:this.runtime.baselineStyle?.textColor||this.runtime.baselineColor||this.secondaryFontColor},baselineDescr:{font:Bi(.9*i),color:this.secondaryFontColor},baselineArrow:"neutral"===this.baselineArrow?void 0:{size:this.keyValue?.8*i:0,color:this.runtime.baselineColor||this.secondaryFontColor}}}getDrawableHeight(){const e=2*this.chartPadding;let t=this.height-e;return t-=this.title?18*1.2:0,t}getWidestElement(){const e=new $i(this.runtime.baselineStyle),t=new Wi(this.runtime.keyValueStyle);return e.getElementWidth(.35,this.context,this)>t.getElementWidth(.65,this.context,this)?e:t}}class Gi{style;constructor(e={}){this.style=e}measureTextWidth(e,t,o){return e.font=Bi(o,this.style.bold,this.style.italic),e.measureText(t).width}}class $i extends Gi{getElementWidth(e,t,o){if(!o.runtime)return 0;const s=o.baseline,n="neutral"!==o.baselineArrow?"A "+s:s;let i=this.measureTextWidth(t,n,e);return i+=this.measureTextWidth(t,o.baselineDescr,.9*e),i}getElementMaxFontSize(e,t){if(!t.runtime)return 0;return(""!==t.baseline||t.baselineDescr?.35*e:0)/1.2}}class Wi extends Gi{getElementWidth(e,t,o){if(!o.runtime)return 0;const s=o.keyValue||"";return this.measureTextWidth(t,s,e)}getElementMaxFontSize(e,t){if(!t.runtime)return 0;return(""!==t.baseline||t.baselineDescr?.65*e:e)/1.2}}class qi extends t.Component{static template="o-spreadsheet-ScorecardChart";canvas=t.useRef("chartContainer");get runtime(){return this.env.model.getters.getChartRuntime(this.props.figure.id)}setup(){t.useEffect(this.createChart.bind(this),(()=>{const e=this.canvas.el.getBoundingClientRect();return[e.width,e.height,this.runtime,this.canvas.el,window.devicePixelRatio]}))}createChart(){const e=this.canvas.el;Ui(Hi(e.getBoundingClientRect(),this.runtime),e)}}qi.props={figure:Object};class Zi{content={};add(e,t){return this.content[e]=t,this}get(e){const t=this.content[e];if(!t&&!(e in this.content))throw new Error(`Cannot find ${e} in this registry!`);return t}contains(e){return e in this.content}getAll(){return Object.values(this.content)}getKeys(){return Object.keys(this.content)}remove(e){delete this.content[e]}}function Yi(e){return/^https?:\/\//i.test(e)?e:`https://${e}`}const ji=new Zi;function Xi(e,t){return{url:e=Yi(e),label:t||e,isExternal:!0,isUrlEditable:!0}}ji.add("sheet_URL",{match:e=>ze(e),createLink:(e,t)=>({label:t,url:e,isExternal:!1,isUrlEditable:!1}),urlRepresentation(e,t){const o=$e(e);return t.tryGetSheetName(o)||a("Invalid sheet")},open(e,t){const o=$e(e);t.model.dispatch("ACTIVATE_SHEET",{sheetIdFrom:t.model.getters.getActiveSheetId(),sheetIdTo:o})},sequence:0});const Ki={createLink:Xi,match:e=>ke(e),open:e=>window.open(e,"_blank"),urlRepresentation:e=>e,sequence:0};function Qi(e){return ji.getAll().sort(((e,t)=>e.sequence-t.sequence)).find((t=>t.match(e)))||Ki}function Ji(e,t){return Qi(e.url).urlRepresentation(e.url,t)}function er(e,t){Qi(e.url).open(e.url,t)}function tr(e){if("string"==typeof e){if(Ve(e)){const{label:t,url:o}=Be(e);return Qi(o).createLink(o,t)}return ke(e)?Xi(e):void 0}}function or(e,t){return nr(sr(e||"",t.locale),t)}function sr(e,t){if(e.startsWith("="))throw new Error(`Cannot parse "${e}" because it's not a literal value. It's a formula`);return go(e,Oo)?Vo(e,Oo):jt(e,t)?Vo(e,t):function(e){const t=e.toUpperCase();return"TRUE"===t||"FALSE"===t}(e)?"TRUE"===e.toUpperCase():e}function nr(e,t){const o=tr(e);return o?{...ir(sr(o.label,t.locale),{format:t.format||Hs(o.label,t.locale)||zs(o.label),locale:t.locale}),link:o}:ir(e,t)}function ir(e,t){try{for(const o of cr){const s=o(e,t);if(s)return s}return function(e,t){return{type:bo.text,value:e,format:t.format,isAutoSummable:!0,defaultAlign:"left",formattedValue:Ts(e,t)}}((e||"").toString(),t)}catch(e){return lr(new d(c.GenericError,e.message||Ce))}}function rr(e,t){return{type:bo.number,value:e||0,format:t.format,isAutoSummable:!0,defaultAlign:"right",formattedValue:Ts(e,t)}}const ar={type:bo.empty,value:"",format:void 0,isAutoSummable:!0,defaultAlign:"left",formattedValue:""};function lr(e){return{type:bo.error,value:e.errorType,error:e,isAutoSummable:!1,defaultAlign:"center",formattedValue:e.errorType}}const cr=[function(e,t){if(""===e)return function(e){return void 0===e.format?ar:{type:bo.empty,value:"",format:e.format,isAutoSummable:!0,defaultAlign:"left",formattedValue:""}}(t)},function(e,t){if(t.format&&"number"==typeof e&&Ds(t.format))return function(e,t){const o=Ts(e,t);return{type:bo.number,value:e,format:t.format,isAutoSummable:!1,defaultAlign:"right",formattedValue:o}}(e,t)},function(e,t){return"number"==typeof e?rr(e,t):null===e?rr(0,t):void 0},function(e,t){if("boolean"==typeof e)return function(e,t){const o=e?"TRUE":"FALSE";return{type:bo.boolean,value:e,format:t.format,isAutoSummable:!1,defaultAlign:"center",formattedValue:o}}(e,t)}],hr=new Zi;hr.add("ALPHANUMERIC_INCREMENT_MODIFIER",{apply:(e,t)=>{e.current+=e.increment;const o=`${e.prefix}${e.current.toString().padStart(e.numberPostfixLength||0,"0")}`;return{cellData:{border:t.border,style:t.cell&&t.cell.style,format:t.cell&&t.cell.format,content:o},tooltip:{props:{content:o}}}}}).add("INCREMENT_MODIFIER",{apply:(e,t,o)=>{e.current+=e.increment;const s=e.current.toString(),n=o.getLocale(),i=Ts(e.current,{format:t.cell?.format,locale:n});return{cellData:{border:t.border,style:t.cell&&t.cell.style,format:t.cell&&t.cell.format,content:s},tooltip:s?{props:{content:i}}:void 0}}}).add("COPY_MODIFIER",{apply:(e,t,o)=>{const s=t.cell?.content||"",n={locale:o.getLocale(),format:t.cell?.format};return{cellData:{border:t.border,style:t.cell&&t.cell.style,format:t.cell&&t.cell.format,content:s},tooltip:s?{props:{content:or(t.cell?.content,n).formattedValue}}:void 0}}}).add("FORMULA_MODIFIER",{apply:(e,t,o,s)=>{e.current+=e.increment;let n=0,i=0;switch(s){case"up":n=0,i=-e.current;break;case"down":n=0,i=e.current;break;case"left":n=-e.current,i=0;break;case"right":n=e.current,i=0}const r=t.cell;if(!r||!r.isFormula)return{cellData:{}};const a=t.sheetId,l=o.getTranslatedCellFormula(a,n,i,r.compiledFormula);return{cellData:{border:t.border,style:r.style,format:r.format,content:l},tooltip:l?{props:{content:l}}:void 0}}});const dr=new Zi,ur=/(\d+)$/,gr=/^(.*\D+)/,pr=/^(.*\D+)(\d+)$/;function mr(e,t,o){let s=[],n=!1;for(let i of t){i===e&&(n=!0);const t=i?.isFormula?void 0:or(i?.content,{locale:Oo});if(t&&o(t))s.push(t);else{if(n)return s;s=[]}}return s}function fr(e){let t=1;return e.length>=2&&(t=function(e){const t=[];let o=e[0];for(let s=1;s<e.length;s++){const n=e[s];t.push(n-o),o=n}return t.reduce(((e,t)=>e+t),0)/t.length}(e)*e.length),t}dr.add("simple_value_copy",{condition:(e,t)=>!(1!==t.length||e.isFormula||e.format&&Ds(e.format)),generateRule:()=>({type:"COPY_MODIFIER"}),sequence:10}).add("increment_alphanumeric_value",{condition:e=>!e.isFormula&&or(e.content,{locale:Oo}).type===bo.text&&pr.test(e.content),generateRule:(e,t,o)=>{const s=parseInt(e.content.match(ur)[0]),n=e.content.match(gr)[0],i=e.content.length-n.length,r=mr(e,t,(e=>e.type===bo.text&&pr.test(e.value))).filter((e=>n===e.value.toString().match(gr)[0])).map((e=>parseInt(e.value.toString().match(ur)[0])));let a=fr(r);return["up","left"].includes(o)&&1===r.length&&(a=-a),{type:"ALPHANUMERIC_INCREMENT_MODIFIER",prefix:n,current:s,increment:a,numberPostfixLength:i}},sequence:15}).add("copy_text",{condition:e=>!e.isFormula&&or(e.content,{locale:Oo}).type===bo.text,generateRule:()=>({type:"COPY_MODIFIER"}),sequence:20}).add("update_formula",{condition:e=>e.isFormula,generateRule:(e,t)=>({type:"FORMULA_MODIFIER",increment:t.length,current:0}),sequence:30}).add("increment_number",{condition:e=>!e.isFormula&&or(e.content,{locale:Oo}).type===bo.number,generateRule:(e,t,o)=>{const s=mr(e,t,(e=>e.type===bo.number)).map((e=>Number(e.value)));let n=fr(s);["up","left"].includes(o)&&1===s.length&&(n=-n);const i=or(e.content,{locale:Oo});return{type:"INCREMENT_MODIFIER",increment:n,current:i.type===bo.number?i.value:0}},sequence:40});const br={};let vr=0;function Sr(e,...t){const o="__sheet__"+vr++;return function(e,t){const o=document.createElement("style");o.textContent=function(e){const t=e.split(/(\{|\}|;)/).map((e=>e.trim())),o=[],s=[];let n=[];function i(e,t){const s=[];for(const n of o[e]){let r=t&&t+" "+n||n;r.includes("&")&&(r=n.replace(/&/g,t||"")),e<o.length-1&&(r=i(e+1,r)),s.push(r)}return s.join(", ")}function r(){n.length&&(s.push(i(0)+" {"),s.push(...n),s.push("}"),n=[])}for(;t.length;){let e=t.shift();"}"===e?(r(),o.pop()):("{"===t[0]&&(r(),o.push(e.split(/\s*,\s*/)),t.shift()),";"===t[0]&&n.push(" "+e+";"))}return s.join("\n")}(t),br[e]=o}(o,String.raw(e,...t)),function(e){const t=br[e];t.setAttribute("component",e),document.head.appendChild(t)}(o),o}function Cr({strikethrough:e,underline:t}){return e||t?`${e?"line-through":""} ${t?"underline":""}`:"none"}function Er(e){const t=function(e){const t={};if(!e)return t;e.bold&&(t["font-weight"]="bold");e.italic&&(t["font-style"]="italic");if(e.strikethrough||e.underline){let o=e.strikethrough?"line-through":"";o=e.underline?o+" underline":o,t["text-decoration"]=o}e.textColor&&(t.color=e.textColor);return t}(e);return e?(e.fillColor&&(t.background=e.fillColor),t):t}function yr(e){let t="";for(const o in e)e[o]&&(t+=`${o}:${e[o]}; `);return t}Sr`
2
2
  .o-error-tooltip {
3
3
  font-size: 13px;
4
4
  background-color: white;
@@ -286,7 +286,7 @@
286
286
  height: 100%;
287
287
  position: relative;
288
288
  }
289
- `;class Dl extends t.Component{static template="o-spreadsheet-ChartFigure";static components={};onDoubleClick(){this.env.model.dispatch("SELECT_FIGURE",{id:this.props.figure.id}),this.env.openSidePanel("ChartPanel")}get chartType(){return this.env.model.getters.getChartType(this.props.figure.id)}get chartComponent(){const e=this.chartType,t=Nl.get(e);if(!t)throw new Error(`Component is not defined for type ${e}`);return t}}Dl.props={figure:Object,onFigureDeleted:Function};class Ll extends t.Component{static template="o-spreadsheet-ImageFigure";static components={};get figureId(){return this.props.figure.id}get getImagePath(){return this.env.model.getters.getImagePath(this.figureId)}}function Pl(e,t){const o=Ae(t),s=e.getSheetViewDimension(),n=s.width,i=s.height;if(o.width>n){const e=n/o.width;o.width=n,o.height=o.height*e}if(o.height>i){const e=i/o.height;o.height=i,o.width=o.width*e}return o}Ll.props={figure:Object,onFigureDeleted:Function};const Vl=new Zi;function kl(e,t){return{id:"copy",name:a("Copy"),sequence:2,description:"Ctrl+C",execute:async()=>{t.model.dispatch("SELECT_FIGURE",{id:e}),t.model.dispatch("COPY"),await t.clipboard.write(t.model.getters.getClipboardContent())},icon:"o-spreadsheet-Icon.COPY"}}function Ul(e,t){return{id:"cut",name:a("Cut"),sequence:3,description:"Ctrl+X",execute:async()=>{t.model.dispatch("SELECT_FIGURE",{id:e}),t.model.dispatch("CUT"),await t.clipboard.write(t.model.getters.getClipboardContent())},icon:"o-spreadsheet-Icon.CUT"}}function Bl(e,t,o){return{id:"delete",name:a("Delete"),sequence:10,execute:()=>{o.model.dispatch("DELETE_FIGURE",{sheetId:o.model.getters.getActiveSheetId(),id:e}),t()},icon:"o-spreadsheet-Icon.DELETE"}}Vl.add("chart",{Component:Dl,SidePanelComponent:"ChartPanel",menuBuilder:function(e,t,o){return ci([{id:"edit",name:a("Edit"),sequence:1,execute:()=>{o.model.dispatch("SELECT_FIGURE",{id:e}),o.openSidePanel("ChartPanel")},icon:"o-spreadsheet-Icon.EDIT"},kl(e,o),Ul(e,o),Bl(e,t,o)])}}),Vl.add("image",{Component:Ll,keepRatio:!0,minFigSize:20,borderWidth:0,menuBuilder:function(e,t,o){return ci([kl(e,o),Ul(e,o),{id:"reset_size",name:a("Reset size"),sequence:4,execute:async()=>{const t=o.model.getters.getImagePath(e),s=o.model.getters.getImageSize(e)??await(o.imageProvider?.getImageOriginalSize(t));if(!o.model.getters.getImageSize(e)){o.model.getters.getImage(e).size=s}const{height:n,width:i}=Pl(o.model.getters,s);o.model.dispatch("UPDATE_FIGURE",{sheetId:o.model.getters.getActiveSheetId(),id:e,height:n,width:i})},icon:"o-spreadsheet-Icon.REFRESH"},Bl(e,t,o)])}});const Hl=(new Zi).add("ADD_COLUMNS_ROWS",(function(e){const t=[];let o=e.base;"after"===e.position&&o++;for(let s=0;s<e.quantity;s++)t.push(s+o);return[{type:"REMOVE_COLUMNS_ROWS",dimension:e.dimension,elements:t,sheetId:e.sheetId}]})).add("REMOVE_COLUMNS_ROWS",(function(e){const t=[],o=[...e.elements].sort(((e,t)=>e-t));for(let s of Fe(o)){const o=0===s[0]?0:s[0]-1,n=0===s[0]?"before":"after";t.push({type:"ADD_COLUMNS_ROWS",dimension:e.dimension,quantity:s.length,base:o,sheetId:e.sheetId,position:n})}return t})).add("ADD_MERGE",(function(e){return[{type:"REMOVE_MERGE",sheetId:e.sheetId,target:e.target}]})).add("REMOVE_MERGE",(function(e){return[{type:"ADD_MERGE",sheetId:e.sheetId,target:e.target}]})).add("CREATE_SHEET",(function(e){return[{type:"DELETE_SHEET",sheetId:e.sheetId}]})).add("DELETE_SHEET",(function(e){return[{type:"CREATE_SHEET",sheetId:e.sheetId,position:1}]})).add("DUPLICATE_SHEET",(function(e){return[{type:"DELETE_SHEET",sheetId:e.sheetIdTo}]})).add("CREATE_FIGURE",(function(e){return[{type:"DELETE_FIGURE",id:e.figure.id,sheetId:e.sheetId}]})).add("CREATE_CHART",(function(e){return[{type:"DELETE_FIGURE",id:e.id,sheetId:e.sheetId}]})).add("HIDE_COLUMNS_ROWS",(function(e){return[{type:"UNHIDE_COLUMNS_ROWS",sheetId:e.sheetId,dimension:e.dimension,elements:e.elements}]})).add("UNHIDE_COLUMNS_ROWS",(function(e){return[{type:"HIDE_COLUMNS_ROWS",sheetId:e.sheetId,dimension:e.dimension,elements:e.elements}]}));for(const lA of wo.values())Hl.contains(lA)||Hl.add(lA,zl);function zl(e){return[e]}function Gl(e){const t=e.model.dispatch("CUT");t.isSuccessful||t.isCancelledBecause("WrongCutSelection")&&e.raiseError(a("This operation is not allowed with multiple selections."))}const $l={MergeIsDestructive:a("Merging these cells will only preserve the top-leftmost value. Merge anyway?"),MergeInFilter:a("You can't merge cells inside of an existing filter.")};function Wl(e,t){const o=Ml.getAll().find((t=>t.match(e.type)));if(!o)throw new Error("Unknown chart type.");return o.transformDefinition(e,t)}function ql(e,t){let o=e;e.left!==e.right&&(o={...e,left:e.left+1});const s=[fn(o)],n=t.getActiveSheetId(),i=t.getCell({sheetId:n,col:e.left,row:e.top});if(1===Vn(e)&&i?.content)return{type:"scorecard",title:"",background:i.style?.fillColor||void 0,keyValue:fn(e),baselineMode:pe,baselineColorUp:me,baselineColorDown:fe};let r="";const l=t.getEvaluatedCellsInZone(n,{...o,bottom:o.top}),c=!!l.find((e=>e.type!==bo.empty&&e.type!==bo.number));if(c){const e=l.filter((e=>e.type!==bo.error&&e.type!==bo.empty)).map((e=>e.formattedValue)),t=e.splice(-1)[0];r=e.join(", "),t&&(r+=(r?" "+a("and")+" ":"")+t)}let h;e.left!==e.right&&(h=fn({...e,right:e.left}));const d=o.right===o.left?"none":"top",u={title:r,dataSets:s,labelsAsText:!1,stacked:!1,aggregated:!1,cumulative:!1,labelRange:h,type:"line",dataSetsHaveTitle:c,verticalAxisPosition:"left",legendPosition:d};return xl(new wl(u,n,t),t)?u:{title:r,dataSets:s,labelRange:h,type:"bar",stacked:!1,aggregated:!1,dataSetsHaveTitle:c,verticalAxisPosition:"left",legendPosition:d}}if(window.Chart){const cA=window.Chart?.DoughnutController;class hA extends cA{static id="gauge";static defaults={...cA.defaults,circumference:180,rotation:270};static overrides={aspectRatio:2,plugins:{legend:{display:!1},tooltip:{enabled:!1}}};get chartHeight(){return Math.abs(this.chart.chartArea.top-this.chart.chartArea.bottom)}get chartWidth(){return Math.abs(this.chart.chartArea.left-this.chart.chartArea.right)}get needleOptions(){const{config:e}=this.chart,t=e.options;return t?.needle||{}}get valueLabelOptions(){const{config:e}=this.chart,t=e.options;return t?.valueLabel||{}}get minValue(){return this.getDataset().minValue||0}getValueAngleInPercent(e){const t=this.getDataset().data||[],o=Math.max(...t),s=this.minValue;return(e-s)/(o-s)}drawValueLabel(e){const{ctx:t}=this.chart;!1!==this.valueLabelOptions.display&&(t.save(),t.beginPath(),t.fillStyle=e.valueLabel.backgroundColor,t.strokeStyle=e.valueLabel.borderColor,t.roundRect(e.valueLabel.rect.x,e.valueLabel.rect.y,e.valueLabel.rect.width,e.valueLabel.rect.height,e.valueLabel.borderRadius),t.stroke(),t.fill(),t.textAlign="center",t.textBaseline="middle",t.font=e.valueLabel.font,t.fillStyle=e.valueLabel.textColor,t.fillText(e.valueLabel.valueText,e.valueLabel.textPosition.x,e.valueLabel.textPosition.y),t.restore())}drawNeedle(e){const{ctx:t}=this.chart;!1!==this.needleOptions.display&&(t.save(),t.translate(e.needle.position.x,e.needle.position.y),t.rotate(-Math.PI/2+Math.PI*e.needle.percent),t.beginPath(),t.fillStyle=e.needle.backgroundColor,t.strokeStyle=e.needle.borderColor,t.ellipse(0,0,e.needle.width/2,e.needle.width/2,0,0,2*Math.PI),t.fill(),t.stroke(),t.closePath(),t.fillStyle=e.needle.backgroundColor,t.strokeStyle=e.needle.borderColor,t.beginPath(),t.moveTo(-e.needle.width/2,0),t.lineTo(0,10-e.needle.height),t.lineTo(+e.needle.width/2,0),t.closePath(),t.fill(),t.stroke(),t.restore())}computeRenderingParams(){const{ctx:e,config:t}=this.chart,o=t.options;o.layout=o.layout||{},o.layout.padding=o.layout.padding||{};const s=this.valueLabelOptions.formatter,n="function"==typeof s?s:e=>e,i=this.getDataset().value||0,r=n(i).toString(),a=this.getValueAngleInPercent(i),l=this.valueLabelOptions.font?.family||"Arial",c=this.valueLabelOptions.font?.size||0,h=`${c>=1?c:30}px ${l}`,d={right:0,left:0,top:0,bottom:0,...this.valueLabelOptions.padding};d.left=d.left>=0?d.left:10,d.right=d.right>=0?d.right:10,d.top=d.top>=0?d.top:10,d.bottom=d.bottom>=0?d.bottom:10;const u=this.chart.chartArea,g=this.offsetX||0,p=this.offsetY||0,m={x:(u.left+u.right)/2+g,y:(u.top+u.bottom)/2+p},f={x:m.x,y:m.y};e.save(),e.font=h;const b=e.measureText(r);e.restore();const v=b.fontBoundingBoxAscent-b.fontBoundingBoxDescent;return{needle:{borderColor:this.needleOptions.borderColor||"#000",backgroundColor:this.needleOptions.backgroundColor||"#000",width:this.needleOptions.width||10,height:Math.min(this.chartHeight,this.chartWidth/2),position:{x:f.x,y:f.y},percent:a},valueLabel:{textColor:this.valueLabelOptions.font?.color||"#FFF",backgroundColor:this.valueLabelOptions.backgroundColor||"#000",borderColor:this.valueLabelOptions.borderColor||"#000",borderRadius:this.valueLabelOptions.borderRadius||10,rect:{x:m.x-b.width/2-d.left,y:m.y+v/2+d.top,width:b.width+d.left+d.right,height:-(v+6+d.top+d.bottom)},valueText:r,textPosition:f,textHeight:v,font:h}}}draw(){super.draw();const e=this.computeRenderingParams();this.drawNeedle(e),this.drawValueLabel(e)}updateElements(e,t,o,s){super.updateElements(e,t,o,s);const n=this.getDataset(),i=this.getDataset().data,r=n.minValue,a=this.chart.options.rotation||0,l=this.chart.options.circumference||0;for(let t=0;t<i.length;t++){const o=0===t?r:i[t-1],n=this.getValueAngleInPercent(o),c=this.getValueAngleInPercent(i[t]),h=dA(a+l*n)-Math.PI/2,d=dA(a+l*c)-Math.PI/2,u=d-h,g=e[t],p={startAngle:h,endAngle:d,circumference:u};this.updateElement(g,t,p,s)}}}function dA(e){return e*Math.PI/180}window.Chart.register(hA)}function Zl(e,t){e.model.dispatch("CANCEL_EDITION"),e.model.dispatch("SET_FORMATTING",{sheetId:e.model.getters.getActiveSheetId(),target:e.model.getters.getSelectedZones(),format:t})}function Yl(e,t){e.model.dispatch("SET_FORMATTING",{sheetId:e.model.getters.getActiveSheetId(),target:e.model.getters.getSelectedZones(),style:t})}const jl=async e=>Xl(e,"onlyValue");async function Xl(e,t){const o=e.model.getters.getClipboardTextContent(),s=await e.clipboard.readText();switch(s.status){case"ok":const n=e.model.getters.getSelectedZones();s&&s.content!==o?Wa(e,n,s.content,t):$a(e,n,t),e.model.getters.isCutOperation()&&"onlyValue"!==t&&await e.clipboard.write({[vo.PlainText]:""});break;case"notImplemented":e.raiseError(a("Pasting from the context menu is not supported in this browser. Use keyboard shortcuts ctrl+c / ctrl+v instead."));break;case"permissionDenied":e.raiseError(a("Access to the clipboard denied by the browser. Please enable clipboard permission for this page in your browser settings."))}}const Kl=(e,t)=>{if("COL"===e&&t.model.getters.getActiveRows().size>0||"ROW"===e&&t.model.getters.getActiveCols().size>0)return!1;const o=t.model.getters.getActiveSheetId(),s=t.model.getters.getElementsFromSelection(e),n=t.model.getters.checkElementsIncludeAllVisibleHeaders(o,e,s),i=t.model.getters.checkElementsIncludeAllNonFrozenHeaders(o,e,s);return!n&&!i},Ql=e=>{const t=e.model.getters.getActiveRows();let o,s;if(t.size)o=gt([...t]),s=t.size;else{const t=e.model.getters.getSelectedZones()[0];o=t.top,s=t.bottom-t.top+1}e.model.dispatch("ADD_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),position:"before",base:o,quantity:s,dimension:"ROW"})},Jl=e=>{const t=e.model.getters.getActiveCols();let o,s;if(t.size)o=gt([...t]),s=t.size;else{const t=e.model.getters.getSelectedZones()[0];o=t.left,s=t.right-t.left+1}e.model.dispatch("ADD_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),position:"before",dimension:"COL",base:o,quantity:s})},ec=e=>{const t=e.model.getters.getActiveCols();let o,s;if(t.size)o=ut([...t]),s=t.size;else{const t=e.model.getters.getSelectedZones()[0];o=t.right,s=t.right-t.left+1}e.model.dispatch("ADD_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),position:"after",dimension:"COL",base:o,quantity:s})};const tc=async e=>{if(e.imageProvider){const t=e.model.getters.getActiveSheetId(),o=e.model.uuidGenerator.smallUuid(),s=await async function(e){try{return await e.imageProvider.requestImage()}catch{return void e.raiseError(a("An unexpected error occurred during the image transfer"))}}(e);if(!s)throw new Error("No image provider was given to the environment");const n=Pl(e.model.getters,s.size),i=function(e,t){const{x:o,y:s}=e.getMainViewportCoordinates(),{scrollX:n,scrollY:i}=e.getActiveSheetScrollInfo(),r=e.getSheetViewDimension(),a=e.getVisibleRect(e.getActiveMainViewport()),l=Math.min(a.width,r.width-o),c=Math.min(a.height,r.height-s);return{x:o+n+Math.max(0,(l-t.width)/2),y:s+i+Math.max(0,(c-t.height)/2)}}(e.model.getters,n);e.model.dispatch("CREATE_IMAGE",{sheetId:t,figureId:o,position:i,size:n,definition:s})}},oc=e=>{let{col:t,row:o}=e.model.getters.getActivePosition();e.model.dispatch("OPEN_CELL_POPOVER",{col:t,row:o,popoverType:"LinkEditor"})},sc=e=>1===e.model.getters.getSelectedZones().length,nc=(e,t)=>{if(!sc(e))return!1;const o="COL"===t?e.model.getters.getActiveCols():e.model.getters.getActiveRows(),s="COL"===t?e.model.getters.getActiveRows():e.model.getters.getActiveCols(),n=e.model.getters.getActiveSheetId(),i=wn(e.model.getters.getSelectedZone(),e.model.getters.getSheetZone(n));return rt(o)&&(0===s.size||i)},ic={name:a("Undo"),description:"Ctrl+Z",execute:e=>e.model.dispatch("REQUEST_UNDO"),isEnabled:e=>e.model.getters.canUndo(),icon:"o-spreadsheet-Icon.UNDO"},rc={name:a("Redo"),description:"Ctrl+Y",execute:e=>e.model.dispatch("REQUEST_REDO"),isEnabled:e=>e.model.getters.canRedo(),icon:"o-spreadsheet-Icon.REDO"},ac={name:a("Copy"),description:"Ctrl+C",isReadonlyAllowed:!0,execute:async e=>{e.model.dispatch("COPY"),await e.clipboard.write(e.model.getters.getClipboardContent())},icon:"o-spreadsheet-Icon.COPY"},lc={name:a("Cut"),description:"Ctrl+X",execute:async e=>{Gl(e),await e.clipboard.write(e.model.getters.getClipboardContent())},icon:"o-spreadsheet-Icon.CUT"},cc={name:a("Paste"),description:"Ctrl+V",execute:async e=>Xl(e),icon:"o-spreadsheet-Icon.PASTE"},hc={name:a("Paste special"),isVisible:e=>!e.model.getters.isCutOperation(),icon:"o-spreadsheet-Icon.PASTE"},dc={name:a("Paste value only"),description:"Ctrl+Shift+V",execute:jl},uc={name:a("Paste format only"),execute:e=>Xl(e,"onlyFormat")},gc={name:a("Find and replace"),description:"Ctrl+H",isReadonlyAllowed:!0,execute:e=>{e.openSidePanel("FindAndReplace",{})},icon:"o-spreadsheet-Icon.FIND_AND_REPLACE"},pc={name:a("Delete values"),execute:e=>e.model.dispatch("DELETE_CONTENT",{sheetId:e.model.getters.getActiveSheetId(),target:e.model.getters.getSelectedZones()})},mc={name:e=>{if(e.model.getters.getSelectedZones().length>1)return a("Delete rows");let t,o;const s=e.model.getters.getActiveRows();if(0!==s.size)t=gt([...s]),o=ut([...s]);else{const s=e.model.getters.getSelectedZones()[0];t=s.top,o=s.bottom}return t===o?a("Delete row %s",(t+1).toString()):a("Delete rows %s - %s",(t+1).toString(),(o+1).toString())},execute:e=>{let t=[...e.model.getters.getActiveRows()];if(!t.length){const o=e.model.getters.getSelectedZones()[0];for(let e=o.top;e<=o.bottom;e++)t.push(e)}e.model.dispatch("REMOVE_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),dimension:"ROW",elements:t})},isVisible:e=>Kl("ROW",e)},fc={...mc,isVisible:sc},bc={name:e=>{if(e.model.getters.getSelectedZones().length>1)return a("Clear rows");let t,o;const s=e.model.getters.getActiveRows();if(0!==s.size)t=gt([...s]),o=ut([...s]);else{const s=e.model.getters.getSelectedZones()[0];t=s.top,o=s.bottom}return t===o?a("Clear row %s",(t+1).toString()):a("Clear rows %s - %s",(t+1).toString(),(o+1).toString())},execute:e=>{const t=e.model.getters.getActiveSheetId(),o=[...e.model.getters.getActiveRows()].map((o=>e.model.getters.getRowsZone(t,o,o)));e.model.dispatch("DELETE_CONTENT",{target:o,sheetId:e.model.getters.getActiveSheetId()})}},vc={name:e=>{if(e.model.getters.getSelectedZones().length>1)return a("Delete columns");let t,o;const s=e.model.getters.getActiveCols();if(0!==s.size)t=gt([...s]),o=ut([...s]);else{const s=e.model.getters.getSelectedZones()[0];t=s.left,o=s.right}return t===o?a("Delete column %s",Ot(t)):a("Delete columns %s - %s",Ot(t),Ot(o))},execute:e=>{let t=[...e.model.getters.getActiveCols()];if(!t.length){const o=e.model.getters.getSelectedZones()[0];for(let e=o.left;e<=o.right;e++)t.push(e)}e.model.dispatch("REMOVE_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),dimension:"COL",elements:t})},isVisible:e=>Kl("COL",e)},Sc={...vc,isVisible:sc},Cc={name:e=>{if(e.model.getters.getSelectedZones().length>1)return a("Clear columns");let t,o;const s=e.model.getters.getActiveCols();if(0!==s.size)t=gt([...s]),o=ut([...s]);else{const s=e.model.getters.getSelectedZones()[0];t=s.left,o=s.right}return t===o?a("Clear column %s",Ot(t)):a("Clear columns %s - %s",Ot(t),Ot(o))},execute:e=>{const t=e.model.getters.getActiveSheetId(),o=[...e.model.getters.getActiveCols()].map((o=>e.model.getters.getColsZone(t,o,o)));e.model.dispatch("DELETE_CONTENT",{target:o,sheetId:e.model.getters.getActiveSheetId()})}},Ec={name:a("Delete cells"),isVisible:sc},yc={name:a("Delete cell and shift up"),execute:e=>{const t=e.model.getters.getSelectedZone(),o=e.model.dispatch("DELETE_CELL",{zone:t,shiftDimension:"ROW"});Ga(e,o)}},wc={name:a("Delete cell and shift left"),execute:e=>{const t=e.model.getters.getSelectedZone(),o=e.model.dispatch("DELETE_CELL",{zone:t,shiftDimension:"COL"});Ga(e,o)}},xc={name:a("Merge cells"),isEnabled:e=>!Ic(e),isActive:e=>Rc(e),execute:e=>function(e){if(Ic(e))return;const t=e.model.getters.getSelectedZones(),o=[t[t.length-1]],s=e.model.getters.getActiveSheetId();Rc(e)?e.model.dispatch("REMOVE_MERGE",{sheetId:s,target:o}):function(e,t,o){const s=e.model.dispatch("ADD_MERGE",{sheetId:t,target:o});s.isCancelledBecause("MergeInFilter")?e.raiseError($l.MergeInFilter):s.isCancelledBecause("MergeIsDestructive")&&e.askConfirmation($l.MergeIsDestructive,(()=>{e.model.dispatch("ADD_MERGE",{sheetId:t,target:o,force:!0})}))}(e,s,o)}(e),icon:"o-spreadsheet-Icon.MERGE_CELL"};function Ic(e){const t=e.model.getters.getSelectedZones(),{top:o,left:s,right:n,bottom:i}=e.model.getters.getSelectedZone(),{sheetId:r}=e.model.getters.getActivePosition(),{xSplit:a,ySplit:l}=e.model.getters.getPaneDivisions(r);return t.length>1||o===i&&s===n||s<a&&a<=n||o<l&&l<=i}function Rc(e){if(!Ic(e)){const t=e.model.getters.getSelectedZones(),{col:o,row:s,sheetId:n}=e.model.getters.getActivePosition(),i=e.model.getters.expandZone(n,Ln({col:o,row:s}));return wn(t[0],i)}return!1}var Tc=Object.freeze({__proto__:null,clearCols:Cc,clearRows:bc,copy:ac,cut:lc,deleteCellShiftLeft:wc,deleteCellShiftUp:yc,deleteCells:Ec,deleteCol:Sc,deleteCols:vc,deleteRow:fc,deleteRows:mc,deleteValues:pc,findAndReplace:gc,mergeCells:xc,paste:cc,pasteSpecial:hc,pasteSpecialFormat:uc,pasteSpecialValue:dc,redo:rc,undo:ic});const Ac=/(.*?)\((.*?)\)(.*)/,Oc=["ANY","BOOLEAN","DATE","NUMBER","STRING","RANGE","RANGE<BOOLEAN>","RANGE<DATE>","RANGE<NUMBER>","RANGE<STRING>","META"];function _c(e,t=""){return function(e,t){let o=e.match(Ac),s=o[1].trim();if(!s)throw new Error(`Function argument definition is missing a name: '${e}'.`);let n,i=[],r=!1,a=!1,l=!1;for(let e of o[2].split(",")){const t=e.trim().toUpperCase();let o=Oc.find((e=>t===e));o?i.push(o):"RANGE<ANY>"===t?i.push("RANGE"):"OPTIONAL"===t?r=!0:"REPEATING"===t?a=!0:"LAZY"===t?l=!0:t.startsWith("DEFAULT=")&&(n=e.trim().slice(8))}const c={name:s,description:t,type:i};r&&(c.optional=!0);a&&(c.repeating=!0);l&&(c.lazy=!0);void 0!==n&&(c.default=!0,c.defaultValue=n);i.some((e=>e.startsWith("RANGE")))&&(c.acceptMatrix=!0);return c}(e,t)}function Mc(e){let t=0,o=0,s=0;for(let n of e.args)t++,n.optional||n.repeating||n.default||o++,n.repeating&&s++;const n=e;return n.minArgRequired=o,n.maxArgPossible=s?1/0:t,n.nbrArgRepeating=s,n.getArgToFocus=function(e,t){if(!t)return e=>e;if(1===t)return t=>Math.min(t,e);const o=e-t;return e=>{if(e<=o)return e;return o+((e-o)%t||t)}}(t,s),n.hidden=e.hidden||!1,n}function Nc(e,t){Lo((()=>1===t.length||1===t[0].length),e)}function Fc(e,...t){if(t.every(Mo)){const o=t[0].length,s=t[0][0].length;for(const n of t)Lo((()=>n.length===o&&n[0].length===s),e)}else if(t.some((e=>Array.isArray(e)&&(1!==e.length||1!==e[0].length))))throw new Error(e)}function Dc(e,t){Lo((()=>t>0),e)}function Lc(e,t){Lo((()=>t.length===t[0].length),e)}function Pc(e){return e.every((e=>e.every((e=>"number"==typeof e))))}function Vc(e){const t=Array(e);for(let o=0;o<e;o++)t[o]=Array(e).fill(0),t[o][o]=1;return t}function kc(e){if(e.length<1||e[0].length<1)throw new Error("invertMatrix: an empty matrix cannot be inverted.");if(e.length!==e[0].length)throw new Error("invertMatrix: only square matrices are invertible");let t=1;const o=e.length,s=Vc(o),n=e.map((e=>e.slice()));for(let e=0;e<o;e++){let i=n[e][e];if(0===i){for(let i=e+1;i<o;i++)if(0!=n[e][i]){Uc(n,e,i),Uc(s,e,i),t*=-1;break}if(i=n[e][e],0===i)return{determinant:0}}for(let t=0;t<o;t++)n[t][e]=n[t][e]/i,s[t][e]=s[t][e]/i;t*=i;for(let t=0;t<o;t++){if(t===e)continue;const i=n[e][t];for(let r=0;r<o;r++)n[r][t]-=i*n[r][e],s[r][t]-=i*s[r][e]}}return{inverted:s,determinant:t}}function Uc(e,t,o){for(let s=0;s<e.length;s++){const n=e[s][t];e[s][t]=e[s][o],e[s][o]=n}}function Bc(e,t){if(e.length<1||t.length<1)throw new Error("multiplyMatrices: empty matrices cannot be multiplied.");if(e.length!==t[0].length)throw new Error("multiplyMatrices: incompatible matrices size.");const o=e[0].length,s=t.length,n=e.length,i=Array(s);for(let r=0;r<s;r++){i[r]=Array(o);for(let s=0;s<o;s++){let o=0;for(let i=0;i<n;i++)o+=e[i][s]*t[r][i];i[r][s]=o}}return i}function Hc(e){if(!Mo(e))return e;if(1!==e.length||1!==e[0].length)throw new Error("toScalar: matrix should be a scalar or a 1x1 matrix");return e[0][0]}const zc={description:a("Returns a result array constrained to a specific width and height."),args:[_c("input_range (any, range<any>)",a("The range to constrain.")),_c("rows (number)",a("The number of rows in the constrained array.")),_c("columns (number)",a("The number of columns in the constrained array."))],returns:["RANGE<ANY>"],computeValueAndFormat:function(e,t,o){const s=gs(e),n=Ho(t?.value,this.locale),i=Ho(o?.value,this.locale);Dc(a("The rows argument (%s) must be strictly positive.",n.toString()),n),Dc(a("The columns argument (%s) must be strictly positive.",n.toString()),i);const r=Math.min(n,s[0].length);return os(Math.min(i,s.length),r,((e,t)=>s[e][t]))},isExported:!1},Gc={description:a("Creates a new array from the selected columns in the existing range."),args:[_c("array (any, range<any>)",a("The array that contains the columns to be returned.")),_c("col_num (number, range<number>)",a("The first column index of the columns to be returned.")),_c("col_num2 (number, range<number>, repeating)",a("The columns indexes of the columns to be returned."))],returns:["RANGE<ANY>"],computeValueAndFormat:function(e,...t){const o=gs(e),s=ps(t,(e=>Ho(e?.value,this.locale)));Lo((()=>s.every((e=>e>0&&e<=o.length))),a("The columns arguments must be between 1 and %s (got %s).",o.length.toString(),(s.find((e=>e<=0||e>o.length))||0).toString()));const n=Array(s.length);for(let e=0;e<s.length;e++){const t=s[e]-1;n[e]=o[t]}return n},isExported:!0},$c={description:a("Creates a new array from the selected rows in the existing range."),args:[_c("array (any, range<any>)",a("The array that contains the rows to be returned.")),_c("row_num (number, range<number>)",a("The first row index of the rows to be returned.")),_c("row_num2 (number, range<number>, repeating)",a("The rows indexes of the rows to be returned."))],returns:["RANGE<ANY>"],computeValueAndFormat:function(e,...t){const o=gs(e),s=ps(t,(e=>Ho(e?.value,this.locale))),n=o.length;return Lo((()=>s.every((e=>e>0&&e<=o[0].length))),a("The rows arguments must be between 1 and %s (got %s).",o[0].length.toString(),(s.find((e=>e<=0||e>o[0].length))||0).toString())),os(n,s.length,((e,t)=>o[e][s[t]-1]))},isExported:!0},Wc={description:a("Expands or pads an array to specified row and column dimensions."),args:[_c("array (any, range<any>)",a("The array to expand.")),_c("rows (number)",a("The number of rows in the expanded array. If missing, rows will not be expanded.")),_c("columns (number, optional)",a("The number of columns in the expanded array. If missing, columns will not be expanded.")),_c("pad_with (any, default=0)",a("The value with which to pad."))],returns:["RANGE<ANY>"],computeValueAndFormat:function(e,t,o,s={value:0}){const n=gs(e),i=Ho(t?.value,this.locale),r=void 0!==o?Ho(o.value,this.local):n.length;return Lo((()=>i>=n[0].length),a("The rows arguments (%s) must be greater or equal than the number of rows of the array.",i.toString())),Lo((()=>r>=n.length),a("The columns arguments (%s) must be greater or equal than the number of columns of the array.",r.toString())),os(r,i,((e,t)=>e>=n.length||t>=n[e].length?s:n[e][t]))},isExported:!0},qc={description:a("Flattens all the values from one or more ranges into a single column."),args:[_c("range (any, range<any>)",a("The first range to flatten.")),_c("range2 (any, range<any>, repeating)",a("Additional ranges to flatten."))],returns:["RANGE<ANY>"],computeValueAndFormat:function(...e){return[ps(e,(e=>void 0===e?{value:""}:e))]},isExported:!1},Zc={description:a("Calculates the frequency distribution of a range."),args:[_c("data (range<number>)",a("The array of ranges containing the values to be counted.")),_c("classes (number, range<number>)",a("The range containing the set of classes."))],returns:["RANGE<NUMBER>"],compute:function(e,t){const o=ps([e],(e=>e)).filter((e=>"number"==typeof e)),s=ps([t],(e=>e)).filter((e=>"number"==typeof e)).map(((e,t)=>({initialIndex:t,value:e,count:0}))).sort(((e,t)=>e.value-t.value));s.push({initialIndex:s.length,value:1/0,count:0});const n=o.sort(((e,t)=>e-t));let i=0;for(const e of n){for(;e>s[i].value&&i<s.length-1;)i++;s[i].count++}return[s.sort(((e,t)=>e.initialIndex-t.initialIndex)).map((e=>e.count))]},isExported:!0},Yc={description:a("Appends ranges horizontally and in sequence to return a larger array."),args:[_c("range1 (any, range<any>)",a("The first range to be appended.")),_c("range2 (any, range<any>, repeating)",a("Additional ranges to add to range1."))],returns:["RANGE<ANY>"],computeValueAndFormat:function(...e){const t=Math.max(...e.map((e=>e?.[0]?.length??0))),o=[];for(const s of e){const e=gs(s);for(let s=0;s<e.length;s++){const n=Array(t).fill({value:null});for(let t=0;t<e[s].length;t++)n[t]=e[s][t];o.push(n)}}return o},isExported:!0},jc={description:a("Returns the matrix determinant of a square matrix."),args:[_c("square_matrix (number, range<number>)",a("An range with an equal number of rows and columns representing a matrix whose determinant will be calculated."))],returns:["NUMBER"],compute:function(e){const t=gs(e);if(Lc(a("The argument square_matrix must have the same number of columns and rows."),t),!Pc(t))throw new Error(a("The argument square_matrix must be a matrix of numbers."));const{determinant:o}=kc(t);return o},isExported:!0},Xc={description:a("Returns the multiplicative inverse of a square matrix."),args:[_c("square_matrix (number, range<number>)",a("An range with an equal number of rows and columns representing a matrix whose multiplicative inverse will be calculated."))],returns:["RANGE<NUMBER>"],compute:function(e){const t=gs(e);if(Lc(a("The argument square_matrix must have the same number of columns and rows."),t),!Pc(t))throw new Error(a("The argument square_matrix must be a matrix of numbers."));const{inverted:o}=kc(t);if(!o)throw new Error(a("The matrix is not invertible."));return o},isExported:!0},Kc={description:a("Calculates the matrix product of two matrices."),args:[_c("matrix1 (number, range<number>)",a("The first matrix in the matrix multiplication operation.")),_c("matrix2 (number, range<number>)",a("The second matrix in the matrix multiplication operation."))],returns:["RANGE<NUMBER>"],compute:function(e,t){const o=gs(e),s=gs(t);if(Lo((()=>o.length>0&&s.length>0),a("The first and second arguments of [[FUNCTION_NAME]] must be non-empty matrices.")),Lo((()=>o.length===s[0].length),a("In [[FUNCTION_NAME]], the number of columns of the first matrix (%s) must be equal to the number of rows of the second matrix (%s).",o.length.toString(),s[0].length.toString())),!Pc(o)||!Pc(s))throw new Error(a("The arguments matrix1 and matrix2 must be matrices of numbers."));return Bc(o,s)},isExported:!0},Qc={description:a("Calculates the sum of the products of corresponding entries in equal-sized ranges."),args:[_c("range1 (number, range<number>)",a("The first range whose entries will be multiplied with corresponding entries in the other ranges.")),_c("range2 (number, range<number>, repeating)",a("The other range whose entries will be multiplied with corresponding entries in the other ranges."))],returns:["NUMBER"],compute:function(...e){Fc(a("All the ranges must have the same dimensions."),...e);const t=e.map(gs);let o=0;for(let e=0;e<t[0].length;e++)for(let s=0;s<t[0][e].length;s++){if(!t.every((t=>"number"==typeof t[e][s])))continue;let n=1;for(const o of t)n*=Vo(o[e][s],this.locale);o+=n}return o},isExported:!0};function Jc(e,t,o){Fc("The arguments array_x and array_y must have the same dimensions.",e,t);const s=gs(e),n=gs(t);let i=!1,r=0;for(const e in s)for(const t in s[e]){const a=s[e][t],l=n[e][t];"number"==typeof a&&"number"==typeof l&&(i=!0,r+=o(a,l))}if(!i)throw new Error("The arguments array_x and array_y must contain at least one pair of numbers.");return r}const eh={description:a("Calculates the sum of the difference of the squares of the values in two array."),args:[_c("array_x (number, range<number>)",a("The array or range of values whose squares will be reduced by the squares of corresponding entries in array_y and added together.")),_c("array_y (number, range<number>)",a("The array or range of values whose squares will be subtracted from the squares of corresponding entries in array_x and added together."))],returns:["NUMBER"],compute:function(e,t){return Jc(e,t,((e,t)=>e**2-t**2))},isExported:!0},th={description:a("Calculates the sum of the sum of the squares of the values in two array."),args:[_c("array_x (number, range<number>)",a("The array or range of values whose squares will be added to the squares of corresponding entries in array_y and added together.")),_c("array_y (number, range<number>)",a("The array or range of values whose squares will be added to the squares of corresponding entries in array_x and added together."))],returns:["NUMBER"],compute:function(e,t){return Jc(e,t,((e,t)=>e**2+t**2))},isExported:!0},oh={description:a("Calculates the sum of squares of the differences of values in two array."),args:[_c("array_x (number, range<number>)",a("The array or range of values that will be reduced by corresponding entries in array_y, squared, and added together.")),_c("array_y (number, range<number>)",a("The array or range of values that will be subtracted from corresponding entries in array_x, the result squared, and all such results added together."))],returns:["NUMBER"],compute:function(e,t){return Jc(e,t,((e,t)=>(e-t)**2))},isExported:!0},sh=!1,nh=[_c("array (any, range<any>)",a("The array which will be transformed.")),_c("ignore (number, default=0)",a("The control to ignore blanks and errors. 0 (default) is to keep all values, 1 is to ignore blanks, 2 is to ignore errors, and 3 is to ignore blanks and errors.")),_c("scan_by_column (number, default=false)",a("Whether the array should be scanned by column. True scans the array by column and false (default) scans the array by row."))],ih={description:a("Transforms a range of cells into a single column."),args:nh,returns:["RANGE<ANY>"],computeValueAndFormat:function(e,t={value:0},o={value:sh}){const s=gs(e),n=Ho(t.value,this.locale),i=Zo(o.value);Lo((()=>n>=0&&n<=3),a("Argument ignore must be between 0 and 3"));const r=(i?s:ns(s)).flat().filter((e=>1!==n&&3!==n||void 0!==e.value&&null!==e.value));if(0===r.length)throw new m(a("No results for the given arguments of TOCOL."));return[r]},isExported:!0},rh={description:a("Transforms a range of cells into a single row."),args:nh,returns:["RANGE<ANY>"],computeValueAndFormat:function(e,t={value:0},o={value:sh}){const s=gs(e),n=Ho(t.value,this.locale),i=Zo(o.value);Lo((()=>n>=0&&n<=3),a("Argument ignore must be between 0 and 3"));const r=(i?s:ns(s)).flat().filter((e=>1!==n&&3!==n||void 0!==e.value&&null!==e.value)).map((e=>[e]));if(0===r.length||0===r[0].length)throw new m(a("No results for the given arguments of TOROW."));return r},isExported:!0},ah={description:a("Transposes the rows and columns of a range."),args:[_c("range (any, range<any>)",a("The range to be transposed."))],returns:["RANGE"],computeValueAndFormat:function(e){const t=gs(e);return os(t[0].length,t.length,((e,o)=>t[o][e]))},isExported:!0},lh={description:a("Appends ranges vertically and in sequence to return a larger array."),args:[_c("range1 (any, range<any>)",a("The first range to be appended.")),_c("range2 (any, range<any>, repeating)",a("Additional ranges to add to range1."))],returns:["RANGE<ANY>"],computeValueAndFormat:function(...e){const t=Math.max(...e.map((e=>gs(e).length))),o=e.reduce(((e,t)=>e+gs(t)[0].length),0),s=Array(t).fill([]).map((()=>Array(o).fill({value:0})));let n=0;for(const t of e){const e=gs(t);for(let t=0;t<e.length;t++)for(let o=0;o<e[t].length;o++)s[t][n+o]=e[t][o];n+=e[0].length}return s},isExported:!0},ch={description:a("Wraps the provided row or column of cells by columns after a specified number of elements to form a new array."),args:[_c("range (any, range<any>)",a("The range to wrap.")),_c("wrap_count (number)",a("The maximum number of cells for each column, rounded down to the nearest whole number.")),_c("pad_with (any, default=0)",a("The value with which to fill the extra cells in the range."))],returns:["RANGE<ANY>"],computeValueAndFormat:function(e,t,o={value:0}){const s=gs(e),n=Ho(t?.value,this.locale);Nc(a("Argument range must be a single row or column."),s);const i=s.flat();return os(Math.ceil(i.length/n),n,((e,t)=>{const s=e*n+t;return s<i.length?i[s]:o}))},isExported:!0},hh={description:a("Wraps the provided row or column of cells by rows after a specified number of elements to form a new array."),args:[_c("range (any, range<any>)",a("The range to wrap.")),_c("wrap_count (number)",a("The maximum number of cells for each row, rounded down to the nearest whole number.")),_c("pad_with (any, default=0)",a("The value with which to fill the extra cells in the range."))],returns:["RANGE<ANY>"],computeValueAndFormat:function(e,t,o={value:0}){const s=gs(e),n=Ho(t?.value,this.locale);Nc(a("Argument range must be a single row or column."),s);const i=s.flat(),r=Math.ceil(i.length/n);return os(n,r,((e,t)=>{const s=t*n+e;return s<i.length?i[s]:o}))},isExported:!0};var dh=Object.freeze({__proto__:null,ARRAY_CONSTRAIN:zc,CHOOSECOLS:Gc,CHOOSEROWS:$c,EXPAND:Wc,FLATTEN:qc,FREQUENCY:Zc,HSTACK:Yc,MDETERM:jc,MINVERSE:Xc,MMULT:Kc,SUMPRODUCT:Qc,SUMX2MY2:eh,SUMX2PY2:th,SUMXMY2:oh,TOCOL:ih,TOROW:rh,TRANSPOSE:ah,VSTACK:lh,WRAPCOLS:ch,WRAPROWS:hh});const uh={description:a("Apply a large number format"),args:[_c("value (number)",a("The number.")),_c("unit (string, optional)",a("The formatting unit. Use 'k', 'm', or 'b' to force the unit"))],returns:["NUMBER"],computeFormat:function(e,t){const o=Math.abs(Vo(e?.value,this.locale)),s=e?.format;if(void 0!==t){const e=t?.value;switch(e){case"k":return Ws(s,1e3,"k",this.locale);case"m":return Ws(s,1e6,"m",this.locale);case"b":return Ws(s,1e9,"b",this.locale);default:throw new Error(a("The formatting unit should be 'k', 'm' or 'b'."))}}return o<1e5?Ws(s,0,"",this.locale):o<1e8?Ws(s,1e3,"k",this.locale):o<1e11?Ws(s,1e6,"m",this.locale):Ws(s,1e9,"b",this.locale)},compute:function(e){return Vo(e,this.locale)}};var gh=Object.freeze({__proto__:null,FORMAT_LARGE_NUMBER:uh});const ph=/^-?[a-z0-9]+$/i,mh={description:a("Absolute value of a number."),args:[_c("value (number)",a("The number of which to return the absolute value."))],returns:["NUMBER"],compute:function(e){return Math.abs(Vo(e,this.locale))},isExported:!0},fh={description:a("Inverse cosine of a value, in radians."),args:[_c("value (number)",a("The value for which to calculate the inverse cosine. Must be between -1 and 1, inclusive."))],returns:["NUMBER"],compute:function(e){const t=Vo(e,this.locale);return Lo((()=>Math.abs(t)<=1),a("The value (%s) must be between -1 and 1 inclusive.",t.toString())),Math.acos(t)},isExported:!0},bh={description:a("Inverse hyperbolic cosine of a number."),args:[_c("value (number)",a("The value for which to calculate the inverse hyperbolic cosine. Must be greater than or equal to 1."))],returns:["NUMBER"],compute:function(e){const t=Vo(e,this.locale);return Lo((()=>t>=1),a("The value (%s) must be greater than or equal to 1.",t.toString())),Math.acosh(t)},isExported:!0},vh={description:a("Inverse cotangent of a value."),args:[_c("value (number)",a("The value for which to calculate the inverse cotangent."))],returns:["NUMBER"],compute:function(e){const t=Vo(e,this.locale);return(Math.sign(t)||1)*Math.PI/2-Math.atan(t)},isExported:!0},Sh={description:a("Inverse hyperbolic cotangent of a value."),args:[_c("value (number)",a("The value for which to calculate the inverse hyperbolic cotangent. Must not be between -1 and 1, inclusive."))],returns:["NUMBER"],compute:function(e){const t=Vo(e,this.locale);return Lo((()=>Math.abs(t)>1),a("The value (%s) cannot be between -1 and 1 inclusive.",t.toString())),Math.log((t+1)/(t-1))/2},isExported:!0},Ch={description:a("Inverse sine of a value, in radians."),args:[_c("value (number)",a("The value for which to calculate the inverse sine. Must be between -1 and 1, inclusive."))],returns:["NUMBER"],compute:function(e){const t=Vo(e,this.locale);return Lo((()=>Math.abs(t)<=1),a("The value (%s) must be between -1 and 1 inclusive.",t.toString())),Math.asin(t)},isExported:!0},Eh={description:a("Inverse hyperbolic sine of a number."),args:[_c("value (number)",a("The value for which to calculate the inverse hyperbolic sine."))],returns:["NUMBER"],compute:function(e){return Math.asinh(Vo(e,this.locale))},isExported:!0},yh={description:a("Inverse tangent of a value, in radians."),args:[_c("value (number)",a("The value for which to calculate the inverse tangent."))],returns:["NUMBER"],compute:function(e){return Math.atan(Vo(e,this.locale))},isExported:!0},wh={description:a("Angle from the X axis to a point (x,y), in radians."),args:[_c("x (number)",a("The x coordinate of the endpoint of the line segment for which to calculate the angle from the x-axis.")),_c("y (number)",a("The y coordinate of the endpoint of the line segment for which to calculate the angle from the x-axis."))],returns:["NUMBER"],compute:function(e,t){const o=Vo(e,this.locale),s=Vo(t,this.locale);return Lo((()=>0!==o||0!==s),a("Function [[FUNCTION_NAME]] caused a divide by zero error.")),Math.atan2(s,o)},isExported:!0},xh={description:a("Inverse hyperbolic tangent of a number."),args:[_c("value (number)",a("The value for which to calculate the inverse hyperbolic tangent. Must be between -1 and 1, exclusive."))],returns:["NUMBER"],compute:function(e){const t=Vo(e,this.locale);return Lo((()=>Math.abs(t)<1),a("The value (%s) must be between -1 and 1 exclusive.",t.toString())),Math.atanh(t)},isExported:!0},Ih={description:a("Rounds number up to nearest multiple of factor."),args:[_c("value (number)",a("The value to round up to the nearest integer multiple of factor.")),_c("factor (number, default=1)",a("The number to whose multiples value will be rounded."))],returns:["NUMBER"],computeFormat:e=>e?.format,compute:function(e,t=1){const o=Vo(e,this.locale),s=Vo(t,this.locale);return Lo((()=>s>=0||o<=0),a("The factor (%s) must be positive when the value (%s) is positive.",s.toString(),o.toString())),s?Math.ceil(o/s)*s:0},isExported:!0},Rh={description:a("Rounds number up to nearest multiple of factor."),args:[_c("number (number)",a("The value to round up to the nearest integer multiple of significance.")),_c("significance (number, default=1)",a("The number to whose multiples number will be rounded. The sign of significance will be ignored.")),_c("mode (number, default=0)",a("If number is negative, specifies the rounding direction. If 0 or blank, it is rounded towards zero. Otherwise, it is rounded away from zero."))],returns:["NUMBER"],computeFormat:e=>e?.format,compute:function(e,t=1,o=0){let s=Vo(t,this.locale);if(0===s)return 0;const n=Vo(e,this.locale);if(s=Math.abs(s),n>=0)return Math.ceil(n/s)*s;return 0===Vo(o,this.locale)?-Math.floor(Math.abs(n)/s)*s:-Math.ceil(Math.abs(n)/s)*s},isExported:!0},Th={description:a("Rounds number up to nearest multiple of factor."),args:[_c("number (number)",a("The value to round up to the nearest integer multiple of significance.")),_c("significance (number, default=1)",a("The number to whose multiples number will be rounded."))],returns:["NUMBER"],computeFormat:e=>e?.format,compute:function(e,t){return Rh.compute.bind(this)(e,t,0)},isExported:!0},Ah={description:a("Cosine of an angle provided in radians."),args:[_c("angle (number)",a("The angle to find the cosine of, in radians."))],returns:["NUMBER"],compute:function(e){return Math.cos(Vo(e,this.locale))},isExported:!0},Oh={description:a("Hyperbolic cosine of any real number."),args:[_c("value (number)",a("Any real value to calculate the hyperbolic cosine of."))],returns:["NUMBER"],compute:function(e){return Math.cosh(Vo(e,this.locale))},isExported:!0},_h={description:a("Cotangent of an angle provided in radians."),args:[_c("angle (number)",a("The angle to find the cotangent of, in radians."))],returns:["NUMBER"],compute:function(e){const t=Vo(e,this.locale);return Lo((()=>0!==t),a("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),1/Math.tan(t)},isExported:!0},Mh={description:a("Hyperbolic cotangent of any real number."),args:[_c("value (number)",a("Any real value to calculate the hyperbolic cotangent of."))],returns:["NUMBER"],compute:function(e){const t=Vo(e,this.locale);return Lo((()=>0!==t),a("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),1/Math.tanh(t)},isExported:!0},Nh={description:a("Number of empty values."),args:[_c("value1 (any, range)",a("The first value or range in which to count the number of blanks.")),_c("value2 (any, range, repeating)",a("Additional values or ranges in which to count the number of blanks."))],returns:["NUMBER"],compute:function(...e){return Jo(e,((e,t)=>null==t||""===t?e+1:e),0)},isExported:!0},Fh={description:a("A conditional count across a range."),args:[_c("range (range)",a("The range that is tested against criterion.")),_c("criterion (string)",a("The pattern or test to apply to range."))],returns:["NUMBER"],compute:function(...e){let t=0;return ls(e,((e,o)=>{t+=1}),this.locale),t},isExported:!0},Dh={description:a("Count values depending on multiple criteria."),args:[_c("criteria_range1 (range)",a("The range to check against criterion1.")),_c("criterion1 (string)",a("The pattern or test to apply to criteria_range1.")),_c("criteria_range2 (any, range, repeating)",a("Additional ranges over which to evaluate the additional criteria. The filtered set will be the intersection of the sets produced by each criterion-range pair.")),_c("criterion2 (string, repeating)",a("Additional criteria to check."))],returns:["NUMBER"],compute:function(...e){let t=0;return ls(e,((e,o)=>{t+=1}),this.locale),t},isExported:!0};function Lh(e){switch(e){case void 0:case"":case null:return!1;default:return!0}}const Ph={description:a("Counts number of unique values in a range."),args:[_c("value1 (any, range)",a("The first value or range to consider for uniqueness.")),_c("value2 (any, range, repeating)",a("Additional values or ranges to consider for uniqueness."))],returns:["NUMBER"],compute:function(...e){return Jo(e,((e,t)=>Lh(t)?e.add(t):e),new Set).size}},Vh={description:a("Counts number of unique values in a range, filtered by a set of criteria."),args:[_c("range (range)",a("The range of cells from which the number of unique values will be counted.")),_c("criteria_range1 (range)",a("The range of cells over which to evaluate criterion1.")),_c("criterion1 (string)",a("The pattern or test to apply to criteria_range1, such that each cell that evaluates to TRUE will be included in the filtered set.")),_c("criteria_range2 (any, range, repeating)",a("Additional ranges over which to evaluate the additional criteria. The filtered set will be the intersection of the sets produced by each criterion-range pair.")),_c("criterion2 (string, repeating)",a("The pattern or test to apply to criteria_range2."))],returns:["NUMBER"],compute:function(e,...t){let o=new Set;return ls(t,((t,s)=>{const n=e[t][s];Lh(n)&&o.add(n)}),this.locale),o.size}},kh={description:a("Cosecant of an angle provided in radians."),args:[_c("angle (number)",a("The angle to find the cosecant of, in radians."))],returns:["NUMBER"],compute:function(e){const t=Vo(e,this.locale);return Lo((()=>0!==t),a("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),1/Math.sin(t)},isExported:!0},Uh={description:a("Hyperbolic cosecant of any real number."),args:[_c("value (number)",a("Any real value to calculate the hyperbolic cosecant of."))],returns:["NUMBER"],compute:function(e){const t=Vo(e,this.locale);return Lo((()=>0!==t),a("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),1/Math.sinh(t)},isExported:!0},Bh={description:a("Converts from another base to decimal."),args:[_c("value (string)",a("The number to convert.")),_c(",base (number)",a("The base to convert the value from."))],returns:["NUMBER"],compute:function(e,t){let o=Vo(t,this.locale);o=Math.floor(o),Lo((()=>2<=o&&o<=36),a("The base (%s) must be between 2 and 36 inclusive.",o.toString()));const s=$o(e);if(""===s)return 0;Lo((()=>!!ph.test(s)),a("The value (%s) must be a valid base %s representation.",s,o.toString()));const n=parseInt(s,o);return Lo((()=>!isNaN(n)),a("The value (%s) must be a valid base %s representation.",s,o.toString())),n},isExported:!0},Hh={description:a("Converts an angle value in radians to degrees."),args:[_c("angle (number)",a("The angle to convert from radians to degrees."))],returns:["NUMBER"],compute:function(e){return 180*Vo(e,this.locale)/Math.PI},isExported:!0},zh={description:a("Euler's number, e (~2.718) raised to a power."),args:[_c("value (number)",a("The exponent to raise e."))],returns:["NUMBER"],compute:function(e){return Math.exp(Vo(e,this.locale))},isExported:!0},Gh={description:a("Rounds number down to nearest multiple of factor."),args:[_c("value (number)",a("The value to round down to the nearest integer multiple of factor.")),_c("factor (number, default=1)",a("The number to whose multiples value will be rounded."))],returns:["NUMBER"],computeFormat:e=>e?.format,compute:function(e,t=1){const o=Vo(e,this.locale),s=Vo(t,this.locale);return Lo((()=>s>=0||o<=0),a("The factor (%s) must be positive when the value (%s) is positive.",s.toString(),o.toString())),s?Math.floor(o/s)*s:0},isExported:!0},$h={description:a("Rounds number down to nearest multiple of factor."),args:[_c("number (number)",a("The value to round down to the nearest integer multiple of significance.")),_c("significance (number, default=1)",a("The number to whose multiples number will be rounded. The sign of significance will be ignored.")),_c("mode (number, default=0)",a("If number is negative, specifies the rounding direction. If 0 or blank, it is rounded away from zero. Otherwise, it is rounded towards zero."))],returns:["NUMBER"],computeFormat:e=>e?.format,compute:function(e,t=1,o=0){let s=Vo(t,this.locale);if(0===s)return 0;const n=Vo(e,this.locale);if(s=Math.abs(s),n>=0)return Math.floor(n/s)*s;return 0===Vo(o,this.locale)?-Math.ceil(Math.abs(n)/s)*s:-Math.floor(Math.abs(n)/s)*s},isExported:!0},Wh={description:a("Rounds number down to nearest multiple of factor."),args:[_c("number (number)",a("The value to round down to the nearest integer multiple of significance.")),_c("significance (number, default=1)",a("The number to whose multiples number will be rounded."))],returns:["NUMBER"],computeFormat:e=>e?.format,compute:function(e,t=1){return $h.compute.bind(this)(e,t,0)},isExported:!0},qh={description:a("Whether the provided value is even."),args:[_c("value (number)",a("The value to be verified as even."))],returns:["BOOLEAN"],compute:function(e){const t=Bo(e,this.locale);return!(1&Math.floor(Math.abs(t)))},isExported:!0},Zh={description:a("Rounds number up to nearest multiple of factor."),args:[_c("number (number)",a("The value to round up to the nearest integer multiple of significance.")),_c("significance (number, default=1)",a("The number to whose multiples number will be rounded."))],returns:["NUMBER"],computeFormat:e=>e?.format,compute:function(e,t=1){return Rh.compute.bind(this)(e,t,0)},isExported:!0},Yh={description:a("Whether the provided value is even."),args:[_c("value (number)",a("The value to be verified as even."))],returns:["BOOLEAN"],compute:function(e){const t=Bo(e,this.locale);return!!(1&Math.floor(Math.abs(t)))},isExported:!0},jh={description:a("The logarithm of a number, base e (euler's number)."),args:[_c("value (number)",a("The value for which to calculate the logarithm, base e."))],returns:["NUMBER"],compute:function(e){const t=Vo(e,this.locale);return Lo((()=>t>0),a("The value (%s) must be strictly positive.",t.toString())),Math.log(t)},isExported:!0},Xh={description:a("The logarithm of a number, for a given base."),args:[_c("value (number)",a("The value for which to calculate the logarithm.")),_c("base (number, default=10)",a("The base of the logarithm."))],returns:["NUMBER"],compute:function(e,t=10){const o=Vo(e,this.locale),s=Vo(t,this.locale);return Lo((()=>o>0),a("The value (%s) must be strictly positive.",o.toString())),Lo((()=>s>0),a("The base (%s) must be strictly positive.",s.toString())),Lo((()=>1!==s),a("The base must be different from 1.")),Math.log10(o)/Math.log10(s)},isExported:!0},Kh={description:a("Modulo (remainder) operator."),args:[_c("dividend (number)",a("The number to be divided to find the remainder.")),_c("divisor (number)",a("The number to divide by."))],returns:["NUMBER"],computeFormat:e=>e?.format,compute:function(e,t){const o=Vo(t,this.locale);Lo((()=>0!==o),a("The divisor must be different from 0."));const s=Vo(e,this.locale)%o;return s>0&&o<0||s<0&&o>0?s+o:s},isExported:!0},Qh={description:a("Returns a n x n unit matrix, where n is the input dimension."),args:[_c("dimension (number)",a("An integer specifying the dimension size of the unit matrix. It must be positive."))],returns:["RANGE<NUMBER>"],compute:function(e){const t=Ho(e,this.locale);return Dc(a("The argument dimension must be positive"),t),Vc(t)},isExported:!0},Jh={description:a("Rounds a number up to the nearest odd integer."),args:[_c("value (number)",a("The value to round to the next greatest odd number."))],returns:["NUMBER"],computeFormat:e=>e?.format,compute:function(e){const t=Vo(e,this.locale);let o=Math.ceil(Math.abs(t));return o=1&o?o:o+1,t<0?-o:o},isExported:!0},ed={description:a("The number pi."),args:[],returns:["NUMBER"],compute:function(){return Math.PI},isExported:!0},td={description:a("A number raised to a power."),args:[_c("base (number)",a("The number to raise to the exponent power.")),_c("exponent (number)",a("The exponent to raise base to."))],returns:["NUMBER"],computeFormat:e=>e?.format,compute:function(e,t){const o=Vo(e,this.locale),s=Vo(t,this.locale);return Lo((()=>o>=0||Number.isInteger(s)),a("The exponent (%s) must be an integer when the base is negative.",s.toString())),Math.pow(o,s)},isExported:!0},od={description:a("Result of multiplying a series of numbers together."),args:[_c("factor1 (number, range<number>)",a("The first number or range to calculate for the product.")),_c("factor2 (number, range<number>, repeating)",a("More numbers or ranges to calculate for the product."))],returns:["NUMBER"],computeFormat:e=>Mo(e)?e[0][0]?.format:e?.format,compute:function(...e){let t=0,o=1;for(let s of e)if(Mo(s))for(let e of s)for(let s of e)"number"==typeof s&&(o*=s,t+=1);else null!=s&&(o*=Bo(s,this.locale),t+=1);return 0===t?0:o},isExported:!0},sd={description:a("A random number between 0 inclusive and 1 exclusive."),args:[],returns:["NUMBER"],compute:function(){return Math.random()},isExported:!0},nd={description:a("Returns a grid of random numbers between 0 inclusive and 1 exclusive."),args:[_c("rows (number, default=1)",a("The number of rows to be returned.")),_c("columns (number, default=1)",a("The number of columns to be returned.")),_c("min (number, default=0)",a("The minimum number you would like returned.")),_c("max (number, default=1)",a("The maximum number you would like returned.")),_c("whole_number (number, default=FALSE)",a("Return a whole number or a decimal value."))],returns:["RANGE<NUMBER>"],compute:function(e=1,t=1,o=0,s=1,n=!1){const i=Ho(t,this.locale),r=Ho(e,this.locale),l=Vo(o,this.locale),c=Vo(s,this.locale),h=Zo(n);Dc(a("The number columns (%s) must be positive.",i.toString()),i),Dc(a("The number rows (%s) must be positive.",r.toString()),r),Lo((()=>l<=c),a("The maximum (%s) must be greater than or equal to the minimum (%s).",c.toString(),l.toString())),h&&Lo((()=>Number.isInteger(l)&&Number.isInteger(c)),a("The maximum (%s) and minimum (%s) must be integers when whole_number is TRUE.",c.toString(),l.toString()));const d=Array(i);for(let e=0;e<i;e++){d[e]=Array(r);for(let t=0;t<r;t++)d[e][t]=h?Math.floor(Math.random()*(c-l+1)+l):l+Math.random()*(c-l)}return d},isExported:!0},id={description:a("Random integer between two values, inclusive."),args:[_c("low (number)",a("The low end of the random range.")),_c("high (number)",a("The high end of the random range."))],returns:["NUMBER"],computeFormat:e=>e?.format,compute:function(e,t){let o=Vo(e,this.locale);Number.isInteger(o)||(o=Math.ceil(o));let s=Vo(t,this.locale);return Number.isInteger(s)||(s=Math.floor(s)),Lo((()=>o<=s),a("The high (%s) must be greater than or equal to the low (%s).",s.toString(),o.toString())),o+Math.ceil((s-o+1)*Math.random())-1},isExported:!0},rd={description:a("Rounds a number according to standard rules."),args:[_c("value (number)",a("The value to round to places number of places.")),_c("places (number, default=0)",a("The number of decimal places to which to round."))],returns:["NUMBER"],computeFormat:e=>e?.format,compute:function(e,t=0){const o=Vo(e,this.locale);let s=Vo(t,this.locale);const n=Math.abs(o);let i;return 0===s?i=Math.round(n):(Number.isInteger(s)||(s=Math.trunc(s)),i=Math.round(n*Math.pow(10,s))/Math.pow(10,s)),o>=0?i:-i},isExported:!0},ad={description:a("Rounds down a number."),args:[_c("value (number)",a("The value to round to places number of places, always rounding down.")),_c("places (number, default=0)",a("The number of decimal places to which to round."))],returns:["NUMBER"],computeFormat:e=>e?.format,compute:function(e,t=0){const o=Vo(e,this.locale);let s=Vo(t,this.locale);const n=Math.abs(o);let i;return 0===s?i=Math.floor(n):(Number.isInteger(s)||(s=Math.trunc(s)),i=Math.floor(n*Math.pow(10,s))/Math.pow(10,s)),o>=0?i:-i},isExported:!0},ld={description:a("Rounds up a number."),args:[_c("value (number)",a("The value to round to places number of places, always rounding up.")),_c("places (number, default=0)",a("The number of decimal places to which to round."))],returns:["NUMBER"],computeFormat:e=>e?.format,compute:function(e,t=0){const o=Vo(e,this.locale);let s=Vo(t,this.locale);const n=Math.abs(o);let i;return 0===s?i=Math.ceil(n):(Number.isInteger(s)||(s=Math.trunc(s)),i=Math.ceil(n*Math.pow(10,s))/Math.pow(10,s)),o>=0?i:-i},isExported:!0},cd={description:a("Secant of an angle provided in radians."),args:[_c("angle (number)",a("The angle to find the secant of, in radians."))],returns:["NUMBER"],compute:function(e){return 1/Math.cos(Vo(e,this.locale))},isExported:!0},hd={description:a("Hyperbolic secant of any real number."),args:[_c("value (number)",a("Any real value to calculate the hyperbolic secant of."))],returns:["NUMBER"],compute:function(e){return 1/Math.cosh(Vo(e,this.locale))},isExported:!0},dd={description:a("Sine of an angle provided in radians."),args:[_c("angle (number)",a("The angle to find the sine of, in radians."))],returns:["NUMBER"],compute:function(e){return Math.sin(Vo(e,this.locale))},isExported:!0},ud={description:a("Hyperbolic sine of any real number."),args:[_c("value (number)",a("Any real value to calculate the hyperbolic sine of."))],returns:["NUMBER"],compute:function(e){return Math.sinh(Vo(e,this.locale))},isExported:!0},gd={description:a("Positive square root of a positive number."),args:[_c("value (number)",a("The number for which to calculate the positive square root."))],returns:["NUMBER"],computeFormat:e=>e?.format,compute:function(e){const t=Vo(e,this.locale);return Lo((()=>t>=0),a("The value (%s) must be positive or null.",t.toString())),Math.sqrt(t)},isExported:!0},pd={description:a("Sum of a series of numbers and/or cells."),args:[_c("value1 (number, range<number>)",a("The first number or range to add together.")),_c("value2 (number, range<number>, repeating)",a("Additional numbers or ranges to add to value1."))],returns:["NUMBER"],computeFormat:e=>Mo(e)?e[0][0]?.format:e?.format,compute:function(...e){return es(e,((e,t)=>e+t),0,this.locale)},isExported:!0},md={description:a("A conditional sum across a range."),args:[_c("criteria_range (range)",a("The range which is tested against criterion.")),_c("criterion (string)",a("The pattern or test to apply to range.")),_c("sum_range (range, default=criteria_range)",a("The range to be summed, if different from range."))],returns:["NUMBER"],compute:function(e,t,o){void 0===o&&(o=e);let s=0;return ls([e,t],((e,t)=>{const n=o[e][t];"number"==typeof n&&(s+=n)}),this.locale),s},isExported:!0},fd={description:a("Sums a range depending on multiple criteria."),args:[_c("sum_range (range)",a("The range to sum.")),_c("criteria_range1 (range)",a("The range to check against criterion1.")),_c("criterion1 (string)",a("The pattern or test to apply to criteria_range1.")),_c("criteria_range2 (any, range, repeating)",a("Additional ranges to check.")),_c("criterion2 (string, repeating)",a("Additional criteria to check."))],returns:["NUMBER"],compute:function(e,...t){let o=0;return ls(t,((t,s)=>{const n=e[t][s];"number"==typeof n&&(o+=n)}),this.locale),o},isExported:!0},bd={description:a("Tangent of an angle provided in radians."),args:[_c("angle (number)",a("The angle to find the tangent of, in radians."))],returns:["NUMBER"],compute:function(e){return Math.tan(Vo(e,this.locale))},isExported:!0},vd={description:a("Hyperbolic tangent of any real number."),args:[_c("value (number)",a("Any real value to calculate the hyperbolic tangent of."))],returns:["NUMBER"],compute:function(e){return Math.tanh(Vo(e,this.locale))},isExported:!0},Sd={description:a("Truncates a number."),args:[_c("value (number)",a("The value to be truncated.")),_c("places (number, default=0)",a("The number of significant digits to the right of the decimal point to retain."))],returns:["NUMBER"],computeFormat:e=>e?.format,compute:function(e,t=0){const o=Vo(e,this.locale);let s=Vo(t,this.locale);return 0===s?Math.trunc(o):(Number.isInteger(s)||(s=Math.trunc(s)),Math.trunc(o*Math.pow(10,s))/Math.pow(10,s))},isExported:!0},Cd={description:a("Rounds a number down to the nearest integer that is less than or equal to it."),args:[_c("value (number)",a("The number to round down to the nearest integer."))],returns:["NUMBER"],compute:function(e){return Math.floor(Vo(e,this.locale))},isExported:!0};var Ed=Object.freeze({__proto__:null,ABS:mh,ACOS:fh,ACOSH:bh,ACOT:vh,ACOTH:Sh,ASIN:Ch,ASINH:Eh,ATAN:yh,ATAN2:wh,ATANH:xh,CEILING:Ih,CEILING_MATH:Rh,CEILING_PRECISE:Th,COS:Ah,COSH:Oh,COT:_h,COTH:Mh,COUNTBLANK:Nh,COUNTIF:Fh,COUNTIFS:Dh,COUNTUNIQUE:Ph,COUNTUNIQUEIFS:Vh,CSC:kh,CSCH:Uh,DECIMAL:Bh,DEGREES:Hh,EXP:zh,FLOOR:Gh,FLOOR_MATH:$h,FLOOR_PRECISE:Wh,INT:Cd,ISEVEN:qh,ISODD:Yh,ISO_CEILING:Zh,LN:jh,LOG:Xh,MOD:Kh,MUNIT:Qh,ODD:Jh,PI:ed,POWER:td,PRODUCT:od,RAND:sd,RANDARRAY:nd,RANDBETWEEN:id,ROUND:rd,ROUNDDOWN:ad,ROUNDUP:ld,SEC:cd,SECH:hd,SIN:dd,SINH:ud,SQRT:gd,SUM:pd,SUMIF:md,SUMIFS:fd,TAN:bd,TANH:vd,TRUNC:Sd});function yd(...e){const t=e[0].length;e.forEach(((e,o)=>Lo((()=>e.length===t),a("[[FUNCTION_NAME]] has mismatched dimensions for argument %s (%s vs %s).",o.toString(),t.toString(),e.length.toString()))))}function wd(e,t){Lo((()=>e.length>0&&e[0].length>0),a("[[FUNCTION_NAME]] expects the provided values of %(argName)s to be a non-empty matrix.",{argName:t}))}function xd(...e){if(0===e.length||e.some((e=>0===e.length)))throw new m(a("[[FUNCTION_NAME]] has no valid input data."))}function Id(e,t){const o=[],s=[];let n=0,i=0;Xo([e],(e=>{o.push(e),n+=1})),Xo([t],(e=>{s.push(e),i+=1})),Lo((()=>n===i),a("[[FUNCTION_NAME]] has mismatched argument count %s vs %s.",n,i));const r=[],l=[];for(let e=0;e<n;e++){const t=o[e],n=s[e];"number"==typeof t&&"number"==typeof n&&(l.push(t),r.push(n))}return{flatDataX:r,flatDataY:l}}function Rd(e,t,o){const{flatDataX:s,flatDataY:n}=Id(e,t),i=n.length;Lo((()=>0!==i&&(!o||1!==i)),a("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error."));let r=0,l=0;for(let e=0;e<i;e++)r+=n[e],l+=s[e];const c=r/i,h=l/i;let d=0;for(let e=0;e<i;e++)d+=(n[e]-c)*(s[e]-h);return d/(i-(o?1:0))}function Td(e,t,o,s){let n=0,i=0;const r=o?ts:es;i=r(e,((e,t)=>(n+=1,e+t)),0,s),Lo((()=>0!==n&&(!t||1!==n)),a("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error."));const l=i/n;return r(e,((e,t)=>e+Math.pow(t-l,2)),0,s)/(n-(t?1:0))}function Ad(e,t,o,s){const n=Vo(t,s);Lo((()=>o?0<=n&&n<=1:0<n&&n<1),a("Function [[FUNCTION_NAME]] parameter 2 value is out of range."));let i,r=[],l=0;return Xo(e,(e=>{"number"==typeof e&&(i=cs(r,e,"nextSmaller","asc",r.length,((e,t)=>e[t])),r.splice(i+1,0,e),l++)})),Lo((()=>0!==l),a("[[FUNCTION_NAME]] has no valid input data.")),o||Lo((()=>1/(l+1)<=n&&n<=l/(l+1)),a("Function [[FUNCTION_NAME]] parameter 2 value is out of range.")),fo(r,n,o)}function Od(e,t,o){const s=e.length?e:[Ne(1,t.flat().length+1)],n=s.length;let i=o.length?o:s;return i=i.length===n?ns(i):i,{_X:s,_newX:i}}function _d(e,t,o=!0,s=!1){const n=t.flat(),i=n.length;let{_X:r}=Od(e,t,[]);r=r.length===i?ns(r):r.slice(),yd(r[0],n);const l=r.length,c=i-l-(o?1:0),h=[n],d=ns(r.reverse());let u=[];for(let e=0;e<l;e++)if(u.push(0),o){for(const t of r[e])u[e]+=t;u[e]/=i}let g=0;if(o){for(const e of n)g+=e;g/=i}const p=d.map((e=>e.map(((e,t)=>e-u[t]))));o&&d.forEach((e=>e.push(1)));const m=Nd(d,h);if(o||m.push([0]),!s)return m;const f=Bc(p,ns(p)),{inverted:b}=kc(f);if(void 0===b)throw new Error(a("Matrix is not invertible"));let v=0,S=0;for(let e=0;e<i;e++){const t=n[e]-g;let o=0;for(let t=0;t<l;t++){o+=p[e][t]*m[t][0]}const s=t-o;v+=s*s,S+=o*o}const C=Math.sqrt(v/c),E=S/(S+v),y=S/l/(v/c),w=[];for(let e=0;e<l;e++)w.push(C*Math.sqrt(b[e][e]));if(o){const e=Bc(b,[u]),t=Bc(ns([u]),e);w.push(C*Math.sqrt(t[0][0]+1/n.length))}const x=[[m[0][0],w[0],E,y,S],[m[1][0],w[1],C,c,v]];for(let e=2;e<l;e++)x.push([m[e][0],w[e],"","",""]);return o?x.push([m[l][0],w[l],"","",""]):x.push([0,"","","",""]),x}function Md(e,t,o,s){yd(t,e),Lo((()=>o>=1),a("Function [[FUNCTION_NAME]] A regression of order less than 1 cannot be possible."));const n=[e],i=t.map((e=>Ne(0,o).map((t=>Math.pow(e,o-t)))));s&&i.forEach((e=>e.push(1)));const r=Nd(i,n);return s||r.push([0]),r}function Nd(e,t){const o=Bc(e,ns(e)),{inverted:s}=kc(o);if(void 0===s)throw new Error(a("Matrix is not invertible"));const n=Bc(e,t);return ns(Bc(s,n))}function Fd(e){return e.map((e=>e.map((e=>Math.log(e)))))}function Dd(e,t,o,s){const{_X:n,_newX:i}=Od(t,e,o),r=_d(n,e,s,!1),a=r.length-1,l=i.map((e=>{let t=0;for(let o=0;o<a;o++)t+=r[o][0]*e[a-o-1];return t+=r[a][0],[t]}));return l.length===o.length?l:ns(l)}const Ld={description:a("Average magnitude of deviations from mean."),args:[_c("value1 (number, range<number>)",a("The first value or range of the sample.")),_c("value2 (number, range<number>, repeating)",a("Additional values or ranges to include in the sample."))],returns:["NUMBER"],compute:function(...e){let t=0;const o=es(e,((e,o)=>(t+=1,e+o)),0,this.locale);Lo((()=>0!==t),a("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error."));const s=o/t;return es(e,((e,t)=>e+Math.abs(s-t)),0,this.locale)/t},isExported:!0},Pd={description:a("Numerical average value in a dataset, ignoring text."),args:[_c("value1 (number, range<number>)",a("The first value or range to consider when calculating the average value.")),_c("value2 (number, range<number>, repeating)",a("Additional values or ranges to consider when calculating the average value."))],returns:["NUMBER"],computeFormat:e=>Mo(e)?e[0][0]?.format:e?.format,compute:function(...e){let t=0;const o=es(e,((e,o)=>(t+=1,e+o)),0,this.locale);return Lo((()=>0!==t),a("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),o/t},isExported:!0},Vd=a("[[FUNCTION_NAME]] has mismatched range sizes."),kd=a("[[FUNCTION_NAME]] expects the weight to be positive or equal to 0."),Ud={description:a("Weighted average."),args:[_c("values (number, range<number>)",a("Values to average.")),_c("weights (number, range<number>)",a("Weights for each corresponding value.")),_c("additional_values (number, range<number>, repeating)",a("Additional values to average.")),_c("additional_weights (number, range<number>, repeating)",a("Additional weights."))],returns:["NUMBER"],computeFormat:e=>Mo(e)?e[0][0]?.format:e?.format,compute:function(...e){let t,o,s=0,n=0;Lo((()=>e.length%2==0),a("Wrong number of Argument[]. Expected an even number of Argument[]."));for(let i=0;i<e.length-1;i+=2)if(t=e[i],o=e[i+1],Mo(t)){Lo((()=>Mo(o)),Vd);let e=t.length,i=t[0].length;Lo((()=>e===o.length&&i===o[0].length),Vd);for(let r=0;r<e;r++)for(let e=0;e<i;e++){let i=t[r][e],l=o[r][e],c="number"==typeof i,h="number"==typeof l;Lo((()=>c===h),a("[[FUNCTION_NAME]] expects number values.")),h&&(Lo((()=>l>=0),kd),s+=i*l,n+=l)}}else o=Vo(o,this.locale),t=Vo(t,this.locale),Lo((()=>o>=0),kd),s+=t*o,n+=o;return Lo((()=>0!==n),a("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),s/n}},Bd={description:a("Numerical average value in a dataset."),args:[_c("value1 (number, range<number>)",a("The first value or range to consider when calculating the average value.")),_c("value2 (number, range<number>, repeating)",a("Additional values or ranges to consider when calculating the average value."))],returns:["NUMBER"],computeFormat:e=>Mo(e)?e[0][0]?.format:e?.format,compute:function(...e){let t=0;const o=ts(e,((e,o)=>(t+=1,e+o)),0,this.locale);return Lo((()=>0!==t),a("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),o/t},isExported:!0},Hd={description:a("Average of values depending on criteria."),args:[_c("criteria_range (number, range<number>)",a("The range to check against criterion.")),_c("criterion (string)",a("The pattern or test to apply to criteria_range.")),_c("average_range (number, range<number>, default=criteria_range)",a("The range to average. If not included, criteria_range is used for the average instead."))],returns:["NUMBER"],compute:function(e,t,o){const s=gs(e),n=void 0===o?s:gs(o);let i=0,r=0;return ls([e,t],((e,t)=>{const o=n[e][t];"number"==typeof o&&(i+=1,r+=o)}),this.locale),Lo((()=>0!==i),a("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),r/i},isExported:!0},zd={description:a("Average of values depending on multiple criteria."),args:[_c("average_range (range)",a("The range to average.")),_c("criteria_range1 (range)",a("The range to check against criterion1.")),_c("criterion1 (string)",a("The pattern or test to apply to criteria_range1.")),_c("criteria_range2 (any, range, repeating)",a("Additional criteria_range and criterion to check.")),_c("criterion2 (string, repeating)",a("The pattern or test to apply to criteria_range2."))],returns:["NUMBER"],compute:function(e,...t){const o=gs(e);let s=0,n=0;return ls(t,((e,t)=>{const i=o[e][t];"number"==typeof i&&(s+=1,n+=i)}),this.locale),Lo((()=>0!==s),a("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),n/s},isExported:!0},Gd={description:a("The number of numeric values in dataset."),args:[_c("value1 (number, range<number>)",a("The first value or range to consider when counting.")),_c("value2 (number, range<number>, repeating)",a("Additional values or ranges to consider when counting."))],returns:["NUMBER"],compute:function(...e){let t=0;for(let o of e)if(Mo(o))for(let e of o)for(let o of e)"number"==typeof o&&(t+=1);else("string"!=typeof o||go(o,this.locale)||Kt(o,this.locale))&&(t+=1);return t},isExported:!0},$d={description:a("The number of values in a dataset."),args:[_c("value1 (any, range)",a("The first value or range to consider when counting.")),_c("value2 (any, range, repeating)",a("Additional values or ranges to consider when counting."))],returns:["NUMBER"],compute:function(...e){return Jo(e,((e,t)=>null!=t?e+1:e),0)},isExported:!0},Wd={description:a("The covariance of a dataset."),args:[_c("data_y (any, range)",a("The range representing the array or matrix of dependent data.")),_c("data_x (any, range)",a("The range representing the array or matrix of independent data."))],returns:["NUMBER"],compute:function(e,t){return Rd(e,t,!1)},isExported:!0},qd={description:a("The covariance of a dataset."),args:[_c("data_y (any, range)",a("The range representing the array or matrix of dependent data.")),_c("data_x (any, range)",a("The range representing the array or matrix of independent data."))],returns:["NUMBER"],compute:function(e,t){return Rd(e,t,!1)},isExported:!0},Zd={description:a("The sample covariance of a dataset."),args:[_c("data_y (any, range)",a("The range representing the array or matrix of dependent data.")),_c("data_x (any, range)",a("The range representing the array or matrix of independent data."))],returns:["NUMBER"],compute:function(e,t){return Rd(e,t,!0)},isExported:!0},Yd={description:a("Calculates the expected y-value for a specified x based on a linear regression of a dataset."),args:[_c("x (number, range<number>)",a("The value(s) on the x-axis to forecast.")),_c("data_y (range<number>)",a("The range representing the array or matrix of dependent data.")),_c("data_x (range<number>)",a("The range representing the array or matrix of independent data."))],returns:["NUMBER"],compute:function(e,t,o){const{flatDataX:s,flatDataY:n}=Id(t,o);return xd(s,n),Dd([n],[s],ss(gs(e),(e=>Vo(e,this.locale))),!0)},isExported:!0},jd={description:a("Fits points to exponential growth trend."),args:[_c("known_data_y (range<number>)",a("The array or range containing dependent (y) values that are already known, used to curve fit an ideal exponential growth curve.")),_c("known_data_x (range<number>, default={1;2;3;...})",a("The values of the independent variable(s) corresponding with known_data_y.")),_c("new_data_x (any, range, default=known_data_x)",a("The data points to return the y values for on the ideal curve fit.")),_c("b (boolean, default=TRUE)",a("Given a general exponential form of y = b*m^x for a curve fit, calculates b if TRUE or forces b to be 1 and only calculates the m values if FALSE."))],returns:["NUMBER"],compute:function(e,t=[],o=[],s=!0){return wd(e,"known_data_y"),Dd(Fd(Uo(e,"the first argument (known_data_y)")),Uo(t,"the second argument (known_data_x)"),Uo(o,"the third argument (new_data_y)"),Zo(s)).map((e=>e.map((e=>Math.exp(e)))))}},Xd={description:a("Compute the intercept of the linear regression."),args:[_c("data_y (range<number>)",a("The range representing the array or matrix of dependent data.")),_c("data_x (range<number>)",a("The range representing the array or matrix of independent data."))],returns:["NUMBER"],compute:function(e,t){const{flatDataX:o,flatDataY:s}=Id(e,t);xd(o,s);const[[],[n]]=_d([o],[s]);return n},isExported:!0},Kd={description:a("Nth largest element from a data set."),args:[_c("data (any, range)",a("Array or range containing the dataset to consider.")),_c("n (number)",a("The rank from largest to smallest of the element to return."))],returns:["NUMBER"],computeValueAndFormat:function(e,t){const o=Math.trunc(Vo(t?.value,this.locale));let s,n=[],i=0;Xo([e],(e=>{"number"==typeof e.value&&(s=cs(n,e.value,"nextSmaller","asc",n.length,((e,t)=>e[t].value)),n.splice(s+1,0,e),i++,i>o&&(n.shift(),i--))}));const r=n.shift();return Lo((()=>void 0!==r),a("[[FUNCTION_NAME]] has no valid input data.")),Lo((()=>i>=o),a("Function [[FUNCTION_NAME]] parameter 2 value (%s) is out of range.",o)),r},isExported:!0},Qd={description:a("Compute the intercept of the linear regression."),args:[_c("data_y (range<number>)",a("The range representing the array or matrix of dependent data.")),_c("data_x (range<number>, default={1;2;3;...})",a("The range representing the array or matrix of independent data.")),_c("calculate_b (boolean, default=TRUE)",a("A flag specifying wheter to compute the slope or not")),_c("verbose (boolean, default=FALSE)",a("A flag specifying whether to return additional regression statistics or only the linear coefficients and the y-intercept"))],returns:["NUMBER"],compute:function(e,t=[],o=!0,s=!1){return wd(e,"data_y"),_d(Uo(t,"the first argument (data_y)"),Uo(e,"the second argument (data_x)"),Zo(o),Zo(s))},isExported:!0},Jd={description:a("Compute the intercept of the linear regression."),args:[_c("data_y (range<number>)",a("The range representing the array or matrix of dependent data.")),_c("data_x (range<number>, optional, default={1;2;3;...})",a("The range representing the array or matrix of independent data.")),_c("calculate_b (boolean, default=TRUE)",a("A flag specifying wheter to compute the slope or not")),_c("verbose (boolean, default=FALSE)",a("A flag specifying whether to return additional regression statistics or only the linear coefficients and the y-intercept"))],returns:["NUMBER"],compute:function(e,t=[],o=!0,s=!1){wd(e,"data_y");const n=_d(Uo(t,"the second argument (data_x)"),Fd(Uo(e,"the first argument (data_y)")),Zo(o),Zo(s));for(let e=0;e<n.length;e++)n[e][0]=Math.exp(n[e][0]);return n},isExported:!0},eu={description:a("Compute the Matthews correlation coefficient of a dataset."),args:[_c("data_x (range)",a("The range representing the array or matrix of observed data.")),_c("data_y (range)",a("The range representing the array or matrix of predicted data."))],returns:["NUMBER"],compute:function(e,t){const o=e.flat(),s=t.flat();yd(o,s),xd(o,s);const n=o.length;let i=0,r=0,a=0,l=0;for(let e=0;e<n;++e){const t=Zo(o[e]);t===Zo(s[e])?t?r++:i++:t?l++:a++}return(r*i-a*l)/Math.sqrt((r+a)*(r+l)*(i+a)*(i+l))},isExported:!1},tu={description:a("Maximum value in a numeric dataset."),args:[_c("value1 (number, range<number>)",a("The first value or range to consider when calculating the maximum value.")),_c("value2 (number, range<number>, repeating)",a("Additional values or ranges to consider when calculating the maximum value."))],returns:["NUMBER"],computeFormat:e=>Mo(e)?e[0][0]?.format:e?.format,compute:function(...e){const t=es(e,((e,t)=>e<t?t:e),-1/0,this.locale);return t===-1/0?0:t},isExported:!0},ou={description:a("Maximum numeric value in a dataset."),args:[_c("value1 (any, range)",a("The first value or range to consider when calculating the maximum value.")),_c("value2 (any, range, repeating)",a("Additional values or ranges to consider when calculating the maximum value."))],returns:["NUMBER"],computeFormat:e=>Mo(e)?e[0][0]?.format:e?.format,compute:function(...e){const t=ts(e,((e,t)=>Math.max(t,e)),-1/0,this.locale);return t===-1/0?0:t},isExported:!0},su={description:a("Returns the maximum value in a range of cells, filtered by a set of criteria."),args:[_c("range (range)",a("The range of cells from which the maximum will be determined.")),_c("criteria_range1 (range)",a("The range of cells over which to evaluate criterion1.")),_c("criterion1 (string)",a("The pattern or test to apply to criteria_range1, such that each cell that evaluates to TRUE will be included in the filtered set.")),_c("criteria_range2 (any, range, repeating)",a("Additional ranges over which to evaluate the additional criteria. The filtered set will be the intersection of the sets produced by each criterion-range pair.")),_c("criterion2 (string, repeating)",a("The pattern or test to apply to criteria_range2."))],returns:["NUMBER"],compute:function(e,...t){let o=-1/0;const s=gs(e);return ls(t,((e,t)=>{const n=s[e][t];"number"==typeof n&&(o=o<n?n:o)}),this.locale),o===-1/0?0:o},isExported:!0},nu={description:a("Median value in a numeric dataset."),args:[_c("value1 (any, range)",a("The first value or range to consider when calculating the median value.")),_c("value2 (any, range, repeating)",a("Additional values or ranges to consider when calculating the median value."))],returns:["NUMBER"],computeFormat:e=>Mo(e)?e[0][0]?.format:e?.format,compute:function(...e){let t=[];return Ko(e,(e=>{t.push(e)}),this.locale),Ad(t,.5,!0,this.locale)},isExported:!0},iu={description:a("Minimum value in a numeric dataset."),args:[_c("value1 (number, range<number>)",a("The first value or range to consider when calculating the minimum value.")),_c("value2 (number, range<number>, repeating)",a("Additional values or ranges to consider when calculating the minimum value."))],returns:["NUMBER"],computeFormat:e=>Mo(e)?e[0][0]?.format:e?.format,compute:function(...e){const t=es(e,((e,t)=>t<e?t:e),1/0,this.locale);return t===1/0?0:t},isExported:!0},ru={description:a("Minimum numeric value in a dataset."),args:[_c("value1 (number, range<number>)",a("The first value or range to consider when calculating the minimum value.")),_c("value2 (number, range<number>, repeating)",a("Additional values or ranges to consider when calculating the minimum value."))],returns:["NUMBER"],computeFormat:e=>Mo(e)?e[0][0]?.format:e?.format,compute:function(...e){const t=ts(e,((e,t)=>Math.min(t,e)),1/0,this.locale);return t===1/0?0:t},isExported:!0},au={description:a("Returns the minimum value in a range of cells, filtered by a set of criteria."),args:[_c("range (range)",a("The range of cells from which the minimum will be determined.")),_c("criteria_range1 (range)",a("The range of cells over which to evaluate criterion1.")),_c("criterion1 (string)",a("The pattern or test to apply to criteria_range1, such that each cell that evaluates to TRUE will be included in the filtered set.")),_c("criteria_range2 (any, range, repeating)",a("Additional ranges over which to evaluate the additional criteria. The filtered set will be the intersection of the sets produced by each criterion-range pair.")),_c("criterion2 (string, repeating)",a("The pattern or test to apply to criteria_range2."))],returns:["NUMBER"],compute:function(e,...t){let o=1/0;const s=gs(e);return ls(t,((e,t)=>{const n=s[e][t];"number"==typeof n&&(o=o>n?n:o)}),this.locale),o===1/0?0:o},isExported:!0},lu={description:a("Compute the Pearson product-moment correlation coefficient of a dataset."),args:[_c("data_y (range<number>)",a("The range representing the array or matrix of dependent data.")),_c("data_x (range<number>)",a("The range representing the array or matrix of independent data."))],returns:["NUMBER"],compute:function(e,t){const{flatDataX:o,flatDataY:s}=Id(t,e);xd(o,s);const n=o.length;let i=0,r=0,a=0,l=0,c=0;for(let e=0;e<n;e++){const t=o[e],n=s[e];i+=t,r+=n,a+=t*n,l+=t*t,c+=n*n}return(n*a-i*r)/Math.sqrt((n*l-i*i)*(n*c-r*r))},isExported:!0},cu=lu,hu={description:a("Value at a given percentile of a dataset."),args:[_c("data (any, range)",a("The array or range containing the dataset to consider.")),_c("percentile (number)",a("The percentile whose value within data will be calculated and returned."))],returns:["NUMBER"],computeFormat:e=>Mo(e)?e[0][0]?.format:e?.format,compute:function(e,t){return uu.compute.bind(this)(e,t)},isExported:!0},du={description:a("Value at a given percentile of a dataset exclusive of 0 and 1."),args:[_c("data (any, range)",a("The array or range containing the dataset to consider.")),_c("percentile (number)",a("The percentile, exclusive of 0 and 1, whose value within 'data' will be calculated and returned."))],returns:["NUMBER"],computeFormat:e=>Mo(e)?e[0][0]?.format:e?.format,compute:function(e,t){return Ad([e],t,!1,this.locale)},isExported:!0},uu={description:a("Value at a given percentile of a dataset."),args:[_c("data (any, range)",a("The array or range containing the dataset to consider.")),_c("percentile (number)",a("The percentile whose value within data will be calculated and returned."))],returns:["NUMBER"],computeFormat:e=>Mo(e)?e[0][0]?.format:e?.format,compute:function(e,t){return Ad([e],t,!0,this.locale)},isExported:!0},gu={description:a("Compute the coefficients of polynomial regression of the dataset."),args:[_c("data_y (range<number>)",a("The range representing the array or matrix of dependent data.")),_c("data_x (range<number>)",a("The range representing the array or matrix of independent data.")),_c("order (number)",a("The order of the polynomial to fit the data, between 1 and 6.")),_c("intercept (boolean, default=TRUE)",a("A flag specifying whether to compute the intercept or not."))],returns:["RANGE<NUMBER>"],compute:function(e,t,o,s=!0){const{flatDataX:n,flatDataY:i}=Id(e,t);return xd(n,i),Md(i,n,Vo(o,this.locale),Zo(s))},isExported:!1},pu={description:a("Predict value by computing a polynomial regression of the dataset."),args:[_c("x (number, range<number>)",a("The value(s) on the x-axis to forecast.")),_c("data_y (range<number>)",a("The range representing the array or matrix of dependent data.")),_c("data_x (range<number>)",a("The range representing the array or matrix of independent data.")),_c("order (number)",a("The order of the polynomial to fit the data, between 1 and 6.")),_c("intercept (boolean, default=TRUE)",a("A flag specifying whether to compute the intercept or not."))],returns:["NUMBER"],compute:function(e,t,o,s,n=!0){const i=Vo(s,this.locale),{flatDataX:r,flatDataY:a}=Id(t,o);xd(r,a);const l=Md(a,r,i,Zo(n)).flat();return ss(gs(e),(e=>function(e,t,o){return e.reduce(((e,s,n)=>e+s*Math.pow(t,o-n)),0)}(l,Vo(e,this.locale),i)))},isExported:!1},mu={description:a("Value nearest to a specific quartile of a dataset."),args:[_c("data (any, range)",a("The array or range containing the dataset to consider.")),_c("quartile_number (number)",a("Which quartile value to return."))],returns:["NUMBER"],computeFormat:e=>Mo(e)?e[0][0]?.format:e?.format,compute:function(e,t){return bu.compute.bind(this)(e,t)},isExported:!0},fu={description:a("Value nearest to a specific quartile of a dataset exclusive of 0 and 4."),args:[_c("data (any, range)",a("The array or range containing the dataset to consider.")),_c("quartile_number (number)",a("Which quartile value, exclusive of 0 and 4, to return."))],returns:["NUMBER"],computeFormat:e=>Mo(e)?e[0][0]?.format:e?.format,compute:function(e,t){return Ad([e],.25*Math.trunc(Vo(t,this.locale)),!1,this.locale)},isExported:!0},bu={description:a("Value nearest to a specific quartile of a dataset."),args:[_c("data (any, range)",a("The array or range containing the dataset to consider.")),_c("quartile_number (number)",a("Which quartile value to return."))],returns:["NUMBER"],computeFormat:e=>Mo(e)?e[0][0]?.format:e?.format,compute:function(e,t){return Ad([e],.25*Math.trunc(Vo(t,this.locale)),!0,this.locale)},isExported:!0},vu={description:a("Returns the rank of a specified value in a dataset."),args:[_c("value (number)",a("The value whose rank will be determined.")),_c("data (range)",a("The range containing the dataset to consider.")),_c("is_ascending (boolean, default=FALSE)",a("Whether to consider the values in data in descending or ascending order."))],returns:["ANY"],compute:function(e,t,o=!1){const s=Zo(o),n=Vo(e,this.locale);let i=1,r=!1;for(const e of t)for(const t of e){if("number"!=typeof t)continue;const e=Vo(t,this.locale);e===n?r=!0:e>n!==s&&i++}if(!r)throw new m(a("Value not found in the given data."));return i},isExported:!0},Su={description:a("Compute the square of r, the Pearson product-moment correlation coefficient of a dataset."),args:[_c("data_y (range<number>)",a("The range representing the array or matrix of dependent data.")),_c("data_x (range<number>)",a("The range representing the array or matrix of independent data."))],returns:["NUMBER"],compute:function(e,t){const o=lu.compute.bind(this);return Math.pow(o(t,e),2)},isExported:!0},Cu={description:a("Compute the slope of the linear regression."),args:[_c("data_y (range<number>)",a("The range representing the array or matrix of dependent data.")),_c("data_x (range<number>)",a("The range representing the array or matrix of independent data."))],returns:["NUMBER"],compute:function(e,t){const{flatDataX:o,flatDataY:s}=Id(e,t);xd(o,s);const[[n]]=_d([o],[s]);return n},isExported:!0},Eu={description:a("Nth smallest element in a data set."),args:[_c("data (any, range)",a("The array or range containing the dataset to consider.")),_c("n (number)",a("The rank from smallest to largest of the element to return."))],returns:["NUMBER"],computeValueAndFormat:function(e,t){const o=Math.trunc(Vo(t?.value,this.locale));let s,n=[],i=0;Xo([e],(e=>{"number"==typeof e.value&&(s=cs(n,e.value,"nextSmaller","asc",n.length,((e,t)=>e[t].value)),n.splice(s+1,0,e),i++,i>o&&(n.pop(),i--))}));const r=n.pop();return Lo((()=>void 0!==r),a("[[FUNCTION_NAME]] has no valid input data.")),Lo((()=>i>=o),a("Function [[FUNCTION_NAME]] parameter 2 value (%s) is out of range.",o)),r},isExported:!0},yu={description:a("Compute the Spearman rank correlation coefficient of a dataset."),args:[_c("data_y (range<number>)",a("The range representing the array or matrix of dependent data.")),_c("data_x (range<number>)",a("The range representing the array or matrix of independent data."))],returns:["NUMBER"],compute:function(e,t){const{flatDataX:o,flatDataY:s}=Id(t,e);xd(o,s);const n=o.length,i=o.map(((e,t)=>[e,s[t]]));i.sort(((e,t)=>e[0]-t[0]));for(let e=0;e<n;++e)i[e][0]=e;i.sort(((e,t)=>e[1]-t[1]));let r=0;for(let e=0;e<n;++e)r+=(i[e][0]-e)**2;return 1-6*r/(n**3-n)},isExported:!1},wu={description:a("Standard deviation."),args:[_c("value1 (number, range<number>)",a("The first value or range of the sample.")),_c("value2 (number, range<number>, repeating)",a("Additional values or ranges to include in the sample."))],returns:["NUMBER"],compute:function(...e){return Math.sqrt(Mu.compute.bind(this)(...e))},isExported:!0},xu={description:a("Standard deviation of entire population."),args:[_c("value1 (number, range<number>)",a("The first value or range of the population.")),_c("value2 (number, range<number>, repeating)",a("Additional values or ranges to include in the population."))],returns:["NUMBER"],compute:function(...e){return Math.sqrt(Nu.compute.bind(this)(...e))},isExported:!0},Iu={description:a("Standard deviation."),args:[_c("value1 (number, range<number>)",a("The first value or range of the sample.")),_c("value2 (number, range<number>, repeating)",a("Additional values or ranges to include in the sample."))],returns:["NUMBER"],compute:function(...e){return Math.sqrt(Fu.compute.bind(this)(...e))},isExported:!0},Ru={description:a("Standard deviation of sample (text as 0)."),args:[_c("value1 (number, range<number>)",a("The first value or range of the sample.")),_c("value2 (number, range<number>, repeating)",a("Additional values or ranges to include in the sample."))],returns:["NUMBER"],compute:function(...e){return Math.sqrt(Du.compute.bind(this)(...e))},isExported:!0},Tu={description:a("Standard deviation of entire population."),args:[_c("value1 (number, range<number>)",a("The first value or range of the population.")),_c("value2 (number, range<number>, repeating)",a("Additional values or ranges to include in the population."))],returns:["NUMBER"],compute:function(...e){return Math.sqrt(Lu.compute.bind(this)(...e))},isExported:!0},Au={description:a("Standard deviation of entire population (text as 0)."),args:[_c("value1 (number, range<number>)",a("The first value or range of the population.")),_c("value2 (number, range<number>, repeating)",a("Additional values or ranges to include in the population."))],returns:["NUMBER"],compute:function(...e){return Math.sqrt(Pu.compute.bind(this)(...e))},isExported:!0},Ou={description:a("Calculates the standard error of the predicted y-value for each x in the regression of a dataset."),args:[_c("data_y (range<number>)",a("The range representing the array or matrix of dependent data.")),_c("data_x (range<number>)",a("The range representing the array or matrix of independent data."))],returns:["NUMBER"],compute:function(e,t){const{flatDataX:o,flatDataY:s}=Id(e,t);xd(o,s);return _d([o],[s],!0,!0)[1][2]},isExported:!0},_u={description:a("Fits points to linear trend derived via least-squares."),args:[_c("known_data_y (number, range<number>)",a("The array or range containing dependent (y) values that are already known, used to curve fit an ideal linear trend.")),_c("known_data_x (number, range<number>, optional, default={1;2;3;...})",a("The values of the independent variable(s) corresponding with known_data_y.")),_c("new_data_x (number, range<number>, optional, default=known_data_x)",a("The data points to return the y values for on the ideal curve fit.")),_c("b (boolean, optional, default=TRUE)",a("Given a general linear form of y = m*x+b for a curve fit, calculates b if TRUE or forces b to be 0 and only calculates the m values if FALSE, i.e. forces the curve fit to pass through the origin."))],returns:["NUMBER"],compute:function(e,t=[],o=[],s=!0){return wd(e,"known_data_y"),Dd(Uo(e,"the first argument (known_data_y)"),Uo(t,"the second argument (known_data_x)"),Uo(o,"the third argument (new_data_y)"),Zo(s))}},Mu={description:a("Variance."),args:[_c("value1 (number, range<number>)",a("The first value or range of the sample.")),_c("value2 (number, range<number>, repeating)",a("Additional values or ranges to include in the sample."))],returns:["NUMBER"],compute:function(...e){return Td(e,!0,!1,this.locale)},isExported:!0},Nu={description:a("Variance of entire population."),args:[_c("value1 (number, range<number>)",a("The first value or range of the population.")),_c("value2 (number, range<number>, repeating)",a("Additional values or ranges to include in the population."))],returns:["NUMBER"],compute:function(...e){return Td(e,!1,!1,this.locale)},isExported:!0},Fu={description:a("Variance."),args:[_c("value1 (number, range<number>)",a("The first value or range of the sample.")),_c("value2 (number, range<number>, repeating)",a("Additional values or ranges to include in the sample."))],returns:["NUMBER"],compute:function(...e){return Td(e,!0,!1,this.locale)},isExported:!0},Du={description:a("Variance of sample (text as 0)."),args:[_c("value1 (number, range<number>)",a("The first value or range of the sample.")),_c("value2 (number, range<number>, repeating)",a("Additional values or ranges to include in the sample."))],returns:["NUMBER"],compute:function(...e){return Td(e,!0,!0,this.locale)},isExported:!0},Lu={description:a("Variance of entire population."),args:[_c("value1 (number, range<number>)",a("The first value or range of the population.")),_c("value2 (number, range<number>, repeating)",a("Additional values or ranges to include in the population."))],returns:["NUMBER"],compute:function(...e){return Td(e,!1,!1,this.locale)},isExported:!0},Pu={description:a("Variance of entire population (text as 0)."),args:[_c("value1 (number, range<number>)",a("The first value or range of the population.")),_c("value2 (number, range<number>, repeating)",a("Additional values or ranges to include in the population."))],returns:["NUMBER"],compute:function(...e){return Td(e,!1,!0,this.locale)},isExported:!0};var Vu=Object.freeze({__proto__:null,AVEDEV:Ld,AVERAGE:Pd,AVERAGEA:Bd,AVERAGEIF:Hd,AVERAGEIFS:zd,AVERAGE_WEIGHTED:Ud,CORREL:cu,COUNT:Gd,COUNTA:$d,COVAR:Wd,COVARIANCE_P:qd,COVARIANCE_S:Zd,FORECAST:Yd,GROWTH:jd,INTERCEPT:Xd,LARGE:Kd,LINEST:Qd,LOGEST:Jd,MATTHEWS:eu,MAX:tu,MAXA:ou,MAXIFS:su,MEDIAN:nu,MIN:iu,MINA:ru,MINIFS:au,PEARSON:lu,PERCENTILE:hu,PERCENTILE_EXC:du,PERCENTILE_INC:uu,POLYFIT_COEFFS:gu,POLYFIT_FORECAST:pu,QUARTILE:mu,QUARTILE_EXC:fu,QUARTILE_INC:bu,RANK:vu,RSQ:Su,SLOPE:Cu,SMALL:Eu,SPEARMAN:yu,STDEV:wu,STDEVA:Ru,STDEVP:Tu,STDEVPA:Au,STDEV_P:xu,STDEV_S:Iu,STEYX:Ou,TREND:_u,VAR:Mu,VARA:Du,VARP:Lu,VARPA:Pu,VAR_P:Nu,VAR_S:Fu});function ku(e,t,o,s){const n=new Map,i=e.length;for(let t=i-1;t>=0;t--)n.set($o(e[t][0]).toUpperCase(),t);if("number"!=typeof t&&"string"!=typeof t)throw new Error(a("The field must be a number or a string"));let r;if("number"==typeof t){if(r=Math.trunc(t)-1,r<0||i-1<r)throw new Error(a("The field (%s) must be one of %s or must be a number between 1 and %s inclusive.",t.toString(),i.toString()))}else{const e=$o(t).toUpperCase();if(r=n.get(e)??-1,-1===r)throw new Error(a("The field (%s) must be one of %s.",$o(t),[...n.keys()].toString()))}const l=o[0].length;if(l<2)throw new Error(a("The criteria range contains %s row, it must be at least 2 rows.",l.toString()));let c=new Set;const h=e[0].length;for(let t=1;t<l;t++){let i=[],r=!0;for(let s=0;s<o.length;s++){const a=$o(o[s][0]).toUpperCase(),l=n.get(a),c=o[s][t];if(null!==c){if(void 0===l){r=!1;break}i.push([e[l].slice(1,h)]),i.push(c)}}if(r){if(!(i.length>0)){c=new Set(Array(h-1).keys());break}ls(i,((e,t)=>{c.add(t)}),s,!0)}}const d=e[r];return[...c].map((e=>d[e+1]))}const Uu=[_c("database (range)",a("The array or range containing the data to consider, structured in such a way that the first row contains the labels for each column's values.")),_c("field (any)",a("Indicates which column in database contains the values to be extracted and operated on.")),_c("criteria (range)",a("An array or range containing zero or more criteria to filter the database values by before operating."))],Bu={description:a("Average of a set of values from a table-like range."),args:Uu,returns:["NUMBER"],compute:function(e,t,o){const s=ku(e,t,o,this.locale);return Pd.compute.bind(this)([s])},isExported:!0},Hu={description:a("Counts values from a table-like range."),args:Uu,returns:["NUMBER"],compute:function(e,t,o){const s=ku(e,t,o,this.locale);return Gd.compute.bind(this)([s])},isExported:!0},zu={description:a("Counts values and text from a table-like range."),args:Uu,returns:["NUMBER"],compute:function(e,t,o){const s=ku(e,t,o,this.locale);return $d.compute.bind(this)([s])},isExported:!0},Gu={description:a("Single value from a table-like range."),args:Uu,returns:["NUMBER"],compute:function(e,t,o){const s=ku(e,t,o,this.locale);return Lo((()=>1===s.length),a("More than one match found in DGET evaluation.")),s[0]},isExported:!0},$u={description:a("Maximum of values from a table-like range."),args:Uu,returns:["NUMBER"],compute:function(e,t,o){const s=ku(e,t,o,this.locale);return tu.compute.bind(this)([s])},isExported:!0},Wu={description:a("Minimum of values from a table-like range."),args:Uu,returns:["NUMBER"],compute:function(e,t,o){const s=ku(e,t,o,this.locale);return iu.compute.bind(this)([s])},isExported:!0},qu={description:a("Product of values from a table-like range."),args:Uu,returns:["NUMBER"],compute:function(e,t,o){const s=ku(e,t,o,this.locale);return od.compute.bind(this)([s])},isExported:!0},Zu={description:a("Standard deviation of population sample from table."),args:Uu,returns:["NUMBER"],compute:function(e,t,o){const s=ku(e,t,o,this.locale);return wu.compute.bind(this)([s])},isExported:!0},Yu={description:a("Standard deviation of entire population from table."),args:Uu,returns:["NUMBER"],compute:function(e,t,o){const s=ku(e,t,o,this.locale);return Tu.compute.bind(this)([s])},isExported:!0},ju={description:a("Sum of values from a table-like range."),args:Uu,returns:["NUMBER"],compute:function(e,t,o){const s=ku(e,t,o,this.locale);return pd.compute.bind(this)([s])},isExported:!0},Xu={description:a("Variance of population sample from table-like range."),args:Uu,returns:["NUMBER"],compute:function(e,t,o){const s=ku(e,t,o,this.locale);return Mu.compute.bind(this)([s])},isExported:!0},Ku={description:a("Variance of a population from a table-like range."),args:Uu,returns:["NUMBER"],compute:function(e,t,o){const s=ku(e,t,o,this.locale);return Lu.compute.bind(this)([s])},isExported:!0};var Qu=Object.freeze({__proto__:null,DAVERAGE:Bu,DCOUNT:Hu,DCOUNTA:zu,DGET:Gu,DMAX:$u,DMIN:Wu,DPRODUCT:qu,DSTDEV:Zu,DSTDEVP:Yu,DSUM:ju,DVAR:Xu,DVARP:Ku});var Ju;!function(e){e.WHOLE_YEARS="Y",e.WHOLE_MONTHS="M",e.WHOLE_DAYS="D",e.DAYS_WITHOUT_WHOLE_MONTHS="MD",e.MONTH_WITHOUT_WHOLE_YEARS="YM",e.DAYS_BETWEEN_NO_MORE_THAN_ONE_YEAR="YD"}(Ju||(Ju={}));const eg={description:a("Converts year/month/day into a date."),args:[_c("year (number)",a("The year component of the date.")),_c("month (number)",a("The month component of the date.")),_c("day (number)",a("The day component of the date."))],returns:["DATE"],computeFormat:function(){return this.locale.dateFormat},compute:function(e,t,o){let s=Math.trunc(Vo(e,this.locale));const n=Math.trunc(Vo(t,this.locale)),i=Math.trunc(Vo(o,this.locale));Lo((()=>0<=s&&s<=9999),a("The year (%s) must be between 0 and 9999 inclusive.",s.toString())),s<1900&&(s+=1900);const r=Jt(new Pt(s,n-1,i));return Lo((()=>r>=0),a("The function [[FUNCTION_NAME]] result must be greater than or equal 01/01/1900.")),r},isExported:!0},tg={description:a("Calculates the number of days, months, or years between two dates."),args:[_c("start_date (date)",a("The start date to consider in the calculation. Must be a reference to a cell containing a DATE, a function returning a DATE type, or a number.")),_c("end_date (date)",a("The end date to consider in the calculation. Must be a reference to a cell containing a DATE, a function returning a DATE type, or a number.")),_c("unit (string)",a('A text abbreviation for unit of time. Accepted values are "Y" (the number of whole years between start_date and end_date), "M" (the number of whole months between start_date and end_date), "D" (the number of days between start_date and end_date), "MD" (the number of days between start_date and end_date after subtracting whole months), "YM" (the number of whole months between start_date and end_date after subtracting whole years), "YD" (the number of days between start_date and end_date, assuming start_date and end_date were no more than one year apart).'))],returns:["NUMBER"],compute:function(e,t,o){const s=$o(o).toUpperCase();Lo((()=>Object.values(Ju).includes(s)),((e,t)=>{const o=e.map((e=>`'${e}'`)).join(", ");return a("The function [[FUNCTION_NAME]] has an argument with value '%s'. It should be one of: %s.",t,o)})(Object.values(Ju),$o(o)));const n=Math.trunc(Vo(e,this.locale)),i=Math.trunc(Vo(t,this.locale)),r=Qt(n),l=Qt(i);switch(Lo((()=>i>=n),a("start_date (%s) should be on or before end_date (%s).",r.toLocaleDateString(),l.toLocaleDateString())),s){case Ju.WHOLE_YEARS:return lo(r,l);case Ju.WHOLE_MONTHS:return ro(r,l);case Ju.WHOLE_DAYS:return ao(r,l);case Ju.MONTH_WITHOUT_WHOLE_YEARS:return ro(r,l)-12*lo(r,l);case Ju.DAYS_WITHOUT_WHOLE_MONTHS:let e=l.getDate()-r.getDate();if(e<0){e=to(new Pt(l.getFullYear(),l.getMonth()-1,1))-Math.abs(e)}return e;case Ju.DAYS_BETWEEN_NO_MORE_THAN_ONE_YEAR:{if(function(e,t){return io(e,t,1)<1}(n,i))return ao(r,l);const e=new Pt(r.getFullYear(),l.getMonth(),l.getDate());let t=ao(r,e);return t<0&&(e.setFullYear(r.getFullYear()+1),t=ao(r,e)),t}}},isExported:!0},og={description:a("Converts a date string to a date value."),args:[_c("date_string (string)",a("The string representing the date."))],returns:["NUMBER"],compute:function(e){const t=$o(e),o=Kt(t,this.locale);return Lo((()=>null!==o),a("The date_string (%s) cannot be parsed to date/time.",t.toString())),Math.trunc(o.value)},isExported:!0},sg={description:a("Day of the month that a specific date falls on."),args:[_c("date (string)",a("The date from which to extract the day."))],returns:["NUMBER"],compute:function(e){return Yo(e,this.locale).getDate()},isExported:!0},ng={description:a("Number of days between two dates."),args:[_c("end_date (date)",a("The end of the date range.")),_c("start_date (date)",a("The start of the date range."))],returns:["NUMBER"],compute:function(e,t){const o=Yo(e,this.locale),s=Yo(t,this.locale),n=o.getTime()-s.getTime();return Math.round(n/kt)},isExported:!0},ig={description:a("Number of days between two dates on a 360-day year (months of 30 days)."),args:[_c("start_date (date)",a("The start date to consider in the calculation.")),_c("end_date (date)",a("The end date to consider in the calculation.")),_c("method (number, default=0)",a("An indicator of what day count method to use. (0) US NASD method (1) European method"))],returns:["NUMBER"],compute:function(e,t,o=0){const s=Vo(e,this.locale),n=Vo(t,this.locale),i=Zo(o)?4:0,r=Ig.compute.bind(this)(e,t,i);return Math.sign(n-s)*Math.round(360*r)},isExported:!0},rg={description:a("Date a number of months before/after another date."),args:[_c("start_date (date)",a("The date from which to calculate the result.")),_c("months (number)",a("The number of months before (negative) or after (positive) 'start_date' to calculate."))],returns:["DATE"],computeFormat:function(){return this.locale.dateFormat},compute:function(e,t){return Jt(so(Yo(e,this.locale),Math.trunc(Vo(t,this.locale)),!1))},isExported:!0},ag={description:a("Last day of a month before or after a date."),args:[_c("start_date (date)",a("The date from which to calculate the result.")),_c("months (number)",a("The number of months before (negative) or after (positive) 'start_date' to consider."))],returns:["DATE"],computeFormat:function(){return this.locale.dateFormat},compute:function(e,t){const o=Yo(e,this.locale),s=Math.trunc(Vo(t,this.locale)),n=o.getFullYear(),i=o.getMonth();return Jt(new Pt(n,i+s+1,0))},isExported:!0},lg={description:a("Hour component of a specific time."),args:[_c("time (date)",a("The time from which to calculate the hour component."))],returns:["NUMBER"],compute:function(e){return Yo(e,this.locale).getHours()},isExported:!0},cg={description:a("ISO week number of the year."),args:[_c("date (date)",a("The date for which to determine the ISO week number. Must be a reference to a cell containing a date, a function returning a date type, or a number."))],returns:["NUMBER"],compute:function(e){const t=Yo(e,this.locale),o=t.getFullYear();let s=1;for(;4!==new Pt(o,0,s).getDay();)s+=1;const n=new Pt(o,0,s-3);let i=31;for(;4!==new Pt(o,11,i).getDay();)i-=1;const r=new Pt(o,11,i+3);let a,l;switch(a=n.getTime()<=t.getTime()?t.getTime()<=r.getTime()?0:1:-1,a){case 0:l=n;break;case 1:l=new Pt(o,11,i+3+1);break;case-1:let e=1;for(;4!==new Pt(o-1,0,e).getDay();)e+=1;l=new Pt(o-1,0,e-3)}const c=(t.getTime()-l.getTime())/kt;return Math.floor(c/7)+1},isExported:!0},hg={description:a("Minute component of a specific time."),args:[_c("time (date)",a("The time from which to calculate the minute component."))],returns:["NUMBER"],compute:function(e){return Yo(e,this.locale).getMinutes()},isExported:!0},dg={description:a("Month of the year a specific date falls in"),args:[_c("date (date)",a("The date from which to extract the month."))],returns:["NUMBER"],compute:function(e){return Yo(e,this.locale).getMonth()+1},isExported:!0},ug={description:a("Net working days between two provided days."),args:[_c("start_date (date)",a("The start date of the period from which to calculate the number of net working days.")),_c("end_date (date)",a("The end date of the period from which to calculate the number of net working days.")),_c("holidays (date, range<date>, optional)",a("A range or array constant containing the date serial numbers to consider holidays."))],returns:["NUMBER"],compute:function(e,t,o){return pg.compute.bind(this)(e,t,1,o)},isExported:!0};function gg(e){if("string"==typeof e){Lo((()=>{if(7!==e.length)return!1;for(let t of e)if("0"!==t&&"1"!==t)return!1;return!0}),a('When weekend is a string (%s) it must be composed of "0" or "1".',e));let t=[];for(let o=0;o<7;o++)"1"===e[o]&&t.push((o+1)%7);return t}if("number"==typeof e)return Lo((()=>1<=e&&e<=7||11<=e&&e<=17),a("The weekend (%s) must be a string or a number in the range 1-7 or 11-17.",e.toString())),e<=7?[e-2==-1?6:e-2,e-1]:[e-11];throw Error(a("The weekend must be a number or a string."))}const pg={description:a("Net working days between two dates (specifying weekends)."),args:[_c("start_date (date)",a("The start date of the period from which to calculate the number of net working days.")),_c("end_date (date)",a("The end date of the period from which to calculate the number of net working days.")),_c("weekend (any, default=1)",a("A number or string representing which days of the week are considered weekends.")),_c("holidays (date, range<date>, optional)",a("A range or array constant containing the dates to consider as holidays."))],returns:["NUMBER"],compute:function(e,t,o=1,s){const n=Yo(e,this.locale),i=Yo(t,this.locale),r=gg(o);let a=new Set;void 0!==s&&Xo([s],(e=>{const t=Yo(e,this.locale);a.add(t.getTime())}));const l=n.getTime()>i.getTime(),c=Pt.fromTimestamp((l?n:i).getTime());let h=Pt.fromTimestamp((l?i:n).getTime());const d=c.getTime();let u=h.getTime(),g=0;for(;u<=d;)r.includes(h.getDay())||a.has(u)||(g+=1),h.setDate(h.getDate()+1),u=h.getTime();return l?-g:g},isExported:!0},mg={description:a("Current date and time as a date value."),args:[],returns:["DATE"],computeFormat:function(){return Aa(this.locale)},compute:function(){let e=Pt.now();const t=e.getTime()-Vt.getTime(),o=e.getHours()/24+e.getMinutes()/1440+e.getSeconds()/86400;return Math.floor(t/kt)+o},isExported:!0},fg={description:a("Minute component of a specific time."),args:[_c("time (date)",a("The time from which to calculate the second component."))],returns:["NUMBER"],compute:function(e){return Yo(e,this.locale).getSeconds()},isExported:!0},bg={description:a("Converts hour/minute/second into a time."),args:[_c("hour (number)",a("The hour component of the time.")),_c("minute (number)",a("The minute component of the time.")),_c("second (number)",a("The second component of the time."))],returns:["DATE"],computeFormat:function(){return this.locale.timeFormat},compute:function(e,t,o){let s=Math.trunc(Vo(e,this.locale)),n=Math.trunc(Vo(t,this.locale)),i=Math.trunc(Vo(o,this.locale));return n+=Math.floor(i/60),i=i%60+(i<0?60:0),s+=Math.floor(n/60),n=n%60+(n<0?60:0),s%=24,Lo((()=>s>=0),a("The function [[FUNCTION_NAME]] result cannot be negative")),s/24+n/1440+i/86400},isExported:!0},vg={description:a("Converts a time string into its serial number representation."),args:[_c("time_string (string)",a("The string that holds the time representation."))],returns:["NUMBER"],compute:function(e){const t=$o(e),o=Kt(t,this.locale);Lo((()=>null!==o),a("The time_string (%s) cannot be parsed to date/time.",t));const s=o.value-Math.trunc(o.value);return s<0?1+s:s},isExported:!0},Sg={description:a("Current date as a date value."),args:[],returns:["DATE"],computeFormat:function(){return this.locale.dateFormat},compute:function(){const e=Pt.now();return Jt(new Pt(e.getFullYear(),e.getMonth(),e.getDate()))},isExported:!0},Cg={description:a("Day of the week of the date provided (as number)."),args:[_c("date (date)",a("The date for which to determine the day of the week. Must be a reference to a cell containing a date, a function returning a date type, or a number.")),_c("type (number, default=1)",a("A number indicating which numbering system to use to represent weekdays. By default, counts starting with Sunday = 1."))],returns:["NUMBER"],compute:function(e,t=1){const o=Yo(e,this.locale),s=Math.round(Vo(t,this.locale)),n=o.getDay();return Lo((()=>[1,2,3].includes(s)),a("The type (%s) must be 1, 2 or 3.",s.toString())),1===s?n+1:2===s?0===n?7:n:0===n?6:n-1},isExported:!0},Eg={description:a("Week number of the year."),args:[_c("date (date)",a("The date for which to determine the week number. Must be a reference to a cell containing a date, a function returning a date type, or a number.")),_c("type (number, default=1)",a("A number representing the day that a week starts on. Sunday = 1."))],returns:["NUMBER"],compute:function(e,t=1){const o=Yo(e,this.locale),s=Math.round(Vo(t,this.locale));if(Lo((()=>1===s||2===s||11<=s&&s<=17||21===s),a("The type (%s) is out of range.",s.toString())),21===s)return cg.compute.bind(this)(e);let n;n=1===s||2===s?s-1:s-10==7?0:s-10;const i=o.getFullYear();let r=1,l=new Pt(i,0,r);for(;l.getDay()!==n;)r+=1,l=new Pt(i,0,r);const c=(o.getTime()-l.getTime())/kt;return c<0?1:Math.floor(c/7)+(1===r?1:2)},isExported:!0},yg={description:a("Date after a number of workdays."),args:[_c("start_date (date)",a("The date from which to begin counting.")),_c("num_days (number)",a("The number of working days to advance from start_date. If negative, counts backwards.")),_c("holidays (date, range<date>, optional)",a("A range or array constant containing the dates to consider holidays."))],returns:["NUMBER"],computeFormat:function(){return this.locale.dateFormat},compute:function(e,t,o=void 0){return wg.compute.bind(this)(e,t,1,o??null)},isExported:!0},wg={description:a("Date after a number of workdays (specifying weekends)."),args:[_c("start_date (date)",a("The date from which to begin counting.")),_c("num_days (number)",a("The number of working days to advance from start_date. If negative, counts backwards.")),_c("weekend (any, default=1)",a("A number or string representing which days of the week are considered weekends.")),_c("holidays (date, range<date>, optional)",a("A range or array constant containing the dates to consider holidays."))],returns:["DATE"],computeFormat:function(){return this.locale.dateFormat},compute:function(e,t,o=1,s){let n=Yo(e,this.locale),i=Math.trunc(Vo(t,this.locale));"string"==typeof o&&Lo((()=>"1111111"!==o),a("The weekend (%s) must be different from '1111111'.",o));const r=gg(o);let l=new Set;void 0!==s&&Xo([s],(e=>{const t=Yo(e,this.locale);l.add(t.getTime())}));let c=Pt.fromTimestamp(n.getTime()),h=c.getTime();const d=Math.sign(i);let u=Math.abs(i);for(;u>0;)c.setDate(c.getDate()+d),h=c.getTime(),r.includes(c.getDay())||l.has(h)||(u-=1);const g=h-Vt.getTime();return Math.round(g/kt)},isExported:!0},xg={description:a("Year specified by a given date."),args:[_c("date (date)",a("The date from which to extract the year."))],returns:["NUMBER"],compute:function(e){return Yo(e,this.locale).getFullYear()},isExported:!0},Ig={description:a("Exact number of years between two dates."),args:[_c("start_date (date)",a("The start date to consider in the calculation. Must be a reference to a cell containing a date, a function returning a date type, or a number.")),_c("end_date (date)",a("The end date to consider in the calculation. Must be a reference to a cell containing a date, a function returning a date type, or a number.")),_c("day_count_convention (number, default=0)",a("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,o=0){let s=Math.trunc(Vo(e,this.locale)),n=Math.trunc(Vo(t,this.locale));const i=Math.trunc(Vo(o,this.locale));return Lo((()=>s>=0),a("The start_date (%s) must be positive or null.",s.toString())),Lo((()=>n>=0),a("The end_date (%s) must be positive or null.",n.toString())),Lo((()=>0<=i&&i<=4),a("The day_count_convention (%s) must be between 0 and 4 inclusive.",i.toString())),io(s,n,i)}},Rg={description:a("First day of the month preceding a date."),args:[_c("date (date)",a("The date from which to calculate the result."))],returns:["DATE"],computeFormat:function(){return this.locale.dateFormat},compute:function(e){const t=Yo(e,this.locale),o=t.getFullYear(),s=t.getMonth();return Jt(new Pt(o,s,1))}},Tg={description:a("Last day of the month following a date."),args:[_c("date (date)",a("The date from which to calculate the result."))],returns:["DATE"],computeFormat:function(){return this.locale.dateFormat},compute:function(e){return ag.compute.bind(this)(e,0)}},Ag={description:a("Quarter of the year a specific date falls in"),args:[_c("date (date)",a("The date from which to extract the quarter."))],returns:["NUMBER"],compute:function(e){return Math.ceil((Yo(e,this.locale).getMonth()+1)/3)}},Og={description:a("First day of the quarter of the year a specific date falls in."),args:[_c("date (date)",a("The date from which to calculate the start of quarter."))],returns:["DATE"],computeFormat:function(){return this.locale.dateFormat},compute:function(e){const t=Ag.compute.bind(this)(e),o=xg.compute.bind(this)(e);return Jt(new Pt(o,3*(t-1),1))}},_g={description:a("Last day of the quarter of the year a specific date falls in."),args:[_c("date (date)",a("The date from which to calculate the end of quarter."))],returns:["DATE"],computeFormat:function(){return this.locale.dateFormat},compute:function(e){const t=Ag.compute.bind(this)(e),o=xg.compute.bind(this)(e);return Jt(new Pt(o,3*t,0))}},Mg={description:a("First day of the year a specific date falls in."),args:[_c("date (date)",a("The date from which to calculate the start of the year."))],returns:["DATE"],computeFormat:function(){return this.locale.dateFormat},compute:function(e){const t=xg.compute.bind(this)(e);return Jt(new Pt(t,0,1))}},Ng={description:a("Last day of the year a specific date falls in."),args:[_c("date (date)",a("The date from which to calculate the end of the year."))],returns:["DATE"],computeFormat:function(){return this.locale.dateFormat},compute:function(e){const t=xg.compute.bind(this)(e);return Jt(new Pt(t+1,0,0))}};var Fg=Object.freeze({__proto__:null,DATE:eg,DATEDIF:tg,DATEVALUE:og,DAY:sg,DAYS:ng,DAYS360:ig,EDATE:rg,EOMONTH:ag,HOUR:lg,ISOWEEKNUM:cg,MINUTE:hg,MONTH:dg,MONTH_END:Tg,MONTH_START:Rg,NETWORKDAYS:ug,NETWORKDAYS_INTL:pg,NOW:mg,QUARTER:Ag,QUARTER_END:_g,QUARTER_START:Og,SECOND:fg,TIME:bg,TIMEVALUE:vg,TODAY:Sg,WEEKDAY:Cg,WEEKNUM:Eg,WORKDAY:yg,WORKDAY_INTL:wg,YEAR:xg,YEARFRAC:Ig,YEAR_END:Ng,YEAR_START:Mg});const Dg={description:a("Compare two numeric values, returning 1 if they're equal."),args:[_c("number1 (number)",a("The first number to compare.")),_c("number2 (number, default=0)",a("The second number to compare."))],returns:["NUMBER"],compute:function(e,t=0){return Vo(e,this.locale)===Vo(t,this.locale)?1:0},isExported:!0};var Lg=Object.freeze({__proto__:null,DELTA:Dg});const Pg=[bo.number,bo.error,bo.text,bo.boolean];function Vg(e){const t="ascending"===e?1:-1;return(e,o)=>{if(e.type===bo.empty)return o.type===bo.empty?0:1;if(o.type===bo.empty)return-1;let s=Pg.indexOf(e.type)-Pg.indexOf(o.type);return 0===s&&(s=e.type===bo.text||e.type===bo.error?e.value.localeCompare(o.value):e.value-o.value),t*s}}function kg(e,t,o,s,n){let i=Io.Success,r=s.right>s.left;if(e.model.getters.doesIntersectMerge(t,s)){let o;r=!1;for(let n=s.top;n<=s.bottom;n++){o=[];for(let i=s.left;i<=s.right;i++){let s=e.model.getters.getMerge({sheetId:t,col:i,row:n});s&&!o.includes(s.id.toString())&&o.push(s.id.toString())}if(o.length>=2){r=!0;break}}}const{col:l,row:c}=o;if(r)i=e.model.dispatch("SORT_CELLS",{sheetId:t,col:l,row:c,zone:s,sortDirection:n});else{const o=e.model.getters.getContiguousZone(t,s);wn(o,s)?i=e.model.dispatch("SORT_CELLS",{sheetId:t,col:l,row:c,zone:s,sortDirection:n}):e.askConfirmation(a("We found data next to your selection. Since this data was not selected, it will not be sorted. Do you want to extend your selection?"),(()=>{s=o,i=e.model.dispatch("SORT_CELLS",{sheetId:t,col:l,row:c,zone:s,sortDirection:n})}),(()=>{i=e.model.dispatch("SORT_CELLS",{sheetId:t,col:l,row:c,zone:s,sortDirection:n})}))}if(i.isCancelledBecause("InvalidSortZone")){const{col:t,row:n}=o;e.model.selection.selectZone({cell:{col:t,row:n},zone:s}),e.raiseError(a("Cannot sort. To sort, select only cells or only merges that have the same size."))}}function Ug(e,t,...o){for(const[e,t]of o.entries())Lo((()=>void 0!==t),a("Value for parameter %d is missing, while the function [[FUNCTION_NAME]] expect a number or a range.",e+1));const s=[],n=[],i=e.length;for(let r=0;r<o.length;r+=2){s.push(Zo(Hc(o[r+1])?.value)?"ascending":"descending");const l=o[r];if(Mo(l)&&(l.length>1||l[0].length>1))Lo((()=>1===l.length&&l[0].length===i),a("Wrong size for %s. Expected a range of size 1x%s. Got %sx%s.",`sort_column${r+1}`,i,l.length,l[0].length)),n.push(l.flat().map((e=>e.value)));else{const o=Vo(Hc(l)?.value,t);if(o<1||o>e[0].length)return e;n.push(e.map((e=>e[o-1].value)))}}if(0===n.length)for(let t=0;t<e[0].length;t++)n.push(e.map((e=>e[t].value))),s.push("ascending");const r={descending:Vg("descending"),ascending:Vg("ascending")},l=Ne(0,e.length);return l.sort(((e,t)=>{for(const[o,i]of n.entries()){const n=i[e],a=i[t],l={value:n,type:null===n?bo.empty:"string"==typeof n?bo.text:typeof n},c={value:a,type:null===a?bo.empty:"string"==typeof a?bo.text:typeof a},h=r[s[o]](l,c);if(0!==h)return h}return 0})),l.map((t=>e[t]))}const Bg={description:a("Returns a filtered version of the source range, returning only rows or columns that meet the specified conditions."),args:[_c("range (any, range<any>)",a("The data to be filtered.")),_c("condition1 (boolean, range<boolean>)",a("A column or row containing true or false values corresponding to the first column or row of range.")),_c("condition2 (boolean, range<boolean>, repeating)",a("Additional column or row containing true or false values."))],returns:["RANGE<ANY>"],computeValueAndFormat:function(e,...t){let o=gs(e);const s=t.map((e=>ss(gs(e),(e=>e.value))));s.map((e=>Nc(a("The arguments condition must be a single column or row."),e))),Fc(a("The arguments conditions must have the same dimensions."),...s);const n=s.map((e=>e.flat())),i=1===s[0].length?"row":"col";o="row"===i?ns(o):o,Lo((()=>n.every((e=>e.length===o.length))),a("FILTER has mismatched sizes on the range and conditions."));const r=[];for(let e=0;e<o.length;e++){const t=o[e];n.every((t=>t[e]))&&r.push(t)}if(!r.length)throw new m(a("No match found in FILTER evaluation"));return"row"===i?ns(r):r},isExported:!1},Hg={description:a("Sorts the rows of a given array or range by the values in one or more columns."),args:[_c("range (range)",a("The data to be sorted.")),_c("sort_column (any, range<number>, repeating)",a("The index of the column in range or a range outside of range containing the values by which to sort.")),_c("is_ascending (boolean, repeating)",a("TRUE or FALSE indicating whether to sort sort_column in ascending order. FALSE sorts in descending order."))],returns:["RANGE"],computeValueAndFormat:function(e,...t){const o=ns(e);return ns(Ug(o,this.locale,...t))},isExported:!0},zg={description:a("Returns the first n items in a data set after performing a sort."),args:[_c("range (range)",a("The data to be sorted.")),_c("n (number, default=1)",a("The number of items to return.")),_c("display_ties_mode (number, default=0)",a("A number representing the way to display ties.")),_c("sort_column (number, range<number>, repeating)",a("The index of the column in range or a range outside of range containing the values by which to sort.")),_c("is_ascending (boolean, repeating)",a("TRUE or FALSE indicating whether to sort sort_column in ascending order. FALSE sorts in descending order."))],returns:["RANGE"],computeValueAndFormat:function(e,t,o,...s){const n=Vo(t?.value??1,this.locale);Lo((()=>n>=0),a("Wrong value of 'n'. Expected a positive number. Got %s.",n));const i=Vo(o?.value??0,this.locale);Lo((()=>i>=0&&i<=3),a("Wrong value of 'display_ties_mode'. Expected a positive number between 0 and 3. Got %s.",i));const r=Ug(ns(e),this.locale,...s),l=(e,t)=>JSON.stringify(r[e].map((e=>e.value)))===JSON.stringify(r[t].map((e=>e.value)));switch(i){case 0:return ns(r.slice(0,n));case 1:for(let e=n;e<r.length;e++)if(!l(e,n-1))return ns(r.slice(0,e));return ns(r);case 2:{const e=[r[0]];for(let t=1;t<r.length;t++)for(let o=0;o<t&&!l(t,o);o++)o===t-1&&e.push(r[t]);return ns(e.slice(0,n))}case 3:{const e=[r[0]];let t=1;for(let o=1;o<r.length&&(l(o,o-1)||t++,!(t>n));o++)e.push(r[o]);return ns(e)}}},isExported:!1},Gg={description:a("Unique rows in the provided source range."),args:[_c("range (any, range<any>)",a("The data to filter by unique entries.")),_c("by_column (boolean, default=FALSE)",a("Whether to filter the data by columns or by rows.")),_c("exactly_once (boolean, default=FALSE)",a("Whether to return only entries with no duplicates."))],returns:["RANGE<NUMBER>"],computeValueAndFormat:function(e={value:""},t,o){if(!Mo(e))return[[e]];const s=Zo(t?.value)||!1,n=Zo(o?.value)||!1;s||(e=ns(e));const i=new Map;for(const t of e){const e=JSON.stringify(t.map((e=>e.value))),o=i.get(e);o?o.count++:i.set(e,{data:t,count:1})}const r=[];for(const e of i.values())n&&e.count>1||r.push(e.data);if(!r.length)throw new Error(a("No unique values found"));return s?r:ns(r)},isExported:!0};var $g=Object.freeze({__proto__:null,FILTER:Bg,SORT:Hg,SORTN:zg,UNIQUE:Gg});function Wg(e,t){Lo((()=>e<t),a("The maturity (%s) must be strictly greater than the settlement (%s).",t.toString(),e.toString()))}function qg(e,t){Lo((()=>t<e),a("The settlement date (%s) must be strictly greater than the issue date (%s).",e.toString(),t.toString()))}function Zg(e){Lo((()=>[1,2,4].includes(e)),a("The frequency (%s) must be one of %s",e.toString(),[1,2,4].toString()))}function Yg(e){Lo((()=>0<=e&&e<=4),a("The day_count_convention (%s) must be between 0 and 4 inclusive.",e.toString()))}function jg(e){Lo((()=>e>0),a("The redemption (%s) must be strictly positive.",e.toString()))}function Xg(e){Lo((()=>e>0),a("The price (%s) must be strictly positive.",e.toString()))}function Kg(e){Lo((()=>e>0),a("The number_of_periods (%s) must be greater than 0.",e.toString()))}function Qg(e){Lo((()=>e>0),a("The rate (%s) must be strictly positive.",e.toString()))}function Jg(e){Lo((()=>e>0),a("The life (%s) must be strictly positive.",e.toString()))}function ep(e){Lo((()=>e>=0),a("The cost (%s) must be positive or null.",e.toString()))}function tp(e){Lo((()=>e>0),a("The period (%s) must be strictly positive.",e.toString()))}function op(e){Lo((()=>e>=0),a("The salvage (%s) must be positive or null.",e.toString()))}function sp(e){Lo((()=>e>0),a("The present value (%s) must be strictly positive.",e.toString()))}function np(e,t){Lo((()=>e<=t),a("The period (%s) must be less than or equal life (%s).",e.toString(),t.toString()))}function ip(e){Lo((()=>e>0),a("The investment (%s) must be strictly positive.",e.toString()))}function rp(e){Lo((()=>e>0),a("The discount (%s) must be strictly positive.",e.toString()))}function ap(e){Lo((()=>e<1),a("The discount (%s) must be smaller than 1.",e.toString()))}function lp(e){Lo((()=>e>0),a("The depreciation factor (%s) must be strictly positive.",e.toString()))}function cp(e,t,o){const s=Yo(e,o),n=Yo(t,o),i=Yo(e,o);i.setFullYear(s.getFullYear()+1),Lo((()=>n.getTime()<=i.getTime()),a("The settlement date (%s) must at most one year after the maturity date (%s).",e.toString(),t.toString()))}function hp(e,t,o){Kg(o),Lo((()=>e>0),a("The first_period (%s) must be strictly positive.",e.toString())),Lo((()=>t>0),a("The last_period (%s) must be strictly positive.",t.toString())),Lo((()=>e<=t),a("The first_period (%s) must be smaller or equal to the last_period (%s).",e.toString(),t.toString())),Lo((()=>t<=o),a("The last_period (%s) must be smaller or equal to the number_of_periods (%s).",e.toString(),o.toString()))}function dp(e){Lo((()=>e>-1),a("The rate_guess (%s) must be strictly greater than -1.",e.toString()))}function up(e,t){Lo((()=>e.length===t.length&&e[0].length===t[0].length),a("The cashflow_amounts and cashflow_dates ranges must have the same dimensions."))}function gp(e){Lo((()=>e.every((t=>t>=e[0]))),a("All the dates should be greater or equal to the first date in cashflow_dates (%s).",e[0].toString()))}const pp=[_c("settlement (date)",a("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),_c("maturity (date)",a("The maturity or end date of the security, when it can be redeemed at face, or par value.")),_c("frequency (number)",a("The number of interest or coupon payments per year (1, 2, or 4).")),_c("day_count_convention (number, default=0 )",a("An indicator of what day count method to use."))];function mp(e,t,o,s,n=1e-10,i){let r,l,c,h,d=o,u=!1,g=0;do{c=e(d),isNaN(c)?(Lo((()=>g<s&&void 0!==i),a("Function [[FUNCTION_NAME]] didn't find any result.")),g++,d=i(h),h=d):(r=d-c/t(d),l=Math.abs(r-d),d=r,u=l<n||Math.abs(c)<n,Lo((()=>g<s),a("Function [[FUNCTION_NAME]] didn't find any result.")),g++)}while(!u);return d}const fp={description:a("Accrued interest of security paying at maturity."),args:[_c("issue (date)",a("The date the security was initially issued.")),_c("maturity (date)",a("The maturity date of the security.")),_c("rate (number)",a("The annualized rate of interest.")),_c("redemption (number)",a("The redemption amount per 100 face value, or par.")),_c("day_count_convention (number, default=0 )",a("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,o,s,n=0){n=n||0;const i=Math.trunc(Vo(e,this.locale)),r=Math.trunc(Vo(t,this.locale)),a=Vo(s,this.locale),l=Vo(o,this.locale),c=Math.trunc(Vo(n,this.locale));qg(r,i),Yg(c),jg(a),Qg(l);return a*l*Ig.compute.bind(this)(i,r,n)},isExported:!0},bp={description:a("Depreciation for an accounting period."),args:[_c("cost (number)",a("The initial cost of the asset.")),_c("purchase_date (date)",a("The date the asset was purchased.")),_c("first_period_end (date)",a("The date the first period ended.")),_c("salvage (number)",a("The value of the asset at the end of depreciation.")),_c("period (number)",a("The single period within life for which to calculate depreciation.")),_c("rate (number)",a("The deprecation rate.")),_c("day_count_convention (number, optional)",a("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,o,s,n,i,r=0){r=r||0;const l=Vo(e,this.locale),c=Math.trunc(Vo(t,this.locale)),h=Math.trunc(Vo(o,this.locale)),d=Vo(s,this.locale),u=Vo(n,this.locale),g=Vo(i,this.locale),p=Math.trunc(Vo(r,this.locale));!function(e){Lo((()=>e>0),a("The cost (%s) must be strictly positive.",e.toString()))}(l),op(d),function(e,t){Lo((()=>e<=t),a("The salvage (%s) must be smaller or equal than the cost (%s).",e.toString(),t.toString()))}(d,l),function(e){Lo((()=>e>=0),a("The period (%s) must be positive or null.",e.toString()))}(u),Qg(g),Yg(p),Lo((()=>c<=h),a("The purchase_date (%s) must be before the first_period_end (%s).",c.toString(),h.toString()));const m=u<1&&u>0?1:Math.trunc(u),f=l*g,b=Ig.compute.bind(this)(c,h,p),v=c===h?f:f*b,S=l-v-f*m;return S>=d?0===m?v:f:d-S<f?f-(d-S):0},isExported:!0},vp={description:a("Days in coupon period containing settlement date."),args:pp,returns:["NUMBER"],compute:function(e,t,o,s=0){s=s||0;const n=Math.trunc(Vo(e,this.locale)),i=Math.trunc(Vo(t,this.locale)),r=Math.trunc(Vo(o,this.locale)),a=Math.trunc(Vo(s,this.locale));if(Wg(n,i),Zg(r),Yg(a),1===a){const n=wp.compute.bind(this)(e,t,o,s);return Ep.compute.bind(this)(e,t,o,s)-n}return(3===a?365:360)/r},isExported:!0},Sp={description:a("Days from settlement until next coupon."),args:pp,returns:["NUMBER"],compute:function(e,t,o,s=0){s=s||0;const n=Math.trunc(Vo(e,this.locale)),i=Math.trunc(Vo(t,this.locale)),r=Math.trunc(Vo(o,this.locale)),a=Math.trunc(Vo(s,this.locale));Wg(n,i),Zg(r),Yg(a);const l=wp.compute.bind(this)(n,i,o,s);if([1,2,3].includes(a))return n-l;if(4===a){const e=io(l,n,a);return Math.round(360*e)}const c=Yo(n,this.locale),h=Yo(l,this.locale),d=h.getFullYear(),u=c.getFullYear(),g=h.getMonth()+1,p=c.getMonth()+1;let m=h.getDate(),f=c.getDate();return 2===g&&2===p&&oo(h)&&oo(c)&&(f=30),31!==f||30!==m&&31!==m||(f=30),2===g&&oo(h)&&(m=30),31===m&&(m=30),360*(u-d)+30*(p-g)+(f-m)},isExported:!0},Cp={description:a("Days from settlement until next coupon."),args:pp,returns:["NUMBER"],compute:function(e,t,o,s=0){s=s||0;const n=Math.trunc(Vo(e,this.locale)),i=Math.trunc(Vo(t,this.locale)),r=Math.trunc(Vo(o,this.locale)),a=Math.trunc(Vo(s,this.locale));Wg(n,i),Zg(r),Yg(a);const l=Ep.compute.bind(this)(n,i,o,s);if([1,2,3].includes(a))return l-n;if(4===a){const e=io(n,l,a);return Math.round(360*e)}const c=Sp.compute.bind(this)(e,t,o,a);return vp.compute.bind(this)(e,t,o,a)-c},isExported:!0},Ep={description:a("Next coupon date after the settlement date."),args:pp,returns:["NUMBER"],computeFormat:function(){return this.locale.dateFormat},compute:function(e,t,o,s=0){s=s||0;const n=Math.trunc(Vo(e,this.locale)),i=Math.trunc(Vo(t,this.locale)),r=Math.trunc(Vo(o,this.locale)),a=Math.trunc(Vo(s,this.locale));Wg(n,i),Zg(r),Yg(a);const l=12/r,c=yp.compute.bind(this)(e,t,o,s);return Jt(so(Yo(i,this.locale),-(c-1)*l,!0))},isExported:!0},yp={description:a("Number of coupons between settlement and maturity."),args:pp,returns:["NUMBER"],compute:function(e,t,o,s=0){s=s||0;const n=Math.trunc(Vo(e,this.locale)),i=Math.trunc(Vo(t,this.locale)),r=Math.trunc(Vo(o,this.locale)),a=Math.trunc(Vo(s,this.locale));Wg(n,i),Zg(r),Yg(a);let l=1,c=i;const h=12/r;for(;c>n;)c=Jt(so(Yo(c,this.locale),-h,!1)),l++;return l-1},isExported:!0},wp={description:a("Last coupon date prior to or on the settlement date."),args:pp,returns:["NUMBER"],computeFormat:function(){return this.locale.dateFormat},compute:function(e,t,o,s=0){s=s||0;const n=Math.trunc(Vo(e,this.locale)),i=Math.trunc(Vo(t,this.locale)),r=Math.trunc(Vo(o,this.locale)),a=Math.trunc(Vo(s,this.locale));Wg(n,i),Zg(r),Yg(a);const l=12/r,c=yp.compute.bind(this)(e,t,o,s);return Jt(so(Yo(i,this.locale),-c*l,!0))},isExported:!0},xp={description:a("Cumulative interest paid over a set of periods."),args:[_c("rate (number)",a("The interest rate.")),_c("number_of_periods (number)",a("The number of payments to be made.")),_c("present_value (number)",a("The current value of the annuity.")),_c("first_period (number)",a("The number of the payment period to begin the cumulative calculation.")),_c("last_period (number)",a("The number of the payment period to end the cumulative calculation.")),_c("end_or_beginning (number, default=0)",a("Whether payments are due at the end (0) or beginning (1) of each period."))],returns:["NUMBER"],compute:function(e,t,o,s,n,i=0){const r=Vo(s,this.locale),a=Vo(n,this.locale),l=Vo(e,this.locale),c=Vo(o,this.locale),h=Vo(t,this.locale);hp(r,a,h),Qg(l),sp(c);let d=0;for(let t=r;t<=a;t++){d+=Pp.compute.bind(this)(e,t,h,o,0,i)}return d},isExported:!0},Ip={description:a("Cumulative principal paid over a set of periods."),args:[_c("rate (number)",a("The interest rate.")),_c("number_of_periods (number)",a("The number of payments to be made.")),_c("present_value (number)",a("The current value of the annuity.")),_c("first_period (number)",a("The number of the payment period to begin the cumulative calculation.")),_c("last_period (number)",a("The number of the payment period to end the cumulative calculation.")),_c("end_or_beginning (number, default=0)",a("Whether payments are due at the end (0) or beginning (1) of each period."))],returns:["NUMBER"],compute:function(e,t,o,s,n,i=0){const r=Vo(s,this.locale),a=Vo(n,this.locale),l=Vo(e,this.locale),c=Vo(o,this.locale),h=Vo(t,this.locale);hp(r,a,h),Qg(l),sp(c);let d=0;for(let t=r;t<=a;t++){d+=qp.compute.bind(this)(e,t,h,o,0,i)}return d},isExported:!0},Rp={description:a("Depreciation via declining balance method."),args:[_c("cost (number)",a("The initial cost of the asset.")),_c("salvage (number)",a("The value of the asset at the end of depreciation.")),_c("life (number)",a("The number of periods over which the asset is depreciated.")),_c("period (number)",a("The single period within life for which to calculate depreciation.")),_c("month (number, optional)",a("The number of months in the first year of depreciation."))],returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,t,o,s,...n){const i=Vo(e,this.locale),r=Vo(t,this.locale),l=Vo(o,this.locale),c=Math.trunc(Vo(s,this.locale)),h=n.length?Math.trunc(Vo(n[0],this.locale)):12,d=l+(12===h?0:1);ep(i),op(r),tp(c),Jg(l),Lo((()=>1<=h&&h<=12),a("The month (%s) must be between 1 and 12 inclusive.",h.toString())),Lo((()=>c<=d),a("The period (%s) must be less than or equal to %s.",c.toString(),d.toString()));const u=h/12;let g=1-Math.pow(r/i,1/l);g=Math.round(1e3*g)/1e3;let p=i,m=i*(1-g*u);for(let e=1;e<c;e++)p=m,m=p*(1-g),e===l&&(m=p*(1-g*(1-u)));return p-m},isExported:!0},Tp={description:a("Depreciation via double-declining balance method."),args:[_c("cost (number)",a("The initial cost of the asset.")),_c("salvage (number)",a("The value of the asset at the end of depreciation.")),_c("life (number)",a("The number of periods over which the asset is depreciated.")),_c("period (number)",a("The single period within life for which to calculate depreciation.")),_c("factor (number, default=2)",a("The factor by which depreciation decreases."))],returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,t,o,s,n=2){n=n||0;const i=Vo(e,this.locale),r=Vo(t,this.locale),a=Vo(o,this.locale),l=Vo(s,this.locale),c=Vo(n,this.locale);if(ep(i),op(r),tp(l),Jg(a),np(l,a),lp(c),0===i||r>=i)return 0;const h=c/a;if(h>1)return 1===s?i-r:0;if(l<=1)return i*h;const d=i*Math.pow(1-h,l-1),u=i*Math.pow(1-h,l),g=u<r?d-r:d-u;return Math.max(g,0)},isExported:!0},Ap={description:a("Discount rate of a security based on price."),args:[_c("settlement (date)",a("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),_c("maturity (date)",a("The maturity or end date of the security, when it can be redeemed at face, or par value.")),_c("price (number)",a("The price at which the security is bought per 100 face value.")),_c("redemption (number)",a("The redemption amount per 100 face value, or par.")),_c("day_count_convention (number, default=0 )",a("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,o,s,n=0){n=n||0;const i=Math.trunc(Vo(e,this.locale)),r=Math.trunc(Vo(t,this.locale)),a=Vo(o,this.locale),l=Vo(s,this.locale),c=Math.trunc(Vo(n,this.locale));Wg(i,r),Yg(c),Xg(a),jg(l);return(l-a)/l/Ig.compute.bind(this)(i,r,c)},isExported:!0},Op={description:a("Convert a decimal fraction to decimal value."),args:[_c("fractional_price (number)",a("The price quotation given using fractional decimal conventions.")),_c("unit (number)",a("The units of the fraction, e.g. 8 for 1/8ths or 32 for 1/32nds."))],returns:["NUMBER"],compute:function(e,t){const o=Vo(e,this.locale),s=Math.trunc(Vo(t,this.locale));Lo((()=>s>0),a("The unit (%s) must be strictly positive.",s.toString()));const n=Math.trunc(o);return n+(o-n)*(10**Math.ceil(Math.log10(s))/s)},isExported:!0},_p={description:a("Convert a decimal value to decimal fraction."),args:[_c("decimal_price (number)",a("The price quotation given as a decimal value.")),_c("unit (number)",a("The units of the desired fraction, e.g. 8 for 1/8ths or 32 for 1/32nds."))],returns:["NUMBER"],compute:function(e,t){const o=Vo(e,this.locale),s=Math.trunc(Vo(t,this.locale));Lo((()=>s>0),a("The unit (%s) must be strictly positive.",s.toString()));const n=Math.trunc(o);return n+(o-n)*(s/10**Math.ceil(Math.log10(s)))},isExported:!0},Mp={description:a("Number of periods for an investment to reach a value."),args:[_c("settlement (date)",a("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),_c("maturity (date)",a("The maturity or end date of the security, when it can be redeemed at face, or par value.")),_c("rate (number)",a("The annualized rate of interest.")),_c("yield (number)",a("The expected annual yield of the security.")),_c("frequency (number)",a("The number of interest or coupon payments per year (1, 2, or 4).")),_c("day_count_convention (number, default=0 )",a("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,o,s,n,i=0){i=i||0;const r=Math.trunc(Vo(e,this.locale)),l=Math.trunc(Vo(t,this.locale)),c=Vo(o,this.locale),h=Vo(s,this.locale),d=Math.trunc(Vo(n,this.locale)),u=Math.trunc(Vo(i,this.locale));Wg(r,l),Zg(d),Yg(u),Lo((()=>c>=0),a("The rate (%s) must be positive or null.",c.toString())),Lo((()=>h>=0),a("The yield (%s) must be positive or null.",h.toString()));const g=Ig.compute.bind(this)(r,l,u),p=g-Math.trunc(g)||1/d,m=Math.ceil(g*d),f=c/d,b=h/d;let v=0,S=0;for(let e=1;e<=m;e++){const t=(f+(e===m?1:0))/(1+b)**e;S+=(p+(e-1)/d)*t,v+=t}return 0===v?0:S/v},isExported:!0},Np={description:a("Annual effective interest rate."),args:[_c("nominal_rate (number)",a("The nominal interest rate per year.")),_c("periods_per_year (number)",a("The number of compounding periods per year."))],returns:["NUMBER"],compute:function(e,t){const o=Vo(e,this.locale),s=Math.trunc(Vo(t,this.locale));return Lo((()=>o>0),a("The nominal rate (%s) must be strictly greater than 0.",o.toString())),Lo((()=>s>0),a("The number of periods by year (%s) must strictly greater than 0.",s.toString())),Math.pow(1+o/s,s)-1},isExported:!0},Fp={description:a("Future value of an annuity investment."),args:[_c("rate (number)",a("The interest rate.")),_c("number_of_periods (number)",a("The number of payments to be made.")),_c("payment_amount (number)",a("The amount per period to be paid.")),_c("present_value (number, default=0)",a("The current value of the annuity.")),_c("end_or_beginning (number, default=0)",a("Whether payments are due at the end (0) or beginning (1) of each period."))],returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,t,o,s=0,n=0){s=s||0,n=n||0;const i=Vo(e,this.locale),r=Vo(t,this.locale),a=Vo(o,this.locale),l=Vo(s,this.locale),c=Zo(n)?1:0;return i?-l*(1+i)**r-a*(1+i*c)*((1+i)**r-1)/i:-(l+a*r)},isExported:!0},Dp={description:a("Future value of principal from series of rates."),args:[_c("principal (number)",a("The amount of initial capital or value to compound against.")),_c("rate_schedule (number, range<number>)",a("A series of interest rates to compound against the principal."))],returns:["NUMBER"],compute:function(e,t){return Jo([t],((e,t)=>e*(1+Vo(t,this.locale))),Vo(e,this.locale))},isExported:!0},Lp={description:a("Calculates effective interest rate."),args:[_c("settlement (date)",a("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),_c("maturity (date)",a("The maturity or end date of the security, when it can be redeemed at face, or par value.")),_c("investment (number)",a("The amount invested in the security.")),_c("redemption (number)",a("The amount to be received at maturity.")),_c("day_count_convention (number, default=0 )",a("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,o,s,n=0){const i=Math.trunc(Vo(e,this.locale)),r=Math.trunc(Vo(t,this.locale)),a=Vo(s,this.locale),l=Vo(o,this.locale);Wg(i,r),ip(l),jg(a);return(a-l)/l/Ig.compute.bind(this)(i,r,n)},isExported:!0},Pp={description:a("Payment on the principal of an investment."),args:[_c("rate (number)",a("The annualized rate of interest.")),_c("period (number)",a("The amortization period, in terms of number of periods.")),_c("number_of_periods (number)",a("The number of payments to be made.")),_c("present_value (number)",a("The current value of the annuity.")),_c("future_value (number, default=0)",a("The future value remaining after the final payment has been made.")),_c("end_or_beginning (number, default=0)",a("Whether payments are due at the end (0) or beginning (1) of each period."))],returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,t,o,s,n=0,i=0){return Wp.compute.bind(this)(e,o,s,n,i)-qp.compute.bind(this)(e,t,o,s,n,i)},isExported:!0},Vp={description:a("Internal rate of return given periodic cashflows."),args:[_c("cashflow_amounts (number, range<number>)",a("An array or range containing the income or payments associated with the investment.")),_c("rate_guess (number, default=0.1)",a("An estimate for what the internal rate of return will be."))],returns:["NUMBER"],computeFormat:()=>"0%",compute:function(e,t=.1){const o=Vo(t,this.locale);dp(o);let s=!1,n=!1,i=[];Ko([e],(e=>{e>0&&(s=!0),e<0&&(n=!0),i.push(e)}),this.locale),Lo((()=>s&&n),a("The cashflow_amounts must include negative and positive values."));const r=i.shift();return mp((function(e){return function(e,t,o){const s=o.length;let n=0;return o.reduce(((t,o)=>(n++,t+o*e**(s-n))),t*e**s)}(e,r,i)}),(function(e){return function(e,t,o){const s=o.length;let n=0;return o.reduce(((t,o)=>(n++,t+o*(s-n)*e**(s-n-1))),t*s*e**(s-1))}(e,r,i)}),o+1,20,1e-5)-1},isExported:!0},kp={description:a("Returns the interest paid at a particular period of an investment."),args:[_c("rate (number)",a("The interest rate.")),_c("period (number)",a("The period for which you want to view the interest payment.")),_c("number_of_periods (number)",a("The number of payments to be made.")),_c("present_value (number)",a("The current value of the annuity."))],returns:["NUMBER"],compute:function(e,t,o,s){const n=Vo(e,this.locale),i=Vo(t,this.locale),r=Vo(o,this.locale),l=Vo(s,this.locale);Lo((()=>0!==r),a("The number of periods must be different than 0.",r.toString()));return-1*(l-l*(i/r))*n},isExported:!0},Up={description:a("Modified Macaulay duration."),args:[_c("settlement (date)",a("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),_c("maturity (date)",a("The maturity or end date of the security, when it can be redeemed at face, or par value.")),_c("rate (number)",a("The annualized rate of interest.")),_c("yield (number)",a("The expected annual yield of the security.")),_c("frequency (number)",a("The number of interest or coupon payments per year (1, 2, or 4).")),_c("day_count_convention (number, default=0 )",a("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,o,s,n,i=0){return Mp.compute.bind(this)(e,t,o,s,n,i)/(1+Vo(s,this.locale)/Math.trunc(Vo(n,this.locale)))},isExported:!0},Bp={description:a("Modified internal rate of return."),args:[_c("cashflow_amounts (range<number>)",a("A range containing the income or payments associated with the investment. The array should contain bot payments and incomes.")),_c("financing_rate (number)",a("The interest rate paid on funds invested.")),_c("reinvestment_return_rate (number)",a("The return (as a percentage) earned on reinvestment of income received from the investment."))],returns:["NUMBER"],compute:function(e,t,o){const s=Vo(t,this.locale),n=Vo(o,this.locale),i=ns(e).flat().filter((e=>null!==e)).map((e=>Vo(e,this.locale))),r=i.length;let l=0,c=0;for(const e of Ne(0,r)){const t=i[e];t>=0?l+=t*(n+1)**(r-e-1):c+=t/(s+1)**e}Lo((()=>0!==c&&0!==l),a("There must be both positive and negative values in cashflow_amounts."));return(-l/c)**(1/(r-1))-1},isExported:!0},Hp={description:a("Annual nominal interest rate."),args:[_c("effective_rate (number)",a("The effective interest rate per year.")),_c("periods_per_year (number)",a("The number of compounding periods per year."))],returns:["NUMBER"],compute:function(e,t){const o=Vo(e,this.locale),s=Math.trunc(Vo(t,this.locale));return Lo((()=>o>0),a("The effective rate (%s) must must strictly greater than 0.",o.toString())),Lo((()=>s>0),a("The number of periods by year (%s) must strictly greater than 0.",s.toString())),(Math.pow(o+1,1/s)-1)*s},isExported:!0},zp={description:a("Number of payment periods for an investment."),args:[_c("rate (number)",a("The interest rate.")),_c("payment_amount (number)",a("The amount of each payment made.")),_c("present_value (number)",a("The current value of the annuity.")),_c("future_value (number, default=0)",a("The future value remaining after the final payment has been made.")),_c("end_or_beginning (number, default=0)",a("Whether payments are due at the end (0) or beginning (1) of each period."))],returns:["NUMBER"],compute:function(e,t,o,s=0,n=0){s=s||0,n=n||0;const i=Vo(e,this.locale),r=Vo(t,this.locale),a=Vo(o,this.locale),l=Vo(s,this.locale),c=Zo(n)?1:0;if(0===i)return-(l+a)/r;const h=r*(1+i*c)/i;return Math.log((h-l)/(a+h))/Math.log(1+i)},isExported:!0};const Gp={description:a("The net present value of an investment based on a series of periodic cash flows and a discount rate."),args:[_c("discount (number)",a("The discount rate of the investment over one period.")),_c("cashflow1 (number, range<number>)",a("The first future cash flow.")),_c("cashflow2 (number, range<number>, repeating)",a("Additional future cash flows."))],returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,...t){const o=Vo(e,this.locale);return Lo((()=>-1!==o),a("The discount (%s) must be different from -1.",o.toString())),function(e,t,o,s){let n=0;return es(o,((t,o)=>(n++,t+o/(1+e)**n)),t,s)}(o,0,t,this.locale)},isExported:!0},$p={description:a("Computes the number of periods needed for an investment to reach a value."),args:[_c("rate (number)",a("The rate at which the investment grows each period.")),_c("present_value (number)",a("The investment's current value.")),_c("future_value (number)",a("The investment's desired future value."))],returns:["NUMBER"],compute:function(e,t,o){const s=Vo(e,this.locale),n=Vo(t,this.locale),i=Vo(o,this.locale);return Qg(s),Lo((()=>n>0),a("The present_value (%s) must be strictly positive.",n.toString())),Lo((()=>i>0),a("The future_value (%s) must be strictly positive.",i.toString())),(Math.log(i)-Math.log(n))/Math.log(1+s)},isExported:!0},Wp={description:a("Periodic payment for an annuity investment."),args:[_c("rate (number)",a("The annualized rate of interest.")),_c("number_of_periods (number)",a("The number of payments to be made.")),_c("present_value (number)",a("The current value of the annuity.")),_c("future_value (number, default=0)",a("The future value remaining after the final payment has been made.")),_c("end_or_beginning (number, default=0)",a("Whether payments are due at the end (0) or beginning (1) of each period."))],returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,t,o,s=0,n=0){s=s||0,n=n||0;const i=Vo(t,this.locale),r=Vo(e,this.locale),a=Zo(n)?1:0;let l=Vo(s,this.locale),c=Vo(o,this.locale);if(Kg(i),0===r)return-(l+c)/i;let h=-(c*(1+r)**i+l);return h=h*r/((1+r*a)*((1+r)**i-1)),h},isExported:!0},qp={description:a("Payment on the principal of an investment."),args:[_c("rate (number)",a("The annualized rate of interest.")),_c("period (number)",a("The amortization period, in terms of number of periods.")),_c("number_of_periods (number)",a("The number of payments to be made.")),_c("present_value (number)",a("The current value of the annuity.")),_c("future_value (number, default=0)",a("The future value remaining after the final payment has been made.")),_c("end_or_beginning (number, default=0)",a("Whether payments are due at the end (0) or beginning (1) of each period."))],returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,t,o,s,n=0,i=0){n=n||0,i=i||0;const r=Vo(o,this.locale),l=Vo(e,this.locale),c=Vo(t,this.locale),h=Zo(i)?1:0,d=Vo(n,this.locale),u=Vo(s,this.locale);Kg(r),Lo((()=>c>0&&c<=r),a("The period must be between 1 and number_of_periods",r.toString()));const g=Wp.compute.bind(this)(l,r,u,d,i);if(1===h&&1===c)return g;const p=0===h?c-1:c-2,m=u+g*h;return g+-Fp.compute.bind(this)(l,p,g,m,0)*l},isExported:!0},Zp={description:a("Present value of an annuity investment."),args:[_c("rate (number)",a("The interest rate.")),_c("number_of_periods (number)",a("The number of payments to be made.")),_c("payment_amount (number)",a("The amount per period to be paid.")),_c("future_value (number, default=0)",a("The future value remaining after the final payment has been made.")),_c("end_or_beginning (number, default=0)",a("Whether payments are due at the end (0) or beginning (1) of each period."))],returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,t,o,s=0,n=0){s=s||0,n=n||0;const i=Vo(e,this.locale),r=Vo(t,this.locale),a=Vo(o,this.locale),l=Vo(s,this.locale),c=Zo(n)?1:0;return i?-(a*(1+i*c)*((1+i)**r-1)/i+l)/(1+i)**r:-(l+a*r)},isExported:!0},Yp={description:a("Price of a security paying periodic interest."),args:[_c("settlement (date)",a("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),_c("maturity (date)",a("The maturity or end date of the security, when it can be redeemed at face, or par value.")),_c("rate (number)",a("The annualized rate of interest.")),_c("yield (number)",a("The expected annual yield of the security.")),_c("redemption (number)",a("The redemption amount per 100 face value, or par.")),_c("frequency (number)",a("The number of interest or coupon payments per year (1, 2, or 4).")),_c("day_count_convention (number, default=0 )",a("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,o,s,n,i,r=0){r=r||0;const l=Math.trunc(Vo(e,this.locale)),c=Math.trunc(Vo(t,this.locale)),h=Vo(o,this.locale),d=Vo(s,this.locale),u=Vo(n,this.locale),g=Math.trunc(Vo(i,this.locale)),p=Math.trunc(Vo(r,this.locale));Wg(l,c),Zg(g),Yg(p),Lo((()=>h>=0),a("The rate (%s) must be positive or null.",h.toString())),Lo((()=>d>=0),a("The yield (%s) must be positive or null.",d.toString())),jg(u);const m=Ig.compute.bind(this)(l,c,p)*g,f=Math.ceil(m),b=m-Math.floor(m)||1,v=1+d/g,S=100*h/g;if(1===f)return(S+u)/(b*d/g+1)-S*(1-b);let C=0;for(let e=1;e<=f;e++)C+=S/v**(e-1+b);return u/v**(f-1+b)+C-S*(1-b)},isExported:!0},jp={description:a("Price of a discount security."),args:[_c("settlement (date)",a("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),_c("maturity (date)",a("The maturity or end date of the security, when it can be redeemed at face, or par value.")),_c("discount (number)",a("The discount rate of the security at time of purchase.")),_c("redemption (number)",a("The redemption amount per 100 face value, or par.")),_c("day_count_convention (number, default=0 )",a("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,o,s,n=0){n=n||0;const i=Math.trunc(Vo(e,this.locale)),r=Math.trunc(Vo(t,this.locale)),a=Vo(o,this.locale),l=Vo(s,this.locale),c=Math.trunc(Vo(n,this.locale));Wg(i,r),Yg(c),rp(a),jg(l);return l-a*l*Ig.compute.bind(this)(i,r,c)},isExported:!0},Xp={description:a("Calculates the price of a security paying interest at maturity, based on expected yield."),args:[_c("settlement (date)",a("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),_c("maturity (date)",a("The maturity or end date of the security, when it can be redeemed at face, or par value.")),_c("issue (date)",a("The date the security was initially issued.")),_c("rate (number)",a("The annualized rate of interest.")),_c("yield (number)",a("The expected annual yield of the security.")),_c("day_count_convention (number, default=0 )",a("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,o,s,n,i=0){i=i||0;const r=Math.trunc(Vo(e,this.locale)),l=Math.trunc(Vo(t,this.locale)),c=Math.trunc(Vo(o,this.locale)),h=Vo(s,this.locale),d=Vo(n,this.locale),u=Math.trunc(Vo(i,this.locale));qg(r,c),Wg(r,l),Yg(u),Lo((()=>h>=0),a("The rate (%s) must be positive or null.",h.toString())),Lo((()=>d>=0),a("The yield (%s) must be positive or null.",d.toString()));const g=Ig.compute.bind(this)(r,l,u),p=Ig.compute.bind(this)(r,c,u);return(100+Ig.compute.bind(this)(c,l,u)*h*100)/(1+g*d)-p*h*100},isExported:!0},Kp=.1,Qp={description:a("Interest rate of an annuity investment."),args:[_c("number_of_periods (number)",a("The number of payments to be made.")),_c("payment_per_period (number)",a("The amount per period to be paid.")),_c("present_value (number)",a("The current value of the annuity.")),_c("future_value (number, default=0)",a("The future value remaining after the final payment has been made.")),_c("end_or_beginning (number, default=0)",a("Whether payments are due at the end (0) or beginning (1) of each period.")),_c("rate_guess (number, default=0.1)",a("An estimate for what the interest rate will be."))],returns:["NUMBER"],computeFormat:()=>"0%",compute:function(e,t,o,s=0,n=0,i=.1){s=s||0,n=n||0,i=i||Kp;const r=Vo(e,this.locale),l=Vo(t,this.locale),c=Zo(n)?1:0,h=Vo(i,this.locale);let d=Vo(s,this.locale),u=Vo(o,this.locale);Kg(r),Lo((()=>[l,u,d].some((e=>e>0))&&[l,u,d].some((e=>e<0))),a("There must be both positive and negative values in [payment_amount, present_value, future_value].",r.toString())),dp(h),d-=l*c,u+=l*c;return mp((e=>{const t=Math.pow(1+e,r);return d+u*t+l*((t-1)/e)}),(e=>{const t=Math.pow(1+e,r-1),o=Math.pow(1+e,r);return u*r*t+l*(r*t/e-(o-1)/e/e)}),h,40,1e-5)},isExported:!0},Jp={description:a("Amount received at maturity for a security."),args:[_c("settlement (date)",a("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),_c("maturity (date)",a("The maturity or end date of the security, when it can be redeemed at face, or par value.")),_c("investment (number)",a("The amount invested (irrespective of face value of each security).")),_c("discount (number)",a("The discount rate of the security invested in.")),_c("day_count_convention (number, default=0 )",a("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,o,s,n=0){n=n||0;const i=Math.trunc(Vo(e,this.locale)),r=Math.trunc(Vo(t,this.locale)),a=Vo(o,this.locale),l=Vo(s,this.locale),c=Math.trunc(Vo(n,this.locale));Wg(i,r),Yg(c),ip(a),rp(l);return a/(1-l*Ig.compute.bind(this)(i,r,c))},isExported:!0},em={description:a("Computes the rate needed for an investment to reach a specific value within a specific number of periods."),args:[_c("number_of_periods (number)",a("The number of periods.")),_c("present_value (number)",a("The present value of the investment.")),_c("future_value (number)",a("The future value of the investment."))],returns:["NUMBER"],compute:function(e,t,o){const s=Vo(e,this.locale),n=Vo(t,this.locale),i=Vo(o,this.locale);return Kg(s),(i/n)**(1/s)-1},isExported:!0},tm={description:a("Depreciation of an asset using the straight-line method."),args:[_c("cost (number)",a("The initial cost of the asset.")),_c("salvage (number)",a("The value of the asset at the end of depreciation.")),_c("life (number)",a("The number of periods over which the asset is depreciated."))],returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,t,o){return(Vo(e,this.locale)-Vo(t,this.locale))/Vo(o,this.locale)},isExported:!0},om={description:a("Depreciation via sum of years digit method."),args:[_c("cost (number)",a("The initial cost of the asset.")),_c("salvage (number)",a("The value of the asset at the end of depreciation.")),_c("life (number)",a("The number of periods over which the asset is depreciated.")),_c("period (number)",a("The single period within life for which to calculate depreciation."))],returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,t,o,s){const n=Vo(e,this.locale),i=Vo(t,this.locale),r=Vo(o,this.locale),a=Vo(s,this.locale);tp(a),Jg(r),np(a,r);return(r-a+1)/(r*(r+1)/2)*(n-i)},isExported:!0},sm={description:a("Price of a US Treasury bill."),args:[_c("settlement (date)",a("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),_c("maturity (date)",a("The maturity or end date of the security, when it can be redeemed at face, or par value.")),_c("discount (number)",a("The discount rate of the bill at time of purchase."))],returns:["NUMBER"],compute:function(e,t,o){const s=Math.trunc(Vo(e,this.locale)),n=Math.trunc(Vo(t,this.locale)),i=Vo(o,this.locale);Wg(s,n),cp(s,n,this.locale),rp(i),ap(i);return 100*(1-i*Ig.compute.bind(this)(s,n,2))},isExported:!0},nm={description:a("Equivalent rate of return for a US Treasury bill."),args:[_c("settlement (date)",a("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),_c("maturity (date)",a("The maturity or end date of the security, when it can be redeemed at face, or par value.")),_c("discount (number)",a("The discount rate of the bill at time of purchase."))],returns:["NUMBER"],compute:function(e,t,o){const s=Math.trunc(Vo(e,this.locale)),n=Math.trunc(Vo(t,this.locale)),i=Vo(o,this.locale);Wg(s,n),cp(s,n,this.locale),rp(i),ap(i);const r=ng.compute.bind(this)(n,s);if(r<=182)return 365*i/(360-i*r);const a=sm.compute.bind(this)(s,n,i)/100,l=r/(366===r?366:365);return(-2*l+2*Math.sqrt(l**2-(2*l-1)*(1-1/a)))/(2*l-1)},isExported:!0},im={description:a("The yield of a US Treasury bill based on price."),args:[_c("settlement (date)",a("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),_c("maturity (date)",a("The maturity or end date of the security, when it can be redeemed at face, or par value.")),_c("price (number)",a("The price at which the security is bought per 100 face value."))],returns:["NUMBER"],compute:function(e,t,o){const s=Math.trunc(Vo(e,this.locale)),n=Math.trunc(Vo(t,this.locale)),i=Vo(o,this.locale);Wg(s,n),cp(s,n,this.locale),Xg(i);return(100-i)/i*(1/Ig.compute.bind(this)(s,n,2))},isExported:!0},rm={description:a("Variable declining balance. WARNING : does not handle decimal periods."),args:[_c("cost (number)",a("The initial cost of the asset.")),_c("salvage (number)",a("The value of the asset at the end of depreciation.")),_c("life (number)",a("The number of periods over which the asset is depreciated.")),_c("start (number)",a("Starting period to calculate depreciation.")),_c("end (number)",a("Ending period to calculate depreciation.")),_c("factor (number, default=2)",a("The number of months in the first year of depreciation.")),_c("no_switch (number, default=false)",a("Whether to switch to straight-line depreciation when the depreciation is greater than the declining balance calculation."))],returns:["NUMBER"],compute:function(e,t,o,s,n,i=2,r=false){i=i||0;const l=Vo(e,this.locale),c=Vo(t,this.locale),h=Vo(o,this.locale),d=Math.trunc(Vo(s,this.locale)),u=Math.trunc(Vo(n,this.locale)),g=Vo(i,this.locale),p=Zo(r);if(ep(l),op(c),function(e,t,o){Jg(o),Lo((()=>e>=0),a("The start_period (%s) must be greater or equal than 0.",e.toString())),Lo((()=>t>=0),a("The end_period (%s) must be greater or equal than 0.",t.toString())),Lo((()=>e<=t),a("The start_period (%s) must be smaller or equal to the end_period (%s).",e.toString(),t.toString())),Lo((()=>t<=o),a("The end_period (%s) must be smaller or equal to the life (%s).",e.toString(),o.toString()))}(d,u,h),lp(g),0===l)return 0;if(c>=l)return d<1?l-c:0;const m=g/h;if(m>=1)return d<1?l-c:0;let f=l,b=0,v=0,S=!1;for(let e=0;e<u;e++){if(!S||p){const t=f*m,o=(f-c)/(h-e);!p&&o>t?(S=!0,b=o):b=t}const t=Math.max(f-b,c);e>=d&&(v+=f-t),f=t}return v},isExported:!0},am={description:a("Internal rate of return given non-periodic cash flows."),args:[_c("cashflow_amounts (range<number>)",a("An range containing the income or payments associated with the investment.")),_c("cashflow_dates (range<number>)",a("An range with dates corresponding to the cash flows in cashflow_amounts.")),_c("rate_guess (number, default=0.1)",a("An estimate for what the internal rate of return will be."))],returns:["NUMBER"],compute:function(e,t,o=.1){const s=Vo(o=o||0,this.locale),n=e.flat().map((e=>Vo(e,this.locale))),i=t.flat().map((e=>Vo(e,this.locale)));var r;up(e,t),r=n,Lo((()=>r.some((e=>e>0))&&r.some((e=>e<0))),a("There must be both positive and negative values in cashflow_amounts.")),gp(i),dp(s);const l=new Map;for(const e of Ne(0,i.length)){const t=i[e];l.has(t)?l.set(t,l.get(t)+n[e]):l.set(t,n[e])}const c=Array.from(l.keys()),h=c.map((e=>l.get(e)));return mp((e=>{let t=h[0];for(const o of Ne(1,h.length)){const s=(c[0]-c[o])/365;t+=h[o]*(1+e)**s}return t}),(e=>{let t=0;for(const o of Ne(1,h.length)){const s=(c[0]-c[o])/365;t+=s*h[o]*(1+e)**(s-1)}return t}),s,40,1e-5,(e=>e?e/10-.9:-.9))},isExported:!0},lm={description:a("Net present value given to non-periodic cash flows.."),args:[_c("discount (number)",a("The discount rate of the investment over one period.")),_c("cashflow_amounts (number, range<number>)",a("An range containing the income or payments associated with the investment.")),_c("cashflow_dates (number, range<number>)",a("An range with dates corresponding to the cash flows in cashflow_amounts."))],returns:["NUMBER"],compute:function(e,t,o){const s=Vo(e,this.locale),n=Mo(t)?t.flat().map((e=>Bo(e,this.locale))):[Bo(t,this.locale)],i=Mo(o)?o.flat().map((e=>Bo(e,this.locale))):[Bo(o,this.locale)];if(Mo(o)&&Mo(t)?up(t,o):Lo((()=>n.length===i.length),a("There must be the same number of values in cashflow_amounts and cashflow_dates.")),gp(i),Qg(s),1===n.length)return n[0];const r=new Map;for(const e of Ne(0,i.length)){const t=i[e];r.has(t)?r.set(t,r.get(t)+n[e]):r.set(t,n[e])}const l=Array.from(r.keys()),c=l.map((e=>r.get(e)));let h=c[0];for(const e of Ne(1,c.length)){const t=(l[0]-l[e])/365;h+=c[e]*(1+s)**t}return h},isExported:!0},cm={description:a("Annual yield of a security paying periodic interest."),args:[_c("settlement (date)",a("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),_c("maturity (date)",a("The maturity or end date of the security, when it can be redeemed at face, or par value.")),_c("rate (number)",a("The annualized rate of interest.")),_c("price (number)",a("The price at which the security is bought per 100 face value.")),_c("redemption (number)",a("The redemption amount per 100 face value, or par.")),_c("frequency (number)",a("The number of interest or coupon payments per year (1, 2, or 4).")),_c("day_count_convention (number, default=0 )",a("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,o,s,n,i,r=0){r=r||0;const l=Math.trunc(Vo(e,this.locale)),c=Math.trunc(Vo(t,this.locale)),h=Vo(o,this.locale),d=Vo(s,this.locale),u=Vo(n,this.locale),g=Math.trunc(Vo(i,this.locale)),p=Math.trunc(Vo(r,this.locale));Wg(l,c),Zg(g),Yg(p),Lo((()=>h>=0),a("The rate (%s) must be positive or null.",h.toString())),Xg(d),jg(u);const m=Ig.compute.bind(this)(l,c,p)*g,f=Math.ceil(m),b=m-Math.floor(m)||1,v=100*h/g;if(1===f){const e=d+v*(1-b);return(u+v-e)*g*(1/b)/e}const S=mp((function(e){return function(e,t,o,s,n,i){let r=i-(e+n*(1-t))*s**(o-1+t);for(let e=1;e<=o;e++)r+=n*s**(e-1);return r}(d,b,f,e,v,u)}),(function(e){return function(e,t,o,s,n){let i=-(e+n*(1-t))*(o-1+t)*s**(o-2+t);for(let e=1;e<=o;e++)i+=n*(e-1)*s**(e-2);return i}(d,b,f,e,v)}),1+(h+1)/g,100,1e-5);return(S-1)*g},isExported:!0},hm={description:a("Annual yield of a discount security."),args:[_c("settlement (date)",a("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),_c("maturity (date)",a("The maturity or end date of the security, when it can be redeemed at face, or par value.")),_c("price (number)",a("The price at which the security is bought per 100 face value.")),_c("redemption (number)",a("The redemption amount per 100 face value, or par.")),_c("day_count_convention (number, default=0 )",a("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,o,s,n=0){n=n||0;const i=Math.trunc(Vo(e,this.locale)),r=Math.trunc(Vo(t,this.locale)),a=Vo(o,this.locale),l=Vo(s,this.locale),c=Math.trunc(Vo(n,this.locale));Wg(i,r),Yg(c),Xg(a),jg(l);return(l/a-1)/Ig.compute.bind(this)(e,t,n)},isExported:!0},dm={description:a("Annual yield of a security paying interest at maturity."),args:[_c("settlement (date)",a("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),_c("maturity (date)",a("The maturity or end date of the security, when it can be redeemed at face, or par value.")),_c("issue (date)",a("The date the security was initially issued.")),_c("rate (number)",a("The annualized rate of interest.")),_c("price (number)",a("The price at which the security is bought.")),_c("day_count_convention (number, default=0 )",a("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,o,s,n,i=0){i=i||0;const r=Math.trunc(Vo(e,this.locale)),l=Math.trunc(Vo(t,this.locale)),c=Math.trunc(Vo(o,this.locale)),h=Vo(s,this.locale),d=Vo(n,this.locale),u=Math.trunc(Vo(i,this.locale));Wg(r,l),Yg(u),Lo((()=>r>=c),a("The settlement (%s) must be greater than or equal to the issue (%s).",r.toString(),c.toString())),Lo((()=>h>=0),a("The rate (%s) must be positive or null.",h.toString())),Xg(d);const g=Ig.compute.bind(this)(c,l,u),p=Ig.compute.bind(this)(c,r,u),m=Ig.compute.bind(this)(r,l,u);return(100*(1+h*g)/(d+100*h*p)-1)/m},isExported:!0};var um=Object.freeze({__proto__:null,ACCRINTM:fp,AMORLINC:bp,COUPDAYBS:Sp,COUPDAYS:vp,COUPDAYSNC:Cp,COUPNCD:Ep,COUPNUM:yp,COUPPCD:wp,CUMIPMT:xp,CUMPRINC:Ip,DB:Rp,DDB:Tp,DISC:Ap,DOLLARDE:Op,DOLLARFR:_p,DURATION:Mp,EFFECT:Np,FV:Fp,FVSCHEDULE:Dp,INTRATE:Lp,IPMT:Pp,IRR:Vp,ISPMT:kp,MDURATION:Up,MIRR:Bp,NOMINAL:Hp,NPER:zp,NPV:Gp,PDURATION:$p,PMT:Wp,PPMT:qp,PRICE:Yp,PRICEDISC:jp,PRICEMAT:Xp,PV:Zp,RATE:Qp,RECEIVED:Jp,RRI:em,SLN:tm,SYD:om,TBILLEQ:nm,TBILLPRICE:sm,TBILLYIELD:im,VDB:rm,XIRR:am,XNPV:lm,YIELD:cm,YIELDDISC:hm,YIELDMAT:dm});const gm={description:a("Whether a value is an error other than #N/A."),args:[_c("value (any, lazy)",a("The value to be verified as an error type."))],returns:["BOOLEAN"],compute:function(e){try{return e(),!1}catch(e){return e?.errorType!=c.NotAvailable}},isExported:!0},pm={description:a("Whether a value is an error."),args:[_c("value (any, lazy)",a("The value to be verified as an error type."))],returns:["BOOLEAN"],compute:function(e){try{return e(),!1}catch(e){return!0}},isExported:!0},mm={description:a("Whether a value is `true` or `false`."),args:[_c("value (any, lazy)",a("The value to be verified as a logical TRUE or FALSE."))],returns:["BOOLEAN"],compute:function(e){try{return"boolean"==typeof e()}catch(e){return!1}},isExported:!0},fm={description:a("Whether a value is the error #N/A."),args:[_c("value (any, lazy)",a("The value to be verified as an error type."))],returns:["BOOLEAN"],compute:function(e){try{return e(),!1}catch(e){return e?.errorType===c.NotAvailable}},isExported:!0},bm={description:a("Whether a value is non-textual."),args:[_c("value (any, lazy)",a("The value to be checked."))],returns:["BOOLEAN"],compute:function(e){try{return"string"!=typeof e()}catch(e){return!0}},isExported:!0},vm={description:a("Whether a value is a number."),args:[_c("value (any, lazy)",a("The value to be verified as a number."))],returns:["BOOLEAN"],compute:function(e){try{return"number"==typeof e()}catch(e){return!1}},isExported:!0},Sm={description:a("Whether a value is text."),args:[_c("value (any, lazy)",a("The value to be verified as text."))],returns:["BOOLEAN"],compute:function(e){try{return"string"==typeof e()}catch(e){return!1}},isExported:!0},Cm={description:a("Whether the referenced cell is empty"),args:[_c("value (any, lazy)",a("Reference to the cell that will be checked for emptiness."))],returns:["BOOLEAN"],compute:function(e){try{return null===e()}catch(e){return!1}},isExported:!0},Em={description:a("Returns the error value #N/A."),args:[],returns:["BOOLEAN"],compute:function(e){throw new m},isExported:!0};var ym=Object.freeze({__proto__:null,ISBLANK:Cm,ISERR:gm,ISERROR:pm,ISLOGICAL:mm,ISNA:fm,ISNONTEXT:bm,ISNUMBER:vm,ISTEXT:Sm,NA:Em});const wm={description:a("Logical `and` operator."),args:[_c("logical_expression1 (boolean, range<boolean>)",a("An expression or reference to a cell containing an expression that represents some logical value, i.e. TRUE or FALSE, or an expression that can be coerced to a logical value.")),_c("logical_expression2 (boolean, range<boolean>, repeating)",a("More expressions that represent logical values."))],returns:["BOOLEAN"],compute:function(...e){let t=!1,o=!0;return is(e,(e=>(t=!0,o=o&&e,o))),Lo((()=>t),a("[[FUNCTION_NAME]] has no valid input data.")),o},isExported:!0},xm={description:a("Logical value `false`."),args:[],returns:["BOOLEAN"],compute:function(){return!1},isExported:!0},Im={description:a("Returns value depending on logical expression."),args:[_c("logical_expression (boolean)",a("An expression or reference to a cell containing an expression that represents some logical value, i.e. TRUE or FALSE.")),_c("value_if_true (any, lazy)",a("The value the function returns if logical_expression is TRUE.")),_c("value_if_false (any, lazy, default=FALSE)",a("The value the function returns if logical_expression is FALSE."))],returns:["ANY"],computeValueAndFormat:function(e,t,o=(()=>({value:!1}))){const s=Zo(e?.value)?t():o();return void 0===s?{value:""}:(null===s.value&&(s.value=""),s)},isExported:!0},Rm={description:a("Value if it is not an error, otherwise 2nd argument."),args:[_c("value (any, lazy)",a("The value to return if value itself is not an error.")),_c('value_if_error (any, lazy, default="empty")',a("The value the function returns if value is an error."))],returns:["ANY"],computeValueAndFormat:function(e,t=(()=>({value:""}))){let o;try{o=e()}catch(e){o=t()}return void 0===o?{value:""}:(null===o.value&&(o.value=""),o)},isExported:!0},Tm={description:a("Value if it is not an #N/A error, otherwise 2nd argument."),args:[_c("value (any, lazy)",a("The value to return if value itself is not #N/A an error.")),_c('value_if_error (any, lazy, default="empty")',a("The value the function returns if value is an #N/A error."))],returns:["ANY"],computeValueAndFormat:function(e,t=(()=>({value:""}))){let o;try{o=e()}catch(s){o=s.errorType===c.NotAvailable?t():e()}return void 0===o?{value:""}:(null===o.value&&(o.value=""),o)},isExported:!0},Am={description:a("Returns a value depending on multiple logical expressions."),args:[_c("condition1 (boolean, lazy)",a("The first condition to be evaluated. This can be a boolean, a number, an array, or a reference to any of those.")),_c("value1 (any, lazy)",a("The returned value if condition1 is TRUE.")),_c("condition2 (boolean, lazy, repeating)",a("Additional conditions to be evaluated if the previous ones are FALSE.")),_c("value2 (any, lazy, repeating)",a("Additional values to be returned if their corresponding conditions are TRUE."))],returns:["ANY"],computeValueAndFormat:function(...e){Lo((()=>e.length%2==0),a("Wrong number of arguments. Expected an even number of arguments."));for(let t=0;t<e.length-1;t+=2)if(Zo(e[t]()?.value)){const o=e[t+1]();return void 0===o?{value:""}:(null===o.value&&(o.value=""),o)}throw new Error(a("No match."))},isExported:!0},Om={description:a("Returns opposite of provided logical value."),args:[_c("logical_expression (boolean)",a("An expression or reference to a cell holding an expression that represents some logical value."))],returns:["BOOLEAN"],compute:function(e){return!Zo(e)},isExported:!0},_m={description:a("Logical `or` operator."),args:[_c("logical_expression1 (boolean, range<boolean>)",a("An expression or reference to a cell containing an expression that represents some logical value, i.e. TRUE or FALSE, or an expression that can be coerced to a logical value.")),_c("logical_expression2 (boolean, range<boolean>, repeating)",a("More expressions that evaluate to logical values."))],returns:["BOOLEAN"],compute:function(...e){let t=!1,o=!1;return is(e,(e=>(t=!0,o=o||e,!o))),Lo((()=>t),a("[[FUNCTION_NAME]] has no valid input data.")),o},isExported:!0},Mm={description:a("Logical value `true`."),args:[],returns:["BOOLEAN"],compute:function(){return!0},isExported:!0},Nm={description:a("Logical `xor` operator."),args:[_c("logical_expression1 (boolean, range<boolean>)",a("An expression or reference to a cell containing an expression that represents some logical value, i.e. TRUE or FALSE, or an expression that can be coerced to a logical value.")),_c("logical_expression2 (boolean, range<boolean>, repeating)",a("More expressions that evaluate to logical values."))],returns:["BOOLEAN"],compute:function(...e){let t=!1,o=!1;return is(e,(e=>(t=!0,o=o?!e:e,!0))),Lo((()=>t),a("[[FUNCTION_NAME]] has no valid input data.")),o},isExported:!0};var Fm=Object.freeze({__proto__:null,AND:wm,FALSE:xm,IF:Im,IFERROR:Rm,IFNA:Tm,IFS:Am,NOT:Om,OR:_m,TRUE:Mm,XOR:Nm});const Dm=!0;function Lm(e,t){if(void 0===e)throw new m(a("Did not find value '%s' in [[FUNCTION_NAME]] evaluation.",$o(t)))}const Pm={description:a("Returns a cell reference as a string. "),args:[_c("row (number)",a("The row number of the cell reference. ")),_c("column (number)",a("The column number (not name) of the cell reference. A is column number 1. ")),_c("absolute_relative_mode (number, default=1)",a("An indicator of whether the reference is row/column absolute. 1 is row and column absolute (e.g. $A$1), 2 is row absolute and column relative (e.g. A$1), 3 is row relative and column absolute (e.g. $A1), and 4 is row and column relative (e.g. A1).")),_c("use_a1_notation (boolean, default=TRUE)",a("A boolean indicating whether to use A1 style notation (TRUE) or R1C1 style notation (FALSE).")),_c("sheet (string, optional)",a("A string indicating the name of the sheet into which the address points."))],returns:["STRING"],compute:function(e,t,o=1,s=!0,n){const i=zo(e,this.locale),r=zo(t,this.locale);Go(i),Go(r);const l=zo(o,this.locale);var c,h;Lo((()=>[1,2,3,4].includes(l)),(c=4,h=l,a("The function [[FUNCTION_NAME]] expects a number value between %s and %s inclusive, but receives %s.",1..toString(),c.toString(),h.toString())));let d;if(Zo(s)){d=Lt(r-1,i-1,{rowFixed:!![1,2].includes(l),colFixed:!![1,3].includes(l)})}else{d=([1,2].includes(l)?`R${i}`:`R[${i}]`)+([1,3].includes(l)?`C${r}`:`C[${r}]`)}return void 0!==n?`${_e($o(n))}!${d}`:d},isExported:!0},Vm={description:a("Column number of a specified cell."),args:[_c("cell_reference (meta, default='this cell')",a("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."))],returns:["NUMBER"],compute:function(e){const t=e||this.__originCellXC?.();Lo((()=>!!t),"In this context, the function [[FUNCTION_NAME]] needs to have a cell or range in parameter.");return gn(t).left+1},isExported:!0},km={description:a("Number of columns in a specified array or range."),args:[_c("range (meta)",a("The range whose column count will be returned."))],returns:["NUMBER"],compute:function(e){const t=gn(e);return t.right-t.left+1},isExported:!0},Um={description:a("Horizontal lookup"),args:[_c("search_key (any)",a("The value to search for. For example, 42, 'Cats', or I24.")),_c("range (any, range)",a("The range to consider for the search. The first row in the range is searched for the key specified in search_key.")),_c("index (number)",a("The row index of the value to be returned, where the first row in range is numbered 1.")),_c("is_sorted (boolean, default=true)",a("Indicates whether the row to be searched (the first row of the specified range) is sorted, in which case the closest match for search_key will be returned."))],returns:["ANY"],computeValueAndFormat:function(e,t,o,s={value:Dm}){const n=Math.trunc(Vo(o?.value,this.locale)),i=gs(t);Lo((()=>1<=n&&n<=i[0].length),a("[[FUNCTION_NAME]] evaluates to an out of bounds range."));const r=(e,t)=>e[t][0].value,l=Zo(s.value)?cs(i,e?.value,"nextSmaller","asc",i.length,r):hs(i,e?.value,"strict",i.length,r),c=i[l];return Lm(c,e?.value),c[n-1]},isExported:!0},Bm={description:a("Returns the content of a cell, specified by row and column offset."),args:[_c("reference (any, range)",a("The range of cells from which the values are returned.")),_c("row (number, default=0)",a("The index of the row to be returned from within the reference range of cells.")),_c("column (number, default=0)",a("The index of the column to be returned from within the reference range of cells."))],returns:["ANY"],computeValueAndFormat:function(e,t={value:0},o={value:0}){const s=Mo(e)?e:[[e]],n=Vo(t.value,this.locale),i=Vo(o.value,this.locale);return Lo((()=>i>=0&&i-1<s.length&&n>=0&&n-1<s[0].length),a("Index out of range.")),0===n&&0===i?s:0===n?[s[i-1]]:0===i?s.map((e=>[e[n-1]])):s[i-1][n-1]},isExported:!0},Hm={description:a("Look up a value."),args:[_c("search_key (any)",a("The value to search for. For example, 42, 'Cats', or I24.")),_c("search_array (any, range)",a("One method of using this function is to provide a single sorted row or column search_array to look through for the search_key with a second argument result_range. The other way is to combine these two arguments into one search_array where the first row or column is searched and a value is returned from the last row or column in the array. If search_key is not found, a non-exact match may be returned.")),_c("result_range (any, range, optional)",a("The range from which to return a result. The value returned corresponds to the location where search_key is found in search_range. This range must be only a single row or column and should not be used if using the search_result_array method."))],returns:["ANY"],computeValueAndFormat:function(e,t,o){const s=gs(t),n=gs(o);let i=s.length,r=s[0].length;const l=r>=i,c=l?(e,t)=>e[0][t].value:(e,t)=>e[t][0].value,h=l?r:i,d=cs(s,e?.value,"nextSmaller","asc",h,c);return-1===d&&Lm(void 0,e?.value),Lm(l?s[0][d]:s[d][r-1],e?.value),0===n[0].length?l?s[i-1][d]:s[d][r-1]:(i=n.length,r=n[0].length,Lo((()=>1===i||1===r),a("The result_range must be a single row or a single column.")),i>1?(Lo((()=>d<=i-1),a("[[FUNCTION_NAME]] evaluates to an out of range row value %s.",(d+1).toString())),n[d][0]):(Lo((()=>d<=r-1),a("[[FUNCTION_NAME]] evaluates to an out of range column value %s.",(d+1).toString())),n[0][d]))},isExported:!0},zm={description:a("Position of item in range that matches value."),args:[_c("search_key (any)",a("The value to search for. For example, 42, 'Cats', or I24.")),_c("range (any, range)",a("The one-dimensional array to be searched.")),_c("search_type (number, default=1)",a("The search method. 1 (default) finds the largest value less than or equal to search_key when range is sorted in ascending order. 0 finds the exact value when range is unsorted. -1 finds the smallest value greater than or equal to search_key when range is sorted in descending order."))],returns:["NUMBER"],compute:function(e,t,o=1){let s=Vo(o,this.locale);const n=gs(t),i=n.length,r=n[0].length;Lo((()=>1===i||1===r),a("The range must be a single row or a single column."));let l=-1;const c=1===i?(e,t)=>e[0][t]:(e,t)=>e[t][0],h=1===i?n[0].length:n.length;switch(s=Math.sign(s),s){case 1:l=cs(n,e,"nextSmaller","asc",h,c);break;case 0:l=hs(n,e,"strict",h,c);break;case-1:l=cs(n,e,"nextGreater","desc",h,c)}return Lm(1===i?n[0][l]:n[l],e),l+1},isExported:!0},Gm={description:a("Row number of a specified cell."),args:[_c("cell_reference (meta, default='this cell')",a("The cell whose row number will be returned. By default, this function uses the cell in which the formula is entered."))],returns:["NUMBER"],compute:function(e){e=e||this.__originCellXC?.(),Lo((()=>!!e),"In this context, the function [[FUNCTION_NAME]] needs to have a cell or range in parameter.");return gn(e).top+1},isExported:!0},$m={description:a("Number of rows in a specified array or range."),args:[_c("range (meta)",a("The range whose row count will be returned."))],returns:["NUMBER"],compute:function(e){const t=gn(e);return t.bottom-t.top+1},isExported:!0},Wm={description:a("Vertical lookup."),args:[_c("search_key (any)",a("The value to search for. For example, 42, 'Cats', or I24.")),_c("range (any, range)",a("The range to consider for the search. The first column in the range is searched for the key specified in search_key.")),_c("index (number)",a("The column index of the value to be returned, where the first column in range is numbered 1.")),_c("is_sorted (boolean, default=true)",a("Indicates whether the column to be searched (the first column of the specified range) is sorted, in which case the closest match for search_key will be returned."))],returns:["ANY"],computeValueAndFormat:function(e,t,o,s={value:Dm}){const n=Math.trunc(Vo(o?.value,this.locale)),i=gs(t);Lo((()=>1<=n&&n<=i.length),a("[[FUNCTION_NAME]] evaluates to an out of bounds range."));const r=(e,t)=>e[0][t].value,l=Zo(s.value)?cs(i,e?.value,"nextSmaller","asc",i[0].length,r):hs(i,e?.value,"strict",i[0].length,r),c=i[n-1][l];return Lm(c,e?.value),c},isExported:!0},qm={description:a("Search a range for a match and return the corresponding item from a second range."),args:[_c("search_key (any)",a("The value to search for.")),_c("lookup_range (any, range)",a("The range to consider for the search. Should be a single column or a single row.")),_c("return_range (any, range)",a("The range containing the return value. Should have the same dimensions as lookup_range.")),_c("if_not_found (any, lazy, optional)",a("If a valid match is not found, return this value.")),_c("match_mode (any, default=0)",a("(0) Exact match. (-1) Return next smaller item if no match. (1) Return next greater item if no match.")),_c("search_mode (any, default=1)",a("(1) Search starting at first item. (-1) Search starting at last item. (2) Perform a binary search that relies on lookup_array being sorted in ascending order. If not sorted, invalid results will be returned. (-2) Perform a binary search that relies on lookup_array being sorted in descending order. If not sorted, invalid results will be returned. "))],returns:["ANY"],computeValueAndFormat:function(e,t,o,s,n={value:0},i={value:1}){const r=Math.trunc(Vo(n.value,this.locale)),l=Math.trunc(Vo(i.value,this.locale)),c=gs(t),h=gs(o);Lo((()=>1===c.length||1===c[0].length),a("lookup_range should be either a single row or single column.")),Lo((()=>[-1,1,-2,2].includes(l)),a("searchMode should be a value in [-1, 1, -2, 2].")),Lo((()=>[-1,0,1].includes(r)),a("matchMode should be a value in [-1, 0, 1]."));const d=1===c.length?"col":"row";Lo((()=>"col"===d?h[0].length===c[0].length:h.length===c.length),a("return_range should have the same dimensions as lookup_range."));const u="col"===d?(e,t)=>e[0][t].value:(e,t)=>e[t][0].value,g="col"===d?c[0].length:c.length,p=0===r?"strict":1===r?"nextGreater":"nextSmaller",m=-1===l,f=2===l||-2===l?cs(c,e?.value,p,2===l?"asc":"desc",g,u):hs(c,e?.value,p,g,u,m);if(-1!==f)return"col"===d?h.map((e=>[e[f]])):[h[f]];const b=s?.();return Lm(b,e?.value),[[b]]},isExported:!0};var Zm=Object.freeze({__proto__:null,ADDRESS:Pm,COLUMN:Vm,COLUMNS:km,HLOOKUP:Um,INDEX:Bm,LOOKUP:Hm,MATCH:zm,ROW:Gm,ROWS:$m,VLOOKUP:Wm,XLOOKUP:qm});const Ym={description:a("Sum of two numbers."),args:[_c("value1 (number)",a("The first addend.")),_c("value2 (number)",a("The second addend."))],returns:["NUMBER"],computeFormat:(e,t)=>e?.format||t?.format,compute:function(e,t){return Vo(e,this.locale)+Vo(t,this.locale)}},jm={description:a("Concatenation of two values."),args:[_c("value1 (string)",a("The value to which value2 will be appended.")),_c("value2 (string)",a("The value to append to value1."))],returns:["STRING"],compute:function(e,t){return $o(e)+$o(t)},isExported:!0},Xm={description:a("One number divided by another."),args:[_c("dividend (number)",a("The number to be divided.")),_c("divisor (number)",a("The number to divide by."))],returns:["NUMBER"],computeFormat:(e,t)=>e?.format||t?.format,compute:function(e,t){const o=Vo(t,this.locale);return Lo((()=>0!==o),a("The divisor must be different from zero.")),Vo(e,this.locale)/o}};function Km(e){return null==e}const Qm={number:0,string:"",boolean:!1};function Jm(e,t,o=2e-16){return Math.abs(e-t)<o}const ef={description:a("Equal."),args:[_c("value1 (any)",a("The first value.")),_c("value2 (any)",a("The value to test against value1 for equality."))],returns:["BOOLEAN"],compute:function(e,t){return e=Km(e)?Qm[typeof t]:e,t=Km(t)?Qm[typeof e]:t,"string"==typeof e&&(e=e.toUpperCase()),"string"==typeof t&&(t=t.toUpperCase()),"number"==typeof e&&"number"==typeof t?Jm(e,t):e===t}};function tf(e,t,o){e=Km(e)?Qm[typeof t]:e,t=Km(t)?Qm[typeof e]:t,"number"!=typeof e&&(e=$o(e).toUpperCase()),"number"!=typeof t&&(t=$o(t).toUpperCase());const s=typeof e,n=typeof t;return"string"===s&&"number"===n||("string"!==n||"number"!==s)&&o(e,t)}const of={description:a("Strictly greater than."),args:[_c("value1 (any)",a("The value to test as being greater than value2.")),_c("value2 (any)",a("The second value."))],returns:["BOOLEAN"],compute:function(e,t){return tf(e,t,((e,t)=>"number"==typeof e&&"number"==typeof t?!Jm(e,t)&&e>t:e>t))}},sf={description:a("Greater than or equal to."),args:[_c("value1 (any)",a("The value to test as being greater than or equal to value2.")),_c("value2 (any)",a("The second value."))],returns:["BOOLEAN"],compute:function(e,t){return tf(e,t,((e,t)=>"number"==typeof e&&"number"==typeof t?Jm(e,t)||e>t:e>=t))}},nf={description:a("Less than."),args:[_c("value1 (any)",a("The value to test as being less than value2.")),_c("value2 (any)",a("The second value."))],returns:["BOOLEAN"],compute:function(e,t){return!sf.compute.bind(this)(e,t)}},rf={description:a("Less than or equal to."),args:[_c("value1 (any)",a("The value to test as being less than or equal to value2.")),_c("value2 (any)",a("The second value."))],returns:["BOOLEAN"],compute:function(e,t){return!of.compute.bind(this)(e,t)}},af={description:a("Difference of two numbers."),args:[_c("value1 (number)",a("The minuend, or number to be subtracted from.")),_c("value2 (number)",a("The subtrahend, or number to subtract from value1."))],returns:["NUMBER"],computeFormat:(e,t)=>e?.format||t?.format,compute:function(e,t){return Vo(e,this.locale)-Vo(t,this.locale)}},lf={description:a("Product of two numbers"),args:[_c("factor1 (number)",a("The first multiplicand.")),_c("factor2 (number)",a("The second multiplicand."))],returns:["NUMBER"],computeFormat:(e,t)=>e?.format||t?.format,compute:function(e,t){return Vo(e,this.locale)*Vo(t,this.locale)}},cf={description:a("Not equal."),args:[_c("value1 (any)",a("The first value.")),_c("value2 (any)",a("The value to test against value1 for inequality."))],returns:["BOOLEAN"],compute:function(e,t){return!ef.compute.bind(this)(e,t)}},hf={description:a("A number raised to a power."),args:[_c("base (number)",a("The number to raise to the exponent power.")),_c("exponent (number)",a("The exponent to raise base to."))],returns:["NUMBER"],compute:function(e,t){return td.compute.bind(this)(e,t)}},df={description:a("A number with the sign reversed."),args:[_c("value (number)",a("The number to have its sign reversed. Equivalently, the number to multiply by -1."))],computeFormat:e=>e?.format,returns:["NUMBER"],compute:function(e){return-Vo(e,this.locale)}},uf={description:a("Value interpreted as a percentage."),args:[_c("percentage (number)",a("The value to interpret as a percentage."))],returns:["NUMBER"],compute:function(e){return Vo(e,this.locale)/100}},gf={description:a("A specified number, unchanged."),args:[_c("value (any)",a("The number to return."))],returns:["ANY"],computeFormat:e=>e?.format,compute:function(e=""){return null===e?"":e}};var pf=Object.freeze({__proto__:null,ADD:Ym,CONCAT:jm,DIVIDE:Xm,EQ:ef,GT:of,GTE:sf,LT:nf,LTE:rf,MINUS:af,MULTIPLY:lf,NE:cf,POW:hf,UMINUS:df,UNARY_PERCENT:uf,UPLUS:gf});const mf=/[A-Za-zÀ-ÖØ-öø-ÿ]+/g,ff={description:a("Gets character associated with number."),args:[_c("table_number (number)",a("The number of the character to look up from the current Unicode table in decimal format."))],returns:["STRING"],compute:function(e){const t=Math.trunc(Vo(e,this.locale));return Lo((()=>t>=1),a("The table_number (%s) is out of range.",t.toString())),String.fromCharCode(t)},isExported:!0},bf={description:a("Remove non-printable characters from a piece of text."),args:[_c("text (string)",a("The text whose non-printable characters are to be removed."))],returns:["STRING"],compute:function(e){const t=$o(e);let o="";for(const e of t)e&&e.charCodeAt(0)>31&&(o+=e);return o},isExported:!0},vf={description:a("Appends strings to one another."),args:[_c("string1 (string, range<string>)",a("The initial string.")),_c("string2 (string, range<string>, repeating)",a("More strings to append in sequence."))],returns:["STRING"],compute:function(...e){return Jo(e,((e,t)=>e+$o(t)),"")},isExported:!0},Sf={description:a("Tests whether two strings are identical."),args:[_c("string1 (string)",a("The first string to compare.")),_c("string2 (string)",a("The second string to compare."))],returns:["BOOLEAN"],compute:function(e,t){return $o(e)===$o(t)},isExported:!0},Cf={description:a("First position of string found in text, case-sensitive."),args:[_c("search_for (string)",a("The string to look for within text_to_search.")),_c("text_to_search (string)",a("The text to search for the first occurrence of search_for.")),_c("starting_at (number, default=1)",a("The character within text_to_search at which to start the search."))],returns:["NUMBER"],compute:function(e,t,o=1){const s=$o(e),n=$o(t),i=Vo(o,this.locale);Lo((()=>""!==n),a("The text_to_search must be non-empty.")),Lo((()=>i>=1),a("The starting_at (%s) must be greater than or equal to 1.",i.toString()));const r=n.indexOf(s,i-1);return Lo((()=>r>=0),a("In [[FUNCTION_NAME]] evaluation, cannot find '%s' within '%s'.",s.toString(),n)),r+1},isExported:!0},Ef={description:a("Concatenates elements of arrays with delimiter."),args:[_c("delimiter (string)",a("The character or string to place between each concatenated value.")),_c("value_or_array1 (string, range<string>)",a("The value or values to be appended using delimiter.")),_c("value_or_array2 (string, range<string>, repeating)",a("More values to be appended using delimiter."))],returns:["STRING"],compute:function(e,...t){const o=$o(e);return Jo(t,((e,t)=>(e?e+o:"")+$o(t)),"")}},yf={description:a("Substring from beginning of specified string."),args:[_c("text (string)",a("The string from which the left portion will be returned.")),_c("number_of_characters (number, optional)",a("The number of characters to return from the left side of string."))],returns:["STRING"],compute:function(e,...t){const o=t.length?Vo(t[0],this.locale):1;return Lo((()=>o>=0),a("The number_of_characters (%s) must be positive or null.",o.toString())),$o(e).substring(0,o)},isExported:!0},wf={description:a("Length of a string."),args:[_c("text (string)",a("The string whose length will be returned."))],returns:["NUMBER"],compute:function(e){return $o(e).length},isExported:!0},xf={description:a("Converts a specified string to lowercase."),args:[_c("text (string)",a("The string to convert to lowercase."))],returns:["STRING"],compute:function(e){return $o(e).toLowerCase()},isExported:!0},If={description:a("A segment of a string."),args:[_c("text (string)",a("The string to extract a segment from.")),_c("starting_at (number)",a("The index from the left of string from which to begin extracting. The first character in string has the index 1.")),_c("extract_length (number)",a("The length of the segment to extract."))],returns:["STRING"],compute:function(e,t,o){const s=$o(e),n=Vo(t,this.locale),i=Vo(o,this.locale);return Lo((()=>n>=1),a("The starting_at argument (%s) must be positive greater than one.",n.toString())),Lo((()=>i>=0),a("The extract_length argument (%s) must be positive or null.",i.toString())),s.slice(n-1,n+i-1)},isExported:!0},Rf={description:a("Capitalizes each word in a specified string."),args:[_c("text_to_capitalize (string)",a("The text which will be returned with the first letter of each word in uppercase and all other letters in lowercase."))],returns:["STRING"],compute:function(e){return $o(e).replace(mf,(e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()))},isExported:!0},Tf={description:a("Replaces part of a text string with different text."),args:[_c("text (string)",a("The text, a part of which will be replaced.")),_c("position (number)",a("The position where the replacement will begin (starting from 1).")),_c("length (number)",a("The number of characters in the text to be replaced.")),_c("new_text (string)",a("The text which will be inserted into the original text."))],returns:["STRING"],compute:function(e,t,o,s){const n=Vo(t,this.locale);Lo((()=>n>=1),a("The position (%s) must be greater than or equal to 1.",n.toString()));const i=$o(e),r=Vo(o,this.locale),l=$o(s);return i.substring(0,n-1)+l+i.substring(n-1+r)},isExported:!0},Af={description:a("A substring from the end of a specified string."),args:[_c("text (string)",a("The string from which the right portion will be returned.")),_c("number_of_characters (number, optional)",a("The number of characters to return from the right side of string."))],returns:["STRING"],compute:function(e,...t){const o=t.length?Vo(t[0],this.locale):1;Lo((()=>o>=0),a("The number_of_characters (%s) must be positive or null.",o.toString()));const s=$o(e),n=s.length;return s.substring(n-o,n)},isExported:!0},Of={description:a("First position of string found in text, ignoring case."),args:[_c("search_for (string)",a("The string to look for within text_to_search.")),_c("text_to_search (string)",a("The text to search for the first occurrence of search_for.")),_c("starting_at (number, default=1)",a("The character within text_to_search at which to start the search."))],returns:["NUMBER"],compute:function(e,t,o=1){const s=$o(e).toLowerCase(),n=$o(t).toLowerCase(),i=Vo(o,this.locale);Lo((()=>""!==n),a("The text_to_search must be non-empty.")),Lo((()=>i>=1),a("The starting_at (%s) must be greater than or equal to 1.",i.toString()));const r=n.indexOf(s,i-1);return Lo((()=>r>=0),a("In [[FUNCTION_NAME]] evaluation, cannot find '%s' within '%s'.",s,n)),r+1},isExported:!0},_f={description:a("Split text by specific character delimiter(s)."),args:[_c("text (string)",a("The text to divide.")),_c("delimiter (string)",a("The character or characters to use to split text.")),_c("split_by_each (boolean, default=true})",a("Whether or not to divide text around each character contained in delimiter.")),_c("remove_empty_text (boolean, default=true)",a("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."))],returns:["RANGE<STRING>"],compute:function(e,t,o=true,s=true){const n=$o(e),i=Te($o(t)),r=Zo(o),l=Zo(s);Lo((()=>i.length>0),a("The _delimiter (%s) must be not be empty.",i));const c=r?new RegExp(`[${i}]`,"g"):new RegExp(i,"g");let h=n.split(c);return l&&(h=h.filter((e=>""!==e))),ns([h])},isExported:!1},Mf={description:a("Replaces existing text with new text in a string."),args:[_c("text_to_search (string)",a("The text within which to search and replace.")),_c("search_for (string)",a("The string to search for within text_to_search.")),_c("replace_with (string)",a("The string that will replace search_for.")),_c("occurrence_number (number, optional)",a("The instance of search_for within text_to_search to replace with replace_with. By default, all occurrences of search_for are replaced; however, if occurrence_number is specified, only the indicated instance of search_for is replaced."))],returns:["NUMBER"],compute:function(e,t,o,s){const n=Vo(s,this.locale);Lo((()=>n>=0),a("The occurrenceNumber (%s) must be positive or null.",n.toString()));const i=$o(e),r=$o(t);if(""===r)return i;const l=$o(o),c=new RegExp(Te(r),"g");if(0===n)return i.replace(c,l);let h=0;return i.replace(c,(e=>++h===n?l:e))},isExported:!0},Nf={description:a("Combines text from multiple strings and/or arrays."),args:[_c("delimiter (string)",a(" A string, possible empty, or a reference to a valid string. If empty, the text will be simply concatenated.")),_c("ignore_empty (boolean)",a("A boolean; if TRUE, empty cells selected in the text arguments won't be included in the result.")),_c("text1 (string, range<string>)",a("Any text item. This could be a string, or an array of strings in a range.")),_c("text2 (string, range<string>, repeating)",a("Additional text item(s)."))],returns:["STRING"],compute:function(e,t,...o){const s=$o(e),n=Zo(t);let i=0;return Jo(o,((e,t)=>n&&""===$o(t)?e:(i++?e+s:"")+$o(t)),"")},isExported:!0},Ff={description:a("Removes space characters."),args:[_c("text (string)",a("The text or reference to a cell containing text to be trimmed."))],returns:["STRING"],compute:function(e){return ht($o(e))},isExported:!0},Df={description:a("Converts a specified string to uppercase."),args:[_c("text (string)",a("The string to convert to uppercase."))],returns:["STRING"],compute:function(e){return $o(e).toUpperCase()},isExported:!0},Lf={description:a("Converts a number to text according to a specified format."),args:[_c("number (number)",a("The number, date or time to format.")),_c("format (string)",a("The pattern by which to format the number, enclosed in quotation marks."))],returns:["STRING"],compute:function(e,t){return Ts(Vo(e,this.locale),{format:$o(t),locale:this.locale})},isExported:!0},Pf={description:a("Converts a string to a numeric value."),args:[_c("value (number)",a("the string to be converted"))],returns:["NUMBER"],compute:function(e){return Vo(e,this.locale)},isExported:!0};var Vf=Object.freeze({__proto__:null,CHAR:ff,CLEAN:bf,CONCATENATE:vf,EXACT:Sf,FIND:Cf,JOIN:Ef,LEFT:yf,LEN:wf,LOWER:xf,MID:If,PROPER:Rf,REPLACE:Tf,RIGHT:Af,SEARCH:Of,SPLIT:_f,SUBSTITUTE:Mf,TEXT:Lf,TEXTJOIN:Nf,TRIM:Ff,UPPER:Df,VALUE:Pf});const kf={description:a("Creates a hyperlink in a cell."),args:[_c("url (string)",a("The full URL of the link enclosed in quotation marks.")),_c("link_label (string, optional)",a("The text to display in the cell, enclosed in quotation marks."))],returns:["STRING"],compute:function(e,t){const o=$o(e).trim(),s=$o(t)||o;return""===o?s:Ue(s,o)},isExported:!0};var Uf=Object.freeze({__proto__:null,HYPERLINK:kf});const Bf=[{name:a("Array"),functions:dh},{name:a("Database"),functions:Qu},{name:a("Date"),functions:Fg},{name:a("Filter"),functions:$g},{name:a("Financial"),functions:um},{name:a("Info"),functions:ym},{name:a("Lookup"),functions:Zm},{name:a("Logical"),functions:Fm},{name:a("Math"),functions:Ed},{name:a("Misc"),functions:gh},{name:a("Operator"),functions:pf},{name:a("Statistical"),functions:Vu},{name:a("Text"),functions:Vf},{name:a("Engineering"),functions:Lg},{name:a("Web"),functions:Uf}],Hf=/^[A-Z0-9\_\.]+$/;function zf(e){return Mo(e)?ss(e,(e=>e.value)):e?.value}const Gf=new class extends Zi{mapping={};add(e,t){if(e=e.toUpperCase(),!Hf.test(e))throw new Error(a("Invalid function name %s. Function names can exclusively contain alphanumerical values separated by dots (.) or underscore (_)",e));const o=Mc(t);return function(e){let t=!1,o=!1,s=!1;for(let n of e){if(n.type.includes("META")&&n.type.length>1)throw new Error(a("Function ${name} has an argument that has been declared with more than one type whose type 'META'. The 'META' type can only be declared alone."));if(t&&!n.repeating)throw new Error(a("Function ${name} has no-repeatable arguments declared after repeatable ones. All repeatable arguments must be declared last."));const e=o||t||s,i=!(n.optional||n.repeating||n.default);if(e&&i)throw new Error(a("Function ${name} has at mandatory arguments declared after optional ones. All optional arguments must be after all mandatory arguments."));t=n.repeating,o=n.optional,s=n.default}}(o.args),this.mapping[e]=function(e,t){function o(...o){for(let t=0;t<o.length;t++){const s=e.args[e.getArgToFocus(t+1)-1],n=o[t];if(Mo(n)&&!s.acceptMatrix){if(1!==n.length||1!==n[0].length)throw new d(c.GenericError,a("Function [[FUNCTION_NAME]] expects the parameter '%s' to be a single value or a single cell reference, not a range.",s.name));o[t]=n[0][0]}}return t.apply(this,o)}return o}(o,function(e){const t="computeValueAndFormat"in e,o="compute"in e,s="computeFormat"in e;if(!t&&!o)throw new Error("Invalid function description, need at least one 'compute' or 'computeValueAndFormat' function");if(t&&(o||s))throw new Error("Invalid function description, cannot have both 'computeValueAndFormat' and 'compute'/'computeFormat' functions");if(t)return e.computeValueAndFormat;return function(e){return function(...t){const o=e.compute.apply(this,function(e){return e.map((e=>{if(void 0!==e)return"function"==typeof e?()=>zf(e()):zf(e)}))}(t)),s=e.computeFormat?.apply(this,t);if(Mo(o)){if(void 0===s||Mo(s))return o.map(((e,t)=>e.map(((e,o)=>({value:e,format:s?.[t]?.[o]})))))}else if(void 0===s||!Mo(s))return{value:o,format:s};throw new Error("A format matrix should never be associated with a scalar value")}}(e)}(o)),super.add(e,o),this}};for(let uA of Bf){const gA=uA.functions;for(let pA in gA){const mA=gA[pA];mA.category=mA.category||uA.name,pA=pA.replace(/_/g,"."),Gf.add(pA,{isExported:!1,...mA})}}const $f={name:e=>{const t=bb(e);return 1===t?a("Insert row"):a("Insert %s rows",t.toString())},isVisible:e=>nc(e,"ROW"),icon:"o-spreadsheet-Icon.INSERT_ROW"},Wf={name:e=>{const t=bb(e);return 1===t?a("Insert row above"):a("Insert %s rows above",t.toString())},execute:Ql,isVisible:e=>nc(e,"ROW"),icon:"o-spreadsheet-Icon.INSERT_ROW_BEFORE"},qf={...Wf,name:e=>{const t=bb(e);return 1===t?a("Row above"):a("%s Rows above",t.toString())}},Zf={...Wf,name:e=>{const t=bb(e);return 1===t?a("Insert row"):a("Insert %s rows",t.toString())},isVisible:sc,icon:"o-spreadsheet-Icon.INSERT_ROW_BEFORE"},Yf={execute:e=>{const t=e.model.getters.getActiveRows();let o,s;if(t.size)o=ut([...t]),s=t.size;else{const t=e.model.getters.getSelectedZones()[0];o=t.bottom,s=t.bottom-t.top+1}e.model.dispatch("ADD_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),position:"after",base:o,quantity:s,dimension:"ROW"})},name:e=>{const t=bb(e);return 1===t?a("Insert row below"):a("Insert %s rows below",t.toString())},isVisible:e=>nc(e,"ROW"),icon:"o-spreadsheet-Icon.INSERT_ROW_AFTER"},jf={...Yf,name:e=>{const t=bb(e);return 1===t?a("Row below"):a("%s Rows below",t.toString())}},Xf={name:e=>{const t=vb(e);return 1===t?a("Insert column"):a("Insert %s columns",t.toString())},isVisible:e=>nc(e,"COL"),icon:"o-spreadsheet-Icon.INSERT_COL"},Kf={name:e=>{const t=vb(e);return 1===t?a("Insert column left"):a("Insert %s columns left",t.toString())},execute:Jl,isVisible:e=>nc(e,"COL"),icon:"o-spreadsheet-Icon.INSERT_COL_BEFORE"},Qf={...Kf,name:e=>{const t=vb(e);return 1===t?a("Column left"):a("%s Columns left",t.toString())}},Jf={...Kf,name:e=>{const t=vb(e);return 1===t?a("Insert column"):a("Insert %s columns",t.toString())},isVisible:sc,icon:"o-spreadsheet-Icon.INSERT_COL_BEFORE"},eb={name:e=>{const t=vb(e);return 1===t?a("Insert column right"):a("Insert %s columns right",t.toString())},execute:ec,isVisible:e=>nc(e,"COL"),icon:"o-spreadsheet-Icon.INSERT_COL_AFTER"},tb={...eb,name:e=>{const t=vb(e);return 1===t?a("Column right"):a("%s Columns right",t.toString())},execute:ec},ob={name:a("Insert cells"),isVisible:e=>sc(e)&&0===e.model.getters.getActiveCols().size&&0===e.model.getters.getActiveRows().size,icon:"o-spreadsheet-Icon.INSERT_CELL"},sb={name:a("Insert cells and shift down"),execute:e=>{const t=e.model.getters.getSelectedZone(),o=e.model.dispatch("INSERT_CELL",{zone:t,shiftDimension:"ROW"});Ga(e,o)},isVisible:e=>0===e.model.getters.getActiveRows().size&&0===e.model.getters.getActiveCols().size,icon:"o-spreadsheet-Icon.INSERT_CELL_SHIFT_DOWN"},nb={name:a("Insert cells and shift right"),execute:e=>{const t=e.model.getters.getSelectedZone(),o=e.model.dispatch("INSERT_CELL",{zone:t,shiftDimension:"COL"});Ga(e,o)},isVisible:e=>0===e.model.getters.getActiveRows().size&&0===e.model.getters.getActiveCols().size,icon:"o-spreadsheet-Icon.INSERT_CELL_SHIFT_RIGHT"},ib={name:a("Chart"),execute:e=>{const t=e.model.getters,o=e.model.uuidGenerator.smallUuid(),s=t.getActiveSheetId();1===Vn(e.model.getters.getSelectedZone())&&e.model.selection.selectTableAroundSelection();const n={width:536,height:335},i=function(e,t){const{x:o,y:s}=e.getMainViewportCoordinates(),{scrollX:n,scrollY:i}=e.getActiveSheetScrollInfo(),{width:r,height:a}=e.getVisibleRect(e.getActiveMainViewport());return{x:o+n+Math.max(0,(r-t.width)/2),y:s+i+Math.max(0,(a-t.height)/2)}}(t,n);e.model.dispatch("CREATE_CHART",{sheetId:s,id:o,position:i,size:n,definition:ql(e.model.getters.getSelectedZone(),e.model.getters)}).isSuccessful&&(e.model.dispatch("SELECT_FIGURE",{id:o}),e.openSidePanel("ChartPanel"))},icon:"o-spreadsheet-Icon.INSERT_CHART"},rb={name:a("Image"),description:"Ctrl+O",execute:tc,isVisible:e=>void 0!==e.imageProvider,icon:"o-spreadsheet-Icon.INSERT_IMAGE"},ab={name:a("Function"),icon:"o-spreadsheet-Icon.SHOW_HIDE_FORMULA"},lb={name:a("SUM"),execute:e=>e.startCellEdition("=SUM(")},cb={name:a("AVERAGE"),execute:e=>e.startCellEdition("=AVERAGE(")},hb={name:a("COUNT"),execute:e=>e.startCellEdition("=COUNT(")},db={name:a("MAX"),execute:e=>e.startCellEdition("=MAX(")},ub={name:a("MIN"),execute:e=>e.startCellEdition("=MIN(")},gb={name:a("All"),children:[function(){return fb(Gf.getKeys().filter((e=>!Gf.get(e).hidden)))}]};const pb={name:a("Link"),execute:oc,icon:"o-spreadsheet-Icon.INSERT_LINK"},mb={name:a("Insert sheet"),execute:e=>{const t=e.model.getters.getActiveSheetId(),o=e.model.getters.getSheetIds().indexOf(t)+1,s=e.model.uuidGenerator.smallUuid();e.model.dispatch("CREATE_SHEET",{sheetId:s,position:o}),e.model.dispatch("ACTIVATE_SHEET",{sheetIdFrom:t,sheetIdTo:s})},icon:"o-spreadsheet-Icon.INSERT_SHEET"};function fb(e){return e.sort().map(((e,t)=>({name:e,sequence:10*t,execute:t=>t.startCellEdition(`=${e}(`)})))}function bb(e){const t=e.model.getters.getActiveRows();if(t.size)return t.size;{const t=e.model.getters.getSelectedZones()[0];return t.bottom-t.top+1}}function vb(e){const t=e.model.getters.getActiveCols();if(t.size)return t.size;{const t=e.model.getters.getSelectedZones()[0];return t.right-t.left+1}}const Sb=new Pa;Sb.add("cut",{...lc,sequence:10}).add("copy",{...ac,sequence:20}).add("paste",{...cc,sequence:30}).add("paste_special",{...hc,sequence:40,separator:!0}).addChild("paste_value_only",["paste_special"],{...dc,sequence:10}).addChild("paste_format_only",["paste_special"],{...uc,sequence:20}).add("add_row_before",{...Zf,sequence:70}).add("add_column_before",{...Jf,sequence:90}).add("insert_cell",{...ob,sequence:100,separator:!0}).addChild("insert_cell_down",["insert_cell"],{...sb,name:a("Shift down"),sequence:10}).addChild("insert_cell_right",["insert_cell"],{...nb,name:a("Shift right"),sequence:20}).add("delete_row",{...fc,sequence:110,icon:"o-spreadsheet-Icon.DELETE"}).add("delete_column",{...Sc,sequence:120,icon:"o-spreadsheet-Icon.DELETE"}).add("delete_cell",{...Ec,sequence:130,separator:!0,icon:"o-spreadsheet-Icon.DELETE"}).addChild("delete_cell_up",["delete_cell"],{...yc,name:a("Shift up"),sequence:10,icon:"o-spreadsheet-Icon.DELETE_CELL_SHIFT_UP"}).addChild("delete_cell_left",["delete_cell"],{...wc,name:a("Shift left"),sequence:20,icon:"o-spreadsheet-Icon.DELETE_CELL_SHIFT_LEFT"}).add("insert_link",{...pb,name:e=>{const t=e.model.getters.getActiveSheetId(),{col:o,row:s}=e.model.getters.getActivePosition(),n=e.model.getters.getEvaluatedCell({sheetId:t,col:o,row:s});return n&&n.link?a("Edit link"):a("Insert link")},sequence:150,separator:!0});const Cb={filterOverlap:a("You cannot create overlapping filters."),nonContinuousTargets:a("A filter can only be created on a continuous selection."),mergeInFilter:a("You can't create a filter over a range that contains a merge.")};function Eb(e,t,o){const s=e.model.getters.getActiveSheetId(),n="COL"===t?"FREEZE_COLUMNS":"FREEZE_ROWS";e.model.dispatch(n,{sheetId:s,quantity:o}).isCancelledBecause("MergeOverlap")&&e.raiseError(Xa)}const yb={name:e=>{const t=e.model.getters.getElementsFromSelection("COL");let o=t[0],s=t[t.length-1];return 1===t.length?a("Hide column %s",Ot(o).toString()):s-o+1===t.length?a("Hide columns %s - %s",Ot(o).toString(),Ot(s).toString()):a("Hide columns")},execute:e=>{const t=e.model.getters.getElementsFromSelection("COL");e.model.dispatch("HIDE_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),dimension:"COL",elements:t})},isVisible:e=>{const t=e.model.getters.getActiveSheetId(),o=e.model.getters.getElementsFromSelection("COL");return!e.model.getters.checkElementsIncludeAllVisibleHeaders(t,"COL",o)},icon:"o-spreadsheet-Icon.HIDE_COL"},wb={name:a("Unhide columns"),execute:e=>{const t=e.model.getters.getElementsFromSelection("COL");e.model.dispatch("UNHIDE_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),dimension:"COL",elements:t})},isVisible:e=>{const t=e.model.getters.getHiddenColsGroups(e.model.getters.getActiveSheetId()).flat();return e.model.getters.getElementsFromSelection("COL").some((e=>t.includes(e)))}},xb={name:a("Unhide all columns"),execute:e=>{const t=e.model.getters.getActiveSheetId();e.model.dispatch("UNHIDE_COLUMNS_ROWS",{sheetId:t,dimension:"COL",elements:Array.from(Array(e.model.getters.getNumberCols(t)).keys())})},isVisible:e=>e.model.getters.getHiddenColsGroups(e.model.getters.getActiveSheetId()).length>0},Ib={name:e=>{const t=e.model.getters.getElementsFromSelection("ROW");let o=t[0],s=t[t.length-1];return 1===t.length?a("Hide row %s",(o+1).toString()):s-o+1===t.length?a("Hide rows %s - %s",(o+1).toString(),(s+1).toString()):a("Hide rows")},execute:e=>{const t=e.model.getters.getElementsFromSelection("ROW");e.model.dispatch("HIDE_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),dimension:"ROW",elements:t})},isVisible:e=>{const t=e.model.getters.getActiveSheetId(),o=e.model.getters.getElementsFromSelection("ROW");return!e.model.getters.checkElementsIncludeAllVisibleHeaders(t,"ROW",o)},icon:"o-spreadsheet-Icon.HIDE_ROW"},Rb={name:a("Unhide rows"),execute:e=>{const t=e.model.getters.getElementsFromSelection("ROW");e.model.dispatch("UNHIDE_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),dimension:"ROW",elements:t})},isVisible:e=>{const t=e.model.getters.getHiddenRowsGroups(e.model.getters.getActiveSheetId()).flat();return e.model.getters.getElementsFromSelection("ROW").some((e=>t.includes(e)))}},Tb={name:a("Unhide all rows"),execute:e=>{const t=e.model.getters.getActiveSheetId();e.model.dispatch("UNHIDE_COLUMNS_ROWS",{sheetId:t,dimension:"ROW",elements:Array.from(Array(e.model.getters.getNumberRows(t)).keys())})},isVisible:e=>e.model.getters.getHiddenRowsGroups(e.model.getters.getActiveSheetId()).length>0},Ab={name:a("Unfreeze"),isVisible:e=>{const{xSplit:t,ySplit:o}=e.model.getters.getPaneDivisions(e.model.getters.getActiveSheetId());return t+o>0},execute:e=>e.model.dispatch("UNFREEZE_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId()}),icon:"o-spreadsheet-Icon.UNFREEZE"},Ob={name:a("Freeze"),icon:"o-spreadsheet-Icon.FREEZE"},_b={name:a("No rows"),execute:e=>e.model.dispatch("UNFREEZE_ROWS",{sheetId:e.model.getters.getActiveSheetId()}),isReadonlyAllowed:!0,isVisible:e=>!!e.model.getters.getPaneDivisions(e.model.getters.getActiveSheetId()).ySplit},Mb={name:a("1 row"),execute:e=>Eb(e,"ROW",1),isReadonlyAllowed:!0},Nb={name:a("2 rows"),execute:e=>Eb(e,"ROW",2),isReadonlyAllowed:!0},Fb={name:a("Up to current row"),execute:e=>{const{bottom:t}=e.model.getters.getSelectedZone();Eb(e,"ROW",t+1)},isReadonlyAllowed:!0},Db={name:a("No columns"),execute:e=>e.model.dispatch("UNFREEZE_COLUMNS",{sheetId:e.model.getters.getActiveSheetId()}),isReadonlyAllowed:!0,isVisible:e=>!!e.model.getters.getPaneDivisions(e.model.getters.getActiveSheetId()).xSplit},Lb={name:a("1 column"),execute:e=>Eb(e,"COL",1),isReadonlyAllowed:!0},Pb={name:a("2 columns"),execute:e=>Eb(e,"COL",2),isReadonlyAllowed:!0},Vb={name:a("Up to current column"),execute:e=>{const{right:t}=e.model.getters.getSelectedZone();Eb(e,"COL",t+1)},isReadonlyAllowed:!0},kb={name:e=>e.model.getters.getGridLinesVisibility(e.model.getters.getActiveSheetId())?a("Hide gridlines"):a("Show gridlines"),execute:e=>{const t=e.model.getters.getActiveSheetId();e.model.dispatch("SET_GRID_LINES_VISIBILITY",{sheetId:t,areGridLinesVisible:!e.model.getters.getGridLinesVisibility(t)})},icon:"o-spreadsheet-Icon.SHOW_HIDE_GRID"},Ub={name:e=>e.model.getters.shouldShowFormulas()?"Hide formulas":a("Show formulas"),execute:e=>e.model.dispatch("SET_FORMULA_VISIBILITY",{show:!e.model.getters.shouldShowFormulas()}),isReadonlyAllowed:!0,icon:"o-spreadsheet-Icon.SHOW_HIDE_FORMULA"},Bb={name:e=>Wb(e)?a("Remove selected filters"):a("Create filter"),isActive:e=>Wb(e),isEnabled:e=>!qb(e),execute:e=>Zb(e),icon:"o-spreadsheet-Icon.FILTER_ICON_INACTIVE"},Hb={name:e=>{const t=e.model.getters.getSelectedZone();return t.left===t.right?a("Group column %s",Ot(t.left)):a("Group columns %s - %s",Ot(t.left),Ot(t.right))},execute:e=>Yb(e,"COL"),isVisible:e=>{const t=e.model.getters.getActiveSheetId(),o=e.model.getters.getSelectedZone(),s=e.model.getters.getHeaderGroupsInZone(t,"COL",o);return sc(e)&&!s.some((e=>e.start===o.left&&e.end===o.right))},icon:"o-spreadsheet-Icon.GROUP_COLUMNS"},zb={name:e=>{const t=e.model.getters.getSelectedZone();return t.top===t.bottom?a("Group row %s",String(t.top+1)):a("Group rows %s - %s",String(t.top+1),String(t.bottom+1))},execute:e=>Yb(e,"ROW"),isVisible:e=>{const t=e.model.getters.getActiveSheetId(),o=e.model.getters.getSelectedZone(),s=e.model.getters.getHeaderGroupsInZone(t,"ROW",o);return sc(e)&&!s.some((e=>e.start===o.top&&e.end===o.bottom))},icon:"o-spreadsheet-Icon.GROUP_ROWS"},Gb={name:e=>{const t=e.model.getters.getSelectedZone();return t.left===t.right?a("Ungroup column %s",Ot(t.left)):a("Ungroup columns %s - %s",Ot(t.left),Ot(t.right))},execute:e=>jb(e,"COL"),icon:"o-spreadsheet-Icon.UNGROUP_COLUMNS"},$b={name:e=>{const t=e.model.getters.getSelectedZone();return t.top===t.bottom?a("Ungroup row %s",String(t.top+1)):a("Ungroup rows %s - %s",String(t.top+1),String(t.bottom+1))},execute:e=>jb(e,"ROW"),icon:"o-spreadsheet-Icon.UNGROUP_ROWS"};function Wb(e){const t=e.model.getters.getActiveSheetId(),o=e.model.getters.getSelectedZones();return e.model.getters.doesZonesContainFilter(t,o)}function qb(e){return!kn(...e.model.getters.getSelectedZones())}function Zb(e){if(Wb(e))return void e.model.dispatch("REMOVE_FILTER_TABLE",{sheetId:e.model.getters.getActiveSheetId(),target:e.model.getters.getSelectedZones()});if(qb(e))return;e.model.selection.selectTableAroundSelection();const t=e.model.getters.getActiveSheetId(),o=e.model.getters.getSelectedZones();!function(e,t,o){const s=e.model.dispatch("CREATE_FILTER_TABLE",{target:o,sheetId:t});s.isCancelledBecause("FilterOverlap")?e.raiseError(Cb.filterOverlap):s.isCancelledBecause("MergeInFilter")?e.raiseError(Cb.mergeInFilter):s.isCancelledBecause("NonContinuousTargets")&&e.raiseError(Cb.nonContinuousTargets)}(e,t,o)}function Yb(e,t){const o=e.model.getters.getSelectedZone(),s=e.model.getters.getActiveSheetId();e.model.dispatch("GROUP_HEADERS",{sheetId:s,dimension:t,start:"COL"===t?o.left:o.top,end:"COL"===t?o.right:o.bottom})}function jb(e,t){const o=e.model.getters.getSelectedZone(),s=e.model.getters.getActiveSheetId();e.model.dispatch("UNGROUP_HEADERS",{sheetId:s,dimension:t,start:"COL"===t?o.left:o.top,end:"COL"===t?o.right:o.bottom})}function Xb(e,t){const o=e.model.getters.getActiveSheetId(),s=e.model.getters.getSelectedZones();return 1===s.length&&e.model.getters.getHeaderGroupsInZone(o,t,s[0]).length>0}var Kb=Object.freeze({__proto__:null,canUngroupHeaders:Xb,createRemoveFilter:Bb,createRemoveFilterAction:Zb,freezeCurrentCol:Vb,freezeCurrentRow:Fb,freezeFirstCol:Lb,freezeFirstRow:Mb,freezePane:Ob,freezeSecondCol:Pb,freezeSecondRow:Nb,groupColumns:Hb,groupRows:zb,hideCols:yb,hideRows:Ib,unFreezeCols:Db,unFreezePane:Ab,unFreezeRows:_b,ungroupColumns:Gb,ungroupRows:$b,unhideAllCols:xb,unhideAllRows:Tb,unhideCols:wb,unhideRows:Rb,viewFormulas:Ub,viewGridlines:kb});const Qb={name:a("Sort range"),isVisible:sc,icon:"o-spreadsheet-Icon.SORT_RANGE"},Jb={name:a("Ascending (A ⟶ Z)"),execute:e=>{const{anchor:t,zones:o}=e.model.getters.getSelection(),s=e.model.getters.getActiveSheetId();kg(e,s,t.cell,o[0],"ascending")},icon:"o-spreadsheet-Icon.SORT_ASCENDING"},ev={name:a("Data cleanup"),icon:"o-spreadsheet-Icon.DATA_CLEANUP"},tv={name:a("Remove duplicates"),execute:e=>{1===Vn(e.model.getters.getSelectedZone())&&e.model.selection.selectTableAroundSelection(),e.openSidePanel("RemoveDuplicates",{})}},ov={name:a("Trim whitespace"),execute:e=>{e.model.dispatch("TRIM_WHITESPACE")}},sv={name:a("Descending (Z ⟶ A)"),execute:e=>{const{anchor:t,zones:o}=e.model.getters.getSelection(),s=e.model.getters.getActiveSheetId();kg(e,s,t.cell,o[0],"descending")},icon:"o-spreadsheet-Icon.SORT_DESCENDING"},nv={name:e=>(e=>{const t=e.model.getters.getActiveSheetId(),o=e.model.getters.getSelectedZones();return e.model.getters.doesZonesContainFilter(t,o)})(e)?a("Remove filter"):a("Create filter"),execute:e=>Zb(e),isEnabled:e=>kn(...e.model.getters.getSelectedZones()),icon:"o-spreadsheet-Icon.MENU_FILTER_ICON"},iv={name:a("Split text to columns"),sequence:1,execute:e=>e.openSidePanel("SplitToColumns",{}),isEnabled:e=>e.model.getters.isSingleColSelected(),icon:"o-spreadsheet-Icon.SPLIT_TEXT"};function rv({name:e,format:t,descriptionValue:o}){const s="function"==typeof t?t:()=>t;return{name:e,description:e=>Ts(o,{format:s(e),locale:e.model.getters.getLocale()}),execute:e=>Zl(e,s(e)),isActive:e=>function(e,t){const o=e.model.getters.getCell(e.model.getters.getActivePosition());return o?.format===t}(e,s(e))}}const av={name:a("Automatic"),execute:e=>Zl(e,""),isActive:e=>function(e){const t=e.model.getters.getCell(e.model.getters.getActivePosition());return!t||!t.format}(e)},lv=rv({name:a("Number"),descriptionValue:1000.12,format:"#,##0.00"}),cv={name:a("Format as percent"),execute:e=>Zl(e,"0.00%"),icon:"o-spreadsheet-Icon.PERCENT"},hv=rv({name:a("Percent"),descriptionValue:.1012,format:"0.00%"}),dv=rv({name:a("Currency"),descriptionValue:1000.12,format:e=>e.model.config.defaultCurrencyFormat??gv}),uv={...rv({name:a("Currency rounded"),descriptionValue:1e3,format:e=>$s(e.model.config.defaultCurrencyFormat??gv)}),isVisible:e=>{const t=e.model.config.defaultCurrencyFormat;return t!==$s(t??gv)}},gv="[$$]#,##0.00",pv=sr("2023/09/26 10:43:00 PM",Oo),mv={name:a("Custom currency"),isVisible:e=>void 0!==e.loadCurrencies,execute:e=>e.openSidePanel("CustomCurrency",{})},fv=rv({name:a("Date"),descriptionValue:pv,format:e=>e.model.getters.getLocale().dateFormat}),bv=rv({name:a("Time"),descriptionValue:pv,format:e=>e.model.getters.getLocale().timeFormat}),vv=rv({name:a("Date time"),descriptionValue:pv,format:e=>Aa(e.model.getters.getLocale())}),Sv=rv({name:a("Duration"),descriptionValue:"27:51:38",format:"hhhh:mm:ss"}),Cv={name:a("More date formats"),execute:e=>e.openSidePanel("MoreFormats",{})},Ev=rv({name:a("Full date time"),format:"dddd d mmmm yyyy hh:mm:ss a",descriptionValue:pv}),yv=rv({name:a("Full week day and month"),format:"dddd d mmmm yyyy",descriptionValue:pv}),wv=rv({name:a("Day and full month"),format:"d mmmm yyyy",descriptionValue:pv}),xv=rv({name:a("Short week day"),format:"ddd d mmm yyyy",descriptionValue:pv}),Iv=rv({name:a("Day and short month"),format:"d mmm yyyy",descriptionValue:pv}),Rv=rv({name:a("Full month"),format:"mmmm yyyy",descriptionValue:pv}),Tv=rv({name:a("Short month"),format:"mmm yyyy",descriptionValue:pv}),Av={name:a("Increase decimal places"),icon:"o-spreadsheet-Icon.INCREASE_DECIMAL",execute:e=>e.model.dispatch("SET_DECIMAL",{sheetId:e.model.getters.getActiveSheetId(),target:e.model.getters.getSelectedZones(),step:1})},Ov={name:a("Decrease decimal places"),icon:"o-spreadsheet-Icon.DECRASE_DECIMAL",execute:e=>e.model.dispatch("SET_DECIMAL",{sheetId:e.model.getters.getActiveSheetId(),target:e.model.getters.getSelectedZones(),step:-1})},_v={name:a("Bold"),description:"Ctrl+B",execute:e=>Yl(e,{bold:!e.model.getters.getCurrentStyle().bold}),icon:"o-spreadsheet-Icon.BOLD",isActive:e=>!!e.model.getters.getCurrentStyle().bold},Mv={name:a("Italic"),description:"Ctrl+I",execute:e=>Yl(e,{italic:!e.model.getters.getCurrentStyle().italic}),icon:"o-spreadsheet-Icon.ITALIC",isActive:e=>!!e.model.getters.getCurrentStyle().italic},Nv={name:a("Underline"),description:"Ctrl+U",execute:e=>Yl(e,{underline:!e.model.getters.getCurrentStyle().underline}),icon:"o-spreadsheet-Icon.UNDERLINE",isActive:e=>!!e.model.getters.getCurrentStyle().underline},Fv={name:a("Strikethrough"),execute:e=>Yl(e,{strikethrough:!e.model.getters.getCurrentStyle().strikethrough}),icon:"o-spreadsheet-Icon.STRIKE",isActive:e=>!!e.model.getters.getCurrentStyle().strikethrough},Dv={name:a("Font size"),children:Ie.map((e=>({name:e.toString(),sequence:e,id:`font_size_${e}`,execute:t=>Yl(t,{fontSize:e}),isActive:t=>function(e,t){const o=e.model.getters.getCurrentStyle().fontSize||ne;return o===t}(t,e)}))),icon:"o-spreadsheet-Icon.FONT_SIZE"},Lv={name:a("Alignment"),icon:"o-spreadsheet-Icon.ALIGN_LEFT"},Pv={name:a("Horizontal align"),icon:e=>function(e){switch(Jv(e)){case"right":return"o-spreadsheet-Icon.ALIGN_RIGHT";case"center":return"o-spreadsheet-Icon.ALIGN_CENTER";default:return"o-spreadsheet-Icon.ALIGN_LEFT"}}(e)},Vv={name:a("Left"),description:"Ctrl+Shift+L",execute:e=>Yl(e,{align:"left"}),isActive:e=>"left"===Jv(e),icon:"o-spreadsheet-Icon.ALIGN_LEFT"},kv={name:a("Center"),description:"Ctrl+Shift+E",execute:e=>Yl(e,{align:"center"}),isActive:e=>"center"===Jv(e),icon:"o-spreadsheet-Icon.ALIGN_CENTER"},Uv={name:a("Right"),description:"Ctrl+Shift+R",execute:e=>Yl(e,{align:"right"}),isActive:e=>"right"===Jv(e),icon:"o-spreadsheet-Icon.ALIGN_RIGHT"},Bv={name:a("Vertical align"),icon:e=>function(e){switch(eS(e)){case"top":return"o-spreadsheet-Icon.ALIGN_TOP";case"middle":return"o-spreadsheet-Icon.ALIGN_MIDDLE";default:return"o-spreadsheet-Icon.ALIGN_BOTTOM"}}(e)},Hv={name:a("Top"),execute:e=>Yl(e,{verticalAlign:"top"}),isActive:e=>"top"===eS(e),icon:"o-spreadsheet-Icon.ALIGN_TOP"},zv={name:a("Middle"),execute:e=>Yl(e,{verticalAlign:"middle"}),isActive:e=>"middle"===eS(e),icon:"o-spreadsheet-Icon.ALIGN_MIDDLE"},Gv={name:a("Bottom"),execute:e=>Yl(e,{verticalAlign:"bottom"}),isActive:e=>"bottom"===eS(e),icon:"o-spreadsheet-Icon.ALIGN_BOTTOM"},$v={name:a("Wrapping"),icon:"o-spreadsheet-Icon.WRAPPING_OVERFLOW"},Wv={name:a("Wrapping"),icon:e=>function(e){switch(tS(e)){case"wrap":return"o-spreadsheet-Icon.WRAPPING_WRAP";case"clip":return"o-spreadsheet-Icon.WRAPPING_CLIP";default:return"o-spreadsheet-Icon.WRAPPING_OVERFLOW"}}(e)},qv={name:a("Overflow"),execute:e=>Yl(e,{wrapping:"overflow"}),isActive:e=>"overflow"===tS(e),icon:"o-spreadsheet-Icon.WRAPPING_OVERFLOW"},Zv={name:a("Wrap"),execute:e=>Yl(e,{wrapping:"wrap"}),isActive:e=>"wrap"===tS(e),icon:"o-spreadsheet-Icon.WRAPPING_WRAP"},Yv={name:a("Clip"),execute:e=>Yl(e,{wrapping:"clip"}),isActive:e=>"clip"===tS(e),icon:"o-spreadsheet-Icon.WRAPPING_CLIP"},jv={name:a("Text Color"),icon:"o-spreadsheet-Icon.TEXT_COLOR"},Xv={name:a("Fill Color"),icon:"o-spreadsheet-Icon.FILL_COLOR"},Kv={name:a("Conditional formatting"),execute:e=>{e.openSidePanel("ConditionalFormatting",{selection:e.model.getters.getSelectedZones()})},icon:"o-spreadsheet-Icon.CONDITIONAL_FORMAT"},Qv={name:a("Clear formatting"),description:"Ctrl+<",execute:e=>e.model.dispatch("CLEAR_FORMATTING",{sheetId:e.model.getters.getActiveSheetId(),target:e.model.getters.getSelectedZones()}),icon:"o-spreadsheet-Icon.CLEAR_FORMAT"};function Jv(e){const t=e.model.getters.getCurrentStyle();if(t.align)return t.align;return e.model.getters.getActiveCell().defaultAlign}function eS(e){const t=e.model.getters.getCurrentStyle();return t.verticalAlign?t.verticalAlign:te}function tS(e){const t=e.model.getters.getCurrentStyle();return t.wrapping?t.wrapping:oe}var oS=Object.freeze({__proto__:null,clearFormat:Qv,decraseDecimalPlaces:Ov,fillColor:Xv,formatAlignment:Lv,formatAlignmentBottom:Gv,formatAlignmentCenter:kv,formatAlignmentHorizontal:Pv,formatAlignmentLeft:Vv,formatAlignmentMiddle:zv,formatAlignmentRight:Uv,formatAlignmentTop:Hv,formatAlignmentVertical:Bv,formatBold:_v,formatCF:Kv,formatCustomCurrency:mv,formatFontSize:Dv,formatItalic:Mv,formatNumberAutomatic:av,formatNumberCurrency:dv,formatNumberCurrencyRounded:uv,formatNumberDate:fv,formatNumberDateTime:vv,formatNumberDayAndFullMonth:wv,formatNumberDayAndShortMonth:Iv,formatNumberDuration:Sv,formatNumberFullDateTime:Ev,formatNumberFullMonth:Rv,formatNumberFullWeekDayAndMonth:yv,formatNumberNumber:lv,formatNumberPercent:hv,formatNumberShortMonth:Tv,formatNumberShortWeekDay:xv,formatNumberTime:bv,formatPercent:cv,formatStrikethrough:Fv,formatUnderline:Nv,formatWrapping:Wv,formatWrappingClip:Yv,formatWrappingIcon:$v,formatWrappingOverflow:qv,formatWrappingWrap:Zv,incraseDecimalPlaces:Av,moreFormats:Cv,textColor:jv});const sS=new Pa;sS.add("cut",{...lc,sequence:10}).add("copy",{...ac,sequence:20}).add("paste",{...cc,sequence:30}).add("paste_special",{...hc,sequence:40,separator:!0}).addChild("paste_value_only",["paste_special"],{...dc,sequence:10}).addChild("paste_format_only",["paste_special"],{...uc,sequence:20}).add("sort_columns",{...Qb,name:e=>e.model.getters.getActiveCols().size>1?a("Sort columns"):a("Sort column"),sequence:50,separator:!0}).addChild("sort_ascending",["sort_columns"],{...Jb,sequence:10}).addChild("sort_descending",["sort_columns"],{...sv,sequence:20}).add("add_column_before",{...Kf,sequence:70}).add("add_column_after",{...eb,sequence:80}).add("delete_column",{...vc,sequence:90,icon:"o-spreadsheet-Icon.DELETE"}).add("clear_column",{...Cc,sequence:100,icon:"o-spreadsheet-Icon.CLEAR"}).add("hide_columns",{...yb,sequence:105,separator:!0}).add("unhide_columns",{...wb,sequence:106,separator:!0}).add("conditional_formatting",{...Kv,sequence:110,separator:!0}).add("group_columns",{sequence:120,...Hb}).add("ungroup_columns",{sequence:130,...Gb,isVisible:e=>Xb(e,"COL")});const nS=new Pa;nS.add("format_number_automatic",{...av,sequence:10,separator:!0}).add("format_number_number",{...lv,sequence:20}).add("format_number_percent",{...hv,sequence:30,separator:!0}).add("format_number_currency",{...dv,sequence:40}).add("format_number_currency_rounded",{...uv,sequence:50}).add("format_custom_currency",{...mv,sequence:60,separator:!0}).add("format_number_date",{...fv,sequence:70}).add("format_number_time",{...bv,sequence:80}).add("format_number_date_time",{...vv,sequence:90}).add("format_number_duration",{...Sv,sequence:100,separator:!0}).add("more_formats",{...Cv,sequence:110});const iS={name:a("More formats"),icon:"o-spreadsheet-Icon.NUMBER_FORMATS",children:[()=>nS.getAll()]},rS=new Pa;rS.add("cut",{...lc,sequence:10}).add("copy",{...ac,sequence:20}).add("paste",{...cc,sequence:30}).add("paste_special",{...hc,sequence:40,separator:!0}).addChild("paste_value_only",["paste_special"],{...dc,sequence:10}).addChild("paste_format_only",["paste_special"],{...uc,sequence:20}).add("add_row_before",{...Wf,sequence:50}).add("add_row_after",{...Yf,sequence:60}).add("delete_row",{...mc,sequence:70,icon:"o-spreadsheet-Icon.DELETE"}).add("clear_row",{...bc,sequence:80,icon:"o-spreadsheet-Icon.CLEAR"}).add("hide_rows",{...Ib,sequence:85,separator:!0}).add("unhide_rows",{...Rb,sequence:86,separator:!0}).add("conditional_formatting",{...Kv,sequence:90,separator:!0}).add("group_rows",{sequence:100,...zb}).add("ungroup_rows",{sequence:110,...$b,isVisible:e=>Xb(e,"ROW")});const aS=new Pa;aS.add("file",{name:a("File"),sequence:10}).addChild("settings",["file"],{name:a("Settings"),sequence:100,execute:e=>e.openSidePanel("Settings"),icon:"o-spreadsheet-Icon.COG"}).add("edit",{name:a("Edit"),sequence:20}).addChild("undo",["edit"],{...ic,sequence:10}).addChild("redo",["edit"],{...rc,sequence:20,separator:!0}).addChild("copy",["edit"],{...ac,sequence:30}).addChild("cut",["edit"],{...lc,sequence:40}).addChild("paste",["edit"],{...cc,sequence:50}).addChild("paste_special",["edit"],{...hc,sequence:60,separator:!0}).addChild("paste_special_value",["edit","paste_special"],{...dc,sequence:10}).addChild("paste_special_format",["edit","paste_special"],{...uc,sequence:20}).addChild("find_and_replace",["edit"],{...gc,sequence:65,separator:!0}).addChild("delete",["edit"],{name:a("Delete"),icon:"o-spreadsheet-Icon.DELETE",sequence:70}).addChild("edit_delete_cell_values",["edit","delete"],{...pc,sequence:10}).addChild("edit_delete_row",["edit","delete"],{...mc,sequence:20}).addChild("edit_delete_column",["edit","delete"],{...vc,sequence:30}).addChild("edit_delete_cell_shift_up",["edit","delete"],{...yc,sequence:40}).addChild("edit_delete_cell_shift_left",["edit","delete"],{...wc,sequence:50}).addChild("edit_unhide_columns",["edit"],{...xb,sequence:80}).addChild("edit_unhide_rows",["edit"],{...Tb,sequence:80}).add("view",{name:a("View"),sequence:30}).addChild("unfreeze_panes",["view"],{...Ab,sequence:4}).addChild("freeze_panes",["view"],{...Ob,sequence:5}).addChild("unfreeze_rows",["view","freeze_panes"],{..._b,sequence:5}).addChild("freeze_first_row",["view","freeze_panes"],{...Mb,sequence:10}).addChild("freeze_second_row",["view","freeze_panes"],{...Nb,sequence:15}).addChild("freeze_current_row",["view","freeze_panes"],{...Fb,sequence:20,separator:!0}).addChild("unfreeze_columns",["view","freeze_panes"],{...Db,sequence:25}).addChild("freeze_first_col",["view","freeze_panes"],{...Lb,sequence:30}).addChild("freeze_second_col",["view","freeze_panes"],{...Pb,sequence:35}).addChild("freeze_current_col",["view","freeze_panes"],{...Vb,sequence:40}).addChild("group_headers",["view"],{name:a("Group"),sequence:15,separator:!0,icon:"o-spreadsheet-Icon.PLUS_IN_BOX",isVisible:sc}).addChild("group_columns",["view","group_headers"],{...Hb,sequence:5}).addChild("ungroup_columns",["view","group_headers"],{...Gb,isVisible:e=>Xb(e,"COL"),sequence:10}).addChild("group_rows",["view","group_headers"],{...zb,sequence:15}).addChild("ungroup_rows",["view","group_headers"],{...$b,isVisible:e=>Xb(e,"ROW"),sequence:20}).addChild("view_gridlines",["view"],{...kb,sequence:15}).addChild("view_formulas",["view"],{...Ub,sequence:20}).add("insert",{name:a("Insert"),sequence:40}).addChild("insert_row",["insert"],{...$f,sequence:10}).addChild("insert_row_before",["insert","insert_row"],{...qf,sequence:10}).addChild("insert_row_after",["insert","insert_row"],{...jf,sequence:20}).addChild("insert_column",["insert"],{...Xf,sequence:20}).addChild("insert_column_before",["insert","insert_column"],{...Qf,sequence:10}).addChild("insert_column_after",["insert","insert_column"],{...tb,sequence:20}).addChild("insert_cell",["insert"],{...ob,sequence:43}).addChild("insert_cell_down",["insert","insert_cell"],{...sb,name:a("Shift down"),sequence:10}).addChild("insert_cell_right",["insert","insert_cell"],{...nb,name:a("Shift right"),sequence:20}).addChild("insert_sheet",["insert"],{...mb,sequence:80,separator:!0}).addChild("insert_chart",["insert"],{...ib,sequence:50}).addChild("insert_image",["insert"],{...rb,sequence:55}).addChild("insert_function",["insert"],{...ab,sequence:60}).addChild("insert_function_sum",["insert","insert_function"],{...lb,sequence:0}).addChild("insert_function_average",["insert","insert_function"],{...cb,sequence:10}).addChild("insert_function_count",["insert","insert_function"],{...hb,sequence:20}).addChild("insert_function_max",["insert","insert_function"],{...db,sequence:30}).addChild("insert_function_min",["insert","insert_function"],{...ub,sequence:40,separator:!0}).addChild("categorie_function_all",["insert","insert_function"],{...gb,sequence:50}).addChild("categories_function_list",["insert","insert_function"],(()=>{const e=Gf.content;return[...new Set(Gf.getAll().filter((e=>!e.hidden)).map((e=>e.category)))].filter(We).sort().map(((t,o)=>{const s=Object.keys(e).filter((o=>e[o].category===t&&!e[o].hidden));return{name:t,children:fb(s)}}))})).addChild("insert_link",["insert"],{...pb,separator:!0,sequence:70}).add("format",{name:a("Format"),sequence:50}).addChild("format_number",["format"],{...iS,name:a("Number"),sequence:10,separator:!0}).addChild("format_bold",["format"],{..._v,sequence:20}).addChild("format_italic",["format"],{...Mv,sequence:30}).addChild("format_underline",["format"],{...Nv,sequence:40}).addChild("format_strikethrough",["format"],{...Fv,sequence:50,separator:!0}).addChild("format_font_size",["format"],{...Dv,sequence:60,separator:!0}).addChild("format_alignment",["format"],{...Lv,sequence:70}).addChild("format_alignment_left",["format","format_alignment"],{...Vv,sequence:10}).addChild("format_alignment_center",["format","format_alignment"],{...kv,sequence:20}).addChild("format_alignment_right",["format","format_alignment"],{...Uv,sequence:30,separator:!0}).addChild("format_alignment_top",["format","format_alignment"],{...Hv,sequence:40}).addChild("format_alignment_middle",["format","format_alignment"],{...zv,sequence:50}).addChild("format_alignment_bottom",["format","format_alignment"],{...Gv,sequence:60,separator:!0}).addChild("format_wrapping",["format"],{...$v,sequence:80,separator:!0}).addChild("format_wrapping_overflow",["format","format_wrapping"],{...qv,sequence:10}).addChild("format_wrapping_wrap",["format","format_wrapping"],{...Zv,sequence:20}).addChild("format_wrapping_clip",["format","format_wrapping"],{...Yv,sequence:30}).addChild("format_cf",["format"],{...Kv,sequence:90,separator:!0}).addChild("format_clearFormat",["format"],{...Qv,sequence:100,separator:!0}).add("data",{name:a("Data"),sequence:60}).addChild("sort_range",["data"],{...Qb,sequence:10,separator:!0}).addChild("sort_ascending",["data","sort_range"],{...Jb,sequence:10}).addChild("sort_descending",["data","sort_range"],{...sv,sequence:20}).addChild("data_cleanup",["data"],{...ev,sequence:15}).addChild("remove_duplicates",["data","data_cleanup"],{...tv,sequence:10}).addChild("trim_whitespace",["data","data_cleanup"],{...ov,sequence:20}).addChild("split_to_columns",["data"],{...iv,sequence:20}).addChild("data_validation",["data"],{name:a("Data Validation"),execute:e=>{e.openSidePanel("DataValidation")},icon:"o-spreadsheet-Icon.DATA_VALIDATION",sequence:30,separator:!0}).addChild("add_remove_data_filter",["data"],{...nv,sequence:40,separator:!0});const lS=new class extends Zi{addTransformation(e,t,o){this.content[e]||(this.content[e]=new Map);for(const s of t)this.content[e].set(s,o);return this}getTransformation(e,t){return this.content[t]&&this.content[t].get(e)}},cS={ArrowDown:"down",ArrowLeft:"left",ArrowRight:"right",ArrowUp:"up"};function hS(e,t){const o=cS[e.key];e.shiftKey?t.resizeAnchorZone(o,Vr(e)?"end":1):t.moveAnchorCell(o,Vr(e)?"end":1)}const dS=new li;Sr`
289
+ `;class Dl extends t.Component{static template="o-spreadsheet-ChartFigure";static components={};onDoubleClick(){this.env.model.dispatch("SELECT_FIGURE",{id:this.props.figure.id}),this.env.openSidePanel("ChartPanel")}get chartType(){return this.env.model.getters.getChartType(this.props.figure.id)}get chartComponent(){const e=this.chartType,t=Nl.get(e);if(!t)throw new Error(`Component is not defined for type ${e}`);return t}}Dl.props={figure:Object,onFigureDeleted:Function};class Ll extends t.Component{static template="o-spreadsheet-ImageFigure";static components={};get figureId(){return this.props.figure.id}get getImagePath(){return this.env.model.getters.getImagePath(this.figureId)}}function Pl(e,t){const o=Ae(t),s=e.getSheetViewDimension(),n=s.width,i=s.height;if(o.width>n){const e=n/o.width;o.width=n,o.height=o.height*e}if(o.height>i){const e=i/o.height;o.height=i,o.width=o.width*e}return o}Ll.props={figure:Object,onFigureDeleted:Function};const Vl=new Zi;function kl(e,t){return{id:"copy",name:a("Copy"),sequence:2,description:"Ctrl+C",execute:async()=>{t.model.dispatch("SELECT_FIGURE",{id:e}),t.model.dispatch("COPY"),await t.clipboard.write(t.model.getters.getClipboardContent())},icon:"o-spreadsheet-Icon.COPY"}}function Ul(e,t){return{id:"cut",name:a("Cut"),sequence:3,description:"Ctrl+X",execute:async()=>{t.model.dispatch("SELECT_FIGURE",{id:e}),t.model.dispatch("CUT"),await t.clipboard.write(t.model.getters.getClipboardContent())},icon:"o-spreadsheet-Icon.CUT"}}function Bl(e,t,o){return{id:"delete",name:a("Delete"),sequence:10,execute:()=>{o.model.dispatch("DELETE_FIGURE",{sheetId:o.model.getters.getActiveSheetId(),id:e}),t()},icon:"o-spreadsheet-Icon.DELETE"}}Vl.add("chart",{Component:Dl,SidePanelComponent:"ChartPanel",menuBuilder:function(e,t,o){return ci([{id:"edit",name:a("Edit"),sequence:1,execute:()=>{o.model.dispatch("SELECT_FIGURE",{id:e}),o.openSidePanel("ChartPanel")},icon:"o-spreadsheet-Icon.EDIT"},kl(e,o),Ul(e,o),Bl(e,t,o)])}}),Vl.add("image",{Component:Ll,keepRatio:!0,minFigSize:20,borderWidth:0,menuBuilder:function(e,t,o){return ci([kl(e,o),Ul(e,o),{id:"reset_size",name:a("Reset size"),sequence:4,execute:async()=>{const t=o.model.getters.getImagePath(e),s=o.model.getters.getImageSize(e)??await(o.imageProvider?.getImageOriginalSize(t));if(!o.model.getters.getImageSize(e)){o.model.getters.getImage(e).size=s}const{height:n,width:i}=Pl(o.model.getters,s);o.model.dispatch("UPDATE_FIGURE",{sheetId:o.model.getters.getActiveSheetId(),id:e,height:n,width:i})},icon:"o-spreadsheet-Icon.REFRESH"},Bl(e,t,o)])}});const Hl=(new Zi).add("ADD_COLUMNS_ROWS",(function(e){const t=[];let o=e.base;"after"===e.position&&o++;for(let s=0;s<e.quantity;s++)t.push(s+o);return[{type:"REMOVE_COLUMNS_ROWS",dimension:e.dimension,elements:t,sheetId:e.sheetId}]})).add("REMOVE_COLUMNS_ROWS",(function(e){const t=[],o=[...e.elements].sort(((e,t)=>e-t));for(let s of Fe(o)){const o=0===s[0]?0:s[0]-1,n=0===s[0]?"before":"after";t.push({type:"ADD_COLUMNS_ROWS",dimension:e.dimension,quantity:s.length,base:o,sheetId:e.sheetId,position:n})}return t})).add("ADD_MERGE",(function(e){return[{type:"REMOVE_MERGE",sheetId:e.sheetId,target:e.target}]})).add("REMOVE_MERGE",(function(e){return[{type:"ADD_MERGE",sheetId:e.sheetId,target:e.target}]})).add("CREATE_SHEET",(function(e){return[{type:"DELETE_SHEET",sheetId:e.sheetId}]})).add("DELETE_SHEET",(function(e){return[{type:"CREATE_SHEET",sheetId:e.sheetId,position:1}]})).add("DUPLICATE_SHEET",(function(e){return[{type:"DELETE_SHEET",sheetId:e.sheetIdTo}]})).add("CREATE_FIGURE",(function(e){return[{type:"DELETE_FIGURE",id:e.figure.id,sheetId:e.sheetId}]})).add("CREATE_CHART",(function(e){return[{type:"DELETE_FIGURE",id:e.id,sheetId:e.sheetId}]})).add("HIDE_COLUMNS_ROWS",(function(e){return[{type:"UNHIDE_COLUMNS_ROWS",sheetId:e.sheetId,dimension:e.dimension,elements:e.elements}]})).add("UNHIDE_COLUMNS_ROWS",(function(e){return[{type:"HIDE_COLUMNS_ROWS",sheetId:e.sheetId,dimension:e.dimension,elements:e.elements}]}));for(const lA of wo.values())Hl.contains(lA)||Hl.add(lA,zl);function zl(e){return[e]}function Gl(e){const t=e.model.dispatch("CUT");t.isSuccessful||t.isCancelledBecause("WrongCutSelection")&&e.raiseError(a("This operation is not allowed with multiple selections."))}const $l={MergeIsDestructive:a("Merging these cells will only preserve the top-leftmost value. Merge anyway?"),MergeInFilter:a("You can't merge cells inside of an existing filter.")};function Wl(e,t){const o=Ml.getAll().find((t=>t.match(e.type)));if(!o)throw new Error("Unknown chart type.");return o.transformDefinition(e,t)}function ql(e,t){let o=e;e.left!==e.right&&(o={...e,left:e.left+1});const s=[fn(o)],n=t.getActiveSheetId(),i=t.getCell({sheetId:n,col:e.left,row:e.top});if(1===Vn(e)&&i?.content)return{type:"scorecard",title:"",background:i.style?.fillColor||void 0,keyValue:fn(e),baselineMode:pe,baselineColorUp:me,baselineColorDown:fe};let r="";const l=t.getEvaluatedCellsInZone(n,{...o,bottom:o.top}),c=!!l.find((e=>e.type!==bo.empty&&e.type!==bo.number));if(c){const e=l.filter((e=>e.type!==bo.error&&e.type!==bo.empty)).map((e=>e.formattedValue)),t=e.splice(-1)[0];r=e.join(", "),t&&(r+=(r?" "+a("and")+" ":"")+t)}let h;e.left!==e.right&&(h=fn({...e,right:e.left}));const d=o.right===o.left?"none":"top",u={title:r,dataSets:s,labelsAsText:!1,stacked:!1,aggregated:!1,cumulative:!1,labelRange:h,type:"line",dataSetsHaveTitle:c,verticalAxisPosition:"left",legendPosition:d};return xl(new wl(u,n,t),t)?u:{title:r,dataSets:s,labelRange:h,type:"bar",stacked:!1,aggregated:!1,dataSetsHaveTitle:c,verticalAxisPosition:"left",legendPosition:d}}if(window.Chart){const cA=window.Chart?.DoughnutController;class hA extends cA{static id="gauge";static defaults={...cA.defaults,circumference:180,rotation:270};static overrides={aspectRatio:2,plugins:{legend:{display:!1},tooltip:{enabled:!1}}};get chartHeight(){return Math.abs(this.chart.chartArea.top-this.chart.chartArea.bottom)}get chartWidth(){return Math.abs(this.chart.chartArea.left-this.chart.chartArea.right)}get needleOptions(){const{config:e}=this.chart,t=e.options;return t?.needle||{}}get valueLabelOptions(){const{config:e}=this.chart,t=e.options;return t?.valueLabel||{}}get minValue(){return this.getDataset().minValue||0}getValueAngleInPercent(e){const t=this.getDataset().data||[],o=Math.max(...t),s=this.minValue;return(e-s)/(o-s)}drawValueLabel(e){const{ctx:t}=this.chart;!1!==this.valueLabelOptions.display&&(t.save(),t.beginPath(),t.fillStyle=e.valueLabel.backgroundColor,t.strokeStyle=e.valueLabel.borderColor,t.roundRect(e.valueLabel.rect.x,e.valueLabel.rect.y,e.valueLabel.rect.width,e.valueLabel.rect.height,e.valueLabel.borderRadius),t.stroke(),t.fill(),t.textAlign="center",t.textBaseline="middle",t.font=e.valueLabel.font,t.fillStyle=e.valueLabel.textColor,t.fillText(e.valueLabel.valueText,e.valueLabel.textPosition.x,e.valueLabel.textPosition.y),t.restore())}drawNeedle(e){const{ctx:t}=this.chart;!1!==this.needleOptions.display&&(t.save(),t.translate(e.needle.position.x,e.needle.position.y),t.rotate(-Math.PI/2+Math.PI*e.needle.percent),t.beginPath(),t.fillStyle=e.needle.backgroundColor,t.strokeStyle=e.needle.borderColor,t.ellipse(0,0,e.needle.width/2,e.needle.width/2,0,0,2*Math.PI),t.fill(),t.stroke(),t.closePath(),t.fillStyle=e.needle.backgroundColor,t.strokeStyle=e.needle.borderColor,t.beginPath(),t.moveTo(-e.needle.width/2,0),t.lineTo(0,10-e.needle.height),t.lineTo(+e.needle.width/2,0),t.closePath(),t.fill(),t.stroke(),t.restore())}computeRenderingParams(){const{ctx:e,config:t}=this.chart,o=t.options;o.layout=o.layout||{},o.layout.padding=o.layout.padding||{};const s=this.valueLabelOptions.formatter,n="function"==typeof s?s:e=>e,i=this.getDataset().value||0,r=n(i).toString(),a=this.getValueAngleInPercent(i),l=this.valueLabelOptions.font?.family||"Arial",c=this.valueLabelOptions.font?.size||0,h=`${c>=1?c:30}px ${l}`,d={right:0,left:0,top:0,bottom:0,...this.valueLabelOptions.padding};d.left=d.left>=0?d.left:10,d.right=d.right>=0?d.right:10,d.top=d.top>=0?d.top:10,d.bottom=d.bottom>=0?d.bottom:10;const u=this.chart.chartArea,g=this.offsetX||0,p=this.offsetY||0,m={x:(u.left+u.right)/2+g,y:(u.top+u.bottom)/2+p},f={x:m.x,y:m.y};e.save(),e.font=h;const b=e.measureText(r);e.restore();const v=b.fontBoundingBoxAscent-b.fontBoundingBoxDescent;return{needle:{borderColor:this.needleOptions.borderColor||"#000",backgroundColor:this.needleOptions.backgroundColor||"#000",width:this.needleOptions.width||10,height:Math.min(this.chartHeight,this.chartWidth/2),position:{x:f.x,y:f.y},percent:a},valueLabel:{textColor:this.valueLabelOptions.font?.color||"#FFF",backgroundColor:this.valueLabelOptions.backgroundColor||"#000",borderColor:this.valueLabelOptions.borderColor||"#000",borderRadius:this.valueLabelOptions.borderRadius||10,rect:{x:m.x-b.width/2-d.left,y:m.y+v/2+d.top,width:b.width+d.left+d.right,height:-(v+6+d.top+d.bottom)},valueText:r,textPosition:f,textHeight:v,font:h}}}draw(){super.draw();const e=this.computeRenderingParams();this.drawNeedle(e),this.drawValueLabel(e)}updateElements(e,t,o,s){super.updateElements(e,t,o,s);const n=this.getDataset(),i=this.getDataset().data,r=n.minValue,a=this.chart.options.rotation||0,l=this.chart.options.circumference||0;for(let t=0;t<i.length;t++){const o=0===t?r:i[t-1],n=this.getValueAngleInPercent(o),c=this.getValueAngleInPercent(i[t]),h=dA(a+l*n)-Math.PI/2,d=dA(a+l*c)-Math.PI/2,u=d-h,g=e[t],p={startAngle:h,endAngle:d,circumference:u};this.updateElement(g,t,p,s)}}}function dA(e){return e*Math.PI/180}window.Chart.register(hA)}function Zl(e,t){e.model.dispatch("CANCEL_EDITION"),e.model.dispatch("SET_FORMATTING",{sheetId:e.model.getters.getActiveSheetId(),target:e.model.getters.getSelectedZones(),format:t})}function Yl(e,t){e.model.dispatch("SET_FORMATTING",{sheetId:e.model.getters.getActiveSheetId(),target:e.model.getters.getSelectedZones(),style:t})}const jl=async e=>Xl(e,"onlyValue");async function Xl(e,t){const o=e.model.getters.getClipboardTextContent(),s=await e.clipboard.readText();switch(s.status){case"ok":const n=e.model.getters.getSelectedZones();s&&s.content!==o?Wa(e,n,s.content,t):$a(e,n,t),e.model.getters.isCutOperation()&&"onlyValue"!==t&&await e.clipboard.write({[vo.PlainText]:""});break;case"notImplemented":e.raiseError(a("Pasting from the context menu is not supported in this browser. Use keyboard shortcuts ctrl+c / ctrl+v instead."));break;case"permissionDenied":e.raiseError(a("Access to the clipboard denied by the browser. Please enable clipboard permission for this page in your browser settings."))}}const Kl=(e,t)=>{if("COL"===e&&t.model.getters.getActiveRows().size>0||"ROW"===e&&t.model.getters.getActiveCols().size>0)return!1;const o=t.model.getters.getActiveSheetId(),s=t.model.getters.getElementsFromSelection(e),n=t.model.getters.checkElementsIncludeAllVisibleHeaders(o,e,s),i=t.model.getters.checkElementsIncludeAllNonFrozenHeaders(o,e,s);return!n&&!i},Ql=e=>{const t=e.model.getters.getActiveRows();let o,s;if(t.size)o=gt([...t]),s=t.size;else{const t=e.model.getters.getSelectedZones()[0];o=t.top,s=t.bottom-t.top+1}e.model.dispatch("ADD_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),position:"before",base:o,quantity:s,dimension:"ROW"})},Jl=e=>{const t=e.model.getters.getActiveCols();let o,s;if(t.size)o=gt([...t]),s=t.size;else{const t=e.model.getters.getSelectedZones()[0];o=t.left,s=t.right-t.left+1}e.model.dispatch("ADD_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),position:"before",dimension:"COL",base:o,quantity:s})},ec=e=>{const t=e.model.getters.getActiveCols();let o,s;if(t.size)o=ut([...t]),s=t.size;else{const t=e.model.getters.getSelectedZones()[0];o=t.right,s=t.right-t.left+1}e.model.dispatch("ADD_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),position:"after",dimension:"COL",base:o,quantity:s})};const tc=async e=>{if(e.imageProvider){const t=e.model.getters.getActiveSheetId(),o=e.model.uuidGenerator.smallUuid(),s=await async function(e){try{return await e.imageProvider.requestImage()}catch{return void e.raiseError(a("An unexpected error occurred during the image transfer"))}}(e);if(!s)throw new Error("No image provider was given to the environment");const n=Pl(e.model.getters,s.size),i=function(e,t){const{x:o,y:s}=e.getMainViewportCoordinates(),{scrollX:n,scrollY:i}=e.getActiveSheetScrollInfo(),r=e.getSheetViewDimension(),a=e.getVisibleRect(e.getActiveMainViewport()),l=Math.min(a.width,r.width-o),c=Math.min(a.height,r.height-s);return{x:o+n+Math.max(0,(l-t.width)/2),y:s+i+Math.max(0,(c-t.height)/2)}}(e.model.getters,n);e.model.dispatch("CREATE_IMAGE",{sheetId:t,figureId:o,position:i,size:n,definition:s})}},oc=e=>{let{col:t,row:o}=e.model.getters.getActivePosition();e.model.dispatch("OPEN_CELL_POPOVER",{col:t,row:o,popoverType:"LinkEditor"})},sc=e=>1===e.model.getters.getSelectedZones().length,nc=(e,t)=>{if(!sc(e))return!1;const o="COL"===t?e.model.getters.getActiveCols():e.model.getters.getActiveRows(),s="COL"===t?e.model.getters.getActiveRows():e.model.getters.getActiveCols(),n=e.model.getters.getActiveSheetId(),i=wn(e.model.getters.getSelectedZone(),e.model.getters.getSheetZone(n));return rt(o)&&(0===s.size||i)},ic={name:a("Undo"),description:"Ctrl+Z",execute:e=>e.model.dispatch("REQUEST_UNDO"),isEnabled:e=>e.model.getters.canUndo(),icon:"o-spreadsheet-Icon.UNDO"},rc={name:a("Redo"),description:"Ctrl+Y",execute:e=>e.model.dispatch("REQUEST_REDO"),isEnabled:e=>e.model.getters.canRedo(),icon:"o-spreadsheet-Icon.REDO"},ac={name:a("Copy"),description:"Ctrl+C",isReadonlyAllowed:!0,execute:async e=>{e.model.dispatch("COPY"),await e.clipboard.write(e.model.getters.getClipboardContent())},icon:"o-spreadsheet-Icon.COPY"},lc={name:a("Cut"),description:"Ctrl+X",execute:async e=>{Gl(e),await e.clipboard.write(e.model.getters.getClipboardContent())},icon:"o-spreadsheet-Icon.CUT"},cc={name:a("Paste"),description:"Ctrl+V",execute:async e=>Xl(e),icon:"o-spreadsheet-Icon.PASTE"},hc={name:a("Paste special"),isVisible:e=>!e.model.getters.isCutOperation(),icon:"o-spreadsheet-Icon.PASTE"},dc={name:a("Paste value only"),description:"Ctrl+Shift+V",execute:jl},uc={name:a("Paste format only"),execute:e=>Xl(e,"onlyFormat")},gc={name:a("Find and replace"),description:"Ctrl+H",isReadonlyAllowed:!0,execute:e=>{e.openSidePanel("FindAndReplace",{})},icon:"o-spreadsheet-Icon.FIND_AND_REPLACE"},pc={name:a("Delete values"),execute:e=>e.model.dispatch("DELETE_CONTENT",{sheetId:e.model.getters.getActiveSheetId(),target:e.model.getters.getSelectedZones()})},mc={name:e=>{if(e.model.getters.getSelectedZones().length>1)return a("Delete rows");let t,o;const s=e.model.getters.getActiveRows();if(0!==s.size)t=gt([...s]),o=ut([...s]);else{const s=e.model.getters.getSelectedZones()[0];t=s.top,o=s.bottom}return t===o?a("Delete row %s",(t+1).toString()):a("Delete rows %s - %s",(t+1).toString(),(o+1).toString())},execute:e=>{let t=[...e.model.getters.getActiveRows()];if(!t.length){const o=e.model.getters.getSelectedZones()[0];for(let e=o.top;e<=o.bottom;e++)t.push(e)}e.model.dispatch("REMOVE_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),dimension:"ROW",elements:t})},isVisible:e=>Kl("ROW",e)},fc={...mc,isVisible:sc},bc={name:e=>{if(e.model.getters.getSelectedZones().length>1)return a("Clear rows");let t,o;const s=e.model.getters.getActiveRows();if(0!==s.size)t=gt([...s]),o=ut([...s]);else{const s=e.model.getters.getSelectedZones()[0];t=s.top,o=s.bottom}return t===o?a("Clear row %s",(t+1).toString()):a("Clear rows %s - %s",(t+1).toString(),(o+1).toString())},execute:e=>{const t=e.model.getters.getActiveSheetId(),o=[...e.model.getters.getActiveRows()].map((o=>e.model.getters.getRowsZone(t,o,o)));e.model.dispatch("DELETE_CONTENT",{target:o,sheetId:e.model.getters.getActiveSheetId()})}},vc={name:e=>{if(e.model.getters.getSelectedZones().length>1)return a("Delete columns");let t,o;const s=e.model.getters.getActiveCols();if(0!==s.size)t=gt([...s]),o=ut([...s]);else{const s=e.model.getters.getSelectedZones()[0];t=s.left,o=s.right}return t===o?a("Delete column %s",Ot(t)):a("Delete columns %s - %s",Ot(t),Ot(o))},execute:e=>{let t=[...e.model.getters.getActiveCols()];if(!t.length){const o=e.model.getters.getSelectedZones()[0];for(let e=o.left;e<=o.right;e++)t.push(e)}e.model.dispatch("REMOVE_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),dimension:"COL",elements:t})},isVisible:e=>Kl("COL",e)},Sc={...vc,isVisible:sc},Cc={name:e=>{if(e.model.getters.getSelectedZones().length>1)return a("Clear columns");let t,o;const s=e.model.getters.getActiveCols();if(0!==s.size)t=gt([...s]),o=ut([...s]);else{const s=e.model.getters.getSelectedZones()[0];t=s.left,o=s.right}return t===o?a("Clear column %s",Ot(t)):a("Clear columns %s - %s",Ot(t),Ot(o))},execute:e=>{const t=e.model.getters.getActiveSheetId(),o=[...e.model.getters.getActiveCols()].map((o=>e.model.getters.getColsZone(t,o,o)));e.model.dispatch("DELETE_CONTENT",{target:o,sheetId:e.model.getters.getActiveSheetId()})}},Ec={name:a("Delete cells"),isVisible:sc},yc={name:a("Delete cell and shift up"),execute:e=>{const t=e.model.getters.getSelectedZone(),o=e.model.dispatch("DELETE_CELL",{zone:t,shiftDimension:"ROW"});Ga(e,o)}},wc={name:a("Delete cell and shift left"),execute:e=>{const t=e.model.getters.getSelectedZone(),o=e.model.dispatch("DELETE_CELL",{zone:t,shiftDimension:"COL"});Ga(e,o)}},xc={name:a("Merge cells"),isEnabled:e=>!Ic(e),isActive:e=>Rc(e),execute:e=>function(e){if(Ic(e))return;const t=e.model.getters.getSelectedZones(),o=[t[t.length-1]],s=e.model.getters.getActiveSheetId();Rc(e)?e.model.dispatch("REMOVE_MERGE",{sheetId:s,target:o}):function(e,t,o){const s=e.model.dispatch("ADD_MERGE",{sheetId:t,target:o});s.isCancelledBecause("MergeInFilter")?e.raiseError($l.MergeInFilter):s.isCancelledBecause("MergeIsDestructive")&&e.askConfirmation($l.MergeIsDestructive,(()=>{e.model.dispatch("ADD_MERGE",{sheetId:t,target:o,force:!0})}))}(e,s,o)}(e),icon:"o-spreadsheet-Icon.MERGE_CELL"};function Ic(e){const t=e.model.getters.getSelectedZones(),{top:o,left:s,right:n,bottom:i}=e.model.getters.getSelectedZone(),{sheetId:r}=e.model.getters.getActivePosition(),{xSplit:a,ySplit:l}=e.model.getters.getPaneDivisions(r);return t.length>1||o===i&&s===n||s<a&&a<=n||o<l&&l<=i}function Rc(e){if(!Ic(e)){const t=e.model.getters.getSelectedZones(),{col:o,row:s,sheetId:n}=e.model.getters.getActivePosition(),i=e.model.getters.expandZone(n,Ln({col:o,row:s}));return wn(t[0],i)}return!1}var Tc=Object.freeze({__proto__:null,clearCols:Cc,clearRows:bc,copy:ac,cut:lc,deleteCellShiftLeft:wc,deleteCellShiftUp:yc,deleteCells:Ec,deleteCol:Sc,deleteCols:vc,deleteRow:fc,deleteRows:mc,deleteValues:pc,findAndReplace:gc,mergeCells:xc,paste:cc,pasteSpecial:hc,pasteSpecialFormat:uc,pasteSpecialValue:dc,redo:rc,undo:ic});const Ac=/(.*?)\((.*?)\)(.*)/,Oc=["ANY","BOOLEAN","DATE","NUMBER","STRING","RANGE","RANGE<BOOLEAN>","RANGE<DATE>","RANGE<NUMBER>","RANGE<STRING>","META"];function _c(e,t=""){return function(e,t){let o=e.match(Ac),s=o[1].trim();if(!s)throw new Error(`Function argument definition is missing a name: '${e}'.`);let n,i=[],r=!1,a=!1,l=!1;for(let e of o[2].split(",")){const t=e.trim().toUpperCase();let o=Oc.find((e=>t===e));o?i.push(o):"RANGE<ANY>"===t?i.push("RANGE"):"OPTIONAL"===t?r=!0:"REPEATING"===t?a=!0:"LAZY"===t?l=!0:t.startsWith("DEFAULT=")&&(n=e.trim().slice(8))}const c={name:s,description:t,type:i};r&&(c.optional=!0);a&&(c.repeating=!0);l&&(c.lazy=!0);void 0!==n&&(c.default=!0,c.defaultValue=n);i.some((e=>e.startsWith("RANGE")))&&(c.acceptMatrix=!0);return c}(e,t)}function Mc(e){let t=0,o=0,s=0;for(let n of e.args)t++,n.optional||n.repeating||n.default||o++,n.repeating&&s++;const n=e;return n.minArgRequired=o,n.maxArgPossible=s?1/0:t,n.nbrArgRepeating=s,n.getArgToFocus=function(e,t){if(!t)return e=>e;if(1===t)return t=>Math.min(t,e);const o=e-t;return e=>{if(e<=o)return e;return o+((e-o)%t||t)}}(t,s),n.hidden=e.hidden||!1,n}function Nc(e,t){Lo((()=>1===t.length||1===t[0].length),e)}function Fc(e,...t){if(t.every(Mo)){const o=t[0].length,s=t[0][0].length;for(const n of t)Lo((()=>n.length===o&&n[0].length===s),e)}else if(t.some((e=>Array.isArray(e)&&(1!==e.length||1!==e[0].length))))throw new Error(e)}function Dc(e,t){Lo((()=>t>0),e)}function Lc(e,t){Lo((()=>t.length===t[0].length),e)}function Pc(e){return e.every((e=>e.every((e=>"number"==typeof e))))}function Vc(e){const t=Array(e);for(let o=0;o<e;o++)t[o]=Array(e).fill(0),t[o][o]=1;return t}function kc(e){if(e.length<1||e[0].length<1)throw new Error("invertMatrix: an empty matrix cannot be inverted.");if(e.length!==e[0].length)throw new Error("invertMatrix: only square matrices are invertible");let t=1;const o=e.length,s=Vc(o),n=e.map((e=>e.slice()));for(let e=0;e<o;e++){let i=n[e][e];if(0===i){for(let i=e+1;i<o;i++)if(0!=n[e][i]){Uc(n,e,i),Uc(s,e,i),t*=-1;break}if(i=n[e][e],0===i)return{determinant:0}}for(let t=0;t<o;t++)n[t][e]=n[t][e]/i,s[t][e]=s[t][e]/i;t*=i;for(let t=0;t<o;t++){if(t===e)continue;const i=n[e][t];for(let r=0;r<o;r++)n[r][t]-=i*n[r][e],s[r][t]-=i*s[r][e]}}return{inverted:s,determinant:t}}function Uc(e,t,o){for(let s=0;s<e.length;s++){const n=e[s][t];e[s][t]=e[s][o],e[s][o]=n}}function Bc(e,t){if(e.length<1||t.length<1)throw new Error("multiplyMatrices: empty matrices cannot be multiplied.");if(e.length!==t[0].length)throw new Error("multiplyMatrices: incompatible matrices size.");const o=e[0].length,s=t.length,n=e.length,i=Array(s);for(let r=0;r<s;r++){i[r]=Array(o);for(let s=0;s<o;s++){let o=0;for(let i=0;i<n;i++)o+=e[i][s]*t[r][i];i[r][s]=o}}return i}function Hc(e){if(!Mo(e))return e;if(1!==e.length||1!==e[0].length)throw new Error("toScalar: matrix should be a scalar or a 1x1 matrix");return e[0][0]}const zc={description:a("Returns a result array constrained to a specific width and height."),args:[_c("input_range (any, range<any>)",a("The range to constrain.")),_c("rows (number)",a("The number of rows in the constrained array.")),_c("columns (number)",a("The number of columns in the constrained array."))],returns:["RANGE<ANY>"],computeValueAndFormat:function(e,t,o){const s=gs(e),n=Ho(t?.value,this.locale),i=Ho(o?.value,this.locale);Dc(a("The rows argument (%s) must be strictly positive.",n.toString()),n),Dc(a("The columns argument (%s) must be strictly positive.",n.toString()),i);const r=Math.min(n,s[0].length);return os(Math.min(i,s.length),r,((e,t)=>s[e][t]))},isExported:!1},Gc={description:a("Creates a new array from the selected columns in the existing range."),args:[_c("array (any, range<any>)",a("The array that contains the columns to be returned.")),_c("col_num (number, range<number>)",a("The first column index of the columns to be returned.")),_c("col_num2 (number, range<number>, repeating)",a("The columns indexes of the columns to be returned."))],returns:["RANGE<ANY>"],computeValueAndFormat:function(e,...t){const o=gs(e),s=ps(t,(e=>Ho(e?.value,this.locale)));Lo((()=>s.every((e=>e>0&&e<=o.length))),a("The columns arguments must be between 1 and %s (got %s).",o.length.toString(),(s.find((e=>e<=0||e>o.length))||0).toString()));const n=Array(s.length);for(let e=0;e<s.length;e++){const t=s[e]-1;n[e]=o[t]}return n},isExported:!0},$c={description:a("Creates a new array from the selected rows in the existing range."),args:[_c("array (any, range<any>)",a("The array that contains the rows to be returned.")),_c("row_num (number, range<number>)",a("The first row index of the rows to be returned.")),_c("row_num2 (number, range<number>, repeating)",a("The rows indexes of the rows to be returned."))],returns:["RANGE<ANY>"],computeValueAndFormat:function(e,...t){const o=gs(e),s=ps(t,(e=>Ho(e?.value,this.locale))),n=o.length;return Lo((()=>s.every((e=>e>0&&e<=o[0].length))),a("The rows arguments must be between 1 and %s (got %s).",o[0].length.toString(),(s.find((e=>e<=0||e>o[0].length))||0).toString())),os(n,s.length,((e,t)=>o[e][s[t]-1]))},isExported:!0},Wc={description:a("Expands or pads an array to specified row and column dimensions."),args:[_c("array (any, range<any>)",a("The array to expand.")),_c("rows (number)",a("The number of rows in the expanded array. If missing, rows will not be expanded.")),_c("columns (number, optional)",a("The number of columns in the expanded array. If missing, columns will not be expanded.")),_c("pad_with (any, default=0)",a("The value with which to pad."))],returns:["RANGE<ANY>"],computeValueAndFormat:function(e,t,o,s={value:0}){const n=gs(e),i=Ho(t?.value,this.locale),r=void 0!==o?Ho(o.value,this.local):n.length;return Lo((()=>i>=n[0].length),a("The rows arguments (%s) must be greater or equal than the number of rows of the array.",i.toString())),Lo((()=>r>=n.length),a("The columns arguments (%s) must be greater or equal than the number of columns of the array.",r.toString())),os(r,i,((e,t)=>e>=n.length||t>=n[e].length?s:n[e][t]))},isExported:!0},qc={description:a("Flattens all the values from one or more ranges into a single column."),args:[_c("range (any, range<any>)",a("The first range to flatten.")),_c("range2 (any, range<any>, repeating)",a("Additional ranges to flatten."))],returns:["RANGE<ANY>"],computeValueAndFormat:function(...e){return[ps(e,(e=>void 0===e?{value:""}:e))]},isExported:!1},Zc={description:a("Calculates the frequency distribution of a range."),args:[_c("data (range<number>)",a("The array of ranges containing the values to be counted.")),_c("classes (number, range<number>)",a("The range containing the set of classes."))],returns:["RANGE<NUMBER>"],compute:function(e,t){const o=ps([e],(e=>e)).filter((e=>"number"==typeof e)),s=ps([t],(e=>e)).filter((e=>"number"==typeof e)).map(((e,t)=>({initialIndex:t,value:e,count:0}))).sort(((e,t)=>e.value-t.value));s.push({initialIndex:s.length,value:1/0,count:0});const n=o.sort(((e,t)=>e-t));let i=0;for(const e of n){for(;e>s[i].value&&i<s.length-1;)i++;s[i].count++}return[s.sort(((e,t)=>e.initialIndex-t.initialIndex)).map((e=>e.count))]},isExported:!0},Yc={description:a("Appends ranges horizontally and in sequence to return a larger array."),args:[_c("range1 (any, range<any>)",a("The first range to be appended.")),_c("range2 (any, range<any>, repeating)",a("Additional ranges to add to range1."))],returns:["RANGE<ANY>"],computeValueAndFormat:function(...e){const t=Math.max(...e.map((e=>e?.[0]?.length??0))),o=[];for(const s of e){const e=gs(s);for(let s=0;s<e.length;s++){const n=Array(t).fill({value:null});for(let t=0;t<e[s].length;t++)n[t]=e[s][t];o.push(n)}}return o},isExported:!0},jc={description:a("Returns the matrix determinant of a square matrix."),args:[_c("square_matrix (number, range<number>)",a("An range with an equal number of rows and columns representing a matrix whose determinant will be calculated."))],returns:["NUMBER"],compute:function(e){const t=gs(e);if(Lc(a("The argument square_matrix must have the same number of columns and rows."),t),!Pc(t))throw new Error(a("The argument square_matrix must be a matrix of numbers."));const{determinant:o}=kc(t);return o},isExported:!0},Xc={description:a("Returns the multiplicative inverse of a square matrix."),args:[_c("square_matrix (number, range<number>)",a("An range with an equal number of rows and columns representing a matrix whose multiplicative inverse will be calculated."))],returns:["RANGE<NUMBER>"],compute:function(e){const t=gs(e);if(Lc(a("The argument square_matrix must have the same number of columns and rows."),t),!Pc(t))throw new Error(a("The argument square_matrix must be a matrix of numbers."));const{inverted:o}=kc(t);if(!o)throw new Error(a("The matrix is not invertible."));return o},isExported:!0},Kc={description:a("Calculates the matrix product of two matrices."),args:[_c("matrix1 (number, range<number>)",a("The first matrix in the matrix multiplication operation.")),_c("matrix2 (number, range<number>)",a("The second matrix in the matrix multiplication operation."))],returns:["RANGE<NUMBER>"],compute:function(e,t){const o=gs(e),s=gs(t);if(Lo((()=>o.length>0&&s.length>0),a("The first and second arguments of [[FUNCTION_NAME]] must be non-empty matrices.")),Lo((()=>o.length===s[0].length),a("In [[FUNCTION_NAME]], the number of columns of the first matrix (%s) must be equal to the number of rows of the second matrix (%s).",o.length.toString(),s[0].length.toString())),!Pc(o)||!Pc(s))throw new Error(a("The arguments matrix1 and matrix2 must be matrices of numbers."));return Bc(o,s)},isExported:!0},Qc={description:a("Calculates the sum of the products of corresponding entries in equal-sized ranges."),args:[_c("range1 (number, range<number>)",a("The first range whose entries will be multiplied with corresponding entries in the other ranges.")),_c("range2 (number, range<number>, repeating)",a("The other range whose entries will be multiplied with corresponding entries in the other ranges."))],returns:["NUMBER"],compute:function(...e){Fc(a("All the ranges must have the same dimensions."),...e);const t=e.map(gs);let o=0;for(let e=0;e<t[0].length;e++)for(let s=0;s<t[0][e].length;s++){if(!t.every((t=>"number"==typeof t[e][s])))continue;let n=1;for(const o of t)n*=Vo(o[e][s],this.locale);o+=n}return o},isExported:!0};function Jc(e,t,o){Fc("The arguments array_x and array_y must have the same dimensions.",e,t);const s=gs(e),n=gs(t);let i=!1,r=0;for(const e in s)for(const t in s[e]){const a=s[e][t],l=n[e][t];"number"==typeof a&&"number"==typeof l&&(i=!0,r+=o(a,l))}if(!i)throw new Error("The arguments array_x and array_y must contain at least one pair of numbers.");return r}const eh={description:a("Calculates the sum of the difference of the squares of the values in two array."),args:[_c("array_x (number, range<number>)",a("The array or range of values whose squares will be reduced by the squares of corresponding entries in array_y and added together.")),_c("array_y (number, range<number>)",a("The array or range of values whose squares will be subtracted from the squares of corresponding entries in array_x and added together."))],returns:["NUMBER"],compute:function(e,t){return Jc(e,t,((e,t)=>e**2-t**2))},isExported:!0},th={description:a("Calculates the sum of the sum of the squares of the values in two array."),args:[_c("array_x (number, range<number>)",a("The array or range of values whose squares will be added to the squares of corresponding entries in array_y and added together.")),_c("array_y (number, range<number>)",a("The array or range of values whose squares will be added to the squares of corresponding entries in array_x and added together."))],returns:["NUMBER"],compute:function(e,t){return Jc(e,t,((e,t)=>e**2+t**2))},isExported:!0},oh={description:a("Calculates the sum of squares of the differences of values in two array."),args:[_c("array_x (number, range<number>)",a("The array or range of values that will be reduced by corresponding entries in array_y, squared, and added together.")),_c("array_y (number, range<number>)",a("The array or range of values that will be subtracted from corresponding entries in array_x, the result squared, and all such results added together."))],returns:["NUMBER"],compute:function(e,t){return Jc(e,t,((e,t)=>(e-t)**2))},isExported:!0},sh=!1,nh=[_c("array (any, range<any>)",a("The array which will be transformed.")),_c("ignore (number, default=0)",a("The control to ignore blanks and errors. 0 (default) is to keep all values, 1 is to ignore blanks, 2 is to ignore errors, and 3 is to ignore blanks and errors.")),_c("scan_by_column (number, default=false)",a("Whether the array should be scanned by column. True scans the array by column and false (default) scans the array by row."))],ih={description:a("Transforms a range of cells into a single column."),args:nh,returns:["RANGE<ANY>"],computeValueAndFormat:function(e,t={value:0},o={value:sh}){const s=gs(e),n=Ho(t.value,this.locale),i=Zo(o.value);Lo((()=>n>=0&&n<=3),a("Argument ignore must be between 0 and 3"));const r=(i?s:ns(s)).flat().filter((e=>1!==n&&3!==n||void 0!==e.value&&null!==e.value));if(0===r.length)throw new m(a("No results for the given arguments of TOCOL."));return[r]},isExported:!0},rh={description:a("Transforms a range of cells into a single row."),args:nh,returns:["RANGE<ANY>"],computeValueAndFormat:function(e,t={value:0},o={value:sh}){const s=gs(e),n=Ho(t.value,this.locale),i=Zo(o.value);Lo((()=>n>=0&&n<=3),a("Argument ignore must be between 0 and 3"));const r=(i?s:ns(s)).flat().filter((e=>1!==n&&3!==n||void 0!==e.value&&null!==e.value)).map((e=>[e]));if(0===r.length||0===r[0].length)throw new m(a("No results for the given arguments of TOROW."));return r},isExported:!0},ah={description:a("Transposes the rows and columns of a range."),args:[_c("range (any, range<any>)",a("The range to be transposed."))],returns:["RANGE"],computeValueAndFormat:function(e){const t=gs(e);return os(t[0].length,t.length,((e,o)=>t[o][e]))},isExported:!0},lh={description:a("Appends ranges vertically and in sequence to return a larger array."),args:[_c("range1 (any, range<any>)",a("The first range to be appended.")),_c("range2 (any, range<any>, repeating)",a("Additional ranges to add to range1."))],returns:["RANGE<ANY>"],computeValueAndFormat:function(...e){const t=Math.max(...e.map((e=>gs(e).length))),o=e.reduce(((e,t)=>e+gs(t)[0].length),0),s=Array(t).fill([]).map((()=>Array(o).fill({value:0})));let n=0;for(const t of e){const e=gs(t);for(let t=0;t<e.length;t++)for(let o=0;o<e[t].length;o++)s[t][n+o]=e[t][o];n+=e[0].length}return s},isExported:!0},ch={description:a("Wraps the provided row or column of cells by columns after a specified number of elements to form a new array."),args:[_c("range (any, range<any>)",a("The range to wrap.")),_c("wrap_count (number)",a("The maximum number of cells for each column, rounded down to the nearest whole number.")),_c("pad_with (any, default=0)",a("The value with which to fill the extra cells in the range."))],returns:["RANGE<ANY>"],computeValueAndFormat:function(e,t,o={value:0}){const s=gs(e),n=Ho(t?.value,this.locale);Nc(a("Argument range must be a single row or column."),s);const i=s.flat();return os(Math.ceil(i.length/n),n,((e,t)=>{const s=e*n+t;return s<i.length?i[s]:o}))},isExported:!0},hh={description:a("Wraps the provided row or column of cells by rows after a specified number of elements to form a new array."),args:[_c("range (any, range<any>)",a("The range to wrap.")),_c("wrap_count (number)",a("The maximum number of cells for each row, rounded down to the nearest whole number.")),_c("pad_with (any, default=0)",a("The value with which to fill the extra cells in the range."))],returns:["RANGE<ANY>"],computeValueAndFormat:function(e,t,o={value:0}){const s=gs(e),n=Ho(t?.value,this.locale);Nc(a("Argument range must be a single row or column."),s);const i=s.flat(),r=Math.ceil(i.length/n);return os(n,r,((e,t)=>{const s=t*n+e;return s<i.length?i[s]:o}))},isExported:!0};var dh=Object.freeze({__proto__:null,ARRAY_CONSTRAIN:zc,CHOOSECOLS:Gc,CHOOSEROWS:$c,EXPAND:Wc,FLATTEN:qc,FREQUENCY:Zc,HSTACK:Yc,MDETERM:jc,MINVERSE:Xc,MMULT:Kc,SUMPRODUCT:Qc,SUMX2MY2:eh,SUMX2PY2:th,SUMXMY2:oh,TOCOL:ih,TOROW:rh,TRANSPOSE:ah,VSTACK:lh,WRAPCOLS:ch,WRAPROWS:hh});const uh={description:a("Apply a large number format"),args:[_c("value (number)",a("The number.")),_c("unit (string, optional)",a("The formatting unit. Use 'k', 'm', or 'b' to force the unit"))],returns:["NUMBER"],computeFormat:function(e,t){const o=Math.abs(Vo(e?.value,this.locale)),s=e?.format;if(void 0!==t){const e=t?.value;switch(e){case"k":return Ws(s,1e3,"k",this.locale);case"m":return Ws(s,1e6,"m",this.locale);case"b":return Ws(s,1e9,"b",this.locale);default:throw new Error(a("The formatting unit should be 'k', 'm' or 'b'."))}}return o<1e5?Ws(s,0,"",this.locale):o<1e8?Ws(s,1e3,"k",this.locale):o<1e11?Ws(s,1e6,"m",this.locale):Ws(s,1e9,"b",this.locale)},compute:function(e){return Vo(e,this.locale)}};var gh=Object.freeze({__proto__:null,FORMAT_LARGE_NUMBER:uh});const ph=/^-?[a-z0-9]+$/i,mh={description:a("Absolute value of a number."),args:[_c("value (number)",a("The number of which to return the absolute value."))],returns:["NUMBER"],compute:function(e){return Math.abs(Vo(e,this.locale))},isExported:!0},fh={description:a("Inverse cosine of a value, in radians."),args:[_c("value (number)",a("The value for which to calculate the inverse cosine. Must be between -1 and 1, inclusive."))],returns:["NUMBER"],compute:function(e){const t=Vo(e,this.locale);return Lo((()=>Math.abs(t)<=1),a("The value (%s) must be between -1 and 1 inclusive.",t.toString())),Math.acos(t)},isExported:!0},bh={description:a("Inverse hyperbolic cosine of a number."),args:[_c("value (number)",a("The value for which to calculate the inverse hyperbolic cosine. Must be greater than or equal to 1."))],returns:["NUMBER"],compute:function(e){const t=Vo(e,this.locale);return Lo((()=>t>=1),a("The value (%s) must be greater than or equal to 1.",t.toString())),Math.acosh(t)},isExported:!0},vh={description:a("Inverse cotangent of a value."),args:[_c("value (number)",a("The value for which to calculate the inverse cotangent."))],returns:["NUMBER"],compute:function(e){const t=Vo(e,this.locale);return(Math.sign(t)||1)*Math.PI/2-Math.atan(t)},isExported:!0},Sh={description:a("Inverse hyperbolic cotangent of a value."),args:[_c("value (number)",a("The value for which to calculate the inverse hyperbolic cotangent. Must not be between -1 and 1, inclusive."))],returns:["NUMBER"],compute:function(e){const t=Vo(e,this.locale);return Lo((()=>Math.abs(t)>1),a("The value (%s) cannot be between -1 and 1 inclusive.",t.toString())),Math.log((t+1)/(t-1))/2},isExported:!0},Ch={description:a("Inverse sine of a value, in radians."),args:[_c("value (number)",a("The value for which to calculate the inverse sine. Must be between -1 and 1, inclusive."))],returns:["NUMBER"],compute:function(e){const t=Vo(e,this.locale);return Lo((()=>Math.abs(t)<=1),a("The value (%s) must be between -1 and 1 inclusive.",t.toString())),Math.asin(t)},isExported:!0},Eh={description:a("Inverse hyperbolic sine of a number."),args:[_c("value (number)",a("The value for which to calculate the inverse hyperbolic sine."))],returns:["NUMBER"],compute:function(e){return Math.asinh(Vo(e,this.locale))},isExported:!0},yh={description:a("Inverse tangent of a value, in radians."),args:[_c("value (number)",a("The value for which to calculate the inverse tangent."))],returns:["NUMBER"],compute:function(e){return Math.atan(Vo(e,this.locale))},isExported:!0},wh={description:a("Angle from the X axis to a point (x,y), in radians."),args:[_c("x (number)",a("The x coordinate of the endpoint of the line segment for which to calculate the angle from the x-axis.")),_c("y (number)",a("The y coordinate of the endpoint of the line segment for which to calculate the angle from the x-axis."))],returns:["NUMBER"],compute:function(e,t){const o=Vo(e,this.locale),s=Vo(t,this.locale);return Lo((()=>0!==o||0!==s),a("Function [[FUNCTION_NAME]] caused a divide by zero error.")),Math.atan2(s,o)},isExported:!0},xh={description:a("Inverse hyperbolic tangent of a number."),args:[_c("value (number)",a("The value for which to calculate the inverse hyperbolic tangent. Must be between -1 and 1, exclusive."))],returns:["NUMBER"],compute:function(e){const t=Vo(e,this.locale);return Lo((()=>Math.abs(t)<1),a("The value (%s) must be between -1 and 1 exclusive.",t.toString())),Math.atanh(t)},isExported:!0},Ih={description:a("Rounds number up to nearest multiple of factor."),args:[_c("value (number)",a("The value to round up to the nearest integer multiple of factor.")),_c("factor (number, default=1)",a("The number to whose multiples value will be rounded."))],returns:["NUMBER"],computeFormat:e=>e?.format,compute:function(e,t=1){const o=Vo(e,this.locale),s=Vo(t,this.locale);return Lo((()=>s>=0||o<=0),a("The factor (%s) must be positive when the value (%s) is positive.",s.toString(),o.toString())),s?Math.ceil(o/s)*s:0},isExported:!0},Rh={description:a("Rounds number up to nearest multiple of factor."),args:[_c("number (number)",a("The value to round up to the nearest integer multiple of significance.")),_c("significance (number, default=1)",a("The number to whose multiples number will be rounded. The sign of significance will be ignored.")),_c("mode (number, default=0)",a("If number is negative, specifies the rounding direction. If 0 or blank, it is rounded towards zero. Otherwise, it is rounded away from zero."))],returns:["NUMBER"],computeFormat:e=>e?.format,compute:function(e,t=1,o=0){let s=Vo(t,this.locale);if(0===s)return 0;const n=Vo(e,this.locale);if(s=Math.abs(s),n>=0)return Math.ceil(n/s)*s;return 0===Vo(o,this.locale)?-Math.floor(Math.abs(n)/s)*s:-Math.ceil(Math.abs(n)/s)*s},isExported:!0},Th={description:a("Rounds number up to nearest multiple of factor."),args:[_c("number (number)",a("The value to round up to the nearest integer multiple of significance.")),_c("significance (number, default=1)",a("The number to whose multiples number will be rounded."))],returns:["NUMBER"],computeFormat:e=>e?.format,compute:function(e,t){return Rh.compute.bind(this)(e,t,0)},isExported:!0},Ah={description:a("Cosine of an angle provided in radians."),args:[_c("angle (number)",a("The angle to find the cosine of, in radians."))],returns:["NUMBER"],compute:function(e){return Math.cos(Vo(e,this.locale))},isExported:!0},Oh={description:a("Hyperbolic cosine of any real number."),args:[_c("value (number)",a("Any real value to calculate the hyperbolic cosine of."))],returns:["NUMBER"],compute:function(e){return Math.cosh(Vo(e,this.locale))},isExported:!0},_h={description:a("Cotangent of an angle provided in radians."),args:[_c("angle (number)",a("The angle to find the cotangent of, in radians."))],returns:["NUMBER"],compute:function(e){const t=Vo(e,this.locale);return Lo((()=>0!==t),a("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),1/Math.tan(t)},isExported:!0},Mh={description:a("Hyperbolic cotangent of any real number."),args:[_c("value (number)",a("Any real value to calculate the hyperbolic cotangent of."))],returns:["NUMBER"],compute:function(e){const t=Vo(e,this.locale);return Lo((()=>0!==t),a("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),1/Math.tanh(t)},isExported:!0},Nh={description:a("Number of empty values."),args:[_c("value1 (any, range)",a("The first value or range in which to count the number of blanks.")),_c("value2 (any, range, repeating)",a("Additional values or ranges in which to count the number of blanks."))],returns:["NUMBER"],compute:function(...e){return Jo(e,((e,t)=>null==t||""===t?e+1:e),0)},isExported:!0},Fh={description:a("A conditional count across a range."),args:[_c("range (range)",a("The range that is tested against criterion.")),_c("criterion (string)",a("The pattern or test to apply to range."))],returns:["NUMBER"],compute:function(...e){let t=0;return ls(e,((e,o)=>{t+=1}),this.locale),t},isExported:!0},Dh={description:a("Count values depending on multiple criteria."),args:[_c("criteria_range1 (range)",a("The range to check against criterion1.")),_c("criterion1 (string)",a("The pattern or test to apply to criteria_range1.")),_c("criteria_range2 (any, range, repeating)",a("Additional ranges over which to evaluate the additional criteria. The filtered set will be the intersection of the sets produced by each criterion-range pair.")),_c("criterion2 (string, repeating)",a("Additional criteria to check."))],returns:["NUMBER"],compute:function(...e){let t=0;return ls(e,((e,o)=>{t+=1}),this.locale),t},isExported:!0};function Lh(e){switch(e){case void 0:case"":case null:return!1;default:return!0}}const Ph={description:a("Counts number of unique values in a range."),args:[_c("value1 (any, range)",a("The first value or range to consider for uniqueness.")),_c("value2 (any, range, repeating)",a("Additional values or ranges to consider for uniqueness."))],returns:["NUMBER"],compute:function(...e){return Jo(e,((e,t)=>Lh(t)?e.add(t):e),new Set).size}},Vh={description:a("Counts number of unique values in a range, filtered by a set of criteria."),args:[_c("range (range)",a("The range of cells from which the number of unique values will be counted.")),_c("criteria_range1 (range)",a("The range of cells over which to evaluate criterion1.")),_c("criterion1 (string)",a("The pattern or test to apply to criteria_range1, such that each cell that evaluates to TRUE will be included in the filtered set.")),_c("criteria_range2 (any, range, repeating)",a("Additional ranges over which to evaluate the additional criteria. The filtered set will be the intersection of the sets produced by each criterion-range pair.")),_c("criterion2 (string, repeating)",a("The pattern or test to apply to criteria_range2."))],returns:["NUMBER"],compute:function(e,...t){let o=new Set;return ls(t,((t,s)=>{const n=e[t][s];Lh(n)&&o.add(n)}),this.locale),o.size}},kh={description:a("Cosecant of an angle provided in radians."),args:[_c("angle (number)",a("The angle to find the cosecant of, in radians."))],returns:["NUMBER"],compute:function(e){const t=Vo(e,this.locale);return Lo((()=>0!==t),a("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),1/Math.sin(t)},isExported:!0},Uh={description:a("Hyperbolic cosecant of any real number."),args:[_c("value (number)",a("Any real value to calculate the hyperbolic cosecant of."))],returns:["NUMBER"],compute:function(e){const t=Vo(e,this.locale);return Lo((()=>0!==t),a("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),1/Math.sinh(t)},isExported:!0},Bh={description:a("Converts from another base to decimal."),args:[_c("value (string)",a("The number to convert.")),_c(",base (number)",a("The base to convert the value from."))],returns:["NUMBER"],compute:function(e,t){let o=Vo(t,this.locale);o=Math.floor(o),Lo((()=>2<=o&&o<=36),a("The base (%s) must be between 2 and 36 inclusive.",o.toString()));const s=$o(e);if(""===s)return 0;Lo((()=>!!ph.test(s)),a("The value (%s) must be a valid base %s representation.",s,o.toString()));const n=parseInt(s,o);return Lo((()=>!isNaN(n)),a("The value (%s) must be a valid base %s representation.",s,o.toString())),n},isExported:!0},Hh={description:a("Converts an angle value in radians to degrees."),args:[_c("angle (number)",a("The angle to convert from radians to degrees."))],returns:["NUMBER"],compute:function(e){return 180*Vo(e,this.locale)/Math.PI},isExported:!0},zh={description:a("Euler's number, e (~2.718) raised to a power."),args:[_c("value (number)",a("The exponent to raise e."))],returns:["NUMBER"],compute:function(e){return Math.exp(Vo(e,this.locale))},isExported:!0},Gh={description:a("Rounds number down to nearest multiple of factor."),args:[_c("value (number)",a("The value to round down to the nearest integer multiple of factor.")),_c("factor (number, default=1)",a("The number to whose multiples value will be rounded."))],returns:["NUMBER"],computeFormat:e=>e?.format,compute:function(e,t=1){const o=Vo(e,this.locale),s=Vo(t,this.locale);return Lo((()=>s>=0||o<=0),a("The factor (%s) must be positive when the value (%s) is positive.",s.toString(),o.toString())),s?Math.floor(o/s)*s:0},isExported:!0},$h={description:a("Rounds number down to nearest multiple of factor."),args:[_c("number (number)",a("The value to round down to the nearest integer multiple of significance.")),_c("significance (number, default=1)",a("The number to whose multiples number will be rounded. The sign of significance will be ignored.")),_c("mode (number, default=0)",a("If number is negative, specifies the rounding direction. If 0 or blank, it is rounded away from zero. Otherwise, it is rounded towards zero."))],returns:["NUMBER"],computeFormat:e=>e?.format,compute:function(e,t=1,o=0){let s=Vo(t,this.locale);if(0===s)return 0;const n=Vo(e,this.locale);if(s=Math.abs(s),n>=0)return Math.floor(n/s)*s;return 0===Vo(o,this.locale)?-Math.ceil(Math.abs(n)/s)*s:-Math.floor(Math.abs(n)/s)*s},isExported:!0},Wh={description:a("Rounds number down to nearest multiple of factor."),args:[_c("number (number)",a("The value to round down to the nearest integer multiple of significance.")),_c("significance (number, default=1)",a("The number to whose multiples number will be rounded."))],returns:["NUMBER"],computeFormat:e=>e?.format,compute:function(e,t=1){return $h.compute.bind(this)(e,t,0)},isExported:!0},qh={description:a("Whether the provided value is even."),args:[_c("value (number)",a("The value to be verified as even."))],returns:["BOOLEAN"],compute:function(e){const t=Bo(e,this.locale);return!(1&Math.floor(Math.abs(t)))},isExported:!0},Zh={description:a("Rounds number up to nearest multiple of factor."),args:[_c("number (number)",a("The value to round up to the nearest integer multiple of significance.")),_c("significance (number, default=1)",a("The number to whose multiples number will be rounded."))],returns:["NUMBER"],computeFormat:e=>e?.format,compute:function(e,t=1){return Rh.compute.bind(this)(e,t,0)},isExported:!0},Yh={description:a("Whether the provided value is even."),args:[_c("value (number)",a("The value to be verified as even."))],returns:["BOOLEAN"],compute:function(e){const t=Bo(e,this.locale);return!!(1&Math.floor(Math.abs(t)))},isExported:!0},jh={description:a("The logarithm of a number, base e (euler's number)."),args:[_c("value (number)",a("The value for which to calculate the logarithm, base e."))],returns:["NUMBER"],compute:function(e){const t=Vo(e,this.locale);return Lo((()=>t>0),a("The value (%s) must be strictly positive.",t.toString())),Math.log(t)},isExported:!0},Xh={description:a("The logarithm of a number, for a given base."),args:[_c("value (number)",a("The value for which to calculate the logarithm.")),_c("base (number, default=10)",a("The base of the logarithm."))],returns:["NUMBER"],compute:function(e,t=10){const o=Vo(e,this.locale),s=Vo(t,this.locale);return Lo((()=>o>0),a("The value (%s) must be strictly positive.",o.toString())),Lo((()=>s>0),a("The base (%s) must be strictly positive.",s.toString())),Lo((()=>1!==s),a("The base must be different from 1.")),Math.log10(o)/Math.log10(s)},isExported:!0},Kh={description:a("Modulo (remainder) operator."),args:[_c("dividend (number)",a("The number to be divided to find the remainder.")),_c("divisor (number)",a("The number to divide by."))],returns:["NUMBER"],computeFormat:e=>e?.format,compute:function(e,t){const o=Vo(t,this.locale);Lo((()=>0!==o),a("The divisor must be different from 0."));const s=Vo(e,this.locale)%o;return s>0&&o<0||s<0&&o>0?s+o:s},isExported:!0},Qh={description:a("Returns a n x n unit matrix, where n is the input dimension."),args:[_c("dimension (number)",a("An integer specifying the dimension size of the unit matrix. It must be positive."))],returns:["RANGE<NUMBER>"],compute:function(e){const t=Ho(e,this.locale);return Dc(a("The argument dimension must be positive"),t),Vc(t)},isExported:!0},Jh={description:a("Rounds a number up to the nearest odd integer."),args:[_c("value (number)",a("The value to round to the next greatest odd number."))],returns:["NUMBER"],computeFormat:e=>e?.format,compute:function(e){const t=Vo(e,this.locale);let o=Math.ceil(Math.abs(t));return o=1&o?o:o+1,t<0?-o:o},isExported:!0},ed={description:a("The number pi."),args:[],returns:["NUMBER"],compute:function(){return Math.PI},isExported:!0},td={description:a("A number raised to a power."),args:[_c("base (number)",a("The number to raise to the exponent power.")),_c("exponent (number)",a("The exponent to raise base to."))],returns:["NUMBER"],computeFormat:e=>e?.format,compute:function(e,t){const o=Vo(e,this.locale),s=Vo(t,this.locale);return Lo((()=>o>=0||Number.isInteger(s)),a("The exponent (%s) must be an integer when the base is negative.",s.toString())),Math.pow(o,s)},isExported:!0},od={description:a("Result of multiplying a series of numbers together."),args:[_c("factor1 (number, range<number>)",a("The first number or range to calculate for the product.")),_c("factor2 (number, range<number>, repeating)",a("More numbers or ranges to calculate for the product."))],returns:["NUMBER"],computeFormat:e=>Mo(e)?e[0][0]?.format:e?.format,compute:function(...e){let t=0,o=1;for(let s of e)if(Mo(s))for(let e of s)for(let s of e)"number"==typeof s&&(o*=s,t+=1);else null!=s&&(o*=Bo(s,this.locale),t+=1);return 0===t?0:o},isExported:!0},sd={description:a("A random number between 0 inclusive and 1 exclusive."),args:[],returns:["NUMBER"],compute:function(){return Math.random()},isExported:!0},nd={description:a("Returns a grid of random numbers between 0 inclusive and 1 exclusive."),args:[_c("rows (number, default=1)",a("The number of rows to be returned.")),_c("columns (number, default=1)",a("The number of columns to be returned.")),_c("min (number, default=0)",a("The minimum number you would like returned.")),_c("max (number, default=1)",a("The maximum number you would like returned.")),_c("whole_number (number, default=FALSE)",a("Return a whole number or a decimal value."))],returns:["RANGE<NUMBER>"],compute:function(e=1,t=1,o=0,s=1,n=!1){const i=Ho(t,this.locale),r=Ho(e,this.locale),l=Vo(o,this.locale),c=Vo(s,this.locale),h=Zo(n);Dc(a("The number columns (%s) must be positive.",i.toString()),i),Dc(a("The number rows (%s) must be positive.",r.toString()),r),Lo((()=>l<=c),a("The maximum (%s) must be greater than or equal to the minimum (%s).",c.toString(),l.toString())),h&&Lo((()=>Number.isInteger(l)&&Number.isInteger(c)),a("The maximum (%s) and minimum (%s) must be integers when whole_number is TRUE.",c.toString(),l.toString()));const d=Array(i);for(let e=0;e<i;e++){d[e]=Array(r);for(let t=0;t<r;t++)d[e][t]=h?Math.floor(Math.random()*(c-l+1)+l):l+Math.random()*(c-l)}return d},isExported:!0},id={description:a("Random integer between two values, inclusive."),args:[_c("low (number)",a("The low end of the random range.")),_c("high (number)",a("The high end of the random range."))],returns:["NUMBER"],computeFormat:e=>e?.format,compute:function(e,t){let o=Vo(e,this.locale);Number.isInteger(o)||(o=Math.ceil(o));let s=Vo(t,this.locale);return Number.isInteger(s)||(s=Math.floor(s)),Lo((()=>o<=s),a("The high (%s) must be greater than or equal to the low (%s).",s.toString(),o.toString())),o+Math.ceil((s-o+1)*Math.random())-1},isExported:!0},rd={description:a("Rounds a number according to standard rules."),args:[_c("value (number)",a("The value to round to places number of places.")),_c("places (number, default=0)",a("The number of decimal places to which to round."))],returns:["NUMBER"],computeFormat:e=>e?.format,compute:function(e,t=0){const o=Vo(e,this.locale);let s=Vo(t,this.locale);const n=Math.abs(o);let i;return 0===s?i=Math.round(n):(Number.isInteger(s)||(s=Math.trunc(s)),i=Math.round(n*Math.pow(10,s))/Math.pow(10,s)),o>=0?i:-i},isExported:!0},ad={description:a("Rounds down a number."),args:[_c("value (number)",a("The value to round to places number of places, always rounding down.")),_c("places (number, default=0)",a("The number of decimal places to which to round."))],returns:["NUMBER"],computeFormat:e=>e?.format,compute:function(e,t=0){const o=Vo(e,this.locale);let s=Vo(t,this.locale);const n=Math.abs(o);let i;return 0===s?i=Math.floor(n):(Number.isInteger(s)||(s=Math.trunc(s)),i=Math.floor(n*Math.pow(10,s))/Math.pow(10,s)),o>=0?i:-i},isExported:!0},ld={description:a("Rounds up a number."),args:[_c("value (number)",a("The value to round to places number of places, always rounding up.")),_c("places (number, default=0)",a("The number of decimal places to which to round."))],returns:["NUMBER"],computeFormat:e=>e?.format,compute:function(e,t=0){const o=Vo(e,this.locale);let s=Vo(t,this.locale);const n=Math.abs(o);let i;return 0===s?i=Math.ceil(n):(Number.isInteger(s)||(s=Math.trunc(s)),i=Math.ceil(n*Math.pow(10,s))/Math.pow(10,s)),o>=0?i:-i},isExported:!0},cd={description:a("Secant of an angle provided in radians."),args:[_c("angle (number)",a("The angle to find the secant of, in radians."))],returns:["NUMBER"],compute:function(e){return 1/Math.cos(Vo(e,this.locale))},isExported:!0},hd={description:a("Hyperbolic secant of any real number."),args:[_c("value (number)",a("Any real value to calculate the hyperbolic secant of."))],returns:["NUMBER"],compute:function(e){return 1/Math.cosh(Vo(e,this.locale))},isExported:!0},dd={description:a("Sine of an angle provided in radians."),args:[_c("angle (number)",a("The angle to find the sine of, in radians."))],returns:["NUMBER"],compute:function(e){return Math.sin(Vo(e,this.locale))},isExported:!0},ud={description:a("Hyperbolic sine of any real number."),args:[_c("value (number)",a("Any real value to calculate the hyperbolic sine of."))],returns:["NUMBER"],compute:function(e){return Math.sinh(Vo(e,this.locale))},isExported:!0},gd={description:a("Positive square root of a positive number."),args:[_c("value (number)",a("The number for which to calculate the positive square root."))],returns:["NUMBER"],computeFormat:e=>e?.format,compute:function(e){const t=Vo(e,this.locale);return Lo((()=>t>=0),a("The value (%s) must be positive or null.",t.toString())),Math.sqrt(t)},isExported:!0},pd={description:a("Sum of a series of numbers and/or cells."),args:[_c("value1 (number, range<number>)",a("The first number or range to add together.")),_c("value2 (number, range<number>, repeating)",a("Additional numbers or ranges to add to value1."))],returns:["NUMBER"],computeFormat:e=>Mo(e)?e[0][0]?.format:e?.format,compute:function(...e){return es(e,((e,t)=>e+t),0,this.locale)},isExported:!0},md={description:a("A conditional sum across a range."),args:[_c("criteria_range (range)",a("The range which is tested against criterion.")),_c("criterion (string)",a("The pattern or test to apply to range.")),_c("sum_range (range, default=criteria_range)",a("The range to be summed, if different from range."))],returns:["NUMBER"],compute:function(e,t,o){void 0===o&&(o=e);let s=0;return ls([e,t],((e,t)=>{const n=o[e][t];"number"==typeof n&&(s+=n)}),this.locale),s},isExported:!0},fd={description:a("Sums a range depending on multiple criteria."),args:[_c("sum_range (range)",a("The range to sum.")),_c("criteria_range1 (range)",a("The range to check against criterion1.")),_c("criterion1 (string)",a("The pattern or test to apply to criteria_range1.")),_c("criteria_range2 (any, range, repeating)",a("Additional ranges to check.")),_c("criterion2 (string, repeating)",a("Additional criteria to check."))],returns:["NUMBER"],compute:function(e,...t){let o=0;return ls(t,((t,s)=>{const n=e[t][s];"number"==typeof n&&(o+=n)}),this.locale),o},isExported:!0},bd={description:a("Tangent of an angle provided in radians."),args:[_c("angle (number)",a("The angle to find the tangent of, in radians."))],returns:["NUMBER"],compute:function(e){return Math.tan(Vo(e,this.locale))},isExported:!0},vd={description:a("Hyperbolic tangent of any real number."),args:[_c("value (number)",a("Any real value to calculate the hyperbolic tangent of."))],returns:["NUMBER"],compute:function(e){return Math.tanh(Vo(e,this.locale))},isExported:!0},Sd={description:a("Truncates a number."),args:[_c("value (number)",a("The value to be truncated.")),_c("places (number, default=0)",a("The number of significant digits to the right of the decimal point to retain."))],returns:["NUMBER"],computeFormat:e=>e?.format,compute:function(e,t=0){const o=Vo(e,this.locale);let s=Vo(t,this.locale);return 0===s?Math.trunc(o):(Number.isInteger(s)||(s=Math.trunc(s)),Math.trunc(o*Math.pow(10,s))/Math.pow(10,s))},isExported:!0},Cd={description:a("Rounds a number down to the nearest integer that is less than or equal to it."),args:[_c("value (number)",a("The number to round down to the nearest integer."))],returns:["NUMBER"],compute:function(e){return Math.floor(Vo(e,this.locale))},isExported:!0};var Ed=Object.freeze({__proto__:null,ABS:mh,ACOS:fh,ACOSH:bh,ACOT:vh,ACOTH:Sh,ASIN:Ch,ASINH:Eh,ATAN:yh,ATAN2:wh,ATANH:xh,CEILING:Ih,CEILING_MATH:Rh,CEILING_PRECISE:Th,COS:Ah,COSH:Oh,COT:_h,COTH:Mh,COUNTBLANK:Nh,COUNTIF:Fh,COUNTIFS:Dh,COUNTUNIQUE:Ph,COUNTUNIQUEIFS:Vh,CSC:kh,CSCH:Uh,DECIMAL:Bh,DEGREES:Hh,EXP:zh,FLOOR:Gh,FLOOR_MATH:$h,FLOOR_PRECISE:Wh,INT:Cd,ISEVEN:qh,ISODD:Yh,ISO_CEILING:Zh,LN:jh,LOG:Xh,MOD:Kh,MUNIT:Qh,ODD:Jh,PI:ed,POWER:td,PRODUCT:od,RAND:sd,RANDARRAY:nd,RANDBETWEEN:id,ROUND:rd,ROUNDDOWN:ad,ROUNDUP:ld,SEC:cd,SECH:hd,SIN:dd,SINH:ud,SQRT:gd,SUM:pd,SUMIF:md,SUMIFS:fd,TAN:bd,TANH:vd,TRUNC:Sd});function yd(...e){const t=e[0].length;e.forEach(((e,o)=>Lo((()=>e.length===t),a("[[FUNCTION_NAME]] has mismatched dimensions for argument %s (%s vs %s).",o.toString(),t.toString(),e.length.toString()))))}function wd(e,t){Lo((()=>e.length>0&&e[0].length>0),a("[[FUNCTION_NAME]] expects the provided values of %(argName)s to be a non-empty matrix.",{argName:t}))}function xd(...e){if(0===e.length||e.some((e=>0===e.length)))throw new m(a("[[FUNCTION_NAME]] has no valid input data."))}function Id(e,t){const o=[],s=[];let n=0,i=0;Xo([e],(e=>{o.push(e),n+=1})),Xo([t],(e=>{s.push(e),i+=1})),Lo((()=>n===i),a("[[FUNCTION_NAME]] has mismatched argument count %s vs %s.",n,i));const r=[],l=[];for(let e=0;e<n;e++){const t=o[e],n=s[e];"number"==typeof t&&"number"==typeof n&&(l.push(t),r.push(n))}return{flatDataX:r,flatDataY:l}}function Rd(e,t,o){const{flatDataX:s,flatDataY:n}=Id(e,t),i=n.length;Lo((()=>0!==i&&(!o||1!==i)),a("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error."));let r=0,l=0;for(let e=0;e<i;e++)r+=n[e],l+=s[e];const c=r/i,h=l/i;let d=0;for(let e=0;e<i;e++)d+=(n[e]-c)*(s[e]-h);return d/(i-(o?1:0))}function Td(e,t,o,s){let n=0,i=0;const r=o?ts:es;i=r(e,((e,t)=>(n+=1,e+t)),0,s),Lo((()=>0!==n&&(!t||1!==n)),a("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error."));const l=i/n;return r(e,((e,t)=>e+Math.pow(t-l,2)),0,s)/(n-(t?1:0))}function Ad(e,t,o,s){const n=Vo(t,s);Lo((()=>o?0<=n&&n<=1:0<n&&n<1),a("Function [[FUNCTION_NAME]] parameter 2 value is out of range."));let i,r=[],l=0;return Xo(e,(e=>{"number"==typeof e&&(i=cs(r,e,"nextSmaller","asc",r.length,((e,t)=>e[t])),r.splice(i+1,0,e),l++)})),Lo((()=>0!==l),a("[[FUNCTION_NAME]] has no valid input data.")),o||Lo((()=>1/(l+1)<=n&&n<=l/(l+1)),a("Function [[FUNCTION_NAME]] parameter 2 value is out of range.")),fo(r,n,o)}function Od(e,t,o){const s=e.length?e:[Ne(1,t.flat().length+1)],n=s.length;let i=o.length?o:s;return i=i.length===n?ns(i):i,{_X:s,_newX:i}}function _d(e,t,o=!0,s=!1){const n=t.flat(),i=n.length;let{_X:r}=Od(e,t,[]);r=r.length===i?ns(r):r.slice(),yd(r[0],n);const l=r.length,c=i-l-(o?1:0),h=[n],d=ns(r.reverse());let u=[];for(let e=0;e<l;e++)if(u.push(0),o){for(const t of r[e])u[e]+=t;u[e]/=i}let g=0;if(o){for(const e of n)g+=e;g/=i}const p=d.map((e=>e.map(((e,t)=>e-u[t]))));o&&d.forEach((e=>e.push(1)));const m=Nd(d,h);if(o||m.push([0]),!s)return m;const f=Bc(p,ns(p)),{inverted:b}=kc(f);if(void 0===b)throw new Error(a("Matrix is not invertible"));let v=0,S=0;for(let e=0;e<i;e++){const t=n[e]-g;let o=0;for(let t=0;t<l;t++){o+=p[e][t]*m[t][0]}const s=t-o;v+=s*s,S+=o*o}const C=Math.sqrt(v/c),E=S/(S+v),y=S/l/(v/c),w=[];for(let e=0;e<l;e++)w.push(C*Math.sqrt(b[e][e]));if(o){const e=Bc(b,[u]),t=Bc(ns([u]),e);w.push(C*Math.sqrt(t[0][0]+1/n.length))}const x=[[m[0][0],w[0],E,y,S],[m[1][0],w[1],C,c,v]];for(let e=2;e<l;e++)x.push([m[e][0],w[e],"","",""]);return o?x.push([m[l][0],w[l],"","",""]):x.push([0,"","","",""]),x}function Md(e,t,o,s){yd(t,e),Lo((()=>o>=1),a("Function [[FUNCTION_NAME]] A regression of order less than 1 cannot be possible."));const n=[e],i=t.map((e=>Ne(0,o).map((t=>Math.pow(e,o-t)))));s&&i.forEach((e=>e.push(1)));const r=Nd(i,n);return s||r.push([0]),r}function Nd(e,t){const o=Bc(e,ns(e)),{inverted:s}=kc(o);if(void 0===s)throw new Error(a("Matrix is not invertible"));const n=Bc(e,t);return ns(Bc(s,n))}function Fd(e){return e.map((e=>e.map((e=>Math.log(e)))))}function Dd(e,t,o,s){const{_X:n,_newX:i}=Od(t,e,o),r=_d(n,e,s,!1),a=r.length-1,l=i.map((e=>{let t=0;for(let o=0;o<a;o++)t+=r[o][0]*e[a-o-1];return t+=r[a][0],[t]}));return l.length===o.length?l:ns(l)}const Ld={description:a("Average magnitude of deviations from mean."),args:[_c("value1 (number, range<number>)",a("The first value or range of the sample.")),_c("value2 (number, range<number>, repeating)",a("Additional values or ranges to include in the sample."))],returns:["NUMBER"],compute:function(...e){let t=0;const o=es(e,((e,o)=>(t+=1,e+o)),0,this.locale);Lo((()=>0!==t),a("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error."));const s=o/t;return es(e,((e,t)=>e+Math.abs(s-t)),0,this.locale)/t},isExported:!0},Pd={description:a("Numerical average value in a dataset, ignoring text."),args:[_c("value1 (number, range<number>)",a("The first value or range to consider when calculating the average value.")),_c("value2 (number, range<number>, repeating)",a("Additional values or ranges to consider when calculating the average value."))],returns:["NUMBER"],computeFormat:e=>Mo(e)?e[0][0]?.format:e?.format,compute:function(...e){let t=0;const o=es(e,((e,o)=>(t+=1,e+o)),0,this.locale);return Lo((()=>0!==t),a("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),o/t},isExported:!0},Vd=a("[[FUNCTION_NAME]] has mismatched range sizes."),kd=a("[[FUNCTION_NAME]] expects the weight to be positive or equal to 0."),Ud={description:a("Weighted average."),args:[_c("values (number, range<number>)",a("Values to average.")),_c("weights (number, range<number>)",a("Weights for each corresponding value.")),_c("additional_values (number, range<number>, repeating)",a("Additional values to average.")),_c("additional_weights (number, range<number>, repeating)",a("Additional weights."))],returns:["NUMBER"],computeFormat:e=>Mo(e)?e[0][0]?.format:e?.format,compute:function(...e){let t,o,s=0,n=0;Lo((()=>e.length%2==0),a("Wrong number of Argument[]. Expected an even number of Argument[]."));for(let i=0;i<e.length-1;i+=2)if(t=e[i],o=e[i+1],Mo(t)){Lo((()=>Mo(o)),Vd);let e=t.length,i=t[0].length;Lo((()=>e===o.length&&i===o[0].length),Vd);for(let r=0;r<e;r++)for(let e=0;e<i;e++){let i=t[r][e],l=o[r][e],c="number"==typeof i,h="number"==typeof l;Lo((()=>c===h),a("[[FUNCTION_NAME]] expects number values.")),h&&(Lo((()=>l>=0),kd),s+=i*l,n+=l)}}else o=Vo(o,this.locale),t=Vo(t,this.locale),Lo((()=>o>=0),kd),s+=t*o,n+=o;return Lo((()=>0!==n),a("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),s/n}},Bd={description:a("Numerical average value in a dataset."),args:[_c("value1 (number, range<number>)",a("The first value or range to consider when calculating the average value.")),_c("value2 (number, range<number>, repeating)",a("Additional values or ranges to consider when calculating the average value."))],returns:["NUMBER"],computeFormat:e=>Mo(e)?e[0][0]?.format:e?.format,compute:function(...e){let t=0;const o=ts(e,((e,o)=>(t+=1,e+o)),0,this.locale);return Lo((()=>0!==t),a("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),o/t},isExported:!0},Hd={description:a("Average of values depending on criteria."),args:[_c("criteria_range (number, range<number>)",a("The range to check against criterion.")),_c("criterion (string)",a("The pattern or test to apply to criteria_range.")),_c("average_range (number, range<number>, default=criteria_range)",a("The range to average. If not included, criteria_range is used for the average instead."))],returns:["NUMBER"],compute:function(e,t,o){const s=gs(e),n=void 0===o?s:gs(o);let i=0,r=0;return ls([e,t],((e,t)=>{const o=n[e][t];"number"==typeof o&&(i+=1,r+=o)}),this.locale),Lo((()=>0!==i),a("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),r/i},isExported:!0},zd={description:a("Average of values depending on multiple criteria."),args:[_c("average_range (range)",a("The range to average.")),_c("criteria_range1 (range)",a("The range to check against criterion1.")),_c("criterion1 (string)",a("The pattern or test to apply to criteria_range1.")),_c("criteria_range2 (any, range, repeating)",a("Additional criteria_range and criterion to check.")),_c("criterion2 (string, repeating)",a("The pattern or test to apply to criteria_range2."))],returns:["NUMBER"],compute:function(e,...t){const o=gs(e);let s=0,n=0;return ls(t,((e,t)=>{const i=o[e][t];"number"==typeof i&&(s+=1,n+=i)}),this.locale),Lo((()=>0!==s),a("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),n/s},isExported:!0},Gd={description:a("The number of numeric values in dataset."),args:[_c("value1 (number, range<number>)",a("The first value or range to consider when counting.")),_c("value2 (number, range<number>, repeating)",a("Additional values or ranges to consider when counting."))],returns:["NUMBER"],compute:function(...e){let t=0;for(let o of e)if(Mo(o))for(let e of o)for(let o of e)"number"==typeof o&&(t+=1);else("string"!=typeof o||go(o,this.locale)||Kt(o,this.locale))&&(t+=1);return t},isExported:!0},$d={description:a("The number of values in a dataset."),args:[_c("value1 (any, range)",a("The first value or range to consider when counting.")),_c("value2 (any, range, repeating)",a("Additional values or ranges to consider when counting."))],returns:["NUMBER"],compute:function(...e){return Jo(e,((e,t)=>null!=t?e+1:e),0)},isExported:!0},Wd={description:a("The covariance of a dataset."),args:[_c("data_y (any, range)",a("The range representing the array or matrix of dependent data.")),_c("data_x (any, range)",a("The range representing the array or matrix of independent data."))],returns:["NUMBER"],compute:function(e,t){return Rd(e,t,!1)},isExported:!0},qd={description:a("The covariance of a dataset."),args:[_c("data_y (any, range)",a("The range representing the array or matrix of dependent data.")),_c("data_x (any, range)",a("The range representing the array or matrix of independent data."))],returns:["NUMBER"],compute:function(e,t){return Rd(e,t,!1)},isExported:!0},Zd={description:a("The sample covariance of a dataset."),args:[_c("data_y (any, range)",a("The range representing the array or matrix of dependent data.")),_c("data_x (any, range)",a("The range representing the array or matrix of independent data."))],returns:["NUMBER"],compute:function(e,t){return Rd(e,t,!0)},isExported:!0},Yd={description:a("Calculates the expected y-value for a specified x based on a linear regression of a dataset."),args:[_c("x (number, range<number>)",a("The value(s) on the x-axis to forecast.")),_c("data_y (range<number>)",a("The range representing the array or matrix of dependent data.")),_c("data_x (range<number>)",a("The range representing the array or matrix of independent data."))],returns:["NUMBER"],compute:function(e,t,o){const{flatDataX:s,flatDataY:n}=Id(t,o);return xd(s,n),Dd([n],[s],ss(gs(e),(e=>Vo(e,this.locale))),!0)},isExported:!0},jd={description:a("Fits points to exponential growth trend."),args:[_c("known_data_y (range<number>)",a("The array or range containing dependent (y) values that are already known, used to curve fit an ideal exponential growth curve.")),_c("known_data_x (range<number>, default={1;2;3;...})",a("The values of the independent variable(s) corresponding with known_data_y.")),_c("new_data_x (any, range, default=known_data_x)",a("The data points to return the y values for on the ideal curve fit.")),_c("b (boolean, default=TRUE)",a("Given a general exponential form of y = b*m^x for a curve fit, calculates b if TRUE or forces b to be 1 and only calculates the m values if FALSE."))],returns:["NUMBER"],compute:function(e,t=[],o=[],s=!0){return wd(e,"known_data_y"),Dd(Fd(Uo(e,"the first argument (known_data_y)")),Uo(t,"the second argument (known_data_x)"),Uo(o,"the third argument (new_data_y)"),Zo(s)).map((e=>e.map((e=>Math.exp(e)))))}},Xd={description:a("Compute the intercept of the linear regression."),args:[_c("data_y (range<number>)",a("The range representing the array or matrix of dependent data.")),_c("data_x (range<number>)",a("The range representing the array or matrix of independent data."))],returns:["NUMBER"],compute:function(e,t){const{flatDataX:o,flatDataY:s}=Id(e,t);xd(o,s);const[[],[n]]=_d([o],[s]);return n},isExported:!0},Kd={description:a("Nth largest element from a data set."),args:[_c("data (any, range)",a("Array or range containing the dataset to consider.")),_c("n (number)",a("The rank from largest to smallest of the element to return."))],returns:["NUMBER"],computeValueAndFormat:function(e,t){const o=Math.trunc(Vo(t?.value,this.locale));let s,n=[],i=0;Xo([e],(e=>{"number"==typeof e.value&&(s=cs(n,e.value,"nextSmaller","asc",n.length,((e,t)=>e[t].value)),n.splice(s+1,0,e),i++,i>o&&(n.shift(),i--))}));const r=n.shift();return Lo((()=>void 0!==r),a("[[FUNCTION_NAME]] has no valid input data.")),Lo((()=>i>=o),a("Function [[FUNCTION_NAME]] parameter 2 value (%s) is out of range.",o)),r},isExported:!0},Qd={description:a("Compute the intercept of the linear regression."),args:[_c("data_y (range<number>)",a("The range representing the array or matrix of dependent data.")),_c("data_x (range<number>, default={1;2;3;...})",a("The range representing the array or matrix of independent data.")),_c("calculate_b (boolean, default=TRUE)",a("A flag specifying wheter to compute the slope or not")),_c("verbose (boolean, default=FALSE)",a("A flag specifying whether to return additional regression statistics or only the linear coefficients and the y-intercept"))],returns:["NUMBER"],compute:function(e,t=[],o=!0,s=!1){return wd(e,"data_y"),_d(Uo(t,"the first argument (data_y)"),Uo(e,"the second argument (data_x)"),Zo(o),Zo(s))},isExported:!0},Jd={description:a("Compute the intercept of the linear regression."),args:[_c("data_y (range<number>)",a("The range representing the array or matrix of dependent data.")),_c("data_x (range<number>, optional, default={1;2;3;...})",a("The range representing the array or matrix of independent data.")),_c("calculate_b (boolean, default=TRUE)",a("A flag specifying wheter to compute the slope or not")),_c("verbose (boolean, default=FALSE)",a("A flag specifying whether to return additional regression statistics or only the linear coefficients and the y-intercept"))],returns:["NUMBER"],compute:function(e,t=[],o=!0,s=!1){wd(e,"data_y");const n=_d(Uo(t,"the second argument (data_x)"),Fd(Uo(e,"the first argument (data_y)")),Zo(o),Zo(s));for(let e=0;e<n.length;e++)n[e][0]=Math.exp(n[e][0]);return n},isExported:!0},eu={description:a("Compute the Matthews correlation coefficient of a dataset."),args:[_c("data_x (range)",a("The range representing the array or matrix of observed data.")),_c("data_y (range)",a("The range representing the array or matrix of predicted data."))],returns:["NUMBER"],compute:function(e,t){const o=e.flat(),s=t.flat();yd(o,s),xd(o,s);const n=o.length;let i=0,r=0,a=0,l=0;for(let e=0;e<n;++e){const t=Zo(o[e]);t===Zo(s[e])?t?r++:i++:t?l++:a++}return(r*i-a*l)/Math.sqrt((r+a)*(r+l)*(i+a)*(i+l))},isExported:!1},tu={description:a("Maximum value in a numeric dataset."),args:[_c("value1 (number, range<number>)",a("The first value or range to consider when calculating the maximum value.")),_c("value2 (number, range<number>, repeating)",a("Additional values or ranges to consider when calculating the maximum value."))],returns:["NUMBER"],computeFormat:e=>Mo(e)?e[0][0]?.format:e?.format,compute:function(...e){const t=es(e,((e,t)=>e<t?t:e),-1/0,this.locale);return t===-1/0?0:t},isExported:!0},ou={description:a("Maximum numeric value in a dataset."),args:[_c("value1 (any, range)",a("The first value or range to consider when calculating the maximum value.")),_c("value2 (any, range, repeating)",a("Additional values or ranges to consider when calculating the maximum value."))],returns:["NUMBER"],computeFormat:e=>Mo(e)?e[0][0]?.format:e?.format,compute:function(...e){const t=ts(e,((e,t)=>Math.max(t,e)),-1/0,this.locale);return t===-1/0?0:t},isExported:!0},su={description:a("Returns the maximum value in a range of cells, filtered by a set of criteria."),args:[_c("range (range)",a("The range of cells from which the maximum will be determined.")),_c("criteria_range1 (range)",a("The range of cells over which to evaluate criterion1.")),_c("criterion1 (string)",a("The pattern or test to apply to criteria_range1, such that each cell that evaluates to TRUE will be included in the filtered set.")),_c("criteria_range2 (any, range, repeating)",a("Additional ranges over which to evaluate the additional criteria. The filtered set will be the intersection of the sets produced by each criterion-range pair.")),_c("criterion2 (string, repeating)",a("The pattern or test to apply to criteria_range2."))],returns:["NUMBER"],compute:function(e,...t){let o=-1/0;const s=gs(e);return ls(t,((e,t)=>{const n=s[e][t];"number"==typeof n&&(o=o<n?n:o)}),this.locale),o===-1/0?0:o},isExported:!0},nu={description:a("Median value in a numeric dataset."),args:[_c("value1 (any, range)",a("The first value or range to consider when calculating the median value.")),_c("value2 (any, range, repeating)",a("Additional values or ranges to consider when calculating the median value."))],returns:["NUMBER"],computeFormat:e=>Mo(e)?e[0][0]?.format:e?.format,compute:function(...e){let t=[];return Ko(e,(e=>{t.push(e)}),this.locale),Ad(t,.5,!0,this.locale)},isExported:!0},iu={description:a("Minimum value in a numeric dataset."),args:[_c("value1 (number, range<number>)",a("The first value or range to consider when calculating the minimum value.")),_c("value2 (number, range<number>, repeating)",a("Additional values or ranges to consider when calculating the minimum value."))],returns:["NUMBER"],computeFormat:e=>Mo(e)?e[0][0]?.format:e?.format,compute:function(...e){const t=es(e,((e,t)=>t<e?t:e),1/0,this.locale);return t===1/0?0:t},isExported:!0},ru={description:a("Minimum numeric value in a dataset."),args:[_c("value1 (number, range<number>)",a("The first value or range to consider when calculating the minimum value.")),_c("value2 (number, range<number>, repeating)",a("Additional values or ranges to consider when calculating the minimum value."))],returns:["NUMBER"],computeFormat:e=>Mo(e)?e[0][0]?.format:e?.format,compute:function(...e){const t=ts(e,((e,t)=>Math.min(t,e)),1/0,this.locale);return t===1/0?0:t},isExported:!0},au={description:a("Returns the minimum value in a range of cells, filtered by a set of criteria."),args:[_c("range (range)",a("The range of cells from which the minimum will be determined.")),_c("criteria_range1 (range)",a("The range of cells over which to evaluate criterion1.")),_c("criterion1 (string)",a("The pattern or test to apply to criteria_range1, such that each cell that evaluates to TRUE will be included in the filtered set.")),_c("criteria_range2 (any, range, repeating)",a("Additional ranges over which to evaluate the additional criteria. The filtered set will be the intersection of the sets produced by each criterion-range pair.")),_c("criterion2 (string, repeating)",a("The pattern or test to apply to criteria_range2."))],returns:["NUMBER"],compute:function(e,...t){let o=1/0;const s=gs(e);return ls(t,((e,t)=>{const n=s[e][t];"number"==typeof n&&(o=o>n?n:o)}),this.locale),o===1/0?0:o},isExported:!0},lu={description:a("Compute the Pearson product-moment correlation coefficient of a dataset."),args:[_c("data_y (range<number>)",a("The range representing the array or matrix of dependent data.")),_c("data_x (range<number>)",a("The range representing the array or matrix of independent data."))],returns:["NUMBER"],compute:function(e,t){const{flatDataX:o,flatDataY:s}=Id(t,e);xd(o,s);const n=o.length;let i=0,r=0,a=0,l=0,c=0;for(let e=0;e<n;e++){const t=o[e],n=s[e];i+=t,r+=n,a+=t*n,l+=t*t,c+=n*n}return(n*a-i*r)/Math.sqrt((n*l-i*i)*(n*c-r*r))},isExported:!0},cu=lu,hu={description:a("Value at a given percentile of a dataset."),args:[_c("data (any, range)",a("The array or range containing the dataset to consider.")),_c("percentile (number)",a("The percentile whose value within data will be calculated and returned."))],returns:["NUMBER"],computeFormat:e=>Mo(e)?e[0][0]?.format:e?.format,compute:function(e,t){return uu.compute.bind(this)(e,t)},isExported:!0},du={description:a("Value at a given percentile of a dataset exclusive of 0 and 1."),args:[_c("data (any, range)",a("The array or range containing the dataset to consider.")),_c("percentile (number)",a("The percentile, exclusive of 0 and 1, whose value within 'data' will be calculated and returned."))],returns:["NUMBER"],computeFormat:e=>Mo(e)?e[0][0]?.format:e?.format,compute:function(e,t){return Ad([e],t,!1,this.locale)},isExported:!0},uu={description:a("Value at a given percentile of a dataset."),args:[_c("data (any, range)",a("The array or range containing the dataset to consider.")),_c("percentile (number)",a("The percentile whose value within data will be calculated and returned."))],returns:["NUMBER"],computeFormat:e=>Mo(e)?e[0][0]?.format:e?.format,compute:function(e,t){return Ad([e],t,!0,this.locale)},isExported:!0},gu={description:a("Compute the coefficients of polynomial regression of the dataset."),args:[_c("data_y (range<number>)",a("The range representing the array or matrix of dependent data.")),_c("data_x (range<number>)",a("The range representing the array or matrix of independent data.")),_c("order (number)",a("The order of the polynomial to fit the data, between 1 and 6.")),_c("intercept (boolean, default=TRUE)",a("A flag specifying whether to compute the intercept or not."))],returns:["RANGE<NUMBER>"],compute:function(e,t,o,s=!0){const{flatDataX:n,flatDataY:i}=Id(e,t);return xd(n,i),Md(i,n,Vo(o,this.locale),Zo(s))},isExported:!1},pu={description:a("Predict value by computing a polynomial regression of the dataset."),args:[_c("x (number, range<number>)",a("The value(s) on the x-axis to forecast.")),_c("data_y (range<number>)",a("The range representing the array or matrix of dependent data.")),_c("data_x (range<number>)",a("The range representing the array or matrix of independent data.")),_c("order (number)",a("The order of the polynomial to fit the data, between 1 and 6.")),_c("intercept (boolean, default=TRUE)",a("A flag specifying whether to compute the intercept or not."))],returns:["NUMBER"],compute:function(e,t,o,s,n=!0){const i=Vo(s,this.locale),{flatDataX:r,flatDataY:a}=Id(t,o);xd(r,a);const l=Md(a,r,i,Zo(n)).flat();return ss(gs(e),(e=>function(e,t,o){return e.reduce(((e,s,n)=>e+s*Math.pow(t,o-n)),0)}(l,Vo(e,this.locale),i)))},isExported:!1},mu={description:a("Value nearest to a specific quartile of a dataset."),args:[_c("data (any, range)",a("The array or range containing the dataset to consider.")),_c("quartile_number (number)",a("Which quartile value to return."))],returns:["NUMBER"],computeFormat:e=>Mo(e)?e[0][0]?.format:e?.format,compute:function(e,t){return bu.compute.bind(this)(e,t)},isExported:!0},fu={description:a("Value nearest to a specific quartile of a dataset exclusive of 0 and 4."),args:[_c("data (any, range)",a("The array or range containing the dataset to consider.")),_c("quartile_number (number)",a("Which quartile value, exclusive of 0 and 4, to return."))],returns:["NUMBER"],computeFormat:e=>Mo(e)?e[0][0]?.format:e?.format,compute:function(e,t){return Ad([e],.25*Math.trunc(Vo(t,this.locale)),!1,this.locale)},isExported:!0},bu={description:a("Value nearest to a specific quartile of a dataset."),args:[_c("data (any, range)",a("The array or range containing the dataset to consider.")),_c("quartile_number (number)",a("Which quartile value to return."))],returns:["NUMBER"],computeFormat:e=>Mo(e)?e[0][0]?.format:e?.format,compute:function(e,t){return Ad([e],.25*Math.trunc(Vo(t,this.locale)),!0,this.locale)},isExported:!0},vu={description:a("Returns the rank of a specified value in a dataset."),args:[_c("value (number)",a("The value whose rank will be determined.")),_c("data (range)",a("The range containing the dataset to consider.")),_c("is_ascending (boolean, default=FALSE)",a("Whether to consider the values in data in descending or ascending order."))],returns:["ANY"],compute:function(e,t,o=!1){const s=Zo(o),n=Vo(e,this.locale);let i=1,r=!1;for(const e of t)for(const t of e){if("number"!=typeof t)continue;const e=Vo(t,this.locale);e===n?r=!0:e>n!==s&&i++}if(!r)throw new m(a("Value not found in the given data."));return i},isExported:!0},Su={description:a("Compute the square of r, the Pearson product-moment correlation coefficient of a dataset."),args:[_c("data_y (range<number>)",a("The range representing the array or matrix of dependent data.")),_c("data_x (range<number>)",a("The range representing the array or matrix of independent data."))],returns:["NUMBER"],compute:function(e,t){const o=lu.compute.bind(this);return Math.pow(o(t,e),2)},isExported:!0},Cu={description:a("Compute the slope of the linear regression."),args:[_c("data_y (range<number>)",a("The range representing the array or matrix of dependent data.")),_c("data_x (range<number>)",a("The range representing the array or matrix of independent data."))],returns:["NUMBER"],compute:function(e,t){const{flatDataX:o,flatDataY:s}=Id(e,t);xd(o,s);const[[n]]=_d([o],[s]);return n},isExported:!0},Eu={description:a("Nth smallest element in a data set."),args:[_c("data (any, range)",a("The array or range containing the dataset to consider.")),_c("n (number)",a("The rank from smallest to largest of the element to return."))],returns:["NUMBER"],computeValueAndFormat:function(e,t){const o=Math.trunc(Vo(t?.value,this.locale));let s,n=[],i=0;Xo([e],(e=>{"number"==typeof e.value&&(s=cs(n,e.value,"nextSmaller","asc",n.length,((e,t)=>e[t].value)),n.splice(s+1,0,e),i++,i>o&&(n.pop(),i--))}));const r=n.pop();return Lo((()=>void 0!==r),a("[[FUNCTION_NAME]] has no valid input data.")),Lo((()=>i>=o),a("Function [[FUNCTION_NAME]] parameter 2 value (%s) is out of range.",o)),r},isExported:!0},yu={description:a("Compute the Spearman rank correlation coefficient of a dataset."),args:[_c("data_y (range<number>)",a("The range representing the array or matrix of dependent data.")),_c("data_x (range<number>)",a("The range representing the array or matrix of independent data."))],returns:["NUMBER"],compute:function(e,t){const{flatDataX:o,flatDataY:s}=Id(t,e);xd(o,s);const n=o.length,i=o.map(((e,t)=>[e,s[t]]));i.sort(((e,t)=>e[0]-t[0]));for(let e=0;e<n;++e)i[e][0]=e;i.sort(((e,t)=>e[1]-t[1]));let r=0;for(let e=0;e<n;++e)r+=(i[e][0]-e)**2;return 1-6*r/(n**3-n)},isExported:!1},wu={description:a("Standard deviation."),args:[_c("value1 (number, range<number>)",a("The first value or range of the sample.")),_c("value2 (number, range<number>, repeating)",a("Additional values or ranges to include in the sample."))],returns:["NUMBER"],compute:function(...e){return Math.sqrt(Mu.compute.bind(this)(...e))},isExported:!0},xu={description:a("Standard deviation of entire population."),args:[_c("value1 (number, range<number>)",a("The first value or range of the population.")),_c("value2 (number, range<number>, repeating)",a("Additional values or ranges to include in the population."))],returns:["NUMBER"],compute:function(...e){return Math.sqrt(Nu.compute.bind(this)(...e))},isExported:!0},Iu={description:a("Standard deviation."),args:[_c("value1 (number, range<number>)",a("The first value or range of the sample.")),_c("value2 (number, range<number>, repeating)",a("Additional values or ranges to include in the sample."))],returns:["NUMBER"],compute:function(...e){return Math.sqrt(Fu.compute.bind(this)(...e))},isExported:!0},Ru={description:a("Standard deviation of sample (text as 0)."),args:[_c("value1 (number, range<number>)",a("The first value or range of the sample.")),_c("value2 (number, range<number>, repeating)",a("Additional values or ranges to include in the sample."))],returns:["NUMBER"],compute:function(...e){return Math.sqrt(Du.compute.bind(this)(...e))},isExported:!0},Tu={description:a("Standard deviation of entire population."),args:[_c("value1 (number, range<number>)",a("The first value or range of the population.")),_c("value2 (number, range<number>, repeating)",a("Additional values or ranges to include in the population."))],returns:["NUMBER"],compute:function(...e){return Math.sqrt(Lu.compute.bind(this)(...e))},isExported:!0},Au={description:a("Standard deviation of entire population (text as 0)."),args:[_c("value1 (number, range<number>)",a("The first value or range of the population.")),_c("value2 (number, range<number>, repeating)",a("Additional values or ranges to include in the population."))],returns:["NUMBER"],compute:function(...e){return Math.sqrt(Pu.compute.bind(this)(...e))},isExported:!0},Ou={description:a("Calculates the standard error of the predicted y-value for each x in the regression of a dataset."),args:[_c("data_y (range<number>)",a("The range representing the array or matrix of dependent data.")),_c("data_x (range<number>)",a("The range representing the array or matrix of independent data."))],returns:["NUMBER"],compute:function(e,t){const{flatDataX:o,flatDataY:s}=Id(e,t);xd(o,s);return _d([o],[s],!0,!0)[1][2]},isExported:!0},_u={description:a("Fits points to linear trend derived via least-squares."),args:[_c("known_data_y (number, range<number>)",a("The array or range containing dependent (y) values that are already known, used to curve fit an ideal linear trend.")),_c("known_data_x (number, range<number>, optional, default={1;2;3;...})",a("The values of the independent variable(s) corresponding with known_data_y.")),_c("new_data_x (number, range<number>, optional, default=known_data_x)",a("The data points to return the y values for on the ideal curve fit.")),_c("b (boolean, optional, default=TRUE)",a("Given a general linear form of y = m*x+b for a curve fit, calculates b if TRUE or forces b to be 0 and only calculates the m values if FALSE, i.e. forces the curve fit to pass through the origin."))],returns:["NUMBER"],compute:function(e,t=[],o=[],s=!0){return wd(e,"known_data_y"),Dd(Uo(e,"the first argument (known_data_y)"),Uo(t,"the second argument (known_data_x)"),Uo(o,"the third argument (new_data_y)"),Zo(s))}},Mu={description:a("Variance."),args:[_c("value1 (number, range<number>)",a("The first value or range of the sample.")),_c("value2 (number, range<number>, repeating)",a("Additional values or ranges to include in the sample."))],returns:["NUMBER"],compute:function(...e){return Td(e,!0,!1,this.locale)},isExported:!0},Nu={description:a("Variance of entire population."),args:[_c("value1 (number, range<number>)",a("The first value or range of the population.")),_c("value2 (number, range<number>, repeating)",a("Additional values or ranges to include in the population."))],returns:["NUMBER"],compute:function(...e){return Td(e,!1,!1,this.locale)},isExported:!0},Fu={description:a("Variance."),args:[_c("value1 (number, range<number>)",a("The first value or range of the sample.")),_c("value2 (number, range<number>, repeating)",a("Additional values or ranges to include in the sample."))],returns:["NUMBER"],compute:function(...e){return Td(e,!0,!1,this.locale)},isExported:!0},Du={description:a("Variance of sample (text as 0)."),args:[_c("value1 (number, range<number>)",a("The first value or range of the sample.")),_c("value2 (number, range<number>, repeating)",a("Additional values or ranges to include in the sample."))],returns:["NUMBER"],compute:function(...e){return Td(e,!0,!0,this.locale)},isExported:!0},Lu={description:a("Variance of entire population."),args:[_c("value1 (number, range<number>)",a("The first value or range of the population.")),_c("value2 (number, range<number>, repeating)",a("Additional values or ranges to include in the population."))],returns:["NUMBER"],compute:function(...e){return Td(e,!1,!1,this.locale)},isExported:!0},Pu={description:a("Variance of entire population (text as 0)."),args:[_c("value1 (number, range<number>)",a("The first value or range of the population.")),_c("value2 (number, range<number>, repeating)",a("Additional values or ranges to include in the population."))],returns:["NUMBER"],compute:function(...e){return Td(e,!1,!0,this.locale)},isExported:!0};var Vu=Object.freeze({__proto__:null,AVEDEV:Ld,AVERAGE:Pd,AVERAGEA:Bd,AVERAGEIF:Hd,AVERAGEIFS:zd,AVERAGE_WEIGHTED:Ud,CORREL:cu,COUNT:Gd,COUNTA:$d,COVAR:Wd,COVARIANCE_P:qd,COVARIANCE_S:Zd,FORECAST:Yd,GROWTH:jd,INTERCEPT:Xd,LARGE:Kd,LINEST:Qd,LOGEST:Jd,MATTHEWS:eu,MAX:tu,MAXA:ou,MAXIFS:su,MEDIAN:nu,MIN:iu,MINA:ru,MINIFS:au,PEARSON:lu,PERCENTILE:hu,PERCENTILE_EXC:du,PERCENTILE_INC:uu,POLYFIT_COEFFS:gu,POLYFIT_FORECAST:pu,QUARTILE:mu,QUARTILE_EXC:fu,QUARTILE_INC:bu,RANK:vu,RSQ:Su,SLOPE:Cu,SMALL:Eu,SPEARMAN:yu,STDEV:wu,STDEVA:Ru,STDEVP:Tu,STDEVPA:Au,STDEV_P:xu,STDEV_S:Iu,STEYX:Ou,TREND:_u,VAR:Mu,VARA:Du,VARP:Lu,VARPA:Pu,VAR_P:Nu,VAR_S:Fu});function ku(e,t,o,s){const n=new Map,i=e.length;for(let t=i-1;t>=0;t--)n.set($o(e[t][0]).toUpperCase(),t);if("number"!=typeof t&&"string"!=typeof t)throw new Error(a("The field must be a number or a string"));let r;if("number"==typeof t){if(r=Math.trunc(t)-1,r<0||i-1<r)throw new Error(a("The field (%s) must be one of %s or must be a number between 1 and %s inclusive.",t.toString(),i.toString()))}else{const e=$o(t).toUpperCase();if(r=n.get(e)??-1,-1===r)throw new Error(a("The field (%s) must be one of %s.",$o(t),[...n.keys()].toString()))}const l=o[0].length;if(l<2)throw new Error(a("The criteria range contains %s row, it must be at least 2 rows.",l.toString()));let c=new Set;const h=e[0].length;for(let t=1;t<l;t++){let i=[],r=!0;for(let s=0;s<o.length;s++){const a=$o(o[s][0]).toUpperCase(),l=n.get(a),c=o[s][t];if(null!==c){if(void 0===l){r=!1;break}i.push([e[l].slice(1,h)]),i.push(c)}}if(r){if(!(i.length>0)){c=new Set(Array(h-1).keys());break}ls(i,((e,t)=>{c.add(t)}),s,!0)}}const d=e[r];return[...c].map((e=>d[e+1]))}const Uu=[_c("database (range)",a("The array or range containing the data to consider, structured in such a way that the first row contains the labels for each column's values.")),_c("field (any)",a("Indicates which column in database contains the values to be extracted and operated on.")),_c("criteria (range)",a("An array or range containing zero or more criteria to filter the database values by before operating."))],Bu={description:a("Average of a set of values from a table-like range."),args:Uu,returns:["NUMBER"],compute:function(e,t,o){const s=ku(e,t,o,this.locale);return Pd.compute.bind(this)([s])},isExported:!0},Hu={description:a("Counts values from a table-like range."),args:Uu,returns:["NUMBER"],compute:function(e,t,o){const s=ku(e,t,o,this.locale);return Gd.compute.bind(this)([s])},isExported:!0},zu={description:a("Counts values and text from a table-like range."),args:Uu,returns:["NUMBER"],compute:function(e,t,o){const s=ku(e,t,o,this.locale);return $d.compute.bind(this)([s])},isExported:!0},Gu={description:a("Single value from a table-like range."),args:Uu,returns:["NUMBER"],compute:function(e,t,o){const s=ku(e,t,o,this.locale);return Lo((()=>1===s.length),a("More than one match found in DGET evaluation.")),s[0]},isExported:!0},$u={description:a("Maximum of values from a table-like range."),args:Uu,returns:["NUMBER"],compute:function(e,t,o){const s=ku(e,t,o,this.locale);return tu.compute.bind(this)([s])},isExported:!0},Wu={description:a("Minimum of values from a table-like range."),args:Uu,returns:["NUMBER"],compute:function(e,t,o){const s=ku(e,t,o,this.locale);return iu.compute.bind(this)([s])},isExported:!0},qu={description:a("Product of values from a table-like range."),args:Uu,returns:["NUMBER"],compute:function(e,t,o){const s=ku(e,t,o,this.locale);return od.compute.bind(this)([s])},isExported:!0},Zu={description:a("Standard deviation of population sample from table."),args:Uu,returns:["NUMBER"],compute:function(e,t,o){const s=ku(e,t,o,this.locale);return wu.compute.bind(this)([s])},isExported:!0},Yu={description:a("Standard deviation of entire population from table."),args:Uu,returns:["NUMBER"],compute:function(e,t,o){const s=ku(e,t,o,this.locale);return Tu.compute.bind(this)([s])},isExported:!0},ju={description:a("Sum of values from a table-like range."),args:Uu,returns:["NUMBER"],compute:function(e,t,o){const s=ku(e,t,o,this.locale);return pd.compute.bind(this)([s])},isExported:!0},Xu={description:a("Variance of population sample from table-like range."),args:Uu,returns:["NUMBER"],compute:function(e,t,o){const s=ku(e,t,o,this.locale);return Mu.compute.bind(this)([s])},isExported:!0},Ku={description:a("Variance of a population from a table-like range."),args:Uu,returns:["NUMBER"],compute:function(e,t,o){const s=ku(e,t,o,this.locale);return Lu.compute.bind(this)([s])},isExported:!0};var Qu=Object.freeze({__proto__:null,DAVERAGE:Bu,DCOUNT:Hu,DCOUNTA:zu,DGET:Gu,DMAX:$u,DMIN:Wu,DPRODUCT:qu,DSTDEV:Zu,DSTDEVP:Yu,DSUM:ju,DVAR:Xu,DVARP:Ku});var Ju;!function(e){e.WHOLE_YEARS="Y",e.WHOLE_MONTHS="M",e.WHOLE_DAYS="D",e.DAYS_WITHOUT_WHOLE_MONTHS="MD",e.MONTH_WITHOUT_WHOLE_YEARS="YM",e.DAYS_BETWEEN_NO_MORE_THAN_ONE_YEAR="YD"}(Ju||(Ju={}));const eg={description:a("Converts year/month/day into a date."),args:[_c("year (number)",a("The year component of the date.")),_c("month (number)",a("The month component of the date.")),_c("day (number)",a("The day component of the date."))],returns:["DATE"],computeFormat:function(){return this.locale.dateFormat},compute:function(e,t,o){let s=Math.trunc(Vo(e,this.locale));const n=Math.trunc(Vo(t,this.locale)),i=Math.trunc(Vo(o,this.locale));Lo((()=>0<=s&&s<=9999),a("The year (%s) must be between 0 and 9999 inclusive.",s.toString())),s<1900&&(s+=1900);const r=Jt(new Pt(s,n-1,i));return Lo((()=>r>=0),a("The function [[FUNCTION_NAME]] result must be greater than or equal 01/01/1900.")),r},isExported:!0},tg={description:a("Calculates the number of days, months, or years between two dates."),args:[_c("start_date (date)",a("The start date to consider in the calculation. Must be a reference to a cell containing a DATE, a function returning a DATE type, or a number.")),_c("end_date (date)",a("The end date to consider in the calculation. Must be a reference to a cell containing a DATE, a function returning a DATE type, or a number.")),_c("unit (string)",a('A text abbreviation for unit of time. Accepted values are "Y" (the number of whole years between start_date and end_date), "M" (the number of whole months between start_date and end_date), "D" (the number of days between start_date and end_date), "MD" (the number of days between start_date and end_date after subtracting whole months), "YM" (the number of whole months between start_date and end_date after subtracting whole years), "YD" (the number of days between start_date and end_date, assuming start_date and end_date were no more than one year apart).'))],returns:["NUMBER"],compute:function(e,t,o){const s=$o(o).toUpperCase();Lo((()=>Object.values(Ju).includes(s)),((e,t)=>{const o=e.map((e=>`'${e}'`)).join(", ");return a("The function [[FUNCTION_NAME]] has an argument with value '%s'. It should be one of: %s.",t,o)})(Object.values(Ju),$o(o)));const n=Math.trunc(Vo(e,this.locale)),i=Math.trunc(Vo(t,this.locale)),r=Qt(n),l=Qt(i);switch(Lo((()=>i>=n),a("start_date (%s) should be on or before end_date (%s).",r.toLocaleDateString(),l.toLocaleDateString())),s){case Ju.WHOLE_YEARS:return lo(r,l);case Ju.WHOLE_MONTHS:return ro(r,l);case Ju.WHOLE_DAYS:return ao(r,l);case Ju.MONTH_WITHOUT_WHOLE_YEARS:return ro(r,l)-12*lo(r,l);case Ju.DAYS_WITHOUT_WHOLE_MONTHS:let e=l.getDate()-r.getDate();if(e<0){e=to(new Pt(l.getFullYear(),l.getMonth()-1,1))-Math.abs(e)}return e;case Ju.DAYS_BETWEEN_NO_MORE_THAN_ONE_YEAR:{if(function(e,t){return io(e,t,1)<1}(n,i))return ao(r,l);const e=new Pt(r.getFullYear(),l.getMonth(),l.getDate());let t=ao(r,e);return t<0&&(e.setFullYear(r.getFullYear()+1),t=ao(r,e)),t}}},isExported:!0},og={description:a("Converts a date string to a date value."),args:[_c("date_string (string)",a("The string representing the date."))],returns:["NUMBER"],compute:function(e){const t=$o(e),o=Kt(t,this.locale);return Lo((()=>null!==o),a("The date_string (%s) cannot be parsed to date/time.",t.toString())),Math.trunc(o.value)},isExported:!0},sg={description:a("Day of the month that a specific date falls on."),args:[_c("date (string)",a("The date from which to extract the day."))],returns:["NUMBER"],compute:function(e){return Yo(e,this.locale).getDate()},isExported:!0},ng={description:a("Number of days between two dates."),args:[_c("end_date (date)",a("The end of the date range.")),_c("start_date (date)",a("The start of the date range."))],returns:["NUMBER"],compute:function(e,t){const o=Yo(e,this.locale),s=Yo(t,this.locale),n=o.getTime()-s.getTime();return Math.round(n/kt)},isExported:!0},ig={description:a("Number of days between two dates on a 360-day year (months of 30 days)."),args:[_c("start_date (date)",a("The start date to consider in the calculation.")),_c("end_date (date)",a("The end date to consider in the calculation.")),_c("method (number, default=0)",a("An indicator of what day count method to use. (0) US NASD method (1) European method"))],returns:["NUMBER"],compute:function(e,t,o=0){const s=Vo(e,this.locale),n=Vo(t,this.locale),i=Zo(o)?4:0,r=Ig.compute.bind(this)(e,t,i);return Math.sign(n-s)*Math.round(360*r)},isExported:!0},rg={description:a("Date a number of months before/after another date."),args:[_c("start_date (date)",a("The date from which to calculate the result.")),_c("months (number)",a("The number of months before (negative) or after (positive) 'start_date' to calculate."))],returns:["DATE"],computeFormat:function(){return this.locale.dateFormat},compute:function(e,t){return Jt(so(Yo(e,this.locale),Math.trunc(Vo(t,this.locale)),!1))},isExported:!0},ag={description:a("Last day of a month before or after a date."),args:[_c("start_date (date)",a("The date from which to calculate the result.")),_c("months (number)",a("The number of months before (negative) or after (positive) 'start_date' to consider."))],returns:["DATE"],computeFormat:function(){return this.locale.dateFormat},compute:function(e,t){const o=Yo(e,this.locale),s=Math.trunc(Vo(t,this.locale)),n=o.getFullYear(),i=o.getMonth();return Jt(new Pt(n,i+s+1,0))},isExported:!0},lg={description:a("Hour component of a specific time."),args:[_c("time (date)",a("The time from which to calculate the hour component."))],returns:["NUMBER"],compute:function(e){return Yo(e,this.locale).getHours()},isExported:!0},cg={description:a("ISO week number of the year."),args:[_c("date (date)",a("The date for which to determine the ISO week number. Must be a reference to a cell containing a date, a function returning a date type, or a number."))],returns:["NUMBER"],compute:function(e){const t=Yo(e,this.locale),o=t.getFullYear();let s=1;for(;4!==new Pt(o,0,s).getDay();)s+=1;const n=new Pt(o,0,s-3);let i=31;for(;4!==new Pt(o,11,i).getDay();)i-=1;const r=new Pt(o,11,i+3);let a,l;switch(a=n.getTime()<=t.getTime()?t.getTime()<=r.getTime()?0:1:-1,a){case 0:l=n;break;case 1:l=new Pt(o,11,i+3+1);break;case-1:let e=1;for(;4!==new Pt(o-1,0,e).getDay();)e+=1;l=new Pt(o-1,0,e-3)}const c=(t.getTime()-l.getTime())/kt;return Math.floor(c/7)+1},isExported:!0},hg={description:a("Minute component of a specific time."),args:[_c("time (date)",a("The time from which to calculate the minute component."))],returns:["NUMBER"],compute:function(e){return Yo(e,this.locale).getMinutes()},isExported:!0},dg={description:a("Month of the year a specific date falls in"),args:[_c("date (date)",a("The date from which to extract the month."))],returns:["NUMBER"],compute:function(e){return Yo(e,this.locale).getMonth()+1},isExported:!0},ug={description:a("Net working days between two provided days."),args:[_c("start_date (date)",a("The start date of the period from which to calculate the number of net working days.")),_c("end_date (date)",a("The end date of the period from which to calculate the number of net working days.")),_c("holidays (date, range<date>, optional)",a("A range or array constant containing the date serial numbers to consider holidays."))],returns:["NUMBER"],compute:function(e,t,o){return pg.compute.bind(this)(e,t,1,o)},isExported:!0};function gg(e){if("string"==typeof e){Lo((()=>{if(7!==e.length)return!1;for(let t of e)if("0"!==t&&"1"!==t)return!1;return!0}),a('When weekend is a string (%s) it must be composed of "0" or "1".',e));let t=[];for(let o=0;o<7;o++)"1"===e[o]&&t.push((o+1)%7);return t}if("number"==typeof e)return Lo((()=>1<=e&&e<=7||11<=e&&e<=17),a("The weekend (%s) must be a string or a number in the range 1-7 or 11-17.",e.toString())),e<=7?[e-2==-1?6:e-2,e-1]:[e-11];throw Error(a("The weekend must be a number or a string."))}const pg={description:a("Net working days between two dates (specifying weekends)."),args:[_c("start_date (date)",a("The start date of the period from which to calculate the number of net working days.")),_c("end_date (date)",a("The end date of the period from which to calculate the number of net working days.")),_c("weekend (any, default=1)",a("A number or string representing which days of the week are considered weekends.")),_c("holidays (date, range<date>, optional)",a("A range or array constant containing the dates to consider as holidays."))],returns:["NUMBER"],compute:function(e,t,o=1,s){const n=Yo(e,this.locale),i=Yo(t,this.locale),r=gg(o);let a=new Set;void 0!==s&&Xo([s],(e=>{const t=Yo(e,this.locale);a.add(t.getTime())}));const l=n.getTime()>i.getTime(),c=Pt.fromTimestamp((l?n:i).getTime());let h=Pt.fromTimestamp((l?i:n).getTime());const d=c.getTime();let u=h.getTime(),g=0;for(;u<=d;)r.includes(h.getDay())||a.has(u)||(g+=1),h.setDate(h.getDate()+1),u=h.getTime();return l?-g:g},isExported:!0},mg={description:a("Current date and time as a date value."),args:[],returns:["DATE"],computeFormat:function(){return Aa(this.locale)},compute:function(){let e=Pt.now();const t=e.getTime()-Vt.getTime(),o=e.getHours()/24+e.getMinutes()/1440+e.getSeconds()/86400;return Math.floor(t/kt)+o},isExported:!0},fg={description:a("Minute component of a specific time."),args:[_c("time (date)",a("The time from which to calculate the second component."))],returns:["NUMBER"],compute:function(e){return Yo(e,this.locale).getSeconds()},isExported:!0},bg={description:a("Converts hour/minute/second into a time."),args:[_c("hour (number)",a("The hour component of the time.")),_c("minute (number)",a("The minute component of the time.")),_c("second (number)",a("The second component of the time."))],returns:["DATE"],computeFormat:function(){return this.locale.timeFormat},compute:function(e,t,o){let s=Math.trunc(Vo(e,this.locale)),n=Math.trunc(Vo(t,this.locale)),i=Math.trunc(Vo(o,this.locale));return n+=Math.floor(i/60),i=i%60+(i<0?60:0),s+=Math.floor(n/60),n=n%60+(n<0?60:0),s%=24,Lo((()=>s>=0),a("The function [[FUNCTION_NAME]] result cannot be negative")),s/24+n/1440+i/86400},isExported:!0},vg={description:a("Converts a time string into its serial number representation."),args:[_c("time_string (string)",a("The string that holds the time representation."))],returns:["NUMBER"],compute:function(e){const t=$o(e),o=Kt(t,this.locale);Lo((()=>null!==o),a("The time_string (%s) cannot be parsed to date/time.",t));const s=o.value-Math.trunc(o.value);return s<0?1+s:s},isExported:!0},Sg={description:a("Current date as a date value."),args:[],returns:["DATE"],computeFormat:function(){return this.locale.dateFormat},compute:function(){const e=Pt.now();return Jt(new Pt(e.getFullYear(),e.getMonth(),e.getDate()))},isExported:!0},Cg={description:a("Day of the week of the date provided (as number)."),args:[_c("date (date)",a("The date for which to determine the day of the week. Must be a reference to a cell containing a date, a function returning a date type, or a number.")),_c("type (number, default=1)",a("A number indicating which numbering system to use to represent weekdays. By default, counts starting with Sunday = 1."))],returns:["NUMBER"],compute:function(e,t=1){const o=Yo(e,this.locale),s=Math.round(Vo(t,this.locale)),n=o.getDay();return Lo((()=>[1,2,3].includes(s)),a("The type (%s) must be 1, 2 or 3.",s.toString())),1===s?n+1:2===s?0===n?7:n:0===n?6:n-1},isExported:!0},Eg={description:a("Week number of the year."),args:[_c("date (date)",a("The date for which to determine the week number. Must be a reference to a cell containing a date, a function returning a date type, or a number.")),_c("type (number, default=1)",a("A number representing the day that a week starts on. Sunday = 1."))],returns:["NUMBER"],compute:function(e,t=1){const o=Yo(e,this.locale),s=Math.round(Vo(t,this.locale));if(Lo((()=>1===s||2===s||11<=s&&s<=17||21===s),a("The type (%s) is out of range.",s.toString())),21===s)return cg.compute.bind(this)(e);let n;n=1===s||2===s?s-1:s-10==7?0:s-10;const i=o.getFullYear();let r=1,l=new Pt(i,0,r);for(;l.getDay()!==n;)r+=1,l=new Pt(i,0,r);const c=(o.getTime()-l.getTime())/kt;return c<0?1:Math.floor(c/7)+(1===r?1:2)},isExported:!0},yg={description:a("Date after a number of workdays."),args:[_c("start_date (date)",a("The date from which to begin counting.")),_c("num_days (number)",a("The number of working days to advance from start_date. If negative, counts backwards.")),_c("holidays (date, range<date>, optional)",a("A range or array constant containing the dates to consider holidays."))],returns:["NUMBER"],computeFormat:function(){return this.locale.dateFormat},compute:function(e,t,o=void 0){return wg.compute.bind(this)(e,t,1,o??null)},isExported:!0},wg={description:a("Date after a number of workdays (specifying weekends)."),args:[_c("start_date (date)",a("The date from which to begin counting.")),_c("num_days (number)",a("The number of working days to advance from start_date. If negative, counts backwards.")),_c("weekend (any, default=1)",a("A number or string representing which days of the week are considered weekends.")),_c("holidays (date, range<date>, optional)",a("A range or array constant containing the dates to consider holidays."))],returns:["DATE"],computeFormat:function(){return this.locale.dateFormat},compute:function(e,t,o=1,s){let n=Yo(e,this.locale),i=Math.trunc(Vo(t,this.locale));"string"==typeof o&&Lo((()=>"1111111"!==o),a("The weekend (%s) must be different from '1111111'.",o));const r=gg(o);let l=new Set;void 0!==s&&Xo([s],(e=>{const t=Yo(e,this.locale);l.add(t.getTime())}));let c=Pt.fromTimestamp(n.getTime()),h=c.getTime();const d=Math.sign(i);let u=Math.abs(i);for(;u>0;)c.setDate(c.getDate()+d),h=c.getTime(),r.includes(c.getDay())||l.has(h)||(u-=1);const g=h-Vt.getTime();return Math.round(g/kt)},isExported:!0},xg={description:a("Year specified by a given date."),args:[_c("date (date)",a("The date from which to extract the year."))],returns:["NUMBER"],compute:function(e){return Yo(e,this.locale).getFullYear()},isExported:!0},Ig={description:a("Exact number of years between two dates."),args:[_c("start_date (date)",a("The start date to consider in the calculation. Must be a reference to a cell containing a date, a function returning a date type, or a number.")),_c("end_date (date)",a("The end date to consider in the calculation. Must be a reference to a cell containing a date, a function returning a date type, or a number.")),_c("day_count_convention (number, default=0)",a("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,o=0){let s=Math.trunc(Vo(e,this.locale)),n=Math.trunc(Vo(t,this.locale));const i=Math.trunc(Vo(o,this.locale));return Lo((()=>s>=0),a("The start_date (%s) must be positive or null.",s.toString())),Lo((()=>n>=0),a("The end_date (%s) must be positive or null.",n.toString())),Lo((()=>0<=i&&i<=4),a("The day_count_convention (%s) must be between 0 and 4 inclusive.",i.toString())),io(s,n,i)}},Rg={description:a("First day of the month preceding a date."),args:[_c("date (date)",a("The date from which to calculate the result."))],returns:["DATE"],computeFormat:function(){return this.locale.dateFormat},compute:function(e){const t=Yo(e,this.locale),o=t.getFullYear(),s=t.getMonth();return Jt(new Pt(o,s,1))}},Tg={description:a("Last day of the month following a date."),args:[_c("date (date)",a("The date from which to calculate the result."))],returns:["DATE"],computeFormat:function(){return this.locale.dateFormat},compute:function(e){return ag.compute.bind(this)(e,0)}},Ag={description:a("Quarter of the year a specific date falls in"),args:[_c("date (date)",a("The date from which to extract the quarter."))],returns:["NUMBER"],compute:function(e){return Math.ceil((Yo(e,this.locale).getMonth()+1)/3)}},Og={description:a("First day of the quarter of the year a specific date falls in."),args:[_c("date (date)",a("The date from which to calculate the start of quarter."))],returns:["DATE"],computeFormat:function(){return this.locale.dateFormat},compute:function(e){const t=Ag.compute.bind(this)(e),o=xg.compute.bind(this)(e);return Jt(new Pt(o,3*(t-1),1))}},_g={description:a("Last day of the quarter of the year a specific date falls in."),args:[_c("date (date)",a("The date from which to calculate the end of quarter."))],returns:["DATE"],computeFormat:function(){return this.locale.dateFormat},compute:function(e){const t=Ag.compute.bind(this)(e),o=xg.compute.bind(this)(e);return Jt(new Pt(o,3*t,0))}},Mg={description:a("First day of the year a specific date falls in."),args:[_c("date (date)",a("The date from which to calculate the start of the year."))],returns:["DATE"],computeFormat:function(){return this.locale.dateFormat},compute:function(e){const t=xg.compute.bind(this)(e);return Jt(new Pt(t,0,1))}},Ng={description:a("Last day of the year a specific date falls in."),args:[_c("date (date)",a("The date from which to calculate the end of the year."))],returns:["DATE"],computeFormat:function(){return this.locale.dateFormat},compute:function(e){const t=xg.compute.bind(this)(e);return Jt(new Pt(t+1,0,0))}};var Fg=Object.freeze({__proto__:null,DATE:eg,DATEDIF:tg,DATEVALUE:og,DAY:sg,DAYS:ng,DAYS360:ig,EDATE:rg,EOMONTH:ag,HOUR:lg,ISOWEEKNUM:cg,MINUTE:hg,MONTH:dg,MONTH_END:Tg,MONTH_START:Rg,NETWORKDAYS:ug,NETWORKDAYS_INTL:pg,NOW:mg,QUARTER:Ag,QUARTER_END:_g,QUARTER_START:Og,SECOND:fg,TIME:bg,TIMEVALUE:vg,TODAY:Sg,WEEKDAY:Cg,WEEKNUM:Eg,WORKDAY:yg,WORKDAY_INTL:wg,YEAR:xg,YEARFRAC:Ig,YEAR_END:Ng,YEAR_START:Mg});const Dg={description:a("Compare two numeric values, returning 1 if they're equal."),args:[_c("number1 (number)",a("The first number to compare.")),_c("number2 (number, default=0)",a("The second number to compare."))],returns:["NUMBER"],compute:function(e,t=0){return Vo(e,this.locale)===Vo(t,this.locale)?1:0},isExported:!0};var Lg=Object.freeze({__proto__:null,DELTA:Dg});const Pg=[bo.number,bo.error,bo.text,bo.boolean];function Vg(e){const t="ascending"===e?1:-1;return(e,o)=>{if(e.type===bo.empty)return o.type===bo.empty?0:1;if(o.type===bo.empty)return-1;let s=Pg.indexOf(e.type)-Pg.indexOf(o.type);return 0===s&&(s=e.type===bo.text||e.type===bo.error?e.value.localeCompare(o.value):e.value-o.value),t*s}}function kg(e,t,o,s,n){let i=Io.Success,r=s.right>s.left;if(e.model.getters.doesIntersectMerge(t,s)){let o;r=!1;for(let n=s.top;n<=s.bottom;n++){o=[];for(let i=s.left;i<=s.right;i++){let s=e.model.getters.getMerge({sheetId:t,col:i,row:n});s&&!o.includes(s.id.toString())&&o.push(s.id.toString())}if(o.length>=2){r=!0;break}}}const{col:l,row:c}=o;if(r)i=e.model.dispatch("SORT_CELLS",{sheetId:t,col:l,row:c,zone:s,sortDirection:n});else{const o=e.model.getters.getContiguousZone(t,s);wn(o,s)?i=e.model.dispatch("SORT_CELLS",{sheetId:t,col:l,row:c,zone:s,sortDirection:n}):e.askConfirmation(a("We found data next to your selection. Since this data was not selected, it will not be sorted. Do you want to extend your selection?"),(()=>{s=o,i=e.model.dispatch("SORT_CELLS",{sheetId:t,col:l,row:c,zone:s,sortDirection:n})}),(()=>{i=e.model.dispatch("SORT_CELLS",{sheetId:t,col:l,row:c,zone:s,sortDirection:n})}))}if(i.isCancelledBecause("InvalidSortZone")){const{col:t,row:n}=o;e.model.selection.selectZone({cell:{col:t,row:n},zone:s}),e.raiseError(a("Cannot sort. To sort, select only cells or only merges that have the same size."))}}function Ug(e,t,...o){for(let e=0;e<o.length;e++){Lo((()=>void 0!==o[e]),a("Value for parameter %s is missing in [[FUNCTION_NAME]].",e%2==0?"sort_column":"is_ascending"))}const s=[],n=[],i=e.length;for(let r=0;r<o.length;r+=2){s.push(Zo(Hc(o[r+1])?.value)?"ascending":"descending");const l=o[r];if(Mo(l)&&(l.length>1||l[0].length>1))Lo((()=>1===l.length&&l[0].length===i),a("Wrong size for %s. Expected a range of size 1x%s. Got %sx%s.",`sort_column${r+1}`,i,l.length,l[0].length)),n.push(l.flat().map((e=>e.value)));else{const o=Vo(Hc(l)?.value,t);if(o<1||o>e[0].length)return e;n.push(e.map((e=>e[o-1].value)))}}if(0===n.length)for(let t=0;t<e[0].length;t++)n.push(e.map((e=>e[t].value))),s.push("ascending");const r={descending:Vg("descending"),ascending:Vg("ascending")},l=Ne(0,e.length);return l.sort(((e,t)=>{for(const[o,i]of n.entries()){const n=i[e],a=i[t],l={value:n,type:null===n?bo.empty:"string"==typeof n?bo.text:typeof n},c={value:a,type:null===a?bo.empty:"string"==typeof a?bo.text:typeof a},h=r[s[o]](l,c);if(0!==h)return h}return 0})),l.map((t=>e[t]))}const Bg={description:a("Returns a filtered version of the source range, returning only rows or columns that meet the specified conditions."),args:[_c("range (any, range<any>)",a("The data to be filtered.")),_c("condition1 (boolean, range<boolean>)",a("A column or row containing true or false values corresponding to the first column or row of range.")),_c("condition2 (boolean, range<boolean>, repeating)",a("Additional column or row containing true or false values."))],returns:["RANGE<ANY>"],computeValueAndFormat:function(e,...t){let o=gs(e);const s=t.map((e=>ss(gs(e),(e=>e.value))));s.map((e=>Nc(a("The arguments condition must be a single column or row."),e))),Fc(a("The arguments conditions must have the same dimensions."),...s);const n=s.map((e=>e.flat())),i=1===s[0].length?"row":"col";o="row"===i?ns(o):o,Lo((()=>n.every((e=>e.length===o.length))),a("FILTER has mismatched sizes on the range and conditions."));const r=[];for(let e=0;e<o.length;e++){const t=o[e];n.every((t=>t[e]))&&r.push(t)}if(!r.length)throw new m(a("No match found in FILTER evaluation"));return"row"===i?ns(r):r},isExported:!1},Hg={description:a("Sorts the rows of a given array or range by the values in one or more columns."),args:[_c("range (range)",a("The data to be sorted.")),_c("sort_column (any, range<number>, repeating)",a("The index of the column in range or a range outside of range containing the values by which to sort.")),_c("is_ascending (boolean, repeating)",a("TRUE or FALSE indicating whether to sort sort_column in ascending order. FALSE sorts in descending order."))],returns:["RANGE"],computeValueAndFormat:function(e,...t){const o=ns(e);return ns(Ug(o,this.locale,...t))},isExported:!0},zg={description:a("Returns the first n items in a data set after performing a sort."),args:[_c("range (range)",a("The data to be sorted.")),_c("n (number, default=1)",a("The number of items to return.")),_c("display_ties_mode (number, default=0)",a("A number representing the way to display ties.")),_c("sort_column (number, range<number>, repeating)",a("The index of the column in range or a range outside of range containing the values by which to sort.")),_c("is_ascending (boolean, repeating)",a("TRUE or FALSE indicating whether to sort sort_column in ascending order. FALSE sorts in descending order."))],returns:["RANGE"],computeValueAndFormat:function(e,t,o,...s){const n=Vo(t?.value??1,this.locale);Lo((()=>n>=0),a("Wrong value of 'n'. Expected a positive number. Got %s.",n));const i=Vo(o?.value??0,this.locale);Lo((()=>i>=0&&i<=3),a("Wrong value of 'display_ties_mode'. Expected a positive number between 0 and 3. Got %s.",i));const r=Ug(ns(e),this.locale,...s),l=(e,t)=>JSON.stringify(r[e].map((e=>e.value)))===JSON.stringify(r[t].map((e=>e.value)));switch(i){case 0:return ns(r.slice(0,n));case 1:for(let e=n;e<r.length;e++)if(!l(e,n-1))return ns(r.slice(0,e));return ns(r);case 2:{const e=[r[0]];for(let t=1;t<r.length;t++)for(let o=0;o<t&&!l(t,o);o++)o===t-1&&e.push(r[t]);return ns(e.slice(0,n))}case 3:{const e=[r[0]];let t=1;for(let o=1;o<r.length&&(l(o,o-1)||t++,!(t>n));o++)e.push(r[o]);return ns(e)}}},isExported:!1},Gg={description:a("Unique rows in the provided source range."),args:[_c("range (any, range<any>)",a("The data to filter by unique entries.")),_c("by_column (boolean, default=FALSE)",a("Whether to filter the data by columns or by rows.")),_c("exactly_once (boolean, default=FALSE)",a("Whether to return only entries with no duplicates."))],returns:["RANGE<NUMBER>"],computeValueAndFormat:function(e={value:""},t,o){if(!Mo(e))return[[e]];const s=Zo(t?.value)||!1,n=Zo(o?.value)||!1;s||(e=ns(e));const i=new Map;for(const t of e){const e=JSON.stringify(t.map((e=>e.value))),o=i.get(e);o?o.count++:i.set(e,{data:t,count:1})}const r=[];for(const e of i.values())n&&e.count>1||r.push(e.data);if(!r.length)throw new Error(a("No unique values found"));return s?r:ns(r)},isExported:!0};var $g=Object.freeze({__proto__:null,FILTER:Bg,SORT:Hg,SORTN:zg,UNIQUE:Gg});function Wg(e,t){Lo((()=>e<t),a("The maturity (%s) must be strictly greater than the settlement (%s).",t.toString(),e.toString()))}function qg(e,t){Lo((()=>t<e),a("The settlement date (%s) must be strictly greater than the issue date (%s).",e.toString(),t.toString()))}function Zg(e){Lo((()=>[1,2,4].includes(e)),a("The frequency (%s) must be one of %s",e.toString(),[1,2,4].toString()))}function Yg(e){Lo((()=>0<=e&&e<=4),a("The day_count_convention (%s) must be between 0 and 4 inclusive.",e.toString()))}function jg(e){Lo((()=>e>0),a("The redemption (%s) must be strictly positive.",e.toString()))}function Xg(e){Lo((()=>e>0),a("The price (%s) must be strictly positive.",e.toString()))}function Kg(e){Lo((()=>e>0),a("The number_of_periods (%s) must be greater than 0.",e.toString()))}function Qg(e){Lo((()=>e>0),a("The rate (%s) must be strictly positive.",e.toString()))}function Jg(e){Lo((()=>e>0),a("The life (%s) must be strictly positive.",e.toString()))}function ep(e){Lo((()=>e>=0),a("The cost (%s) must be positive or null.",e.toString()))}function tp(e){Lo((()=>e>0),a("The period (%s) must be strictly positive.",e.toString()))}function op(e){Lo((()=>e>=0),a("The salvage (%s) must be positive or null.",e.toString()))}function sp(e){Lo((()=>e>0),a("The present value (%s) must be strictly positive.",e.toString()))}function np(e,t){Lo((()=>e<=t),a("The period (%s) must be less than or equal life (%s).",e.toString(),t.toString()))}function ip(e){Lo((()=>e>0),a("The investment (%s) must be strictly positive.",e.toString()))}function rp(e){Lo((()=>e>0),a("The discount (%s) must be strictly positive.",e.toString()))}function ap(e){Lo((()=>e<1),a("The discount (%s) must be smaller than 1.",e.toString()))}function lp(e){Lo((()=>e>0),a("The depreciation factor (%s) must be strictly positive.",e.toString()))}function cp(e,t,o){const s=Yo(e,o),n=Yo(t,o),i=Yo(e,o);i.setFullYear(s.getFullYear()+1),Lo((()=>n.getTime()<=i.getTime()),a("The settlement date (%s) must at most one year after the maturity date (%s).",e.toString(),t.toString()))}function hp(e,t,o){Kg(o),Lo((()=>e>0),a("The first_period (%s) must be strictly positive.",e.toString())),Lo((()=>t>0),a("The last_period (%s) must be strictly positive.",t.toString())),Lo((()=>e<=t),a("The first_period (%s) must be smaller or equal to the last_period (%s).",e.toString(),t.toString())),Lo((()=>t<=o),a("The last_period (%s) must be smaller or equal to the number_of_periods (%s).",e.toString(),o.toString()))}function dp(e){Lo((()=>e>-1),a("The rate_guess (%s) must be strictly greater than -1.",e.toString()))}function up(e,t){Lo((()=>e.length===t.length&&e[0].length===t[0].length),a("The cashflow_amounts and cashflow_dates ranges must have the same dimensions."))}function gp(e){Lo((()=>e.every((t=>t>=e[0]))),a("All the dates should be greater or equal to the first date in cashflow_dates (%s).",e[0].toString()))}const pp=[_c("settlement (date)",a("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),_c("maturity (date)",a("The maturity or end date of the security, when it can be redeemed at face, or par value.")),_c("frequency (number)",a("The number of interest or coupon payments per year (1, 2, or 4).")),_c("day_count_convention (number, default=0 )",a("An indicator of what day count method to use."))];function mp(e,t,o,s,n=1e-10,i){let r,l,c,h,d=o,u=!1,g=0;do{c=e(d),isNaN(c)?(Lo((()=>g<s&&void 0!==i),a("Function [[FUNCTION_NAME]] didn't find any result.")),g++,d=i(h),h=d):(r=d-c/t(d),l=Math.abs(r-d),d=r,u=l<n||Math.abs(c)<n,Lo((()=>g<s),a("Function [[FUNCTION_NAME]] didn't find any result.")),g++)}while(!u);return d}const fp={description:a("Accrued interest of security paying at maturity."),args:[_c("issue (date)",a("The date the security was initially issued.")),_c("maturity (date)",a("The maturity date of the security.")),_c("rate (number)",a("The annualized rate of interest.")),_c("redemption (number)",a("The redemption amount per 100 face value, or par.")),_c("day_count_convention (number, default=0 )",a("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,o,s,n=0){n=n||0;const i=Math.trunc(Vo(e,this.locale)),r=Math.trunc(Vo(t,this.locale)),a=Vo(s,this.locale),l=Vo(o,this.locale),c=Math.trunc(Vo(n,this.locale));qg(r,i),Yg(c),jg(a),Qg(l);return a*l*Ig.compute.bind(this)(i,r,n)},isExported:!0},bp={description:a("Depreciation for an accounting period."),args:[_c("cost (number)",a("The initial cost of the asset.")),_c("purchase_date (date)",a("The date the asset was purchased.")),_c("first_period_end (date)",a("The date the first period ended.")),_c("salvage (number)",a("The value of the asset at the end of depreciation.")),_c("period (number)",a("The single period within life for which to calculate depreciation.")),_c("rate (number)",a("The deprecation rate.")),_c("day_count_convention (number, optional)",a("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,o,s,n,i,r=0){r=r||0;const l=Vo(e,this.locale),c=Math.trunc(Vo(t,this.locale)),h=Math.trunc(Vo(o,this.locale)),d=Vo(s,this.locale),u=Vo(n,this.locale),g=Vo(i,this.locale),p=Math.trunc(Vo(r,this.locale));!function(e){Lo((()=>e>0),a("The cost (%s) must be strictly positive.",e.toString()))}(l),op(d),function(e,t){Lo((()=>e<=t),a("The salvage (%s) must be smaller or equal than the cost (%s).",e.toString(),t.toString()))}(d,l),function(e){Lo((()=>e>=0),a("The period (%s) must be positive or null.",e.toString()))}(u),Qg(g),Yg(p),Lo((()=>c<=h),a("The purchase_date (%s) must be before the first_period_end (%s).",c.toString(),h.toString()));const m=u<1&&u>0?1:Math.trunc(u),f=l*g,b=Ig.compute.bind(this)(c,h,p),v=c===h?f:f*b,S=l-v-f*m;return S>=d?0===m?v:f:d-S<f?f-(d-S):0},isExported:!0},vp={description:a("Days in coupon period containing settlement date."),args:pp,returns:["NUMBER"],compute:function(e,t,o,s=0){s=s||0;const n=Math.trunc(Vo(e,this.locale)),i=Math.trunc(Vo(t,this.locale)),r=Math.trunc(Vo(o,this.locale)),a=Math.trunc(Vo(s,this.locale));if(Wg(n,i),Zg(r),Yg(a),1===a){const n=wp.compute.bind(this)(e,t,o,s);return Ep.compute.bind(this)(e,t,o,s)-n}return(3===a?365:360)/r},isExported:!0},Sp={description:a("Days from settlement until next coupon."),args:pp,returns:["NUMBER"],compute:function(e,t,o,s=0){s=s||0;const n=Math.trunc(Vo(e,this.locale)),i=Math.trunc(Vo(t,this.locale)),r=Math.trunc(Vo(o,this.locale)),a=Math.trunc(Vo(s,this.locale));Wg(n,i),Zg(r),Yg(a);const l=wp.compute.bind(this)(n,i,o,s);if([1,2,3].includes(a))return n-l;if(4===a){const e=io(l,n,a);return Math.round(360*e)}const c=Yo(n,this.locale),h=Yo(l,this.locale),d=h.getFullYear(),u=c.getFullYear(),g=h.getMonth()+1,p=c.getMonth()+1;let m=h.getDate(),f=c.getDate();return 2===g&&2===p&&oo(h)&&oo(c)&&(f=30),31!==f||30!==m&&31!==m||(f=30),2===g&&oo(h)&&(m=30),31===m&&(m=30),360*(u-d)+30*(p-g)+(f-m)},isExported:!0},Cp={description:a("Days from settlement until next coupon."),args:pp,returns:["NUMBER"],compute:function(e,t,o,s=0){s=s||0;const n=Math.trunc(Vo(e,this.locale)),i=Math.trunc(Vo(t,this.locale)),r=Math.trunc(Vo(o,this.locale)),a=Math.trunc(Vo(s,this.locale));Wg(n,i),Zg(r),Yg(a);const l=Ep.compute.bind(this)(n,i,o,s);if([1,2,3].includes(a))return l-n;if(4===a){const e=io(n,l,a);return Math.round(360*e)}const c=Sp.compute.bind(this)(e,t,o,a);return vp.compute.bind(this)(e,t,o,a)-c},isExported:!0},Ep={description:a("Next coupon date after the settlement date."),args:pp,returns:["NUMBER"],computeFormat:function(){return this.locale.dateFormat},compute:function(e,t,o,s=0){s=s||0;const n=Math.trunc(Vo(e,this.locale)),i=Math.trunc(Vo(t,this.locale)),r=Math.trunc(Vo(o,this.locale)),a=Math.trunc(Vo(s,this.locale));Wg(n,i),Zg(r),Yg(a);const l=12/r,c=yp.compute.bind(this)(e,t,o,s);return Jt(so(Yo(i,this.locale),-(c-1)*l,!0))},isExported:!0},yp={description:a("Number of coupons between settlement and maturity."),args:pp,returns:["NUMBER"],compute:function(e,t,o,s=0){s=s||0;const n=Math.trunc(Vo(e,this.locale)),i=Math.trunc(Vo(t,this.locale)),r=Math.trunc(Vo(o,this.locale)),a=Math.trunc(Vo(s,this.locale));Wg(n,i),Zg(r),Yg(a);let l=1,c=i;const h=12/r;for(;c>n;)c=Jt(so(Yo(c,this.locale),-h,!1)),l++;return l-1},isExported:!0},wp={description:a("Last coupon date prior to or on the settlement date."),args:pp,returns:["NUMBER"],computeFormat:function(){return this.locale.dateFormat},compute:function(e,t,o,s=0){s=s||0;const n=Math.trunc(Vo(e,this.locale)),i=Math.trunc(Vo(t,this.locale)),r=Math.trunc(Vo(o,this.locale)),a=Math.trunc(Vo(s,this.locale));Wg(n,i),Zg(r),Yg(a);const l=12/r,c=yp.compute.bind(this)(e,t,o,s);return Jt(so(Yo(i,this.locale),-c*l,!0))},isExported:!0},xp={description:a("Cumulative interest paid over a set of periods."),args:[_c("rate (number)",a("The interest rate.")),_c("number_of_periods (number)",a("The number of payments to be made.")),_c("present_value (number)",a("The current value of the annuity.")),_c("first_period (number)",a("The number of the payment period to begin the cumulative calculation.")),_c("last_period (number)",a("The number of the payment period to end the cumulative calculation.")),_c("end_or_beginning (number, default=0)",a("Whether payments are due at the end (0) or beginning (1) of each period."))],returns:["NUMBER"],compute:function(e,t,o,s,n,i=0){const r=Vo(s,this.locale),a=Vo(n,this.locale),l=Vo(e,this.locale),c=Vo(o,this.locale),h=Vo(t,this.locale);hp(r,a,h),Qg(l),sp(c);let d=0;for(let t=r;t<=a;t++){d+=Pp.compute.bind(this)(e,t,h,o,0,i)}return d},isExported:!0},Ip={description:a("Cumulative principal paid over a set of periods."),args:[_c("rate (number)",a("The interest rate.")),_c("number_of_periods (number)",a("The number of payments to be made.")),_c("present_value (number)",a("The current value of the annuity.")),_c("first_period (number)",a("The number of the payment period to begin the cumulative calculation.")),_c("last_period (number)",a("The number of the payment period to end the cumulative calculation.")),_c("end_or_beginning (number, default=0)",a("Whether payments are due at the end (0) or beginning (1) of each period."))],returns:["NUMBER"],compute:function(e,t,o,s,n,i=0){const r=Vo(s,this.locale),a=Vo(n,this.locale),l=Vo(e,this.locale),c=Vo(o,this.locale),h=Vo(t,this.locale);hp(r,a,h),Qg(l),sp(c);let d=0;for(let t=r;t<=a;t++){d+=qp.compute.bind(this)(e,t,h,o,0,i)}return d},isExported:!0},Rp={description:a("Depreciation via declining balance method."),args:[_c("cost (number)",a("The initial cost of the asset.")),_c("salvage (number)",a("The value of the asset at the end of depreciation.")),_c("life (number)",a("The number of periods over which the asset is depreciated.")),_c("period (number)",a("The single period within life for which to calculate depreciation.")),_c("month (number, optional)",a("The number of months in the first year of depreciation."))],returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,t,o,s,...n){const i=Vo(e,this.locale),r=Vo(t,this.locale),l=Vo(o,this.locale),c=Math.trunc(Vo(s,this.locale)),h=n.length?Math.trunc(Vo(n[0],this.locale)):12,d=l+(12===h?0:1);ep(i),op(r),tp(c),Jg(l),Lo((()=>1<=h&&h<=12),a("The month (%s) must be between 1 and 12 inclusive.",h.toString())),Lo((()=>c<=d),a("The period (%s) must be less than or equal to %s.",c.toString(),d.toString()));const u=h/12;let g=1-Math.pow(r/i,1/l);g=Math.round(1e3*g)/1e3;let p=i,m=i*(1-g*u);for(let e=1;e<c;e++)p=m,m=p*(1-g),e===l&&(m=p*(1-g*(1-u)));return p-m},isExported:!0},Tp={description:a("Depreciation via double-declining balance method."),args:[_c("cost (number)",a("The initial cost of the asset.")),_c("salvage (number)",a("The value of the asset at the end of depreciation.")),_c("life (number)",a("The number of periods over which the asset is depreciated.")),_c("period (number)",a("The single period within life for which to calculate depreciation.")),_c("factor (number, default=2)",a("The factor by which depreciation decreases."))],returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,t,o,s,n=2){n=n||0;const i=Vo(e,this.locale),r=Vo(t,this.locale),a=Vo(o,this.locale),l=Vo(s,this.locale),c=Vo(n,this.locale);if(ep(i),op(r),tp(l),Jg(a),np(l,a),lp(c),0===i||r>=i)return 0;const h=c/a;if(h>1)return 1===s?i-r:0;if(l<=1)return i*h;const d=i*Math.pow(1-h,l-1),u=i*Math.pow(1-h,l),g=u<r?d-r:d-u;return Math.max(g,0)},isExported:!0},Ap={description:a("Discount rate of a security based on price."),args:[_c("settlement (date)",a("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),_c("maturity (date)",a("The maturity or end date of the security, when it can be redeemed at face, or par value.")),_c("price (number)",a("The price at which the security is bought per 100 face value.")),_c("redemption (number)",a("The redemption amount per 100 face value, or par.")),_c("day_count_convention (number, default=0 )",a("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,o,s,n=0){n=n||0;const i=Math.trunc(Vo(e,this.locale)),r=Math.trunc(Vo(t,this.locale)),a=Vo(o,this.locale),l=Vo(s,this.locale),c=Math.trunc(Vo(n,this.locale));Wg(i,r),Yg(c),Xg(a),jg(l);return(l-a)/l/Ig.compute.bind(this)(i,r,c)},isExported:!0},Op={description:a("Convert a decimal fraction to decimal value."),args:[_c("fractional_price (number)",a("The price quotation given using fractional decimal conventions.")),_c("unit (number)",a("The units of the fraction, e.g. 8 for 1/8ths or 32 for 1/32nds."))],returns:["NUMBER"],compute:function(e,t){const o=Vo(e,this.locale),s=Math.trunc(Vo(t,this.locale));Lo((()=>s>0),a("The unit (%s) must be strictly positive.",s.toString()));const n=Math.trunc(o);return n+(o-n)*(10**Math.ceil(Math.log10(s))/s)},isExported:!0},_p={description:a("Convert a decimal value to decimal fraction."),args:[_c("decimal_price (number)",a("The price quotation given as a decimal value.")),_c("unit (number)",a("The units of the desired fraction, e.g. 8 for 1/8ths or 32 for 1/32nds."))],returns:["NUMBER"],compute:function(e,t){const o=Vo(e,this.locale),s=Math.trunc(Vo(t,this.locale));Lo((()=>s>0),a("The unit (%s) must be strictly positive.",s.toString()));const n=Math.trunc(o);return n+(o-n)*(s/10**Math.ceil(Math.log10(s)))},isExported:!0},Mp={description:a("Number of periods for an investment to reach a value."),args:[_c("settlement (date)",a("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),_c("maturity (date)",a("The maturity or end date of the security, when it can be redeemed at face, or par value.")),_c("rate (number)",a("The annualized rate of interest.")),_c("yield (number)",a("The expected annual yield of the security.")),_c("frequency (number)",a("The number of interest or coupon payments per year (1, 2, or 4).")),_c("day_count_convention (number, default=0 )",a("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,o,s,n,i=0){i=i||0;const r=Math.trunc(Vo(e,this.locale)),l=Math.trunc(Vo(t,this.locale)),c=Vo(o,this.locale),h=Vo(s,this.locale),d=Math.trunc(Vo(n,this.locale)),u=Math.trunc(Vo(i,this.locale));Wg(r,l),Zg(d),Yg(u),Lo((()=>c>=0),a("The rate (%s) must be positive or null.",c.toString())),Lo((()=>h>=0),a("The yield (%s) must be positive or null.",h.toString()));const g=Ig.compute.bind(this)(r,l,u),p=g-Math.trunc(g)||1/d,m=Math.ceil(g*d),f=c/d,b=h/d;let v=0,S=0;for(let e=1;e<=m;e++){const t=(f+(e===m?1:0))/(1+b)**e;S+=(p+(e-1)/d)*t,v+=t}return 0===v?0:S/v},isExported:!0},Np={description:a("Annual effective interest rate."),args:[_c("nominal_rate (number)",a("The nominal interest rate per year.")),_c("periods_per_year (number)",a("The number of compounding periods per year."))],returns:["NUMBER"],compute:function(e,t){const o=Vo(e,this.locale),s=Math.trunc(Vo(t,this.locale));return Lo((()=>o>0),a("The nominal rate (%s) must be strictly greater than 0.",o.toString())),Lo((()=>s>0),a("The number of periods by year (%s) must strictly greater than 0.",s.toString())),Math.pow(1+o/s,s)-1},isExported:!0},Fp={description:a("Future value of an annuity investment."),args:[_c("rate (number)",a("The interest rate.")),_c("number_of_periods (number)",a("The number of payments to be made.")),_c("payment_amount (number)",a("The amount per period to be paid.")),_c("present_value (number, default=0)",a("The current value of the annuity.")),_c("end_or_beginning (number, default=0)",a("Whether payments are due at the end (0) or beginning (1) of each period."))],returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,t,o,s=0,n=0){s=s||0,n=n||0;const i=Vo(e,this.locale),r=Vo(t,this.locale),a=Vo(o,this.locale),l=Vo(s,this.locale),c=Zo(n)?1:0;return i?-l*(1+i)**r-a*(1+i*c)*((1+i)**r-1)/i:-(l+a*r)},isExported:!0},Dp={description:a("Future value of principal from series of rates."),args:[_c("principal (number)",a("The amount of initial capital or value to compound against.")),_c("rate_schedule (number, range<number>)",a("A series of interest rates to compound against the principal."))],returns:["NUMBER"],compute:function(e,t){return Jo([t],((e,t)=>e*(1+Vo(t,this.locale))),Vo(e,this.locale))},isExported:!0},Lp={description:a("Calculates effective interest rate."),args:[_c("settlement (date)",a("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),_c("maturity (date)",a("The maturity or end date of the security, when it can be redeemed at face, or par value.")),_c("investment (number)",a("The amount invested in the security.")),_c("redemption (number)",a("The amount to be received at maturity.")),_c("day_count_convention (number, default=0 )",a("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,o,s,n=0){const i=Math.trunc(Vo(e,this.locale)),r=Math.trunc(Vo(t,this.locale)),a=Vo(s,this.locale),l=Vo(o,this.locale);Wg(i,r),ip(l),jg(a);return(a-l)/l/Ig.compute.bind(this)(i,r,n)},isExported:!0},Pp={description:a("Payment on the principal of an investment."),args:[_c("rate (number)",a("The annualized rate of interest.")),_c("period (number)",a("The amortization period, in terms of number of periods.")),_c("number_of_periods (number)",a("The number of payments to be made.")),_c("present_value (number)",a("The current value of the annuity.")),_c("future_value (number, default=0)",a("The future value remaining after the final payment has been made.")),_c("end_or_beginning (number, default=0)",a("Whether payments are due at the end (0) or beginning (1) of each period."))],returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,t,o,s,n=0,i=0){return Wp.compute.bind(this)(e,o,s,n,i)-qp.compute.bind(this)(e,t,o,s,n,i)},isExported:!0},Vp={description:a("Internal rate of return given periodic cashflows."),args:[_c("cashflow_amounts (number, range<number>)",a("An array or range containing the income or payments associated with the investment.")),_c("rate_guess (number, default=0.1)",a("An estimate for what the internal rate of return will be."))],returns:["NUMBER"],computeFormat:()=>"0%",compute:function(e,t=.1){const o=Vo(t,this.locale);dp(o);let s=!1,n=!1,i=[];Ko([e],(e=>{e>0&&(s=!0),e<0&&(n=!0),i.push(e)}),this.locale),Lo((()=>s&&n),a("The cashflow_amounts must include negative and positive values."));const r=i.shift();return mp((function(e){return function(e,t,o){const s=o.length;let n=0;return o.reduce(((t,o)=>(n++,t+o*e**(s-n))),t*e**s)}(e,r,i)}),(function(e){return function(e,t,o){const s=o.length;let n=0;return o.reduce(((t,o)=>(n++,t+o*(s-n)*e**(s-n-1))),t*s*e**(s-1))}(e,r,i)}),o+1,20,1e-5)-1},isExported:!0},kp={description:a("Returns the interest paid at a particular period of an investment."),args:[_c("rate (number)",a("The interest rate.")),_c("period (number)",a("The period for which you want to view the interest payment.")),_c("number_of_periods (number)",a("The number of payments to be made.")),_c("present_value (number)",a("The current value of the annuity."))],returns:["NUMBER"],compute:function(e,t,o,s){const n=Vo(e,this.locale),i=Vo(t,this.locale),r=Vo(o,this.locale),l=Vo(s,this.locale);Lo((()=>0!==r),a("The number of periods must be different than 0.",r.toString()));return-1*(l-l*(i/r))*n},isExported:!0},Up={description:a("Modified Macaulay duration."),args:[_c("settlement (date)",a("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),_c("maturity (date)",a("The maturity or end date of the security, when it can be redeemed at face, or par value.")),_c("rate (number)",a("The annualized rate of interest.")),_c("yield (number)",a("The expected annual yield of the security.")),_c("frequency (number)",a("The number of interest or coupon payments per year (1, 2, or 4).")),_c("day_count_convention (number, default=0 )",a("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,o,s,n,i=0){return Mp.compute.bind(this)(e,t,o,s,n,i)/(1+Vo(s,this.locale)/Math.trunc(Vo(n,this.locale)))},isExported:!0},Bp={description:a("Modified internal rate of return."),args:[_c("cashflow_amounts (range<number>)",a("A range containing the income or payments associated with the investment. The array should contain bot payments and incomes.")),_c("financing_rate (number)",a("The interest rate paid on funds invested.")),_c("reinvestment_return_rate (number)",a("The return (as a percentage) earned on reinvestment of income received from the investment."))],returns:["NUMBER"],compute:function(e,t,o){const s=Vo(t,this.locale),n=Vo(o,this.locale),i=ns(e).flat().filter((e=>null!==e)).map((e=>Vo(e,this.locale))),r=i.length;let l=0,c=0;for(const e of Ne(0,r)){const t=i[e];t>=0?l+=t*(n+1)**(r-e-1):c+=t/(s+1)**e}Lo((()=>0!==c&&0!==l),a("There must be both positive and negative values in cashflow_amounts."));return(-l/c)**(1/(r-1))-1},isExported:!0},Hp={description:a("Annual nominal interest rate."),args:[_c("effective_rate (number)",a("The effective interest rate per year.")),_c("periods_per_year (number)",a("The number of compounding periods per year."))],returns:["NUMBER"],compute:function(e,t){const o=Vo(e,this.locale),s=Math.trunc(Vo(t,this.locale));return Lo((()=>o>0),a("The effective rate (%s) must must strictly greater than 0.",o.toString())),Lo((()=>s>0),a("The number of periods by year (%s) must strictly greater than 0.",s.toString())),(Math.pow(o+1,1/s)-1)*s},isExported:!0},zp={description:a("Number of payment periods for an investment."),args:[_c("rate (number)",a("The interest rate.")),_c("payment_amount (number)",a("The amount of each payment made.")),_c("present_value (number)",a("The current value of the annuity.")),_c("future_value (number, default=0)",a("The future value remaining after the final payment has been made.")),_c("end_or_beginning (number, default=0)",a("Whether payments are due at the end (0) or beginning (1) of each period."))],returns:["NUMBER"],compute:function(e,t,o,s=0,n=0){s=s||0,n=n||0;const i=Vo(e,this.locale),r=Vo(t,this.locale),a=Vo(o,this.locale),l=Vo(s,this.locale),c=Zo(n)?1:0;if(0===i)return-(l+a)/r;const h=r*(1+i*c)/i;return Math.log((h-l)/(a+h))/Math.log(1+i)},isExported:!0};const Gp={description:a("The net present value of an investment based on a series of periodic cash flows and a discount rate."),args:[_c("discount (number)",a("The discount rate of the investment over one period.")),_c("cashflow1 (number, range<number>)",a("The first future cash flow.")),_c("cashflow2 (number, range<number>, repeating)",a("Additional future cash flows."))],returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,...t){const o=Vo(e,this.locale);return Lo((()=>-1!==o),a("The discount (%s) must be different from -1.",o.toString())),function(e,t,o,s){let n=0;return es(o,((t,o)=>(n++,t+o/(1+e)**n)),t,s)}(o,0,t,this.locale)},isExported:!0},$p={description:a("Computes the number of periods needed for an investment to reach a value."),args:[_c("rate (number)",a("The rate at which the investment grows each period.")),_c("present_value (number)",a("The investment's current value.")),_c("future_value (number)",a("The investment's desired future value."))],returns:["NUMBER"],compute:function(e,t,o){const s=Vo(e,this.locale),n=Vo(t,this.locale),i=Vo(o,this.locale);return Qg(s),Lo((()=>n>0),a("The present_value (%s) must be strictly positive.",n.toString())),Lo((()=>i>0),a("The future_value (%s) must be strictly positive.",i.toString())),(Math.log(i)-Math.log(n))/Math.log(1+s)},isExported:!0},Wp={description:a("Periodic payment for an annuity investment."),args:[_c("rate (number)",a("The annualized rate of interest.")),_c("number_of_periods (number)",a("The number of payments to be made.")),_c("present_value (number)",a("The current value of the annuity.")),_c("future_value (number, default=0)",a("The future value remaining after the final payment has been made.")),_c("end_or_beginning (number, default=0)",a("Whether payments are due at the end (0) or beginning (1) of each period."))],returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,t,o,s=0,n=0){s=s||0,n=n||0;const i=Vo(t,this.locale),r=Vo(e,this.locale),a=Zo(n)?1:0;let l=Vo(s,this.locale),c=Vo(o,this.locale);if(Kg(i),0===r)return-(l+c)/i;let h=-(c*(1+r)**i+l);return h=h*r/((1+r*a)*((1+r)**i-1)),h},isExported:!0},qp={description:a("Payment on the principal of an investment."),args:[_c("rate (number)",a("The annualized rate of interest.")),_c("period (number)",a("The amortization period, in terms of number of periods.")),_c("number_of_periods (number)",a("The number of payments to be made.")),_c("present_value (number)",a("The current value of the annuity.")),_c("future_value (number, default=0)",a("The future value remaining after the final payment has been made.")),_c("end_or_beginning (number, default=0)",a("Whether payments are due at the end (0) or beginning (1) of each period."))],returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,t,o,s,n=0,i=0){n=n||0,i=i||0;const r=Vo(o,this.locale),l=Vo(e,this.locale),c=Vo(t,this.locale),h=Zo(i)?1:0,d=Vo(n,this.locale),u=Vo(s,this.locale);Kg(r),Lo((()=>c>0&&c<=r),a("The period must be between 1 and number_of_periods",r.toString()));const g=Wp.compute.bind(this)(l,r,u,d,i);if(1===h&&1===c)return g;const p=0===h?c-1:c-2,m=u+g*h;return g+-Fp.compute.bind(this)(l,p,g,m,0)*l},isExported:!0},Zp={description:a("Present value of an annuity investment."),args:[_c("rate (number)",a("The interest rate.")),_c("number_of_periods (number)",a("The number of payments to be made.")),_c("payment_amount (number)",a("The amount per period to be paid.")),_c("future_value (number, default=0)",a("The future value remaining after the final payment has been made.")),_c("end_or_beginning (number, default=0)",a("Whether payments are due at the end (0) or beginning (1) of each period."))],returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,t,o,s=0,n=0){s=s||0,n=n||0;const i=Vo(e,this.locale),r=Vo(t,this.locale),a=Vo(o,this.locale),l=Vo(s,this.locale),c=Zo(n)?1:0;return i?-(a*(1+i*c)*((1+i)**r-1)/i+l)/(1+i)**r:-(l+a*r)},isExported:!0},Yp={description:a("Price of a security paying periodic interest."),args:[_c("settlement (date)",a("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),_c("maturity (date)",a("The maturity or end date of the security, when it can be redeemed at face, or par value.")),_c("rate (number)",a("The annualized rate of interest.")),_c("yield (number)",a("The expected annual yield of the security.")),_c("redemption (number)",a("The redemption amount per 100 face value, or par.")),_c("frequency (number)",a("The number of interest or coupon payments per year (1, 2, or 4).")),_c("day_count_convention (number, default=0 )",a("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,o,s,n,i,r=0){r=r||0;const l=Math.trunc(Vo(e,this.locale)),c=Math.trunc(Vo(t,this.locale)),h=Vo(o,this.locale),d=Vo(s,this.locale),u=Vo(n,this.locale),g=Math.trunc(Vo(i,this.locale)),p=Math.trunc(Vo(r,this.locale));Wg(l,c),Zg(g),Yg(p),Lo((()=>h>=0),a("The rate (%s) must be positive or null.",h.toString())),Lo((()=>d>=0),a("The yield (%s) must be positive or null.",d.toString())),jg(u);const m=Ig.compute.bind(this)(l,c,p)*g,f=Math.ceil(m),b=m-Math.floor(m)||1,v=1+d/g,S=100*h/g;if(1===f)return(S+u)/(b*d/g+1)-S*(1-b);let C=0;for(let e=1;e<=f;e++)C+=S/v**(e-1+b);return u/v**(f-1+b)+C-S*(1-b)},isExported:!0},jp={description:a("Price of a discount security."),args:[_c("settlement (date)",a("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),_c("maturity (date)",a("The maturity or end date of the security, when it can be redeemed at face, or par value.")),_c("discount (number)",a("The discount rate of the security at time of purchase.")),_c("redemption (number)",a("The redemption amount per 100 face value, or par.")),_c("day_count_convention (number, default=0 )",a("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,o,s,n=0){n=n||0;const i=Math.trunc(Vo(e,this.locale)),r=Math.trunc(Vo(t,this.locale)),a=Vo(o,this.locale),l=Vo(s,this.locale),c=Math.trunc(Vo(n,this.locale));Wg(i,r),Yg(c),rp(a),jg(l);return l-a*l*Ig.compute.bind(this)(i,r,c)},isExported:!0},Xp={description:a("Calculates the price of a security paying interest at maturity, based on expected yield."),args:[_c("settlement (date)",a("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),_c("maturity (date)",a("The maturity or end date of the security, when it can be redeemed at face, or par value.")),_c("issue (date)",a("The date the security was initially issued.")),_c("rate (number)",a("The annualized rate of interest.")),_c("yield (number)",a("The expected annual yield of the security.")),_c("day_count_convention (number, default=0 )",a("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,o,s,n,i=0){i=i||0;const r=Math.trunc(Vo(e,this.locale)),l=Math.trunc(Vo(t,this.locale)),c=Math.trunc(Vo(o,this.locale)),h=Vo(s,this.locale),d=Vo(n,this.locale),u=Math.trunc(Vo(i,this.locale));qg(r,c),Wg(r,l),Yg(u),Lo((()=>h>=0),a("The rate (%s) must be positive or null.",h.toString())),Lo((()=>d>=0),a("The yield (%s) must be positive or null.",d.toString()));const g=Ig.compute.bind(this)(r,l,u),p=Ig.compute.bind(this)(r,c,u);return(100+Ig.compute.bind(this)(c,l,u)*h*100)/(1+g*d)-p*h*100},isExported:!0},Kp=.1,Qp={description:a("Interest rate of an annuity investment."),args:[_c("number_of_periods (number)",a("The number of payments to be made.")),_c("payment_per_period (number)",a("The amount per period to be paid.")),_c("present_value (number)",a("The current value of the annuity.")),_c("future_value (number, default=0)",a("The future value remaining after the final payment has been made.")),_c("end_or_beginning (number, default=0)",a("Whether payments are due at the end (0) or beginning (1) of each period.")),_c("rate_guess (number, default=0.1)",a("An estimate for what the interest rate will be."))],returns:["NUMBER"],computeFormat:()=>"0%",compute:function(e,t,o,s=0,n=0,i=.1){s=s||0,n=n||0,i=i||Kp;const r=Vo(e,this.locale),l=Vo(t,this.locale),c=Zo(n)?1:0,h=Vo(i,this.locale);let d=Vo(s,this.locale),u=Vo(o,this.locale);Kg(r),Lo((()=>[l,u,d].some((e=>e>0))&&[l,u,d].some((e=>e<0))),a("There must be both positive and negative values in [payment_amount, present_value, future_value].",r.toString())),dp(h),d-=l*c,u+=l*c;return mp((e=>{const t=Math.pow(1+e,r);return d+u*t+l*((t-1)/e)}),(e=>{const t=Math.pow(1+e,r-1),o=Math.pow(1+e,r);return u*r*t+l*(r*t/e-(o-1)/e/e)}),h,40,1e-5)},isExported:!0},Jp={description:a("Amount received at maturity for a security."),args:[_c("settlement (date)",a("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),_c("maturity (date)",a("The maturity or end date of the security, when it can be redeemed at face, or par value.")),_c("investment (number)",a("The amount invested (irrespective of face value of each security).")),_c("discount (number)",a("The discount rate of the security invested in.")),_c("day_count_convention (number, default=0 )",a("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,o,s,n=0){n=n||0;const i=Math.trunc(Vo(e,this.locale)),r=Math.trunc(Vo(t,this.locale)),a=Vo(o,this.locale),l=Vo(s,this.locale),c=Math.trunc(Vo(n,this.locale));Wg(i,r),Yg(c),ip(a),rp(l);return a/(1-l*Ig.compute.bind(this)(i,r,c))},isExported:!0},em={description:a("Computes the rate needed for an investment to reach a specific value within a specific number of periods."),args:[_c("number_of_periods (number)",a("The number of periods.")),_c("present_value (number)",a("The present value of the investment.")),_c("future_value (number)",a("The future value of the investment."))],returns:["NUMBER"],compute:function(e,t,o){const s=Vo(e,this.locale),n=Vo(t,this.locale),i=Vo(o,this.locale);return Kg(s),(i/n)**(1/s)-1},isExported:!0},tm={description:a("Depreciation of an asset using the straight-line method."),args:[_c("cost (number)",a("The initial cost of the asset.")),_c("salvage (number)",a("The value of the asset at the end of depreciation.")),_c("life (number)",a("The number of periods over which the asset is depreciated."))],returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,t,o){return(Vo(e,this.locale)-Vo(t,this.locale))/Vo(o,this.locale)},isExported:!0},om={description:a("Depreciation via sum of years digit method."),args:[_c("cost (number)",a("The initial cost of the asset.")),_c("salvage (number)",a("The value of the asset at the end of depreciation.")),_c("life (number)",a("The number of periods over which the asset is depreciated.")),_c("period (number)",a("The single period within life for which to calculate depreciation."))],returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,t,o,s){const n=Vo(e,this.locale),i=Vo(t,this.locale),r=Vo(o,this.locale),a=Vo(s,this.locale);tp(a),Jg(r),np(a,r);return(r-a+1)/(r*(r+1)/2)*(n-i)},isExported:!0},sm={description:a("Price of a US Treasury bill."),args:[_c("settlement (date)",a("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),_c("maturity (date)",a("The maturity or end date of the security, when it can be redeemed at face, or par value.")),_c("discount (number)",a("The discount rate of the bill at time of purchase."))],returns:["NUMBER"],compute:function(e,t,o){const s=Math.trunc(Vo(e,this.locale)),n=Math.trunc(Vo(t,this.locale)),i=Vo(o,this.locale);Wg(s,n),cp(s,n,this.locale),rp(i),ap(i);return 100*(1-i*Ig.compute.bind(this)(s,n,2))},isExported:!0},nm={description:a("Equivalent rate of return for a US Treasury bill."),args:[_c("settlement (date)",a("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),_c("maturity (date)",a("The maturity or end date of the security, when it can be redeemed at face, or par value.")),_c("discount (number)",a("The discount rate of the bill at time of purchase."))],returns:["NUMBER"],compute:function(e,t,o){const s=Math.trunc(Vo(e,this.locale)),n=Math.trunc(Vo(t,this.locale)),i=Vo(o,this.locale);Wg(s,n),cp(s,n,this.locale),rp(i),ap(i);const r=ng.compute.bind(this)(n,s);if(r<=182)return 365*i/(360-i*r);const a=sm.compute.bind(this)(s,n,i)/100,l=r/(366===r?366:365);return(-2*l+2*Math.sqrt(l**2-(2*l-1)*(1-1/a)))/(2*l-1)},isExported:!0},im={description:a("The yield of a US Treasury bill based on price."),args:[_c("settlement (date)",a("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),_c("maturity (date)",a("The maturity or end date of the security, when it can be redeemed at face, or par value.")),_c("price (number)",a("The price at which the security is bought per 100 face value."))],returns:["NUMBER"],compute:function(e,t,o){const s=Math.trunc(Vo(e,this.locale)),n=Math.trunc(Vo(t,this.locale)),i=Vo(o,this.locale);Wg(s,n),cp(s,n,this.locale),Xg(i);return(100-i)/i*(1/Ig.compute.bind(this)(s,n,2))},isExported:!0},rm={description:a("Variable declining balance. WARNING : does not handle decimal periods."),args:[_c("cost (number)",a("The initial cost of the asset.")),_c("salvage (number)",a("The value of the asset at the end of depreciation.")),_c("life (number)",a("The number of periods over which the asset is depreciated.")),_c("start (number)",a("Starting period to calculate depreciation.")),_c("end (number)",a("Ending period to calculate depreciation.")),_c("factor (number, default=2)",a("The number of months in the first year of depreciation.")),_c("no_switch (number, default=false)",a("Whether to switch to straight-line depreciation when the depreciation is greater than the declining balance calculation."))],returns:["NUMBER"],compute:function(e,t,o,s,n,i=2,r=false){i=i||0;const l=Vo(e,this.locale),c=Vo(t,this.locale),h=Vo(o,this.locale),d=Math.trunc(Vo(s,this.locale)),u=Math.trunc(Vo(n,this.locale)),g=Vo(i,this.locale),p=Zo(r);if(ep(l),op(c),function(e,t,o){Jg(o),Lo((()=>e>=0),a("The start_period (%s) must be greater or equal than 0.",e.toString())),Lo((()=>t>=0),a("The end_period (%s) must be greater or equal than 0.",t.toString())),Lo((()=>e<=t),a("The start_period (%s) must be smaller or equal to the end_period (%s).",e.toString(),t.toString())),Lo((()=>t<=o),a("The end_period (%s) must be smaller or equal to the life (%s).",e.toString(),o.toString()))}(d,u,h),lp(g),0===l)return 0;if(c>=l)return d<1?l-c:0;const m=g/h;if(m>=1)return d<1?l-c:0;let f=l,b=0,v=0,S=!1;for(let e=0;e<u;e++){if(!S||p){const t=f*m,o=(f-c)/(h-e);!p&&o>t?(S=!0,b=o):b=t}const t=Math.max(f-b,c);e>=d&&(v+=f-t),f=t}return v},isExported:!0},am={description:a("Internal rate of return given non-periodic cash flows."),args:[_c("cashflow_amounts (range<number>)",a("An range containing the income or payments associated with the investment.")),_c("cashflow_dates (range<number>)",a("An range with dates corresponding to the cash flows in cashflow_amounts.")),_c("rate_guess (number, default=0.1)",a("An estimate for what the internal rate of return will be."))],returns:["NUMBER"],compute:function(e,t,o=.1){const s=Vo(o=o||0,this.locale),n=e.flat().map((e=>Vo(e,this.locale))),i=t.flat().map((e=>Vo(e,this.locale)));var r;up(e,t),r=n,Lo((()=>r.some((e=>e>0))&&r.some((e=>e<0))),a("There must be both positive and negative values in cashflow_amounts.")),gp(i),dp(s);const l=new Map;for(const e of Ne(0,i.length)){const t=i[e];l.has(t)?l.set(t,l.get(t)+n[e]):l.set(t,n[e])}const c=Array.from(l.keys()),h=c.map((e=>l.get(e)));return mp((e=>{let t=h[0];for(const o of Ne(1,h.length)){const s=(c[0]-c[o])/365;t+=h[o]*(1+e)**s}return t}),(e=>{let t=0;for(const o of Ne(1,h.length)){const s=(c[0]-c[o])/365;t+=s*h[o]*(1+e)**(s-1)}return t}),s,40,1e-5,(e=>e?e/10-.9:-.9))},isExported:!0},lm={description:a("Net present value given to non-periodic cash flows.."),args:[_c("discount (number)",a("The discount rate of the investment over one period.")),_c("cashflow_amounts (number, range<number>)",a("An range containing the income or payments associated with the investment.")),_c("cashflow_dates (number, range<number>)",a("An range with dates corresponding to the cash flows in cashflow_amounts."))],returns:["NUMBER"],compute:function(e,t,o){const s=Vo(e,this.locale),n=Mo(t)?t.flat().map((e=>Bo(e,this.locale))):[Bo(t,this.locale)],i=Mo(o)?o.flat().map((e=>Bo(e,this.locale))):[Bo(o,this.locale)];if(Mo(o)&&Mo(t)?up(t,o):Lo((()=>n.length===i.length),a("There must be the same number of values in cashflow_amounts and cashflow_dates.")),gp(i),Qg(s),1===n.length)return n[0];const r=new Map;for(const e of Ne(0,i.length)){const t=i[e];r.has(t)?r.set(t,r.get(t)+n[e]):r.set(t,n[e])}const l=Array.from(r.keys()),c=l.map((e=>r.get(e)));let h=c[0];for(const e of Ne(1,c.length)){const t=(l[0]-l[e])/365;h+=c[e]*(1+s)**t}return h},isExported:!0},cm={description:a("Annual yield of a security paying periodic interest."),args:[_c("settlement (date)",a("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),_c("maturity (date)",a("The maturity or end date of the security, when it can be redeemed at face, or par value.")),_c("rate (number)",a("The annualized rate of interest.")),_c("price (number)",a("The price at which the security is bought per 100 face value.")),_c("redemption (number)",a("The redemption amount per 100 face value, or par.")),_c("frequency (number)",a("The number of interest or coupon payments per year (1, 2, or 4).")),_c("day_count_convention (number, default=0 )",a("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,o,s,n,i,r=0){r=r||0;const l=Math.trunc(Vo(e,this.locale)),c=Math.trunc(Vo(t,this.locale)),h=Vo(o,this.locale),d=Vo(s,this.locale),u=Vo(n,this.locale),g=Math.trunc(Vo(i,this.locale)),p=Math.trunc(Vo(r,this.locale));Wg(l,c),Zg(g),Yg(p),Lo((()=>h>=0),a("The rate (%s) must be positive or null.",h.toString())),Xg(d),jg(u);const m=Ig.compute.bind(this)(l,c,p)*g,f=Math.ceil(m),b=m-Math.floor(m)||1,v=100*h/g;if(1===f){const e=d+v*(1-b);return(u+v-e)*g*(1/b)/e}const S=mp((function(e){return function(e,t,o,s,n,i){let r=i-(e+n*(1-t))*s**(o-1+t);for(let e=1;e<=o;e++)r+=n*s**(e-1);return r}(d,b,f,e,v,u)}),(function(e){return function(e,t,o,s,n){let i=-(e+n*(1-t))*(o-1+t)*s**(o-2+t);for(let e=1;e<=o;e++)i+=n*(e-1)*s**(e-2);return i}(d,b,f,e,v)}),1+(h+1)/g,100,1e-5);return(S-1)*g},isExported:!0},hm={description:a("Annual yield of a discount security."),args:[_c("settlement (date)",a("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),_c("maturity (date)",a("The maturity or end date of the security, when it can be redeemed at face, or par value.")),_c("price (number)",a("The price at which the security is bought per 100 face value.")),_c("redemption (number)",a("The redemption amount per 100 face value, or par.")),_c("day_count_convention (number, default=0 )",a("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,o,s,n=0){n=n||0;const i=Math.trunc(Vo(e,this.locale)),r=Math.trunc(Vo(t,this.locale)),a=Vo(o,this.locale),l=Vo(s,this.locale),c=Math.trunc(Vo(n,this.locale));Wg(i,r),Yg(c),Xg(a),jg(l);return(l/a-1)/Ig.compute.bind(this)(e,t,n)},isExported:!0},dm={description:a("Annual yield of a security paying interest at maturity."),args:[_c("settlement (date)",a("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),_c("maturity (date)",a("The maturity or end date of the security, when it can be redeemed at face, or par value.")),_c("issue (date)",a("The date the security was initially issued.")),_c("rate (number)",a("The annualized rate of interest.")),_c("price (number)",a("The price at which the security is bought.")),_c("day_count_convention (number, default=0 )",a("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,o,s,n,i=0){i=i||0;const r=Math.trunc(Vo(e,this.locale)),l=Math.trunc(Vo(t,this.locale)),c=Math.trunc(Vo(o,this.locale)),h=Vo(s,this.locale),d=Vo(n,this.locale),u=Math.trunc(Vo(i,this.locale));Wg(r,l),Yg(u),Lo((()=>r>=c),a("The settlement (%s) must be greater than or equal to the issue (%s).",r.toString(),c.toString())),Lo((()=>h>=0),a("The rate (%s) must be positive or null.",h.toString())),Xg(d);const g=Ig.compute.bind(this)(c,l,u),p=Ig.compute.bind(this)(c,r,u),m=Ig.compute.bind(this)(r,l,u);return(100*(1+h*g)/(d+100*h*p)-1)/m},isExported:!0};var um=Object.freeze({__proto__:null,ACCRINTM:fp,AMORLINC:bp,COUPDAYBS:Sp,COUPDAYS:vp,COUPDAYSNC:Cp,COUPNCD:Ep,COUPNUM:yp,COUPPCD:wp,CUMIPMT:xp,CUMPRINC:Ip,DB:Rp,DDB:Tp,DISC:Ap,DOLLARDE:Op,DOLLARFR:_p,DURATION:Mp,EFFECT:Np,FV:Fp,FVSCHEDULE:Dp,INTRATE:Lp,IPMT:Pp,IRR:Vp,ISPMT:kp,MDURATION:Up,MIRR:Bp,NOMINAL:Hp,NPER:zp,NPV:Gp,PDURATION:$p,PMT:Wp,PPMT:qp,PRICE:Yp,PRICEDISC:jp,PRICEMAT:Xp,PV:Zp,RATE:Qp,RECEIVED:Jp,RRI:em,SLN:tm,SYD:om,TBILLEQ:nm,TBILLPRICE:sm,TBILLYIELD:im,VDB:rm,XIRR:am,XNPV:lm,YIELD:cm,YIELDDISC:hm,YIELDMAT:dm});const gm={description:a("Whether a value is an error other than #N/A."),args:[_c("value (any, lazy)",a("The value to be verified as an error type."))],returns:["BOOLEAN"],compute:function(e){try{return e(),!1}catch(e){return e?.errorType!=c.NotAvailable}},isExported:!0},pm={description:a("Whether a value is an error."),args:[_c("value (any, lazy)",a("The value to be verified as an error type."))],returns:["BOOLEAN"],compute:function(e){try{return e(),!1}catch(e){return!0}},isExported:!0},mm={description:a("Whether a value is `true` or `false`."),args:[_c("value (any, lazy)",a("The value to be verified as a logical TRUE or FALSE."))],returns:["BOOLEAN"],compute:function(e){try{return"boolean"==typeof e()}catch(e){return!1}},isExported:!0},fm={description:a("Whether a value is the error #N/A."),args:[_c("value (any, lazy)",a("The value to be verified as an error type."))],returns:["BOOLEAN"],compute:function(e){try{return e(),!1}catch(e){return e?.errorType===c.NotAvailable}},isExported:!0},bm={description:a("Whether a value is non-textual."),args:[_c("value (any, lazy)",a("The value to be checked."))],returns:["BOOLEAN"],compute:function(e){try{return"string"!=typeof e()}catch(e){return!0}},isExported:!0},vm={description:a("Whether a value is a number."),args:[_c("value (any, lazy)",a("The value to be verified as a number."))],returns:["BOOLEAN"],compute:function(e){try{return"number"==typeof e()}catch(e){return!1}},isExported:!0},Sm={description:a("Whether a value is text."),args:[_c("value (any, lazy)",a("The value to be verified as text."))],returns:["BOOLEAN"],compute:function(e){try{return"string"==typeof e()}catch(e){return!1}},isExported:!0},Cm={description:a("Whether the referenced cell is empty"),args:[_c("value (any, lazy)",a("Reference to the cell that will be checked for emptiness."))],returns:["BOOLEAN"],compute:function(e){try{return null===e()}catch(e){return!1}},isExported:!0},Em={description:a("Returns the error value #N/A."),args:[],returns:["BOOLEAN"],compute:function(e){throw new m},isExported:!0};var ym=Object.freeze({__proto__:null,ISBLANK:Cm,ISERR:gm,ISERROR:pm,ISLOGICAL:mm,ISNA:fm,ISNONTEXT:bm,ISNUMBER:vm,ISTEXT:Sm,NA:Em});const wm={description:a("Logical `and` operator."),args:[_c("logical_expression1 (boolean, range<boolean>)",a("An expression or reference to a cell containing an expression that represents some logical value, i.e. TRUE or FALSE, or an expression that can be coerced to a logical value.")),_c("logical_expression2 (boolean, range<boolean>, repeating)",a("More expressions that represent logical values."))],returns:["BOOLEAN"],compute:function(...e){let t=!1,o=!0;return is(e,(e=>(t=!0,o=o&&e,o))),Lo((()=>t),a("[[FUNCTION_NAME]] has no valid input data.")),o},isExported:!0},xm={description:a("Logical value `false`."),args:[],returns:["BOOLEAN"],compute:function(){return!1},isExported:!0},Im={description:a("Returns value depending on logical expression."),args:[_c("logical_expression (boolean)",a("An expression or reference to a cell containing an expression that represents some logical value, i.e. TRUE or FALSE.")),_c("value_if_true (any, lazy)",a("The value the function returns if logical_expression is TRUE.")),_c("value_if_false (any, lazy, default=FALSE)",a("The value the function returns if logical_expression is FALSE."))],returns:["ANY"],computeValueAndFormat:function(e,t,o=(()=>({value:!1}))){const s=Zo(e?.value)?t():o();return void 0===s?{value:""}:(null===s.value&&(s.value=""),s)},isExported:!0},Rm={description:a("Value if it is not an error, otherwise 2nd argument."),args:[_c("value (any, lazy)",a("The value to return if value itself is not an error.")),_c('value_if_error (any, lazy, default="empty")',a("The value the function returns if value is an error."))],returns:["ANY"],computeValueAndFormat:function(e,t=(()=>({value:""}))){let o;try{o=e()}catch(e){o=t()}return void 0===o?{value:""}:(null===o.value&&(o.value=""),o)},isExported:!0},Tm={description:a("Value if it is not an #N/A error, otherwise 2nd argument."),args:[_c("value (any, lazy)",a("The value to return if value itself is not #N/A an error.")),_c('value_if_error (any, lazy, default="empty")',a("The value the function returns if value is an #N/A error."))],returns:["ANY"],computeValueAndFormat:function(e,t=(()=>({value:""}))){let o;try{o=e()}catch(s){o=s.errorType===c.NotAvailable?t():e()}return void 0===o?{value:""}:(null===o.value&&(o.value=""),o)},isExported:!0},Am={description:a("Returns a value depending on multiple logical expressions."),args:[_c("condition1 (boolean, lazy)",a("The first condition to be evaluated. This can be a boolean, a number, an array, or a reference to any of those.")),_c("value1 (any, lazy)",a("The returned value if condition1 is TRUE.")),_c("condition2 (boolean, lazy, repeating)",a("Additional conditions to be evaluated if the previous ones are FALSE.")),_c("value2 (any, lazy, repeating)",a("Additional values to be returned if their corresponding conditions are TRUE."))],returns:["ANY"],computeValueAndFormat:function(...e){Lo((()=>e.length%2==0),a("Wrong number of arguments. Expected an even number of arguments."));for(let t=0;t<e.length-1;t+=2)if(Zo(e[t]()?.value)){const o=e[t+1]();return void 0===o?{value:""}:(null===o.value&&(o.value=""),o)}throw new Error(a("No match."))},isExported:!0},Om={description:a("Returns opposite of provided logical value."),args:[_c("logical_expression (boolean)",a("An expression or reference to a cell holding an expression that represents some logical value."))],returns:["BOOLEAN"],compute:function(e){return!Zo(e)},isExported:!0},_m={description:a("Logical `or` operator."),args:[_c("logical_expression1 (boolean, range<boolean>)",a("An expression or reference to a cell containing an expression that represents some logical value, i.e. TRUE or FALSE, or an expression that can be coerced to a logical value.")),_c("logical_expression2 (boolean, range<boolean>, repeating)",a("More expressions that evaluate to logical values."))],returns:["BOOLEAN"],compute:function(...e){let t=!1,o=!1;return is(e,(e=>(t=!0,o=o||e,!o))),Lo((()=>t),a("[[FUNCTION_NAME]] has no valid input data.")),o},isExported:!0},Mm={description:a("Logical value `true`."),args:[],returns:["BOOLEAN"],compute:function(){return!0},isExported:!0},Nm={description:a("Logical `xor` operator."),args:[_c("logical_expression1 (boolean, range<boolean>)",a("An expression or reference to a cell containing an expression that represents some logical value, i.e. TRUE or FALSE, or an expression that can be coerced to a logical value.")),_c("logical_expression2 (boolean, range<boolean>, repeating)",a("More expressions that evaluate to logical values."))],returns:["BOOLEAN"],compute:function(...e){let t=!1,o=!1;return is(e,(e=>(t=!0,o=o?!e:e,!0))),Lo((()=>t),a("[[FUNCTION_NAME]] has no valid input data.")),o},isExported:!0};var Fm=Object.freeze({__proto__:null,AND:wm,FALSE:xm,IF:Im,IFERROR:Rm,IFNA:Tm,IFS:Am,NOT:Om,OR:_m,TRUE:Mm,XOR:Nm});const Dm=!0;function Lm(e,t){if(void 0===e)throw new m(a("Did not find value '%s' in [[FUNCTION_NAME]] evaluation.",$o(t)))}const Pm={description:a("Returns a cell reference as a string. "),args:[_c("row (number)",a("The row number of the cell reference. ")),_c("column (number)",a("The column number (not name) of the cell reference. A is column number 1. ")),_c("absolute_relative_mode (number, default=1)",a("An indicator of whether the reference is row/column absolute. 1 is row and column absolute (e.g. $A$1), 2 is row absolute and column relative (e.g. A$1), 3 is row relative and column absolute (e.g. $A1), and 4 is row and column relative (e.g. A1).")),_c("use_a1_notation (boolean, default=TRUE)",a("A boolean indicating whether to use A1 style notation (TRUE) or R1C1 style notation (FALSE).")),_c("sheet (string, optional)",a("A string indicating the name of the sheet into which the address points."))],returns:["STRING"],compute:function(e,t,o=1,s=!0,n){const i=zo(e,this.locale),r=zo(t,this.locale);Go(i),Go(r);const l=zo(o,this.locale);var c,h;Lo((()=>[1,2,3,4].includes(l)),(c=4,h=l,a("The function [[FUNCTION_NAME]] expects a number value between %s and %s inclusive, but receives %s.",1..toString(),c.toString(),h.toString())));let d;if(Zo(s)){d=Lt(r-1,i-1,{rowFixed:!![1,2].includes(l),colFixed:!![1,3].includes(l)})}else{d=([1,2].includes(l)?`R${i}`:`R[${i}]`)+([1,3].includes(l)?`C${r}`:`C[${r}]`)}return void 0!==n?`${_e($o(n))}!${d}`:d},isExported:!0},Vm={description:a("Column number of a specified cell."),args:[_c("cell_reference (meta, default='this cell')",a("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."))],returns:["NUMBER"],compute:function(e){const t=e||this.__originCellXC?.();Lo((()=>!!t),"In this context, the function [[FUNCTION_NAME]] needs to have a cell or range in parameter.");return gn(t).left+1},isExported:!0},km={description:a("Number of columns in a specified array or range."),args:[_c("range (meta)",a("The range whose column count will be returned."))],returns:["NUMBER"],compute:function(e){const t=gn(e);return t.right-t.left+1},isExported:!0},Um={description:a("Horizontal lookup"),args:[_c("search_key (any)",a("The value to search for. For example, 42, 'Cats', or I24.")),_c("range (any, range)",a("The range to consider for the search. The first row in the range is searched for the key specified in search_key.")),_c("index (number)",a("The row index of the value to be returned, where the first row in range is numbered 1.")),_c("is_sorted (boolean, default=true)",a("Indicates whether the row to be searched (the first row of the specified range) is sorted, in which case the closest match for search_key will be returned."))],returns:["ANY"],computeValueAndFormat:function(e,t,o,s={value:Dm}){const n=Math.trunc(Vo(o?.value,this.locale)),i=gs(t);Lo((()=>1<=n&&n<=i[0].length),a("[[FUNCTION_NAME]] evaluates to an out of bounds range."));const r=(e,t)=>e[t][0].value,l=Zo(s.value)?cs(i,e?.value,"nextSmaller","asc",i.length,r):hs(i,e?.value,"strict",i.length,r),c=i[l];return Lm(c,e?.value),c[n-1]},isExported:!0},Bm={description:a("Returns the content of a cell, specified by row and column offset."),args:[_c("reference (any, range)",a("The range of cells from which the values are returned.")),_c("row (number, default=0)",a("The index of the row to be returned from within the reference range of cells.")),_c("column (number, default=0)",a("The index of the column to be returned from within the reference range of cells."))],returns:["ANY"],computeValueAndFormat:function(e,t={value:0},o={value:0}){const s=Mo(e)?e:[[e]],n=Vo(t.value,this.locale),i=Vo(o.value,this.locale);return Lo((()=>i>=0&&i-1<s.length&&n>=0&&n-1<s[0].length),a("Index out of range.")),0===n&&0===i?s:0===n?[s[i-1]]:0===i?s.map((e=>[e[n-1]])):s[i-1][n-1]},isExported:!0},Hm={description:a("Look up a value."),args:[_c("search_key (any)",a("The value to search for. For example, 42, 'Cats', or I24.")),_c("search_array (any, range)",a("One method of using this function is to provide a single sorted row or column search_array to look through for the search_key with a second argument result_range. The other way is to combine these two arguments into one search_array where the first row or column is searched and a value is returned from the last row or column in the array. If search_key is not found, a non-exact match may be returned.")),_c("result_range (any, range, optional)",a("The range from which to return a result. The value returned corresponds to the location where search_key is found in search_range. This range must be only a single row or column and should not be used if using the search_result_array method."))],returns:["ANY"],computeValueAndFormat:function(e,t,o){const s=gs(t),n=gs(o);let i=s.length,r=s[0].length;const l=r>=i,c=l?(e,t)=>e[0][t].value:(e,t)=>e[t][0].value,h=l?r:i,d=cs(s,e?.value,"nextSmaller","asc",h,c);return-1===d&&Lm(void 0,e?.value),Lm(l?s[0][d]:s[d][r-1],e?.value),0===n[0].length?l?s[i-1][d]:s[d][r-1]:(i=n.length,r=n[0].length,Lo((()=>1===i||1===r),a("The result_range must be a single row or a single column.")),i>1?(Lo((()=>d<=i-1),a("[[FUNCTION_NAME]] evaluates to an out of range row value %s.",(d+1).toString())),n[d][0]):(Lo((()=>d<=r-1),a("[[FUNCTION_NAME]] evaluates to an out of range column value %s.",(d+1).toString())),n[0][d]))},isExported:!0},zm={description:a("Position of item in range that matches value."),args:[_c("search_key (any)",a("The value to search for. For example, 42, 'Cats', or I24.")),_c("range (any, range)",a("The one-dimensional array to be searched.")),_c("search_type (number, default=1)",a("The search method. 1 (default) finds the largest value less than or equal to search_key when range is sorted in ascending order. 0 finds the exact value when range is unsorted. -1 finds the smallest value greater than or equal to search_key when range is sorted in descending order."))],returns:["NUMBER"],compute:function(e,t,o=1){let s=Vo(o,this.locale);const n=gs(t),i=n.length,r=n[0].length;Lo((()=>1===i||1===r),a("The range must be a single row or a single column."));let l=-1;const c=1===i?(e,t)=>e[0][t]:(e,t)=>e[t][0],h=1===i?n[0].length:n.length;switch(s=Math.sign(s),s){case 1:l=cs(n,e,"nextSmaller","asc",h,c);break;case 0:l=hs(n,e,"strict",h,c);break;case-1:l=cs(n,e,"nextGreater","desc",h,c)}return Lm(1===i?n[0][l]:n[l],e),l+1},isExported:!0},Gm={description:a("Row number of a specified cell."),args:[_c("cell_reference (meta, default='this cell')",a("The cell whose row number will be returned. By default, this function uses the cell in which the formula is entered."))],returns:["NUMBER"],compute:function(e){e=e||this.__originCellXC?.(),Lo((()=>!!e),"In this context, the function [[FUNCTION_NAME]] needs to have a cell or range in parameter.");return gn(e).top+1},isExported:!0},$m={description:a("Number of rows in a specified array or range."),args:[_c("range (meta)",a("The range whose row count will be returned."))],returns:["NUMBER"],compute:function(e){const t=gn(e);return t.bottom-t.top+1},isExported:!0},Wm={description:a("Vertical lookup."),args:[_c("search_key (any)",a("The value to search for. For example, 42, 'Cats', or I24.")),_c("range (any, range)",a("The range to consider for the search. The first column in the range is searched for the key specified in search_key.")),_c("index (number)",a("The column index of the value to be returned, where the first column in range is numbered 1.")),_c("is_sorted (boolean, default=true)",a("Indicates whether the column to be searched (the first column of the specified range) is sorted, in which case the closest match for search_key will be returned."))],returns:["ANY"],computeValueAndFormat:function(e,t,o,s={value:Dm}){const n=Math.trunc(Vo(o?.value,this.locale)),i=gs(t);Lo((()=>1<=n&&n<=i.length),a("[[FUNCTION_NAME]] evaluates to an out of bounds range."));const r=(e,t)=>e[0][t].value,l=Zo(s.value)?cs(i,e?.value,"nextSmaller","asc",i[0].length,r):hs(i,e?.value,"strict",i[0].length,r),c=i[n-1][l];return Lm(c,e?.value),c},isExported:!0},qm={description:a("Search a range for a match and return the corresponding item from a second range."),args:[_c("search_key (any)",a("The value to search for.")),_c("lookup_range (any, range)",a("The range to consider for the search. Should be a single column or a single row.")),_c("return_range (any, range)",a("The range containing the return value. Should have the same dimensions as lookup_range.")),_c("if_not_found (any, lazy, optional)",a("If a valid match is not found, return this value.")),_c("match_mode (any, default=0)",a("(0) Exact match. (-1) Return next smaller item if no match. (1) Return next greater item if no match.")),_c("search_mode (any, default=1)",a("(1) Search starting at first item. (-1) Search starting at last item. (2) Perform a binary search that relies on lookup_array being sorted in ascending order. If not sorted, invalid results will be returned. (-2) Perform a binary search that relies on lookup_array being sorted in descending order. If not sorted, invalid results will be returned. "))],returns:["ANY"],computeValueAndFormat:function(e,t,o,s,n={value:0},i={value:1}){const r=Math.trunc(Vo(n.value,this.locale)),l=Math.trunc(Vo(i.value,this.locale)),c=gs(t),h=gs(o);Lo((()=>1===c.length||1===c[0].length),a("lookup_range should be either a single row or single column.")),Lo((()=>[-1,1,-2,2].includes(l)),a("searchMode should be a value in [-1, 1, -2, 2].")),Lo((()=>[-1,0,1].includes(r)),a("matchMode should be a value in [-1, 0, 1]."));const d=1===c.length?"col":"row";Lo((()=>"col"===d?h[0].length===c[0].length:h.length===c.length),a("return_range should have the same dimensions as lookup_range."));const u="col"===d?(e,t)=>e[0][t].value:(e,t)=>e[t][0].value,g="col"===d?c[0].length:c.length,p=0===r?"strict":1===r?"nextGreater":"nextSmaller",m=-1===l,f=2===l||-2===l?cs(c,e?.value,p,2===l?"asc":"desc",g,u):hs(c,e?.value,p,g,u,m);if(-1!==f)return"col"===d?h.map((e=>[e[f]])):[h[f]];const b=s?.();return Lm(b,e?.value),[[b]]},isExported:!0};var Zm=Object.freeze({__proto__:null,ADDRESS:Pm,COLUMN:Vm,COLUMNS:km,HLOOKUP:Um,INDEX:Bm,LOOKUP:Hm,MATCH:zm,ROW:Gm,ROWS:$m,VLOOKUP:Wm,XLOOKUP:qm});const Ym={description:a("Sum of two numbers."),args:[_c("value1 (number)",a("The first addend.")),_c("value2 (number)",a("The second addend."))],returns:["NUMBER"],computeFormat:(e,t)=>e?.format||t?.format,compute:function(e,t){return Vo(e,this.locale)+Vo(t,this.locale)}},jm={description:a("Concatenation of two values."),args:[_c("value1 (string)",a("The value to which value2 will be appended.")),_c("value2 (string)",a("The value to append to value1."))],returns:["STRING"],compute:function(e,t){return $o(e)+$o(t)},isExported:!0},Xm={description:a("One number divided by another."),args:[_c("dividend (number)",a("The number to be divided.")),_c("divisor (number)",a("The number to divide by."))],returns:["NUMBER"],computeFormat:(e,t)=>e?.format||t?.format,compute:function(e,t){const o=Vo(t,this.locale);return Lo((()=>0!==o),a("The divisor must be different from zero.")),Vo(e,this.locale)/o}};function Km(e){return null==e}const Qm={number:0,string:"",boolean:!1};function Jm(e,t,o=2e-16){return Math.abs(e-t)<o}const ef={description:a("Equal."),args:[_c("value1 (any)",a("The first value.")),_c("value2 (any)",a("The value to test against value1 for equality."))],returns:["BOOLEAN"],compute:function(e,t){return e=Km(e)?Qm[typeof t]:e,t=Km(t)?Qm[typeof e]:t,"string"==typeof e&&(e=e.toUpperCase()),"string"==typeof t&&(t=t.toUpperCase()),"number"==typeof e&&"number"==typeof t?Jm(e,t):e===t}};function tf(e,t,o){e=Km(e)?Qm[typeof t]:e,t=Km(t)?Qm[typeof e]:t,"number"!=typeof e&&(e=$o(e).toUpperCase()),"number"!=typeof t&&(t=$o(t).toUpperCase());const s=typeof e,n=typeof t;return"string"===s&&"number"===n||("string"!==n||"number"!==s)&&o(e,t)}const of={description:a("Strictly greater than."),args:[_c("value1 (any)",a("The value to test as being greater than value2.")),_c("value2 (any)",a("The second value."))],returns:["BOOLEAN"],compute:function(e,t){return tf(e,t,((e,t)=>"number"==typeof e&&"number"==typeof t?!Jm(e,t)&&e>t:e>t))}},sf={description:a("Greater than or equal to."),args:[_c("value1 (any)",a("The value to test as being greater than or equal to value2.")),_c("value2 (any)",a("The second value."))],returns:["BOOLEAN"],compute:function(e,t){return tf(e,t,((e,t)=>"number"==typeof e&&"number"==typeof t?Jm(e,t)||e>t:e>=t))}},nf={description:a("Less than."),args:[_c("value1 (any)",a("The value to test as being less than value2.")),_c("value2 (any)",a("The second value."))],returns:["BOOLEAN"],compute:function(e,t){return!sf.compute.bind(this)(e,t)}},rf={description:a("Less than or equal to."),args:[_c("value1 (any)",a("The value to test as being less than or equal to value2.")),_c("value2 (any)",a("The second value."))],returns:["BOOLEAN"],compute:function(e,t){return!of.compute.bind(this)(e,t)}},af={description:a("Difference of two numbers."),args:[_c("value1 (number)",a("The minuend, or number to be subtracted from.")),_c("value2 (number)",a("The subtrahend, or number to subtract from value1."))],returns:["NUMBER"],computeFormat:(e,t)=>e?.format||t?.format,compute:function(e,t){return Vo(e,this.locale)-Vo(t,this.locale)}},lf={description:a("Product of two numbers"),args:[_c("factor1 (number)",a("The first multiplicand.")),_c("factor2 (number)",a("The second multiplicand."))],returns:["NUMBER"],computeFormat:(e,t)=>e?.format||t?.format,compute:function(e,t){return Vo(e,this.locale)*Vo(t,this.locale)}},cf={description:a("Not equal."),args:[_c("value1 (any)",a("The first value.")),_c("value2 (any)",a("The value to test against value1 for inequality."))],returns:["BOOLEAN"],compute:function(e,t){return!ef.compute.bind(this)(e,t)}},hf={description:a("A number raised to a power."),args:[_c("base (number)",a("The number to raise to the exponent power.")),_c("exponent (number)",a("The exponent to raise base to."))],returns:["NUMBER"],compute:function(e,t){return td.compute.bind(this)(e,t)}},df={description:a("A number with the sign reversed."),args:[_c("value (number)",a("The number to have its sign reversed. Equivalently, the number to multiply by -1."))],computeFormat:e=>e?.format,returns:["NUMBER"],compute:function(e){return-Vo(e,this.locale)}},uf={description:a("Value interpreted as a percentage."),args:[_c("percentage (number)",a("The value to interpret as a percentage."))],returns:["NUMBER"],compute:function(e){return Vo(e,this.locale)/100}},gf={description:a("A specified number, unchanged."),args:[_c("value (any)",a("The number to return."))],returns:["ANY"],computeFormat:e=>e?.format,compute:function(e=""){return null===e?"":e}};var pf=Object.freeze({__proto__:null,ADD:Ym,CONCAT:jm,DIVIDE:Xm,EQ:ef,GT:of,GTE:sf,LT:nf,LTE:rf,MINUS:af,MULTIPLY:lf,NE:cf,POW:hf,UMINUS:df,UNARY_PERCENT:uf,UPLUS:gf});const mf=/[A-Za-zÀ-ÖØ-öø-ÿ]+/g,ff={description:a("Gets character associated with number."),args:[_c("table_number (number)",a("The number of the character to look up from the current Unicode table in decimal format."))],returns:["STRING"],compute:function(e){const t=Math.trunc(Vo(e,this.locale));return Lo((()=>t>=1),a("The table_number (%s) is out of range.",t.toString())),String.fromCharCode(t)},isExported:!0},bf={description:a("Remove non-printable characters from a piece of text."),args:[_c("text (string)",a("The text whose non-printable characters are to be removed."))],returns:["STRING"],compute:function(e){const t=$o(e);let o="";for(const e of t)e&&e.charCodeAt(0)>31&&(o+=e);return o},isExported:!0},vf={description:a("Appends strings to one another."),args:[_c("string1 (string, range<string>)",a("The initial string.")),_c("string2 (string, range<string>, repeating)",a("More strings to append in sequence."))],returns:["STRING"],compute:function(...e){return Jo(e,((e,t)=>e+$o(t)),"")},isExported:!0},Sf={description:a("Tests whether two strings are identical."),args:[_c("string1 (string)",a("The first string to compare.")),_c("string2 (string)",a("The second string to compare."))],returns:["BOOLEAN"],compute:function(e,t){return $o(e)===$o(t)},isExported:!0},Cf={description:a("First position of string found in text, case-sensitive."),args:[_c("search_for (string)",a("The string to look for within text_to_search.")),_c("text_to_search (string)",a("The text to search for the first occurrence of search_for.")),_c("starting_at (number, default=1)",a("The character within text_to_search at which to start the search."))],returns:["NUMBER"],compute:function(e,t,o=1){const s=$o(e),n=$o(t),i=Vo(o,this.locale);Lo((()=>""!==n),a("The text_to_search must be non-empty.")),Lo((()=>i>=1),a("The starting_at (%s) must be greater than or equal to 1.",i.toString()));const r=n.indexOf(s,i-1);return Lo((()=>r>=0),a("In [[FUNCTION_NAME]] evaluation, cannot find '%s' within '%s'.",s.toString(),n)),r+1},isExported:!0},Ef={description:a("Concatenates elements of arrays with delimiter."),args:[_c("delimiter (string)",a("The character or string to place between each concatenated value.")),_c("value_or_array1 (string, range<string>)",a("The value or values to be appended using delimiter.")),_c("value_or_array2 (string, range<string>, repeating)",a("More values to be appended using delimiter."))],returns:["STRING"],compute:function(e,...t){const o=$o(e);return Jo(t,((e,t)=>(e?e+o:"")+$o(t)),"")}},yf={description:a("Substring from beginning of specified string."),args:[_c("text (string)",a("The string from which the left portion will be returned.")),_c("number_of_characters (number, optional)",a("The number of characters to return from the left side of string."))],returns:["STRING"],compute:function(e,...t){const o=t.length?Vo(t[0],this.locale):1;return Lo((()=>o>=0),a("The number_of_characters (%s) must be positive or null.",o.toString())),$o(e).substring(0,o)},isExported:!0},wf={description:a("Length of a string."),args:[_c("text (string)",a("The string whose length will be returned."))],returns:["NUMBER"],compute:function(e){return $o(e).length},isExported:!0},xf={description:a("Converts a specified string to lowercase."),args:[_c("text (string)",a("The string to convert to lowercase."))],returns:["STRING"],compute:function(e){return $o(e).toLowerCase()},isExported:!0},If={description:a("A segment of a string."),args:[_c("text (string)",a("The string to extract a segment from.")),_c("starting_at (number)",a("The index from the left of string from which to begin extracting. The first character in string has the index 1.")),_c("extract_length (number)",a("The length of the segment to extract."))],returns:["STRING"],compute:function(e,t,o){const s=$o(e),n=Vo(t,this.locale),i=Vo(o,this.locale);return Lo((()=>n>=1),a("The starting_at argument (%s) must be positive greater than one.",n.toString())),Lo((()=>i>=0),a("The extract_length argument (%s) must be positive or null.",i.toString())),s.slice(n-1,n+i-1)},isExported:!0},Rf={description:a("Capitalizes each word in a specified string."),args:[_c("text_to_capitalize (string)",a("The text which will be returned with the first letter of each word in uppercase and all other letters in lowercase."))],returns:["STRING"],compute:function(e){return $o(e).replace(mf,(e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()))},isExported:!0},Tf={description:a("Replaces part of a text string with different text."),args:[_c("text (string)",a("The text, a part of which will be replaced.")),_c("position (number)",a("The position where the replacement will begin (starting from 1).")),_c("length (number)",a("The number of characters in the text to be replaced.")),_c("new_text (string)",a("The text which will be inserted into the original text."))],returns:["STRING"],compute:function(e,t,o,s){const n=Vo(t,this.locale);Lo((()=>n>=1),a("The position (%s) must be greater than or equal to 1.",n.toString()));const i=$o(e),r=Vo(o,this.locale),l=$o(s);return i.substring(0,n-1)+l+i.substring(n-1+r)},isExported:!0},Af={description:a("A substring from the end of a specified string."),args:[_c("text (string)",a("The string from which the right portion will be returned.")),_c("number_of_characters (number, optional)",a("The number of characters to return from the right side of string."))],returns:["STRING"],compute:function(e,...t){const o=t.length?Vo(t[0],this.locale):1;Lo((()=>o>=0),a("The number_of_characters (%s) must be positive or null.",o.toString()));const s=$o(e),n=s.length;return s.substring(n-o,n)},isExported:!0},Of={description:a("First position of string found in text, ignoring case."),args:[_c("search_for (string)",a("The string to look for within text_to_search.")),_c("text_to_search (string)",a("The text to search for the first occurrence of search_for.")),_c("starting_at (number, default=1)",a("The character within text_to_search at which to start the search."))],returns:["NUMBER"],compute:function(e,t,o=1){const s=$o(e).toLowerCase(),n=$o(t).toLowerCase(),i=Vo(o,this.locale);Lo((()=>""!==n),a("The text_to_search must be non-empty.")),Lo((()=>i>=1),a("The starting_at (%s) must be greater than or equal to 1.",i.toString()));const r=n.indexOf(s,i-1);return Lo((()=>r>=0),a("In [[FUNCTION_NAME]] evaluation, cannot find '%s' within '%s'.",s,n)),r+1},isExported:!0},_f={description:a("Split text by specific character delimiter(s)."),args:[_c("text (string)",a("The text to divide.")),_c("delimiter (string)",a("The character or characters to use to split text.")),_c("split_by_each (boolean, default=true})",a("Whether or not to divide text around each character contained in delimiter.")),_c("remove_empty_text (boolean, default=true)",a("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."))],returns:["RANGE<STRING>"],compute:function(e,t,o=true,s=true){const n=$o(e),i=Te($o(t)),r=Zo(o),l=Zo(s);Lo((()=>i.length>0),a("The _delimiter (%s) must be not be empty.",i));const c=r?new RegExp(`[${i}]`,"g"):new RegExp(i,"g");let h=n.split(c);return l&&(h=h.filter((e=>""!==e))),ns([h])},isExported:!1},Mf={description:a("Replaces existing text with new text in a string."),args:[_c("text_to_search (string)",a("The text within which to search and replace.")),_c("search_for (string)",a("The string to search for within text_to_search.")),_c("replace_with (string)",a("The string that will replace search_for.")),_c("occurrence_number (number, optional)",a("The instance of search_for within text_to_search to replace with replace_with. By default, all occurrences of search_for are replaced; however, if occurrence_number is specified, only the indicated instance of search_for is replaced."))],returns:["NUMBER"],compute:function(e,t,o,s){const n=Vo(s,this.locale);Lo((()=>n>=0),a("The occurrenceNumber (%s) must be positive or null.",n.toString()));const i=$o(e),r=$o(t);if(""===r)return i;const l=$o(o),c=new RegExp(Te(r),"g");if(0===n)return i.replace(c,l);let h=0;return i.replace(c,(e=>++h===n?l:e))},isExported:!0},Nf={description:a("Combines text from multiple strings and/or arrays."),args:[_c("delimiter (string)",a(" A string, possible empty, or a reference to a valid string. If empty, the text will be simply concatenated.")),_c("ignore_empty (boolean)",a("A boolean; if TRUE, empty cells selected in the text arguments won't be included in the result.")),_c("text1 (string, range<string>)",a("Any text item. This could be a string, or an array of strings in a range.")),_c("text2 (string, range<string>, repeating)",a("Additional text item(s)."))],returns:["STRING"],compute:function(e,t,...o){const s=$o(e),n=Zo(t);let i=0;return Jo(o,((e,t)=>n&&""===$o(t)?e:(i++?e+s:"")+$o(t)),"")},isExported:!0},Ff={description:a("Removes space characters."),args:[_c("text (string)",a("The text or reference to a cell containing text to be trimmed."))],returns:["STRING"],compute:function(e){return ht($o(e))},isExported:!0},Df={description:a("Converts a specified string to uppercase."),args:[_c("text (string)",a("The string to convert to uppercase."))],returns:["STRING"],compute:function(e){return $o(e).toUpperCase()},isExported:!0},Lf={description:a("Converts a number to text according to a specified format."),args:[_c("number (number)",a("The number, date or time to format.")),_c("format (string)",a("The pattern by which to format the number, enclosed in quotation marks."))],returns:["STRING"],compute:function(e,t){return Ts(Vo(e,this.locale),{format:$o(t),locale:this.locale})},isExported:!0},Pf={description:a("Converts a string to a numeric value."),args:[_c("value (number)",a("the string to be converted"))],returns:["NUMBER"],compute:function(e){return Vo(e,this.locale)},isExported:!0};var Vf=Object.freeze({__proto__:null,CHAR:ff,CLEAN:bf,CONCATENATE:vf,EXACT:Sf,FIND:Cf,JOIN:Ef,LEFT:yf,LEN:wf,LOWER:xf,MID:If,PROPER:Rf,REPLACE:Tf,RIGHT:Af,SEARCH:Of,SPLIT:_f,SUBSTITUTE:Mf,TEXT:Lf,TEXTJOIN:Nf,TRIM:Ff,UPPER:Df,VALUE:Pf});const kf={description:a("Creates a hyperlink in a cell."),args:[_c("url (string)",a("The full URL of the link enclosed in quotation marks.")),_c("link_label (string, optional)",a("The text to display in the cell, enclosed in quotation marks."))],returns:["STRING"],compute:function(e,t){const o=$o(e).trim(),s=$o(t)||o;return""===o?s:Ue(s,o)},isExported:!0};var Uf=Object.freeze({__proto__:null,HYPERLINK:kf});const Bf=[{name:a("Array"),functions:dh},{name:a("Database"),functions:Qu},{name:a("Date"),functions:Fg},{name:a("Filter"),functions:$g},{name:a("Financial"),functions:um},{name:a("Info"),functions:ym},{name:a("Lookup"),functions:Zm},{name:a("Logical"),functions:Fm},{name:a("Math"),functions:Ed},{name:a("Misc"),functions:gh},{name:a("Operator"),functions:pf},{name:a("Statistical"),functions:Vu},{name:a("Text"),functions:Vf},{name:a("Engineering"),functions:Lg},{name:a("Web"),functions:Uf}],Hf=/^[A-Z0-9\_\.]+$/;function zf(e){return Mo(e)?ss(e,(e=>e.value)):e?.value}const Gf=new class extends Zi{mapping={};add(e,t){if(e=e.toUpperCase(),!Hf.test(e))throw new Error(a("Invalid function name %s. Function names can exclusively contain alphanumerical values separated by dots (.) or underscore (_)",e));const o=Mc(t);return function(e){let t=!1,o=!1,s=!1;for(let n of e){if(n.type.includes("META")&&n.type.length>1)throw new Error(a("Function ${name} has an argument that has been declared with more than one type whose type 'META'. The 'META' type can only be declared alone."));if(t&&!n.repeating)throw new Error(a("Function ${name} has no-repeatable arguments declared after repeatable ones. All repeatable arguments must be declared last."));const e=o||t||s,i=!(n.optional||n.repeating||n.default);if(e&&i)throw new Error(a("Function ${name} has at mandatory arguments declared after optional ones. All optional arguments must be after all mandatory arguments."));t=n.repeating,o=n.optional,s=n.default}}(o.args),this.mapping[e]=function(e,t){function o(...o){for(let t=0;t<o.length;t++){const s=e.args[e.getArgToFocus(t+1)-1],n=o[t];if(Mo(n)&&!s.acceptMatrix){if(1!==n.length||1!==n[0].length)throw new d(c.GenericError,a("Function [[FUNCTION_NAME]] expects the parameter '%s' to be a single value or a single cell reference, not a range.",s.name));o[t]=n[0][0]}}return t.apply(this,o)}return o}(o,function(e){const t="computeValueAndFormat"in e,o="compute"in e,s="computeFormat"in e;if(!t&&!o)throw new Error("Invalid function description, need at least one 'compute' or 'computeValueAndFormat' function");if(t&&(o||s))throw new Error("Invalid function description, cannot have both 'computeValueAndFormat' and 'compute'/'computeFormat' functions");if(t)return e.computeValueAndFormat;return function(e){return function(...t){const o=e.compute.apply(this,function(e){return e.map((e=>{if(void 0!==e)return"function"==typeof e?()=>zf(e()):zf(e)}))}(t)),s=e.computeFormat?.apply(this,t);if(Mo(o)){if(void 0===s||Mo(s))return o.map(((e,t)=>e.map(((e,o)=>({value:e,format:s?.[t]?.[o]})))))}else if(void 0===s||!Mo(s))return{value:o,format:s};throw new Error("A format matrix should never be associated with a scalar value")}}(e)}(o)),super.add(e,o),this}};for(let uA of Bf){const gA=uA.functions;for(let pA in gA){const mA=gA[pA];mA.category=mA.category||uA.name,pA=pA.replace(/_/g,"."),Gf.add(pA,{isExported:!1,...mA})}}const $f={name:e=>{const t=bb(e);return 1===t?a("Insert row"):a("Insert %s rows",t.toString())},isVisible:e=>nc(e,"ROW"),icon:"o-spreadsheet-Icon.INSERT_ROW"},Wf={name:e=>{const t=bb(e);return 1===t?a("Insert row above"):a("Insert %s rows above",t.toString())},execute:Ql,isVisible:e=>nc(e,"ROW"),icon:"o-spreadsheet-Icon.INSERT_ROW_BEFORE"},qf={...Wf,name:e=>{const t=bb(e);return 1===t?a("Row above"):a("%s Rows above",t.toString())}},Zf={...Wf,name:e=>{const t=bb(e);return 1===t?a("Insert row"):a("Insert %s rows",t.toString())},isVisible:sc,icon:"o-spreadsheet-Icon.INSERT_ROW_BEFORE"},Yf={execute:e=>{const t=e.model.getters.getActiveRows();let o,s;if(t.size)o=ut([...t]),s=t.size;else{const t=e.model.getters.getSelectedZones()[0];o=t.bottom,s=t.bottom-t.top+1}e.model.dispatch("ADD_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),position:"after",base:o,quantity:s,dimension:"ROW"})},name:e=>{const t=bb(e);return 1===t?a("Insert row below"):a("Insert %s rows below",t.toString())},isVisible:e=>nc(e,"ROW"),icon:"o-spreadsheet-Icon.INSERT_ROW_AFTER"},jf={...Yf,name:e=>{const t=bb(e);return 1===t?a("Row below"):a("%s Rows below",t.toString())}},Xf={name:e=>{const t=vb(e);return 1===t?a("Insert column"):a("Insert %s columns",t.toString())},isVisible:e=>nc(e,"COL"),icon:"o-spreadsheet-Icon.INSERT_COL"},Kf={name:e=>{const t=vb(e);return 1===t?a("Insert column left"):a("Insert %s columns left",t.toString())},execute:Jl,isVisible:e=>nc(e,"COL"),icon:"o-spreadsheet-Icon.INSERT_COL_BEFORE"},Qf={...Kf,name:e=>{const t=vb(e);return 1===t?a("Column left"):a("%s Columns left",t.toString())}},Jf={...Kf,name:e=>{const t=vb(e);return 1===t?a("Insert column"):a("Insert %s columns",t.toString())},isVisible:sc,icon:"o-spreadsheet-Icon.INSERT_COL_BEFORE"},eb={name:e=>{const t=vb(e);return 1===t?a("Insert column right"):a("Insert %s columns right",t.toString())},execute:ec,isVisible:e=>nc(e,"COL"),icon:"o-spreadsheet-Icon.INSERT_COL_AFTER"},tb={...eb,name:e=>{const t=vb(e);return 1===t?a("Column right"):a("%s Columns right",t.toString())},execute:ec},ob={name:a("Insert cells"),isVisible:e=>sc(e)&&0===e.model.getters.getActiveCols().size&&0===e.model.getters.getActiveRows().size,icon:"o-spreadsheet-Icon.INSERT_CELL"},sb={name:a("Insert cells and shift down"),execute:e=>{const t=e.model.getters.getSelectedZone(),o=e.model.dispatch("INSERT_CELL",{zone:t,shiftDimension:"ROW"});Ga(e,o)},isVisible:e=>0===e.model.getters.getActiveRows().size&&0===e.model.getters.getActiveCols().size,icon:"o-spreadsheet-Icon.INSERT_CELL_SHIFT_DOWN"},nb={name:a("Insert cells and shift right"),execute:e=>{const t=e.model.getters.getSelectedZone(),o=e.model.dispatch("INSERT_CELL",{zone:t,shiftDimension:"COL"});Ga(e,o)},isVisible:e=>0===e.model.getters.getActiveRows().size&&0===e.model.getters.getActiveCols().size,icon:"o-spreadsheet-Icon.INSERT_CELL_SHIFT_RIGHT"},ib={name:a("Chart"),execute:e=>{const t=e.model.getters,o=e.model.uuidGenerator.smallUuid(),s=t.getActiveSheetId();1===Vn(e.model.getters.getSelectedZone())&&e.model.selection.selectTableAroundSelection();const n={width:536,height:335},i=function(e,t){const{x:o,y:s}=e.getMainViewportCoordinates(),{scrollX:n,scrollY:i}=e.getActiveSheetScrollInfo(),{width:r,height:a}=e.getVisibleRect(e.getActiveMainViewport());return{x:o+n+Math.max(0,(r-t.width)/2),y:s+i+Math.max(0,(a-t.height)/2)}}(t,n);e.model.dispatch("CREATE_CHART",{sheetId:s,id:o,position:i,size:n,definition:ql(e.model.getters.getSelectedZone(),e.model.getters)}).isSuccessful&&(e.model.dispatch("SELECT_FIGURE",{id:o}),e.openSidePanel("ChartPanel"))},icon:"o-spreadsheet-Icon.INSERT_CHART"},rb={name:a("Image"),description:"Ctrl+O",execute:tc,isVisible:e=>void 0!==e.imageProvider,icon:"o-spreadsheet-Icon.INSERT_IMAGE"},ab={name:a("Function"),icon:"o-spreadsheet-Icon.SHOW_HIDE_FORMULA"},lb={name:a("SUM"),execute:e=>e.startCellEdition("=SUM(")},cb={name:a("AVERAGE"),execute:e=>e.startCellEdition("=AVERAGE(")},hb={name:a("COUNT"),execute:e=>e.startCellEdition("=COUNT(")},db={name:a("MAX"),execute:e=>e.startCellEdition("=MAX(")},ub={name:a("MIN"),execute:e=>e.startCellEdition("=MIN(")},gb={name:a("All"),children:[function(){return fb(Gf.getKeys().filter((e=>!Gf.get(e).hidden)))}]};const pb={name:a("Link"),execute:oc,icon:"o-spreadsheet-Icon.INSERT_LINK"},mb={name:a("Insert sheet"),execute:e=>{const t=e.model.getters.getActiveSheetId(),o=e.model.getters.getSheetIds().indexOf(t)+1,s=e.model.uuidGenerator.smallUuid();e.model.dispatch("CREATE_SHEET",{sheetId:s,position:o}),e.model.dispatch("ACTIVATE_SHEET",{sheetIdFrom:t,sheetIdTo:s})},icon:"o-spreadsheet-Icon.INSERT_SHEET"};function fb(e){return e.sort().map(((e,t)=>({name:e,sequence:10*t,execute:t=>t.startCellEdition(`=${e}(`)})))}function bb(e){const t=e.model.getters.getActiveRows();if(t.size)return t.size;{const t=e.model.getters.getSelectedZones()[0];return t.bottom-t.top+1}}function vb(e){const t=e.model.getters.getActiveCols();if(t.size)return t.size;{const t=e.model.getters.getSelectedZones()[0];return t.right-t.left+1}}const Sb=new Pa;Sb.add("cut",{...lc,sequence:10}).add("copy",{...ac,sequence:20}).add("paste",{...cc,sequence:30}).add("paste_special",{...hc,sequence:40,separator:!0}).addChild("paste_value_only",["paste_special"],{...dc,sequence:10}).addChild("paste_format_only",["paste_special"],{...uc,sequence:20}).add("add_row_before",{...Zf,sequence:70}).add("add_column_before",{...Jf,sequence:90}).add("insert_cell",{...ob,sequence:100,separator:!0}).addChild("insert_cell_down",["insert_cell"],{...sb,name:a("Shift down"),sequence:10}).addChild("insert_cell_right",["insert_cell"],{...nb,name:a("Shift right"),sequence:20}).add("delete_row",{...fc,sequence:110,icon:"o-spreadsheet-Icon.DELETE"}).add("delete_column",{...Sc,sequence:120,icon:"o-spreadsheet-Icon.DELETE"}).add("delete_cell",{...Ec,sequence:130,separator:!0,icon:"o-spreadsheet-Icon.DELETE"}).addChild("delete_cell_up",["delete_cell"],{...yc,name:a("Shift up"),sequence:10,icon:"o-spreadsheet-Icon.DELETE_CELL_SHIFT_UP"}).addChild("delete_cell_left",["delete_cell"],{...wc,name:a("Shift left"),sequence:20,icon:"o-spreadsheet-Icon.DELETE_CELL_SHIFT_LEFT"}).add("insert_link",{...pb,name:e=>{const t=e.model.getters.getActiveSheetId(),{col:o,row:s}=e.model.getters.getActivePosition(),n=e.model.getters.getEvaluatedCell({sheetId:t,col:o,row:s});return n&&n.link?a("Edit link"):a("Insert link")},sequence:150,separator:!0});const Cb={filterOverlap:a("You cannot create overlapping filters."),nonContinuousTargets:a("A filter can only be created on a continuous selection."),mergeInFilter:a("You can't create a filter over a range that contains a merge.")};function Eb(e,t,o){const s=e.model.getters.getActiveSheetId(),n="COL"===t?"FREEZE_COLUMNS":"FREEZE_ROWS";e.model.dispatch(n,{sheetId:s,quantity:o}).isCancelledBecause("MergeOverlap")&&e.raiseError(Xa)}const yb={name:e=>{const t=e.model.getters.getElementsFromSelection("COL");let o=t[0],s=t[t.length-1];return 1===t.length?a("Hide column %s",Ot(o).toString()):s-o+1===t.length?a("Hide columns %s - %s",Ot(o).toString(),Ot(s).toString()):a("Hide columns")},execute:e=>{const t=e.model.getters.getElementsFromSelection("COL");e.model.dispatch("HIDE_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),dimension:"COL",elements:t})},isVisible:e=>{const t=e.model.getters.getActiveSheetId(),o=e.model.getters.getElementsFromSelection("COL");return!e.model.getters.checkElementsIncludeAllVisibleHeaders(t,"COL",o)},icon:"o-spreadsheet-Icon.HIDE_COL"},wb={name:a("Unhide columns"),execute:e=>{const t=e.model.getters.getElementsFromSelection("COL");e.model.dispatch("UNHIDE_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),dimension:"COL",elements:t})},isVisible:e=>{const t=e.model.getters.getHiddenColsGroups(e.model.getters.getActiveSheetId()).flat();return e.model.getters.getElementsFromSelection("COL").some((e=>t.includes(e)))}},xb={name:a("Unhide all columns"),execute:e=>{const t=e.model.getters.getActiveSheetId();e.model.dispatch("UNHIDE_COLUMNS_ROWS",{sheetId:t,dimension:"COL",elements:Array.from(Array(e.model.getters.getNumberCols(t)).keys())})},isVisible:e=>e.model.getters.getHiddenColsGroups(e.model.getters.getActiveSheetId()).length>0},Ib={name:e=>{const t=e.model.getters.getElementsFromSelection("ROW");let o=t[0],s=t[t.length-1];return 1===t.length?a("Hide row %s",(o+1).toString()):s-o+1===t.length?a("Hide rows %s - %s",(o+1).toString(),(s+1).toString()):a("Hide rows")},execute:e=>{const t=e.model.getters.getElementsFromSelection("ROW");e.model.dispatch("HIDE_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),dimension:"ROW",elements:t})},isVisible:e=>{const t=e.model.getters.getActiveSheetId(),o=e.model.getters.getElementsFromSelection("ROW");return!e.model.getters.checkElementsIncludeAllVisibleHeaders(t,"ROW",o)},icon:"o-spreadsheet-Icon.HIDE_ROW"},Rb={name:a("Unhide rows"),execute:e=>{const t=e.model.getters.getElementsFromSelection("ROW");e.model.dispatch("UNHIDE_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),dimension:"ROW",elements:t})},isVisible:e=>{const t=e.model.getters.getHiddenRowsGroups(e.model.getters.getActiveSheetId()).flat();return e.model.getters.getElementsFromSelection("ROW").some((e=>t.includes(e)))}},Tb={name:a("Unhide all rows"),execute:e=>{const t=e.model.getters.getActiveSheetId();e.model.dispatch("UNHIDE_COLUMNS_ROWS",{sheetId:t,dimension:"ROW",elements:Array.from(Array(e.model.getters.getNumberRows(t)).keys())})},isVisible:e=>e.model.getters.getHiddenRowsGroups(e.model.getters.getActiveSheetId()).length>0},Ab={name:a("Unfreeze"),isVisible:e=>{const{xSplit:t,ySplit:o}=e.model.getters.getPaneDivisions(e.model.getters.getActiveSheetId());return t+o>0},execute:e=>e.model.dispatch("UNFREEZE_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId()}),icon:"o-spreadsheet-Icon.UNFREEZE"},Ob={name:a("Freeze"),icon:"o-spreadsheet-Icon.FREEZE"},_b={name:a("No rows"),execute:e=>e.model.dispatch("UNFREEZE_ROWS",{sheetId:e.model.getters.getActiveSheetId()}),isReadonlyAllowed:!0,isVisible:e=>!!e.model.getters.getPaneDivisions(e.model.getters.getActiveSheetId()).ySplit},Mb={name:a("1 row"),execute:e=>Eb(e,"ROW",1),isReadonlyAllowed:!0},Nb={name:a("2 rows"),execute:e=>Eb(e,"ROW",2),isReadonlyAllowed:!0},Fb={name:a("Up to current row"),execute:e=>{const{bottom:t}=e.model.getters.getSelectedZone();Eb(e,"ROW",t+1)},isReadonlyAllowed:!0},Db={name:a("No columns"),execute:e=>e.model.dispatch("UNFREEZE_COLUMNS",{sheetId:e.model.getters.getActiveSheetId()}),isReadonlyAllowed:!0,isVisible:e=>!!e.model.getters.getPaneDivisions(e.model.getters.getActiveSheetId()).xSplit},Lb={name:a("1 column"),execute:e=>Eb(e,"COL",1),isReadonlyAllowed:!0},Pb={name:a("2 columns"),execute:e=>Eb(e,"COL",2),isReadonlyAllowed:!0},Vb={name:a("Up to current column"),execute:e=>{const{right:t}=e.model.getters.getSelectedZone();Eb(e,"COL",t+1)},isReadonlyAllowed:!0},kb={name:e=>e.model.getters.getGridLinesVisibility(e.model.getters.getActiveSheetId())?a("Hide gridlines"):a("Show gridlines"),execute:e=>{const t=e.model.getters.getActiveSheetId();e.model.dispatch("SET_GRID_LINES_VISIBILITY",{sheetId:t,areGridLinesVisible:!e.model.getters.getGridLinesVisibility(t)})},icon:"o-spreadsheet-Icon.SHOW_HIDE_GRID"},Ub={name:e=>e.model.getters.shouldShowFormulas()?"Hide formulas":a("Show formulas"),execute:e=>e.model.dispatch("SET_FORMULA_VISIBILITY",{show:!e.model.getters.shouldShowFormulas()}),isReadonlyAllowed:!0,icon:"o-spreadsheet-Icon.SHOW_HIDE_FORMULA"},Bb={name:e=>Wb(e)?a("Remove selected filters"):a("Create filter"),isActive:e=>Wb(e),isEnabled:e=>!qb(e),execute:e=>Zb(e),icon:"o-spreadsheet-Icon.FILTER_ICON_INACTIVE"},Hb={name:e=>{const t=e.model.getters.getSelectedZone();return t.left===t.right?a("Group column %s",Ot(t.left)):a("Group columns %s - %s",Ot(t.left),Ot(t.right))},execute:e=>Yb(e,"COL"),isVisible:e=>{const t=e.model.getters.getActiveSheetId(),o=e.model.getters.getSelectedZone(),s=e.model.getters.getHeaderGroupsInZone(t,"COL",o);return sc(e)&&!s.some((e=>e.start===o.left&&e.end===o.right))},icon:"o-spreadsheet-Icon.GROUP_COLUMNS"},zb={name:e=>{const t=e.model.getters.getSelectedZone();return t.top===t.bottom?a("Group row %s",String(t.top+1)):a("Group rows %s - %s",String(t.top+1),String(t.bottom+1))},execute:e=>Yb(e,"ROW"),isVisible:e=>{const t=e.model.getters.getActiveSheetId(),o=e.model.getters.getSelectedZone(),s=e.model.getters.getHeaderGroupsInZone(t,"ROW",o);return sc(e)&&!s.some((e=>e.start===o.top&&e.end===o.bottom))},icon:"o-spreadsheet-Icon.GROUP_ROWS"},Gb={name:e=>{const t=e.model.getters.getSelectedZone();return t.left===t.right?a("Ungroup column %s",Ot(t.left)):a("Ungroup columns %s - %s",Ot(t.left),Ot(t.right))},execute:e=>jb(e,"COL"),icon:"o-spreadsheet-Icon.UNGROUP_COLUMNS"},$b={name:e=>{const t=e.model.getters.getSelectedZone();return t.top===t.bottom?a("Ungroup row %s",String(t.top+1)):a("Ungroup rows %s - %s",String(t.top+1),String(t.bottom+1))},execute:e=>jb(e,"ROW"),icon:"o-spreadsheet-Icon.UNGROUP_ROWS"};function Wb(e){const t=e.model.getters.getActiveSheetId(),o=e.model.getters.getSelectedZones();return e.model.getters.doesZonesContainFilter(t,o)}function qb(e){return!kn(...e.model.getters.getSelectedZones())}function Zb(e){if(Wb(e))return void e.model.dispatch("REMOVE_FILTER_TABLE",{sheetId:e.model.getters.getActiveSheetId(),target:e.model.getters.getSelectedZones()});if(qb(e))return;e.model.selection.selectTableAroundSelection();const t=e.model.getters.getActiveSheetId(),o=e.model.getters.getSelectedZones();!function(e,t,o){const s=e.model.dispatch("CREATE_FILTER_TABLE",{target:o,sheetId:t});s.isCancelledBecause("FilterOverlap")?e.raiseError(Cb.filterOverlap):s.isCancelledBecause("MergeInFilter")?e.raiseError(Cb.mergeInFilter):s.isCancelledBecause("NonContinuousTargets")&&e.raiseError(Cb.nonContinuousTargets)}(e,t,o)}function Yb(e,t){const o=e.model.getters.getSelectedZone(),s=e.model.getters.getActiveSheetId();e.model.dispatch("GROUP_HEADERS",{sheetId:s,dimension:t,start:"COL"===t?o.left:o.top,end:"COL"===t?o.right:o.bottom})}function jb(e,t){const o=e.model.getters.getSelectedZone(),s=e.model.getters.getActiveSheetId();e.model.dispatch("UNGROUP_HEADERS",{sheetId:s,dimension:t,start:"COL"===t?o.left:o.top,end:"COL"===t?o.right:o.bottom})}function Xb(e,t){const o=e.model.getters.getActiveSheetId(),s=e.model.getters.getSelectedZones();return 1===s.length&&e.model.getters.getHeaderGroupsInZone(o,t,s[0]).length>0}var Kb=Object.freeze({__proto__:null,canUngroupHeaders:Xb,createRemoveFilter:Bb,createRemoveFilterAction:Zb,freezeCurrentCol:Vb,freezeCurrentRow:Fb,freezeFirstCol:Lb,freezeFirstRow:Mb,freezePane:Ob,freezeSecondCol:Pb,freezeSecondRow:Nb,groupColumns:Hb,groupRows:zb,hideCols:yb,hideRows:Ib,unFreezeCols:Db,unFreezePane:Ab,unFreezeRows:_b,ungroupColumns:Gb,ungroupRows:$b,unhideAllCols:xb,unhideAllRows:Tb,unhideCols:wb,unhideRows:Rb,viewFormulas:Ub,viewGridlines:kb});const Qb={name:a("Sort range"),isVisible:sc,icon:"o-spreadsheet-Icon.SORT_RANGE"},Jb={name:a("Ascending (A ⟶ Z)"),execute:e=>{const{anchor:t,zones:o}=e.model.getters.getSelection(),s=e.model.getters.getActiveSheetId();kg(e,s,t.cell,o[0],"ascending")},icon:"o-spreadsheet-Icon.SORT_ASCENDING"},ev={name:a("Data cleanup"),icon:"o-spreadsheet-Icon.DATA_CLEANUP"},tv={name:a("Remove duplicates"),execute:e=>{1===Vn(e.model.getters.getSelectedZone())&&e.model.selection.selectTableAroundSelection(),e.openSidePanel("RemoveDuplicates",{})}},ov={name:a("Trim whitespace"),execute:e=>{e.model.dispatch("TRIM_WHITESPACE")}},sv={name:a("Descending (Z ⟶ A)"),execute:e=>{const{anchor:t,zones:o}=e.model.getters.getSelection(),s=e.model.getters.getActiveSheetId();kg(e,s,t.cell,o[0],"descending")},icon:"o-spreadsheet-Icon.SORT_DESCENDING"},nv={name:e=>(e=>{const t=e.model.getters.getActiveSheetId(),o=e.model.getters.getSelectedZones();return e.model.getters.doesZonesContainFilter(t,o)})(e)?a("Remove filter"):a("Create filter"),execute:e=>Zb(e),isEnabled:e=>kn(...e.model.getters.getSelectedZones()),icon:"o-spreadsheet-Icon.MENU_FILTER_ICON"},iv={name:a("Split text to columns"),sequence:1,execute:e=>e.openSidePanel("SplitToColumns",{}),isEnabled:e=>e.model.getters.isSingleColSelected(),icon:"o-spreadsheet-Icon.SPLIT_TEXT"};function rv({name:e,format:t,descriptionValue:o}){const s="function"==typeof t?t:()=>t;return{name:e,description:e=>Ts(o,{format:s(e),locale:e.model.getters.getLocale()}),execute:e=>Zl(e,s(e)),isActive:e=>function(e,t){const o=e.model.getters.getCell(e.model.getters.getActivePosition());return o?.format===t}(e,s(e))}}const av={name:a("Automatic"),execute:e=>Zl(e,""),isActive:e=>function(e){const t=e.model.getters.getCell(e.model.getters.getActivePosition());return!t||!t.format}(e)},lv=rv({name:a("Number"),descriptionValue:1000.12,format:"#,##0.00"}),cv={name:a("Format as percent"),execute:e=>Zl(e,"0.00%"),icon:"o-spreadsheet-Icon.PERCENT"},hv=rv({name:a("Percent"),descriptionValue:.1012,format:"0.00%"}),dv=rv({name:a("Currency"),descriptionValue:1000.12,format:e=>e.model.config.defaultCurrencyFormat??gv}),uv={...rv({name:a("Currency rounded"),descriptionValue:1e3,format:e=>$s(e.model.config.defaultCurrencyFormat??gv)}),isVisible:e=>{const t=e.model.config.defaultCurrencyFormat;return t!==$s(t??gv)}},gv="[$$]#,##0.00",pv=sr("2023/09/26 10:43:00 PM",Oo),mv={name:a("Custom currency"),isVisible:e=>void 0!==e.loadCurrencies,execute:e=>e.openSidePanel("CustomCurrency",{})},fv=rv({name:a("Date"),descriptionValue:pv,format:e=>e.model.getters.getLocale().dateFormat}),bv=rv({name:a("Time"),descriptionValue:pv,format:e=>e.model.getters.getLocale().timeFormat}),vv=rv({name:a("Date time"),descriptionValue:pv,format:e=>Aa(e.model.getters.getLocale())}),Sv=rv({name:a("Duration"),descriptionValue:"27:51:38",format:"hhhh:mm:ss"}),Cv={name:a("More date formats"),execute:e=>e.openSidePanel("MoreFormats",{})},Ev=rv({name:a("Full date time"),format:"dddd d mmmm yyyy hh:mm:ss a",descriptionValue:pv}),yv=rv({name:a("Full week day and month"),format:"dddd d mmmm yyyy",descriptionValue:pv}),wv=rv({name:a("Day and full month"),format:"d mmmm yyyy",descriptionValue:pv}),xv=rv({name:a("Short week day"),format:"ddd d mmm yyyy",descriptionValue:pv}),Iv=rv({name:a("Day and short month"),format:"d mmm yyyy",descriptionValue:pv}),Rv=rv({name:a("Full month"),format:"mmmm yyyy",descriptionValue:pv}),Tv=rv({name:a("Short month"),format:"mmm yyyy",descriptionValue:pv}),Av={name:a("Increase decimal places"),icon:"o-spreadsheet-Icon.INCREASE_DECIMAL",execute:e=>e.model.dispatch("SET_DECIMAL",{sheetId:e.model.getters.getActiveSheetId(),target:e.model.getters.getSelectedZones(),step:1})},Ov={name:a("Decrease decimal places"),icon:"o-spreadsheet-Icon.DECRASE_DECIMAL",execute:e=>e.model.dispatch("SET_DECIMAL",{sheetId:e.model.getters.getActiveSheetId(),target:e.model.getters.getSelectedZones(),step:-1})},_v={name:a("Bold"),description:"Ctrl+B",execute:e=>Yl(e,{bold:!e.model.getters.getCurrentStyle().bold}),icon:"o-spreadsheet-Icon.BOLD",isActive:e=>!!e.model.getters.getCurrentStyle().bold},Mv={name:a("Italic"),description:"Ctrl+I",execute:e=>Yl(e,{italic:!e.model.getters.getCurrentStyle().italic}),icon:"o-spreadsheet-Icon.ITALIC",isActive:e=>!!e.model.getters.getCurrentStyle().italic},Nv={name:a("Underline"),description:"Ctrl+U",execute:e=>Yl(e,{underline:!e.model.getters.getCurrentStyle().underline}),icon:"o-spreadsheet-Icon.UNDERLINE",isActive:e=>!!e.model.getters.getCurrentStyle().underline},Fv={name:a("Strikethrough"),execute:e=>Yl(e,{strikethrough:!e.model.getters.getCurrentStyle().strikethrough}),icon:"o-spreadsheet-Icon.STRIKE",isActive:e=>!!e.model.getters.getCurrentStyle().strikethrough},Dv={name:a("Font size"),children:Ie.map((e=>({name:e.toString(),sequence:e,id:`font_size_${e}`,execute:t=>Yl(t,{fontSize:e}),isActive:t=>function(e,t){const o=e.model.getters.getCurrentStyle().fontSize||ne;return o===t}(t,e)}))),icon:"o-spreadsheet-Icon.FONT_SIZE"},Lv={name:a("Alignment"),icon:"o-spreadsheet-Icon.ALIGN_LEFT"},Pv={name:a("Horizontal align"),icon:e=>function(e){switch(Jv(e)){case"right":return"o-spreadsheet-Icon.ALIGN_RIGHT";case"center":return"o-spreadsheet-Icon.ALIGN_CENTER";default:return"o-spreadsheet-Icon.ALIGN_LEFT"}}(e)},Vv={name:a("Left"),description:"Ctrl+Shift+L",execute:e=>Yl(e,{align:"left"}),isActive:e=>"left"===Jv(e),icon:"o-spreadsheet-Icon.ALIGN_LEFT"},kv={name:a("Center"),description:"Ctrl+Shift+E",execute:e=>Yl(e,{align:"center"}),isActive:e=>"center"===Jv(e),icon:"o-spreadsheet-Icon.ALIGN_CENTER"},Uv={name:a("Right"),description:"Ctrl+Shift+R",execute:e=>Yl(e,{align:"right"}),isActive:e=>"right"===Jv(e),icon:"o-spreadsheet-Icon.ALIGN_RIGHT"},Bv={name:a("Vertical align"),icon:e=>function(e){switch(eS(e)){case"top":return"o-spreadsheet-Icon.ALIGN_TOP";case"middle":return"o-spreadsheet-Icon.ALIGN_MIDDLE";default:return"o-spreadsheet-Icon.ALIGN_BOTTOM"}}(e)},Hv={name:a("Top"),execute:e=>Yl(e,{verticalAlign:"top"}),isActive:e=>"top"===eS(e),icon:"o-spreadsheet-Icon.ALIGN_TOP"},zv={name:a("Middle"),execute:e=>Yl(e,{verticalAlign:"middle"}),isActive:e=>"middle"===eS(e),icon:"o-spreadsheet-Icon.ALIGN_MIDDLE"},Gv={name:a("Bottom"),execute:e=>Yl(e,{verticalAlign:"bottom"}),isActive:e=>"bottom"===eS(e),icon:"o-spreadsheet-Icon.ALIGN_BOTTOM"},$v={name:a("Wrapping"),icon:"o-spreadsheet-Icon.WRAPPING_OVERFLOW"},Wv={name:a("Wrapping"),icon:e=>function(e){switch(tS(e)){case"wrap":return"o-spreadsheet-Icon.WRAPPING_WRAP";case"clip":return"o-spreadsheet-Icon.WRAPPING_CLIP";default:return"o-spreadsheet-Icon.WRAPPING_OVERFLOW"}}(e)},qv={name:a("Overflow"),execute:e=>Yl(e,{wrapping:"overflow"}),isActive:e=>"overflow"===tS(e),icon:"o-spreadsheet-Icon.WRAPPING_OVERFLOW"},Zv={name:a("Wrap"),execute:e=>Yl(e,{wrapping:"wrap"}),isActive:e=>"wrap"===tS(e),icon:"o-spreadsheet-Icon.WRAPPING_WRAP"},Yv={name:a("Clip"),execute:e=>Yl(e,{wrapping:"clip"}),isActive:e=>"clip"===tS(e),icon:"o-spreadsheet-Icon.WRAPPING_CLIP"},jv={name:a("Text Color"),icon:"o-spreadsheet-Icon.TEXT_COLOR"},Xv={name:a("Fill Color"),icon:"o-spreadsheet-Icon.FILL_COLOR"},Kv={name:a("Conditional formatting"),execute:e=>{e.openSidePanel("ConditionalFormatting",{selection:e.model.getters.getSelectedZones()})},icon:"o-spreadsheet-Icon.CONDITIONAL_FORMAT"},Qv={name:a("Clear formatting"),description:"Ctrl+<",execute:e=>e.model.dispatch("CLEAR_FORMATTING",{sheetId:e.model.getters.getActiveSheetId(),target:e.model.getters.getSelectedZones()}),icon:"o-spreadsheet-Icon.CLEAR_FORMAT"};function Jv(e){const t=e.model.getters.getCurrentStyle();if(t.align)return t.align;return e.model.getters.getActiveCell().defaultAlign}function eS(e){const t=e.model.getters.getCurrentStyle();return t.verticalAlign?t.verticalAlign:te}function tS(e){const t=e.model.getters.getCurrentStyle();return t.wrapping?t.wrapping:oe}var oS=Object.freeze({__proto__:null,clearFormat:Qv,decraseDecimalPlaces:Ov,fillColor:Xv,formatAlignment:Lv,formatAlignmentBottom:Gv,formatAlignmentCenter:kv,formatAlignmentHorizontal:Pv,formatAlignmentLeft:Vv,formatAlignmentMiddle:zv,formatAlignmentRight:Uv,formatAlignmentTop:Hv,formatAlignmentVertical:Bv,formatBold:_v,formatCF:Kv,formatCustomCurrency:mv,formatFontSize:Dv,formatItalic:Mv,formatNumberAutomatic:av,formatNumberCurrency:dv,formatNumberCurrencyRounded:uv,formatNumberDate:fv,formatNumberDateTime:vv,formatNumberDayAndFullMonth:wv,formatNumberDayAndShortMonth:Iv,formatNumberDuration:Sv,formatNumberFullDateTime:Ev,formatNumberFullMonth:Rv,formatNumberFullWeekDayAndMonth:yv,formatNumberNumber:lv,formatNumberPercent:hv,formatNumberShortMonth:Tv,formatNumberShortWeekDay:xv,formatNumberTime:bv,formatPercent:cv,formatStrikethrough:Fv,formatUnderline:Nv,formatWrapping:Wv,formatWrappingClip:Yv,formatWrappingIcon:$v,formatWrappingOverflow:qv,formatWrappingWrap:Zv,incraseDecimalPlaces:Av,moreFormats:Cv,textColor:jv});const sS=new Pa;sS.add("cut",{...lc,sequence:10}).add("copy",{...ac,sequence:20}).add("paste",{...cc,sequence:30}).add("paste_special",{...hc,sequence:40,separator:!0}).addChild("paste_value_only",["paste_special"],{...dc,sequence:10}).addChild("paste_format_only",["paste_special"],{...uc,sequence:20}).add("sort_columns",{...Qb,name:e=>e.model.getters.getActiveCols().size>1?a("Sort columns"):a("Sort column"),sequence:50,separator:!0}).addChild("sort_ascending",["sort_columns"],{...Jb,sequence:10}).addChild("sort_descending",["sort_columns"],{...sv,sequence:20}).add("add_column_before",{...Kf,sequence:70}).add("add_column_after",{...eb,sequence:80}).add("delete_column",{...vc,sequence:90,icon:"o-spreadsheet-Icon.DELETE"}).add("clear_column",{...Cc,sequence:100,icon:"o-spreadsheet-Icon.CLEAR"}).add("hide_columns",{...yb,sequence:105,separator:!0}).add("unhide_columns",{...wb,sequence:106,separator:!0}).add("conditional_formatting",{...Kv,sequence:110,separator:!0}).add("group_columns",{sequence:120,...Hb}).add("ungroup_columns",{sequence:130,...Gb,isVisible:e=>Xb(e,"COL")});const nS=new Pa;nS.add("format_number_automatic",{...av,sequence:10,separator:!0}).add("format_number_number",{...lv,sequence:20}).add("format_number_percent",{...hv,sequence:30,separator:!0}).add("format_number_currency",{...dv,sequence:40}).add("format_number_currency_rounded",{...uv,sequence:50}).add("format_custom_currency",{...mv,sequence:60,separator:!0}).add("format_number_date",{...fv,sequence:70}).add("format_number_time",{...bv,sequence:80}).add("format_number_date_time",{...vv,sequence:90}).add("format_number_duration",{...Sv,sequence:100,separator:!0}).add("more_formats",{...Cv,sequence:110});const iS={name:a("More formats"),icon:"o-spreadsheet-Icon.NUMBER_FORMATS",children:[()=>nS.getAll()]},rS=new Pa;rS.add("cut",{...lc,sequence:10}).add("copy",{...ac,sequence:20}).add("paste",{...cc,sequence:30}).add("paste_special",{...hc,sequence:40,separator:!0}).addChild("paste_value_only",["paste_special"],{...dc,sequence:10}).addChild("paste_format_only",["paste_special"],{...uc,sequence:20}).add("add_row_before",{...Wf,sequence:50}).add("add_row_after",{...Yf,sequence:60}).add("delete_row",{...mc,sequence:70,icon:"o-spreadsheet-Icon.DELETE"}).add("clear_row",{...bc,sequence:80,icon:"o-spreadsheet-Icon.CLEAR"}).add("hide_rows",{...Ib,sequence:85,separator:!0}).add("unhide_rows",{...Rb,sequence:86,separator:!0}).add("conditional_formatting",{...Kv,sequence:90,separator:!0}).add("group_rows",{sequence:100,...zb}).add("ungroup_rows",{sequence:110,...$b,isVisible:e=>Xb(e,"ROW")});const aS=new Pa;aS.add("file",{name:a("File"),sequence:10}).addChild("settings",["file"],{name:a("Settings"),sequence:100,execute:e=>e.openSidePanel("Settings"),icon:"o-spreadsheet-Icon.COG"}).add("edit",{name:a("Edit"),sequence:20}).addChild("undo",["edit"],{...ic,sequence:10}).addChild("redo",["edit"],{...rc,sequence:20,separator:!0}).addChild("copy",["edit"],{...ac,sequence:30}).addChild("cut",["edit"],{...lc,sequence:40}).addChild("paste",["edit"],{...cc,sequence:50}).addChild("paste_special",["edit"],{...hc,sequence:60,separator:!0}).addChild("paste_special_value",["edit","paste_special"],{...dc,sequence:10}).addChild("paste_special_format",["edit","paste_special"],{...uc,sequence:20}).addChild("find_and_replace",["edit"],{...gc,sequence:65,separator:!0}).addChild("delete",["edit"],{name:a("Delete"),icon:"o-spreadsheet-Icon.DELETE",sequence:70}).addChild("edit_delete_cell_values",["edit","delete"],{...pc,sequence:10}).addChild("edit_delete_row",["edit","delete"],{...mc,sequence:20}).addChild("edit_delete_column",["edit","delete"],{...vc,sequence:30}).addChild("edit_delete_cell_shift_up",["edit","delete"],{...yc,sequence:40}).addChild("edit_delete_cell_shift_left",["edit","delete"],{...wc,sequence:50}).addChild("edit_unhide_columns",["edit"],{...xb,sequence:80}).addChild("edit_unhide_rows",["edit"],{...Tb,sequence:80}).add("view",{name:a("View"),sequence:30}).addChild("unfreeze_panes",["view"],{...Ab,sequence:4}).addChild("freeze_panes",["view"],{...Ob,sequence:5}).addChild("unfreeze_rows",["view","freeze_panes"],{..._b,sequence:5}).addChild("freeze_first_row",["view","freeze_panes"],{...Mb,sequence:10}).addChild("freeze_second_row",["view","freeze_panes"],{...Nb,sequence:15}).addChild("freeze_current_row",["view","freeze_panes"],{...Fb,sequence:20,separator:!0}).addChild("unfreeze_columns",["view","freeze_panes"],{...Db,sequence:25}).addChild("freeze_first_col",["view","freeze_panes"],{...Lb,sequence:30}).addChild("freeze_second_col",["view","freeze_panes"],{...Pb,sequence:35}).addChild("freeze_current_col",["view","freeze_panes"],{...Vb,sequence:40}).addChild("group_headers",["view"],{name:a("Group"),sequence:15,separator:!0,icon:"o-spreadsheet-Icon.PLUS_IN_BOX",isVisible:sc}).addChild("group_columns",["view","group_headers"],{...Hb,sequence:5}).addChild("ungroup_columns",["view","group_headers"],{...Gb,isVisible:e=>Xb(e,"COL"),sequence:10}).addChild("group_rows",["view","group_headers"],{...zb,sequence:15}).addChild("ungroup_rows",["view","group_headers"],{...$b,isVisible:e=>Xb(e,"ROW"),sequence:20}).addChild("view_gridlines",["view"],{...kb,sequence:15}).addChild("view_formulas",["view"],{...Ub,sequence:20}).add("insert",{name:a("Insert"),sequence:40}).addChild("insert_row",["insert"],{...$f,sequence:10}).addChild("insert_row_before",["insert","insert_row"],{...qf,sequence:10}).addChild("insert_row_after",["insert","insert_row"],{...jf,sequence:20}).addChild("insert_column",["insert"],{...Xf,sequence:20}).addChild("insert_column_before",["insert","insert_column"],{...Qf,sequence:10}).addChild("insert_column_after",["insert","insert_column"],{...tb,sequence:20}).addChild("insert_cell",["insert"],{...ob,sequence:43}).addChild("insert_cell_down",["insert","insert_cell"],{...sb,name:a("Shift down"),sequence:10}).addChild("insert_cell_right",["insert","insert_cell"],{...nb,name:a("Shift right"),sequence:20}).addChild("insert_sheet",["insert"],{...mb,sequence:80,separator:!0}).addChild("insert_chart",["insert"],{...ib,sequence:50}).addChild("insert_image",["insert"],{...rb,sequence:55}).addChild("insert_function",["insert"],{...ab,sequence:60}).addChild("insert_function_sum",["insert","insert_function"],{...lb,sequence:0}).addChild("insert_function_average",["insert","insert_function"],{...cb,sequence:10}).addChild("insert_function_count",["insert","insert_function"],{...hb,sequence:20}).addChild("insert_function_max",["insert","insert_function"],{...db,sequence:30}).addChild("insert_function_min",["insert","insert_function"],{...ub,sequence:40,separator:!0}).addChild("categorie_function_all",["insert","insert_function"],{...gb,sequence:50}).addChild("categories_function_list",["insert","insert_function"],(()=>{const e=Gf.content;return[...new Set(Gf.getAll().filter((e=>!e.hidden)).map((e=>e.category)))].filter(We).sort().map(((t,o)=>{const s=Object.keys(e).filter((o=>e[o].category===t&&!e[o].hidden));return{name:t,children:fb(s)}}))})).addChild("insert_link",["insert"],{...pb,separator:!0,sequence:70}).add("format",{name:a("Format"),sequence:50}).addChild("format_number",["format"],{...iS,name:a("Number"),sequence:10,separator:!0}).addChild("format_bold",["format"],{..._v,sequence:20}).addChild("format_italic",["format"],{...Mv,sequence:30}).addChild("format_underline",["format"],{...Nv,sequence:40}).addChild("format_strikethrough",["format"],{...Fv,sequence:50,separator:!0}).addChild("format_font_size",["format"],{...Dv,sequence:60,separator:!0}).addChild("format_alignment",["format"],{...Lv,sequence:70}).addChild("format_alignment_left",["format","format_alignment"],{...Vv,sequence:10}).addChild("format_alignment_center",["format","format_alignment"],{...kv,sequence:20}).addChild("format_alignment_right",["format","format_alignment"],{...Uv,sequence:30,separator:!0}).addChild("format_alignment_top",["format","format_alignment"],{...Hv,sequence:40}).addChild("format_alignment_middle",["format","format_alignment"],{...zv,sequence:50}).addChild("format_alignment_bottom",["format","format_alignment"],{...Gv,sequence:60,separator:!0}).addChild("format_wrapping",["format"],{...$v,sequence:80,separator:!0}).addChild("format_wrapping_overflow",["format","format_wrapping"],{...qv,sequence:10}).addChild("format_wrapping_wrap",["format","format_wrapping"],{...Zv,sequence:20}).addChild("format_wrapping_clip",["format","format_wrapping"],{...Yv,sequence:30}).addChild("format_cf",["format"],{...Kv,sequence:90,separator:!0}).addChild("format_clearFormat",["format"],{...Qv,sequence:100,separator:!0}).add("data",{name:a("Data"),sequence:60}).addChild("sort_range",["data"],{...Qb,sequence:10,separator:!0}).addChild("sort_ascending",["data","sort_range"],{...Jb,sequence:10}).addChild("sort_descending",["data","sort_range"],{...sv,sequence:20}).addChild("data_cleanup",["data"],{...ev,sequence:15}).addChild("remove_duplicates",["data","data_cleanup"],{...tv,sequence:10}).addChild("trim_whitespace",["data","data_cleanup"],{...ov,sequence:20}).addChild("split_to_columns",["data"],{...iv,sequence:20}).addChild("data_validation",["data"],{name:a("Data Validation"),execute:e=>{e.openSidePanel("DataValidation")},icon:"o-spreadsheet-Icon.DATA_VALIDATION",sequence:30,separator:!0}).addChild("add_remove_data_filter",["data"],{...nv,sequence:40,separator:!0});const lS=new class extends Zi{addTransformation(e,t,o){this.content[e]||(this.content[e]=new Map);for(const s of t)this.content[e].set(s,o);return this}getTransformation(e,t){return this.content[t]&&this.content[t].get(e)}},cS={ArrowDown:"down",ArrowLeft:"left",ArrowRight:"right",ArrowUp:"up"};function hS(e,t){const o=cS[e.key];e.shiftKey?t.resizeAnchorZone(o,Vr(e)?"end":1):t.moveAnchorCell(o,Vr(e)?"end":1)}const dS=new li;Sr`
290
290
  .o-selection {
291
291
  .o-selection-input {
292
292
  padding: 2px 0px;
@@ -2657,4 +2657,4 @@
2657
2657
  <tableParts count="${e.filterTables.length}">
2658
2658
  ${lx(a)}
2659
2659
  </tableParts>
2660
- `}var XT;!function(e){e[e.Ready=0]="Ready",e[e.Running=1]="Running",e[e.RunningCore=2]="RunningCore",e[e.Finalizing=3]="Finalizing"}(XT||(XT={}));function KT(e,t={}){const o=Ae(t);return o.type=e,o}const QT={},JT={MIN_ROW_HEIGHT:10,MIN_COL_WIDTH:5,HEADER_HEIGHT:B,HEADER_WIDTH:H,TOPBAR_HEIGHT:63,BOTTOMBAR_HEIGHT:36,DEFAULT_CELL_WIDTH:z,DEFAULT_CELL_HEIGHT:G,SCROLLBAR_WIDTH:$},eA={autofillModifiersRegistry:hr,autofillRulesRegistry:dr,cellMenuRegistry:Sb,colMenuRegistry:sS,linkMenuRegistry:Va,functionRegistry:Gf,featurePluginRegistry:SR,statefulUIPluginRegistry:CR,coreViewsPluginRegistry:ER,corePluginRegistry:vR,rowMenuRegistry:rS,sidePanelRegistry:bC,figureRegistry:Vl,chartSidePanelComponentRegistry:AS,chartComponentRegistry:Nl,chartRegistry:Ml,topbarMenuRegistry:aS,topbarComponentRegistry:vC,clickableCellRegistry:yR,otRegistry:lS,inverseCommandRegistry:Hl,urlRegistry:ji,cellPopoverRegistry:Ba,numberFormatMenuRegistry:nS,repeatLocalCommandTransformRegistry:nR,repeatCommandTransformRegistry:sR},tA={arg:_c,toBoolean:Zo,toJsDate:Yo,toNumber:Vo,toString:$o,toXC:Lt,toZone:gn,toUnboundedZone:un,toCartesian:Dt,numberToLetters:Ot,lettersToNumber:Mt,UuidGenerator:li,formatValue:Ts,createCurrencyFormat:Gs,computeTextWidth:Jn,createEmptyWorkbookData:Lx,createEmptySheet:Dx,createEmptyExcelSheet:Px,getDefaultChartJsRuntime:nl,chartFontColor:Ti,ChartColors:Ri,EvaluationError:d,CellErrorLevel:h,getFillingMode:cl,rgbaToHex:wt,colorToRGBA:xt,positionToZone:Ln,isDefined:We,isMatrix:Mo,lazy:Xe,genericRepeat:iR,createAction:di,createActions:ci,transformRangeData:gi,deepEquals:Je,isNumber:go,isDateTime:jt},oA={isMarkdownLink:Ve,parseMarkdownLink:Be,markdownLink:Ue,openLink:er,urlRepresentation:Ji},sA={ChartPanel:OS,ChartFigure:Dl,ChartJsComponent:pi,Grid:wE,GridOverlay:aE,ScorecardChart:qi,LineConfigPanel:IS,LineBarPieDesignPanel:yS,BarConfigPanel:mS,LineBarPieConfigPanel:pS,GaugeChartConfigPanel:wS,GaugeChartDesignPanel:xS,ScorecardChartConfigPanel:RS,ScorecardChartDesignPanel:TS,FigureComponent:SC,Menu:Zr,SelectionInput:uS},nA={useDragAndDropListItems:DS};const iA={DEFAULT_LOCALE:Oo};e.AbstractChart=mi,e.CorePlugin=kx,e.DispatchResult=Io,e.EvaluationError=d,e.Model=class extends NI{corePlugins=[];featurePlugins=[];statefulUIPlugins=[];coreViewsPlugins=[];range;session;isReplayingCommand=!1;renderers=[];status=0;config;corePluginConfig;uiPluginConfig;state;selection;getters;coreGetters;uuidGenerator;handlers=[];uiHandlers=[];coreHandlers=[];constructor(e={},r={},a=[],l=new li,c=!0){super(),n===o&&i===s&&(i=()=>!0),a=Mx(e,a);const h=Ox(e,c);this.state=new aT,this.uuidGenerator=l,this.config=this.setupConfig(r),this.session=this.setupSession(h.revisionId),this.coreGetters={},this.range=new Jx(this.coreGetters),this.coreGetters.getRangeString=this.range.getRangeString.bind(this.range),this.coreGetters.getRangeFromSheetXC=this.range.getRangeFromSheetXC.bind(this.range),this.coreGetters.createAdaptedRanges=this.range.createAdaptedRanges.bind(this.range),this.coreGetters.getRangeDataFromXc=this.range.getRangeDataFromXc.bind(this.range),this.coreGetters.getRangeDataFromZone=this.range.getRangeDataFromZone.bind(this.range),this.coreGetters.getRangeFromRangeData=this.range.getRangeFromRangeData.bind(this.range),this.coreGetters.getRangeFromZone=this.range.getRangeFromZone.bind(this.range),this.getters={isReadonly:()=>"readonly"===this.config.mode||"dashboard"===this.config.mode,isDashboard:()=>"dashboard"===this.config.mode},this.uuidGenerator.setIsFastStrategy(!0),this.selection=new rT(this.getters),this.coreHandlers.push(this.range),this.handlers.push(this.range),this.corePluginConfig=this.setupCorePluginConfig(),this.uiPluginConfig=this.setupUiPluginConfig();for(let e of vR.getAll())this.setupCorePlugin(e,h);Object.assign(this.getters,this.coreGetters),this.session.loadInitialMessages(a);for(let e of ER.getAll()){const t=this.setupUiPlugin(e);this.coreViewsPlugins.push(t),this.handlers.push(t),this.uiHandlers.push(t),this.coreHandlers.push(t)}for(let e of CR.getAll()){const t=this.setupUiPlugin(e);this.statefulUIPlugins.push(t),this.handlers.push(t),this.uiHandlers.push(t)}for(let e of SR.getAll()){const t=this.setupUiPlugin(e);this.featurePlugins.push(t),this.handlers.push(t),this.uiHandlers.push(t)}this.uuidGenerator.setIsFastStrategy(!1),this.dispatch("START"),this.selection.observe(this,{handleEvent:()=>this.trigger("update")}),this.setupSessionEvents(),this.joinSession(),r.snapshotRequested&&(this.session.snapshot(this.exportData()),this.garbageCollectExternalResources()),t.markRaw(this)}joinSession(){this.session.join(this.config.client)}async leaveSession(){const e=this.getters.isReadonly()?void 0:Xe((()=>this.exportData()));await this.session.leave(e)}setupUiPlugin(e){const t=new e(this.uiPluginConfig);for(let o of e.getters){if(!(o in t))throw new Error(`Invalid getter name: ${o} for plugin ${t.constructor}`);if(o in this.getters)throw new Error(`Getter "${o}" is already defined.`);this.getters[o]=t[o].bind(t)}const o=e.layers.map((e=>[t,e]));return this.renderers.push(...o),this.renderers.sort(((e,t)=>e[1]-t[1])),t}setupCorePlugin(e,t){const o=new e(this.corePluginConfig);for(let t of e.getters){if(!(t in o))throw new Error(`Invalid getter name: ${t} for plugin ${o.constructor}`);if(t in this.coreGetters)throw new Error(`Getter "${t}" is already defined.`);this.coreGetters[t]=o[t].bind(o)}o.import(t),this.corePlugins.push(o),this.coreHandlers.push(o),this.handlers.push(o)}onRemoteRevisionReceived({commands:e}){for(let t of e){const e=this.status;this.status=2,this.dispatchToHandlers(this.statefulUIPlugins,t),this.status=e}this.finalize()}setupSession(e){return new GI(sT({initialRevisionId:e,recordChanges:this.state.recordChanges.bind(this.state),dispatch:e=>{this.checkDispatchAllowed(e).isSuccessful?(this.isReplayingCommand=!0,this.dispatchToHandlers(this.coreHandlers,e),this.isReplayingCommand=!1):this.dispatchToHandlers(this.coreHandlers,{type:"UNDO",commands:[e]})}}),this.config.transportService,e)}setupSessionEvents(){this.session.on("remote-revision-received",this,this.onRemoteRevisionReceived),this.session.on("revision-undone",this,(({commands:e})=>{this.dispatchFromCorePlugin("UNDO",{commands:e}),this.finalize()})),this.session.on("revision-redone",this,(({commands:e})=>{this.dispatchFromCorePlugin("REDO",{commands:e}),this.finalize()})),this.session.on("unexpected-revision-id",this,(()=>this.trigger("unexpected-revision-id"))),this.session.on("collaborative-event-received",this,(()=>{this.trigger("update")}))}setupConfig(e){const t=e.client||{id:this.uuidGenerator.smallUuid(),name:a("Anonymous").toString()},o=e.transportService||new YR;return{...e,mode:e.mode||"normal",custom:e.custom||{},external:this.setupExternalConfig(e.external||{}),transportService:o,client:t,moveClient:()=>{},snapshotRequested:!1,notifyUI:e=>this.trigger("notify-ui",e),raiseBlockingErrorUI:e=>this.trigger("raise-error-ui",{text:e})}}setupExternalConfig(e){const t=e.loadLocales||(()=>Promise.resolve(Ao));return{...e,loadLocales:t}}setupCorePluginConfig(){return{getters:this.coreGetters,stateObserver:this.state,range:this.range,dispatch:this.dispatchFromCorePlugin,uuidGenerator:this.uuidGenerator,custom:this.config.custom,external:this.config.external}}setupUiPluginConfig(){return{getters:this.getters,stateObserver:this.state,dispatch:this.dispatch,selection:this.selection,moveClient:this.session.move.bind(this.session),custom:this.config.custom,uiActions:this.config,session:this.session,defaultCurrencyFormat:this.config.defaultCurrencyFormat}}checkDispatchAllowed(e){const t=xo(e)?this.checkDispatchAllowedCoreCommand(e):this.checkDispatchAllowedLocalCommand(e);return t.some((e=>"Success"!==e))?new Io(t.flat()):Io.Success}checkDispatchAllowedCoreCommand(e){const t=this.corePlugins.map((t=>t.allowDispatch(e)));return t.push(this.range.allowDispatch(e)),t}checkDispatchAllowedLocalCommand(e){return this.uiHandlers.map((t=>t.allowDispatch(e)))}finalize(){this.status=3;for(const e of this.handlers)e.finalize();this.status=0}canDispatch=(e,t)=>this.checkDispatchAllowed(KT(e,t));dispatch=(e,t)=>{const o=KT(e,t);let s=this.status;if(this.getters.isReadonly()&&(n=o,!yo.has(n.type)))return new Io("Readonly");var n;if(!this.session.canApplyOptimisticUpdate())return new Io("WaitingSessionConfirmation");switch(s){case 0:const t=this.checkDispatchAllowed(o);if(!t.isSuccessful)return t;this.status=1;const{changes:s,commands:n}=this.state.recordChanges((()=>{xo(o)&&this.state.addCommand(o),this.dispatchToHandlers(this.handlers,o),this.finalize()}));this.session.save(o,n,s),this.status=0,this.trigger("update");break;case 1:if(xo(o)){const e=this.checkDispatchAllowed(o);if(!e.isSuccessful)return e;this.state.addCommand(o)}this.dispatchToHandlers(this.handlers,o);break;case 3:throw new Error("Cannot dispatch commands in the finalize state");case 2:if(xo(o))throw new Error(`A UI plugin cannot dispatch ${e} while handling a core command`);this.dispatchToHandlers(this.handlers,o)}return Io.Success};dispatchFromCorePlugin=(e,t)=>{const o=KT(e,t),s=this.status;this.status=2;const n=this.isReplayingCommand?this.coreHandlers:this.handlers;return this.dispatchToHandlers(n,o),this.status=s,Io.Success};dispatchToHandlers(e,t){const o=xo(t);for(const s of e)!o&&s instanceof kx||s.beforeHandle(t);for(const s of e)!o&&s instanceof kx||s.handle(t)}drawGrid(e){for(let[t,o]of this.renderers)e.ctx.save(),t.drawGrid(e,o),e.ctx.restore()}exportData(){let e=Lx();for(let t of this.handlers)t instanceof kx&&t.export(e);return e.revisionId=this.session.getRevisionId()||he,e=Ae(e),e}updateMode(e){"normal"!==e&&this.dispatch("CANCEL_EDITION"),this.config.mode=e,this.trigger("update")}exportXLSX(){this.dispatch("EVALUATE_CELLS");let e={...Lx(),sheets:[Px(Ax,"Sheet1")]};for(let t of this.handlers)t instanceof Vx&&t.exportForExcel(e);return e=Ae(e),YT(e)}garbageCollectExternalResources(){for(const e of this.corePlugins)e.garbageCollectExternalResources()}},e.Registry=Zi,e.Revision=HI,e.SPREADSHEET_DIMENSIONS=JT,e.Spreadsheet=ZR,e.UIPlugin=eI,e.__info__=QT,e.addFunction=function e(t,o){return Gf.add(t,o),{addFunction:(t,o)=>e(t,o)}},e.astToFormula=fy,e.compile=wy,e.compileTokens=xy,e.components=sA,e.constants=iA,e.convertAstNodes=uy,e.coreTypes=wo,e.findCellInNewZone=Fn,e.functionCache=yy,e.helpers=tA,e.hooks=nA,e.invalidateCFEvaluationCommands=Eo,e.invalidateDependenciesCommands=Co,e.invalidateEvaluationCommands=So,e.iterateAstNodes=gy,e.links=oA,e.load=Ox,e.parse=hy,e.parseTokens=dy,e.readonlyAllowedCommands=yo,e.registries=eA,e.setDefaultSheetViewSize=function(e){ye=e},e.setTranslationMethod=function(e,t=(()=>!0)){n=e,i=t},e.tokenize=Qr,QT.version="17.0.73",QT.date="2025-09-11T08:40:46.367Z",QT.hash="a11c622"}(this.o_spreadsheet=this.o_spreadsheet||{},owl);
2660
+ `}var XT;!function(e){e[e.Ready=0]="Ready",e[e.Running=1]="Running",e[e.RunningCore=2]="RunningCore",e[e.Finalizing=3]="Finalizing"}(XT||(XT={}));function KT(e,t={}){const o=Ae(t);return o.type=e,o}const QT={},JT={MIN_ROW_HEIGHT:10,MIN_COL_WIDTH:5,HEADER_HEIGHT:B,HEADER_WIDTH:H,TOPBAR_HEIGHT:63,BOTTOMBAR_HEIGHT:36,DEFAULT_CELL_WIDTH:z,DEFAULT_CELL_HEIGHT:G,SCROLLBAR_WIDTH:$},eA={autofillModifiersRegistry:hr,autofillRulesRegistry:dr,cellMenuRegistry:Sb,colMenuRegistry:sS,linkMenuRegistry:Va,functionRegistry:Gf,featurePluginRegistry:SR,statefulUIPluginRegistry:CR,coreViewsPluginRegistry:ER,corePluginRegistry:vR,rowMenuRegistry:rS,sidePanelRegistry:bC,figureRegistry:Vl,chartSidePanelComponentRegistry:AS,chartComponentRegistry:Nl,chartRegistry:Ml,topbarMenuRegistry:aS,topbarComponentRegistry:vC,clickableCellRegistry:yR,otRegistry:lS,inverseCommandRegistry:Hl,urlRegistry:ji,cellPopoverRegistry:Ba,numberFormatMenuRegistry:nS,repeatLocalCommandTransformRegistry:nR,repeatCommandTransformRegistry:sR},tA={arg:_c,toBoolean:Zo,toJsDate:Yo,toNumber:Vo,toString:$o,toXC:Lt,toZone:gn,toUnboundedZone:un,toCartesian:Dt,numberToLetters:Ot,lettersToNumber:Mt,UuidGenerator:li,formatValue:Ts,createCurrencyFormat:Gs,computeTextWidth:Jn,createEmptyWorkbookData:Lx,createEmptySheet:Dx,createEmptyExcelSheet:Px,getDefaultChartJsRuntime:nl,chartFontColor:Ti,ChartColors:Ri,EvaluationError:d,CellErrorLevel:h,getFillingMode:cl,rgbaToHex:wt,colorToRGBA:xt,positionToZone:Ln,isDefined:We,isMatrix:Mo,lazy:Xe,genericRepeat:iR,createAction:di,createActions:ci,transformRangeData:gi,deepEquals:Je,isNumber:go,isDateTime:jt},oA={isMarkdownLink:Ve,parseMarkdownLink:Be,markdownLink:Ue,openLink:er,urlRepresentation:Ji},sA={ChartPanel:OS,ChartFigure:Dl,ChartJsComponent:pi,Grid:wE,GridOverlay:aE,ScorecardChart:qi,LineConfigPanel:IS,LineBarPieDesignPanel:yS,BarConfigPanel:mS,LineBarPieConfigPanel:pS,GaugeChartConfigPanel:wS,GaugeChartDesignPanel:xS,ScorecardChartConfigPanel:RS,ScorecardChartDesignPanel:TS,FigureComponent:SC,Menu:Zr,SelectionInput:uS},nA={useDragAndDropListItems:DS};const iA={DEFAULT_LOCALE:Oo};e.AbstractChart=mi,e.CorePlugin=kx,e.DispatchResult=Io,e.EvaluationError=d,e.Model=class extends NI{corePlugins=[];featurePlugins=[];statefulUIPlugins=[];coreViewsPlugins=[];range;session;isReplayingCommand=!1;renderers=[];status=0;config;corePluginConfig;uiPluginConfig;state;selection;getters;coreGetters;uuidGenerator;handlers=[];uiHandlers=[];coreHandlers=[];constructor(e={},r={},a=[],l=new li,c=!0){super(),n===o&&i===s&&(i=()=>!0),a=Mx(e,a);const h=Ox(e,c);this.state=new aT,this.uuidGenerator=l,this.config=this.setupConfig(r),this.session=this.setupSession(h.revisionId),this.coreGetters={},this.range=new Jx(this.coreGetters),this.coreGetters.getRangeString=this.range.getRangeString.bind(this.range),this.coreGetters.getRangeFromSheetXC=this.range.getRangeFromSheetXC.bind(this.range),this.coreGetters.createAdaptedRanges=this.range.createAdaptedRanges.bind(this.range),this.coreGetters.getRangeDataFromXc=this.range.getRangeDataFromXc.bind(this.range),this.coreGetters.getRangeDataFromZone=this.range.getRangeDataFromZone.bind(this.range),this.coreGetters.getRangeFromRangeData=this.range.getRangeFromRangeData.bind(this.range),this.coreGetters.getRangeFromZone=this.range.getRangeFromZone.bind(this.range),this.getters={isReadonly:()=>"readonly"===this.config.mode||"dashboard"===this.config.mode,isDashboard:()=>"dashboard"===this.config.mode},this.uuidGenerator.setIsFastStrategy(!0),this.selection=new rT(this.getters),this.coreHandlers.push(this.range),this.handlers.push(this.range),this.corePluginConfig=this.setupCorePluginConfig(),this.uiPluginConfig=this.setupUiPluginConfig();for(let e of vR.getAll())this.setupCorePlugin(e,h);Object.assign(this.getters,this.coreGetters),this.session.loadInitialMessages(a);for(let e of ER.getAll()){const t=this.setupUiPlugin(e);this.coreViewsPlugins.push(t),this.handlers.push(t),this.uiHandlers.push(t),this.coreHandlers.push(t)}for(let e of CR.getAll()){const t=this.setupUiPlugin(e);this.statefulUIPlugins.push(t),this.handlers.push(t),this.uiHandlers.push(t)}for(let e of SR.getAll()){const t=this.setupUiPlugin(e);this.featurePlugins.push(t),this.handlers.push(t),this.uiHandlers.push(t)}this.uuidGenerator.setIsFastStrategy(!1),this.dispatch("START"),this.selection.observe(this,{handleEvent:()=>this.trigger("update")}),this.setupSessionEvents(),this.joinSession(),r.snapshotRequested&&(this.session.snapshot(this.exportData()),this.garbageCollectExternalResources()),t.markRaw(this)}joinSession(){this.session.join(this.config.client)}async leaveSession(){const e=this.getters.isReadonly()?void 0:Xe((()=>this.exportData()));await this.session.leave(e)}setupUiPlugin(e){const t=new e(this.uiPluginConfig);for(let o of e.getters){if(!(o in t))throw new Error(`Invalid getter name: ${o} for plugin ${t.constructor}`);if(o in this.getters)throw new Error(`Getter "${o}" is already defined.`);this.getters[o]=t[o].bind(t)}const o=e.layers.map((e=>[t,e]));return this.renderers.push(...o),this.renderers.sort(((e,t)=>e[1]-t[1])),t}setupCorePlugin(e,t){const o=new e(this.corePluginConfig);for(let t of e.getters){if(!(t in o))throw new Error(`Invalid getter name: ${t} for plugin ${o.constructor}`);if(t in this.coreGetters)throw new Error(`Getter "${t}" is already defined.`);this.coreGetters[t]=o[t].bind(o)}o.import(t),this.corePlugins.push(o),this.coreHandlers.push(o),this.handlers.push(o)}onRemoteRevisionReceived({commands:e}){for(let t of e){const e=this.status;this.status=2,this.dispatchToHandlers(this.statefulUIPlugins,t),this.status=e}this.finalize()}setupSession(e){return new GI(sT({initialRevisionId:e,recordChanges:this.state.recordChanges.bind(this.state),dispatch:e=>{this.checkDispatchAllowed(e).isSuccessful?(this.isReplayingCommand=!0,this.dispatchToHandlers(this.coreHandlers,e),this.isReplayingCommand=!1):this.dispatchToHandlers(this.coreHandlers,{type:"UNDO",commands:[e]})}}),this.config.transportService,e)}setupSessionEvents(){this.session.on("remote-revision-received",this,this.onRemoteRevisionReceived),this.session.on("revision-undone",this,(({commands:e})=>{this.dispatchFromCorePlugin("UNDO",{commands:e}),this.finalize()})),this.session.on("revision-redone",this,(({commands:e})=>{this.dispatchFromCorePlugin("REDO",{commands:e}),this.finalize()})),this.session.on("unexpected-revision-id",this,(()=>this.trigger("unexpected-revision-id"))),this.session.on("collaborative-event-received",this,(()=>{this.trigger("update")}))}setupConfig(e){const t=e.client||{id:this.uuidGenerator.smallUuid(),name:a("Anonymous").toString()},o=e.transportService||new YR;return{...e,mode:e.mode||"normal",custom:e.custom||{},external:this.setupExternalConfig(e.external||{}),transportService:o,client:t,moveClient:()=>{},snapshotRequested:!1,notifyUI:e=>this.trigger("notify-ui",e),raiseBlockingErrorUI:e=>this.trigger("raise-error-ui",{text:e})}}setupExternalConfig(e){const t=e.loadLocales||(()=>Promise.resolve(Ao));return{...e,loadLocales:t}}setupCorePluginConfig(){return{getters:this.coreGetters,stateObserver:this.state,range:this.range,dispatch:this.dispatchFromCorePlugin,uuidGenerator:this.uuidGenerator,custom:this.config.custom,external:this.config.external}}setupUiPluginConfig(){return{getters:this.getters,stateObserver:this.state,dispatch:this.dispatch,selection:this.selection,moveClient:this.session.move.bind(this.session),custom:this.config.custom,uiActions:this.config,session:this.session,defaultCurrencyFormat:this.config.defaultCurrencyFormat}}checkDispatchAllowed(e){const t=xo(e)?this.checkDispatchAllowedCoreCommand(e):this.checkDispatchAllowedLocalCommand(e);return t.some((e=>"Success"!==e))?new Io(t.flat()):Io.Success}checkDispatchAllowedCoreCommand(e){const t=this.corePlugins.map((t=>t.allowDispatch(e)));return t.push(this.range.allowDispatch(e)),t}checkDispatchAllowedLocalCommand(e){return this.uiHandlers.map((t=>t.allowDispatch(e)))}finalize(){this.status=3;for(const e of this.handlers)e.finalize();this.status=0}canDispatch=(e,t)=>this.checkDispatchAllowed(KT(e,t));dispatch=(e,t)=>{const o=KT(e,t);let s=this.status;if(this.getters.isReadonly()&&(n=o,!yo.has(n.type)))return new Io("Readonly");var n;if(!this.session.canApplyOptimisticUpdate())return new Io("WaitingSessionConfirmation");switch(s){case 0:const t=this.checkDispatchAllowed(o);if(!t.isSuccessful)return t;this.status=1;const{changes:s,commands:n}=this.state.recordChanges((()=>{xo(o)&&this.state.addCommand(o),this.dispatchToHandlers(this.handlers,o),this.finalize()}));this.session.save(o,n,s),this.status=0,this.trigger("update");break;case 1:if(xo(o)){const e=this.checkDispatchAllowed(o);if(!e.isSuccessful)return e;this.state.addCommand(o)}this.dispatchToHandlers(this.handlers,o);break;case 3:throw new Error("Cannot dispatch commands in the finalize state");case 2:if(xo(o))throw new Error(`A UI plugin cannot dispatch ${e} while handling a core command`);this.dispatchToHandlers(this.handlers,o)}return Io.Success};dispatchFromCorePlugin=(e,t)=>{const o=KT(e,t),s=this.status;this.status=2;const n=this.isReplayingCommand?this.coreHandlers:this.handlers;return this.dispatchToHandlers(n,o),this.status=s,Io.Success};dispatchToHandlers(e,t){const o=xo(t);for(const s of e)!o&&s instanceof kx||s.beforeHandle(t);for(const s of e)!o&&s instanceof kx||s.handle(t)}drawGrid(e){for(let[t,o]of this.renderers)e.ctx.save(),t.drawGrid(e,o),e.ctx.restore()}exportData(){let e=Lx();for(let t of this.handlers)t instanceof kx&&t.export(e);return e.revisionId=this.session.getRevisionId()||he,e=Ae(e),e}updateMode(e){"normal"!==e&&this.dispatch("CANCEL_EDITION"),this.config.mode=e,this.trigger("update")}exportXLSX(){this.dispatch("EVALUATE_CELLS");let e={...Lx(),sheets:[Px(Ax,"Sheet1")]};for(let t of this.handlers)t instanceof Vx&&t.exportForExcel(e);return e=Ae(e),YT(e)}garbageCollectExternalResources(){for(const e of this.corePlugins)e.garbageCollectExternalResources()}},e.Registry=Zi,e.Revision=HI,e.SPREADSHEET_DIMENSIONS=JT,e.Spreadsheet=ZR,e.UIPlugin=eI,e.__info__=QT,e.addFunction=function e(t,o){return Gf.add(t,o),{addFunction:(t,o)=>e(t,o)}},e.astToFormula=fy,e.compile=wy,e.compileTokens=xy,e.components=sA,e.constants=iA,e.convertAstNodes=uy,e.coreTypes=wo,e.findCellInNewZone=Fn,e.functionCache=yy,e.helpers=tA,e.hooks=nA,e.invalidateCFEvaluationCommands=Eo,e.invalidateDependenciesCommands=Co,e.invalidateEvaluationCommands=So,e.iterateAstNodes=gy,e.links=oA,e.load=Ox,e.parse=hy,e.parseTokens=dy,e.readonlyAllowedCommands=yo,e.registries=eA,e.setDefaultSheetViewSize=function(e){ye=e},e.setTranslationMethod=function(e,t=(()=>!0)){n=e,i=t},e.tokenize=Qr,QT.version="17.0.74",QT.date="2025-09-19T07:22:25.998Z",QT.hash="bf7d9c8"}(this.o_spreadsheet=this.o_spreadsheet||{},owl);