@odoo/o-spreadsheet 16.4.1 → 16.5.0-alpha.1

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.
@@ -1188,7 +1188,7 @@ const DATE_JS_1900_OFFSET = INITIAL_JS_DAY - INITIAL_1900_DAY;
1188
1188
  const mdyDateRegexp = /^\d{1,2}(\/|-|\s)\d{1,2}((\/|-|\s)\d{1,4})?$/;
1189
1189
  const ymdDateRegexp = /^\d{3,4}(\/|-|\s)\d{1,2}(\/|-|\s)\d{1,2}$/;
1190
1190
  const dateSeparatorsRegex = /\/|-|\s/;
1191
- const dateRegexp = /^(\d{1,4})[\/-\s](\d{1,2})([\/-\s](\d{1,4}))?$/;
1191
+ const dateRegexp = /^(\d{1,4})[\/-\s](\d{1,4})([\/-\s](\d{1,4}))?$/;
1192
1192
  const timeRegexp = /((\d+(:\d+)?(:\d+)?\s*(AM|PM))|(\d+:\d+(:\d+)?))$/;
1193
1193
  function isDateTime(str, locale) {
1194
1194
  return parseDateTime(str, locale) !== null;
@@ -1249,6 +1249,10 @@ function getDateParts(dateString, locale) {
1249
1249
  }
1250
1250
  const localeDateType = getLocaleDateFormatType(locale);
1251
1251
  if (!part3) {
1252
+ if (part2.length > 2) {
1253
+ // e.g. 11/2023
1254
+ return { month: part1, year: part2, day: undefined, dateString, type: localeDateType };
1255
+ }
1252
1256
  if (localeDateType === "dmy") {
1253
1257
  return { day: part1, month: part2, year: part3, dateString, type: "dmy" };
1254
1258
  }
@@ -50528,6 +50532,6 @@ exports.setTranslationMethod = setTranslationMethod;
50528
50532
  exports.tokenize = tokenize;
50529
50533
 
50530
50534
 
50531
- __info__.version = '16.4.1';
50532
- __info__.date = '2023-07-26T12:13:04.992Z';
50533
- __info__.hash = 'e687fa9';
50535
+ __info__.version = '16.5.0-alpha.1';
50536
+ __info__.date = '2023-07-26T12:11:43.109Z';
50537
+ __info__.hash = '9160731';
@@ -1184,7 +1184,7 @@ const DATE_JS_1900_OFFSET = INITIAL_JS_DAY - INITIAL_1900_DAY;
1184
1184
  const mdyDateRegexp = /^\d{1,2}(\/|-|\s)\d{1,2}((\/|-|\s)\d{1,4})?$/;
1185
1185
  const ymdDateRegexp = /^\d{3,4}(\/|-|\s)\d{1,2}(\/|-|\s)\d{1,2}$/;
1186
1186
  const dateSeparatorsRegex = /\/|-|\s/;
1187
- const dateRegexp = /^(\d{1,4})[\/-\s](\d{1,2})([\/-\s](\d{1,4}))?$/;
1187
+ const dateRegexp = /^(\d{1,4})[\/-\s](\d{1,4})([\/-\s](\d{1,4}))?$/;
1188
1188
  const timeRegexp = /((\d+(:\d+)?(:\d+)?\s*(AM|PM))|(\d+:\d+(:\d+)?))$/;
1189
1189
  function isDateTime(str, locale) {
1190
1190
  return parseDateTime(str, locale) !== null;
@@ -1245,6 +1245,10 @@ function getDateParts(dateString, locale) {
1245
1245
  }
1246
1246
  const localeDateType = getLocaleDateFormatType(locale);
1247
1247
  if (!part3) {
1248
+ if (part2.length > 2) {
1249
+ // e.g. 11/2023
1250
+ return { month: part1, year: part2, day: undefined, dateString, type: localeDateType };
1251
+ }
1248
1252
  if (localeDateType === "dmy") {
1249
1253
  return { day: part1, month: part2, year: part3, dateString, type: "dmy" };
1250
1254
  }
@@ -50492,6 +50496,6 @@ const constants = {
50492
50496
  export { AbstractChart, CommandResult, CorePlugin, DispatchResult, EvaluationError, Model, Registry, Revision, SPREADSHEET_DIMENSIONS, Spreadsheet, UIPlugin, __info__, addFunction, astToFormula, compile, components, constants, convertAstNodes, coreTypes, findCellInNewZone, functionCache, helpers, invalidateCFEvaluationCommands, invalidateDependenciesCommands, invalidateEvaluationCommands, iterateAstNodes, links, load, parse, readonlyAllowedCommands, registries, setDefaultSheetViewSize, setTranslationMethod, tokenize };
50493
50497
 
50494
50498
 
50495
- __info__.version = '16.4.1';
50496
- __info__.date = '2023-07-26T12:13:04.992Z';
50497
- __info__.hash = 'e687fa9';
50499
+ __info__.version = '16.5.0-alpha.1';
50500
+ __info__.date = '2023-07-26T12:11:43.109Z';
50501
+ __info__.hash = '9160731';
@@ -1185,7 +1185,7 @@
1185
1185
  const mdyDateRegexp = /^\d{1,2}(\/|-|\s)\d{1,2}((\/|-|\s)\d{1,4})?$/;
1186
1186
  const ymdDateRegexp = /^\d{3,4}(\/|-|\s)\d{1,2}(\/|-|\s)\d{1,2}$/;
1187
1187
  const dateSeparatorsRegex = /\/|-|\s/;
1188
- const dateRegexp = /^(\d{1,4})[\/-\s](\d{1,2})([\/-\s](\d{1,4}))?$/;
1188
+ const dateRegexp = /^(\d{1,4})[\/-\s](\d{1,4})([\/-\s](\d{1,4}))?$/;
1189
1189
  const timeRegexp = /((\d+(:\d+)?(:\d+)?\s*(AM|PM))|(\d+:\d+(:\d+)?))$/;
1190
1190
  function isDateTime(str, locale) {
1191
1191
  return parseDateTime(str, locale) !== null;
@@ -1246,6 +1246,10 @@
1246
1246
  }
1247
1247
  const localeDateType = getLocaleDateFormatType(locale);
1248
1248
  if (!part3) {
1249
+ if (part2.length > 2) {
1250
+ // e.g. 11/2023
1251
+ return { month: part1, year: part2, day: undefined, dateString, type: localeDateType };
1252
+ }
1249
1253
  if (localeDateType === "dmy") {
1250
1254
  return { day: part1, month: part2, year: part3, dateString, type: "dmy" };
1251
1255
  }
@@ -50527,9 +50531,9 @@
50527
50531
  Object.defineProperty(exports, '__esModule', { value: true });
50528
50532
 
50529
50533
 
50530
- __info__.version = '16.4.1';
50531
- __info__.date = '2023-07-26T12:13:04.992Z';
50532
- __info__.hash = 'e687fa9';
50534
+ __info__.version = '16.5.0-alpha.1';
50535
+ __info__.date = '2023-07-26T12:11:43.109Z';
50536
+ __info__.hash = '9160731';
50533
50537
 
50534
50538
 
50535
50539
  })(this.o_spreadsheet = this.o_spreadsheet || {}, owl);
@@ -1,4 +1,4 @@
1
- !function(e,t){"use strict";let o=e=>e;function i(e,...t){if(1===t.length&&"object"==typeof t[0]){const o=t[0];e=e.replace(/\%\(?([^\)]+)\)s/g,((e,t)=>o[t]))}else t.length>0&&(e=e.replace(/\%s/g,(()=>t.shift())));return e}const s=function(e,...t){return i(o(e),...t)},r=function(e,...t){return new n(e,t)};class n extends String{values;constructor(e,t){super(e),this.values=t}valueOf(){const e=super.valueOf();return i(o(e),...this.values)}toString(){return this.valueOf()}}var a,l;!function(e){e.NotAvailable="#N/A",e.InvalidReference="#REF",e.BadExpression="#BAD_EXPR",e.CircularDependency="#CYCLE",e.UnknownFunction="#NAME?",e.GenericError="#ERROR"}(a||(a={})),function(e){e[e.silent=0]="silent",e[e.error=1]="error"}(l||(l={}));class c extends Error{errorType;logLevel;constructor(e,t,o=l.error){super(t),this.errorType=e,this.logLevel=o}}class h extends c{constructor(e){super(a.BadExpression,e)}}class d extends c{constructor(){super(a.CircularDependency,r("Circular reference"))}}class u extends c{constructor(){super(a.InvalidReference,r("Invalid reference"))}}class g extends c{constructor(e){super(a.NotAvailable,e||r("Data not available"),e?l.error:l.silent)}}class p extends c{constructor(e){super(a.UnknownFunction,r('Unknown function: "%s"',e))}}const m=.5,f="#f5f5f5",b="#F8F9FA",v="#E8EAED",S="#595959",C="#666666",E="#3266ca",w="#FFFFFF",y="#EBEBEB",x="#CACACA",I=11982760,R="#01666b",T="#188038",A="#E6F4EA",O="#CEEAD6",N="#E0E2E4",M="#4A4F59",_=["#000000","#434343","#666666","#999999","#B7B7B7","#CCCCCC","#D9D9D9","#EFEFEF","#F3F3F3","#FFFFFF","#980000","#FF0000","#FF9900","#FFFF00","#00FF00","#00FFFF","#4A86E8","#0000FF","#9900FF","#FF00FF","#E6B8AF","#F4CCCC","#FCE5CD","#FFF2CC","#D9EAD3","#D0E0E3","#C9DAF8","#CFE2F3","#D9D2E9","#EAD1DC","#DD7E6B","#EA9999","#F9CB9C","#FFE599","#B6D7A8","#A2C4C9","#A4C2F4","#9FC5E8","#B4A7D6","#D5A6BD","#CC4125","#E06666","#F6B26B","#FFD966","#93C47D","#76A5AF","#6D9EEB","#6FA8DC","#8E7CC3","#C27BA0","#A61C00","#CC0000","#E69138","#F1C232","#6AA84F","#45818E","#3C78D8","#3D85C6","#674EA7","#A64D79","#85200C","#990000","#B45F06","#BF9000","#38761D","#134F5C","#1155CC","#0B5394","#351C75","#741B47","#5B0F00","#660000","#783F04","#7F6000","#274E13","#0C343D","#1C4587","#073763","#20124D","#4C1130"],F=26,D=48,L=96,P=23,k=15,U=18,V=14,z=4,B=4,H=3,$=B,W=17,G=250,q="400",Z=10,j="'Roboto', arial",Y="bottom",X="overflow",K="thin",Q="#000000",J={style:"thin",color:T},ee=a.InvalidReference,te="START_REVISION",oe=1,ie=20,se="??",re="difference",ne="#00A04A",ae="#DC6965",le=.4,ce=["'","*","?","/","\\","[","]"],he=/'|\*|\?|\/|\\|\[|\]/,de="|",ue=r("Invalid expression");var ge;!function(e){e[e.Grid=0]="Grid",e[e.Highlight=5]="Highlight",e[e.Figure=10]="Figure",e[e.ScrollBar=15]="ScrollBar",e[e.GridPopover=19]="GridPopover",e[e.GridComposer=20]="GridComposer",e[e.Dropdown=21]="Dropdown",e[e.IconPicker=25]="IconPicker",e[e.TopBarComposer=30]="TopBarComposer",e[e.Popover=35]="Popover",e[e.FigureAnchor=1e3]="FigureAnchor",e[e.FigureSnapLine=1001]="FigureSnapLine"}(ge||(ge={}));let pe=0;function me(){return pe}const fe="\n",be=[6,7,8,9,10,11,12,14,18,24,36];function ve(e){return JSON.stringify(e,Object.keys(e).sort())}function Se(e){return'"'===e[0]&&(e=e.slice(1)),'"'===e[e.length-1]&&"\\"!==e[e.length-2]?e.slice(0,e.length-1):e}function Ce(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Ee(e){const t=Array.isArray(e)?[]:{};switch(typeof e){case"object":if(null===e)return e;if(function(e){return"clone"in e&&e.clone instanceof Function}(e))return e.clone();if(!(function(e){return"object"==typeof e&&e?.constructor===Object}(e)||e instanceof Array))throw new Error("Unsupported type: only objects and arrays are supported");for(const o in e)t[o]=Ee(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 we(e){return e.startsWith("'")&&(e=e.slice(1,-1).replace(/''/g,"'")),e}function ye(e){return e.match(/\w/g)?.length!==e.length&&(e=`'${e}'`),e}function xe(e,t,o){return e<t?t:e>o?o:e}function Ie(e,t,o=1){if(t<=e&&o>0)return[];if(0===o)throw new Error("range() step must not be zero");const i=Math.ceil(Math.abs((t-e)/o)),s=Array(i);for(let t=0;t<i;t++)s[t]=e+t*o;return s}function Re(e){return e.reduce(((e,t,o,i)=>{if(1===Math.abs(t-i[o-1])){e[e.length-1].push(t)}else e.push([t]);return e}),[])}function*Te(e,t){t.next();for(const o of e){const e=t.next();yield{...o,next:e.done?void 0:e.value}}}const Ae=/^\[([^\[]+)\]\((.+)\)$/,Oe=/^https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,4}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)$/;function Ne(e){return Ae.test(e)}function Me(e){return Oe.test(e)}function _e(e,t){return`[${e}](${t})`}function Fe(e){const t=e.match(Ae)||[],o=t[1],i=t[2];if(!o||!i)throw new Error(`Could not parse markdown link ${e}.`);return{label:o,url:i}}const De="o-spreadsheet://";function Le(e){return e.startsWith(De)}function Pe(e){return`${De}${e}`}function ke(e){if(e.startsWith(De))return e.substr(De.length);throw new Error(`${e} is not a valid sheet link`)}function Ue(e){return void 0!==e}function Ve(e){return void 0===e||Object.values(e).every((e=>"object"==typeof e?Ve(e):!e))}function ze(e,t){for(let[o,i]of Object.entries(t))if(ve(i)===ve(e))return parseInt(o,10);const o=Object.keys(t),i=0===o.length?0:Math.max(...o.map((e=>parseInt(e,10))));return t[i+1]=e,i+1}function Be(e,t,o){let i;return function(){const s=this,r=arguments;const n=o&&!i;clearTimeout(i),i=setTimeout((function(){i=null,o||e.apply(s,r)}),t),n&&e.apply(s,r)}}function He(e){let t="";for(let o=0,i=e.length;o<i;o++)t+=e[o];return t}function $e(e){let t,o=!1;const i=()=>(o||(t=e instanceof Function?e():e,o=!0),t);return i.map=e=>$e((()=>e(i()))),i}function We(e,t){let o=e.slice(t).find((e=>e));return o||(o=e.slice(0,t).reverse().find((e=>e))),o||""}function Ge(e,t){return"after"===e?t+1:t}function qe(e,t){if(e===t)return!0;if(e&&!t||t&&!e)return!1;const o=new Set;Object.keys(e).forEach((e=>o.add(e))),Object.keys(t).forEach((e=>o.add(e)));for(let i of o){if(typeof e[i]!=typeof e[i])return!1;if("object"==typeof e[i]){if(!qe(e[i],t[i]))return!1}else if(e[i]!==t[i])return!1}return!0}function Ze(e){const t={...e};return Object.keys(t).forEach((e=>!t[e]&&delete t[e])),t}function je(e,t=(e=>e)){if(!e.length)return[];const o=Array(e[0].length);for(let i=0;i<e[0].length;i++){o[i]=Array(e.length);for(let s=0;s<e.length;s++)o[i][s]=t(e[s][i])}return o}const Ye=[" ","\t","\f","\v",String.fromCharCode(parseInt("00a0",16)),String.fromCharCode(parseInt("1680",16)),String.fromCharCode(parseInt("2000",16)),String.fromCharCode(parseInt("200a",16)),String.fromCharCode(parseInt("2028",16)),String.fromCharCode(parseInt("2029",16)),String.fromCharCode(parseInt("202f",16)),String.fromCharCode(parseInt("205f",16)),String.fromCharCode(parseInt("3000",16)),String.fromCharCode(parseInt("feff",16))],Xe=new RegExp(Ye.join("|"),"g"),Ke=/\r\n|\r|\n/g;function Qe(e){return e?e=(e=e.replace(Xe," ")).replace(Ke,fe):""}function Je(e){const t=Array.from(e).sort(((e,t)=>e-t));for(let e=1;e<t.length;e++)if(t[e]-t[e-1]!=1)return!1;return!0}class et extends Set{add(...e){for(const t of e)super.add(t);return this}delete(...e){let t=!1;for(const o of e)t||=super.delete(o);return t}}function tt(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 ot(e,t){return e.filter(((e,o)=>!t.includes(o)))}const it=/rgba?\(|\s+|\)/gi,st=/^#([A-F\d]{2}){3,4}$/,rt=["#eb6d00","#0074d9","#ad8e00","#169ed4","#b10dc9","#00a82d","#00a3a3","#f012be","#3d9970","#111111","#62A300","#ff4136","#949494","#85144b","#001f3f"];function nt(e){return at(e.toString(16).padStart(6,"0"))}function at(e){let t=e;if(e.startsWith("rgb")?t=function(e){const t=e.replace(it,"").split(",");let o=255;if(3!==t.length&&4!==t.length)throw new Error("invalid color");if(4===t.length){const e=parseFloat(t.pop()||"1");o=Math.round(255*(e||1))}const i=t.map((e=>parseInt(e,10)));255!==o&&i.push(o);return"#"+He(i.map((e=>e.toString(16).padStart(2,"0")))).toUpperCase()}(e):(t=e.replace("#","").toUpperCase(),3!==t.length&&4!==t.length||(t=t.split("").reduce(((e,t)=>e+t+t),"")),t=`#${t}`),!st.test(t))throw new Error(`invalid color input: ${e}`);return t}function lt(e){try{return at(e),!0}catch(e){return!1}}const ct=e=>e>=0&&e<=255;function ht(e,t,o,i=1){if(!ct(e)||!ct(t)||!ct(o)||i<0||i>1)throw new Error(`Invalid RGBA values ${[e,t,o,i]}`);return{a:i,b:o,g:t,r:e}}function dt(e){let{r:t,g:o,b:i}=gt(e);t/=255,o/=255,i/=255;const s=e=>e<=.03928?e/12.92:((e+.055)/1.055)**2.4;return.2126*s(t)+.7152*s(o)+.0722*s(i)}function ut(e){let t=e.r.toString(16),o=e.g.toString(16),i=e.b.toString(16),s=Math.round(255*e.a).toString(16);return 1===t.length&&(t="0"+t),1===o.length&&(o="0"+o),1===i.length&&(i="0"+i),1===s.length&&(s="0"+s),"ff"===s&&(s=""),("#"+t+o+i+s).toUpperCase()}function gt(e){let t,o,i,s;if(7===(e=at(e)).length)t=parseInt(e[1]+e[2],16),o=parseInt(e[3]+e[4],16),i=parseInt(e[5]+e[6],16),s=255;else{if(9!==e.length)throw new Error("Invalid color");t=parseInt(e[1]+e[2],16),o=parseInt(e[3]+e[4],16),i=parseInt(e[5]+e[6],16),s=parseInt(e[7]+e[8],16)}return s=+(s/255).toFixed(3),{a:s,r:t,g:o,b:i}}function pt(e){(e={...e}).s/=100,e.l/=100;let t=(1-Math.abs(2*e.l-1))*e.s,o=t*(1-Math.abs(e.h/60%2-1)),i=e.l-t/2,s=0,r=0,n=0;return 0<=e.h&&e.h<60?(s=t,r=o,n=0):60<=e.h&&e.h<120?(s=o,r=t,n=0):120<=e.h&&e.h<180?(s=0,r=t,n=o):180<=e.h&&e.h<240?(s=0,r=o,n=t):240<=e.h&&e.h<300?(s=o,r=0,n=t):300<=e.h&&e.h<360&&(s=t,r=0,n=o),s=Math.round(255*(s+i)),r=Math.round(255*(r+i)),n=Math.round(255*(n+i)),{a:e.a,r:s,g:r,b:n}}function mt(e){const t=e.r/255,o=e.g/255,i=e.b/255;let s=Math.min(t,o,i),r=Math.max(t,o,i),n=r-s,a=0,l=0,c=0;return a=0===n?0:r===t?(o-i)/n%6:r===o?(i-t)/n+2:(t-o)/n+4,a=Math.round(60*a),a<0&&(a+=360),c=(r+s)/2,l=0===n?0:n/(1-Math.abs(2*c-1)),l=+(100*l).toFixed(1),c=+(100*c).toFixed(1),{a:e.a,h:a,s:l,l:c}}function ft(e){return ut(pt(e))}function bt(e){return mt(gt(e))}function vt(e){if(e<0)throw new Error(`number must be positive. Got ${e}`);return e<26?String.fromCharCode(65+e):vt(Math.floor(e/26)-1)+vt(e%26)}const St={};for(const e of"ABCDEFGHIJKLMNOPQRSTUVWXYZ"){const t=e.charCodeAt(0)-64;St[e]=t,St[e.toLowerCase()]=t}function Ct(e){let t=-1;let o=1;for(let i=e.length-1;i>=0;i--){t+=St[e[i]]*o,o*=26}return t}function Et(e){return e>="A"&&e<="Z"||e>="a"&&e<="z"}function wt(e){return e>="0"&&e<="9"}function yt(e){let t;e=e.trim();for(let o=0;o<e.length;o++){const i=e[o];if(!t){if("$"===i&&0===o||Et(i))continue;t=o}if(!wt(i)){if("$"===i&&o===t)continue;throw new Error(`Invalid cell description: ${e}`)}}if(!t||t===e.length)throw new Error(`Invalid cell description: ${e}`);const o="$"===e[0]?e.slice(1,t):e.slice(0,t),i="$"===e[t]?e.slice(t+1):e.slice(t);if(o.length<1||o.length>3||i.length<1||i.length>7)throw new Error(`Invalid cell description: ${e}`);const s=Ct(o),r=Number(i)-1;if(isNaN(r))throw new Error(`Invalid cell description: ${e}`);return{col:s,row:r}}function xt(e,t,o={colFixed:!1,rowFixed:!1}){return(o.colFixed?"$":"")+vt(e)+(o.rowFixed?"$":"")+String(t+1)}const It=new Date(1899,11,30),Rt=864e5,Tt=2e3,At=(new Date).getFullYear(),Ot=(new Date).getMonth(),Nt=new Date(0)-It,Mt=/^\d{1,2}(\/|-|\s)\d{1,2}((\/|-|\s)\d{1,4})?$/,_t=/^\d{3,4}(\/|-|\s)\d{1,2}(\/|-|\s)\d{1,2}$/,Ft=/\/|-|\s/,Dt=/^(\d{1,4})[\/-\s](\d{1,2})([\/-\s](\d{1,4}))?$/,Lt=/((\d+(:\d+)?(:\d+)?\s*(AM|PM))|(\d+:\d+(:\d+)?))$/;function Pt(e,t){return null!==kt(e,t)}function kt(e,t){let o=null;const i=(e=e.trim()).match(Lt);if(i){if(o=function(e){if(e=e.trim(),Lt.test(e)){const t=/AM/i.test(e),o=/PM/i.test(e),i=(t||o?e.substring(0,e.length-2).trim():e).split(/:/),s=i.length>=2,r=3===i.length;let n=Number(i[0]),a=s?Number(i[1]):0,l=r?Number(i[2]):0,c=r?"hh:mm:ss":"hh:mm";if(t||o)c+=" a";else if(!s)return null;n>=12&&t?n-=12:n<12&&o&&(n+=12),a+=Math.floor(l/60),l%=60,n+=Math.floor(a/60),a%=60,n>=24&&(c="hhhh:mm:ss");return{value:n/24+a/1440+l/86400,format:c,jsDate:new Date(1899,11,30,n,a,l)}}return null}(i[0]),null===o)return null;e=e.replace(i[0],"").trim()}let s=null;const r=function(e,t){const o=e.match(Dt);if(!o)return null;const[,i,s,,r]=o;if(i.length>2&&r&&r.length>2)return null;if(i.length>2)return{year:i,month:s,day:r,dateString:e,type:"ymd"};const n=function(e){switch(e.dateFormat[0]){case"d":return"dmy";case"m":return"mdy";case"y":return"ymd"}throw new Error("Invalid date format in locale")}(t);if(!r)return"dmy"===n?{day:i,month:s,year:r,dateString:e,type:"dmy"}:{month:i,day:s,year:r,dateString:e,type:"mdy"};if(r.length>2)return"mdy"===n?{month:i,day:s,year:r,dateString:e,type:"mdy"}:{day:i,month:s,year:r,dateString:e,type:"dmy"};if("mdy"===n)return{month:i,day:s,year:r,dateString:e,type:"mdy"};if("ymd"===n)return{year:i,month:s,day:r,dateString:e,type:"ymd"};if("dmy"===n)return{day:i,month:s,year:r,dateString:e,type:"dmy"};return null}(e,t);if(r){const t=r.dateString.match(Ft)[0];if(s=function(e,t){let{year:o,month:i,day:s}=e;const r=function(e){if(!e)return Ot;const t=Number(e);if(t>=1&&t<=12)return t-1;return null}(i),n=function(e){if(!e)return 1;const t=Number(e);if(t>=0&&t<=31)return t;return null}(s),a=function(e){if(!e)return At;const t=Number(e);switch(e.length){case 1:return Tt+t;case 2:return Tt+(Tt+t>At+10?-100:0)+t;case 3:case 4:return t}return null}(o);if(null===a||null===r||null===n)return null;const l=2===i?.length&&r+1<10||2===s?.length&&n<10,c=2!==o?.length,h=new Date(a,r,n);if(h.getMonth()!==r||h.getDate()!==n)return null;const d=h-It,u=function(e,t,o,i){const s=e.year?i?"yyyy":"yy":void 0,r=e.month?o?"mm":"m":void 0,n=e.day?o?"dd":"d":void 0;switch(e.type){case"mdy":return[r,n,s].filter(Ue).join(t);case"ymd":return[s,r,n].filter(Ue).join(t);case"dmy":return[n,r,s].filter(Ue).join(t)}}(e,t,l,c);return{value:Math.round(d/Rt),format:u,jsDate:h}}(r,t),null===s)return null;e=e.replace(r.dateString,"").trim()}return""!==e||!s&&!o?null:s&&s.jsDate&&o&&o.jsDate?{value:s.value+o.value,format:s.format+" "+("hhhh:mm:ss"===o.format?"hh:mm:ss":o.format),jsDate:new Date(s.jsDate.getFullYear()+o.jsDate.getFullYear()-1899,s.jsDate.getMonth()+o.jsDate.getMonth()-11,s.jsDate.getDate()+o.jsDate.getDate()-30,s.jsDate.getHours()+o.jsDate.getHours(),s.jsDate.getMinutes()+o.jsDate.getMinutes(),s.jsDate.getSeconds()+o.jsDate.getSeconds())}:s||o}function Ut(e){const t=Math.trunc(e);let o=new Date(t*Rt-Nt),i=e-t;i=i<0?1+i:i;const s=Math.round(24*i),r=Math.round(24*(i-s/24)*60),n=Math.round(24*(i-s/24-r/24/60)*60*60);return o.setHours(s),o.setMinutes(r),o.setSeconds(n),o}function Vt(e){const t=e.getTime()-It.getTime();return Math.round(t/Rt)}function zt(e){return new Date(e.getFullYear(),e.getMonth()+1,0).getDate()}function Bt(e){return zt(e)===e.getDate()}function Ht(e,t,o){const i=e.getFullYear(),s=e.getMonth(),r=e.getDate(),n=new Date(i,s+t);return o&&r===zt(e)||r>zt(n)?n.setDate(zt(n)):n.setDate(r),n}function $t(e){const t=Math.trunc(e);return t%4==0&&t%100!=0||t%400==0}function Wt(e,t,o){if(e===t)return 0;if(e>t){const o=t;t=e,e=o}const i=Ut(e),s=Ut(t);let r=i.getDate(),n=s.getDate();const a=i.getMonth(),l=s.getMonth(),c=i.getFullYear(),h=s.getFullYear();let d=0,u=0;switch(o){case 0:31===r&&(r=30),30===r&&31===n&&(n=30),1===a&&r===($t(c)?29:28)&&(r=30,1===l&&n===($t(h)?29:28)&&(n=30)),d=c+(30*a+r)/360,u=h+(30*l+n)/360;break;case 1:let o=365;const i=c===h;if(!i&&!(c+1===h)||!i&&a<l||!i&&a===l&&r<n){let e=0,t=0;for(let o=c;o<=h;o++)e++,t+=$t(o)?366:365;o=t/e}else i?$t(c)&&(o=366):($t(c)&&a<2&&(o=366),$t(h)&&(l>1||1===l&&29===n)&&(o=366));d=e/o,u=t/o;break;case 2:d=e/360,u=t/360;break;case 3:d=e/365,u=t/365;break;case 4:31===r&&(r=30),31===n&&(n=30),d=c+(30*a+r)/360,u=h+(30*l+n)/360}return u-d}function Gt(e,t){const o=12*(t.getFullYear()-e.getFullYear())+t.getMonth()-e.getMonth();return e.getDate()>t.getDate()?o-1:o}function qt(e,t){const o=e.getTime(),i=t.getTime();return Math.floor((i-o)/Rt)}function Zt(e,t){const o=t.getFullYear()-e.getFullYear(),i=e.getMonth(),s=t.getMonth(),r=e.getDate(),n=t.getDate();return s>i||s===i&&n>=r?o:o-1}const jt=140,Yt=20,Xt=.035;function Kt(e){return Yt+(jt-Yt)*Math.exp(-Xt*(e-1))}const Qt=[{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:";"}],Jt=Qt[0],eo=tt((function(e){return e=Ce(e),new RegExp(`(^-?\\d+(${e}?\\d*(e\\d+)?)?|^-?${e}\\d+)(?!\\w|!)`)})),to=tt((function(e){const t=Ce(e.decimalSeparator),o="(\\s*"+`(\\d+(${Ce(e.thousandsSeparator)}\\d{3,})*(${t}\\d*)?)`+"|"+`(${t}\\d+)`+")(e(\\+|-)?\\d+)?(\\s*%)?",i="(\\s*-)?",s="(\\s*[\\$€])?",r="^(("+[i+s+o,i+o+s,s+i+o].join(")|(")+"))$";return new RegExp(r,"i")}));function oo(e,t){return!!e&&to(t).test(e.trim())}const io=tt((function(e){return new RegExp(`[$€${Ce(e.thousandsSeparator)}]`,"g")}));function so(e,t){"."!==t.decimalSeparator&&(e=e.replace(t.decimalSeparator,".")),e=e.replace(io(t),"");let o=Number(e);return isNaN(o)&&e.includes("%")&&(o=Number(e.split("%")[0]),!isNaN(o))?o/100:o}function ro(e,t,o){const i=[...e].sort(((e,t)=>e-t));let s=(i.length+(o?-1:1))*t;if(o||s--,Number.isInteger(s))return i[s];const r=Math.ceil(s),n=Math.floor(s);return i[r]*(s-n)+i[n]*(r-s)}const no=20,ao=11,lo=/(\d+?)(?=(\d{3})+(?!\d)|$)/g,co=/0/g,ho={0:r("January"),1:r("February"),2:r("March"),3:r("April"),4:r("May"),5:r("June"),6:r("July"),7:r("August"),8:r("September"),9:r("October"),10:r("November"),11:r("December")},uo={0:r("Sunday"),1:r("Monday"),2:r("Tuesday"),3:r("Wednesday"),4:r("Thursday"),5:r("Friday"),6:r("Saturday")},go={};function po(e){let t=go[e];return void 0===t&&(t=function(e){if(""===e)throw new Error("A format cannot be empty");let t=0,o=[];for(;t<e.length;){let i;if("["===e.charAt(t)){if("$"!==e.charAt(t+1))throw new Error(`Currency formats have to be prefixed by a $: ${e}`);if(i=e.substring(t+1).indexOf("]")+t+2,0===i)throw new Error(`Invalid currency brackets format: ${e}`);const s=e.substring(t+2,i-1);if(s.includes("["))throw new Error(`Invalid currency format: ${e}`);o.push({type:"STRING",format:s})}else{const s=e.substring(t).indexOf("[");i=s>-1?s+t:e.length;const r=e.substring(t,i);wo(r)?o.push({type:"DATE",format:r}):o.push({type:"NUMBER",format:ko(r)})}t=i}return o}(e),go[e]=t),t}function mo(e,{format:t,locale:o}){switch(typeof e){case"string":return e;case"boolean":return e?"TRUE":"FALSE";case"number":t||(t=Ao(e));return function(e,t,o){if("DATE"===t[0].type)return xo(e,t[0].format);let i=e<0?"-":"";for(let s of t)switch(s.type){case"NUMBER":i+=fo(Math.abs(e),s.format,o);break;case"STRING":i+=s.format}return i}(e,po(t),o);case"object":return"0"}}function fo(e,t,o){t.isPercent&&(e*=100),e/=t.magnitude;let i=0;void 0!==t.decimalPart&&(i=t.decimalPart.length);const{integerDigits:s,decimalDigits:r}=vo(e,i);let n=function(e,t,o){const i="0"===e?"":e;let s=i;const r=t.length-i.length;if(r>0){const e=(t.substring(0,r).match(co)||[]).length;s="0".repeat(e)+s}o&&(s=s.match(lo)?.join(o)||s);return s}(s,t.integerPart,t.thousandsSeparator?o.thousandsSeparator:void 0);return void 0!==t.decimalPart&&(n+=o.decimalSeparator+function(e,t){let o=e;if(t.length-e.length>0){const i=(t.substring(e.length,t.length+1).match(co)||[]).length;o+="0".repeat(i)}return o}(r||"",t.decimalPart)),t.isPercent&&(n+="%"),n}const bo=[];function vo(e,t=no){const o=e.toString();if(o.includes("e"))return function(e,t=no){let o=bo[t];o||(o=new Intl.NumberFormat("en-US",{maximumFractionDigits:t,useGrouping:!1}),bo[t]=o);const[i,s]=o.format(e).split(".");return{integerDigits:i,decimalDigits:s}}(e,t);if(Number.isInteger(e))return{integerDigits:o,decimalDigits:void 0};const i=o.indexOf(".");let s=o.substring(0,i),r=o.substring(i+1);if(0===t)return Number(r[0])>=5&&(s=(Number(s)+1).toString()),{integerDigits:s,decimalDigits:void 0};if(r.length>t){const{integerDigits:e,decimalDigits:o}=function(e,t){let o="0",i=e,s=e.slice(0,t);const r=t;if(Number(e[r])<5)return{integerDigits:o,decimalDigits:s};const n=s.match(Co)?.[0]||"",a=(Number(s)+1).toString(),l=s.slice(n.length),c=a.length>l.length;c&&!n?(o="1",i=void 0):i=c?n.slice(0,-1)+a:n+a;return{integerDigits:o,decimalDigits:i}}(r,t);r=o,"0"!==e&&(s=(Number(s)+Number(e)).toString())}return{integerDigits:s,decimalDigits:So(r||"")}}function So(e){let t=e.length-1;for(;t>=0&&"0"===e[t];)t--;return e.slice(0,t+1)||void 0}const Co=/^0+/;function Eo(e,t){const{integerDigits:o,decimalDigits:i}=vo(e,20);return i?o+t+i:o}function wo(e){if(!yo.has(e[0]))return!1;try{return xo(1,e),!0}catch(e){return!1}}const yo=new Set(["h","m","y","d"]);function xo(e,t){const o=Ut(e),i=t.indexOf("h");let s="",r="";return i>0?(s=Io(o,t.substring(0,i-1)),r=Ro(o,t.substring(i))):0===i?r=Ro(o,t):i<0&&(s=Io(o,t)),s+(s&&r?" ":"")+r}function Io(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 uo[e.getDay()].slice(0,3);case"dddd":return uo[e.getDay()];case"m":return e.getMonth()+1;case"mm":return String(e.getMonth()+1).padStart(2,"0");case"mmm":return ho[e.getMonth()].slice(0,3);case"mmmm":return ho[e.getMonth()];case"mmmmm":return ho[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 Ro(e,t){let o=t.split(/:|\s/);const i=e.getHours(),s="a"===o[o.length-1];let r=i,n="";return s&&(r=0===r?12:r>12?r-12:r,n=i>=12?" PM":" AM",o.pop()),o.map((o=>{switch(o){case"hhhh":return Math.floor((e.getTime()-It)/36e5).toString();case"hh":return r.toString().padStart(2,"0");case"mm":return e.getMinutes().toString().padStart(2,"0");case"ss":return e.getSeconds().toString().padStart(2,"0");default:throw new Error(`invalid format: ${t}`)}})).join(":")+n}const To=tt((function(e){return new RegExp(`[0-9]+${Ce(e.decimalSeparator)}[0-9]`)}));function Ao(e){let{integerDigits:t,decimalDigits:o}=vo(e);if(!o)return"0";const i=t.replace("-","").length;if(i+2>ao)return"0";const s=ao-i-1;return({decimalDigits:o}=vo(e,Math.min(s,o.length))),o?"0."+"0".repeat(o.length):"0"}function Oo(e,t){if(!Pt(e,t))return;return kt(e,t).format}function No(e){if(!oo(e,Jt))return;const t=e.includes(".")?"0.00":"0",o=e.match(/[\$€]/);if(o){const i=e.match(/[\d]/),s="[$"+o.values().next().value+"]";return i.index<o.index?"#,##"+t+s:s+"#,##"+t}return e.includes("%")?t+"%":void 0}function Mo(e){const t=e.decimalPlaces??2,o=e.position??"before",i=e.code??"",s=e.symbol??"",r="#,##0"+(t?"."+"0".repeat(t):"");let n=`${i} ${s}`.trim();return"after"===o&&i&&(n=" "+n),function(e,t,o){const i=`[$${e}]`;return"before"===t?i+o:o+i}(n,o,r)}function _o(e){return Vo(po(e).map((e=>"NUMBER"===e.type?{type:e.type,format:{...e.format,decimalPart:void 0}}:e)))}function Fo(e,t,o,i){return Vo(po(e||"#,##0").map((e=>"NUMBER"===e.type?[{...e,format:{...e.format,magnitude:t,decimalPart:void 0}},{type:"STRING",format:o}]:e)).flat())}function Do(e,t,o){const i=po(e).map((e=>"NUMBER"===e.type?{...e,format:Lo(e.format,t)}:e)),s=Vo(i);return go[s]=i,s}function Lo(e,t){const o={...e},i=Math.sign(t),s=o.decimalPart?.length||0,r=Math.min(Math.max(0,s+i),no);return o.decimalPart="0".repeat(r),""===o.decimalPart&&delete o.decimalPart,o}const Po=/,*?$/;function ko(e){if(function(e){return Boolean(e.replace(Uo,""))}(e=e.trim()))throw new Error(`Invalid number format: ${e}`);const t=e.includes("%"),o=e.match(Po)?.[0]||"",i=o?1e3**o.length:1;let s=e.slice(0,e.length-(o.length||0));const r=s.includes(",");if(/\..*,/.test(s))throw new Error("A format can't contain ',' symbol in the decimal part");s=s.replace("%","").replace(",","");const n=s.match(/[\%|,]/);if(n)throw new Error(`A format can only contain a single '${n[0]}' symbol`);const[a,l]=s.split(".");if(l&&l.length>20)throw new Error("A format can't contain more than 20 decimal places");return void 0!==l?{integerPart:a,isPercent:t,thousandsSeparator:r,decimalPart:l,magnitude:i}:{integerPart:a,isPercent:t,thousandsSeparator:r,magnitude:i}}const Uo=/[,#0.%]/g;function Vo(e){let t="";for(let o of e){let e;switch(o.type){case"NUMBER":const t=o.format;e=t.integerPart,t.thousandsSeparator&&(e=e.slice(0,-3)+","+e.slice(-3)),void 0!==t.decimalPart&&(e+="."+t.decimalPart),t.isPercent&&(e+="%"),t.magnitude&&(e+=",".repeat(Math.log10(t.magnitude)/3));break;case"STRING":e=`[$${o.format}]`;break;case"DATE":e=o.format}t+=e}return t}const zo=new RegExp(/\$?([A-Z]{1,3})\$?([0-9]{1,7})/,"i"),Bo=new RegExp(/^\$?([A-Z]{1,3})\$?([0-9]{1,7})$/,"i"),Ho=new RegExp(/^([A-Z]{1,3})+$/,"i"),$o=new RegExp(/^\s*('.+'!|[^']+!)?\$?([A-Z]{1,3})$/,"i"),Wo=new RegExp(/^\s*('.+'!|[^']+!)?\$?([0-9]{1,7})$/,"i"),Go=new RegExp(/^\s*('.+'!|[^']+!)?/.source+"("+[zo.source,/(\$?[A-Z]{1,3})?\$?[0-9]{1,7}\s*:\s*(\$?[A-Z]{1,3})?\$?[0-9]{1,7}\s*/i.source,/\$?[A-Z]{1,3}(\$?[0-9]{1,7})?\s*:\s*\$?[A-Z]{1,3}(\$?[0-9]{1,7})?\s*/i.source].join("|")+")"+/$/.source,"i");function qo(e){return $o.test(e)}function Zo(e){return Wo.test(e)}function jo(e){return Ho.test(e)}function Yo(e){return Bo.test(e)}function Xo(e){const t=e.split("!"),o=t.pop();return{sheetName:we(t.join("!"))||void 0,xc:o}}function Ko(e){const t=function(e){let t,o,i,s,r;e.includes("!")&&(e=e.split("!").at(-1)),e.includes("$")&&(e=e.replace(/\$/g,"")),t=e.includes(":")?e.split(":").map((e=>e.trim())):[e.trim()];let n=!1,a=!1,l=!1;const c=t[0],h=t[1]&&t[1];if(qo(c))s=r=Ct(c),o=i=0,n=!0;else if(Zo(c))o=i=parseInt(c,10)-1,s=r=0,a=!0;else{const e=yt(c);s=r=e.col,o=i=e.row,l=!0}if(2===t.length)if(qo(h))r=Ct(h),n=!0;else if(Zo(h))i=parseInt(h,10)-1,a=!0;else{const e=yt(h);r=e.col,i=e.row,o=n?i:o,s=a?r:s,l=!0}if(n&&a)throw new Error("Wrong zone xc. The zone cannot be at the same time a full column and a full row");const d={top:o,left:s,bottom:n?void 0:i,right:a?void 0:r};return l=l&&(a||n),l&&(d.hasHeader=l),d}(e);if(void 0!==t.right&&t.right<t.left){const e=t.left;t.left=t.right,t.right=e}if(void 0!==t.bottom&&t.bottom<t.top){const e=t.top;t.top=t.bottom,t.bottom=e}return t}function Qo(e){const t=Ko(e);if(void 0===t.bottom||void 0===t.right)throw new Error("This does not support unbounded ranges");return t}function Jo(e){const{bottom:t,top:o,left:i,right:s}=e;return!(void 0!==t&&isNaN(t)||isNaN(o)||isNaN(i)||void 0!==s&&isNaN(s))&&((void 0===e.bottom||e.bottom>=e.top&&e.bottom>=0)&&(void 0===e.right||e.right>=e.left&&e.right>=0)&&e.top>=0&&e.left>=0)}function ei(e){const{top:t,bottom:o,left:i,right:s}=e,n="hasHeader"in e&&e.hasHeader,a=t===o&&i===s;if(void 0===o&&void 0!==s)return 0!==t||n?`${xt(i,t)}:${vt(s)}`:`${vt(i)}:${vt(s)}`;if(void 0===s&&void 0!==o)return 0!==i||n?`${xt(i,t)}:${o+1}`:`${t+1}:${o+1}`;if(void 0!==o&&void 0!==s)return a?xt(i,t):`${xt(i,t)}:${xt(s,o)}`;throw new Error(r("Bad zone format"))}function ti(e,t,o,i,s){const r="left"===t?"columns":"rows",n="before"===i?o-1:o,a=e["left"===t?"right":"bottom"];return e[t]<=n&&a&&a>n?bi(e,r,"RESIZE",s):n<e[t]?bi(e,r,"MOVE",s):{...e}}function oi(e,t,o,i,s){const r="left"===t?"columns":"rows",n="before"===i?o-1:o,a="left"===t?"right":"bottom";return e[t]<=n&&e[a]>n?bi(e,r,"RESIZE",s):n<e[t]?bi(e,r,"MOVE",s):{...e}}function ii(e,t,o){const i="left"===t?"right":"bottom";let s=e[t],r=e[i];for(let n of o.sort(((e,t)=>t-e)))e[t]>n&&(s--,r--),e[t]<n&&e[i]>=n&&r--;return{...e,[t]:s,[i]:r}}function si(e,t,o){const i="left"===t?"right":"bottom";let s=e[t],r=e[i];const n=e[i];for(let i of o.sort(((e,t)=>t-e)))e[t]>i&&(s--,void 0!==r&&r--),void 0!==n&&void 0!==r&&e[t]<=i&&n>=i&&r--;if(!(void 0!==r&&s>r))return{...e,[t]:s,[i]:r}}function ri(...e){return{top:Math.min(...e.map((e=>e.top))),left:Math.min(...e.map((e=>e.left))),bottom:Math.max(...e.map((e=>e.bottom))),right:Math.max(...e.map((e=>e.right)))}}function ni(e,t){if(li(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 ai(e,t){return e.left===t.left&&e.right===t.right&&e.top===t.top&&e.bottom===t.bottom}function li(e,t){return!(e.bottom<t.top||t.bottom<e.top)&&!(e.right<t.left||t.right<e.left)}function ci(e,t,o){const{left:i,right:s,top:r,bottom:n}=o;return e>=i&&e<=s&&t>=r&&t<=n}function hi(e,t){return ai(ri(t,e),t)}function di(e,t){const o=e.map(Ko),i=t.map(Qo),s=Math.max(...o.concat(i).map((e=>e.bottom||0))),r=Math.max(...o.concat(i).map((e=>e.right||0))),n=o.map((e=>({...e,bottom:void 0===e.bottom?s+1:e.bottom,right:void 0===e.right?r+1:e.right}))),a=i.map((e=>({...e,bottom:void 0===e.bottom?s+1:e.bottom,right:void 0===e.right?r+1:e.right}))),l=function(e,t){const o=new Set(t.map((({col:e,row:t})=>`${e}-${t}`)));return e.filter((({col:e,row:t})=>!o.has(`${e}-${t}`)))}(n.map(mi).flat(),a.map(mi).flat()),c=function(e){if(0===e.length)return[];const[t,...o]=[...e].sort(((e,t)=>e.row-t.row)).sort(((e,t)=>e.col-t.col)),i=[];let s=Ci(t);for(const{col:e,row:t}of o)if(!ci(e,t,s))if(e===s.left&&t===s.bottom+1){const e=s.bottom+1;s={...s,bottom:e}}else i.push(s),s=Ci({col:e,row:t});return[...i,s]}(l);return function(e){if(0===e.length)return[];if(e.some((e=>e.left!==e.right)))throw new Error("only columns can be merged");const t=[],o=ui(e),i=(e,t)=>e.top===t.top&&e.bottom===t.bottom&&e.right+1===t.left;for(;o.length;){const e=o.reduce(((e,t)=>i(e,t)?ri(e,t):e),o.shift());t.push(e)}return ui(t)}(c).map((e=>({...e,bottom:e.bottom===s+1?void 0:e.bottom,right:e.right===r+1?void 0:e.right}))).map(ei)}function ui(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=>hi(e,t)))||o.push(e)}return o.reverse()}function gi(e){return{numberOfRows:e.bottom-e.top+1,numberOfCols:e.right-e.left+1}}function pi(e){const{numberOfCols:t,numberOfRows:o}=gi(e);return 1===t||1===o}function mi(e){const t=[],[o,i]=[e.right,e.left].sort(((e,t)=>e-t)),[s,r]=[e.top,e.bottom].sort(((e,t)=>e-t));for(const e of Ie(o,i+1))for(const o of Ie(s,r+1))t.push({col:e,row:o});return t}function fi(e,t){const{left:o,right:i,top:s,bottom:r}=e;for(let e=o;e<=i;e++)for(let o=s;o<=r;o++)t(e,o)}function bi(e,t,o,i){const s="both"===t?i[0]:"columns"===t?i:0,r="both"===t?i[1]:"rows"===t?i:0,n="hasHeader"in e&&e.hasHeader;let a;a=!function(e){return void 0===e.bottom}(e)||n?!(Ei(e)&&!n)||"columns"!==t:"rows"!==t;const l={...e};return a&&"MOVE"===o&&(l.left+=s,l.top+=r),void 0!==l.right&&(l.right+=s),void 0!==l.bottom&&(l.bottom+=r),l}function vi(e,t){let o,i;const{left:s,right:r,top:n,bottom:a}=e,{left:l,right:c,top:h,bottom:d}=t;return o=l!=s?l:c!=r?c:l,i=h!=n?h:d!=a?d:h,{col:o,row:i}}function Si(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 Ci(e){return{left:e.col,right:e.col,top:e.row,bottom:e.row}}function Ei(e){return void 0===e.right}function wi(e){return(e.bottom-e.top+1)*(e.right-e.left+1)}function yi(...e){return e.length<2||1===di(e.map(ei),[]).length}class xi{getSheetSize;_zone;parts;invalidXc;prefixSheet=!1;sheetId;invalidSheetName;constructor(e,t){this.getSheetSize=t,this._zone=e.zone,this.parts=e.parts,this.prefixSheet=e.prefixSheet,this.invalidXc=e.invalidXc,this.sheetId=e.sheetId,this.invalidSheetName=e.invalidSheetName}static fromRange(e,t){return e instanceof xi?e:new xi(e,t.getSheetSize)}get unboundedZone(){return this._zone}get zone(){const{left:e,top:t,bottom:o,right:i}=this._zone;if(void 0!==i&&void 0!==o)return{left:e,top:t,right:i,bottom:o};if(void 0===o&&void 0!==i)return{right:i,top:t,left:e,bottom:this.getSheetSize(this.sheetId).numberOfRows-1};if(void 0===i&&void 0!==o)return{bottom:o,left:e,top:t,right:this.getSheetSize(this.sheetId).numberOfCols-1};throw new Error(r("Bad zone format"))}static getRangeParts(e,t){const o=e.split(":").map((e=>{const t=Zo(e);return{colFixed:!t&&e.startsWith("$"),rowFixed:t?e.startsWith("$"):e.includes("$",1)}})),i=void 0===t.bottom,s=void 0===t.right;return i&&(o[0].rowFixed=o[0].rowFixed||o[1].rowFixed,o[1].rowFixed=o[0].rowFixed||o[1].rowFixed,t.left===t.right&&(o[0].colFixed=o[0].colFixed||o[1].colFixed,o[1].colFixed=o[0].colFixed||o[1].colFixed)),s&&(o[0].colFixed=o[0].colFixed||o[1].colFixed,o[1].colFixed=o[0].colFixed||o[1].colFixed,t.top===t.bottom&&(o[0].rowFixed=o[0].rowFixed||o[1].rowFixed,o[1].rowFixed=o[0].rowFixed||o[1].rowFixed)),o}get isFullCol(){return void 0===this._zone.bottom}get isFullRow(){return void 0===this._zone.right}get rangeData(){return{_zone:this._zone,_sheetId:this.sheetId}}orderZone(){const e={...this._zone};let t=this.parts;if(void 0!==e.right&&e.right<e.left){let o=e.right;e.right=e.left,e.left=o,t=[{colFixed:t[1]?.colFixed||!1,rowFixed:t[0]?.rowFixed||!1},{colFixed:t[0]?.colFixed||!1,rowFixed:t[1]?.rowFixed||!1}]}if(void 0!==e.bottom&&e.bottom<e.top){let o=e.bottom;e.bottom=e.top,e.top=o,t=[{colFixed:t[0]?.colFixed||!1,rowFixed:t[1]?.rowFixed||!1},{colFixed:t[1]?.colFixed||!1,rowFixed:t[0]?.rowFixed||!1}]}return this.clone({zone:e,parts:t})}clone(e){return new xi({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 Ii(e,t,o){const i=o.sheetId===e?t:o.sheetId;return o.clone({sheetId:i})}function Ri(e,t,o){return o?e.getRangeFromSheetXC(t,o):void 0}function Ti(e,t,o){const i=[];return t.forEach((t=>{const s=function(e,t){e=e.toLocaleLowerCase();let o=0,i=0,s=(t=t.toLocaleLowerCase()).length,r=0;for(let n=0;n<s;n++)t[n]===e[r]?(r++,i+=100+i-n/200):i=0,o+=i;return r===e.length?o:0}(e,o(t));s>0&&i.push({score:s,elem:t})})),i.sort(((e,t)=>t.score-e.score)),i.map((e=>e.elem))}function Ai(e){const t=[];for(let o=0;o<e;o++){const e={cells:{}};t.push(e)}return t}function Oi(e,t=1){return t*(e+B)-B}const Ni={};function Mi(e,t,o){const i=Fi(o);if(Ni[i]||(Ni[i]={}),void 0===Ni[i][t]){e.save(),e.font=i;const o=e.measureText(t).width;e.restore(),Ni[i][t]=o}return Ni[i][t]}function _i(e){return Math.round(96*e/72)}function Fi(e){return`${e.italic?"italic ":""}${e.bold?"bold":q} ${Di(e)}px ${j}`}function Di(e){return _i(e?.fontSize||Z)}function Li(e,t,o,i){if(Mi(e,t,i)<=o)return[t];const s=[];let r="";for(let n of t){Mi(e,r+n,i)>o?(s.push(r),r=n):r+=n}return s.push(r),s}function Pi(e,t,o,i){o||(o={});const s=[],r=t.includes(fe)?t.split(fe):[t];for(const t of r){const r=t.includes(" ")?t.split(" "):[t];if(!i){s.push(t);continue}let n="",a=i;for(let t of r){const r=Li(e,t,i,o),l=r.pop(),c=Mi(e,l,o);if(r.length)""!==n&&(s.push(n),n="",a=i),r.forEach((e=>{s.push(e)})),n=l,a=i-c;else{const t=""===n?l:" "+l,r=Mi(e,t,o);r<=a?(n+=t,a-=r):(s.push(n),n=l,a=i-c)}}""!==n&&s.push(n)}return s}function ki(e){return e?e.toLowerCase():""}class Ui{isFastIdStrategy=!1;fastIdStart=0;setIsFastStrategy(e){this.isFastIdStrategy=e}uuidv4(){return this.isFastIdStrategy?(this.fastIdStart++,String(this.fastIdStart)):window.crypto&&window.crypto.getRandomValues?([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g,(e=>(e^crypto.getRandomValues(new Uint8Array(1))[0]&15>>e/4).toString(16))):"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(e){var t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)}))}}class Vi extends t.Component{static template="o-spreadsheet-ChartJsComponent";canvas=t.useRef("graphContainer");chart;get background(){return this.chartRuntime.background}get canvasStyle(){return`background-color: ${this.background}`}get chartRuntime(){const e=this.env.model.getters.getChartRuntime(this.props.figure.id);if(!("chartJsConfig"in e))throw new Error("Unsupported chart runtime");return e}setup(){t.onMounted((()=>{const e=this.chartRuntime;this.createChart(e.chartJsConfig)}));let e=this.chartRuntime;t.onPatched((()=>{const t=this.chartRuntime;qe(e,t)||(this.updateChartJs(t),e=t)}))}createChart(e){const t=this.canvas.el.getContext("2d");this.chart=new window.Chart(t,e)}updateChartJs(e){const t=e.chartJsConfig;t.data&&t.data.datasets?(this.chart.data=t.data,t.options?.title&&(this.chart.config.options.title=t.options.title),t.options&&"valueLabel"in t.options&&t.options?.valueLabel&&(this.chart.config.options.valueLabel=t.options.valueLabel)):this.chart.data.datasets=void 0,this.chart.config.options.tooltips=t.options?.tooltips,this.chart.config.options.legend=t.options?.legend,this.chart.config.options.scales=t.options?.scales,this.chart.update({duration:0})}}Vi.props={figure:Object};const zi={};let Bi=0;function Hi(e,...t){const o="__sheet__"+Bi++;return function(e,t){const o=document.createElement("style");o.textContent=function(e){const t=e.split(/(\{|\}|;)/).map((e=>e.trim())),o=[],i=[];let s=[];function r(e,t){const i=[];for(const s of o[e]){let n=t&&t+" "+s||s;n.includes("&")&&(n=s.replace(/&/g,t||"")),e<o.length-1&&(n=r(e+1,n)),i.push(n)}return i.join(", ")}function n(){s.length&&(i.push(r(0)+" {"),i.push(...s),i.push("}"),s=[])}for(;t.length;){let e=t.shift();"}"===e?(n(),o.pop()):("{"===t[0]&&(n(),o.push(e.split(/\s*,\s*/)),t.shift()),";"===t[0]&&s.push(" "+e+";"))}return i.join("\n")}(t),zi[e]=o}(o,String.raw(e,...t)),function(e){const t=zi[e];t.setAttribute("component",e),document.head.appendChild(t)}(o),o}function $i({strikethrough:e,underline:t}){return e||t?`${e?"line-through":""} ${t?"underline":""}`:"none"}function Wi(e){const t=Gi(e);return e?(e.fillColor&&(t.background=e.fillColor),t):t}function Gi(e){const t={};if(!e)return t;if(e.bold&&(t["font-weight"]="bold"),e.italic&&(t["font-style"]="italic"),e.strikethrough||e.underline){let o=e.strikethrough?"line-through":"";o=e.underline?o+" underline":o,t["text-decoration"]=o}return e.textColor&&(t.color=e.textColor),t}function qi(e){return Object.entries(e).filter((([e,t])=>void 0!==t)).map((([e,t])=>`${e}:${t};`)).join(" ")}const Zi=1.2;Hi`
1
+ !function(e,t){"use strict";let o=e=>e;function i(e,...t){if(1===t.length&&"object"==typeof t[0]){const o=t[0];e=e.replace(/\%\(?([^\)]+)\)s/g,((e,t)=>o[t]))}else t.length>0&&(e=e.replace(/\%s/g,(()=>t.shift())));return e}const s=function(e,...t){return i(o(e),...t)},r=function(e,...t){return new n(e,t)};class n extends String{values;constructor(e,t){super(e),this.values=t}valueOf(){const e=super.valueOf();return i(o(e),...this.values)}toString(){return this.valueOf()}}var a,l;!function(e){e.NotAvailable="#N/A",e.InvalidReference="#REF",e.BadExpression="#BAD_EXPR",e.CircularDependency="#CYCLE",e.UnknownFunction="#NAME?",e.GenericError="#ERROR"}(a||(a={})),function(e){e[e.silent=0]="silent",e[e.error=1]="error"}(l||(l={}));class c extends Error{errorType;logLevel;constructor(e,t,o=l.error){super(t),this.errorType=e,this.logLevel=o}}class h extends c{constructor(e){super(a.BadExpression,e)}}class d extends c{constructor(){super(a.CircularDependency,r("Circular reference"))}}class u extends c{constructor(){super(a.InvalidReference,r("Invalid reference"))}}class g extends c{constructor(e){super(a.NotAvailable,e||r("Data not available"),e?l.error:l.silent)}}class p extends c{constructor(e){super(a.UnknownFunction,r('Unknown function: "%s"',e))}}const m=.5,f="#f5f5f5",b="#F8F9FA",v="#E8EAED",S="#595959",C="#666666",E="#3266ca",w="#FFFFFF",y="#EBEBEB",x="#CACACA",I=11982760,R="#01666b",T="#188038",A="#E6F4EA",O="#CEEAD6",N="#E0E2E4",M="#4A4F59",_=["#000000","#434343","#666666","#999999","#B7B7B7","#CCCCCC","#D9D9D9","#EFEFEF","#F3F3F3","#FFFFFF","#980000","#FF0000","#FF9900","#FFFF00","#00FF00","#00FFFF","#4A86E8","#0000FF","#9900FF","#FF00FF","#E6B8AF","#F4CCCC","#FCE5CD","#FFF2CC","#D9EAD3","#D0E0E3","#C9DAF8","#CFE2F3","#D9D2E9","#EAD1DC","#DD7E6B","#EA9999","#F9CB9C","#FFE599","#B6D7A8","#A2C4C9","#A4C2F4","#9FC5E8","#B4A7D6","#D5A6BD","#CC4125","#E06666","#F6B26B","#FFD966","#93C47D","#76A5AF","#6D9EEB","#6FA8DC","#8E7CC3","#C27BA0","#A61C00","#CC0000","#E69138","#F1C232","#6AA84F","#45818E","#3C78D8","#3D85C6","#674EA7","#A64D79","#85200C","#990000","#B45F06","#BF9000","#38761D","#134F5C","#1155CC","#0B5394","#351C75","#741B47","#5B0F00","#660000","#783F04","#7F6000","#274E13","#0C343D","#1C4587","#073763","#20124D","#4C1130"],F=26,D=48,L=96,P=23,k=15,U=18,V=14,z=4,B=4,H=3,$=B,W=17,G=250,q="400",Z=10,j="'Roboto', arial",Y="bottom",X="overflow",K="thin",Q="#000000",J={style:"thin",color:T},ee=a.InvalidReference,te="START_REVISION",oe=1,ie=20,se="??",re="difference",ne="#00A04A",ae="#DC6965",le=.4,ce=["'","*","?","/","\\","[","]"],he=/'|\*|\?|\/|\\|\[|\]/,de="|",ue=r("Invalid expression");var ge;!function(e){e[e.Grid=0]="Grid",e[e.Highlight=5]="Highlight",e[e.Figure=10]="Figure",e[e.ScrollBar=15]="ScrollBar",e[e.GridPopover=19]="GridPopover",e[e.GridComposer=20]="GridComposer",e[e.Dropdown=21]="Dropdown",e[e.IconPicker=25]="IconPicker",e[e.TopBarComposer=30]="TopBarComposer",e[e.Popover=35]="Popover",e[e.FigureAnchor=1e3]="FigureAnchor",e[e.FigureSnapLine=1001]="FigureSnapLine"}(ge||(ge={}));let pe=0;function me(){return pe}const fe="\n",be=[6,7,8,9,10,11,12,14,18,24,36];function ve(e){return JSON.stringify(e,Object.keys(e).sort())}function Se(e){return'"'===e[0]&&(e=e.slice(1)),'"'===e[e.length-1]&&"\\"!==e[e.length-2]?e.slice(0,e.length-1):e}function Ce(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Ee(e){const t=Array.isArray(e)?[]:{};switch(typeof e){case"object":if(null===e)return e;if(function(e){return"clone"in e&&e.clone instanceof Function}(e))return e.clone();if(!(function(e){return"object"==typeof e&&e?.constructor===Object}(e)||e instanceof Array))throw new Error("Unsupported type: only objects and arrays are supported");for(const o in e)t[o]=Ee(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 we(e){return e.startsWith("'")&&(e=e.slice(1,-1).replace(/''/g,"'")),e}function ye(e){return e.match(/\w/g)?.length!==e.length&&(e=`'${e}'`),e}function xe(e,t,o){return e<t?t:e>o?o:e}function Ie(e,t,o=1){if(t<=e&&o>0)return[];if(0===o)throw new Error("range() step must not be zero");const i=Math.ceil(Math.abs((t-e)/o)),s=Array(i);for(let t=0;t<i;t++)s[t]=e+t*o;return s}function Re(e){return e.reduce(((e,t,o,i)=>{if(1===Math.abs(t-i[o-1])){e[e.length-1].push(t)}else e.push([t]);return e}),[])}function*Te(e,t){t.next();for(const o of e){const e=t.next();yield{...o,next:e.done?void 0:e.value}}}const Ae=/^\[([^\[]+)\]\((.+)\)$/,Oe=/^https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,4}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)$/;function Ne(e){return Ae.test(e)}function Me(e){return Oe.test(e)}function _e(e,t){return`[${e}](${t})`}function Fe(e){const t=e.match(Ae)||[],o=t[1],i=t[2];if(!o||!i)throw new Error(`Could not parse markdown link ${e}.`);return{label:o,url:i}}const De="o-spreadsheet://";function Le(e){return e.startsWith(De)}function Pe(e){return`${De}${e}`}function ke(e){if(e.startsWith(De))return e.substr(De.length);throw new Error(`${e} is not a valid sheet link`)}function Ue(e){return void 0!==e}function Ve(e){return void 0===e||Object.values(e).every((e=>"object"==typeof e?Ve(e):!e))}function ze(e,t){for(let[o,i]of Object.entries(t))if(ve(i)===ve(e))return parseInt(o,10);const o=Object.keys(t),i=0===o.length?0:Math.max(...o.map((e=>parseInt(e,10))));return t[i+1]=e,i+1}function Be(e,t,o){let i;return function(){const s=this,r=arguments;const n=o&&!i;clearTimeout(i),i=setTimeout((function(){i=null,o||e.apply(s,r)}),t),n&&e.apply(s,r)}}function He(e){let t="";for(let o=0,i=e.length;o<i;o++)t+=e[o];return t}function $e(e){let t,o=!1;const i=()=>(o||(t=e instanceof Function?e():e,o=!0),t);return i.map=e=>$e((()=>e(i()))),i}function We(e,t){let o=e.slice(t).find((e=>e));return o||(o=e.slice(0,t).reverse().find((e=>e))),o||""}function Ge(e,t){return"after"===e?t+1:t}function qe(e,t){if(e===t)return!0;if(e&&!t||t&&!e)return!1;const o=new Set;Object.keys(e).forEach((e=>o.add(e))),Object.keys(t).forEach((e=>o.add(e)));for(let i of o){if(typeof e[i]!=typeof e[i])return!1;if("object"==typeof e[i]){if(!qe(e[i],t[i]))return!1}else if(e[i]!==t[i])return!1}return!0}function Ze(e){const t={...e};return Object.keys(t).forEach((e=>!t[e]&&delete t[e])),t}function je(e,t=(e=>e)){if(!e.length)return[];const o=Array(e[0].length);for(let i=0;i<e[0].length;i++){o[i]=Array(e.length);for(let s=0;s<e.length;s++)o[i][s]=t(e[s][i])}return o}const Ye=[" ","\t","\f","\v",String.fromCharCode(parseInt("00a0",16)),String.fromCharCode(parseInt("1680",16)),String.fromCharCode(parseInt("2000",16)),String.fromCharCode(parseInt("200a",16)),String.fromCharCode(parseInt("2028",16)),String.fromCharCode(parseInt("2029",16)),String.fromCharCode(parseInt("202f",16)),String.fromCharCode(parseInt("205f",16)),String.fromCharCode(parseInt("3000",16)),String.fromCharCode(parseInt("feff",16))],Xe=new RegExp(Ye.join("|"),"g"),Ke=/\r\n|\r|\n/g;function Qe(e){return e?e=(e=e.replace(Xe," ")).replace(Ke,fe):""}function Je(e){const t=Array.from(e).sort(((e,t)=>e-t));for(let e=1;e<t.length;e++)if(t[e]-t[e-1]!=1)return!1;return!0}class et extends Set{add(...e){for(const t of e)super.add(t);return this}delete(...e){let t=!1;for(const o of e)t||=super.delete(o);return t}}function tt(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 ot(e,t){return e.filter(((e,o)=>!t.includes(o)))}const it=/rgba?\(|\s+|\)/gi,st=/^#([A-F\d]{2}){3,4}$/,rt=["#eb6d00","#0074d9","#ad8e00","#169ed4","#b10dc9","#00a82d","#00a3a3","#f012be","#3d9970","#111111","#62A300","#ff4136","#949494","#85144b","#001f3f"];function nt(e){return at(e.toString(16).padStart(6,"0"))}function at(e){let t=e;if(e.startsWith("rgb")?t=function(e){const t=e.replace(it,"").split(",");let o=255;if(3!==t.length&&4!==t.length)throw new Error("invalid color");if(4===t.length){const e=parseFloat(t.pop()||"1");o=Math.round(255*(e||1))}const i=t.map((e=>parseInt(e,10)));255!==o&&i.push(o);return"#"+He(i.map((e=>e.toString(16).padStart(2,"0")))).toUpperCase()}(e):(t=e.replace("#","").toUpperCase(),3!==t.length&&4!==t.length||(t=t.split("").reduce(((e,t)=>e+t+t),"")),t=`#${t}`),!st.test(t))throw new Error(`invalid color input: ${e}`);return t}function lt(e){try{return at(e),!0}catch(e){return!1}}const ct=e=>e>=0&&e<=255;function ht(e,t,o,i=1){if(!ct(e)||!ct(t)||!ct(o)||i<0||i>1)throw new Error(`Invalid RGBA values ${[e,t,o,i]}`);return{a:i,b:o,g:t,r:e}}function dt(e){let{r:t,g:o,b:i}=gt(e);t/=255,o/=255,i/=255;const s=e=>e<=.03928?e/12.92:((e+.055)/1.055)**2.4;return.2126*s(t)+.7152*s(o)+.0722*s(i)}function ut(e){let t=e.r.toString(16),o=e.g.toString(16),i=e.b.toString(16),s=Math.round(255*e.a).toString(16);return 1===t.length&&(t="0"+t),1===o.length&&(o="0"+o),1===i.length&&(i="0"+i),1===s.length&&(s="0"+s),"ff"===s&&(s=""),("#"+t+o+i+s).toUpperCase()}function gt(e){let t,o,i,s;if(7===(e=at(e)).length)t=parseInt(e[1]+e[2],16),o=parseInt(e[3]+e[4],16),i=parseInt(e[5]+e[6],16),s=255;else{if(9!==e.length)throw new Error("Invalid color");t=parseInt(e[1]+e[2],16),o=parseInt(e[3]+e[4],16),i=parseInt(e[5]+e[6],16),s=parseInt(e[7]+e[8],16)}return s=+(s/255).toFixed(3),{a:s,r:t,g:o,b:i}}function pt(e){(e={...e}).s/=100,e.l/=100;let t=(1-Math.abs(2*e.l-1))*e.s,o=t*(1-Math.abs(e.h/60%2-1)),i=e.l-t/2,s=0,r=0,n=0;return 0<=e.h&&e.h<60?(s=t,r=o,n=0):60<=e.h&&e.h<120?(s=o,r=t,n=0):120<=e.h&&e.h<180?(s=0,r=t,n=o):180<=e.h&&e.h<240?(s=0,r=o,n=t):240<=e.h&&e.h<300?(s=o,r=0,n=t):300<=e.h&&e.h<360&&(s=t,r=0,n=o),s=Math.round(255*(s+i)),r=Math.round(255*(r+i)),n=Math.round(255*(n+i)),{a:e.a,r:s,g:r,b:n}}function mt(e){const t=e.r/255,o=e.g/255,i=e.b/255;let s=Math.min(t,o,i),r=Math.max(t,o,i),n=r-s,a=0,l=0,c=0;return a=0===n?0:r===t?(o-i)/n%6:r===o?(i-t)/n+2:(t-o)/n+4,a=Math.round(60*a),a<0&&(a+=360),c=(r+s)/2,l=0===n?0:n/(1-Math.abs(2*c-1)),l=+(100*l).toFixed(1),c=+(100*c).toFixed(1),{a:e.a,h:a,s:l,l:c}}function ft(e){return ut(pt(e))}function bt(e){return mt(gt(e))}function vt(e){if(e<0)throw new Error(`number must be positive. Got ${e}`);return e<26?String.fromCharCode(65+e):vt(Math.floor(e/26)-1)+vt(e%26)}const St={};for(const e of"ABCDEFGHIJKLMNOPQRSTUVWXYZ"){const t=e.charCodeAt(0)-64;St[e]=t,St[e.toLowerCase()]=t}function Ct(e){let t=-1;let o=1;for(let i=e.length-1;i>=0;i--){t+=St[e[i]]*o,o*=26}return t}function Et(e){return e>="A"&&e<="Z"||e>="a"&&e<="z"}function wt(e){return e>="0"&&e<="9"}function yt(e){let t;e=e.trim();for(let o=0;o<e.length;o++){const i=e[o];if(!t){if("$"===i&&0===o||Et(i))continue;t=o}if(!wt(i)){if("$"===i&&o===t)continue;throw new Error(`Invalid cell description: ${e}`)}}if(!t||t===e.length)throw new Error(`Invalid cell description: ${e}`);const o="$"===e[0]?e.slice(1,t):e.slice(0,t),i="$"===e[t]?e.slice(t+1):e.slice(t);if(o.length<1||o.length>3||i.length<1||i.length>7)throw new Error(`Invalid cell description: ${e}`);const s=Ct(o),r=Number(i)-1;if(isNaN(r))throw new Error(`Invalid cell description: ${e}`);return{col:s,row:r}}function xt(e,t,o={colFixed:!1,rowFixed:!1}){return(o.colFixed?"$":"")+vt(e)+(o.rowFixed?"$":"")+String(t+1)}const It=new Date(1899,11,30),Rt=864e5,Tt=2e3,At=(new Date).getFullYear(),Ot=(new Date).getMonth(),Nt=new Date(0)-It,Mt=/^\d{1,2}(\/|-|\s)\d{1,2}((\/|-|\s)\d{1,4})?$/,_t=/^\d{3,4}(\/|-|\s)\d{1,2}(\/|-|\s)\d{1,2}$/,Ft=/\/|-|\s/,Dt=/^(\d{1,4})[\/-\s](\d{1,4})([\/-\s](\d{1,4}))?$/,Lt=/((\d+(:\d+)?(:\d+)?\s*(AM|PM))|(\d+:\d+(:\d+)?))$/;function Pt(e,t){return null!==kt(e,t)}function kt(e,t){let o=null;const i=(e=e.trim()).match(Lt);if(i){if(o=function(e){if(e=e.trim(),Lt.test(e)){const t=/AM/i.test(e),o=/PM/i.test(e),i=(t||o?e.substring(0,e.length-2).trim():e).split(/:/),s=i.length>=2,r=3===i.length;let n=Number(i[0]),a=s?Number(i[1]):0,l=r?Number(i[2]):0,c=r?"hh:mm:ss":"hh:mm";if(t||o)c+=" a";else if(!s)return null;n>=12&&t?n-=12:n<12&&o&&(n+=12),a+=Math.floor(l/60),l%=60,n+=Math.floor(a/60),a%=60,n>=24&&(c="hhhh:mm:ss");return{value:n/24+a/1440+l/86400,format:c,jsDate:new Date(1899,11,30,n,a,l)}}return null}(i[0]),null===o)return null;e=e.replace(i[0],"").trim()}let s=null;const r=function(e,t){const o=e.match(Dt);if(!o)return null;const[,i,s,,r]=o;if(i.length>2&&r&&r.length>2)return null;if(i.length>2)return{year:i,month:s,day:r,dateString:e,type:"ymd"};const n=function(e){switch(e.dateFormat[0]){case"d":return"dmy";case"m":return"mdy";case"y":return"ymd"}throw new Error("Invalid date format in locale")}(t);if(!r)return s.length>2?{month:i,year:s,day:void 0,dateString:e,type:n}:"dmy"===n?{day:i,month:s,year:r,dateString:e,type:"dmy"}:{month:i,day:s,year:r,dateString:e,type:"mdy"};if(r.length>2)return"mdy"===n?{month:i,day:s,year:r,dateString:e,type:"mdy"}:{day:i,month:s,year:r,dateString:e,type:"dmy"};if("mdy"===n)return{month:i,day:s,year:r,dateString:e,type:"mdy"};if("ymd"===n)return{year:i,month:s,day:r,dateString:e,type:"ymd"};if("dmy"===n)return{day:i,month:s,year:r,dateString:e,type:"dmy"};return null}(e,t);if(r){const t=r.dateString.match(Ft)[0];if(s=function(e,t){let{year:o,month:i,day:s}=e;const r=function(e){if(!e)return Ot;const t=Number(e);if(t>=1&&t<=12)return t-1;return null}(i),n=function(e){if(!e)return 1;const t=Number(e);if(t>=0&&t<=31)return t;return null}(s),a=function(e){if(!e)return At;const t=Number(e);switch(e.length){case 1:return Tt+t;case 2:return Tt+(Tt+t>At+10?-100:0)+t;case 3:case 4:return t}return null}(o);if(null===a||null===r||null===n)return null;const l=2===i?.length&&r+1<10||2===s?.length&&n<10,c=2!==o?.length,h=new Date(a,r,n);if(h.getMonth()!==r||h.getDate()!==n)return null;const d=h-It,u=function(e,t,o,i){const s=e.year?i?"yyyy":"yy":void 0,r=e.month?o?"mm":"m":void 0,n=e.day?o?"dd":"d":void 0;switch(e.type){case"mdy":return[r,n,s].filter(Ue).join(t);case"ymd":return[s,r,n].filter(Ue).join(t);case"dmy":return[n,r,s].filter(Ue).join(t)}}(e,t,l,c);return{value:Math.round(d/Rt),format:u,jsDate:h}}(r,t),null===s)return null;e=e.replace(r.dateString,"").trim()}return""!==e||!s&&!o?null:s&&s.jsDate&&o&&o.jsDate?{value:s.value+o.value,format:s.format+" "+("hhhh:mm:ss"===o.format?"hh:mm:ss":o.format),jsDate:new Date(s.jsDate.getFullYear()+o.jsDate.getFullYear()-1899,s.jsDate.getMonth()+o.jsDate.getMonth()-11,s.jsDate.getDate()+o.jsDate.getDate()-30,s.jsDate.getHours()+o.jsDate.getHours(),s.jsDate.getMinutes()+o.jsDate.getMinutes(),s.jsDate.getSeconds()+o.jsDate.getSeconds())}:s||o}function Ut(e){const t=Math.trunc(e);let o=new Date(t*Rt-Nt),i=e-t;i=i<0?1+i:i;const s=Math.round(24*i),r=Math.round(24*(i-s/24)*60),n=Math.round(24*(i-s/24-r/24/60)*60*60);return o.setHours(s),o.setMinutes(r),o.setSeconds(n),o}function Vt(e){const t=e.getTime()-It.getTime();return Math.round(t/Rt)}function zt(e){return new Date(e.getFullYear(),e.getMonth()+1,0).getDate()}function Bt(e){return zt(e)===e.getDate()}function Ht(e,t,o){const i=e.getFullYear(),s=e.getMonth(),r=e.getDate(),n=new Date(i,s+t);return o&&r===zt(e)||r>zt(n)?n.setDate(zt(n)):n.setDate(r),n}function $t(e){const t=Math.trunc(e);return t%4==0&&t%100!=0||t%400==0}function Wt(e,t,o){if(e===t)return 0;if(e>t){const o=t;t=e,e=o}const i=Ut(e),s=Ut(t);let r=i.getDate(),n=s.getDate();const a=i.getMonth(),l=s.getMonth(),c=i.getFullYear(),h=s.getFullYear();let d=0,u=0;switch(o){case 0:31===r&&(r=30),30===r&&31===n&&(n=30),1===a&&r===($t(c)?29:28)&&(r=30,1===l&&n===($t(h)?29:28)&&(n=30)),d=c+(30*a+r)/360,u=h+(30*l+n)/360;break;case 1:let o=365;const i=c===h;if(!i&&!(c+1===h)||!i&&a<l||!i&&a===l&&r<n){let e=0,t=0;for(let o=c;o<=h;o++)e++,t+=$t(o)?366:365;o=t/e}else i?$t(c)&&(o=366):($t(c)&&a<2&&(o=366),$t(h)&&(l>1||1===l&&29===n)&&(o=366));d=e/o,u=t/o;break;case 2:d=e/360,u=t/360;break;case 3:d=e/365,u=t/365;break;case 4:31===r&&(r=30),31===n&&(n=30),d=c+(30*a+r)/360,u=h+(30*l+n)/360}return u-d}function Gt(e,t){const o=12*(t.getFullYear()-e.getFullYear())+t.getMonth()-e.getMonth();return e.getDate()>t.getDate()?o-1:o}function qt(e,t){const o=e.getTime(),i=t.getTime();return Math.floor((i-o)/Rt)}function Zt(e,t){const o=t.getFullYear()-e.getFullYear(),i=e.getMonth(),s=t.getMonth(),r=e.getDate(),n=t.getDate();return s>i||s===i&&n>=r?o:o-1}const jt=140,Yt=20,Xt=.035;function Kt(e){return Yt+(jt-Yt)*Math.exp(-Xt*(e-1))}const Qt=[{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:";"}],Jt=Qt[0],eo=tt((function(e){return e=Ce(e),new RegExp(`(^-?\\d+(${e}?\\d*(e\\d+)?)?|^-?${e}\\d+)(?!\\w|!)`)})),to=tt((function(e){const t=Ce(e.decimalSeparator),o="(\\s*"+`(\\d+(${Ce(e.thousandsSeparator)}\\d{3,})*(${t}\\d*)?)`+"|"+`(${t}\\d+)`+")(e(\\+|-)?\\d+)?(\\s*%)?",i="(\\s*-)?",s="(\\s*[\\$€])?",r="^(("+[i+s+o,i+o+s,s+i+o].join(")|(")+"))$";return new RegExp(r,"i")}));function oo(e,t){return!!e&&to(t).test(e.trim())}const io=tt((function(e){return new RegExp(`[$€${Ce(e.thousandsSeparator)}]`,"g")}));function so(e,t){"."!==t.decimalSeparator&&(e=e.replace(t.decimalSeparator,".")),e=e.replace(io(t),"");let o=Number(e);return isNaN(o)&&e.includes("%")&&(o=Number(e.split("%")[0]),!isNaN(o))?o/100:o}function ro(e,t,o){const i=[...e].sort(((e,t)=>e-t));let s=(i.length+(o?-1:1))*t;if(o||s--,Number.isInteger(s))return i[s];const r=Math.ceil(s),n=Math.floor(s);return i[r]*(s-n)+i[n]*(r-s)}const no=20,ao=11,lo=/(\d+?)(?=(\d{3})+(?!\d)|$)/g,co=/0/g,ho={0:r("January"),1:r("February"),2:r("March"),3:r("April"),4:r("May"),5:r("June"),6:r("July"),7:r("August"),8:r("September"),9:r("October"),10:r("November"),11:r("December")},uo={0:r("Sunday"),1:r("Monday"),2:r("Tuesday"),3:r("Wednesday"),4:r("Thursday"),5:r("Friday"),6:r("Saturday")},go={};function po(e){let t=go[e];return void 0===t&&(t=function(e){if(""===e)throw new Error("A format cannot be empty");let t=0,o=[];for(;t<e.length;){let i;if("["===e.charAt(t)){if("$"!==e.charAt(t+1))throw new Error(`Currency formats have to be prefixed by a $: ${e}`);if(i=e.substring(t+1).indexOf("]")+t+2,0===i)throw new Error(`Invalid currency brackets format: ${e}`);const s=e.substring(t+2,i-1);if(s.includes("["))throw new Error(`Invalid currency format: ${e}`);o.push({type:"STRING",format:s})}else{const s=e.substring(t).indexOf("[");i=s>-1?s+t:e.length;const r=e.substring(t,i);wo(r)?o.push({type:"DATE",format:r}):o.push({type:"NUMBER",format:ko(r)})}t=i}return o}(e),go[e]=t),t}function mo(e,{format:t,locale:o}){switch(typeof e){case"string":return e;case"boolean":return e?"TRUE":"FALSE";case"number":t||(t=Ao(e));return function(e,t,o){if("DATE"===t[0].type)return xo(e,t[0].format);let i=e<0?"-":"";for(let s of t)switch(s.type){case"NUMBER":i+=fo(Math.abs(e),s.format,o);break;case"STRING":i+=s.format}return i}(e,po(t),o);case"object":return"0"}}function fo(e,t,o){t.isPercent&&(e*=100),e/=t.magnitude;let i=0;void 0!==t.decimalPart&&(i=t.decimalPart.length);const{integerDigits:s,decimalDigits:r}=vo(e,i);let n=function(e,t,o){const i="0"===e?"":e;let s=i;const r=t.length-i.length;if(r>0){const e=(t.substring(0,r).match(co)||[]).length;s="0".repeat(e)+s}o&&(s=s.match(lo)?.join(o)||s);return s}(s,t.integerPart,t.thousandsSeparator?o.thousandsSeparator:void 0);return void 0!==t.decimalPart&&(n+=o.decimalSeparator+function(e,t){let o=e;if(t.length-e.length>0){const i=(t.substring(e.length,t.length+1).match(co)||[]).length;o+="0".repeat(i)}return o}(r||"",t.decimalPart)),t.isPercent&&(n+="%"),n}const bo=[];function vo(e,t=no){const o=e.toString();if(o.includes("e"))return function(e,t=no){let o=bo[t];o||(o=new Intl.NumberFormat("en-US",{maximumFractionDigits:t,useGrouping:!1}),bo[t]=o);const[i,s]=o.format(e).split(".");return{integerDigits:i,decimalDigits:s}}(e,t);if(Number.isInteger(e))return{integerDigits:o,decimalDigits:void 0};const i=o.indexOf(".");let s=o.substring(0,i),r=o.substring(i+1);if(0===t)return Number(r[0])>=5&&(s=(Number(s)+1).toString()),{integerDigits:s,decimalDigits:void 0};if(r.length>t){const{integerDigits:e,decimalDigits:o}=function(e,t){let o="0",i=e,s=e.slice(0,t);const r=t;if(Number(e[r])<5)return{integerDigits:o,decimalDigits:s};const n=s.match(Co)?.[0]||"",a=(Number(s)+1).toString(),l=s.slice(n.length),c=a.length>l.length;c&&!n?(o="1",i=void 0):i=c?n.slice(0,-1)+a:n+a;return{integerDigits:o,decimalDigits:i}}(r,t);r=o,"0"!==e&&(s=(Number(s)+Number(e)).toString())}return{integerDigits:s,decimalDigits:So(r||"")}}function So(e){let t=e.length-1;for(;t>=0&&"0"===e[t];)t--;return e.slice(0,t+1)||void 0}const Co=/^0+/;function Eo(e,t){const{integerDigits:o,decimalDigits:i}=vo(e,20);return i?o+t+i:o}function wo(e){if(!yo.has(e[0]))return!1;try{return xo(1,e),!0}catch(e){return!1}}const yo=new Set(["h","m","y","d"]);function xo(e,t){const o=Ut(e),i=t.indexOf("h");let s="",r="";return i>0?(s=Io(o,t.substring(0,i-1)),r=Ro(o,t.substring(i))):0===i?r=Ro(o,t):i<0&&(s=Io(o,t)),s+(s&&r?" ":"")+r}function Io(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 uo[e.getDay()].slice(0,3);case"dddd":return uo[e.getDay()];case"m":return e.getMonth()+1;case"mm":return String(e.getMonth()+1).padStart(2,"0");case"mmm":return ho[e.getMonth()].slice(0,3);case"mmmm":return ho[e.getMonth()];case"mmmmm":return ho[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 Ro(e,t){let o=t.split(/:|\s/);const i=e.getHours(),s="a"===o[o.length-1];let r=i,n="";return s&&(r=0===r?12:r>12?r-12:r,n=i>=12?" PM":" AM",o.pop()),o.map((o=>{switch(o){case"hhhh":return Math.floor((e.getTime()-It)/36e5).toString();case"hh":return r.toString().padStart(2,"0");case"mm":return e.getMinutes().toString().padStart(2,"0");case"ss":return e.getSeconds().toString().padStart(2,"0");default:throw new Error(`invalid format: ${t}`)}})).join(":")+n}const To=tt((function(e){return new RegExp(`[0-9]+${Ce(e.decimalSeparator)}[0-9]`)}));function Ao(e){let{integerDigits:t,decimalDigits:o}=vo(e);if(!o)return"0";const i=t.replace("-","").length;if(i+2>ao)return"0";const s=ao-i-1;return({decimalDigits:o}=vo(e,Math.min(s,o.length))),o?"0."+"0".repeat(o.length):"0"}function Oo(e,t){if(!Pt(e,t))return;return kt(e,t).format}function No(e){if(!oo(e,Jt))return;const t=e.includes(".")?"0.00":"0",o=e.match(/[\$€]/);if(o){const i=e.match(/[\d]/),s="[$"+o.values().next().value+"]";return i.index<o.index?"#,##"+t+s:s+"#,##"+t}return e.includes("%")?t+"%":void 0}function Mo(e){const t=e.decimalPlaces??2,o=e.position??"before",i=e.code??"",s=e.symbol??"",r="#,##0"+(t?"."+"0".repeat(t):"");let n=`${i} ${s}`.trim();return"after"===o&&i&&(n=" "+n),function(e,t,o){const i=`[$${e}]`;return"before"===t?i+o:o+i}(n,o,r)}function _o(e){return Vo(po(e).map((e=>"NUMBER"===e.type?{type:e.type,format:{...e.format,decimalPart:void 0}}:e)))}function Fo(e,t,o,i){return Vo(po(e||"#,##0").map((e=>"NUMBER"===e.type?[{...e,format:{...e.format,magnitude:t,decimalPart:void 0}},{type:"STRING",format:o}]:e)).flat())}function Do(e,t,o){const i=po(e).map((e=>"NUMBER"===e.type?{...e,format:Lo(e.format,t)}:e)),s=Vo(i);return go[s]=i,s}function Lo(e,t){const o={...e},i=Math.sign(t),s=o.decimalPart?.length||0,r=Math.min(Math.max(0,s+i),no);return o.decimalPart="0".repeat(r),""===o.decimalPart&&delete o.decimalPart,o}const Po=/,*?$/;function ko(e){if(function(e){return Boolean(e.replace(Uo,""))}(e=e.trim()))throw new Error(`Invalid number format: ${e}`);const t=e.includes("%"),o=e.match(Po)?.[0]||"",i=o?1e3**o.length:1;let s=e.slice(0,e.length-(o.length||0));const r=s.includes(",");if(/\..*,/.test(s))throw new Error("A format can't contain ',' symbol in the decimal part");s=s.replace("%","").replace(",","");const n=s.match(/[\%|,]/);if(n)throw new Error(`A format can only contain a single '${n[0]}' symbol`);const[a,l]=s.split(".");if(l&&l.length>20)throw new Error("A format can't contain more than 20 decimal places");return void 0!==l?{integerPart:a,isPercent:t,thousandsSeparator:r,decimalPart:l,magnitude:i}:{integerPart:a,isPercent:t,thousandsSeparator:r,magnitude:i}}const Uo=/[,#0.%]/g;function Vo(e){let t="";for(let o of e){let e;switch(o.type){case"NUMBER":const t=o.format;e=t.integerPart,t.thousandsSeparator&&(e=e.slice(0,-3)+","+e.slice(-3)),void 0!==t.decimalPart&&(e+="."+t.decimalPart),t.isPercent&&(e+="%"),t.magnitude&&(e+=",".repeat(Math.log10(t.magnitude)/3));break;case"STRING":e=`[$${o.format}]`;break;case"DATE":e=o.format}t+=e}return t}const zo=new RegExp(/\$?([A-Z]{1,3})\$?([0-9]{1,7})/,"i"),Bo=new RegExp(/^\$?([A-Z]{1,3})\$?([0-9]{1,7})$/,"i"),Ho=new RegExp(/^([A-Z]{1,3})+$/,"i"),$o=new RegExp(/^\s*('.+'!|[^']+!)?\$?([A-Z]{1,3})$/,"i"),Wo=new RegExp(/^\s*('.+'!|[^']+!)?\$?([0-9]{1,7})$/,"i"),Go=new RegExp(/^\s*('.+'!|[^']+!)?/.source+"("+[zo.source,/(\$?[A-Z]{1,3})?\$?[0-9]{1,7}\s*:\s*(\$?[A-Z]{1,3})?\$?[0-9]{1,7}\s*/i.source,/\$?[A-Z]{1,3}(\$?[0-9]{1,7})?\s*:\s*\$?[A-Z]{1,3}(\$?[0-9]{1,7})?\s*/i.source].join("|")+")"+/$/.source,"i");function qo(e){return $o.test(e)}function Zo(e){return Wo.test(e)}function jo(e){return Ho.test(e)}function Yo(e){return Bo.test(e)}function Xo(e){const t=e.split("!"),o=t.pop();return{sheetName:we(t.join("!"))||void 0,xc:o}}function Ko(e){const t=function(e){let t,o,i,s,r;e.includes("!")&&(e=e.split("!").at(-1)),e.includes("$")&&(e=e.replace(/\$/g,"")),t=e.includes(":")?e.split(":").map((e=>e.trim())):[e.trim()];let n=!1,a=!1,l=!1;const c=t[0],h=t[1]&&t[1];if(qo(c))s=r=Ct(c),o=i=0,n=!0;else if(Zo(c))o=i=parseInt(c,10)-1,s=r=0,a=!0;else{const e=yt(c);s=r=e.col,o=i=e.row,l=!0}if(2===t.length)if(qo(h))r=Ct(h),n=!0;else if(Zo(h))i=parseInt(h,10)-1,a=!0;else{const e=yt(h);r=e.col,i=e.row,o=n?i:o,s=a?r:s,l=!0}if(n&&a)throw new Error("Wrong zone xc. The zone cannot be at the same time a full column and a full row");const d={top:o,left:s,bottom:n?void 0:i,right:a?void 0:r};return l=l&&(a||n),l&&(d.hasHeader=l),d}(e);if(void 0!==t.right&&t.right<t.left){const e=t.left;t.left=t.right,t.right=e}if(void 0!==t.bottom&&t.bottom<t.top){const e=t.top;t.top=t.bottom,t.bottom=e}return t}function Qo(e){const t=Ko(e);if(void 0===t.bottom||void 0===t.right)throw new Error("This does not support unbounded ranges");return t}function Jo(e){const{bottom:t,top:o,left:i,right:s}=e;return!(void 0!==t&&isNaN(t)||isNaN(o)||isNaN(i)||void 0!==s&&isNaN(s))&&((void 0===e.bottom||e.bottom>=e.top&&e.bottom>=0)&&(void 0===e.right||e.right>=e.left&&e.right>=0)&&e.top>=0&&e.left>=0)}function ei(e){const{top:t,bottom:o,left:i,right:s}=e,n="hasHeader"in e&&e.hasHeader,a=t===o&&i===s;if(void 0===o&&void 0!==s)return 0!==t||n?`${xt(i,t)}:${vt(s)}`:`${vt(i)}:${vt(s)}`;if(void 0===s&&void 0!==o)return 0!==i||n?`${xt(i,t)}:${o+1}`:`${t+1}:${o+1}`;if(void 0!==o&&void 0!==s)return a?xt(i,t):`${xt(i,t)}:${xt(s,o)}`;throw new Error(r("Bad zone format"))}function ti(e,t,o,i,s){const r="left"===t?"columns":"rows",n="before"===i?o-1:o,a=e["left"===t?"right":"bottom"];return e[t]<=n&&a&&a>n?bi(e,r,"RESIZE",s):n<e[t]?bi(e,r,"MOVE",s):{...e}}function oi(e,t,o,i,s){const r="left"===t?"columns":"rows",n="before"===i?o-1:o,a="left"===t?"right":"bottom";return e[t]<=n&&e[a]>n?bi(e,r,"RESIZE",s):n<e[t]?bi(e,r,"MOVE",s):{...e}}function ii(e,t,o){const i="left"===t?"right":"bottom";let s=e[t],r=e[i];for(let n of o.sort(((e,t)=>t-e)))e[t]>n&&(s--,r--),e[t]<n&&e[i]>=n&&r--;return{...e,[t]:s,[i]:r}}function si(e,t,o){const i="left"===t?"right":"bottom";let s=e[t],r=e[i];const n=e[i];for(let i of o.sort(((e,t)=>t-e)))e[t]>i&&(s--,void 0!==r&&r--),void 0!==n&&void 0!==r&&e[t]<=i&&n>=i&&r--;if(!(void 0!==r&&s>r))return{...e,[t]:s,[i]:r}}function ri(...e){return{top:Math.min(...e.map((e=>e.top))),left:Math.min(...e.map((e=>e.left))),bottom:Math.max(...e.map((e=>e.bottom))),right:Math.max(...e.map((e=>e.right)))}}function ni(e,t){if(li(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 ai(e,t){return e.left===t.left&&e.right===t.right&&e.top===t.top&&e.bottom===t.bottom}function li(e,t){return!(e.bottom<t.top||t.bottom<e.top)&&!(e.right<t.left||t.right<e.left)}function ci(e,t,o){const{left:i,right:s,top:r,bottom:n}=o;return e>=i&&e<=s&&t>=r&&t<=n}function hi(e,t){return ai(ri(t,e),t)}function di(e,t){const o=e.map(Ko),i=t.map(Qo),s=Math.max(...o.concat(i).map((e=>e.bottom||0))),r=Math.max(...o.concat(i).map((e=>e.right||0))),n=o.map((e=>({...e,bottom:void 0===e.bottom?s+1:e.bottom,right:void 0===e.right?r+1:e.right}))),a=i.map((e=>({...e,bottom:void 0===e.bottom?s+1:e.bottom,right:void 0===e.right?r+1:e.right}))),l=function(e,t){const o=new Set(t.map((({col:e,row:t})=>`${e}-${t}`)));return e.filter((({col:e,row:t})=>!o.has(`${e}-${t}`)))}(n.map(mi).flat(),a.map(mi).flat()),c=function(e){if(0===e.length)return[];const[t,...o]=[...e].sort(((e,t)=>e.row-t.row)).sort(((e,t)=>e.col-t.col)),i=[];let s=Ci(t);for(const{col:e,row:t}of o)if(!ci(e,t,s))if(e===s.left&&t===s.bottom+1){const e=s.bottom+1;s={...s,bottom:e}}else i.push(s),s=Ci({col:e,row:t});return[...i,s]}(l);return function(e){if(0===e.length)return[];if(e.some((e=>e.left!==e.right)))throw new Error("only columns can be merged");const t=[],o=ui(e),i=(e,t)=>e.top===t.top&&e.bottom===t.bottom&&e.right+1===t.left;for(;o.length;){const e=o.reduce(((e,t)=>i(e,t)?ri(e,t):e),o.shift());t.push(e)}return ui(t)}(c).map((e=>({...e,bottom:e.bottom===s+1?void 0:e.bottom,right:e.right===r+1?void 0:e.right}))).map(ei)}function ui(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=>hi(e,t)))||o.push(e)}return o.reverse()}function gi(e){return{numberOfRows:e.bottom-e.top+1,numberOfCols:e.right-e.left+1}}function pi(e){const{numberOfCols:t,numberOfRows:o}=gi(e);return 1===t||1===o}function mi(e){const t=[],[o,i]=[e.right,e.left].sort(((e,t)=>e-t)),[s,r]=[e.top,e.bottom].sort(((e,t)=>e-t));for(const e of Ie(o,i+1))for(const o of Ie(s,r+1))t.push({col:e,row:o});return t}function fi(e,t){const{left:o,right:i,top:s,bottom:r}=e;for(let e=o;e<=i;e++)for(let o=s;o<=r;o++)t(e,o)}function bi(e,t,o,i){const s="both"===t?i[0]:"columns"===t?i:0,r="both"===t?i[1]:"rows"===t?i:0,n="hasHeader"in e&&e.hasHeader;let a;a=!function(e){return void 0===e.bottom}(e)||n?!(Ei(e)&&!n)||"columns"!==t:"rows"!==t;const l={...e};return a&&"MOVE"===o&&(l.left+=s,l.top+=r),void 0!==l.right&&(l.right+=s),void 0!==l.bottom&&(l.bottom+=r),l}function vi(e,t){let o,i;const{left:s,right:r,top:n,bottom:a}=e,{left:l,right:c,top:h,bottom:d}=t;return o=l!=s?l:c!=r?c:l,i=h!=n?h:d!=a?d:h,{col:o,row:i}}function Si(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 Ci(e){return{left:e.col,right:e.col,top:e.row,bottom:e.row}}function Ei(e){return void 0===e.right}function wi(e){return(e.bottom-e.top+1)*(e.right-e.left+1)}function yi(...e){return e.length<2||1===di(e.map(ei),[]).length}class xi{getSheetSize;_zone;parts;invalidXc;prefixSheet=!1;sheetId;invalidSheetName;constructor(e,t){this.getSheetSize=t,this._zone=e.zone,this.parts=e.parts,this.prefixSheet=e.prefixSheet,this.invalidXc=e.invalidXc,this.sheetId=e.sheetId,this.invalidSheetName=e.invalidSheetName}static fromRange(e,t){return e instanceof xi?e:new xi(e,t.getSheetSize)}get unboundedZone(){return this._zone}get zone(){const{left:e,top:t,bottom:o,right:i}=this._zone;if(void 0!==i&&void 0!==o)return{left:e,top:t,right:i,bottom:o};if(void 0===o&&void 0!==i)return{right:i,top:t,left:e,bottom:this.getSheetSize(this.sheetId).numberOfRows-1};if(void 0===i&&void 0!==o)return{bottom:o,left:e,top:t,right:this.getSheetSize(this.sheetId).numberOfCols-1};throw new Error(r("Bad zone format"))}static getRangeParts(e,t){const o=e.split(":").map((e=>{const t=Zo(e);return{colFixed:!t&&e.startsWith("$"),rowFixed:t?e.startsWith("$"):e.includes("$",1)}})),i=void 0===t.bottom,s=void 0===t.right;return i&&(o[0].rowFixed=o[0].rowFixed||o[1].rowFixed,o[1].rowFixed=o[0].rowFixed||o[1].rowFixed,t.left===t.right&&(o[0].colFixed=o[0].colFixed||o[1].colFixed,o[1].colFixed=o[0].colFixed||o[1].colFixed)),s&&(o[0].colFixed=o[0].colFixed||o[1].colFixed,o[1].colFixed=o[0].colFixed||o[1].colFixed,t.top===t.bottom&&(o[0].rowFixed=o[0].rowFixed||o[1].rowFixed,o[1].rowFixed=o[0].rowFixed||o[1].rowFixed)),o}get isFullCol(){return void 0===this._zone.bottom}get isFullRow(){return void 0===this._zone.right}get rangeData(){return{_zone:this._zone,_sheetId:this.sheetId}}orderZone(){const e={...this._zone};let t=this.parts;if(void 0!==e.right&&e.right<e.left){let o=e.right;e.right=e.left,e.left=o,t=[{colFixed:t[1]?.colFixed||!1,rowFixed:t[0]?.rowFixed||!1},{colFixed:t[0]?.colFixed||!1,rowFixed:t[1]?.rowFixed||!1}]}if(void 0!==e.bottom&&e.bottom<e.top){let o=e.bottom;e.bottom=e.top,e.top=o,t=[{colFixed:t[0]?.colFixed||!1,rowFixed:t[1]?.rowFixed||!1},{colFixed:t[1]?.colFixed||!1,rowFixed:t[0]?.rowFixed||!1}]}return this.clone({zone:e,parts:t})}clone(e){return new xi({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 Ii(e,t,o){const i=o.sheetId===e?t:o.sheetId;return o.clone({sheetId:i})}function Ri(e,t,o){return o?e.getRangeFromSheetXC(t,o):void 0}function Ti(e,t,o){const i=[];return t.forEach((t=>{const s=function(e,t){e=e.toLocaleLowerCase();let o=0,i=0,s=(t=t.toLocaleLowerCase()).length,r=0;for(let n=0;n<s;n++)t[n]===e[r]?(r++,i+=100+i-n/200):i=0,o+=i;return r===e.length?o:0}(e,o(t));s>0&&i.push({score:s,elem:t})})),i.sort(((e,t)=>t.score-e.score)),i.map((e=>e.elem))}function Ai(e){const t=[];for(let o=0;o<e;o++){const e={cells:{}};t.push(e)}return t}function Oi(e,t=1){return t*(e+B)-B}const Ni={};function Mi(e,t,o){const i=Fi(o);if(Ni[i]||(Ni[i]={}),void 0===Ni[i][t]){e.save(),e.font=i;const o=e.measureText(t).width;e.restore(),Ni[i][t]=o}return Ni[i][t]}function _i(e){return Math.round(96*e/72)}function Fi(e){return`${e.italic?"italic ":""}${e.bold?"bold":q} ${Di(e)}px ${j}`}function Di(e){return _i(e?.fontSize||Z)}function Li(e,t,o,i){if(Mi(e,t,i)<=o)return[t];const s=[];let r="";for(let n of t){Mi(e,r+n,i)>o?(s.push(r),r=n):r+=n}return s.push(r),s}function Pi(e,t,o,i){o||(o={});const s=[],r=t.includes(fe)?t.split(fe):[t];for(const t of r){const r=t.includes(" ")?t.split(" "):[t];if(!i){s.push(t);continue}let n="",a=i;for(let t of r){const r=Li(e,t,i,o),l=r.pop(),c=Mi(e,l,o);if(r.length)""!==n&&(s.push(n),n="",a=i),r.forEach((e=>{s.push(e)})),n=l,a=i-c;else{const t=""===n?l:" "+l,r=Mi(e,t,o);r<=a?(n+=t,a-=r):(s.push(n),n=l,a=i-c)}}""!==n&&s.push(n)}return s}function ki(e){return e?e.toLowerCase():""}class Ui{isFastIdStrategy=!1;fastIdStart=0;setIsFastStrategy(e){this.isFastIdStrategy=e}uuidv4(){return this.isFastIdStrategy?(this.fastIdStart++,String(this.fastIdStart)):window.crypto&&window.crypto.getRandomValues?([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g,(e=>(e^crypto.getRandomValues(new Uint8Array(1))[0]&15>>e/4).toString(16))):"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(e){var t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)}))}}class Vi extends t.Component{static template="o-spreadsheet-ChartJsComponent";canvas=t.useRef("graphContainer");chart;get background(){return this.chartRuntime.background}get canvasStyle(){return`background-color: ${this.background}`}get chartRuntime(){const e=this.env.model.getters.getChartRuntime(this.props.figure.id);if(!("chartJsConfig"in e))throw new Error("Unsupported chart runtime");return e}setup(){t.onMounted((()=>{const e=this.chartRuntime;this.createChart(e.chartJsConfig)}));let e=this.chartRuntime;t.onPatched((()=>{const t=this.chartRuntime;qe(e,t)||(this.updateChartJs(t),e=t)}))}createChart(e){const t=this.canvas.el.getContext("2d");this.chart=new window.Chart(t,e)}updateChartJs(e){const t=e.chartJsConfig;t.data&&t.data.datasets?(this.chart.data=t.data,t.options?.title&&(this.chart.config.options.title=t.options.title),t.options&&"valueLabel"in t.options&&t.options?.valueLabel&&(this.chart.config.options.valueLabel=t.options.valueLabel)):this.chart.data.datasets=void 0,this.chart.config.options.tooltips=t.options?.tooltips,this.chart.config.options.legend=t.options?.legend,this.chart.config.options.scales=t.options?.scales,this.chart.update({duration:0})}}Vi.props={figure:Object};const zi={};let Bi=0;function Hi(e,...t){const o="__sheet__"+Bi++;return function(e,t){const o=document.createElement("style");o.textContent=function(e){const t=e.split(/(\{|\}|;)/).map((e=>e.trim())),o=[],i=[];let s=[];function r(e,t){const i=[];for(const s of o[e]){let n=t&&t+" "+s||s;n.includes("&")&&(n=s.replace(/&/g,t||"")),e<o.length-1&&(n=r(e+1,n)),i.push(n)}return i.join(", ")}function n(){s.length&&(i.push(r(0)+" {"),i.push(...s),i.push("}"),s=[])}for(;t.length;){let e=t.shift();"}"===e?(n(),o.pop()):("{"===t[0]&&(n(),o.push(e.split(/\s*,\s*/)),t.shift()),";"===t[0]&&s.push(" "+e+";"))}return i.join("\n")}(t),zi[e]=o}(o,String.raw(e,...t)),function(e){const t=zi[e];t.setAttribute("component",e),document.head.appendChild(t)}(o),o}function $i({strikethrough:e,underline:t}){return e||t?`${e?"line-through":""} ${t?"underline":""}`:"none"}function Wi(e){const t=Gi(e);return e?(e.fillColor&&(t.background=e.fillColor),t):t}function Gi(e){const t={};if(!e)return t;if(e.bold&&(t["font-weight"]="bold"),e.italic&&(t["font-style"]="italic"),e.strikethrough||e.underline){let o=e.strikethrough?"line-through":"";o=e.underline?o+" underline":o,t["text-decoration"]=o}return e.textColor&&(t.color=e.textColor),t}function qi(e){return Object.entries(e).filter((([e,t])=>void 0!==t)).map((([e,t])=>`${e}:${t};`)).join(" ")}const Zi=1.2;Hi`
2
2
  div.o-scorecard {
3
3
  font-family: ${j};
4
4
  user-select: none;
@@ -2538,4 +2538,4 @@
2538
2538
  <tableParts count="${e.filterTables.length}">
2539
2539
  ${gE(a)}
2540
2540
  </tableParts>
2541
- `}var Cx;!function(e){e[e.Ready=0]="Ready",e[e.Running=1]="Running",e[e.RunningCore=2]="RunningCore",e[e.Finalizing=3]="Finalizing"}(Cx||(Cx={}));function Ex(e,t={}){const o=Ee(t);return o.type=e,o}const wx={},yx={MIN_ROW_HEIGHT:10,MIN_COL_WIDTH:5,HEADER_HEIGHT:F,HEADER_WIDTH:D,TOPBAR_HEIGHT:63,BOTTOMBAR_HEIGHT:36,DEFAULT_CELL_WIDTH:L,DEFAULT_CELL_HEIGHT:P,SCROLLBAR_WIDTH:k},xx={autofillModifiersRegistry:ar,autofillRulesRegistry:lr,cellMenuRegistry:ff,colMenuRegistry:kb,linkMenuRegistry:Ng,functionRegistry:cu,featurePluginRegistry:qw,statefulUIPluginRegistry:Zw,coreViewsPluginRegistry:jw,corePluginRegistry:Gw,rowMenuRegistry:zb,sidePanelRegistry:Ev,figureRegistry:$p,chartSidePanelComponentRegistry:lv,chartComponentRegistry:Up,chartRegistry:kp,topbarMenuRegistry:Bb,topbarComponentRegistry:wv,clickableCellRegistry:Yw,otRegistry:Hb,inverseCommandRegistry:Zp,urlRegistry:Ji,cellPopoverRegistry:Fg,numberFormatMenuRegistry:Ub,repeatLocalCommandTransformRegistry:Aw,repeatCommandTransformRegistry:Tw},Ix={arg:Ur,toBoolean:Ms,toJsDate:_s,toNumber:ys,toString:As,toXC:xt,toZone:Qo,toCartesian:yt,numberToLetters:vt,UuidGenerator:Ui,formatValue:mo,createCurrencyFormat:Mo,computeTextWidth:Mi,createEmptyWorkbookData:VE,createEmptySheet:UE,createEmptyExcelSheet:zE,getDefaultChartJsRuntime:dp,chartFontColor:jg,ChartColors:Zg,EvaluationError:c,CellErrorLevel:l,getFillingMode:mp,rgbaToHex:ut,colorToRGBA:gt,positionToZone:Ci,isDefined:Ue,lazy:$e,genericRepeat:Ow},Rx={isMarkdownLink:Ne,parseMarkdownLink:Fe,markdownLink:_e,openLink:ss,urlRepresentation:is},Tx={ChartPanel:cv,ChartFigure:zp,ChartJsComponent:Vi,Grid:bS,GridOverlay:tS,ScorecardChart:ji,LineConfigPanel:rv,LineBarPieDesignPanel:ov,BarConfigPanel:Yb,LineBarPieConfigPanel:jb,GaugeChartConfigPanel:iv,GaugeChartDesignPanel:sv,ScorecardChartConfigPanel:nv,ScorecardChartDesignPanel:av,FigureComponent:yv};const Ax={DEFAULT_LOCALE:Jt};e.AbstractChart=Lg,e.CorePlugin=HE,e.DispatchResult=ps,e.EvaluationError=c,e.Model=class extends lw{corePlugins=[];featurePlugins=[];statefulUIPlugins=[];coreViewsPlugins=[];range;session;isReplayingCommand=!1;renderers=[];status=0;config;corePluginConfig;uiPluginConfig;state;selection;getters;coreGetters;uuidGenerator;handlers=[];uiHandlers=[];coreHandlers=[];constructor(e={},o={},i=[],s=new Ui,r=!0){super(),i=PE(e,i);const n=DE(e,r);this.state=new _y,this.uuidGenerator=s,this.config=this.setupConfig(o),this.session=this.setupSession(n.revisionId),this.coreGetters={},this.range=new YE(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 My(this.getters),this.coreHandlers.push(this.range),this.handlers.push(this.range),this.corePluginConfig=this.setupCorePluginConfig(),this.uiPluginConfig=this.setupUiPluginConfig();for(let e of Gw.getAll())this.setupCorePlugin(e,n);Object.assign(this.getters,this.coreGetters),this.session.loadInitialMessages(i);for(let e of jw.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 Zw.getAll()){const t=this.setupUiPlugin(e);this.statefulUIPlugins.push(t),this.handlers.push(t),this.uiHandlers.push(t)}for(let e of qw.getAll()){const t=this.setupUiPlugin(e);this.featurePlugins.push(t),this.handlers.push(t),this.uiHandlers.push(t)}this.uuidGenerator.setIsFastStrategy(!1),this.dispatch("START"),this.selection.observe(this,{handleEvent:()=>this.trigger("update")}),this.setupSessionEvents(),this.joinSession(),o.snapshotRequested&&(this.session.snapshot(this.exportData()),this.garbageCollectExternalResources()),t.markRaw(this)}joinSession(){this.session.join(this.config.client)}leaveSession(){this.session.leave()}setupUiPlugin(e){const t=new e(this.uiPluginConfig);for(let o of e.getters){if(!(o in t))throw new Error(`Invalid getter name: ${o} for plugin ${t.constructor}`);if(o in this.getters)throw new Error(`Getter "${o}" is already defined.`);this.getters[o]=t[o].bind(t)}const o=e.layers.map((e=>[t,e]));return this.renderers.push(...o),this.renderers.sort(((e,t)=>e[1]-t[1])),t}setupCorePlugin(e,t){const o=new e(this.corePluginConfig);for(let t of e.getters){if(!(t in o))throw new Error(`Invalid getter name: ${t} for plugin ${o.constructor}`);if(t in this.coreGetters)throw new Error(`Getter "${t}" is already defined.`);this.coreGetters[t]=o[t].bind(o)}o.import(t),this.corePlugins.push(o),this.coreHandlers.push(o),this.handlers.push(o)}onRemoteRevisionReceived({commands:e}){for(let t of e){const e=this.status;this.status=2,this.dispatchToHandlers(this.statefulUIPlugins,t),this.status=e}this.finalize()}setupSession(e){return new bw(Ay({initialRevisionId:e,recordChanges:this.state.recordChanges.bind(this.state),dispatch:e=>{this.checkDispatchAllowed(e).isSuccessful&&(this.isReplayingCommand=!0,this.dispatchToHandlers(this.coreHandlers,e),this.isReplayingCommand=!1)}}),this.config.transportService,e)}setupSessionEvents(){this.session.on("remote-revision-received",this,this.onRemoteRevisionReceived),this.session.on("revision-undone",this,(({commands:e})=>{this.dispatchFromCorePlugin("UNDO",{commands:e}),this.finalize()})),this.session.on("revision-redone",this,(({commands:e})=>{this.dispatchFromCorePlugin("REDO",{commands:e}),this.finalize()})),this.session.on("unexpected-revision-id",this,(()=>this.trigger("unexpected-revision-id"))),this.session.on("collaborative-event-received",this,(()=>{this.trigger("update")}))}setupConfig(e){const t=e.client||{id:this.uuidGenerator.uuidv4(),name:r("Anonymous").toString()},o=e.transportService||new Sy;return{...e,mode:e.mode||"normal",custom:e.custom||{},defaultCurrencyFormat:e.defaultCurrencyFormat||"[$$]#,##0.00",external:this.setupExternalConfig(e.external||{}),transportService:o,client:t,moveClient:()=>{},snapshotRequested:!1,notifyUI:e=>this.trigger("notify-ui",e)}}setupExternalConfig(e){const t=e.loadLocales||(()=>Promise.resolve(Qt));return{...e,loadLocales:t}}setupCorePluginConfig(){return{getters:this.coreGetters,stateObserver:this.state,range:this.range,dispatch:this.dispatchFromCorePlugin,uuidGenerator:this.uuidGenerator,custom:this.config.custom,external:this.config.external}}setupUiPluginConfig(){return{getters:this.getters,stateObserver:this.state,dispatch:this.dispatch,selection:this.selection,moveClient:this.session.move.bind(this.session),custom:this.config.custom,uiActions:this.config,session:this.session}}checkDispatchAllowed(e){return gs(e)?this.checkDispatchAllowedCoreCommand(e):this.checkDispatchAllowedLocalCommand(e)}checkDispatchAllowedCoreCommand(e){const t=this.corePlugins.map((t=>t.allowDispatch(e)));return t.push(this.range.allowDispatch(e)),new ps(t.flat())}checkDispatchAllowedLocalCommand(e){const t=this.uiHandlers.map((t=>t.allowDispatch(e)));return new ps(t.flat())}finalize(){this.status=3;for(const e of this.handlers)e.finalize();this.status=0}canDispatch=(e,t)=>this.checkDispatchAllowed(Ex(e,t));dispatch=(e,t)=>{const o=Ex(e,t);let i=this.status;if(this.getters.isReadonly()&&(s=o,!ds.has(s.type)))return new ps(68);var s;if(!this.session.canApplyOptimisticUpdate())return new ps(65);switch(i){case 0:const t=this.checkDispatchAllowed(o);if(!t.isSuccessful)return t;this.status=1;const{changes:i,commands:s}=this.state.recordChanges((()=>{gs(o)&&this.state.addCommand(o),this.dispatchToHandlers(this.handlers,o),this.finalize()}));this.session.save(o,s,i),this.status=0,this.trigger("update");break;case 1:if(gs(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(gs(o))throw new Error(`A UI plugin cannot dispatch ${e} while handling a core command`);this.dispatchToHandlers(this.handlers,o)}return ps.Success};dispatchFromCorePlugin=(e,t)=>{const o=Ex(e,t),i=this.status;this.status=2;const s=this.isReplayingCommand?this.coreHandlers:this.handlers;return this.dispatchToHandlers(s,o),this.status=i,ps.Success};dispatchToHandlers(e,t){for(const o of e)o.beforeHandle(t);for(const o of e)o.handle(t)}drawGrid(e){for(let[t,o]of this.renderers)e.ctx.save(),t.drawGrid(e,o),e.ctx.restore()}exportData(){let e=VE();for(let t of this.handlers)t instanceof HE&&t.export(e);return e.revisionId=this.session.getRevisionId()||te,e=Ee(e),e}updateMode(e){"normal"!==e&&this.dispatch("STOP_EDITION",{cancel:!0}),this.config.mode=e,this.trigger("update")}exportXLSX(){this.dispatch("EVALUATE_CELLS");let e={...VE(),sheets:[zE(FE,"Sheet1")]};for(let t of this.handlers)t instanceof BE&&t.exportForExcel(e);return e=Ee(e),vx(e)}garbageCollectExternalResources(){for(const e of this.corePlugins)e.garbageCollectExternalResources()}},e.Registry=Ki,e.Revision=mw,e.SPREADSHEET_DIMENSIONS=yx,e.Spreadsheet=vy,e.UIPlugin=XE,e.__info__=wx,e.addFunction=function(e,t){cu.add(e,t)},e.astToFormula=Wu,e.compile=ig,e.components=Tx,e.constants=Ax,e.convertAstNodes=zu,e.coreTypes=us,e.findCellInNewZone=vi,e.functionCache=og,e.helpers=Ix,e.invalidateCFEvaluationCommands=hs,e.invalidateDependenciesCommands=cs,e.invalidateEvaluationCommands=ls,e.iterateAstNodes=Bu,e.links=Rx,e.load=DE,e.parse=Uu,e.readonlyAllowedCommands=ds,e.registries=xx,e.setDefaultSheetViewSize=function(e){pe=e},e.setTranslationMethod=function(e){o=e},e.tokenize=fu,Object.defineProperty(e,"__esModule",{value:!0}),wx.version="16.4.1",wx.date="2023-07-26T12:13:04.992Z",wx.hash="e687fa9"}(this.o_spreadsheet=this.o_spreadsheet||{},owl);
2541
+ `}var Cx;!function(e){e[e.Ready=0]="Ready",e[e.Running=1]="Running",e[e.RunningCore=2]="RunningCore",e[e.Finalizing=3]="Finalizing"}(Cx||(Cx={}));function Ex(e,t={}){const o=Ee(t);return o.type=e,o}const wx={},yx={MIN_ROW_HEIGHT:10,MIN_COL_WIDTH:5,HEADER_HEIGHT:F,HEADER_WIDTH:D,TOPBAR_HEIGHT:63,BOTTOMBAR_HEIGHT:36,DEFAULT_CELL_WIDTH:L,DEFAULT_CELL_HEIGHT:P,SCROLLBAR_WIDTH:k},xx={autofillModifiersRegistry:ar,autofillRulesRegistry:lr,cellMenuRegistry:ff,colMenuRegistry:kb,linkMenuRegistry:Ng,functionRegistry:cu,featurePluginRegistry:qw,statefulUIPluginRegistry:Zw,coreViewsPluginRegistry:jw,corePluginRegistry:Gw,rowMenuRegistry:zb,sidePanelRegistry:Ev,figureRegistry:$p,chartSidePanelComponentRegistry:lv,chartComponentRegistry:Up,chartRegistry:kp,topbarMenuRegistry:Bb,topbarComponentRegistry:wv,clickableCellRegistry:Yw,otRegistry:Hb,inverseCommandRegistry:Zp,urlRegistry:Ji,cellPopoverRegistry:Fg,numberFormatMenuRegistry:Ub,repeatLocalCommandTransformRegistry:Aw,repeatCommandTransformRegistry:Tw},Ix={arg:Ur,toBoolean:Ms,toJsDate:_s,toNumber:ys,toString:As,toXC:xt,toZone:Qo,toCartesian:yt,numberToLetters:vt,UuidGenerator:Ui,formatValue:mo,createCurrencyFormat:Mo,computeTextWidth:Mi,createEmptyWorkbookData:VE,createEmptySheet:UE,createEmptyExcelSheet:zE,getDefaultChartJsRuntime:dp,chartFontColor:jg,ChartColors:Zg,EvaluationError:c,CellErrorLevel:l,getFillingMode:mp,rgbaToHex:ut,colorToRGBA:gt,positionToZone:Ci,isDefined:Ue,lazy:$e,genericRepeat:Ow},Rx={isMarkdownLink:Ne,parseMarkdownLink:Fe,markdownLink:_e,openLink:ss,urlRepresentation:is},Tx={ChartPanel:cv,ChartFigure:zp,ChartJsComponent:Vi,Grid:bS,GridOverlay:tS,ScorecardChart:ji,LineConfigPanel:rv,LineBarPieDesignPanel:ov,BarConfigPanel:Yb,LineBarPieConfigPanel:jb,GaugeChartConfigPanel:iv,GaugeChartDesignPanel:sv,ScorecardChartConfigPanel:nv,ScorecardChartDesignPanel:av,FigureComponent:yv};const Ax={DEFAULT_LOCALE:Jt};e.AbstractChart=Lg,e.CorePlugin=HE,e.DispatchResult=ps,e.EvaluationError=c,e.Model=class extends lw{corePlugins=[];featurePlugins=[];statefulUIPlugins=[];coreViewsPlugins=[];range;session;isReplayingCommand=!1;renderers=[];status=0;config;corePluginConfig;uiPluginConfig;state;selection;getters;coreGetters;uuidGenerator;handlers=[];uiHandlers=[];coreHandlers=[];constructor(e={},o={},i=[],s=new Ui,r=!0){super(),i=PE(e,i);const n=DE(e,r);this.state=new _y,this.uuidGenerator=s,this.config=this.setupConfig(o),this.session=this.setupSession(n.revisionId),this.coreGetters={},this.range=new YE(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 My(this.getters),this.coreHandlers.push(this.range),this.handlers.push(this.range),this.corePluginConfig=this.setupCorePluginConfig(),this.uiPluginConfig=this.setupUiPluginConfig();for(let e of Gw.getAll())this.setupCorePlugin(e,n);Object.assign(this.getters,this.coreGetters),this.session.loadInitialMessages(i);for(let e of jw.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 Zw.getAll()){const t=this.setupUiPlugin(e);this.statefulUIPlugins.push(t),this.handlers.push(t),this.uiHandlers.push(t)}for(let e of qw.getAll()){const t=this.setupUiPlugin(e);this.featurePlugins.push(t),this.handlers.push(t),this.uiHandlers.push(t)}this.uuidGenerator.setIsFastStrategy(!1),this.dispatch("START"),this.selection.observe(this,{handleEvent:()=>this.trigger("update")}),this.setupSessionEvents(),this.joinSession(),o.snapshotRequested&&(this.session.snapshot(this.exportData()),this.garbageCollectExternalResources()),t.markRaw(this)}joinSession(){this.session.join(this.config.client)}leaveSession(){this.session.leave()}setupUiPlugin(e){const t=new e(this.uiPluginConfig);for(let o of e.getters){if(!(o in t))throw new Error(`Invalid getter name: ${o} for plugin ${t.constructor}`);if(o in this.getters)throw new Error(`Getter "${o}" is already defined.`);this.getters[o]=t[o].bind(t)}const o=e.layers.map((e=>[t,e]));return this.renderers.push(...o),this.renderers.sort(((e,t)=>e[1]-t[1])),t}setupCorePlugin(e,t){const o=new e(this.corePluginConfig);for(let t of e.getters){if(!(t in o))throw new Error(`Invalid getter name: ${t} for plugin ${o.constructor}`);if(t in this.coreGetters)throw new Error(`Getter "${t}" is already defined.`);this.coreGetters[t]=o[t].bind(o)}o.import(t),this.corePlugins.push(o),this.coreHandlers.push(o),this.handlers.push(o)}onRemoteRevisionReceived({commands:e}){for(let t of e){const e=this.status;this.status=2,this.dispatchToHandlers(this.statefulUIPlugins,t),this.status=e}this.finalize()}setupSession(e){return new bw(Ay({initialRevisionId:e,recordChanges:this.state.recordChanges.bind(this.state),dispatch:e=>{this.checkDispatchAllowed(e).isSuccessful&&(this.isReplayingCommand=!0,this.dispatchToHandlers(this.coreHandlers,e),this.isReplayingCommand=!1)}}),this.config.transportService,e)}setupSessionEvents(){this.session.on("remote-revision-received",this,this.onRemoteRevisionReceived),this.session.on("revision-undone",this,(({commands:e})=>{this.dispatchFromCorePlugin("UNDO",{commands:e}),this.finalize()})),this.session.on("revision-redone",this,(({commands:e})=>{this.dispatchFromCorePlugin("REDO",{commands:e}),this.finalize()})),this.session.on("unexpected-revision-id",this,(()=>this.trigger("unexpected-revision-id"))),this.session.on("collaborative-event-received",this,(()=>{this.trigger("update")}))}setupConfig(e){const t=e.client||{id:this.uuidGenerator.uuidv4(),name:r("Anonymous").toString()},o=e.transportService||new Sy;return{...e,mode:e.mode||"normal",custom:e.custom||{},defaultCurrencyFormat:e.defaultCurrencyFormat||"[$$]#,##0.00",external:this.setupExternalConfig(e.external||{}),transportService:o,client:t,moveClient:()=>{},snapshotRequested:!1,notifyUI:e=>this.trigger("notify-ui",e)}}setupExternalConfig(e){const t=e.loadLocales||(()=>Promise.resolve(Qt));return{...e,loadLocales:t}}setupCorePluginConfig(){return{getters:this.coreGetters,stateObserver:this.state,range:this.range,dispatch:this.dispatchFromCorePlugin,uuidGenerator:this.uuidGenerator,custom:this.config.custom,external:this.config.external}}setupUiPluginConfig(){return{getters:this.getters,stateObserver:this.state,dispatch:this.dispatch,selection:this.selection,moveClient:this.session.move.bind(this.session),custom:this.config.custom,uiActions:this.config,session:this.session}}checkDispatchAllowed(e){return gs(e)?this.checkDispatchAllowedCoreCommand(e):this.checkDispatchAllowedLocalCommand(e)}checkDispatchAllowedCoreCommand(e){const t=this.corePlugins.map((t=>t.allowDispatch(e)));return t.push(this.range.allowDispatch(e)),new ps(t.flat())}checkDispatchAllowedLocalCommand(e){const t=this.uiHandlers.map((t=>t.allowDispatch(e)));return new ps(t.flat())}finalize(){this.status=3;for(const e of this.handlers)e.finalize();this.status=0}canDispatch=(e,t)=>this.checkDispatchAllowed(Ex(e,t));dispatch=(e,t)=>{const o=Ex(e,t);let i=this.status;if(this.getters.isReadonly()&&(s=o,!ds.has(s.type)))return new ps(68);var s;if(!this.session.canApplyOptimisticUpdate())return new ps(65);switch(i){case 0:const t=this.checkDispatchAllowed(o);if(!t.isSuccessful)return t;this.status=1;const{changes:i,commands:s}=this.state.recordChanges((()=>{gs(o)&&this.state.addCommand(o),this.dispatchToHandlers(this.handlers,o),this.finalize()}));this.session.save(o,s,i),this.status=0,this.trigger("update");break;case 1:if(gs(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(gs(o))throw new Error(`A UI plugin cannot dispatch ${e} while handling a core command`);this.dispatchToHandlers(this.handlers,o)}return ps.Success};dispatchFromCorePlugin=(e,t)=>{const o=Ex(e,t),i=this.status;this.status=2;const s=this.isReplayingCommand?this.coreHandlers:this.handlers;return this.dispatchToHandlers(s,o),this.status=i,ps.Success};dispatchToHandlers(e,t){for(const o of e)o.beforeHandle(t);for(const o of e)o.handle(t)}drawGrid(e){for(let[t,o]of this.renderers)e.ctx.save(),t.drawGrid(e,o),e.ctx.restore()}exportData(){let e=VE();for(let t of this.handlers)t instanceof HE&&t.export(e);return e.revisionId=this.session.getRevisionId()||te,e=Ee(e),e}updateMode(e){"normal"!==e&&this.dispatch("STOP_EDITION",{cancel:!0}),this.config.mode=e,this.trigger("update")}exportXLSX(){this.dispatch("EVALUATE_CELLS");let e={...VE(),sheets:[zE(FE,"Sheet1")]};for(let t of this.handlers)t instanceof BE&&t.exportForExcel(e);return e=Ee(e),vx(e)}garbageCollectExternalResources(){for(const e of this.corePlugins)e.garbageCollectExternalResources()}},e.Registry=Ki,e.Revision=mw,e.SPREADSHEET_DIMENSIONS=yx,e.Spreadsheet=vy,e.UIPlugin=XE,e.__info__=wx,e.addFunction=function(e,t){cu.add(e,t)},e.astToFormula=Wu,e.compile=ig,e.components=Tx,e.constants=Ax,e.convertAstNodes=zu,e.coreTypes=us,e.findCellInNewZone=vi,e.functionCache=og,e.helpers=Ix,e.invalidateCFEvaluationCommands=hs,e.invalidateDependenciesCommands=cs,e.invalidateEvaluationCommands=ls,e.iterateAstNodes=Bu,e.links=Rx,e.load=DE,e.parse=Uu,e.readonlyAllowedCommands=ds,e.registries=xx,e.setDefaultSheetViewSize=function(e){pe=e},e.setTranslationMethod=function(e){o=e},e.tokenize=fu,Object.defineProperty(e,"__esModule",{value:!0}),wx.version="16.5.0-alpha.1",wx.date="2023-07-26T12:11:43.109Z",wx.hash="9160731"}(this.o_spreadsheet=this.o_spreadsheet||{},owl);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@odoo/o-spreadsheet",
3
- "version": "16.4.1",
3
+ "version": "16.5.0-alpha.1",
4
4
  "description": "A spreadsheet component",
5
5
  "main": "dist/o-spreadsheet.cjs.js",
6
6
  "browser": "dist/o-spreadsheet.iife.js",
@@ -133,6 +133,6 @@
133
133
  "*": "prettier --write"
134
134
  },
135
135
  "publishConfig": {
136
- "tag": "latest"
136
+ "tag": "alpha"
137
137
  }
138
138
  }