@odoo/o-spreadsheet 16.2.0-alpha.3 → 16.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{o_spreadsheet.cjs.js → o-spreadsheet.cjs.js} +15002 -14928
- package/dist/{o_spreadsheet.d.ts → o-spreadsheet.d.ts} +97 -96
- package/dist/{o_spreadsheet.esm.js → o-spreadsheet.esm.js} +15003 -14929
- package/dist/{o_spreadsheet.iife.js → o-spreadsheet.iife.js} +15023 -14949
- package/dist/o-spreadsheet.iife.min.js +2431 -0
- package/package.json +11 -10
- package/readme.md +3 -1
- package/dist/o_spreadsheet.iife.min.js +0 -2398
|
@@ -1,2398 +0,0 @@
|
|
|
1
|
-
!function(e,t){"use strict";let i=e=>e;function o(e,...t){if(1===t.length&&"object"==typeof t[0]){const i=t[0];e=e.replace(/\%\(?([^\)]+)\)s/g,((e,t)=>i[t]))}else t.length>0&&(e=e.replace(/\%s/g,(()=>t.shift())));return e}const n=function(e,...t){return o(i(e),...t)},s=function(e,...t){return new r(e,t)};class r extends String{constructor(e,t){super(e),this.values=t}valueOf(){const e=super.valueOf();return o(i(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{constructor(e,t,i=l.error){super(t),this.errorType=e,this.logLevel=i}}class h extends c{constructor(e){super(a.BadExpression,e)}}class d extends c{constructor(){super(a.CircularDependency,s("Circular reference"))}}class u extends c{constructor(){super(a.InvalidReference,s("Invalid reference"))}}class g extends c{constructor(e){super(a.NotAvailable,e||s("Data not available"),e?l.error:l.silent)}}class p extends c{constructor(e){super(a.UnknownFunction,s('Unknown function: "%s"',e))}}const m=.5,f="#f5f5f5",v="#F8F9FA",b="#E8EAED",S="#595959",C="#666666",E="#3266ca",w="#FFFFFF",y=11982760,x="#01666b",I="#188038",R="#E6F4EA",T="#CEEAD6",A="#E0E2E4",M=["#000000","#434343","#666666","#999999","#b7b7b7","#cccccc","#d9d9d9","#efefef","#f3f3f3","#ffffff","#980000","#ff0000","#ff9900","#ffff00","#00ff00","#00ffff","#4a86e8","#0000ff","#9900ff","#ff00ff","#e6b8af","#f4cccc","#fce5cd","#fff2cc","#d9ead3","#d0e0e3","#c9daf8","#cfe2f3","#d9d2e9","#ead1dc","#dd7e6b","#ea9999","#f9cb9c","#ffe599","#b6d7a8","#a2c4c9","#a4c2f4","#9fc5e8","#b4a7d6","#d5a6bd","#cc4125","#e06666","#f6b26b","#ffd966","#93c47d","#76a5af","#6d9eeb","#6fa8dc","#8e7cc3","#c27ba0","#a61c00","#cc0000","#e69138","#f1c232","#6aa84f","#45818e","#3c78d8","#3d85c6","#674ea7","#a64d79","#85200c","#990000","#b45f06","#bf9000","#38761d","#134f5c","#1155cc","#0b5394","#351c75","#741b47","#5b0f00","#660000","#783f04","#7f6000","#274e13","#0c343d","#1c4587","#073763","#20124d","#4c1130"],O=26,N=48,_=96,F=23,D=15,k=18,L=14,P=4,U=4,V=3,z=U,B=17,H=250,$=1,W="400",G=10,q="'Roboto', arial",Z=["thin","#000"],j=["thin",I],X=/[ymd:]/,Y=a.InvalidReference,K="START_REVISION",Q=20,J="??",ee="difference",te="#00A04A",ie="#DC6965",oe=.4,ne=["'","*","?","/","\\","[","]"],se=/'|\*|\?|\/|\\|\[|\]/,re="|",ae=s("Invalid expression");var le;!function(e){e[e.Grid=0]="Grid",e[e.Highlight=5]="Highlight",e[e.Figure=10]="Figure",e[e.ScrollBar=15]="ScrollBar",e[e.Dropdown=16]="Dropdown",e[e.GridComposer=20]="GridComposer",e[e.TopBarComposer=21]="TopBarComposer",e[e.IconPicker=25]="IconPicker",e[e.Popover=30]="Popover",e[e.ChartAnchor=1e3]="ChartAnchor"}(le||(le={}));const ce="\n",he=[6,7,8,9,10,11,12,14,18,24,36],de=new Date(1899,11,30),ue=864e5,ge=2e3,pe=(new Date).getFullYear(),me=new Date(0)-de,fe=/^\d{1,2}(\/|-|\s)\d{1,2}((\/|-|\s)\d{1,4})?$/,ve=/^\d{3,4}(\/|-|\s)\d{1,2}(\/|-|\s)\d{1,2}$/,be=/((\d+(:\d+)?(:\d+)?\s*(AM|PM))|(\d+:\d+(:\d+)?))$/;function Se(e){let t;const i=(e=e.trim()).match(be);if(i){if(t=function(e){if(e=e.trim(),be.test(e)){const t=/AM/i.test(e),i=/PM/i.test(e),o=(t||i?e.substring(0,e.length-2).trim():e).split(/:/),n=o.length>=2,s=3===o.length;let r=Number(o[0]),a=n?Number(o[1]):0,l=s?Number(o[2]):0,c=s?"hh:mm:ss":"hh:mm";if(t||i)c+=" a";else if(!n)return null;r>=12&&t?r-=12:r<12&&i&&(r+=12),a+=Math.floor(l/60),l%=60,r+=Math.floor(a/60),a%=60,r>=24&&(c="hhhh:mm:ss");return{value:r/24+a/1440+l/86400,format:c,jsDate:new Date(1899,11,30,r,a,l)}}return null}(i[0]),null===t)return null;e=e.replace(i[0],"").trim()}let o;const n=e.match(fe),s=e.match(ve);if(n||s){let t;if(n?(t=n[0],o=Ce(t,"mdy")):(t=s[0],o=Ce(t,"ymd")),null===o)return null;e=e.replace(t,"").trim()}return""!==e||!o&&!t?null:o&&t?{value:o.value+t.value,format:o.format+" "+("hhhh:mm:ss"===t.format?"hh:mm:ss":t.format),jsDate:new Date(o.jsDate.getFullYear()+t.jsDate.getFullYear()-1899,o.jsDate.getMonth()+t.jsDate.getMonth()-11,o.jsDate.getDate()+t.jsDate.getDate()-30,o.jsDate.getHours()+t.jsDate.getHours(),o.jsDate.getMinutes()+t.jsDate.getMinutes(),o.jsDate.getSeconds()+t.jsDate.getSeconds())}:o||t}function Ce(e,t){const i="mdy"===t;if(i||"ymd"===t){const t=e.split(/\/|-|\s/),o=i?0:1,n=i?1:2,s=i?2:0,r=Number(t[o]),a=Number(t[n]),l=2===t[o].length&&r<10||2===t[n].length&&a<10,c=t[s]?function(e){const t=Number(e);switch(e.length){case 1:return ge+t;case 2:return ge+(ge+t>pe+10?-100:0)+t;case 3:case 4:return t}return 0}(t[s]):pe,h=new Date(c,r-1,a),d=e.match(/\/|-|\s/)[0];if(h.getMonth()!==r-1||h.getDate()!==a)return null;const u=h-de;let g=l?`mm${d}dd`:`m${d}d`;return t[s]&&(g=i?g+d+"yyyy":"yyyy"+d+g),{value:Math.round(u/ue),format:g,jsDate:h}}return null}function Ee(e){const t=Math.trunc(e);let i=new Date(t*ue-me),o=e-t;o=o<0?1+o:o;const n=Math.round(24*o),s=Math.round(24*(o-n/24)*60),r=Math.round(24*(o-n/24-s/24/60)*60*60);return i.setHours(n),i.setMinutes(s),i.setSeconds(r),i}function we(e){const t=e.getTime()-de.getTime();return Math.round(t/ue)}function ye(e){return new Date(e.getFullYear(),e.getMonth()+1,0).getDate()}function xe(e){return ye(e)===e.getDate()}function Ie(e,t,i){const o=e.getFullYear(),n=e.getMonth(),s=e.getDate(),r=new Date(o,n+t);return i&&s===ye(e)||s>ye(r)?r.setDate(ye(r)):r.setDate(s),r}function Re(e){const t=Math.trunc(e);return t%4==0&&t%100!=0||t%400==0}function Te(e,t,i){if(e===t)return 0;if(e>t){const i=t;t=e,e=i}const o=Ee(e),n=Ee(t);let s=o.getDate(),r=n.getDate();const a=o.getMonth(),l=n.getMonth(),c=o.getFullYear(),h=n.getFullYear();let d=0,u=0;switch(i){case 0:31===s&&(s=30),30===s&&31===r&&(r=30),1===a&&s===(Re(c)?29:28)&&(s=30,1===l&&r===(Re(h)?29:28)&&(r=30)),d=c+(30*a+s)/360,u=h+(30*l+r)/360;break;case 1:let i=365;const o=c===h;if(!o&&!(c+1===h)||!o&&a<l||!o&&a===l&&s<r){let e=0,t=0;for(let i=c;i<=h;i++)e++,t+=Re(i)?366:365;i=t/e}else o?Re(c)&&(i=366):(Re(c)&&a<2&&(i=366),Re(h)&&(l>1||1===l&&29===r)&&(i=366));d=e/i,u=t/i;break;case 2:d=e/360,u=t/360;break;case 3:d=e/365,u=t/365;break;case 4:31===s&&(s=30),31===r&&(r=30),d=c+(30*a+s)/360,u=h+(30*l+r)/360}return u-d}function Ae(e){return JSON.stringify(e,Object.keys(e).sort())}function Me(e){return'"'===e[0]&&(e=e.slice(1)),'"'===e[e.length-1]&&"\\"!==e[e.length-2]?e.slice(0,e.length-1):e}function Oe(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Ne(e){const t=Array.isArray(e)?[]:{};switch(typeof e){case"object":if(null===e)return e;if(function(e){return"clone"in e&&e.clone instanceof Function}(e))return e.clone();if(!(function(e){return"object"==typeof e&&(null==e?void 0:e.constructor)===Object}(e)||e instanceof Array))throw new Error("Unsupported type: only objects and arrays are supported");for(const i in e)t[i]=Ne(e[i]);return t;case"number":case"string":case"boolean":case"function":case"undefined":return e;default:throw new Error("Unsupported type: "+typeof e)}}function _e(e){return e.startsWith("'")&&(e=e.slice(1,-1).replace(/''/g,"'")),e}function Fe(e){var t;return(null===(t=e.match(/\w/g))||void 0===t?void 0:t.length)!==e.length&&(e=`'${e}'`),e}function De(e,t,i){return e<t?t:e>i?i:e}function ke(e,t=1){return t*(e+U)-U}function Le(e,t,i){e.save(),e.font=Ue(i);const o=e.measureText(t).width;return e.restore(),o}function Pe(e){return Math.round(96*e/72)}function Ue(e){return`${e.italic?"italic ":""}${e.bold?"bold":W} ${Ve(e)}px ${q}`}function Ve(e){return Pe((null==e?void 0:e.fontSize)||G)}function ze(e,t,i=1){if(t<=e&&i>0)return[];if(0===i)throw new Error("range() step must not be zero");const o=Math.ceil(Math.abs((t-e)/i)),n=Array(o);for(let t=0;t<o;t++)n[t]=e+t*i;return n}function Be(e){return e.reduce(((e,t,i,o)=>{if(1===Math.abs(t-o[i-1])){e[e.length-1].push(t)}else e.push([t]);return e}),[])}function*He(e,t){t.next();for(const i of e){const e=t.next();yield{...i,next:e.done?void 0:e.value}}}function $e(e){return null!==Se(e)}const We=/^\[([^\[]+)\]\((.+)\)$/,Ge=/^https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,4}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)$/;function qe(e){return We.test(e)}function Ze(e){return Ge.test(e)}function je(e,t){return`[${e}](${t})`}function Xe(e){const t=e.match(We)||[],i=t[1],o=t[2];if(!i||!o)throw new Error(`Could not parse markdown link ${e}.`);return{label:i,url:o}}const Ye="o-spreadsheet://";function Ke(e){return e.startsWith(Ye)}function Qe(e){return`${Ye}${e}`}function Je(e){if(e.startsWith(Ye))return e.substr(Ye.length);throw new Error(`${e} is not a valid sheet link`)}function et(e){return void 0!==e}function tt(e){return void 0===e||Object.values(e).every((e=>"object"==typeof e?tt(e):!e))}function it(e,t){for(let[i,o]of Object.entries(t))if(Ae(o)===Ae(e))return parseInt(i,10);const i=Object.keys(t),o=0===i.length?0:Math.max(...i.map((e=>parseInt(e,10))));return t[o+1]=e,o+1}function ot(e){let t="";for(let i=0,o=e.length;i<o;i++)t+=e[i];return t}function nt(e){let t,i=!1;const o=()=>(i||(t=e instanceof Function?e():e,i=!0),t);return o.map=e=>nt((()=>e(o()))),o}function st(e,t){let i=e.slice(t).find((e=>e));return i||(i=e.slice(0,t).reverse().find((e=>e))),i||""}function rt(e,t){return"after"===e?t+1:t}function at(e,t){if(e===t)return!0;if(e&&!t||t&&!e)return!1;const i=new Set;Object.keys(e).forEach((e=>i.add(e))),Object.keys(t).forEach((e=>i.add(e)));for(let o of i){if(typeof e[o]!=typeof e[o])return!1;if("object"==typeof e[o]){if(!at(e[o],t[o]))return!1}else if(e[o]!==t[o])return!1}return!0}function lt(e){const t={...e};return Object.keys(t).forEach((e=>!t[e]&&delete t[e])),t}function ct(e){return e?e.toLowerCase():""}const ht=[" ","\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))],dt=new RegExp(ht.join("|"),"g"),ut=/\r\n|\r|\n/g;function gt(e){return e?e=(e=e.replace(dt," ")).replace(ut,ce):""}const pt=["#eb6d00","#0074d9","#ad8e00","#169ed4","#b10dc9","#00a82d","#00a3a3","#f012be","#3d9970","#111111","#62A300","#ff4136","#949494","#85144b","#001f3f"];function mt(e){return ft(e.toString(16).padStart(6,"0"))}function ft(e){if(e.includes("rgba"))throw new Error(`rgba() conversion currently not supported: ${e}`);if(e.includes("rgb"))return function(e){return"#"+ot(e.slice(4,-1).split(",").map((e=>parseInt(e,10).toString(16).padStart(2,"0")))).toUpperCase()}(e);if(3!==(e=e.replace("#","").toUpperCase()).length&&4!==e.length||(e=e.split("").reduce(((e,t)=>e+t+t),"")),""!==e.replace(/[a-f0-9]/gi,""))throw new Error("invalid color");return"#"+e}function vt(e){try{const{r:t,g:i,b:o,a:n}=wt(e);return bt(t)&&bt(i)&&bt(o)&&bt(n)}catch(e){return!1}}const bt=e=>e>=0&&e<=255;function St(e,t,i,o=1){if(!bt(e)||!bt(t)||!bt(i)||o<0||o>1)throw new Error(`Invalid RGBA values ${[e,t,i,o]}`);return{a:o,b:i,g:t,r:e}}function Ct(e){let{r:t,g:i,b:o}=wt(e);t/=255,i/=255,o/=255;const n=e=>e<=.03928?e/12.92:((e+.055)/1.055)**2.4;return.2126*n(t)+.7152*n(i)+.0722*n(o)}function Et(e){let t=e.r.toString(16),i=e.g.toString(16),o=e.b.toString(16),n=Math.round(255*e.a).toString(16);return 1==t.length&&(t="0"+t),1==i.length&&(i="0"+i),1==o.length&&(o="0"+o),1==n.length&&(n="0"+n),"ff"===n&&(n=""),"#"+t+i+o+n}function wt(e){let t,i,o,n;if(7===(e=ft(e)).length)t=parseInt(e[1]+e[2],16),i=parseInt(e[3]+e[4],16),o=parseInt(e[5]+e[6],16),n=255;else{if(9!==e.length)throw new Error("Invalid color");t=parseInt(e[1]+e[2],16),i=parseInt(e[3]+e[4],16),o=parseInt(e[5]+e[6],16),n=parseInt(e[7]+e[8],16)}return n=+(n/255).toFixed(3),{a:n,r:t,g:i,b:o}}function yt(e){(e={...e}).s/=100,e.l/=100;let t=(1-Math.abs(2*e.l-1))*e.s,i=t*(1-Math.abs(e.h/60%2-1)),o=e.l-t/2,n=0,s=0,r=0;return 0<=e.h&&e.h<60?(n=t,s=i,r=0):60<=e.h&&e.h<120?(n=i,s=t,r=0):120<=e.h&&e.h<180?(n=0,s=t,r=i):180<=e.h&&e.h<240?(n=0,s=i,r=t):240<=e.h&&e.h<300?(n=i,s=0,r=t):300<=e.h&&e.h<360&&(n=t,s=0,r=i),n=Math.round(255*(n+o)),s=Math.round(255*(s+o)),r=Math.round(255*(r+o)),{a:e.a,r:n,g:s,b:r}}function xt(e){const t=e.r/255,i=e.g/255,o=e.b/255;let n=Math.min(t,i,o),s=Math.max(t,i,o),r=s-n,a=0,l=0,c=0;return a=0==r?0:s==t?(i-o)/r%6:s==i?(o-t)/r+2:(t-i)/r+4,a=Math.round(60*a),a<0&&(a+=360),c=(s+n)/2,l=0==r?0:r/(1-Math.abs(2*c-1)),l=+(100*l).toFixed(1),c=+(100*c).toFixed(1),{a:e.a,h:a,s:l,l:c}}const It=new RegExp(/\$?([A-Z]{1,3})\$?([0-9]{1,7})/,"i"),Rt=new RegExp(/^\$?([A-Z]{1,3})\$?([0-9]{1,7})$/,"i"),Tt=new RegExp(/^([A-Z]{1,3})+$/,"i"),At=new RegExp(/^\s*('.+'!|[^']+!)?\$?([A-Z]{1,3})$/,"i"),Mt=new RegExp(/^\s*('.+'!|[^']+!)?\$?([0-9]{1,7})$/,"i"),Ot=new RegExp(/^\s*('.+'!|[^']+!)?/.source+"("+[It.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 Nt(e){return At.test(e)}function _t(e){return Mt.test(e)}function Ft(e){return Tt.test(e)}function Dt(e){return Rt.test(e)}function kt(e){const t=e.split("!"),i=t.pop();return{sheetName:_e(t.join("!"))||void 0,xc:i}}function Lt(e){if(e<0)throw new Error(`number must be positive. Got ${e}`);return e<26?String.fromCharCode(65+e):Lt(Math.floor(e/26)-1)+Lt(e%26)}function Pt(e){let t=0;const i=e.length;for(let o=0;o<i;o++){t+=(e.charCodeAt(o)-65+(o<i-1?1:0))*26**(i-o-1)}return t}function Ut(e){const t=(e=e.toUpperCase().trim()).match(It);if(null!==t){const[i,o,n]=t;if(i===e){return{col:Pt(o),row:parseInt(n,10)-1}}}throw new Error(`Invalid cell description: ${e}`)}function Vt(e,t,i={colFixed:!1,rowFixed:!1}){return(i.colFixed?"$":"")+Lt(e)+(i.rowFixed?"$":"")+String(t+1)}const zt=140,Bt=20,Ht=.035;function $t(e){return Bt+(zt-Bt)*Math.exp(-Ht*(e-1))}const Wt=/^-?\d+(\.?\d*(e\d+)?)?|^-?\.\d+/,Gt="(\\s*(\\d+(,\\d{3,})*(\\.\\d*)?)|(\\.\\d+))(e(\\+|-)?\\d+)?(\\s*%)?",qt="(\\s*-)?",Zt="(\\s*[\\$€])?",jt="^(("+[qt+Zt+Gt,qt+Gt+Zt,Zt+qt+Gt].join(")|(")+"))$",Xt=new RegExp(jt,"i");function Yt(e){return!!e&&Xt.test(e.trim())}const Kt=/[,\$€]+/g;function Qt(e){e=e.replace(Kt,"");let t=Number(e);return isNaN(t)&&e.includes("%")&&(t=Number(e.split("%")[0]),!isNaN(t))?t/100:t}function Jt(e,t,i){const o=[...e].sort(((e,t)=>e-t));let n=(o.length+(i?-1:1))*t;if(i||n--,Number.isInteger(n))return o[n];const s=Math.ceil(n),r=Math.floor(n);return o[s]*(n-r)+o[r]*(s-n)}const ei=20,ti=11,ii=/(\d+?)(?=(\d{3})+(?!\d)|$)/g,oi=/0/g,ni={0:s("January"),1:s("February"),2:s("March"),3:s("April"),4:s("May"),5:s("June"),6:s("July"),7:s("August"),8:s("September"),9:s("October"),10:s("November"),11:s("December")},si={0:s("Sunday"),1:s("Monday"),2:s("Tuesday"),3:s("Wednesday"),4:s("Thursday"),5:s("Friday"),6:s("Saturday")},ri={};function ai(e){let t=ri[e];return void 0===t&&(t=function(e){if(""===e)throw new Error("A format cannot be empty");let t=0,i=[];for(;t<e.length;){let o;if("["===e.charAt(t)){if("$"!==e.charAt(t+1))throw new Error(`Currency formats have to be prefixed by a $: ${e}`);if(o=e.substring(t+1).indexOf("]")+t+2,0===o)throw new Error(`Invalid currency brackets format: ${e}`);const n=e.substring(t+2,o-1);if(n.includes("["))throw new Error(`Invalid currency format: ${e}`);i.push({type:"STRING",format:n})}else{const n=e.substring(t).indexOf("[");o=n>-1?n+t:e.length;const s=e.substring(t,o);s.match(X)?i.push({type:"DATE",format:s}):i.push({type:"NUMBER",format:wi(s)})}t=o}return i}(e),ri[e]=t),t}function li(e,t){switch(typeof e){case"string":return e;case"boolean":return e?"TRUE":"FALSE";case"number":t||(t=fi(e));return function(e,t){if("DATE"===t[0].type)return gi(e,t[0].format);let i=e<0?"-":"";for(let o of t)switch(o.type){case"NUMBER":i+=ci(Math.abs(e),o.format);break;case"STRING":i+=o.format}return i}(e,ai(t));case"object":return"0"}}function ci(e,t){t.isPercent&&(e*=100),e/=t.magnitude;let i=0;void 0!==t.decimalPart&&(i=t.decimalPart.length);const{integerDigits:o,decimalDigits:n}=di(e,i);let s=function(e,t,i){var o;const n="0"===e?"":e;let s=n;const r=t.length-n.length;if(r>0){const e=(t.substring(0,r).match(oi)||[]).length;s="0".repeat(e)+s}i&&(s=(null===(o=s.match(ii))||void 0===o?void 0:o.join(","))||s);return s}(o,t.integerPart,t.thousandsSeparator);return void 0!==t.decimalPart&&(s+="."+function(e,t){let i=e;if(t.length-e.length>0){const o=(t.substring(e.length,t.length+1).match(oi)||[]).length;i+="0".repeat(o)}return i}(n||"",t.decimalPart)),t.isPercent&&(s+="%"),s}const hi=[];function di(e,t=ei){let i=hi[t];i||(i=new Intl.NumberFormat("en-US",{maximumFractionDigits:t,useGrouping:!1}),hi[t]=i);const[o,n]=i.format(e).split(".");return{integerDigits:o,decimalDigits:n}}function ui(e){try{return gi(1,e),!0}catch(e){return!1}}function gi(e,t){const i=Ee(e),o=t.indexOf("h");let n="",s="";return o>0?(n=pi(i,t.substring(0,o-1)),s=mi(i,t.substring(o))):0===o?s=mi(i,t):o<0&&(n=pi(i,t)),n+(n&&s?" ":"")+s}function pi(e,t){var i;const o=null===(i=t.match(/\/|-|\s/))||void 0===i?void 0:i[0];return(o?t.split(o):[t]).map((i=>{switch(i){case"d":return e.getDate();case"dd":return e.getDate().toString().padStart(2,"0");case"ddd":return si[e.getDay()].slice(0,3);case"dddd":return si[e.getDay()];case"m":return e.getMonth()+1;case"mm":return String(e.getMonth()+1).padStart(2,"0");case"mmm":return ni[e.getMonth()].slice(0,3);case"mmmm":return ni[e.getMonth()];case"mmmmm":return ni[e.getMonth()].slice(0,1);case"yy":const i=String(e.getFullYear()).replace("-","").padStart(2,"0");return i.slice(i.length-2);case"yyyy":return e.getFullYear();default:throw new Error(`invalid format: ${t}`)}})).join(o)}function mi(e,t){let i=t.split(/:|\s/);const o=e.getHours(),n="a"===i[i.length-1];let s=o,r="";return n&&(s=0===s?12:s>12?s-12:s,r=o>=12?" PM":" AM",i.pop()),i.map((i=>{switch(i){case"hhhh":return Math.floor((e.getTime()-de)/36e5).toString();case"hh":return s.toString().padStart(2,"0");case"mm":return e.getMinutes().toString().padStart(2,"0");case"ss":return e.getSeconds().toString().padStart(2,"0");default:throw new Error(`invalid format: ${t}`)}})).join(":")+r}function fi(e){let{integerDigits:t,decimalDigits:i}=di(e);if(!i)return"0";const o=t.replace("-","").length;if(o+2>ti)return"0";const n=ti-o-1;return({decimalDigits:i}=di(e,Math.min(n,i.length))),i?"0."+"0".repeat(i.length):"0"}function vi(e){if($e(e)){return Se(e).format}if(!Yt(e))return;const t=e.includes(".")?"0.00":"0",i=e.match(/[\$€]/);if(i){const o=e.match(/[\d]/),n="[$"+i.values().next().value+"]";return o.index<i.index?"#,##"+t+n:n+"#,##"+t}return e.includes("%")?t+"%":void 0}function bi(e,t,i){return xi(ai(e||"#,##0").map((e=>"NUMBER"===e.type?[{...e,format:{...e.format,magnitude:t,decimalPart:void 0}},{type:"STRING",format:i}]:e)).flat())}function Si(e,t){const i=ai(e).map((e=>"NUMBER"===e.type?{...e,format:Ci(e.format,t)}:e)),o=xi(i);return ri[o]=i,o}function Ci(e,t){var i;const o={...e},n=Math.sign(t),s=(null===(i=o.decimalPart)||void 0===i?void 0:i.length)||0,r=Math.min(Math.max(0,s+n),ei);return o.decimalPart="0".repeat(r),""===o.decimalPart&&delete o.decimalPart,o}const Ei=/,*?$/;function wi(e){var t;if(function(e){return Boolean(e.replace(yi,""))}(e=e.trim()))throw new Error(`Invalid number format: ${e}`);const i=e.includes("%"),o=(null===(t=e.match(Ei))||void 0===t?void 0:t[0])||"",n=o?1e3**o.length:1;let s=e.slice(0,e.length-(o.length||0));const r=s.includes(",");if(s.match(/\..*,/))throw new Error("A format can't contain ',' symbol in the decimal part");s=s.replace("%","").replace(",","");const a=s.match(/[\%|,]/);if(a)throw new Error(`A format can only contain a single '${a[0]}' symbol`);const[l,c]=s.split(".");if(c&&c.length>20)throw new Error("A format can't contain more than 20 decimal places");return void 0!==c?{integerPart:l,isPercent:i,thousandsSeparator:r,decimalPart:c,magnitude:n}:{integerPart:l,isPercent:i,thousandsSeparator:r,magnitude:n}}const yi=/[,#0.%]/g;function xi(e){let t="";for(let i of e){let e;switch(i.type){case"NUMBER":const t=i.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=`[$${i.format}]`;break;case"DATE":e=i.format}t+=e}return t}class Ii{constructor(e,t){this.getSheetSize=t,this.prefixSheet=!1,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 Ii?e:new Ii(e,t.getSheetSize)}get unboundedZone(){return this._zone}get zone(){const{left:e,top:t,bottom:i,right:o}=this._zone;if(void 0!==o&&void 0!==i)return{left:e,top:t,right:o,bottom:i};if(void 0===i&&void 0!==o)return{right:o,top:t,left:e,bottom:this.getSheetSize(this.sheetId).height-1};if(void 0===o&&void 0!==i)return{bottom:i,left:e,top:t,right:this.getSheetSize(this.sheetId).width-1};throw new Error(s("Bad zone format"))}static getRangeParts(e,t){const i=e.split(":").map((e=>{const t=_t(e);return{colFixed:!t&&e.startsWith("$"),rowFixed:t?e.startsWith("$"):e.includes("$",1)}})),o=void 0===t.bottom,n=void 0===t.right;return o&&(i[0].rowFixed=i[0].rowFixed||i[1].rowFixed,i[1].rowFixed=i[0].rowFixed||i[1].rowFixed,t.left===t.right&&(i[0].colFixed=i[0].colFixed||i[1].colFixed,i[1].colFixed=i[0].colFixed||i[1].colFixed)),n&&(i[0].colFixed=i[0].colFixed||i[1].colFixed,i[1].colFixed=i[0].colFixed||i[1].colFixed,t.top===t.bottom&&(i[0].rowFixed=i[0].rowFixed||i[1].rowFixed,i[1].rowFixed=i[0].rowFixed||i[1].rowFixed)),i}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(){var e,t,i,o,n,s,r,a;const l={...this._zone};let c=this.parts;if(void 0!==l.right&&l.right<l.left){let n=l.right;l.right=l.left,l.left=n,c=[{colFixed:(null===(e=c[1])||void 0===e?void 0:e.colFixed)||!1,rowFixed:(null===(t=c[0])||void 0===t?void 0:t.rowFixed)||!1},{colFixed:(null===(i=c[0])||void 0===i?void 0:i.colFixed)||!1,rowFixed:(null===(o=c[1])||void 0===o?void 0:o.rowFixed)||!1}]}if(void 0!==l.bottom&&l.bottom<l.top){let e=l.bottom;l.bottom=l.top,l.top=e,c=[{colFixed:(null===(n=c[0])||void 0===n?void 0:n.colFixed)||!1,rowFixed:(null===(s=c[1])||void 0===s?void 0:s.rowFixed)||!1},{colFixed:(null===(r=c[1])||void 0===r?void 0:r.colFixed)||!1,rowFixed:(null===(a=c[0])||void 0===a?void 0:a.rowFixed)||!1}]}return this.clone({zone:l,parts:c})}clone(e){return new Ii({zone:(null==e?void 0:e.zone)?e.zone:{...this._zone},sheetId:(null==e?void 0: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:(null==e?void 0:e.parts)?e.parts:this.parts.map((e=>({rowFixed:e.rowFixed,colFixed:e.colFixed}))),prefixSheet:(null==e?void 0:e.prefixSheet)?e.prefixSheet:this.prefixSheet},this.getSheetSize)}}function Ri(e,t,i){const o=i.sheetId===e?t:i.sheetId;return i.clone({sheetId:o})}function Ti(e,t,i){return i?e.getRangeFromSheetXC(t,i):void 0}function Ai(e,t,i){const o=[];return t.forEach((t=>{const n=function(e,t){e=e.toLocaleLowerCase();let i=0,o=0,n=(t=t.toLocaleLowerCase()).length,s=0;for(let r=0;r<n;r++)t[r]===e[s]?(s++,o+=100+o-r/200):o=0,i+=o;return s===e.length?i:0}(e,i(t));n>0&&o.push({score:n,elem:t})})),o.sort(((e,t)=>t.score-e.score)),o.map((e=>e.elem))}function Mi(e){const t=[];for(let i=0;i<e;i++){const e={cells:{}};t.push(e)}return t}class Oi{constructor(){this.isFastIdStrategy=!1,this.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)}))}}function Ni(e){const t=function(e){const t=(e=e.split("!").pop()).replace(/\$/g,"").split(":").map((e=>e.trim()));let i,o,n,s,r=!1,a=!1,l=!1;const c=t[0],h=t[1]&&t[1];if(Nt(c))n=s=Pt(c),i=o=0,r=!0;else if(_t(c))i=o=parseInt(c,10)-1,n=s=0,a=!0;else{const e=Ut(c);n=s=e.col,i=o=e.row,l=!0}if(2===t.length)if(Nt(h))s=Pt(h),r=!0;else if(_t(h))o=parseInt(h,10)-1,a=!0;else{const e=Ut(h);s=e.col,o=e.row,i=r?o:i,n=a?s:n,l=!0}if(r&&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:i,left:n,bottom:r?void 0:o,right:a?void 0:s};return l=l&&(a||r),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 _i(e){const t=Ni(e);if(void 0===t.bottom||void 0===t.right)throw new Error("This does not support unbounded ranges");return t}function Fi(e){const{bottom:t,top:i,left:o,right:n}=e;return!(void 0!==t&&isNaN(t)||isNaN(i)||isNaN(o)||void 0!==n&&isNaN(n))&&((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 Di(e){const{top:t,bottom:i,left:o,right:n}=e,r="hasHeader"in e&&e.hasHeader,a=t===i&&o===n;if(void 0===i&&void 0!==n)return 0!==t||r?`${Vt(o,t)}:${Lt(n)}`:`${Lt(o)}:${Lt(n)}`;if(void 0===n&&void 0!==i)return 0!==o||r?`${Vt(o,t)}:${i+1}`:`${t+1}:${i+1}`;if(void 0!==i&&void 0!==n)return a?Vt(o,t):`${Vt(o,t)}:${Vt(n,i)}`;throw new Error(s("Bad zone format"))}function ki(e,t,i,o,n){const s="left"===t?"columns":"rows",r="before"===o?i-1:i,a=e["left"===t?"right":"bottom"];return e[t]<=r&&a&&a>r?Yi(e,s,"RESIZE",n):r<e[t]?Yi(e,s,"MOVE",n):{...e}}function Li(e,t,i,o,n){const s="left"===t?"columns":"rows",r="before"===o?i-1:i,a="left"===t?"right":"bottom";return e[t]<=r&&e[a]>r?Yi(e,s,"RESIZE",n):r<e[t]?Yi(e,s,"MOVE",n):{...e}}function Pi(e,t,i){const o="left"===t?"right":"bottom";let n=e[t],s=e[o];for(let r of i.sort(((e,t)=>t-e)))e[t]>r&&(n--,s--),e[t]<r&&e[o]>=r&&s--;return{...e,[t]:n,[o]:s}}function Ui(e,t,i){const o="left"===t?"right":"bottom";let n=e[t],s=e[o];const r=e[o];for(let o of i.sort(((e,t)=>t-e)))e[t]>o&&(n--,void 0!==s&&s--),void 0!==r&&void 0!==s&&e[t]<=o&&r>=o&&s--;if(!(void 0!==s&&n>s))return{...e,[t]:n,[o]:s}}function Vi(...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 zi(e,t){if(Hi(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 Bi(e,t){return e.left===t.left&&e.right===t.right&&e.top===t.top&&e.bottom===t.bottom}function Hi(e,t){return!(e.bottom<t.top||t.bottom<e.top)&&!(e.right<t.left||t.right<e.left)}function $i(e,t,i){const{left:o,right:n,top:s,bottom:r}=i;return e>=o&&e<=n&&t>=s&&t<=r}function Wi(e,t){return Bi(Vi(t,e),t)}function Gi(e,t){const i=e.map(Ni),o=t.map(_i),n=Math.max(...i.concat(o).map((e=>e.bottom||0))),s=Math.max(...i.concat(o).map((e=>e.right||0))),r=i.map((e=>({...e,bottom:void 0===e.bottom?n+1:e.bottom,right:void 0===e.right?s+1:e.right}))),a=o.map((e=>({...e,bottom:void 0===e.bottom?n+1:e.bottom,right:void 0===e.right?s+1:e.right}))),l=function(e,t){const i=new Set(t.map((({col:e,row:t})=>`${e}-${t}`)));return e.filter((({col:e,row:t})=>!i.has(`${e}-${t}`)))}(r.map(Xi).flat(),a.map(Xi).flat()),c=function(e){if(0===e.length)return[];const[t,...i]=[...e].sort(((e,t)=>e.row-t.row)).sort(((e,t)=>e.col-t.col)),o=[];let n=Ji(t);for(const{col:e,row:t}of i)if(!$i(e,t,n))if(e===n.left&&t===n.bottom+1){const e=n.bottom+1;n={...n,bottom:e}}else o.push(n),n=Ji({col:e,row:t});return[...o,n]}(l);return function(e){if(0===e.length)return[];if(e.some((e=>e.left!==e.right)))throw new Error("only columns can be merged");const t=[],i=qi(e),o=(e,t)=>e.top===t.top&&e.bottom===t.bottom&&e.right+1===t.left;for(;i.length;){const e=i.reduce(((e,t)=>o(e,t)?Vi(e,t):e),i.shift());t.push(e)}return qi(t)}(c).map((e=>({...e,bottom:e.bottom===n+1?void 0:e.bottom,right:e.right===s+1?void 0:e.right}))).map(Di)}function qi(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(),i=[];for(;0!==t.length;){const e=t.shift();t.some((t=>Wi(e,t)))||i.push(e)}return i.reverse()}function Zi(e){return{height:e.bottom-e.top+1,width:e.right-e.left+1}}function ji(e){const{width:t,height:i}=Zi(e);return 1===t||1===i}function Xi(e){const t=[],[i,o]=[e.right,e.left].sort(((e,t)=>e-t)),[n,s]=[e.top,e.bottom].sort(((e,t)=>e-t));for(const e of ze(i,o+1))for(const i of ze(n,s+1))t.push({col:e,row:i});return t}function Yi(e,t,i,o){const n="both"===t?o[0]:"columns"===t?o:0,s="both"===t?o[1]:"rows"===t?o:0,r="hasHeader"in e&&e.hasHeader;let a;a=!function(e){return void 0===e.bottom}(e)||r?!(eo(e)&&!r)||"columns"!==t:"rows"!==t;const l={...e};return a&&"MOVE"===i&&(l.left+=n,l.top+=s),void 0!==l.right&&(l.right+=n),void 0!==l.bottom&&(l.bottom+=s),l}function Ki(e,t){let i,o;const{left:n,right:s,top:r,bottom:a}=e,{left:l,right:c,top:h,bottom:d}=t;return i=l!=n?l:c!=s?c:l,o=h!=r?h:d!=a?d:h,{col:i,row:o}}function Qi(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 Ji(e){return{left:e.col,right:e.col,top:e.row,bottom:e.row}}function eo(e){return void 0===e.right}function to(e){return(e.bottom-e.top+1)*(e.right-e.left+1)}function io(...e){return e.length<2||1===Gi(e.map(Di),[]).length}class oo extends t.Component{constructor(){super(...arguments),this.canvas=t.useRef("graphContainer")}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;at(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){var t,i,o,n,s;const r=e.chartJsConfig;r.data&&r.data.datasets?(this.chart.data=r.data,(null===(t=r.options)||void 0===t?void 0:t.title)&&(this.chart.config.options.title=r.options.title),r.options&&"valueLabel"in r.options&&(null===(i=r.options)||void 0===i?void 0:i.valueLabel)&&(this.chart.config.options.valueLabel=r.options.valueLabel)):this.chart.data.datasets=void 0,this.chart.config.options.tooltips=null===(o=r.options)||void 0===o?void 0:o.tooltips,this.chart.config.options.legend=null===(n=r.options)||void 0===n?void 0:n.legend,this.chart.config.options.scales=null===(s=r.options)||void 0===s?void 0:s.scales,this.chart.update({duration:0})}}oo.template="o-spreadsheet-ChartJsComponent",oo.props={figure:Object};const no={};let so=0;function ro(e,...t){const i="__sheet__"+so++;return function(e,t){const i=document.createElement("style");i.textContent=function(e){const t=e.split(/(\{|\}|;)/).map((e=>e.trim())),i=[],o=[];let n=[];function s(e,t){const o=[];for(const n of i[e]){let r=t&&t+" "+n||n;r.includes("&")&&(r=n.replace(/&/g,t||"")),e<i.length-1&&(r=s(e+1,r)),o.push(r)}return o.join(", ")}function r(){n.length&&(o.push(s(0)+" {"),o.push(...n),o.push("}"),n=[])}for(;t.length;){let e=t.shift();"}"===e?(r(),i.pop()):("{"===t[0]&&(r(),i.push(e.split(/\s*,\s*/)),t.shift()),";"===t[0]&&n.push(" "+e+";"))}return o.join("\n")}(t),no[e]=i}(i,String.raw(e,...t)),function(e){const t=no[e];t.setAttribute("component",e),document.head.appendChild(t)}(i),i}function ao({strikethrough:e,underline:t}){return e||t?`${e?"line-through":""} ${t?"underline":""}`:"none"}function lo(e){const t=co(e);return e?(e.fillColor&&(t.background=e.fillColor),t):t}function co(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 i=e.strikethrough?"line-through":"";i=e.underline?i+" underline":i,t["text-decoration"]=i}return e.textColor&&(t.color=e.textColor),t}function ho(e){return Object.entries(e).filter((([e,t])=>void 0!==t)).map((([e,t])=>`${e}:${t};`)).join(" ")}const uo=1.2;ro`
|
|
2
|
-
div.o-scorecard {
|
|
3
|
-
user-select: none;
|
|
4
|
-
background-color: white;
|
|
5
|
-
display: flex;
|
|
6
|
-
flex-direction: column;
|
|
7
|
-
box-sizing: border-box;
|
|
8
|
-
|
|
9
|
-
.o-scorecard-content {
|
|
10
|
-
display: flex;
|
|
11
|
-
flex-direction: column;
|
|
12
|
-
height: 100%;
|
|
13
|
-
justify-content: center;
|
|
14
|
-
text-align: center;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
.o-title-text {
|
|
18
|
-
text-align: left;
|
|
19
|
-
height: ${uo+"em"};
|
|
20
|
-
line-height: ${uo+"em"};
|
|
21
|
-
overflow: hidden;
|
|
22
|
-
white-space: nowrap;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
.o-key-text {
|
|
26
|
-
line-height: ${uo+"em"};
|
|
27
|
-
height: ${uo+"em"};
|
|
28
|
-
overflow: hidden;
|
|
29
|
-
white-space: nowrap;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
.o-cf-icon {
|
|
33
|
-
display: inline-block;
|
|
34
|
-
width: 0.65em;
|
|
35
|
-
height: 1em;
|
|
36
|
-
line-height: 1em;
|
|
37
|
-
padding-bottom: 0.07em;
|
|
38
|
-
padding-right: 3px;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
.o-baseline-text {
|
|
42
|
-
line-height: ${uo+"em"};
|
|
43
|
-
height: ${uo+"em"};
|
|
44
|
-
overflow: hidden;
|
|
45
|
-
white-space: nowrap;
|
|
46
|
-
|
|
47
|
-
.o-baseline-text-description {
|
|
48
|
-
white-space: pre;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
`;class go extends t.Component{constructor(){super(...arguments),this.ctx=document.createElement("canvas").getContext("2d")}get runtime(){return this.env.model.getters.getChartRuntime(this.props.figure.id)}get title(){return this.runtime.title}get keyValue(){return this.runtime.keyValue}get baseline(){return this.runtime.baselineDisplay}get baselineDescr(){const e=this.runtime.baselineDescr||"";return this.baseline&&e?" "+e:e}get baselineArrowDirection(){return this.runtime.baselineArrow}get backgroundColor(){return this.runtime.background}get primaryFontColor(){return this.runtime.fontColor}get secondaryFontColor(){return Ct(this.primaryFontColor)<=.3?"#757575":"#bbbbbb"}get figure(){return this.props.figure}get chartStyle(){return ho({padding:`${this.chartPadding}px`,background:this.backgroundColor})}get chartContentStyle(){return ho({height:`${this.getDrawableHeight()}px`})}get chartPadding(){return.02*this.props.figure.width}getTextStyles(){const e=.96*this.props.figure.width,t=this.getWidestElement(),i=t.getElementMaxFontSize(this.getDrawableHeight(),this);let o=function(e,t,i,o=.25){let n=1;if(i(n)>e)return n;if(i(t)<e)return t;let s=(n+t)/2,r=i(s),a=0;for(;Math.abs(r-e)>o&&a<20;)r>=e?t=(n+t)/2:n=(n+t)/2,s=(n+t)/2,r=i(s),a++;return s}(e,i,(e=>t.getElementWidth(e,this.ctx,this)))/i;const n=(new mo).getElementMaxFontSize(this.getDrawableHeight(),this)*o,s=(new po).getElementMaxFontSize(this.getDrawableHeight(),this)*o;return{titleStyle:this.getTextStyle({fontSize:18,color:this.secondaryFontColor}),keyStyle:this.getTextStyle({fontSize:n,cellStyle:this.runtime.keyValueStyle,color:this.primaryFontColor}),baselineStyle:this.getTextStyle({fontSize:s}),baselineValueStyle:this.getTextStyle({fontSize:s,cellStyle:this.runtime.baselineStyle,color:this.runtime.baselineColor||this.secondaryFontColor}),baselineDescrStyle:this.getTextStyle({fontSize:.9*s,color:this.secondaryFontColor})}}getTextStyle(e){const t=co(e.cellStyle);return t["font-size"]=`${e.fontSize}px`,t.display="inline-block",!t.color&&e.color&&(t.color=e.color),ho(t)}getDrawableHeight(){const e=2*this.chartPadding;let t=this.props.figure.height-e;return t-=this.title?18*uo:0,t}getWidestElement(){const e=new po,t=new mo;return e.getElementWidth(.35,this.ctx,this)>t.getElementWidth(.65,this.ctx,this)?e:t}}go.template="o-spreadsheet-ScorecardChart";class po{getElementWidth(e,t,i){if(!i.runtime)return 0;const o=i.baseline,n="neutral"!==i.baselineArrowDirection?"A "+o:o;t.font=`${e}px ${q}`;let s=t.measureText(n).width;return t.font=`${.9*e}px ${q}`,s+=t.measureText(i.baselineDescr).width,s}getElementMaxFontSize(e,t){if(!t.runtime)return 0;return(""!==t.baseline||t.baselineDescr?.35*e:0)/uo}}class mo{getElementWidth(e,t,i){if(!i.runtime)return 0;const o=i.keyValue||"";return t.font=`${e}px ${q}`,t.measureText(o).width}getElementMaxFontSize(e,t){if(!t.runtime)return 0;return(""!==t.baseline||t.baselineDescr?.65*e:e)/uo}}function fo(e){return 8===(e=ft(e).replace("#","")).length?e.slice(6)+e.slice(0,6):e}go.props={figure:Object};class vo{constructor(e,t,i){this.title=e.title,this.sheetId=t,this.getters=i}static validateChartDefinition(e,t){throw new Error("This method should be implemented by sub class")}static transformDefinition(e,t){throw new Error("This method should be implemented by sub class")}static getDefinitionFromContextCreation(e){throw new Error("This method should be implemented by sub class")}}function bo(e,t){return"REMOVE_COLUMNS_ROWS"===t.type?Ui(e,"COL"===t.dimension?"left":"top",t.elements):"ADD_COLUMNS_ROWS"===t.type?ki(e,"COL"===t.dimension?"left":"top",t.base,t.position,t.quantity):{...e}}var So,Co;!function(e){e.boolean="boolean",e.number="number",e.text="text",e.empty="empty",e.error="error"}(So||(So={})),function(e){e.PlainText="text/plain",e.Html="text/html"}(Co||(Co={}));const Eo=new Set(["RENAME_SHEET","DELETE_SHEET","CREATE_SHEET","ADD_COLUMNS_ROWS","REMOVE_COLUMNS_ROWS","DELETE_CELL","INSERT_CELL","UNDO","REDO"]),wo=new Set([...Eo,"DUPLICATE_SHEET","EVALUATE_CELLS","ADD_CONDITIONAL_FORMAT","REMOVE_CONDITIONAL_FORMAT","MOVE_CONDITIONAL_FORMAT"]),yo=new Set(["START","ACTIVATE_SHEET","COPY","PREPARE_SELECTION_INPUT_EXPANSION","STOP_SELECTION_INPUT","RESIZE_SHEETVIEW","SET_VIEWPORT_OFFSET","SELECT_SEARCH_NEXT_MATCH","SELECT_SEARCH_PREVIOUS_MATCH","REFRESH_SEARCH","UPDATE_SEARCH","CLEAR_SEARCH","EVALUATE_CELLS","SET_CURRENT_CONTENT","SET_FORMULA_VISIBILITY","OPEN_CELL_POPOVER","CLOSE_CELL_POPOVER","UPDATE_FILTER"]),xo=new Set(["UPDATE_CELL","UPDATE_CELL_POSITION","CLEAR_CELL","DELETE_CONTENT","ADD_COLUMNS_ROWS","REMOVE_COLUMNS_ROWS","RESIZE_COLUMNS_ROWS","HIDE_COLUMNS_ROWS","UNHIDE_COLUMNS_ROWS","SET_GRID_LINES_VISIBILITY","UNFREEZE_COLUMNS","UNFREEZE_ROWS","FREEZE_COLUMNS","FREEZE_ROWS","UNFREEZE_COLUMNS_ROWS","ADD_MERGE","REMOVE_MERGE","CREATE_SHEET","DELETE_SHEET","DUPLICATE_SHEET","MOVE_SHEET","RENAME_SHEET","HIDE_SHEET","SHOW_SHEET","MOVE_RANGES","ADD_CONDITIONAL_FORMAT","REMOVE_CONDITIONAL_FORMAT","MOVE_CONDITIONAL_FORMAT","CREATE_FIGURE","DELETE_FIGURE","UPDATE_FIGURE","SET_FORMATTING","CLEAR_FORMATTING","SET_BORDER","CREATE_CHART","UPDATE_CHART","CREATE_FILTER_TABLE","REMOVE_FILTER_TABLE","CREATE_IMAGE"]);function Io(e){return xo.has(e.type)}class Ro{constructor(e=[]){Array.isArray(e)||(e=[e]),e=[...new Set(e)],this.reasons=e.filter((e=>0!==e))}static get Success(){return new Ro}get isSuccessful(){return 0===this.reasons.length}isCancelledBecause(e){return this.reasons.includes(e)}}var To,Ao,Mo;function Oo(e,t,i,o){let n=!1;const s=[];for(let o in i){let r=i[o];if(r.labelCell){const e=Fo(r.labelCell,t);r.labelCell!==e&&(n=!0,r={...r,labelCell:e})}const a=Fo(r.dataRange,t);void 0===a||e.getRangeString(a,a.sheetId)===Y?(n=!0,r=void 0):a!==r.dataRange&&(n=!0,r={...r,dataRange:a}),s[o]=r}let r=o;const a=Fo(r,t);a!==r&&(n=!0,r=a);return{isStale:n,dataSets:s.filter(et),labelRange:r}}function No(e,t,i){return i.map((i=>({dataRange:Ri(e,t,i.dataRange),labelCell:i.labelCell?Ri(e,t,i.labelCell):void 0})))}function _o(e,t,i){return i?Ri(e,t,i):void 0}function Fo(e,t){if(!e)return;const i=t(e);switch(i.changeType){case"NONE":return e;case"REMOVE":return;default:return i.range}}function Do(e,t,i,o){const n=[];for(const s of t){const t=e.getRangeFromSheetXC(i,s),{unboundedZone:r,sheetId:a,invalidSheetName:l}=t;if(!l)if(r.left!==r.right&&r.top!==r.bottom){if(void 0===r.right)continue;for(let t=r.left;t<=r.right;t++){const i={...r,left:t,right:t};n.push(ko(e,a,i,o?{top:i.top,bottom:i.top,left:i.left,right:i.left}:void 0))}}else r.left===r.right&&r.top===r.bottom?o||n.push(ko(e,a,r,void 0)):n.push(ko(e,a,r,o?{top:r.top,bottom:r.top,left:r.left,right:r.left}:void 0))}return n}function ko(e,t,i,o){if(i.left!==i.right&&i.top!==i.bottom)throw new Error(`Zone should be a single column or row: ${Di(i)}`);if(o){const n=Di(i),s=Di(o);return{labelCell:e.getRangeFromSheetXC(t,s),dataRange:e.getRangeFromSheetXC(t,n)}}return{labelCell:void 0,dataRange:e.getRangeFromSheetXC(t,Di(i))}}function Lo(e,t){var i;const o=null===(i=t.labelCell)||void 0===i?void 0:i.zone;let n=t.dataRange.zone;if(o){const{height:e,width:t}=Zi(n);1===e?n={...n,left:n.left+1}:1===t&&(n={...n,top:n.top+1})}const s=t.dataRange.clone({zone:n});return{label:t.labelCell?e.getRangeString(t.labelCell,"forceSheetReference"):void 0,range:e.getRangeString(s,"forceSheetReference")}}function Po(e,t){let i;if(e.labelRange){const o=bo(Ni(e.labelRange),t);i=o?Di(o):void 0}const o=e.dataSets.map(Ni).map((e=>bo(e,t))).filter(et).map(Di);return{...e,labelRange:i,dataSets:o}}e.CommandResult=void 0,(To=e.CommandResult||(e.CommandResult={}))[To.Success=0]="Success",To[To.CancelledForUnknownReason=1]="CancelledForUnknownReason",To[To.WillRemoveExistingMerge=2]="WillRemoveExistingMerge",To[To.MergeIsDestructive=3]="MergeIsDestructive",To[To.CellIsMerged=4]="CellIsMerged",To[To.InvalidTarget=5]="InvalidTarget",To[To.EmptyUndoStack=6]="EmptyUndoStack",To[To.EmptyRedoStack=7]="EmptyRedoStack",To[To.NotEnoughElements=8]="NotEnoughElements",To[To.NotEnoughSheets=9]="NotEnoughSheets",To[To.MissingSheetName=10]="MissingSheetName",To[To.DuplicatedSheetName=11]="DuplicatedSheetName",To[To.DuplicatedSheetId=12]="DuplicatedSheetId",To[To.ForbiddenCharactersInSheetName=13]="ForbiddenCharactersInSheetName",To[To.WrongSheetMove=14]="WrongSheetMove",To[To.WrongSheetPosition=15]="WrongSheetPosition",To[To.InvalidAnchorZone=16]="InvalidAnchorZone",To[To.SelectionOutOfBound=17]="SelectionOutOfBound",To[To.TargetOutOfSheet=18]="TargetOutOfSheet",To[To.WrongCutSelection=19]="WrongCutSelection",To[To.WrongPasteSelection=20]="WrongPasteSelection",To[To.WrongPasteOption=21]="WrongPasteOption",To[To.WrongFigurePasteOption=22]="WrongFigurePasteOption",To[To.EmptyClipboard=23]="EmptyClipboard",To[To.EmptyRange=24]="EmptyRange",To[To.InvalidRange=25]="InvalidRange",To[To.InvalidZones=26]="InvalidZones",To[To.InvalidSheetId=27]="InvalidSheetId",To[To.InvalidFigureId=28]="InvalidFigureId",To[To.InputAlreadyFocused=29]="InputAlreadyFocused",To[To.MaximumRangesReached=30]="MaximumRangesReached",To[To.InvalidChartDefinition=31]="InvalidChartDefinition",To[To.InvalidDataSet=32]="InvalidDataSet",To[To.InvalidLabelRange=33]="InvalidLabelRange",To[To.InvalidScorecardKeyValue=34]="InvalidScorecardKeyValue",To[To.InvalidScorecardBaseline=35]="InvalidScorecardBaseline",To[To.InvalidGaugeDataRange=36]="InvalidGaugeDataRange",To[To.EmptyGaugeRangeMin=37]="EmptyGaugeRangeMin",To[To.GaugeRangeMinNaN=38]="GaugeRangeMinNaN",To[To.EmptyGaugeRangeMax=39]="EmptyGaugeRangeMax",To[To.GaugeRangeMaxNaN=40]="GaugeRangeMaxNaN",To[To.GaugeRangeMinBiggerThanRangeMax=41]="GaugeRangeMinBiggerThanRangeMax",To[To.GaugeLowerInflectionPointNaN=42]="GaugeLowerInflectionPointNaN",To[To.GaugeUpperInflectionPointNaN=43]="GaugeUpperInflectionPointNaN",To[To.GaugeLowerBiggerThanUpper=44]="GaugeLowerBiggerThanUpper",To[To.InvalidAutofillSelection=45]="InvalidAutofillSelection",To[To.WrongComposerSelection=46]="WrongComposerSelection",To[To.MinBiggerThanMax=47]="MinBiggerThanMax",To[To.LowerBiggerThanUpper=48]="LowerBiggerThanUpper",To[To.MidBiggerThanMax=49]="MidBiggerThanMax",To[To.MinBiggerThanMid=50]="MinBiggerThanMid",To[To.FirstArgMissing=51]="FirstArgMissing",To[To.SecondArgMissing=52]="SecondArgMissing",To[To.MinNaN=53]="MinNaN",To[To.MidNaN=54]="MidNaN",To[To.MaxNaN=55]="MaxNaN",To[To.ValueUpperInflectionNaN=56]="ValueUpperInflectionNaN",To[To.ValueLowerInflectionNaN=57]="ValueLowerInflectionNaN",To[To.MinInvalidFormula=58]="MinInvalidFormula",To[To.MidInvalidFormula=59]="MidInvalidFormula",To[To.MaxInvalidFormula=60]="MaxInvalidFormula",To[To.ValueUpperInvalidFormula=61]="ValueUpperInvalidFormula",To[To.ValueLowerInvalidFormula=62]="ValueLowerInvalidFormula",To[To.InvalidSortZone=63]="InvalidSortZone",To[To.WaitingSessionConfirmation=64]="WaitingSessionConfirmation",To[To.MergeOverlap=65]="MergeOverlap",To[To.TooManyHiddenElements=66]="TooManyHiddenElements",To[To.Readonly=67]="Readonly",To[To.InvalidViewportSize=68]="InvalidViewportSize",To[To.InvalidScrollingDirection=69]="InvalidScrollingDirection",To[To.FigureDoesNotExist=70]="FigureDoesNotExist",To[To.InvalidConditionalFormatId=71]="InvalidConditionalFormatId",To[To.InvalidCellPopover=72]="InvalidCellPopover",To[To.EmptyTarget=73]="EmptyTarget",To[To.InvalidFreezeQuantity=74]="InvalidFreezeQuantity",To[To.FrozenPaneOverlap=75]="FrozenPaneOverlap",To[To.ValuesNotChanged=76]="ValuesNotChanged",To[To.InvalidFilterZone=77]="InvalidFilterZone",To[To.FilterOverlap=78]="FilterOverlap",To[To.FilterNotFound=79]="FilterNotFound",To[To.MergeInFilter=80]="MergeInFilter",To[To.NonContinuousTargets=81]="NonContinuousTargets",To[To.DuplicatedFigureId=82]="DuplicatedFigureId",To[To.InvalidSelectionStep=83]="InvalidSelectionStep",To[To.DuplicatedChartId=84]="DuplicatedChartId",To[To.ChartDoesNotExist=85]="ChartDoesNotExist",function(e){e.UP="up",e.DOWN="down",e.LEFT="left",e.RIGHT="right"}(Ao||(Ao={})),function(e){e[e.Background=0]="Background",e[e.Highlights=1]="Highlights",e[e.Clipboard=2]="Clipboard",e[e.Search=3]="Search",e[e.Chart=4]="Chart",e[e.Autofill=5]="Autofill",e[e.Selection=6]="Selection",e[e.Headers=7]="Headers"}(Mo||(Mo={}));const Uo=["rgb(31,119,180)","rgb(255,127,14)","rgb(174,199,232)","rgb(255,187,120)","rgb(44,160,44)","rgb(152,223,138)","rgb(214,39,40)","rgb(255,152,150)","rgb(148,103,189)","rgb(197,176,213)","rgb(140,86,75)","rgb(196,156,148)","rgb(227,119,194)","rgb(247,182,210)","rgb(127,127,127)","rgb(199,199,199)","rgb(188,189,34)","rgb(219,219,141)","rgb(23,190,207)","rgb(158,218,229)"];class Vo{constructor(){this.graphColorIndex=0}next(){return Uo[this.graphColorIndex++%Uo.length]}}function zo(e){return e&&Ct(e)<.3?"#FFFFFF":"#000000"}function Bo(e){if(e.dataSets){const t=void 0!==e.dataSets.find((e=>!Ot.test(e)));if(t)return 32;if(e.dataSets.map(Ni).some((e=>e.top!==e.bottom&&eo(e))))return 32}return 0}function Ho(e){if(e.labelRange){if(!Ot.test(e.labelRange||""))return 33}return 0}function $o(e,t,i){if(e){if("text"===i||(null==t?void 0:t.type)!==So.number||e.type!==So.number)return e.formattedValue;{let o=t.value-e.value;if("percentage"===i&&0!==o&&(o=o/e.value*100),"percentage"!==i&&e.format)return li(o,e.format);const n=Math.abs(parseFloat(o.toFixed(2))).toLocaleString();return"percentage"===i?n+"%":n}}return""}function Wo(e,t,i,o,n){if("text"===t||(null==e?void 0:e.type)!==So.number||(null==i?void 0:i.type)!==So.number)return;const s=i.value-e.value;return s>0?o:s<0?n:void 0}function Go(e,t,i){if("text"===i||(null==e?void 0:e.type)!==So.number||(null==t?void 0:t.type)!==So.number)return"neutral";const o=t.value-e.value;return o>0?"up":o<0?"down":"neutral"}const qo={Errors:{25:s("The range is invalid"),51:s("The argument is missing. Please provide a value"),52:s("The second argument is missing. Please provide a value"),53:s("The minpoint must be a number"),54:s("The midpoint must be a number"),55:s("The maxpoint must be a number"),56:s("The first value must be a number"),57:s("The second value must be a number"),47:s("Minimum must be smaller then Maximum"),50:s("Minimum must be smaller then Midpoint"),49:s("Midpoint must be smaller then Maximum"),48:s("Lower inflection point must be smaller than upper inflection point"),58:s("Invalid Minpoint formula"),60:s("Invalid Maxpoint formula"),59:s("Invalid Midpoint formula"),61:s("Invalid upper inflection point formula"),62:s("Invalid lower inflection point formula"),24:s("A range needs to be defined"),Unexpected:s("The rule is invalid for an unknown reason")},ColorScale:s("Color scale"),IconSet:s("Icon set")},Zo={IsEmpty:s("Is empty"),IsNotEmpty:s("Is not empty"),ContainsText:s("Contains"),NotContains:s("Does not contain"),BeginsWith:s("Starts with"),EndsWith:s("Ends with"),Equal:s("Is equal to"),NotEqual:s("Is not equal to"),GreaterThan:s("Is greater than"),GreaterThanOrEqual:s("Is greater than or equal to"),LessThan:s("Is less than"),LessThanOrEqual:s("Is less than or equal to"),Between:s("Is between"),NotBetween:s("Is not between")},jo={Series:s("Series"),Errors:{Unexpected:s("The chart definition is invalid for an unknown reason"),32:s("The dataset is invalid"),33:s("Labels are invalid"),34:s("The key value is invalid"),35:s("The baseline value is invalid"),36:s("The data range is invalid"),37:s("A minimum range limit value is needed"),38:s("The minimum range limit value must be a number"),39:s("A maximum range limit value is needed"),40:s("The maximum range limit value must be a number"),41:s("Minimum range limit must be smaller than maximum range limit"),42:s("The lower inflection point value must be a number"),43:s("The upper inflection point value must be a number")}},Xo={Automatic:s("Automatic"),Number:s("Number"),Percent:s("Percent"),Currency:s("Currency"),CurrencyRounded:s("Currency rounded"),Date:s("Date"),Time:s("Time"),DateTime:s("Date time"),Duration:s("Duration"),CustomCurrency:s("Custom currency")},Yo={Custom:s("Custom")},Ko=s("Merged cells are preventing this operation. Unmerge those cells and try again.");function Qo(e,t){if(t.dataRange){const i=t.labelCell?[Di(t.labelCell.zone)]:[],o=Gi([Di(t.dataRange.zone)],i)[0];if(void 0===o)return[];const n=e.getRangeFromSheetXC(t.dataRange.sheetId,o);return e.getRangeValues(n).map((e=>""===e?void 0:e))}return[]}function Jo(e,t){const i=ze(0,Math.max(e.length,...t.map((e=>{var t;return(null===(t=e.data)||void 0===t?void 0:t.length)||0})))).filter((i=>{const o=e[i],n=t.map((e=>{var t;return null===(t=e.data)||void 0===t?void 0:t[i]}));return o||n.some((e=>0===e||Boolean(e)))}));return{labels:i.map((t=>e[t]||"")),dataSetsValues:t.map((e=>({...e,data:i.map((t=>e.data[t]))})))}}function en(e,t){const i=new Set(e),o={};i.forEach((e=>{o[e]=new Array(t.length).fill(0)}));for(const i of ze(0,e.length)){const s=e[i];for(const e of ze(0,t.length))o[s][e]+="number"==typeof(n=t[e].data[i])?n:0}var n;return{labels:Object.keys(o),dataSetsValues:t.map(((e,t)=>({...e,data:Object.values(o).map((e=>e[t]))})))}}function tn(e){return e?e.length>Q?e.substring(0,Q)+"…":e:""}function on(e,t,i,o){return{type:e.type,options:{responsive:!0,maintainAspectRatio:!1,layout:{padding:{left:20,right:20,top:e.title?10:25,bottom:10}},elements:{line:{fill:!1},point:{hitRadius:15}},animation:{duration:0},hover:{animationDuration:10},responsiveAnimationDuration:0,title:{display:!!e.title,fontSize:22,fontStyle:"normal",text:n(e.title),fontColor:i},legend:{onClick:void 0},tooltips:{callbacks:{label:function(e,t){var i,n,s,r,a;let l=null===(n=null===(i=t.datasets)||void 0===i?void 0:i[e.datasetIndex||0])||void 0===n?void 0:n.label;const c=""!==e.yLabel?e.yLabel:null===(a=null===(r=null===(s=t.datasets)||void 0===s?void 0:s[e.datasetIndex||0])||void 0===r?void 0:r.data)||void 0===a?void 0:a[e.index||0],h=o&&"number"==typeof c?li(c,o):(null==c?void 0:c.toLocaleString())||"";return l?`${l}: ${h}`:h}}}},data:{labels:t.map(tn),datasets:[]}}}function nn(e,t,i){let o={values:[],formattedValues:[]};if(i)i.invalidXc||i.invalidSheetName||(o={formattedValues:e.getRangeFormattedValues(i),values:e.getRangeValues(i).map((e=>String(e)))});else if(1===t.length)for(let i=0;i<Qo(e,t[0]).length;i++)o.formattedValues.push(""),o.values.push("");else if(t[0]){o={formattedValues:ze(0,Qo(e,t[0]).length).map((e=>e.toString())),values:o.formattedValues}}return o}function sn(e,t){for(const i of t){const t=e.getRangeFormats(i.dataRange).find((e=>void 0!==e&&!ui(e)));if(t)return t}}function rn(e,t){const i=[];for(const[o,n]of Object.entries(t)){let t;if(n.labelCell){const i=n.labelCell,s=i?e.getEvaluatedCell({sheetId:i.sheetId,col:i.zone.left,row:i.zone.top}):void 0;t=s&&i?tn(s.formattedValue):t=`${jo.Series} ${parseInt(o)+1}`}else t=t=`${jo.Series} ${parseInt(o)+1}`;let s=n.dataRange?Qo(e,n):[];i.push({data:s,label:t})}return i}function an(e){return 0===e?"origin":e-1}class ln extends vo{constructor(e,t,i){super(e,t,i),this.type="bar",this.dataSets=Do(i,e.dataSets,t,e.dataSetsHaveTitle),this.labelRange=Ti(i,t,e.labelRange),this.background=e.background,this.verticalAxisPosition=e.verticalAxisPosition,this.legendPosition=e.legendPosition,this.stacked=e.stacked,this.aggregated=e.aggregated}static transformDefinition(e,t){return Po(e,t)}static validateChartDefinition(e,t){return e.checkValidations(t,Bo,Ho)}static getDefinitionFromContextCreation(e){return{background:e.background,dataSets:e.range?e.range:[],dataSetsHaveTitle:!1,stacked:!1,aggregated:!1,legendPosition:"top",title:e.title||"",type:"bar",verticalAxisPosition:"left",labelRange:e.auxiliaryRange||void 0}}getContextCreation(){return{background:this.background,title:this.title,range:this.dataSets.map((e=>this.getters.getRangeString(e.dataRange,this.sheetId))),auxiliaryRange:this.labelRange?this.getters.getRangeString(this.labelRange,this.sheetId):void 0}}copyForSheetId(e){const t=No(this.sheetId,e,this.dataSets),i=_o(this.sheetId,e,this.labelRange),o=this.getDefinitionWithSpecificDataSets(t,i,e);return new ln(o,e,this.getters)}copyInSheetId(e){const t=this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange,e);return new ln(t,e,this.getters)}getDefinition(){return this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange)}getDefinitionWithSpecificDataSets(e,t,i){return{type:"bar",dataSetsHaveTitle:!!e.length&&Boolean(e[0].labelCell),background:this.background,dataSets:e.map((e=>this.getters.getRangeString(e.dataRange,i||this.sheetId))),legendPosition:this.legendPosition,verticalAxisPosition:this.verticalAxisPosition,labelRange:t?this.getters.getRangeString(t,i||this.sheetId):void 0,title:this.title,stacked:this.stacked,aggregated:this.aggregated}}getDefinitionForExcel(){if(this.aggregated)return;const e=this.dataSets.map((e=>Lo(this.getters,e))).filter((e=>""!==e.range));return{...this.getDefinition(),backgroundColor:fo(this.background||w),fontColor:fo(zo(this.background)),dataSets:e}}updateRanges(e){const{dataSets:t,labelRange:i,isStale:o}=Oo(this.getters,e,this.dataSets,this.labelRange);if(!o)return this;const n=this.getDefinitionWithSpecificDataSets(t,i);return new ln(n,this.sheetId,this.getters)}}function cn(e){return e.dataRange&&!Ot.test(e.dataRange)?36:0}function hn(e,t){return t((t=>t.sectionRule?e(t.sectionRule.rangeMin,"rangeMin"):0),(t=>t.sectionRule?e(t.sectionRule.rangeMax,"rangeMax"):0))}function dn(e){return e.sectionRule&&Number(e.sectionRule.rangeMin)>=Number(e.sectionRule.rangeMax)?41:0}function un(e,t){if(""===e)switch(t){case"rangeMin":return 37;case"rangeMax":return 39}return 0}function gn(e,t){if(isNaN(e))switch(t){case"rangeMin":return 38;case"rangeMax":return 40;case"lowerInflectionPointValue":return 42;case"upperInflectionPointValue":return 43}return 0}class pn extends vo{constructor(e,t,i){super(e,t,i),this.type="gauge",this.dataRange=Ti(this.getters,this.sheetId,e.dataRange),this.sectionRule=e.sectionRule,this.background=e.background}static validateChartDefinition(e,t){return e.checkValidations(t,cn,e.chainValidations(hn(un,e.batchValidations),hn(gn,e.batchValidations),dn),e.chainValidations((i=gn,(0,e.batchValidations)((e=>e.sectionRule?i(e.sectionRule.lowerInflectionPoint.value,"lowerInflectionPointValue"):0),(e=>e.sectionRule?i(e.sectionRule.upperInflectionPoint.value,"upperInflectionPointValue"):0)))));var i}static transformDefinition(e,t){let i;return e.dataRange&&(i=bo(Ni(e.dataRange),t)),{...e,dataRange:i?Di(i):void 0}}static getDefinitionFromContextCreation(e){return{background:e.background,title:e.title||"",type:"gauge",dataRange:e.range?e.range[0]:void 0,sectionRule:{colors:{lowerColor:"#cc0000",middleColor:"#f1c232",upperColor:"#6aa84f"},rangeMin:"0",rangeMax:"100",lowerInflectionPoint:{type:"percentage",value:"15"},upperInflectionPoint:{type:"percentage",value:"40"}}}}copyForSheetId(e){const t=_o(this.sheetId,e,this.dataRange),i=this.getDefinitionWithSpecificRanges(t,e);return new pn(i,e,this.getters)}copyInSheetId(e){const t=this.getDefinitionWithSpecificRanges(this.dataRange,e);return new pn(t,e,this.getters)}getDefinition(){return this.getDefinitionWithSpecificRanges(this.dataRange)}getDefinitionWithSpecificRanges(e,t){return{background:this.background,sectionRule:this.sectionRule,title:this.title,type:"gauge",dataRange:e?this.getters.getRangeString(e,t||this.sheetId):void 0}}getDefinitionForExcel(){}getContextCreation(){return{background:this.background,title:this.title,range:this.dataRange?[this.getters.getRangeString(this.dataRange,this.sheetId)]:void 0}}updateRanges(e){const t=Fo(this.dataRange,e);if(this.dataRange===t)return this;const i=this.getDefinitionWithSpecificRanges(t);return new pn(i,this.sheetId,this.getters)}}const mn={second:1e3,minute:6e4,hour:36e5,day:864e5,month:2592e6,year:31536e6},fn={inSeconds:function(e){return Math.floor(e/mn.second)},inMinutes:function(e){return Math.floor(e/mn.minute)},inHours:function(e){return Math.floor(e/mn.hour)},inDays:function(e){return Math.floor(e/mn.day)},inMonths:function(e){return Math.floor(e/mn.month)},inYears:function(e){return Math.floor(e/mn.year)}},vn=/^((d|dd|m|mm|yyyy|yy|hh|h|ss|a)(-|:|\s|\/))*(d|dd|m|mm|yyyy|yy|hh|h|ss|a)$/i;function bn(e,t){const i=function(e){const t=(e=(e=e.replace(/y/g,"Y")).replace(/d/g,"D")).indexOf("h");e=t>=0?e.slice(0,t).replace(/m/g,"M")+e.slice(t):e.replace(/m/g,"M");e.includes("a")||(e=e.replace(/h/g,"H"));return e}(t),o=function(e,t){const i=e.map((e=>{var t;return null===(t=Se(e))||void 0===t?void 0:t.jsDate}));if(i.some((e=>void 0===e))||e.length<2)return;const o=i.map((e=>e.getTime())),n=Math.max(...o)-Math.min(...o),s=function(e){if(e.includes("s"))return"second";if(e.includes("m"))return"minute";if(e.includes("h")||e.includes("H"))return"hour";if(e.includes("D"))return"day";if(e.includes("M"))return"month";return"year"}(t);if(mn.second>=mn[s]&&fn.inSeconds(n)<180)return"second";if(mn.minute>=mn[s]&&fn.inMinutes(n)<180)return"minute";if(mn.hour>=mn[s]&&fn.inHours(n)<96)return"hour";if(mn.day>=mn[s]&&fn.inDays(n)<90)return"day";if(mn.month>=mn[s]&&fn.inMonths(n)<36)return"month";return"year"}(e,i),n={};return o&&(n[o]=i),{parser:i,displayFormats:n,unit:o}}class Sn extends vo{constructor(e,t,i){super(e,t,i),this.type="line",this.dataSets=Do(this.getters,e.dataSets,t,e.dataSetsHaveTitle),this.labelRange=Ti(this.getters,t,e.labelRange),this.background=e.background,this.verticalAxisPosition=e.verticalAxisPosition,this.legendPosition=e.legendPosition,this.labelsAsText=e.labelsAsText,this.stacked=e.stacked,this.aggregated=e.aggregated}static validateChartDefinition(e,t){return e.checkValidations(t,Bo,Ho)}static transformDefinition(e,t){return Po(e,t)}static getDefinitionFromContextCreation(e){return{background:e.background,dataSets:e.range?e.range:[],dataSetsHaveTitle:!1,labelsAsText:!1,legendPosition:"top",title:e.title||"",type:"line",verticalAxisPosition:"left",labelRange:e.auxiliaryRange||void 0,stacked:!1,aggregated:!1}}getDefinition(){return this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange)}getDefinitionWithSpecificDataSets(e,t,i){return{type:"line",dataSetsHaveTitle:!!e.length&&Boolean(e[0].labelCell),background:this.background,dataSets:e.map((e=>this.getters.getRangeString(e.dataRange,i||this.sheetId))),legendPosition:this.legendPosition,verticalAxisPosition:this.verticalAxisPosition,labelRange:t?this.getters.getRangeString(t,i||this.sheetId):void 0,title:this.title,labelsAsText:this.labelsAsText,stacked:this.stacked,aggregated:this.aggregated}}getContextCreation(){return{background:this.background,title:this.title,range:this.dataSets.map((e=>this.getters.getRangeString(e.dataRange,this.sheetId))),auxiliaryRange:this.labelRange?this.getters.getRangeString(this.labelRange,this.sheetId):void 0}}updateRanges(e){const{dataSets:t,labelRange:i,isStale:o}=Oo(this.getters,e,this.dataSets,this.labelRange);if(!o)return this;const n=this.getDefinitionWithSpecificDataSets(t,i);return new Sn(n,this.sheetId,this.getters)}getDefinitionForExcel(){if(this.aggregated)return;const e=this.dataSets.map((e=>Lo(this.getters,e))).filter((e=>""!==e.range));return{...this.getDefinition(),backgroundColor:fo(this.background||w),fontColor:fo(zo(this.background)),dataSets:e}}copyForSheetId(e){const t=No(this.sheetId,e,this.dataSets),i=_o(this.sheetId,e,this.labelRange),o=this.getDefinitionWithSpecificDataSets(t,i,e);return new Sn(o,e,this.getters)}copyInSheetId(e){const t=this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange,e);return new Sn(t,e,this.getters)}}function Cn(e,t){return wn(e,t)||yn(e,t)}function En(e,t){return function(e,t){return!e.labelsAsText&&wn(e.labelRange,t)}(e,t)?"time":function(e,t){return!e.labelsAsText&&yn(e.labelRange,t)}(e,t)?"linear":"category"}function wn(e,t){if(!e||!yn(e,t))return!1;const i=t.getEvaluatedCell({sheetId:e.sheetId,col:e.zone.left,row:e.zone.top}).format;return Boolean(i&&vn.test(i))}function yn(e,t){if(!e)return!1;const i=t.getRangeValues(e);return!i.some((e=>isNaN(Number(e))&&e))&&!i.every((e=>!e))}class xn extends vo{constructor(e,t,i){super(e,t,i),this.type="pie",this.dataSets=Do(i,e.dataSets,t,e.dataSetsHaveTitle),this.labelRange=Ti(i,t,e.labelRange),this.background=e.background,this.legendPosition=e.legendPosition,this.aggregated=e.aggregated}static transformDefinition(e,t){return Po(e,t)}static validateChartDefinition(e,t){return e.checkValidations(t,Bo,Ho)}static getDefinitionFromContextCreation(e){return{background:e.background,dataSets:e.range?e.range:[],dataSetsHaveTitle:!1,legendPosition:"top",title:e.title||"",type:"pie",labelRange:e.auxiliaryRange||void 0,aggregated:!1}}getDefinition(){return this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange)}getContextCreation(){return{background:this.background,title:this.title,range:this.dataSets.map((e=>this.getters.getRangeString(e.dataRange,this.sheetId))),auxiliaryRange:this.labelRange?this.getters.getRangeString(this.labelRange,this.sheetId):void 0}}getDefinitionWithSpecificDataSets(e,t,i){return{type:"pie",dataSetsHaveTitle:!!e.length&&Boolean(e[0].labelCell),background:this.background,dataSets:e.map((e=>this.getters.getRangeString(e.dataRange,i||this.sheetId))),legendPosition:this.legendPosition,labelRange:t?this.getters.getRangeString(t,i||this.sheetId):void 0,title:this.title,aggregated:this.aggregated}}copyForSheetId(e){const t=No(this.sheetId,e,this.dataSets),i=_o(this.sheetId,e,this.labelRange),o=this.getDefinitionWithSpecificDataSets(t,i,e);return new xn(o,e,this.getters)}copyInSheetId(e){const t=this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange,e);return new xn(t,e,this.getters)}getDefinitionForExcel(){if(this.aggregated)return;const e=this.dataSets.map((e=>Lo(this.getters,e))).filter((e=>""!==e.range));return{...this.getDefinition(),backgroundColor:fo(this.background||w),fontColor:fo(zo(this.background)),verticalAxisPosition:"left",dataSets:e}}updateRanges(e){const{dataSets:t,labelRange:i,isStale:o}=Oo(this.getters,e,this.dataSets,this.labelRange);if(!o)return this;const n=this.getDefinitionWithSpecificDataSets(t,i);return new xn(n,this.sheetId,this.getters)}}function In(e,t){const i=[],o=Math.max(...t.map((e=>e.data.length)));for(let t=0;t<=o;t++)i.push(e.next());return i}function Rn(e){return e.keyValue&&!Ot.test(e.keyValue)?34:0}function Tn(e){return e.baseline&&!Ot.test(e.baseline)?35:0}class An extends vo{constructor(e,t,i){super(e,t,i),this.type="scorecard",this.keyValue=Ti(i,t,e.keyValue),this.baseline=Ti(i,t,e.baseline),this.baselineMode=e.baselineMode,this.baselineDescr=e.baselineDescr,this.background=e.background,this.baselineColorUp=e.baselineColorUp,this.baselineColorDown=e.baselineColorDown}static validateChartDefinition(e,t){return e.checkValidations(t,Rn,Tn)}static getDefinitionFromContextCreation(e){return{background:e.background,type:"scorecard",keyValue:e.range?e.range[0]:void 0,title:e.title||"",baselineMode:ee,baselineColorUp:te,baselineColorDown:ie,baseline:e.auxiliaryRange||""}}static transformDefinition(e,t){let i,o;return e.baseline&&(i=bo(Ni(e.baseline),t)),e.keyValue&&(o=bo(Ni(e.keyValue),t)),{...e,baseline:i?Di(i):void 0,keyValue:o?Di(o):void 0}}copyForSheetId(e){const t=_o(this.sheetId,e,this.baseline),i=_o(this.sheetId,e,this.keyValue),o=this.getDefinitionWithSpecificRanges(t,i,e);return new An(o,e,this.getters)}copyInSheetId(e){const t=this.getDefinitionWithSpecificRanges(this.baseline,this.keyValue,e);return new An(t,e,this.getters)}getDefinition(){return this.getDefinitionWithSpecificRanges(this.baseline,this.keyValue)}getContextCreation(){return{background:this.background,title:this.title,range:this.keyValue?[this.getters.getRangeString(this.keyValue,this.sheetId)]:void 0,auxiliaryRange:this.baseline?this.getters.getRangeString(this.baseline,this.sheetId):void 0}}getDefinitionWithSpecificRanges(e,t,i){return{baselineColorDown:this.baselineColorDown,baselineColorUp:this.baselineColorUp,baselineMode:this.baselineMode,title:this.title,type:"scorecard",background:this.background,baseline:e?this.getters.getRangeString(e,i||this.sheetId):void 0,baselineDescr:this.baselineDescr,keyValue:t?this.getters.getRangeString(t,i||this.sheetId):void 0}}getDefinitionForExcel(){}updateRanges(e){const t=Fo(this.baseline,e),i=Fo(this.keyValue,e);if(this.baseline===t&&this.keyValue===i)return this;const o=this.getDefinitionWithSpecificRanges(t,i);return new An(o,this.sheetId,this.getters)}}class Mn{constructor(){this.content={}}add(e,t){return this.content[e]=t,this}get(e){const t=this.content[e];if(!t&&!(e in this.content))throw new Error(`Cannot find ${e} in this registry!`);return t}contains(e){return e in this.content}getAll(){return Object.values(this.content)}getKeys(){return Object.keys(this.content)}remove(e){delete this.content[e]}}const On=new Mn;On.add("bar",{match:e=>"bar"===e,createChart:(e,t,i)=>new ln(e,t,i),getChartRuntime:function(e,t){let i=nn(t,e.dataSets,e.labelRange).formattedValues,o=rn(t,e.dataSets);({labels:i,dataSetsValues:o}=Jo(i,o)),e.aggregated&&({labels:i,dataSetsValues:o}=en(i,o));const n=function(e,t,i){var o;const n=zo(e.background),s=on(e,t,n,i),r={labels:{fontColor:n}};return!e.labelRange&&1===e.dataSets.length||"none"===e.legendPosition?r.display=!1:r.position=e.legendPosition,s.options.legend={...null===(o=s.options)||void 0===o?void 0:o.legend,...r},s.options.layout={padding:{left:20,right:20,top:e.title?10:25,bottom:10}},s.options.scales={xAxes:[{ticks:{maxRotation:60,minRotation:15,padding:5,labelOffset:2,fontColor:n}}],yAxes:[{position:e.verticalAxisPosition,ticks:{fontColor:n,beginAtZero:!0,callback:e=>i?li(e,i):(null==e?void 0:e.toLocaleString())||e}}]},e.stacked&&(s.options.scales.xAxes[0].stacked=!0,s.options.scales.yAxes[0].stacked=!0),s}(e,i,sn(t,e.dataSets)),s=new Vo;for(let{label:e,data:t}of o){const i=s.next(),o={label:e,data:t,borderColor:i,backgroundColor:i};n.data.datasets.push(o)}return{chartJsConfig:n,background:e.background||w}},validateChartDefinition:(e,t)=>ln.validateChartDefinition(e,t),transformDefinition:(e,t)=>ln.transformDefinition(e,t),getChartDefinitionFromContextCreation:e=>ln.getDefinitionFromContextCreation(e),name:s("Bar"),sequence:10}),On.add("line",{match:e=>"line"===e,createChart:(e,t,i)=>new Sn(e,t,i),getChartRuntime:function(e,t){const i=En(e,t),o=nn(t,e.dataSets,e.labelRange);let n="linear"===i?o.values:o.formattedValues,s=rn(t,e.dataSets);({labels:n,dataSetsValues:s}=Jo(n,s)),"time"===i&&({labels:n,dataSetsValues:s}=function(e,t){if(0===e.length||e.every((e=>!e)))return{labels:e,dataSetsValues:t};const i=[...e],o=Ne(t);for(let e=0;e<i.length;e++)if(!i[e]){i[e]=st(i,e);for(let t of o)t.data[e]=void 0}return{labels:i,dataSetsValues:o}}(n,s)),e.aggregated&&({labels:n,dataSetsValues:s}=en(n,s));const r=sn(t,e.dataSets),a=function(e,t,i){var o;const n=zo(e.background),s=on(e,t,n,i),r={labels:{fontColor:n,generateLabels(e){const{data:t}=e,i=window.Chart.defaults.global.legend.labels.generateLabels(e);for(const[e,o]of i.entries())o.fillStyle=t.datasets[e].borderColor;return i}}};return!e.labelRange&&1===e.dataSets.length||"none"===e.legendPosition?r.display=!1:r.position=e.legendPosition,s.options.legend={...null===(o=s.options)||void 0===o?void 0:o.legend,...r},s.options.layout={padding:{left:20,right:20,top:e.title?10:25,bottom:10}},s.options.scales={xAxes:[{ticks:{maxRotation:60,minRotation:15,padding:5,labelOffset:2,fontColor:n}}],yAxes:[{position:e.verticalAxisPosition,ticks:{fontColor:n,beginAtZero:!0,callback:e=>i?li(e,i):(null==e?void 0:e.toLocaleString())||e}}]},e.stacked&&(s.options.scales.yAxes[0].stacked=!0),s}(e,n,r),l=function(e,t){if(t)return e.getEvaluatedCell({sheetId:t.sheetId,col:t.zone.left,row:t.zone.top}).format}(t,e.labelRange);"time"===i?(a.options.scales.xAxes[0].type="time",a.options.scales.xAxes[0].time=bn(n,l),a.options.scales.xAxes[0].ticks.maxTicksLimit=15):"linear"===i&&(a.options.scales.xAxes[0].type="linear",a.options.scales.xAxes[0].ticks.callback=e=>li(e,l),a.options.tooltips.callbacks.title=e=>{var t;return li((null===(t=e[0])||void 0===t?void 0:t.xLabel)||"",l)});const c=new Vo;for(let[t,{label:o,data:r}]of s.entries()){["linear","time"].includes(i)&&(r=r.map(((e,t)=>({x:n[t]||void 0,y:e}))));const s=c.next();let l=wt(s);e.stacked&&(l.a=oe);const h={label:o,data:r,lineTension:0,borderColor:s,backgroundColor:Et(l),pointBackgroundColor:s,fill:!!e.stacked&&an(t)};a.data.datasets.push(h)}return{chartJsConfig:a,background:e.background||w}},validateChartDefinition:(e,t)=>Sn.validateChartDefinition(e,t),transformDefinition:(e,t)=>Sn.transformDefinition(e,t),getChartDefinitionFromContextCreation:e=>Sn.getDefinitionFromContextCreation(e),name:s("Line"),sequence:20}),On.add("pie",{match:e=>"pie"===e,createChart:(e,t,i)=>new xn(e,t,i),getChartRuntime:function(e,t){let i=nn(t,e.dataSets,e.labelRange).formattedValues,o=rn(t,e.dataSets);({labels:i,dataSetsValues:o}=Jo(i,o)),e.aggregated&&({labels:i,dataSetsValues:o}=en(i,o));const n=function(e,t,i){var o;const n=zo(e.background),s=on(e,t,n,i),r={labels:{fontColor:n}};return!e.labelRange&&1===e.dataSets.length||"none"===e.legendPosition?r.display=!1:r.position=e.legendPosition,s.options.legend={...null===(o=s.options)||void 0===o?void 0:o.legend,...r},s.options.layout={padding:{left:20,right:20,top:e.title?10:25,bottom:10}},s.options.tooltips.callbacks.title=function(e,t){return t.datasets[e[0].datasetIndex].label},s}(e,i,sn(t,e.dataSets)),s=new Vo;for(let{label:e,data:t}of o){const i={label:e,data:t,borderColor:"#FFFFFF",backgroundColor:In(s,o)};n.data.datasets.push(i)}return{chartJsConfig:n,background:e.background||w}},validateChartDefinition:(e,t)=>xn.validateChartDefinition(e,t),transformDefinition:(e,t)=>xn.transformDefinition(e,t),getChartDefinitionFromContextCreation:e=>xn.getDefinitionFromContextCreation(e),name:s("Pie"),sequence:30}),On.add("scorecard",{match:e=>"scorecard"===e,createChart:(e,t,i)=>new An(e,t,i),getChartRuntime:function(e,t){let i,o,s="",r="";if(e.keyValue){const o={sheetId:e.keyValue.sheetId,col:e.keyValue.zone.left,row:e.keyValue.zone.top};i=t.getEvaluatedCell(o),s=String(i.value),r=i.formattedValue}const a=e.baseline;if(a){const i={sheetId:e.baseline.sheetId,col:e.baseline.zone.left,row:e.baseline.zone.top};o=t.getEvaluatedCell(i)}const l=t.getBackgroundOfSingleCellChart(e.background,e.keyValue);return{title:n(e.title),keyValue:r||s,baselineDisplay:$o(o,i,e.baselineMode),baselineArrow:Go(o,i,e.baselineMode),baselineColor:Wo(o,e.baselineMode,i,e.baselineColorUp,e.baselineColorDown),baselineDescr:e.baselineDescr?n(e.baselineDescr):"",fontColor:zo(l),background:l,baselineStyle:"percentage"!==e.baselineMode&&a?t.getCellStyle({sheetId:a.sheetId,col:a.zone.left,row:a.zone.top}):void 0,keyValueStyle:e.keyValue?t.getCellStyle({sheetId:e.keyValue.sheetId,col:e.keyValue.zone.left,row:e.keyValue.zone.top}):void 0}},validateChartDefinition:(e,t)=>An.validateChartDefinition(e,t),transformDefinition:(e,t)=>An.transformDefinition(e,t),getChartDefinitionFromContextCreation:e=>An.getDefinitionFromContextCreation(e),name:s("Scorecard"),sequence:40}),On.add("gauge",{match:e=>"gauge"===e,createChart:(e,t,i)=>new pn(e,t,i),getChartRuntime:function(e,t){const i=function(e){const t=on(e,[],zo(e.background));return t.options.hover=void 0,t.options.events=[],t.options.layout={padding:{left:30,right:30,top:e.title?10:25,bottom:25}},t.options.needle={radiusPercentage:2,widthPercentage:3.2,lengthPercentage:80,color:"#000000"},t.options.valueLabel={display:!1,formatter:null,color:"#FFFFFF",backgroundColor:"#000000",fontSize:30,borderRadius:5,padding:{top:5,right:5,bottom:5,left:5},bottomMarginPercentage:5},t}(e),o=e.sectionRule.colors,n=e.sectionRule.lowerInflectionPoint,s=e.sectionRule.upperInflectionPoint,r=Number(n.value),a=Number(s.value),l=Number(e.sectionRule.rangeMin),c=Number(e.sectionRule.rangeMax),h=c-l,d=[];if(""!==n.value){const e="number"===n.type?r:l+h*r/100;d.push({value:De(e,l,c),color:o.lowerColor})}if(""!==s.value){const e="number"===s.type?a:l+h*a/100;d.push({value:De(e,l,c),color:o.middleColor})}const u=[],g=[];d.sort(((e,t)=>e.value-t.value)).map((e=>{u.push(e.value),g.push(e.color)})),u.push(c),g.push(o.upperColor);const p=e.dataRange,m=h/30;let f=l-m,v=null,b=!1;if(void 0!==p){const e=t.getEvaluatedCell({sheetId:p.sheetId,col:p.zone.left,row:p.zone.top});e.type===So.number&&(f=De(e.value,l-m,c+m),v=()=>t.getRangeFormattedValues(p)[0],b=!0)}return i.options.valueLabel.display=b,i.options.valueLabel.formatter=v,i.data.datasets.push({data:u,minValue:Number(e.sectionRule.rangeMin),value:f,backgroundColor:g}),{chartJsConfig:i,background:t.getBackgroundOfSingleCellChart(e.background,p)}},validateChartDefinition:(e,t)=>pn.validateChartDefinition(e,t),transformDefinition:(e,t)=>pn.transformDefinition(e,t),getChartDefinitionFromContextCreation:e=>pn.getDefinitionFromContextCreation(e),name:s("Gauge"),sequence:50});const Nn=new Mn;function _n(e){return e.map(Dn).sort(((e,t)=>e.sequence-t.sequence))}Nn.add("line",oo),Nn.add("bar",oo),Nn.add("pie",oo),Nn.add("gauge",oo),Nn.add("scorecard",go);const Fn=new Oi;function Dn(e){const t=e.name,i=e.children;return{id:e.id||Fn.uuidv4(),name:"function"==typeof t?t:()=>t,isVisible:e.isVisible?e.isVisible:()=>!0,isEnabled:e.isEnabled?e.isEnabled:()=>!0,action:e.action,children:i?e=>i.map((t=>"function"==typeof t?t(e):t)).flat().map(Dn):()=>[],isReadonlyAllowed:e.isReadonlyAllowed||!1,separator:e.separator||!1,icon:e.icon,description:e.description||"",textColor:e.textColor,sequence:e.sequence||0}}class kn extends Mn{add(e,t){return void 0===t.id&&(t.id=e),this.content[e]=t,this}addChild(e,t,i){"function"!=typeof i&&void 0===i.id&&(i.id=e);const o=t.splice(0,1)[0];let n=this.content[o];if(!n)throw new Error(`Path ${o+":"+t.join(":")} not found`);for(let e of t){const i=n.children;if(!i||"function"==typeof i)throw new Error(`${e} is either not a node or it's dynamically computed`);if(n=i.find((t=>t.id===e)),!n)throw new Error(`Path ${o+":"+t.join(":")} not found`)}return n.children||(n.children=[]),n.children.push(i),this}getMenuItems(){return _n(this.getAll())}}function Ln(){const e=t.useState({x:0,y:0,width:0,height:0});let i=document.querySelector(".o-spreadsheet");function o(){if(i||(i=document.querySelector(".o-spreadsheet")),i){const{top:t,left:o,width:n,height:s}=i.getBoundingClientRect();e.x=o,e.y=t,e.width=n,e.height=s}}return o(),t.onMounted(o),t.onPatched(o),e}function Pn(e){const i=t.useState({x:0,y:0,width:0,height:0});function o(){const t=e.el;if(null===t)return;const{top:o,left:n,width:s,height:r}=t.getBoundingClientRect();i.x=n,i.y=o,i.width=s,i.height=r}return t.onMounted(o),t.onPatched(o),i}function Un(e,t){return!!t.target&&e.contains(t.target)}function Vn(){const e=document.querySelector(".o-grid-overlay");if(e){const{top:t,left:i}=null==e?void 0:e.getBoundingClientRect();return{top:t,left:i}}throw new Error("Can't find spreadsheet position")}function zn(e){const t=e.getBoundingClientRect();return{x:t.x,y:t.y,width:t.width,height:t.height}}function*Bn(e){if(yield e,e.hasChildNodes())for(let t of e.childNodes)yield*Bn(t)}function Hn(e,t){return(i=zi($n(e),$n(t)))?{x:i.left,y:i.top,width:i.right-i.left,height:i.bottom-i.top}:void 0;var i}function $n(e){return{left:e.x,top:e.y,right:e.x+e.width,bottom:e.y+e.height}}ro`
|
|
53
|
-
.o-popover {
|
|
54
|
-
position: absolute;
|
|
55
|
-
z-index: ${le.Popover};
|
|
56
|
-
overflow: auto;
|
|
57
|
-
box-shadow: 1px 2px 5px 2px rgb(51 51 51 / 15%);
|
|
58
|
-
width: fit-content;
|
|
59
|
-
height: fit-content;
|
|
60
|
-
}
|
|
61
|
-
`;class Wn extends t.Component{constructor(){super(...arguments),this.popoverRef=t.useRef("popover"),this.currentPosition=void 0,this.currentDisplayValue=void 0,this.spreadsheetRect=Ln()}setup(){this.containerRect=function(){const e=t.useState({x:0,y:0,width:0,height:0}),i=t.useComponent(),o=Ln();function n(){const t=i.env,n="getPopoverContainerRect"in t?t.getPopoverContainerRect():o;e.x=n.x,e.y=n.y,e.width=n.width,e.height=n.height}return n(),t.onMounted(n),t.onPatched(n),e}(),t.useEffect((()=>{var e,t,i,o;if(!this.containerRect)throw new Error("Popover container is not defined");const n=this.popoverRef.el,s=Hn(this.props.anchorRect,this.containerRect),r=s?"block":"none";if("none"!==this.currentDisplayValue&&"none"===r&&(null===(t=(e=this.props).onPopoverHidden)||void 0===t||t.call(e)),n.style.display=r,this.currentDisplayValue=r,!s)return;const a={width:this.props.maxWidth,height:this.props.maxHeight},l={width:n.getBoundingClientRect().width,height:n.getBoundingClientRect().height},c=this.spreadsheetRect,h="BottomLeft"===this.props.positioning?new qn(s,this.containerRect,a,c):new Zn(s,this.containerRect,a,c),d=h.getCss(l,this.props.verticalOffset);for(const e of Object.keys(d))n.style[e]=d[e];const u=h.getCurrentPosition(l);this.currentPosition&&u!==this.currentPosition&&(null===(o=(i=this.props).onPopoverMoved)||void 0===o||o.call(i)),this.currentPosition=u}))}}Wn.template="o-spreadsheet-Popover",Wn.defaultProps={positioning:"BottomLeft",verticalOffset:0,onMouseWheel:()=>{},onPopoverMoved:()=>{},onPopoverHidden:()=>{}},Wn.props={anchorRect:Object,containerRect:{type:Object,optional:!0},positioning:{type:String,optional:!0},maxWidth:{type:Number,optional:!0},maxHeight:{type:Number,optional:!0},verticalOffset:{type:Number,optional:!0},onMouseWheel:{type:Function,optional:!0},onPopoverHidden:{type:Function,optional:!0},onPopoverMoved:{type:Function,optional:!0},slots:Object};class Gn{constructor(e,t,i,o){this.anchorRect=e,this.containerRect=t,this.propsMaxSize=i,this.spreadsheetOffset=o}shouldRenderAtBottom(e){return e<=this.availableHeightDown||this.availableHeightDown>=this.availableHeightUp}shouldRenderAtRight(e){return e<=this.availableWidthRight||this.availableWidthRight>=this.availableWidthLeft}getMaxHeight(e){const t=this.shouldRenderAtBottom(e)?this.availableHeightDown:this.availableHeightUp;return this.propsMaxSize.height?Math.min(t,this.propsMaxSize.height):t}getMaxWidth(e){const t=this.shouldRenderAtRight(e)?this.availableWidthRight:this.availableWidthLeft;return this.propsMaxSize.width?Math.min(t,this.propsMaxSize.width):t}getCss(e,t){const i=this.getMaxHeight(e.height),o=this.getMaxWidth(e.width),n=Math.min(i,e.height),s=Math.min(o,e.width),r=this.shouldRenderAtBottom(e.height),a=this.shouldRenderAtRight(e.width);t=r?t:-t;return{"max-height":i+"px","max-width":o+"px",top:this.getTopCoordinate(n,r)-this.spreadsheetOffset.y-t+"px",left:this.getLeftCoordinate(s,a)-this.spreadsheetOffset.x+"px"}}getCurrentPosition(e){const t=this.shouldRenderAtBottom(e.height),i=this.shouldRenderAtRight(e.width);return t&&i?"BottomRight":t&&!i?"BottomLeft":!t&&i?"TopRight":"TopLeft"}}class qn extends Gn{get availableHeightUp(){return this.anchorRect.y-this.containerRect.y}get availableHeightDown(){return this.containerRect.height-this.availableHeightUp-this.anchorRect.height}get availableWidthRight(){return this.containerRect.x+this.containerRect.width-this.anchorRect.x}get availableWidthLeft(){return this.anchorRect.x+this.anchorRect.width-this.containerRect.x}getTopCoordinate(e,t){return t?this.anchorRect.y+this.anchorRect.height:this.anchorRect.y-e}getLeftCoordinate(e,t){return t?this.anchorRect.x:this.anchorRect.x+this.anchorRect.width-e}}class Zn extends Gn{get availableHeightUp(){return this.anchorRect.y+this.anchorRect.height-this.containerRect.y}get availableHeightDown(){return this.containerRect.y+this.containerRect.height-this.anchorRect.y}get availableWidthRight(){return this.containerRect.width-this.anchorRect.width-this.availableWidthLeft}get availableWidthLeft(){return this.anchorRect.x-this.containerRect.x}getTopCoordinate(e,t){return t?this.anchorRect.y:this.anchorRect.y+this.anchorRect.height-e}getLeftCoordinate(e,t){return t?this.anchorRect.x+this.anchorRect.width:this.anchorRect.x-e}}ro`
|
|
62
|
-
.o-menu {
|
|
63
|
-
background-color: white;
|
|
64
|
-
padding: ${8}px 0px;
|
|
65
|
-
width: ${H}px;
|
|
66
|
-
box-sizing: border-box !important;
|
|
67
|
-
|
|
68
|
-
.o-menu-item {
|
|
69
|
-
display: flex;
|
|
70
|
-
justify-content: space-between;
|
|
71
|
-
align-items: center;
|
|
72
|
-
box-sizing: border-box;
|
|
73
|
-
height: ${28}px;
|
|
74
|
-
padding: 4px 16px;
|
|
75
|
-
cursor: pointer;
|
|
76
|
-
user-select: none;
|
|
77
|
-
|
|
78
|
-
.o-menu-item-name {
|
|
79
|
-
overflow: hidden;
|
|
80
|
-
white-space: nowrap;
|
|
81
|
-
text-overflow: ellipsis;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
&.o-menu-root {
|
|
85
|
-
display: flex;
|
|
86
|
-
justify-content: space-between;
|
|
87
|
-
}
|
|
88
|
-
.o-menu-item-icon {
|
|
89
|
-
margin-top: auto;
|
|
90
|
-
margin-bottom: auto;
|
|
91
|
-
}
|
|
92
|
-
.o-icon {
|
|
93
|
-
width: 10px;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
&:not(.disabled) {
|
|
97
|
-
&:hover,
|
|
98
|
-
&.o-menu-item-active {
|
|
99
|
-
background-color: #ebebeb;
|
|
100
|
-
}
|
|
101
|
-
.o-menu-item-description {
|
|
102
|
-
color: grey;
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
&.disabled {
|
|
106
|
-
color: ${"#CACACA"};
|
|
107
|
-
cursor: not-allowed;
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
`;class jn extends t.Component{constructor(){super(...arguments),this.subMenu=t.useState({isOpen:!1,position:null,scrollOffset:0,menuItems:[]}),this.menuRef=t.useRef("menu"),this.position=Pn(this.menuRef)}setup(){t.useExternalListener(window,"click",this.onExternalClick,{capture:!0}),t.useExternalListener(window,"contextmenu",this.onExternalClick,{capture:!0}),t.onWillUpdateProps((e=>{e.menuItems!==this.props.menuItems&&this.closeSubMenu()}))}get visibleMenuItems(){return this.props.menuItems.filter((e=>e.isVisible(this.env)))}get subMenuPosition(){const e=Object.assign({},this.subMenu.position);return e.y-=this.subMenu.scrollOffset||0,e}get menuHeight(){const e=this.visibleMenuItems;let t=this.getMenuItemsHeight(e);e[e.length-1].separator&&(t-=11);const i=16+t;return this.props.maxHeight?Math.min(i,this.props.maxHeight):i}get popoverProps(){const e=1===this.props.depth;return{anchorRect:{x:this.props.position.x-H*(this.props.depth-1),y:this.props.position.y,width:e?0:H,height:e?0:28},positioning:"TopRight",verticalOffset:e?0:8,onPopoverHidden:()=>this.closeSubMenu(),onPopoverMoved:()=>this.closeSubMenu(),maxHeight:this.menuHeight}}getColor(e){return e.textColor?`color: ${e.textColor}`:void 0}async activateMenu(e){var t,i,o;const n=await(null===(t=e.action)||void 0===t?void 0:t.call(e,this.env));this.close(),null===(o=(i=this.props).onMenuClicked)||void 0===o||o.call(i,{detail:n})}close(){this.closeSubMenu(),this.props.onClose()}subMenuVerticalPosition(e){const t=this.visibleMenuItems.slice(0,e);return this.position.y+this.getMenuItemsHeight(t)+8}onExternalClick(e){this.menuRef.el&&Array.from(document.querySelectorAll(".o-spreadsheet .o-menu")).some((t=>Un(t,e)))||(e.closedMenuId=this.props.menuId,this.close())}getMenuItemsHeight(e){const t=e.filter((e=>e.separator)).length;return 28*e.length+11*t}getName(e){return e.name(this.env)}isRoot(e){return!e.action}isEnabled(e){return!!e.isEnabled(this.env)&&(!this.env.model.getters.isReadonly()||e.isReadonlyAllowed)}onScroll(e){this.subMenu.scrollOffset=e.target.scrollTop}openSubMenu(e,t){const i=this.subMenuVerticalPosition(t);this.subMenu.position={x:this.position.x+this.props.depth*H,y:i-(this.subMenu.scrollOffset||0)},this.subMenu.menuItems=e.children(this.env),this.subMenu.isOpen=!0,this.subMenu.parentMenu=e}isParentMenu(e,t){var i;return(null===(i=e.parentMenu)||void 0===i?void 0:i.id)===t.id}closeSubMenu(){this.subMenu.isOpen=!1,this.subMenu.parentMenu=void 0}onClickMenu(e,t){this.isEnabled(e)&&(this.isRoot(e)?this.openSubMenu(e,t):this.activateMenu(e))}onMouseOver(e,t){e.isEnabled(this.env)&&(this.isRoot(e)?this.openSubMenu(e,t):this.closeSubMenu())}}jn.template="o-spreadsheet-Menu",jn.components={Menu:jn,Popover:Wn},jn.defaultProps={depth:1},jn.props={position:Object,menuItems:Array,depth:{type:Number,optional:!0},maxHeight:{type:Number,optional:!0},onClose:Function,onMenuClicked:{type:Function,optional:!0},menuId:{type:String,optional:!0}},ro`
|
|
112
|
-
.o-chart-container {
|
|
113
|
-
width: 100%;
|
|
114
|
-
height: 100%;
|
|
115
|
-
position: relative;
|
|
116
|
-
}
|
|
117
|
-
`;class Xn extends t.Component{constructor(){super(...arguments),this.menuState=t.useState({isOpen:!1,position:null,menuItems:[]}),this.chartContainerRef=t.useRef("chartContainer"),this.menuButtonRef=t.useRef("menuButton"),this.menuButtonRect=Pn(this.menuButtonRef),this.position=Pn(this.chartContainerRef)}getMenuItemRegistry(){const e=new kn;return e.add("edit",{name:s("Edit"),sequence:1,action:()=>{this.env.model.dispatch("SELECT_FIGURE",{id:this.props.figure.id}),this.env.openSidePanel("ChartPanel")}}),e.add("copy",{name:s("Copy"),sequence:2,action:async()=>{this.env.model.dispatch("SELECT_FIGURE",{id:this.props.figure.id}),this.env.model.dispatch("COPY"),await this.env.clipboard.write(this.env.model.getters.getClipboardContent())}}),e.add("cut",{name:s("Cut"),sequence:3,action:async()=>{this.env.model.dispatch("SELECT_FIGURE",{id:this.props.figure.id}),this.env.model.dispatch("CUT"),await this.env.clipboard.write(this.env.model.getters.getClipboardContent())}}),e.add("delete",{name:s("Delete"),sequence:10,action:()=>{this.env.model.dispatch("DELETE_FIGURE",{sheetId:this.env.model.getters.getActiveSheetId(),id:this.props.figure.id}),this.props.onFigureDeleted()}}),e}get chartType(){return this.env.model.getters.getChartType(this.props.figure.id)}onContextMenu(e){const t={x:this.position.x+e.offsetX,y:this.position.y+e.offsetY};this.openContextMenu(t)}showMenu(){const{x:e,y:t,width:i}=this.menuButtonRect,o={x:e>=H?e-H:e+i,y:t};this.openContextMenu(o)}openContextMenu(e){const t=this.getMenuItemRegistry();this.menuState.isOpen=!0,this.menuState.menuItems=t.getMenuItems(),this.menuState.position=e}get chartComponent(){const e=this.chartType,t=Nn.get(e);if(!t)throw new Error(`Component is not defined for type ${e}`);return t}}function Yn(e){const t=e.model.dispatch("CUT");t.isSuccessful||t.isCancelledBecause(19)&&e.raiseError(s("This operation is not allowed with multiple selections."))}Xn.template="o-spreadsheet-ChartFigure",Xn.components={Menu:jn},Xn.props={figure:Object,onFigureDeleted:Function};const Kn={wrongPasteSelection:s("This operation is not allowed with multiple selections."),willRemoveExistingMerge:s("This operation is not possible due to a merge. Please remove the merges first than try again."),wrongFigurePasteOption:s("Cannot do a special paste of a figure."),frozenPaneOverlap:s("Cannot paste merged cells over a frozen pane.")};function Qn(e,t){t.isSuccessful||(t.reasons.includes(20)?e.raiseError(Kn.wrongPasteSelection):t.reasons.includes(2)?e.raiseError(Kn.willRemoveExistingMerge):t.reasons.includes(22)?e.raiseError(Kn.wrongFigurePasteOption):t.reasons.includes(75)&&e.raiseError(Kn.frozenPaneOverlap))}function Jn(e,t,i){const o=e.model.dispatch("PASTE",{target:t,pasteOption:i});Qn(e,o)}function es(e,t,i){const o=e.model.dispatch("PASTE_FROM_OS_CLIPBOARD",{target:t,text:i});Qn(e,o)}function ts(e,t){const i=On.getAll().find((t=>t.match(e.type)));if(!i)throw new Error("Unknown chart type.");return i.transformDefinition(e,t)}function is(e,t){var i;let o=e;e.left!==e.right&&(o={...e,left:e.left+1});const s=[Di(o)],r=t.getActiveSheetId(),a=t.getCell({sheetId:r,col:e.left,row:e.top});if(1===to(e)&&(null==a?void 0:a.content))return{type:"scorecard",title:"",background:(null===(i=a.style)||void 0===i?void 0:i.fillColor)||void 0,keyValue:Di(e),baselineMode:ee,baselineColorUp:te,baselineColorDown:ie};let l="";const c=t.getEvaluatedCellsInZone(r,{...o,bottom:o.top}),h=!!c.find((e=>e.type!==So.empty&&e.type!==So.number));if(h){const e=c.filter((e=>e.type!==So.error&&e.type!==So.empty)).map((e=>e.formattedValue)),t=e.splice(-1)[0];l=e.join(", "),t&&(l+=(l?" "+n("and")+" ":"")+t)}let d;e.left!==e.right&&(d=Di({...e,right:e.left,top:h?e.top+1:e.top}));const u=o.right===o.left?"none":"top";return Cn(d?t.getRangeFromSheetXC(r,d):void 0,t)?{title:l,dataSets:s,labelsAsText:!1,stacked:!1,aggregated:!1,labelRange:d,type:"line",dataSetsHaveTitle:h,verticalAxisPosition:"left",legendPosition:u}:{title:l,dataSets:s,labelRange:d,type:"bar",stacked:!1,aggregated:!1,dataSetsHaveTitle:h,verticalAxisPosition:"left",legendPosition:u}}function os(e,t){const i=Ne(t),o=e.getSheetViewDimension(),n=o.width,s=o.height;if(i.width>n){const e=n/i.width;i.width=n,i.height=i.height*e}if(i.height>s){const e=s/i.height;i.height=s,i.width=i.width*e}return i}const ns=[So.number,So.error,So.text,So.boolean];function ss(e,t,i,o,n){let r=Ro.Success,a=o.right>o.left;if(e.model.getters.doesIntersectMerge(t,o)){let i;a=!1;for(let n=o.top;n<=o.bottom;n++){i=[];for(let s=o.left;s<=o.right;s++){let o=e.model.getters.getMerge({sheetId:t,col:s,row:n});o&&!i.includes(o.id.toString())&&i.push(o.id.toString())}if(i.length>=2){a=!0;break}}}const{col:l,row:c}=i;if(a)r=e.model.dispatch("SORT_CELLS",{sheetId:t,col:l,row:c,zone:o,sortDirection:n});else{const i=e.model.getters.getContiguousZone(t,o);Bi(i,o)?r=e.model.dispatch("SORT_CELLS",{sheetId:t,col:l,row:c,zone:o,sortDirection:n}):e.askConfirmation(s("We found data next to your selection. Since this data was not selected, it will not be sorted. Do you want to extend your selection?"),(()=>{o=i,r=e.model.dispatch("SORT_CELLS",{sheetId:t,col:l,row:c,zone:o,sortDirection:n})}),(()=>{r=e.model.dispatch("SORT_CELLS",{sheetId:t,col:l,row:c,zone:o,sortDirection:n})}))}if(r.isCancelledBecause(63)){const{col:t,row:n}=i;e.model.selection.selectZone({cell:{col:t,row:n},zone:o}),e.raiseError(s("Cannot sort. To sort, select only cells or only merges that have the same size."))}}const rs={filterOverlap:s("You cannot create overlapping filters."),nonContinuousTargets:s("A filter can only be created on a continuous selection."),mergeInFilter:s("You can't create a filter over a range that contains a merge.")};function as(e,t,i){const o=e.model.dispatch("CREATE_FILTER_TABLE",{target:i,sheetId:t});o.isCancelledBecause(78)?e.raiseError(rs.filterOverlap):o.isCancelledBecause(80)?e.raiseError(rs.mergeInFilter):o.isCancelledBecause(81)&&e.raiseError(rs.nonContinuousTargets)}function ls(e){const t=e.model.getters.getActiveCols();if(t.size)return t.size;{const t=e.model.getters.getSelectedZones()[0];return t.right-t.left+1}}function cs(e){const t=e.model.getters.getActiveRows();if(t.size)return t.size;{const t=e.model.getters.getSelectedZones()[0];return t.bottom-t.top+1}}function hs(e,t){e.model.dispatch("SET_FORMATTING",{sheetId:e.model.getters.getActiveSheetId(),target:e.model.getters.getSelectedZones(),format:t})}function ds(e,t){e.model.dispatch("SET_FORMATTING",{sheetId:e.model.getters.getActiveSheetId(),target:e.model.getters.getSelectedZones(),style:t})}const us=async e=>{e.model.dispatch("COPY"),await e.clipboard.write(e.model.getters.getClipboardContent())},gs=async e=>{Yn(e),await e.clipboard.write(e.model.getters.getClipboardContent())},ps=async e=>fs(e),ms=async e=>fs(e,"onlyValue");async function fs(e,t){const i=e.model.getters.getClipboardTextContent(),o=await e.clipboard.readText();switch(o.status){case"ok":const n=e.model.getters.getSelectedZones();o&&o.content!==i?es(e,n,o.content):Jn(e,n,t);break;case"notImplemented":e.raiseError(s("Pasting from the context menu is not supported in this browser. Use keyboard shortcuts ctrl+c / ctrl+v instead."));break;case"permissionDenied":e.raiseError(s("Access to the clipboard denied by the browser. Please enable clipboard permission for this page in your browser settings."))}}const vs=e=>Jn(e,e.model.getters.getSelectedZones(),"onlyFormat"),bs=e=>!e.model.getters.isCutOperation(),Ss=e=>{if(e.model.getters.getSelectedZones().length>1)return s("Delete rows");let t,i;const o=e.model.getters.getActiveRows();if(0!==o.size)t=Math.min(...o),i=Math.max(...o);else{const o=e.model.getters.getSelectedZones()[0];t=o.top,i=o.bottom}return t===i?s("Delete row %s",(t+1).toString()):s("Delete rows %s - %s",(t+1).toString(),(i+1).toString())},Cs=e=>{let t=[...e.model.getters.getActiveRows()];if(!t.length){const i=e.model.getters.getSelectedZones()[0];for(let e=i.top;e<=i.bottom;e++)t.push(e)}e.model.dispatch("REMOVE_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),dimension:"ROW",elements:t})},Es=e=>{if(e.model.getters.getSelectedZones().length>1)return s("Delete columns");let t,i;const o=e.model.getters.getActiveCols();if(0!==o.size)t=Math.min(...o),i=Math.max(...o);else{const o=e.model.getters.getSelectedZones()[0];t=o.left,i=o.right}return t===i?s("Delete column %s",Lt(t)):s("Delete columns %s - %s",Lt(t),Lt(i))},ws=e=>{let t=[...e.model.getters.getActiveCols()];if(!t.length){const i=e.model.getters.getSelectedZones()[0];for(let e=i.left;e<=i.right;e++)t.push(e)}e.model.dispatch("REMOVE_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),dimension:"COL",elements:t})},ys=e=>{const t=e.model.getters.getSelectedZone(),i=e.model.dispatch("INSERT_CELL",{zone:t,shiftDimension:"ROW"});Qn(e,i)},xs=e=>{const t=e.model.getters.getSelectedZone(),i=e.model.dispatch("INSERT_CELL",{zone:t,shiftDimension:"COL"});Qn(e,i)},Is=e=>{const t=e.model.getters.getSelectedZone(),i=e.model.dispatch("DELETE_CELL",{zone:t,shiftDimension:"ROW"});Qn(e,i)},Rs=e=>{const t=e.model.getters.getSelectedZone(),i=e.model.dispatch("DELETE_CELL",{zone:t,shiftDimension:"COL"});Qn(e,i)},Ts=e=>{const t=e.model.getters.getActiveRows();let i,o;if(t.size)i=Math.min(...t),o=t.size;else{const t=e.model.getters.getSelectedZones()[0];i=t.top,o=t.bottom-t.top+1}e.model.dispatch("ADD_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),position:"before",base:i,quantity:o,dimension:"ROW"})},As=e=>{const t=e.model.getters.getActiveRows();let i,o;if(t.size)i=Math.max(...t),o=t.size;else{const t=e.model.getters.getSelectedZones()[0];i=t.bottom,o=t.bottom-t.top+1}e.model.dispatch("ADD_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),position:"after",base:i,quantity:o,dimension:"ROW"})},Ms=e=>{const t=e.model.getters.getActiveCols();let i,o;if(t.size)i=Math.min(...t),o=t.size;else{const t=e.model.getters.getSelectedZones()[0];i=t.left,o=t.right-t.left+1}e.model.dispatch("ADD_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),position:"before",dimension:"COL",base:i,quantity:o})},Os=e=>{const t=e.model.getters.getActiveCols();let i,o;if(t.size)i=Math.max(...t),o=t.size;else{const t=e.model.getters.getSelectedZones()[0];i=t.right,o=t.right-t.left+1}e.model.dispatch("ADD_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),position:"after",dimension:"COL",base:i,quantity:o})};const Ns=e=>{e.openSidePanel("ConditionalFormatting",{selection:e.model.getters.getSelectedZones()})},_s=e=>{let{col:t,row:i}=e.model.getters.getActivePosition();e.model.dispatch("OPEN_CELL_POPOVER",{col:t,row:i,popoverType:"LinkEditor"})},Fs=e=>{const t=e.model.getters.getActiveSheetId(),i=e.model.getters.getSelectedZones();return e.model.getters.doesZonesContainFilter(t,i)},Ds=e=>{const{anchor:t,zones:i}=e.model.getters.getSelection(),o=e.model.getters.getActiveSheetId();ss(e,o,t.cell,i[0],"ascending")},ks=e=>{const{anchor:t,zones:i}=e.model.getters.getSelection(),o=e.model.getters.getActiveSheetId();ss(e,o,t.cell,i[0],"descending")},Ls=e=>1===e.model.getters.getSelectedZones().length,Ps=new kn;Ps.add("cut",{name:s("Cut"),description:"Ctrl+X",sequence:10,action:gs}).add("copy",{name:s("Copy"),description:"Ctrl+C",sequence:20,isReadonlyAllowed:!0,action:us}).add("paste",{name:s("Paste"),description:"Ctrl+V",sequence:30,action:ps}).add("paste_special",{name:s("Paste special"),sequence:40,separator:!0,isVisible:bs}).addChild("paste_value_only",["paste_special"],{name:s("Paste values only"),sequence:10,action:ms}).addChild("paste_format_only",["paste_special"],{name:s("Paste format only"),sequence:20,action:vs}).add("add_row_before",{name:e=>{const t=cs(e);return 1===t?s("Insert row"):s("Insert %s rows",t.toString())},sequence:70,action:Ts,isVisible:Ls}).add("add_column_before",{name:e=>{const t=ls(e);return 1===t?s("Insert column"):s("Insert %s columns",t.toString())},sequence:90,action:Ms,isVisible:Ls}).add("insert_cell",{name:s("Insert cells"),sequence:100,isVisible:Ls,separator:!0}).addChild("insert_cell_down",["insert_cell"],{name:s("Shift down"),sequence:10,action:ys}).addChild("insert_cell_right",["insert_cell"],{name:s("Shift right"),sequence:20,action:xs}).add("delete_row",{name:Ss,sequence:110,action:Cs,isVisible:Ls}).add("delete_column",{name:Es,sequence:120,action:ws,isVisible:Ls}).add("delete_cell",{name:s("Delete cells"),sequence:130,isVisible:Ls}).addChild("delete_cell_up",["delete_cell"],{name:s("Shift up"),sequence:10,action:Is}).addChild("delete_cell_down",["delete_cell"],{name:s("Shift left"),sequence:20,action:Rs}).add("insert_link",{name:s("Insert link"),separator:!0,sequence:150,action:_s});const Us=new kn;Us.add("cut",{name:s("Cut"),description:"Ctrl+X",sequence:10,action:gs}).add("copy",{name:s("Copy"),description:"Ctrl+C",sequence:20,isReadonlyAllowed:!0,action:us}).add("paste",{name:s("Paste"),description:"Ctrl+V",sequence:30,action:ps}).add("paste_special",{name:s("Paste special"),sequence:40,separator:!0,isVisible:bs}).addChild("paste_value_only",["paste_special"],{name:s("Paste value only"),sequence:10,action:ms}).addChild("paste_format_only",["paste_special"],{name:s("Paste format only"),sequence:20,action:vs}).add("sort_columns",{name:e=>e.model.getters.getActiveCols().size>1?s("Sort columns"):s("Sort column"),sequence:50,isVisible:Ls,separator:!0}).addChild("sort_ascending",["sort_columns"],{name:s("Ascending (A ⟶ Z)"),sequence:10,action:Ds}).addChild("sort_descending",["sort_columns"],{name:s("Descending (Z ⟶ A)"),sequence:20,action:ks}).add("add_column_before",{name:e=>{const t=ls(e);return 1===t?s("Insert column left"):s("Insert %s columns left",t.toString())},sequence:70,action:Ms}).add("add_column_after",{name:e=>{const t=ls(e);return 1===t?s("Insert column right"):s("Insert %s columns right",t.toString())},sequence:80,action:Os}).add("delete_column",{name:Es,sequence:90,action:ws}).add("clear_column",{name:e=>{if(e.model.getters.getSelectedZones().length>1)return s("Clear columns");let t,i;const o=e.model.getters.getActiveCols();if(0!==o.size)t=Math.min(...o),i=Math.max(...o);else{const o=e.model.getters.getSelectedZones()[0];t=o.left,i=o.right}return t===i?s("Clear column %s",Lt(t)):s("Clear columns %s - %s",Lt(t),Lt(i))},sequence:100,action:e=>{const t=e.model.getters.getActiveSheetId(),i=[...e.model.getters.getActiveCols()].map((i=>e.model.getters.getColsZone(t,i,i)));e.model.dispatch("DELETE_CONTENT",{target:i,sheetId:e.model.getters.getActiveSheetId()})}}).add("hide_columns",{name:e=>{const t=e.model.getters.getElementsFromSelection("COL");let i=t[0],o=t[t.length-1];return 1===t.length?s("Hide column %s",Lt(i).toString()):o-i+1===t.length?s("Hide columns %s - %s",Lt(i).toString(),Lt(o).toString()):s("Hide columns")},sequence:85,action:e=>{const t=e.model.getters.getElementsFromSelection("COL");e.model.dispatch("HIDE_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),dimension:"COL",elements:t})},isVisible:e=>{const t=e.model.getters.getActiveSheetId(),i=e.model.getters.getHiddenColsGroups(t).flat();return e.model.getters.getNumberCols(t)>i.length+e.model.getters.getElementsFromSelection("COL").length},separator:!0}).add("unhide_columns",{name:s("Unhide columns"),sequence:86,action:e=>{const t=e.model.getters.getElementsFromSelection("COL");e.model.dispatch("UNHIDE_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),dimension:"COL",elements:t})},isVisible:e=>{const t=e.model.getters.getHiddenColsGroups(e.model.getters.getActiveSheetId()).flat();return e.model.getters.getElementsFromSelection("COL").some((e=>t.includes(e)))},separator:!0}).add("conditional_formatting",{name:s("Conditional formatting"),sequence:110,action:Ns});const Vs=new kn;function zs(e,t,i=(()=>{})){const o=e=>{e.preventDefault(),i(e)},n=t=>{t.preventDefault(),e(t)},s=e=>{e.preventDefault(),t(e),window.removeEventListener("mousedown",o),window.removeEventListener("mouseup",s),window.removeEventListener("dragstart",r),window.removeEventListener("mousemove",n),window.removeEventListener("wheel",n)};function r(e){e.preventDefault()}window.addEventListener("mousedown",o),window.addEventListener("mouseup",s),window.addEventListener("dragstart",r),window.addEventListener("mousemove",n),window.addEventListener("wheel",n,{passive:!1})}function Bs(e,t,i,o=!1){let n,s,r,a,l,c=null;const h=e.model.getters,d=h.getActiveSheetId(),u=Vn();let g,p;const m=i=>{if(n=i,c)return;const{x:r,y:f}=h.getMainViewportCoordinates();let{top:v,left:b,bottom:S,right:C}=h.getActiveMainViewport(),{scrollX:E,scrollY:w}=h.getActiveSheetDOMScrollInfo();const{xSplit:y,ySplit:x}=h.getPaneDivisions(d);let I=!1,R=zt;const T=n.clientX-u.left;if(g=h.getColIndex(T),"vertical"!==o){const t=s.clientX-u.left,i=h.getEdgeScrollCol(T,t,a);if(i.canEdgeScroll){let t;switch(I=!0,R=Math.min(R,i.delay),i.direction){case"reset":g=y,t=y;break;case 1:g=C,t=b+1;break;case-1:for(g=b-1;e.model.getters.isColHidden(d,g);)g--;t=g}E=h.getColDimensions(d,t).start-r}}const A=n.clientY-u.top;if(p=h.getRowIndex(A),"horizontal"!==o){const t=s.clientY-u.top,i=h.getEdgeScrollRow(A,t,l);if(i.canEdgeScroll){let t;switch(I=!0,R=Math.min(R,i.delay),i.direction){case"reset":p=x,t=x;break;case 1:p=S,t=v+i.direction;break;case-1:for(p=v-1;e.model.getters.isRowHidden(d,p);)p--;t=p}w=e.model.getters.getRowDimensions(d,t).start-f}}I||(-1===p&&(p=A<0?0:h.getNumberRows(d)-1),-1===g&&T<0&&(g=T<0?0:h.getNumberCols(d)-1)),t(g,p,n),I&&(e.model.dispatch("SET_VIEWPORT_OFFSET",{offsetX:E,offsetY:w}),c=setTimeout((()=>{c=null,m(n)}),Math.round(R))),s=n};zs(m,(()=>{clearTimeout(c),i()}),(e=>{s=e,r=e,a=r.clientX-u.left,l=r.clientY-u.top}))}Vs.add("cut",{name:s("Cut"),sequence:10,description:"Ctrl+X",action:gs}).add("copy",{name:s("Copy"),description:"Ctrl+C",sequence:20,isReadonlyAllowed:!0,action:us}).add("paste",{name:s("Paste"),description:"Ctrl+V",sequence:30,action:ps}).add("paste_special",{name:s("Paste special"),sequence:40,separator:!0,isVisible:bs}).addChild("paste_value_only",["paste_special"],{name:s("Paste value only"),sequence:10,action:ms}).addChild("paste_format_only",["paste_special"],{name:s("Paste format only"),sequence:20,action:vs}).add("add_row_before",{name:e=>{const t=cs(e);return 1===t?s("Insert row above"):s("Insert %s rows above",t.toString())},sequence:50,action:Ts}).add("add_row_after",{name:e=>{const t=cs(e);return 1===t?s("Insert row below"):s("Insert %s rows below",t.toString())},sequence:60,action:As}).add("delete_row",{name:Ss,sequence:70,action:Cs}).add("clear_row",{name:e=>{if(e.model.getters.getSelectedZones().length>1)return s("Clear rows");let t,i;const o=e.model.getters.getActiveRows();if(0!==o.size)t=Math.min(...o),i=Math.max(...o);else{const o=e.model.getters.getSelectedZones()[0];t=o.top,i=o.bottom}return t===i?s("Clear row %s",(t+1).toString()):s("Clear rows %s - %s",(t+1).toString(),(i+1).toString())},sequence:80,action:e=>{const t=e.model.getters.getActiveSheetId(),i=[...e.model.getters.getActiveRows()].map((i=>e.model.getters.getRowsZone(t,i,i)));e.model.dispatch("DELETE_CONTENT",{target:i,sheetId:e.model.getters.getActiveSheetId()})}}).add("hide_rows",{name:e=>{const t=e.model.getters.getElementsFromSelection("ROW");let i=t[0],o=t[t.length-1];return 1===t.length?s("Hide row %s",(i+1).toString()):o-i+1===t.length?s("Hide rows %s - %s",(i+1).toString(),(o+1).toString()):s("Hide rows")},sequence:85,action:e=>{const t=e.model.getters.getElementsFromSelection("ROW");e.model.dispatch("HIDE_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),dimension:"ROW",elements:t})},isVisible:e=>{const t=e.model.getters.getActiveSheetId(),i=e.model.getters.getHiddenRowsGroups(t).flat();return e.model.getters.getNumberRows(t)>i.length+e.model.getters.getElementsFromSelection("ROW").length},separator:!0}).add("unhide_rows",{name:s("Unhide rows"),sequence:86,action:e=>{const t=e.model.getters.getElementsFromSelection("ROW");e.model.dispatch("UNHIDE_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),dimension:"ROW",elements:t})},isVisible:e=>{const t=e.model.getters.getHiddenRowsGroups(e.model.getters.getActiveSheetId()).flat();return e.model.getters.getElementsFromSelection("ROW").some((e=>t.includes(e)))},separator:!0}).add("conditional_formatting",{name:s("Conditional formatting"),sequence:90,action:Ns}),ro`
|
|
118
|
-
.o-autofill {
|
|
119
|
-
position: absolute;
|
|
120
|
-
height: ${8}px;
|
|
121
|
-
width: ${8}px;
|
|
122
|
-
border: 1px solid white;
|
|
123
|
-
box-sizing: border-box !important;
|
|
124
|
-
background-color: #1a73e8;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
.o-autofill-handler {
|
|
128
|
-
position: absolute;
|
|
129
|
-
height: ${8}px;
|
|
130
|
-
width: ${8}px;
|
|
131
|
-
&:hover {
|
|
132
|
-
cursor: crosshair;
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
.o-autofill-nextvalue {
|
|
137
|
-
position: absolute;
|
|
138
|
-
background-color: #ffffff;
|
|
139
|
-
border: 1px solid black;
|
|
140
|
-
padding: 5px;
|
|
141
|
-
font-size: 12px;
|
|
142
|
-
pointer-events: none;
|
|
143
|
-
white-space: nowrap;
|
|
144
|
-
}
|
|
145
|
-
`;class Hs extends t.Component{constructor(){super(...arguments),this.state=t.useState({position:{left:0,top:0},handler:!1})}get style(){const{left:e,top:t}=this.props.position;return ho({top:`${t}px`,left:`${e}px`,visibility:this.props.isVisible?"visible":"hidden"})}get handlerStyle(){const{left:e,top:t}=this.state.handler?this.state.position:this.props.position;return ho({top:`${t}px`,left:`${e}px`})}get styleNextValue(){const{left:e,top:t}=this.state.position;return ho({top:`${t+5}px`,left:`${e+15}px`})}getTooltip(){const e=this.env.model.getters.getAutofillTooltip();return e&&!e.component&&(e.component=$s),e}onMouseDown(e){let t,i;this.state.handler=!0;const o=e.clientX-this.props.position.left,n=e.clientY-this.props.position.top;Bs(this.env,((e,s,r)=>{if(this.state.position={left:r.clientX-o,top:r.clientY-n},t!==e||i!==s){const o=this.env.model.getters.getActiveSheetId(),n=this.env.model.getters.getNumberCols(o),r=this.env.model.getters.getNumberRows(o);t=-1===e?t:De(e,0,n),i=-1===s?i:De(s,0,r),void 0!==t&&void 0!==i&&this.env.model.dispatch("AUTOFILL_SELECT",{col:t,row:i})}}),(()=>{this.state.handler=!1,this.state.position={...this.props.position},this.env.model.dispatch("AUTOFILL")}))}onDblClick(){this.env.model.dispatch("AUTOFILL_AUTO")}}Hs.template="o-spreadsheet-Autofill",Hs.props={position:Object,isVisible:Boolean};class $s extends t.Component{}$s.template=t.xml`
|
|
146
|
-
<div t-esc="props.content"/>
|
|
147
|
-
`,$s.props={content:String},ro`
|
|
148
|
-
.o-client-tag {
|
|
149
|
-
position: absolute;
|
|
150
|
-
border-top-left-radius: 4px;
|
|
151
|
-
border-top-right-radius: 4px;
|
|
152
|
-
font-size: ${G};
|
|
153
|
-
color: white;
|
|
154
|
-
opacity: 0;
|
|
155
|
-
pointer-events: none;
|
|
156
|
-
}
|
|
157
|
-
`;class Ws extends t.Component{get tagStyle(){const{col:e,row:t,color:i}=this.props,{height:o}=this.env.model.getters.getSheetViewDimensionWithHeaders(),{x:n,y:s}=this.env.model.getters.getVisibleRect({left:e,top:t,right:e,bottom:t});return ho({bottom:o-s+15+"px",left:n-1+"px",border:`1px solid ${i}`,"background-color":i,opacity:this.props.active?"opacity:1 !important":void 0})}}Ws.template="o-spreadsheet-ClientTag",Ws.props={active:Boolean,name:String,color:String,col:Number,row:Number};const Gs=/(.*?)\((.*?)\)(.*)/,qs=["ANY","BOOLEAN","DATE","NUMBER","STRING","RANGE","RANGE<BOOLEAN>","RANGE<DATE>","RANGE<NUMBER>","RANGE<STRING>","META"];function Zs(e,t=""){return function(e){let t,i=e.match(Gs),o=i[1].trim(),n=[],s=!1,r=!1,a=!1;for(let e of i[2].split(",")){const i=e.trim().toUpperCase();let o=qs.find((e=>i===e));o?n.push(o):"RANGE<ANY>"===i?n.push("RANGE"):"OPTIONAL"===i?s=!0:"REPEATING"===i?r=!0:"LAZY"===i?a=!0:i.startsWith("DEFAULT=")&&(t=e.trim().slice(8))}let l=i[3].trim();const c={name:o,description:l,type:n};s&&(c.optional=!0);r&&(c.repeating=!0);a&&(c.lazy=!0);void 0!==t&&(c.default=!0,c.defaultValue=t);return c}(`${e} ${t}`)}function js(e){let t=0,i=0,o=0;for(let n of e.args)t++,n.optional||n.repeating||n.default||i++,n.repeating&&o++;const n=e;return n.minArgRequired=i,n.maxArgPossible=o?1/0:t,n.nbrArgRepeating=o,n.getArgToFocus=function(e,t){if(!t)return e=>e;if(1===t)return t=>Math.min(t,e);const i=e-t;return e=>{if(e<=i)return e;return i+((e-i)%t||t)}}(t,o),n.hidden=e.hidden||!1,n}const Xs=["number","string","boolean","undefined"];function Ys(e,t){if(!e())throw new Error(t)}const Ks=e=>s("The function [[FUNCTION_NAME]] expects a number value, but '%s' is a string, and cannot be coerced to a number.",e);function Qs(e){switch(typeof e){case"number":return e;case"boolean":return e?1:0;case"string":if(Yt(e)||""===e)return Qt(e);const t=Se(e);if(t)return t.value;throw new Error(Ks(e));default:return 0}}function Js(e){if(""===e)throw new Error(Ks(e));return Qs(e)}function er(e){switch(typeof e){case"string":return e;case"number":return e.toString();case"boolean":return e?"TRUE":"FALSE";default:return""}}function tr(e){return"string"==typeof e?e.toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g,""):e}const ir=e=>s("The function [[FUNCTION_NAME]] expects a boolean value, but '%s' is a text, and cannot be coerced to a number.",e);function or(e){switch(typeof e){case"boolean":return e;case"string":if(e){let t=e.toUpperCase();if("TRUE"===t)return!0;if("FALSE"===t)return!1;throw new Error(ir(e))}return!1;case"number":return!!e;default:return!1}}function nr(e){return Ee(Qs(e))}function sr(e,t,i){for(let o of e)if(Array.isArray(o)){const e=o.length,i=o[0].length;for(let n=0;n<i;n++)for(let i=0;i<e;i++)t(o[i][n])}else i(o)}function rr(e,t){sr(e,t,t)}function ar(e,t){sr(e,(e=>{"number"==typeof e&&t(e)}),(e=>{t(Js(e))}))}function lr(e,t,i,o){let n=o;for(let o of e)if(Array.isArray(o)){const e=o.length,i=o[0].length;for(let s=0;s<i;s++)for(let i=0;i<e;i++)n=t(n,o[i][s])}else n=i(n,o);return n}function cr(e,t,i){return lr(e,t,t,i)}function hr(e,t,i){return lr(e,((e,i)=>"number"==typeof i?t(e,i):e),((e,i)=>t(e,Js(i))),i)}function dr(e,t,i){return lr(e,((e,i)=>null!=i?t(e,"number"==typeof i?i:"boolean"==typeof i?Qs(i):0):e),((e,i)=>t(e,Qs(i))),i)}function ur(e,t){return function(e,t,i){for(let o of e)if(Array.isArray(o)){const e=o.length,i=o[0].length;for(let n=0;n<i;n++)for(let i=0;i<e;i++)if(!t(o[i][n]))return}else if(!i(o))return}(e,(e=>"boolean"==typeof e?t(e):"number"!=typeof e||t(!!e)),(e=>null==e||t(function(e){if(""===e)throw new Error(ir(e));return or(e)}(e))))}function gr(e,t){let i,o,n=e.substring(0,2);"<="===n||">="===n||"<>"===n?(i=n,o=e.substring(2)):(n=e.substring(0,1),"<"===n||">"===n||"="===n?(i=n,o=e.substring(1)):(i="=",o=e)),Yt(o)?o=Qs(o):"TRUE"!==o&&"FALSE"!==o||(o=or(o));const s={operator:i,operand:o};return"string"==typeof o&&(t&&(o+="*"),s.regexp=function(e){let t="",i="";for(let o of e)"?"===o&&"~"!==i?t+=".":"*"===o&&"~"!==i?t+=".*":("*"!==o&&"?"!==o||(t=t.slice(0,-1)),["^",".","[","]","$","(",")","*","+","?","|","{","}","\\"].includes(o)&&(t+="\\"),t+=o),i=o;return new RegExp("^"+t+"$","i")}(o)),s}function pr(e,t){const{operator:i,operand:o}=t;if(void 0===e||void 0===o)return!1;if("number"==typeof o&&"="===i)return er(e)===er(o);if("<>"===i||"="===i){let n;return n=typeof e==typeof o&&("string"==typeof e&&t.regexp?t.regexp.test(e):e===o),"="===i?n:!n}if(typeof e==typeof o)switch(i){case"<":return e<o;case">":return e>o;case"<=":return e<=o;case">=":return e>=o}return!1}function mr(e,t,i=!1){const o=e.length;if(o%2==1)throw new Error(s("Function [[FUNCTION_NAME]] expects criteria_range and criterion to be in pairs."));const n=e[0].length,r=e[0][0].length;let a=[];for(let t=0;t<o-1;t+=2){const o=e[t];if(!Array.isArray(o)||o.length!==n||o[0].length!==r)throw new Error(s("Function [[FUNCTION_NAME]] expects criteria_range to have the same dimension"));const l=er(e[t+1]);a.push(gr(l,i))}for(let i=0;i<n;i++)for(let n=0;n<r;n++){let s=!0;for(let t=0;t<o-1;t+=2){if(s=pr(e[t][i][n],a[t/2]),!s)break}s&&t(i,n)}}function fr(e,t){return tr(e[0][t])}function vr(e,t){return tr(e[t][0])}function br(e,t,i,o,n,s){if(null==t)return-1;const r=typeof t;let a,l,c,h,d,u,g=0,p=n-1;for(;p-g>=0;){for(c=Math.floor((g+p)/2),h=c,d=s(e,h),u=typeof d;g<h&&r!==u;)h--,d=s(e,h),u=typeof d;u===r&&void 0!==d?("strict"===i&&d===t?(a=d,l=h):"nextSmaller"===i&&d<=t?(void 0===a||a<d||a===d&&"asc"===o&&l<h||a===d&&"desc"===o&&l>h)&&(a=d,l=h):"nextGreater"===i&&d>=t&&(void 0===a||a>d||a===d&&"asc"===o&&l<h||a===d&&"desc"===o&&l>h)&&(a=d,l=h),"asc"===o&&d>t||"desc"===o&&d<=t?p=h-1:g=c+1):g=c+1}return void 0!==l?l:-1}function Sr(e,t,i,o,n,s=!1){if(null==t)return-1;const r=s?(e,t)=>n(e,o-t-1):n;let a,l=-1;for(let n=0;n<o;n++){const c=r(e,n);if(c===t)return s?o-n-1:n;"nextSmaller"===i?(!a&&Cr(t,c)>=0||Cr(t,c)>=0&&Cr(c,a)>0)&&(a=c,l=n):"nextGreater"===i&&(!a&&Cr(t,c)<=0||Cr(t,c)<=0&&Cr(c,a)<0)&&(a=c,l=n)}return s?o-l-1:l}function Cr(e,t){let i=Xs.indexOf(typeof e)-Xs.indexOf(typeof t);return 0===i&&("string"==typeof e&&"string"==typeof t?i=e.localeCompare(t):"number"==typeof e&&"number"==typeof t?i=e-t:"boolean"==typeof e&&"boolean"==typeof t&&(i=Number(e)-Number(t))),i}const Er={description:s("Apply a large number format"),args:[Zs("value (number)",s("The number.")),Zs("unit (string, optional)",s("The formatting unit. Use 'k', 'm', or 'b' to force the unit"))],returns:["NUMBER"],computeFormat:(e,t)=>{const i=Math.abs(Qs(e.value)),o=e.format;if(void 0!==t){switch(null==t?void 0:t.value){case"k":return bi(o,1e3,"k");case"m":return bi(o,1e6,"m");case"b":return bi(o,1e9,"b");default:throw new Error(s("The formatting unit should be 'k', 'm' or 'b'."))}}return i<1e5?bi(o,0,""):i<1e8?bi(o,1e3,"k"):i<1e11?bi(o,1e6,"m"):bi(o,1e9,"b")},compute:function(e){return Qs(e)}};var wr=Object.freeze({__proto__:null,FORMAT_LARGE_NUMBER:Er});const yr={description:s("Absolute value of a number."),args:[Zs("value (number)",s("The number of which to return the absolute value."))],returns:["NUMBER"],compute:function(e){return Math.abs(Qs(e))},isExported:!0},xr={description:s("Inverse cosine of a value, in radians."),args:[Zs("value (number)",s("The value for which to calculate the inverse cosine. Must be between -1 and 1, inclusive."))],returns:["NUMBER"],compute:function(e){const t=Qs(e);return Ys((()=>Math.abs(t)<=1),s("The value (%s) must be between -1 and 1 inclusive.",t.toString())),Math.acos(t)},isExported:!0},Ir={description:s("Inverse hyperbolic cosine of a number."),args:[Zs("value (number)",s("The value for which to calculate the inverse hyperbolic cosine. Must be greater than or equal to 1."))],returns:["NUMBER"],compute:function(e){const t=Qs(e);return Ys((()=>t>=1),s("The value (%s) must be greater than or equal to 1.",t.toString())),Math.acosh(t)},isExported:!0},Rr={description:s("Inverse cotangent of a value."),args:[Zs("value (number)",s("The value for which to calculate the inverse cotangent."))],returns:["NUMBER"],compute:function(e){const t=Qs(e);return(Math.sign(t)||1)*Math.PI/2-Math.atan(t)},isExported:!0},Tr={description:s("Inverse hyperbolic cotangent of a value."),args:[Zs("value (number)",s("The value for which to calculate the inverse hyperbolic cotangent. Must not be between -1 and 1, inclusive."))],returns:["NUMBER"],compute:function(e){const t=Qs(e);return Ys((()=>Math.abs(t)>1),s("The value (%s) cannot be between -1 and 1 inclusive.",t.toString())),Math.log((t+1)/(t-1))/2},isExported:!0},Ar={description:s("Inverse sine of a value, in radians."),args:[Zs("value (number)",s("The value for which to calculate the inverse sine. Must be between -1 and 1, inclusive."))],returns:["NUMBER"],compute:function(e){const t=Qs(e);return Ys((()=>Math.abs(t)<=1),s("The value (%s) must be between -1 and 1 inclusive.",t.toString())),Math.asin(t)},isExported:!0},Mr={description:s("Inverse hyperbolic sine of a number."),args:[Zs("value (number)",s("The value for which to calculate the inverse hyperbolic sine."))],returns:["NUMBER"],compute:function(e){return Math.asinh(Qs(e))},isExported:!0},Or={description:s("Inverse tangent of a value, in radians."),args:[Zs("value (number)",s("The value for which to calculate the inverse tangent."))],returns:["NUMBER"],compute:function(e){return Math.atan(Qs(e))},isExported:!0},Nr={description:s("Angle from the X axis to a point (x,y), in radians."),args:[Zs("x (number)",s("The x coordinate of the endpoint of the line segment for which to calculate the angle from the x-axis.")),Zs("y (number)",s("The y coordinate of the endpoint of the line segment for which to calculate the angle from the x-axis."))],returns:["NUMBER"],compute:function(e,t){const i=Qs(e),o=Qs(t);return Ys((()=>0!==i||0!==o),s("Function [[FUNCTION_NAME]] caused a divide by zero error.")),Math.atan2(o,i)},isExported:!0},_r={description:s("Inverse hyperbolic tangent of a number."),args:[Zs("value (number)",s("The value for which to calculate the inverse hyperbolic tangent. Must be between -1 and 1, exclusive."))],returns:["NUMBER"],compute:function(e){const t=Qs(e);return Ys((()=>Math.abs(t)<1),s("The value (%s) must be between -1 and 1 exclusive.",t.toString())),Math.atanh(t)},isExported:!0},Fr={description:s("Rounds number up to nearest multiple of factor."),args:[Zs("value (number)",s("The value to round up to the nearest integer multiple of factor.")),Zs("factor (number, default=1)",s("The number to whose multiples value will be rounded."))],returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t=1){const i=Qs(e),o=Qs(t);return Ys((()=>o>=0||i<=0),s("The factor (%s) must be positive when the value (%s) is positive.",o.toString(),i.toString())),o?Math.ceil(i/o)*o:0},isExported:!0},Dr={description:s("Rounds number up to nearest multiple of factor."),args:[Zs("number (number)",s("The value to round up to the nearest integer multiple of significance.")),Zs("significance (number, default=1)",s("The number to whose multiples number will be rounded. The sign of significance will be ignored.")),Zs("mode (number, default=0)",s("If number is negative, specifies the rounding direction. If 0 or blank, it is rounded towards zero. Otherwise, it is rounded away from zero."))],returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t=1,i=0){let o=Qs(t);if(0===o)return 0;const n=Qs(e);if(o=Math.abs(o),n>=0)return Math.ceil(n/o)*o;return 0===Qs(i)?-Math.floor(Math.abs(n)/o)*o:-Math.ceil(Math.abs(n)/o)*o},isExported:!0},kr={description:s("Rounds number up to nearest multiple of factor."),args:[Zs("number (number)",s("The value to round up to the nearest integer multiple of significance.")),Zs("significance (number, default=1)",s("The number to whose multiples number will be rounded."))],returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t){return Dr.compute(e,t,0)},isExported:!0},Lr={description:s("Cosine of an angle provided in radians."),args:[Zs("angle (number)",s("The angle to find the cosine of, in radians."))],returns:["NUMBER"],compute:function(e){return Math.cos(Qs(e))},isExported:!0},Pr={description:s("Hyperbolic cosine of any real number."),args:[Zs("value (number)",s("Any real value to calculate the hyperbolic cosine of."))],returns:["NUMBER"],compute:function(e){return Math.cosh(Qs(e))},isExported:!0},Ur={description:s("Cotangent of an angle provided in radians."),args:[Zs("angle (number)",s("The angle to find the cotangent of, in radians."))],returns:["NUMBER"],compute:function(e){const t=Qs(e);return Ys((()=>0!==t),s("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),1/Math.tan(t)},isExported:!0},Vr={description:s("Hyperbolic cotangent of any real number."),args:[Zs("value (number)",s("Any real value to calculate the hyperbolic cotangent of."))],returns:["NUMBER"],compute:function(e){const t=Qs(e);return Ys((()=>0!==t),s("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),1/Math.tanh(t)},isExported:!0},zr={description:s("Number of empty values."),args:[Zs("value1 (any, range)",s("The first value or range in which to count the number of blanks.")),Zs("value2 (any, range, repeating)",s("Additional values or ranges in which to count the number of blanks."))],returns:["NUMBER"],compute:function(...e){return cr(e,((e,t)=>null==t||""===t?e+1:e),0)},isExported:!0},Br={description:s("A conditional count across a range."),args:[Zs("range (range)",s("The range that is tested against criterion.")),Zs("criterion (string)",s("The pattern or test to apply to range."))],returns:["NUMBER"],compute:function(...e){let t=0;return mr(e,((e,i)=>{t+=1})),t},isExported:!0},Hr={description:s("Count values depending on multiple criteria."),args:[Zs("criteria_range1 (range)",s("The range to check against criterion1.")),Zs("criterion1 (string)",s("The pattern or test to apply to criteria_range1.")),Zs("criteria_range2 (any, range, repeating)",s("Additional ranges over which to evaluate the additional criteria. The filtered set will be the intersection of the sets produced by each criterion-range pair.")),Zs("criterion2 (string, repeating)",s("Additional criteria to check."))],returns:["NUMBER"],compute:function(...e){let t=0;return mr(e,((e,i)=>{t+=1})),t},isExported:!0};function $r(e){switch(e){case void 0:case"":case null:return!1;default:return!0}}const Wr={description:s("Counts number of unique values in a range."),args:[Zs("value1 (any, range)",s("The first value or range to consider for uniqueness.")),Zs("value2 (any, range, repeating)",s("Additional values or ranges to consider for uniqueness."))],returns:["NUMBER"],compute:function(...e){return cr(e,((e,t)=>$r(t)?e.add(t):e),new Set).size}},Gr={description:s("Counts number of unique values in a range, filtered by a set of criteria."),args:[Zs("range (range)",s("The range of cells from which the number of unique values will be counted.")),Zs("criteria_range1 (range)",s("The range of cells over which to evaluate criterion1.")),Zs("criterion1 (string)",s("The pattern or test to apply to criteria_range1, such that each cell that evaluates to TRUE will be included in the filtered set.")),Zs("criteria_range2 (any, range, repeating)",s("Additional ranges over which to evaluate the additional criteria. The filtered set will be the intersection of the sets produced by each criterion-range pair.")),Zs("criterion2 (string, repeating)",s("The pattern or test to apply to criteria_range2."))],returns:["NUMBER"],compute:function(e,...t){let i=new Set;return mr(t,((t,o)=>{const n=e[t][o];$r(n)&&i.add(n)})),i.size}},qr={description:s("Cosecant of an angle provided in radians."),args:[Zs("angle (number)",s("The angle to find the cosecant of, in radians."))],returns:["NUMBER"],compute:function(e){const t=Qs(e);return Ys((()=>0!==t),s("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),1/Math.sin(t)},isExported:!0},Zr={description:s("Hyperbolic cosecant of any real number."),args:[Zs("value (number)",s("Any real value to calculate the hyperbolic cosecant of."))],returns:["NUMBER"],compute:function(e){const t=Qs(e);return Ys((()=>0!==t),s("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),1/Math.sinh(t)},isExported:!0},jr={description:s("Converts from another base to decimal."),args:[Zs("value (string)",s("The number to convert.")),Zs(",base (number)",s("The base to convert the value from."))],returns:["NUMBER"],compute:function(e,t){let i=Qs(t);i=Math.floor(i),Ys((()=>2<=i&&i<=36),s("The base (%s) must be between 2 and 36 inclusive.",i.toString()));const o=er(e);if(""===o)return 0;Ys((()=>!!o.match(/^-?[a-z0-9]+$/i)),s("The value (%s) must be a valid base %s representation.",o,i.toString()));const n=parseInt(o,i);return Ys((()=>!isNaN(n)),s("The value (%s) must be a valid base %s representation.",o,i.toString())),n},isExported:!0},Xr={description:s("Converts an angle value in radians to degrees."),args:[Zs("angle (number)",s("The angle to convert from radians to degrees."))],returns:["NUMBER"],compute:function(e){return 180*Qs(e)/Math.PI},isExported:!0},Yr={description:s("Euler's number, e (~2.718) raised to a power."),args:[Zs("value (number)",s("The exponent to raise e."))],returns:["NUMBER"],compute:function(e){return Math.exp(Qs(e))},isExported:!0},Kr={description:s("Rounds number down to nearest multiple of factor."),args:[Zs("value (number)",s("The value to round down to the nearest integer multiple of factor.")),Zs("factor (number, default=1)",s("The number to whose multiples value will be rounded."))],returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t=1){const i=Qs(e),o=Qs(t);return Ys((()=>o>=0||i<=0),s("The factor (%s) must be positive when the value (%s) is positive.",o.toString(),i.toString())),o?Math.floor(i/o)*o:0},isExported:!0},Qr={description:s("Rounds number down to nearest multiple of factor."),args:[Zs("number (number)",s("The value to round down to the nearest integer multiple of significance.")),Zs("significance (number, default=1)",s("The number to whose multiples number will be rounded. The sign of significance will be ignored.")),Zs("mode (number, default=0)",s("If number is negative, specifies the rounding direction. If 0 or blank, it is rounded away from zero. Otherwise, it is rounded towards zero."))],returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t=1,i=0){let o=Qs(t);if(0===o)return 0;const n=Qs(e);if(o=Math.abs(o),n>=0)return Math.floor(n/o)*o;return 0===Qs(i)?-Math.ceil(Math.abs(n)/o)*o:-Math.floor(Math.abs(n)/o)*o},isExported:!0},Jr={description:s("Rounds number down to nearest multiple of factor."),args:[Zs("number (number)",s("The value to round down to the nearest integer multiple of significance.")),Zs("significance (number, default=1)",s("The number to whose multiples number will be rounded."))],returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t=1){return Qr.compute(e,t,0)},isExported:!0},ea={description:s("Whether the provided value is even."),args:[Zs("value (number)",s("The value to be verified as even."))],returns:["BOOLEAN"],compute:function(e){const t=Js(e);return!(1&Math.floor(Math.abs(t)))},isExported:!0},ta={description:s("Rounds number up to nearest multiple of factor."),args:[Zs("number (number)",s("The value to round up to the nearest integer multiple of significance.")),Zs("significance (number, default=1)",s("The number to whose multiples number will be rounded."))],returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t=1){return Dr.compute(e,t,0)},isExported:!0},ia={description:s("Whether the provided value is even."),args:[Zs("value (number)",s("The value to be verified as even."))],returns:["BOOLEAN"],compute:function(e){const t=Js(e);return!!(1&Math.floor(Math.abs(t)))},isExported:!0},oa={description:s("The logarithm of a number, base e (euler's number)."),args:[Zs("value (number)",s("The value for which to calculate the logarithm, base e."))],returns:["NUMBER"],compute:function(e){const t=Qs(e);return Ys((()=>t>0),s("The value (%s) must be strictly positive.",t.toString())),Math.log(t)},isExported:!0},na={description:s("Modulo (remainder) operator."),args:[Zs("dividend (number)",s("The number to be divided to find the remainder.")),Zs("divisor (number)",s("The number to divide by."))],returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t){const i=Qs(t);Ys((()=>0!==i),s("The divisor must be different from 0."));const o=Qs(e)%i;return o>0&&i<0||o<0&&i>0?o+i:o},isExported:!0},sa={description:s("Rounds a number up to the nearest odd integer."),args:[Zs("value (number)",s("The value to round to the next greatest odd number."))],returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e){const t=Qs(e);let i=Math.ceil(Math.abs(t));return i=1&i?i:i+1,t<0?-i:i},isExported:!0},ra={description:s("The number pi."),args:[],returns:["NUMBER"],compute:function(){return Math.PI},isExported:!0},aa={description:s("A number raised to a power."),args:[Zs("base (number)",s("The number to raise to the exponent power.")),Zs("exponent (number)",s("The exponent to raise base to."))],returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t){const i=Qs(e),o=Qs(t);return Ys((()=>i>=0||Number.isInteger(o)),s("The exponent (%s) must be an integer when the base is negative.",o.toString())),Math.pow(i,o)},isExported:!0},la={description:s("Result of multiplying a series of numbers together."),args:[Zs("factor1 (number, range<number>)",s("The first number or range to calculate for the product.")),Zs("factor2 (number, range<number>, repeating)",s("More numbers or ranges to calculate for the product."))],returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(...e){let t=0,i=1;for(let o of e)if(Array.isArray(o))for(let e of o)for(let o of e)"number"==typeof o&&(i*=o,t+=1);else null!=o&&(i*=Js(o),t+=1);return 0===t?0:i},isExported:!0},ca={description:s("A random number between 0 inclusive and 1 exclusive."),args:[],returns:["NUMBER"],compute:function(){return Math.random()},isExported:!0},ha={description:s("Random integer between two values, inclusive."),args:[Zs("low (number)",s("The low end of the random range.")),Zs("high (number)",s("The high end of the random range."))],returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t){let i=Qs(e);Number.isInteger(i)||(i=Math.ceil(i));let o=Qs(t);return Number.isInteger(o)||(o=Math.floor(o)),Ys((()=>i<=o),s("The high (%s) must be greater than or equal to the low (%s).",o.toString(),i.toString())),i+Math.ceil((o-i+1)*Math.random())-1},isExported:!0},da={description:s("Rounds a number according to standard rules."),args:[Zs("value (number)",s("The value to round to places number of places.")),Zs("places (number, default=0)",s("The number of decimal places to which to round."))],returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t=0){const i=Qs(e);let o=Qs(t);const n=Math.abs(i);let s;return 0===o?s=Math.round(n):(Number.isInteger(o)||(o=Math.trunc(o)),s=Math.round(n*Math.pow(10,o))/Math.pow(10,o)),i>=0?s:-s},isExported:!0},ua={description:s("Rounds down a number."),args:[Zs("value (number)",s("The value to round to places number of places, always rounding down.")),Zs("places (number, default=0)",s("The number of decimal places to which to round."))],returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t=0){const i=Qs(e);let o=Qs(t);const n=Math.abs(i);let s;return 0===o?s=Math.floor(n):(Number.isInteger(o)||(o=Math.trunc(o)),s=Math.floor(n*Math.pow(10,o))/Math.pow(10,o)),i>=0?s:-s},isExported:!0},ga={description:s("Rounds up a number."),args:[Zs("value (number)",s("The value to round to places number of places, always rounding up.")),Zs("places (number, default=0)",s("The number of decimal places to which to round."))],returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t=0){const i=Qs(e);let o=Qs(t);const n=Math.abs(i);let s;return 0===o?s=Math.ceil(n):(Number.isInteger(o)||(o=Math.trunc(o)),s=Math.ceil(n*Math.pow(10,o))/Math.pow(10,o)),i>=0?s:-s},isExported:!0},pa={description:s("Secant of an angle provided in radians."),args:[Zs("angle (number)",s("The angle to find the secant of, in radians."))],returns:["NUMBER"],compute:function(e){return 1/Math.cos(Qs(e))},isExported:!0},ma={description:s("Hyperbolic secant of any real number."),args:[Zs("value (number)",s("Any real value to calculate the hyperbolic secant of."))],returns:["NUMBER"],compute:function(e){return 1/Math.cosh(Qs(e))},isExported:!0},fa={description:s("Sine of an angle provided in radians."),args:[Zs("angle (number)",s("The angle to find the sine of, in radians."))],returns:["NUMBER"],compute:function(e){return Math.sin(Qs(e))},isExported:!0},va={description:s("Hyperbolic sine of any real number."),args:[Zs("value (number)",s("Any real value to calculate the hyperbolic sine of."))],returns:["NUMBER"],compute:function(e){return Math.sinh(Qs(e))},isExported:!0},ba={description:s("Positive square root of a positive number."),args:[Zs("value (number)",s("The number for which to calculate the positive square root."))],returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e){const t=Qs(e);return Ys((()=>t>=0),s("The value (%s) must be positive or null.",t.toString())),Math.sqrt(t)},isExported:!0},Sa={description:s("Sum of a series of numbers and/or cells."),args:[Zs("value1 (number, range<number>)",s("The first number or range to add together.")),Zs("value2 (number, range<number>, repeating)",s("Additional numbers or ranges to add to value1."))],returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(...e){return hr(e,((e,t)=>e+t),0)},isExported:!0},Ca={description:s("A conditional sum across a range."),args:[Zs("criteria_range (range)",s("The range which is tested against criterion.")),Zs("criterion (string)",s("The pattern or test to apply to range.")),Zs("sum_range (range, default=criteria_range)",s("The range to be summed, if different from range."))],returns:["NUMBER"],compute:function(e,t,i){void 0===i&&(i=e);let o=0;return mr([e,t],((e,t)=>{const n=i[e][t];"number"==typeof n&&(o+=n)})),o},isExported:!0},Ea={description:s("Sums a range depending on multiple criteria."),args:[Zs("sum_range (range)",s("The range to sum.")),Zs("criteria_range1 (range)",s("The range to check against criterion1.")),Zs("criterion1 (string)",s("The pattern or test to apply to criteria_range1.")),Zs("criteria_range2 (any, range, repeating)",s("Additional ranges to check.")),Zs("criterion2 (string, repeating)",s("Additional criteria to check."))],returns:["NUMBER"],compute:function(e,...t){let i=0;return mr(t,((t,o)=>{const n=e[t][o];"number"==typeof n&&(i+=n)})),i},isExported:!0},wa={description:s("Tangent of an angle provided in radians."),args:[Zs("angle (number)",s("The angle to find the tangent of, in radians."))],returns:["NUMBER"],compute:function(e){return Math.tan(Qs(e))},isExported:!0},ya={description:s("Hyperbolic tangent of any real number."),args:[Zs("value (number)",s("Any real value to calculate the hyperbolic tangent of."))],returns:["NUMBER"],compute:function(e){return Math.tanh(Qs(e))},isExported:!0},xa={description:s("Truncates a number."),args:[Zs("value (number)",s("The value to be truncated.")),Zs("places (number, default=0)",s("The number of significant digits to the right of the decimal point to retain."))],returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t=0){const i=Qs(e);let o=Qs(t);return 0===o?Math.trunc(i):(Number.isInteger(o)||(o=Math.trunc(o)),Math.trunc(i*Math.pow(10,o))/Math.pow(10,o))},isExported:!0};var Ia=Object.freeze({__proto__:null,ABS:yr,ACOS:xr,ACOSH:Ir,ACOT:Rr,ACOTH:Tr,ASIN:Ar,ASINH:Mr,ATAN:Or,ATAN2:Nr,ATANH:_r,CEILING:Fr,CEILING_MATH:Dr,CEILING_PRECISE:kr,COS:Lr,COSH:Pr,COT:Ur,COTH:Vr,COUNTBLANK:zr,COUNTIF:Br,COUNTIFS:Hr,COUNTUNIQUE:Wr,COUNTUNIQUEIFS:Gr,CSC:qr,CSCH:Zr,DECIMAL:jr,DEGREES:Xr,EXP:Yr,FLOOR:Kr,FLOOR_MATH:Qr,FLOOR_PRECISE:Jr,ISEVEN:ea,ISO_CEILING:ta,ISODD:ia,LN:oa,MOD:na,ODD:sa,PI:ra,POWER:aa,PRODUCT:la,RAND:ca,RANDBETWEEN:ha,ROUND:da,ROUNDDOWN:ua,ROUNDUP:ga,SEC:pa,SECH:ma,SIN:fa,SINH:va,SQRT:ba,SUM:Sa,SUMIF:Ca,SUMIFS:Ea,TAN:wa,TANH:ya,TRUNC:xa});function Ra(e,t,i){let o=[],n=[],r=0,a=0;rr([e],(e=>{o.push(e),r+=1})),rr([t],(e=>{n.push(e),a+=1})),Ys((()=>r===a),s("[[FUNCTION_NAME]] has mismatched argument count %s vs %s.",r.toString(),a.toString()));let l=0,c=0,h=0;for(let e=0;e<r;e++){const t=o[e],i=n[e];"number"==typeof t&&"number"==typeof i&&(l+=1,c+=t,h+=i)}Ys((()=>0!==l&&(!i||1!==l)),s("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error."));const d=c/l,u=h/l;let g=0;for(let e=0;e<r;e++){const t=o[e],i=n[e];"number"==typeof t&&"number"==typeof i&&(g+=(t-d)*(i-u))}return g/(l-(i?1:0))}function Ta(e,t,i){let o=0,n=0;const r=i?dr:hr;n=r(e,((e,t)=>(o+=1,e+t)),0),Ys((()=>0!==o&&(!t||1!==o)),s("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error."));const a=n/o;return r(e,((e,t)=>e+Math.pow(t-a,2)),0)/(o-(t?1:0))}function Aa(e,t,i){const o=Qs(t);Ys((()=>i?0<=o&&o<=1:0<o&&o<1),s("Function [[FUNCTION_NAME]] parameter 2 value is out of range."));let n,r=[],a=0;return rr(e,(e=>{"number"==typeof e&&(n=br(r,e,"nextSmaller","asc",r.length,((e,t)=>e[t])),r.splice(n+1,0,e),a++)})),Ys((()=>0!==a),s("[[FUNCTION_NAME]] has no valid input data.")),i||Ys((()=>1/(a+1)<=o&&o<=a/(a+1)),s("Function [[FUNCTION_NAME]] parameter 2 value is out of range.")),Jt(r,o,i)}const Ma={description:s("Average magnitude of deviations from mean."),args:[Zs("value1 (number, range<number>)",s("The first value or range of the sample.")),Zs("value2 (number, range<number>, repeating)",s("Additional values or ranges to include in the sample."))],returns:["NUMBER"],compute:function(...e){let t=0;const i=hr(e,((e,i)=>(t+=1,e+i)),0);Ys((()=>0!==t),s("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error."));const o=i/t;return hr(e,((e,t)=>e+Math.abs(o-t)),0)/t},isExported:!0},Oa={description:s("Numerical average value in a dataset, ignoring text."),args:[Zs("value1 (number, range<number>)",s("The first value or range to consider when calculating the average value.")),Zs("value2 (number, range<number>, repeating)",s("Additional values or ranges to consider when calculating the average value."))],returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(...e){let t=0;const i=hr(e,((e,i)=>(t+=1,e+i)),0);return Ys((()=>0!==t),s("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),i/t},isExported:!0},Na=s("[[FUNCTION_NAME]] has mismatched range sizes."),_a=s("[[FUNCTION_NAME]] expects the weight to be positive or equal to 0."),Fa={description:s("Weighted average."),args:[Zs("values (number, range<number>)",s("Values to average.")),Zs("weights (number, range<number>)",s("Weights for each corresponding value.")),Zs("additional_values (number, range<number>, repeating)",s("Additional values to average.")),Zs("additional_weights (number, range<number>, repeating)",s("Additional weights."))],returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(...e){let t,i,o=0,n=0;Ys((()=>e.length%2==0),s("Wrong number of Argument[]. Expected an even number of Argument[]."));for(let r=0;r<e.length-1;r+=2)if(t=e[r],i=e[r+1],Array.isArray(t)){Ys((()=>Array.isArray(i)),Na);let e=t.length,r=t[0].length;Ys((()=>e===i.length&&r===i[0].length),Na);for(let a=0;a<e;a++)for(let e=0;e<r;e++){let r=t[a][e],l=i[a][e],c="number"==typeof r,h="number"==typeof l;Ys((()=>c===h),s("[[FUNCTION_NAME]] expects number values.")),h&&(Ys((()=>l>=0),_a),o+=r*l,n+=l)}}else i=Qs(i),t=Qs(t),Ys((()=>i>=0),_a),o+=t*i,n+=i;return Ys((()=>0!==n),s("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),o/n}},Da={description:s("Numerical average value in a dataset."),args:[Zs("value1 (number, range<number>)",s("The first value or range to consider when calculating the average value.")),Zs("value2 (number, range<number>, repeating)",s("Additional values or ranges to consider when calculating the average value."))],returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(...e){let t=0;const i=dr(e,((e,i)=>(t+=1,e+i)),0);return Ys((()=>0!==t),s("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),i/t},isExported:!0},ka={description:s("Average of values depending on criteria."),args:[Zs("criteria_range (range)",s("The range to check against criterion.")),Zs("criterion (string)",s("The pattern or test to apply to criteria_range.")),Zs("average_range (range, default=criteria_range)",s("The range to average. If not included, criteria_range is used for the average instead."))],returns:["NUMBER"],compute:function(e,t,i){null==i&&(i=e);let o=0,n=0;return mr([e,t],((t,s)=>{const r=(i||e)[t][s];"number"==typeof r&&(o+=1,n+=r)})),Ys((()=>0!==o),s("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),n/o},isExported:!0},La={description:s("Average of values depending on multiple criteria."),args:[Zs("average_range (range)",s("The range to average.")),Zs("criteria_range1 (range)",s("The range to check against criterion1.")),Zs("criterion1 (string)",s("The pattern or test to apply to criteria_range1.")),Zs("criteria_range2 (any, range, repeating)",s("Additional criteria_range and criterion to check.")),Zs("criterion2 (string, repeating)",s("The pattern or test to apply to criteria_range2."))],returns:["NUMBER"],compute:function(e,...t){let i=0,o=0;return mr(t,((t,n)=>{const s=e[t][n];"number"==typeof s&&(i+=1,o+=s)})),Ys((()=>0!==i),s("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),o/i},isExported:!0},Pa={description:s("The number of numeric values in dataset."),args:[Zs("value1 (number, range<number>)",s("The first value or range to consider when counting.")),Zs("value2 (number, range<number>, repeating)",s("Additional values or ranges to consider when counting."))],returns:["NUMBER"],compute:function(...e){let t=0;for(let i of e)if(Array.isArray(i))for(let e of i)for(let i of e)"number"==typeof i&&(t+=1);else("string"!=typeof i||Yt(i)||Se(i))&&(t+=1);return t},isExported:!0},Ua={description:s("The number of values in a dataset."),args:[Zs("value1 (any, range)",s("The first value or range to consider when counting.")),Zs("value2 (any, range, repeating)",s("Additional values or ranges to consider when counting."))],returns:["NUMBER"],compute:function(...e){return cr(e,((e,t)=>null!=t?e+1:e),0)},isExported:!0},Va={description:s("The covariance of a dataset."),args:[Zs("data_y (any, range)",s("The range representing the array or matrix of dependent data.")),Zs("data_x (any, range)",s("The range representing the array or matrix of independent data."))],returns:["NUMBER"],compute:function(e,t){return Ra(e,t,!1)},isExported:!0},za={description:s("The covariance of a dataset."),args:[Zs("data_y (any, range)",s("The range representing the array or matrix of dependent data.")),Zs("data_x (any, range)",s("The range representing the array or matrix of independent data."))],returns:["NUMBER"],compute:function(e,t){return Ra(e,t,!1)},isExported:!0},Ba={description:s("The sample covariance of a dataset."),args:[Zs("data_y (any, range)",s("The range representing the array or matrix of dependent data.")),Zs("data_x (any, range)",s("The range representing the array or matrix of independent data."))],returns:["NUMBER"],compute:function(e,t){return Ra(e,t,!0)},isExported:!0},Ha={description:s("Nth largest element from a data set."),args:[Zs("data (any, range)",s("Array or range containing the dataset to consider.")),Zs("n (number)",s("The rank from largest to smallest of the element to return."))],returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(e,t){const i=Math.trunc(Qs(t));let o,n=[],r=0;rr([e],(e=>{"number"==typeof e&&(o=br(n,e,"nextSmaller","asc",n.length,((e,t)=>e[t])),n.splice(o+1,0,e),r++,r>i&&(n.shift(),r--))}));const a=n.shift();return Ys((()=>void 0!==a),s("[[FUNCTION_NAME]] has no valid input data.")),Ys((()=>r>=i),s("Function [[FUNCTION_NAME]] parameter 2 value (%s) is out of range.",i.toString())),a},isExported:!0},$a={description:s("Maximum value in a numeric dataset."),args:[Zs("value1 (number, range<number>)",s("The first value or range to consider when calculating the maximum value.")),Zs("value2 (number, range<number>, repeating)",s("Additional values or ranges to consider when calculating the maximum value."))],returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(...e){const t=hr(e,((e,t)=>e<t?t:e),-1/0);return t===-1/0?0:t},isExported:!0},Wa={description:s("Maximum numeric value in a dataset."),args:[Zs("value1 (any, range)",s("The first value or range to consider when calculating the maximum value.")),Zs("value2 (any, range, repeating)",s("Additional values or ranges to consider when calculating the maximum value."))],returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(...e){const t=dr(e,((e,t)=>Math.max(t,e)),-1/0);return t===-1/0?0:t},isExported:!0},Ga={description:s("Returns the maximum value in a range of cells, filtered by a set of criteria."),args:[Zs("range (range)",s("The range of cells from which the maximum will be determined.")),Zs("criteria_range1 (range)",s("The range of cells over which to evaluate criterion1.")),Zs("criterion1 (string)",s("The pattern or test to apply to criteria_range1, such that each cell that evaluates to TRUE will be included in the filtered set.")),Zs("criteria_range2 (any, range, repeating)",s("Additional ranges over which to evaluate the additional criteria. The filtered set will be the intersection of the sets produced by each criterion-range pair.")),Zs("criterion2 (string, repeating)",s("The pattern or test to apply to criteria_range2."))],returns:["NUMBER"],compute:function(e,...t){let i=-1/0;return mr(t,((t,o)=>{const n=e[t][o];"number"==typeof n&&(i=i<n?n:i)})),i===-1/0?0:i},isExported:!0},qa={description:s("Median value in a numeric dataset."),args:[Zs("value1 (any, range)",s("The first value or range to consider when calculating the median value.")),Zs("value2 (any, range, repeating)",s("Additional values or ranges to consider when calculating the median value."))],returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(...e){let t=[];return ar(e,(e=>{t.push(e)})),Aa(t,.5,!0)},isExported:!0},Za={description:s("Minimum value in a numeric dataset."),args:[Zs("value1 (number, range<number>)",s("The first value or range to consider when calculating the minimum value.")),Zs("value2 (number, range<number>, repeating)",s("Additional values or ranges to consider when calculating the minimum value."))],returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(...e){const t=hr(e,((e,t)=>t<e?t:e),1/0);return t===1/0?0:t},isExported:!0},ja={description:s("Minimum numeric value in a dataset."),args:[Zs("value1 (number, range<number>)",s("The first value or range to consider when calculating the minimum value.")),Zs("value2 (number, range<number>, repeating)",s("Additional values or ranges to consider when calculating the minimum value."))],returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(...e){const t=dr(e,((e,t)=>Math.min(t,e)),1/0);return t===1/0?0:t},isExported:!0},Xa={description:s("Returns the minimum value in a range of cells, filtered by a set of criteria."),args:[Zs("range (range)",s("The range of cells from which the minimum will be determined.")),Zs("criteria_range1 (range)",s("The range of cells over which to evaluate criterion1.")),Zs("criterion1 (string)",s("The pattern or test to apply to criteria_range1, such that each cell that evaluates to TRUE will be included in the filtered set.")),Zs("criteria_range2 (any, range, repeating)",s("Additional ranges over which to evaluate the additional criteria. The filtered set will be the intersection of the sets produced by each criterion-range pair.")),Zs("criterion2 (string, repeating)",s("The pattern or test to apply to criteria_range2."))],returns:["NUMBER"],compute:function(e,...t){let i=1/0;return mr(t,((t,o)=>{const n=e[t][o];"number"==typeof n&&(i=i>n?n:i)})),i===1/0?0:i},isExported:!0},Ya={description:s("Value at a given percentile of a dataset."),args:[Zs("data (any, range)",s("The array or range containing the dataset to consider.")),Zs("percentile (number)",s("The percentile whose value within data will be calculated and returned."))],returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(e,t){return Qa.compute(e,t)},isExported:!0},Ka={description:s("Value at a given percentile of a dataset exclusive of 0 and 1."),args:[Zs("data (any, range)",s("The array or range containing the dataset to consider.")),Zs("percentile (number)",s("The percentile, exclusive of 0 and 1, whose value within 'data' will be calculated and returned."))],returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(e,t){return Aa([e],t,!1)},isExported:!0},Qa={description:s("Value at a given percentile of a dataset."),args:[Zs("data (any, range)",s("The array or range containing the dataset to consider.")),Zs("percentile (number)",s("The percentile whose value within data will be calculated and returned."))],returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(e,t){return Aa([e],t,!0)},isExported:!0},Ja={description:s("Value nearest to a specific quartile of a dataset."),args:[Zs("data (any, range)",s("The array or range containing the dataset to consider.")),Zs("quartile_number (number)",s("Which quartile value to return."))],returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(e,t){return tl.compute(e,t)},isExported:!0},el={description:s("Value nearest to a specific quartile of a dataset exclusive of 0 and 4."),args:[Zs("data (any, range)",s("The array or range containing the dataset to consider.")),Zs("quartile_number (number)",s("Which quartile value, exclusive of 0 and 4, to return."))],returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(e,t){return Aa([e],.25*Math.trunc(Qs(t)),!1)},isExported:!0},tl={description:s("Value nearest to a specific quartile of a dataset."),args:[Zs("data (any, range)",s("The array or range containing the dataset to consider.")),Zs("quartile_number (number)",s("Which quartile value to return."))],returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(e,t){return Aa([e],.25*Math.trunc(Qs(t)),!0)},isExported:!0},il={description:s("Nth smallest element in a data set."),args:[Zs("data (any, range)",s("The array or range containing the dataset to consider.")),Zs("n (number)",s("The rank from smallest to largest of the element to return."))],returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(e,t){const i=Math.trunc(Qs(t));let o,n=[],r=0;rr([e],(e=>{"number"==typeof e&&(o=br(n,e,"nextSmaller","asc",n.length,((e,t)=>e[t])),n.splice(o+1,0,e),r++,r>i&&(n.pop(),r--))}));const a=n.pop();return Ys((()=>void 0!==a),s("[[FUNCTION_NAME]] has no valid input data.")),Ys((()=>r>=i),s("Function [[FUNCTION_NAME]] parameter 2 value (%s) is out of range.",i.toString())),a},isExported:!0},ol={description:s("Standard deviation."),args:[Zs("value1 (number, range<number>)",s("The first value or range of the sample.")),Zs("value2 (number, range<number>, repeating)",s("Additional values or ranges to include in the sample."))],returns:["NUMBER"],compute:function(...e){return Math.sqrt(cl.compute(...e))},isExported:!0},nl={description:s("Standard deviation of entire population."),args:[Zs("value1 (number, range<number>)",s("The first value or range of the population.")),Zs("value2 (number, range<number>, repeating)",s("Additional values or ranges to include in the population."))],returns:["NUMBER"],compute:function(...e){return Math.sqrt(hl.compute(...e))},isExported:!0},sl={description:s("Standard deviation."),args:[Zs("value1 (number, range<number>)",s("The first value or range of the sample.")),Zs("value2 (number, range<number>, repeating)",s("Additional values or ranges to include in the sample."))],returns:["NUMBER"],compute:function(...e){return Math.sqrt(dl.compute(...e))},isExported:!0},rl={description:s("Standard deviation of sample (text as 0)."),args:[Zs("value1 (number, range<number>)",s("The first value or range of the sample.")),Zs("value2 (number, range<number>, repeating)",s("Additional values or ranges to include in the sample."))],returns:["NUMBER"],compute:function(...e){return Math.sqrt(ul.compute(...e))},isExported:!0},al={description:s("Standard deviation of entire population."),args:[Zs("value1 (number, range<number>)",s("The first value or range of the population.")),Zs("value2 (number, range<number>, repeating)",s("Additional values or ranges to include in the population."))],returns:["NUMBER"],compute:function(...e){return Math.sqrt(gl.compute(...e))},isExported:!0},ll={description:s("Standard deviation of entire population (text as 0)."),args:[Zs("value1 (number, range<number>)",s("The first value or range of the population.")),Zs("value2 (number, range<number>, repeating)",s("Additional values or ranges to include in the population."))],returns:["NUMBER"],compute:function(...e){return Math.sqrt(pl.compute(...e))},isExported:!0},cl={description:s("Variance."),args:[Zs("value1 (number, range<number>)",s("The first value or range of the sample.")),Zs("value2 (number, range<number>, repeating)",s("Additional values or ranges to include in the sample."))],returns:["NUMBER"],compute:function(...e){return Ta(e,!0,!1)},isExported:!0},hl={description:s("Variance of entire population."),args:[Zs("value1 (number, range<number>)",s("The first value or range of the population.")),Zs("value2 (number, range<number>, repeating)",s("Additional values or ranges to include in the population."))],returns:["NUMBER"],compute:function(...e){return Ta(e,!1,!1)},isExported:!0},dl={description:s("Variance."),args:[Zs("value1 (number, range<number>)",s("The first value or range of the sample.")),Zs("value2 (number, range<number>, repeating)",s("Additional values or ranges to include in the sample."))],returns:["NUMBER"],compute:function(...e){return Ta(e,!0,!1)},isExported:!0},ul={description:s("Variance of sample (text as 0)."),args:[Zs("value1 (number, range<number>)",s("The first value or range of the sample.")),Zs("value2 (number, range<number>, repeating)",s("Additional values or ranges to include in the sample."))],returns:["NUMBER"],compute:function(...e){return Ta(e,!0,!0)},isExported:!0},gl={description:s("Variance of entire population."),args:[Zs("value1 (number, range<number>)",s("The first value or range of the population.")),Zs("value2 (number, range<number>, repeating)",s("Additional values or ranges to include in the population."))],returns:["NUMBER"],compute:function(...e){return Ta(e,!1,!1)},isExported:!0},pl={description:s("Variance of entire population (text as 0)."),args:[Zs("value1 (number, range<number>)",s("The first value or range of the population.")),Zs("value2 (number, range<number>, repeating)",s("Additional values or ranges to include in the population."))],returns:["NUMBER"],compute:function(...e){return Ta(e,!1,!0)},isExported:!0};var ml=Object.freeze({__proto__:null,AVEDEV:Ma,AVERAGE:Oa,AVERAGE_WEIGHTED:Fa,AVERAGEA:Da,AVERAGEIF:ka,AVERAGEIFS:La,COUNT:Pa,COUNTA:Ua,COVAR:Va,COVARIANCE_P:za,COVARIANCE_S:Ba,LARGE:Ha,MAX:$a,MAXA:Wa,MAXIFS:Ga,MEDIAN:qa,MIN:Za,MINA:ja,MINIFS:Xa,PERCENTILE:Ya,PERCENTILE_EXC:Ka,PERCENTILE_INC:Qa,QUARTILE:Ja,QUARTILE_EXC:el,QUARTILE_INC:tl,SMALL:il,STDEV:ol,STDEV_P:nl,STDEV_S:sl,STDEVA:rl,STDEVP:al,STDEVPA:ll,VAR:cl,VAR_P:hl,VAR_S:dl,VARA:ul,VARP:gl,VARPA:pl});function fl(e,t,i){var o;const n=new Map,r=e.length;for(let t=r-1;t>=0;t--)n.set(er(e[t][0]).toUpperCase(),t);if("number"!=typeof t&&"string"!=typeof t)throw new Error(s("The field must be a number or a string"));let a;if("number"==typeof t){if(a=Math.trunc(t)-1,a<0||r-1<a)throw new Error(s("The field (%s) must be one of %s or must be a number between 1 and %s inclusive.",t.toString(),r.toString()))}else{const e=er(t).toUpperCase();if(a=null!==(o=n.get(e))&&void 0!==o?o:-1,-1===a)throw new Error(s("The field (%s) must be one of %s.",er(t),[...n.keys()].toString()))}const l=i[0].length;if(l<2)throw new Error(s("The criteria range contains %s row, it must be at least 2 rows.",l.toString()));let c=new Set;const h=e[0].length;for(let t=1;t<l;t++){let o=[],s=!0;for(let r=0;r<i.length;r++){const a=er(i[r][0]).toUpperCase(),l=n.get(a),c=i[r][t];if(void 0!==c){if(void 0===l){s=!1;break}o.push([e[l].slice(1,h)]),o.push(c)}}if(s){if(!(o.length>0)){c=new Set(Array(h-1).keys());break}mr(o,((e,t)=>{c.add(t)}),!0)}}const d=e[a];return[...c].map((e=>d[e+1]))}const vl=[Zs("database (range)",s("The array or range containing the data to consider, structured in such a way that the first row contains the labels for each column's values.")),Zs("field (any)",s("Indicates which column in database contains the values to be extracted and operated on.")),Zs("criteria (range)",s("An array or range containing zero or more criteria to filter the database values by before operating."))],bl={description:s("Average of a set of values from a table-like range."),args:vl,returns:["NUMBER"],compute:function(e,t,i){const o=fl(e,t,i);return Oa.compute([o])},isExported:!0},Sl={description:s("Counts values from a table-like range."),args:vl,returns:["NUMBER"],compute:function(e,t,i){const o=fl(e,t,i);return Pa.compute([o])},isExported:!0},Cl={description:s("Counts values and text from a table-like range."),args:vl,returns:["NUMBER"],compute:function(e,t,i){const o=fl(e,t,i);return Ua.compute([o])},isExported:!0},El={description:s("Single value from a table-like range."),args:vl,returns:["NUMBER"],compute:function(e,t,i){const o=fl(e,t,i);return Ys((()=>1===o.length),s("More than one match found in DGET evaluation.")),o[0]},isExported:!0},wl={description:s("Maximum of values from a table-like range."),args:vl,returns:["NUMBER"],compute:function(e,t,i){const o=fl(e,t,i);return $a.compute([o])},isExported:!0},yl={description:s("Minimum of values from a table-like range."),args:vl,returns:["NUMBER"],compute:function(e,t,i){const o=fl(e,t,i);return Za.compute([o])},isExported:!0},xl={description:s("Product of values from a table-like range."),args:vl,returns:["NUMBER"],compute:function(e,t,i){const o=fl(e,t,i);return la.compute([o])},isExported:!0},Il={description:s("Standard deviation of population sample from table."),args:vl,returns:["NUMBER"],compute:function(e,t,i){const o=fl(e,t,i);return ol.compute([o])},isExported:!0},Rl={description:s("Standard deviation of entire population from table."),args:vl,returns:["NUMBER"],compute:function(e,t,i){const o=fl(e,t,i);return al.compute([o])},isExported:!0},Tl={description:s("Sum of values from a table-like range."),args:vl,returns:["NUMBER"],compute:function(e,t,i){const o=fl(e,t,i);return Sa.compute([o])},isExported:!0},Al={description:s("Variance of population sample from table-like range."),args:vl,returns:["NUMBER"],compute:function(e,t,i){const o=fl(e,t,i);return cl.compute([o])},isExported:!0},Ml={description:s("Variance of a population from a table-like range."),args:vl,returns:["NUMBER"],compute:function(e,t,i){const o=fl(e,t,i);return gl.compute([o])},isExported:!0};var Ol=Object.freeze({__proto__:null,DAVERAGE:bl,DCOUNT:Sl,DCOUNTA:Cl,DGET:El,DMAX:wl,DMIN:yl,DPRODUCT:xl,DSTDEV:Il,DSTDEVP:Rl,DSUM:Tl,DVAR:Al,DVARP:Ml});const Nl={description:s("Converts year/month/day into a date."),args:[Zs("year (number)",s("The year component of the date.")),Zs("month (number)",s("The month component of the date.")),Zs("day (number)",s("The day component of the date."))],returns:["DATE"],computeFormat:()=>"m/d/yyyy",compute:function(e,t,i){let o=Math.trunc(Qs(e));const n=Math.trunc(Qs(t)),r=Math.trunc(Qs(i));Ys((()=>0<=o&&o<=9999),s("The year (%s) must be between 0 and 9999 inclusive.",o.toString())),o<1900&&(o+=1900);const a=we(new Date(o,n-1,r));return Ys((()=>a>=0),s("The function [[FUNCTION_NAME]] result must be greater than or equal 01/01/1900.")),a},isExported:!0},_l={description:s("Converts a date string to a date value."),args:[Zs("date_string (string)",s("The string representing the date."))],returns:["NUMBER"],compute:function(e){const t=er(e),i=Se(t);return Ys((()=>null!==i),s("The date_string (%s) cannot be parsed to date/time.",t.toString())),Math.trunc(i.value)},isExported:!0},Fl={description:s("Day of the month that a specific date falls on."),args:[Zs("date (string)",s("The date from which to extract the day."))],returns:["NUMBER"],compute:function(e){return nr(e).getDate()},isExported:!0},Dl={description:s("Number of days between two dates."),args:[Zs("end_date (date)",s("The end of the date range.")),Zs("start_date (date)",s("The start of the date range."))],returns:["NUMBER"],compute:function(e,t){const i=nr(e),o=nr(t),n=i.getTime()-o.getTime();return Math.round(n/ue)},isExported:!0},kl={description:s("Number of days between two dates on a 360-day year (months of 30 days)."),args:[Zs("start_date (date)",s("The start date to consider in the calculation.")),Zs("end_date (date)",s("The end date to consider in the calculation.")),Zs("method (number, default=0)",s("An indicator of what day count method to use. (0) US NASD method (1) European method"))],returns:["NUMBER"],compute:function(e,t,i=0){const o=Qs(e),n=Qs(t),s=or(i)?4:0,r=tc.compute(e,t,s);return Math.sign(n-o)*Math.round(360*r)},isExported:!0},Ll={description:s("Date a number of months before/after another date."),args:[Zs("start_date (date)",s("The date from which to calculate the result.")),Zs("months (number)",s("The number of months before (negative) or after (positive) 'start_date' to calculate."))],returns:["DATE"],computeFormat:()=>"m/d/yyyy",compute:function(e,t){return we(Ie(nr(e),Math.trunc(Qs(t)),!1))},isExported:!0},Pl={description:s("Last day of a month before or after a date."),args:[Zs("start_date (date)",s("The date from which to calculate the result.")),Zs("months (number)",s("The number of months before (negative) or after (positive) 'start_date' to consider."))],returns:["DATE"],computeFormat:()=>"m/d/yyyy",compute:function(e,t){const i=nr(e),o=Math.trunc(Qs(t)),n=i.getFullYear(),s=i.getMonth();return we(new Date(n,s+o+1,0))},isExported:!0},Ul={description:s("Hour component of a specific time."),args:[Zs("time (date)",s("The time from which to calculate the hour component."))],returns:["NUMBER"],compute:function(e){return nr(e).getHours()},isExported:!0},Vl={description:s("ISO week number of the year."),args:[Zs("date (date)",s("The date for which to determine the ISO week number. Must be a reference to a cell containing a date, a function returning a date type, or a number."))],returns:["NUMBER"],compute:function(e){const t=nr(e),i=t.getFullYear();let o=1;for(;4!==new Date(i,0,o).getDay();)o+=1;const n=new Date(i,0,o-3);let s=31;for(;4!==new Date(i,11,s).getDay();)s-=1;const r=new Date(i,11,s+3);let a,l;switch(a=n.getTime()<=t.getTime()?t.getTime()<=r.getTime()?0:1:-1,a){case 0:l=n;break;case 1:l=new Date(i,11,s+3+1);break;case-1:let e=1;for(;4!==new Date(i-1,0,e).getDay();)e+=1;l=new Date(i-1,0,e-3)}const c=(t.getTime()-l.getTime())/ue;return Math.floor(c/7)+1},isExported:!0},zl={description:s("Minute component of a specific time."),args:[Zs("time (date)",s("The time from which to calculate the minute component."))],returns:["NUMBER"],compute:function(e){return nr(e).getMinutes()},isExported:!0},Bl={description:s("Month of the year a specific date falls in"),args:[Zs("date (date)",s("The date from which to extract the month."))],returns:["NUMBER"],compute:function(e){return nr(e).getMonth()+1},isExported:!0},Hl={description:s("Net working days between two provided days."),args:[Zs("start_date (date)",s("The start date of the period from which to calculate the number of net working days.")),Zs("end_date (date)",s("The end date of the period from which to calculate the number of net working days.")),Zs("holidays (date, range<date>, optional)",s("A range or array constant containing the date serial numbers to consider holidays."))],returns:["NUMBER"],compute:function(e,t,i){return Wl.compute(e,t,1,i)},isExported:!0};function $l(e){if("string"==typeof e){Ys((()=>{if(7!==e.length)return!1;for(let t of e)if("0"!==t&&"1"!==t)return!1;return!0}),s('When weekend is a string (%s) it must be composed of "0" or "1".',e));let t=[];for(let i=0;i<7;i++)"1"===e[i]&&t.push((i+1)%7);return t}if("number"==typeof e)return Ys((()=>1<=e&&e<=7||11<=e&&e<=17),s("The weekend (%s) must be a string or a number in the range 1-7 or 11-17.",e.toString())),e<=7?[e-2==-1?6:e-2,e-1]:[e-11];throw Error(s("The weekend must be a number or a string."))}const Wl={description:s("Net working days between two dates (specifying weekends)."),args:[Zs("start_date (date)",s("The start date of the period from which to calculate the number of net working days.")),Zs("end_date (date)",s("The end date of the period from which to calculate the number of net working days.")),Zs("weekend (any, default=1)",s("A number or string representing which days of the week are considered weekends.")),Zs("holidays (date, range<date>, optional)",s("A range or array constant containing the dates to consider as holidays."))],returns:["NUMBER"],compute:function(e,t,i=1,o){const n=nr(e),s=nr(t),r=$l(i);let a=new Set;void 0!==o&&rr([o],(e=>{const t=nr(e);a.add(t.getTime())}));const l=n.getTime()>s.getTime(),c=new Date((l?n:s).getTime());let h=new Date((l?s:n).getTime());const d=c.getTime();let u=h.getTime(),g=0;for(;u<=d;)r.includes(h.getDay())||a.has(u)||(g+=1),h.setDate(h.getDate()+1),u=h.getTime();return l?-g:g},isExported:!0},Gl={description:s("Current date and time as a date value."),args:[],returns:["DATE"],computeFormat:()=>"m/d/yyyy hh:mm:ss",compute:function(){let e=new Date;e.setMilliseconds(0);const t=e.getTime()-de.getTime(),i=e.getHours()/24+e.getMinutes()/1440+e.getSeconds()/86400;return Math.floor(t/ue)+i},isExported:!0},ql={description:s("Minute component of a specific time."),args:[Zs("time (date)",s("The time from which to calculate the second component."))],returns:["NUMBER"],compute:function(e){return nr(e).getSeconds()},isExported:!0},Zl={description:s("Converts hour/minute/second into a time."),args:[Zs("hour (number)",s("The hour component of the time.")),Zs("minute (number)",s("The minute component of the time.")),Zs("second (number)",s("The second component of the time."))],returns:["DATE"],computeFormat:()=>"hh:mm:ss a",compute:function(e,t,i){let o=Math.trunc(Qs(e)),n=Math.trunc(Qs(t)),r=Math.trunc(Qs(i));return n+=Math.floor(r/60),r=r%60+(r<0?60:0),o+=Math.floor(n/60),n=n%60+(n<0?60:0),o%=24,Ys((()=>o>=0),s("The function [[FUNCTION_NAME]] result cannot be negative")),o/24+n/1440+r/86400},isExported:!0},jl={description:s("Converts a time string into its serial number representation."),args:[Zs("time_string (string)",s("The string that holds the time representation."))],returns:["NUMBER"],compute:function(e){const t=er(e),i=Se(t);Ys((()=>null!==i),s("The time_string (%s) cannot be parsed to date/time.",t));const o=i.value-Math.trunc(i.value);return o<0?1+o:o},isExported:!0},Xl={description:s("Current date as a date value."),args:[],returns:["DATE"],computeFormat:()=>"m/d/yyyy",compute:function(){const e=new Date;return we(new Date(e.getFullYear(),e.getMonth(),e.getDate()))},isExported:!0},Yl={description:s("Day of the week of the date provided (as number)."),args:[Zs("date (date)",s("The date for which to determine the day of the week. Must be a reference to a cell containing a date, a function returning a date type, or a number.")),Zs("type (number, default=1)",s("A number indicating which numbering system to use to represent weekdays. By default, counts starting with Sunday = 1."))],returns:["NUMBER"],compute:function(e,t=1){const i=nr(e),o=Math.round(Qs(t)),n=i.getDay();return Ys((()=>[1,2,3].includes(o)),s("The type (%s) must be 1, 2 or 3.",o.toString())),1===o?n+1:2===o?0===n?7:n:0===n?6:n-1},isExported:!0},Kl={description:s("Week number of the year."),args:[Zs("date (date)",s("The date for which to determine the week number. Must be a reference to a cell containing a date, a function returning a date type, or a number.")),Zs("type (number, default=1)",s("A number representing the day that a week starts on. Sunday = 1."))],returns:["NUMBER"],compute:function(e,t=1){const i=nr(e),o=Math.round(Qs(t));if(Ys((()=>1===o||2===o||11<=o&&o<=17||21===o),s("The type (%s) is out of range.",o.toString())),21===o)return Vl.compute(e);let n;n=1===o||2===o?o-1:o-10==7?0:o-10;const r=i.getFullYear();let a=1,l=new Date(r,0,a);for(;l.getDay()!==n;)a+=1,l=new Date(r,0,a);const c=(i.getTime()-l.getTime())/ue;return c<0?1:Math.floor(c/7)+(1===a?1:2)},isExported:!0},Ql={description:s("Date after a number of workdays."),args:[Zs("start_date (date)",s("The date from which to begin counting.")),Zs("num_days (number)",s("The number of working days to advance from start_date. If negative, counts backwards.")),Zs("holidays (date, range<date>, optional)",s("A range or array constant containing the dates to consider holidays."))],returns:["NUMBER"],computeFormat:()=>"m/d/yyyy",compute:function(e,t,i){return Jl.compute(e,t,1,i)},isExported:!0},Jl={description:s("Date after a number of workdays (specifying weekends)."),args:[Zs("start_date (date)",s("The date from which to begin counting.")),Zs("num_days (number)",s("The number of working days to advance from start_date. If negative, counts backwards.")),Zs("weekend (any, default=1)",s("A number or string representing which days of the week are considered weekends.")),Zs("holidays (date, range<date>, optional)",s("A range or array constant containing the dates to consider holidays."))],returns:["DATE"],computeFormat:()=>"m/d/yyyy",compute:function(e,t,i=1,o){let n=nr(e),r=Math.trunc(Qs(t));"string"==typeof i&&Ys((()=>"1111111"!==i),s("The weekend (%s) must be different from '1111111'.",i));const a=$l(i);let l=new Set;void 0!==o&&rr([o],(e=>{const t=nr(e);l.add(t.getTime())}));let c=new Date(n.getTime()),h=c.getTime();const d=Math.sign(r);let u=Math.abs(r);for(;u>0;)c.setDate(c.getDate()+d),h=c.getTime(),a.includes(c.getDay())||l.has(h)||(u-=1);const g=h-de.getTime();return Math.round(g/ue)},isExported:!0},ec={description:s("Year specified by a given date."),args:[Zs("date (date)",s("The date from which to extract the year."))],returns:["NUMBER"],compute:function(e){return nr(e).getFullYear()},isExported:!0},tc={description:s("Exact number of years between two dates."),args:[Zs("start_date (date)",s("The start date to consider in the calculation. Must be a reference to a cell containing a date, a function returning a date type, or a number.")),Zs("end_date (date)",s("The end date to consider in the calculation. Must be a reference to a cell containing a date, a function returning a date type, or a number.")),Zs("day_count_convention (number, default=0)",s("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,i=0){let o=Math.trunc(Qs(e)),n=Math.trunc(Qs(t));const r=Math.trunc(Qs(i));return Ys((()=>o>=0),s("The start_date (%s) must be positive or null.",o.toString())),Ys((()=>n>=0),s("The end_date (%s) must be positive or null.",n.toString())),Ys((()=>0<=r&&r<=4),s("The day_count_convention (%s) must be between 0 and 4 inclusive.",r.toString())),Te(o,n,r)}},ic={description:s("First day of the month preceding a date."),args:[Zs("date (date)",s("The date from which to calculate the result."))],returns:["DATE"],computeFormat:()=>"m/d/yyyy",compute:function(e){const t=nr(e),i=t.getFullYear(),o=t.getMonth();return we(new Date(i,o,1))}},oc={description:s("Last day of the month following a date."),args:[Zs("date (date)",s("The date from which to calculate the result."))],returns:["DATE"],computeFormat:()=>"m/d/yyyy",compute:function(e){return Pl.compute(e,0)}},nc={description:s("Quarter of the year a specific date falls in"),args:[Zs("date (date)",s("The date from which to extract the quarter."))],returns:["NUMBER"],compute:function(e){return Math.ceil((nr(e).getMonth()+1)/3)}},sc={description:s("First day of the quarter of the year a specific date falls in."),args:[Zs("date (date)",s("The date from which to calculate the start of quarter."))],returns:["DATE"],computeFormat:()=>"m/d/yyyy",compute:function(e){const t=nc.compute(e),i=ec.compute(e);return we(new Date(i,3*(t-1),1))}},rc={description:s("Last day of the quarter of the year a specific date falls in."),args:[Zs("date (date)",s("The date from which to calculate the end of quarter."))],returns:["DATE"],computeFormat:()=>"m/d/yyyy",compute:function(e){const t=nc.compute(e),i=ec.compute(e);return we(new Date(i,3*t,0))}},ac={description:s("First day of the year a specific date falls in."),args:[Zs("date (date)",s("The date from which to calculate the start of the year."))],returns:["DATE"],computeFormat:()=>"m/d/yyyy",compute:function(e){const t=ec.compute(e);return we(new Date(t,0,1))}},lc={description:s("Last day of the year a specific date falls in."),args:[Zs("date (date)",s("The date from which to calculate the end of the year."))],returns:["DATE"],computeFormat:()=>"m/d/yyyy",compute:function(e){const t=ec.compute(e);return we(new Date(t+1,0,0))}};var cc=Object.freeze({__proto__:null,DATE:Nl,DATEVALUE:_l,DAY:Fl,DAYS:Dl,DAYS360:kl,EDATE:Ll,EOMONTH:Pl,HOUR:Ul,ISOWEEKNUM:Vl,MINUTE:zl,MONTH:Bl,NETWORKDAYS:Hl,NETWORKDAYS_INTL:Wl,NOW:Gl,SECOND:ql,TIME:Zl,TIMEVALUE:jl,TODAY:Xl,WEEKDAY:Yl,WEEKNUM:Kl,WORKDAY:Ql,WORKDAY_INTL:Jl,YEAR:ec,YEARFRAC:tc,MONTH_START:ic,MONTH_END:oc,QUARTER:nc,QUARTER_START:sc,QUARTER_END:rc,YEAR_START:ac,YEAR_END:lc});const hc={description:s("Compare two numeric values, returning 1 if they're equal."),args:[Zs(" (number)",s("The first number to compare.")),Zs(" (number, default=0)",s("The second number to compare."))],returns:["NUMBER"],compute:function(e,t=0){return Qs(e)===Qs(t)?1:0},isExported:!0};var dc=Object.freeze({__proto__:null,DELTA:hc});function uc(e,t){Ys((()=>e<t),s("The maturity (%s) must be strictly greater than the settlement (%s).",t.toString(),e.toString()))}function gc(e,t){Ys((()=>t<e),s("The settlement date (%s) must be strictly greater than the issue date (%s).",e.toString(),t.toString()))}function pc(e){Ys((()=>[1,2,4].includes(e)),s("The frequency (%s) must be one of %s",e.toString(),[1,2,4].toString()))}function mc(e){Ys((()=>0<=e&&e<=4),s("The day_count_convention (%s) must be between 0 and 4 inclusive.",e.toString()))}function fc(e){Ys((()=>e>0),s("The redemption (%s) must be strictly positive.",e.toString()))}function vc(e){Ys((()=>e>0),s("The price (%s) must be strictly positive.",e.toString()))}function bc(e){Ys((()=>e>0),s("The number_of_periods (%s) must be greater than 0.",e.toString()))}function Sc(e){Ys((()=>e>0),s("The rate (%s) must be strictly positive.",e.toString()))}function Cc(e){Ys((()=>e>0),s("The life (%s) must be strictly positive.",e.toString()))}function Ec(e){Ys((()=>e>=0),s("The cost (%s) must be positive or null.",e.toString()))}function wc(e){Ys((()=>e>0),s("The period (%s) must be strictly positive.",e.toString()))}function yc(e){Ys((()=>e>=0),s("The salvage (%s) must be positive or null.",e.toString()))}function xc(e){Ys((()=>e>0),s("The present value (%s) must be strictly positive.",e.toString()))}function Ic(e,t){Ys((()=>e<=t),s("The period (%s) must be less than or equal life (%s).",e.toString(),t.toString()))}function Rc(e){Ys((()=>e>0),s("The investment (%s) must be strictly positive.",e.toString()))}function Tc(e){Ys((()=>e>0),s("The discount (%s) must be strictly positive.",e.toString()))}function Ac(e){Ys((()=>e<1),s("The discount (%s) must be smaller than 1.",e.toString()))}function Mc(e){Ys((()=>e>0),s("The depreciation factor (%s) must be strictly positive.",e.toString()))}function Oc(e,t){const i=nr(e),o=nr(t),n=new Date(i);n.setFullYear(i.getFullYear()+1),Ys((()=>o.getTime()<=n.getTime()),s("The settlement date (%s) must at most one year after the maturity date (%s).",e.toString(),t.toString()))}function Nc(e,t,i){bc(i),Ys((()=>e>0),s("The first_period (%s) must be strictly positive.",e.toString())),Ys((()=>t>0),s("The last_period (%s) must be strictly positive.",t.toString())),Ys((()=>e<=t),s("The first_period (%s) must be smaller or equal to the last_period (%s).",e.toString(),t.toString())),Ys((()=>t<=i),s("The last_period (%s) must be smaller or equal to the number_of_periods (%s).",e.toString(),i.toString()))}function _c(e){Ys((()=>e>-1),s("The rate_guess (%s) must be strictly greater than -1.",e.toString()))}function Fc(e,t){Ys((()=>e.length===t.length&&e[0].length===t[0].length),s("The cashflow_amounts and cashflow_dates ranges must have the same dimensions."))}function Dc(e){Ys((()=>e.every((t=>t>=e[0]))),s("All the dates should be greater or equal to the first date in cashflow_dates (%s).",e[0].toString()))}const kc=[Zs("settlement (date)",s("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),Zs("maturity (date)",s("The maturity or end date of the security, when it can be redeemed at face, or par value.")),Zs("frequency (number)",s("The number of interest or coupon payments per year (1, 2, or 4).")),Zs("day_count_convention (number, default=0 )",s("An indicator of what day count method to use."))];function Lc(e,t,i,o,n=1e-10,r){let a,l,c,h,d=i,u=!1,g=0;do{c=e(d),isNaN(c)?(Ys((()=>g<o&&void 0!==r),s("Function [[FUNCTION_NAME]] didn't find any result.")),g++,d=r(h),h=d):(a=d-c/t(d),l=Math.abs(a-d),d=a,u=l<n||Math.abs(c)<n,Ys((()=>g<o),s("Function [[FUNCTION_NAME]] didn't find any result.")),g++)}while(!u);return d}const Pc={description:s("Accrued interest of security paying at maturity."),args:[Zs("issue (date)",s("The date the security was initially issued.")),Zs("maturity (date)",s("The maturity date of the security.")),Zs("rate (number)",s("The annualized rate of interest.")),Zs("redemption (number)",s("The redemption amount per 100 face value, or par.")),Zs("day_count_convention (number, default=0 )",s("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,i,o,n=0){n=n||0;const s=Math.trunc(Qs(e)),r=Math.trunc(Qs(t)),a=Qs(o),l=Qs(i),c=Math.trunc(Qs(n));gc(r,s),mc(c),fc(a),Sc(l);return a*l*tc.compute(s,r,n)},isExported:!0},Uc={description:s("Depreciation for an accounting period."),args:[Zs("cost (number)",s("The initial cost of the asset.")),Zs("purchase_date (date)",s("The date the asset was purchased.")),Zs("first_period_end (date)",s("The date the first period ended.")),Zs("salvage (number)",s("The value of the asset at the end of depreciation.")),Zs("period (number)",s("The single period within life for which to calculate depreciation.")),Zs("rate (number)",s("The deprecation rate.")),Zs(" (number, optional)",s("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,i,o,n,r,a=0){a=a||0;const l=Qs(e),c=Math.trunc(Qs(t)),h=Math.trunc(Qs(i)),d=Qs(o),u=Qs(n),g=Qs(r),p=Math.trunc(Qs(a));!function(e){Ys((()=>e>0),s("The cost (%s) must be strictly positive.",e.toString()))}(l),yc(d),function(e,t){Ys((()=>e<=t),s("The salvage (%s) must be smaller or equal than the cost (%s).",e.toString(),t.toString()))}(d,l),function(e){Ys((()=>e>=0),s("The period (%s) must be positive or null.",e.toString()))}(u),Sc(g),mc(p),Ys((()=>c<=h),s("The purchase_date (%s) must be before the first_period_end (%s).",c.toString(),h.toString()));const m=u<1&&u>0?1:Math.trunc(u),f=l*g,v=tc.compute(c,h,p),b=c===h?f:f*v,S=l-b-f*m;return S>=d?0===m?b:f:d-S<f?f-(d-S):0},isExported:!0},Vc={description:s("Days in coupon period containing settlement date."),args:kc,returns:["NUMBER"],compute:function(e,t,i,o=0){o=o||0;const n=Math.trunc(Qs(e)),s=Math.trunc(Qs(t)),r=Math.trunc(Qs(i)),a=Math.trunc(Qs(o));if(uc(n,s),pc(r),mc(a),1===a){const n=Wc.compute(e,t,i,o);return Hc.compute(e,t,i,o)-n}return(3===a?365:360)/r},isExported:!0},zc={description:s("Days from settlement until next coupon."),args:kc,returns:["NUMBER"],compute:function(e,t,i,o=0){o=o||0;const n=Math.trunc(Qs(e)),s=Math.trunc(Qs(t)),r=Math.trunc(Qs(i)),a=Math.trunc(Qs(o));uc(n,s),pc(r),mc(a);const l=Wc.compute(n,s,i,o);if([1,2,3].includes(a))return n-l;if(4===a){const e=Te(l,n,a);return Math.round(360*e)}const c=nr(n),h=nr(l),d=h.getFullYear(),u=c.getFullYear(),g=h.getMonth()+1,p=c.getMonth()+1;let m=h.getDate(),f=c.getDate();return 2===g&&2===p&&xe(h)&&xe(c)&&(f=30),31!==f||30!==m&&31!==m||(f=30),2===g&&xe(h)&&(m=30),31===m&&(m=30),360*(u-d)+30*(p-g)+(f-m)},isExported:!0},Bc={description:s("Days from settlement until next coupon."),args:kc,returns:["NUMBER"],compute:function(e,t,i,o=0){o=o||0;const n=Math.trunc(Qs(e)),s=Math.trunc(Qs(t)),r=Math.trunc(Qs(i)),a=Math.trunc(Qs(o));uc(n,s),pc(r),mc(a);const l=Hc.compute(n,s,i,o);if([1,2,3].includes(a))return l-n;if(4===a){const e=Te(n,l,a);return Math.round(360*e)}const c=zc.compute(e,t,i,a);return Vc.compute(e,t,i,a)-c},isExported:!0},Hc={description:s("Next coupon date after the settlement date."),args:kc,returns:["NUMBER"],computeFormat:()=>"m/d/yyyy",compute:function(e,t,i,o=0){o=o||0;const n=Math.trunc(Qs(e)),s=Math.trunc(Qs(t)),r=Math.trunc(Qs(i)),a=Math.trunc(Qs(o));uc(n,s),pc(r),mc(a);const l=12/r,c=$c.compute(e,t,i,o);return we(Ie(nr(s),-(c-1)*l,!0))},isExported:!0},$c={description:s("Number of coupons between settlement and maturity."),args:kc,returns:["NUMBER"],compute:function(e,t,i,o=0){o=o||0;const n=Math.trunc(Qs(e)),s=Math.trunc(Qs(t)),r=Math.trunc(Qs(i)),a=Math.trunc(Qs(o));uc(n,s),pc(r),mc(a);let l=1,c=s;const h=12/r;for(;c>n;)c=we(Ie(nr(c),-h,!1)),l++;return l-1},isExported:!0},Wc={description:s("Last coupon date prior to or on the settlement date."),args:kc,returns:["NUMBER"],computeFormat:()=>"m/d/yyyy",compute:function(e,t,i,o=0){o=o||0;const n=Math.trunc(Qs(e)),s=Math.trunc(Qs(t)),r=Math.trunc(Qs(i)),a=Math.trunc(Qs(o));uc(n,s),pc(r),mc(a);const l=12/r,c=$c.compute(e,t,i,o);return we(Ie(nr(s),-c*l,!0))},isExported:!0},Gc={description:s("Cumulative interest paid over a set of periods."),args:[Zs("rate (number)",s("The interest rate.")),Zs("number_of_periods (number)",s("The number of payments to be made.")),Zs("present_value (number)",s("The current value of the annuity.")),Zs("first_period (number)",s("The number of the payment period to begin the cumulative calculation.")),Zs("last_period (number)",s("The number of the payment period to end the cumulative calculation.")),Zs("end_or_beginning (number, default=0)",s("Whether payments are due at the end (0) or beginning (1) of each period."))],returns:["NUMBER"],compute:function(e,t,i,o,n,s=0){const r=Qs(o),a=Qs(n),l=Qs(e),c=Qs(i),h=Qs(t);Nc(r,a,h),Sc(l),xc(c);let d=0;for(let t=r;t<=a;t++){d+=oh.compute(e,t,h,i,0,s)}return d},isExported:!0},qc={description:s("Cumulative principal paid over a set of periods."),args:[Zs("rate (number)",s("The interest rate.")),Zs("number_of_periods (number)",s("The number of payments to be made.")),Zs("present_value (number)",s("The current value of the annuity.")),Zs("first_period (number)",s("The number of the payment period to begin the cumulative calculation.")),Zs("last_period (number)",s("The number of the payment period to end the cumulative calculation.")),Zs("end_or_beginning (number, default=0)",s("Whether payments are due at the end (0) or beginning (1) of each period."))],returns:["NUMBER"],compute:function(e,t,i,o,n,s=0){const r=Qs(o),a=Qs(n),l=Qs(e),c=Qs(i),h=Qs(t);Nc(r,a,h),Sc(l),xc(c);let d=0;for(let t=r;t<=a;t++){d+=gh.compute(e,t,h,i,0,s)}return d},isExported:!0},Zc={description:s("Depreciation via declining balance method."),args:[Zs("cost (number)",s("The initial cost of the asset.")),Zs("salvage (number)",s("The value of the asset at the end of depreciation.")),Zs("life (number)",s("The number of periods over which the asset is depreciated.")),Zs("period (number)",s("The single period within life for which to calculate depreciation.")),Zs("month (number, optional)",s("The number of months in the first year of depreciation."))],returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,t,i,o,...n){const r=Qs(e),a=Qs(t),l=Qs(i),c=Math.trunc(Qs(o)),h=n.length?Math.trunc(Qs(n[0])):12,d=l+(12===h?0:1);Ec(r),yc(a),wc(c),Cc(l),Ys((()=>1<=h&&h<=12),s("The month (%s) must be between 1 and 12 inclusive.",h.toString())),Ys((()=>c<=d),s("The period (%s) must be less than or equal to %s.",c.toString(),d.toString()));const u=h/12;let g=1-Math.pow(a/r,1/l);g=Math.round(1e3*g)/1e3;let p=r,m=r*(1-g*u);for(let e=1;e<c;e++)p=m,m=p*(1-g),e===l&&(m=p*(1-g*(1-u)));return p-m},isExported:!0},jc={description:s("Depreciation via double-declining balance method."),args:[Zs("cost (number)",s("The initial cost of the asset.")),Zs("salvage (number)",s("The value of the asset at the end of depreciation.")),Zs("life (number)",s("The number of periods over which the asset is depreciated.")),Zs("period (number)",s("The single period within life for which to calculate depreciation.")),Zs("factor (number, default=2)",s("The factor by which depreciation decreases."))],returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,t,i,o,n=2){n=n||0;const s=Qs(e),r=Qs(t),a=Qs(i),l=Qs(o),c=Qs(n);if(Ec(s),yc(r),wc(l),Cc(a),Ic(l,a),Mc(c),0===s||r>=s)return 0;const h=c/a;if(h>1)return 1===o?s-r:0;if(l<=1)return s*h;const d=s*Math.pow(1-h,l-1),u=s*Math.pow(1-h,l),g=u<r?d-r:d-u;return Math.max(g,0)},isExported:!0},Xc={description:s("Discount rate of a security based on price."),args:[Zs("settlement (date)",s("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),Zs("maturity (date)",s("The maturity or end date of the security, when it can be redeemed at face, or par value.")),Zs("price (number)",s("The price at which the security is bought per 100 face value.")),Zs("redemption (number)",s("The redemption amount per 100 face value, or par.")),Zs("day_count_convention (number, default=0 )",s("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,i,o,n=0){n=n||0;const s=Math.trunc(Qs(e)),r=Math.trunc(Qs(t)),a=Qs(i),l=Qs(o),c=Math.trunc(Qs(n));uc(s,r),mc(c),vc(a),fc(l);return(l-a)/l/tc.compute(s,r,c)},isExported:!0},Yc={description:s("Convert a decimal fraction to decimal value."),args:[Zs("fractional_price (number)",s("The price quotation given using fractional decimal conventions.")),Zs("unit (number)",s("The units of the fraction, e.g. 8 for 1/8ths or 32 for 1/32nds."))],returns:["NUMBER"],compute:function(e,t){const i=Qs(e),o=Math.trunc(Qs(t));Ys((()=>o>0),s("The unit (%s) must be strictly positive.",o.toString()));const n=Math.trunc(i);return n+(i-n)*(10**Math.ceil(Math.log10(o))/o)},isExported:!0},Kc={description:s("Convert a decimal value to decimal fraction."),args:[Zs("decimal_price (number)",s("The price quotation given as a decimal value.")),Zs("unit (number)",s("The units of the desired fraction, e.g. 8 for 1/8ths or 32 for 1/32nds."))],returns:["NUMBER"],compute:function(e,t){const i=Qs(e),o=Math.trunc(Qs(t));Ys((()=>o>0),s("The unit (%s) must be strictly positive.",o.toString()));const n=Math.trunc(i);return n+(i-n)*(o/10**Math.ceil(Math.log10(o)))},isExported:!0},Qc={description:s("Number of periods for an investment to reach a value."),args:[Zs("settlement (date)",s("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),Zs("maturity (date)",s("The maturity or end date of the security, when it can be redeemed at face, or par value.")),Zs("rate (number)",s("The annualized rate of interest.")),Zs("yield (number)",s("The expected annual yield of the security.")),Zs("frequency (number)",s("The number of interest or coupon payments per year (1, 2, or 4).")),Zs("day_count_convention (number, default=0 )",s("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,i,o,n,r=0){r=r||0;const a=Math.trunc(Qs(e)),l=Math.trunc(Qs(t)),c=Qs(i),h=Qs(o),d=Math.trunc(Qs(n)),u=Math.trunc(Qs(r));uc(a,l),pc(d),mc(u),Ys((()=>c>=0),s("The rate (%s) must be positive or null.",c.toString())),Ys((()=>h>=0),s("The yield (%s) must be positive or null.",h.toString()));const g=tc.compute(a,l,u),p=g-Math.trunc(g)||1/d,m=Math.ceil(g*d),f=c/d,v=h/d;let b=0,S=0;for(let e=1;e<=m;e++){const t=(f+(e===m?1:0))/(1+v)**e;S+=(p+(e-1)/d)*t,b+=t}return 0===b?0:S/b},isExported:!0},Jc={description:s("Annual effective interest rate."),args:[Zs("nominal_rate (number)",s("The nominal interest rate per year.")),Zs("periods_per_year (number)",s("The number of compounding periods per year."))],returns:["NUMBER"],compute:function(e,t){const i=Qs(e),o=Math.trunc(Qs(t));return Ys((()=>i>0),s("The nominal rate (%s) must be strictly greater than 0.",i.toString())),Ys((()=>o>0),s("The number of periods by year (%s) must strictly greater than 0.",o.toString())),Math.pow(1+i/o,o)-1},isExported:!0},eh={description:s("Future value of an annuity investment."),args:[Zs("rate (number)",s("The interest rate.")),Zs("number_of_periods (number)",s("The number of payments to be made.")),Zs("payment_amount (number)",s("The amount per period to be paid.")),Zs("present_value (number, default=0)",s("The current value of the annuity.")),Zs("end_or_beginning (number, default=0)",s("Whether payments are due at the end (0) or beginning (1) of each period."))],returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,t,i,o=0,n=0){o=o||0,n=n||0;const s=Qs(e),r=Qs(t),a=Qs(i),l=Qs(o),c=or(n)?1:0;return s?-l*(1+s)**r-a*(1+s*c)*((1+s)**r-1)/s:-(l+a*r)},isExported:!0},th={description:s("Future value of principal from series of rates."),args:[Zs("principal (number)",s("The amount of initial capital or value to compound against.")),Zs("rate_schedule (number, range<number>)",s("A series of interest rates to compound against the principal."))],returns:["NUMBER"],compute:function(e,t){return cr([t],((e,t)=>e*(1+Qs(t))),Qs(e))},isExported:!0},ih={description:s("Calculates effective interest rate."),args:[Zs("settlement (date)",s("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),Zs("maturity (date)",s("The maturity or end date of the security, when it can be redeemed at face, or par value.")),Zs("investment (number)",s("The amount invested in the security.")),Zs("redemption (number)",s("The amount to be received at maturity.")),Zs("day_count_convention (number, default=0 )",s("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,i,o,n=0){const s=Math.trunc(Qs(e)),r=Math.trunc(Qs(t)),a=Qs(o),l=Qs(i);uc(s,r),Rc(l),fc(a);return(a-l)/l/tc.compute(s,r,n)},isExported:!0},oh={description:s("Payment on the principal of an investment."),args:[Zs("rate (number)",s("The annualized rate of interest.")),Zs("period (number)",s("The amortization period, in terms of number of periods.")),Zs("number_of_periods (number)",s("The number of payments to be made.")),Zs("present_value (number)",s("The current value of the annuity.")),Zs("future_value (number, default=0)",s("The future value remaining after the final payment has been made.")),Zs("end_or_beginning (number, default=0)",s("Whether payments are due at the end (0) or beginning (1) of each period."))],returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,t,i,o,n=0,s=0){return uh.compute(e,i,o,n,s)-gh.compute(e,t,i,o,n,s)},isExported:!0},nh={description:s("Internal rate of return given periodic cashflows."),args:[Zs("cashflow_amounts (number, range<number>)",s("An array or range containing the income or payments associated with the investment.")),Zs("rate_guess (number, default=0.1)",s("An estimate for what the internal rate of return will be."))],returns:["NUMBER"],computeFormat:()=>"0%",compute:function(e,t=.1){const i=Qs(t);_c(i);let o=!1,n=!1,r=[];ar([e],(e=>{e>0&&(o=!0),e<0&&(n=!0),r.push(e)})),Ys((()=>o&&n),s("The cashflow_amounts must include negative and positive values."));const a=r.shift();return Lc((function(e){return function(e,t,i){const o=i.length;let n=0;return i.reduce(((t,i)=>(n++,t+i*e**(o-n))),t*e**o)}(e,a,r)}),(function(e){return function(e,t,i){const o=i.length;let n=0;return i.reduce(((t,i)=>(n++,t+i*(o-n)*e**(o-n-1))),t*o*e**(o-1))}(e,a,r)}),i+1,20,1e-5)-1},isExported:!0},sh={description:s("Returns the interest paid at a particular period of an investment."),args:[Zs("rate (number)",s("The interest rate.")),Zs("period (number)",s("The period for which you want to view the interest payment.")),Zs("number_of_periods (number)",s("The number of payments to be made.")),Zs("present_value (number)",s("The current value of the annuity."))],returns:["NUMBER"],compute:function(e,t,i,o){const n=Qs(e),r=Qs(t),a=Qs(i),l=Qs(o);Ys((()=>0!==a),s("The number of periods must be different than 0.",a.toString()));return-1*(l-l*(r/a))*n},isExported:!0},rh={description:s("Modified Macaulay duration."),args:[Zs("settlement (date)",s("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),Zs("maturity (date)",s("The maturity or end date of the security, when it can be redeemed at face, or par value.")),Zs("rate (number)",s("The annualized rate of interest.")),Zs("yield (number)",s("The expected annual yield of the security.")),Zs("frequency (number)",s("The number of interest or coupon payments per year (1, 2, or 4).")),Zs("day_count_convention (number, default=0 )",s("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,i,o,n,s=0){return Qc.compute(e,t,i,o,n,s)/(1+Qs(o)/Math.trunc(Qs(n)))},isExported:!0},ah={description:s("Modified internal rate of return."),args:[Zs("cashflow_amounts (range<number>)",s("A range containing the income or payments associated with the investment. The array should contain bot payments and incomes.")),Zs("financing_rate (number)",s("The interest rate paid on funds invested.")),Zs("reinvestment_return_rate (number)",s("The return (as a percentage) earned on reinvestment of income received from the investment."))],returns:["NUMBER"],compute:function(e,t,i){const o=Qs(t),n=Qs(i),r=(a=e,a.length?a[0].map(((e,t)=>a.map((e=>e[t])))):a).flat().filter(et).map(Qs);var a;const l=r.length;let c=0,h=0;for(const e of ze(0,l)){const t=r[e];t>=0?c+=t*(n+1)**(l-e-1):h+=t/(o+1)**e}Ys((()=>0!==h&&0!==c),s("There must be both positive and negative values in cashflow_amounts."));return(-c/h)**(1/(l-1))-1},isExported:!0},lh={description:s("Annual nominal interest rate."),args:[Zs("effective_rate (number)",s("The effective interest rate per year.")),Zs("periods_per_year (number)",s("The number of compounding periods per year."))],returns:["NUMBER"],compute:function(e,t){const i=Qs(e),o=Math.trunc(Qs(t));return Ys((()=>i>0),s("The effective rate (%s) must must strictly greater than 0.",i.toString())),Ys((()=>o>0),s("The number of periods by year (%s) must strictly greater than 0.",o.toString())),(Math.pow(i+1,1/o)-1)*o},isExported:!0},ch={description:s("Number of payment periods for an investment."),args:[Zs("rate (number)",s("The interest rate.")),Zs("payment_amount (number)",s("The amount of each payment made.")),Zs("present_value (number)",s("The current value of the annuity.")),Zs("future_value (number, default=0)",s("The future value remaining after the final payment has been made.")),Zs("end_or_beginning (number, default=0)",s("Whether payments are due at the end (0) or beginning (1) of each period."))],returns:["NUMBER"],compute:function(e,t,i,o=0,n=0){o=o||0,n=n||0;const s=Qs(e),r=Qs(t),a=Qs(i),l=Qs(o),c=or(n)?1:0;if(0===s)return-(l+a)/r;const h=r*(1+s*c)/s;return Math.log((h-l)/(a+h))/Math.log(1+s)},isExported:!0};const hh={description:s("The net present value of an investment based on a series of periodic cash flows and a discount rate."),args:[Zs("discount (number)",s("The discount rate of the investment over one period.")),Zs("cashflow1 (number, range<number>)",s("The first future cash flow.")),Zs("cashflow2 (number, range<number>, repeating)",s("Additional future cash flows."))],returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,...t){const i=Qs(e);return Ys((()=>-1!==i),s("The discount (%s) must be different from -1.",i.toString())),function(e,t,i){let o=0;return hr(i,((t,i)=>(o++,t+i/(1+e)**o)),t)}(i,0,t)},isExported:!0},dh={description:s("Computes the number of periods needed for an investment to reach a value."),args:[Zs("rate (number)",s("The rate at which the investment grows each period.")),Zs("present_value (number)",s("The investment's current value.")),Zs("future_value (number)",s("The investment's desired future value."))],returns:["NUMBER"],compute:function(e,t,i){const o=Qs(e),n=Qs(t),r=Qs(i);return Sc(o),Ys((()=>n>0),s("The present_value (%s) must be strictly positive.",n.toString())),Ys((()=>r>0),s("The future_value (%s) must be strictly positive.",r.toString())),(Math.log(r)-Math.log(n))/Math.log(1+o)},isExported:!0},uh={description:s("Periodic payment for an annuity investment."),args:[Zs("rate (number)",s("The annualized rate of interest.")),Zs("number_of_periods (number)",s("The number of payments to be made.")),Zs("present_value (number)",s("The current value of the annuity.")),Zs("future_value (number, default=0)",s("The future value remaining after the final payment has been made.")),Zs("end_or_beginning (number, default=0)",s("Whether payments are due at the end (0) or beginning (1) of each period."))],returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,t,i,o=0,n=0){o=o||0,n=n||0;const s=Qs(t),r=Qs(e),a=or(n)?1:0;let l=Qs(o),c=Qs(i);if(bc(s),0===r)return-(l+c)/s;let h=-(c*(1+r)**s+l);return h=h*r/((1+r*a)*((1+r)**s-1)),h},isExported:!0},gh={description:s("Payment on the principal of an investment."),args:[Zs("rate (number)",s("The annualized rate of interest.")),Zs("period (number)",s("The amortization period, in terms of number of periods.")),Zs("number_of_periods (number)",s("The number of payments to be made.")),Zs("present_value (number)",s("The current value of the annuity.")),Zs("future_value (number, default=0)",s("The future value remaining after the final payment has been made.")),Zs("end_or_beginning (number, default=0)",s("Whether payments are due at the end (0) or beginning (1) of each period."))],returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,t,i,o,n=0,r=0){n=n||0,r=r||0;const a=Qs(i),l=Qs(e),c=Qs(t),h=or(r)?1:0,d=Qs(n),u=Qs(o);bc(a),Ys((()=>c>0&&c<=a),s("The period must be between 1 and number_of_periods",a.toString()));const g=uh.compute(l,a,u,d,r);if(1===h&&1===c)return g;return g+-eh.compute(l,0===h?c-1:c-2,g,u+g*h,0)*l},isExported:!0},ph={description:s("Present value of an annuity investment."),args:[Zs("rate (number)",s("The interest rate.")),Zs("number_of_periods (number)",s("The number of payments to be made.")),Zs("payment_amount (number)",s("The amount per period to be paid.")),Zs("future_value (number, default=0)",s("The future value remaining after the final payment has been made.")),Zs("end_or_beginning (number, default=0)",s("Whether payments are due at the end (0) or beginning (1) of each period."))],returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,t,i,o=0,n=0){o=o||0,n=n||0;const s=Qs(e),r=Qs(t),a=Qs(i),l=Qs(o),c=or(n)?1:0;return s?-(a*(1+s*c)*((1+s)**r-1)/s+l)/(1+s)**r:-(l+a*r)},isExported:!0},mh={description:s("Price of a security paying periodic interest."),args:[Zs("settlement (date)",s("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),Zs("maturity (date)",s("The maturity or end date of the security, when it can be redeemed at face, or par value.")),Zs("rate (number)",s("The annualized rate of interest.")),Zs("yield (number)",s("The expected annual yield of the security.")),Zs("redemption (number)",s("The redemption amount per 100 face value, or par.")),Zs("frequency (number)",s("The number of interest or coupon payments per year (1, 2, or 4).")),Zs("day_count_convention (number, default=0 )",s("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,i,o,n,r,a=0){a=a||0;const l=Math.trunc(Qs(e)),c=Math.trunc(Qs(t)),h=Qs(i),d=Qs(o),u=Qs(n),g=Math.trunc(Qs(r)),p=Math.trunc(Qs(a));uc(l,c),pc(g),mc(p),Ys((()=>h>=0),s("The rate (%s) must be positive or null.",h.toString())),Ys((()=>d>=0),s("The yield (%s) must be positive or null.",d.toString())),fc(u);const m=tc.compute(l,c,p)*g,f=Math.ceil(m),v=m-Math.floor(m)||1,b=1+d/g,S=100*h/g;if(1===f)return(S+u)/(v*d/g+1)-S*(1-v);let C=0;for(let e=1;e<=f;e++)C+=S/b**(e-1+v);return u/b**(f-1+v)+C-S*(1-v)},isExported:!0},fh={description:s("Price of a discount security."),args:[Zs("settlement (date)",s("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),Zs("maturity (date)",s("The maturity or end date of the security, when it can be redeemed at face, or par value.")),Zs("discount (number)",s("The discount rate of the security at time of purchase.")),Zs("redemption (number)",s("The redemption amount per 100 face value, or par.")),Zs("day_count_convention (number, default=0 )",s("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,i,o,n=0){n=n||0;const s=Math.trunc(Qs(e)),r=Math.trunc(Qs(t)),a=Qs(i),l=Qs(o),c=Math.trunc(Qs(n));uc(s,r),mc(c),Tc(a),fc(l);return l-a*l*tc.compute(s,r,c)},isExported:!0},vh={description:s("Calculates the price of a security paying interest at maturity, based on expected yield."),args:[Zs("settlement (date)",s("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),Zs("maturity (date)",s("The maturity or end date of the security, when it can be redeemed at face, or par value.")),Zs("issue (date)",s("The date the security was initially issued.")),Zs("rate (number)",s("The annualized rate of interest.")),Zs("yield (number)",s("The expected annual yield of the security.")),Zs("day_count_convention (number, default=0 )",s("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,i,o,n,r=0){r=r||0;const a=Math.trunc(Qs(e)),l=Math.trunc(Qs(t)),c=Math.trunc(Qs(i)),h=Qs(o),d=Qs(n),u=Math.trunc(Qs(r));gc(a,c),uc(a,l),mc(u),Ys((()=>h>=0),s("The rate (%s) must be positive or null.",h.toString())),Ys((()=>d>=0),s("The yield (%s) must be positive or null.",d.toString()));const g=tc.compute(a,l,u),p=tc.compute(a,c,u);return(100+tc.compute(c,l,u)*h*100)/(1+g*d)-p*h*100},isExported:!0},bh=.1,Sh={description:s("Interest rate of an annuity investment."),args:[Zs("number_of_periods (number)",s("The number of payments to be made.")),Zs("payment_per_period (number)",s("The amount per period to be paid.")),Zs("present_value (number)",s("The current value of the annuity.")),Zs("future_value (number, default=0)",s("The future value remaining after the final payment has been made.")),Zs("end_or_beginning (number, default=0)",s("Whether payments are due at the end (0) or beginning (1) of each period.")),Zs("rate_guess (number, default=0.1)",s("An estimate for what the interest rate will be."))],returns:["NUMBER"],computeFormat:()=>"0%",compute:function(e,t,i,o=0,n=0,r=.1){o=o||0,n=n||0,r=r||bh;const a=Qs(e),l=Qs(t),c=or(n)?1:0,h=Qs(r);let d=Qs(o),u=Qs(i);bc(a),Ys((()=>[l,u,d].some((e=>e>0))&&[l,u,d].some((e=>e<0))),s("There must be both positive and negative values in [payment_amount, present_value, future_value].",a.toString())),_c(h),d-=l*c,u+=l*c;return Lc((e=>{const t=Math.pow(1+e,a);return d+u*t+l*((t-1)/e)}),(e=>{const t=Math.pow(1+e,a-1),i=Math.pow(1+e,a);return u*a*t+l*(a*t/e-(i-1)/e/e)}),h,40,1e-5)},isExported:!0},Ch={description:s("Amount received at maturity for a security."),args:[Zs("settlement (date)",s("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),Zs("maturity (date)",s("The maturity or end date of the security, when it can be redeemed at face, or par value.")),Zs("investment (number)",s("The amount invested (irrespective of face value of each security).")),Zs("discount (number)",s("The discount rate of the security invested in.")),Zs("day_count_convention (number, default=0 )",s("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,i,o,n=0){n=n||0;const s=Math.trunc(Qs(e)),r=Math.trunc(Qs(t)),a=Qs(i),l=Qs(o),c=Math.trunc(Qs(n));uc(s,r),mc(c),Rc(a),Tc(l);return a/(1-l*tc.compute(s,r,c))},isExported:!0},Eh={description:s("Computes the rate needed for an investment to reach a specific value within a specific number of periods."),args:[Zs("number_of_periods (number)",s("The number of periods.")),Zs("present_value (number)",s("The present value of the investment.")),Zs("future_value (number)",s("The future value of the investment."))],returns:["NUMBER"],compute:function(e,t,i){const o=Qs(e),n=Qs(t),s=Qs(i);return bc(o),(s/n)**(1/o)-1},isExported:!0},wh={description:s("Depreciation of an asset using the straight-line method."),args:[Zs("cost (number)",s("The initial cost of the asset.")),Zs("salvage (number)",s("The value of the asset at the end of depreciation.")),Zs("life (number)",s("The number of periods over which the asset is depreciated."))],returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,t,i){return(Qs(e)-Qs(t))/Qs(i)},isExported:!0},yh={description:s("Depreciation via sum of years digit method."),args:[Zs("cost (number)",s("The initial cost of the asset.")),Zs("salvage (number)",s("The value of the asset at the end of depreciation.")),Zs("life (number)",s("The number of periods over which the asset is depreciated.")),Zs("period (number)",s("The single period within life for which to calculate depreciation."))],returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,t,i,o){const n=Qs(e),s=Qs(t),r=Qs(i),a=Qs(o);wc(a),Cc(r),Ic(a,r);return(r-a+1)/(r*(r+1)/2)*(n-s)},isExported:!0},xh={description:s("Price of a US Treasury bill."),args:[Zs("settlement (date)",s("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),Zs("maturity (date)",s("The maturity or end date of the security, when it can be redeemed at face, or par value.")),Zs("discount (number)",s("The discount rate of the bill at time of purchase."))],returns:["NUMBER"],compute:function(e,t,i){const o=Math.trunc(Qs(e)),n=Math.trunc(Qs(t)),s=Qs(i);uc(o,n),Oc(o,n),Tc(s),Ac(s);return 100*(1-s*tc.compute(o,n,2))},isExported:!0},Ih={description:s("Equivalent rate of return for a US Treasury bill."),args:[Zs("settlement (date)",s("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),Zs("maturity (date)",s("The maturity or end date of the security, when it can be redeemed at face, or par value.")),Zs("discount (number)",s("The discount rate of the bill at time of purchase."))],returns:["NUMBER"],compute:function(e,t,i){const o=Math.trunc(Qs(e)),n=Math.trunc(Qs(t)),s=Qs(i);uc(o,n),Oc(o,n),Tc(s),Ac(s);const r=Dl.compute(n,o);if(r<=182)return 365*s/(360-s*r);const a=xh.compute(o,n,s)/100,l=r/(366===r?366:365);return(-2*l+2*Math.sqrt(l**2-(2*l-1)*(1-1/a)))/(2*l-1)},isExported:!0},Rh={description:s("The yield of a US Treasury bill based on price."),args:[Zs("settlement (date)",s("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),Zs("maturity (date)",s("The maturity or end date of the security, when it can be redeemed at face, or par value.")),Zs("price (number)",s("The price at which the security is bought per 100 face value."))],returns:["NUMBER"],compute:function(e,t,i){const o=Math.trunc(Qs(e)),n=Math.trunc(Qs(t)),s=Qs(i);uc(o,n),Oc(o,n),vc(s);return(100-s)/s*(1/tc.compute(o,n,2))},isExported:!0},Th={description:s("Variable declining balance. WARNING : does not handle decimal periods."),args:[Zs("cost (number)",s("The initial cost of the asset.")),Zs("salvage (number)",s("The value of the asset at the end of depreciation.")),Zs("life (number)",s("The number of periods over which the asset is depreciated.")),Zs("start (number)",s("Starting period to calculate depreciation.")),Zs("end (number)",s("Ending period to calculate depreciation.")),Zs("factor (number, default=2)",s("The number of months in the first year of depreciation.")),Zs("no_switch (number, default=false)",s("Whether to switch to straight-line depreciation when the depreciation is greater than the declining balance calculation."))],returns:["NUMBER"],compute:function(e,t,i,o,n,r=2,a=false){r=r||0;const l=Qs(e),c=Qs(t),h=Qs(i),d=Math.trunc(Qs(o)),u=Math.trunc(Qs(n)),g=Qs(r),p=or(a);if(Ec(l),yc(c),function(e,t,i){Cc(i),Ys((()=>e>=0),s("The start_period (%s) must be greater or equal than 0.",e.toString())),Ys((()=>t>=0),s("The end_period (%s) must be greater or equal than 0.",t.toString())),Ys((()=>e<=t),s("The start_period (%s) must be smaller or equal to the end_period (%s).",e.toString(),t.toString())),Ys((()=>t<=i),s("The end_period (%s) must be smaller or equal to the life (%s).",e.toString(),i.toString()))}(d,u,h),Mc(g),0===l)return 0;if(c>=l)return d<1?l-c:0;const m=g/h;if(m>=1)return d<1?l-c:0;let f=l,v=0,b=0,S=!1;for(let e=0;e<u;e++){if(!S||p){const t=f*m,i=(f-c)/(h-e);!p&&i>t?(S=!0,v=i):v=t}const t=Math.max(f-v,c);e>=d&&(b+=f-t),f=t}return b},isExported:!0},Ah={description:s("Internal rate of return given non-periodic cash flows."),args:[Zs("cashflow_amounts (range<number>)",s("An range containing the income or payments associated with the investment.")),Zs("cashflow_dates (range<number>)",s("An range with dates corresponding to the cash flows in cashflow_amounts.")),Zs("rate_guess (number, default=0.1)",s("An estimate for what the internal rate of return will be."))],returns:["NUMBER"],compute:function(e,t,i=.1){const o=Qs(i=i||0),n=e.flat().map(Qs),r=t.flat().map(Qs);var a;Fc(e,t),a=n,Ys((()=>a.some((e=>e>0))&&a.some((e=>e<0))),s("There must be both positive and negative values in cashflow_amounts.")),Dc(r),_c(o);const l=new Map;for(const e of ze(0,r.length)){const t=r[e];l.has(t)?l.set(t,l.get(t)+n[e]):l.set(t,n[e])}const c=Array.from(l.keys()),h=c.map((e=>l.get(e)));return Lc((e=>{let t=h[0];for(const i of ze(1,h.length)){const o=(c[0]-c[i])/365;t+=h[i]*(1+e)**o}return t}),(e=>{let t=0;for(const i of ze(1,h.length)){const o=(c[0]-c[i])/365;t+=o*h[i]*(1+e)**(o-1)}return t}),o,40,1e-5,(e=>e?e/10-.9:-.9))},isExported:!0},Mh={description:s("Net present value given to non-periodic cash flows.."),args:[Zs("discount (number)",s("The discount rate of the investment over one period.")),Zs("cashflow_amounts (number, range<number>)",s("An range containing the income or payments associated with the investment.")),Zs("cashflow_dates (number, range<number>)",s("An range with dates corresponding to the cash flows in cashflow_amounts."))],returns:["NUMBER"],compute:function(e,t,i){const o=Qs(e),n=Array.isArray(t)?t.flat().map(Js):[Js(t)],r=Array.isArray(i)?i.flat().map(Js):[Js(i)];if(Array.isArray(i)&&Array.isArray(t)?Fc(t,i):Ys((()=>n.length===r.length),s("There must be the same number of values in cashflow_amounts and cashflow_dates.")),Dc(r),Sc(o),1===n.length)return n[0];const a=new Map;for(const e of ze(0,r.length)){const t=r[e];a.has(t)?a.set(t,a.get(t)+n[e]):a.set(t,n[e])}const l=Array.from(a.keys()),c=l.map((e=>a.get(e)));let h=c[0];for(const e of ze(1,c.length)){const t=(l[0]-l[e])/365;h+=c[e]*(1+o)**t}return h},isExported:!0},Oh={description:s("Annual yield of a security paying periodic interest."),args:[Zs("settlement (date)",s("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),Zs("maturity (date)",s("The maturity or end date of the security, when it can be redeemed at face, or par value.")),Zs("rate (number)",s("The annualized rate of interest.")),Zs("price (number)",s("The price at which the security is bought per 100 face value.")),Zs("redemption (number)",s("The redemption amount per 100 face value, or par.")),Zs("frequency (number)",s("The number of interest or coupon payments per year (1, 2, or 4).")),Zs("day_count_convention (number, default=0 )",s("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,i,o,n,r,a=0){a=a||0;const l=Math.trunc(Qs(e)),c=Math.trunc(Qs(t)),h=Qs(i),d=Qs(o),u=Qs(n),g=Math.trunc(Qs(r)),p=Math.trunc(Qs(a));uc(l,c),pc(g),mc(p),Ys((()=>h>=0),s("The rate (%s) must be positive or null.",h.toString())),vc(d),fc(u);const m=tc.compute(l,c,p)*g,f=Math.ceil(m),v=m-Math.floor(m)||1,b=100*h/g;if(1===f){const e=d+b*(1-v);return(u+b-e)*g*(1/v)/e}const S=Lc((function(e){return function(e,t,i,o,n,s){let r=s-(e+n*(1-t))*o**(i-1+t);for(let e=1;e<=i;e++)r+=n*o**(e-1);return r}(d,v,f,e,b,u)}),(function(e){return function(e,t,i,o,n){let s=-(e+n*(1-t))*(i-1+t)*o**(i-2+t);for(let e=1;e<=i;e++)s+=n*(e-1)*o**(e-2);return s}(d,v,f,e,b)}),1+(h+1)/g,100,1e-5);return(S-1)*g},isExported:!0},Nh={description:s("Annual yield of a discount security."),args:[Zs("settlement (date)",s("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),Zs("maturity (date)",s("The maturity or end date of the security, when it can be redeemed at face, or par value.")),Zs("price (number)",s("The price at which the security is bought per 100 face value.")),Zs("redemption (number)",s("The redemption amount per 100 face value, or par.")),Zs("day_count_convention (number, default=0 )",s("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,i,o,n=0){n=n||0;const s=Math.trunc(Qs(e)),r=Math.trunc(Qs(t)),a=Qs(i),l=Qs(o),c=Math.trunc(Qs(n));uc(s,r),mc(c),vc(a),fc(l);return(l/a-1)/tc.compute(e,t,n)},isExported:!0},_h={description:s("Annual yield of a security paying interest at maturity."),args:[Zs("settlement (date)",s("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),Zs("maturity (date)",s("The maturity or end date of the security, when it can be redeemed at face, or par value.")),Zs("issue (date)",s("The date the security was initially issued.")),Zs("rate (number)",s("The annualized rate of interest.")),Zs("price (number)",s("The price at which the security is bought.")),Zs("day_count_convention (number, default=0 )",s("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,i,o,n,r=0){r=r||0;const a=Math.trunc(Qs(e)),l=Math.trunc(Qs(t)),c=Math.trunc(Qs(i)),h=Qs(o),d=Qs(n),u=Math.trunc(Qs(r));uc(a,l),mc(u),Ys((()=>a>=c),s("The settlement (%s) must be greater than or equal to the issue (%s).",a.toString(),c.toString())),Ys((()=>h>=0),s("The rate (%s) must be positive or null.",h.toString())),vc(d);const g=tc.compute(c,l,u),p=tc.compute(c,a,u),m=tc.compute(a,l,u);return(100*(1+h*g)/(d+100*h*p)-1)/m},isExported:!0};var Fh=Object.freeze({__proto__:null,ACCRINTM:Pc,AMORLINC:Uc,COUPDAYS:Vc,COUPDAYBS:zc,COUPDAYSNC:Bc,COUPNCD:Hc,COUPNUM:$c,COUPPCD:Wc,CUMIPMT:Gc,CUMPRINC:qc,DB:Zc,DDB:jc,DISC:Xc,DOLLARDE:Yc,DOLLARFR:Kc,DURATION:Qc,EFFECT:Jc,FV:eh,FVSCHEDULE:th,INTRATE:ih,IPMT:oh,IRR:nh,ISPMT:sh,MDURATION:rh,MIRR:ah,NOMINAL:lh,NPER:ch,NPV:hh,PDURATION:dh,PMT:uh,PPMT:gh,PV:ph,PRICE:mh,PRICEDISC:fh,PRICEMAT:vh,RATE:Sh,RECEIVED:Ch,RRI:Eh,SLN:wh,SYD:yh,TBILLPRICE:xh,TBILLEQ:Ih,TBILLYIELD:Rh,VDB:Th,XIRR:Ah,XNPV:Mh,YIELD:Oh,YIELDDISC:Nh,YIELDMAT:_h});const Dh={description:s("Whether a value is an error other than #N/A."),args:[Zs("value (any, lazy)",s("The value to be verified as an error type."))],returns:["BOOLEAN"],compute:function(e){try{return e(),!1}catch(e){return(null==e?void 0:e.errorType)!=a.NotAvailable}},isExported:!0},kh={description:s("Whether a value is an error."),args:[Zs("value (any, lazy)",s("The value to be verified as an error type."))],returns:["BOOLEAN"],compute:function(e){try{return e(),!1}catch(e){return!0}},isExported:!0},Lh={description:s("Whether a value is `true` or `false`."),args:[Zs("value (any, lazy)",s("The value to be verified as a logical TRUE or FALSE."))],returns:["BOOLEAN"],compute:function(e){try{return"boolean"==typeof e()}catch(e){return!1}},isExported:!0},Ph={description:s("Whether a value is the error #N/A."),args:[Zs("value (any, lazy)",s("The value to be verified as an error type."))],returns:["BOOLEAN"],compute:function(e){try{return e(),!1}catch(e){return(null==e?void 0:e.errorType)==a.NotAvailable}},isExported:!0},Uh={description:s("Whether a value is non-textual."),args:[Zs("value (any, lazy)",s("The value to be checked."))],returns:["BOOLEAN"],compute:function(e){try{return"string"!=typeof e()}catch(e){return!0}},isExported:!0},Vh={description:s("Whether a value is a number."),args:[Zs("value (any, lazy)",s("The value to be verified as a number."))],returns:["BOOLEAN"],compute:function(e){try{return"number"==typeof e()}catch(e){return!1}},isExported:!0},zh={description:s("Whether a value is text."),args:[Zs("value (any, lazy)",s("The value to be verified as text."))],returns:["BOOLEAN"],compute:function(e){try{return"string"==typeof e()}catch(e){return!1}},isExported:!0},Bh={description:s("Whether the referenced cell is empty"),args:[Zs("value (any, lazy)",s("Reference to the cell that will be checked for emptiness."))],returns:["BOOLEAN"],compute:function(e){try{return null===e()}catch(e){return!1}},isExported:!0},Hh={description:s("Returns the error value #N/A."),args:[],returns:["BOOLEAN"],compute:function(e){throw new g},isExported:!0};var $h=Object.freeze({__proto__:null,ISERR:Dh,ISERROR:kh,ISLOGICAL:Lh,ISNA:Ph,ISNONTEXT:Uh,ISNUMBER:Vh,ISTEXT:zh,ISBLANK:Bh,NA:Hh});const Wh={description:s("Logical `and` operator."),args:[Zs("logical_expression1 (boolean, range<boolean>)",s("An expression or reference to a cell containing an expression that represents some logical value, i.e. TRUE or FALSE, or an expression that can be coerced to a logical value.")),Zs("logical_expression2 (boolean, range<boolean>, repeating)",s("More expressions that represent logical values."))],returns:["BOOLEAN"],compute:function(...e){let t=!1,i=!0;return ur(e,(e=>(t=!0,i=i&&e,i))),Ys((()=>t),s("[[FUNCTION_NAME]] has no valid input data.")),i},isExported:!0},Gh={description:s("Returns value depending on logical expression."),args:[Zs("logical_expression (boolean)",s("An expression or reference to a cell containing an expression that represents some logical value, i.e. TRUE or FALSE.")),Zs("value_if_true (any, lazy)",s("The value the function returns if logical_expression is TRUE.")),Zs("value_if_false (any, lazy, default=FALSE)",s("The value the function returns if logical_expression is FALSE."))],returns:["ANY"],compute:function(e,t,i=(()=>!1)){const o=or(e)?t():i();return null==o?"":o},isExported:!0},qh={description:s("Value if it is not an error, otherwise 2nd argument."),args:[Zs("value (any, lazy)",s("The value to return if value itself is not an error.")),Zs('value_if_error (any, lazy, default="empty")',s("The value the function returns if value is an error."))],returns:["ANY"],computeFormat:(e,t=(()=>({value:""})))=>{var i;try{return e().format}catch(e){return null===(i=t())||void 0===i?void 0:i.format}},compute:function(e,t=(()=>"")){let i;try{i=e()}catch(e){i=t()}return null==i?"":i},isExported:!0},Zh={description:s("Value if it is not an #N/A error, otherwise 2nd argument."),args:[Zs("value (any, lazy)",s("The value to return if value itself is not #N/A an error.")),Zs('value_if_error (any, lazy, default="empty")',s("The value the function returns if value is an #N/A error."))],returns:["ANY"],compute:function(e,t=(()=>"")){let i;try{i=e()}catch(o){i=o.errorType===a.NotAvailable?t():e()}return null==i?"":i},isExported:!0},jh={description:s("Returns a value depending on multiple logical expressions."),args:[Zs("condition1 (boolean, lazy)",s("The first condition to be evaluated. This can be a boolean, a number, an array, or a reference to any of those.")),Zs("value1 (any, lazy)",s("The returned value if condition1 is TRUE.")),Zs("condition2 (boolean, lazy, repeating)",s("Additional conditions to be evaluated if the previous ones are FALSE.")),Zs("value2 (any, lazy, repeating)",s("Additional values to be returned if their corresponding conditions are TRUE."))],returns:["ANY"],compute:function(...e){Ys((()=>e.length%2==0),s("Wrong number of arguments. Expected an even number of arguments."));for(let t=0;t<e.length-1;t+=2)if(or(e[t]())){const i=e[t+1]();return null!==i?i:""}throw new Error(s("No match."))},isExported:!0},Xh={description:s("Returns opposite of provided logical value."),args:[Zs("logical_expression (boolean)",s("An expression or reference to a cell holding an expression that represents some logical value."))],returns:["BOOLEAN"],compute:function(e){return!or(e)},isExported:!0},Yh={description:s("Logical `or` operator."),args:[Zs("logical_expression1 (boolean, range<boolean>)",s("An expression or reference to a cell containing an expression that represents some logical value, i.e. TRUE or FALSE, or an expression that can be coerced to a logical value.")),Zs("logical_expression2 (boolean, range<boolean>, repeating)",s("More expressions that evaluate to logical values."))],returns:["BOOLEAN"],compute:function(...e){let t=!1,i=!1;return ur(e,(e=>(t=!0,i=i||e,!i))),Ys((()=>t),s("[[FUNCTION_NAME]] has no valid input data.")),i},isExported:!0},Kh={description:s("Logical `xor` operator."),args:[Zs("logical_expression1 (boolean, range<boolean>)",s("An expression or reference to a cell containing an expression that represents some logical value, i.e. TRUE or FALSE, or an expression that can be coerced to a logical value.")),Zs("logical_expression2 (boolean, range<boolean>, repeating)",s("More expressions that evaluate to logical values."))],returns:["BOOLEAN"],compute:function(...e){let t=!1,i=!1;return ur(e,(e=>(t=!0,i=i?!e:e,!0))),Ys((()=>t),s("[[FUNCTION_NAME]] has no valid input data.")),i},isExported:!0};var Qh=Object.freeze({__proto__:null,AND:Wh,IF:Gh,IFERROR:qh,IFNA:Zh,IFS:jh,NOT:Xh,OR:Yh,XOR:Kh});function Jh(e,t){if(void 0===e)throw new g(s("Did not find value '%s' in [[FUNCTION_NAME]] evaluation.",er(t)))}const ed={description:s("Column number of a specified cell."),args:[Zs("cell_reference (meta, default='this cell')",s("The cell whose column number will be returned. Column A corresponds to 1. By default, the function use the cell in which the formula is entered."))],returns:["NUMBER"],compute:function(e){var t;const i=e||(null===(t=this.__originCellXC)||void 0===t?void 0:t.call(this));Ys((()=>!!i),"In this context, the function [[FUNCTION_NAME]] needs to have a cell or range in parameter.");return _i(i).left+1},isExported:!0},td={description:s("Number of columns in a specified array or range."),args:[Zs("range (meta)",s("The range whose column count will be returned."))],returns:["NUMBER"],compute:function(e){const t=_i(e);return t.right-t.left+1},isExported:!0},id={description:s("Horizontal lookup"),args:[Zs("search_key (any)",s("The value to search for. For example, 42, 'Cats', or I24.")),Zs("range (range)",s("The range to consider for the search. The first row in the range is searched for the key specified in search_key.")),Zs("index (number)",s("The row index of the value to be returned, where the first row in range is numbered 1.")),Zs("is_sorted (boolean, default=true)",s("Indicates whether the row to be searched (the first row of the specified range) is sorted, in which case the closest match for search_key will be returned."))],returns:["ANY"],compute:function(e,t,i,o=true){const n=Math.trunc(Qs(i)),r=tr(e);Ys((()=>1<=n&&n<=t[0].length),s("[[FUNCTION_NAME]] evaluates to an out of bounds range."));let a;a=or(o)?br(t,r,"nextSmaller","asc",t.length,vr):Sr(t,r,"strict",t.length,vr);const l=t[a];return Jh(l,e),l[n-1]},isExported:!0},od={description:s("Look up a value."),args:[Zs("search_key (any)",s("The value to search for. For example, 42, 'Cats', or I24.")),Zs("search_array (range)",s("One method of using this function is to provide a single sorted row or column search_array to look through for the search_key with a second argument result_range. The other way is to combine these two arguments into one search_array where the first row or column is searched and a value is returned from the last row or column in the array. If search_key is not found, a non-exact match may be returned.")),Zs("result_range (range, optional)",s("The range from which to return a result. The value returned corresponds to the location where search_key is found in search_range. This range must be only a single row or column and should not be used if using the search_result_array method."))],returns:["ANY"],compute:function(e,t,i){let o=t.length,n=t[0].length;const r=tr(e),a=n>=o,l=br(t,r,"nextSmaller","asc",a?n:o,a?fr:vr);return Jh(t[0][l],e),void 0===i?a?t[o-1][l]:t[l][n-1]:(o=i.length,n=i[0].length,Ys((()=>1===o||1===n),s("The result_range must be a single row or a single column.")),o>1?(Ys((()=>l<=o-1),s("[[FUNCTION_NAME]] evaluates to an out of range row value %s.",(l+1).toString())),i[l][0]):(Ys((()=>l<=n-1),s("[[FUNCTION_NAME]] evaluates to an out of range column value %s.",(l+1).toString())),i[0][l]))},isExported:!0},nd={description:s("Position of item in range that matches value."),args:[Zs("search_key (any)",s("The value to search for. For example, 42, 'Cats', or I24.")),Zs("range (any, range)",s("The one-dimensional array to be searched.")),Zs("search_type (number, default=1)",s("The search method. 1 (default) finds the largest value less than or equal to search_key when range is sorted in ascending order. 0 finds the exact value when range is unsorted. -1 finds the smallest value greater than or equal to search_key when range is sorted in descending order."))],returns:["NUMBER"],compute:function(e,t,i=1){let o=Qs(i);const n=tr(e),r=t.length,a=t[0].length;Ys((()=>1===r||1===a),s("The range must be a single row or a single column."));let l=-1;const c=1===r?fr:vr,h=1===r?t[0].length:t.length;switch(o=Math.sign(o),o){case 1:l=br(t,n,"nextSmaller","asc",h,c);break;case 0:l=Sr(t,n,"strict",h,c);break;case-1:l=br(t,n,"nextGreater","desc",h,c)}return Jh(1===r?t[0][l]:t[l],e),l+1},isExported:!0},sd={description:s("Row number of a specified cell."),args:[Zs("cell_reference (meta, default='this cell')",s("The cell whose row number will be returned. By default, this function uses the cell in which the formula is entered."))],returns:["NUMBER"],compute:function(e){var t;e=e||(null===(t=this.__originCellXC)||void 0===t?void 0:t.call(this)),Ys((()=>!!e),"In this context, the function [[FUNCTION_NAME]] needs to have a cell or range in parameter.");return _i(e).top+1},isExported:!0},rd={description:s("Number of rows in a specified array or range."),args:[Zs("range (meta)",s("The range whose row count will be returned."))],returns:["NUMBER"],compute:function(e){const t=_i(e);return t.bottom-t.top+1},isExported:!0},ad={description:s("Vertical lookup."),args:[Zs("search_key (any)",s("The value to search for. For example, 42, 'Cats', or I24.")),Zs("range (any, range)",s("The range to consider for the search. The first column in the range is searched for the key specified in search_key.")),Zs("index (number)",s("The column index of the value to be returned, where the first column in range is numbered 1.")),Zs("is_sorted (boolean, default=true)",s("Indicates whether the column to be searched (the first column of the specified range) is sorted, in which case the closest match for search_key will be returned."))],returns:["ANY"],compute:function(e,t,i,o=true){const n=Math.trunc(Qs(i)),r=tr(e);Ys((()=>1<=n&&n<=t.length),s("[[FUNCTION_NAME]] evaluates to an out of bounds range."));let a;a=or(o)?br(t,r,"nextSmaller","asc",t[0].length,fr):Sr(t,r,"strict",t[0].length,fr);const l=t[n-1][a];return Jh(l,e),l},isExported:!0},ld={description:s("Search a range for a match and return the corresponding item from a second range."),args:[Zs("search_key (any)",s("The value to search for.")),Zs("lookup_range (any, range)",s("The range to consider for the search. Should be a single column or a single row.")),Zs("return_range (any, range)",s("The range containing the return value. Should have the same dimensions as lookup_range.")),Zs("if_not_found (any, lazy, optional)",s("If a valid match is not found, return this value.")),Zs("match_mode (any, default=0)",s("(0) Exact match. (-1) Return next smaller item if no match. (1) Return next greater item if no match.")),Zs("search_mode (any, default=1)",s("(1) Search starting at first item. (-1) Search starting at last item. (2) Perform a binary search that relies on lookup_array being sorted in ascending order. If not sorted, invalid results will be returned. (-2) Perform a binary search that relies on lookup_array being sorted in descending order. If not sorted, invalid results will be returned. "))],returns:["ANY"],compute:function(e,t,i,o,n=0,r=1){const a=Math.trunc(Qs(n)),l=Math.trunc(Qs(r)),c=tr(e);Ys((()=>1===t.length||1===t[0].length),s("lookup_range should be either a single row or single column.")),Ys((()=>1===i.length||1===i[0].length),s("return_range should be either a single row or single column.")),Ys((()=>i.length===t.length&&i[0].length===t[0].length),s("return_range should have the same dimensions as lookup_range.")),Ys((()=>[-1,1,-2,2].includes(l)),s("searchMode should be a value in [-1, 1, -2, 2].")),Ys((()=>[-1,0,1].includes(a)),s("matchMode should be a value in [-1, 0, 1]."));const h=1===t.length?fr:vr,d=1===t.length?t[0].length:t.length,u=0===a?"strict":1===a?"nextGreater":"nextSmaller",g=-1===l;let p;if(2===l||-2===l){p=br(t,c,u,2===l?"asc":"desc",d,h)}else p=Sr(t,c,u,d,h,g);if(-1!==p)return 1===t.length?i[0][p]:i[p][0];const m=null==o?void 0:o();return Jh(m,e),m},isExported:!0};var cd=Object.freeze({__proto__:null,COLUMN:ed,COLUMNS:td,HLOOKUP:id,LOOKUP:od,MATCH:nd,ROW:sd,ROWS:rd,VLOOKUP:ad,XLOOKUP:ld});const hd={description:s("Sum of two numbers."),args:[Zs("value1 (number)",s("The first addend.")),Zs("value2 (number)",s("The second addend."))],returns:["NUMBER"],computeFormat:(e,t)=>(null==e?void 0:e.format)||(null==t?void 0:t.format),compute:function(e,t){return Qs(e)+Qs(t)}},dd={description:s("Concatenation of two values."),args:[Zs("value1 (string)",s("The value to which value2 will be appended.")),Zs("value2 (string)",s("The value to append to value1."))],returns:["STRING"],compute:function(e,t){return er(e)+er(t)},isExported:!0},ud={description:s("One number divided by another."),args:[Zs("dividend (number)",s("The number to be divided.")),Zs("divisor (number)",s("The number to divide by."))],returns:["NUMBER"],computeFormat:(e,t)=>(null==e?void 0:e.format)||(null==t?void 0:t.format),compute:function(e,t){const i=Qs(t);return Ys((()=>0!==i),s("The divisor must be different from zero.")),Qs(e)/i}};function gd(e){return null==e}const pd={number:0,string:"",boolean:!1},md={description:s("Equal."),args:[Zs("value1 (any)",s("The first value.")),Zs("value2 (any)",s("The value to test against value1 for equality."))],returns:["BOOLEAN"],compute:function(e,t){return e=gd(e)?pd[typeof t]:e,t=gd(t)?pd[typeof e]:t,"string"==typeof e&&(e=e.toUpperCase()),"string"==typeof t&&(t=t.toUpperCase()),e===t}};function fd(e,t,i){e=gd(e)?pd[typeof t]:e,t=gd(t)?pd[typeof e]:t,"number"!=typeof e&&(e=er(e).toUpperCase()),"number"!=typeof t&&(t=er(t).toUpperCase());const o=typeof e,n=typeof t;return"string"===o&&"number"===n||("string"!==n||"number"!==o)&&i(e,t)}const vd={description:s("Strictly greater than."),args:[Zs("value1 (any)",s("The value to test as being greater than value2.")),Zs("value2 (any)",s("The second value."))],returns:["BOOLEAN"],compute:function(e,t){return fd(e,t,((e,t)=>e>t))}},bd={description:s("Greater than or equal to."),args:[Zs("value1 (any)",s("The value to test as being greater than or equal to value2.")),Zs("value2 (any)",s("The second value."))],returns:["BOOLEAN"],compute:function(e,t){return fd(e,t,((e,t)=>e>=t))}},Sd={description:s("Less than."),args:[Zs("value1 (any)",s("The value to test as being less than value2.")),Zs("value2 (any)",s("The second value."))],returns:["BOOLEAN"],compute:function(e,t){return!bd.compute(e,t)}},Cd={description:s("Less than or equal to."),args:[Zs("value1 (any)",s("The value to test as being less than or equal to value2.")),Zs("value2 (any)",s("The second value."))],returns:["BOOLEAN"],compute:function(e,t){return!vd.compute(e,t)}},Ed={description:s("Difference of two numbers."),args:[Zs("value1 (number)",s("The minuend, or number to be subtracted from.")),Zs("value2 (number)",s("The subtrahend, or number to subtract from value1."))],returns:["NUMBER"],computeFormat:(e,t)=>(null==e?void 0:e.format)||(null==t?void 0:t.format),compute:function(e,t){return Qs(e)-Qs(t)}},wd={description:s("Product of two numbers"),args:[Zs("factor1 (number)",s("The first multiplicand.")),Zs("factor2 (number)",s("The second multiplicand."))],returns:["NUMBER"],computeFormat:(e,t)=>(null==e?void 0:e.format)||(null==t?void 0:t.format),compute:function(e,t){return Qs(e)*Qs(t)}},yd={description:s("Not equal."),args:[Zs("value1 (any)",s("The first value.")),Zs("value2 (any)",s("The value to test against value1 for inequality."))],returns:["BOOLEAN"],compute:function(e,t){return!md.compute(e,t)}},xd={description:s("A number raised to a power."),args:[Zs("base (number)",s("The number to raise to the exponent power.")),Zs("exponent (number)",s("The exponent to raise base to."))],returns:["BOOLEAN"],compute:function(e,t){return aa.compute(e,t)}},Id={description:s("A number with the sign reversed."),args:[Zs("value (number)",s("The number to have its sign reversed. Equivalently, the number to multiply by -1."))],computeFormat:e=>null==e?void 0:e.format,returns:["NUMBER"],compute:function(e){return-Qs(e)}},Rd={description:s("Value interpreted as a percentage."),args:[Zs("percentage (number)",s("The value to interpret as a percentage."))],returns:["NUMBER"],compute:function(e){return Qs(e)/100}},Td={description:s("A specified number, unchanged."),args:[Zs("value (any)",s("The number to return."))],returns:["ANY"],computeFormat:e=>null==e?void 0:e.format,compute:function(e){return null===e?"":e}};var Ad=Object.freeze({__proto__:null,ADD:hd,CONCAT:dd,DIVIDE:ud,EQ:md,GT:vd,GTE:bd,LT:Sd,LTE:Cd,MINUS:Ed,MULTIPLY:wd,NE:yd,POW:xd,UMINUS:Id,UNARY_PERCENT:Rd,UPLUS:Td});const Md=/[A-Za-zÀ-ÖØ-öø-ÿ]+/g,Od={description:s("Gets character associated with number."),args:[Zs("table_number (number)",s("The number of the character to look up from the current Unicode table in decimal format."))],returns:["STRING"],compute:function(e){const t=Math.trunc(Qs(e));return Ys((()=>t>=1),s("The table_number (%s) is out of range.",t.toString())),String.fromCharCode(t)},isExported:!0},Nd={description:s("Remove non-printable characters from a piece of text."),args:[Zs("text (string)",s("The text whose non-printable characters are to be removed."))],returns:["STRING"],compute:function(e){const t=er(e);let i="";for(const e of t)e&&e.charCodeAt(0)>31&&(i+=e);return i},isExported:!0},_d={description:s("Appends strings to one another."),args:[Zs("string1 (string, range<string>)",s("The initial string.")),Zs("string2 (string, range<string>, repeating)",s("More strings to append in sequence."))],returns:["STRING"],compute:function(...e){return cr(e,((e,t)=>e+er(t)),"")},isExported:!0},Fd={description:s("Tests whether two strings are identical."),args:[Zs("string1 (string)",s("The first string to compare.")),Zs("string2 (string)",s("The second string to compare."))],returns:["BOOLEAN"],compute:function(e,t){return er(e)===er(t)},isExported:!0},Dd={description:s("First position of string found in text, case-sensitive."),args:[Zs("search_for (string)",s("The string to look for within text_to_search.")),Zs("text_to_search (string)",s("The text to search for the first occurrence of search_for.")),Zs("starting_at (number, default=1)",s("The character within text_to_search at which to start the search."))],returns:["NUMBER"],compute:function(e,t,i=1){const o=er(e),n=er(t),r=Qs(i);Ys((()=>""!==n),s("The text_to_search must be non-empty.")),Ys((()=>r>=1),s("The starting_at (%s) must be greater than or equal to 1.",r.toString()));const a=n.indexOf(o,r-1);return Ys((()=>a>=0),s("In [[FUNCTION_NAME]] evaluation, cannot find '%s' within '%s'.",o.toString(),n)),a+1},isExported:!0},kd={description:s("Concatenates elements of arrays with delimiter."),args:[Zs("delimiter (string)",s("The character or string to place between each concatenated value.")),Zs("value_or_array1 (string, range<string>)",s("The value or values to be appended using delimiter.")),Zs("value_or_array2 (string, range<string>, repeating)",s("More values to be appended using delimiter."))],returns:["STRING"],compute:function(e,...t){const i=er(e);return cr(t,((e,t)=>(e?e+i:"")+er(t)),"")}},Ld={description:s("Substring from beginning of specified string."),args:[Zs("text (string)",s("The string from which the left portion will be returned.")),Zs("number_of_characters (number, optional)",s("The number of characters to return from the left side of string."))],returns:["STRING"],compute:function(e,...t){const i=t.length?Qs(t[0]):1;return Ys((()=>i>=0),s("The number_of_characters (%s) must be positive or null.",i.toString())),er(e).substring(0,i)},isExported:!0},Pd={description:s("Length of a string."),args:[Zs("text (string)",s("The string whose length will be returned."))],returns:["NUMBER"],compute:function(e){return er(e).length},isExported:!0},Ud={description:s("Converts a specified string to lowercase."),args:[Zs("text (string)",s("The string to convert to lowercase."))],returns:["STRING"],compute:function(e){return er(e).toLowerCase()},isExported:!0},Vd={description:s("A segment of a string."),args:[Zs("text (string)",s("The string to extract a segment from.")),Zs(" (number)",s("The index from the left of string from which to begin extracting. The first character in string has the index 1.")),Zs(" (number)",s("The length of the segment to extract."))],returns:["STRING"],compute:function(e,t,i){const o=er(e),n=Qs(t),r=Qs(i);return Ys((()=>n>=1),s("The starting_at argument (%s) must be positive greater than one.",n.toString())),Ys((()=>r>=0),s("The extract_length argument (%s) must be positive or null.",r.toString())),o.slice(n-1,n+r-1)},isExported:!0},zd={description:s("Capitalizes each word in a specified string."),args:[Zs("text_to_capitalize (string)",s("The text which will be returned with the first letter of each word in uppercase and all other letters in lowercase."))],returns:["STRING"],compute:function(e){return er(e).replace(Md,(e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()))},isExported:!0},Bd={description:s("Replaces part of a text string with different text."),args:[Zs("text (string)",s("The text, a part of which will be replaced.")),Zs("position (number)",s("The position where the replacement will begin (starting from 1).")),Zs("length (number)",s("The number of characters in the text to be replaced.")),Zs("new_text (string)",s("The text which will be inserted into the original text."))],returns:["STRING"],compute:function(e,t,i,o){const n=Qs(t);Ys((()=>n>=1),s("The position (%s) must be greater than or equal to 1.",n.toString()));const r=er(e),a=Qs(i),l=er(o);return r.substring(0,n-1)+l+r.substring(n-1+a)},isExported:!0},Hd={description:s("A substring from the end of a specified string."),args:[Zs("text (string)",s("The string from which the right portion will be returned.")),Zs("number_of_characters (number, optional)",s("The number of characters to return from the right side of string."))],returns:["STRING"],compute:function(e,...t){const i=t.length?Qs(t[0]):1;Ys((()=>i>=0),s("The number_of_characters (%s) must be positive or null.",i.toString()));const o=er(e),n=o.length;return o.substring(n-i,n)},isExported:!0},$d={description:s("First position of string found in text, ignoring case."),args:[Zs("search_for (string)",s("The string to look for within text_to_search.")),Zs("text_to_search (string)",s("The text to search for the first occurrence of search_for.")),Zs("starting_at (number, default=1)",s("The character within text_to_search at which to start the search."))],returns:["NUMBER"],compute:function(e,t,i=1){const o=er(e).toLowerCase(),n=er(t).toLowerCase(),r=Qs(i);Ys((()=>""!==n),s("The text_to_search must be non-empty.")),Ys((()=>r>=1),s("The starting_at (%s) must be greater than or equal to 1.",r.toString()));const a=n.indexOf(o,r-1);return Ys((()=>a>=0),s("In [[FUNCTION_NAME]] evaluation, cannot find '%s' within '%s'.",o,n)),a+1},isExported:!0},Wd={description:s("Replaces existing text with new text in a string."),args:[Zs("text_to_search (string)",s("The text within which to search and replace.")),Zs("search_for (string)",s("The string to search for within text_to_search.")),Zs("replace_with (string)",s("The string that will replace search_for.")),Zs("occurrence_number (number, optional)",s("The instance of search_for within text_to_search to replace with replace_with. By default, all occurrences of search_for are replaced; however, if occurrence_number is specified, only the indicated instance of search_for is replaced."))],returns:["NUMBER"],compute:function(e,t,i,o){const n=Qs(o);Ys((()=>n>=0),s("The occurrenceNumber (%s) must be positive or null.",n.toString()));const r=er(e),a=er(t);if(""===a)return r;const l=er(i),c=new RegExp(Oe(a),"g");if(0===n)return r.replace(c,l);let h=0;return r.replace(c,(e=>++h===n?l:e))},isExported:!0},Gd={description:s("Combines text from multiple strings and/or arrays."),args:[Zs("delimiter (string)",s(" A string, possible empty, or a reference to a valid string. If empty, the text will be simply concatenated.")),Zs("ignore_empty (boolean)",s("A boolean; if TRUE, empty cells selected in the text arguments won't be included in the result.")),Zs("text1 (string, range<string>)",s("Any text item. This could be a string, or an array of strings in a range.")),Zs("text2 (string, range<string>, repeating)",s("Additional text item(s)."))],returns:["STRING"],compute:function(e,t,...i){const o=er(e),n=or(t);let s=0;return cr(i,((e,t)=>n&&""===er(t)?e:(s++?e+o:"")+er(t)),"")},isExported:!0},qd={description:s("Removes space characters."),args:[Zs("text (string)",s("The text or reference to a cell containing text to be trimmed."))],returns:["STRING"],compute:function(e){return er(e).trim()},isExported:!0},Zd={description:s("Converts a specified string to uppercase."),args:[Zs("text (string)",s("The string to convert to uppercase."))],returns:["STRING"],compute:function(e){return er(e).toUpperCase()},isExported:!0},jd={description:s("Converts a number to text according to a specified format."),args:[Zs("number (number)",s("The number, date or time to format.")),Zs("format (string)",s("The pattern by which to format the number, enclosed in quotation marks."))],returns:["STRING"],compute:function(e,t){return li(Qs(e),er(t))},isExported:!0};var Xd=Object.freeze({__proto__:null,CHAR:Od,CLEAN:Nd,CONCATENATE:_d,EXACT:Fd,FIND:Dd,JOIN:kd,LEFT:Ld,LEN:Pd,LOWER:Ud,MID:Vd,PROPER:zd,REPLACE:Bd,RIGHT:Hd,SEARCH:$d,SUBSTITUTE:Wd,TEXTJOIN:Gd,TRIM:qd,UPPER:Zd,TEXT:jd});const Yd={description:s("Creates a hyperlink in a cell."),args:[Zs("url (string)",s("The full URL of the link enclosed in quotation marks.")),Zs("link_label (string, optional)",s("The text to display in the cell, enclosed in quotation marks."))],returns:["STRING"],compute:function(e,t){const i=er(e).trim(),o=er(t)||i;return""===i?o:je(o,i)},isExported:!0};var Kd=Object.freeze({__proto__:null,HYPERLINK:Yd});const Qd=[{name:s("Database"),functions:Ol},{name:s("Date"),functions:cc},{name:s("Financial"),functions:Fh},{name:s("Info"),functions:$h},{name:s("Lookup"),functions:cd},{name:s("Logical"),functions:Qh},{name:s("Math"),functions:Ia},{name:s("Misc"),functions:wr},{name:s("Operator"),functions:Ad},{name:s("Statistical"),functions:ml},{name:s("Text"),functions:Xd},{name:s("Engineering"),functions:dc},{name:s("Web"),functions:Kd}],Jd=/^[A-Z0-9\_\.]+$/;function eu(e){return e.map((e=>{if(void 0!==e)return"function"==typeof e?()=>tu(e()):tu(e)}))}function tu(e){return Array.isArray(e)?e.map((e=>e.map((e=>null==e?void 0:e.value)))):null==e?void 0:e.value}const iu=new class extends Mn{constructor(){super(...arguments),this.mapping={}}add(e,t){if(!(e=e.toUpperCase()).match(Jd))throw new Error(s("Invalid function name %s. Function names can exclusively contain alphanumerical values separated by dots (.) or underscore (_)",e));const i=js(t);return function(e){let t=!1,i=!1,o=!1;for(let n of e){if(n.type.includes("META")&&n.type.length>1)throw new Error(s("Function ${name} has an argument that has been declared with more than one type whose type 'META'. The 'META' type can only be declared alone."));if(t&&!n.repeating)throw new Error(s("Function ${name} has no-repeatable arguments declared after repeatable ones. All repeatable arguments must be declared last."));const e=i||t||o,r=!(n.optional||n.repeating||n.default);if(e&&r)throw new Error(s("Function ${name} has at mandatory arguments declared after optional ones. All optional arguments must be after all mandatory arguments."));t=n.repeating,i=n.optional,o=n.default}}(i.args),this.mapping[e]=function(...e){const t=i.compute.bind(this),o=i.computeFormat?i.computeFormat.bind(this):()=>{};return{value:t(...eu(e)),format:o(...e)}},super.add(e,i),this}};for(let e of Qd){const t=e.functions;for(let i in t){const o=t[i];o.category=o.category||e.name,i=i.replace(/_/g,"."),iu.add(i,{isExported:!1,...o})}}const ou={ArrowDown:"down",ArrowLeft:"left",ArrowRight:"right",ArrowUp:"up"};function nu(e,t){const i=ou[e.key];e.shiftKey?t.resizeAnchorZone(i,e.ctrlKey?"end":1):t.moveAnchorCell(i,e.ctrlKey?"end":1)}ro`
|
|
158
|
-
.o-autocomplete-dropdown {
|
|
159
|
-
pointer-events: auto;
|
|
160
|
-
background-color: #fff;
|
|
161
|
-
& > div:hover {
|
|
162
|
-
background-color: #f2f2f2;
|
|
163
|
-
}
|
|
164
|
-
.o-autocomplete-value-focus {
|
|
165
|
-
background-color: rgba(0, 0, 0, 0.08);
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
& > div {
|
|
169
|
-
padding: 1px 0 5px 5px;
|
|
170
|
-
.o-autocomplete-description {
|
|
171
|
-
padding-left: 5px;
|
|
172
|
-
font-size: 11px;
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
`;class su extends t.Component{}su.template="o-spreadsheet-TextValueProvider",su.props={values:Array,selectedIndex:Number,onValueSelected:Function};class ru{constructor(e){this.el=e}updateEl(e){this.el=e}selectRange(e,t){let i=window.getSelection();this.removeSelection();let o=document.createRange();if(e==t&&0===e)o.setStart(this.el,0),o.setEnd(this.el,0),i.addRange(o);else{const n=this.getText().length;(e<0||t>n)&&(console.warn(`wrong selection asked start ${e}, end ${t}, text content length ${n}`),e<0&&(e=0),t>n&&(t=n));let s=this.findChildAtCharacterIndex(e),r=this.findChildAtCharacterIndex(t);o.setStart(s.node,s.offset),i.addRange(o),i.extend(r.node,r.offset)}}findChildAtCharacterIndex(e){let t,i,o=Bn(this.el),n=e,s=!0;do{t=o.next(),t.done||t.value.hasChildNodes()||(t.value.textContent&&t.value.textContent.length<n?n-=t.value.textContent.length:t.value.textContent&&t.value.textContent.length>=n&&o.return(t.value),i=t.value),t.done||"P"!==t.value.nodeName||(s?s=!1:n--)}while(!t.done&&n);return t.value?{node:t.value,offset:n}:{node:i,offset:n}}setText(e){if(this.el.innerHTML="",0!==e.length)for(const t of e){const e=document.createElement("p");if(0===t.length||t.every((e=>!e.value&&!e.class)))e.appendChild(document.createElement("br")),this.el.appendChild(e);else{for(const i of t){if(!i.value&&!i.class)continue;const t=document.createElement("span");t.innerText=i.value,t.style.color=i.color||"",i.class&&t.classList.add(i.class),e.appendChild(t)}this.el.appendChild(e)}}}scrollSelectionIntoView(){var e;const t=null===(e=document.getSelection())||void 0===e?void 0:e.focusNode;if(!t||!this.el.contains(t))return;const i=t instanceof HTMLElement?t:t.parentElement;null==i||i.scrollIntoView({block:"nearest"})}removeSelection(){window.getSelection().removeAllRanges()}removeAll(){if(this.el)for(;this.el.firstChild;)this.el.removeChild(this.el.firstChild)}getCurrentSelection(){let{startElement:e,endElement:t,startSelectionOffset:i,endSelectionOffset:o}=this.getStartAndEndSelection();return{start:this.findSizeBeforeElement(e)+i,end:this.findSizeBeforeElement(t)+o}}findSizeBeforeElement(e){let t=0,i=Bn(this.el),o=i.next(),n=!0;for(;!o.done&&o.value!==e;)o.value.hasChildNodes()||o.value.textContent&&(t+=o.value.textContent.length),("P"===o.value.nodeName||"DIV"===o.value.nodeName&&o.value!==this.el)&&(n?n=!1:t++),o=i.next();if(o.value!==e)throw new Error("Cannot find the node in the children of the element");return"P"!==e.nodeName||n||""!=e.textContent||t++,t}getStartAndEndSelection(){const e=document.getSelection();return{startElement:e.anchorNode||this.el,startSelectionOffset:e.anchorOffset,endElement:e.focusNode||this.el,endSelectionOffset:e.focusOffset}}getText(){let e="",t=Bn(this.el),i=t.next(),o=!0;for(;!i.done;)i.value.hasChildNodes()||(e+=i.value.textContent),("P"===i.value.nodeName||"DIV"===i.value.nodeName&&i.value!==this.el)&&(o?o=!1:e+=ce),i=t.next();return e}}ro`
|
|
177
|
-
.o-formula-assistant {
|
|
178
|
-
.o-formula-assistant-head {
|
|
179
|
-
background-color: #f2f2f2;
|
|
180
|
-
padding: 10px;
|
|
181
|
-
}
|
|
182
|
-
.o-formula-assistant-core {
|
|
183
|
-
border-bottom: 1px solid gray;
|
|
184
|
-
}
|
|
185
|
-
.o-formula-assistant-arg-description {
|
|
186
|
-
font-size: 85%;
|
|
187
|
-
}
|
|
188
|
-
.o-formula-assistant-focus {
|
|
189
|
-
div:first-child,
|
|
190
|
-
span {
|
|
191
|
-
color: purple;
|
|
192
|
-
text-shadow: 0px 0px 1px purple;
|
|
193
|
-
}
|
|
194
|
-
div:last-child {
|
|
195
|
-
color: black;
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
.o-formula-assistant-gray {
|
|
199
|
-
color: gray;
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
`;class au extends t.Component{constructor(){super(...arguments),this.assistantState=t.useState({allowCellSelectionBehind:!1}),this.timeOutId=0}setup(){t.onWillUnmount((()=>{this.timeOutId&&clearTimeout(this.timeOutId)}))}getContext(){return this.props}onMouseMove(){this.assistantState.allowCellSelectionBehind=!0,this.timeOutId&&clearTimeout(this.timeOutId),this.timeOutId=setTimeout((()=>{this.assistantState.allowCellSelectionBehind=!1}),2e3)}}au.template="o-spreadsheet-FunctionDescriptionProvider",au.props={functionName:String,functionDescription:Object,argToFocus:Number};const lu=iu.content,cu="selector-flag",hu="#4a4e4d",du="#3da4ab",uu={OPERATOR:du,NUMBER:"#02c39a",STRING:"#00a82d",FUNCTION:hu,DEBUGGER:du,LEFT_PAREN:hu,RIGHT_PAREN:hu,COMMA:hu,MATCHING_PAREN:"#000000"};ro`
|
|
203
|
-
.o-composer-container {
|
|
204
|
-
.o-composer {
|
|
205
|
-
overflow-y: auto;
|
|
206
|
-
overflow-x: hidden;
|
|
207
|
-
word-break: break-all;
|
|
208
|
-
padding-right: 2px;
|
|
209
|
-
|
|
210
|
-
box-sizing: border-box;
|
|
211
|
-
|
|
212
|
-
caret-color: black;
|
|
213
|
-
padding-left: 3px;
|
|
214
|
-
padding-right: 3px;
|
|
215
|
-
outline: none;
|
|
216
|
-
|
|
217
|
-
&.unfocusable {
|
|
218
|
-
pointer-events: none;
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
p {
|
|
222
|
-
margin-bottom: 0px;
|
|
223
|
-
|
|
224
|
-
span {
|
|
225
|
-
white-space: pre-wrap;
|
|
226
|
-
&.${cu}:after {
|
|
227
|
-
content: "${"␣"}";
|
|
228
|
-
color: ${"#a9a9a9"};
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
.o-composer-assistant {
|
|
235
|
-
position: absolute;
|
|
236
|
-
margin: 1px 4px;
|
|
237
|
-
pointer-events: none;
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
`;class gu extends t.Component{constructor(){super(...arguments),this.composerRef=t.useRef("o_composer"),this.contentHelper=new ru(this.composerRef.el),this.composerState=t.useState({positionStart:0,positionEnd:0}),this.autoCompleteState=t.useState({showProvider:!1,values:[],selectedIndex:0}),this.functionDescriptionState=t.useState({showDescription:!1,functionName:"",functionDescription:{},argToFocus:0}),this.isKeyStillDown=!1,this.compositionActive=!1,this.shouldProcessInputEvents=!1,this.tokens=[],this.keyMapping={ArrowUp:this.processArrowKeys,ArrowDown:this.processArrowKeys,ArrowLeft:this.processArrowKeys,ArrowRight:this.processArrowKeys,Enter:this.processEnterKey,Escape:this.processEscapeKey,F2:()=>console.warn("Not implemented"),F4:this.processF4Key,Tab:e=>this.processTabKey(e)}}get assistantStyle(){if(this.props.delimitation&&this.props.rect){const{x:e,y:t,height:i}=this.props.rect;let o={};return t>this.props.delimitation.height-(t+i)&&(o.top="-3px",o.transform="translate(0, -100%)"),e+300>this.props.delimitation.width&&(o.right="0px"),o.width="300px",ho(o)}return ho({width:"300px"})}setup(){t.onMounted((()=>{const e=this.composerRef.el;this.contentHelper.updateEl(e),this.processContent(),this.contentHelper.scrollSelectionIntoView()})),t.onWillUnmount((()=>{var e,t;null===(t=(e=this.props).onComposerUnmounted)||void 0===t||t.call(e)})),t.onPatched((()=>{this.isKeyStillDown||this.processContent()}))}processArrowKeys(e){if(this.env.model.getters.isSelectingForComposer())return this.functionDescriptionState.showDescription=!1,e.preventDefault(),e.stopPropagation(),void nu(e,this.env.model.selection);const t=this.env.model.getters.getCurrentContent();"cellFocus"!==this.props.focus||this.autoCompleteState.showProvider||t.startsWith("=")?(e.stopPropagation(),this.handleArrowKeysForAutocomplete(e)):this.env.model.dispatch("STOP_EDITION")}handleArrowKeysForAutocomplete(e){["ArrowUp","ArrowDown"].includes(e.key)&&this.autoCompleteState.showProvider&&(e.preventDefault(),"ArrowUp"===e.key?(this.autoCompleteState.selectedIndex--,this.autoCompleteState.selectedIndex<0&&(this.autoCompleteState.selectedIndex=this.autoCompleteState.values.length-1)):this.autoCompleteState.selectedIndex=(this.autoCompleteState.selectedIndex+1)%this.autoCompleteState.values.length)}processTabKey(e){var t;if(e.preventDefault(),e.stopPropagation(),this.autoCompleteState.showProvider){const e=null===(t=this.autoCompleteState.values[this.autoCompleteState.selectedIndex])||void 0===t?void 0:t.text;if(e)return void this.autoComplete(e)}else this.env.model.dispatch("STOP_COMPOSER_RANGE_SELECTION");const i=e.shiftKey?"left":"right";this.env.model.dispatch("STOP_EDITION"),this.env.model.selection.moveAnchorCell(i,1)}processEnterKey(e){var t;if(e.preventDefault(),e.stopPropagation(),e.altKey||e.ctrlKey){const e=this.contentHelper.getCurrentSelection(),t=this.env.model.getters.getCurrentContent(),i=t.slice(0,e.start)+ce+t.slice(e.end);return this.env.model.dispatch("SET_CURRENT_CONTENT",{content:i,selection:{start:e.start+1,end:e.start+1}}),this.processContent(),void this.contentHelper.scrollSelectionIntoView()}if(this.isKeyStillDown=!1,this.autoCompleteState.showProvider){const e=null===(t=this.autoCompleteState.values[this.autoCompleteState.selectedIndex])||void 0===t?void 0:t.text;if(e)return void this.autoComplete(e)}this.env.model.dispatch("STOP_EDITION");const i=e.shiftKey?"up":"down";this.env.model.selection.moveAnchorCell(i,1)}processEscapeKey(){this.env.model.dispatch("STOP_EDITION",{cancel:!0})}processF4Key(){this.env.model.dispatch("CYCLE_EDITION_REFERENCES"),this.processContent()}onCompositionStart(){this.compositionActive=!0}onCompositionEnd(){this.compositionActive=!1}onKeydown(e){let t=this.keyMapping[e.key];t?t.call(this,e):e.stopPropagation();const{start:i,end:o}=this.contentHelper.getCurrentSelection();this.env.model.getters.isSelectingForComposer()||"Enter"===e.key&&(e.altKey||e.ctrlKey)||(this.env.model.dispatch("CHANGE_COMPOSER_CURSOR_SELECTION",{start:i,end:o}),this.isKeyStillDown=!0)}onInput(){"inactive"!==this.props.focus&&this.shouldProcessInputEvents&&(this.env.model.dispatch("STOP_COMPOSER_RANGE_SELECTION"),this.env.model.dispatch("SET_CURRENT_CONTENT",{content:this.contentHelper.getText(),selection:this.contentHelper.getCurrentSelection()}))}onKeyup(e){if(this.isKeyStillDown=!1,"inactive"===this.props.focus||["Control","Alt","Shift","Tab","Enter","F4"].includes(e.key))return;if(this.autoCompleteState.showProvider&&["ArrowUp","ArrowDown"].includes(e.key))return;if(this.env.model.getters.isSelectingForComposer()&&["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"].includes(e.key))return;if(e.preventDefault(),e.stopPropagation(),this.autoCompleteState.showProvider=!1,e.ctrlKey&&" "===e.key)return this.showAutocomplete(""),void this.env.model.dispatch("STOP_COMPOSER_RANGE_SELECTION");const{start:t,end:i}=this.env.model.getters.getComposerSelection(),{start:o,end:n}=this.contentHelper.getCurrentSelection();o===t&&n===i||this.env.model.dispatch("CHANGE_COMPOSER_CURSOR_SELECTION",this.contentHelper.getCurrentSelection()),this.processTokenAtCursor(),this.processContent()}showAutocomplete(e){this.autoCompleteState.showProvider=!0;let t=Object.entries(iu.content).filter((([e,{hidden:t}])=>!t)).map((([e,{description:t}])=>({text:e,description:t})));t=e?Ai(e,t,(e=>e.text)):t.sort(((e,t)=>e.text.localeCompare(t.text))),this.autoCompleteState.values=t.slice(0,10),this.autoCompleteState.selectedIndex=0}onMousedown(e){e.button>0||this.contentHelper.removeSelection()}onClick(){if(this.env.model.getters.isReadonly())return;const e=this.contentHelper.getCurrentSelection();this.env.model.dispatch("STOP_COMPOSER_RANGE_SELECTION"),"inactive"===this.props.focus&&this.props.onComposerContentFocused(e),this.env.model.dispatch("CHANGE_COMPOSER_CURSOR_SELECTION",e),this.processTokenAtCursor()}onBlur(){this.isKeyStillDown=!1}processContent(){if(this.compositionActive)return;const e=(null==(t=this.composerRef.el)?void 0:t.scrollTop)||0;var t;this.contentHelper.removeAll(),this.shouldProcessInputEvents=!1,"inactive"!==this.props.focus&&(this.contentHelper.el.focus(),this.contentHelper.selectRange(0,0));const i=this.getContentLines();if(0!==i.length&&0!==i.length[0]){this.contentHelper.setText(i);const{start:t,end:o}=this.env.model.getters.getComposerSelection();"inactive"!==this.props.focus&&this.contentHelper.selectRange(t,o),function(e,t){e&&(e.scrollTop=t)}(this.composerRef.el,e)}this.shouldProcessInputEvents=!0}getContentLines(){let e=this.env.model.getters.getCurrentContent();const t=e.startsWith("=")&&this.env.model.getters.getCurrentTokens().length>0;return""===e?[]:t&&"inactive"!==this.props.focus?this.splitHtmlContentIntoLines(this.getColoredTokens()):this.splitHtmlContentIntoLines([{value:e}])}getColoredTokens(){const e=this.env.model.getters.getCurrentTokens(),t=this.env.model.getters.getTokenAtCursor(),i=[],{end:o,start:n}=this.env.model.getters.getComposerSelection();for(const s of e){switch(s.type){case"OPERATOR":case"NUMBER":case"FUNCTION":case"COMMA":case"STRING":i.push({value:s.value,color:uu[s.type]||"#000"});break;case"REFERENCE":const{xc:e,sheetName:o}=kt(s.value);i.push({value:s.value,color:this.rangeColor(e,o)||"#000"});break;case"SYMBOL":let n=s.value;["TRUE","FALSE"].includes(n.toUpperCase())?i.push({value:s.value,color:uu.NUMBER}):i.push({value:s.value,color:"#000"});break;case"LEFT_PAREN":case"RIGHT_PAREN":t&&["LEFT_PAREN","RIGHT_PAREN"].includes(t.type)&&t.parenIndex&&t.parenIndex===s.parenIndex?i.push({value:s.value,color:uu.MATCHING_PAREN}):i.push({value:s.value,color:uu[s.type]||"#000"});break;default:i.push({value:s.value,color:"#000"})}this.env.model.getters.showSelectionIndicator()&&o===n&&o===s.end&&(i[i.length-1].class=cu)}return i}splitHtmlContentIntoLines(e){const t=[];let i=[];for(const o of e)if(o.value.includes(ce)){const e=o.value.split(ce),n=e.pop();for(const n of e)i.push({color:o.color,value:n}),t.push(i),i=[];i.push({...o,value:n})}else i.push(o);i.length&&t.push(i);const o=[];for(const e of t)e.every(this.isContentEmpty)?o.push([e[0]]):o.push(e.filter((e=>!this.isContentEmpty(e))));return o}isContentEmpty(e){return!(e.value||e.class)}rangeColor(e,t){if("inactive"===this.props.focus)return;const i=this.env.model.getters.getHighlights(),o=t?this.env.model.getters.getSheetIdByName(t):this.env.model.getters.getEditionSheet(),n=i.find((t=>{if(t.sheetId!==o)return!1;let i=this.env.model.getters.getRangeFromSheetXC(o,e).zone;const{height:n,width:s}=Zi(i);return i=n*s==1?this.env.model.getters.expandZone(o,i):i,Bi(i,t.zone)}));return n&&n.color?n.color:void 0}processTokenAtCursor(){let e=this.env.model.getters.getCurrentContent();if(this.autoCompleteState.showProvider=!1,this.functionDescriptionState.showDescription=!1,e.startsWith("=")){const e=this.env.model.getters.getTokenAtCursor();if(e){const{xc:t}=kt(e.value);if("FUNCTION"===e.type||"SYMBOL"===e.type&&!Ot.test(t))this.showAutocomplete(e.value);else if(e.functionContext&&"UNKNOWN"!==e.type){const t=e.functionContext,i=t.parent.toUpperCase(),o=lu[i],n=t.argPosition;this.functionDescriptionState.functionName=i,this.functionDescriptionState.functionDescription=o,this.functionDescriptionState.argToFocus=o.getArgToFocus(n+1)-1,this.functionDescriptionState.showDescription=!0}}}}autoComplete(e){if(e){const t=this.env.model.getters.getTokenAtCursor();if(t){let i=t.end,o=t.end;["SYMBOL","FUNCTION"].includes(t.type)&&(i=t.start);const n=this.env.model.getters.getCurrentTokens();if(n.length){e+="(";const i=n.map((e=>e.start)).indexOf(t.start);if(i+1<n.length){"LEFT_PAREN"===n[i+1].type&&o++}}this.env.model.dispatch("CHANGE_COMPOSER_CURSOR_SELECTION",{start:i,end:o})}this.env.model.dispatch("REPLACE_COMPOSER_CURSOR_SELECTION",{text:e})}this.processTokenAtCursor()}}gu.template="o-spreadsheet-Composer",gu.components={TextValueProvider:su,FunctionDescriptionProvider:au},gu.defaultProps={inputStyle:""},gu.props={focus:{validate:e=>["inactive","cellFocus","contentFocus"].includes(e)},onComposerContentFocused:Function,inputStyle:{type:String,optional:!0},rect:{type:Object,optional:!0},delimitation:{type:Object,optional:!0},onComposerUnmounted:{type:Function,optional:!0}};const pu=3*.4*window.devicePixelRatio||1;ro`
|
|
241
|
-
div.o-grid-composer {
|
|
242
|
-
z-index: ${le.GridComposer};
|
|
243
|
-
box-sizing: border-box;
|
|
244
|
-
position: absolute;
|
|
245
|
-
border: ${pu}px solid ${E};
|
|
246
|
-
|
|
247
|
-
display: flex;
|
|
248
|
-
align-items: center;
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
div.o-cell-reference {
|
|
252
|
-
position: absolute;
|
|
253
|
-
z-index: ${le.GridComposer};
|
|
254
|
-
background: ${E};
|
|
255
|
-
color: white;
|
|
256
|
-
font-size: 12px;
|
|
257
|
-
line-height: 14px;
|
|
258
|
-
padding: 6px 7px;
|
|
259
|
-
border-radius: 4px;
|
|
260
|
-
}
|
|
261
|
-
`;class mu extends t.Component{setup(){this.gridComposerRef=t.useRef("gridComposer"),this.composerState=t.useState({rect:void 0,delimitation:void 0});const{sheetId:e,col:i,row:o}=this.env.model.getters.getActivePosition();this.zone=this.env.model.getters.expandZone(e,Ji({col:i,row:o})),this.rect=this.env.model.getters.getVisibleRect(this.zone),this.isCellReferenceVisible=!1,t.onMounted((()=>{const e=this.gridComposerRef.el;this.composerState.rect={x:this.rect.x,y:this.rect.y,width:e.clientWidth,height:e.clientHeight},this.composerState.delimitation={width:e.parentElement.clientWidth,height:e.parentElement.clientHeight}})),t.onWillUpdateProps((()=>{if(this.isCellReferenceVisible)return;const e=this.env.model.getters.getActiveSheetId(),t=this.env.model.getters.getSelectedZone();at(this.env.model.getters.getVisibleRect(t),this.rect)&&e===this.env.model.getters.getCurrentEditedCell().sheetId||(this.isCellReferenceVisible=!0)}))}get shouldDisplayCellReference(){return this.isCellReferenceVisible}get cellReference(){const{col:e,row:t,sheetId:i}=this.env.model.getters.getCurrentEditedCell();return`${i!==this.env.model.getters.getActiveSheetId()?Fe(this.env.model.getters.getSheetName(i))+"!":""}${Vt(e,t)}`}get cellReferenceStyle(){const{x:e,y:t}=this.rect;return ho({left:e-pu+"px",top:t-28+"px"})}get containerStyle(){const e=this.env.model.getters.getCurrentContent().startsWith("="),t=this.env.model.getters.getActiveCell(),i=this.env.model.getters.getActivePosition(),o=this.env.model.getters.getCellComputedStyle(i),{x:n,y:s,width:r,height:a}=this.rect,l=!e&&o.fillColor||"#ffffff",c=!e&&o.textColor||"#000000",h=!e&&o.fontSize||10,d=!e&&o.bold?"bold":void 0,u=!e&&o.italic?"italic":"normal",g=e?"none":ao(o);let p="left";return e||(p=o.align||t.defaultAlign),ho({left:n-1+"px",top:`${s}px`,"min-width":`${r+1}px`,"min-height":`${a+1}px`,background:l,color:c,"font-size":`${Pe(h)}px`,"font-weight":d,"font-style":u,"text-decoration":g,"text-align":p})}get composerStyle(){const e=this.props.gridDims.height-this.rect.y;return ho({"max-width":`${this.props.gridDims.width-this.rect.x}px`,"max-height":`${e}px`})}}mu.template="o-spreadsheet-GridComposer",mu.components={Composer:gu},mu.props={focus:{validate:e=>["inactive","cellFocus","contentFocus"].includes(e)},onComposerUnmounted:Function,onComposerContentFocused:Function,gridDims:Object};const fu=ro`
|
|
262
|
-
.o-filter-icon {
|
|
263
|
-
color: ${I};
|
|
264
|
-
position: absolute;
|
|
265
|
-
display: flex;
|
|
266
|
-
align-items: center;
|
|
267
|
-
justify-content: center;
|
|
268
|
-
width: ${B}px;
|
|
269
|
-
height: ${B}px;
|
|
270
|
-
|
|
271
|
-
svg {
|
|
272
|
-
path {
|
|
273
|
-
fill: ${I};
|
|
274
|
-
}
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
|
-
.o-filter-icon:hover {
|
|
278
|
-
background: ${I};
|
|
279
|
-
svg {
|
|
280
|
-
path {
|
|
281
|
-
fill: white;
|
|
282
|
-
}
|
|
283
|
-
}
|
|
284
|
-
}
|
|
285
|
-
`;class vu extends t.Component{get style(){const{x:e,y:t}=this.props.position;return`top:${t}px;left:${e}px`}}vu.style=fu,vu.template="o-spreadsheet-FilterIcon",vu.props={position:Object,isActive:Boolean,onClick:Function};const bu=ro``;class Su extends t.Component{getVisibleFilterHeaders(){const e=this.env.model.getters.getActiveSheetId();return this.env.model.getters.getFilterHeaders(e).filter((e=>this.isPositionVisible(e.col,e.row)))}getFilterHeaderPosition(e){const t=this.env.model.getters.getActiveSheetId(),i=this.env.model.getters.getRowDimensionsInViewport(t,e.row),o=this.env.model.getters.getColDimensionsInViewport(t,e.col),n=Math.floor((i.size-B)/2);return{x:o.end-B+this.props.gridPosition.x-2-1,y:i.end-B+this.props.gridPosition.y-n}}isFilterActive(e){const t=this.env.model.getters.getActiveSheetId();return this.env.model.getters.isFilterActive({sheetId:t,...e})}toggleFilterMenu(e){const t=this.env.model.getters.getPersistentPopoverTypeAtPosition(e);if(t&&"FilterMenu"===t)return void this.env.model.dispatch("CLOSE_CELL_POPOVER");const{col:i,row:o}=e;this.env.model.dispatch("OPEN_CELL_POPOVER",{col:i,row:o,popoverType:"FilterMenu"})}isPositionVisible(e,t){const i=this.env.model.getters.getVisibleRect({left:e,right:e,top:t,bottom:t});return!(0===i.width||0===i.height)}}function Cu(e){return/^https?:\/\//i.test(e)?e:`https://${e}`}Su.style=bu,Su.template="o-spreadsheet-FilterIconsOverlay",Su.components={FilterIcon:vu},Su.defaultProps={gridPosition:{x:0,y:0}},Su.props={gridPosition:{type:Object,optional:!0}};const Eu=new Mn;function wu(e,t){return{url:e=Cu(e),label:t||e,isExternal:!0,isUrlEditable:!0}}Eu.add("sheet_URL",{match:e=>Ke(e),createLink:(e,t)=>({label:t,url:e,isExternal:!1,isUrlEditable:!1}),urlRepresentation(e,t){const i=Je(e);return t.tryGetSheetName(i)||s("Invalid sheet")},open(e,t){const i=Je(e);t.model.dispatch("ACTIVATE_SHEET",{sheetIdFrom:t.model.getters.getActiveSheetId(),sheetIdTo:i})},sequence:0});const yu={createLink:wu,match:e=>Ze(e),open:e=>window.open(e,"_blank"),urlRepresentation:e=>e,sequence:0};function xu(e){return Eu.getAll().sort(((e,t)=>e.sequence-t.sequence)).find((t=>t.match(e)))||yu}function Iu(e,t){return xu(e.url).urlRepresentation(e.url,t)}function Ru(e,t){xu(e.url).open(e.url,t)}function Tu(e){if("string"==typeof e){if(qe(e)){const{label:t,url:i}=Xe(e);return xu(i).createLink(i,t)}return Ze(e)?wu(e):void 0}}function Au(e,t){return Ou(Mu(e||""),t)}function Mu(e){if(e.startsWith("="))throw new Error(`Cannot parse "${e}" because it's not a literal value. It's a formula`);return Yt(e)||$e(e)?Qs(e):function(e){const t=e.toUpperCase();return"TRUE"===t||"FALSE"===t}(e)?"TRUE"===e.toUpperCase():e}function Ou(e,t){const i=Tu(e);return i?{...Nu(Mu(i.label),t||vi(i.label)),link:i}:Nu(e,t)}function Nu(e,t){try{for(const i of ku){const o=i(e,t);if(o)return o}return function(e,t){return{type:So.text,value:e,format:t,isAutoSummable:!0,defaultAlign:"left",formattedValue:li(e,t)}}((e||"").toString(),t)}catch(t){return Du((e||"").toString(),new c(a.GenericError,t.message||ae))}}function _u(e,t){return{type:So.number,value:e||0,format:t,isAutoSummable:!0,defaultAlign:"right",formattedValue:li(e,t)}}const Fu={type:So.empty,value:"",format:void 0,isAutoSummable:!0,defaultAlign:"left",formattedValue:""};function Du(e,t){return{type:So.error,value:t.errorType,error:t,isAutoSummable:!1,defaultAlign:"center",formattedValue:t.errorType}}const ku=[function(e,t){if(""===e)return function(e){return void 0===e?Fu:{type:So.empty,value:"",format:e,isAutoSummable:!0,defaultAlign:"left",formattedValue:""}}(t)},function(e,t){if(t&&"number"==typeof e&&ui(t))return function(e,t){const i=li(e,t);return{type:So.number,value:e,format:t,isAutoSummable:!1,defaultAlign:"right",formattedValue:i}}(e,t)},function(e,t){return"number"==typeof e?_u(e,t):null===e?_u(0,t):void 0},function(e,t){if("boolean"==typeof e)return function(e,t){const i=e?"TRUE":"FALSE";return{type:So.boolean,value:e,format:t,isAutoSummable:!1,defaultAlign:"center",formattedValue:i}}(e,t)}],Lu=new Mn;Lu.add("ALPHANUMERIC_INCREMENT_MODIFIER",{apply:(e,t)=>{e.current+=e.increment;const i=`${e.prefix}${e.current.toString().padStart(e.numberPostfixLength||0,"0")}`;return{cellData:{border:t.border,style:t.cell&&t.cell.style,format:t.cell&&t.cell.format,content:i},tooltip:{props:{content:i}}}}}).add("INCREMENT_MODIFIER",{apply:(e,t)=>{var i;e.current+=e.increment;const o=e.current.toString(),n=li(e.current,null===(i=t.cell)||void 0===i?void 0:i.format);return{cellData:{border:t.border,style:t.cell&&t.cell.style,format:t.cell&&t.cell.format,content:o},tooltip:o?{props:{content:n}}:void 0}}}).add("COPY_MODIFIER",{apply:(e,t,i)=>{var o,n,s;const r=(null===(o=t.cell)||void 0===o?void 0:o.content)||"";return{cellData:{border:t.border,style:t.cell&&t.cell.style,format:t.cell&&t.cell.format,content:r},tooltip:r?{props:{content:Au(null===(n=t.cell)||void 0===n?void 0:n.content,null===(s=t.cell)||void 0===s?void 0:s.format).formattedValue}}:void 0}}}).add("FORMULA_MODIFIER",{apply:(e,t,i,o)=>{e.current+=e.increment;let n=0,s=0;switch(o){case"up":n=0,s=-e.current;break;case"down":n=0,s=e.current;break;case"left":n=-e.current,s=0;break;case"right":n=e.current,s=0}const r=t.cell;if(!r||!r.isFormula)return{cellData:{}};const a=t.sheetId,l=i.createAdaptedRanges(r.dependencies,n,s,a),c=i.buildFormulaContent(a,r,l);return{cellData:{border:t.border,style:r.style,format:r.format,content:c},tooltip:c?{props:{content:c}}:void 0}}});const Pu=new Mn,Uu=/(\d+)$/,Vu=/^(.*\D+)/,zu=/^(.*\D+)(\d+)$/;function Bu(e,t,i){let o=[],n=!1;for(let s of t){s===e&&(n=!0);const t=Au(null==s?void 0:s.content);if(i(t))o.push(t);else{if(n)return o;o=[]}}return o}function Hu(e){let t=1;return e.length>=2&&(t=function(e){const t=[];let i=e[0];for(let o=1;o<e.length;o++){const n=e[o];t.push(n-i),i=n}return t.reduce(((e,t)=>e+t),0)/t.length}(e)*e.length),t}Pu.add("simple_value_copy",{condition:(e,t)=>{var i;return 1===t.length&&!e.isFormula&&!(null===(i=e.format)||void 0===i?void 0:i.match(X))},generateRule:()=>({type:"COPY_MODIFIER"}),sequence:10}).add("increment_alphanumeric_value",{condition:e=>!e.isFormula&&Au(e.content).type===So.text&&zu.test(e.content),generateRule:(e,t)=>{const i=parseInt(e.content.match(Uu)[0]),o=e.content.match(Vu)[0],n=e.content.length-o.length,s=Bu(e,t,(e=>e.type===So.text&&zu.test(e.value))).filter((e=>o===e.value.toString().match(Vu)[0])).map((e=>parseInt(e.value.toString().match(Uu)[0]))),r=Hu(s);return{type:"ALPHANUMERIC_INCREMENT_MODIFIER",prefix:o,current:i,increment:r,numberPostfixLength:n}},sequence:15}).add("copy_text",{condition:e=>!e.isFormula&&Au(e.content).type===So.text,generateRule:()=>({type:"COPY_MODIFIER"}),sequence:20}).add("update_formula",{condition:e=>e.isFormula,generateRule:(e,t)=>({type:"FORMULA_MODIFIER",increment:t.length,current:0}),sequence:30}).add("increment_number",{condition:e=>!e.isFormula&&Au(e.content).type===So.number,generateRule:(e,t)=>{const i=Hu(Bu(e,t,(e=>e.type===So.number)).map((e=>Number(e.value)))),o=Au(e.content);return{type:"INCREMENT_MODIFIER",increment:i,current:o.type===So.number?o.value:0}},sequence:40});ro`
|
|
286
|
-
.o-error-tooltip {
|
|
287
|
-
font-size: 13px;
|
|
288
|
-
background-color: white;
|
|
289
|
-
border-left: 3px solid red;
|
|
290
|
-
padding: 10px;
|
|
291
|
-
width: ${180}px;
|
|
292
|
-
box-sizing: border-box !important;
|
|
293
|
-
}
|
|
294
|
-
`;class $u extends t.Component{}$u.maxSize={maxHeight:80},$u.template="o-spreadsheet-ErrorToolTip",$u.components={},$u.props={text:String,onClosed:{type:Function,optional:!0}};const Wu={onHover:(e,t)=>{const i=t.getEvaluatedCell(e);return i.type===So.error&&i.error.logLevel>l.silent?{isOpen:!0,props:{text:i.error.message},Component:$u,cellCorner:"TopRight"}:{isOpen:!1}}};ro`
|
|
295
|
-
.o-filter-menu-value {
|
|
296
|
-
padding: 4px;
|
|
297
|
-
line-height: 20px;
|
|
298
|
-
height: 28px;
|
|
299
|
-
.o-filter-menu-value-checked {
|
|
300
|
-
width: 20px;
|
|
301
|
-
}
|
|
302
|
-
}
|
|
303
|
-
`;class Gu extends t.Component{constructor(){super(...arguments),this.itemRef=t.useRef("menuValueItem")}setup(){t.onWillPatch((()=>{this.props.scrolledTo&&this.scrollListToSelectedValue()}))}scrollListToSelectedValue(){var e,t;this.itemRef.el&&(null===(t=(e=this.itemRef.el).scrollIntoView)||void 0===t||t.call(e,{block:"bottom"===this.props.scrolledTo?"end":"start"}))}}Gu.template="o-spreadsheet-FilterMenuValueItem",Gu.props={value:String,isChecked:Boolean,isSelected:Boolean,onMouseMove:Function,onClick:Function,scrolledTo:{type:String,optional:!0}};const qu=ro`
|
|
304
|
-
.o-filter-menu {
|
|
305
|
-
box-sizing: border-box;
|
|
306
|
-
padding: 8px 16px;
|
|
307
|
-
height: ${295}px;
|
|
308
|
-
line-height: 1;
|
|
309
|
-
|
|
310
|
-
.o-filter-menu-item {
|
|
311
|
-
display: flex;
|
|
312
|
-
box-sizing: border-box;
|
|
313
|
-
height: ${28}px;
|
|
314
|
-
padding: 4px 4px 4px 0px;
|
|
315
|
-
cursor: pointer;
|
|
316
|
-
user-select: none;
|
|
317
|
-
|
|
318
|
-
&.selected {
|
|
319
|
-
background-color: rgba(0, 0, 0, 0.08);
|
|
320
|
-
}
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
input {
|
|
324
|
-
box-sizing: border-box;
|
|
325
|
-
margin-bottom: 5px;
|
|
326
|
-
border: 1px solid #949494;
|
|
327
|
-
height: 24px;
|
|
328
|
-
padding-right: 28px;
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
.o-search-icon {
|
|
332
|
-
right: 5px;
|
|
333
|
-
top: 4px;
|
|
334
|
-
|
|
335
|
-
svg {
|
|
336
|
-
height: 16px;
|
|
337
|
-
width: 16px;
|
|
338
|
-
vertical-align: middle;
|
|
339
|
-
}
|
|
340
|
-
}
|
|
341
|
-
|
|
342
|
-
.o-filter-menu-actions {
|
|
343
|
-
display: flex;
|
|
344
|
-
flex-direction: row;
|
|
345
|
-
margin-bottom: 4px;
|
|
346
|
-
|
|
347
|
-
.o-filter-menu-action-text {
|
|
348
|
-
cursor: pointer;
|
|
349
|
-
margin-right: 10px;
|
|
350
|
-
color: blue;
|
|
351
|
-
text-decoration: underline;
|
|
352
|
-
}
|
|
353
|
-
}
|
|
354
|
-
|
|
355
|
-
.o-filter-menu-list {
|
|
356
|
-
flex: auto;
|
|
357
|
-
overflow-y: auto;
|
|
358
|
-
border: 1px solid #949494;
|
|
359
|
-
|
|
360
|
-
.o-filter-menu-no-values {
|
|
361
|
-
color: #949494;
|
|
362
|
-
font-style: italic;
|
|
363
|
-
}
|
|
364
|
-
}
|
|
365
|
-
|
|
366
|
-
.o-filter-menu-buttons {
|
|
367
|
-
margin-top: 9px;
|
|
368
|
-
|
|
369
|
-
.o-filter-menu-button {
|
|
370
|
-
border: 1px solid lightgrey;
|
|
371
|
-
padding: 6px 10px;
|
|
372
|
-
cursor: pointer;
|
|
373
|
-
border-radius: 4px;
|
|
374
|
-
font-weight: 500;
|
|
375
|
-
line-height: 16px;
|
|
376
|
-
}
|
|
377
|
-
|
|
378
|
-
.o-filter-menu-button-cancel {
|
|
379
|
-
background: white;
|
|
380
|
-
&:hover {
|
|
381
|
-
background-color: rgba(0, 0, 0, 0.08);
|
|
382
|
-
}
|
|
383
|
-
}
|
|
384
|
-
|
|
385
|
-
.o-filter-menu-button-primary {
|
|
386
|
-
background-color: #188038;
|
|
387
|
-
&:hover {
|
|
388
|
-
background-color: #1d9641;
|
|
389
|
-
}
|
|
390
|
-
color: white;
|
|
391
|
-
font-weight: bold;
|
|
392
|
-
margin-left: 10px;
|
|
393
|
-
}
|
|
394
|
-
}
|
|
395
|
-
}
|
|
396
|
-
`;class Zu extends t.Component{constructor(){super(...arguments),this.state=t.useState({values:[],textFilter:"",selectedValue:void 0}),this.searchBar=t.useRef("filterMenuSearchBar")}setup(){t.onWillUpdateProps((e=>{at(e.filterPosition,this.props.filterPosition)||(this.state.values=this.getFilterValues(e.filterPosition))})),this.state.values=this.getFilterValues(this.props.filterPosition)}getFilterValues(e){const t=this.env.model.getters.getActiveSheetId(),i=this.env.model.getters.getFilter({sheetId:t,...e});if(!i)return[];const o=(i.filteredZone?Xi(i.filteredZone):[]).filter((({row:e})=>!this.env.model.getters.isRowHidden(t,e))).map((({col:e,row:i})=>this.env.model.getters.getEvaluatedCell({sheetId:t,col:e,row:i}).formattedValue)),n=this.env.model.getters.getFilterValues({sheetId:t,...e}),s=[...o,...n],r=n.map(ct);return[...new Set(s.map(ct))].sort(((e,t)=>e.localeCompare(t,void 0,{numeric:!0,sensitivity:"base"}))).map((e=>({checked:-1===r.findIndex((t=>t===e)),string:s.find((t=>ct(t)===e))||""})))}checkValue(e){var t;this.state.selectedValue=e.string,e.checked=!e.checked,null===(t=this.searchBar.el)||void 0===t||t.focus()}onMouseMove(e){this.state.selectedValue=e.string}selectAll(){this.state.values.forEach((e=>e.checked=!0))}clearAll(){this.state.values.forEach((e=>e.checked=!1))}get filterTable(){const e=this.env.model.getters.getActiveSheetId(),t=this.props.filterPosition;return this.env.model.getters.getFilterTable({sheetId:e,...t})}get displayedValues(){return this.state.textFilter?Ai(this.state.textFilter,this.state.values,(e=>e.string)):this.state.values}confirm(){var e,t;const i=this.props.filterPosition;this.env.model.dispatch("UPDATE_FILTER",{...i,sheetId:this.env.model.getters.getActiveSheetId(),values:this.state.values.filter((e=>!e.checked)).map((e=>e.string))}),null===(t=(e=this.props).onClosed)||void 0===t||t.call(e)}cancel(){var e,t;null===(t=(e=this.props).onClosed)||void 0===t||t.call(e)}onKeyDown(e){const t=this.displayedValues;if(0===t.length)return;let i;if(void 0!==this.state.selectedValue){const e=t.findIndex((e=>e.string===this.state.selectedValue));i=-1===e?void 0:e}switch(e.key){case"ArrowDown":i=void 0===i?0:Math.min(i+1,t.length-1),e.preventDefault(),e.stopPropagation();break;case"ArrowUp":i=void 0===i?t.length-1:Math.max(i-1,0),e.preventDefault(),e.stopPropagation();break;case"Enter":void 0!==i&&this.checkValue(t[i]),e.stopPropagation(),e.preventDefault()}this.state.selectedValue=void 0!==i?t[i].string:void 0,"ArrowUp"!==e.key&&"ArrowDown"!==e.key||this.scrollListToSelectedValue(e.key)}clearScrolledToValue(){this.state.values.forEach((e=>e.scrolledTo=void 0))}scrollListToSelectedValue(e){this.clearScrolledToValue();const t=this.state.values.find((e=>e.string===this.state.selectedValue));t&&(t.scrolledTo="ArrowUp"===e?"top":"bottom")}sortFilterZone(e){var t,i;const o=this.props.filterPosition,n=this.filterTable;if(!o||!n||!n.contentZone)return;const s=this.env.model.getters.getActiveSheetId();this.env.model.dispatch("SORT_CELLS",{sheetId:s,col:o.col,row:n.contentZone.top,zone:n.contentZone,sortDirection:e,sortOptions:{emptyCellAsZero:!0,sortHeaders:!0}}),null===(i=(t=this.props).onClosed)||void 0===i||i.call(t)}}Zu.size={width:H,height:295},Zu.template="o-spreadsheet-FilterMenu",Zu.style=qu,Zu.components={FilterMenuValueItem:Gu},Zu.props={filterPosition:Object,onClosed:{type:Function,optional:!0}};const ju={onOpen:(e,t)=>({isOpen:!0,props:{filterPosition:e},Component:Zu,cellCorner:"BottomLeft"})};ro`
|
|
397
|
-
.o-link-tool {
|
|
398
|
-
font-size: 13px;
|
|
399
|
-
background-color: white;
|
|
400
|
-
box-shadow: 0 1px 4px 3px rgba(60, 64, 67, 0.15);
|
|
401
|
-
padding: 6px 12px;
|
|
402
|
-
border-radius: 4px;
|
|
403
|
-
display: flex;
|
|
404
|
-
justify-content: space-between;
|
|
405
|
-
height: ${32}px;
|
|
406
|
-
width: ${220}px;
|
|
407
|
-
box-sizing: border-box !important;
|
|
408
|
-
|
|
409
|
-
img {
|
|
410
|
-
margin-right: 3px;
|
|
411
|
-
width: 16px;
|
|
412
|
-
height: 16px;
|
|
413
|
-
}
|
|
414
|
-
|
|
415
|
-
a.o-link {
|
|
416
|
-
color: #01666b;
|
|
417
|
-
text-decoration: none;
|
|
418
|
-
flex-grow: 2;
|
|
419
|
-
white-space: nowrap;
|
|
420
|
-
overflow: hidden;
|
|
421
|
-
text-overflow: ellipsis;
|
|
422
|
-
}
|
|
423
|
-
a.o-link:hover {
|
|
424
|
-
text-decoration: none;
|
|
425
|
-
color: #001d1f;
|
|
426
|
-
cursor: pointer;
|
|
427
|
-
}
|
|
428
|
-
}
|
|
429
|
-
.o-link-icon {
|
|
430
|
-
float: right;
|
|
431
|
-
padding-left: 5px;
|
|
432
|
-
.o-icon {
|
|
433
|
-
height: 16px;
|
|
434
|
-
}
|
|
435
|
-
}
|
|
436
|
-
.o-link-icon .o-icon {
|
|
437
|
-
height: 13px;
|
|
438
|
-
}
|
|
439
|
-
.o-link-icon:hover {
|
|
440
|
-
cursor: pointer;
|
|
441
|
-
color: #000;
|
|
442
|
-
}
|
|
443
|
-
`;class Xu extends t.Component{get cell(){const{col:e,row:t}=this.props.cellPosition,i=this.env.model.getters.getActiveSheetId();return this.env.model.getters.getEvaluatedCell({sheetId:i,col:e,row:t})}get link(){if(this.cell.link)return this.cell.link;const{col:e,row:t}=this.props.cellPosition;throw new Error(`LinkDisplay Component can only be used with link cells. ${Vt(e,t)} is not a link.`)}getUrlRepresentation(e){return Iu(e,this.env.model.getters)}openLink(){Ru(this.link,this.env)}edit(){const{col:e,row:t}=this.props.cellPosition;this.env.model.dispatch("OPEN_CELL_POPOVER",{col:e,row:t,popoverType:"LinkEditor"})}unlink(){const e=this.env.model.getters.getActiveSheetId(),{col:t,row:i}=this.props.cellPosition,o=this.env.model.getters.getCellComputedStyle({sheetId:e,col:t,row:i}),n=(null==o?void 0:o.textColor)===x||null==o?void 0:o.textColor;this.env.model.dispatch("UPDATE_CELL",{col:t,row:i,sheetId:e,content:this.link.label,style:{...o,textColor:n,underline:void 0}})}}Xu.components={Menu:jn},Xu.template="o-spreadsheet-LinkDisplay";const Yu={onHover:(e,t)=>{const i=t.getEvaluatedCell(e);return!t.isDashboard()&&i.link&&t.isVisibleInViewport(e)?{isOpen:!0,Component:Xu,props:{cellPosition:e},cellCorner:"BottomLeft"}:{isOpen:!1}}};Xu.props={cellPosition:Object,onClosed:{type:Function,optional:!0}};const Ku=new kn;Ku.add("sheet",{name:s("Link sheet"),sequence:10}).addChild("sheet_list",["sheet"],(e=>e.model.getters.getSheetIds().map((t=>e.model.getters.getSheet(t))).map((e=>({id:e.id,name:e.name,action:()=>je(e.name,Qe(e.id))})))));ro`
|
|
444
|
-
.o-link-editor {
|
|
445
|
-
font-size: 13px;
|
|
446
|
-
background-color: white;
|
|
447
|
-
box-shadow: 0 1px 4px 3px rgba(60, 64, 67, 0.15);
|
|
448
|
-
padding: ${12}px;
|
|
449
|
-
display: flex;
|
|
450
|
-
flex-direction: column;
|
|
451
|
-
border-radius: 4px;
|
|
452
|
-
height: ${165}px;
|
|
453
|
-
width: ${340}px;
|
|
454
|
-
|
|
455
|
-
.o-section {
|
|
456
|
-
.o-section-title {
|
|
457
|
-
font-weight: bold;
|
|
458
|
-
color: dimgrey;
|
|
459
|
-
margin-bottom: 5px;
|
|
460
|
-
}
|
|
461
|
-
}
|
|
462
|
-
.o-buttons {
|
|
463
|
-
padding-left: 16px;
|
|
464
|
-
padding-top: 16px;
|
|
465
|
-
padding-bottom: 16px;
|
|
466
|
-
text-align: right;
|
|
467
|
-
.o-button {
|
|
468
|
-
border: 1px solid lightgrey;
|
|
469
|
-
padding: 0px 20px 0px 20px;
|
|
470
|
-
border-radius: 4px;
|
|
471
|
-
font-weight: 500;
|
|
472
|
-
font-size: 14px;
|
|
473
|
-
height: 30px;
|
|
474
|
-
line-height: 16px;
|
|
475
|
-
background: white;
|
|
476
|
-
margin-right: 8px;
|
|
477
|
-
&:hover:enabled {
|
|
478
|
-
background-color: rgba(0, 0, 0, 0.08);
|
|
479
|
-
}
|
|
480
|
-
}
|
|
481
|
-
.o-button:enabled {
|
|
482
|
-
cursor: pointer;
|
|
483
|
-
}
|
|
484
|
-
.o-button:last-child {
|
|
485
|
-
margin-right: 0px;
|
|
486
|
-
}
|
|
487
|
-
}
|
|
488
|
-
input {
|
|
489
|
-
box-sizing: border-box;
|
|
490
|
-
width: 100%;
|
|
491
|
-
border-radius: 4px;
|
|
492
|
-
padding: 4px 23px 4px 10px;
|
|
493
|
-
border: none;
|
|
494
|
-
height: 24px;
|
|
495
|
-
border: 1px solid lightgrey;
|
|
496
|
-
}
|
|
497
|
-
.o-link-url {
|
|
498
|
-
position: relative;
|
|
499
|
-
flex-grow: 1;
|
|
500
|
-
button {
|
|
501
|
-
position: absolute;
|
|
502
|
-
right: 0px;
|
|
503
|
-
top: 0px;
|
|
504
|
-
border: none;
|
|
505
|
-
height: 20px;
|
|
506
|
-
width: 20px;
|
|
507
|
-
background-color: #fff;
|
|
508
|
-
margin: 2px 3px 1px 0px;
|
|
509
|
-
padding: 0px 1px 0px 0px;
|
|
510
|
-
}
|
|
511
|
-
button:hover {
|
|
512
|
-
cursor: pointer;
|
|
513
|
-
}
|
|
514
|
-
}
|
|
515
|
-
}
|
|
516
|
-
`;class Qu extends t.Component{constructor(){super(...arguments),this.menuItems=Ku.getMenuItems(),this.link=t.useState(this.defaultState),this.menu=t.useState({isOpen:!1}),this.linkEditorRef=t.useRef("linkEditor"),this.position=Pn(this.linkEditorRef),this.urlInput=t.useRef("urlInput")}setup(){t.onMounted((()=>{var e;return null===(e=this.urlInput.el)||void 0===e?void 0:e.focus()}))}get defaultState(){const{col:e,row:t}=this.props.cellPosition,i=this.env.model.getters.getActiveSheetId(),o=this.env.model.getters.getEvaluatedCell({sheetId:i,col:e,row:t});return o.link?{url:o.link.url,label:o.formattedValue,isUrlEditable:o.link.isUrlEditable}:{label:o.formattedValue,url:"",isUrlEditable:!0}}get menuPosition(){return{x:this.position.x+320-12-2,y:this.position.y+100}}onSpecialLink(e){const{detail:t}=e,i=Tu(t);i&&(this.link.url=i.url,this.link.label=i.label,this.link.isUrlEditable=i.isUrlEditable)}getUrlRepresentation(e){return Iu(e,this.env.model.getters)}openMenu(){this.menu.isOpen=!0}removeLink(){this.link.url="",this.link.isUrlEditable=!0}save(){var e,t;const{col:i,row:o}=this.props.cellPosition,n=this.link.label||this.link.url;this.env.model.dispatch("UPDATE_CELL",{col:i,row:o,sheetId:this.env.model.getters.getActiveSheetId(),content:je(n,this.link.url)}),null===(t=(e=this.props).onClosed)||void 0===t||t.call(e)}cancel(){var e,t;null===(t=(e=this.props).onClosed)||void 0===t||t.call(e)}onKeyDown(e){switch(e.key){case"Enter":this.link.url&&this.save(),e.stopPropagation();break;case"Escape":this.cancel(),e.stopPropagation()}}}Qu.template="o-spreadsheet-LinkEditor",Qu.components={Menu:jn};const Ju={onOpen:(e,t)=>({isOpen:!0,props:{cellPosition:e},Component:Qu,cellCorner:"BottomLeft"})};Qu.props={cellPosition:Object,onClosed:{type:Function,optional:!0}};const eg=new Mn;eg.add("ErrorToolTip",Wu).add("LinkCell",Yu).add("LinkEditor",Ju).add("FilterMenu",ju);const tg=new Mn;class ig extends t.Component{constructor(){super(...arguments),this.menuState=t.useState({isOpen:!1,position:null}),this.imageContainerRef=t.useRef("o-image"),this.menuButtonRef=t.useRef("menuButton"),this.menuButtonRect=Pn(this.menuButtonRef),this.position=Pn(this.imageContainerRef),this.menuItems=_n([{id:"copy",name:s("Copy"),description:"Ctrl+C",action:async()=>{this.env.model.dispatch("SELECT_FIGURE",{id:this.figureId}),this.env.model.dispatch("COPY"),await this.env.clipboard.write(this.env.model.getters.getClipboardContent())}},{id:"cut",name:s("Cut"),description:"Ctrl+X",action:async()=>{this.env.model.dispatch("SELECT_FIGURE",{id:this.figureId}),this.env.model.dispatch("CUT"),await this.env.clipboard.write(this.env.model.getters.getClipboardContent())}},{id:"reset_size",name:s("Reset size"),action:()=>{const e=this.env.model.getters.getImageSize(this.figureId),{height:t,width:i}=os(this.env.model.getters,e);this.env.model.dispatch("UPDATE_FIGURE",{sheetId:this.env.model.getters.getActiveSheetId(),id:this.figureId,height:t,width:i})}},{id:"delete",name:s("Delete image"),description:"delete",action:()=>{this.env.model.dispatch("DELETE_FIGURE",{sheetId:this.env.model.getters.getActiveSheetId(),id:this.figureId})}}])}onContextMenu(e){const t={x:this.position.x+e.offsetX,y:this.position.y+e.offsetY};this.openContextMenu(t)}showMenu(){const{x:e,y:t,width:i}=this.menuButtonRect,o={x:e>=H?e-H:e+i,y:t};this.openContextMenu(o)}openContextMenu(e){this.menuState.isOpen=!0,this.menuState.position=e}get figureId(){return this.props.figure.id}get getImagePath(){return this.env.model.getters.getImagePath(this.figureId)}}ig.template="o-spreadsheet-ImageFigure",ig.components={Menu:jn},ig.props={figure:Object,onFigureDeleted:Function};const og=new Mn;og.add("chart",{Component:Xn,SidePanelComponent:"ChartPanel"}),og.add("image",{Component:ig,keepRatio:!0,minFigSize:20,borderWidth:0});const ng=(new Mn).add("ADD_COLUMNS_ROWS",(function(e){const t=[];let i=e.base;"after"===e.position&&i++;for(let o=0;o<e.quantity;o++)t.push(o+i);return[{type:"REMOVE_COLUMNS_ROWS",dimension:e.dimension,elements:t,sheetId:e.sheetId}]})).add("REMOVE_COLUMNS_ROWS",(function(e){const t=[],i=[...e.elements].sort(((e,t)=>e-t));for(let o of Be(i)){const i=0===o[0]?0:o[0]-1,n=0===o[0]?"before":"after";t.push({type:"ADD_COLUMNS_ROWS",dimension:e.dimension,quantity:o.length,base:i,sheetId:e.sheetId,position:n})}return t})).add("ADD_MERGE",(function(e){return[{type:"REMOVE_MERGE",sheetId:e.sheetId,target:e.target}]})).add("REMOVE_MERGE",(function(e){return[{type:"ADD_MERGE",sheetId:e.sheetId,target:e.target}]})).add("CREATE_SHEET",(function(e){return[{type:"DELETE_SHEET",sheetId:e.sheetId}]})).add("DELETE_SHEET",(function(e){return[{type:"CREATE_SHEET",sheetId:e.sheetId,position:1}]})).add("DUPLICATE_SHEET",(function(e){return[{type:"DELETE_SHEET",sheetId:e.sheetIdTo}]})).add("CREATE_FIGURE",(function(e){return[{type:"DELETE_FIGURE",id:e.figure.id,sheetId:e.sheetId}]})).add("CREATE_CHART",(function(e){return[{type:"DELETE_FIGURE",id:e.id,sheetId:e.sheetId}]})).add("HIDE_COLUMNS_ROWS",(function(e){return[{type:"UNHIDE_COLUMNS_ROWS",sheetId:e.sheetId,dimension:e.dimension,elements:e.elements}]})).add("UNHIDE_COLUMNS_ROWS",(function(e){return[{type:"HIDE_COLUMNS_ROWS",sheetId:e.sheetId,dimension:e.dimension,elements:e.elements}]}));for(const e of xo.values())ng.contains(e)||ng.add(e,sg);function sg(e){return[e]}function rg(e,t,i){const o=e.model.getters.getActiveSheetId(),n="COL"===t?"FREEZE_COLUMNS":"FREEZE_ROWS";e.model.dispatch(n,{sheetId:o,quantity:i}).isCancelledBecause(65)&&e.raiseError(Ko)}const ag=new kn;ag.add("file",{name:s("File"),sequence:10}).add("edit",{name:s("Edit"),sequence:20}).add("view",{name:s("View"),sequence:30}).add("insert",{name:s("Insert"),sequence:40}).add("format",{name:s("Format"),sequence:50}).add("data",{name:s("Data"),sequence:60}).addChild("save",["file"],{name:s("Save"),description:"Ctrl+S",sequence:10,action:()=>console.log("Not implemented")}).addChild("undo",["edit"],{name:s("Undo"),description:"Ctrl+Z",sequence:10,action:e=>e.model.dispatch("REQUEST_UNDO")}).addChild("redo",["edit"],{name:s("Redo"),description:"Ctrl+Y",sequence:20,action:e=>e.model.dispatch("REQUEST_REDO"),separator:!0}).addChild("copy",["edit"],{name:s("Copy"),description:"Ctrl+C",sequence:30,isReadonlyAllowed:!0,action:us}).addChild("cut",["edit"],{name:s("Cut"),description:"Ctrl+X",sequence:40,action:gs}).addChild("paste",["edit"],{name:s("Paste"),description:"Ctrl+V",sequence:50,action:ps}).addChild("paste_special",["edit"],{name:s("Paste special"),sequence:60,separator:!0,isVisible:bs}).addChild("paste_special_value",["edit","paste_special"],{name:s("Paste value only"),sequence:10,action:ms}).addChild("paste_special_format",["edit","paste_special"],{name:s("Paste format only"),sequence:20,action:vs}).addChild("sort_range",["data"],{name:s("Sort range"),sequence:20,isVisible:Ls,separator:!0}).addChild("sort_ascending",["data","sort_range"],{name:s("Ascending (A ⟶ Z)"),sequence:10,action:Ds}).addChild("sort_descending",["data","sort_range"],{name:s("Descending (Z ⟶ A)"),sequence:20,action:ks}).addChild("find_and_replace",["edit"],{name:s("Find and replace"),description:"Ctrl+H",sequence:65,isReadonlyAllowed:!0,action:e=>{e.openSidePanel("FindAndReplace",{})},separator:!0}).addChild("edit_delete_cell_values",["edit"],{name:s("Delete values"),sequence:70,action:e=>e.model.dispatch("DELETE_CONTENT",{sheetId:e.model.getters.getActiveSheetId(),target:e.model.getters.getSelectedZones()})}).addChild("edit_delete_row",["edit"],{name:Ss,sequence:80,action:Cs}).addChild("edit_delete_column",["edit"],{name:Es,sequence:90,action:ws}).addChild("edit_delete_cell_shift_up",["edit"],{name:s("Delete cell and shift up"),sequence:93,action:Is}).addChild("edit_delete_cell_shift_left",["edit"],{name:s("Delete cell and shift left"),sequence:97,action:Rs}).addChild("edit_unhide_columns",["edit"],{name:s("Unhide all columns"),sequence:100,action:e=>{const t=e.model.getters.getActiveSheetId();e.model.dispatch("UNHIDE_COLUMNS_ROWS",{sheetId:t,dimension:"COL",elements:Array.from(Array(e.model.getters.getNumberCols(t)).keys())})},isVisible:e=>e.model.getters.getHiddenColsGroups(e.model.getters.getActiveSheetId()).length>0}).addChild("edit_unhide_rows",["edit"],{name:s("Unhide all rows"),sequence:100,action:e=>{const t=e.model.getters.getActiveSheetId();e.model.dispatch("UNHIDE_COLUMNS_ROWS",{sheetId:t,dimension:"ROW",elements:Array.from(Array(e.model.getters.getNumberRows(t)).keys())})},isVisible:e=>e.model.getters.getHiddenRowsGroups(e.model.getters.getActiveSheetId()).length>0}).addChild("insert_row_before",["insert"],{name:e=>{const t=cs(e);return 1===t?s("Row above"):s("%s Rows above",t.toString())},sequence:10,action:Ts,isVisible:e=>0===e.model.getters.getActiveCols().size}).addChild("insert_row_after",["insert"],{name:e=>{const t=cs(e);return 1===t?s("Row below"):s("%s Rows below",t.toString())},sequence:20,action:As,isVisible:e=>0===e.model.getters.getActiveCols().size,separator:!0}).addChild("insert_column_before",["insert"],{name:e=>{const t=ls(e);return 1===t?s("Column left"):s("%s Columns left",t.toString())},sequence:30,action:Ms,isVisible:e=>0===e.model.getters.getActiveRows().size}).addChild("insert_column_after",["insert"],{name:e=>{const t=ls(e);return 1===t?s("Column right"):s("%s Columns right",t.toString())},sequence:40,action:Os,isVisible:e=>0===e.model.getters.getActiveRows().size,separator:!0}).addChild("insert_insert_cell_shift_down",["insert"],{name:s("Insert cells and shift down"),sequence:43,action:ys}).addChild("insert_insert_cell_shift_right",["insert"],{name:s("Insert cells and shift right"),sequence:47,action:xs,separator:!0}).addChild("insert_chart",["insert"],{name:s("Chart"),sequence:50,action:e=>{const t=e.model.getters,i=e.model.uuidGenerator.uuidv4(),o=t.getActiveSheetId();1===to(e.model.getters.getSelectedZone())&&e.model.selection.selectTableAroundSelection();const n={width:536,height:335},s=function(e,t){const{x:i,y:o}=e.getMainViewportCoordinates(),{scrollX:n,scrollY:s}=e.getActiveSheetScrollInfo(),{width:r,height:a}=e.getVisibleRect(e.getActiveMainViewport());return{x:i+n+Math.max(0,(r-t.width)/2),y:o+s+Math.max(0,(a-t.height)/2)}}(t,n);e.model.dispatch("CREATE_CHART",{sheetId:o,id:i,position:s,size:n,definition:is(e.model.getters.getSelectedZone(),e.model.getters)}).isSuccessful&&(e.model.dispatch("SELECT_FIGURE",{id:i}),e.openSidePanel("ChartPanel"))}}).addChild("insert_image",["insert"],{name:s("Image"),sequence:55,action:async e=>{if(e.imageProvider){const t=e.model.getters.getActiveSheetId(),i=e.model.uuidGenerator.uuidv4(),o=await async function(e){try{return await e.imageProvider.requestImage()}catch{return void e.raiseError(s("An unexpected error occurred during the image transfer"))}}(e);if(!o)throw new Error("No image provider was given to the environment");const n=os(e.model.getters,o.size),r=function(e,t){const{x:i,y:o}=e.getMainViewportCoordinates(),{scrollX:n,scrollY:s}=e.getActiveSheetScrollInfo(),r=e.getSheetViewDimension(),a=e.getVisibleRect(e.getActiveMainViewport()),l=Math.min(a.width,r.width-i),c=Math.min(a.height,r.height-o);return{x:i+n+Math.max(0,(l-t.width)/2),y:o+s+Math.max(0,(c-t.height)/2)}}(e.model.getters,n);e.model.dispatch("CREATE_IMAGE",{sheetId:t,figureId:i,position:r,size:n,definition:o})}},isVisible:e=>void 0!==e.imageProvider}).addChild("insert_function",["insert"],{name:s("Function"),sequence:60}).addChild("insert_function_sum",["insert","insert_function"],{name:s("SUM"),action:e=>e.startCellEdition("=SUM("),sequence:0}).addChild("insert_function_average",["insert","insert_function"],{name:s("AVERAGE"),action:e=>e.startCellEdition("=AVERAGE("),sequence:10}).addChild("insert_function_count",["insert","insert_function"],{name:s("COUNT"),action:e=>e.startCellEdition("=COUNT("),sequence:20}).addChild("insert_function_max",["insert","insert_function"],{name:s("MAX"),action:e=>e.startCellEdition("=MAX("),sequence:30}).addChild("insert_function_min",["insert","insert_function"],{name:s("MIN"),action:e=>e.startCellEdition("=MIN("),sequence:40,separator:!0}).addChild("categorie_function_all",["insert","insert_function"],{name:s("All"),sequence:50}).addChild("all_function_list",["insert","insert_function","categorie_function_all"],(()=>lg(iu.getKeys()))).addChild("categories_function_list",["insert","insert_function"],(()=>{const e=iu.content;return[...new Set(iu.getAll().map((e=>e.category)))].filter(et).sort().map(((t,i)=>{const o=Object.keys(e).filter((i=>e[i].category===t));return{name:t,sequence:60+10*i,children:lg(o)}}))})).addChild("insert_link",["insert"],{name:s("Link"),separator:!0,sequence:70,action:_s}).addChild("insert_sheet",["insert"],{name:s("New sheet"),sequence:80,action:e=>{const t=e.model.getters.getActiveSheetId(),i=e.model.getters.getSheetIds().indexOf(t)+1,o=e.model.uuidGenerator.uuidv4();e.model.dispatch("CREATE_SHEET",{sheetId:o,position:i}),e.model.dispatch("ACTIVATE_SHEET",{sheetIdFrom:t,sheetIdTo:o})},separator:!0}).addChild("unfreeze_panes",["view"],{name:s("Unfreeze"),sequence:4,isVisible:e=>{const{xSplit:t,ySplit:i}=e.model.getters.getPaneDivisions(e.model.getters.getActiveSheetId());return t+i>0},action:e=>e.model.dispatch("UNFREEZE_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId()})}).addChild("freeze_panes",["view"],{name:s("Freeze"),sequence:5,separator:!0}).addChild("unfreeze_rows",["view","freeze_panes"],{name:s("No rows"),action:e=>e.model.dispatch("UNFREEZE_ROWS",{sheetId:e.model.getters.getActiveSheetId()}),isReadonlyAllowed:!0,sequence:5,isVisible:e=>!!e.model.getters.getPaneDivisions(e.model.getters.getActiveSheetId()).ySplit}).addChild("freeze_first_row",["view","freeze_panes"],{name:s("1 row"),action:e=>rg(e,"ROW",1),isReadonlyAllowed:!0,sequence:10}).addChild("freeze_second_row",["view","freeze_panes"],{name:s("2 rows"),action:e=>rg(e,"ROW",2),isReadonlyAllowed:!0,sequence:15}).addChild("freeze_current_row",["view","freeze_panes"],{name:s("Up to current row"),action:e=>{const{bottom:t}=e.model.getters.getSelectedZone();rg(e,"ROW",t+1)},isReadonlyAllowed:!0,sequence:20,separator:!0}).addChild("unfreeze_columns",["view","freeze_panes"],{name:s("No columns"),action:e=>e.model.dispatch("UNFREEZE_COLUMNS",{sheetId:e.model.getters.getActiveSheetId()}),isReadonlyAllowed:!0,sequence:25,isVisible:e=>!!e.model.getters.getPaneDivisions(e.model.getters.getActiveSheetId()).xSplit}).addChild("freeze_first_col",["view","freeze_panes"],{name:s("1 column"),action:e=>rg(e,"COL",1),isReadonlyAllowed:!0,sequence:30}).addChild("freeze_second_col",["view","freeze_panes"],{name:s("2 columns"),action:e=>rg(e,"COL",2),isReadonlyAllowed:!0,sequence:35}).addChild("freeze_current_col",["view","freeze_panes"],{name:s("Up to current column"),action:e=>{const{right:t}=e.model.getters.getSelectedZone();rg(e,"COL",t+1)},isReadonlyAllowed:!0,sequence:40}).addChild("view_gridlines",["view"],{name:e=>e.model.getters.getGridLinesVisibility(e.model.getters.getActiveSheetId())?s("Hide gridlines"):s("Show gridlines"),action:e=>{const t=e.model.getters.getActiveSheetId();e.model.dispatch("SET_GRID_LINES_VISIBILITY",{sheetId:t,areGridLinesVisible:!e.model.getters.getGridLinesVisibility(t)})},sequence:10}).addChild("view_formulas",["view"],{name:e=>e.model.getters.shouldShowFormulas()?s("Hide formulas"):s("Show formulas"),action:e=>e.model.dispatch("SET_FORMULA_VISIBILITY",{show:!e.model.getters.shouldShowFormulas()}),isReadonlyAllowed:!0,sequence:15}).addChild("format_number",["format"],{name:s("Numbers"),sequence:10,separator:!0}).addChild("format_number_automatic",["format","format_number"],{name:Xo.Automatic,sequence:10,separator:!0,action:e=>hs(e,"")}).addChild("format_number_number",["format","format_number"],{name:Xo.Number,description:"1,000.12",sequence:20,action:e=>hs(e,"#,##0.00")}).addChild("format_number_percent",["format","format_number"],{name:Xo.Percent,description:"10.12%",sequence:30,separator:!0,action:e=>hs(e,"0.00%")}).addChild("format_number_currency",["format","format_number"],{name:Xo.Currency,description:"$1,000.12",sequence:37,action:e=>hs(e,"[$$]#,##0.00")}).addChild("format_number_currency_rounded",["format","format_number"],{name:Xo.CurrencyRounded,description:"$1,000",sequence:38,action:e=>hs(e,"[$$]#,##0")}).addChild("format_custom_currency",["format","format_number"],{name:Xo.CustomCurrency,sequence:39,separator:!0,isVisible:e=>void 0!==e.loadCurrencies,action:e=>{e.openSidePanel("CustomCurrency",{})}}).addChild("format_number_date",["format","format_number"],{name:Xo.Date,description:"9/26/2008",sequence:40,action:e=>hs(e,"m/d/yyyy")}).addChild("format_number_time",["format","format_number"],{name:Xo.Time,description:"10:43:00 PM",sequence:50,action:e=>hs(e,"hh:mm:ss a")}).addChild("format_number_date_time",["format","format_number"],{name:Xo.DateTime,description:"9/26/2008 22:43:00",sequence:60,action:e=>hs(e,"m/d/yyyy hh:mm:ss")}).addChild("format_number_duration",["format","format_number"],{name:Xo.Duration,description:"27:51:38",sequence:70,separator:!0,action:e=>hs(e,"hhhh:mm:ss")}).addChild("format_bold",["format"],{name:s("Bold"),sequence:20,description:"Ctrl+B",action:e=>ds(e,{bold:!e.model.getters.getCurrentStyle().bold})}).addChild("format_italic",["format"],{name:s("Italic"),sequence:30,description:"Ctrl+I",action:e=>ds(e,{italic:!e.model.getters.getCurrentStyle().italic})}).addChild("format_underline",["format"],{name:s("Underline"),description:"Ctrl+U",sequence:40,action:e=>ds(e,{underline:!e.model.getters.getCurrentStyle().underline})}).addChild("format_strikethrough",["format"],{name:s("Strikethrough"),sequence:50,action:e=>ds(e,{strikethrough:!e.model.getters.getCurrentStyle().strikethrough}),separator:!0}).addChild("format_font_size",["format"],{name:s("Font size"),sequence:60,separator:!0}).addChild("format_alignment",["format"],{name:s("Alignment"),sequence:70}).addChild("format_alignment_left",["format","format_alignment"],{name:"Left",sequence:10,action:e=>ds(e,{align:"left"})}).addChild("format_alignment_center",["format","format_alignment"],{name:"Center",sequence:20,action:e=>ds(e,{align:"center"})}).addChild("format_alignment_right",["format","format_alignment"],{name:"Right",sequence:30,action:e=>ds(e,{align:"right"}),separator:!0}).addChild("format_alignment_top",["format","format_alignment"],{name:"Top",sequence:40,action:e=>ds(e,{verticalAlign:"top"})}).addChild("format_alignment_middle",["format","format_alignment"],{name:"Middle",sequence:50,action:e=>ds(e,{verticalAlign:"middle"})}).addChild("format_alignment_bottom",["format","format_alignment"],{name:"Bottom",sequence:60,action:e=>ds(e,{verticalAlign:"bottom"}),separator:!0}).addChild("format_wrapping",["format"],{name:s("Wrapping"),sequence:80,separator:!0}).addChild("format_wrapping_overflow",["format","format_wrapping"],{name:s("Overflow"),sequence:10,action:e=>ds(e,{wrapping:"overflow"})}).addChild("format_wrapping_wrap",["format","format_wrapping"],{name:s("Wrap"),sequence:20,action:e=>ds(e,{wrapping:"wrap"})}).addChild("format_wrapping_clip",["format","format_wrapping"],{name:s("Clip"),sequence:30,action:e=>ds(e,{wrapping:"clip"})}).addChild("format_cf",["format"],{name:s("Conditional formatting"),sequence:90,action:Ns,separator:!0}).addChild("format_clearFormat",["format"],{name:s("Clear formatting"),sequence:100,action:e=>{e.model.dispatch("CLEAR_FORMATTING",{sheetId:e.model.getters.getActiveSheetId(),target:e.model.getters.getSelectedZones()})},separator:!0}).addChild("add_data_filter",["data"],{name:s("Create filter"),sequence:10,action:e=>{const t=e.model.getters.getActiveSheetId(),i=e.model.getters.getSelection().zones;as(e,t,i)},isVisible:e=>!Fs(e),isEnabled:e=>(e=>io(...e.model.getters.getSelectedZones()))(e)}).addChild("remove_data_filter",["data"],{name:s("Remove filter"),sequence:10,action:e=>{const t=e.model.getters.getActiveSheetId();e.model.dispatch("REMOVE_FILTER_TABLE",{sheetId:t,target:e.model.getters.getSelectedZones()})},isVisible:Fs});for(let e of he)ag.addChild(`format_font_size_${e}`,["format","format_font_size"],{name:e.toString(),sequence:e,action:t=>ds(t,{fontSize:e})});function lg(e){return e.sort().map(((e,t)=>({name:e,sequence:10*t,action:t=>t.startCellEdition(`=${e}(`)})))}const cg=new class extends Mn{addTransformation(e,t,i){for(let o of t)this.content[o]||(this.content[o]=new Map),this.content[o].set(e,i);return this}getTransformation(e,t){return this.content[e]&&this.content[e].get(t)}},hg=new Oi;ro`
|
|
517
|
-
.o-selection {
|
|
518
|
-
.o-selection-input {
|
|
519
|
-
display: flex;
|
|
520
|
-
flex-direction: row;
|
|
521
|
-
|
|
522
|
-
input {
|
|
523
|
-
padding: 4px 6px;
|
|
524
|
-
border-radius: 4px;
|
|
525
|
-
box-sizing: border-box;
|
|
526
|
-
flex-grow: 2;
|
|
527
|
-
}
|
|
528
|
-
input:focus {
|
|
529
|
-
outline: none;
|
|
530
|
-
}
|
|
531
|
-
input.o-required,
|
|
532
|
-
input.o-focused {
|
|
533
|
-
border-width: 2px;
|
|
534
|
-
padding: 3px 5px;
|
|
535
|
-
}
|
|
536
|
-
input.o-focused {
|
|
537
|
-
border-color: ${E};
|
|
538
|
-
}
|
|
539
|
-
input.o-invalid {
|
|
540
|
-
border-color: red;
|
|
541
|
-
}
|
|
542
|
-
button.o-btn {
|
|
543
|
-
background: transparent;
|
|
544
|
-
border: none;
|
|
545
|
-
color: #333;
|
|
546
|
-
cursor: pointer;
|
|
547
|
-
}
|
|
548
|
-
button.o-btn-action {
|
|
549
|
-
margin: 8px 1px;
|
|
550
|
-
border-radius: 4px;
|
|
551
|
-
background: transparent;
|
|
552
|
-
border: 1px solid #dadce0;
|
|
553
|
-
color: #188038;
|
|
554
|
-
font-weight: bold;
|
|
555
|
-
font-size: 14px;
|
|
556
|
-
height: 25px;
|
|
557
|
-
}
|
|
558
|
-
}
|
|
559
|
-
}
|
|
560
|
-
`;class dg extends t.Component{constructor(){super(...arguments),this.id=hg.uuidv4(),this.previousRanges=this.props.ranges||[],this.originSheet=this.env.model.getters.getActiveSheetId(),this.state=t.useState({isMissing:!1,mode:"select-range"}),this.focusedInput=t.useRef("focusedInput")}get ranges(){const e=this.env.model.getters.getSelectionInput(this.id);return(e.length?e:this.props.ranges?this.props.ranges.map(((e,t)=>({xc:e,id:t,isFocused:!1}))):[]).map((e=>({...e,isValidRange:""===e.xc||this.env.model.getters.isRangeValid(e.xc)})))}get hasFocus(){return this.ranges.filter((e=>e.isFocused)).length>0}get canAddRange(){return!this.props.hasSingleRange}get isInvalid(){return this.props.isInvalid||this.state.isMissing}setup(){t.useEffect((()=>{var e;return null===(e=this.focusedInput.el)||void 0===e?void 0:e.focus()}),(()=>[this.focusedInput.el])),t.onMounted((()=>this.enableNewSelectionInput())),t.onWillUnmount((async()=>this.disableNewSelectionInput())),t.onPatched((()=>this.checkChange()))}enableNewSelectionInput(){this.env.model.dispatch("ENABLE_NEW_SELECTION_INPUT",{id:this.id,initialRanges:this.props.ranges,hasSingleRange:this.props.hasSingleRange})}disableNewSelectionInput(){this.env.model.dispatch("DISABLE_SELECTION_INPUT",{id:this.id})}checkChange(){const e=this.env.model.getters.getSelectionInputValue(this.id);this.previousRanges.join()!==e.join()&&this.triggerChange()}getColor(e){return"color: "+(e.color||"#000")+";"}triggerChange(){var e,t;const i=this.env.model.getters.getSelectionInputValue(this.id);null===(t=(e=this.props).onSelectionChanged)||void 0===t||t.call(e,i),this.previousRanges=i}onKeydown(e){if("F2"===e.key)e.preventDefault(),e.stopPropagation(),this.state.mode="select-range"===this.state.mode?"text-edit":"select-range";else if(e.key.startsWith("Arrow"))e.stopPropagation(),"select-range"===this.state.mode&&(e.preventDefault(),nu(e,this.env.model.selection));else if("Enter"===e.key){e.target.blur(),this.confirm()}}focus(e){this.state.isMissing=!1,this.state.mode="select-range",this.env.model.dispatch("FOCUS_RANGE",{id:this.id,rangeId:e})}addEmptyInput(){this.env.model.dispatch("ADD_EMPTY_RANGE",{id:this.id})}removeInput(e){var t,i;this.env.model.dispatch("REMOVE_RANGE",{id:this.id,rangeId:e}),this.triggerChange(),null===(i=(t=this.props).onSelectionConfirmed)||void 0===i||i.call(t)}onInputChanged(e,t){const i=t.target;this.env.model.dispatch("CHANGE_RANGE",{id:this.id,rangeId:e,value:i.value}),this.triggerChange()}confirm(){var e,t;this.env.model.dispatch("UNFOCUS_SELECTION_INPUT");const i=this.env.model.getters.getSelectionInputValue(this.id);this.props.required&&0===i.length&&(this.state.isMissing=!0);const o=this.env.model.getters.getActiveSheetId();this.originSheet!==o&&this.env.model.dispatch("ACTIVATE_SHEET",{sheetIdFrom:o,sheetIdTo:this.originSheet}),null===(t=(e=this.props).onSelectionConfirmed)||void 0===t||t.call(e)}}dg.template="o-spreadsheet-SelectionInput",dg.props={ranges:Array,hasSingleRange:{type:Boolean,optional:!0},required:{type:Boolean,optional:!0},isInvalid:{type:Boolean,optional:!0},class:{type:String,optional:!0},onSelectionChanged:{type:Function,optional:!0},onSelectionConfirmed:{type:Function,optional:!0}};class ug extends t.Component{constructor(){super(...arguments),this.state=t.useState({datasetDispatchResult:void 0,labelsDispatchResult:void 0}),this.dataSeriesRanges=[]}setup(){this.dataSeriesRanges=this.props.definition.dataSets,this.labelRange=this.props.definition.labelRange}get errorMessages(){var e,t;return[...(null===(e=this.state.datasetDispatchResult)||void 0===e?void 0:e.reasons)||[],...(null===(t=this.state.labelsDispatchResult)||void 0===t?void 0:t.reasons)||[]].map((e=>jo.Errors[e]||jo.Errors.Unexpected))}get isDatasetInvalid(){var e;return!!(null===(e=this.state.datasetDispatchResult)||void 0===e?void 0:e.isCancelledBecause(32))}get isLabelInvalid(){var e;return!!(null===(e=this.state.labelsDispatchResult)||void 0===e?void 0:e.isCancelledBecause(33))}onUpdateDataSetsHaveTitle(e){this.props.updateChart({dataSetsHaveTitle:e.target.checked})}onDataSeriesRangesChanged(e){this.dataSeriesRanges=e}onDataSeriesConfirmed(){this.state.datasetDispatchResult=this.props.updateChart({dataSets:this.dataSeriesRanges})}onLabelRangeChanged(e){this.labelRange=e[0]}onLabelRangeConfirmed(){this.state.labelsDispatchResult=this.props.updateChart({labelRange:this.labelRange})}onUpdateAggregated(e){this.props.updateChart({aggregated:e.target.checked})}}ug.template="o-spreadsheet-LineBarPieConfigPanel",ug.components={SelectionInput:dg},ug.props={figureId:String,definition:Object,updateChart:Function};class gg extends ug{onUpdateStacked(e){this.props.updateChart({stacked:e.target.checked})}onUpdateAggregated(e){this.props.updateChart({aggregated:e.target.checked})}}gg.template="o-spreadsheet-BarConfigPanel";const pg=218,mg=182;function fg(e){return Et(yt({h:360*e.offsetX/pg,s:100,l:100*e.offsetY/mg,a:1}))}ro`
|
|
561
|
-
.o-color-picker {
|
|
562
|
-
padding: ${6}px 0px;
|
|
563
|
-
box-shadow: 1px 2px 5px 2px rgba(51, 51, 51, 0.15);
|
|
564
|
-
background-color: white;
|
|
565
|
-
line-height: 1.2;
|
|
566
|
-
overflow-y: auto;
|
|
567
|
-
overflow-x: hidden;
|
|
568
|
-
width: ${pg+12}px;
|
|
569
|
-
|
|
570
|
-
.o-color-picker-section-name {
|
|
571
|
-
margin: 0px ${1}px;
|
|
572
|
-
padding: 4px ${6}px;
|
|
573
|
-
}
|
|
574
|
-
.colors-grid {
|
|
575
|
-
display: grid;
|
|
576
|
-
padding: ${1}px ${6}px;
|
|
577
|
-
grid-template-columns: repeat(${10}, 1fr);
|
|
578
|
-
grid-gap: ${2}px;
|
|
579
|
-
}
|
|
580
|
-
.o-color-picker-line-item {
|
|
581
|
-
width: ${18}px;
|
|
582
|
-
height: ${18}px;
|
|
583
|
-
margin: 0px;
|
|
584
|
-
border-radius: 50px;
|
|
585
|
-
border: ${1}px solid #666666;
|
|
586
|
-
padding: 0px;
|
|
587
|
-
font-size: 16px;
|
|
588
|
-
background: white;
|
|
589
|
-
&:hover {
|
|
590
|
-
background-color: rgba(0, 0, 0, 0.08);
|
|
591
|
-
outline: 1px solid gray;
|
|
592
|
-
cursor: pointer;
|
|
593
|
-
}
|
|
594
|
-
}
|
|
595
|
-
.o-buttons {
|
|
596
|
-
padding: 6px;
|
|
597
|
-
display: flex;
|
|
598
|
-
.o-cancel {
|
|
599
|
-
margin: 0px ${1}px;
|
|
600
|
-
border: ${1}px solid #c0c0c0;
|
|
601
|
-
width: 100%;
|
|
602
|
-
padding: 5px;
|
|
603
|
-
font-size: 14px;
|
|
604
|
-
background: white;
|
|
605
|
-
border-radius: 4px;
|
|
606
|
-
&:hover:enabled {
|
|
607
|
-
background-color: rgba(0, 0, 0, 0.08);
|
|
608
|
-
}
|
|
609
|
-
}
|
|
610
|
-
}
|
|
611
|
-
.o-add-button {
|
|
612
|
-
border: ${1}px solid #c0c0c0;
|
|
613
|
-
padding: 4px;
|
|
614
|
-
background: white;
|
|
615
|
-
border-radius: 4px;
|
|
616
|
-
&:hover:enabled {
|
|
617
|
-
background-color: rgba(0, 0, 0, 0.08);
|
|
618
|
-
}
|
|
619
|
-
}
|
|
620
|
-
.o-separator {
|
|
621
|
-
border-bottom: ${1}px solid ${A};
|
|
622
|
-
margin-top: ${5}px;
|
|
623
|
-
margin-bottom: ${5}px;
|
|
624
|
-
}
|
|
625
|
-
input {
|
|
626
|
-
box-sizing: border-box;
|
|
627
|
-
width: 100%;
|
|
628
|
-
border-radius: 4px;
|
|
629
|
-
padding: 4px 23px 4px 10px;
|
|
630
|
-
height: 24px;
|
|
631
|
-
border: 1px solid #c0c0c0;
|
|
632
|
-
margin: 0 2px 0 0;
|
|
633
|
-
}
|
|
634
|
-
input.o-wrong-color {
|
|
635
|
-
border-color: red;
|
|
636
|
-
}
|
|
637
|
-
.o-custom-selector {
|
|
638
|
-
padding: ${6}px;
|
|
639
|
-
position: relative;
|
|
640
|
-
.o-gradient {
|
|
641
|
-
background: linear-gradient(to bottom, hsl(0 100% 0%), transparent, hsl(0 0% 100%)),
|
|
642
|
-
linear-gradient(
|
|
643
|
-
to right,
|
|
644
|
-
hsl(0 100% 50%) 0%,
|
|
645
|
-
hsl(0.2turn 100% 50%) 20%,
|
|
646
|
-
hsl(0.3turn 100% 50%) 30%,
|
|
647
|
-
hsl(0.4turn 100% 50%) 40%,
|
|
648
|
-
hsl(0.5turn 100% 50%) 50%,
|
|
649
|
-
hsl(0.6turn 100% 50%) 60%,
|
|
650
|
-
hsl(0.7turn 100% 50%) 70%,
|
|
651
|
-
hsl(0.8turn 100% 50%) 80%,
|
|
652
|
-
hsl(0.9turn 100% 50%) 90%,
|
|
653
|
-
hsl(1turn 100% 50%) 100%
|
|
654
|
-
);
|
|
655
|
-
border: ${1}px solid #c0c0c0;
|
|
656
|
-
width: ${pg}px;
|
|
657
|
-
height: ${mg}px;
|
|
658
|
-
&:hover {
|
|
659
|
-
cursor: crosshair;
|
|
660
|
-
}
|
|
661
|
-
}
|
|
662
|
-
.o-custom-input-preview {
|
|
663
|
-
padding: 2px ${1}px;
|
|
664
|
-
display: flex;
|
|
665
|
-
}
|
|
666
|
-
.o-custom-input-buttons {
|
|
667
|
-
padding: 2px ${1}px;
|
|
668
|
-
text-align: right;
|
|
669
|
-
}
|
|
670
|
-
.o-color-preview {
|
|
671
|
-
border: 1px solid #c0c0c0;
|
|
672
|
-
border-radius: 4px;
|
|
673
|
-
width: 100%;
|
|
674
|
-
}
|
|
675
|
-
}
|
|
676
|
-
}
|
|
677
|
-
.o-magnifier-glass {
|
|
678
|
-
position: absolute;
|
|
679
|
-
border: ${1}px solid #c0c0c0;
|
|
680
|
-
border-radius: 50%;
|
|
681
|
-
width: 30px;
|
|
682
|
-
height: 30px;
|
|
683
|
-
}
|
|
684
|
-
`;class vg extends t.Component{constructor(){super(...arguments),this.COLORS=M,this.state=t.useState({showGradient:!1,currentColor:vt(this.props.currentColor)?this.props.currentColor:"",isCurrentColorInvalid:!1,style:{display:"none",background:"#ffffff",left:"0",top:"0"}})}get colorPickerStyle(){return void 0!==this.props.maxHeight&&this.props.maxHeight<=0?ho({display:"none"}):""}get popoverProps(){return{anchorRect:this.props.anchorRect,maxHeight:this.props.maxHeight,positioning:"BottomLeft",verticalOffset:0}}onColorClick(e){e&&this.props.onColorPicked(e)}getCheckMarkColor(){return zo(this.props.currentColor)}resetColor(){this.props.onColorPicked("")}setCustomColor(e){if(!vt(this.state.currentColor))return e.stopPropagation(),void(this.state.isCurrentColorInvalid=!0);this.state.isCurrentColorInvalid=!1,this.props.onColorPicked(this.state.currentColor)}toggleColorPicker(){this.state.showGradient=!this.state.showGradient}computeCustomColor(e){this.state.isCurrentColorInvalid=!1,this.state.currentColor=fg(e)}hideMagnifier(e){this.state.style.display="none"}showMagnifier(e){this.state.style.display="block"}moveMagnifier(e){this.state.style.background=fg(e);this.state.style.left=`${e.offsetX+10}px`,this.state.style.top=`${e.offsetY+10}px`}get magnifyingGlassStyle(){const{display:e,background:t,left:i,top:o}=this.state.style;return ho({display:e,"background-color":"block"===e?t:void 0,left:i,top:o})}}vg.template="o-spreadsheet-ColorPicker",vg.defaultProps={currentColor:""},vg.components={Popover:Wn},vg.props={onColorPicked:Function,currentColor:{type:String,optional:!0},maxHeight:{type:Number,optional:!0},anchorRect:Object},ro`
|
|
685
|
-
.o-color-picker-widget {
|
|
686
|
-
display: inline-block;
|
|
687
|
-
position: relative;
|
|
688
|
-
|
|
689
|
-
.o-color-picker-button-style {
|
|
690
|
-
display: flex;
|
|
691
|
-
justify-content: center;
|
|
692
|
-
align-items: center;
|
|
693
|
-
margin: 2px;
|
|
694
|
-
padding: 3px;
|
|
695
|
-
border-radius: 2px;
|
|
696
|
-
cursor: pointer;
|
|
697
|
-
&:not([disabled]):hover {
|
|
698
|
-
background-color: rgba(0, 0, 0, 0.08);
|
|
699
|
-
}
|
|
700
|
-
}
|
|
701
|
-
|
|
702
|
-
.o-color-picker-button {
|
|
703
|
-
> span {
|
|
704
|
-
border-bottom: 4px solid;
|
|
705
|
-
height: 16px;
|
|
706
|
-
margin-top: 2px;
|
|
707
|
-
}
|
|
708
|
-
|
|
709
|
-
&[disabled] {
|
|
710
|
-
pointer-events: none;
|
|
711
|
-
opacity: 0.3;
|
|
712
|
-
}
|
|
713
|
-
}
|
|
714
|
-
}
|
|
715
|
-
`;class bg extends t.Component{constructor(){super(...arguments),this.colorPickerButtonRef=t.useRef("colorPickerButton")}get iconStyle(){return this.props.currentColor?`border-color: ${this.props.currentColor}`:"border-bottom-style: hidden"}get colorPickerAnchorRect(){const e=this.colorPickerButtonRef.el.getBoundingClientRect();return{x:e.x,y:e.y,width:e.width,height:e.height}}}bg.template="o-spreadsheet-ColorPickerWidget",bg.components={ColorPicker:vg},bg.props={currentColor:{type:String,optional:!0},toggleColorPicker:Function,showColorPicker:Boolean,onColorPicked:Function,icon:String,title:{type:String,optional:!0},disabled:{type:Boolean,optional:!0},dropdownMaxHeight:{type:Number,optional:!0},class:{type:String,optional:!0}};class Sg extends t.Component{constructor(){super(...arguments),this.state=t.useState({fillColorTool:!1})}onClick(e){this.state.fillColorTool=!1}setup(){t.useExternalListener(window,"click",this.onClick)}toggleColorPicker(){this.state.fillColorTool=!this.state.fillColorTool}updateBackgroundColor(e){this.props.updateChart({background:e})}updateTitle(e){this.props.updateChart({title:e.target.value})}updateSelect(e,t){this.props.updateChart({[e]:t.target.value})}}Sg.template="o-spreadsheet-LineBarPieDesignPanel",Sg.components={ColorPickerWidget:bg},Sg.props={figureId:String,definition:Object,updateChart:Function};class Cg extends Sg{}Cg.template="o-spreadsheet-BarChartDesignPanel";class Eg extends t.Component{constructor(){super(...arguments),this.state=t.useState({dataRangeDispatchResult:void 0}),this.dataRange=this.props.definition.dataRange}get configurationErrorMessages(){var e;return[...(null===(e=this.state.dataRangeDispatchResult)||void 0===e?void 0:e.reasons)||[]].map((e=>jo.Errors[e]||jo.Errors.Unexpected))}get isDataRangeInvalid(){var e;return!!(null===(e=this.state.dataRangeDispatchResult)||void 0===e?void 0:e.isCancelledBecause(36))}onDataRangeChanged(e){this.dataRange=e[0]}updateDataRange(){this.state.dataRangeDispatchResult=this.props.updateChart({dataRange:this.dataRange})}}Eg.template="o-spreadsheet-GaugeChartConfigPanel",Eg.components={SelectionInput:dg},Eg.props={figureId:String,definition:Object,updateChart:Function},ro`
|
|
716
|
-
.o-gauge-color-set {
|
|
717
|
-
table {
|
|
718
|
-
table-layout: fixed;
|
|
719
|
-
margin-top: 2%;
|
|
720
|
-
display: table;
|
|
721
|
-
text-align: left;
|
|
722
|
-
font-size: 12px;
|
|
723
|
-
line-height: 18px;
|
|
724
|
-
width: 100%;
|
|
725
|
-
}
|
|
726
|
-
th.o-gauge-color-set-colorPicker {
|
|
727
|
-
width: 8%;
|
|
728
|
-
}
|
|
729
|
-
th.o-gauge-color-set-text {
|
|
730
|
-
width: 40%;
|
|
731
|
-
}
|
|
732
|
-
th.o-gauge-color-set-value {
|
|
733
|
-
width: 22%;
|
|
734
|
-
}
|
|
735
|
-
th.o-gauge-color-set-type {
|
|
736
|
-
width: 30%;
|
|
737
|
-
}
|
|
738
|
-
input,
|
|
739
|
-
select {
|
|
740
|
-
width: 100%;
|
|
741
|
-
height: 100%;
|
|
742
|
-
box-sizing: border-box;
|
|
743
|
-
}
|
|
744
|
-
}
|
|
745
|
-
`;class wg extends t.Component{constructor(){super(...arguments),this.state=t.useState({openedMenu:void 0,sectionRuleDispatchResult:void 0})}setup(){t.useExternalListener(window,"click",this.closeMenus)}get designErrorMessages(){var e;return[...(null===(e=this.state.sectionRuleDispatchResult)||void 0===e?void 0:e.reasons)||[]].map((e=>jo.Errors[e]||jo.Errors.Unexpected))}updateBackgroundColor(e){this.state.openedMenu=void 0,this.props.updateChart({background:e})}updateTitle(e){this.props.updateChart({title:e.target.value})}isRangeMinInvalid(){var e,t,i;return!!((null===(e=this.state.sectionRuleDispatchResult)||void 0===e?void 0:e.isCancelledBecause(37))||(null===(t=this.state.sectionRuleDispatchResult)||void 0===t?void 0:t.isCancelledBecause(38))||(null===(i=this.state.sectionRuleDispatchResult)||void 0===i?void 0:i.isCancelledBecause(41)))}isRangeMaxInvalid(){var e,t,i;return!!((null===(e=this.state.sectionRuleDispatchResult)||void 0===e?void 0:e.isCancelledBecause(39))||(null===(t=this.state.sectionRuleDispatchResult)||void 0===t?void 0:t.isCancelledBecause(40))||(null===(i=this.state.sectionRuleDispatchResult)||void 0===i?void 0:i.isCancelledBecause(41)))}get isLowerInflectionPointInvalid(){var e,t;return!(!(null===(e=this.state.sectionRuleDispatchResult)||void 0===e?void 0:e.isCancelledBecause(42))&&!(null===(t=this.state.sectionRuleDispatchResult)||void 0===t?void 0:t.isCancelledBecause(44)))}get isUpperInflectionPointInvalid(){var e,t;return!(!(null===(e=this.state.sectionRuleDispatchResult)||void 0===e?void 0:e.isCancelledBecause(43))&&!(null===(t=this.state.sectionRuleDispatchResult)||void 0===t?void 0:t.isCancelledBecause(44)))}updateInflectionPointValue(e,t){const i=Ne(this.props.definition.sectionRule);i[e].value=t.target.value,this.updateSectionRule(i)}updateInflectionPointType(e,t){const i=Ne(this.props.definition.sectionRule);i[e].type=t.target.value,this.updateSectionRule(i)}updateSectionColor(e,t){const i=Ne(this.props.definition.sectionRule);i.colors[e]=t,this.updateSectionRule(i),this.closeMenus()}updateRangeMin(e){let t=Ne(this.props.definition.sectionRule);t={...t,rangeMin:e.target.value},this.updateSectionRule(t)}updateRangeMax(e){let t=Ne(this.props.definition.sectionRule);t={...t,rangeMax:e.target.value},this.updateSectionRule(t)}toggleMenu(e){const t=this.state.openedMenu===e;this.closeMenus(),t||(this.state.openedMenu=e)}updateSectionRule(e){this.state.sectionRuleDispatchResult=this.props.updateChart({sectionRule:e})}closeMenus(){this.state.openedMenu=void 0}}wg.template="o-spreadsheet-GaugeChartDesignPanel",wg.components={ColorPickerWidget:bg},wg.props={figureId:String,definition:Object,updateChart:Function};class yg extends ug{get canTreatLabelsAsText(){const e=this.env.model.getters.getChart(this.props.figureId);return!!(e&&e instanceof Sn)&&Cn(e.labelRange,this.env.model.getters)}onUpdateLabelsAsText(e){this.props.updateChart({labelsAsText:e.target.checked})}onUpdateStacked(e){this.props.updateChart({stacked:e.target.checked})}onUpdateAggregated(e){this.props.updateChart({aggregated:e.target.checked})}}yg.template="o-spreadsheet-LineConfigPanel";class xg extends Sg{}xg.template="o-spreadsheet-LineChartDesignPanel";class Ig extends t.Component{constructor(){super(...arguments),this.state=t.useState({keyValueDispatchResult:void 0,baselineDispatchResult:void 0}),this.keyValue=this.props.definition.keyValue,this.baseline=this.props.definition.baseline}get errorMessages(){var e,t;return[...(null===(e=this.state.keyValueDispatchResult)||void 0===e?void 0:e.reasons)||[],...(null===(t=this.state.baselineDispatchResult)||void 0===t?void 0:t.reasons)||[]].map((e=>jo.Errors[e]||jo.Errors.Unexpected))}get isKeyValueInvalid(){var e;return!!(null===(e=this.state.keyValueDispatchResult)||void 0===e?void 0:e.isCancelledBecause(34))}get isBaselineInvalid(){var e;return!!(null===(e=this.state.keyValueDispatchResult)||void 0===e?void 0:e.isCancelledBecause(35))}onKeyValueRangeChanged(e){this.keyValue=e[0]}updateKeyValueRange(){this.state.keyValueDispatchResult=this.props.updateChart({keyValue:this.keyValue})}onBaselineRangeChanged(e){this.baseline=e[0]}updateBaselineRange(){this.state.baselineDispatchResult=this.props.updateChart({baseline:this.baseline})}updateBaselineMode(e){this.props.updateChart({baselineMode:e.target.value})}}Ig.template="o-spreadsheet-ScorecardChartConfigPanel",Ig.components={SelectionInput:dg},Ig.props={figureId:String,definition:Object,updateChart:Function};class Rg extends t.Component{constructor(){super(...arguments),this.state=t.useState({openedColorPicker:void 0})}setup(){t.useExternalListener(window,"click",this.closeMenus)}updateTitle(e){this.props.updateChart({title:e.target.value})}updateBaselineDescr(e){this.props.updateChart({baselineDescr:e.target.value})}toggleColorPicker(e){this.state.openedColorPicker===e?this.state.openedColorPicker=void 0:this.state.openedColorPicker=e}setColor(e,t){switch(t){case"backgroundColor":this.props.updateChart({background:e});break;case"baselineColorDown":this.props.updateChart({baselineColorDown:e});break;case"baselineColorUp":this.props.updateChart({baselineColorUp:e})}this.closeMenus()}closeMenus(){this.state.openedColorPicker=void 0}}Rg.template="o-spreadsheet-ScorecardChartDesignPanel",Rg.components={ColorPickerWidget:bg},Rg.props={figureId:String,definition:Object,updateChart:Function};const Tg=new Mn;Tg.add("line",{configuration:yg,design:xg}).add("bar",{configuration:gg,design:Cg}).add("pie",{configuration:ug,design:Sg}).add("gauge",{configuration:Eg,design:wg}).add("scorecard",{configuration:Ig,design:Rg}),ro`
|
|
746
|
-
.o-chart {
|
|
747
|
-
.o-panel {
|
|
748
|
-
display: flex;
|
|
749
|
-
.o-panel-element {
|
|
750
|
-
flex: 1 0 auto;
|
|
751
|
-
padding: 8px 0px;
|
|
752
|
-
text-align: center;
|
|
753
|
-
cursor: pointer;
|
|
754
|
-
border-right: 1px solid darkgray;
|
|
755
|
-
&.inactive {
|
|
756
|
-
background-color: ${v};
|
|
757
|
-
border-bottom: 1px solid darkgray;
|
|
758
|
-
}
|
|
759
|
-
.fa {
|
|
760
|
-
margin-right: 4px;
|
|
761
|
-
}
|
|
762
|
-
}
|
|
763
|
-
.o-panel-element:last-child {
|
|
764
|
-
border-right: none;
|
|
765
|
-
}
|
|
766
|
-
}
|
|
767
|
-
}
|
|
768
|
-
`;class Ag extends t.Component{constructor(){super(...arguments),this.shouldUpdateChart=!0}get figureId(){return this.state.figureId}get sheetId(){return this.state.sheetId}setup(){const e=this.env.model.getters.getSelectedFigureId();if(!e)throw new Error(s("Cannot open the chart side panel while no chart are selected"));this.state=t.useState({panel:"configuration",figureId:e,sheetId:this.env.model.getters.getActiveSheetId()}),t.onWillUpdateProps((()=>{const e=this.env.model.getters.getSelectedFigureId();e&&e!==this.state.figureId?(this.state.figureId=e,this.state.sheetId=this.env.model.getters.getActiveSheetId(),this.shouldUpdateChart=!1):this.shouldUpdateChart=!0,this.env.model.getters.isChartDefined(this.figureId)||this.props.onCloseSidePanel()}))}updateChart(e){if(!this.shouldUpdateChart)return;const t={...this.getChartDefinition(),...e};return this.env.model.dispatch("UPDATE_CHART",{definition:t,id:this.figureId,sheetId:this.sheetId})}onTypeChange(e){const t=this.env.model.getters.getContextCreationChart(this.figureId);if(!t)throw new Error("Chart not defined.");const i=function(e,t){return On.get(t).getChartDefinitionFromContextCreation(e)}(t,e);this.env.model.dispatch("UPDATE_CHART",{definition:i,id:this.figureId,sheetId:this.sheetId})}get chartPanel(){const e=this.env.model.getters.getChartType(this.figureId);if(!e)throw new Error("Chart not defined.");const t=Tg.get(e);if(!t)throw new Error(`Component is not defined for type ${e}`);return t}getChartDefinition(e=this.figureId){return this.env.model.getters.getChartDefinition(e)}get chartTypes(){return function(){const e={};for(const t of On.getKeys())e[t]=On.get(t).name;return e}()}activatePanel(e){this.state.panel=e}}Ag.template="o-spreadsheet-ChartPanel",Ag.props={onCloseSidePanel:Function};function Mg(e){e=`<svg xmlns="http://www.w3.org/2000/svg" ${e.slice(4)}`;const t=new Image;return t.src="data:image/svg+xml; charset=utf8, "+encodeURIComponent(e),t}const Og={arrowGood:{template:"ARROW_UP",img:Mg('<svg class="o-cf-icon arrow-up" width="10" height="10" focusable="false" viewBox="0 0 448 512"><path fill="#00A04A" d="M34.9 289.5l-22.2-22.2c-9.4-9.4-9.4-24.6 0-33.9L207 39c9.4-9.4 24.6-9.4 33.9 0l194.3 194.3c9.4 9.4 9.4 24.6 0 33.9L413 289.4c-9.5 9.5-25 9.3-34.3-.4L264 168.6V456c0 13.3-10.7 24-24 24h-32c-13.3 0-24-10.7-24-24V168.6L69.2 289.1c-9.3 9.8-24.8 10-34.3.4z"></path></svg>')},arrowNeutral:{template:"ARROW_RIGHT",img:Mg('<svg class="o-cf-icon arrow-right" width="10" height="10" focusable="false" viewBox="0 0 448 512"><path fill="#F0AD4E" d="M190.5 66.9l22.2-22.2c9.4-9.4 24.6-9.4 33.9 0L441 239c9.4 9.4 9.4 24.6 0 33.9L246.6 467.3c-9.4 9.4-24.6 9.4-33.9 0l-22.2-22.2c-9.5-9.5-9.3-25 .4-34.3L311.4 296H24c-13.3 0-24-10.7-24-24v-32c0-13.3 10.7-24 24-24h287.4L190.9 101.2c-9.8-9.3-10-24.8-.4-34.3z"></path></svg>')},arrowBad:{template:"ARROW_DOWN",img:Mg('<svg class="o-cf-icon arrow-down" width="10" height="10" focusable="false" viewBox="0 0 448 512"><path fill="#DC6965" d="M413.1 222.5l22.2 22.2c9.4 9.4 9.4 24.6 0 33.9L241 473c-9.4 9.4-24.6 9.4-33.9 0L12.7 278.6c-9.4-9.4-9.4-24.6 0-33.9l22.2-22.2c9.5-9.5 25-9.3 34.3.4L184 343.4V56c0-13.3 10.7-24 24-24h32c13.3 0 24 10.7 24 24v287.4l114.8-120.5c9.3-9.8 24.8-10 34.3-.4z"></path></svg>')},smileyGood:{template:"SMILE",img:Mg('<svg class="o-cf-icon smile" width="10" height="10" focusable="false" viewBox="0 0 496 512"><path fill="#00A04A" d="M248 8C111 8 0 119 0 256s111 248 248 248 248-111 248-248S385 8 248 8zm0 448c-110.3 0-200-89.7-200-200S137.7 56 248 56s200 89.7 200 200-89.7 200-200 200zm-80-216c17.7 0 32-14.3 32-32s-14.3-32-32-32-32 14.3-32 32 14.3 32 32 32zm160 0c17.7 0 32-14.3 32-32s-14.3-32-32-32-32 14.3-32 32 14.3 32 32 32zm4 72.6c-20.8 25-51.5 39.4-84 39.4s-63.2-14.3-84-39.4c-8.5-10.2-23.7-11.5-33.8-3.1-10.2 8.5-11.5 23.6-3.1 33.8 30 36 74.1 56.6 120.9 56.6s90.9-20.6 120.9-56.6c8.5-10.2 7.1-25.3-3.1-33.8-10.1-8.4-25.3-7.1-33.8 3.1z"></path></svg>')},smileyNeutral:{template:"MEH",img:Mg('<svg class="o-cf-icon meh" width="10" height="10" focusable="false" viewBox="0 0 496 512"><path fill="#F0AD4E" d="M248 8C111 8 0 119 0 256s111 248 248 248 248-111 248-248S385 8 248 8zm0 448c-110.3 0-200-89.7-200-200S137.7 56 248 56s200 89.7 200 200-89.7 200-200 200zm-80-216c17.7 0 32-14.3 32-32s-14.3-32-32-32-32 14.3-32 32 14.3 32 32 32zm160-64c-17.7 0-32 14.3-32 32s14.3 32 32 32 32-14.3 32-32-14.3-32-32-32zm8 144H160c-13.2 0-24 10.8-24 24s10.8 24 24 24h176c13.2 0 24-10.8 24-24s-10.8-24-24-24z"></path></svg>')},smileyBad:{template:"FROWN",img:Mg('<svg class="o-cf-icon frown" width="10" height="10" focusable="false" viewBox="0 0 496 512"><path fill="#DC6965" d="M248 8C111 8 0 119 0 256s111 248 248 248 248-111 248-248S385 8 248 8zm0 448c-110.3 0-200-89.7-200-200S137.7 56 248 56s200 89.7 200 200-89.7 200-200 200zm-80-216c17.7 0 32-14.3 32-32s-14.3-32-32-32-32 14.3-32 32 14.3 32 32 32zm160-64c-17.7 0-32 14.3-32 32s14.3 32 32 32 32-14.3 32-32-14.3-32-32-32zm-80 128c-40.2 0-78 17.7-103.8 48.6-8.5 10.2-7.1 25.3 3.1 33.8 10.2 8.4 25.3 7.1 33.8-3.1 16.6-19.9 41-31.4 66.9-31.4s50.3 11.4 66.9 31.4c8.1 9.7 23.1 11.9 33.8 3.1 10.2-8.5 11.5-23.6 3.1-33.8C326 321.7 288.2 304 248 304z"></path></svg>')},dotGood:{template:"GREEN_DOT",img:Mg('<svg class="o-cf-icon green-dot" width="10" height="10" focusable="false" viewBox="0 0 512 512"><path fill="#00A04A" d="M256 8C119 8 8 119 8 256s111 248 248 248 248-111 248-248S393 8 256 8z"></path></svg>')},dotNeutral:{template:"YELLOW_DOT",img:Mg('<svg class="o-cf-icon yellow-dot" width="10" height="10" focusable="false" viewBox="0 0 512 512"><path fill="#F0AD4E" d="M256 8C119 8 8 119 8 256s111 248 248 248 248-111 248-248S393 8 256 8z"></path></svg>')},dotBad:{template:"RED_DOT",img:Mg('<svg class="o-cf-icon red-dot" width="10" height="10" focusable="false" viewBox="0 0 512 512"><path fill="#DC6965" d="M256 8C119 8 8 119 8 256s111 248 248 248 248-111 248-248S393 8 256 8z"></path></svg>')}},Ng={arrows:{good:"arrowGood",neutral:"arrowNeutral",bad:"arrowBad"},smiley:{good:"smileyGood",neutral:"smileyNeutral",bad:"smileyBad"},dots:{good:"dotGood",neutral:"dotNeutral",bad:"dotBad"}};ro`
|
|
769
|
-
.o-icon-picker {
|
|
770
|
-
position: absolute;
|
|
771
|
-
z-index: ${le.IconPicker};
|
|
772
|
-
box-shadow: 1px 2px 5px 2px rgba(51, 51, 51, 0.15);
|
|
773
|
-
background-color: white;
|
|
774
|
-
padding: 2px 1px;
|
|
775
|
-
}
|
|
776
|
-
.o-cf-icon-line {
|
|
777
|
-
display: flex;
|
|
778
|
-
padding: 3px 6px;
|
|
779
|
-
}
|
|
780
|
-
.o-icon-picker-item {
|
|
781
|
-
margin: 0px 2px;
|
|
782
|
-
&:hover {
|
|
783
|
-
background-color: rgba(0, 0, 0, 0.08);
|
|
784
|
-
outline: 1px solid gray;
|
|
785
|
-
}
|
|
786
|
-
}
|
|
787
|
-
`;class _g extends t.Component{constructor(){super(...arguments),this.icons=Og,this.iconSets=Ng}onIconClick(e){e&&this.props.onIconPicked(e)}}_g.template="o-spreadsheet-IconPicker",_g.props={onIconPicked:Function},ro`
|
|
788
|
-
label {
|
|
789
|
-
vertical-align: middle;
|
|
790
|
-
}
|
|
791
|
-
.o_cf_radio_item {
|
|
792
|
-
margin-right: 10%;
|
|
793
|
-
}
|
|
794
|
-
.radio input:checked {
|
|
795
|
-
color: #e9ecef;
|
|
796
|
-
border-color: #00a09d;
|
|
797
|
-
background-color: #00a09d;
|
|
798
|
-
}
|
|
799
|
-
.o-cf-editor {
|
|
800
|
-
border-bottom: solid;
|
|
801
|
-
border-color: lightgrey;
|
|
802
|
-
}
|
|
803
|
-
.o-cf {
|
|
804
|
-
.o-cf-type-selector {
|
|
805
|
-
*,
|
|
806
|
-
::after,
|
|
807
|
-
::before {
|
|
808
|
-
box-sizing: border-box;
|
|
809
|
-
}
|
|
810
|
-
margin-top: 10px;
|
|
811
|
-
display: flex;
|
|
812
|
-
}
|
|
813
|
-
.o-section-subtitle:first-child {
|
|
814
|
-
margin-top: 0px;
|
|
815
|
-
}
|
|
816
|
-
.o-cf-cursor-ptr {
|
|
817
|
-
cursor: pointer;
|
|
818
|
-
}
|
|
819
|
-
.o-cf-preview {
|
|
820
|
-
background-color: #fff;
|
|
821
|
-
border-bottom: 1px solid #ccc;
|
|
822
|
-
display: flex;
|
|
823
|
-
height: 60px;
|
|
824
|
-
padding: 10px;
|
|
825
|
-
position: relative;
|
|
826
|
-
&:hover {
|
|
827
|
-
background-color: rgba(0, 0, 0, 0.08);
|
|
828
|
-
}
|
|
829
|
-
&:not(:hover) .o-cf-delete-button {
|
|
830
|
-
display: none;
|
|
831
|
-
}
|
|
832
|
-
.o-cf-preview-image {
|
|
833
|
-
border: 1px solid lightgrey;
|
|
834
|
-
height: 50px;
|
|
835
|
-
line-height: 50px;
|
|
836
|
-
margin-right: 15px;
|
|
837
|
-
margin-top: 3px;
|
|
838
|
-
position: absolute;
|
|
839
|
-
text-align: center;
|
|
840
|
-
width: 50px;
|
|
841
|
-
}
|
|
842
|
-
.o-cf-preview-icon {
|
|
843
|
-
border: 1px solid lightgrey;
|
|
844
|
-
position: absolute;
|
|
845
|
-
height: 50px;
|
|
846
|
-
line-height: 50px;
|
|
847
|
-
margin-right: 15px;
|
|
848
|
-
margin-top: 3px;
|
|
849
|
-
display: flex;
|
|
850
|
-
justify-content: space-around;
|
|
851
|
-
align-items: center;
|
|
852
|
-
}
|
|
853
|
-
.o-cf-preview-description {
|
|
854
|
-
left: 65px;
|
|
855
|
-
margin-bottom: auto;
|
|
856
|
-
margin-right: 8px;
|
|
857
|
-
margin-top: auto;
|
|
858
|
-
position: relative;
|
|
859
|
-
width: 142px;
|
|
860
|
-
.o-cf-preview-description-rule {
|
|
861
|
-
margin-bottom: 4px;
|
|
862
|
-
overflow: hidden;
|
|
863
|
-
text-overflow: ellipsis;
|
|
864
|
-
font-weight: 600;
|
|
865
|
-
color: #303030;
|
|
866
|
-
max-height: 2.8em;
|
|
867
|
-
line-height: 1.4em;
|
|
868
|
-
}
|
|
869
|
-
.o-cf-preview-range {
|
|
870
|
-
text-overflow: ellipsis;
|
|
871
|
-
font-size: 12px;
|
|
872
|
-
overflow: hidden;
|
|
873
|
-
}
|
|
874
|
-
}
|
|
875
|
-
.o-cf-delete {
|
|
876
|
-
color: dimgrey;
|
|
877
|
-
left: 90%;
|
|
878
|
-
top: 39%;
|
|
879
|
-
position: absolute;
|
|
880
|
-
}
|
|
881
|
-
.o-cf-reorder {
|
|
882
|
-
color: gray;
|
|
883
|
-
left: 90%;
|
|
884
|
-
position: absolute;
|
|
885
|
-
height: 100%;
|
|
886
|
-
width: 10%;
|
|
887
|
-
}
|
|
888
|
-
.o-cf-reorder-button:hover {
|
|
889
|
-
cursor: pointer;
|
|
890
|
-
background-color: rgba(0, 0, 0, 0.08);
|
|
891
|
-
}
|
|
892
|
-
.o-cf-reorder-button-up {
|
|
893
|
-
width: 15px;
|
|
894
|
-
height: 20px;
|
|
895
|
-
padding: 5px;
|
|
896
|
-
padding-top: 0px;
|
|
897
|
-
}
|
|
898
|
-
.o-cf-reorder-button-down {
|
|
899
|
-
width: 15px;
|
|
900
|
-
height: 20px;
|
|
901
|
-
bottom: 20px;
|
|
902
|
-
padding: 5px;
|
|
903
|
-
padding-top: 0px;
|
|
904
|
-
position: absolute;
|
|
905
|
-
}
|
|
906
|
-
}
|
|
907
|
-
.o-cf-ruleEditor {
|
|
908
|
-
font-size: 12px;
|
|
909
|
-
line-height: 1.5;
|
|
910
|
-
.o-selection-cf {
|
|
911
|
-
margin-bottom: 3%;
|
|
912
|
-
}
|
|
913
|
-
.o-cell-content {
|
|
914
|
-
font-size: 12px;
|
|
915
|
-
font-weight: 500;
|
|
916
|
-
padding: 0 12px;
|
|
917
|
-
margin: 0;
|
|
918
|
-
line-height: 35px;
|
|
919
|
-
}
|
|
920
|
-
}
|
|
921
|
-
.o-cf-btn-link {
|
|
922
|
-
font-size: 14px;
|
|
923
|
-
padding: 20px 24px 11px 24px;
|
|
924
|
-
height: 44px;
|
|
925
|
-
cursor: pointer;
|
|
926
|
-
text-decoration: none;
|
|
927
|
-
}
|
|
928
|
-
.o-cf-btn-link:hover {
|
|
929
|
-
color: #003a39;
|
|
930
|
-
text-decoration: none;
|
|
931
|
-
}
|
|
932
|
-
.o-cf-error {
|
|
933
|
-
color: red;
|
|
934
|
-
margin-top: 10px;
|
|
935
|
-
}
|
|
936
|
-
}
|
|
937
|
-
.o-cf-cell-is-rule {
|
|
938
|
-
.o-cf-preview-line {
|
|
939
|
-
border: 1px solid darkgrey;
|
|
940
|
-
padding: 10px;
|
|
941
|
-
}
|
|
942
|
-
.o-cell-is-operator {
|
|
943
|
-
margin-bottom: 5px;
|
|
944
|
-
width: 96%;
|
|
945
|
-
}
|
|
946
|
-
.o-cell-is-value {
|
|
947
|
-
margin-bottom: 5px;
|
|
948
|
-
width: 96%;
|
|
949
|
-
}
|
|
950
|
-
.o-color-picker-widget .o-color-picker-button {
|
|
951
|
-
pointer-events: all;
|
|
952
|
-
cursor: default;
|
|
953
|
-
}
|
|
954
|
-
}
|
|
955
|
-
.o-cf-color-scale-editor {
|
|
956
|
-
.o-threshold {
|
|
957
|
-
display: flex;
|
|
958
|
-
flex-direction: row;
|
|
959
|
-
justify-content: center;
|
|
960
|
-
align-items: center;
|
|
961
|
-
select {
|
|
962
|
-
width: 100%;
|
|
963
|
-
}
|
|
964
|
-
.o-threshold-value {
|
|
965
|
-
margin-left: 2%;
|
|
966
|
-
width: 20%;
|
|
967
|
-
min-width: 0px; // input overflows in Firefox otherwise
|
|
968
|
-
}
|
|
969
|
-
.o-threshold-value:disabled {
|
|
970
|
-
background-color: #edebed;
|
|
971
|
-
}
|
|
972
|
-
}
|
|
973
|
-
.o-cf-preview-gradient {
|
|
974
|
-
border: 1px solid darkgrey;
|
|
975
|
-
padding: 10px;
|
|
976
|
-
border-radius: 4px;
|
|
977
|
-
}
|
|
978
|
-
}
|
|
979
|
-
.o-cf-iconset-rule {
|
|
980
|
-
font-size: 12;
|
|
981
|
-
.o-cf-iconsets {
|
|
982
|
-
display: flex;
|
|
983
|
-
justify-content: space-between;
|
|
984
|
-
.o-cf-iconset {
|
|
985
|
-
border: 1px solid #dadce0;
|
|
986
|
-
border-radius: 4px;
|
|
987
|
-
display: inline-flex;
|
|
988
|
-
padding: 5px 8px;
|
|
989
|
-
width: 25%;
|
|
990
|
-
cursor: pointer;
|
|
991
|
-
justify-content: space-between;
|
|
992
|
-
.o-cf-icon {
|
|
993
|
-
display: inline;
|
|
994
|
-
margin-left: 1%;
|
|
995
|
-
margin-right: 1%;
|
|
996
|
-
}
|
|
997
|
-
svg {
|
|
998
|
-
vertical-align: baseline;
|
|
999
|
-
}
|
|
1000
|
-
}
|
|
1001
|
-
.o-cf-iconset:hover {
|
|
1002
|
-
background-color: rgba(0, 0, 0, 0.08);
|
|
1003
|
-
}
|
|
1004
|
-
}
|
|
1005
|
-
.o-inflection {
|
|
1006
|
-
.o-cf-icon-button {
|
|
1007
|
-
display: inline-block;
|
|
1008
|
-
border: 1px solid #dadce0;
|
|
1009
|
-
border-radius: 4px;
|
|
1010
|
-
cursor: pointer;
|
|
1011
|
-
padding: 1px 2px;
|
|
1012
|
-
}
|
|
1013
|
-
.o-cf-icon-button:hover {
|
|
1014
|
-
background-color: rgba(0, 0, 0, 0.08);
|
|
1015
|
-
}
|
|
1016
|
-
table {
|
|
1017
|
-
table-layout: fixed;
|
|
1018
|
-
margin-top: 2%;
|
|
1019
|
-
display: table;
|
|
1020
|
-
text-align: left;
|
|
1021
|
-
font-size: 12px;
|
|
1022
|
-
line-height: 18px;
|
|
1023
|
-
width: 100%;
|
|
1024
|
-
}
|
|
1025
|
-
th.o-cf-iconset-icons {
|
|
1026
|
-
width: 8%;
|
|
1027
|
-
}
|
|
1028
|
-
th.o-cf-iconset-text {
|
|
1029
|
-
width: 28%;
|
|
1030
|
-
}
|
|
1031
|
-
th.o-cf-iconset-operator {
|
|
1032
|
-
width: 14%;
|
|
1033
|
-
}
|
|
1034
|
-
th.o-cf-iconset-type {
|
|
1035
|
-
width: 28%;
|
|
1036
|
-
}
|
|
1037
|
-
th.o-cf-iconset-value {
|
|
1038
|
-
width: 26%;
|
|
1039
|
-
}
|
|
1040
|
-
input,
|
|
1041
|
-
select {
|
|
1042
|
-
width: 100%;
|
|
1043
|
-
height: 100%;
|
|
1044
|
-
box-sizing: border-box;
|
|
1045
|
-
}
|
|
1046
|
-
}
|
|
1047
|
-
.o-cf-iconset-reverse {
|
|
1048
|
-
margin-bottom: 2%;
|
|
1049
|
-
margin-top: 2%;
|
|
1050
|
-
.o-cf-label {
|
|
1051
|
-
display: inline-block;
|
|
1052
|
-
vertical-align: bottom;
|
|
1053
|
-
margin-bottom: 2px;
|
|
1054
|
-
}
|
|
1055
|
-
}
|
|
1056
|
-
}
|
|
1057
|
-
`;class Fg extends t.Component{constructor(){super(...arguments),this.icons=Og,this.cellIsOperators=Zo,this.iconSets=Ng,this.getTextDecoration=ao,this.colorNumberString=mt}setup(){this.activeSheetId=this.env.model.getters.getActiveSheetId(),this.state=t.useState({mode:"list",errors:[],rules:this.getDefaultRules()});const e=this.env.model.getters.getActiveSheetId(),i=this.env.model.getters.getRulesSelection(e,this.props.selection||[]);if(1===i.length){const e=this.conditionalFormats.find((e=>e.id===i[0]));e&&this.editConditionalFormat(e)}t.onWillUpdateProps((e=>{const t=this.env.model.getters.getActiveSheetId();if(t!==this.activeSheetId)this.activeSheetId=t,this.switchToList();else if(e.selection!==this.props.selection){const t=this.env.model.getters.getActiveSheetId(),i=this.env.model.getters.getRulesSelection(t,e.selection||[]);if(1===i.length){const e=this.conditionalFormats.find((e=>e.id===i[0]));e&&this.editConditionalFormat(e)}else this.switchToList()}})),t.useExternalListener(window,"click",this.closeMenus)}get conditionalFormats(){return this.env.model.getters.getConditionalFormats(this.env.model.getters.getActiveSheetId())}get isRangeValid(){return this.state.errors.includes(24)}errorMessage(e){return qo.Errors[e]||qo.Errors.Unexpected}switchToList(){this.state.mode="list",this.state.currentCF=void 0,this.state.currentCFType=void 0,this.state.errors=[],this.state.rules=this.getDefaultRules()}getStyle(e){if("CellIsRule"===e.type)return ho({"font-weight":e.style.bold?"bold":"normal","text-decoration":ao(e.style),"font-style":e.style.italic?"italic":"normal",color:e.style.textColor||"none","background-color":e.style.fillColor||"none"});if("ColorScaleRule"===e.type){const t=mt(e.minimum.color),i=e.midpoint?mt(e.midpoint.color):null,o=mt(e.maximum.color),n="background-image: linear-gradient(to right, ";return i?n+t+", "+i+", "+o+")":n+t+", "+o+")"}return""}getDescription(e){switch(e.rule.type){case"CellIsRule":const t=Zo[e.rule.operator];return 1===e.rule.values.length?`${t} ${e.rule.values[0]}`:2===e.rule.values.length?n("%s %s and %s",t,e.rule.values[0],e.rule.values[1]):t;case"ColorScaleRule":return qo.ColorScale;case"IconSetRule":return qo.IconSet;default:return""}}saveConditionalFormat(){if(this.state.currentCF){if(this.state.currentCF.ranges.some((e=>!e.match(Ot))))return void(this.state.errors=[25]);const e=this.env.model.getters.getActiveSheetId(),t=this.env.model.dispatch("ADD_CONDITIONAL_FORMAT",{cf:{rule:this.getEditorRule(),id:"edit"===this.state.mode?this.state.currentCF.id:this.env.model.uuidGenerator.uuidv4()},ranges:this.state.currentCF.ranges.map((t=>this.env.model.getters.getRangeDataFromXc(e,t))),sheetId:e});t.isSuccessful?this.switchToList():this.state.errors=t.reasons}}getEditorRule(){switch(this.state.currentCFType){case"CellIsRule":return this.state.rules.cellIs;case"ColorScaleRule":return this.state.rules.colorScale;case"IconSetRule":return this.state.rules.iconSet}throw new Error(`Invalid cf type: ${this.state.currentCFType}`)}getDefaultRules(){return{cellIs:{type:"CellIsRule",operator:"IsNotEmpty",values:[],style:{fillColor:"#b6d7a8"}},colorScale:{type:"ColorScaleRule",minimum:{type:"value",color:16777215},midpoint:void 0,maximum:{type:"value",color:6989903}},iconSet:{type:"IconSetRule",icons:{upper:"arrowGood",middle:"arrowNeutral",lower:"arrowBad"},upperInflectionPoint:{type:"percentage",value:"66",operator:"gt"},lowerInflectionPoint:{type:"percentage",value:"33",operator:"gt"}}}}addConditionalFormat(){this.state.mode="add",this.state.currentCFType="CellIsRule",this.state.currentCF={id:this.env.model.uuidGenerator.uuidv4(),ranges:this.env.model.getters.getSelectedZones().map((e=>this.env.model.getters.zoneToXC(this.env.model.getters.getActiveSheetId(),e)))}}deleteConditionalFormat(e){this.env.model.dispatch("REMOVE_CONDITIONAL_FORMAT",{id:e.id,sheetId:this.env.model.getters.getActiveSheetId()})}editConditionalFormat(e){if("reorder"!==this.state.mode)switch(this.state.mode="edit",this.state.currentCF=e,this.state.currentCFType=e.rule.type,e.rule.type){case"CellIsRule":this.state.rules.cellIs=e.rule;break;case"ColorScaleRule":this.state.rules.colorScale=e.rule;break;case"IconSetRule":this.state.rules.iconSet=e.rule}}reorderConditionalFormats(){this.state.mode="reorder"}reorderRule(e,t){this.env.model.dispatch("MOVE_CONDITIONAL_FORMAT",{cfId:e.id,direction:t,sheetId:this.env.model.getters.getActiveSheetId()})}changeRuleType(e){this.state.currentCFType!==e&&this.state.rules&&(this.state.errors=[],this.state.currentCFType=e)}onRangesChanged(e){this.state.currentCF&&(this.state.currentCF.ranges=e)}toggleMenu(e){const t=this.state.openedMenu===e;this.closeMenus(),t||(this.state.openedMenu=e)}closeMenus(){this.state.openedMenu=void 0}get isValue1Invalid(){var e;return!!(null===(e=this.state.errors)||void 0===e?void 0:e.includes(51))}get isValue2Invalid(){var e;return!!(null===(e=this.state.errors)||void 0===e?void 0:e.includes(52))}toggleStyle(e){const t=this.state.rules.cellIs.style;t[e]=!t[e],this.closeMenus()}setColor(e,t){this.state.rules.cellIs.style[e]=t,this.closeMenus()}isValueInvalid(e){switch(e){case"minimum":return this.state.errors.includes(58)||this.state.errors.includes(50)||this.state.errors.includes(47)||this.state.errors.includes(53);case"midpoint":return this.state.errors.includes(59)||this.state.errors.includes(54)||this.state.errors.includes(49);case"maximum":return this.state.errors.includes(60)||this.state.errors.includes(55);default:return!1}}setColorScaleColor(e,t){const i=this.state.rules.colorScale[e];i&&(i.color=Number.parseInt(t.substr(1),16)),this.closeMenus()}getPreviewGradient(){var e;const t=this.state.rules.colorScale,i=mt(t.minimum.color),o=mt((null===(e=t.midpoint)||void 0===e?void 0:e.color)||y),n=mt(t.maximum.color),s="background-image: linear-gradient(to right, ";return void 0===t.midpoint?s+i+", "+n+")":s+i+", "+o+", "+n+")"}getThresholdColor(e){return mt(e?e.color:y)}onMidpointChange(e){const t=e.target.value,i=this.state.rules.colorScale;i.midpoint="none"===t?void 0:{color:y,value:"",...i.midpoint,type:t}}isInflectionPointInvalid(e){switch(e){case"lowerInflectionPoint":return this.state.errors.includes(57)||this.state.errors.includes(62)||this.state.errors.includes(48);case"upperInflectionPoint":return this.state.errors.includes(56)||this.state.errors.includes(61)||this.state.errors.includes(48);default:return!0}}reverseIcons(){const e=this.state.rules.iconSet.icons,t=e.upper;e.upper=e.lower,e.lower=t}setIconSet(e){const t=this.state.rules.iconSet.icons;t.upper=this.iconSets[e].good,t.middle=this.iconSets[e].neutral,t.lower=this.iconSets[e].bad}setIcon(e,t){this.state.rules.iconSet.icons[e]=t}}Fg.template="o-spreadsheet-ConditionalFormattingPanel",Fg.components={SelectionInput:dg,IconPicker:_g,ColorPickerWidget:bg},Fg.props={selection:{type:Object,optional:!0},onCloseSidePanel:Function},ro`
|
|
1058
|
-
.o-custom-currency {
|
|
1059
|
-
.o-format-proposals {
|
|
1060
|
-
color: black;
|
|
1061
|
-
}
|
|
1062
|
-
}
|
|
1063
|
-
`;class Dg extends t.Component{setup(){this.availableCurrencies=[],this.state=t.useState({selectedCurrencyIndex:0,currencyCode:"",currencySymbol:"",selectedFormatIndex:0}),t.onWillStart((()=>this.updateAvailableCurrencies()))}get formatProposals(){const e=this.availableCurrencies[this.state.selectedCurrencyIndex],t=this.initProposalBases(e.decimalPlaces),i=e.position,o="before"===e.position?"after":"before",n=this.state.currencySymbol.trim()?this.state.currencySymbol:"",s=this.state.currencyCode.trim()?this.state.currencyCode:"";return s||n?[...this.createFormatProposals(t,n,s,i),...this.createFormatProposals(t,n,s,o)]:[]}get isSameFormat(){const e=this.formatProposals[this.state.selectedFormatIndex];return!!e&&e.format===this.getCommonFormat()}async updateAvailableCurrencies(){var e,t;if(0===tg.getAll().length){(await(null===(t=(e=this.env).loadCurrencies)||void 0===t?void 0:t.call(e))||[]).forEach(((e,t)=>{tg.add(t.toString(),e)}))}const i={name:this.env._t(Yo.Custom),code:"",symbol:"",decimalPlaces:2,position:"after"};this.availableCurrencies=[i,...tg.getAll()]}updateSelectCurrency(e){const t=e.target;this.state.selectedCurrencyIndex=parseInt(t.value,10);const i=this.availableCurrencies[this.state.selectedCurrencyIndex];this.state.currencyCode=i.code,this.state.currencySymbol=i.symbol}updateCode(e){const t=e.target;this.state.currencyCode=t.value,this.initAvailableCurrencies()}updateSymbol(e){const t=e.target;this.state.currencySymbol=t.value,this.initAvailableCurrencies()}updateSelectFormat(e){const t=e.target;this.state.selectedFormatIndex=parseInt(t.value,10)}apply(){const e=this.formatProposals[this.state.selectedFormatIndex];this.env.model.dispatch("SET_FORMATTING",{sheetId:this.env.model.getters.getActiveSheetId(),target:this.env.model.getters.getSelectedZones(),format:e.format})}initAvailableCurrencies(){this.state.selectedCurrencyIndex=0}initProposalBases(e){const t=[{format:"#,##0",example:"1,000"}],i=e?"."+"0".repeat(e):"";return i&&t.push({format:"#,##0"+i,example:"1,000"+i}),t}createFormatProposals(e,t,i,o){let n=[];if(t)for(let i of e)n.push(this.createFormatProposal(o,i.example,i.format,t));if(i)for(let s of e){const e=("after"===o?" ":"")+i+" "+t;n.push(this.createFormatProposal(o,s.example,s.format,e))}return n}createFormatProposal(e,t,i,o){const n="[$"+o+"]";return{example:"before"===e?o+t:t+o,format:"before"===e?n+i:i+n}}getCommonFormat(){const e=this.env.model.getters.getSelectedZones(),t=this.env.model.getters.getActiveSheetId(),i=e.map((e=>this.env.model.getters.getEvaluatedCellsInZone(t,e))).flat(),o=i[0].format;return i.every((e=>e.format===o))?o:void 0}currencyDisplayName(e){return e.name+(e.code?` (${e.code})`:"")}}Dg.template="o-spreadsheet-CustomCurrencyPanel",Dg.props={onCloseSidePanel:Function},ro`
|
|
1064
|
-
.o-find-and-replace {
|
|
1065
|
-
.o-far-item {
|
|
1066
|
-
display: block;
|
|
1067
|
-
.o-far-checkbox {
|
|
1068
|
-
display: inline-block;
|
|
1069
|
-
.o-far-input {
|
|
1070
|
-
vertical-align: middle;
|
|
1071
|
-
}
|
|
1072
|
-
.o-far-label {
|
|
1073
|
-
position: relative;
|
|
1074
|
-
top: 1.5px;
|
|
1075
|
-
padding-left: 4px;
|
|
1076
|
-
}
|
|
1077
|
-
}
|
|
1078
|
-
}
|
|
1079
|
-
outline: none;
|
|
1080
|
-
height: 100%;
|
|
1081
|
-
.o-input-search-container {
|
|
1082
|
-
display: flex;
|
|
1083
|
-
.o-input-with-count {
|
|
1084
|
-
flex-grow: 1;
|
|
1085
|
-
width: auto;
|
|
1086
|
-
}
|
|
1087
|
-
.o-input-without-count {
|
|
1088
|
-
width: 100%;
|
|
1089
|
-
}
|
|
1090
|
-
.o-input-count {
|
|
1091
|
-
width: fit-content;
|
|
1092
|
-
padding: 4 0 4 4;
|
|
1093
|
-
}
|
|
1094
|
-
}
|
|
1095
|
-
}
|
|
1096
|
-
`;class kg extends t.Component{constructor(){super(...arguments),this.state=t.useState(this.initialState()),this.showFormulaState=!1,this.findAndReplaceRef=t.useRef("findAndReplace")}get hasSearchResult(){return null!==this.env.model.getters.getCurrentSelectedMatchIndex()}get pendingSearch(){return void 0!==this.debounceTimeoutId}setup(){this.showFormulaState=this.env.model.getters.shouldShowFormulas(),t.onMounted((()=>this.focusInput())),t.onWillUnmount((()=>{this.env.model.dispatch("CLEAR_SEARCH"),this.env.model.dispatch("SET_FORMULA_VISIBILITY",{show:this.showFormulaState})}))}onInput(e){this.state.toSearch=e.target.value,this.debouncedUpdateSearch()}onKeydownSearch(e){"Enter"===e.key&&(e.preventDefault(),e.stopPropagation(),this.onSelectNextCell())}onKeydownReplace(e){"Enter"===e.key&&(e.preventDefault(),e.stopPropagation(),this.replace())}onFocusSidePanel(){this.state.searchOptions.searchFormulas=this.env.model.getters.shouldShowFormulas(),this.env.model.dispatch("REFRESH_SEARCH")}searchFormulas(){this.env.model.dispatch("SET_FORMULA_VISIBILITY",{show:this.state.searchOptions.searchFormulas}),this.updateSearch()}onSelectPreviousCell(){this.env.model.dispatch("SELECT_SEARCH_PREVIOUS_MATCH")}onSelectNextCell(){this.env.model.dispatch("SELECT_SEARCH_NEXT_MATCH")}updateSearch(){this.env.model.dispatch("UPDATE_SEARCH",{toSearch:this.state.toSearch,searchOptions:this.state.searchOptions})}debouncedUpdateSearch(){clearTimeout(this.debounceTimeoutId),this.debounceTimeoutId=setTimeout((()=>{this.updateSearch(),this.debounceTimeoutId=void 0}),400)}replace(){this.env.model.dispatch("REPLACE_SEARCH",{replaceWith:this.state.replaceWith})}replaceAll(){this.env.model.dispatch("REPLACE_ALL_SEARCH",{replaceWith:this.state.replaceWith})}focusInput(){const e=this.findAndReplaceRef.el.querySelector("input");e&&e.focus()}initialState(){return{toSearch:"",replaceWith:"",searchOptions:{matchCase:!1,exactMatch:!1,searchFormulas:!1}}}}kg.template="o-spreadsheet-FindAndReplacePanel",kg.props={onCloseSidePanel:Function};const Lg=new Mn;Lg.add("ConditionalFormatting",{title:s("Conditional formatting"),Body:Fg}),Lg.add("ChartPanel",{title:s("Chart"),Body:Ag}),Lg.add("FindAndReplace",{title:s("Find and Replace"),Body:kg}),Lg.add("CustomCurrency",{title:s("Custom currency format"),Body:Dg});const Pg=new class extends Mn{constructor(){super(...arguments),this.mapping={},this.uuidGenerator=new Oi}add(e,t){const i={...t,id:this.uuidGenerator.uuidv4()};return super.add(e,i)}};ro`
|
|
1097
|
-
div.o-figure {
|
|
1098
|
-
box-sizing: border-box;
|
|
1099
|
-
position: absolute;
|
|
1100
|
-
width: 100%;
|
|
1101
|
-
height: 100%;
|
|
1102
|
-
user-select: none;
|
|
1103
|
-
|
|
1104
|
-
&:focus {
|
|
1105
|
-
outline: none;
|
|
1106
|
-
}
|
|
1107
|
-
}
|
|
1108
|
-
|
|
1109
|
-
div.o-figure-border {
|
|
1110
|
-
box-sizing: border-box;
|
|
1111
|
-
z-index: 1;
|
|
1112
|
-
}
|
|
1113
|
-
|
|
1114
|
-
.o-figure-wrapper {
|
|
1115
|
-
position: absolute;
|
|
1116
|
-
box-sizing: content-box;
|
|
1117
|
-
|
|
1118
|
-
.o-fig-anchor {
|
|
1119
|
-
z-index: ${le.ChartAnchor};
|
|
1120
|
-
position: absolute;
|
|
1121
|
-
width: ${8}px;
|
|
1122
|
-
height: ${8}px;
|
|
1123
|
-
background-color: #1a73e8;
|
|
1124
|
-
outline: ${1}px solid white;
|
|
1125
|
-
|
|
1126
|
-
&.o-top {
|
|
1127
|
-
cursor: n-resize;
|
|
1128
|
-
}
|
|
1129
|
-
&.o-topRight {
|
|
1130
|
-
cursor: ne-resize;
|
|
1131
|
-
}
|
|
1132
|
-
&.o-right {
|
|
1133
|
-
cursor: e-resize;
|
|
1134
|
-
}
|
|
1135
|
-
&.o-bottomRight {
|
|
1136
|
-
cursor: se-resize;
|
|
1137
|
-
}
|
|
1138
|
-
&.o-bottom {
|
|
1139
|
-
cursor: s-resize;
|
|
1140
|
-
}
|
|
1141
|
-
&.o-bottomLeft {
|
|
1142
|
-
cursor: sw-resize;
|
|
1143
|
-
}
|
|
1144
|
-
&.o-left {
|
|
1145
|
-
cursor: w-resize;
|
|
1146
|
-
}
|
|
1147
|
-
&.o-topLeft {
|
|
1148
|
-
cursor: nw-resize;
|
|
1149
|
-
}
|
|
1150
|
-
}
|
|
1151
|
-
|
|
1152
|
-
.o-figure-menu {
|
|
1153
|
-
right: 0px;
|
|
1154
|
-
display: none;
|
|
1155
|
-
position: absolute;
|
|
1156
|
-
padding: 5px;
|
|
1157
|
-
}
|
|
1158
|
-
|
|
1159
|
-
.o-figure-menu-item {
|
|
1160
|
-
cursor: pointer;
|
|
1161
|
-
}
|
|
1162
|
-
|
|
1163
|
-
.o-figure.active:focus,
|
|
1164
|
-
.o-figure:hover {
|
|
1165
|
-
.o-figure-menu {
|
|
1166
|
-
display: flex;
|
|
1167
|
-
}
|
|
1168
|
-
}
|
|
1169
|
-
}
|
|
1170
|
-
`;class Ug extends t.Component{constructor(){super(...arguments),this.figureRef=t.useRef("figure")}get isSelected(){return this.env.model.getters.getSelectedFigureId()===this.props.figure.id}get figureRegistry(){return og}getBorderWidth(){return this.env.isDashboard()?0:this.isSelected?2:this.borderWidth}get borderStyle(){return`border: ${this.getBorderWidth()}px solid ${this.isSelected?E:"#c9ccd2"};`}get wrapperStyle(){const{x:e,y:t,width:i,height:o}=this.props.figure;return ho({left:`${e}px`,top:`${t}px`,width:`${i}px`,height:`${o}px`,"z-index":String(le.Figure+(this.isSelected?1:0))})}getResizerPosition(e){let t={};return e.includes("top")?t.top="-3px":e.includes("bottom")?t.bottom="-3px":t.bottom="calc(50% - 3px)",e.includes("left")?t.left="-3px":e.includes("right")?t.right="-3px":t.right="calc(50% - 3px)",ho(t)}setup(){const e=og.get(this.props.figure.tag).borderWidth;this.borderWidth=void 0!==e?e:1,t.useEffect(((e,t,i)=>{e===t&&(null==i||i.focus({preventScroll:!0}))}),(()=>[this.env.model.getters.getSelectedFigureId(),this.props.figure.id,this.figureRef.el]))}clickAnchor(e,t,i){this.props.onClickAnchor(e,t,i)}onMouseDown(e){this.props.onMouseDown(e)}onKeyDown(e){const t=this.props.figure;switch(e.key){case"Delete":this.env.model.dispatch("DELETE_FIGURE",{sheetId:this.env.model.getters.getActiveSheetId(),id:t.id}),this.props.onFigureDeleted(),e.stopPropagation(),e.preventDefault();break;case"ArrowDown":case"ArrowLeft":case"ArrowRight":case"ArrowUp":const i={ArrowDown:[0,1],ArrowLeft:[-1,0],ArrowRight:[1,0],ArrowUp:[0,-1]}[e.key];this.env.model.dispatch("UPDATE_FIGURE",{sheetId:this.env.model.getters.getActiveSheetId(),id:t.id,x:t.x+i[0],y:t.y+i[1]}),e.stopPropagation(),e.preventDefault()}}}Ug.template="o-spreadsheet-FigureComponent",Ug.components={},Ug.defaultProps={onFigureDeleted:()=>{},onMouseDown:()=>{},onClickAnchor:()=>{}},Ug.props={figure:Object,style:{type:String,optional:!0},onFigureDeleted:{type:Function,optional:!0},onMouseDown:{type:Function,optional:!0},onClickAnchor:{type:Function,optional:!0}};class Vg extends t.Component{constructor(){super(...arguments),this.dnd=t.useState({figId:void 0,x:0,y:0,width:0,height:0})}setup(){t.onMounted((()=>{this.render()}))}getVisibleFigures(){const e=this.env.model.getters.getVisibleFigures();return this.dnd.figId&&!e.some((e=>e.id===this.dnd.figId))&&e.push(this.env.model.getters.getFigure(this.env.model.getters.getActiveSheetId(),this.dnd.figId)),e}get containers(){const e=this.getVisibleFigures(),t=[];for(const i of["topLeft","topRight","bottomLeft","bottomRight"]){const o=e.filter((e=>this.getFigureContainer(e)===i));o.length>0&&t.push({type:i,figures:o,style:this.getContainerStyle(i),inverseViewportStyle:this.getInverseViewportPositionStyle(i)})}return this.dnd.figId&&t.push({type:"dnd",figures:[this.getDndFigure()],style:this.getContainerStyle("dnd"),inverseViewportStyle:this.getInverseViewportPositionStyle("dnd")}),t}getContainerStyle(e){const{width:t,height:i}=this.env.model.getters.getMainViewportRect(),{x:o,y:n}=this.env.model.getters.getMainViewportCoordinates(),s=["bottomRight","topRight"].includes(e)?o:0,r=t-s,a=["bottomRight","bottomLeft"].includes(e)?n:0;return ho({left:`${s}px`,top:`${a}px`,width:`${r}px`,height:`${i-a}px`})}getInverseViewportPositionStyle(e){const{scrollX:t,scrollY:i}=this.env.model.getters.getActiveSheetScrollInfo(),{x:o,y:n}=this.env.model.getters.getMainViewportCoordinates();return ho({left:`${["bottomRight","topRight"].includes(e)?-(o+t):0}px`,top:`${["bottomRight","bottomLeft"].includes(e)?-(n+i):0}px`})}getFigureContainer(e){const{x:t,y:i}=this.env.model.getters.getMainViewportCoordinates();return e.id===this.dnd.figId?"dnd":e.x<t&&e.y<i?"topLeft":e.x<t?"bottomLeft":e.y<i?"topRight":"bottomRight"}startDraggingFigure(e,t){if(t.button>0||this.env.model.getters.isReadonly())return;if(!this.env.model.dispatch("SELECT_FIGURE",{id:e.id}).isSuccessful)return;const i=this.env.model.getters.getActiveSheetId(),o=t.clientX,n=t.clientY,{x:s,y:r}=this.internalToScreenCoordinates(e);this.dnd.x=s,this.dnd.y=r,this.dnd.width=e.width,this.dnd.height=e.height;zs((t=>{const{x:i,y:a}=this.env.model.getters.getMainViewportCoordinates(),{scrollX:l,scrollY:c}=this.env.model.getters.getActiveSheetScrollInfo(),h=i?0:-l,d=a?0:-c;this.dnd.figId=e.id;let u=t.clientX-o;this.dnd.x=Math.max(s+u,h);let g=t.clientY-n;this.dnd.y=Math.max(r+g,d)}),(t=>{if(!this.dnd.figId)return;let{x:o,y:n}=this.screenCoordinatesToInternal(this.dnd);this.dnd.figId=void 0,this.env.model.dispatch("UPDATE_FIGURE",{sheetId:i,id:e.id,x:o,y:n})}))}startResize(e,t,i,o){o.stopPropagation();const n=o.clientX,s=o.clientY,{x:r,y:a}=this.internalToScreenCoordinates(e);this.dnd.x=r,this.dnd.y=a,this.dnd.width=e.width,this.dnd.height=e.height;const l=og.get(e.tag).keepRatio||!1,c=og.get(e.tag).minFigSize||80;let h;h=l&&0!=t&&0!=i?o=>{this.dnd.figId=e.id;const l=Math.min(t*(n-o.clientX),e.width-c),h=Math.min(i*(s-o.clientY),e.height-c),d=Math.min(l/e.width,h/e.height);this.dnd.width=e.width*(1-d),this.dnd.height=e.height*(1-d),t<0&&(this.dnd.x=r+e.width*d),i<0&&(this.dnd.y=a+e.height*d)}:o=>{this.dnd.figId=e.id;const l=Math.max(t*(o.clientX-n),c-e.width),h=Math.max(i*(o.clientY-s),c-e.height);this.dnd.width=e.width+l,this.dnd.height=e.height+h,t<0&&(this.dnd.x=r-l),i<0&&(this.dnd.y=a-h)};zs(h,(o=>{if(!this.dnd.figId)return;this.dnd.figId=void 0;let{x:n,y:s}=this.screenCoordinatesToInternal(this.dnd);const r={x:n,y:s};t&&(r.width=this.dnd.width),i&&(r.height=this.dnd.height),this.env.model.dispatch("UPDATE_FIGURE",{sheetId:this.env.model.getters.getActiveSheetId(),id:e.id,...r})}))}getDndFigure(){const e=this.getVisibleFigures().find((e=>e.id===this.dnd.figId));if(!e)throw new Error("Dnd figure not found");return{...e,x:this.dnd.x,y:this.dnd.y,width:this.dnd.width,height:this.dnd.height}}getFigureStyle(e){return e.id!==this.dnd.figId?"":ho({opacity:"0.9",cursor:"grabbing"})}internalToScreenCoordinates({x:e,y:t}){const{x:i,y:o}=this.env.model.getters.getMainViewportCoordinates(),{scrollX:n,scrollY:s}=this.env.model.getters.getActiveSheetScrollInfo();return{x:e=e<i?e:e-n,y:t=t<o?t:t-s}}screenCoordinatesToInternal({x:e,y:t}){const{x:i,y:o}=this.env.model.getters.getMainViewportCoordinates(),{scrollX:n,scrollY:s}=this.env.model.getters.getActiveSheetScrollInfo();return{x:e=i&&e<i?e:e+n,y:t=o&&t<o?t:t+s}}}function zg(e,i,o){let n={col:void 0,row:void 0};const{Date:s}=window;let r=0,a=0,l=0;function c(){return{col:e.model.getters.getColIndex(r),row:e.model.getters.getRowIndex(a)}}const{pause:h,resume:d}=function(e,i){let o;const{setInterval:n,clearInterval:s}=window;return t.useEffect((()=>(o=n(e,i),()=>s(o))),(()=>[i])),{pause:()=>{s(o),o=void 0},resume:()=>{void 0===o&&(o=n(e,i))}}}((function(){const{col:e,row:t}=c(),i=s.now()-l;i>300&&(e!==n.col||t!==n.row)&&p(void 0,void 0);if(i>300){if(e<0||t<0)return;p(e,t)}}),200);function u(e){r=e.offsetX,a=e.offsetY,l=s.now()}function g(){const{col:e,row:t}=c();e===n.col&&t===n.row||p(void 0,void 0)}function p(e,t){e===n.col&&t===n.row||(n.col=e,n.row=t,o({col:e,row:t}))}return t.onMounted((()=>{const e=i.el;e.addEventListener("mousemove",u),e.addEventListener("mouseleave",h),e.addEventListener("mouseenter",d),e.addEventListener("mousedown",g)})),t.onWillUnmount((()=>{const e=i.el;e.removeEventListener("mousemove",u),e.removeEventListener("mouseleave",h),e.removeEventListener("mouseenter",d),e.removeEventListener("mousedown",g)})),n}Vg.template="o-spreadsheet-FiguresContainer",Vg.components={FigureComponent:Ug},Vg.props={onFigureDeleted:Function};class Bg extends t.Component{setup(){this.gridOverlay=t.useRef("gridOverlay"),zg(this.env,this.gridOverlay,this.props.onCellHovered);const e=new ResizeObserver((()=>{this.props.onGridResized({height:this.gridOverlayEl.clientHeight,width:this.gridOverlayEl.clientWidth})}));t.onMounted((()=>{e.observe(this.gridOverlayEl)})),function(e,i,o){let n=null,s=null;function r(e){1===e.touches.length&&(n=e.touches[0].clientX,s=e.touches[0].clientY)}function a(){n=null,s=null}function l(e){if(1!==e.touches.length)return;o()&&(e.preventDefault(),e.stopPropagation());const t=e.touches[0].clientX,r=e.touches[0].clientY;i(n-t,s-r),n=t,s=r}t.onMounted((()=>{e.el.addEventListener("touchstart",r),e.el.addEventListener("touchend",a),e.el.addEventListener("touchmove",l)})),t.onWillUnmount((()=>{e.el.removeEventListener("touchstart",r),e.el.removeEventListener("touchend",a),e.el.removeEventListener("touchmove",l)}))}(this.gridOverlay,this.props.onGridMoved,(()=>{const{scrollY:e}=this.env.model.getters.getActiveSheetDOMScrollInfo();return e>0}))}get gridOverlayEl(){if(!this.gridOverlay.el)throw new Error("GridOverlay el is not defined.");return this.gridOverlay.el}onMouseDown(e){if(e.button>0)return;const[t,i]=this.getCartesianCoordinates(e);this.props.onCellClicked(t,i,{shiftKey:e.shiftKey,ctrlKey:e.ctrlKey})}onDoubleClick(e){const[t,i]=this.getCartesianCoordinates(e);this.props.onCellDoubleClicked(t,i)}onContextMenu(e){e.preventDefault();const[t,i]=this.getCartesianCoordinates(e);this.props.onCellRightClicked(t,i,{x:e.clientX,y:e.clientY})}getCartesianCoordinates(e){return[this.env.model.getters.getColIndex(e.offsetX),this.env.model.getters.getRowIndex(e.offsetY)]}}Bg.template="o-spreadsheet-GridOverlay",Bg.components={FiguresContainer:Vg},Bg.defaultProps={onCellHovered:()=>{},onCellDoubleClicked:()=>{},onCellClicked:()=>{},onCellRightClicked:()=>{},onGridResized:()=>{},onFigureDeleted:()=>{}},Bg.props={onCellHovered:{type:Function,optional:!0},onCellDoubleClicked:{type:Function,optional:!0},onCellClicked:{type:Function,optional:!0},onCellRightClicked:{type:Function,optional:!0},onGridResized:{type:Function,optional:!0},onFigureDeleted:{type:Function,optional:!0},onGridMoved:Function,gridOverlayDimensions:String};class Hg extends t.Component{get cellPopover(){const e=this.env.model.getters.getCellPopover(this.props.hoveredCell);if(!e.isOpen)return{isOpen:!1};const t=e.anchorRect;return{...e,anchorRect:{...t,x:t.x+this.props.gridRect.x,y:t.y+this.props.gridRect.y}}}}Hg.template="o-spreadsheet-GridPopover",Hg.components={Popover:Wn},Hg.props={hoveredCell:Object,onClosePopover:Function,onMouseWheel:Function,gridRect:Object};class $g extends t.Component{constructor(){super(...arguments),this.PADDING=0,this.MAX_SIZE_MARGIN=0,this.MIN_ELEMENT_SIZE=0,this.lastSelectedElementIndex=null,this.state=t.useState({resizerIsActive:!1,isResizing:!1,isMoving:!1,isSelecting:!1,waitingForMove:!1,activeElement:0,draggerLinePosition:0,draggerShadowPosition:0,draggerShadowThickness:0,delta:0,base:0})}_computeHandleDisplay(e){const t=this._getEvOffset(e),i=this._getElementIndex(t);if(i<0)return;const o=this._getDimensionsInViewport(i);t-o.start<this.PADDING&&i!==this._getViewportOffset()?(this.state.resizerIsActive=!0,this.state.draggerLinePosition=o.start,this.state.activeElement=this._getPreviousVisibleElement(i)):o.end-t<this.PADDING?(this.state.resizerIsActive=!0,this.state.draggerLinePosition=o.end,this.state.activeElement=i):this.state.resizerIsActive=!1}_computeGrabDisplay(e){const t=this._getElementIndex(this._getEvOffset(e)),i=this._getActiveElements(),o=this._getSelectedZoneStart(),n=this._getSelectedZoneEnd();i.has(o)&&o<=t&&t<=n?this.state.waitingForMove=!0:this.state.waitingForMove=!1}onMouseMove(e){this.state.isResizing||this.state.isMoving||this.state.isSelecting||(this._computeHandleDisplay(e),this._computeGrabDisplay(e))}onMouseLeave(){this.state.resizerIsActive=this.state.isResizing,this.state.waitingForMove=!1}onDblClick(e){this._fitElementSize(this.state.activeElement),this.state.isResizing=!1,this._computeHandleDisplay(e),this._computeGrabDisplay(e)}onMouseDown(e){this.state.isResizing=!0,this.state.delta=0;const t=this._getClientPosition(e),i=this.state.draggerLinePosition,o=this._getElementSize(this.state.activeElement),n=i-o+this.MIN_ELEMENT_SIZE,s=this._getMaxSize();zs((e=>{this.state.delta=this._getClientPosition(e)-t,this.state.draggerLinePosition=i+this.state.delta,this.state.draggerLinePosition<n&&(this.state.draggerLinePosition=n,this.state.delta=this.MIN_ELEMENT_SIZE-o),this.state.draggerLinePosition>s&&(this.state.draggerLinePosition=s,this.state.delta=s-i)}),(e=>{this.state.isResizing=!1,0!==this.state.delta&&this._updateSize()}))}select(e){if(e.button>0)return;const t=this._getElementIndex(this._getEvOffset(e));t<0||(!0!==this.state.waitingForMove?("editing"===this.env.model.getters.getEditionMode()&&this.env.model.selection.getBackToDefault(),this.startSelection(e,t)):this.startMovement(e))}startMovement(e){this.state.waitingForMove=!1,this.state.isMoving=!0;const t=this._getDimensionsInViewport(this._getSelectedZoneStart()),i=this._getDimensionsInViewport(this._getSelectedZoneEnd()),o=t.start;this.state.draggerLinePosition=o,this.state.base=this._getSelectedZoneStart(),this.state.draggerShadowPosition=o,this.state.draggerShadowThickness=i.end-t.start;Bs(this.env,((e,i)=>{let o="COL"===this._getType()?e:i;if(o>=0){const e=this._getDimensionsInViewport(o);o<=this._getSelectedZoneStart()?(this.state.draggerLinePosition=e.start,this.state.draggerShadowPosition=e.start,this.state.base=o):this._getSelectedZoneEnd()<o?(this.state.draggerLinePosition=e.end,this.state.draggerShadowPosition=e.end-this.state.draggerShadowThickness,this.state.base=o+1):(this.state.draggerLinePosition=t.start,this.state.draggerShadowPosition=t.start,this.state.base=this._getSelectedZoneStart())}}),(()=>{this.state.isMoving=!1,this.state.base!==this._getSelectedZoneStart()&&this._moveElements(),this._computeGrabDisplay(e)}))}startSelection(e,t){this.state.isSelecting=!0,e.shiftKey?this._increaseSelection(t):this._selectElement(t,e.ctrlKey),this.lastSelectedElementIndex=t;Bs(this.env,((e,t)=>{let i="COL"===this._getType()?e:t;i!==this.lastSelectedElementIndex&&-1!==i&&(this._increaseSelection(i),this.lastSelectedElementIndex=i)}),(()=>{this.state.isSelecting=!1,this.lastSelectedElementIndex=null,this.env.model.dispatch(e.ctrlKey?"PREPARE_SELECTION_INPUT_EXPANSION":"STOP_SELECTION_INPUT"),this._computeGrabDisplay(e)}))}onMouseUp(e){this.lastSelectedElementIndex=null}onContextMenu(e){e.preventDefault();const t=this._getElementIndex(this._getEvOffset(e));if(t<0)return;this._getActiveElements().has(t)||this._selectElement(t,!1);const i=this._getType();this.props.onOpenContextMenu(i,e.clientX,e.clientY)}}ro`
|
|
1171
|
-
.o-col-resizer {
|
|
1172
|
-
position: absolute;
|
|
1173
|
-
top: 0;
|
|
1174
|
-
left: ${N}px;
|
|
1175
|
-
right: 0;
|
|
1176
|
-
height: ${O}px;
|
|
1177
|
-
&.o-dragging {
|
|
1178
|
-
cursor: grabbing;
|
|
1179
|
-
}
|
|
1180
|
-
&.o-grab {
|
|
1181
|
-
cursor: grab;
|
|
1182
|
-
}
|
|
1183
|
-
.dragging-col-line {
|
|
1184
|
-
top: ${O}px;
|
|
1185
|
-
position: absolute;
|
|
1186
|
-
width: 2px;
|
|
1187
|
-
height: 10000px;
|
|
1188
|
-
background-color: black;
|
|
1189
|
-
}
|
|
1190
|
-
.dragging-col-shadow {
|
|
1191
|
-
top: ${O}px;
|
|
1192
|
-
position: absolute;
|
|
1193
|
-
height: 10000px;
|
|
1194
|
-
background-color: black;
|
|
1195
|
-
opacity: 0.1;
|
|
1196
|
-
}
|
|
1197
|
-
.o-handle {
|
|
1198
|
-
position: absolute;
|
|
1199
|
-
height: ${O}px;
|
|
1200
|
-
width: 4px;
|
|
1201
|
-
cursor: e-resize;
|
|
1202
|
-
background-color: ${E};
|
|
1203
|
-
}
|
|
1204
|
-
.dragging-resizer {
|
|
1205
|
-
top: ${O}px;
|
|
1206
|
-
position: absolute;
|
|
1207
|
-
margin-left: 2px;
|
|
1208
|
-
width: 1px;
|
|
1209
|
-
height: 10000px;
|
|
1210
|
-
background-color: ${E};
|
|
1211
|
-
}
|
|
1212
|
-
.o-unhide {
|
|
1213
|
-
width: ${L}px;
|
|
1214
|
-
height: ${L}px;
|
|
1215
|
-
position: absolute;
|
|
1216
|
-
overflow: hidden;
|
|
1217
|
-
border-radius: 2px;
|
|
1218
|
-
top: calc(${O}px / 2 - ${L}px / 2);
|
|
1219
|
-
}
|
|
1220
|
-
.o-unhide:hover {
|
|
1221
|
-
z-index: ${le.Grid+1};
|
|
1222
|
-
background-color: lightgrey;
|
|
1223
|
-
}
|
|
1224
|
-
.o-unhide > svg {
|
|
1225
|
-
position: relative;
|
|
1226
|
-
top: calc(${L}px / 2 - ${k}px / 2);
|
|
1227
|
-
}
|
|
1228
|
-
}
|
|
1229
|
-
`,$g.props={onOpenContextMenu:Function};class Wg extends $g{setup(){super.setup(),this.colResizerRef=t.useRef("colResizer"),this.PADDING=15,this.MAX_SIZE_MARGIN=90,this.MIN_ELEMENT_SIZE=5}_getEvOffset(e){return e.offsetX}_getViewportOffset(){return this.env.model.getters.getActiveMainViewport().left}_getClientPosition(e){return e.clientX}_getElementIndex(e){return this.env.model.getters.getColIndex(e)}_getSelectedZoneStart(){return this.env.model.getters.getSelectedZone().left}_getSelectedZoneEnd(){return this.env.model.getters.getSelectedZone().right}_getEdgeScroll(e){return this.env.model.getters.getEdgeScrollCol(e,e,e)}_getDimensionsInViewport(e){return this.env.model.getters.getColDimensionsInViewport(this.env.model.getters.getActiveSheetId(),e)}_getElementSize(e){return this.env.model.getters.getColSize(this.env.model.getters.getActiveSheetId(),e)}_getMaxSize(){return this.colResizerRef.el.clientWidth}_updateSize(){const e=this.state.activeElement,t=this.state.delta+this._getElementSize(e),i=this.env.model.getters.getActiveCols();this.env.model.dispatch("RESIZE_COLUMNS_ROWS",{dimension:"COL",sheetId:this.env.model.getters.getActiveSheetId(),elements:i.has(e)?[...i]:[e],size:t})}_moveElements(){const e=[],t=this._getSelectedZoneStart(),i=this._getSelectedZoneEnd();for(let o=t;o<=i;o++)e.push(o);const o=this.env.model.dispatch("MOVE_COLUMNS_ROWS",{sheetId:this.env.model.getters.getActiveSheetId(),dimension:"COL",base:this.state.base,elements:e});!o.isSuccessful&&o.reasons.includes(2)&&this.env.raiseError(Ko)}_selectElement(e,t){this.env.model.selection.selectColumn(e,t?"newAnchor":"overrideSelection")}_increaseSelection(e){this.env.model.selection.selectColumn(e,"updateAnchor")}_fitElementSize(e){const t=this.env.model.getters.getActiveCols();this.env.model.dispatch("AUTORESIZE_COLUMNS",{sheetId:this.env.model.getters.getActiveSheetId(),cols:t.has(e)?[...t]:[e]})}_getType(){return"COL"}_getActiveElements(){return this.env.model.getters.getActiveCols()}_getPreviousVisibleElement(e){const t=this.env.model.getters.getActiveSheetId();let i;for(i=e-1;i>=0&&this.env.model.getters.isColHidden(t,i);i--);return i}unhide(e){this.env.model.dispatch("UNHIDE_COLUMNS_ROWS",{sheetId:this.env.model.getters.getActiveSheetId(),elements:e,dimension:"COL"})}unhideStyleValue(e){return this._getDimensionsInViewport(e).start}}Wg.template="o-spreadsheet-ColResizer",ro`
|
|
1230
|
-
.o-row-resizer {
|
|
1231
|
-
position: absolute;
|
|
1232
|
-
top: ${O}px;
|
|
1233
|
-
left: 0;
|
|
1234
|
-
right: 0;
|
|
1235
|
-
width: ${N}px;
|
|
1236
|
-
height: 100%;
|
|
1237
|
-
&.o-dragging {
|
|
1238
|
-
cursor: grabbing;
|
|
1239
|
-
}
|
|
1240
|
-
&.o-grab {
|
|
1241
|
-
cursor: grab;
|
|
1242
|
-
}
|
|
1243
|
-
.dragging-row-line {
|
|
1244
|
-
left: ${N}px;
|
|
1245
|
-
position: absolute;
|
|
1246
|
-
width: 10000px;
|
|
1247
|
-
height: 2px;
|
|
1248
|
-
background-color: black;
|
|
1249
|
-
}
|
|
1250
|
-
.dragging-row-shadow {
|
|
1251
|
-
left: ${N}px;
|
|
1252
|
-
position: absolute;
|
|
1253
|
-
width: 10000px;
|
|
1254
|
-
background-color: black;
|
|
1255
|
-
opacity: 0.1;
|
|
1256
|
-
}
|
|
1257
|
-
.o-handle {
|
|
1258
|
-
position: absolute;
|
|
1259
|
-
height: 4px;
|
|
1260
|
-
width: ${N}px;
|
|
1261
|
-
cursor: n-resize;
|
|
1262
|
-
background-color: ${E};
|
|
1263
|
-
}
|
|
1264
|
-
.dragging-resizer {
|
|
1265
|
-
left: ${N}px;
|
|
1266
|
-
position: absolute;
|
|
1267
|
-
margin-top: 2px;
|
|
1268
|
-
width: 10000px;
|
|
1269
|
-
height: 1px;
|
|
1270
|
-
background-color: ${E};
|
|
1271
|
-
}
|
|
1272
|
-
.o-unhide {
|
|
1273
|
-
width: ${L}px;
|
|
1274
|
-
height: ${L}px;
|
|
1275
|
-
position: absolute;
|
|
1276
|
-
overflow: hidden;
|
|
1277
|
-
border-radius: 2px;
|
|
1278
|
-
left: calc(${N}px - ${L}px - 2px);
|
|
1279
|
-
}
|
|
1280
|
-
.o-unhide > svg {
|
|
1281
|
-
position: relative;
|
|
1282
|
-
left: calc(${L}px / 2 - ${k}px / 2);
|
|
1283
|
-
top: calc(${L}px / 2 - ${k}px / 2);
|
|
1284
|
-
}
|
|
1285
|
-
.o-unhide:hover {
|
|
1286
|
-
z-index: ${le.Grid+1};
|
|
1287
|
-
background-color: lightgrey;
|
|
1288
|
-
}
|
|
1289
|
-
}
|
|
1290
|
-
`,Wg.props={onOpenContextMenu:Function};class Gg extends $g{setup(){super.setup(),this.rowResizerRef=t.useRef("rowResizer"),this.PADDING=5,this.MAX_SIZE_MARGIN=60,this.MIN_ELEMENT_SIZE=10}_getEvOffset(e){return e.offsetY}_getViewportOffset(){return this.env.model.getters.getActiveMainViewport().top}_getClientPosition(e){return e.clientY}_getElementIndex(e){return this.env.model.getters.getRowIndex(e)}_getSelectedZoneStart(){return this.env.model.getters.getSelectedZone().top}_getSelectedZoneEnd(){return this.env.model.getters.getSelectedZone().bottom}_getEdgeScroll(e){return this.env.model.getters.getEdgeScrollRow(e,e,e)}_getDimensionsInViewport(e){return this.env.model.getters.getRowDimensionsInViewport(this.env.model.getters.getActiveSheetId(),e)}_getElementSize(e){return this.env.model.getters.getRowSize(this.env.model.getters.getActiveSheetId(),e)}_getMaxSize(){return this.rowResizerRef.el.clientHeight}_updateSize(){const e=this.state.activeElement,t=this.state.delta+this._getElementSize(e),i=this.env.model.getters.getActiveRows();this.env.model.dispatch("RESIZE_COLUMNS_ROWS",{dimension:"ROW",sheetId:this.env.model.getters.getActiveSheetId(),elements:i.has(e)?[...i]:[e],size:t})}_moveElements(){const e=[],t=this._getSelectedZoneStart(),i=this._getSelectedZoneEnd();for(let o=t;o<=i;o++)e.push(o);const o=this.env.model.dispatch("MOVE_COLUMNS_ROWS",{sheetId:this.env.model.getters.getActiveSheetId(),dimension:"ROW",base:this.state.base,elements:e});!o.isSuccessful&&o.reasons.includes(2)&&this.env.raiseError(Ko)}_selectElement(e,t){this.env.model.selection.selectRow(e,t?"newAnchor":"overrideSelection")}_increaseSelection(e){this.env.model.selection.selectRow(e,"updateAnchor")}_fitElementSize(e){const t=this.env.model.getters.getActiveRows();this.env.model.dispatch("AUTORESIZE_ROWS",{sheetId:this.env.model.getters.getActiveSheetId(),rows:t.has(e)?[...t]:[e]})}_getType(){return"ROW"}_getActiveElements(){return this.env.model.getters.getActiveRows()}_getPreviousVisibleElement(e){const t=this.env.model.getters.getActiveSheetId();let i;for(i=e-1;i>=0&&this.env.model.getters.isRowHidden(t,i);i--);return i}unhide(e){this.env.model.dispatch("UNHIDE_COLUMNS_ROWS",{sheetId:this.env.model.getters.getActiveSheetId(),dimension:"ROW",elements:e})}unhideStyleValue(e){return this._getDimensionsInViewport(e).start}}Gg.template="o-spreadsheet-RowResizer",ro`
|
|
1291
|
-
.o-overlay {
|
|
1292
|
-
.all {
|
|
1293
|
-
position: absolute;
|
|
1294
|
-
top: 0;
|
|
1295
|
-
left: 0;
|
|
1296
|
-
right: 0;
|
|
1297
|
-
width: ${N}px;
|
|
1298
|
-
height: ${O}px;
|
|
1299
|
-
}
|
|
1300
|
-
}
|
|
1301
|
-
`,Gg.props={onOpenContextMenu:Function};class qg extends t.Component{selectAll(){this.env.model.selection.selectAll()}}function Zg(e,i,o){const n=t.useRef(e);t.useEffect((function(){const e=n.el,t=window.devicePixelRatio||1,s=e.getContext("2d",{alpha:!1}),r={ctx:s,dpr:t,thinLineWidth:.4*t},{width:a,height:l}=o();e.style.width=`${a}px`,e.style.height=`${l}px`,e.width=a*t,e.height=l*t,e.setAttribute("style",`width:${a}px;height:${l}px;`),s.translate(-m,-m),s.scale(t,t),i.drawGrid(r)}))}function jg(e){function t(e,t){return e*(0===t?1:F)}return i=>{const o=t(i.shiftKey?i.deltaY:i.deltaX,i.deltaMode),n=t(i.shiftKey?i.deltaX:i.deltaY,i.deltaMode);e(o,n)}}qg.template="o-spreadsheet-HeadersOverlay",qg.components={ColResizer:Wg,RowResizer:Gg},qg.props={onOpenContextMenu:Function},ro`
|
|
1302
|
-
.o-border {
|
|
1303
|
-
position: absolute;
|
|
1304
|
-
&:hover {
|
|
1305
|
-
cursor: grab;
|
|
1306
|
-
}
|
|
1307
|
-
}
|
|
1308
|
-
.o-moving {
|
|
1309
|
-
cursor: grabbing;
|
|
1310
|
-
}
|
|
1311
|
-
`;class Xg extends t.Component{get style(){const e=["n","w","e"].includes(this.props.orientation),t=["n","w","s"].includes(this.props.orientation),i=["n","s"].includes(this.props.orientation),o=["w","e"].includes(this.props.orientation),n=this.props.zone,s=this.env.model.getters.getVisibleRect(n),r=s.x,a=s.x+s.width-4,l=s.y,c=s.y+s.height-4;return ho({left:`${t?r:a}px`,top:`${e?l:c}px`,width:`${i?a-r:4}px`,height:`${o?c-l:4}px`})}onMouseDown(e){this.props.onMoveHighlight(e.clientX,e.clientY)}}Xg.template="o-spreadsheet-Border",Xg.props={zone:Object,orientation:String,isMoving:Boolean,onMoveHighlight:Function},ro`
|
|
1312
|
-
.o-corner {
|
|
1313
|
-
position: absolute;
|
|
1314
|
-
height: 6px;
|
|
1315
|
-
width: 6px;
|
|
1316
|
-
border: 1px solid white;
|
|
1317
|
-
}
|
|
1318
|
-
.o-corner-nw,
|
|
1319
|
-
.o-corner-se {
|
|
1320
|
-
&:hover {
|
|
1321
|
-
cursor: nwse-resize;
|
|
1322
|
-
}
|
|
1323
|
-
}
|
|
1324
|
-
.o-corner-ne,
|
|
1325
|
-
.o-corner-sw {
|
|
1326
|
-
&:hover {
|
|
1327
|
-
cursor: nesw-resize;
|
|
1328
|
-
}
|
|
1329
|
-
}
|
|
1330
|
-
.o-resizing {
|
|
1331
|
-
cursor: grabbing;
|
|
1332
|
-
}
|
|
1333
|
-
`;class Yg extends t.Component{constructor(){super(...arguments),this.isTop="n"===this.props.orientation[0],this.isLeft="w"===this.props.orientation[1]}get style(){const e=this.props.zone,t=this.isLeft?e.left:e.right,i=this.isTop?e.top:e.bottom,o=this.env.model.getters.getVisibleRect({left:t,right:t,top:i,bottom:i});if(o.width*o.height==0)return"display:none";return ho({left:(this.isLeft?o.x:o.x+o.width)-4+"px",top:(this.isTop?o.y:o.y+o.height)-4+"px","background-color":this.props.color})}onMouseDown(e){this.props.onResizeHighlight(this.isLeft,this.isTop)}}Yg.template="o-spreadsheet-Corner",Yg.props={zone:Object,color:String,orientation:String,isResizing:Boolean,onResizeHighlight:Function},ro`
|
|
1334
|
-
.o-highlight {
|
|
1335
|
-
z-index: ${le.Highlight};
|
|
1336
|
-
}
|
|
1337
|
-
`;class Kg extends t.Component{constructor(){super(...arguments),this.highlightState=t.useState({shiftingMode:"none"})}onResizeHighlight(e,t){const i=this.env.model.getters.getActiveSheet();this.highlightState.shiftingMode="isResizing";const o=this.props.zone,n=e?o.right:o.left,s=t?o.bottom:o.top;let r=e?o.left:o.right,a=t?o.top:o.bottom,l=o;this.env.model.dispatch("START_CHANGE_HIGHLIGHT",{range:this.env.model.getters.getRangeDataFromZone(i.id,l)});Bs(this.env,((e,t)=>{if(r!==e||a!==t){const o=this.env.model.getters.getActiveSheetId();r=De(-1===e?r:e,0,this.env.model.getters.getNumberCols(o)-1),a=De(-1===t?a:t,0,this.env.model.getters.getNumberRows(o)-1);let c={left:Math.min(n,r),top:Math.min(s,a),right:Math.max(n,r),bottom:Math.max(s,a)};c=this.env.model.getters.expandZone(o,c),Bi(c,l)||(this.env.model.dispatch("CHANGE_HIGHLIGHT",{range:this.env.model.getters.getRangeDataFromZone(i.id,c)}),l=c)}}),(()=>{this.highlightState.shiftingMode="none",this.env.model.dispatch("STOP_COMPOSER_RANGE_SELECTION")}))}onMoveHighlight(e,t){this.highlightState.shiftingMode="isMoving";const i=this.props.zone,o=Vn(),n=this.env.model.getters.getActiveSheetId(),s=this.env.model.getters.getColIndex(e-o.left),r=this.env.model.getters.getRowIndex(t-o.top),a=-i.left,l=this.env.model.getters.getNumberCols(n)-i.right-1,c=-i.top,h=this.env.model.getters.getNumberRows(n)-i.bottom-1;let d=i;this.env.model.dispatch("START_CHANGE_HIGHLIGHT",{range:this.env.model.getters.getRangeDataFromZone(n,d)});let u=s,g=r;Bs(this.env,((e,t)=>{if(u!==e||g!==t){u=-1===e?u:e,g=-1===t?g:t;const o=De(u-s,a,l),p=De(g-r,c,h);let m={left:i.left+o,top:i.top+p,right:i.right+o,bottom:i.bottom+p};m=this.env.model.getters.expandZone(n,m),Bi(m,d)||(this.env.model.dispatch("CHANGE_HIGHLIGHT",{range:this.env.model.getters.getRangeDataFromZone(n,m)}),d=m)}}),(()=>{this.highlightState.shiftingMode="none",this.env.model.dispatch("STOP_COMPOSER_RANGE_SELECTION")}))}}Kg.template="o-spreadsheet-Highlight",Kg.components={Corner:Yg,Border:Xg},Kg.props={zone:Object,color:String};class Qg{constructor(e,t){this.el=e,this.direction=t}get scroll(){return"horizontal"===this.direction?this.el.scrollLeft:this.el.scrollTop}set scroll(e){"horizontal"===this.direction?this.el.scrollLeft=e:this.el.scrollTop=e}}ro`
|
|
1338
|
-
.o-scrollbar {
|
|
1339
|
-
position: absolute;
|
|
1340
|
-
overflow: auto;
|
|
1341
|
-
z-index: ${le.ScrollBar};
|
|
1342
|
-
background-color: ${f};
|
|
1343
|
-
|
|
1344
|
-
&.corner {
|
|
1345
|
-
right: 0px;
|
|
1346
|
-
bottom: 0px;
|
|
1347
|
-
height: ${D}px;
|
|
1348
|
-
width: ${D}px;
|
|
1349
|
-
border-top: 1px solid #e2e3e3;
|
|
1350
|
-
border-left: 1px solid #e2e3e3;
|
|
1351
|
-
}
|
|
1352
|
-
}
|
|
1353
|
-
`;class Jg extends t.Component{setup(){this.scrollbarRef=t.useRef("scrollbar"),this.scrollbar=new Qg(this.scrollbarRef.el,this.props.direction),t.onMounted((()=>{this.scrollbar.el=this.scrollbarRef.el})),t.useEffect((()=>{this.scrollbar.scroll!==this.props.offset&&(this.scrollbar.scroll=this.props.offset)}),(()=>[this.scrollbar.scroll,this.props.offset]))}get sizeCss(){return ho({width:`${this.props.width}px`,height:`${this.props.height}px`})}get positionCss(){return ho(this.props.position)}onScroll(e){this.props.offset!==this.scrollbar.scroll&&this.props.onScroll(this.scrollbar.scroll)}}Jg.template=t.xml`
|
|
1354
|
-
<div
|
|
1355
|
-
t-attf-class="o-scrollbar {{props.direction}}"
|
|
1356
|
-
t-on-scroll="onScroll"
|
|
1357
|
-
t-ref="scrollbar"
|
|
1358
|
-
t-att-style="positionCss">
|
|
1359
|
-
<div t-att-style="sizeCss"/>
|
|
1360
|
-
</div>
|
|
1361
|
-
`,Jg.defaultProps={width:1,height:1},Jg.props={width:{type:Number,optional:!0},height:{type:Number,optional:!0},direction:String,position:Object,offset:Number,onScroll:Function};class ep extends t.Component{get offset(){return this.env.model.getters.getActiveSheetDOMScrollInfo().scrollX}get width(){return this.env.model.getters.getMainViewportRect().width}get isDisplayed(){const{xRatio:e}=this.env.model.getters.getFrozenSheetViewRatio(this.env.model.getters.getActiveSheetId());return e<1}get position(){const{x:e}=this.env.model.getters.getMainViewportRect();return{left:`${this.props.leftOffset+e}px`,bottom:"0px",height:"15px",right:"0px"}}onScroll(e){const{scrollY:t}=this.env.model.getters.getActiveSheetDOMScrollInfo();this.env.model.dispatch("SET_VIEWPORT_OFFSET",{offsetX:e,offsetY:t})}}ep.components={ScrollBar:Jg},ep.template=t.xml`
|
|
1362
|
-
<ScrollBar
|
|
1363
|
-
t-if="isDisplayed"
|
|
1364
|
-
width="width"
|
|
1365
|
-
position="position"
|
|
1366
|
-
offset="offset"
|
|
1367
|
-
direction="'horizontal'"
|
|
1368
|
-
onScroll.bind="onScroll"
|
|
1369
|
-
/>`,ep.defaultProps={leftOffset:0},ep.props={leftOffset:{type:Number,optional:!0}};class tp extends t.Component{get offset(){return this.env.model.getters.getActiveSheetDOMScrollInfo().scrollY}get height(){return this.env.model.getters.getMainViewportRect().height}get isDisplayed(){const{yRatio:e}=this.env.model.getters.getFrozenSheetViewRatio(this.env.model.getters.getActiveSheetId());return e<1}get position(){const{y:e}=this.env.model.getters.getMainViewportRect();return{top:`${this.props.topOffset+e}px`,right:"0px",width:"15px",bottom:"0px"}}onScroll(e){const{scrollX:t}=this.env.model.getters.getActiveSheetDOMScrollInfo();this.env.model.dispatch("SET_VIEWPORT_OFFSET",{offsetX:t,offsetY:e})}}tp.components={ScrollBar:Jg},tp.template=t.xml`
|
|
1370
|
-
<ScrollBar
|
|
1371
|
-
t-if="isDisplayed"
|
|
1372
|
-
height="height"
|
|
1373
|
-
position="position"
|
|
1374
|
-
offset="offset"
|
|
1375
|
-
direction="'vertical'"
|
|
1376
|
-
onScroll.bind="onScroll"
|
|
1377
|
-
/>`,tp.defaultProps={topOffset:0},tp.props={topOffset:{type:Number,optional:!0}};const ip={ROW:Vs,COL:Us,CELL:Ps};class op extends t.Component{constructor(){super(...arguments),this.HEADER_HEIGHT=O,this.HEADER_WIDTH=N,this.keyDownMapping={ENTER:()=>{this.env.model.getters.getActiveCell().type===So.empty?this.props.onGridComposerCellFocused():this.props.onComposerContentFocused()},TAB:()=>this.env.model.selection.moveAnchorCell("right",1),"SHIFT+TAB":()=>this.env.model.selection.moveAnchorCell("left",1),F2:()=>{this.env.model.getters.getActiveCell().type===So.empty?this.props.onGridComposerCellFocused():this.props.onComposerContentFocused()},DELETE:()=>{this.env.model.dispatch("DELETE_CONTENT",{sheetId:this.env.model.getters.getActiveSheetId(),target:this.env.model.getters.getSelectedZones()})},BACKSPACE:()=>{this.env.model.dispatch("DELETE_CONTENT",{sheetId:this.env.model.getters.getActiveSheetId(),target:this.env.model.getters.getSelectedZones()})},ESCAPE:()=>{this.env.model.getters.hasOpenedPopover()?this.closeOpenedPopover():this.menuState.isOpen?this.closeMenu():this.env.model.dispatch("CLEAN_CLIPBOARD_HIGHLIGHT")},"CTRL+A":()=>this.env.model.selection.loopSelection(),"CTRL+Z":()=>this.env.model.dispatch("REQUEST_UNDO"),"CTRL+Y":()=>this.env.model.dispatch("REQUEST_REDO"),"CTRL+B":()=>this.env.model.dispatch("SET_FORMATTING",{sheetId:this.env.model.getters.getActiveSheetId(),target:this.env.model.getters.getSelectedZones(),style:{bold:!this.env.model.getters.getCurrentStyle().bold}}),"CTRL+I":()=>this.env.model.dispatch("SET_FORMATTING",{sheetId:this.env.model.getters.getActiveSheetId(),target:this.env.model.getters.getSelectedZones(),style:{italic:!this.env.model.getters.getCurrentStyle().italic}}),"CTRL+U":()=>this.env.model.dispatch("SET_FORMATTING",{sheetId:this.env.model.getters.getActiveSheetId(),target:this.env.model.getters.getSelectedZones(),style:{underline:!this.env.model.getters.getCurrentStyle().underline}}),"ALT+=":()=>{var e;const t=this.env.model.getters.getActiveSheetId(),i=this.env.model.getters.getSelectedZone(),{anchor:o}=this.env.model.getters.getSelection(),n=this.env.model.getters.getAutomaticSums(t,i,o.cell);if(this.env.model.getters.isSingleCellOrMerge(t,i)||this.env.model.getters.isEmpty(t,i)&&n.length<=1){const i=(null===(e=n[0])||void 0===e?void 0:e.zone)?this.env.model.getters.zoneToXC(t,n[0].zone):"",o=`=SUM(${i})`;this.props.onGridComposerCellFocused(o,{start:5,end:5+i.length})}else this.env.model.dispatch("SUM_SELECTION")},"CTRL+HOME":()=>{const e=this.env.model.getters.getActiveSheetId(),{col:t,row:i}=this.env.model.getters.getNextVisibleCellPosition({sheetId:e,col:0,row:0});this.env.model.selection.selectCell(t,i)},"CTRL+END":()=>{const e=this.env.model.getters.getActiveSheetId(),t=this.env.model.getters.findVisibleHeader(e,"COL",ze(0,this.env.model.getters.getNumberCols(e)).reverse()),i=this.env.model.getters.findVisibleHeader(e,"ROW",ze(0,this.env.model.getters.getNumberRows(e)).reverse());this.env.model.selection.selectCell(t,i)},"SHIFT+ ":()=>{const e=this.env.model.getters.getActiveSheetId(),t={...this.env.model.getters.getSelectedZone(),left:0,right:this.env.model.getters.getNumberCols(e)-1},i=this.env.model.getters.getActivePosition();this.env.model.selection.selectZone({cell:i,zone:t})},"CTRL+ ":()=>{const e=this.env.model.getters.getActiveSheetId(),t={...this.env.model.getters.getSelectedZone(),top:0,bottom:this.env.model.getters.getNumberRows(e)-1},i=this.env.model.getters.getActivePosition();this.env.model.selection.selectZone({cell:i,zone:t})},"CTRL+SHIFT+ ":()=>{this.env.model.selection.selectAll()},"SHIFT+PAGEDOWN":()=>{this.env.model.dispatch("ACTIVATE_NEXT_SHEET")},"SHIFT+PAGEUP":()=>{this.env.model.dispatch("ACTIVATE_PREVIOUS_SHEET")},PAGEDOWN:()=>this.env.model.dispatch("SHIFT_VIEWPORT_DOWN"),PAGEUP:()=>this.env.model.dispatch("SHIFT_VIEWPORT_UP"),"CTRL+K":()=>_s(this.env)}}setup(){this.menuState=t.useState({isOpen:!1,position:null,menuItems:[]}),this.gridRef=t.useRef("grid"),this.hiddenInput=t.useRef("hiddenInput"),this.canvasPosition=Pn(this.gridRef),this.hoveredCell=t.useState({col:void 0,row:void 0}),t.useChildSubEnv({getPopoverContainerRect:()=>this.getGridRect()}),t.useExternalListener(document.body,"cut",this.copy.bind(this,!0)),t.useExternalListener(document.body,"copy",this.copy.bind(this,!1)),t.useExternalListener(document.body,"paste",this.paste),t.onMounted((()=>this.focus())),this.props.exposeFocus((()=>this.focus())),Zg("canvas",this.env.model,(()=>this.env.model.getters.getSheetViewDimensionWithHeaders())),t.useEffect((()=>this.focus()),(()=>[this.env.model.getters.getActiveSheetId()])),this.onMouseWheel=jg(((e,t)=>{this.moveCanvas(e,t),this.hoveredCell.col=void 0,this.hoveredCell.row=void 0}))}onCellHovered({col:e,row:t}){this.hoveredCell.col=e,this.hoveredCell.row=t}get gridOverlayDimensions(){return ho({top:"26px",left:"48px",height:"calc(100% - 41px)",width:"calc(100% - 63px)"})}onClosePopover(){this.env.model.getters.hasOpenedPopover()&&this.closeOpenedPopover(),this.focus()}focus(){this.env.model.getters.getSelectedFigureId()||"inactive"!==this.env.model.getters.getEditionMode()||this.hiddenInput.el.focus()}get gridEl(){if(!this.gridRef.el)throw new Error("Grid el is not defined.");return this.gridRef.el}getAutofillPosition(){const e=this.env.model.getters.getSelectedZone(),t=this.env.model.getters.getVisibleRect(e);return{left:t.x+t.width-4,top:t.y+t.height-4}}get isAutofillVisible(){const e=this.env.model.getters.getSelectedZone(),t=this.env.model.getters.getVisibleRect({left:e.right,right:e.right,top:e.bottom,bottom:e.bottom});return!(0===t.width||0===t.height)}onGridResized({height:e,width:t}){this.env.model.dispatch("RESIZE_SHEETVIEW",{width:t,height:e,gridOffsetX:N,gridOffsetY:O})}moveCanvas(e,t){const{scrollX:i,scrollY:o}=this.env.model.getters.getActiveSheetDOMScrollInfo();this.env.model.dispatch("SET_VIEWPORT_OFFSET",{offsetX:i+e,offsetY:o+t})}getClientPositionKey(e){var t,i,o;return`${e.id}-${null===(t=e.position)||void 0===t?void 0:t.sheetId}-${null===(i=e.position)||void 0===i?void 0:i.col}-${null===(o=e.position)||void 0===o?void 0:o.row}`}isCellHovered(e,t){return this.hoveredCell.col===e&&this.hoveredCell.row===t}getGridRect(){return{...this.canvasPosition,...this.env.model.getters.getSheetViewDimensionWithHeaders()}}onCellClicked(e,t,{ctrlKey:i,shiftKey:o}){i&&this.env.model.dispatch("PREPARE_SELECTION_INPUT_EXPANSION"),this.env.model.getters.hasOpenedPopover()&&this.closeOpenedPopover(),"editing"===this.env.model.getters.getEditionMode()&&this.env.model.dispatch("STOP_EDITION"),o?this.env.model.selection.setAnchorCorner(e,t):i?this.env.model.selection.addCellToSelection(e,t):this.env.model.selection.selectCell(e,t);let n=e,s=t;Bs(this.env,((e,t)=>{(e!==n&&-1!=e||t!==s&&-1!=t)&&(n=-1===e?n:e,s=-1===t?s:t,this.env.model.selection.setAnchorCorner(n,s))}),(()=>{this.env.model.dispatch("STOP_SELECTION_INPUT"),this.env.model.getters.isPaintingFormat()&&this.env.model.dispatch("PASTE",{target:this.env.model.getters.getSelectedZones()})}))}onCellDoubleClicked(e,t){const i=this.env.model.getters.getActiveSheetId();({col:e,row:t}=this.env.model.getters.getMainCellPosition({sheetId:i,col:e,row:t}));this.env.model.getters.getEvaluatedCell({sheetId:i,col:e,row:t}).type===So.empty?this.props.onGridComposerCellFocused():this.props.onComposerContentFocused()}closeOpenedPopover(){this.env.model.dispatch("CLOSE_CELL_POPOVER")}processArrows(e){e.preventDefault(),e.stopPropagation(),this.env.model.getters.hasOpenedPopover()&&this.closeOpenedPopover(),nu(e,this.env.model.selection),this.env.model.getters.isPaintingFormat()&&this.env.model.dispatch("PASTE",{target:this.env.model.getters.getSelectedZones()})}onKeydown(e){if(e.key.startsWith("Arrow"))return void this.processArrows(e);let t="";e.ctrlKey&&(t+="CTRL+"),e.metaKey&&(t+="CTRL+"),e.altKey&&(t+="ALT+"),e.shiftKey&&(t+="SHIFT+"),t+=e.key.toUpperCase();let i=this.keyDownMapping[t];return i?(e.preventDefault(),e.stopPropagation(),void i()):void 0}onInput(e){e.data&&(e.preventDefault(),e.stopPropagation(),this.props.onGridComposerCellFocused(e.data))}onInputContextMenu(e){e.preventDefault();const t=this.env.model.getters.getSelectedZone(),{left:i,top:o}=t;let n="CELL";this.env.model.dispatch("STOP_EDITION"),this.env.model.getters.getActiveCols().has(i)?n="COL":this.env.model.getters.getActiveRows().has(o)&&(n="ROW");const{x:s,y:r,width:a,height:l}=this.env.model.getters.getVisibleRect(t);this.toggleContextMenu(n,s+a,r+l)}onCellRightClicked(e,t,{x:i,y:o}){const n=this.env.model.getters.getSelectedZones();let s="CELL";$i(e,t,n[n.length-1])?this.env.model.getters.getActiveCols().has(e)?s="COL":this.env.model.getters.getActiveRows().has(t)&&(s="ROW"):(this.env.model.selection.getBackToDefault(),this.env.model.selection.selectCell(e,t)),this.toggleContextMenu(s,i,o)}toggleContextMenu(e,t,i){this.env.model.getters.hasOpenedPopover()&&this.closeOpenedPopover(),this.menuState.isOpen=!0,this.menuState.position={x:t,y:i},this.menuState.menuItems=ip[e].getMenuItems()}copy(e,t){if(!this.gridEl.contains(document.activeElement))return;const i=t.clipboardData;if(!i)return void this.displayWarningCopyPasteNotSupported();if("inactive"!==this.env.model.getters.getEditionMode())return;e?Yn(this.env):this.env.model.dispatch("COPY");const o=this.env.model.getters.getClipboardContent();for(const e in o)i.setData(e,o[e]);t.preventDefault()}paste(e){if(!this.gridEl.contains(document.activeElement))return;const t=e.clipboardData;if(t){if(t.types.indexOf(Co.PlainText)>-1){const e=t.getData(Co.PlainText),i=this.env.model.getters.getSelectedZones();this.env.model.getters.getClipboardTextContent()===e?Jn(this.env,i):es(this.env,i,e)}}else this.displayWarningCopyPasteNotSupported()}displayWarningCopyPasteNotSupported(){this.env.raiseError(s("Copy/Paste is not supported in this browser."))}closeMenu(){this.menuState.isOpen=!1,this.focus()}}op.template="o-spreadsheet-Grid",op.components={GridComposer:mu,GridOverlay:Bg,GridPopover:Hg,HeadersOverlay:qg,Menu:jn,Autofill:Hs,ClientTag:Ws,Highlight:Kg,Popover:Wn,VerticalScrollBar:tp,HorizontalScrollBar:ep,FilterIconsOverlay:Su},op.props={sidePanelIsOpen:Boolean,exposeFocus:Function,focusComposer:String,onComposerContentFocused:Function,onGridComposerCellFocused:Function};class np{constructor(e){this.xmlString=e}toString(){return this.xmlString}}const sp=["areaChart","area3DChart","lineChart","line3DChart","stockChart","radarChart","scatterChart","pieChart","pie3DChart","doughnutChart","barChart","bar3DChart","ofPieChart","surfaceChart","surface3DChart","bubbleChart"],rp="000000",ap={arrow:"3Arrows",smiley:"3Symbols",dot:"3TrafficLights1"},lp={styleSheet:"http://schemas.openxmlformats.org/spreadsheetml/2006/main",sst:"http://schemas.openxmlformats.org/spreadsheetml/2006/main",Relationships:"http://schemas.openxmlformats.org/package/2006/relationships",Types:"http://schemas.openxmlformats.org/package/2006/content-types",worksheet:"http://schemas.openxmlformats.org/spreadsheetml/2006/main",workbook:"http://schemas.openxmlformats.org/spreadsheetml/2006/main",drawing:"http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing",table:"http://schemas.openxmlformats.org/spreadsheetml/2006/main",revision:"http://schemas.microsoft.com/office/spreadsheetml/2014/revision",revision3:"http://schemas.microsoft.com/office/spreadsheetml/2016/revision3",markupCompatibility:"http://schemas.openxmlformats.org/markup-compatibility/2006"},cp="http://schemas.openxmlformats.org/drawingml/2006/main",hp="http://schemas.openxmlformats.org/drawingml/2006/chart",dp={workbook:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml",sheet:"application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml",sharedStrings:"application/vnd.openxmlformats-officedocument.spreadsheetml.sharedStrings+xml",styles:"application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml",drawing:"application/vnd.openxmlformats-officedocument.drawing+xml",chart:"application/vnd.openxmlformats-officedocument.drawingml.chart+xml",themes:"application/vnd.openxmlformats-officedocument.theme+xml",table:"application/vnd.openxmlformats-officedocument.spreadsheetml.table+xml",pivot:"application/vnd.openxmlformats-officedocument.spreadsheetml.pivotTable+xml",externalLink:"application/vnd.openxmlformats-officedocument.spreadsheetml.externalLink+xml"},up={document:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument",sheet:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet",sharedStrings:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings",styles:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles",drawing:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/drawing",chart:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart",theme:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme",table:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/table",hyperlink:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink"},gp="http://schemas.openxmlformats.org/officeDocument/2006/relationships",pp=.75,mp=.1317,fp=8.43,vp=12.75,bp=30,Sp=100,Cp=164,Ep={FLOOR:[{type:"NUMBER",value:1}],CEILING:[{type:"NUMBER",value:1}],ROUND:[{type:"NUMBER",value:0}],ROUNDUP:[{type:"NUMBER",value:0}],ROUNDDOWN:[{type:"NUMBER",value:0}]},wp=["ACOT","ACOTH","AGGREGATE","ARABIC","BASE","BETA.DIST","BETA.INV","BINOM.DIST","BINOM.DIST.RANGE","BINOM.INV","BITAND","BITLSHIFT","BITOR","BITRSHIFT","BITXOR","CEILING.MATH","CEILING.PRECISE","CHISQ.DIST","CHISQ.DIST.RT","CHISQ.INV","CHISQ.INV.RT","CHISQ.TEST","COMBINA","CONCAT","CONFIDENCE.NORM","CONFIDENCE.T","COT","COTH","COVARIANCE.P","COVARIANCE.S","CSC","CSCH","DAYS","DECIMAL","ERF.PRECISE","ERFC.PRECISE","EXPON.DIST","F.DIST","F.DIST.RT","F.INV","F.INV.RT","F.TEST","FILTERXML","FLOOR.MATH","FLOOR.PRECISE","FORECAST.ETS","FORECAST.ETS.CONFINT","FORECAST.ETS.SEASONALITY","FORECAST.ETS.STAT","FORECAST.LINEAR","FORMULATEXT","GAMMA","GAMMA.DIST","GAMMA.INV","GAMMALN.PRECISE","GAUSS","HYPGEOM.DIST","IFNA","IFS","IMCOSH","IMCOT","IMCSC","IMCSCH","IMSEC","IMSECH","IMSINH","IMTAN","ISFORMULA","ISOWEEKNUM","LOGNORM.DIST","LOGNORM.INV","MAXIFS","MINIFS","MODE.MULT","MODE.SNGL","MUNIT","NEGBINOM.DIST","NORM.DIST","NORM.INV","NORM.S.DIST","NORM.S.INV","NUMBERVALUE","PDURATION","PERCENTILE.EXC","PERCENTILE.INC","PERCENTRANK.EXC","PERCENTRANK.INC","PERMUTATIONA","PHI","POISSON.DIST","QUARTILE.EXC","QUARTILE.INC","QUERYSTRING","RANK.AVG","RANK.EQ","RRI","SEC","SECH","SHEET","SHEETS","SKEW.P","STDEV.P","STDEV.S","SWITCH","T.DIST","T.DIST.2T","T.DIST.RT","T.INV","T.INV.2T","T.TEST","TEXTJOIN","UNICHAR","UNICODE","VAR.P","VAR.S","WEBSERVICE","WEIBULL.DIST","XOR","Z.TEST"],yp="[Content_Types].xml";var xp;!function(e){e.DiagonalBorderNotSupported="Diagonal Borders",e.BorderStyleNotSupported="Border style",e.FillStyleNotSupported="Fill Style",e.FontNotSupported="Font",e.HorizontalAlignmentNotSupported="Horizontal Alignment",e.VerticalAlignmentNotSupported="Vertical Alignments",e.MultipleRulesCfNotSupported="Multiple rules conditional formats",e.CfTypeNotSupported="Conditional format type",e.CfFormatBorderNotSupported="Borders in conditional formats",e.CfFormatAlignmentNotSupported="Alignment in conditional formats",e.CfFormatNumFmtNotSupported="Num formats in conditional formats",e.CfIconSetEmptyIconNotSupported="IconSets with empty icons",e.BadlyFormattedHyperlink="Badly formatted hyperlink",e.NumFmtIdNotSupported="Number format"}(xp||(xp={}));class Ip{constructor(){this._parsingWarnings=new Set,this._conversionWarnings=new Set}addParsingWarning(e){this._parsingWarnings.add(e)}addConversionWarning(e){this._conversionWarnings.add(e)}get warnings(){return[...this._parsingWarnings,...this._conversionWarnings]}generateNotSupportedWarning(e,t,i){let o=`${e} ${t?'"'+t+'" is':"are"} not yet supported. `;i&&(o+=`Only ${i.join(", ")} are currently supported.`),this._conversionWarnings.has(o)||this._conversionWarnings.add(o)}}const Rp=["thin"],Tp=["general","left","center","right"],Ap=["Arial"],Mp=["solid"],Op=["expression","cellIs","colorScale","iconSet","containsText","notContainsText","beginsWith","endsWith","containsBlanks","notContainsBlanks"],Np={b:"boolean",d:"date",e:"error",inlineStr:"inlineStr",n:"number",s:"sharedString",str:"str"},_p={dashDot:"thin",dashDotDot:"thin",dashed:"thin",dotted:"thin",double:"thin",hair:"thin",medium:"thin",mediumDashDot:"thin",mediumDashDotDot:"thin",mediumDashed:"thin",none:void 0,slantDashDot:"thin",thick:"thin",thin:"thin"},Fp={general:void 0,left:"left",center:"center",right:"right",fill:"left",justify:"left",centerContinuous:"center",distributed:"center"};const Dp={aboveAverage:void 0,expression:void 0,cellIs:void 0,colorScale:void 0,dataBar:void 0,iconSet:void 0,top10:void 0,uniqueValues:void 0,duplicateValues:void 0,containsText:"ContainsText",notContainsText:"NotContains",beginsWith:"BeginsWith",endsWith:"EndsWith",containsBlanks:"IsEmpty",notContainsBlanks:"IsNotEmpty",containsErrors:void 0,notContainsErrors:void 0,timePeriod:void 0},kp={num:"number",percent:"percentage",max:"value",min:"value",percentile:"percentile",formula:"formula"},Lp={NoIcons:void 0,"3Arrows":"arrows","3ArrowsGray":"arrows","3Symbols":"smiley","3Symbols2":"smiley","3Signs":"dots","3Flags":"dots","3TrafficLights1":"dots","3TrafficLights2":"dots","4Arrows":"arrows","4ArrowsGray":"arrows","4RedToBlack":"dots","4Rating":"smiley","4TrafficLights":"dots","5Arrows":"arrows","5ArrowsGray":"arrows","5Rating":"smiley","5Quarters":"dots","3Stars":"smiley","3Triangles":"arrows","5Boxes":"dots"},Pp={b:"bottom",t:"top",l:"left",r:"right",tr:"right"},Up={areaChart:void 0,area3DChart:void 0,lineChart:"line",line3DChart:void 0,stockChart:void 0,radarChart:void 0,scatterChart:void 0,pieChart:"pie",pie3DChart:void 0,doughnutChart:"pie",barChart:"bar",bar3DChart:void 0,ofPieChart:void 0,surfaceChart:void 0,surface3DChart:void 0,bubbleChart:void 0},Vp={1:"AVERAGE",2:"COUNT",3:"COUNTA",4:"MAX",5:"MIN",6:"PRODUCT",7:"STDEV",8:"STDEVP",9:"SUM",10:"VAR",11:"VARP",101:"AVERAGE",102:"COUNT",103:"COUNTA",104:"MAX",105:"MIN",106:"PRODUCT",107:"STDEV",108:"STDEVP",109:"SUM",110:"VAR",111:"VARP"},zp={0:"",1:"0",2:"0.00",3:"#,#00",4:"#,##0.00",9:"0%",10:"0.00%",11:void 0,12:void 0,13:void 0,14:"m/d/yyyy",15:"m/d/yyyy",16:"m/d/yyyy",17:"m/d/yyyy",18:"hh:mm:ss a",19:"hh:mm:ss a",20:"hhhh:mm:ss",21:"hhhh:mm:ss",22:"m/d/yy h:mm",37:void 0,38:void 0,39:void 0,40:void 0,45:"hhhh:mm:ss",46:"hhhh:mm:ss",47:"hhhh:mm:ss",48:void 0,49:void 0},Bp={0:1,"0.00":2,"#,#00":3,"#,##0.00":4,"0%":9,"0.00%":10,"0.00E+00":11,"# ?/?":12,"# ??/??":13,"mm-dd-yy":14,"d-mm-yy":15,"mm-yy":16,"mmm-yy":17,"h:mm AM/PM":18,"h:mm:ss AM/PM":19,"h:mm":20,"h:mm:ss":21,"m/d/yy h:mm":22,"#,##0 ;(#,##0)":37,"#,##0 ;[Red](#,##0)":38,"#,##0.00;(#,##0.00)":39,"#,##0.00;[Red](#,##0.00)":40,"mm:ss":45,"[h]:mm:ss":46,"mmss.0":47,"##0.0E+0":48,"@":49,"hh:mm:ss a":19},Hp={0:"000000",1:"FFFFFF",2:"FF0000",3:"00FF00",4:"0000FF",5:"FFFF00",6:"FF00FF",7:"00FFFF",8:"000000",9:"FFFFFF",10:"FF0000",11:"00FF00",12:"0000FF",13:"FFFF00",14:"FF00FF",15:"00FFFF",16:"800000",17:"008000",18:"000080",19:"808000",20:"800080",21:"008080",22:"C0C0C0",23:"808080",24:"9999FF",25:"993366",26:"FFFFCC",27:"CCFFFF",28:"660066",29:"FF8080",30:"0066CC",31:"CCCCFF",32:"000080",33:"FF00FF",34:"FFFF00",35:"00FFFF",36:"800080",37:"800000",38:"008080",39:"0000FF",40:"00CCFF",41:"CCFFFF",42:"CCFFCC",43:"FFFF99",44:"99CCFF",45:"FF99CC",46:"CC99FF",47:"FFCC99",48:"3366FF",49:"33CCCC",50:"99CC00",51:"FFCC00",52:"FF9900",53:"FF6600",54:"666699",55:"969696",56:"003366",57:"339966",58:"003300",59:"333300",60:"993300",61:"993366",62:"333399",63:"333333",64:"000000",65:"FFFFFF"};function $p(e){if(!e)return;let t;if(e.rgb)t=e.rgb;else if(e.auto)t=rp;else{if(!e.indexed)return;t=Hp[e.indexed]}var i;return t=6===(i=t).length?"#"+i+"FF":"#"+i.slice(2)+i.slice(0,2),e.tint&&(t=function(e,t){const i=wt(e),o=xt(i);t<0&&(o.l=o.l*(1+t));t>0&&(o.l=o.l*(1-t)+(100-100*(1-t)));return Et(yt(o))}(t,e.tint)),t=t.toUpperCase(),9===t.length&&t.endsWith("FF")&&(t=t.slice(0,7)),t}function Wp(e,t){const i=e.split("/"),o=t.split("/");let n="",s=0;for(let e=0;e<i.length-1;e++)i[e]===o[e]?s++:n+="../";return n+=o.slice(s).join("/"),n}function Gp(e,t=0){const i={};for(let o=0;o<e.length;o++)e[o]&&(i[o+t]=e[o]);return i}function qp(e){const t=[];for(let i of Object.keys(e).map(Number))t[i]=e[i];return t}function Zp(e){return e.replace(/_x([0-9a-zA-Z]{4})_/g,((e,t)=>String.fromCharCode(parseInt(t,16))))}function jp(e,t){const i=e.borders.map((e=>{!function(e,t){e.diagonal&&t.generateNotSupportedWarning(xp.DiagonalBorderNotSupported)}(e,t);const i={top:Xp(e.top,t),bottom:Xp(e.bottom,t),left:Xp(e.left,t),right:Xp(e.right,t)};return Object.keys(i).forEach((e=>void 0===i[e]&&delete i[e])),i}));return Gp(i,1)}function Xp(e,t){if(!e)return;!function(e,t){Rp.includes(e.style)||t.generateNotSupportedWarning(xp.BorderStyleNotSupported,e.style,Rp)}(e,t);const i=_p[e.style];return i?[i,$p(e.color)]:void 0}function Yp(e,t){return Gp(e.styles.map((i=>Kp({fontStyle:e.fonts[i.fontId],fillStyle:e.fills[i.fillId],alignment:i.alignment},t))),1)}function Kp(e,t){var i,o,n,s,r,a,l,c,h,d,u,g;return function(e,t,i){e&&e.name&&!Ap.includes(e.name)&&i.generateNotSupportedWarning(xp.FontNotSupported,e.name,Ap);t&&t.patternType&&!Mp.includes(t.patternType)&&i.generateNotSupportedWarning(xp.FillStyleNotSupported,t.patternType,Mp)}(null==e?void 0:e.fontStyle,null==e?void 0:e.fillStyle,t),function(e,t){e&&!Tp.includes(e)&&t.generateNotSupportedWarning(xp.HorizontalAlignmentNotSupported,e,Tp)}(null===(i=null==e?void 0:e.alignment)||void 0===i?void 0:i.horizontal,t),function(e,t){e&&t.generateNotSupportedWarning(xp.VerticalAlignmentNotSupported)}(null===(o=null==e?void 0:e.alignment)||void 0===o?void 0:o.vertical,t),{bold:null===(n=e.fontStyle)||void 0===n?void 0:n.bold,italic:null===(s=e.fontStyle)||void 0===s?void 0:s.italic,strikethrough:null===(r=e.fontStyle)||void 0===r?void 0:r.strike,underline:null===(a=e.fontStyle)||void 0===a?void 0:a.underline,align:(null===(l=e.alignment)||void 0===l?void 0:l.horizontal)?Fp[e.alignment.horizontal]:void 0,fillColor:"solid"===(null===(c=e.fillStyle)||void 0===c?void 0:c.patternType)?$p(null===(h=e.fillStyle)||void 0===h?void 0:h.fgColor):$p(null===(d=e.fillStyle)||void 0===d?void 0:d.bgColor),textColor:$p(null===(u=e.fontStyle)||void 0===u?void 0:u.color),fontSize:null===(g=e.fontStyle)||void 0===g?void 0:g.size}}function Qp(e,t){const i=[];for(let o of e.styles){const n=Jp(o.numFmtId,e.numFmts,t);n&&(i[o.numFmtId]=n)}return Gp(i,1)}function Jp(e,t,i){var o,n,s;if(0===e)return;let r=zp[e]||(null===(o=t.find((t=>t.id===e)))||void 0===o?void 0:o.format);if(r)try{let e=r.replace(/(.*?);.*/,"$1");e=e.replace(/\[(.*)-[A-Z0-9]{3}\]/g,"[$1]"),e=e.replace(/\[\$\]/g,"");const t=(null===(n=e.match(/"/g))||void 0===n?void 0:n.length)||0;if(t/2+((null===(s=e.match(/\[/g))||void 0===s?void 0:s.length)||0)>1)throw new Error("Multiple escaped blocks in format");return e=e.replace(/"(.*)"/g,"[$$$1]"),e=e.replace(/_.{1}/g,""),e=e.replace(/\*.{1}/g,""),e=e.replace(/\\ /g," "),li(0,e),e}catch(e){}i.generateNotSupportedWarning(xp.NumFmtIdNotSupported,r||`nmFmtId ${e}`)}function em(e,t,i){const o=[];let n=1;for(let r of e){if(0===r.cfRules.length)continue;nm(r,t,i);const e=r.cfRules[0];let a;const l=[];if(void 0!==e.dxfId||"colorScale"===e.type||"iconSet"===e.type){switch(e.type){case"aboveAverage":case"containsErrors":case"notContainsErrors":case"dataBar":case"duplicateValues":case"expression":case"top10":case"uniqueValues":case"timePeriod":continue;case"colorScale":const t=tm(n++,r);t&&o.push(t);continue;case"iconSet":const c=im(n++,r,i);c&&o.push(c);continue;case"containsText":case"notContainsText":case"beginsWith":case"endsWith":if(!e.text)continue;a=Dp[e.type],l.push(e.text);break;case"containsBlanks":case"notContainsBlanks":a=Dp[e.type];break;case"cellIs":if(!e.operator||!e.formula||0===e.formula.length)continue;a=(s=e.operator).slice(0,1).toUpperCase()+s.slice(1),l.push(e.formula[0]),2===e.formula.length&&l.push(e.formula[1])}a&&void 0!==e.dxfId&&o.push({id:(n++).toString(),ranges:r.sqref,stopIfTrue:e.stopIfTrue,rule:{type:"CellIsRule",operator:a,values:l,style:Kp({fontStyle:t[e.dxfId].font,fillStyle:t[e.dxfId].fill},i)}})}}var s;return o}function tm(e,t){const i=t.cfRules[0].colorScale;if(!i||i.cfvos.length!==i.colors.length||i.cfvos.length<2||i.cfvos.length>3)return;const o=[];for(let e=0;e<i.cfvos.length;e++)o.push({color:(n=$p(i.colors[e])||"#FFFFFF",9===n.length&&(n=n.slice(0,7)),parseInt(n.replace("#",""),16)),type:kp[i.cfvos[e].type],value:i.cfvos[e].value});var n;const s=o[0],r=2===o.length?o[1]:o[2],a=3===o.length?o[1]:void 0;return{id:e.toString(),stopIfTrue:t.cfRules[0].stopIfTrue,ranges:t.sqref,rule:{type:"ColorScaleRule",minimum:s,midpoint:a,maximum:r}}}function im(e,t,i){const o=t.cfRules[0].iconSet;if(!o)return;let n=o.cfvos,s=o.cfIcons;if(n.length<3||s&&s.length<3)return;n.length>3&&(n=[n[0],n[Math.floor(n.length/2)],n[n.length-1]]),s&&s.length>3&&(s=[s[0],s[Math.floor(s.length/2)],s[s.length-1]]);const r=[];for(let e=1;e<=2;e++){const t=kp[n[e].type];if("value"===t)return;r.push({value:n[e].value||"",operator:n[e].gte?"ge":"gt",type:t})}let a={lower:s?om(s[0].iconSet,s[0].iconId):om(o.iconSet,0),middle:s?om(s[1].iconSet,s[1].iconId):om(o.iconSet,1),upper:s?om(s[2].iconSet,s[2].iconId):om(o.iconSet,2)};o.reverse&&(a={upper:a.lower,middle:a.middle,lower:a.upper});for(let e of Object.keys(a))if(!a[e])switch(i.generateNotSupportedWarning(xp.CfIconSetEmptyIconNotSupported),e){case"upper":a[e]=Ng.dots.good;break;case"middle":a[e]=Ng.dots.neutral;break;case"lower":a[e]=Ng.dots.bad}return{id:e.toString(),stopIfTrue:t.cfRules[0].stopIfTrue,ranges:t.sqref,rule:{type:"IconSetRule",icons:a,upperInflectionPoint:r[1],lowerInflectionPoint:r[0]}}}function om(e,t){const i=Lp[e];return i?0===t?Ng[i].bad:1===t?Ng[i].neutral:Ng[i].good:""}function nm(e,t,i){if(e.cfRules.length>1&&i.generateNotSupportedWarning(xp.MultipleRulesCfNotSupported),Op.includes(e.cfRules[0].type)||i.generateNotSupportedWarning(xp.CfTypeNotSupported,e.cfRules[0].type),e.cfRules[0].dxfId){const o=t[e.cfRules[0].dxfId];o.border&&i.generateNotSupportedWarning(xp.CfFormatBorderNotSupported),o.alignment&&i.generateNotSupportedWarning(xp.CfFormatAlignmentNotSupported),o.numFmt&&i.generateNotSupportedWarning(xp.CfFormatNumFmtNotSupported)}}function sm(e){switch(e){case"IsNotEmpty":case"NotContains":return"notContainsBlanks";case"IsEmpty":return"containsBlanks";default:return e.charAt(0).toLowerCase()+e.slice(1)}}function rm(e){return Math.round(pp*e*window.devicePixelRatio*100)/100}function am(e){return Math.round(mp*e*100)/100}function lm(e){if(e)return{style:e[0],color:{rgb:e[1]}}}function cm(e,t){let i={};e.style&&(i=t.styles[e.style]);const o=e.format?t.formats[e.format]:void 0,n={};if(e.border){const i=t.borders[e.border];n.left=lm(i.left),n.right=lm(i.right),n.bottom=lm(i.bottom),n.top=lm(i.top)}const s={font:{size:(null==i?void 0:i.fontSize)||G,color:{rgb:(null==i?void 0:i.textColor)?i.textColor:"000000"},family:2,name:"Arial"},fill:(null==i?void 0:i.fillColor)?{fgColor:{rgb:i.fillColor}}:{reservedAttribute:"none"},numFmt:o?{format:o,id:0}:void 0,border:n||{},alignment:{vertical:"center",horizontal:i.align}};return s.font.strike=!!(null==i?void 0:i.strikethrough)||void 0,s.font.underline=!!(null==i?void 0:i.underline)||void 0,s.font.bold=!!(null==i?void 0:i.bold)||void 0,s.font.italic=!!(null==i?void 0:i.italic)||void 0,s}function hm(e,t){const{id:i}=um(t.font,e.fonts),{id:o}=um(t.fill,e.fills),{id:n}=um(t.border,e.borders),s=function(e,t){if(!e)return 0;let i=Bp[e.format];if(!i){const{id:o}=um(e,t);i=o+Cp}return i}(t.numFmt,e.numFmts),r={fontId:i,fillId:o,borderId:n,numFmtId:s,alignment:{vertical:t.alignment.vertical,horizontal:t.alignment.horizontal}},{id:a}=um(r,e.styles);return a}function dm(e,t,i){let o,n=e.find((e=>e.path===t));return n?(o=`rId${(n.rels.length+1).toString()}`,n.rels.push({...i,id:o})):(o="rId1",e.push({path:t,rels:[{...i,id:o}]})),o}function um(e,t){for(let[i,o]of Object.entries(t))if(JSON.stringify(o)===JSON.stringify(e))return{id:parseInt(i,10),list:t};let i=t.findIndex((t=>JSON.stringify(t)===JSON.stringify(e)));return-1===i&&(t.push(e),i=t.length-1),{id:i,list:t}}const gm=[];function pm(e){const t=gm.findIndex((t=>t===e));return-1===t?(gm.push(e),gm.length):t+1}function mm(e){return Math.round(914400*e/96)}function fm(e,t,i){let o,n,s=e;if(({xc:s,sheetName:o}=kt(e)),o){const e=i.sheets.findIndex((e=>e.name===o));if(e<0)throw new Error("Unable to find a sheet with the name "+o);n=e}else n=Number(t);const r=Ni(s);return void 0===r.right&&(r.right=i.sheets[n].colNumber),void 0===r.bottom&&(r.bottom=i.sheets[n].rowNumber),(r.right-r.left+1)*(r.bottom-r.top+1)}function vm(e){return Math.round(96*e/914400)}function bm(e,t){var i;let o=0;for(let n=0;n<e;n++){const e=t.cols.find((e=>n>=e.min&&n<=e.max));(null==e?void 0:e.width)?o+=e.width:(null===(i=t.sheetFormat)||void 0===i?void 0:i.defaultColWidth)?o+=t.sheetFormat.defaultColWidth:o+=fp}return o/mp}function Sm(e,t){var i;let o=0;for(let n=0;n<e;n++){const e=t.rows[n];(null==e?void 0:e.height)?o+=e.height:(null===(i=t.sheetFormat)||void 0===i?void 0:i.defaultRowHeight)?o+=t.sheetFormat.defaultRowHeight:o+=vp}return o/pp}function Cm(e){let t=1;return e.figures.map((i=>function(e,t,i){const o=bm(e.anchors[0].col,i)+vm(e.anchors[0].colOffset),n=bm(e.anchors[1].col,i)+vm(e.anchors[1].colOffset),s=Sm(e.anchors[0].row,i)+vm(e.anchors[0].rowOffset),r=Sm(e.anchors[1].row,i)+vm(e.anchors[1].rowOffset),a=n-o,l=r-s,c=Em(e.data);return c?{id:t,x:o,y:s,width:a,height:l,tag:"chart",data:Em(e.data)}:void 0}(i,(t++).toString(),e))).filter(et)}function Em(e){var t;const i=null===(t=e.dataSets[0].label)||void 0===t?void 0:t.replace(/\$/g,"");let o=e.dataSets.map((e=>e.range.replace(/\$/g,"")));return"pie"===e.type&&o.reverse(),{dataSets:o,dataSetsHaveTitle:!1,labelRange:i,title:e.title||"",type:e.type,background:$p({rgb:e.backgroundColor})||"#FFFFFF",verticalAxisPosition:e.verticalAxisPosition,legendPosition:e.legendPosition,stacked:e.stacked||!1,aggregated:!1,labelsAsText:!1}}const wm=new RegExp(/'?\[([0-9]*)\](.*)'?!(\$?[a-zA-Z]*\$?[0-9]*)/g),ym=new RegExp(/SUBTOTAL\(([0-9]*),/g),xm=new RegExp(It.source,"ig");function Im(e,t){const i=function(e){const t={};for(let i of e.rows)for(let e of i.cells)e.formula&&void 0!==e.formula.sharedIndex&&e.formula.content&&(t[e.formula.sharedIndex]={refCellXc:e.xc,formula:e.formula.content});return t}(e);for(let o of e.rows.map((e=>e.cells)).flat())(null==o?void 0:o.formula)&&(o.formula.content=void 0===o.formula.sharedIndex||o.formula.content?"="+o.formula.content:"="+Tm(o.xc,i[o.formula.sharedIndex]),o.formula.content=Rm(o.formula.content,t))}function Rm(e,t){return e=(e=(e=(e=e.replace("_xlfn.","")).replace(/#REF!/g,"#REF")).replace(ym,((e,t)=>{const i=Vp[t];return i?i+"(":e}))).replace(wm,((e,i,o,n)=>{var s;i=Number(i)-1,n=n.replace(/\$/g,"");const r=t.externalBooks[i].sheetNames.findIndex((e=>e===o));if(-1===r)return e;const a=null===(s=t.externalBooks[i].datasets.find((e=>e.sheetId===r)))||void 0===s?void 0:s.data;if(!a)return e;const l=a&&a[n];return(Number(l)?l:`"${l}"`)||e}))}function Tm(e,t){const i=Ut(t.refCellXc);let o,n=t.formula.slice();do{if(o=xm.exec(n),o){const t=Ut(o[0].replace("$","")),s=Ut(e),r={colFixed:o[0].startsWith("$"),rowFixed:o[0].includes("$",1)},a={col:s.col-i.col,row:s.row-i.row},l={col:r.colFixed?t.col:t.col+a.col,row:r.rowFixed?t.row:t.row+a.row};n=n.slice(0,o.index)+Vt(l.col,l.row,r)+n.slice(o.index+o[0].length)}}while(o);return n}function Am(e,t){return e.sheets.map((i=>{Im(i,e);const o=function(e){const t=[0,0];for(let i of e.rows)t[0]=Math.max(t[0],...i.cells.map((e=>Ut(e.xc).col))),t[1]=Math.max(t[1],i.index);return t[0]=Math.max(t[0],bp),t[1]=Math.max(t[1],Sp),t}(i),n=i.sheetViews[0];return{id:i.sheetName,areGridLinesVisible:!n||n.showGridLines,name:i.sheetName,colNumber:o[0],rowNumber:o[1],cells:Nm(i,e,o,t),merges:i.merges,cols:Mm(i,o[0]),rows:Om(i,o[1]),conditionalFormats:em(i.cfs,e.dxfs,t),figures:Cm(i),isVisible:i.isVisible,panes:n?{xSplit:n.pane.xSplit,ySplit:n.pane.ySplit}:{xSplit:0,ySplit:0},filterTables:[]}}))}function Mm(e,t){var i;const o={};for(let s=1;s<t+1;s++){const t=e.cols.find((e=>e.min<=s&&s<=e.max));let r;r=t&&t.width?t.width:(null===(i=e.sheetFormat)||void 0===i?void 0:i.defaultColWidth)?e.sheetFormat.defaultColWidth:fp,o[s-1]={size:(n=r,n?Math.round(n/mp*100)/100:n),isHidden:null==t?void 0:t.hidden}}var n;return o}function Om(e,t){var i;const o={};for(let s=1;s<t+1;s++){const t=e.rows.find((e=>e.index===s));let r;r=t&&t.height?t.height:(null===(i=e.sheetFormat)||void 0===i?void 0:i.defaultRowHeight)?e.sheetFormat.defaultRowHeight:vp,o[s-1]={size:(n=r,n?Math.round(n/pp*100)/100:n),isHidden:null==t?void 0:t.hidden}}var n;return o}function Nm(e,t,i,o){const n={},s=t.sharedStrings.map((e=>e.replace(/\n/g,"")));const r=e.hyperlinks.reduce(((e,t)=>(e[t.xc]=t,e)),{});for(let i of e.rows)for(let e of i.cells)n[e.xc]={content:_m(e,r,s,o),style:e.styleIndex?e.styleIndex+1:void 0,border:e.styleIndex?t.styles[e.styleIndex].borderId+1:void 0,format:e.styleIndex?t.styles[e.styleIndex].numFmtId+1:void 0};for(let o of e.rows.filter((e=>e.styleIndex)))for(let e=1;e<=i[0];e++){const i=Vt(e-1,o.index-1);let s=n[i];s||(s={},n[i]=s),s.style=s.style?s.style:o.styleIndex+1,s.border=s.border?s.border:t.styles[o.styleIndex].borderId+1,s.format=s.format?s.format:t.styles[o.styleIndex].numFmtId+1}for(let o of e.cols.filter((e=>e.styleIndex)))for(let e=o.min;e<=Math.min(o.max,i[0]);e++)for(let s=1;s<=i[1];s++){const i=Vt(e-1,s-1);let r=n[i];r||(r={},n[i]=r),r.style=r.style?r.style:o.styleIndex+1,r.border=r.border?r.border:t.styles[o.styleIndex].borderId+1,r.format=r.format?r.format:t.styles[o.styleIndex].numFmtId+1}return n}function _m(e,t,i,o){let n;switch(e.type){case"sharedString":n=i[parseInt(e.value,10)];break;case"boolean":n=Number(e.value)?"TRUE":"FALSE";break;case"date":case"error":case"inlineStr":case"number":case"str":n=e.value}return n&&t[e.xc]&&(n=function(e,t,i){const o=e.display||t;e.relTarget||e.location||i.generateNotSupportedWarning(xp.BadlyFormattedHyperlink);const n=e.relTarget?e.relTarget:Qe(kt(e.location).sheetName);return je(o,n)}(t[e.xc],n,o)),e.formula&&(n=e.formula.content),n}const Fm={fillColor:"#000000",textColor:"#ffffff",bold:!0},Dm={bold:!0},km=["thin","#000000FF"];function Lm(e,t){for(const i of t.sheets)for(const t of i.tables){const o=e.sheets.find((e=>e.name===i.sheetName));o&&t.autoFilter&&(o.filterTables||(o.filterTables=[]),o.filterTables.push({range:t.ref}))}!function(e,t){var i,o,n,s;const r=qp(e.styles),a=qp(e.borders);for(let l of t.sheets)for(let t of l.tables){const c=e.sheets.find((e=>e.name===l.sheetName));if(!c)continue;const h=_i(t.ref);for(let e=0;e<t.headerRowCount;e++)Pm(Fm,{...h,bottom:h.top+e},c.cells,r);for(let e=0;e<t.totalsRowCount;e++)Pm(Dm,{...h,top:h.bottom-e},c.cells,r);(null===(i=t.style)||void 0===i?void 0:i.showFirstColumn)&&Pm(Dm,{...h,right:h.left},c.cells,r),(null===(o=t.style)||void 0===o?void 0:o.showLastColumn)&&Pm(Dm,{...h,left:h.right},c.cells,r);for(let e=h.left;e<=h.right;e++)for(let i=h.top;i<=h.bottom;i++){const o=Vt(e,i),r=c.cells[o],l={left:e===h.left||(null===(n=t.style)||void 0===n?void 0:n.showColumnStripes)?km:void 0,right:e===h.right?km:void 0,top:i===h.top||(null===(s=t.style)||void 0===s?void 0:s.showRowStripes)||i>h.bottom-t.totalsRowCount?km:void 0,bottom:i===h.bottom?km:void 0},d=(null==r?void 0:r.border)?{...a[r.border],...l}:l;let u=a.findIndex((e=>at(e,d)));-1===u&&(u=a.length,a.push(d)),r?r.border=u:c.cells[o]={border:u}}}e.styles=Gp(r),e.borders=Gp(a)}(e,t),function(e,t){for(let i of e){const e=t.find((e=>e.sheetName===i.name)).tables;for(let t of e){const e=t.name+"[";for(let o of Xi(_i(t.ref))){const n=Vt(o.col,o.row),s=i.cells[n];if(s&&s.content&&s.content.startsWith("=")){let i;for(;-1!==(i=s.content.indexOf(e));){let o=s.content.slice(i+e.length),r=o.indexOf("]");o.startsWith("[")&&(r=o.indexOf("]",r+1),r=o.indexOf("]",r+1)),o=o.slice(0,r);const a=Um(o,t,n);s.content=s.content.slice(0,i)+a+s.content.slice(e.length+i+r+1)}}}}}}(e.sheets,t.sheets)}function Pm(e,t,i,o){for(let n=t.left;n<=t.right;n++)for(let s=t.top;s<=t.bottom;s++){const t=Vt(n,s),r=i[t],a=(null==r?void 0:r.style)?{...o[r.style],...e}:e;let l=o.findIndex((e=>at(e,a)));-1===l&&(l=o.length,o.push(a)),r?r.style=l:i[t]={style:l}}}function Um(e,t,i){const o=e.split(","),n=_i(t.ref),s={...n};let r=!0;if(1===o.length){const e=t.cols.findIndex((e=>e.name===o[0]));s.left=s.right=e+n.left,t.headerRowCount&&(s.top+=t.headerRowCount),t.totalsRowCount&&(s.bottom-=1)}else{switch(o[0].slice(1,o[0].length-1)){case"#All":s.top=t.headerRowCount?n.top+t.headerRowCount:n.top,s.bottom=n.bottom;break;case"#Data":s.top=t.headerRowCount?n.top+t.headerRowCount:n.top,s.bottom=t.totalsRowCount?n.bottom+1:n.bottom;break;case"#This Row":s.top=s.bottom=Ut(i).row;break;case"#Headers":s.top=s.bottom=n.top,t.headerRowCount||(r=!1);break;case"#Totals":s.top=s.bottom=n.bottom,t.totalsRowCount||(r=!1)}const e=o[1].slice(1,o[1].length-1),a=t.cols.findIndex((t=>t.name===e));s.left=s.right=a+n.left}return r?s.top!==s.bottom?Di(s):Vt(s.left,s.top):Y}function Vm(e,t,i){return{content:(new XMLSerializer).serializeToString(e),path:t,contentType:i}}function zm(e){return String(e).replace(/\&/g,"&").replace(/\</g,"<").replace(/\>/g,">").replace(/\"/g,""").replace(/\'/g,"'")}function Bm(e){return new np(e.map((([e,t])=>`${e}="${zm(t)}"`)).join(" "))}function Hm(e,t="text/xml"){const i=(new DOMParser).parseFromString(e.toString(),t),o=i.querySelector("parsererror");if(o){const t=o.innerHTML,i=parseInt(t.split(":")[0],10),n=e.toString().trim().split("\n"),s=n.slice(Math.max(i-3,0),Math.min(i+2,n.length)).join("\n");throw new Error(`XML string could not be parsed: ${t}\n${s}`)}return i}function $m(e,t){return Gm`
|
|
1378
|
-
<Override ContentType="${t}" PartName="${e}" />
|
|
1379
|
-
`}function Wm(e){return new np(e.join("\n"))}function Gm(e,...t){let i=[e[0]];for(let o=0;o<t.length;o++){const n=t[o]instanceof np?t[o]:zm(t[o]);i.push(n+e[o+1])}return new np(ot(i))}function qm(e){return e.replace(/[a-z0-9]+:(?=[a-z0-9]+)/gi,"")}function Zm(e){return e.replace(/([a-z0-9]+):(?=[a-z0-9]+)/gi,"$1\\:")}class jm{constructor(e){this.value=e}asString(){return Zp(String(this.value))}asBool(){return Boolean(Number(this.value))}asNum(){return Number(this.value)}}class Xm{constructor(e,t,i){this.currentFile=void 0,this.rootFile=e,this.currentFile=e.file.fileName,this.xlsxFileStructure=t,this.warningManager=i,this.areNamespaceIgnored=null!==(new DOMParser).parseFromString("<t:test xmlns:t='a'/>","text/xml").querySelector("test"),this.relationships={},e.rels&&this.extractRelationships(e.rels).map((e=>{this.relationships[e.id]=e}))}extractRelationships(e){return this.mapOnElements({parent:e.xml,query:"Relationship"},(e=>({id:this.extractAttr(e,"Id",{required:!0}).asString(),target:this.extractAttr(e,"Target",{required:!0}).asString(),type:this.extractAttr(e,"Type",{required:!0}).asString()})))}getListOfFiles(){return Object.values(this.xlsxFileStructure).flat().filter(et)}mapOnElements(e,t){var i;const o=[],n=this.currentFile;let s;if(e.children){const t=null===(i=this.querySelector(e.parent,e.query))||void 0===i?void 0:i.children;s=t||[]}else s=this.querySelectorAll(e.parent,e.query);if(s)for(let e of s)try{o.push(t(e))}catch(t){this.catchErrorOnElement(t,e)}return this.currentFile=n,o}catchErrorOnElement(e,t){const i=t?`Error when parsing an element <${t.tagName}> of file ${this.currentFile}, skip this element. \n${e.stack}`:`Error when parsing file ${this.currentFile}.`;this.warningManager.addParsingWarning([i,e.message].join("\n"))}extractAttr(e,t,i){const o=e.attributes[t];o||this.handleMissingValue(e,`attribute "${t}"`,i);const n=(null==o?void 0:o.value)?o.value:null==i?void 0:i.default;return void 0===n?void 0:new jm(n)}extractTextContent(e,t){var i;if(void 0!==(null==t?void 0:t.default)&&"string"!=typeof t.default)throw new Error("extractTextContent default value should be a string");const o="preserve"===(null===(i=null==e?void 0:e.attributes["xml:space"])||void 0===i?void 0:i.value);let n=null==e?void 0:e.textContent;return e&&null!==n||this.handleMissingValue(e,"text content",t),n&&(n=o?n:n.trim()),n?Zp(n):null==t?void 0:t.default}extractChildAttr(e,t,i,o){var n;let s;s="number"==typeof t?e.children[t]:this.querySelector(e,t),s||this.handleMissingValue(e,"number"==typeof t?`child at index ${t}`:`child <${t}>`,o);const r=s?null===(n=this.extractAttr(s,i,o))||void 0===n?void 0:n.asString():null==o?void 0:o.default;return void 0!==r?new jm(r):void 0}extractChildTextContent(e,t,i){if(void 0!==(null==i?void 0:i.default)&&"string"!=typeof i.default)throw new Error("extractTextContent default value should be a string");let o=this.querySelector(e,t);return o||this.handleMissingValue(e,`child <${t}>`,i),o?this.extractTextContent(o,i):null==i?void 0:i.default}handleMissingValue(e,t,i){if(null==i?void 0:i.required){if(!(null==i?void 0:i.default))throw new Error(`Missing required ${t} in element <${e.tagName}> of ${this.currentFile}, and no default value was set`);this.warningManager.addParsingWarning(`Missing required ${t} in element <${e.tagName}> of ${this.currentFile}, replacing it by the default value ${i.default}`)}}extractColor(e,t,i){var o,n,s,r,a;if(!e)return i?{rgb:i}:void 0;const l=null===(o=this.extractAttr(e,"theme"))||void 0===o?void 0:o.asString();let c;if(void 0!==l){if(!t||!t.clrScheme)throw new Error("Color referencing a theme but no theme was provided");c=this.getThemeColor(l,t.clrScheme)}else c=null===(n=this.extractAttr(e,"rgb"))||void 0===n?void 0:n.asString();return{rgb:c,auto:null===(s=this.extractAttr(e,"auto"))||void 0===s?void 0:s.asBool(),indexed:null===(r=this.extractAttr(e,"indexed"))||void 0===r?void 0:r.asNum(),tint:null===(a=this.extractAttr(e,"tint"))||void 0===a?void 0:a.asNum()}}getTargetXmlFile(e){if(!e)throw new Error("Undefined target file");let t=e.target;t=t.replace("../",""),t=t.replace("./","");const i=this.getListOfFiles().find((e=>e.file.fileName.endsWith(t)));if(!i||!i.file)throw new Error("Cannot find target file");return i}querySelector(e,t){return t=this.areNamespaceIgnored?qm(t):Zm(t),e.querySelector(t)}querySelectorAll(e,t){return t=this.areNamespaceIgnored?qm(t):Zm(t),e.querySelectorAll(t)}getThemeColor(e,t){switch(e){case"0":return"FFFFFF";case"1":return"000000";case"2":return t[3].value;case"3":return t[2].value;default:return t[e].value}}}class Ym extends Xm{getTheme(){return{clrScheme:this.mapOnElements({query:"a:clrScheme",parent:this.rootFile.file.xml,children:!0},(e=>({name:e.tagName,value:this.extractChildAttr(e,0,"val",{required:!0,default:rp}).asString(),lastClr:this.extractChildAttr(e,0,"lastClr",{default:rp}).asString()})))}}getSharedStrings(){return this.mapOnElements({parent:this.rootFile.file.xml,query:"si"},(e=>"t"===e.children[0].tagName?this.extractTextContent(e)||"":this.mapOnElements({parent:e,query:"t"},(e=>this.extractTextContent(e)||"")).join("")))}}class Km extends Xm{constructor(e,t,i,o){super(e,t,i),this.theme=o}extractConditionalFormattings(){const e=this.mapOnElements({parent:this.rootFile.file.xml,query:"worksheet > conditionalFormatting"},(e=>{var t;return{sqref:this.extractAttr(e,"sqref",{required:!0}).asString().split(" "),pivot:null===(t=this.extractAttr(e,"pivot"))||void 0===t?void 0:t.asBool(),cfRules:this.extractCFRules(e,this.theme)}}));return e.push(...this.mapOnElements({parent:this.rootFile.file.xml,query:"extLst x14:conditionalFormatting"},(e=>{var t;return{sqref:this.extractChildTextContent(e,"xm:sqref",{required:!0}).split(" "),pivot:null===(t=this.extractAttr(e,"xm:pivot"))||void 0===t?void 0:t.asBool(),cfRules:this.extractCFRules(e,this.theme)}}))),e}extractCFRules(e,t){return this.mapOnElements({parent:e,query:"cfRule, x14:cfRule"},(e=>{var i,o,n,s,r,a,l,c,h,d,u;const g=this.extractAttr(e,"type",{required:!0}).asString();if("dataBar"===g)throw new Error("Databars conditional formats are not supported.");return{type:g,priority:this.extractAttr(e,"priority",{required:!0}).asNum(),colorScale:this.extractCfColorScale(e,t),formula:this.extractCfFormula(e),iconSet:this.extractCfIconSet(e),dxfId:null===(i=this.extractAttr(e,"dxfId"))||void 0===i?void 0:i.asNum(),stopIfTrue:null===(o=this.extractAttr(e,"stopIfTrue"))||void 0===o?void 0:o.asBool(),aboveAverage:null===(n=this.extractAttr(e,"aboveAverage"))||void 0===n?void 0:n.asBool(),percent:null===(s=this.extractAttr(e,"percent"))||void 0===s?void 0:s.asBool(),bottom:null===(r=this.extractAttr(e,"bottom"))||void 0===r?void 0:r.asBool(),operator:null===(a=this.extractAttr(e,"operator"))||void 0===a?void 0:a.asString(),text:null===(l=this.extractAttr(e,"text"))||void 0===l?void 0:l.asString(),timePeriod:null===(c=this.extractAttr(e,"timePeriod"))||void 0===c?void 0:c.asString(),rank:null===(h=this.extractAttr(e,"rank"))||void 0===h?void 0:h.asNum(),stdDev:null===(d=this.extractAttr(e,"stdDev"))||void 0===d?void 0:d.asNum(),equalAverage:null===(u=this.extractAttr(e,"equalAverage"))||void 0===u?void 0:u.asBool()}}))}extractCfFormula(e){return this.mapOnElements({parent:e,query:"formula"},(e=>this.extractTextContent(e,{required:!0})))}extractCfColorScale(e,t){const i=this.querySelector(e,"colorScale");if(i)return{colors:this.mapOnElements({parent:i,query:"color"},(e=>this.extractColor(e,t,"ffffff"))),cfvos:this.extractCFVos(i)}}extractCfIconSet(e){var t,i;const o=this.querySelector(e,"iconSet, x14:iconSet");if(o)return{iconSet:this.extractAttr(o,"iconSet",{default:"3TrafficLights1"}).asString(),showValue:this.extractAttr(o,"showValue",{default:!0}).asBool(),percent:this.extractAttr(o,"percent",{default:!0}).asBool(),reverse:null===(t=this.extractAttr(o,"reverse"))||void 0===t?void 0:t.asBool(),custom:null===(i=this.extractAttr(o,"custom"))||void 0===i?void 0:i.asBool(),cfvos:this.extractCFVos(o),cfIcons:this.extractCfIcons(o)}}extractCfIcons(e){const t=this.mapOnElements({parent:e,query:"cfIcon, x14:cfIcon"},(e=>({iconSet:this.extractAttr(e,"iconSet",{required:!0}).asString(),iconId:this.extractAttr(e,"iconId",{required:!0}).asNum()})));return 0===t.length?void 0:t}extractCFVos(e){return this.mapOnElements({parent:e,query:"cfvo, x14:cfvo"},(e=>{var t,i;return{type:this.extractAttr(e,"type",{required:!0}).asString(),gte:null===(t=this.extractAttr(e,"gte",{default:!0}))||void 0===t?void 0:t.asBool(),value:e.attributes.val?null===(i=this.extractAttr(e,"val"))||void 0===i?void 0:i.asString():this.extractChildTextContent(e,"f, xm:f")}}))}}class Qm extends Xm{extractChart(){return this.mapOnElements({parent:this.rootFile.file.xml,query:"c:chartSpace"},(e=>{const t=this.getChartType(e);if(!Up[t])throw new Error(`Unsupported chart type ${t}`);const i=this.mapOnElements({parent:e,query:"c:title a:t"},(e=>e.textContent||"")).join(""),o=this.extractChildAttr(e,"c:grouping","val",{default:"clustered"}).asString();return{title:i,type:Up[t],dataSets:this.extractChartDatasets(this.querySelector(e,`c:${t}`)),backgroundColor:this.extractChildAttr(e,"c:chartSpace > c:spPr a:srgbClr","val",{default:"ffffff"}).asString(),verticalAxisPosition:"r"===this.extractChildAttr(e,"c:valAx > c:axPos","val",{default:"l"}).asString()?"right":"left",legendPosition:Pp[this.extractChildAttr(e,"c:legendPos","val",{default:"b"}).asString()],stacked:"stacked"===o,fontColor:"000000"}}))[0]}extractChartDatasets(e){return this.mapOnElements({parent:e,query:"c:ser"},(e=>({label:this.extractChildTextContent(e,"c:cat c:f"),range:this.extractChildTextContent(e,"c:val c:f",{required:!0})})))}getChartType(e){const t=this.querySelector(e,"c:plotArea");if(!t)throw new Error("Missing plot area in the chart definition.");for(let e of t.children){const t=qm(e.tagName);if(sp.some((e=>e===t)))return t}throw new Error("Unknown chart type")}}class Jm extends Xm{extractFigures(){return this.mapOnElements({parent:this.rootFile.file.xml,query:"xdr:wsDr",children:!0},(e=>{if("twoCellAnchor"!==qm(e.tagName))throw new Error("Only twoCellAnchor are supported for xlsx drawings.");const t=this.querySelector(e,"c:chart");if(!t)throw new Error("Only chart figures are currently supported.");return{anchors:[this.extractFigureAnchor("xdr:from",e),this.extractFigureAnchor("xdr:to",e)],data:this.extractChart(t)}}))}extractFigureAnchor(e,t){const i=this.querySelector(t,e);if(!i)throw new Error(`Missing anchor element ${e}`);return{col:Number(this.extractChildTextContent(i,"xdr:col",{required:!0})),colOffset:Number(this.extractChildTextContent(i,"xdr:colOff",{required:!0})),row:Number(this.extractChildTextContent(i,"xdr:row",{required:!0})),rowOffset:Number(this.extractChildTextContent(i,"xdr:rowOff",{required:!0}))}}extractChart(e){const t=this.extractAttr(e,"r:id",{required:!0}).asString(),i=this.getTargetXmlFile(this.relationships[t]),o=new Qm(i,this.xlsxFileStructure,this.warningManager).extractChart();if(!o)throw new Error("Unable to extract chart definition");return o}}class ef extends Xm{getPivotTable(){return this.mapOnElements({query:":root",parent:this.rootFile.file.xml},(e=>({displayName:this.extractAttr(e,"name",{required:!0}).asString(),id:this.extractAttr(e,"name",{required:!0}).asString(),ref:this.extractChildAttr(e,"location","ref",{required:!0}).asString(),headerRowCount:this.extractChildAttr(e,"location","firstDataRow",{default:0}).asNum(),totalsRowCount:1,cols:[],style:{showFirstColumn:!0,showRowStripes:!0}})))[0]}}class tf extends Xm{getTable(){return this.mapOnElements({query:"table",parent:this.rootFile.file.xml},(e=>{var t;return{displayName:this.extractAttr(e,"displayName",{required:!0}).asString(),name:null===(t=this.extractAttr(e,"name"))||void 0===t?void 0:t.asString(),id:this.extractAttr(e,"id",{required:!0}).asString(),ref:this.extractAttr(e,"ref",{required:!0}).asString(),headerRowCount:this.extractAttr(e,"headerRowCount",{default:1}).asNum(),totalsRowCount:this.extractAttr(e,"totalsRowCount",{default:0}).asNum(),cols:this.extractTableCols(e),style:this.extractTableStyleInfo(e),autoFilter:this.extractTableAutoFilter(e)}}))[0]}extractTableCols(e){return this.mapOnElements({query:"tableColumn",parent:e},(e=>({id:this.extractAttr(e,"id",{required:!0}).asString(),name:this.extractAttr(e,"name",{required:!0}).asString(),colFormula:this.extractChildTextContent(e,"calculatedColumnFormula")})))}extractTableStyleInfo(e){return this.mapOnElements({query:"tableStyleInfo",parent:e},(e=>{var t,i,o,n,s;return{name:null===(t=this.extractAttr(e,"name"))||void 0===t?void 0:t.asString(),showFirstColumn:null===(i=this.extractAttr(e,"showFirstColumn"))||void 0===i?void 0:i.asBool(),showLastColumn:null===(o=this.extractAttr(e,"showLastColumn"))||void 0===o?void 0:o.asBool(),showRowStripes:null===(n=this.extractAttr(e,"showRowStripes"))||void 0===n?void 0:n.asBool(),showColumnStripes:null===(s=this.extractAttr(e,"showColumnStripes"))||void 0===s?void 0:s.asBool()}}))[0]}extractTableAutoFilter(e){return this.mapOnElements({query:"autoFilter",parent:e},(e=>({columns:this.extractFilterColumns(e),zone:this.extractAttr(e,"ref",{required:!0}).asString()})))[0]}extractFilterColumns(e){return this.mapOnElements({query:"tableColumn",parent:e},(t=>({colId:this.extractAttr(e,"colId",{required:!0}).asNum(),hiddenButton:this.extractAttr(e,"hiddenButton",{default:!1}).asBool(),filters:this.extractSimpleFilter(t)})))}extractSimpleFilter(e){return this.mapOnElements({query:"filter",parent:e},(e=>({val:this.extractAttr(e,"val",{required:!0}).asString()})))}}class of extends Xm{constructor(e,t,i,o){super(e,t,i),this.theme=o}getSheet(){return this.mapOnElements({query:"worksheet",parent:this.rootFile.file.xml},(e=>{const t=this.getSheetWorkbookInfo();return{sheetName:this.extractSheetName(),sheetViews:this.extractSheetViews(e),sheetFormat:this.extractSheetFormat(e),cols:this.extractCols(e),rows:this.extractRows(e),sharedFormulas:this.extractSharedFormulas(e),merges:this.extractMerges(e),cfs:this.extractConditionalFormats(),figures:this.extractFigures(e),hyperlinks:this.extractHyperLinks(e),tables:[...this.extractTables(e),...this.extractPivotTables()],isVisible:"visible"===t.state}}))[0]}extractSheetViews(e){return this.mapOnElements({parent:e,query:"sheetView"},(e=>{const t=this.querySelector(e,"pane");return{tabSelected:this.extractAttr(e,"tabSelected",{default:!1}).asBool(),showFormulas:this.extractAttr(e,"showFormulas",{default:!1}).asBool(),showGridLines:this.extractAttr(e,"showGridLines",{default:!0}).asBool(),showRowColHeaders:this.extractAttr(e,"showRowColHeaders",{default:!0}).asBool(),pane:{xSplit:t?this.extractAttr(t,"xSplit",{default:0}).asNum():0,ySplit:t?this.extractAttr(t,"ySplit",{default:0}).asNum():0}}}))}extractSheetName(){const e=Wp(this.xlsxFileStructure.workbook.file.fileName,this.rootFile.file.fileName),t=this.extractRelationships(this.xlsxFileStructure.workbook.rels).find((t=>t.target===e)).id;for(let e of this.querySelectorAll(this.xlsxFileStructure.workbook.file.xml,"sheet"))if(e.attributes["r:id"].value===t)return e.attributes.name.value;throw new Error("Missing sheet name")}getSheetWorkbookInfo(){const e=Wp(this.xlsxFileStructure.workbook.file.fileName,this.rootFile.file.fileName),t=this.extractRelationships(this.xlsxFileStructure.workbook.rels).find((t=>t.target===e)).id,i=this.mapOnElements({parent:this.xlsxFileStructure.workbook.file.xml,query:"sheet"},(e=>({relationshipId:this.extractAttr(e,"r:id",{required:!0}).asString(),sheetId:this.extractAttr(e,"sheetId",{required:!0}).asString(),sheetName:this.extractAttr(e,"name",{required:!0}).asString(),state:this.extractAttr(e,"state",{default:"visible"}).asString()}))).find((e=>e.relationshipId===t));if(!i)throw new Error("Cannot find corresponding workbook sheet");return i}extractConditionalFormats(){return new Km(this.rootFile,this.xlsxFileStructure,this.warningManager,this.theme).extractConditionalFormattings()}extractFigures(e){return this.mapOnElements({parent:e,query:"drawing"},(e=>{var t;const i=null===(t=this.extractAttr(e,"r:id",{required:!0}))||void 0===t?void 0:t.asString(),o=this.getTargetXmlFile(this.relationships[i]);return new Jm(o,this.xlsxFileStructure,this.warningManager).extractFigures()}))[0]||[]}extractTables(e){return this.mapOnElements({query:"tablePart",parent:e},(e=>{var t;const i=null===(t=this.extractAttr(e,"r:id",{required:!0}))||void 0===t?void 0:t.asString(),o=this.getTargetXmlFile(this.relationships[i]);return new tf(o,this.xlsxFileStructure,this.warningManager).getTable()}))}extractPivotTables(){try{return Object.values(this.relationships).filter((e=>e.type.endsWith("pivotTable"))).map((e=>{const t=this.getTargetXmlFile(e);return new ef(t,this.xlsxFileStructure,this.warningManager).getPivotTable()}))}catch(e){return this.catchErrorOnElement(e),[]}}extractMerges(e){return this.mapOnElements({parent:e,query:"mergeCell"},(e=>this.extractAttr(e,"ref",{required:!0}).asString()))}extractSheetFormat(e){const t=this.querySelector(e,"sheetFormatPr");if(t)return{defaultColWidth:this.extractAttr(t,"defaultColWidth",{default:fp.toString()}).asNum(),defaultRowHeight:this.extractAttr(t,"defaultRowHeight",{default:vp.toString()}).asNum()}}extractCols(e){return this.mapOnElements({parent:e,query:"cols col"},(e=>{var t,i,o,n,s,r,a;return{width:null===(t=this.extractAttr(e,"width"))||void 0===t?void 0:t.asNum(),customWidth:null===(i=this.extractAttr(e,"customWidth"))||void 0===i?void 0:i.asBool(),bestFit:null===(o=this.extractAttr(e,"bestFit"))||void 0===o?void 0:o.asBool(),hidden:null===(n=this.extractAttr(e,"hidden"))||void 0===n?void 0:n.asBool(),min:null===(s=this.extractAttr(e,"min",{required:!0}))||void 0===s?void 0:s.asNum(),max:null===(r=this.extractAttr(e,"max",{required:!0}))||void 0===r?void 0:r.asNum(),styleIndex:null===(a=this.extractAttr(e,"style"))||void 0===a?void 0:a.asNum()}}))}extractRows(e){return this.mapOnElements({parent:e,query:"sheetData row"},(e=>{var t,i,o,n,s;return{index:null===(t=this.extractAttr(e,"r",{required:!0}))||void 0===t?void 0:t.asNum(),cells:this.extractCells(e),height:null===(i=this.extractAttr(e,"ht"))||void 0===i?void 0:i.asNum(),customHeight:null===(o=this.extractAttr(e,"customHeight"))||void 0===o?void 0:o.asBool(),hidden:null===(n=this.extractAttr(e,"hidden"))||void 0===n?void 0:n.asBool(),styleIndex:null===(s=this.extractAttr(e,"s"))||void 0===s?void 0:s.asNum()}}))}extractCells(e){return this.mapOnElements({parent:e,query:"c"},(e=>{var t,i,o;return{xc:null===(t=this.extractAttr(e,"r",{required:!0}))||void 0===t?void 0:t.asString(),styleIndex:null===(i=this.extractAttr(e,"s"))||void 0===i?void 0:i.asNum(),type:Np[null===(o=this.extractAttr(e,"t",{default:"n"}))||void 0===o?void 0:o.asString()],value:this.extractChildTextContent(e,"v"),formula:this.extractCellFormula(e)}}))}extractCellFormula(e){var t,i;const o=this.querySelector(e,"f");if(o)return{content:this.extractTextContent(o),sharedIndex:null===(t=this.extractAttr(o,"si"))||void 0===t?void 0:t.asNum(),ref:null===(i=this.extractAttr(o,"ref"))||void 0===i?void 0:i.asString()}}extractHyperLinks(e){return this.mapOnElements({parent:e,query:"hyperlink"},(e=>{var t,i,o,n;const s=null===(t=this.extractAttr(e,"r:id"))||void 0===t?void 0:t.asString();return{xc:null===(i=this.extractAttr(e,"ref",{required:!0}))||void 0===i?void 0:i.asString(),location:null===(o=this.extractAttr(e,"location"))||void 0===o?void 0:o.asString(),display:null===(n=this.extractAttr(e,"display"))||void 0===n?void 0:n.asString(),relTarget:s?this.relationships[s].target:void 0}}))}extractSharedFormulas(e){const t=this.querySelectorAll(e,"f[si][ref]"),i={};for(let e of t){const t=this.extractAttr(e,"si",{required:!0}).asNum(),o=this.extractTextContent(e,{required:!0});i[t]=o}const o=[];for(let e=0;e<Object.keys(i).length;e++)i[e]?o.push(i[e]):(this.warningManager.addParsingWarning(`Missing shared formula ${e}, replacing it by empty formula`),o.push(""));return o}}class nf extends Xm{constructor(e,t,i){super(e.styles,e,t),this.theme=i}getNumFormats(){return this.mapOnElements({parent:this.rootFile.file.xml,query:"numFmt"},(e=>this.extractNumFormats(e)))}extractNumFormats(e){return{id:this.extractAttr(e,"numFmtId",{required:!0}).asNum(),format:this.extractAttr(e,"formatCode",{required:!0,default:""}).asString()}}getFonts(){return this.mapOnElements({parent:this.rootFile.file.xml,query:"font"},(e=>this.extractFont(e)))}extractFont(e){var t,i,o,n;const s=this.extractChildAttr(e,"name","val",{default:"Arial"}).asString(),r=this.extractChildAttr(e,"sz","val",{default:G.toString()}).asNum(),a=this.extractColor(this.querySelector(e,"color"),this.theme),l=this.querySelector(e,"i")||void 0,c=l&&"0"!==(null===(t=l.attributes.val)||void 0===t?void 0:t.value),h=this.querySelector(e,"b")||void 0,d=h&&"0"!==(null===(i=h.attributes.val)||void 0===i?void 0:i.value),u=this.querySelector(e,"strike")||void 0,g=u&&"0"!==(null===(o=u.attributes.val)||void 0===o?void 0:o.value),p=this.querySelector(e,"u")||void 0;return{name:s,size:r,color:a,italic:c,bold:d,underline:p&&"none"!==(null===(n=p.attributes.val)||void 0===n?void 0:n.value),strike:g}}getFills(){return this.mapOnElements({parent:this.rootFile.file.xml,query:"fill"},(e=>this.extractFill(e)))}extractFill(e){var t;const i=e.children[0];return"patternFill"===i.tagName?{patternType:null===(t=i.attributes.patternType)||void 0===t?void 0:t.value,bgColor:this.extractColor(this.querySelector(i,"bgColor"),this.theme),fgColor:this.extractColor(this.querySelector(i,"fgColor"),this.theme)}:{patternType:"solid",fgColor:this.extractColor(this.querySelectorAll(i,"color")[1],this.theme)}}getBorders(){return this.mapOnElements({parent:this.rootFile.file.xml,query:"border"},(e=>this.extractBorder(e)))}extractBorder(e){var t,i;const o={left:this.extractSingleBorder(e,"left",this.theme),right:this.extractSingleBorder(e,"right",this.theme),top:this.extractSingleBorder(e,"top",this.theme),bottom:this.extractSingleBorder(e,"bottom",this.theme),diagonal:this.extractSingleBorder(e,"diagonal",this.theme)};return o.diagonal&&(o.diagonalUp=null===(t=this.extractAttr(e,"diagonalUp"))||void 0===t?void 0:t.asBool(),o.diagonalDown=null===(i=this.extractAttr(e,"diagonalDown"))||void 0===i?void 0:i.asBool()),o}extractSingleBorder(e,t,i){const o=this.querySelector(e,t);if(o&&o.attributes.style)return{style:this.extractAttr(o,"style",{required:!0,default:"thin"}).asString(),color:this.extractColor(o.children[0],i,"000000")}}extractAlignment(e){var t,i,o,n,s,r,a;return{horizontal:this.extractAttr(e,"horizontal",{default:"general"}).asString(),vertical:this.extractAttr(e,"vertical",{default:"center"}).asString(),textRotation:null===(t=this.extractAttr(e,"textRotation"))||void 0===t?void 0:t.asNum(),wrapText:null===(i=this.extractAttr(e,"wrapText"))||void 0===i?void 0:i.asBool(),indent:null===(o=this.extractAttr(e,"indent"))||void 0===o?void 0:o.asNum(),relativeIndent:null===(n=this.extractAttr(e,"relativeIndent"))||void 0===n?void 0:n.asNum(),justifyLastLine:null===(s=this.extractAttr(e,"justifyLastLine"))||void 0===s?void 0:s.asBool(),shrinkToFit:null===(r=this.extractAttr(e,"shrinkToFit"))||void 0===r?void 0:r.asBool(),readingOrder:null===(a=this.extractAttr(e,"readingOrder"))||void 0===a?void 0:a.asNum()}}getDxfs(){return this.mapOnElements({query:"dxf",parent:this.rootFile.file.xml},(e=>{const t=this.querySelector(e,"font"),i=this.querySelector(e,"fill"),o=this.querySelector(e,"border"),n=this.querySelector(e,"numFmt"),s=this.querySelector(e,"alignment");return{font:t?this.extractFont(t):void 0,fill:i?this.extractFill(i):void 0,numFmt:n?this.extractNumFormats(n):void 0,alignment:s?this.extractAlignment(s):void 0,border:o?this.extractBorder(o):void 0}}))}getStyles(){return this.mapOnElements({query:"cellXfs xf",parent:this.rootFile.file.xml},(e=>{const t=this.querySelector(e,"alignment");return{fontId:this.extractAttr(e,"fontId",{required:!0,default:0}).asNum(),fillId:this.extractAttr(e,"fillId",{required:!0,default:0}).asNum(),borderId:this.extractAttr(e,"borderId",{required:!0,default:0}).asNum(),numFmtId:this.extractAttr(e,"numFmtId",{required:!0,default:0}).asNum(),alignment:t?this.extractAlignment(t):void 0}}))}}class sf extends Xm{getExternalBook(){return this.mapOnElements({parent:this.rootFile.file.xml,query:"externalBook"},(e=>({rId:this.extractAttr(e,"r:id",{required:!0}).asString(),sheetNames:this.mapOnElements({parent:e,query:"sheetName"},(e=>this.extractAttr(e,"val",{required:!0}).asString())),datasets:this.extractExternalSheetData(e)})))[0]}extractExternalSheetData(e){return this.mapOnElements({parent:e,query:"sheetData"},(e=>{const t=this.mapOnElements({parent:e,query:"cell"},(e=>({xc:this.extractAttr(e,"r",{required:!0}).asString(),value:this.extractChildTextContent(e,"v",{required:!0})}))),i={};for(let e of t)i[e.xc]=e.value;return{sheetId:this.extractAttr(e,"sheetId",{required:!0}).asNum(),data:i}}))}}function rf(e,t){const i=function(e,t){const i=t[yp],o=i.querySelectorAll(`Override[ContentType="${e}"]`),n=[];for(let e of o){const t=null==e?void 0:e.attributes.PartName.value;n.push(t.substring(1))}return n}(e,t);return function(e,t){const i=[];for(let o of e){const e=af(o,t);i.push({file:{fileName:o,xml:t[o]},rels:e?{fileName:e,xml:t[e]}:void 0})}return i}(i,t)}function af(e,t){if(e===yp)return"_rels/.rels";let i="";const o=e.split("/");for(let e=0;e<o.length-1;e++)i+=o[e]+"/";return i+="_rels/",i+=o[o.length-1]+".rels",t[i]||(i=void 0),i}class lf{constructor(e){this.warningManager=new Ip,this.xmls={};for(let t of Object.keys(e))(t.endsWith(".xml")||t.endsWith(".rels"))&&(this.xmls[t]=Hm(new np(e[t])))}convertXlsx(){const e=this.getXlsxData();return this.convertImportedData(e)}getXlsxData(){const e=this.buildXlsxFileStructure(),t=e.theme?new Ym(e.theme,e,this.warningManager).getTheme():void 0,i=e.sharedStrings?new Ym(e.sharedStrings,e,this.warningManager).getSharedStrings():[],o=e.sheets.sort(((e,t)=>e.file.fileName.localeCompare(t.file.fileName,void 0,{numeric:!0}))).map((i=>new of(i,e,this.warningManager,t).getSheet())),n=e.externalLinks.map((t=>new sf(t,e,this.warningManager).getExternalBook())),s=new nf(e,this.warningManager,t);return{fonts:s.getFonts(),fills:s.getFills(),borders:s.getBorders(),dxfs:s.getDxfs(),numFmts:s.getNumFormats(),styles:s.getStyles(),sheets:o,sharedStrings:i,externalBooks:n}}buildXlsxFileStructure(){const e={sheets:rf(dp.sheet,this.xmls),workbook:rf(dp.workbook,this.xmls)[0],styles:rf(dp.styles,this.xmls)[0],sharedStrings:rf(dp.sharedStrings,this.xmls)[0],theme:rf(dp.themes,this.xmls)[0],charts:rf(dp.chart,this.xmls),figures:rf(dp.drawing,this.xmls),tables:rf(dp.table,this.xmls),pivots:rf(dp.pivot,this.xmls),externalLinks:rf(dp.externalLink,this.xmls)};if(!e.workbook.rels)throw Error(s("Cannot find workbook relations file"));return e}convertImportedData(e){const t={version:12,sheets:Am(e,this.warningManager),styles:Yp(e,this.warningManager),formats:Qp(e,this.warningManager),borders:jp(e,this.warningManager),entities:{},revisionId:K};return Lm(t,e),Object.keys(e.styles).map((t=>{e.styles[t]=lt(e.styles[t])})),t}}const cf=iu.content,hf=["%"],df="+,-,*,/,:,=,<>,>=,>,<=,<,^,&".split(",").concat(hf);function uf(e){const t=(e=gt(e)).split(""),i=[];for(;t.length;){let e=wf(t)||mf(t)||vf(t)||Sf(t)||gf(t)||yf(t)||bf(t)||Ef(t);e||(e={type:"UNKNOWN",value:t.shift()}),i.push(e)}return i}function gf(e){return"?"===e[0]?(e.shift(),{type:"DEBUGGER",value:"?"}):null}const pf={",":"COMMA","(":"LEFT_PAREN",")":"RIGHT_PAREN"};function mf(e){if(e[0]in pf){const t=e.shift();return{type:pf[t],value:t}}return null}function ff(e,t){for(let i=0;i<t.length;i++)if(t[i]!==e[i])return!1;return!0}function vf(e){for(let t of df)if(ff(e,t))return e.splice(0,t.length),{type:"OPERATOR",value:t};return null}function bf(e){const t=ot(e).match(Wt);return t?(e.splice(0,t[0].length),{type:"NUMBER",value:t[0]}):null}function Sf(e){if('"'===e[0]){const t=e.shift();let i=t;for(;e[0]&&(e[0]!==t||"\\"===i[i.length-1]);)i+=e.shift();return'"'===e[0]&&(i+=e.shift()),{type:"STRING",value:i}}return null}const Cf=/\w|\.|!|\$/;function Ef(e){let t="";if("'"===e[0]){let i=e.shift();for(t+=i;e[0];)if(i=e.shift(),t+=i,"'"===i){if(!e[0]||"'"!==e[0])break;i=e.shift(),t+=i}if("'"!==i)return{type:"UNKNOWN",value:t}}for(;e[0]&&e[0].match(Cf);)t+=e.shift();if(t.length){const e=t;if(e.toUpperCase()in cf)return{type:"FUNCTION",value:e};return e.match(Ot)?{type:"REFERENCE",value:e}:{type:"SYMBOL",value:e}}return null}function wf(e){let t=0;for(;e[0]===ce;)t++,e.shift();if(t)return{type:"SPACE",value:ce.repeat(t)};for(;" "===e[0];)t++,e.shift();return t?{type:"SPACE",value:" ".repeat(t)}:null}function yf(e){return ff(e,Y)?(e.splice(0,Y.length),{type:"INVALID_REFERENCE",value:Y}):null}var xf;!function(e){e[e.LeftRef=0]="LeftRef",e[e.RightRef=1]="RightRef",e[e.Separator=2]="Separator",e[e.FullColumnSeparator=3]="FullColumnSeparator",e[e.FullRowSeparator=4]="FullRowSeparator",e[e.RightColumnRef=5]="RightColumnRef",e[e.RightRowRef=6]="RightRowRef",e[e.Found=7]="Found"}(xf||(xf={}));const If=(e,t=(()=>!0))=>[{goTo:e,guard:t}],Rf=(e,t=(()=>!0))=>({goTo:e,guard:t}),Tf={[xf.LeftRef]:{REFERENCE:If(xf.Separator),NUMBER:If(xf.FullRowSeparator),SYMBOL:[Rf(xf.FullColumnSeparator,(e=>Nt(e.value))),Rf(xf.FullRowSeparator,(e=>_t(e.value)))]},[xf.FullColumnSeparator]:{SPACE:If(xf.FullColumnSeparator),OPERATOR:If(xf.RightColumnRef,(e=>":"===e.value))},[xf.FullRowSeparator]:{SPACE:If(xf.FullRowSeparator),OPERATOR:If(xf.RightRowRef,(e=>":"===e.value))},[xf.Separator]:{SPACE:If(xf.Separator),OPERATOR:If(xf.RightRef,(e=>":"===e.value))},[xf.RightRef]:{SPACE:If(xf.RightRef),NUMBER:If(xf.Found),REFERENCE:If(xf.Found,(e=>Dt(e.value))),SYMBOL:If(xf.Found,(e=>Ft(e.value)))},[xf.RightColumnRef]:{SPACE:If(xf.RightColumnRef),SYMBOL:If(xf.Found,(e=>Ft(e.value))),REFERENCE:If(xf.Found,(e=>Dt(e.value)))},[xf.RightRowRef]:{SPACE:If(xf.RightRowRef),NUMBER:If(xf.Found),REFERENCE:If(xf.Found,(e=>Dt(e.value)))},[xf.Found]:{}};function Af(e){var t;let i=0,o=Tf[xf.LeftRef];const n=[];for(;void 0!==o;){const s=e[i++];if(!s)return null;const r=null===(t=o[s.type])||void 0===t?void 0:t.find((e=>e.guard(s))),a=r?r.goTo:void 0;switch(a){case void 0:return null;case xf.Found:return n.push(s),e.splice(0,i),{type:"REFERENCE",value:ot(n.map((e=>e.value)))};default:o=Tf[a],n.push(s)}}return null}function Mf(e){const t=uf(e),i=[];for(;t.length;)i.push(Af(t)||t.shift());return i}function Of(e){const t=Mf(e);let i=[];return{text:"".concat(...t.map((e=>{if("REFERENCE"===e.type&&It.test(e.value)){const t=e.value.trim();return i.includes(t)||i.push(t),`${re}${i.indexOf(t)}${re}`}return e.value}))),dependencies:i}}const Nf=12,_f="Sheet1";function Ff(e,t){if(!e)return Uf();if(e["[Content_Types].xml"]){const i=new lf(e);if(e=i.convertXlsx(),t)for(let e of i.warningManager.warnings.sort())console.warn(e)}return"version"in(e=JSON.parse(JSON.stringify(e)))&&e.version<Nf&&(e=function(e){for(let t=Df.findIndex((t=>t.from===e.version));t<Df.length;t++)e=Df[t].applyMigration(e);return e}(e)),e=function(e){return e=function(e){if(e.uniqueFigureIds)return e;const t=new Set,i=new Oi;for(const o of e.sheets||[])for(const e of o.figures||[])t.has(e.id)&&(e.id+=i.uuidv4()),t.add(e.id);return e.uniqueFigureIds=!0,e}(e),e=function(e){e=Object.assign(Uf(),e,{version:Nf}),e.sheets=e.sheets?e.sheets.map(((e,t)=>Object.assign(Pf(`Sheet${t+1}`,`Sheet${t+1}`),e))):[],0===e.sheets.length&&e.sheets.push(Pf(_f,"Sheet1"));return e}(e),e}(e),e}const Df=[{description:"add the `activeSheet` field on data",from:1,to:2,applyMigration:e=>(e.sheets&&e.sheets[0]&&(e.activeSheet=e.sheets[0].name),e)},{description:"add an id field in each sheet",from:2,to:3,applyMigration(e){if(e.sheets&&e.sheets.length)for(let t of e.sheets)t.id=t.id||t.name;return e}},{description:"activeSheet is now an id, not the name of a sheet",from:3,to:4,applyMigration(e){if(e.sheets&&e.activeSheet){const t=e.sheets.find((t=>t.name===e.activeSheet));e.activeSheet=t.id}return e}},{description:"add figures object in each sheets",from:4,to:5,applyMigration(e){for(let t of e.sheets||[])t.figures=t.figures||[];return e}},{description:"normalize the content of the cell if it is a formula to avoid parsing all the formula that vary only by the cells they use",from:5,to:6,applyMigration(e){for(let t of e.sheets||[])for(let e in t.cells||[]){const i=t.cells[e];i.content&&i.content.startsWith("=")&&(i.formula=Of(i.content))}return e}},{description:"transform chart data structure",from:6,to:7,applyMigration(e){for(let t of e.sheets||[])for(let e in t.figures||[]){const{dataSets:i,...o}=t.figures[e].data,n=[];for(let e of i)if(e.labelCell){const t=_i(e.dataRange),i=e.labelCell+":"+Vt(t.right,t.bottom);n.push(i)}else n.push(e.dataRange);o.dataSetsHaveTitle=Boolean(i[0].labelCell),o.dataSets=n,t.figures[e].data=o}return e}},{description:"remove single quotes in sheet names",from:7,to:8,applyMigration(e){var t;const i=[],o=new RegExp(se,"g");for(let n of e.sheets||[]){if(!n.name)continue;const e=n.name,s=e.replace(o,"_");let r=1,a=s;for(;i.includes(a);)a=`${s}${r}`,r++;n.name=a,i.push(a);const l=t=>{if(void 0===t)return t;let i=t.replace(e,a),o=t;for(;o!==i;)o=i,i=o.replace(e,a);return o};for(let e in n.cells){const t=n.cells[e];t.formula&&(t.formula.dependencies=t.formula.dependencies.map(l))}for(let e of n.figures||[])if("chart"===e.type){const t=e.data.dataSets.map(l),i=l(e.data.labelRange);e.data={...e.data,dataSets:t,labelRange:i}}for(let e of n.conditionalFormats||[]){e.ranges=e.ranges.map(l);for(const i of["minimum","maximum","midpoint","upperInflectionPoint","lowerInflectionPoint"])"formula"===(null===(t=e.rule[i])||void 0===t?void 0:t.type)&&(e.rule[i].value=l(e.rule[i].value))}}return e}},{description:"transform chart data structure with design attributes",from:8,to:9,applyMigration(e){for(const t of e.sheets||[])for(const e of t.figures||[])e.data.background=w,e.data.verticalAxisPosition="left",e.data.legendPosition="top",e.data.stacked=!1;return e}},{description:"de-normalize formula to reduce exported json size (~30%)",from:9,to:10,applyMigration(e){for(let t of e.sheets||[])for(let e in t.cells||[]){const i=t.cells[e];if(i.formula){let{text:e,dependencies:t}=i.formula;for(let[i,o]of Object.entries(t)){const t=`\\${re}${i}\\${re}`;e=e.replace(new RegExp(t,"g"),o)}i.content=e,delete i.formula}}return e}},{description:"normalize the formats of the cells",from:10,to:11,applyMigration(e){const t={};for(let i of e.sheets||[])for(let e in i.cells||[]){const o=i.cells[e];o.format&&(o.format=it(o.format,t))}return e.formats=t,e}},{description:"Add isVisible to sheets",from:11,to:12,applyMigration(e){for(let t of e.sheets||[])t.isVisible=!0;return e}}];function kf(e,t){return t=function(e,t){if(0!==Object.keys(e).length)return t;const i=[],o=[],n=e=>{if("CREATE_SHEET"===e.type)i.push(e.sheetId);else if("sheetId"in e&&!i.includes(e.sheetId))return{...e,sheetId:_f};return e};for(const e of t)"REMOTE_REVISION"===e.type?o.push({...e,commands:e.commands.map(n)}):o.push(e);return o}(e,t),t=Lf(t,"SORT_CELLS"),t=function(e,t){var i;const o=[],n={};for(const t of e.sheets||[])null===(i=t.figures)||void 0===i||i.forEach((e=>{"chart"===e.tag&&(n[e.id]=e.data)}));for(const e of t)if("REMOTE_REVISION"===e.type){const t=[];for(const i of e.commands){let e=i;switch(i.type){case"CREATE_CHART":n[i.id]=i.definition;break;case"UPDATE_CHART":if(!n[i.id]){console.log(`Fix chart definition: chart with id ${i.id} not found.`);continue}const t={...n[i.id],...i.definition};e={...i,definition:t},n[i.id]=t}t.push(e)}o.push({...e,commands:t})}else o.push(e);return o}(e,t=Lf(t,"SET_DECIMAL")),t}function Lf(e,t){const i=[];for(const o of e)"REMOTE_REVISION"===o.type?i.push({...o,commands:o.commands.filter((e=>e.type!==t))}):i.push(o);return i}function Pf(e,t){return{id:e,name:t,colNumber:26,rowNumber:100,cells:{},cols:{},rows:{},merges:[],conditionalFormats:[],figures:[],filterTables:[],isVisible:!0}}function Uf(e="Sheet1"){return{version:Nf,sheets:[Pf(_f,e)],entities:{},styles:{},formats:{},borders:{},revisionId:K,uniqueFigureIds:!0}}function Vf(e,t){return{...Pf(e,t),charts:[]}}class zf{constructor(e,t){this.history=Object.assign(Object.create(e),{update:e.addChange.bind(e,this),selectCell:()=>{}}),this.dispatch=t}exportForExcel(e){}allowDispatch(e){return 0}beforeHandle(e){}handle(e){}finalize(){}batchValidations(...e){return t=>e.map((e=>e.call(this,t))).flat()}chainValidations(...e){return t=>{for(const i of e){let e=i.call(this,t);Array.isArray(e)||(e=[e]);const o=e.filter((e=>0!==e));if(o.length)return o}return 0}}checkValidations(e,...t){return this.batchValidations(...t)(e)}}zf.getters=[];class Bf extends zf{constructor({getters:e,stateObserver:t,range:i,dispatch:o,uuidGenerator:n}){super(t,o),this.range=i,i.addRangeProvider(this.adaptRanges.bind(this)),this.getters=e,this.uuidGenerator=n}import(e){}export(e){}adaptRanges(e,t){}garbageCollectExternalResources(){}}class Hf extends Bf{constructor(){super(...arguments),this.borders={}}handle(e){switch(e.type){case"ADD_MERGE":for(const t of e.target)this.addBordersToMerge(e.sheetId,t);break;case"DUPLICATE_SHEET":const t=this.borders[e.sheetId];if(t){const i=t.slice().map((e=>null==e?void 0:e.slice().map((e=>({...e})))));this.history.update("borders",e.sheetIdTo,i)}break;case"DELETE_SHEET":const i={...this.borders};delete i[e.sheetId],this.history.update("borders",i);break;case"SET_BORDER":this.setBorder(e.sheetId,e.col,e.row,e.border);break;case"SET_FORMATTING":if(e.border){const t=e.target.map((t=>this.getters.expandZone(e.sheetId,t)));this.setBorders(e.sheetId,t,e.border)}break;case"CLEAR_FORMATTING":this.clearBorders(e.sheetId,e.target);break;case"REMOVE_COLUMNS_ROWS":for(let t of e.elements)"COL"===e.dimension?this.shiftBordersHorizontally(e.sheetId,t+1,-1):this.shiftBordersVertically(e.sheetId,t+1,-1);break;case"ADD_COLUMNS_ROWS":"COL"===e.dimension?this.handleAddColumns(e):this.handleAddRows(e)}}handleAddColumns(e){let t,i;"before"===e.position?(this.shiftBordersHorizontally(e.sheetId,e.base,e.quantity,{moveFirstLeftBorder:!0}),t=e.base-1,i=e.base+e.quantity):(this.shiftBordersHorizontally(e.sheetId,e.base+1,e.quantity,{moveFirstLeftBorder:!1}),t=e.base,i=e.base+e.quantity+1),this.ensureColumnBorderContinuity(e.sheetId,t,i)}handleAddRows(e){let t,i;"before"===e.position?(this.shiftBordersVertically(e.sheetId,e.base,e.quantity,{moveFirstTopBorder:!0}),t=e.base-1,i=e.base+e.quantity):(this.shiftBordersVertically(e.sheetId,e.base+1,e.quantity,{moveFirstTopBorder:!1}),t=e.base,i=e.base+e.quantity+1),this.ensureRowBorderContinuity(e.sheetId,t,i)}getCellBorder({sheetId:e,col:t,row:i}){var o,n,s,r,a,l,c,h,d,u,g,p;const m={top:null===(s=null===(n=null===(o=this.borders[e])||void 0===o?void 0:o[t])||void 0===n?void 0:n[i])||void 0===s?void 0:s.horizontal,bottom:null===(l=null===(a=null===(r=this.borders[e])||void 0===r?void 0:r[t])||void 0===a?void 0:a[i+1])||void 0===l?void 0:l.horizontal,left:null===(d=null===(h=null===(c=this.borders[e])||void 0===c?void 0:c[t])||void 0===h?void 0:h[i])||void 0===d?void 0:d.vertical,right:null===(p=null===(g=null===(u=this.borders[e])||void 0===u?void 0:u[t+1])||void 0===g?void 0:g[i])||void 0===p?void 0:p.vertical};return m.bottom||m.left||m.right||m.top?m:null}ensureColumnBorderContinuity(e,t,i){const o=ze(t+1,i);for(let n=0;n<this.getters.getNumberRows(e);n++){const s=this.getCellBorder({sheetId:e,col:t,row:n}),r=this.getCellBorder({sheetId:e,col:i,row:n});if(s&&r){const t=this.getCommonSides(s,r);for(let i of o)this.addBorder(e,i,n,t)}}}ensureRowBorderContinuity(e,t,i){const o=ze(t+1,i);for(let n=0;n<this.getters.getNumberCols(e);n++){const s=this.getCellBorder({sheetId:e,col:n,row:t}),r=this.getCellBorder({sheetId:e,col:n,row:i});if(s&&r){const t=this.getCommonSides(s,r);for(let i of o)this.addBorder(e,n,i,t)}}}getCommonSides(e,t){const i={};for(let o of["top","bottom","left","right"])e[o]&&e[o]===t[o]&&(i[o]=e[o]);return i}getColumnsWithBorders(e){const t=this.borders[e];return t?Object.keys(t).map((e=>parseInt(e,10))):[]}getRowsRange(e){return this.borders[e]?ze(0,this.getters.getNumberRows(e)+1):[]}shiftBordersHorizontally(e,t,i,{moveFirstLeftBorder:o}={}){this.borders[e]&&(i<0&&this.moveBordersOfColumn(e,t,i,"vertical",{destructive:!1}),this.getColumnsWithBorders(e).filter((e=>e>=t)).sort(((e,t)=>i<0?e-t:t-e)).forEach((n=>{(n===t&&o||n!==t)&&this.moveBordersOfColumn(e,n,i,"vertical"),this.moveBordersOfColumn(e,n,i,"horizontal")})))}shiftBordersVertically(e,t,i,{moveFirstTopBorder:o}={}){this.borders[e]&&(i<0&&this.moveBordersOfRow(e,t,i,"horizontal",{destructive:!1}),this.getRowsRange(e).filter((e=>e>=t)).sort(((e,t)=>i<0?e-t:t-e)).forEach((n=>{(n===t&&o||n!==t)&&this.moveBordersOfRow(e,n,i,"horizontal"),this.moveBordersOfRow(e,n,i,"vertical")})))}moveBordersOfRow(e,t,i,o,{destructive:n}={destructive:!0}){const s=this.borders[e];s&&this.getColumnsWithBorders(e).forEach((r=>{var a,l,c,h;const d=null===(l=null===(a=s[r])||void 0===a?void 0:a[t+i])||void 0===l?void 0:l[o],u=null===(h=null===(c=s[r])||void 0===c?void 0:c[t])||void 0===h?void 0:h[o];this.history.update("borders",e,r,t+i,o,n?u:u||d),this.history.update("borders",e,r,t,o,void 0)}))}moveBordersOfColumn(e,t,i,o,{destructive:n}={destructive:!0}){const s=this.borders[e];s&&this.getRowsRange(e).forEach((r=>{var a,l,c,h;const d=null===(l=null===(a=s[t+i])||void 0===a?void 0:a[r])||void 0===l?void 0:l[o],u=null===(h=null===(c=s[t])||void 0===c?void 0:c[r])||void 0===h?void 0:h[o];this.history.update("borders",e,t+i,r,o,n?u:u||d),this.history.update("borders",e,t,r,o,void 0)}))}setBorder(e,t,i,o,n=!0){var s,r,a,l,c,h,d,u,g,p,m,f,v,b,S,C;!n&&(null===(l=null===(a=null===(r=null===(s=this.borders)||void 0===s?void 0:s[e])||void 0===r?void 0:r[t])||void 0===a?void 0:a[i])||void 0===l?void 0:l.vertical)||this.history.update("borders",e,t,i,"vertical",null==o?void 0:o.left),!n&&(null===(u=null===(d=null===(h=null===(c=this.borders)||void 0===c?void 0:c[e])||void 0===h?void 0:h[t])||void 0===d?void 0:d[i])||void 0===u?void 0:u.horizontal)||this.history.update("borders",e,t,i,"horizontal",null==o?void 0:o.top),!n&&(null===(f=null===(m=null===(p=null===(g=this.borders)||void 0===g?void 0:g[e])||void 0===p?void 0:p[t+1])||void 0===m?void 0:m[i])||void 0===f?void 0:f.vertical)||this.history.update("borders",e,t+1,i,"vertical",null==o?void 0:o.right),!n&&(null===(C=null===(S=null===(b=null===(v=this.borders)||void 0===v?void 0:v[e])||void 0===b?void 0:b[t])||void 0===S?void 0:S[i+1])||void 0===C?void 0:C.horizontal)||this.history.update("borders",e,t,i+1,"horizontal",null==o?void 0:o.bottom)}clearBorders(e,t){for(let i of t){for(let t=i.top;t<=i.bottom;t++){this.history.update("borders",e,i.right+1,t,"vertical",void 0);for(let o=i.left;o<=i.right;o++)this.history.update("borders",e,o,t,void 0)}for(let t=i.left;t<=i.right;t++)this.history.update("borders",e,t,i.bottom+1,"horizontal",void 0)}}addBorder(e,t,i,o){this.setBorder(e,t,i,{...this.getCellBorder({sheetId:e,col:t,row:i}),...o})}setBorders(e,t,i){if("clear"===i)return this.clearBorders(e,t);for(let o of t){if("h"===i||"hv"===i||"all"===i)for(let t=o.top+1;t<=o.bottom;t++)for(let i=o.left;i<=o.right;i++)this.addBorder(e,i,t,{top:Z});if("v"===i||"hv"===i||"all"===i)for(let t=o.top;t<=o.bottom;t++)for(let i=o.left+1;i<=o.right;i++)this.addBorder(e,i,t,{left:Z});if("left"===i||"all"===i||"external"===i)for(let t=o.top;t<=o.bottom;t++)this.addBorder(e,o.left,t,{left:Z});if("right"===i||"all"===i||"external"===i)for(let t=o.top;t<=o.bottom;t++)this.addBorder(e,o.right+1,t,{left:Z});if("top"===i||"all"===i||"external"===i)for(let t=o.left;t<=o.right;t++)this.addBorder(e,t,o.top,{top:Z});if("bottom"===i||"all"===i||"external"===i)for(let t=o.left;t<=o.right;t++)this.addBorder(e,t,o.bottom+1,{top:Z})}}addBordersToMerge(e,t){const{left:i,right:o,top:n,bottom:s}=t,r=this.getCellBorder({sheetId:e,col:i,row:n}),a=this.getCellBorder({sheetId:e,col:o,row:s});this.clearBorders(e,[t]),(null==r?void 0:r.top)&&this.setBorders(e,[{...t,bottom:n}],"top"),(null==r?void 0:r.left)&&this.setBorders(e,[{...t,right:i}],"left"),((null==a?void 0:a.bottom)||(null==r?void 0:r.bottom))&&this.setBorders(e,[{...t,top:s}],"bottom"),((null==a?void 0:a.right)||(null==r?void 0:r.right))&&this.setBorders(e,[{...t,left:o}],"right")}import(e){if(e.borders)for(let t of e.sheets)for(let[i,o]of Object.entries(t.cells))if(null==o?void 0:o.border){const n=e.borders[o.border],{col:s,row:r}=Ut(i);this.setBorder(t.id,s,r,n,!1)}for(let t of e.sheets)if(t.merges)for(let e of t.merges)this.addBordersToMerge(t.id,_i(e))}export(e){let t=0;const i={};function o(e){for(let[t,o]of Object.entries(i))if(Ae(o)===Ae(e))return parseInt(t,10);return i[++t]=e,t}for(let t of e.sheets)for(let e=0;e<t.colNumber;e++)for(let i=0;i<t.rowNumber;i++){const n=this.getCellBorder({sheetId:t.id,col:e,row:i});if(n){const s=Vt(e,i),r=t.cells[s],a=o(n);r?r.border=a:t.cells[s]={border:a}}}e.borders=i}exportForExcel(e){this.export(e)}}Hf.getters=["getCellBorder"];class $f{constructor(e=new Gf){this.scope=e,this.code=""}append(...e){this.code+=e.map((e=>e.toString())).join("\n")+"\n"}return(e){return new Wf(this.scope,this.code,e)}toString(){return qf(this.code)}}class Wf{constructor(e,t,i){this.scope=e,this.returnExpression=i,this.code=qf(t)}toString(){return this.code}wrapInClosure(){const e=this.scope.nextVariableName(),t=new $f(this.scope);return t.append(`const ${e} = () => {`),t.append(this.code),t.append(`return ${this.returnExpression};`),t.append("}"),t.return(e)}assignResultToVariable(){if(this.scope.isAlreadyDeclared(this.returnExpression))return this;const e=this.scope.nextVariableName(),t=new $f(this.scope);return t.append(this.code),t.append(`const ${e} = ${this.returnExpression};`),t.return(e)}}class Gf{constructor(){this.nextId=1,this.declaredVariables=new Set}nextVariableName(){const e="_"+this.nextId++;return this.declaredVariables.add(e),e}isAlreadyDeclared(e){return this.declaredVariables.has(e)}}function qf(e){let t="",i=0;const o=e.split("\n").map((e=>e.trim())).filter((e=>""!==e));for(const e of o)e.startsWith("}")&&i--,t+="\t".repeat(i)+e+"\n",e.endsWith("{")&&i++;return t.trim()}const Zf=/[a-zA-Z0-9\_]+(\.[a-zA-Z0-9\_]+)*/,jf=["-","+"],Xf=["%"],Yf=["*","+","&"],Kf={"^":30,"%":30,"*":20,"/":20,"+":15,"-":15,"&":13,">":10,"<>":10,">=":10,"<":10,"<=":10,"=":10};function Qf(e){var t,i,o;const n=e.shift();if(!n)throw new h(ae);switch(n.type){case"DEBUGGER":const r=tv(e,1e3);return r.debug=!0,r;case"NUMBER":return{type:"NUMBER",value:Qt(n.value)};case"STRING":return{type:"STRING",value:Me(n.value)};case"FUNCTION":const a=function(e){var t;ev(e,"LEFT_PAREN",s("Missing opening parenthesis"));const i=e[0];if("RIGHT_PAREN"===(null==i?void 0:i.type))return ev(e,"RIGHT_PAREN"),[];const o=[];o.push(Jf(e));for(;"RIGHT_PAREN"!==(null===(t=e[0])||void 0===t?void 0:t.type);)ev(e,"COMMA",s("Wrong function call")),o.push(Jf(e));return ev(e,"RIGHT_PAREN"),o}(e);return{type:"FUNCALL",value:n.value,args:a};case"INVALID_REFERENCE":throw new u;case"REFERENCE":if(":"===(null===(t=e[0])||void 0===t?void 0:t.value)&&"REFERENCE"===(null===(i=e[1])||void 0===i?void 0:i.type)){e.shift();const t=e.shift();return{type:"REFERENCE",value:`${n.value}:${null==t?void 0:t.value}`}}return{type:"REFERENCE",value:n.value};case"SYMBOL":if(["TRUE","FALSE"].includes(n.value.toUpperCase()))return{type:"BOOLEAN",value:"TRUE"===n.value.toUpperCase()};if(n.value&&Zf.test(n.value)&&"LEFT_PAREN"===(null===(o=e[0])||void 0===o?void 0:o.type))throw new p(n.value);throw new h(s("Invalid formula"));case"LEFT_PAREN":const l=tv(e);return ev(e,"RIGHT_PAREN",s("Missing closing parenthesis")),l;case"OPERATOR":const c=n.value;if(jf.includes(c))return{type:"UNARY_OPERATION",value:c,operand:tv(e,Kf[c])};throw new h(s("Unexpected token: %s",n.value));default:throw new h(s("Unexpected token: %s",n.value))}}function Jf(e){const t=e[0];return"COMMA"===(null==t?void 0:t.type)||"RIGHT_PAREN"===(null==t?void 0:t.type)?{type:"EMPTY",value:""}:tv(e)}function ev(e,t,i=ae){const o=e.shift();if(!o||o.type!==t)throw new h(i)}function tv(e,t=0){var i;if(0===e.length)throw new h(ae);let o=Qf(e);for(;"OPERATOR"===(null===(i=e[0])||void 0===i?void 0:i.type)&&Kf[e[0].value]>t;){const t=e.shift().value;if(Xf.includes(t))o={type:"UNARY_OPERATION",value:t,operand:o,postfix:!0};else{o={type:"BIN_OPERATION",value:t,left:o,right:tv(e,Kf[t])}}}return o}function iv(e){return ov(uf(e))}function ov(e){"="===(e=e.filter((e=>"SPACE"!==e.type)))[0].value&&e.splice(0,1);const t=tv(e);if(e.length)throw new h(ae);return t}function nv(e,t,i){switch(t===e.type&&(e=i(e)),e.type){case"FUNCALL":return{...e,args:e.args.map((e=>nv(e,t,i)))};case"UNARY_OPERATION":return{...e,operand:nv(e.operand,t,i)};case"BIN_OPERATION":return{...e,right:nv(e.right,t,i),left:nv(e.left,t,i)};default:return e}}function sv(e){switch(e.type){case"FUNCALL":const t=e.args.map((e=>sv(e)));return`${e.value}(${t.join(",")})`;case"NUMBER":return e.value.toString();case"REFERENCE":default:return e.value;case"STRING":return`"${e.value}"`;case"BOOLEAN":return e.value?"TRUE":"FALSE";case"UNARY_OPERATION":return e.postfix?rv(e)+e.value:e.value+av(e);case"BIN_OPERATION":return rv(e)+e.value+av(e)}}function rv(e){const t=e.value,i="left"in e?e.left:e.operand,o=i.value;return"BIN_OPERATION"===i.type&&Kf[o]<Kf[t]?`(${sv(i)})`:sv(i)}function av(e){const t=e.value,i="right"in e?e.right:e.operand,o=Kf[i.value],n=Kf[t];let s=!1;return"BIN_OPERATION"!==i.type?s=!1:o<n?s=!0:o!==n||Yf.includes(t)||(s=!0),s?`(${sv(i)})`:sv(i)}const lv=iu.content,cv={"=":"EQ","+":"ADD","-":"MINUS","*":"MULTIPLY","/":"DIVIDE",">=":"GTE","<>":"NE",">":"GT","<=":"LTE","<":"LT","^":"POWER","&":"CONCATENATE"},hv={"-":"UMINUS","+":"UPLUS","%":"UNARY.PERCENT"},dv={};function uv(e){const t=Mf(e),{dependencies:i,constantValues:o}=function(e){const t={numbers:[],strings:[]},i=[];for(const o of e)switch(o.type){case"INVALID_REFERENCE":case"REFERENCE":i.push(o.value);break;case"STRING":const e=Me(o.value);t.strings.includes(e)||t.strings.push(e);break;case"NUMBER":{const e=Qt(o.value);t.numbers.includes(e)||t.numbers.push(e);break}}return{dependencies:i,constantValues:t}}(t),n=function(e,t,i){return ot(e.map((e=>{switch(e.type){case"STRING":const o=Me(e.value);return`|S${i.strings.indexOf(o)}|`;case"NUMBER":return`|N${i.numbers.indexOf(Qt(e.value))}|`;case"REFERENCE":case"INVALID_REFERENCE":return`|${t.indexOf(e.value)}|`;case"SPACE":return"";default:return e.value}})))}(t,i,o);if(!dv[n]){const r=ov([...t]),a=new Gf;if("BIN_OPERATION"===r.type&&":"===r.value)throw new h(s("Invalid formula"));if("EMPTY"===r.type)throw new h(s("Invalid formula"));const l=g(r),c=new $f;c.append(`// ${n}`),c.append(l),c.append(`return ${l.returnExpression};`);let d=new Function("deps","ref","range","ctx",c.toString());function u(e){const t=lv[e.value.toUpperCase()],i=e.args,o=i.length;if(o<t.minArgRequired)throw new h(s("Invalid number of arguments for the %s function. Expected %s minimum, but got %s instead.",e.value.toUpperCase(),t.minArgRequired.toString(),o.toString()));if(o>t.maxArgPossible)throw new h(s("Invalid number of arguments for the %s function. Expected %s maximum, but got %s instead.",e.value.toUpperCase(),t.maxArgPossible.toString(),o.toString()));const n=t.nbrArgRepeating;if(n>1){const i=t.args.length-n;if((o-i)%n!=0)throw new h(s("Invalid number of arguments for the %s function. Expected all arguments after position %s to be supplied by groups of %s arguments",e.value.toUpperCase(),i.toString(),n.toString()))}let r=[];for(let n=0;n<o;n++){const o=t.getArgToFocus(n+1)-1;if(0<=o&&o<t.args.length){const a=i[n],l=t.args[o],c=l.type||[],d=c.includes("META"),u=l.lazy,p=c.some((e=>"RANGE"===e||"RANGE<BOOLEAN>"===e||"RANGE<DATE>"===e||"RANGE<NUMBER>"===e||"RANGE<STRING>"===e)),m=c.every((e=>"RANGE"===e||"RANGE<BOOLEAN>"===e||"RANGE<DATE>"===e||"RANGE<NUMBER>"===e||"RANGE<STRING>"===e));if(m&&"REFERENCE"!==a.type)throw new h(s("Function %s expects the parameter %s to be reference to a cell or range, not a %s.",e.value.toUpperCase(),(n+1).toString(),a.type.toLowerCase()));const f=g(a,d,p,{functionName:e.value.toUpperCase(),paramIndex:n+1});r.push(u?f.wrapInClosure():f)}}return r}function g(e,t=!1,n=!1,r={}){const l=new $f(a);if("REFERENCE"!==e.type&&("BIN_OPERATION"!==e.type||":"!==e.value)&&t)throw new h(s("Argument must be a reference to a cell or range."));switch(e.debug&&l.append("debugger;"),e.type){case"BOOLEAN":return l.return(`{ value: ${e.value} }`);case"NUMBER":return l.return(`{ value: this.constantValues.numbers[${o.numbers.indexOf(e.value)}] }`);case"STRING":return l.return(`{ value: this.constantValues.strings[${o.strings.indexOf(e.value)}] }`);case"REFERENCE":const s=i.indexOf(e.value);return n?l.return(`range(deps[${s}])`):l.return(`ref(deps[${s}], ${t?"true":"false"}, "${r.functionName||cv["="]}", ${r.paramIndex})`);case"FUNCALL":const a=u(e).map((e=>e.assignResultToVariable()));l.append(...a);const c=e.value.toUpperCase();return l.append(`ctx.__lastFnCalled = '${c}';`),l.return(`ctx['${c}'](${a.map((e=>e.returnExpression))})`);case"UNARY_OPERATION":{const t=hv[e.value],i=g(e.operand,!1,!1,{functionName:t}).assignResultToVariable();return l.append(i),l.append(`ctx.__lastFnCalled = '${t}';`),l.return(`ctx['${t}'](${i.returnExpression})`)}case"BIN_OPERATION":{const t=cv[e.value],i=g(e.left,!1,!1,{functionName:t}).assignResultToVariable(),o=g(e.right,!1,!1,{functionName:t}).assignResultToVariable();return l.append(i),l.append(o),l.append(`ctx.__lastFnCalled = '${t}';`),l.return(`ctx['${t}'](${i.returnExpression}, ${o.returnExpression})`)}case"EMPTY":return l.return("undefined")}}dv[n]={execute:d}}return{execute:dv[n].execute,dependencies:i,constantValues:o,tokens:t}}function gv(e){return function(e){let t=[],i="";return e.map(((e,o)=>{switch(["SPACE","LEFT_PAREN"].includes(e.type)||(i=""),e.type){case"FUNCTION":i=e.value;break;case"LEFT_PAREN":t.push({parent:i,argPosition:0}),i="";break;case"RIGHT_PAREN":t.pop();break;case"COMMA":t.length&&t[t.length-1].argPosition++}if(t.length){const i=t[t.length-1];i.parent&&(e.functionContext=Object.assign({},i))}return e}))}(function(e){let t=1;const i=[];return e.map((e=>("LEFT_PAREN"===e.type?(i.push(t),e.parenIndex=t,t++):"RIGHT_PAREN"===e.type&&(e.parenIndex=i.pop()),e)))}(function(e){let t=0;return e.map((e=>{const i=e.value.toString().length,o=Object.assign({},e,{start:t,end:t+i,length:i});return t=o.end,o}))}(Mf(e))))}class pv extends Bf{constructor(){super(...arguments),this.nextId=1,this.cells={}}adaptRanges(e,t){for(const i of Object.keys(this.cells))for(const o of Object.values(this.cells[i]||{}))if(o.isFormula)for(const n of o.dependencies)if(!t||n.sheetId===t){const t=e(n);"NONE"!==t.changeType&&this.history.update("cells",i,o.id,"dependencies",o.dependencies.indexOf(n),t.range)}}allowDispatch(e){switch(e.type){case"UPDATE_CELL":case"CLEAR_CELL":return this.checkCellOutOfSheet(e.sheetId,e.col,e.row);default:return 0}}handle(e){switch(e.type){case"SET_FORMATTING":"style"in e&&this.setStyle(e.sheetId,e.target,e.style),"format"in e&&void 0!==e.format&&this.setFormatter(e.sheetId,e.target,e.format);break;case"CLEAR_FORMATTING":this.clearFormatting(e.sheetId,e.target);break;case"ADD_COLUMNS_ROWS":"COL"===e.dimension?this.handleAddColumnsRows(e,this.copyColumnStyle.bind(this)):this.handleAddColumnsRows(e,this.copyRowStyle.bind(this));break;case"UPDATE_CELL":this.updateCell(e.sheetId,e.col,e.row,e);break;case"CLEAR_CELL":this.dispatch("UPDATE_CELL",{sheetId:e.sheetId,col:e.col,row:e.row,content:"",style:null,format:""})}}setFormatter(e,t,i){for(let o of t)for(let t=o.top;t<=o.bottom;t++)for(let n=o.left;n<=o.right;n++)this.dispatch("UPDATE_CELL",{sheetId:e,col:n,row:t,format:i})}clearFormatting(e,t){for(let i of t)for(let t=i.left;t<=i.right;t++)for(let o=i.top;o<=i.bottom;o++)this.dispatch("UPDATE_CELL",{sheetId:e,col:t,row:o,style:null,format:""})}handleAddColumnsRows(e,t){let i,o;"before"===e.position?(i=ze(e.base,e.base+e.quantity),o=e.base+e.quantity):(i=ze(e.base+1,e.base+e.quantity+1),o=e.base),t(e.sheetId,o,i)}import(e){for(let t of e.sheets)for(let i in t.cells){const o=t.cells[i],{col:n,row:s}=Ut(i);if((null==o?void 0:o.content)||(null==o?void 0:o.format)||(null==o?void 0:o.style)){const i=this.importCell(t.id,o,e.styles,e.formats);this.history.update("cells",t.id,i.id,i),this.dispatch("UPDATE_CELL_POSITION",{cellId:i.id,col:n,row:s,sheetId:t.id})}}}export(e){const t={},i={};for(let o of e.sheets){const e={},n=Object.keys(this.cells[o.id]||{}).map((e=>this.getters.getCellPosition(e))).sort(((e,t)=>e.col===t.col?e.row-t.row:e.col-t.col));for(const o of n){const n=this.getters.getCell(o);e[Vt(o.col,o.row)]={style:n.style?it(n.style,t):void 0,format:n.format?it(n.format,i):void 0,content:n.content||void 0}}o.cells=e}e.styles=t,e.formats=i}importCell(e,t,i,o){const n=t.style&&i[t.style]||void 0,s=t.format&&o[t.format]||void 0,r=this.getNextUid();return this.createCell(r,(null==t?void 0:t.content)||"",s,n,e)}exportForExcel(e){this.export(e)}getCells(e){return this.cells[e]||{}}getCellById(e){for(const t in this.cells){const i=this.cells[t][e];if(i)return i}}buildFormulaContent(e,t,i){const o=i||[...t.dependencies];return ot(t.compiledFormula.tokens.map((t=>{if("REFERENCE"===t.type){const t=o.shift();return this.getters.getRangeString(t,e)}return t.value})))}getFormulaCellContent(e,t){return this.buildFormulaContent(e,t)}getCellStyle(e){var t;return(null===(t=this.getters.getCell(e))||void 0===t?void 0:t.style)||{}}zoneToXC(e,t,i=[{colFixed:!1,rowFixed:!1}]){const o=Vt((t=this.getters.expandZone(e,t)).left,t.top,i[0]),n=Vt(t.right,t.bottom,i.length>1?i[1]:i[0]),s=this.getters.getMainCellPosition({sheetId:e,col:t.left,row:t.top}),r=this.getters.getMainCellPosition({sheetId:e,col:t.right,row:t.bottom}),a=s.col===r.col&&s.row===r.row;return o==n||a?o:o+":"+n}setStyle(e,t,i){for(let o of t)for(let t=o.left;t<=o.right;t++)for(let n=o.top;n<=o.bottom;n++){const o=this.getters.getCell({sheetId:e,col:t,row:n});this.dispatch("UPDATE_CELL",{sheetId:e,col:t,row:n,style:i?{...null==o?void 0:o.style,...i}:void 0})}}copyColumnStyle(e,t,i){for(let o=0;o<this.getters.getNumberRows(e);o++){const n=this.getFormat(e,t,o);if(n.style||n.format)for(let t of i)this.dispatch("UPDATE_CELL",{sheetId:e,col:t,row:o,...n})}}copyRowStyle(e,t,i){for(let o=0;o<this.getters.getNumberCols(e);o++){const n=this.getFormat(e,o,t);if(n.style||n.format)for(let t of i)this.dispatch("UPDATE_CELL",{sheetId:e,col:o,row:t,...n})}}getFormat(e,t,i){const o={},n=this.getters.getMainCellPosition({sheetId:e,col:t,row:i}),s=this.getters.getCell(n);return s&&(s.style&&(o.style=s.style),s.format&&(o.format=s.format)),o}getNextUid(){const e=this.nextId.toString();return this.history.update("nextId",this.nextId+1),e}updateCell(e,t,i,o){const n=this.getters.getCell({sheetId:e,col:t,row:i}),s="content"in o||"formula"in o,r=s?gt(null==o?void 0:o.content):(null==n?void 0:n.content)||"";let a;a=void 0!==o.style?o.style||void 0:n?n.style:void 0;let l=("format"in o?o.format:n&&n.format)||vi(r);if((s&&!r&&!o.formula||!s&&(!n||""===n.content))&&!a&&!l)return void(n&&(this.history.update("cells",e,n.id,void 0),this.dispatch("UPDATE_CELL_POSITION",{cellId:void 0,col:t,row:i,sheetId:e})));const c=(null==n?void 0:n.id)||this.getNextUid(),h=this.createCell(c,r,l,a,e);this.history.update("cells",e,h.id,h),this.dispatch("UPDATE_CELL_POSITION",{cellId:h.id,col:t,row:i,sheetId:e})}createCell(e,t,i,o,n){if(!t.startsWith("="))return this.createLiteralCell(e,t,i,o);try{return this.createFormulaCell(e,t,i,o,n)}catch(n){return this.createErrorFormula(e,t,i,o,n)}}createLiteralCell(e,t,i,o){return{id:e,content:t,style:o,format:i,isFormula:!1}}createFormulaCell(e,t,i,o,n){const s=uv(t);return s.dependencies.length?this.createFormulaCellWithDependencies(e,s,i,o,n):{id:e,content:t,style:o,format:i,isFormula:!0,compiledFormula:s,dependencies:[]}}createFormulaCellWithDependencies(e,t,i,o,n){const s=t.dependencies.map((e=>this.getters.getRangeFromSheetXC(n,e))),r=this.buildFormulaContent.bind(this);return{id:e,get content(){return r(n,{dependencies:this.dependencies,compiledFormula:this.compiledFormula})},style:o,format:i,isFormula:!0,compiledFormula:t,dependencies:s}}createErrorFormula(e,t,i,o,n){return{id:e,content:t,style:o,format:i,isFormula:!0,compiledFormula:{dependencies:[],tokens:uf(t),execute:function(){throw n}},dependencies:[]}}checkCellOutOfSheet(e,t,i){if(!this.getters.tryGetSheet(e))return 27;return $i(t,i,this.getters.getSheetZone(e))?0:18}}pv.getters=["zoneToXC","getCells","getFormulaCellContent","getCellStyle","buildFormulaContent","getCellById"];class mv extends Bf{constructor(){super(...arguments),this.charts={},this.createChart=function(e){const t=On.getAll().sort(((e,t)=>e.sequence-t.sequence));return function(i,o,n){const s=t.find((e=>e.match(o.type)));if(!s)throw new Error(`No builder for this chart: ${o.type}`);return s.createChart(o,n,e)}}(this.getters),this.validateChartDefinition=e=>function(e,t){const i=On.getAll().find((e=>e.match(t.type)));if(!i)throw new Error("Unknown chart type.");return i.validateChartDefinition(e,t)}(this,e.definition)}adaptRanges(e){for(const[t,i]of Object.entries(this.charts))this.history.update("charts",t,null==i?void 0:i.updateRanges(e))}allowDispatch(e){switch(e.type){case"CREATE_CHART":return this.checkValidations(e,this.chainValidations(this.validateChartDefinition,this.checkChartDuplicate));case"UPDATE_CHART":return this.checkValidations(e,this.chainValidations(this.validateChartDefinition,this.checkChartExists));default:return 0}}handle(e){var t;switch(e.type){case"CREATE_CHART":this.addFigure(e.id,e.sheetId,e.position,e.size),this.addChart(e.id,e.definition);break;case"UPDATE_CHART":this.addChart(e.id,e.definition);break;case"DUPLICATE_SHEET":{const i=this.getters.getFigures(e.sheetId);for(const o of i)if("chart"===o.tag){const i=o.id.split(J).pop(),n=`${e.sheetIdTo}${J}${i}`,s=null===(t=this.charts[o.id])||void 0===t?void 0:t.copyForSheetId(e.sheetIdTo);s&&this.dispatch("CREATE_CHART",{id:n,position:{x:o.x,y:o.y},size:{width:o.width,height:o.height},definition:s.getDefinition(),sheetId:e.sheetIdTo})}break}case"DELETE_FIGURE":this.history.update("charts",e.id,void 0);break;case"DELETE_SHEET":for(let t of this.getChartIds(e.sheetId))this.history.update("charts",t,void 0)}}getContextCreationChart(e){var t;return null===(t=this.charts[e])||void 0===t?void 0:t.getContextCreation()}getChart(e){return this.charts[e]}getChartType(e){var t;const i=null===(t=this.charts[e])||void 0===t?void 0:t.type;if(!i)throw new Error("Chart not defined.");return i}isChartDefined(e){return e in this.charts&&void 0!==this.charts}getChartIds(e){return Object.entries(this.charts).filter((([,t])=>(null==t?void 0:t.sheetId)===e)).map((([e])=>e))}getChartDefinition(e){var t;const i=null===(t=this.charts[e])||void 0===t?void 0:t.getDefinition();if(!i)throw new Error(`There is no chart with the given figureId: ${e}`);return i}import(e){for(let t of e.sheets)if(t.figures)for(let e of t.figures)"chart"===e.tag&&(this.charts[e.id]=this.createChart(e.id,e.data,t.id))}export(e){var t;if(e.sheets)for(let i of e.sheets){const e=this.getters.getFigures(i.id),o=[];for(let i of e){const e=i;if(e&&"chart"===e.tag){const i=null===(t=this.charts[e.id])||void 0===t?void 0:t.getDefinition();i&&(e.data=i,o.push(e))}else o.push(e)}i.figures=o}}exportForExcel(e){var t;for(let i of e.sheets){const e=this.getters.getFigures(i.id),o=[];for(let i of e)if(i&&"chart"===i.tag){const e=null===(t=this.charts[i.id])||void 0===t?void 0:t.getDefinitionForExcel();e&&o.push({...i,data:e})}i.charts=o}}addFigure(e,t,i={x:0,y:0},o={width:536,height:335}){if(this.getters.getFigure(t,e))return;const n={id:e,x:i.x,y:i.y,width:o.width,height:o.height,tag:"chart"};this.dispatch("CREATE_FIGURE",{sheetId:t,figure:n})}addChart(e,t){const i=this.getters.getFigureSheetId(e);i&&this.history.update("charts",e,this.createChart(e,t,i))}checkChartDuplicate(e){return this.getters.getFigureSheetId(e.id)?84:0}checkChartExists(e){return this.getters.getFigureSheetId(e.id)?0:85}}function fv(e){return""===e?NaN:Number(e)}mv.getters=["isChartDefined","getChartDefinition","getChartType","getChartIds","getChart","getContextCreationChart"];class vv extends Bf{constructor(){super(...arguments),this.cfRules={}}loopThroughRangesOfSheet(e,t){for(const i of this.cfRules[e])for(const o of i.ranges){const n=t(o);switch(n.changeType){case"REMOVE":let t=i.ranges.slice();t.splice(i.ranges.indexOf(o),1),t.length>=1?this.history.update("cfRules",e,this.cfRules[e].indexOf(i),"ranges",t):this.removeConditionalFormatting(i.id,e);break;case"RESIZE":case"MOVE":case"CHANGE":this.history.update("cfRules",e,this.cfRules[e].indexOf(i),"ranges",i.ranges.indexOf(o),n.range)}}}adaptRanges(e,t){if(t)this.loopThroughRangesOfSheet(t,e);else for(const t of Object.keys(this.cfRules))this.loopThroughRangesOfSheet(t,e)}allowDispatch(e){switch(e.type){case"ADD_CONDITIONAL_FORMAT":return this.checkValidations(e,this.checkCFRule,this.checkEmptyRange);case"MOVE_CONDITIONAL_FORMAT":return this.checkValidReordering(e.cfId,e.direction,e.sheetId)}return 0}handle(e){switch(e.type){case"CREATE_SHEET":this.cfRules[e.sheetId]=[];break;case"DUPLICATE_SHEET":this.history.update("cfRules",e.sheetIdTo,[]);for(const t of this.getConditionalFormats(e.sheetId))this.addConditionalFormatting(t,e.sheetIdTo);break;case"DELETE_SHEET":const t=Object.assign({},this.cfRules);delete t[e.sheetId],this.history.update("cfRules",t);break;case"ADD_CONDITIONAL_FORMAT":const i={...e.cf,ranges:e.ranges.map((t=>this.getters.getRangeString(this.getters.getRangeFromRangeData(t),e.sheetId)))};this.addConditionalFormatting(i,e.sheetId);break;case"REMOVE_CONDITIONAL_FORMAT":this.removeConditionalFormatting(e.id,e.sheetId);break;case"MOVE_CONDITIONAL_FORMAT":this.reorderConditionalFormatting(e.cfId,e.direction,e.sheetId)}}import(e){for(let t of e.sheets)this.cfRules[t.id]=t.conditionalFormats.map((e=>this.mapToConditionalFormatInternal(t.id,e)))}export(e){if(e.sheets)for(let t of e.sheets)this.cfRules[t.id]&&(t.conditionalFormats=this.cfRules[t.id].map((e=>this.mapToConditionalFormat(t.id,e))))}exportForExcel(e){this.export(e)}getConditionalFormats(e){var t;return(null===(t=this.cfRules[e])||void 0===t?void 0:t.map((t=>this.mapToConditionalFormat(e,t))))||[]}getRulesSelection(e,t){const i=new Set;return t.forEach((t=>{this.getRulesByZone(e,t).forEach((e=>{i.add(e)}))})),Array.from(i)}getRulesByZone(e,t){const i=new Set;for(let o=t.top;o<=t.bottom;o++)for(let n=t.left;n<=t.right;n++){this.getRulesByCell(e,n,o).forEach((e=>{i.add(e.id)}))}return i}getRulesByCell(e,t,i){const o=[];for(let n of this.cfRules[e])for(let e of n.ranges)$i(t,i,e.zone)&&o.push(n);return new Set(o.map((t=>this.mapToConditionalFormat(e,t))))}mapToConditionalFormat(e,t){return{...t,ranges:t.ranges.map((t=>this.getters.getRangeString(t,e)))}}mapToConditionalFormatInternal(e,t){const i={...t,ranges:t.ranges.map((t=>this.getters.getRangeFromSheetXC(e,t)))};return i}addConditionalFormatting(e,t){const i=this.cfRules[t].slice(),o=i.findIndex((t=>t.id===e.id)),n=this.mapToConditionalFormatInternal(t,e);o>-1?i.splice(o,1,n):i.push(n),this.history.update("cfRules",t,i)}checkValidReordering(e,t,i){if(!this.cfRules[i])return 27;const o=this.cfRules[i].findIndex((t=>t.id===e));if(-1===o)return 71;const n="up"===t?o-1:o+1;return n<0||n>=this.cfRules[i].length?71:0}checkEmptyRange(e){return e.ranges.length?0:24}checkCFRule(e){const t=e.cf.rule;switch(t.type){case"CellIsRule":return this.checkValidations(t,this.checkOperatorArgsNumber(2,["Between","NotBetween"]),this.checkOperatorArgsNumber(1,["BeginsWith","ContainsText","EndsWith","GreaterThan","GreaterThanOrEqual","LessThan","LessThanOrEqual","NotContains"]),this.checkOperatorArgsNumber(0,["IsEmpty","IsNotEmpty"]));case"ColorScaleRule":return this.checkValidations(t,this.chainValidations(this.checkThresholds(this.checkFormulaCompilation)),this.chainValidations(this.checkThresholds(this.checkNaN),this.batchValidations(this.checkMinBiggerThanMax,this.checkMinBiggerThanMid,this.checkMidBiggerThanMax)));case"IconSetRule":return this.checkValidations(t,this.chainValidations(this.checkInflectionPoints(this.checkNaN),this.checkLowerBiggerThanUpper),this.chainValidations(this.checkInflectionPoints(this.checkFormulaCompilation)))}return 0}checkOperatorArgsNumber(e,t){if(e>2)throw new Error("Checking more than 2 arguments is currently not supported. Add the appropriate CommandResult if you want to.");return i=>{if(t.includes(i.operator)){const t=[],o=e=>void 0===e||""===e;return e>=1&&o(i.values[0])&&t.push(51),e>=2&&o(i.values[1])&&t.push(52),t.length?t:0}return 0}}checkNaN(e,t){if(["number","percentage","percentile"].includes(e.type)&&(""===e.value||isNaN(e.value)))switch(t){case"min":return 53;case"max":return 55;case"mid":return 54;case"upperInflectionPoint":return 56;case"lowerInflectionPoint":return 57}return 0}checkFormulaCompilation(e,t){if("formula"!==e.type)return 0;try{uv(e.value||"")}catch(e){switch(t){case"min":return 58;case"max":return 60;case"mid":return 59;case"upperInflectionPoint":return 61;case"lowerInflectionPoint":return 62}}return 0}checkThresholds(e){return this.batchValidations((t=>e(t.minimum,"min")),(t=>e(t.maximum,"max")),(t=>t.midpoint?e(t.midpoint,"mid"):0))}checkInflectionPoints(e){return this.batchValidations((t=>e(t.lowerInflectionPoint,"lowerInflectionPoint")),(t=>e(t.upperInflectionPoint,"upperInflectionPoint")))}checkLowerBiggerThanUpper(e){const t=e.lowerInflectionPoint.value,i=e.upperInflectionPoint.value;return["number","percentage","percentile"].includes(e.lowerInflectionPoint.type)&&e.lowerInflectionPoint.type===e.upperInflectionPoint.type&&Number(t)>Number(i)?48:0}checkMinBiggerThanMax(e){const t=e.minimum.value,i=e.maximum.value;return["number","percentage","percentile"].includes(e.minimum.type)&&e.minimum.type===e.maximum.type&&fv(t)>=fv(i)?47:0}checkMidBiggerThanMax(e){var t;const i=null===(t=e.midpoint)||void 0===t?void 0:t.value,o=e.maximum.value;return e.midpoint&&["number","percentage","percentile"].includes(e.midpoint.type)&&e.midpoint.type===e.maximum.type&&fv(i)>=fv(o)?49:0}checkMinBiggerThanMid(e){var t;const i=e.minimum.value,o=null===(t=e.midpoint)||void 0===t?void 0:t.value;return e.midpoint&&["number","percentage","percentile"].includes(e.midpoint.type)&&e.minimum.type===e.midpoint.type&&fv(i)>=fv(o)?50:0}removeConditionalFormatting(e,t){const i=this.cfRules[t].findIndex((t=>t.id===e));if(-1!==i){const e=this.cfRules[t].slice();e.splice(i,1),this.history.update("cfRules",t,e)}}reorderConditionalFormatting(e,t,i){const o=this.cfRules[i].findIndex((t=>t.id===e)),n="up"===t?o-1:o+1;if(!(n<0||n>=this.cfRules[i].length)&&-1!==o&&-1!==n){const e=[...this.cfRules[i]],t=e[o];e[o]=e[n],e[n]=t,this.history.update("cfRules",i,e)}}}vv.getters=["getConditionalFormats","getRulesSelection","getRulesByCell"];class bv extends Bf{constructor(){super(...arguments),this.figures={}}allowDispatch(e){switch(e.type){case"CREATE_FIGURE":return this.checkFigureDuplicate(e.figure.id);case"UPDATE_FIGURE":case"DELETE_FIGURE":return this.checkFigureExists(e.sheetId,e.id);default:return 0}}handle(e){switch(e.type){case"CREATE_SHEET":this.figures[e.sheetId]={};break;case"DELETE_SHEET":this.deleteSheet(e.sheetId);break;case"CREATE_FIGURE":this.addFigure(e.figure,e.sheetId);break;case"UPDATE_FIGURE":const{type:t,sheetId:i,...o}=e,n=o;this.updateFigure(i,n);break;case"DELETE_FIGURE":this.removeFigure(e.id,e.sheetId)}}updateFigure(e,t){if("id"in t)for(const[i,o]of Object.entries(t))switch(i){case"x":case"y":void 0!==o&&this.history.update("figures",e,t.id,i,Math.max(o,0));break;case"width":case"height":void 0!==o&&this.history.update("figures",e,t.id,i,o)}}addFigure(e,t){this.history.update("figures",t,e.id,e)}deleteSheet(e){this.history.update("figures",e,void 0)}removeFigure(e,t){this.history.update("figures",t,e,void 0)}checkFigureExists(e,t){var i;return void 0===(null===(i=this.figures[e])||void 0===i?void 0:i[t])?70:0}checkFigureDuplicate(e){return Object.values(this.figures).find((t=>null==t?void 0:t[e]))?82:0}getFigures(e){return Object.values(this.figures[e]||{}).filter(et)}getFigure(e,t){var i;return null===(i=this.figures[e])||void 0===i?void 0:i[t]}getFigureSheetId(e){return Object.keys(this.figures).find((t=>{var i;return void 0!==(null===(i=this.figures[t])||void 0===i?void 0:i[e])}))}import(e){for(let t of e.sheets){const e={};t.figures.forEach((t=>{e[t.id]=t})),this.figures[t.id]=e}}export(e){for(const t of e.sheets)for(const e of this.getFigures(t.id)){const i=void 0;t.figures.push({...e,data:i})}}exportForExcel(e){this.export(e)}}bv.getters=["getFigures","getFigure","getFigureSheetId"];class Sv{constructor(e){this.filters=[],this.zone=e;const t=new Oi;this.id=t.uuidv4();for(const i of ze(e.left,e.right+1)){const e={...this.zone,left:i,right:i};this.filters.push(new Cv(t.uuidv4(),e))}}get contentZone(){if(this.zone.bottom!==this.zone.top)return{...this.zone,top:this.zone.top+1}}getFilterId(e){var t;return null===(t=this.filters.find((t=>t.col===e)))||void 0===t?void 0:t.id}clone(){return new Sv(this.zone)}}class Cv{constructor(e,t){if(t.left!==t.right)throw new Error("Can only define a filter on a single column");this.id=e,this.zoneWithHeaders=t}get col(){return this.zoneWithHeaders.left}get filteredZone(){const e=this.zoneWithHeaders;if(e.bottom!==e.top)return{...e,top:e.top+1}}}class Ev extends Bf{constructor(){super(...arguments),this.tables={}}allowDispatch(e){switch(e.type){case"CREATE_FILTER_TABLE":if(!io(...e.target))return 81;const t=Vi(...e.target),i=()=>this.getFilterTables(e.sheetId).some((e=>Hi(e.zone,t)))?78:0,o=()=>{const i=this.getters.getMergesInZone(e.sheetId,t);for(let e of i)if(Hi(t,e))return 80;return 0};return this.checkValidations(e,i,o);case"ADD_MERGE":for(let t of e.target)for(let i of this.getFilterTables(e.sheetId))if(Hi(i.zone,t))return 80}return 0}handle(e){switch(e.type){case"CREATE_SHEET":this.history.update("tables",e.sheetId,{});break;case"DELETE_SHEET":const t={...this.tables};delete t[e.sheetId],this.history.update("tables",t);break;case"DUPLICATE_SHEET":this.history.update("tables",e.sheetIdTo,Ne(this.tables[e.sheetId]));break;case"ADD_COLUMNS_ROWS":this.onAddColumnsRows(e);break;case"REMOVE_COLUMNS_ROWS":this.onDeleteColumnsRows(e);break;case"CREATE_FILTER_TABLE":{const t=Vi(...e.target),i=this.createFilterTable(t);this.history.update("tables",e.sheetId,i.id,i);break}case"REMOVE_FILTER_TABLE":{const t={};for(const i of this.getFilterTables(e.sheetId))e.target.every((e=>!zi(e,i.zone)))&&(t[i.id]=i);this.history.update("tables",e.sheetId,t);break}case"UPDATE_CELL":{const t=e.sheetId;for(let i of this.getFilterTables(t))this.canUpdateCellCmdExtendTable(e,i)&&this.extendTableDown(t,i);break}}}getFilters(e){return this.getFilterTables(e).map((e=>e.filters)).flat()}getFilterTables(e){return this.tables[e]?Object.values(this.tables[e]).filter(et):[]}getFilter(e){var t;return null===(t=this.getFilterTable(e))||void 0===t?void 0:t.filters.find((t=>t.col===e.col))}getFilterId(e){var t;return null===(t=this.getFilter(e))||void 0===t?void 0:t.id}getFilterTable({sheetId:e,col:t,row:i}){return this.getFilterTables(e).find((e=>$i(t,i,e.zone)))}getFilterTablesInZone(e,t){return this.getFilterTables(e).filter((e=>Wi(e.zone,t)))}doesZonesContainFilter(e,t){for(const i of t)for(const t of this.getFilterTables(e))if(zi(i,t.zone))return!0;return!1}onAddColumnsRows(e){for(const t of this.getFilterTables(e.sheetId)){const i=ki(t.zone,"COL"===e.dimension?"left":"top",e.base,e.position,e.quantity),o=[];for(const i of t.filters){const t=ki(i.zoneWithHeaders,"COL"===e.dimension?"left":"top",e.base,e.position,e.quantity);o.push(new Cv(i.id,t))}if(o.length<Zi(i).width){for(let e=i.left;e<=i.right;e++)o.find((t=>t.col===e))||o.push(new Cv(this.uuidGenerator.uuidv4(),{...i,left:e,right:e}));o.sort(((e,t)=>e.col-t.col))}this.history.update("tables",e.sheetId,t.id,"zone",i),this.history.update("tables",e.sheetId,t.id,"filters",o)}}onDeleteColumnsRows(e){for(const t of this.getFilterTables(e.sheetId)){const i=Ui(t.zone,"COL"===e.dimension?"left":"top",e.elements);if(i){if(Di(i)!==Di(t.zone)){const o=[];for(const i of t.filters){const t=Ui(i.zoneWithHeaders,"COL"===e.dimension?"left":"top",e.elements);t&&o.push(new Cv(i.id,t))}this.history.update("tables",e.sheetId,t.id,"zone",i),this.history.update("tables",e.sheetId,t.id,"filters",o)}}else{const i={...this.tables[e.sheetId]};delete i[t.id],this.history.update("tables",e.sheetId,i)}}}createFilterTable(e){return new Sv(e)}extendTableDown(e,t){const i={...t.zone,bottom:t.zone.bottom+1};this.history.update("tables",e,t.id,"zone",i);for(let i=0;i<t.filters.length;i++){const o=t.filters[i],n={...o.zoneWithHeaders,bottom:o.zoneWithHeaders.bottom+1};this.history.update("tables",e,t.id,"filters",i,"zoneWithHeaders",n)}}canUpdateCellCmdExtendTable({content:e,sheetId:t,col:i,row:o},n){var s;if(!e)return;const r=n.zone;if(!(r.bottom+1===o&&i>=r.left&&i<=r.right))return!1;for(const e of ze(r.left,r.right+1)){const i={sheetId:t,col:e,row:o};if(null===(s=this.getters.getCell(i))||void 0===s?void 0:s.content)return!1;if(this.getters.getFilter(i))return!1;if(this.getters.isInMerge(i))return!1}return!0}import(e){for(const t of e.sheets)for(const e of t.filterTables||[]){const i=this.createFilterTable(_i(e.range));this.history.update("tables",t.id,i.id,i)}}export(e){for(const t of e.sheets)for(const e of this.getFilterTables(t.id))t.filterTables.push({range:Di(e.zone)})}exportForExcel(e){this.export(e)}}Ev.getters=["doesZonesContainFilter","getFilter","getFilters","getFilterTable","getFilterTables","getFilterTablesInZone","getFilterId"];class wv extends Bf{constructor(){super(...arguments),this.sizes={}}handle(e){var t,i,o;switch(e.type){case"CREATE_SHEET":{const t=this.computeSheetSizes(e.sheetId),i={COL:t.COL.map((e=>({manualSize:void 0,computedSize:nt(e)}))),ROW:t.ROW.map((e=>({manualSize:void 0,computedSize:nt(e)})))};this.history.update("sizes",e.sheetId,i);break}case"DUPLICATE_SHEET":for(const t of this.sizes[e.sheetId].ROW)t.computedSize();for(const t of this.sizes[e.sheetId].COL)t.computedSize();this.history.update("sizes",e.sheetIdTo,Ne(this.sizes[e.sheetId]));break;case"DELETE_SHEET":const n={...this.sizes};delete n[e.sheetId],this.history.update("sizes",n);break;case"REMOVE_COLUMNS_ROWS":{let t=[...this.sizes[e.sheetId][e.dimension]];for(let i of[...e.elements].sort(((e,t)=>t-e)))t.splice(i,1);const i=Math.min(...e.elements);t=t.map(((t,o)=>"ROW"===e.dimension&&o>=i?{manualSize:t.manualSize,computedSize:nt((()=>this.getRowTallestCellSize(e.sheetId,o)))}:t)),this.history.update("sizes",e.sheetId,e.dimension,t);break}case"ADD_COLUMNS_ROWS":{let t=[...this.sizes[e.sheetId][e.dimension]];const i=rt(e.position,e.base),o=t[e.base];t.splice(i,0,...Array(e.quantity).fill(o)),t=t.map(((t,i)=>"ROW"===e.dimension&&i>e.base+e.quantity?{manualSize:t.manualSize,computedSize:nt((()=>this.getRowTallestCellSize(e.sheetId,i)))}:t)),this.history.update("sizes",e.sheetId,e.dimension,t);break}case"RESIZE_COLUMNS_ROWS":for(let t of e.elements)if("ROW"===e.dimension){const i=this.getRowTallestCellSize(e.sheetId,t);this.history.update("sizes",e.sheetId,e.dimension,t,{manualSize:e.size||void 0,computedSize:nt(i)})}else this.history.update("sizes",e.sheetId,e.dimension,t,{manualSize:e.size||void 0,computedSize:nt(e.size||_)});break;case"UPDATE_CELL":if(!(null===(o=null===(i=null===(t=this.sizes[e.sheetId])||void 0===t?void 0:t.ROW)||void 0===i?void 0:i[e.row])||void 0===o?void 0:o.manualSize)){const{sheetId:t,row:i}=e;this.history.update("sizes",t,"ROW",i,"computedSize",nt((()=>this.getRowTallestCellSize(t,i))))}break;case"ADD_MERGE":case"REMOVE_MERGE":for(let t of e.target)for(let i of ze(t.top,t.bottom+1)){const t=this.getRowTallestCellSize(e.sheetId,i);t!==this.getRowSize(e.sheetId,i)&&this.history.update("sizes",e.sheetId,"ROW",i,"computedSize",nt(t))}}}getColSize(e,t){return this.getHeaderSize(e,"COL",t)}getRowSize(e,t){return this.getHeaderSize(e,"ROW",t)}getHeaderSize(e,t,i){var o,n,s,r;return Math.round((null===(n=null===(o=this.sizes[e])||void 0===o?void 0:o[t][i])||void 0===n?void 0:n.manualSize)||(null===(r=null===(s=this.sizes[e])||void 0===s?void 0:s[t][i])||void 0===r?void 0:r.computedSize())||this.getDefaultHeaderSize(t))}computeSheetSizes(e){var t,i;const o={COL:[],ROW:[]};for(let t of ze(0,this.getters.getNumberCols(e)))o.COL.push(this.getHeaderSize(e,"COL",t));for(let n of ze(0,this.getters.getNumberRows(e))){let s=null===(i=null===(t=this.sizes[e])||void 0===t?void 0:t.ROW)||void 0===i?void 0:i[n].manualSize;if(!s){s=this.getRowTallestCellSize(e,n)}o.ROW.push(s)}return o}getDefaultHeaderSize(e){return"COL"===e?_:F}getCellHeight(e){const t=this.getters.getMerge(e);if(t&&t.bottom!==t.top)return F;return function(e){return e&&e.content?ke(Ve(e.style),e.content.split(ce).length)+2*V:F}(this.getters.getCell(e))}getRowTallestCellSize(e,t){const i=this.getters.getRowCells(e,t);let o=0;for(let e=0;e<i.length;e++){const t=this.getters.getCellById(i[e]);if(!t)continue;const n=this.getters.getCellPosition(t.id),s=this.getCellHeight(n);s>o&&s>F&&(o=s)}return o<=F?F:o}import(e){for(let t of e.sheets){const e={COL:[],ROW:[]};for(let[i,o]of Object.entries(t.rows))o.size&&(e.ROW[i]=o.size);for(let[i,o]of Object.entries(t.cols))o.size&&(e.COL[i]=o.size);const i=this.computeSheetSizes(t.id);this.sizes[t.id]={COL:i.COL.map(((t,i)=>({manualSize:e.COL[i],computedSize:nt(t)}))),ROW:i.ROW.map(((t,i)=>({manualSize:e.ROW[i],computedSize:nt(t)})))}}}exportForExcel(e){this.exportData(e,!0)}export(e){this.exportData(e)}exportData(e,t=!1){var i,o;for(let n of e.sheets){void 0===n.rows&&(n.rows={});for(let e of ze(0,this.getters.getNumberRows(n.id)))(t||(null===(i=this.sizes[n.id].ROW[e])||void 0===i?void 0:i.manualSize))&&(n.rows[e]={...n.rows[e],size:this.getRowSize(n.id,e)});void 0===n.cols&&(n.cols={});for(let e of ze(0,this.getters.getNumberCols(n.id)))(t||(null===(o=this.sizes[n.id].COL[e])||void 0===o?void 0:o.manualSize))&&(n.cols[e]={...n.cols[e],size:this.getColSize(n.id,e)})}}}wv.getters=["getRowSize","getColSize"];class yv extends Bf{constructor(){super(...arguments),this.hiddenHeaders={}}allowDispatch(e){if("HIDE_COLUMNS_ROWS"===e.type){if(!this.hiddenHeaders[e.sheetId])return 27;const t="COL"===e.dimension?this.getHiddenColsGroups(e.sheetId):this.getHiddenRowsGroups(e.sheetId),i="COL"===e.dimension?this.getters.getNumberCols(e.sheetId):this.getters.getNumberRows(e.sheetId);return(t||[]).flat().concat(e.elements).length<i?0:66}return 0}handle(e){switch(e.type){case"CREATE_SHEET":const t={COL:Array(this.getters.getNumberCols(e.sheetId)).fill(!1),ROW:Array(this.getters.getNumberRows(e.sheetId)).fill(!1)};this.history.update("hiddenHeaders",e.sheetId,t);break;case"DUPLICATE_SHEET":this.history.update("hiddenHeaders",e.sheetIdTo,Ne(this.hiddenHeaders[e.sheetId]));break;case"DELETE_SHEET":this.history.update("hiddenHeaders",e.sheetId,void 0);break;case"REMOVE_COLUMNS_ROWS":{const t=[...this.hiddenHeaders[e.sheetId][e.dimension]];for(let i of[...e.elements].sort(((e,t)=>t-e)))t.splice(i,1);this.history.update("hiddenHeaders",e.sheetId,e.dimension,t);break}case"ADD_COLUMNS_ROWS":{const t=[...this.hiddenHeaders[e.sheetId][e.dimension]],i=rt(e.position,e.base);t.splice(i,0,...Array(e.quantity).fill(!1)),this.history.update("hiddenHeaders",e.sheetId,e.dimension,t);break}case"HIDE_COLUMNS_ROWS":for(let t of e.elements)this.history.update("hiddenHeaders",e.sheetId,e.dimension,t,!0);break;case"UNHIDE_COLUMNS_ROWS":for(let t of e.elements)this.history.update("hiddenHeaders",e.sheetId,e.dimension,t,!1)}}isRowHiddenByUser(e,t){return this.hiddenHeaders[e].ROW[t]}isColHiddenByUser(e,t){return this.hiddenHeaders[e].COL[t]}getHiddenColsGroups(e){const t=[[]],i=this.hiddenHeaders[e].COL;for(let e=0;e<i.length;e++){i[e]?t[t.length-1].push(e):0!==t[t.length-1].length&&t.push([])}return 0===t[t.length-1].length&&t.pop(),t}getHiddenRowsGroups(e){const t=[[]],i=this.hiddenHeaders[e].ROW;for(let e=0;e<i.length;e++){i[e]?t[t.length-1].push(e):0!==t[t.length-1].length&&t.push([])}return 0===t[t.length-1].length&&t.pop(),t}import(e){var t,i;for(let o of e.sheets){this.hiddenHeaders[o.id]={COL:[],ROW:[]};for(let e=0;e<o.rowNumber;e++)this.hiddenHeaders[o.id].ROW[e]=Boolean(null===(t=o.rows[e])||void 0===t?void 0:t.isHidden);for(let e=0;e<o.colNumber;e++)this.hiddenHeaders[o.id].COL[e]=Boolean(null===(i=o.cols[e])||void 0===i?void 0:i.isHidden)}}exportForExcel(e){this.exportData(e,!0)}export(e){this.exportData(e)}exportData(e,t=!1){for(let i of e.sheets){void 0===i.rows&&(i.rows={});for(let e=0;e<this.getters.getNumberRows(i.id);e++)(t||this.hiddenHeaders[i.id].ROW[e])&&(void 0===i.rows[e]&&(i.rows[e]={}),i.rows[e].isHidden=this.hiddenHeaders[i.id].ROW[e]);void 0===i.cols&&(i.cols={});for(let e=0;e<this.getters.getNumberCols(i.id);e++)(t||this.hiddenHeaders[i.id].COL[e])&&(void 0===i.cols[e]&&(i.cols[e]={}),i.cols[e].isHidden=this.hiddenHeaders[i.id].COL[e])}}}yv.getters=["getHiddenColsGroups","getHiddenRowsGroups","isRowHiddenByUser","isColHiddenByUser"];class xv extends Bf{constructor(e){super(e),this.images={},this.syncedImages=new Set,this.fileStore=e.external.fileStore}allowDispatch(e){return"CREATE_IMAGE"===e.type&&this.getters.getFigure(e.sheetId,e.figureId)?28:0}handle(e){switch(e.type){case"CREATE_IMAGE":this.addFigure(e.figureId,e.sheetId,e.position,e.size),this.history.update("images",e.sheetId,e.figureId,e.definition),this.syncedImages.add(e.definition.path);break;case"DUPLICATE_SHEET":{const t=this.getters.getFigures(e.sheetId);for(const i of t)if("image"===i.tag){const t=i.id.split(J).pop(),o=`${e.sheetIdTo}${J}${t}`,n=this.getImage(i.id);if(n){const t={width:i.width,height:i.height};this.dispatch("CREATE_IMAGE",{sheetId:e.sheetIdTo,figureId:o,position:{x:i.x,y:i.y},size:t,definition:Ne(n)})}}break}case"DELETE_FIGURE":this.history.update("images",e.sheetId,e.id,void 0);break;case"DELETE_SHEET":this.history.update("images",e.sheetId,void 0)}}garbageCollectExternalResources(){var e;const t=new Set(this.getAllImages().map((e=>e.path)));for(const i of this.syncedImages)t.has(i)||null===(e=this.fileStore)||void 0===e||e.delete(i)}getImage(e){for(const t of Object.values(this.images))if(t&&t[e])return t[e];throw new Error(`There is no image with the given figureId: ${e}`)}getImagePath(e){return this.getImage(e).path}getImageSize(e){return this.getImage(e).size}addFigure(e,t,i,o){const n={id:e,x:i.x,y:i.y,width:o.width,height:o.height,tag:"image"};this.dispatch("CREATE_FIGURE",{sheetId:t,figure:n})}import(e){for(const t of e.sheets){const e=(t.figures||[]).filter((e=>"image"===e.tag));for(const i of e)this.history.update("images",t.id,i.id,i.data),this.syncedImages.add(i.data.path)}}export(e){var t;for(const i of e.sheets){const e=i.figures.filter((e=>"image"===e.tag));for(const o of e)o.data=null===(t=this.images[i.id])||void 0===t?void 0:t[o.id]}}getAllImages(){const e=[];for(const t in this.images)e.push(...Object.values(this.images[t]||{}).filter(et));return e}}xv.getters=["getImage","getImagePath","getImageSize"];class Iv extends Bf{constructor(){super(...arguments),this.nextId=1,this.merges={},this.mergeCellMap={}}allowDispatch(e){const t="force"in e&&!!e.force;switch(e.type){case"ADD_MERGE":return t?this.checkValidations(e,this.checkFrozenPanes):this.checkValidations(e,this.checkDestructiveMerge,this.checkOverlap,this.checkFrozenPanes);case"UPDATE_CELL":return this.checkMergedContentUpdate(e);case"REMOVE_MERGE":return this.checkMergeExists(e);default:return 0}}handle(e){switch(e.type){case"CREATE_SHEET":case"DELETE_SHEET":this.history.update("merges",e.sheetId,{}),this.history.update("mergeCellMap",e.sheetId,{});break;case"DUPLICATE_SHEET":const t=this.merges[e.sheetId];if(!t)break;for(const i of Object.values(t).filter(et))this.addMerge(e.sheetIdTo,i.zone);break;case"ADD_MERGE":for(const t of e.target)this.addMerge(e.sheetId,t);break;case"REMOVE_MERGE":for(const t of e.target)this.removeMerge(e.sheetId,t)}}adaptRanges(e,t){const i=t?[t]:Object.keys(this.merges);for(const t of i)this.applyRangeChangeOnSheet(t,e)}getMerges(e){return Object.keys(this.merges[e]||{}).map((t=>this.getMergeById(e,parseInt(t,10)))).filter(et)}getMerge({sheetId:e,col:t,row:i}){var o;const n=this.mergeCellMap[e],s=n?t in n&&(null===(o=n[t])||void 0===o?void 0:o[i]):void 0;return s?this.getMergeById(e,s):void 0}getMergesInZone(e,t){var i;const o=this.mergeCellMap[e];if(!o)return[];const n=new Set;for(const{col:e,row:s}of Xi(t)){const t=null===(i=o[e])||void 0===i?void 0:i[s];t&&n.add(t)}return Array.from(n).map((t=>this.getMergeById(e,t))).filter(et)}doesIntersectMerge(e,t){return Xi(t).some((({col:t,row:i})=>void 0!==this.getMerge({sheetId:e,col:t,row:i})))}doesColumnsHaveCommonMerges(e,t,i){const o=this.getters.getSheet(e);for(let n=0;n<this.getters.getNumberRows(e);n++)if(this.isInSameMerge(o.id,t,n,i,n))return!0;return!1}doesRowsHaveCommonMerges(e,t,i){const o=this.getters.getSheet(e);for(let n=0;n<=this.getters.getNumberCols(e);n++)if(this.isInSameMerge(o.id,n,t,n,i))return!0;return!1}expandZone(e,t){let{left:i,right:o,top:n,bottom:s}=t,r={left:i,right:o,top:n,bottom:s};for(let t in this.merges[e]){const i=this.getMergeById(e,parseInt(t));i&&Hi(i,r)&&(r=Vi(i,r))}return Bi(r,t)?r:this.expandZone(e,r)}isInSameMerge(e,t,i,o,n){const s=this.getMerge({sheetId:e,col:t,row:i}),r=this.getMerge({sheetId:e,col:o,row:n});return!(!s||!r)&&Bi(s,r)}isInMerge({sheetId:e,col:t,row:i}){var o;const n=this.mergeCellMap[e];return!!n&&(t in n&&Boolean(null===(o=n[t])||void 0===o?void 0:o[i]))}getMainCellPosition(e){if(!this.isInMerge(e))return e;const t=this.getMerge(e).topLeft;return{sheetId:e.sheetId,col:t.col,row:t.row}}getBottomLeftCell(e){if(!this.isInMerge(e))return e;const{bottom:t,left:i}=this.getMerge(e);return{sheetId:e.sheetId,col:i,row:t}}isMergeHidden(e,t){const i=this.getters.getHiddenColsGroups(e),o=this.getters.getHiddenRowsGroups(e);for(let e of i)if(t.left>=e[0]&&t.right<=e[e.length-1])return!0;for(let e of o)if(t.top>=e[0]&&t.bottom<=e[e.length-1])return!0;return!1}isSingleCellOrMerge(e,t){const i=this.getMerge({sheetId:e,col:t.left,row:t.top});if(i)return Bi(t,i);const{width:o,height:n}=Zi(t);return 1===o&&1===n}isMergeDestructive(e,t){let{left:i,right:o,top:n,bottom:s}=t;o=De(o,0,this.getters.getNumberCols(e)-1),s=De(s,0,this.getters.getNumberRows(e)-1);for(let t=n;t<=s;t++)for(let s=i;s<=o;s++)if(s!==i||t!==n){const i=this.getters.getCell({sheetId:e,col:s,row:t});if(i&&""!==i.content)return!0}return!1}getMergeById(e,t){var i;const o=null===(i=this.merges[e])||void 0===i?void 0:i[t];return void 0!==o?Tv(t,o):void 0}checkDestructiveMerge({sheetId:e,target:t}){if(!this.getters.tryGetSheet(e))return 0;return t.some((t=>this.isMergeDestructive(e,t)))?3:0}checkOverlap({target:e}){for(const t of e)for(const i of e)if(t!==i&&Hi(t,i))return 65;return 0}checkFrozenPanes({sheetId:e,target:t}){if(!this.getters.tryGetSheet(e))return 0;const{xSplit:i,ySplit:o}=this.getters.getPaneDivisions(e);for(const e of t)if(e.left<i&&e.right>=i||e.top<o&&e.bottom>=o)return 75;return 0}checkMergedContentUpdate(e){const{col:t,row:i,content:o}=e;if(void 0===o)return 0;const{col:n,row:s}=this.getMainCellPosition(e);return n===t&&s===i?0:4}checkMergeExists(e){const{sheetId:t,target:i}=e;for(const e of i){const{left:i,top:o}=e,n=this.getMerge({sheetId:t,col:i,row:o});if(void 0===n||!Bi(e,n))return 5}return 0}addMerge(e,t){let{left:i,right:o,top:n,bottom:s}=t;o=De(o,0,this.getters.getNumberCols(e)-1),s=De(s,0,this.getters.getNumberRows(e)-1);if(Vt(i,n)===Vt(o,s))return;const r=this.getters.getCell({sheetId:e,col:i,row:n});let a=this.nextId++;this.history.update("merges",e,a,this.getters.getRangeFromSheetXC(e,Di({left:i,top:n,right:o,bottom:s})));let l=new Set;for(let t=n;t<=s;t++)for(let s=i;s<=o;s++){s===i&&t===n||this.dispatch("UPDATE_CELL",{sheetId:e,col:s,row:t,style:r?r.style:null,content:""});const o=this.getMerge({sheetId:e,col:s,row:t});o&&l.add(o.id),this.history.update("mergeCellMap",e,s,t,a)}for(let t of l){const{top:i,bottom:o,left:n,right:s}=this.getMergeById(e,t);for(let t=i;t<=o;t++)for(let i=n;i<=s;i++){const o={sheetId:e,col:i,row:t},n=this.getMerge(o);n&&n.id===a||(this.history.update("mergeCellMap",e,i,t,void 0),this.dispatch("CLEAR_CELL",o))}this.history.update("merges",e,t,void 0)}}removeMerge(e,t){const{left:i,top:o,bottom:n,right:s}=t,r=this.getMerge({sheetId:e,col:i,row:o});if(void 0!==r&&Bi(t,r)){this.history.update("merges",e,r.id,void 0);for(let t=o;t<=n;t++)for(let o=i;o<=s;o++)this.history.update("mergeCellMap",e,o,t,void 0)}}applyRangeChangeOnSheet(e,t){const i=Object.entries(this.merges[e]||{});for(const[o,n]of i)if(n){const i=n.zone,s=t(n);switch(s.changeType){case"NONE":break;case"REMOVE":this.removeMerge(e,i);break;default:const{width:t,height:n}=Zi(s.range.zone);1===t&&1===n?this.removeMerge(e,i):this.history.update("merges",e,parseInt(o,10),s.range)}}this.history.update("mergeCellMap",e,{});for(const t of this.getMerges(e))for(const{col:i,row:o}of Xi(t))this.history.update("mergeCellMap",e,i,o,t.id)}import(e){const t=e.sheets||[];for(let e of t)this.history.update("merges",e.id,{}),this.history.update("mergeCellMap",e.id,{}),e.merges&&this.importMerges(e.id,e.merges)}importMerges(e,t){for(let i of t)this.addMerge(e,_i(i))}export(e){for(let t of e.sheets){const e=this.merges[t.id];e&&t.merges.push(...Rv(e))}}exportForExcel(e){this.export(e)}}function Rv(e){return Object.entries(e).map((([e,t])=>t?Tv(parseInt(e,10),t):void 0)).filter(et).map((e=>Vt(e.left,e.top)+":"+Vt(e.right,e.bottom)))}function Tv(e,t){return{...t.zone,topLeft:{col:t.zone.left,row:t.zone.top},id:e}}Iv.getters=["isInMerge","isInSameMerge","isMergeHidden","getMainCellPosition","getBottomLeftCell","expandZone","doesIntersectMerge","doesColumnsHaveCommonMerges","doesRowsHaveCommonMerges","getMerges","getMerge","getMergesInZone","isSingleCellOrMerge"];class Av{constructor(e){this.providers=[],this.getters=e}allowDispatch(e){return"MOVE_RANGES"===e.type?1===e.target.length?0:26:0}beforeHandle(e){}handle(e){switch(e.type){case"REMOVE_COLUMNS_ROWS":{let t="COL"===e.dimension?"left":"top",i="COL"===e.dimension?"right":"bottom",o="COL"===e.dimension?"columns":"rows";const n=[...e.elements];n.sort(((e,t)=>t-e));const s=Be(n);this.executeOnAllRanges((n=>{if(n.sheetId!==e.sheetId)return{changeType:"NONE"};let r=n,a="NONE";for(let e of s){const s=Math.min(...e),l=Math.max(...e);if(n.zone[t]<=s&&s<=n.zone[i]){const e=Math.min(n.zone[i],l)-s+1;a="RESIZE",r=this.createAdaptedRange(r,o,a,-e)}else if(n.zone[t]>=s&&n.zone[i]<=l)a="REMOVE";else if(n.zone[t]<=l&&n.zone[i]>=l){const e=l-n.zone[t]+1;a="RESIZE",r=this.createAdaptedRange(r,o,a,-e),r=this.createAdaptedRange(r,o,"MOVE",-(n.zone[t]-s))}else s<n.zone[t]&&(a="MOVE",r=this.createAdaptedRange(r,o,a,-(l-s+1)))}return"NONE"!==a?{changeType:a,range:r}:{changeType:"NONE"}}),e.sheetId);break}case"ADD_COLUMNS_ROWS":{let t="COL"===e.dimension?"left":"top",i="COL"===e.dimension?"right":"bottom",o="COL"===e.dimension?"columns":"rows";this.executeOnAllRanges((n=>{if(n.sheetId!==e.sheetId)return{changeType:"NONE"};if("after"===e.position){if(n.zone[t]<=e.base&&e.base<n.zone[i])return{changeType:"RESIZE",range:this.createAdaptedRange(n,o,"RESIZE",e.quantity)};if(e.base<n.zone[t])return{changeType:"MOVE",range:this.createAdaptedRange(n,o,"MOVE",e.quantity)}}else{if(n.zone[t]<e.base&&e.base<=n.zone[i])return{changeType:"RESIZE",range:this.createAdaptedRange(n,o,"RESIZE",e.quantity)};if(e.base<=n.zone[t])return{changeType:"MOVE",range:this.createAdaptedRange(n,o,"MOVE",e.quantity)}}return{changeType:"NONE"}}),e.sheetId);break}case"DELETE_SHEET":this.executeOnAllRanges((t=>{if(t.sheetId!==e.sheetId)return{changeType:"NONE"};const i=this.getters.getSheetName(e.sheetId);return{changeType:"REMOVE",range:t=t.clone({sheetId:"",invalidSheetName:i})}}),e.sheetId);break;case"RENAME_SHEET":this.executeOnAllRanges((t=>{if(t.sheetId===e.sheetId)return{changeType:"CHANGE",range:t};if(e.name&&t.invalidSheetName===e.name){const i=void 0,o=e.sheetId;return{changeType:"CHANGE",range:t.clone({sheetId:o,invalidSheetName:i})}}return{changeType:"NONE"}}));break;case"MOVE_RANGES":{const t=e.target[0];this.executeOnAllRanges((i=>{if(i.sheetId!==e.sheetId||!Wi(i.zone,t))return{changeType:"NONE"};const o=e.targetSheetId,n=e.col-t.left,s=e.row-t.top,r=this.createAdaptedRange(i,"both","MOVE",[n,s]),a=e.sheetId!==o||r.prefixSheet;return{changeType:"MOVE",range:r.clone({sheetId:o,prefixSheet:a})}}));break}}}finalize(){}verifyRangeRemoved(e){return t=>{const i=e(t);return"NONE"===i.changeType||Fi(i.range.zone)?i:{range:i.range,changeType:"REMOVE"}}}createAdaptedRange(e,t,i,o){const n=Yi(e.unboundedZone,t,i,o);return e.clone({zone:n})}executeOnAllRanges(e,t){const i=this.verifyRangeRemoved(e);for(const e of this.providers)e(i,t)}addRangeProvider(e){this.providers.push(e)}createAdaptedRanges(e,t,i,o){const n=e.map((e=>Ii.fromRange(e,this.getters)));return n.map((e=>{if(!Fi(e.zone))return e;const n=e.prefixSheet?e.sheetId:o,s={...e.unboundedZone,left:e.isFullRow&&!e.unboundedZone.hasHeader?e.unboundedZone.left:e.unboundedZone.left+(e.parts[0].colFixed?0:t),right:e.isFullRow?e.unboundedZone.right:e.unboundedZone.right+((e.parts[1]||e.parts[0]).colFixed?0:t),top:e.isFullCol&&!e.unboundedZone.hasHeader?e.unboundedZone.top:e.unboundedZone.top+(e.parts[0].rowFixed?0:i),bottom:e.isFullCol?e.unboundedZone.bottom:e.unboundedZone.bottom+((e.parts[1]||e.parts[0]).rowFixed?0:i)};return e.clone({sheetId:n,zone:s}).orderZone()}))}getRangeFromSheetXC(e,t){if(!Ot.test(t))return new Ii({sheetId:"",zone:{left:-1,top:-1,right:-1,bottom:-1},parts:[],invalidXc:t,prefixSheet:!1},this.getters.getSheetSize);let i,o=t,n=!1;t.includes("!")&&(({xc:o,sheetName:i}=kt(t)),i&&(n=!0));const s=Ni(o),r=Ii.getRangeParts(o,s),a=i&&!this.getters.getSheetIdByName(i)?i:void 0,l=this.getters.getSheetIdByName(i)||e;return new Ii({prefixSheet:n,zone:s,sheetId:l,invalidSheetName:a,parts:r},this.getters.getSheetSize).orderZone()}getSelectionRangeString(e,t){const i=Ii.fromRange(e,this.getters),o=this.getters.expandZone(i.sheetId,i.zone),n=i.clone({zone:{...o,bottom:i.isFullCol?void 0:o.bottom,right:i.isFullRow?void 0:o.right}});return this.getRangeString(n,t)}getRangeString(e,t){if(!e)return Y;if(e.invalidXc)return e.invalidXc;if(e.zone.bottom-e.zone.top<0||e.zone.right-e.zone.left<0)return Y;if(e.zone.left<0||e.zone.top<0)return Y;const i=Ii.fromRange(e,this.getters);let o=i.sheetId!==t||i.invalidSheetName||i.prefixSheet,n="";if(o&&(n=i.invalidSheetName?i.invalidSheetName:Fe(this.getters.getSheetName(i.sheetId))),o&&!n)return Y;let s=this.getRangePartString(i,0);return i.parts&&2===i.parts.length&&(i.zone.top!==i.zone.bottom||i.zone.left!==i.zone.right||i.parts[0].rowFixed||i.parts[0].colFixed||i.parts[1].rowFixed||i.parts[1].colFixed)&&(s+=":",s+=this.getRangePartString(i,1)),`${o?n+"!":""}${s}`}getRangeDataFromXc(e,t){return this.getters.getRangeFromSheetXC(e,t).rangeData}getRangeDataFromZone(e,t){return{_sheetId:e,_zone:t}}getRangeFromRangeData(e){const t={prefixSheet:!1,zone:e._zone,sheetId:e._sheetId,invalidSheetName:void 0,parts:[{colFixed:!1,rowFixed:!1},{colFixed:!1,rowFixed:!1}]};return new Ii(t,this.getters.getSheetSize)}getRangePartString(e,t){const i=e.parts&&e.parts[t].colFixed?"$":"",o=Lt(0===t?e.zone.left:e.zone.right),n=e.parts&&e.parts[t].rowFixed?"$":"",s=String(0===t?e.zone.top+1:e.zone.bottom+1);let r="";return r=e.isFullCol?0===t&&e.unboundedZone.hasHeader?i+o+n+s:i+o:e.isFullRow?0===t&&e.unboundedZone.hasHeader?i+o+n+s:n+s:i+o+n+s,r}}Av.getters=["getRangeString","getSelectionRangeString","getRangeFromSheetXC","createAdaptedRanges","getRangeDataFromXc","getRangeDataFromZone","getRangeFromRangeData"];class Mv extends Bf{constructor(){super(...arguments),this.sheetIdsMapName={},this.orderedSheetIds=[],this.sheets={},this.cellPosition={}}allowDispatch(e){const t=this.chainValidations(this.checkSheetExists,this.checkZones)(e);if(0!==t)return t;switch(e.type){case"HIDE_SHEET":return 1===this.getVisibleSheetIds().length?9:0;case"CREATE_SHEET":return this.checkValidations(e,this.checkSheetName,this.checkSheetPosition);case"MOVE_SHEET":try{const t=this.orderedSheetIds.findIndex((t=>t===e.sheetId));return this.findIndexOfTargetSheet(t,e.delta),0}catch(e){return 14}case"RENAME_SHEET":return this.isRenameAllowed(e);case"DELETE_SHEET":return this.orderedSheetIds.length>1?0:9;case"REMOVE_COLUMNS_ROWS":return("COL"===e.dimension?this.getNumberCols(e.sheetId):this.getNumberRows(e.sheetId))>e.elements.length?0:8;case"FREEZE_ROWS":return this.checkValidations(e,this.checkRowFreezeQuantity,this.checkRowFreezeOverlapMerge);case"FREEZE_COLUMNS":return this.checkValidations(e,this.checkColFreezeQuantity,this.checkColFreezeOverlapMerge);default:return 0}}handle(e){switch(e.type){case"SET_GRID_LINES_VISIBILITY":this.setGridLinesVisibility(e.sheetId,e.areGridLinesVisible);break;case"DELETE_CONTENT":this.clearZones(e.sheetId,e.target);break;case"CREATE_SHEET":const t=this.createSheet(e.sheetId,e.name||this.getNextSheetName(),e.cols||26,e.rows||100,e.position);this.history.update("sheetIdsMapName",t.name,t.id);break;case"MOVE_SHEET":this.moveSheet(e.sheetId,e.delta);break;case"RENAME_SHEET":this.renameSheet(this.sheets[e.sheetId],e.name);break;case"HIDE_SHEET":this.hideSheet(e.sheetId);break;case"SHOW_SHEET":this.showSheet(e.sheetId);break;case"DUPLICATE_SHEET":this.duplicateSheet(e.sheetId,e.sheetIdTo);break;case"DELETE_SHEET":this.deleteSheet(this.sheets[e.sheetId]);break;case"REMOVE_COLUMNS_ROWS":"COL"===e.dimension?this.removeColumns(this.sheets[e.sheetId],[...e.elements]):this.removeRows(this.sheets[e.sheetId],[...e.elements]);break;case"ADD_COLUMNS_ROWS":"COL"===e.dimension?this.addColumns(this.sheets[e.sheetId],e.base,e.position,e.quantity):this.addRows(this.sheets[e.sheetId],e.base,e.position,e.quantity);break;case"UPDATE_CELL_POSITION":this.updateCellPosition(e);break;case"FREEZE_COLUMNS":this.setPaneDivisions(e.sheetId,e.quantity,"COL");break;case"FREEZE_ROWS":this.setPaneDivisions(e.sheetId,e.quantity,"ROW");break;case"UNFREEZE_ROWS":this.setPaneDivisions(e.sheetId,0,"ROW");break;case"UNFREEZE_COLUMNS":this.setPaneDivisions(e.sheetId,0,"COL");break;case"UNFREEZE_COLUMNS_ROWS":this.setPaneDivisions(e.sheetId,0,"COL"),this.setPaneDivisions(e.sheetId,0,"ROW")}}import(e){var t,i;for(let t of e.sheets)this.sheetIdsMapName[t.name]=t.id;for(let o of e.sheets){const e=o.name||n("Sheet")+(Object.keys(this.sheets).length+1),{colNumber:s,rowNumber:r}=this.getImportedSheetSize(o),a={id:o.id,name:e,numberOfCols:s,rows:Mi(r),areGridLinesVisible:void 0===o.areGridLinesVisible||o.areGridLinesVisible,isVisible:o.isVisible,panes:{xSplit:(null===(t=o.panes)||void 0===t?void 0:t.xSplit)||0,ySplit:(null===(i=o.panes)||void 0===i?void 0:i.ySplit)||0}};this.orderedSheetIds.push(a.id),this.sheets[a.id]=a}}exportSheets(e){e.sheets=this.orderedSheetIds.filter(et).map((e=>{const t=this.sheets[e],i={id:t.id,name:t.name,colNumber:t.numberOfCols,rowNumber:this.getters.getNumberRows(t.id),rows:{},cols:{},merges:[],cells:{},conditionalFormats:[],figures:[],filterTables:[],areGridLinesVisible:void 0===t.areGridLinesVisible||t.areGridLinesVisible,isVisible:t.isVisible};return(t.panes.xSplit||t.panes.ySplit)&&(i.panes=t.panes),i}))}export(e){this.exportSheets(e)}exportForExcel(e){this.exportSheets(e)}getGridLinesVisibility(e){return this.getSheet(e).areGridLinesVisible}tryGetSheet(e){return this.sheets[e]}getSheet(e){const t=this.sheets[e];if(!t)throw new Error(`Sheet ${e} not found.`);return t}isSheetVisible(e){return this.getSheet(e).isVisible}getSheetName(e){return this.getSheet(e).name}tryGetSheetName(e){var t;return null===(t=this.tryGetSheet(e))||void 0===t?void 0:t.name}getSheetIdByName(e){if(e){const t=_e(e);for(const e in this.sheetIdsMapName)if(e.toUpperCase()===t.toUpperCase())return this.sheetIdsMapName[e]}}getSheetIds(){return this.orderedSheetIds}getVisibleSheetIds(){return this.orderedSheetIds.filter(this.isSheetVisible.bind(this))}getEvaluationSheets(){return this.sheets}doesHeaderExist(e,t,i){return"COL"===t?i>=0&&i<this.getNumberCols(e):i>=0&&i<this.getNumberRows(e)}getRow(e,t){const i=this.getSheet(e).rows[t];if(!i)throw new Error(`Row ${i} not found.`);return i}getCell({sheetId:e,col:t,row:i}){var o;const n=this.tryGetSheet(e),s=null===(o=null==n?void 0:n.rows[i])||void 0===o?void 0:o.cells[t];if(void 0!==s)return this.getters.getCellById(s)}getColsZone(e,t,i){return{top:0,bottom:this.getNumberRows(e)-1,left:t,right:i}}getRowCells(e,t){var i;return Object.values(null===(i=this.getSheet(e).rows[t])||void 0===i?void 0:i.cells).filter(et)}getRowsZone(e,t,i){return{top:t,bottom:i,left:0,right:this.getSheet(e).numberOfCols-1}}getCellPosition(e){const t=this.cellPosition[e];if(!t)throw new Error(`asking for a cell position that doesn't exist, cell id: ${e}`);return t}getNumberCols(e){return this.getSheet(e).numberOfCols}getNumberRows(e){return this.getSheet(e).rows.length}getNumberHeaders(e,t){return"COL"===t?this.getNumberCols(e):this.getNumberRows(e)}getNextSheetName(e="Sheet"){let t=1;const i=this.orderedSheetIds.map(this.getSheetName.bind(this));let o=`${e}${t}`;for(;i.includes(o);)o=`${e}${t}`,t++;return o}getSheetSize(e){return{height:this.getNumberRows(e),width:this.getNumberCols(e)}}getSheetZone(e){return{top:0,left:0,bottom:this.getNumberRows(e)-1,right:this.getNumberCols(e)-1}}getPaneDivisions(e){return this.getSheet(e).panes}setPaneDivisions(e,t,i){const o={...this.getPaneDivisions(e)};"COL"===i?o.xSplit=t:"ROW"===i&&(o.ySplit=t),this.history.update("sheets",e,"panes",o)}isEmpty(e,t){return Xi(t).map((({col:t,row:i})=>this.getCell({sheetId:e,col:t,row:i}))).every((e=>!e||""===e.content))}updateCellPosition(e){const{sheetId:t,cellId:i,col:o,row:n}=e;i?this.setNewPosition(i,t,o,n):this.clearPosition(t,o,n)}setNewPosition(e,t,i,o){const n=this.cellPosition[e];n&&this.clearPosition(t,n.col,n.row),this.history.update("cellPosition",e,{row:o,col:i,sheetId:t}),this.history.update("sheets",t,"rows",o,"cells",i,e)}clearPosition(e,t,i){var o;const n=null===(o=this.sheets[e])||void 0===o?void 0:o.rows[i].cells[t];n&&(this.history.update("cellPosition",n,void 0),this.history.update("sheets",e,"rows",i,"cells",t,void 0))}setGridLinesVisibility(e,t){this.history.update("sheets",e,"areGridLinesVisible",t)}clearZones(e,t){for(let i of t)for(let t=i.left;t<=i.right;t++)for(let o=i.top;o<=i.bottom;o++){this.sheets[e].rows[o].cells[t]&&this.dispatch("UPDATE_CELL",{sheetId:e,content:"",col:t,row:o})}}createSheet(e,t,i,o,n){const s={id:e,name:t,numberOfCols:i,rows:Mi(o),areGridLinesVisible:!0,isVisible:!0,panes:{xSplit:0,ySplit:0}},r=this.orderedSheetIds.slice();r.splice(n,0,s.id);const a=this.sheets;return this.history.update("orderedSheetIds",r),this.history.update("sheets",Object.assign({},a,{[s.id]:s})),s}moveSheet(e,t){const i=this.orderedSheetIds.slice(),o=i.findIndex((t=>t===e)),n=i.splice(o,1);let s=this.findIndexOfTargetSheet(o,t);i.splice(s,0,n[0]),this.history.update("orderedSheetIds",i)}findIndexOfTargetSheet(e,t){for(;0!=t&&0<=e&&e<=this.orderedSheetIds.length;)t>0?(e++,this.isSheetVisible(this.orderedSheetIds[e])&&t--):t<0&&(e--,this.isSheetVisible(this.orderedSheetIds[e])&&t++);if(0===t)return e;throw new Error(s("There is not enough visible sheets"))}checkSheetName(e){const{orderedSheetIds:t,sheets:i}=this,o=e.name&&e.name.trim().toLowerCase();return t.find((e=>{var t;return(null===(t=i[e])||void 0===t?void 0:t.name.toLowerCase())===o}))?11:se.test(o)?13:0}checkSheetPosition(e){const{orderedSheetIds:t}=this;return e.position>t.length||e.position<0?15:0}checkRowFreezeQuantity(e){return e.quantity>=1&&e.quantity<this.getNumberRows(e.sheetId)?0:74}checkColFreezeQuantity(e){return e.quantity>=1&&e.quantity<this.getNumberCols(e.sheetId)?0:74}checkRowFreezeOverlapMerge(e){const t=this.getters.getMerges(e.sheetId);for(let i of t)if(i.top<e.quantity&&e.quantity<=i.bottom)return 65;return 0}checkColFreezeOverlapMerge(e){const t=this.getters.getMerges(e.sheetId);for(let i of t)if(i.left<e.quantity&&e.quantity<=i.right)return 65;return 0}isRenameAllowed(e){return e.name&&e.name.trim().toLowerCase()?this.checkSheetName(e):10}renameSheet(e,t){const i=e.name;this.history.update("sheets",e.id,"name",t.trim());const o=Object.assign({},this.sheetIdsMapName);o[t]=e.id,delete o[i],this.history.update("sheetIdsMapName",o)}hideSheet(e){this.history.update("sheets",e,"isVisible",!1)}showSheet(e){this.history.update("sheets",e,"isVisible",!0)}duplicateSheet(e,t){const i=this.getSheet(e),o=this.getDuplicateSheetName(i.name),n=JSON.parse(JSON.stringify(i));n.id=t,n.name=o;for(let e=0;e<=n.numberOfCols;e++)for(let t=0;t<=n.rows.length;t++)n.rows[t]&&(n.rows[t].cells[e]=void 0);const s=this.orderedSheetIds.slice(),r=s.indexOf(e);s.splice(r+1,0,n.id),this.history.update("orderedSheetIds",s),this.history.update("sheets",Object.assign({},this.sheets,{[n.id]:n}));for(const t of Object.values(this.getters.getCells(e))){const{col:e,row:i}=this.getCellPosition(t.id);this.dispatch("UPDATE_CELL",{sheetId:n.id,col:e,row:i,content:t.content,format:t.format,style:t.style})}const a=Object.assign({},this.sheetIdsMapName);a[n.name]=n.id,this.history.update("sheetIdsMapName",a)}getDuplicateSheetName(e){let t=1;const i=this.orderedSheetIds.map(this.getSheetName.bind(this)),o=s("Copy of %s",e);let n=o.toString();for(;i.includes(n);)n=`${o} (${t})`,t++;return n}deleteSheet(e){const t=e.name,i=Object.assign({},this.sheets);delete i[e.id],this.history.update("sheets",i);const o=this.orderedSheetIds.slice(),n=o.indexOf(e.id);o.splice(n,1),this.history.update("orderedSheetIds",o);const s=Object.assign({},this.sheetIdsMapName);delete s[t],this.history.update("sheetIdsMapName",s)}removeColumns(e,t){t.sort(((e,t)=>t-e));for(let i of t)this.moveCellOnColumnsDeletion(e,i);const i=this.sheets[e.id].numberOfCols;this.history.update("sheets",e.id,"numberOfCols",i-t.length);const o=t.filter((t=>t<e.panes.xSplit)).length;o&&this.setPaneDivisions(e.id,e.panes.xSplit-o,"COL")}removeRows(e,t){t.sort(((e,t)=>t-e));for(let i of Be(t))this.moveCellOnRowsDeletion(e,i[i.length-1],i[0]),i.map((t=>this.updateRowsStructureOnDeletion(t,e)));const i=t.filter((t=>t<e.panes.ySplit)).length;i&&this.setPaneDivisions(e.id,e.panes.ySplit-i,"ROW")}addColumns(e,t,i,o){const n="before"===i?t:t+1;this.moveCellsOnAddition(e,n,o,"columns");const s=this.sheets[e.id].numberOfCols;this.history.update("sheets",e.id,"numberOfCols",s+o),n<e.panes.xSplit&&this.setPaneDivisions(e.id,e.panes.xSplit+o,"COL")}addRows(e,t,i,o){const n="before"===i?t:t+1;this.addEmptyRows(e,o),this.moveCellsOnAddition(e,n,o,"rows"),this.updateRowsStructureOnAddition(e,t,o),n<e.panes.ySplit&&this.setPaneDivisions(e.id,e.panes.ySplit+o,"ROW")}moveCellOnColumnsDeletion(e,t){for(let[i,o]of Object.entries(e.rows)){const n=parseInt(i,10);for(let i in o.cells){const s=parseInt(i,10),r=o.cells[i];r&&(s===t&&this.dispatch("CLEAR_CELL",{sheetId:e.id,col:s,row:n}),s>t&&this.dispatch("UPDATE_CELL_POSITION",{sheetId:e.id,cellId:r,col:s-1,row:n}))}}}moveCellsOnAddition(e,t,i,o){const n=[];for(const[s,r]of Object.entries(e.rows)){const a=parseInt(s,10);if("rows"!==o||a>=t)for(let s in r.cells){const l=parseInt(s,10),c=r.cells[s];c&&("rows"===o||l>=t)&&n.push({type:"UPDATE_CELL_POSITION",sheetId:e.id,cellId:c,col:l+("columns"===o?i:0),row:a+("rows"===o?i:0)})}}for(let e of n.reverse())this.dispatch(e.type,e)}moveCellOnRowsDeletion(e,t,i){const o=i-t+1;for(let[n,s]of Object.entries(e.rows)){const r=parseInt(n,10);if(r>=t&&r<=i)for(let t in s.cells){const i=parseInt(t,10);s.cells[t]&&this.dispatch("CLEAR_CELL",{sheetId:e.id,col:i,row:r})}if(r>i)for(let t in s.cells){const i=parseInt(t,10),n=s.cells[t];n&&this.dispatch("UPDATE_CELL_POSITION",{sheetId:e.id,cellId:n,col:i,row:r-o})}}}updateRowsStructureOnDeletion(e,t){const i=[],o=t.rows.map((e=>e.cells));for(let n in t.rows)parseInt(n,10)!==e&&i.push({cells:o.shift()});this.history.update("sheets",t.id,"rows",i)}updateRowsStructureOnAddition(e,t,i){const o=[],n=e.rows.map((e=>e.cells));e.rows.forEach((()=>o.push({cells:n.shift()}))),this.history.update("sheets",e.id,"rows",o)}addEmptyRows(e,t){const i=e.rows.slice();for(let e=0;e<t;e++)i.push({cells:{}});this.history.update("sheets",e.id,"rows",i)}getImportedSheetSize(e){const t=Object.keys(e.cells).map(Ut);let i=e.rowNumber,o=e.colNumber;for(let{col:e,row:n}of t)i=Math.max(i,n+1),o=Math.max(o,e+1);return{rowNumber:i,colNumber:o}}checkSheetExists(e){return"CREATE_SHEET"!==e.type&&"sheetId"in e&&void 0===this.sheets[e.sheetId]?27:"CREATE_SHEET"===e.type&&void 0!==this.sheets[e.sheetId]?12:0}checkZones(e){const t=[];if("zone"in e&&t.push(e.zone),"target"in e&&Array.isArray(e.target)&&t.push(...e.target),"ranges"in e&&Array.isArray(e.ranges)&&t.push(...e.ranges.map((e=>this.getters.getRangeFromRangeData(e).zone))),!t.every(Fi))return 25;if(t.length&&"sheetId"in e){const i=this.getSheetZone(e.sheetId);return t.every((e=>Wi(e,i)))?0:18}return 0}}Mv.getters=["getSheetName","tryGetSheetName","getSheet","tryGetSheet","getSheetIdByName","getSheetIds","getVisibleSheetIds","isSheetVisible","getEvaluationSheets","doesHeaderExist","getCell","getCellPosition","getColsZone","getRowCells","getRowsZone","getNumberCols","getNumberRows","getNumberHeaders","getGridLinesVisibility","getNextSheetName","isEmpty","getSheetSize","getSheetZone","getPaneDivisions"];class Ov extends zf{constructor({getters:e,stateObserver:t,dispatch:i,uiActions:o,selection:n}){super(t,i),this.getters=e,this.ui=o,this.selection=n}drawGrid(e,t){}}Ov.layers=[];class Nv extends Ov{constructor(){super(...arguments),this.customColors=new Set,this.shouldUpdateColors=!1}handle(e){switch(e.type){case"UPDATE_CELL":case"UPDATE_CHART":case"CREATE_CHART":case"ADD_CONDITIONAL_FORMAT":this.shouldUpdateColors=!0}}finalize(){if(this.shouldUpdateColors){this.shouldUpdateColors=!1;for(const e of this.getCustomColors())this.tryToAddColor(e)}}getCustomColors(){let e=[];for(const t of this.getters.getSheetIds()){const i=Object.values(this.getters.getCells(t));e=e.concat(this.getColorsFromCells(i),this.getFormattingColors(t),this.getChartColors(t))}return function(e){const t=[{leadColor:St(255,0,0),colors:[]},{leadColor:St(255,128,0),colors:[]},{leadColor:St(128,128,0),colors:[]},{leadColor:St(128,255,0),colors:[]},{leadColor:St(0,255,0),colors:[]},{leadColor:St(0,255,128),colors:[]},{leadColor:St(0,255,255),colors:[]},{leadColor:St(0,127,255),colors:[]},{leadColor:St(0,0,255),colors:[]},{leadColor:St(127,0,255),colors:[]},{leadColor:St(128,0,128),colors:[]},{leadColor:St(255,0,128),colors:[]}];for(const i of e.map(wt)){let e=500,o=0;t.forEach(((t,n)=>{const s=(r=i,a=t.leadColor,Math.sqrt(Math.pow(r.r-a.r,2)+Math.pow(r.g-a.g,2)+Math.pow(r.b-a.b,2)));var r,a;e>s&&(e=s,o=n)})),t[o].colors.push(i)}return t.map((e=>e.colors.sort(((e,t)=>xt(e).s-xt(t).s)))).flat().map(Et)}([...new Set([...new Set([...e,...this.customColors])].filter(vt).map((e=>ft(e).toLowerCase())))]).filter((e=>!M.includes(e)))}getColorsFromCells(e){var t,i;const o=new Set;for(const n of e)(null===(t=n.style)||void 0===t?void 0:t.textColor)&&o.add(n.style.textColor),(null===(i=n.style)||void 0===i?void 0:i.fillColor)&&o.add(n.style.fillColor);return[...o]}getFormattingColors(e){const t=this.getters.getConditionalFormats(e),i=[];for(const e of t){const t=e.rule;"CellIsRule"===t.type?(i.push(t.style.textColor),i.push(t.style.fillColor)):"ColorScaleRule"===t.type&&(i.push(mt(t.minimum.color)),i.push(t.midpoint?mt(t.midpoint.color):void 0),i.push(mt(t.maximum.color)))}return i.filter(et)}getChartColors(e){const t=this.getters.getChartIds(e).map((e=>this.getters.getChart(e)));let i=new Set;for(let e of t){if(void 0===e)continue;const t=e.getDefinition().background;switch(void 0!==t&&i.add(t),e.type){case"gauge":const t=e.sectionRule.colors;i.add(t.lowerColor),i.add(t.middleColor),i.add(t.upperColor);break;case"scorecard":const o=e;i.add(o.baselineColorDown),i.add(o.baselineColorUp)}}return[...i]}tryToAddColor(e){const t=ft(e).toLowerCase();e&&!M.includes(t)&&this.customColors.add(t)}}Nv.getters=["getCustomColors"];const _v=iu.mapping;class Fv extends Ov{constructor(e){super(e),this.isUpToDate=!1,this.evaluatedCells={},this.evalContext=e.custom,this.lazyEvaluation=e.lazyEvaluation}handle(e){switch(Eo.has(e.type)&&(this.isUpToDate=!1),e.type){case"UPDATE_CELL":("content"in e||"format"in e)&&(this.isUpToDate=!1);break;case"EVALUATE_CELLS":this.evaluate()}}finalize(){this.isUpToDate||(this.evaluate(),this.isUpToDate=!0)}evaluateFormula(e,t=this.getters.getActiveSheetId()){const i=uv(e),o=this.getCompilationParameters((e=>this.getEvaluatedCell(this.getters.getCellPosition(e.id)))),n=[];for(let e of i.dependencies)n.push(this.getters.getRangeFromSheetXC(t,e));return i.execute(n,...o).value}getRangeFormattedValues(e){const t=this.getters.tryGetSheet(e.sheetId);return void 0===t?[]:this.getters.getEvaluatedCellsInZone(t.id,e.zone).map((e=>e.formattedValue))}getRangeValues(e){const t=this.getters.tryGetSheet(e.sheetId);return void 0===t?[]:this.getters.getEvaluatedCellsInZone(t.id,e.zone).map((e=>e.value))}getRangeFormats(e){const t=this.getters.tryGetSheet(e.sheetId);return void 0===t?[]:this.getters.getEvaluatedCellsInZone(t.id,e.zone).map((e=>e.format))}getEvaluatedCell({sheetId:e,col:t,row:i}){var o,n,s;return void 0===this.getters.getCell({sheetId:e,col:t,row:i})?Ou(""):(null===(s=null===(n=null===(o=this.evaluatedCells[e])||void 0===o?void 0:o[t])||void 0===n?void 0:n[i])||void 0===s?void 0:s.call(n))||Ou("")}getEvaluatedCells(e){const t=this.getters.getCells(e)||{},i={};for(let e of Object.keys(t)){const t=this.getters.getCellPosition(e);i[e]=this.getEvaluatedCell(t)}return i}getColEvaluatedCells(e,t){var i;return Object.values((null===(i=this.evaluatedCells[e])||void 0===i?void 0:i[t])||[]).filter(et).map((e=>e()))}getEvaluatedCellsInZone(e,t){return Xi(t).map((({col:t,row:i})=>this.getters.getEvaluatedCell({sheetId:e,col:t,row:i})))}setEvaluatedCell(e,t){const{col:i,row:o,sheetId:n}=this.getters.getCellPosition(e);this.evaluatedCells[n]||(this.evaluatedCells[n]={}),this.evaluatedCells[n][i]||(this.evaluatedCells[n][i]={}),this.evaluatedCells[n][i][o]=t,this.lazyEvaluation||this.evaluatedCells[n][i][o]()}*getAllCells(){for(const e of this.getters.getSheetIds()){const t=this.getters.getCells(e);for(const e in t)yield t[e]}}evaluate(){this.evaluatedCells={};const e=new Set,t=e=>{var t,n;const s=e.id,{col:r,row:a,sheetId:l}=this.getters.getCellPosition(s),c=null===(n=null===(t=this.evaluatedCells[l])||void 0===t?void 0:t[r])||void 0===n?void 0:n[a];return c||nt((()=>{try{switch(e.isFormula){case!0:return o(e);case!1:return Au(e.content,e.format)}}catch(t){return i(t,e)}}))},i=(e,t)=>{e instanceof Error||(e=new Error(e));const i=(null==e?void 0:e.errorType)||a.GenericError,o=n[2].__lastFnCalled||"",s=new c(i,e.message.replace("[[FUNCTION_NAME]]",o),void 0!==e.logLevel?e.logLevel:l.error);return Du(t.content,s)},o=t=>{const i=t.id;if(e.has(i))throw new d;n[2].__originCellXC=()=>{const e=n[2].getters.getCellPosition(i);return Vt(e.col,e.row)},e.add(i);const o=t.compiledFormula.execute(t.dependencies,...n);if(e.delete(i),Array.isArray(o.value))throw new Error(s("This formula depends on invalid values"));return Ou(o.value,t.format||o.format)},n=this.getCompilationParameters((e=>t(e)()));for(const e of this.getAllCells())this.setEvaluatedCell(e.id,t(e))}getCompilationParameters(e){const t=Object.assign(Object.create(_v),this.evalContext,{getters:this.getters}),i=this.getters;const o=t=>{const i=e(t);if(i.type===So.error)throw i.error;return i};return[function(e,t,n,r){if(t)return{value:Di(e.zone)};if(!Fi(e.zone))throw new u;if(e.zone.bottom!==e.zone.top||e.zone.left!==e.zone.right)throw new Error(r?s("Function %s expects the parameter %s to be a single value or a single cell reference, not a range.",n.toString(),r.toString()):s("Function %s expects its parameters to be single values or single cell references, not ranges.",n.toString()));if(e.invalidSheetName)throw new Error(s("Invalid sheet name: %s",e.invalidSheetName));return function(e){let t;if(!i.tryGetSheet(e.sheetId))throw new Error(s("Invalid sheet name"));return t=i.getCell({sheetId:e.sheetId,col:e.zone.left,row:e.zone.top}),t&&""!==t.content?o(t):{value:null}}(e)},function(e){const n=e.sheetId;if(!Fi(e.zone))throw new u;const s=i.getSheetZone(n),r=[],a=zi(e.zone,s);if(!a)return r.push([]),r;for(let i=a.left;i<=a.right;i++){const n=[];for(let s=a.top;s<=a.bottom;s++){const r=t.getters.getCell({sheetId:e.sheetId,col:i,row:s});n.push(r?o(r):void 0)}r.push(n)}return r},t]}exportForExcel(e){for(let t of e.sheets)for(const e in t.cells){const i={sheetId:t.id,...Ut(e)},o=this.getters.getCell(i);if(o){const n=t.cells[e];n.value=this.getEvaluatedCell(i).value,n.isFormula=o.isFormula&&!this.isBadExpression(o.content)}}}isBadExpression(e){try{return uv(e),!1}catch(e){return!0}}}Fv.getters=["evaluateFormula","getRangeFormattedValues","getRangeValues","getRangeFormats","getEvaluatedCell","getEvaluatedCells","getColEvaluatedCells","getEvaluatedCellsInZone"];class Dv extends Ov{constructor(){super(...arguments),this.charts={},this.createRuntimeChart=function(e){const t=On.getAll().sort(((e,t)=>e.sequence-t.sequence));return function(i){const o=t.find((e=>e.match(i.type)));if(!o)throw new Error("No runtime builder for this chart.");return o.getChartRuntime(i,e)}}(this.getters)}handle(e){if(Eo.has(e.type)||wo.has(e.type)||"EVALUATE_CELLS"===e.type||"UPDATE_CELL"===e.type)for(const e in this.charts)this.charts[e]=void 0;switch(e.type){case"UPDATE_CHART":case"CREATE_CHART":case"DELETE_FIGURE":this.charts[e.id]=void 0;break;case"DELETE_SHEET":for(let e in this.charts)this.getters.isChartDefined(e)||(this.charts[e]=void 0)}}getChartRuntime(e){if(!this.charts[e]){const t=this.getters.getChart(e);if(!t)throw new Error(`No chart for the given id: ${e}`);this.charts[e]=this.createRuntimeChart(t)}return this.charts[e]}getBackgroundOfSingleCellChart(e,t){if(e)return e;if(!t)return w;const i=t.zone.left,o=t.zone.top,n=t.sheetId;return this.getters.getCellComputedStyle({sheetId:n,col:i,row:o}).fillColor||w}}Dv.getters=["getChartRuntime","getBackgroundOfSingleCellChart"];class kv extends Ov{constructor(){super(...arguments),this.isStale=!0,this.computedStyles={},this.computedIcons={},this.rulePredicate={CellIsRule:(e,t)=>{if(e.type===So.error)return!1;const i=t.values.map(Mu);switch(t.operator){case"IsEmpty":return""===e.value.toString().trim();case"IsNotEmpty":return""!==e.value.toString().trim();case"BeginsWith":return""!==i[0]&&e.value.toString().startsWith(i[0].toString());case"EndsWith":return""!==i[0]&&e.value.toString().endsWith(i[0].toString());case"Between":return e.value>=i[0]&&e.value<=i[1];case"NotBetween":return!(e.value>=i[0]&&e.value<=i[1]);case"ContainsText":return e.value.toString().indexOf(i[0].toString())>-1;case"NotContains":return!e.value||-1==e.value.toString().indexOf(i[0].toString());case"GreaterThan":return e.value>i[0];case"GreaterThanOrEqual":return e.value>=i[0];case"LessThan":return e.value<i[0];case"LessThanOrEqual":return e.value<=i[0];case"NotEqual":return""!==i[0]&&e.value!==i[0];case"Equal":return""===i[0]||e.value===i[0];default:console.warn(s("Not implemented operator %s for kind of conditional formatting: %s",t.operator,t.type))}return!1}}}handle(e){switch((wo.has(e.type)||"UPDATE_CELL"===e.type&&"content"in e)&&(this.isStale=!0),e.type){case"ACTIVATE_SHEET":const t=e.sheetIdTo;this.computedStyles[t]=this.computedStyles[t]||{},this.computedIcons[t]=this.computedIcons[t]||{},this.isStale=!0;break;case"AUTOFILL_CELL":const i=this.getters.getActiveSheetId(),o=this.getters.getRulesByCell(i,e.originCol,e.originRow);for(const t of o)this.adaptRules(i,t,[Vt(e.col,e.row)],[]);break;case"PASTE_CONDITIONAL_FORMAT":this.pasteCf(e.origin,e.target,e.operation)}}finalize(){this.isStale&&(this.computeStyles(),this.isStale=!1)}getCellComputedStyle(e){var t;const{sheetId:i,col:o,row:n}=e,s=this.getters.getCell(e),r=this.computedStyles[i],a=r&&(null===(t=r[o])||void 0===t?void 0:t[n]),l={...null==s?void 0:s.style,...a};return this.getters.getEvaluatedCell(e).link&&!l.textColor&&(l.textColor=x),this.getters.isFilterHeader(e)&&(l.bold=!0),l}getConditionalIcon({col:e,row:t}){var i;const o=this.getters.getActiveSheetId(),n=this.computedIcons[o];return n&&(null===(i=n[e])||void 0===i?void 0:i[t])}computeStyles(){var e;const t=this.getters.getActiveSheetId();this.computedStyles[t]={},this.computedIcons[t]={};const i=this.computedStyles[t];for(let o of this.getters.getConditionalFormats(t).reverse())try{switch(o.rule.type){case"ColorScaleRule":for(let e of o.ranges)this.applyColorScale(e,o.rule);break;case"IconSetRule":for(let e of o.ranges)this.applyIcon(e,o.rule);break;default:for(let n of o.ranges){const s=this.getters.getRangeFromSheetXC(t,n).zone;for(let n=s.top;n<=s.bottom;n++)for(let r=s.left;r<=s.right;r++){const s=this.rulePredicate[o.rule.type];let a=this.getters.getEvaluatedCell({sheetId:t,col:r,row:n});s&&s(a,o.rule)&&(i[r]||(i[r]=[]),i[r][n]=Object.assign((null===(e=i[r])||void 0===e?void 0:e[n])||{},o.rule.style))}}}}catch(e){}}parsePoint(e,t,i){const o=this.getters.getActiveSheetId(),n=this.getters.getEvaluatedCellsInZone(o,this.getters.getRangeFromSheetXC(o,e).zone).filter((e=>e.type===So.number)).map((e=>e.value));switch(t.type){case"value":return"max"===i?Math.max(...n):Math.min(...n);case"number":return Number(t.value);case"percentage":const e=Math.min(...n);return e+(Math.max(...n)-e)*Number(t.value)/100;case"percentile":return Jt(n,Number(t.value)/100,!0);case"formula":const o=t.value&&this.getters.evaluateFormula(t.value);return o instanceof Promise?null:o;default:return null}}applyIcon(e,t){const i=this.parsePoint(e,t.lowerInflectionPoint),o=this.parsePoint(e,t.upperInflectionPoint);if(null===i||null===o||i>o)return;const n=this.getters.getActiveSheetId(),s=this.getters.getRangeFromSheetXC(n,e).zone,r=this.computedIcons[n],a=[t.icons.upper,t.icons.middle,t.icons.lower];for(let e=s.top;e<=s.bottom;e++)for(let l=s.left;l<=s.right;l++){const s=this.getters.getEvaluatedCell({sheetId:n,col:l,row:e});if(s.type!==So.number)continue;const c=this.computeIcon(s.value,o,t.upperInflectionPoint.operator,i,t.lowerInflectionPoint.operator,a);r[l]||(r[l]=[]),r[l][e]=c}}computeIcon(e,t,i,o,n,s){return"ge"===i&&e>=t||"gt"===i&&e>t?s[0]:"ge"===n&&e>=o||"gt"===n&&e>o?s[1]:s[2]}applyColorScale(e,t){var i;const o=this.parsePoint(e,t.minimum,"min"),n=t.midpoint?this.parsePoint(e,t.midpoint):null,s=this.parsePoint(e,t.maximum,"max");if(null===o||null===s||o>=s||n&&(o>=n||n>=s))return;const r=this.getters.getActiveSheetId(),a=this.getters.getRangeFromSheetXC(r,e).zone,l=this.computedStyles[r],c=[];t.midpoint&&n?(c.push({minValue:o,minColor:t.minimum.color,colorDiffUnit:this.computeColorDiffUnits(o,n,t.minimum.color,t.midpoint.color)}),c.push({minValue:n,minColor:t.midpoint.color,colorDiffUnit:this.computeColorDiffUnits(n,s,t.midpoint.color,t.maximum.color)})):c.push({minValue:o,minColor:t.minimum.color,colorDiffUnit:this.computeColorDiffUnits(o,s,t.minimum.color,t.maximum.color)});for(let e=a.top;e<=a.bottom;e++)for(let t=a.left;t<=a.right;t++){const a=this.getters.getEvaluatedCell({sheetId:r,col:t,row:e});if(a.type===So.number){const r=De(a.value,o,s);let h;h=2===c.length&&n?r<=n?this.colorCell(r,c[0].minValue,c[0].minColor,c[0].colorDiffUnit):this.colorCell(r,c[1].minValue,c[1].minColor,c[1].colorDiffUnit):this.colorCell(r,c[0].minValue,c[0].minColor,c[0].colorDiffUnit),l[t]||(l[t]=[]),l[t][e]=(null===(i=l[t])||void 0===i?void 0:i[e])||{},l[t][e].fillColor=mt(h)}}}computeColorDiffUnits(e,t,i,o){const n=t-e;return[((i>>16)%256-(o>>16)%256)/n,((i>>8)%256-(o>>8)%256)/n,(i%256-o%256)/n]}colorCell(e,t,i,o){const[n,s,r]=o;return Math.round((i>>16)%256-n*(e-t))<<16|Math.round((i>>8)%256-s*(e-t))<<8|Math.round(i%256-r*(e-t))}adaptRules(e,t,i,o){if(0===i.length&&0===o.length)return;const n=this.getters.getConditionalFormats(e),s=n.findIndex((e=>e.id===t.id));let r=[];s>-1&&(r=n[s].ranges),r=r.concat(i);const a=Gi(r,o);this.dispatch("ADD_CONDITIONAL_FORMAT",{cf:{id:t.id,rule:t.rule,stopIfTrue:t.stopIfTrue},ranges:a.map((t=>this.getters.getRangeDataFromXc(e,t))),sheetId:e})}pasteCf(e,t,i){const o=Vt(t.col,t.row);for(let n of this.getters.getConditionalFormats(e.sheetId))for(let s of n.ranges)if($i(e.col,e.row,this.getters.getRangeFromSheetXC(e.sheetId,s).zone)){const s=n,r=[];"CUT"===i&&r.push(Vt(e.col,e.row)),e.sheetId===t.sheetId?this.adaptRules(e.sheetId,s,[o],r):(this.adaptRules(t.sheetId,s,[o],[]),this.adaptRules(e.sheetId,s,[],r))}}}kv.getters=["getConditionalIcon","getCellComputedStyle"];class Lv extends Ov{constructor(){super(...arguments),this.filterValues={},this.hiddenRows=new Set,this.isEvaluationDirty=!1}allowDispatch(e){if("UPDATE_FILTER"===e.type)if(!this.getters.getFilterId(e))return 79;return 0}handle(e){switch(e.type){case"UNDO":case"REDO":case"UPDATE_CELL":case"EVALUATE_CELLS":case"ACTIVATE_SHEET":case"REMOVE_FILTER_TABLE":this.isEvaluationDirty=!0;break;case"START":for(const e of this.getters.getSheetIds()){this.filterValues[e]={};for(const t of this.getters.getFilters(e))this.filterValues[e][t.id]=[]}break;case"CREATE_SHEET":this.filterValues[e.sheetId]={};break;case"UPDATE_FILTER":this.updateFilter(e),this.updateHiddenRows();break;case"DUPLICATE_SHEET":const t={};for(const i of this.getters.getFilters(e.sheetIdTo)){const o=i.zoneWithHeaders;t[i.id]=this.getFilterValues({sheetId:e.sheetId,col:o.left,row:o.top})}this.filterValues[e.sheetIdTo]=t}}finalize(){this.isEvaluationDirty&&(this.updateHiddenRows(),this.isEvaluationDirty=!1)}isRowFiltered(e,t){return e===this.getters.getActiveSheetId()&&this.hiddenRows.has(t)}getCellBorderWithFilterBorder(e){const{sheetId:t,col:i,row:o}=e;let n;for(let e of this.getters.getFilterTables(t)){const s=e.zone;if($i(i,o,s)){const e=this.intersectZoneWithViewport(t,s);n={top:o===e.top?j:void 0,bottom:o===e.bottom?j:void 0,left:i===e.left?j:void 0,right:i===e.right?j:void 0}}}const s=this.getters.getCellBorder(e),r={...n,...lt(s||{})};return tt(r)?null:r}getFilterHeaders(e){const t=[];for(let i of this.getters.getFilterTables(e)){const o=i.zone;if(!o)continue;const n=o.top;for(let i=o.left;i<=o.right;i++)this.getters.isColHidden(e,i)||this.getters.isRowHidden(e,n)||t.push({col:i,row:n})}return t}getFilterValues(e){const t=this.getters.getFilterId(e),i=e.sheetId;return t&&this.filterValues[i]&&this.filterValues[i][t]||[]}isFilterHeader({sheetId:e,col:t,row:i}){return this.getFilterHeaders(e).some((e=>e.col===t&&e.row===i))}isFilterActive(e){var t,i;const o=this.getters.getFilterId(e),n=e.sheetId;return Boolean(o&&(null===(i=null===(t=this.filterValues[n])||void 0===t?void 0:t[o])||void 0===i?void 0:i.length))}intersectZoneWithViewport(e,t){const i=ze(t.left,t.right+1),o=ze(t.top,t.bottom+1);return{left:this.getters.findVisibleHeader(e,"COL",i),right:this.getters.findVisibleHeader(e,"COL",i.reverse()),top:this.getters.findVisibleHeader(e,"ROW",o),bottom:this.getters.findVisibleHeader(e,"ROW",o.reverse())}}updateFilter({col:e,row:t,values:i,sheetId:o}){const n=this.getters.getFilterId({sheetId:o,col:e,row:t});n&&(this.filterValues[o]||(this.filterValues[o]={}),this.filterValues[o][n]=i)}updateHiddenRows(){var e,t;const i=this.getters.getActiveSheetId(),o=this.getters.getFilters(i),n=new Set;for(let s of o){const o=null===(t=null===(e=this.filterValues[i])||void 0===e?void 0:e[s.id])||void 0===t?void 0:t.map(ct);if(o&&s.filteredZone)for(let e=s.filteredZone.top;e<=s.filteredZone.bottom;e++){const t=this.getCellValueAsString(i,s.col,e);o.includes(t)&&n.add(e)}}this.hiddenRows=n}getCellValueAsString(e,t,i){return this.getters.getEvaluatedCell({sheetId:e,col:t,row:i}).formattedValue.toLowerCase()}exportForExcel(e){for(const t of e.sheets)for(const e of t.filterTables){const i=_i(e.range),o=[],n=[];for(const e of ze(0,Zi(i).width)){const s={sheetId:t.id,col:i.left+e,row:i.top},r=this.getFilterValues(s),a=this.getters.getFilter(s);if(!a)continue;const l=(a.filteredZone?Xi(a.filteredZone).map((({col:e,row:i})=>this.getters.getEvaluatedCell({sheetId:t.id,col:e,row:i}))).filter((e=>e.type!==So.empty)).map((e=>e.formattedValue)):[]).filter((e=>!r.includes(e)));o.push({colId:e,filteredValues:[...new Set(l)]});const c={col:a.col,row:a.zoneWithHeaders.top,sheetId:t.id},h=this.getters.getEvaluatedCell(c).formattedValue,d=this.getUniqueColNameForExcel(e,h,n);n.push(d),t.cells[Vt(c.col,c.row)]={...t.cells[Vt(c.col,c.row)],content:d,value:d,isFormula:!1}}e.filters=o}}getUniqueColNameForExcel(e,t,i){t||(t=`Column${e}`);let o=t,n=2;for(;i.includes(o);)o=t+String(n),n++;return o}}Lv.getters=["getCellBorderWithFilterBorder","getFilterHeaders","getFilterValues","isFilterHeader","isRowFiltered","isFilterActive"];class Pv{constructor(e,t,i,o,n,s){this.getters=e,this.sheetId=t,this.boundaries=i,this.width=o.width,this.height=o.height,this.offsetScrollbarX=s.x,this.offsetScrollbarY=s.y,this.canScrollVertically=n.canScrollVertically,this.canScrollHorizontally=n.canScrollHorizontally,this.offsetCorrectionX=this.getters.getColDimensions(this.sheetId,this.boundaries.left).start,this.offsetCorrectionY=this.getters.getRowDimensions(this.sheetId,this.boundaries.top).start,this.adjustViewportOffsetX(),this.adjustViewportOffsetY()}getMaxSize(){const e=this.getters.findLastVisibleColRowIndex(this.sheetId,"COL",{first:this.boundaries.left,last:this.boundaries.right}),t=this.getters.findLastVisibleColRowIndex(this.sheetId,"ROW",{first:this.boundaries.top,last:this.boundaries.bottom}),{end:i,size:o}=this.getters.getColDimensions(this.sheetId,e),{end:n,size:s}=this.getters.getRowDimensions(this.sheetId,t),r=this.searchHeaderIndex("COL",i-this.width,0),a=this.getters.getColSize(this.sheetId,r),l=this.searchHeaderIndex("ROW",n-this.height,0),c=this.getters.getRowSize(this.sheetId,l);return{width:i-this.offsetCorrectionX+(this.canScrollHorizontally?Math.max(_,Math.min(a,this.width-o)):0),height:n-this.offsetCorrectionY+(this.canScrollVertically?Math.max(F+5,Math.min(c,this.height-s)):0)}}getColIndex(e,t=!1){return e<this.offsetCorrectionX||e>this.offsetCorrectionX+this.width?-1:this.searchHeaderIndex("COL",e-this.offsetCorrectionX,this.left,t)}getRowIndex(e,t=!1){return e<this.offsetCorrectionY||e>this.offsetCorrectionY+this.height?-1:this.searchHeaderIndex("ROW",e-this.offsetCorrectionY,this.top,t)}adjustPosition(e){const t=this.sheetId;e||(e=this.getters.getSheetPosition(t));const i=this.getters.getMainCellPosition({sheetId:t,...e}),{col:o,row:n}=this.getters.getNextVisibleCellPosition(i);$i(o,this.boundaries.top,this.boundaries)&&this.adjustPositionX(o),$i(this.boundaries.left,n,this.boundaries)&&this.adjustPositionY(n)}adjustPositionX(e){const t=this.sheetId,{start:i,end:o}=this.getters.getColDimensions(t,e);for(;o>this.offsetX+this.offsetCorrectionX+this.width&&this.offsetX+this.offsetCorrectionX<i;)this.offsetX=this.getters.getColDimensions(t,this.left).end-this.offsetCorrectionX,this.offsetScrollbarX=this.offsetX,this.adjustViewportZoneX();for(;e<this.left;){let e;for(e=this.left;e>=0&&this.getters.isColHidden(t,e);e--);this.offsetX=this.getters.getColDimensions(t,e-1).start-this.offsetCorrectionX,this.offsetScrollbarX=this.offsetX,this.adjustViewportZoneX()}}adjustPositionY(e){const t=this.sheetId;for(;this.getters.getRowDimensions(t,e).end>this.offsetY+this.height+this.offsetCorrectionY&&this.offsetY+this.offsetCorrectionY<this.getters.getRowDimensions(t,e).start;)this.offsetY=this.getters.getRowDimensions(t,this.top).end-this.offsetCorrectionY,this.offsetScrollbarY=this.offsetY,this.adjustViewportZoneY();for(;e<this.top;){let e;for(e=this.top;e>=0&&this.getters.isRowHidden(t,e);e--);this.offsetY=this.getters.getRowDimensions(t,e-1).start-this.offsetCorrectionY,this.offsetScrollbarY=this.offsetY,this.adjustViewportZoneY()}}setViewportOffset(e,t){this.setViewportOffsetX(e),this.setViewportOffsetY(t)}adjustViewportZone(){this.adjustViewportZoneX(),this.adjustViewportZoneY()}getRect(e){const t=zi(e,this.zone);if(t){return{x:this.getters.getColRowOffset("COL",this.zone.left,t.left)+this.offsetCorrectionX,y:this.getters.getColRowOffset("ROW",this.zone.top,t.top)+this.offsetCorrectionY,width:Math.min(this.getters.getColRowOffset("COL",t.left,t.right+1),this.width),height:Math.min(this.getters.getColRowOffset("ROW",t.top,t.bottom+1),this.height)}}}isVisible(e,t){return t<=this.bottom&&t>=this.top&&e>=this.left&&e<=this.right&&!this.getters.isColHidden(this.sheetId,e)&&!this.getters.isRowHidden(this.sheetId,t)}searchHeaderIndex(e,t,i=0,o=!1){let n=0;const s=this.sheetId,r=this.getters.getNumberHeaders(s,e);for(let a=i;a<=r-1;a++){const i=o||"COL"!==e?a<this.top&&a>this.bottom:a<this.left&&a>this.right;if(!this.getters.isHeaderHidden(s,e,a)&&!i&&(n+="COL"===e?this.getters.getColSize(s,a):this.getters.getRowSize(s,a),n>t))return a}return-1}get zone(){return{left:this.left,right:this.right,top:this.top,bottom:this.bottom}}setViewportOffsetX(e){this.canScrollHorizontally&&(this.offsetScrollbarX=e,this.adjustViewportZoneX())}setViewportOffsetY(e){this.canScrollVertically&&(this.offsetScrollbarY=e,this.adjustViewportZoneY())}adjustViewportOffsetX(){if(this.canScrollHorizontally){const{width:e}=this.getMaxSize();this.width+this.offsetScrollbarX>e&&(this.offsetScrollbarX=Math.max(0,e-this.width))}this.left=this.getColIndex(this.offsetScrollbarX,!0),this.right=this.getColIndex(this.offsetScrollbarX+this.width,!0),-1===this.right&&(this.right=this.boundaries.right),this.adjustViewportZoneX()}adjustViewportOffsetY(){if(this.canScrollVertically){const{height:e}=this.getMaxSize();this.height+this.offsetScrollbarY>e&&(this.offsetScrollbarY=Math.max(0,e-this.height))}this.top=this.getRowIndex(this.offsetScrollbarY,!0),this.bottom=this.getRowIndex(this.offsetScrollbarY+this.width,!0),-1===this.bottom&&(this.bottom=this.boundaries.bottom),this.adjustViewportZoneY()}adjustViewportZoneX(){const e=this.sheetId;this.left=this.searchHeaderIndex("COL",this.offsetScrollbarX,this.boundaries.left),this.right=Math.min(this.boundaries.right,this.searchHeaderIndex("COL",this.width,this.left)),-1===this.right&&(this.right=this.getters.getNumberCols(e)-1),this.offsetX=this.getters.getColDimensions(e,this.left).start-this.getters.getColDimensions(e,this.boundaries.left).start}adjustViewportZoneY(){const e=this.sheetId;this.top=this.searchHeaderIndex("ROW",this.offsetScrollbarY,this.boundaries.top),this.bottom=Math.min(this.boundaries.bottom,this.searchHeaderIndex("ROW",this.height,this.top)),-1===this.bottom&&(this.bottom=this.getters.getNumberRows(e)-1),this.offsetY=this.getters.getRowDimensions(e,this.top).start-this.getters.getRowDimensions(e,this.boundaries.top).start}}class Uv extends Ov{constructor(){super(...arguments),this.viewports={},this.sheetViewWidth=1e3,this.sheetViewHeight=1e3,this.gridOffsetX=0,this.gridOffsetY=0,this.sheetsWithDirtyViewports=new Set}allowDispatch(e){switch(e.type){case"SET_VIEWPORT_OFFSET":return this.checkScrollingDirection(e);case"RESIZE_SHEETVIEW":return this.chainValidations(this.checkValuesAreDifferent,this.checkPositiveDimension)(e);default:return 0}}handleEvent(e){switch(e.type){case"HeadersSelected":case"AlterZone":break;case"ZonesSelected":let{col:t,row:i}=Ki(e.previousAnchor.zone,e.anchor.zone);if("updateAnchor"===e.mode){const o=e.previousAnchor.zone,n=e.anchor.zone,{top:s,bottom:r,left:a,right:l}=this.getters.getActiveMainViewport();o.left===n.left&&o.right===n.right&&(t=a>t||t>l?a:t),o.top===n.top&&o.bottom===n.bottom&&(i=s>i||i>r?s:i)}const o=this.getters.getActiveSheetId();t=Math.min(t,this.getters.getNumberCols(o)-1),i=Math.min(i,this.getters.getNumberRows(o)-1),this.refreshViewport(this.getters.getActiveSheetId(),{col:t,row:i})}}handle(e){var t;switch(this.cleanViewports(),e.type){case"START":this.selection.observe(this,{handleEvent:this.handleEvent.bind(this)}),this.resetViewports(this.getters.getActiveSheetId());break;case"UNDO":case"REDO":this.resetSheetViews();break;case"RESIZE_SHEETVIEW":this.resizeSheetView(e.height,e.width,e.gridOffsetX,e.gridOffsetY);break;case"SET_VIEWPORT_OFFSET":this.setSheetViewOffset(e.offsetX,e.offsetY);break;case"SHIFT_VIEWPORT_DOWN":const{top:i}=this.getActiveMainViewport(),o=this.getters.getActiveSheetId(),n=this.clipOffsetY(this.getters.getRowDimensions(o,i).start+this.sheetViewHeight);this.shiftVertically(n);break;case"SHIFT_VIEWPORT_UP":{const{top:e}=this.getActiveMainViewport(),t=this.getters.getActiveSheetId(),i=this.clipOffsetY(this.getters.getRowDimensions(t,e).end-this.sheetViewHeight);this.shiftVertically(i);break}case"REMOVE_COLUMNS_ROWS":case"RESIZE_COLUMNS_ROWS":case"HIDE_COLUMNS_ROWS":case"ADD_COLUMNS_ROWS":case"UNHIDE_COLUMNS_ROWS":case"UPDATE_FILTER":this.resetViewports(e.sheetId);break;case"UPDATE_CELL":("content"in e||"format"in e||void 0!==(null===(t=e.style)||void 0===t?void 0:t.fontSize))&&this.sheetsWithDirtyViewports.add(e.sheetId);break;case"ACTIVATE_SHEET":this.setViewports(),this.refreshViewport(e.sheetIdTo);break;case"UNFREEZE_ROWS":case"UNFREEZE_COLUMNS":case"FREEZE_COLUMNS":case"FREEZE_ROWS":case"UNFREEZE_COLUMNS_ROWS":this.resetViewports(this.getters.getActiveSheetId());break;case"DELETE_SHEET":this.sheetsWithDirtyViewports.delete(e.sheetId);break;case"START_EDITION":const{col:s,row:r}=this.getters.getActivePosition();this.refreshViewport(this.getters.getActiveSheetId(),{col:s,row:r})}}finalize(){for(const e of this.sheetsWithDirtyViewports)this.resetViewports(e);this.sheetsWithDirtyViewports=new Set,this.setViewports()}setViewports(){var e;const t=this.getters.getSheetIds();for(const i of t)(null===(e=this.viewports[i])||void 0===e?void 0:e.bottomRight)||this.resetViewports(i)}getColIndex(e){const t=this.getters.getActiveSheetId();return Math.max(...this.getSubViewports(t).map((t=>t.getColIndex(e))))}getRowIndex(e){const t=this.getters.getActiveSheetId();return Math.max(...this.getSubViewports(t).map((t=>t.getRowIndex(e))))}getSheetViewDimensionWithHeaders(){return{width:this.sheetViewWidth+this.gridOffsetX,height:this.sheetViewHeight+this.gridOffsetY}}getSheetViewDimension(){return{width:this.sheetViewWidth,height:this.sheetViewHeight}}getActiveMainViewport(){const e=this.getters.getActiveSheetId();return this.getMainViewport(e)}getActiveSheetScrollInfo(){const e=this.getters.getActiveSheetId(),t=this.getMainInternalViewport(e);return{scrollX:t.offsetX,scrollY:t.offsetY}}getActiveSheetDOMScrollInfo(){const e=this.getters.getActiveSheetId(),t=this.getMainInternalViewport(e);return{scrollX:t.offsetScrollbarX,scrollY:t.offsetScrollbarY}}getSheetViewVisibleCols(){const e=this.getters.getActiveSheetId(),t=this.getSubViewports(e);return[...new Set(t.map((e=>ze(e.left,e.right+1))).flat())].filter((t=>!this.getters.isHeaderHidden(e,"COL",t)))}getSheetViewVisibleRows(){const e=this.getters.getActiveSheetId(),t=this.getSubViewports(e);return[...new Set(t.map((e=>ze(e.top,e.bottom+1))).flat())].filter((t=>!this.getters.isHeaderHidden(e,"ROW",t)))}getMainViewportRect(){const e=this.getters.getActiveSheetId(),t=this.getMainInternalViewport(e),{xSplit:i,ySplit:o}=this.getters.getPaneDivisions(e);let{width:n,height:s}=t.getMaxSize();return{x:this.getters.getColDimensions(e,i).start,y:this.getters.getRowDimensions(e,o).start,width:n,height:s}}getMaximumSheetOffset(){const e=this.getters.getActiveSheetId(),{width:t,height:i}=this.getMainViewportRect(),o=this.getMainInternalViewport(e);return{maxOffsetX:Math.max(0,t-o.width+1),maxOffsetY:Math.max(0,i-o.height+1)}}getColRowOffsetInViewport(e,t,i){const o=this.getters.getActiveSheetId(),n=this.getters.getSheetViewVisibleCols(),s=this.getters.getSheetViewVisibleRows();if(i<t)return-this.getColRowOffsetInViewport(e,i,t);let r=0;const a="COL"===e?n:s;for(let n=t;n<i;n++)a.includes(n)&&(r+="COL"===e?this.getters.getColSize(o,n):this.getters.getRowSize(o,n));return r}isVisibleInViewport({sheetId:e,col:t,row:i}){return this.getSubViewports(e).some((e=>e.isVisible(t,i)))}getEdgeScrollCol(e,t,i){let o=!1,n=0,s=0;const{xSplit:r}=this.getters.getPaneDivisions(this.getters.getActiveSheetId()),{width:a}=this.getSheetViewDimension(),{x:l}=this.getMainViewportCoordinates(),c=this.getActiveSheetScrollInfo().scrollX;return e>a?(o=!0,s=$t(e-a),n=1):e<l&&i>=l&&c>0?(o=!0,s=$t(l-e),n=-1):r&&t<l&&e>l&&(o=!0,s=$t(e),n="reset"),{canEdgeScroll:o,direction:n,delay:s}}getEdgeScrollRow(e,t,i){let o=!1,n=0,s=0;const{ySplit:r}=this.getters.getPaneDivisions(this.getters.getActiveSheetId()),{height:a}=this.getSheetViewDimension(),{y:l}=this.getMainViewportCoordinates(),c=this.getActiveSheetScrollInfo().scrollY;return e>a?(o=!0,s=$t(e-a),n=1):e<l&&i>=l&&c>0?(o=!0,s=$t(l-e),n=-1):r&&t<l&&e>l&&(o=!0,s=$t(e),n="reset"),{canEdgeScroll:o,direction:n,delay:s}}getVisibleRect(e){const t=this.getters.getActiveSheetId(),i=this.getSubViewports(t).map((t=>t.getRect(e))).filter(et);if(0===i.length)return{x:0,y:0,width:0,height:0};const o=Math.min(...i.map((e=>e.x))),n=Math.min(...i.map((e=>e.y))),s=Math.max(...i.map((e=>e.x+e.width)))-o,r=Math.max(...i.map((e=>e.y+e.height)))-n;return{x:o+this.gridOffsetX,y:n+this.gridOffsetY,width:s,height:r}}getMainViewportCoordinates(){const e=this.getters.getActiveSheetId(),{xSplit:t,ySplit:i}=this.getters.getPaneDivisions(e);return{x:this.getters.getColDimensions(e,t).start,y:this.getters.getRowDimensions(e,i).start}}ensureMainViewportExist(e){this.viewports[e]||this.resetViewports(e)}getSubViewports(e){return this.ensureMainViewportExist(e),Object.values(this.viewports[e]).filter(et)}checkPositiveDimension(e){return e.width<0||e.height<0?68:0}checkValuesAreDifferent(e){const{height:t,width:i}=this.getSheetViewDimension();return e.gridOffsetX===this.gridOffsetX&&e.gridOffsetY===this.gridOffsetY&&e.width===i&&e.height===t?76:0}checkScrollingDirection({offsetX:e,offsetY:t}){const i=this.getMainInternalViewport(this.getters.getActiveSheetId());return!i.canScrollHorizontally&&e>0||!i.canScrollVertically&&t>0?69:0}getMainViewport(e){const t=this.getMainInternalViewport(e);return{top:t.top,left:t.left,bottom:t.bottom,right:t.right}}getMainInternalViewport(e){return this.ensureMainViewportExist(e),this.viewports[e].bottomRight}cleanViewports(){const e=this.getters.getSheetIds();for(let t of Object.keys(this.viewports))e.includes(t)||delete this.viewports[t]}resetSheetViews(){for(let e of Object.keys(this.viewports)){const t=this.getters.getSheetPosition(e);this.resetViewports(e);const i=this.getSubViewports(e);Object.values(i).forEach((e=>{e.adjustPosition(t)}))}}resizeSheetView(e,t,i=0,o=0){this.sheetViewHeight=e,this.sheetViewWidth=t,this.gridOffsetX=i,this.gridOffsetY=o,this.recomputeViewports()}recomputeViewports(){for(let e of Object.keys(this.viewports))this.resetViewports(e)}setSheetViewOffset(e,t){const i=this.getters.getActiveSheetId(),{maxOffsetX:o,maxOffsetY:n}=this.getMaximumSheetOffset();Object.values(this.getSubViewports(i)).forEach((i=>i.setViewportOffset(De(e,0,o),De(t,0,n))))}clipOffsetY(e){const{height:t}=this.getMainViewportRect(),i=t-this.sheetViewHeight;return e=Math.min(e,i),e=Math.max(e,0)}getViewportOffset(e){var t,i;return{x:(null===(t=this.viewports[e])||void 0===t?void 0:t.bottomRight.offsetScrollbarX)||0,y:(null===(i=this.viewports[e])||void 0===i?void 0:i.bottomRight.offsetScrollbarY)||0}}resetViewports(e){if(!this.getters.tryGetSheet(e))return;const{xSplit:t,ySplit:i}=this.getters.getPaneDivisions(e),o=this.getters.getNumberCols(e),n=this.getters.getNumberRows(e),s=this.getters.getColRowOffset("COL",0,t,e),r=this.getters.getColRowOffset("ROW",0,i,e),{xRatio:a,yRatio:l}=this.getFrozenSheetViewRatio(e),c=a<1,h=l<1,d=this.getViewportOffset(e),u={topLeft:i&&t&&new Pv(this.getters,e,{left:0,right:t-1,top:0,bottom:i-1},{width:s,height:r},{canScrollHorizontally:!1,canScrollVertically:!1},{x:0,y:0})||void 0,topRight:i&&new Pv(this.getters,e,{left:t,right:o-1,top:0,bottom:i-1},{width:this.sheetViewWidth-s,height:r},{canScrollHorizontally:c,canScrollVertically:!1},{x:c?d.x:0,y:0})||void 0,bottomLeft:t&&new Pv(this.getters,e,{left:0,right:t-1,top:i,bottom:n-1},{width:s,height:this.sheetViewHeight-r},{canScrollHorizontally:!1,canScrollVertically:h},{x:0,y:h?d.y:0})||void 0,bottomRight:new Pv(this.getters,e,{left:t,right:o-1,top:i,bottom:n-1},{width:this.sheetViewWidth-s,height:this.sheetViewHeight-r},{canScrollHorizontally:c,canScrollVertically:h},{x:c?d.x:0,y:h?d.y:0})};this.viewports[e]=u}refreshViewport(e,t){Object.values(this.getSubViewports(e)).forEach((e=>{e.adjustViewportZone(),e.adjustPosition(t)}))}shiftVertically(e){const{top:t}=this.getActiveMainViewport(),{scrollX:i}=this.getActiveSheetScrollInfo();this.setSheetViewOffset(i,e);const{anchor:o}=this.getters.getSelection(),n=this.getActiveMainViewport().top-t;this.selection.selectCell(o.cell.col,o.cell.row+n)}getVisibleFigures(){const e=this.getters.getActiveSheetId(),t=[],i=this.getters.getFigures(e),{scrollX:o,scrollY:n}=this.getActiveSheetScrollInfo(),{x:s,y:r}=this.getters.getMainViewportCoordinates(),{width:a,height:l}=this.getters.getSheetViewDimensionWithHeaders();for(const e of i)e.x>=s&&(e.x+e.width<=s+o||e.x>=a+o+s)||e.y>=r&&(e.y+e.height<=r+n||e.y>=l+n+r)||t.push(e);return t}getFrozenSheetViewRatio(e){const{xSplit:t,ySplit:i}=this.getters.getPaneDivisions(e),o=this.getters.getColDimensions(e,t).start,n=this.getters.getRowDimensions(e,i).start;return{xRatio:o/(this.sheetViewWidth+this.gridOffsetX),yRatio:n/(this.sheetViewHeight+this.gridOffsetY)}}}Uv.getters=["getColIndex","getRowIndex","getActiveMainViewport","getSheetViewDimension","getSheetViewDimensionWithHeaders","getMainViewportRect","isVisibleInViewport","getEdgeScrollCol","getEdgeScrollRow","getVisibleFigures","getVisibleRect","getColRowOffsetInViewport","getMainViewportCoordinates","getActiveSheetScrollInfo","getActiveSheetDOMScrollInfo","getSheetViewVisibleCols","getSheetViewVisibleRows","getFrozenSheetViewRatio"];class Vv{constructor(e,t,i){this.index=0,this.cells=e,this.getters=t,this.direction=i}next(){const e=this.cells[this.index++%this.cells.length],t=e.rule,{cellData:i,tooltip:o}=Lu.get(t.type).apply(t,e.data,this.getters,this.direction);return{cellData:i,tooltip:o,origin:{col:e.data.col,row:e.data.row}}}}class zv extends Ov{constructor(){super(...arguments),this.lastCellSelected={}}allowDispatch(e){switch(e.type){case"AUTOFILL_SELECT":const t=this.getters.getActiveSheetId();return this.lastCellSelected.col=-1===e.col?this.lastCellSelected.col:De(e.col,0,this.getters.getNumberCols(t)),this.lastCellSelected.row=-1===e.row?this.lastCellSelected.row:De(e.row,0,this.getters.getNumberRows(t)),void 0!==this.lastCellSelected.col&&void 0!==this.lastCellSelected.row?0:45;case"AUTOFILL_AUTO":const i=this.getters.getSelectedZone();return i.top===i.bottom?0:1}return 0}handle(e){switch(e.type){case"AUTOFILL":this.autofill(!0);break;case"AUTOFILL_SELECT":this.select(e.col,e.row);break;case"AUTOFILL_AUTO":this.autofillAuto();break;case"AUTOFILL_CELL":this.autoFillMerge(e.originCol,e.originRow,e.col,e.row);const t=this.getters.getActiveSheetId();this.dispatch("UPDATE_CELL",{sheetId:t,col:e.col,row:e.row,style:e.style||null,content:e.content||"",format:e.format||""}),this.dispatch("SET_BORDER",{sheetId:t,col:e.col,row:e.row,border:e.border})}}getAutofillTooltip(){return this.tooltip}autofill(e){if(!this.autofillZone||!this.steps||void 0===this.direction)return void(this.tooltip=void 0);const t=this.getters.getSelectedZone(),i=this.autofillZone;switch(this.direction){case"down":for(let o=t.left;o<=t.right;o++){const n=[];for(let e=t.top;e<=t.bottom;e++)n.push(Vt(o,e));const s=this.createGenerator(n);for(let t=i.top;t<=i.bottom;t++)this.computeNewCell(s,o,t,e)}break;case"up":for(let o=t.left;o<=t.right;o++){const n=[];for(let e=t.bottom;e>=t.top;e--)n.push(Vt(o,e));const s=this.createGenerator(n);for(let t=i.bottom;t>=i.top;t--)this.computeNewCell(s,o,t,e)}break;case"left":for(let o=t.top;o<=t.bottom;o++){const n=[];for(let e=t.right;e>=t.left;e--)n.push(Vt(e,o));const s=this.createGenerator(n);for(let t=i.right;t>=i.left;t--)this.computeNewCell(s,t,o,e)}break;case"right":for(let o=t.top;o<=t.bottom;o++){const n=[];for(let e=t.left;e<=t.right;e++)n.push(Vt(e,o));const s=this.createGenerator(n);for(let t=i.left;t<=i.right;t++)this.computeNewCell(s,t,o,e)}}e&&(this.autofillZone=void 0,this.selection.resizeAnchorZone(this.direction,this.steps),this.lastCellSelected={},this.direction=void 0,this.steps=0,this.tooltip=void 0)}select(e,t){const i=this.getters.getSelectedZone();if($i(e,t,i))this.autofillZone=void 0;else{switch(this.direction=this.getDirection(e,t),this.direction){case"up":this.saveZone(t,i.top-1,i.left,i.right),this.steps=i.top-t;break;case"down":this.saveZone(i.bottom+1,t,i.left,i.right),this.steps=t-i.bottom;break;case"left":this.saveZone(i.top,i.bottom,e,i.left-1),this.steps=i.left-e;break;case"right":this.saveZone(i.top,i.bottom,i.right+1,e),this.steps=e-i.right}this.autofill(!1)}}autofillAuto(){const e=this.getters.getSelectedZone(),t=this.getters.getActiveSheetId();let i=e.left,o=e.bottom;if(i>0){let e=this.getters.getEvaluatedCell({sheetId:t,col:i-1,row:o});for(;e.type!==So.empty;)o+=1,e=this.getters.getEvaluatedCell({sheetId:t,col:i-1,row:o})}if(o===e.bottom&&(i=e.right,i<=this.getters.getNumberCols(t))){let e=this.getters.getEvaluatedCell({sheetId:t,col:i+1,row:o});for(;e.type!==So.empty;)o+=1,e=this.getters.getEvaluatedCell({sheetId:t,col:i+1,row:o})}o!==e.bottom&&(this.select(e.left,o-1),this.autofill(!0))}computeNewCell(e,t,i,o){const{cellData:n,tooltip:s,origin:r}=e.next(),{content:a,style:l,border:c,format:h}=n;this.tooltip=s,o&&this.dispatch("AUTOFILL_CELL",{originCol:r.col,originRow:r.row,col:t,row:i,content:a,style:l,border:c,format:h})}getRule(e,t){const i=Pu.getAll().sort(((e,t)=>e.sequence-t.sequence)).find((i=>i.condition(e,t)));return i&&i.generateRule(e,t)}createGenerator(e){const t=[],i=[],o=this.getters.getActiveSheetId();for(let t of e){const{col:e,row:n}=Ut(t),s=this.getters.getCell({sheetId:o,col:e,row:n});i.push({col:e,row:n,cell:s,sheetId:o})}const n=i.map((e=>e.cell));for(let e of i){let i={type:"COPY_MODIFIER"};if(e&&e.cell){i=this.getRule(e.cell,n)||i}const o=this.getters.getCellBorder(e)||void 0;t.push({data:{...e,border:o},rule:i})}return new Vv(t,this.getters,this.direction)}saveZone(e,t,i,o){this.autofillZone={top:e,bottom:t,left:i,right:o}}getDirection(e,t){const i=this.getters.getSelectedZone(),o={up:{number:i.top-t,value:"up"},down:{number:t-i.bottom,value:"down"},left:{number:i.left-e,value:"left"},right:{number:e-i.right,value:"right"}};if(1===Object.values(o).map((e=>e.number>0?1:0)).reduce(((e,t)=>e+t)))return Object.values(o).find((e=>e.number>0?1:0)).value;const n=o.up.number>0?"up":"down",s=o.left.number>0?"left":"right";return Math.abs(o[n].number)>=Math.abs(o[s].number)?o[n].value:o[s].value}autoFillMerge(e,t,i,o){const n=this.getters.getActiveSheetId(),s={sheetId:n,col:i,row:o},r={sheetId:n,col:e,row:t};if(this.getters.isInMerge(s)&&!this.getters.isInMerge(r)){const e=this.getters.getMerge(s);e&&this.dispatch("REMOVE_MERGE",{sheetId:n,target:[e]})}const a=this.getters.getMerge(r);(null==a?void 0:a.topLeft.col)===e&&(null==a?void 0:a.topLeft.row)===t&&this.dispatch("ADD_MERGE",{sheetId:n,target:[{top:o,bottom:o+a.bottom-a.top,left:i,right:i+a.right-a.left}]})}drawGrid(e){if(!this.autofillZone)return;const{ctx:t,thinLineWidth:i}=e,{x:o,y:n,width:s,height:r}=this.getters.getVisibleRect(this.autofillZone);s>0&&r>0&&(t.strokeStyle="black",t.lineWidth=i,t.setLineDash([3]),t.strokeRect(o,n,s,r),t.setLineDash([]))}}zv.layers=[5],zv.getters=["getAutofillTooltip"];class Bv extends Ov{handle(e){if("SUM_SELECTION"===e.type){const e=this.getters.getActiveSheetId(),{zones:t,anchor:i}=this.getters.getSelection();for(const o of t){const t=this.getAutomaticSums(e,o,i.cell);this.dispatchCellUpdates(e,t)}}}getAutomaticSums(e,t,i){return this.shouldFindData(e,t)?this.sumAdjacentData(e,t,i):this.sumData(e,t)}sumData(e,t){const i=this.dimensionsToSum(e,t),o=this.sumDimensions(e,t,i).filter((({zone:t})=>!this.getters.isEmpty(e,t)));return i.has("ROW")&&i.has("COL")&&o.push(this.sumTotal(t)),o}sumAdjacentData(e,t,i){const{col:o,row:n}=$i(i.col,i.row,t)?i:{col:t.left,row:t.top},s=this.findAdjacentData(e,o,n);return s?this.getters.isSingleCellOrMerge(e,t)||ji(Vi(s,t))?[{position:{col:o,row:n},zone:s}]:this.sumDimensions(e,Vi(s,t),this.transpose(this.dimensionsToSum(e,t))):[]}findAdjacentData(e,t,i){const o=this.getters.getSheet(e),n=this.getters.getMainCellPosition({sheetId:e,col:t,row:i}),s=this.findSuitableZoneToSum(o,n.col,n.row);if(s)return this.getters.expandZone(e,s)}findSuitableZoneToSum(e,t,i){const o=this.getters.getEvaluatedCell({sheetId:e.id,col:t,row:i-1}),n=this.getters.getEvaluatedCell({sheetId:e.id,col:t-1,row:i});if(this.isNumber(n)&&!this.isNumber(o))return this.findHorizontalZone(e,t,i);const s=this.findVerticalZone(e,t,i);if(this.isZoneValid(s))return s;const r=this.findHorizontalZone(e,t,i);return this.isZoneValid(r)?r:void 0}findVerticalZone(e,t,i){const o={top:0,bottom:i-1,left:t,right:t},n=this.reduceZoneStart(e,o,o.bottom);return{...o,top:n}}findHorizontalZone(e,t,i){const o={top:i,bottom:i,left:0,right:t-1},n=this.reduceZoneStart(e,o,o.right);return{...o,left:n}}reduceZoneStart(e,t,i){const o=this.getters.getEvaluatedCellsInZone(e.id,t),n=ze(i,-1,-1),s=n.filter((e=>o[e]&&!o[e].isAutoSummable)),r=Math.max(...s),a=Be(n.filter((e=>this.isNumber(o[e]))))[0]||[];return Math.max(...a)<r?1/0:Math.min(...a)}shouldFindData(e,t){return this.getters.isEmpty(e,t)||this.getters.isSingleCellOrMerge(e,t)}isNumber(e){var t;return e.type===So.number&&!(null===(t=e.format)||void 0===t?void 0:t.match(X))}isZoneValid(e){return e.bottom>=e.top&&e.right>=e.left}lastColIsEmpty(e,t){return this.getters.isEmpty(e,{...t,left:t.right})}lastRowIsEmpty(e,t){return this.getters.isEmpty(e,{...t,top:t.bottom})}dimensionsToSum(e,t){const i=new Set;return ji(t)?(i.add(1===Zi(t).width?"COL":"ROW"),i):(this.lastColIsEmpty(e,t)&&i.add("ROW"),this.lastRowIsEmpty(e,t)&&i.add("COL"),0===i.size&&i.add("COL"),i)}sumDimensions(e,t,i){return[...i.has("COL")?this.sumColumns(t,e):[],...i.has("ROW")?this.sumRows(t,e):[]]}sumTotal(e){const{bottom:t,right:i}=e;return{position:{col:i,row:t},zone:{...e,top:t,right:i-1}}}sumColumns(e,t){const i=this.nextEmptyRow(t,{...e,bottom:e.bottom-1});return e={...e,bottom:Math.min(e.bottom,i.bottom-1)},Xi(i).map((t=>({position:t,zone:{...e,right:t.col,left:t.col}})))}sumRows(e,t){const i=this.nextEmptyCol(t,{...e,right:e.right-1});return e={...e,right:Math.min(e.right,i.right-1)},Xi(i).map((t=>({position:t,zone:{...e,top:t.row,bottom:t.row}})))}dispatchCellUpdates(e,t){for(const i of t){const{col:t,row:o}=i.position;this.dispatch("UPDATE_CELL",{sheetId:e,col:t,row:o,content:`=SUM(${this.getters.zoneToXC(e,i.zone)})`})}}nextEmptyRow(e,t){let i=t.bottom+1;const{left:o,right:n}=t;for(;!this.getters.isEmpty(e,{bottom:i,top:i,left:o,right:n});)i++;return{...t,top:i,bottom:i}}nextEmptyCol(e,t){let i=t.right+1;const{top:o,bottom:n}=t;for(;!this.getters.isEmpty(e,{left:i,right:i,top:o,bottom:n});)i++;return{...t,left:i,right:i}}transpose(e){return new Set([...e.values()].map((e=>"COL"===e?"ROW":"COL")))}}Bv.getters=["getAutomaticSums"];class Hv extends Ov{allowDispatch(e){if("OPEN_CELL_POPOVER"===e.type){try{eg.get(e.popoverType)}catch(e){return 72}return 0}return 0}handle(e){switch(e.type){case"ACTIVATE_SHEET":case"CLOSE_CELL_POPOVER":this.persistentPopover=void 0;break;case"OPEN_CELL_POPOVER":this.persistentPopover={col:e.col,row:e.row,sheetId:this.getters.getActiveSheetId(),type:e.popoverType}}}getCellPopover({col:e,row:t}){var i,o;const n=this.getters.getActiveSheetId();if(this.persistentPopover&&this.getters.isVisibleInViewport(this.persistentPopover)){const e=this.getters.getMainCellPosition(this.persistentPopover),t=null===(o=(i=eg.get(this.persistentPopover.type)).onOpen)||void 0===o?void 0:o.call(i,e,this.getters);return(null==t?void 0:t.isOpen)?{...t,anchorRect:this.computePopoverAnchorRect(this.persistentPopover)}:{isOpen:!1}}if(void 0===e||void 0===t||!this.getters.isVisibleInViewport({sheetId:n,col:e,row:t}))return{isOpen:!1};const s=this.getters.getMainCellPosition({sheetId:n,col:e,row:t}),r=eg.getAll().map((e=>{var t;return null===(t=e.onHover)||void 0===t?void 0:t.call(e,s,this.getters)})).find((e=>null==e?void 0:e.isOpen));return(null==r?void 0:r.isOpen)?{...r,anchorRect:this.computePopoverAnchorRect(s)}:{isOpen:!1}}hasOpenedPopover(){return void 0!==this.persistentPopover}getPersistentPopoverTypeAtPosition({col:e,row:t}){if(this.persistentPopover&&this.persistentPopover.col===e&&this.persistentPopover.row===t)return this.persistentPopover.type}computePopoverAnchorRect({col:e,row:t}){const i=this.getters.getActiveSheetId(),o=this.getters.getMerge({sheetId:i,col:e,row:t});return o?this.getters.getVisibleRect(o):this.getters.getVisibleRect(Ji({col:e,row:t}))}}Hv.getters=["getCellPopover","getPersistentPopoverTypeAtPosition","hasOpenedPopover"];var $v;!function(e){e[e.previous=-1]="previous",e[e.current=0]="current",e[e.next=1]="next"}($v||($v={}));class Wv extends Ov{constructor(){super(...arguments),this.searchMatches=[],this.selectedMatchIndex=null,this.currentSearchRegex=null,this.searchOptions={matchCase:!1,exactMatch:!1,searchFormulas:!1},this.toSearch=""}handle(e){switch(e.type){case"UPDATE_SEARCH":this.updateSearch(e.toSearch,e.searchOptions);break;case"CLEAR_SEARCH":case"UNDO":case"REDO":case"REMOVE_COLUMNS_ROWS":case"ADD_COLUMNS_ROWS":this.clearSearch();break;case"SELECT_SEARCH_PREVIOUS_MATCH":this.selectNextCell($v.previous);break;case"SELECT_SEARCH_NEXT_MATCH":this.selectNextCell($v.next);break;case"REPLACE_SEARCH":this.replace(e.replaceWith);break;case"REPLACE_ALL_SEARCH":this.replaceAll(e.replaceWith);break;case"ACTIVATE_SHEET":case"REFRESH_SEARCH":this.refreshSearch()}}getSearchMatches(){return this.searchMatches}getCurrentSelectedMatchIndex(){return this.selectedMatchIndex}updateSearch(e,t){this.searchOptions=t,e!==this.toSearch&&(this.selectedMatchIndex=null),this.toSearch=e,this.updateRegex(),this.refreshSearch()}refreshSearch(){const e=this.findMatches();this.searchMatches=e,this.selectNextCell($v.current)}updateRegex(){let e=Oe(this.toSearch);const t=this.searchOptions.matchCase?"":"i";this.searchOptions.exactMatch&&(e=`^${e}$`),this.currentSearchRegex=RegExp(e,t)}findMatches(){const e=this.getters.getActiveSheetId(),t=this.getters.getCells(e),i=[];if(this.toSearch)for(const o of Object.values(t)){const{col:t,row:n}=this.getters.getCellPosition(o.id);if(o&&this.currentSearchRegex&&this.currentSearchRegex.test(this.getSearchableString({sheetId:e,col:t,row:n}))){const e={col:t,row:n,selected:!1};i.push(e)}}return i.sort(this.sortByRowThenColumn)}sortByRowThenColumn(e,t){return e.row===t.row?e.col-t.col:e.row>t.row?1:-1}selectNextCell(e){const t=this.searchMatches;if(!t.length)return void(this.selectedMatchIndex=null);let i;i=null===this.selectedMatchIndex?0:this.selectedMatchIndex+e,i=(i%t.length+t.length)%t.length,this.selectedMatchIndex=i,this.selection.selectCell(t[i].col,t[i].row);for(let e=0;e<this.searchMatches.length;e++)this.searchMatches[e].selected=e===this.selectedMatchIndex}clearSearch(){this.toSearch="",this.searchMatches=[],this.selectedMatchIndex=null,this.currentSearchRegex=null,this.searchOptions={matchCase:!1,exactMatch:!1,searchFormulas:!1}}replace(e){if(null===this.selectedMatchIndex||!this.currentSearchRegex)return;const t=this.searchMatches[this.selectedMatchIndex],i=this.getters.getActiveSheetId(),o=this.getters.getCell({sheetId:i,...t});if((null==o?void 0:o.isFormula)&&!this.searchOptions.searchFormulas)this.selectNextCell($v.next);else{const o=new RegExp(this.currentSearchRegex.source,this.currentSearchRegex.flags+"g"),n=this.getSearchableString({sheetId:i,col:t.col,row:t.row}).replace(o,e);this.dispatch("UPDATE_CELL",{sheetId:this.getters.getActiveSheetId(),col:t.col,row:t.row,content:n}),this.searchMatches.splice(this.selectedMatchIndex,1),this.selectNextCell($v.current)}}replaceAll(e){const t=this.searchMatches.length;for(let i=0;i<t;i++)this.replace(e)}getSearchableString(e){const t=this.getters.getCell(e);return this.searchOptions.searchFormulas&&(null==t?void 0:t.isFormula)?t.content:this.getters.getEvaluatedCell(e).formattedValue}drawGrid(e){const{ctx:t}=e,i=this.getters.getActiveSheetId();for(const e of this.searchMatches){const o=this.getters.getMerge({sheetId:i,col:e.col,row:e.row}),n=o?o.left:e.col,s=o?o.right:e.col,r=o?o.top:e.row,a=o?o.bottom:e.row,{x:l,y:c,width:h,height:d}=this.getters.getVisibleRect({top:r,left:n,right:s,bottom:a});h>0&&d>0&&(t.fillStyle="#8B008B33",t.fillRect(l,c,h,d),e.selected&&(t.strokeStyle="#8B008B",t.strokeRect(l,c,h,d)))}}}Wv.layers=[3],Wv.getters=["getSearchMatches","getCurrentSelectedMatchIndex"];class Gv extends Ov{isRowHidden(e,t){return this.getters.isRowHiddenByUser(e,t)||this.getters.isRowFiltered(e,t)}isColHidden(e,t){return this.getters.isColHiddenByUser(e,t)}isHeaderHidden(e,t,i){return"COL"===t?this.isColHidden(e,i):this.isRowHidden(e,i)}getNextVisibleCellPosition({sheetId:e,col:t,row:i}){return{sheetId:e,col:this.findVisibleHeader(e,"COL",ze(t,this.getters.getNumberCols(e))),row:this.findVisibleHeader(e,"ROW",ze(i,this.getters.getNumberRows(e)))}}findVisibleHeader(e,t,i){return i.find((i=>this.getters.doesHeaderExist(e,t,i)&&!this.isHeaderHidden(e,t,i)))}findLastVisibleColRowIndex(e,t,{last:i,first:o}){return ze(i,o,-1).find((i=>!this.isHeaderHidden(e,t,i)))||o}findFirstVisibleColRowIndex(e,t){const i=this.getters.getNumberHeaders(e,t);for(let o=0;o<i-1;o++){if("COL"===t&&!this.isColHidden(e,o))return o;if("ROW"===t&&!this.isRowHidden(e,o))return o}}exportForExcel(e){for(const t of e.sheets)for(const[e,i]of Object.entries(t.rows)){const o=this.isRowHidden(t.id,Number(e));i.isHidden=o}}}Gv.getters=["getNextVisibleCellPosition","findVisibleHeader","findLastVisibleColRowIndex","findFirstVisibleColRowIndex","isRowHidden","isColHidden","isHeaderHidden"];class qv extends Ov{getHighlights(){return this.prepareHighlights(this.getters.getComposerHighlights().concat(this.getters.getSelectionInputHighlights()))}prepareHighlights(e){return e.filter((e=>e.zone.top>=0&&e.zone.left>=0&&e.zone.bottom<this.getters.getNumberRows(e.sheetId)&&e.zone.right<this.getters.getNumberCols(e.sheetId))).map((e=>{const{height:t,width:i}=Zi(e.zone),o=t*i==1?this.getters.expandZone(e.sheetId,e.zone):e.zone;return{...e,zone:o}}))}drawGrid(e){const{ctx:t,thinLineWidth:i}=e,o=this.getters.getActiveSheetId(),n=3*i;t.lineWidth=n;const s=this.getHighlights();for(let e of s.filter(((e,t)=>s.findIndex((t=>Bi(t.zone,e.zone)&&t.sheetId===o))===t))){const{x:i,y:o,width:s,height:r}=this.getters.getVisibleRect(e.zone);s>0&&r>0&&(t.strokeStyle=e.color,t.strokeRect(i+n/2,o+n/2,s-n,r-n),t.globalCompositeOperation="source-over",t.fillStyle=e.color+"20",t.fillRect(i+n,o+n,s-2*n,r-2*n))}}}qv.layers=[1],qv.getters=["getHighlights"];class Zv extends Ov{constructor(){super(...arguments),this.boxes=[]}getColDimensionsInViewport(e,t){const i=Math.min(...this.getters.getSheetViewVisibleCols()),o=this.getters.getColRowOffsetInViewport("COL",i,t),n=this.getters.getColSize(e,t);return{start:o,size:n,end:o+(this.getters.isColHidden(e,t)?0:n)}}getRowDimensionsInViewport(e,t){const i=Math.min(...this.getters.getSheetViewVisibleRows()),o=this.getters.getColRowOffsetInViewport("ROW",i,t),n=this.getters.getRowSize(e,t);return{start:o,size:n,end:o+(this.getters.isRowHidden(e,t)?0:n)}}getHeaderOffset(e,t,i){let o=this.getters.getColRowOffsetInViewport(e,t,i);return this.getters.isDashboard()||(o+="ROW"===e?O:N),o}drawGrid(e,t){switch(t){case 0:this.boxes=this.getGridBoxes(),this.drawBackground(e),this.drawOverflowingCellBackground(e),this.drawCellBackground(e),this.drawBorders(e),this.drawTexts(e),this.drawIcon(e),this.drawFrozenPanes(e);break;case 7:this.getters.isDashboard()||(this.drawHeaders(e),this.drawFrozenPanesHeaders(e))}}drawBackground(e){const{ctx:t,thinLineWidth:i}=e,{width:o,height:n}=this.getters.getSheetViewDimensionWithHeaders();t.fillStyle="#ffffff",t.fillRect(0,0,o+m,n+m);const s=!this.getters.isDashboard()&&this.getters.getGridLinesVisibility(this.getters.getActiveSheetId()),r=s?.1*i:0;if(s)for(const e of this.boxes)t.strokeStyle="#E2E3E3",t.lineWidth=i,t.strokeRect(e.x+r,e.y+r,e.width-2*r,e.height-2*r)}drawCellBackground(e){const{ctx:t}=e;for(const e of this.boxes){let i=e.style;i.fillColor&&"#ffffff"!==i.fillColor&&(t.fillStyle=i.fillColor||"#ffffff",t.fillRect(e.x,e.y,e.width,e.height)),e.error&&(t.fillStyle="red",t.beginPath(),t.moveTo(e.x+e.width-5,e.y),t.lineTo(e.x+e.width,e.y),t.lineTo(e.x+e.width,e.y+5),t.fill())}}drawOverflowingCellBackground(e){var t,i;const{ctx:o,thinLineWidth:n}=e;for(const e of this.boxes)if(e.content&&e.isOverflow){const s=e.content.align||"left";let r,a;const l=e.y+n/2,c=e.height-n,h=Math.min((null===(t=e.clipRect)||void 0===t?void 0:t.width)||1/0,e.content.width);"left"===s?(r=e.x+n/2,a=h-2*n):"right"===s?(r=e.x+e.width-n/2,a=2*n-h):(r=((null===(i=e.clipRect)||void 0===i?void 0:i.x)||e.x+e.width/2-e.content.width/2)+n/2,a=h-2*n),o.fillStyle="#ffffff",o.fillRect(r,l,a,c)}}drawBorders(e){const{ctx:t,thinLineWidth:i}=e;for(let e of this.boxes){const t=e.border;if(t){const{x:i,y:n,width:s,height:r}=e;t.left&&o(t.left,i,n,i,n+r),t.top&&o(t.top,i,n,i+s,n),t.right&&o(t.right,i+s,n,i+s,n+r),t.bottom&&o(t.bottom,i,n+r,i+s,n+r)}}function o([e,o],n,s,r,a){t.strokeStyle=o,t.lineWidth=("thin"===e?2:3)*i,t.beginPath(),t.moveTo(n,s),t.lineTo(r,a),t.stroke()}}drawTexts(e){const{ctx:t,thinLineWidth:i}=e;let o;t.textBaseline="top";for(let e of this.boxes)if(e.content){const n=e.style||{},s=e.content.align||"left",r=Ue(n);r!==o&&(o=r,t.font=r),t.fillStyle=n.textColor||"#000";let a=e.x;if(a+="left"===s?U+(e.image?e.image.size+P:0):"right"===s?e.width-U-(e.isFilterHeader?20:0):e.width/2,t.textAlign=s,e.clipRect){t.save(),t.beginPath();const{x:i,y:o,width:n,height:s}=e.clipRect;t.rect(i,o,n,s),t.clip()}const l=Ve(n),c=e.content.textLines.length;let h=this.computeTextYCoordinate(e,l,c);for(let o of e.content.textLines){if(t.fillText(o,Math.round(a),Math.round(h)),n.strikethrough||n.underline){const e=Le(t,o,n);let r=a;"right"===s?r-=e:"center"===s&&(r-=e/2),n.strikethrough&&t.fillRect(r,h+l/2,e,2.6*i),n.underline&&t.fillRect(r,h+l+1,e,1.3*i)}h+=U+l}e.clipRect&&t.restore()}}drawIcon(e){const{ctx:t}=e;for(const e of this.boxes)if(e.image){const i=e.image.image;if(e.image.clipIcon){t.save(),t.beginPath();const{x:i,y:o,width:n,height:s}=e.image.clipIcon;t.rect(i,o,n,s),t.clip()}const o=e.image.size,n=this.computeTextYCoordinate(e,o);t.drawImage(i,e.x+P,n,o,o),e.image.clipIcon&&t.restore()}}computeTextYCoordinate(e,t,i=1){const o=e.y+1,n=ke(t,i),s=e.height>n+2*U,r=e.verticalAlign||"middle";if(s){if("middle"===r)return o+(e.height-n)/2;if("bottom"===r)return o+e.height-n-U}return o+U}drawHeaders(e){const{ctx:t,thinLineWidth:i}=e,o=this.getters.getSheetViewVisibleCols(),n=o[0],s=o[o.length-1],r=this.getters.getSheetViewVisibleRows(),a=r[0],l=r[r.length-1],{width:c,height:h}=this.getters.getSheetViewDimensionWithHeaders(),d=this.getters.getSelectedZones(),u=function(e){const t=new Set;for(let i of e)for(let e of ze(i.left,i.right+1))t.add(e);return t}(d),g=function(e){const t=new Set;for(let i of e)for(let e of ze(i.top,i.bottom+1))t.add(e);return t}(d),p=this.getters.getActiveSheetId(),m=this.getters.getNumberCols(p),f=this.getters.getNumberRows(p),E=this.getters.getActiveCols(),w=this.getters.getActiveRows();t.font=`400 11px ${q}`,t.textAlign="center",t.textBaseline="middle",t.lineWidth=i,t.strokeStyle="#333";for(let e=n;e<=s;e++){const i={left:e,right:e,top:0,bottom:f-1},{x:o,width:n}=this.getters.getVisibleRect(i),s=this.getters.doesZonesContainFilter(p,[i]),r=E.has(e),a=u.has(e);t.fillStyle=r?s?I:S:a?s?T:b:s?R:v,t.fillRect(o,0,n,O)}for(let e=a;e<=l;e++){const i={top:e,bottom:e,left:0,right:m-1},{y:o,height:n}=this.getters.getVisibleRect(i),s=this.getters.doesZonesContainFilter(p,[i]),r=w.has(e),a=g.has(e);t.fillStyle=r?s?I:S:a?s?T:b:s?R:v,t.fillRect(0,o,N,n)}t.beginPath(),t.moveTo(N,0),t.lineTo(N,h),t.moveTo(0,O),t.lineTo(c,O),t.strokeStyle="#C0C0C0",t.stroke(),t.beginPath();for(const e of o){const i=this.getters.getColSize(p,e),o=Lt(e);t.fillStyle=E.has(e)?"#fff":C;let s=this.getHeaderOffset("COL",n,e);t.fillText(o,s+i/2,13),t.moveTo(s+i,0),t.lineTo(s+i,O)}for(const e of r){const i=this.getters.getRowSize(p,e);t.fillStyle=w.has(e)?"#fff":C;let o=this.getHeaderOffset("ROW",a,e);t.fillText(String(e+1),24,o+i/2),t.moveTo(0,o+i),t.lineTo(N,o+i)}t.stroke()}drawFrozenPanesHeaders(e){const{ctx:t,thinLineWidth:i}=e,{x:o,y:n}=this.getters.getMainViewportCoordinates(),s=this.getters.isDashboard()?0:N,r=this.getters.isDashboard()?0:O;t.lineWidth=6*i,t.strokeStyle="#BCBCBC",t.beginPath(),o&&(t.moveTo(s+o,0),t.lineTo(s+o,r)),n&&(t.moveTo(0,r+n),t.lineTo(s,r+n)),t.stroke()}drawFrozenPanes(e){const{ctx:t,thinLineWidth:i}=e,{x:o,y:n}=this.getters.getMainViewportCoordinates(),s=this.getters.getSheetViewVisibleCols(),r=s[0],a=s[s.length-1],l=this.getters.getSheetViewVisibleRows(),c={left:r,right:a,top:l[0],bottom:l[l.length-1]},h=this.getters.getVisibleRect(c),d=this.getters.isDashboard()?0:N,u=this.getters.isDashboard()?0:O;t.lineWidth=6*i,t.strokeStyle="#DADFE8",t.beginPath(),o&&(t.moveTo(d+o,u),t.lineTo(d+o,h.height+u)),n&&(t.moveTo(d,u+n),t.lineTo(h.width+d,u+n)),t.stroke()}findNextEmptyCol(e,t,i){const o=this.getters.getActiveSheetId();let n=e;for(;n<t;){const e={sheetId:o,col:n+1,row:i},t=this.getters.getEvaluatedCell(e),s=this.getters.getCellBorderWithFilterBorder(e);if(t.type!==So.empty||this.getters.isInMerge(e)||(null==s?void 0:s.left))return n;n++}return n}findPreviousEmptyCol(e,t,i){const o=this.getters.getActiveSheetId();let n=e;for(;n>t;){const e={sheetId:o,col:n-1,row:i},t=this.getters.getEvaluatedCell(e),s=this.getters.getCellBorderWithFilterBorder(e);if(t.type!==So.empty||this.getters.isInMerge(e)||(null==s?void 0:s.right))return n;n--}return n}computeCellAlignment(e,t){const i=this.getters.getCell(e);if((null==i?void 0:i.isFormula)&&this.getters.shouldShowFormulas())return"left";const{align:o}=this.getters.getCellStyle(e),n=this.getters.getEvaluatedCell(e);return t&&n.type===So.number?"center"!==o?"left":o:o||n.defaultAlign}createZoneBox(e,t,i){const{left:o,right:n}=i,s=t.left,r=t.top,a={sheetId:e,col:s,row:r},c=this.getters.getEvaluatedCell(a),h=this.getters.shouldShowFormulas(),{x:d,y:u,width:g,height:p}=this.getters.getVisibleRect(t),{verticalAlign:m}=this.getters.getCellStyle(a),f={x:d,y:u,width:g,height:p,border:this.getters.getCellBorderWithFilterBorder(a)||void 0,style:this.getters.getCellComputedStyle(a),verticalAlign:m};if(c.type===So.empty)return f;const v=this.getters.getConditionalIcon(a),b=Ve(f.style),S=v?P+b:0;v&&(f.image={type:"icon",size:b,clipIcon:{x:f.x,y:f.y,width:Math.min(S,g),height:p},image:Og[v].img}),f.isFilterHeader=this.getters.isFilterHeader(a);const C=f.isFilterHeader?19:0,E=this.getters.getCellComputedStyle(a),w=E.wrapping||"overflow",y="wrap"!==w||h?void 0:g-2*U,x=this.getters.getCellMultiLineText(a,y),I=Math.max(...x.map((e=>this.getters.getTextWidth(e,E)+U))),R=S+I+C,T=this.computeCellAlignment(a,R>g);f.content={textLines:x,width:"overflow"===w?I:g,align:T},c.type===So.error&&c.error.logLevel>l.silent&&(f.error=c.error.message);const A=R>g||b>p;if(v||f.isFilterHeader)f.clipRect={x:f.x+S,y:f.y,width:Math.max(0,g-S-C),height:p};else if(A&&"overflow"===w){let e,i;switch(this.getters.isInMerge(a)?(e=this.getters.getMerge(a).right,i=s):(e=this.findNextEmptyCol(s,n,r),i=this.findPreviousEmptyCol(s,o,r),f.isOverflow=!0),T){case"left":{const i=Ji({col:e,row:r}),{x:o,y:n,width:s,height:a}=this.getters.getVisibleRect(Vi(t,i));(s<R||b>a||x.length>1)&&(f.clipRect={x:o,y:n,width:s,height:a});break}case"right":{const e=Ji({col:i,row:r}),{x:o,y:n,width:s,height:a}=this.getters.getVisibleRect(Vi(t,e));(s<R||b>a||x.length>1)&&(f.clipRect={x:o,y:n,width:s,height:a});break}case"center":{const o={...t,left:i,right:e},{x:n,y:s,height:r,width:a}=this.getters.getVisibleRect(o),l=R/2,c=f.x+f.width/2;if(n+a<c+l||n>c-l||b>r||x.length>1){const e=n>c-l?n:c-l,t=n+a-e;f.clipRect={x:e,y:s,width:t,height:r}}break}}}else("clip"===w||"wrap"===w||x.length>1)&&(f.clipRect={x:f.x,y:f.y,width:g,height:p});return f}getGridBoxes(){const e=[],t=this.getters.getSheetViewVisibleCols(),i=t[0],o=t[t.length-1],n=this.getters.getSheetViewVisibleRows(),s={left:i,right:o,top:n[0],bottom:n[n.length-1]},r=this.getters.getActiveSheetId();for(const i of n)for(const o of t){const t={sheetId:r,col:o,row:i};this.getters.isInMerge(t)||e.push(this.createZoneBox(r,Ji(t),s))}for(const t of this.getters.getMerges(r))if(!this.getters.isMergeHidden(r,t)&&Hi(t,s)){const i=this.createZoneBox(r,t,s),o=this.getters.getCellBorder({sheetId:r,col:t.right,row:t.bottom});i.border={...i.border,bottom:o?o.bottom:void 0,right:o?o.right:void 0},i.isMerge=!0,e.push(i)}return e}}Zv.layers=[0,7],Zv.getters=["getColDimensionsInViewport","getRowDimensionsInViewport"];class jv extends Ov{constructor(e,t,i){super(e),this.inputHasSingleRange=i,this.ranges=[],this.focusedRangeIndex=null,this.willAddNewRange=!1,this.insertNewRange(0,t),this.activeSheet=this.getters.getActiveSheetId(),0===this.ranges.length&&(this.insertNewRange(this.ranges.length,[""]),this.focusLast())}allowDispatch(e){if("ADD_EMPTY_RANGE"===e.type)if(this.inputHasSingleRange&&1===this.ranges.length)return 30;return 0}handleEvent(e){const t=Di(e.anchor.zone),i=this.activeSheet,o=this.getters.getActiveSheetId(),n=this.getters.getSheetName(o);this.add([o===i?t:`${Fe(n)}!${t}`])}handle(e){switch(e.type){case"UNFOCUS_SELECTION_INPUT":this.unfocus();break;case"FOCUS_RANGE":this.focus(this.getIndex(e.rangeId));break;case"CHANGE_RANGE":{const t=this.getIndex(e.rangeId);if(null!==t&&this.focusedRangeIndex!==t&&this.focus(t),null!==t){const i=e.value.replace(/^,+/,"").split(",").map((e=>e.trim()));this.setRange(t,i)}break}case"ADD_EMPTY_RANGE":this.insertNewRange(this.ranges.length,[""]),this.focusLast();break;case"REMOVE_RANGE":const t=this.getIndex(e.rangeId);null!==t&&this.removeRange(t);break;case"STOP_SELECTION_INPUT":this.willAddNewRange=!1;break;case"PREPARE_SELECTION_INPUT_EXPANSION":{const e=this.focusedRangeIndex;null===e||this.inputHasSingleRange||(this.willAddNewRange=""!==this.ranges[e].xc.trim());break}case"ACTIVATE_SHEET":if(e.sheetIdFrom!==e.sheetIdTo){const{col:t,row:i}=this.getters.getNextVisibleCellPosition({sheetId:e.sheetIdTo,col:0,row:0}),o=this.getters.expandZone(e.sheetIdTo,Ji({col:t,row:i}));this.selection.resetAnchor(this,{cell:{col:t,row:i},zone:o})}}}getSelectionInputValue(){return this.cleanInputs(this.ranges.map((e=>e.xc?e.xc:"")))}getSelectionInputHighlights(){return this.ranges.map((e=>this.inputToHighlights(e))).flat()}focus(e){this.focusedRangeIndex=e}focusLast(){this.focus(this.ranges.length-1)}unfocus(){this.focusedRangeIndex=null}add(e){null!==this.focusedRangeIndex&&0!==e.length&&(this.willAddNewRange?(this.insertNewRange(this.ranges.length,e),this.focusLast(),this.willAddNewRange=!1):this.setRange(this.focusedRangeIndex,e))}setContent(e,t){this.ranges[e]={...this.ranges[e],xc:t}}insertNewRange(e,t){const i=Math.max(0,...this.ranges.map((e=>Number(e.id))));this.ranges.splice(e,0,...t.map(((e,t)=>({xc:e,id:i+t+1,color:pt[(i+t)%pt.length]}))))}setRange(e,t){const[,...i]=t;this.setContent(e,t[0]),this.insertNewRange(e+1,i),i.length&&this.focus(e+i.length)}removeRange(e){this.ranges.splice(e,1),null!==this.focusedRangeIndex&&this.focusLast()}inputToHighlights({xc:e,color:t}){const i=this.cleanInputs([e]).filter((e=>this.getters.isRangeValid(e))).filter((e=>this.shouldBeHighlighted(this.activeSheet,e)));return i.map((e=>{const{sheetName:i}=kt(e);return{zone:this.getters.getRangeFromSheetXC(this.activeSheet,e).zone,sheetId:i&&this.getters.getSheetIdByName(i)||this.activeSheet,color:t}}))}cleanInputs(e){return e.map((e=>e.split(","))).flat().map((e=>e.trim())).filter((e=>""!==e))}shouldBeHighlighted(e,t){const{sheetName:i}=kt(t),o=this.getters.getSheetIdByName(i),n=this.getters.getActiveSheet().id;return this.getters.isRangeValid(t)&&(o===n||void 0===o&&n===e)}getIndex(e){const t=this.ranges.findIndex((t=>t.id===e));return t>=0?t:null}}jv.layers=[1],jv.getters=[];class Xv extends Ov{constructor(e){super(e),this.config=e,this.inputs={},this.focusedInputId=null}get currentInput(){return this.focusedInputId?this.inputs[this.focusedInputId]:null}allowDispatch(e){var t,i;if("FOCUS_RANGE"===e.type){const o=null===(t=this.currentInput)||void 0===t?void 0:t.getIndex(e.rangeId);if(this.focusedInputId===e.id&&(null===(i=this.currentInput)||void 0===i?void 0:i.focusedRangeIndex)===o)return 29}return this.currentInput?this.currentInput.allowDispatch(e):0}handle(e){var t;switch(e.type){case"ENABLE_NEW_SELECTION_INPUT":this.initInput(e.id,e.initialRanges||[],e.hasSingleRange);break;case"DISABLE_SELECTION_INPUT":this.focusedInputId===e.id&&this.unfocus(),delete this.inputs[e.id];break;case"UNFOCUS_SELECTION_INPUT":this.unfocus();break;case"ADD_EMPTY_RANGE":case"REMOVE_RANGE":if(e.id!==this.focusedInputId){const t=this.inputs[e.id];this.selection.capture(t,{cell:{col:0,row:0},zone:Ji({col:0,row:0})},{handleEvent:t.handleEvent.bind(t)}),this.focusedInputId=e.id}break;case"FOCUS_RANGE":case"CHANGE_RANGE":if(e.id!==this.focusedInputId){const t=this.inputs[e.id],i=t.ranges.find((t=>t.id===e.rangeId)),o=this.getters.getActiveSheetId(),n=this.getters.getRangeFromSheetXC(o,(null==i?void 0:i.xc)||"A1").zone;this.selection.capture(t,{cell:{col:n.left,row:n.top},zone:n},{handleEvent:t.handleEvent.bind(t)}),this.focusedInputId=e.id}}null===(t=this.currentInput)||void 0===t||t.handle(e)}getSelectionInput(e){return this.inputs[e]?this.inputs[e].ranges.map(((t,i)=>Object.assign({},t,{color:this.focusedInputId===e&&null!==this.inputs[e].focusedRangeIndex&&this.isRangeValid(t.xc)?t.color:null,isFocused:this.focusedInputId===e&&this.inputs[e].focusedRangeIndex===i}))):[]}isRangeValid(e){if(!e)return!1;const{xc:t,sheetName:i}=kt(e);return null!==t.match(Ot)&&(!i||void 0!==this.getters.getSheetIdByName(i))}getSelectionInputValue(e){return this.inputs[e].getSelectionInputValue()}getSelectionInputHighlights(){return this.focusedInputId?this.inputs[this.focusedInputId].getSelectionInputHighlights():[]}initInput(e,t,i=!1){if(this.inputs[e]=new jv(this.config,t,i),0===t.length){const t=this.inputs[e],i={zone:Ji({col:0,row:0}),cell:{col:0,row:0}};this.selection.capture(t,i,{handleEvent:t.handleEvent.bind(t)}),this.focusedInputId=e}}unfocus(){this.selection.release(this.currentInput),this.focusedInputId=null}}Xv.layers=[1],Xv.getters=["getSelectionInput","getSelectionInputValue","isRangeValid","getSelectionInputHighlights"];class Yv{constructor(){this.subscriptions={}}on(e,t,i){if(!i)throw new Error("Missing callback");this.subscriptions[e]||(this.subscriptions[e]=[]),this.subscriptions[e].push({owner:t,callback:i})}trigger(e,t){const i=this.subscriptions[e]||[];for(let e=0,o=i.length;e<o;e++){const o=i[e];o.callback.call(o.owner,t)}}off(e,t){const i=this.subscriptions[e];i&&(this.subscriptions[e]=i.filter((e=>e.owner!==t)))}clear(){this.subscriptions={}}}function Kv(e,t){return{...e,definition:ts(e.definition,t)}}function Qv(e,t){if(e.sheetId!==t.sheetId)return e;if(("FREEZE_COLUMNS"===e.type?"COL":"ROW")!==t.dimension)return e;let i=e.quantity;if("REMOVE_COLUMNS_ROWS"===t.type){const e=[...t.elements].sort(((e,t)=>t-e));for(let t of e)i>t&&i--}if("ADD_COLUMNS_ROWS"===t.type){i=i>("before"===t.position?t.base-1:t.base)?i+t.quantity:i}return i>0?{...e,quantity:i}:void 0}cg.addTransformation("ADD_COLUMNS_ROWS",["CREATE_CHART","UPDATE_CHART"],Kv),cg.addTransformation("REMOVE_COLUMNS_ROWS",["CREATE_CHART","UPDATE_CHART"],Kv),cg.addTransformation("DELETE_SHEET",["MOVE_RANGES"],(function(e,t){const i=t.sheetId;if(e.targetSheetId===i||e.sheetId===i)return;return e})),cg.addTransformation("DELETE_FIGURE",["UPDATE_FIGURE","UPDATE_CHART"],(function(e,t){if(e.id===t.id)return;return e})),cg.addTransformation("CREATE_SHEET",["CREATE_SHEET"],(function(e,t){var i;if(e.name===t.name)return{...e,name:(null===(i=e.name)||void 0===i?void 0:i.match(/\d+/))?e.name.replace(/\d+/,(e=>(parseInt(e)+1).toString())):`${e.name}~`,position:e.position+1};return e})),cg.addTransformation("ADD_MERGE",["ADD_MERGE","REMOVE_MERGE","CREATE_FILTER_TABLE"],(function(e,t){if(e.sheetId!==t.sheetId)return e;const i=[];for(const o of e.target)for(const e of t.target)Hi(o,e)||i.push({...o});if(i.length)return{...e,target:i};return})),cg.addTransformation("ADD_COLUMNS_ROWS",["FREEZE_COLUMNS","FREEZE_ROWS"],Qv),cg.addTransformation("REMOVE_COLUMNS_ROWS",["FREEZE_COLUMNS","FREEZE_ROWS"],Qv),cg.addTransformation("CREATE_FILTER_TABLE",["CREATE_FILTER_TABLE","ADD_MERGE"],(function(e,t){if(e.sheetId!==t.sheetId)return e;for(const i of e.target)for(const e of t.target)if(Hi(e,i))return;return e}));const Jv=[{match:function(e){return"sheetId"in e},fn:ib},{match:function(e){return"target"in e&&"sheetId"in e},fn:function(e,t){const i=ib(e,t);if("SKIP_TRANSFORMATION"!==i)return"IGNORE_COMMAND"===i?"IGNORE_COMMAND":e;const o=[];for(const i of e.target){const e=bo(i,t);e&&o.push(e)}if(!o.length)return"IGNORE_COMMAND";return{...e,target:o}}},{match:function(e){return"col"in e&&"row"in e&&"sheetId"in e},fn:function(e,t){const i=ib(e,t);if("SKIP_TRANSFORMATION"!==i)return"IGNORE_COMMAND"===i?"IGNORE_COMMAND":e;if("ADD_COLUMNS_ROWS"===t.type||"REMOVE_COLUMNS_ROWS"===t.type)return function(e,t){const i="COL"===t.dimension?"col":"row";let o=e[i];if("REMOVE_COLUMNS_ROWS"===t.type){const e=[...t.elements].sort(((e,t)=>t-e));if(e.includes(o))return"IGNORE_COMMAND";for(let t of e)o>=t&&o--}"ADD_COLUMNS_ROWS"===t.type&&(o>t.base||o===t.base&&"before"===t.position)&&(o+=t.quantity);return{...e,[i]:o}}(e,t);if("ADD_MERGE"===t.type)return function(e,t){for(const i of t.target){if(!(e.col===i.left&&e.row===i.top)&&$i(e.col,e.row,i))return"IGNORE_COMMAND"}return e}(e,t);return"SKIP_TRANSFORMATION"}},{match:function(e){return"dimension"in e&&"sheetId"in e},fn:function(e,t){const i=ib(e,t);if("SKIP_TRANSFORMATION"!==i)return"IGNORE_COMMAND"===i?"IGNORE_COMMAND":e;if("ADD_COLUMNS_ROWS"===t.type||"REMOVE_COLUMNS_ROWS"===t.type){if(t.dimension!==e.dimension)return e;const i="ADD_COLUMNS_ROWS"===e.type,o=i?"base":"elements";let n=i?[e[o]]:e[o];if("REMOVE_COLUMNS_ROWS"===t.type&&(n=n.map((e=>{if(t.elements.includes(e))return;const i=t.elements.sort(((e,t)=>t-e));for(let t of i)e>t&&e--;return e})).filter(et)),"ADD_COLUMNS_ROWS"===t.type){const e="before"===t.position?t.base-1:t.base;n=n.map((i=>i>e?i+t.quantity:i))}if(n.length){let t=n;return i&&(t=n[0]),{...e,[o]:t}}return"IGNORE_COMMAND"}return"SKIP_TRANSFORMATION"}},{match:function(e){return"ranges"in e},fn:function(e,t){const i=[],o="DELETE_SHEET"===t.type&&t.sheetId;for(const n of e.ranges)if(n._sheetId!==t.sheetId)i.push({...n,_zone:n._zone});else{const e=bo(n._zone,t);e&&o!==n._sheetId&&i.push({...n,_zone:e})}if(!i.length)return"IGNORE_COMMAND";return{...e,ranges:i}}}];function eb(e,t){const i=cg.getTransformation(e.type,t.type);return i?i(e,t):function(e,t){for(const{match:i,fn:o}of Jv)if(i(e)){const i=o(e,t);if("SKIP_TRANSFORMATION"===i)continue;if("IGNORE_COMMAND"===i)return;e=i}return e}(e,t)}function tb(e,t){let i=[...e];for(const e of t)i=i.map((t=>eb(t,e))).filter(et);return i}function ib(e,t){const i="DELETE_SHEET"===t.type&&t.sheetId;return e.sheetId===i?"IGNORE_COMMAND":"CREATE_SHEET"===e.type||"CREATE_SHEET"===t.type||e.sheetId!==t.sheetId?e:"SKIP_TRANSFORMATION"}class ob{constructor(e,t,i,o){this._commands=[],this._changes=[],this.id=e,this.clientId=t,this._commands=[...i],this._changes=o?[...o]:[]}setChanges(e){this._changes=e}get commands(){return this._commands}get changes(){return this._changes}}class nb extends Error{}class sb extends Yv{constructor(e,t,i=K){super(),this.revisions=e,this.transportService=t,this.serverRevisionId=i,this.clients={},this.clientId="local",this.pendingMessages=[],this.waitingAck=!1,this.waitingUndoRedoAck=!1,this.isReplayingInitialRevisions=!1,this.processedRevisions=new Set,this.uuidGenerator=new Oi,this.debouncedMove=function(e,t,i){let o;return function(){const n=this,s=arguments,r=i&&!o;clearTimeout(o),o=setTimeout((function(){o=null,i||e.apply(n,s)}),t),r&&e.apply(n,s)}}(this._move.bind(this),200)}canApplyOptimisticUpdate(){return!this.waitingUndoRedoAck}save(e,t){if(!e.length||!t.length||!this.canApplyOptimisticUpdate())return;const i=new ob(this.uuidGenerator.uuidv4(),this.clientId,e,t);this.revisions.append(i.id,i),this.trigger("new-local-state-update",{id:i.id}),this.sendUpdateMessage({type:"REMOTE_REVISION",version:1,serverRevisionId:this.serverRevisionId,nextRevisionId:i.id,clientId:i.clientId,commands:i.commands})}undo(e){this.waitingUndoRedoAck=!0,this.sendUpdateMessage({type:"REVISION_UNDONE",version:1,serverRevisionId:this.serverRevisionId,nextRevisionId:this.uuidGenerator.uuidv4(),undoneRevisionId:e})}redo(e){this.waitingUndoRedoAck=!0,this.sendUpdateMessage({type:"REVISION_REDONE",version:1,serverRevisionId:this.serverRevisionId,nextRevisionId:this.uuidGenerator.uuidv4(),redoneRevisionId:e})}move(e){this.debouncedMove(e)}join(e){e?(this.clients[e.id]=e,this.clientId=e.id):(this.clients.local={id:"local",name:"local"},this.clientId="local"),this.transportService.onNewMessage(this.clientId,this.onMessageReceived.bind(this))}loadInitialMessages(e){this.isReplayingInitialRevisions=!0,this.on("unexpected-revision-id",this,(({revisionId:e})=>{throw new Error(`The spreadsheet could not be loaded. Revision ${e} is corrupted.`)}));for(const t of e)this.onMessageReceived(t);this.off("unexpected-revision-id",this),this.isReplayingInitialRevisions=!1}leave(){delete this.clients[this.clientId],this.transportService.leave(this.clientId),this.transportService.sendMessage({type:"CLIENT_LEFT",clientId:this.clientId,version:1})}snapshot(e){const t=this.uuidGenerator.uuidv4();this.transportService.sendMessage({type:"SNAPSHOT",nextRevisionId:t,serverRevisionId:this.serverRevisionId,data:{...e,revisionId:t},version:1})}getClient(){const e=this.clients[this.clientId];if(!e)throw new nb("The client left the session");return e}getConnectedClients(){return new Set(Object.values(this.clients).filter(et))}getRevisionId(){return this.serverRevisionId}isFullySynchronized(){return 0===this.pendingMessages.length}_move(e){var t;if(!this.clients[this.clientId])return;const i=null===(t=this.clients[this.clientId])||void 0===t?void 0:t.position;if((null==i?void 0:i.col)===e.col&&i.row===e.row&&i.sheetId===e.sheetId)return;const o=i?"CLIENT_MOVED":"CLIENT_JOINED",n=this.getClient();this.clients[this.clientId]={...n,position:e},this.transportService.sendMessage({type:o,version:1,client:{...n,position:e}})}onMessageReceived(e){if(!this.isAlreadyProcessed(e)){switch(e.type){case"CLIENT_MOVED":this.onClientMoved(e);break;case"CLIENT_JOINED":this.onClientJoined(e);break;case"CLIENT_LEFT":this.onClientLeft(e);break;case"REVISION_REDONE":this.revisions.redo(e.redoneRevisionId,e.nextRevisionId,e.serverRevisionId),this.trigger("revision-redone",{revisionId:e.redoneRevisionId,commands:this.revisions.get(e.redoneRevisionId).commands});break;case"REVISION_UNDONE":this.revisions.undo(e.undoneRevisionId,e.nextRevisionId,e.serverRevisionId),this.trigger("revision-undone",{revisionId:e.undoneRevisionId,commands:this.revisions.get(e.undoneRevisionId).commands});break;case"REMOTE_REVISION":if(e.serverRevisionId!==this.serverRevisionId)return void this.trigger("unexpected-revision-id",{revisionId:e.serverRevisionId});const{clientId:t,commands:i}=e,o=new ob(e.nextRevisionId,t,i);if(o.clientId!==this.clientId){this.revisions.insert(o.id,o,e.serverRevisionId);const t=this.pendingMessages.filter((e=>"REMOTE_REVISION"===e.type)).map((e=>e.commands)).flat();this.trigger("remote-revision-received",{commands:tb(i,t)})}break;case"SNAPSHOT_CREATED":{const t=new ob(e.nextRevisionId,"server",[]);this.revisions.insert(t.id,t,e.serverRevisionId),this.dropPendingHistoryMessages(),this.trigger("snapshot");break}}this.acknowledge(e),this.trigger("collaborative-event-received")}}onClientMoved(e){e.client.id!==this.clientId&&(this.clients[e.client.id]=e.client)}onClientJoined(e){if(e.client.id!==this.clientId){this.clients[e.client.id]=e.client;const t=this.clients[this.clientId];if(t){const{position:e}=t;e&&this.transportService.sendMessage({type:"CLIENT_MOVED",version:1,client:{...t,position:e}})}}}onClientLeft(e){e.clientId!==this.clientId&&delete this.clients[e.clientId]}sendUpdateMessage(e){this.pendingMessages.push(e),this.waitingAck||(this.waitingAck=!0,this.sendPendingMessage())}sendPendingMessage(){let e=this.pendingMessages[0];if(e){if("REMOTE_REVISION"===e.type){const t=this.revisions.get(e.nextRevisionId);if(0===t.commands.length){this.revisions.drop(t.id);const e=this.pendingMessages.filter((e=>"REMOTE_REVISION"===e.type)).map((e=>e.nextRevisionId));return this.trigger("pending-revisions-dropped",{revisionIds:e}),this.waitingAck=!1,this.waitingUndoRedoAck=!1,void(this.pendingMessages=[])}e={...e,clientId:t.clientId,commands:t.commands}}if(this.isReplayingInitialRevisions)throw new Error(`Trying to send a new revision while replaying initial revision. This can lead to endless dispatches every time the spreadsheet is open.\n ${JSON.stringify(e)}`);this.transportService.sendMessage({...e,serverRevisionId:this.serverRevisionId})}}acknowledge(e){switch("REVISION_UNDONE"!==e.type&&"REVISION_REDONE"!==e.type||(this.waitingUndoRedoAck=!1),e.type){case"REMOTE_REVISION":case"REVISION_REDONE":case"REVISION_UNDONE":case"SNAPSHOT_CREATED":this.waitingAck=!1,this.pendingMessages=this.pendingMessages.filter((t=>t.nextRevisionId!==e.nextRevisionId)),this.serverRevisionId=e.nextRevisionId,this.processedRevisions.add(e.nextRevisionId),this.sendPendingMessage()}}isAlreadyProcessed(e){if("CLIENT_MOVED"===e.type&&e.client.id===this.clientId)return!0;switch(e.type){case"REMOTE_REVISION":case"REVISION_REDONE":case"REVISION_UNDONE":return this.processedRevisions.has(e.nextRevisionId);default:return!1}}dropPendingHistoryMessages(){this.waitingUndoRedoAck=!1,this.pendingMessages=this.pendingMessages.filter((({type:e})=>"REVISION_REDONE"!==e&&"REVISION_UNDONE"!==e))}}const rb=["#ff851b","#0074d9","#7fdbff","#b10dc9","#39cccc","#f012be","#3d9970","#111111","#ff4136","#aaaaaa","#85144b","#001f3f"];class ab extends Ov{constructor(){super(...arguments),this.availableColors=new Set(rb),this.colors={}}isPositionValid(e){return e.row<this.getters.getNumberRows(e.sheetId)&&e.col<this.getters.getNumberCols(e.sheetId)}chooseNewColor(){0===this.availableColors.size&&(this.availableColors=new Set(rb));const e=(t=[...this.availableColors.values()])[Math.floor(Math.random()*t.length)];var t;return this.availableColors.delete(e),e}getClientsToDisplay(){try{this.getters.getClient()}catch(e){if(e instanceof nb)return[];throw e}const e=this.getters.getActiveSheetId(),t=[];for(const i of this.getters.getConnectedClients())if(i.id!==this.getters.getClient().id&&i.position&&i.position.sheetId===e&&this.isPositionValid(i.position)){const e=i.position;this.colors[i.id]||(this.colors[i.id]=this.chooseNewColor());const o=this.colors[i.id];t.push({...i,position:e,color:o})}return t}drawGrid(e){if(this.getters.isDashboard())return;const{ctx:t,thinLineWidth:i}=e,o=this.getters.getActiveSheetId();for(const e of this.getClientsToDisplay()){const{row:n,col:s}=e.position,r=this.getters.expandZone(o,{top:n,bottom:n,left:s,right:s}),{x:a,y:l,width:c,height:h}=this.getters.getVisibleRect(r);if(c<=0||h<=0)continue;const d=e.color,u=`${d}10`;t.fillStyle=u,t.lineWidth=4*i,t.strokeStyle=d,t.globalCompositeOperation="multiply",t.fillRect(a,l,c,h),t.globalCompositeOperation="source-over",t.strokeRect(a,l,c,h),t.font=`bold ${G+1}px ${q}`}}}ab.getters=["getClientsToDisplay"],ab.layers=[6];class lb extends Ov{allowDispatch(e){if("SORT_CELLS"===e.type){if(!$i(e.col,e.row,e.zone))throw new Error(s("The anchor must be part of the provided zone"));return this.checkValidations(e,this.checkMerge,this.checkMergeSizes)}return 0}handle(e){if("SORT_CELLS"===e.type)this.sortZone(e.sheetId,e,e.zone,e.sortDirection,e.sortOptions||{})}checkMerge({sheetId:e,zone:t}){if(!this.getters.doesIntersectMerge(e,t))return 0;return Xi(t).some((({col:t,row:i})=>!this.getters.isInMerge({sheetId:e,col:t,row:i})))?63:0}checkMergeSizes({sheetId:e,zone:t}){if(!this.getters.doesIntersectMerge(e,t))return 0;const i=this.getters.getMerges(e).filter((e=>Hi(e,t))),o=Zi(i[0]);let[n,s]=[o.width,o.height];return i.every((e=>{let[t,i]=[e.right-e.left+1,e.bottom-e.top+1];return t===n&&i===s}))?0:63}expand(e,t){const{left:i,right:o,top:n,bottom:s}=this.getters.expandZone(e,t);return{left:Math.max(0,i),right:Math.min(this.getters.getNumberCols(e)-1,o),top:Math.max(0,n),bottom:Math.min(this.getters.getNumberRows(e)-1,s)}}checkExpandedValues(e,t){const i=this.expand(e,t);let o;if(this.getters.doesIntersectMerge(e,i)){const{left:t,right:n,top:s,bottom:r}=i;for(let i=t;i<=n;i++)for(let t=s;t<=r;t++){const{col:n,row:s}=this.getters.getMainCellPosition({sheetId:e,col:i,row:t});if(o=this.getters.getEvaluatedCell({sheetId:e,col:n,row:s}),o.formattedValue)return!0}}else for(let t of this.getters.getEvaluatedCellsInZone(e,i))if(t.formattedValue)return!0;return!1}getContiguousZone(e,t){let i,{top:o,bottom:n,left:s,right:r}=t,a=!1;for(;!a;)a=!0,o>0&&(i=this.checkExpandedValues(e,{left:s-1,right:r+1,top:o-1,bottom:o-1}),i&&(a=!1,o--)),s>0&&(i=this.checkExpandedValues(e,{left:s-1,right:s-1,top:o-1,bottom:n+1}),i&&(a=!1,s--)),r<this.getters.getNumberCols(e)-1&&(i=this.checkExpandedValues(e,{left:r+1,right:r+1,top:o-1,bottom:n+1}),i&&(a=!1,r++)),n<this.getters.getNumberRows(e)-1&&(i=this.checkExpandedValues(e,{left:s-1,right:r+1,top:n+1,bottom:n+1}),i&&(a=!1,n++));return{left:s,right:r,top:o,bottom:n}}hasHeader(e,t){if(1===t[0].length)return!1;let i=t.map((t=>t.map((({col:t,row:i})=>this.getters.getEvaluatedCell({sheetId:e,col:t,row:i}).type))));return i[0][0]===So.empty&&(i=i.slice(1)),!i.some((e=>e[0]===So.empty))&&!!i.some((e=>e[1]!==So.empty&&e[0]!==e[1]))}sortZone(e,t,i,o,n){const[s,r]=this.mainCellsSteps(e,i);let a=this.getters.getMainCellPosition({sheetId:e,col:t.col,row:t.row}).col,l=Object.assign({},i),c=this.mainCells(e,i);!n.sortHeaders&&this.hasHeader(e,c)&&(l.top+=r),c=this.mainCells(e,l);const h=function(e,t,i){const o=e.map(((e,t)=>({index:t,type:e.type,value:e.value})));let n=o.filter((e=>e.type===So.empty)),s=o.filter((e=>e.type!==So.empty));i&&(s.push(...n.map((e=>({...e,type:So.number,value:0})))),n=[]);const r="descending"===t?-1:1;return s.sort(((e,t)=>{let i=ns.indexOf(e.type)-ns.indexOf(t.type);return 0===i&&(i=e.type===So.text||e.type===So.error?e.value.localeCompare(t.value):e.value-t.value),r*i})).concat(n)}(c[a-l.left].map((e=>this.getters.getEvaluatedCell(e))),o,Boolean(n.emptyCellAsZero)),d=h.map((e=>e.index)),[u,g]=[c.length,c[0].length],p=[];for(let e=0;e<u;e++){for(let t=0;t<g;t++){let{col:i,row:o,sheetId:n}=c[e][d[t]];const a=this.getters.getCell({sheetId:n,col:i,row:o});let h=l.left+e*s,u=l.top+t*r,g={sheetId:n,col:h,row:u,content:""};if(a){let e=a.content;if(a.isFormula){const t=u-this.getters.getCellPosition(a.id).row,i=this.getters.createAdaptedRanges(a.dependencies,0,t,n);e=this.getters.buildFormulaContent(n,a,i)}g.style=a.style,g.content=e,g.format=a.format}p.push(g)}for(const e of p)this.dispatch("UPDATE_CELL",e)}}mainCellsSteps(e,t){const i=this.getters.getMerge({sheetId:e,col:t.left,row:t.top});return[i?i.right-i.left+1:1,i?i.bottom-i.top+1:1]}mainCells(e,t){const[i,o]=this.mainCellsSteps(e,t),n=[],s=ze(t.left,t.right+1,i),r=ze(t.top,t.bottom+1,o);for(const t of s){const i=[];n.push(i);for(const o of r)i.push({sheetId:e,col:t,row:o})}return n}}lb.getters=["getContiguousZone"];class cb extends Ov{constructor(){super(...arguments),this.showFormulas=!1}handle(e){if("SET_FORMULA_VISIBILITY"===e.type)this.showFormulas=e.show}shouldShowFormulas(){return this.showFormulas}}cb.getters=["shouldShowFormulas"];class hb extends Ov{constructor(){super(...arguments),this.ctx=document.createElement("canvas").getContext("2d")}allowDispatch(e){switch(e.type){case"AUTORESIZE_ROWS":case"AUTORESIZE_COLUMNS":try{this.getters.getSheet(e.sheetId);break}catch(e){return 27}}return 0}handle(e){switch(e.type){case"AUTORESIZE_COLUMNS":for(let t of e.cols){const i=this.getColMaxWidth(e.sheetId,t);0!==i&&this.dispatch("RESIZE_COLUMNS_ROWS",{elements:[t],dimension:"COL",size:i,sheetId:e.sheetId})}break;case"AUTORESIZE_ROWS":for(let t of e.rows)this.dispatch("RESIZE_COLUMNS_ROWS",{elements:[t],dimension:"ROW",size:null,sheetId:e.sheetId})}}getCellWidth(e){const t=this.getCellText(e),i=this.getters.getCellComputedStyle(e);let o=this.getTextWidth(t,i);this.getters.getConditionalIcon(e)&&(o+=function(e){return Ve(e)+2*P}(this.getters.getCellStyle(e)));if(this.getters.isFilterHeader(e)&&(o+=20),o>0&&(o+=2*z,"wrap"===this.getters.getCellStyle(e).wrapping)){const t=this.getters.getColSize(this.getters.getActiveSheetId(),e.col);return Math.min(t,o)}return o}getTextWidth(e,t){return Le(this.ctx,e,t)}getCellText(e,t=!1){const i=this.getters.getCell(e);return t&&(null==i?void 0:i.isFormula)?i.content:this.getters.getEvaluatedCell(e).formattedValue}getCellMultiLineText(e,t){const i=this.getters.getCellStyle(e),o=this.getters.getCellText(e,this.getters.shouldShowFormulas()),n=[];for(const e of o.split("\n")){const o=e.split(" ");if(!t){n.push(e);continue}let s="",r=t;for(let e of o){const o=this.splitWordToSpecificWidth(this.ctx,e,t,i),a=o.pop(),l=Le(this.ctx,a,i);if(o.length)""!==s&&(n.push(s),s="",r=t),o.forEach((e=>{n.push(e)})),s=a,r=t-l;else{const e=""===s?a:" "+a,o=Le(this.ctx,e,i);o<=r?(s+=e,r-=o):(n.push(s),s=a,r=t-l)}}""!==s&&n.push(s)}return n}getColDimensions(e,t){const i=this.getColRowOffset("COL",0,t,e),o=this.getters.getColSize(e,t);return{start:i,size:o,end:i+(this.getters.isColHidden(e,t)?0:o)}}getRowDimensions(e,t){const i=this.getColRowOffset("ROW",0,t,e),o=this.getters.getRowSize(e,t);return{start:i,size:o,end:i+(this.getters.isRowHidden(e,t)?0:o)}}getColRowOffset(e,t,i,o=this.getters.getActiveSheetId()){if(i<t)return-this.getColRowOffset(e,i,t);let n=0;for(let s=t;s<i;s++)this.getters.isHeaderHidden(o,e,s)||(n+="COL"===e?this.getters.getColSize(o,s):this.getters.getRowSize(o,s));return n}getColMaxWidth(e,t){const i=Xi(this.getters.getColsZone(e,t,t)).map((t=>this.getCellWidth({sheetId:e,...t})));return Math.max(0,...i)}splitWordToSpecificWidth(e,t,i,o){if(Le(e,t,o)<=i)return[t];const n=[];let s="";for(let r of t){Le(e,s+r,o)>i?(n.push(s),s=r):s+=r}return n.push(s),n}}hb.getters=["getCellWidth","getTextWidth","getCellText","getCellMultiLineText","getColDimensions","getRowDimensions","getColRowOffset"];class db{constructor(e,t,i,o){this.getters=t,this.dispatch=i,this.selection=o,this.operation=e,this.sheetId=t.getActiveSheetId()}isCutAllowed(e){return 0}isPasteAllowed(e,t){return 0}addMissingDimensions(e,t,i,o){const n=this.getters.getActiveSheetId(),s=t+o-this.getters.getNumberRows(n);s>0&&this.dispatch("ADD_COLUMNS_ROWS",{dimension:"ROW",base:this.getters.getNumberRows(n)-1,sheetId:n,quantity:s,position:"after"});const r=e+i-this.getters.getNumberCols(n);r>0&&this.dispatch("ADD_COLUMNS_ROWS",{dimension:"COL",base:this.getters.getNumberCols(n)-1,sheetId:n,quantity:r,position:"after"})}isColRowDirtyingClipboard(e,t){return!1}drawClipboard(e){}}class ub extends db{constructor(e,t,i,o,n){if(super(t,i,o,n),!e.length)return this.cells=[[]],this.zones=[],void(this.copiedTables=[]);const s=new Set(e.map((e=>e.left))),r=new Set(e.map((e=>e.right))),a=new Set(e.map((e=>e.top))),l=new Set(e.map((e=>e.bottom))),c=1===a.size&&1===l.size||1===s.size&&1===r.size?function(e){return e.reduce(((e,t)=>{const i=e.length;for(let o=0;o<i;o++)if(Hi(e[o],t))return e[o]=Vi(e[o],t),e;return e[i]=t,e}),[])}(e):[e[e.length-1]],h=c.map((e=>Xi(e))).flat(),d=[...new Set(h.map((e=>e.col)))].sort(((e,t)=>e-t)),u=[...new Set(h.map((e=>e.row)))].sort(((e,t)=>e-t)),g=[],p=i.getActiveSheetId();for(let e of u){let t=[];for(let o of d){const n={col:o,row:e,sheetId:p};t.push({cell:i.getCell(n),style:i.getCellComputedStyle(n),evaluatedCell:i.getEvaluatedCell(n),border:i.getCellBorder(n)||void 0,position:n})}g.push(t)}const m=[];for(const t of e)for(const e of this.getters.getFilterTablesInZone(p,t)){const t=[];for(const i of ze(e.zone.left,e.zone.right+1))t.push(this.getters.getFilterValues({sheetId:p,col:i,row:e.zone.top}));m.push({filtersValues:t,zone:e.zone})}this.cells=g,this.zones=c,this.copiedTables=m}isCutAllowed(e){return 1!==e.length?19:0}isPasteAllowed(e,t){const i=this.getters.getActiveSheetId();if("CUT"===this.operation&&void 0!==(null==t?void 0:t.pasteOption))return 21;if(e.length>1&&(this.cells.length>1||this.cells[0].length>1))return 20;const o=this.cells.length,n=this.cells[0].length;for(let t of this.getPasteZones(e))if(this.getters.doesIntersectMerge(i,t)&&(e.length>1||!this.getters.isSingleCellOrMerge(i,e[0])||o*n!=1))return 2;const{xSplit:s,ySplit:r}=this.getters.getPaneDivisions(i);for(const t of this.getPasteZones(e))if(t.left<s&&t.right>=s||t.top<r&&t.bottom>=r)return 75;return 0}paste(e,t){"COPY"===this.operation?this.pasteFromCopy(e,t):this.pasteFromCut(e,t);const i=this.cells.length,o=this.cells[0].length,n="CUT"===this.operation;(null==t?void 0:t.selectTarget)&&this.selectPastedZone(o,i,n,e)}pasteFromCopy(e,t){if(1===e.length){const i=this.cells.length,o=this.cells[0].length,n=this.pastedZones(e,o,i);for(const e of n)this.pasteZone(e.left,e.top,t)}else for(const i of e)for(let e=i.left;e<=i.right;e++)for(let o=i.top;o<=i.bottom;o++)this.pasteZone(e,o,t);void 0===(null==t?void 0:t.pasteOption)&&this.pasteCopiedTables(e)}pasteFromCut(e,t){this.clearClippedZones();const i=e[0];this.pasteZone(i.left,i.top,t),this.dispatch("MOVE_RANGES",{target:this.zones,sheetId:this.sheetId,targetSheetId:this.getters.getActiveSheetId(),col:i.left,row:i.top});for(const e of this.copiedTables)this.dispatch("REMOVE_FILTER_TABLE",{sheetId:this.getters.getActiveSheetId(),target:[e.zone]});this.pasteCopiedTables(e)}pastedZones(e,t,i){const o=e[0],n=Math.max(1,Math.floor((o.right+1-o.left)/t)),s=Math.max(1,Math.floor((o.bottom+1-o.top)/i)),r=[];for(let e=0;e<n;e++)for(let n=0;n<s;n++){const s=o.top+n*i,a=o.left+e*t;r.push({left:a,top:s,bottom:s+i-1,right:a+t-1})}return r}getPasteZones(e){const t=this.cells;if(!t.length||!t[0].length)return e;const i=[],o=t.length,n=t[0].length,s=e[e.length-1],r=s.left,a=s.top,l=Math.max(1,Math.floor((s.right+1-r)/n)),c=Math.max(1,Math.floor((s.bottom+1-a)/o));for(let e=1;e<=l;e++)for(let t=1;t<=c;t++)i.push({left:r,top:a,right:r-1+e*n,bottom:a-1+t*o});return i}selectPastedZone(e,t,i,o){const n=o[0],s=n.left,r=n.top;if(t>1||e>1||i){const n=this.pastedZones(o,e,t),a=i?n[0]:Vi(...n);this.selection.selectZone({cell:{col:s,row:r},zone:a})}}clearClippedZones(){for(const e of this.cells)for(const t of e)t.cell&&this.dispatch("CLEAR_CELL",t.position);this.dispatch("CLEAR_FORMATTING",{sheetId:this.sheetId,target:this.zones})}pasteZone(e,t,i){const o=this.cells.length,n=this.cells[0].length,s="onlyValue"!==(null==i?void 0:i.pasteOption)&&(null==i?void 0:i.shouldPasteCF),r=this.getters.getActiveSheetId();this.addMissingDimensions(n,o,e,t);for(let a=0;a<o;a++){const o=this.cells[a];for(let l=0;l<n;l++){const n=o[l],c={col:e+l,row:t+a,sheetId:r};"CUT"!==this.operation&&this.pasteMergeIfExist(n.position,c),this.pasteCell(n,c,this.operation,i),s&&this.dispatch("PASTE_CONDITIONAL_FORMAT",{origin:n.position,target:c,operation:this.operation})}}}pasteCell(e,t,i,o){const{sheetId:n,col:s,row:r}=t,a=this.getters.getEvaluatedCell(t);if("onlyValue"!==(null==o?void 0:o.pasteOption)){const i=this.getters.getCellBorder(t),o=e.border,a={top:(null==i?void 0:i.top)||(null==o?void 0:o.top),bottom:(null==i?void 0:i.bottom)||(null==o?void 0:o.bottom),left:(null==i?void 0:i.left)||(null==o?void 0:o.left),right:(null==i?void 0:i.right)||(null==o?void 0:o.right)};this.dispatch("SET_BORDER",{sheetId:n,col:s,row:r,border:a})}if(e.cell){if("onlyFormat"===(null==o?void 0:o.pasteOption))return void this.dispatch("UPDATE_CELL",{...t,style:e.cell.style,format:e.evaluatedCell.format});if("onlyValue"===(null==o?void 0:o.pasteOption)){const i=li(e.evaluatedCell.value);return void this.dispatch("UPDATE_CELL",{...t,content:i})}let a=e.cell.content;if(e.cell.isFormula&&"COPY"===i){const t=s-e.position.col,o=r-e.position.row;a=this.getUpdatedContent(n,e.cell,t,o,i)}this.dispatch("UPDATE_CELL",{...t,content:a,style:e.cell.style||null,format:e.cell.format})}else a&&("onlyValue"===(null==o?void 0:o.pasteOption)?this.dispatch("UPDATE_CELL",{...t,content:""}):"onlyFormat"===(null==o?void 0:o.pasteOption)?this.dispatch("UPDATE_CELL",{...t,style:null,format:""}):this.dispatch("CLEAR_CELL",t))}getUpdatedContent(e,t,i,o,n){const s=this.getters.createAdaptedRanges(t.dependencies,i,o,e);return this.getters.buildFormulaContent(e,t,s)}pasteMergeIfExist(e,t){let{sheetId:i,col:o,row:n}=e;const{col:s,row:r}=this.getters.getMainCellPosition(e);if(s===o&&r===n){const s=this.getters.getMerge(e);if(!s)return;({sheetId:i,col:o,row:n}=t),this.dispatch("ADD_MERGE",{sheetId:i,force:!0,target:[{left:o,top:n,right:o+s.right-s.left,bottom:n+s.bottom-s.top}]})}}pasteCopiedTables(e){const t=this.getters.getActiveSheetId(),i=e[0],o=this.zones[0],n=[i.left-o.left,i.top-o.top];for(const e of this.copiedTables){const i=Yi(e.zone,"both","MOVE",n);this.dispatch("CREATE_FILTER_TABLE",{sheetId:t,target:[i]});for(const o of ze(0,e.filtersValues.length))this.dispatch("UPDATE_FILTER",{sheetId:t,col:i.left+o,row:i.top,values:e.filtersValues[o]})}}getClipboardContent(){return{[Co.PlainText]:this.getPlainTextContent(),[Co.Html]:this.getHTMLContent()}}getPlainTextContent(){return this.cells.map((e=>e.map((e=>e.cell?this.getters.getCellText(e.position,this.getters.shouldShowFormulas()):"")).join("\t"))).join("\n")||"\t"}getHTMLContent(){if(1==this.cells.length&&1==this.cells[0].length)return this.getters.getCellText(this.cells[0][0].position);let e='<table border="1" style="border-collapse:collapse">';for(const t of this.cells){e+="<tr>";for(const i of t){e+=`<td style="${ho(lo(i.style))}">`+zm(this.getters.getCellText(i.position))+"</td>"}e+="</tr>"}return e+="</table>",e}isColRowDirtyingClipboard(e,t){if(!this.zones)return!1;for(let i of this.zones){if("COL"===t&&e<=i.right)return!0;if("ROW"===t&&e<=i.bottom)return!0}return!1}drawClipboard(e){const{ctx:t,thinLineWidth:i}=e;if(this.sheetId===this.getters.getActiveSheetId()&&this.zones&&this.zones.length){t.setLineDash([8,5]),t.strokeStyle=E,t.lineWidth=3.3*i;for(const e of this.zones){const{x:i,y:o,width:n,height:s}=this.getters.getVisibleRect(e);n>0&&s>0&&t.strokeRect(i,o,n,s)}}}}class gb{constructor(e,t,i){this.operation=e,this.getters=t,this.dispatch=i,this.sheetId=t.getActiveSheetId();const o=t.getSelectedFigureId();if(!o)throw new Error("No figure selected");const n=t.getFigure(this.sheetId,o);if(!n)throw new Error(`No figure for the given id: ${o}`);switch(this.copiedFigure={...n},n.tag){case"chart":this.copiedFigureContent=new pb(i,t,this.sheetId,o);break;case"image":this.copiedFigureContent=new mb(i,t,this.sheetId,o);break;default:throw new Error(`Unknow tag '${n.tag}' for the given figure id: ${o}`)}}isCutAllowed(e){return 0}isPasteAllowed(e,t){return 0===e.length?73:void 0!==(null==t?void 0:t.pasteOption)?22:0}paste(e){const t=this.getters.getActiveSheetId(),i={x:this.getters.getColDimensions(t,e[0].left).start,y:this.getters.getRowDimensions(t,e[0].top).start},o={height:this.copiedFigure.height,width:this.copiedFigure.width},n=(new Oi).uuidv4();this.copiedFigureContent.paste(t,n,i,o),"CUT"===this.operation&&this.dispatch("DELETE_FIGURE",{sheetId:this.copiedFigureContent.sheetId,id:this.copiedFigure.id}),this.dispatch("SELECT_FIGURE",{id:n})}getClipboardContent(){return{[Co.PlainText]:"\t"}}isColRowDirtyingClipboard(e,t){return!1}drawClipboard(e){}}class pb{constructor(e,t,i,o){this.dispatch=e,this.sheetId=i;const n=t.getChart(o);if(!n)throw new Error(`No chart for the given id: ${o}`);this.copiedChart=n.copyInSheetId(i)}paste(e,t,i,o){const n=this.copiedChart.copyInSheetId(e);this.dispatch("CREATE_CHART",{id:t,sheetId:e,position:i,size:o,definition:n.getDefinition()})}}class mb{constructor(e,t,i,o){this.dispatch=e,this.sheetId=i;const n=t.getImage(o);this.copiedImage=Ne(n)}paste(e,t,i,o){const n=Ne(this.copiedImage);this.dispatch("CREATE_IMAGE",{figureId:t,sheetId:e,position:i,size:o,definition:n})}}class fb extends db{constructor(e,t,i,o){super("COPY",t,i,o),this.values=e.replace(/\r/g,"").split("\n").map((e=>e.split("\t")))}isPasteAllowed(e,t){const i=this.getters.getActiveSheetId(),o=this.getPasteZone(e);return this.getters.doesIntersectMerge(i,o)?2:0}paste(e){const t=this.values,i=this.getPasteZone(e),{left:o,top:n}=i,{width:s,height:r}=Zi(i),a=this.getters.getActiveSheetId();this.addMissingDimensions(s,r,o,n);for(let e=0;e<t.length;e++)for(let i=0;i<t[e].length;i++)this.dispatch("UPDATE_CELL",{row:n+e,col:o+i,content:t[e][i],sheetId:a});const l={left:o,top:n,right:o+s-1,bottom:n+r-1};this.selection.selectZone({cell:{col:o,row:n},zone:l})}getClipboardContent(){return{[Co.PlainText]:this.values.map((e=>e.join("\t"))).join("\n")}}getPasteZone(e){const t=this.values.length,i=Math.max(...this.values.map((e=>e.length))),{left:o,top:n}=e[0];return{top:n,left:o,bottom:n+t-1,right:o+i-1}}}class vb extends Ov{constructor(){super(...arguments),this.status="invisible",this._isPaintingFormat=!1}allowDispatch(e){switch(e.type){case"CUT":const t=e.target||this.getters.getSelectedZones();return this.getClipboardState(t,e.type).isCutAllowed(t);case"PASTE":if(!this.state)return 23;const i=e.pasteOption||(this._isPaintingFormat?"onlyFormat":void 0);return this.state.isPasteAllowed(e.target,{pasteOption:i});case"PASTE_FROM_OS_CLIPBOARD":return new fb(e.text,this.getters,this.dispatch,this.selection).isPasteAllowed(e.target);case"INSERT_CELL":{const{cut:t,paste:i}=this.getInsertCellsTargets(e.zone,e.shiftDimension);return this.getClipboardStateForCopyCells(t,"CUT").isPasteAllowed(i)}case"DELETE_CELL":{const{cut:t,paste:i}=this.getDeleteCellsTargets(e.zone,e.shiftDimension);return this.getClipboardStateForCopyCells(t,"CUT").isPasteAllowed(i)}}return 0}handle(e){var t,i;switch(e.type){case"COPY":case"CUT":const o="target"in e&&e.target||this.getters.getSelectedZones();this.state=this.getClipboardState(o,e.type),this.status="visible";break;case"PASTE":if(!this.state)break;const n=e.pasteOption||(this._isPaintingFormat?"onlyFormat":void 0);this._isPaintingFormat=!1,this.state.paste(e.target,{pasteOption:n,shouldPasteCF:!0,selectTarget:!0}),"CUT"===this.state.operation&&(this.state=void 0),this.status="invisible";break;case"CLEAN_CLIPBOARD_HIGHLIGHT":this.status="invisible";break;case"DELETE_CELL":{const{cut:t,paste:i}=this.getDeleteCellsTargets(e.zone,e.shiftDimension);if(!Fi(t[0])){for(const{col:t,row:i}of Xi(e.zone))this.dispatch("CLEAR_CELL",{col:t,row:i,sheetId:this.getters.getActiveSheetId()});break}this.getClipboardStateForCopyCells(t,"CUT").paste(i);break}case"INSERT_CELL":{const{cut:t,paste:i}=this.getInsertCellsTargets(e.zone,e.shiftDimension);this.getClipboardStateForCopyCells(t,"CUT").paste(i);break}case"ADD_COLUMNS_ROWS":if(this.status="invisible","CUT"!==(null===(t=this.state)||void 0===t?void 0:t.operation))return;this.state.isColRowDirtyingClipboard("before"===e.position?e.base:e.base+1,e.dimension)&&(this.state=void 0);break;case"REMOVE_COLUMNS_ROWS":if(this.status="invisible","CUT"!==(null===(i=this.state)||void 0===i?void 0:i.operation))return;for(let t of e.elements){if(this.state.isColRowDirtyingClipboard(t,e.dimension)){this.state=void 0;break}}this.status="invisible";break;case"PASTE_FROM_OS_CLIPBOARD":new fb(e.text,this.getters,this.dispatch,this.selection).paste(e.target),this.status="invisible";break;case"ACTIVATE_PAINT_FORMAT":{const e=this.getters.getSelectedZones();this.state=this.getClipboardStateForCopyCells(e,"COPY"),this._isPaintingFormat=!0,this.status="visible";break}default:Io(e)&&(this.status="invisible")}}getClipboardContent(){var e;return(null===(e=this.state)||void 0===e?void 0:e.getClipboardContent())||{[Co.PlainText]:"\t"}}getClipboardTextContent(){var e;return(null===(e=this.state)||void 0===e?void 0:e.getClipboardContent()[Co.PlainText])||"\t"}isCutOperation(){return!!this.state&&"CUT"===this.state.operation}isPaintingFormat(){return this._isPaintingFormat}getDeleteCellsTargets(e,t){const i=this.getters.getActiveSheetId();let o;return o="COL"===t?{...e,left:e.right+1,right:this.getters.getNumberCols(i)-1}:{...e,top:e.bottom+1,bottom:this.getters.getNumberRows(i)-1},{cut:[o],paste:[e]}}getInsertCellsTargets(e,t){const i=this.getters.getActiveSheetId();let o,n;return"COL"===t?(o={...e,right:this.getters.getNumberCols(i)-1},n={...e,left:e.right+1,right:e.right+1}):(o={...e,bottom:this.getters.getNumberRows(i)-1},n={...e,top:e.bottom+1,bottom:this.getters.getNumberRows(i)-1}),{cut:[o],paste:[n]}}getClipboardStateForCopyCells(e,t){return new ub(e,t,this.getters,this.dispatch,this.selection)}getClipboardState(e,t){return this.getters.getSelectedFigureId()?new gb(t,this.getters,this.dispatch):new ub(e,t,this.getters,this.dispatch,this.selection)}drawGrid(e){"visible"===this.status&&this.state&&this.state.drawClipboard(e)}}function bb(e){if("REFERENCE"!==e.type)return e;const{xc:t,sheetName:i}=kt(e.value),[o,n]=t.split(":"),s=i?`${Fe(i)}!`:"",r=Sb(o),a=n?`:${Sb(n)}`:"";return{...e,value:s+r+a}}function Sb(e){switch(function(e){if(function(e){return e.startsWith("$")&&e.length>1&&e.slice(1).includes("$")}(e))return"colrow";if(function(e){return e.startsWith("$")}(e))return"col";if(function(e){return e.includes("$",1)}(e))return"row";return"none"}(e)){case"none":e=Cb(e,"colrow");break;case"colrow":e=Cb(e,"row");break;case"row":e=Cb(e,"col");break;case"col":e=Cb(e,"none")}return e}function Cb(e,t){let i;switch(e=e.replace(/\$/g,""),t){case"col":return"$"+e;case"row":return i=e.search(/[0-9]/),e.slice(0,i)+"$"+e.slice(i);case"colrow":return i=e.search(/[0-9]/),"$"+(e=e.slice(0,i)+"$"+e.slice(i));case"none":return e}}vb.layers=[2],vb.getters=["getClipboardContent","getClipboardTextContent","isCutOperation","isPaintingFormat"];const Eb=s("The cell you are trying to edit has been deleted.");class wb extends Ov{constructor(){super(...arguments),this.col=0,this.row=0,this.mode="inactive",this.sheetId="",this.currentContent="",this.currentTokens=[],this.selectionStart=0,this.selectionEnd=0,this.selectionInitialStart=0,this.initialContent="",this.previousRef="",this.previousRange=void 0,this.colorIndexByRange={}}allowDispatch(e){switch(e.type){case"CHANGE_COMPOSER_CURSOR_SELECTION":return this.validateSelection(this.currentContent.length,e.start,e.end);case"SET_CURRENT_CONTENT":return e.selection?this.validateSelection(e.content.length,e.selection.start,e.selection.end):0;case"START_EDITION":if(e.selection){const t=e.text||this.getComposerContent(this.getters.getActivePosition());return this.validateSelection(t.length,e.selection.start,e.selection.end)}return 0;default:return 0}}handleEvent(e){if("selecting"===this.mode)if("newAnchor"===e.mode)this.insertSelectedRange(e.anchor.zone);else this.replaceSelectedRanges(e.anchor.zone)}handle(e){switch(e.type){case"CHANGE_COMPOSER_CURSOR_SELECTION":this.selectionStart=e.start,this.selectionEnd=e.end;break;case"STOP_COMPOSER_RANGE_SELECTION":this.isSelectingForComposer()&&(this.mode="editing");break;case"START_EDITION":"inactive"!==this.mode&&e.text?this.setContent(e.text,e.selection):this.startEdition(e.text,e.selection),this.updateRangeColor();break;case"STOP_EDITION":e.cancel?(this.cancelEditionAndActivateSheet(),this.resetContent()):this.stopEdition(),this.colorIndexByRange={};break;case"SET_CURRENT_CONTENT":this.setContent(e.content,e.selection,!0),this.updateRangeColor();break;case"REPLACE_COMPOSER_CURSOR_SELECTION":this.replaceSelection(e.text);break;case"SELECT_FIGURE":this.cancelEditionAndActivateSheet(),this.resetContent();break;case"ADD_COLUMNS_ROWS":this.onAddElements(e);break;case"REMOVE_COLUMNS_ROWS":"COL"===e.dimension?this.onColumnsRemoved(e):this.onRowsRemoved(e);break;case"START_CHANGE_HIGHLIGHT":this.dispatch("STOP_COMPOSER_RANGE_SELECTION");const t=this.getters.getRangeFromRangeData(e.range),i=this.currentTokens.filter((e=>"REFERENCE"===e.type)).find((e=>{const{xc:i,sheetName:o}=kt(e.value),n=o||this.getters.getSheetName(this.sheetId),s=this.getters.getActiveSheetId();if(this.getters.getSheetName(s)!==n)return!1;const r=this.getters.getRangeFromSheetXC(s,i);return Bi(this.getters.expandZone(s,r.zone),t.zone)}));this.previousRef=i.value,this.previousRange=this.getters.getRangeFromSheetXC(this.getters.getActiveSheetId(),this.previousRef),this.selectionInitialStart=i.start;break;case"CHANGE_HIGHLIGHT":const o=this.getters.getRangeFromRangeData(e.range),n=this.getRangeReference(o,this.previousRange.parts);this.selectionStart=this.selectionInitialStart,this.selectionEnd=this.selectionInitialStart+this.previousRef.length,this.replaceSelection(n),this.previousRef=n,this.selectionStart=this.currentContent.length,this.selectionEnd=this.currentContent.length;break;case"ACTIVATE_SHEET":if(this.currentContent.startsWith("=")||(this.cancelEdition(),this.resetContent()),e.sheetIdFrom!==e.sheetIdTo){const t=this.getters.getActivePosition(),{col:i,row:o}=this.getters.getNextVisibleCellPosition({sheetId:e.sheetIdTo,col:t.col,row:t.row}),n=this.getters.expandZone(e.sheetIdTo,Ji({col:i,row:o}));this.selection.resetAnchor(this,{cell:{col:i,row:o},zone:n})}break;case"DELETE_SHEET":case"UNDO":case"REDO":!!this.getters.tryGetSheet(this.sheetId)||"inactive"===this.mode||(this.sheetId=this.getters.getActiveSheetId(),this.cancelEditionAndActivateSheet(),this.resetContent(),this.ui.notifyUI({type:"ERROR",text:Eb}));break;case"CYCLE_EDITION_REFERENCES":this.cycleReferences()}}getEditionMode(){return this.mode}getCurrentContent(){return"inactive"===this.mode?this.getComposerContent(this.getters.getActivePosition()):this.currentContent}getEditionSheet(){return this.sheetId}getComposerSelection(){return{start:this.selectionStart,end:this.selectionEnd}}getCurrentEditedCell(){return{sheetId:this.sheetId,col:this.col,row:this.row}}isSelectingForComposer(){return"selecting"===this.mode}showSelectionIndicator(){return this.isSelectingForComposer()&&this.canStartComposerRangeSelection()}getCurrentTokens(){return this.currentTokens}getTokenAtCursor(){const e=Math.min(this.selectionStart,this.selectionEnd),t=Math.max(this.selectionStart,this.selectionEnd);return e===t&&0===t?void 0:this.currentTokens.find((i=>i.start<=e&&i.end>=t))}cycleReferences(){const e=this.getTokensInSelection(),t=e.filter((e=>"REFERENCE"===e.type));if(0===t.length)return;const i=e.map(bb).map((e=>e.value)).join(""),o=this.currentContent,n=e[0].start,s=e[e.length-1].end,r=o.slice(0,n)+i+o.slice(s),a=r.length-o.length,l={start:t[0].start,end:t[t.length-1].end+a};1===t.length&&this.selectionStart===this.selectionEnd&&(l.start=l.end),this.dispatch("SET_CURRENT_CONTENT",{content:r,selection:l})}validateSelection(e,t,i){return t>=0&&t<=e&&i>=0&&i<=e?0:46}onColumnsRemoved(e){if(e.elements.includes(this.col)&&"inactive"!==this.mode)return this.dispatch("STOP_EDITION",{cancel:!0}),void this.ui.notifyUI({type:"ERROR",text:Eb});const{top:t,left:i}=Pi({left:this.col,right:this.col,top:this.row,bottom:this.row},"left",[...e.elements]);this.col=i,this.row=t}onRowsRemoved(e){if(e.elements.includes(this.row)&&"inactive"!==this.mode)return this.dispatch("STOP_EDITION",{cancel:!0}),void this.ui.notifyUI({type:"ERROR",text:Eb});const{top:t,left:i}=Pi({left:this.col,right:this.col,top:this.row,bottom:this.row},"top",[...e.elements]);this.col=i,this.row=t}onAddElements(e){const{top:t,left:i}=Li({left:this.col,right:this.col,top:this.row,bottom:this.row},"COL"===e.dimension?"left":"top",e.base,e.position,e.quantity);this.col=i,this.row=t}startComposerRangeSelection(){if(this.sheetId===this.getters.getActiveSheetId()){const e=Ji({col:this.col,row:this.row});this.selection.resetAnchor(this,{cell:{col:this.col,row:this.row},zone:e})}this.mode="selecting",this.selectionInitialStart=this.selectionStart}startEdition(e,t){var i;const o=this.getters.getActiveCell();e&&(null===(i=o.format)||void 0===i?void 0:i.includes("%"))&&Yt(e)&&(t=t||{start:e.length,end:e.length},e=`${e}%`);const{col:n,row:s,sheetId:r}=this.getters.getActivePosition();this.col=n,this.sheetId=r,this.row=s,this.initialContent=this.getComposerContent({sheetId:r,col:n,row:s}),this.mode="editing",this.setContent(e||this.initialContent,t),this.colorIndexByRange={};const a=Ji({col:this.col,row:this.row});this.selection.capture(this,{cell:{col:this.col,row:this.row},zone:a},{handleEvent:this.handleEvent.bind(this),release:()=>{this.stopEdition()}})}stopEdition(){if("inactive"!==this.mode){this.cancelEditionAndActivateSheet();const e=this.col,t=this.row;let i=this.currentContent;if(!(this.initialContent!==i))return;if(i){const o=this.getters.getActiveSheetId(),n=this.getters.getEvaluatedCell({sheetId:o,col:this.col,row:this.row});if(i.startsWith("=")){const e=this.currentTokens.filter((e=>"LEFT_PAREN"===e.type)).length,t=this.currentTokens.filter((e=>"RIGHT_PAREN"===e.type)).length,o=e-t;o>0&&(i+=ot(new Array(o).fill(")")))}else n.link&&(i=je(i,n.link.url));this.dispatch("UPDATE_CELL",{sheetId:this.sheetId,col:e,row:t,content:i})}else this.dispatch("UPDATE_CELL",{sheetId:this.sheetId,content:"",col:e,row:t});this.setContent("")}}cancelEditionAndActivateSheet(){if("inactive"===this.mode)return;this.cancelEdition();this.getters.getActiveSheetId()!==this.sheetId&&this.dispatch("ACTIVATE_SHEET",{sheetIdFrom:this.getters.getActiveSheetId(),sheetIdTo:this.sheetId})}getComposerContent(e){const t=this.getters.getCell(e);if(null==t?void 0:t.isFormula)return t.content;const{format:i,value:o,type:n,formattedValue:s}=this.getters.getEvaluatedCell(e);switch(n){case So.text:case So.empty:return o;case So.boolean:return s;case So.error:return(null==t?void 0:t.content)||"";case So.number:return i&&ui(i)?s:this.numberComposerContent(o,i)}}numberComposerContent(e,t){return(null==t?void 0:t.includes("%"))?100*e+"%":function(e){const{integerDigits:t,decimalDigits:i}=di(e,20);return i?`${t}.${i}`:t}(e)}cancelEdition(){"inactive"!==this.mode&&(this.mode="inactive",this.selection.release(this))}resetContent(){this.setContent(this.initialContent||"")}setContent(e,t,i){const o=this.currentContent!==e;this.currentContent=e,t?(this.selectionStart=t.start,this.selectionEnd=t.end):this.selectionStart=this.selectionEnd=e.length,(o||"inactive"!==this.mode)&&(this.currentTokens=e.startsWith("=")?gv(e):[],this.currentTokens.length>100&&i&&this.ui.notifyUI({type:"ERROR",text:s("This formula has over 100 parts. It can't be processed properly, consider splitting it into multiple cells")})),this.canStartComposerRangeSelection()&&this.startComposerRangeSelection()}insertSelectedRange(e){const t=Math.min(this.selectionStart,this.selectionEnd),i=this.getZoneReference(e);this.canStartComposerRangeSelection()?(this.insertText(i,t),this.selectionInitialStart=t):(this.insertText(","+i,t),this.selectionInitialStart=t+1)}replaceSelectedRanges(e){const t=this.getZoneReference(e);this.replaceText(t,this.selectionInitialStart,this.selectionEnd)}getZoneReference(e,t=[{colFixed:!1,rowFixed:!1}]){const i=this.getters.getActiveSheetId();let o=this.getters.zoneToXC(i,e,t);if(this.getters.getEditionSheet()!==this.getters.getActiveSheetId()){o=`${Fe(this.getters.getSheetName(this.getters.getActiveSheetId()))}!${o}`}return o}getRangeReference(e,t=[{colFixed:!1,rowFixed:!1}]){let i=[...t];1===t.length&&to(e.zone)>1?i.push({...t[0]}):2===t.length&&1===to(e.zone)&&i.pop();const o=e.clone({parts:i});return this.getters.getSelectionRangeString(o,this.getters.getEditionSheet())}replaceSelection(e){const t=Math.min(this.selectionStart,this.selectionEnd),i=Math.max(this.selectionStart,this.selectionEnd);this.replaceText(e,t,i)}replaceText(e,t,i){this.currentContent=this.currentContent.slice(0,t)+this.currentContent.slice(i,this.currentContent.length),this.insertText(e,t)}insertText(e,t){const i=this.currentContent.slice(0,t)+e+this.currentContent.slice(t),o=t+e.length;this.dispatch("SET_CURRENT_CONTENT",{content:i,selection:{start:o,end:o}})}updateRangeColor(){if(!this.currentContent.startsWith("=")||"inactive"===this.mode)return;const e=this.getters.getEditionSheet(),t=this.getReferencedRanges().map((t=>this.getters.getRangeString(t,e))),i={};for(const e of t)void 0!==this.colorIndexByRange[e]&&(i[e]=this.colorIndexByRange[e]);const o=new Set(Object.values(i));let n=0;const s=()=>{for(;o.has(n);)n++;return o.add(n),n};for(const e of t){const t=e in i?i[e]:s();i[e]=t}this.colorIndexByRange=i}getComposerHighlights(){if(!this.currentContent.startsWith("=")||"inactive"===this.mode)return[];const e=this.getters.getEditionSheet(),t=e=>{const t=this.colorIndexByRange[e];return pt[t%pt.length]};return this.getReferencedRanges().map((i=>{const o=this.getters.getRangeString(i,e);return{zone:i.zone,color:t(o),sheetId:i.sheetId}}))}getReferencedRanges(){const e=this.getters.getEditionSheet();return this.currentTokens.filter((e=>"REFERENCE"===e.type)).map((t=>this.getters.getRangeFromSheetXC(e,t.value)))}canStartComposerRangeSelection(){if(this.currentContent.startsWith("=")){const e=this.getTokenAtCursor();if(!e)return!1;const t=this.currentTokens.map((e=>e.start)).indexOf(e.start);let i=t,o=e;for(;!["COMMA","LEFT_PAREN","OPERATOR"].includes(o.type)||hf.includes(o.value);){if("SPACE"!==o.type||i<1)return!1;i--,o=this.currentTokens[i]}for(i=t+1,o=this.currentTokens[i];o&&!["COMMA","RIGHT_PAREN","OPERATOR"].includes(o.type);){if("SPACE"!==o.type)return!1;i++,o=this.currentTokens[i]}return!0}return!1}getTokensInSelection(){const e=Math.min(this.selectionStart,this.selectionEnd),t=Math.max(this.selectionStart,this.selectionEnd);return this.currentTokens.filter((i=>i.start<=e&&i.end>=e||i.start>=e&&i.start<t))}}wb.getters=["getEditionMode","isSelectingForComposer","showSelectionIndicator","getCurrentContent","getEditionSheet","getComposerSelection","getCurrentTokens","getTokenAtCursor","getComposerHighlights","getCurrentEditedCell"];const yb=[{name:s("Sum"),types:[So.number],compute:e=>Sa.compute([e])},{name:s("Avg"),types:[So.number],compute:e=>Oa.compute([e])},{name:s("Min"),types:[So.number],compute:e=>Za.compute([e])},{name:s("Max"),types:[So.number],compute:e=>$a.compute([e])},{name:s("Count"),types:[So.number,So.text,So.boolean,So.error],compute:e=>Ua.compute([e])},{name:s("Count Numbers"),types:[So.number,So.text,So.boolean,So.error],compute:e=>Pa.compute([e])}];class xb extends Ov{constructor(e){super(e),this.gridSelection={anchor:{cell:{col:0,row:0},zone:{top:0,left:0,bottom:0,right:0}},zones:[{top:0,left:0,bottom:0,right:0}]},this.selectedFigureId=null,this.sheetsData={},this.activeSheet=null,this.moveClient=e.moveClient}allowDispatch(e){switch(e.type){case"ACTIVATE_SHEET":try{this.getters.getSheet(e.sheetIdTo);break}catch(e){return 27}case"MOVE_COLUMNS_ROWS":return this.isMoveElementAllowed(e)}return 0}handleEvent(e){const t=e.anchor;let i=[];switch(e.mode){case"overrideSelection":i=[t.zone];break;case"updateAnchor":i=[...this.gridSelection.zones];const o=i.findIndex((t=>Bi(t,e.previousAnchor.zone)));o>=0&&(i[o]=t.zone);break;case"newAnchor":i=[...this.gridSelection.zones,t.zone]}this.setSelectionMixin(e.anchor,i),this.selection.resetDefaultAnchor(this,Ne(this.gridSelection.anchor));const{col:o,row:n}=this.gridSelection.anchor.cell;this.moveClient({sheetId:this.getters.getActiveSheetId(),col:o,row:n}),this.selectedFigureId=null}handle(e){switch(e.type){case"START_EDITION":case"ACTIVATE_SHEET":this.selectedFigureId=null;break;case"DELETE_FIGURE":this.selectedFigureId===e.id&&(this.selectedFigureId=null);break;case"DELETE_SHEET":this.selectedFigureId&&this.getters.getFigure(e.sheetId,this.selectedFigureId)&&(this.selectedFigureId=null)}switch(e.type){case"START":const t=this.getters.getVisibleSheetIds()[0];this.dispatch("ACTIVATE_SHEET",{sheetIdTo:t,sheetIdFrom:t});const{col:i,row:o}=this.getters.getNextVisibleCellPosition({sheetId:t,col:0,row:0});this.selectCell(i,o),this.selection.registerAsDefault(this,this.gridSelection.anchor,{handleEvent:this.handleEvent.bind(this)}),this.moveClient({sheetId:t,col:0,row:0});break;case"ACTIVATE_SHEET":if(this.getters.isSheetVisible(e.sheetIdTo)||this.dispatch("SHOW_SHEET",{sheetId:e.sheetIdTo}),this.setActiveSheet(e.sheetIdTo),this.sheetsData[e.sheetIdFrom]={gridSelection:Ne(this.gridSelection)},e.sheetIdTo in this.sheetsData)Object.assign(this,this.sheetsData[e.sheetIdTo]),this.selection.resetDefaultAnchor(this,Ne(this.gridSelection.anchor));else{const{col:t,row:i}=this.getters.getNextVisibleCellPosition({sheetId:e.sheetIdTo,col:0,row:0});this.selectCell(t,i)}break;case"REMOVE_COLUMNS_ROWS":{const t=this.getters.getActiveSheetId();if(e.sheetId===t){"COL"===e.dimension?this.onColumnsRemoved(e):this.onRowsRemoved(e);const{col:i,row:o}=this.gridSelection.anchor.cell;this.moveClient({sheetId:t,col:i,row:o})}break}case"ADD_COLUMNS_ROWS":{const t=this.getters.getActiveSheetId();if(e.sheetId===t){this.onAddElements(e);const{col:i,row:o}=this.gridSelection.anchor.cell;this.moveClient({sheetId:t,col:i,row:o})}break}case"MOVE_COLUMNS_ROWS":e.sheetId===this.getActiveSheetId()&&this.onMoveElements(e);break;case"SELECT_FIGURE":this.selectedFigureId=e.id;break;case"ACTIVATE_NEXT_SHEET":this.activateNextSheet("right");break;case"ACTIVATE_PREVIOUS_SHEET":this.activateNextSheet("left");break;case"HIDE_SHEET":e.sheetId===this.getActiveSheetId()&&this.dispatch("ACTIVATE_SHEET",{sheetIdFrom:e.sheetId,sheetIdTo:this.getters.getVisibleSheetIds()[0]});break;case"UNDO":case"REDO":case"DELETE_SHEET":const n=Object.keys(this.sheetsData).filter((e=>!this.getters.tryGetSheet(e)));for(const e of n)delete this.sheetsData[e];for(const e in this.sheetsData){const t=this.clipSelection(e,this.sheetsData[e].gridSelection);this.sheetsData[e]={gridSelection:Ne(t)}}if(!this.getters.tryGetSheet(this.getters.getActiveSheetId())){const e=this.getters.getVisibleSheetIds();if(this.activeSheet=this.getters.getSheet(e[0]),this.activeSheet.id in this.sheetsData){const{anchor:e}=this.clipSelection(this.activeSheet.id,this.sheetsData[this.activeSheet.id].gridSelection);this.selectCell(e.cell.col,e.cell.row)}else this.selectCell(0,0);const{col:t,row:i}=this.gridSelection.anchor.cell;this.moveClient({sheetId:this.getters.getActiveSheetId(),col:t,row:i})}const s=this.getters.getActiveSheetId();this.gridSelection.zones=this.gridSelection.zones.map((e=>this.getters.expandZone(s,e))),this.gridSelection.anchor.zone=this.getters.expandZone(s,this.gridSelection.anchor.zone),this.setSelectionMixin(this.gridSelection.anchor,this.gridSelection.zones)}this.selection.resetDefaultAnchor(this,Ne(this.gridSelection.anchor))}getActiveSheet(){return this.activeSheet}getActiveSheetId(){return this.activeSheet.id}getActiveCell(){return this.getters.getEvaluatedCell(this.getActivePosition())}getActiveCols(){const e=new Set;for(let t of this.gridSelection.zones)if(0===t.top&&t.bottom===this.getters.getNumberRows(this.getters.getActiveSheetId())-1)for(let i=t.left;i<=t.right;i++)e.add(i);return e}getActiveRows(){const e=new Set,t=this.getters.getActiveSheetId();for(let i of this.gridSelection.zones)if(0===i.left&&i.right===this.getters.getNumberCols(t)-1)for(let t=i.top;t<=i.bottom;t++)e.add(t);return e}getCurrentStyle(){const e=this.getters.getSelectedZone(),t=this.getters.getActiveSheetId();return this.getters.getCellStyle({sheetId:t,col:e.left,row:e.top})}getSelectedZones(){return Ne(this.gridSelection.zones)}getSelectedZone(){return Ne(this.gridSelection.anchor.zone)}getSelection(){return Ne(this.gridSelection)}getSelectedFigureId(){return this.selectedFigureId}getActivePosition(){return this.getters.getMainCellPosition({sheetId:this.getActiveSheetId(),col:this.gridSelection.anchor.cell.col,row:this.gridSelection.anchor.cell.row})}getSheetPosition(e){if(e===this.getters.getActiveSheetId())return this.getActivePosition();{const t=this.sheetsData[e];return t?{sheetId:e,col:t.gridSelection.anchor.cell.col,row:t.gridSelection.anchor.cell.row}:this.getters.getNextVisibleCellPosition({sheetId:e,col:0,row:0})}}getStatisticFnResults(){const e=new Set(this.gridSelection.zones.map((e=>this.getters.getEvaluatedCellsInZone(this.getters.getActiveSheetId(),e))).flat().filter((e=>e.type!==So.empty)));let t=new Set,i=[];for(let o of e)t.add(o.type),i.push(o.value);let o={};for(let e of yb){let n;e.types.some((e=>t.has(e)))&&(n=e.compute(i)),o[e.name]=n}return o}getAggregate(){let e=0,t=0;const i=this.getters.getActiveSheetId(),o=this.gridSelection.zones.map(Xi).flat();for(const{col:n,row:s}of o){const o=this.getters.getEvaluatedCell({sheetId:i,col:n,row:s});o.type===So.number&&(t++,e+=o.value)}return t<2?null:li(e)}isSelected(e){return!!this.getters.getSelectedZones().find((t=>Bi(t,e)))}getElementsFromSelection(e){if("COL"===e&&0===this.getters.getActiveCols().size)return[];if("ROW"===e&&0===this.getters.getActiveRows().size)return[];const t=this.getters.getSelectedZones();let i=[];const o="COL"===e?"left":"top",n="COL"===e?"right":"bottom";for(const e of t){const t=Array.from({length:e[n]-e[o]+1},((t,i)=>e[o]+i));i=i.concat(t)}return[...new Set(i)].sort()}setSelectionMixin(e,t){const{anchor:i,zones:o}=this.clipSelection(this.getters.getActiveSheetId(),{anchor:e,zones:t});this.gridSelection.anchor=i,this.gridSelection.zones=function(e){return e.reverse().filter(((e,t,i)=>t===i.findIndex((t=>t.top===e.top&&t.bottom===e.bottom&&t.left===e.left&&t.right===e.right)))).reverse()}(o)}selectCell(e,t){const i=this.getters.getActiveSheetId(),o=this.getters.expandZone(i,{left:e,right:e,top:t,bottom:t});this.setSelectionMixin({zone:o,cell:{col:e,row:t}},[o])}setActiveSheet(e){const t=this.getters.getSheet(e);this.activeSheet=t}activateNextSheet(e){const t=this.getters.getSheetIds(),i=(t.findIndex((e=>e===this.activeSheet.id))+("left"===e?t.length-1:1))%t.length;this.dispatch("ACTIVATE_SHEET",{sheetIdFrom:this.getActiveSheetId(),sheetIdTo:t[i]})}onColumnsRemoved(e){const{cell:t,zone:i}=this.gridSelection.anchor,o=Pi(i,"left",[...e.elements]);let n={left:t.col,right:t.col,top:t.row,bottom:t.row};n=Pi(n,"left",[...e.elements]);const s={cell:{col:n.left,row:n.top},zone:o};this.setSelectionMixin(s,[o])}onRowsRemoved(e){const{cell:t,zone:i}=this.gridSelection.anchor,o=Pi(i,"top",[...e.elements]);let n={left:t.col,right:t.col,top:t.row,bottom:t.row};n=Pi(n,"top",[...e.elements]);const s={cell:{col:n.left,row:n.top},zone:o};this.setSelectionMixin(s,[o])}onAddElements(e){const t=Li(this.gridSelection.anchor.zone,"COL"===e.dimension?"left":"top",e.base,e.position,e.quantity),i={cell:{col:t.left,row:t.top},zone:t};this.setSelectionMixin(i,[t])}onMoveElements(e){const t=e.elements.length;this.dispatch("ADD_COLUMNS_ROWS",{dimension:e.dimension,sheetId:e.sheetId,base:e.base,quantity:t,position:"before"});const i="COL"===e.dimension,o=e.elements[0],n=e.elements[t-1],s=e.base<o,r=s&&i?t:0,a=s&&!i?t:0;this.dispatch("CUT",{target:[{left:i?o+r:0,right:i?n+r:this.getters.getNumberCols(e.sheetId)-1,top:i?0:o+a,bottom:i?this.getters.getNumberRows(e.sheetId)-1:n+a}]}),this.dispatch("PASTE",{target:[{left:i?e.base:0,right:i?e.base+t-1:this.getters.getNumberCols(e.sheetId)-1,top:i?0:e.base,bottom:i?this.getters.getNumberRows(e.sheetId)-1:e.base+t-1}]});const l=s?e.elements.map((e=>e+t)):e.elements;let c=e.base;for(const t of l){const i="COL"===e.dimension?this.getters.getColSize(e.sheetId,t):this.getters.getRowSize(e.sheetId,t);this.dispatch("RESIZE_COLUMNS_ROWS",{dimension:e.dimension,sheetId:e.sheetId,size:i,elements:[c]}),c+=1}this.dispatch("REMOVE_COLUMNS_ROWS",{dimension:e.dimension,sheetId:e.sheetId,elements:l})}isMoveElementAllowed(e){const t="COL"===e.dimension,i=e.elements[0],o=e.elements[e.elements.length-1],n=e.sheetId,s=t?this.getters.doesColumnsHaveCommonMerges:this.getters.doesRowsHaveCommonMerges;return s(n,i-1,i)||s(n,o,o+1)||s(n,e.base-1,e.base)?2:0}clipSelection(e,t){const i=this.getters.getNumberCols(e)-1,o=this.getters.getNumberRows(e)-1;return{zones:t.zones.map((e=>({left:De(e.left,0,i),right:De(e.right,0,i),top:De(e.top,0,o),bottom:De(e.bottom,0,o)}))),anchor:{cell:{col:De(t.anchor.cell.col,0,i),row:De(t.anchor.cell.row,0,o)},zone:{left:De(t.anchor.zone.left,0,i),right:De(t.anchor.zone.right,0,i),top:De(t.anchor.zone.top,0,o),bottom:De(t.anchor.zone.bottom,0,o)}}}}drawGrid(e){if(this.getters.isDashboard())return;const{ctx:t,thinLineWidth:i}=e,o=this.getSelectedZones();t.fillStyle="#f3f7fe";const n=1===o.length&&o[0].left===o[0].right&&o[0].top===o[0].bottom;t.fillStyle=n?"#f3f7fe":"#e9f0ff",t.strokeStyle=E,t.lineWidth=1.5*i;for(const e of o){const{x:i,y:o,width:n,height:s}=this.getters.getVisibleRect(e);t.globalCompositeOperation="multiply",t.fillRect(i,o,n,s),t.globalCompositeOperation="source-over",t.strokeRect(i,o,n,s)}t.globalCompositeOperation="source-over";const s=this.getActivePosition();let r;t.strokeStyle=E,t.lineWidth=3*i,r=this.getters.isInMerge(s)?this.getters.getMerge(s):Ji(s);const{x:a,y:l,width:c,height:h}=this.getters.getVisibleRect(r);c>0&&h>0&&t.strokeRect(a,l,c,h)}}xb.layers=[6],xb.getters=["getActiveSheet","getActiveSheetId","getActiveCell","getActiveCols","getActiveRows","getCurrentStyle","getSelectedZones","getSelectedZone","getStatisticFnResults","getAggregate","getSelectedFigureId","getSelection","getActivePosition","getSheetPosition","isSelected","getElementsFromSelection"];const Ib=(new Mn).add("sheet",Mv).add("header visibility",yv).add("filters",Ev).add("cell",pv).add("merge",Iv).add("headerSize",wv).add("borders",Hf).add("conditional formatting",vv).add("figures",bv).add("chart",mv).add("image",xv),Rb=(new Mn).add("ui_sheet",hb).add("header_visibility_ui",Gv).add("ui_options",cb).add("selectionInputManager",Xv).add("highlight",qv).add("grid renderer",Zv).add("autofill",zv).add("find_and_replace",Wv).add("sort",lb).add("automatic_sum",Bv).add("format",class extends Ov{handle(e){if("SET_DECIMAL"===e.type)this.setDecimal(e.sheetId,e.target,e.step)}setDecimal(e,t,i){for(const o of t)for(const t of Xi(o)){const o=this.getCellNumberFormat({sheetId:e,...t});if(void 0!==o){const n=Si(o,i);this.dispatch("SET_FORMATTING",{sheetId:e,target:[Ji(t)],format:n})}}}getCellNumberFormat(e){var t;for(const i of[e]){const e=this.getters.getEvaluatedCell(i);if(e.type===So.number&&!(null===(t=e.format)||void 0===t?void 0:t.match(X)))return e.format||fi(e.value)}}}).add("cell_popovers",Hv).add("selection_multiuser",ab),Tb=(new Mn).add("selection",xb).add("clipboard",vb).add("edition",wb),Ab=(new Mn).add("evaluation",Fv).add("evaluation_filter",Lv).add("evaluation_chart",Dv).add("evaluation_cf",kv).add("viewport",Uv).add("custom_colors",Nv),Mb=new Mn;Mb.add("link",{condition:(e,t)=>!!t.model.getters.getEvaluatedCell(e).link,action:(e,t)=>Ru(t.model.getters.getEvaluatedCell(e).link,t),sequence:5});class Ob{constructor(e){this.fileStore=e}async requestImage(){const e=await this.getImageFromUser(),t=await this.fileStore.upload(e);return{path:t,size:await this.getImageSize(t)}}getImageFromUser(){return new Promise(((e,t)=>{const i=document.createElement("input");i.setAttribute("type","file"),i.setAttribute("accept","image/*"),i.addEventListener("change",(async()=>{null===i.files||1!=i.files.length?t():e(i.files[0])})),i.click()}))}getImageSize(e){return new Promise(((t,i)=>{const o=new Image;o.src=e,o.addEventListener("load",(()=>{const e={width:o.width,height:o.height};t(e)})),o.addEventListener("error",i)}))}}const Nb=[{transform:"scale(0)"},{transform:"scale(0.8)",offset:.33},{opacity:"0",transform:"scale(1)",offset:1}];ro`
|
|
1380
|
-
.o-ripple {
|
|
1381
|
-
z-index: 1;
|
|
1382
|
-
}
|
|
1383
|
-
`;class _b extends t.Component{constructor(){super(...arguments),this.rippleRef=t.useRef("ripple")}setup(){let e;t.onMounted((()=>{const t=this.rippleRef.el;t&&t.animate&&(e=t.animate(Nb,{duration:this.props.duration,easing:"ease-out"}),e.addEventListener("finish",this.props.onAnimationEnd))})),t.onWillUnmount((()=>{null==e||e.removeEventListener("finish",this.props.onAnimationEnd)}))}get rippleStyle(){const{x:e,y:t,width:i,height:o}=this.props;return ho({transform:"scale(0)",left:e,top:t,"margin-left":`${-i/2+(this.props.offsetX||0)}px`,"margin-top":`${-o/2+(this.props.offsetY||0)}px`,width:`${i}px`,height:`${o}px`,background:this.props.color,"border-radius":"100%",opacity:`${this.props.opacity}`})}}_b.template="o-spreadsheet-RippleEffect",_b.props={x:String,y:String,color:String,opacity:Number,duration:Number,width:Number,height:Number,offsetY:Number,offsetX:Number,allowOverflow:Boolean,onAnimationEnd:Function,style:String};class Fb extends t.Component{constructor(){super(...arguments),this.childContainer=t.useRef("childContainer"),this.state=t.useState({ripples:[]}),this.currentId=1}onClick(e){if(!this.props.enabled)return;if(!this.childContainer.el)return;const t=this.getRippleChildRectInfo(),{x:i,y:o,width:n,height:s}=t,r=Math.max(n,s),a={x:e.clientX-i,y:e.clientY-o,width:this.props.width||2.85*r,height:this.props.height||2.85*r};this.state.ripples.push({rippleRect:a,id:this.currentId++})}getRippleStyle(){const e=this.childContainer.el;if(!e||1!==e.childElementCount||!e.firstElementChild)return"";const t=this.getRippleChildRectInfo();return ho({top:t.marginTop+"px",left:t.marginLeft+"px",width:t.width+"px",height:t.height+"px"})}getRippleChildRectInfo(){const e=this.childContainer.el;if(!e)throw new Error("No child container element found");if(1!==e.childElementCount||!e.firstElementChild){return{...zn(e),marginLeft:0,marginTop:0}}const t=e.firstElementChild,i=function(e){const t=window.getComputedStyle(e);return{top:parseInt(t.marginTop,10)||0,bottom:parseInt(t.marginBottom,10)||0,left:parseInt(t.marginLeft,10)||0,right:parseInt(t.marginRight,10)||0}}(t);return{...zn(t),marginLeft:i.left,marginTop:i.top}}removeRipple(e){const t=this.state.ripples.findIndex((t=>t.id===e));-1!==t&&this.state.ripples.splice(t,1)}getRippleEffectProps(e){var t;const i=null===(t=this.state.ripples.find((t=>t.id===e)))||void 0===t?void 0:t.rippleRect;if(!i)throw new Error("Cannot find a ripple with the id "+e);return{color:this.props.color,opacity:this.props.opacity,duration:this.props.duration,x:this.props.ignoreClickPosition?"50%":i.x+"px",y:this.props.ignoreClickPosition?"50%":i.y+"px",width:i.width,height:i.height,offsetX:this.props.offsetX||0,offsetY:this.props.offsetY||0,allowOverflow:this.props.allowOverflow||!1,style:this.getRippleStyle(),onAnimationEnd:()=>this.removeRipple(e)}}}Fb.template="o-spreadsheet-Ripple",Fb.components={RippleEffect:_b},Fb.defaultProps={color:"#aaaaaa",opacity:.4,duration:800,enabled:!0,onAnimationEnd:()=>{},class:""},Fb.props={color:{type:String,optional:!0},opacity:{type:Number,optional:!0},duration:{type:Number,optional:!0},ignoreClickPosition:{type:Boolean,optional:!0},width:{type:Number,optional:!0},height:{type:Number,optional:!0},offsetY:{type:Number,optional:!0},offsetX:{type:Number,optional:!0},allowOverflow:{type:Boolean,optional:!0},enabled:{type:Boolean,optional:!0},onAnimationEnd:{type:Function,optional:!0},slots:Object,class:{type:String,optional:!0}},ro`
|
|
1384
|
-
.o-sheet {
|
|
1385
|
-
color: #666;
|
|
1386
|
-
padding: 0 15px;
|
|
1387
|
-
padding-right: 10px;
|
|
1388
|
-
height: ${36}px;
|
|
1389
|
-
border-left: 1px solid #c1c1c1;
|
|
1390
|
-
border-right: 1px solid #c1c1c1;
|
|
1391
|
-
margin-left: -1px;
|
|
1392
|
-
cursor: pointer;
|
|
1393
|
-
&:hover {
|
|
1394
|
-
background-color: rgba(0, 0, 0, 0.08);
|
|
1395
|
-
}
|
|
1396
|
-
|
|
1397
|
-
&.active {
|
|
1398
|
-
color: #484;
|
|
1399
|
-
background-color: #ffffff;
|
|
1400
|
-
box-shadow: 0 1px 3px 1px rgba(60, 64, 67, 0.15);
|
|
1401
|
-
}
|
|
1402
|
-
|
|
1403
|
-
.o-sheet-icon {
|
|
1404
|
-
z-index: 1;
|
|
1405
|
-
|
|
1406
|
-
&:hover {
|
|
1407
|
-
background-color: rgba(0, 0, 0, 0.08);
|
|
1408
|
-
}
|
|
1409
|
-
}
|
|
1410
|
-
|
|
1411
|
-
.o-sheet-name {
|
|
1412
|
-
outline: none;
|
|
1413
|
-
padding: 2px 4px;
|
|
1414
|
-
|
|
1415
|
-
&.o-sheet-name-editable {
|
|
1416
|
-
border-radius: 2px;
|
|
1417
|
-
border: 2px solid mediumblue;
|
|
1418
|
-
/* negative margins so nothing moves when the border is added */
|
|
1419
|
-
margin-left: -2px;
|
|
1420
|
-
margin-right: -2px;
|
|
1421
|
-
}
|
|
1422
|
-
}
|
|
1423
|
-
}
|
|
1424
|
-
`;class Db extends t.Component{constructor(){super(...arguments),this.state=t.useState({isEditing:!1}),this.sheetDivRef=t.useRef("sheetDiv"),this.sheetNameRef=t.useRef("sheetNameSpan"),this.editionState="initializing"}setup(){t.onMounted((()=>{this.isSheetActive&&this.scrollToSheet()})),t.onPatched((()=>{this.sheetNameRef.el&&this.state.isEditing&&"initializing"===this.editionState&&(this.editionState="editing",this.focusInputAndSelectContent())}))}focusInputAndSelectContent(){var e;if(!this.state.isEditing||!this.sheetNameRef.el)return;this.sheetNameRef.el.focus();const t=window.getSelection();t&&this.sheetNameRef.el.firstChild&&t.setBaseAndExtent(this.sheetNameRef.el.firstChild,0,this.sheetNameRef.el.firstChild,(null===(e=this.sheetNameRef.el.textContent)||void 0===e?void 0:e.length)||0)}scrollToSheet(){var e,t;null===(t=null===(e=this.sheetDivRef.el)||void 0===e?void 0:e.scrollIntoView)||void 0===t||t.call(e)}onFocusOut(){this.state.isEditing&&"initializing"!==this.editionState&&this.stopEdition()}onMouseDown(e){this.activateSheet(),this.props.onMouseDown(e)}activateSheet(){this.env.model.dispatch("ACTIVATE_SHEET",{sheetIdFrom:this.env.model.getters.getActiveSheetId(),sheetIdTo:this.props.sheetId}),this.scrollToSheet()}onDblClick(){this.startEdition()}onKeyDown(e){this.state.isEditing&&("Enter"===e.key&&(e.preventDefault(),this.stopEdition()),"Escape"===e.key&&this.cancelEdition())}onClickSheetName(e){this.state.isEditing&&e.stopPropagation()}startEdition(){this.state.isEditing=!0,this.editionState="initializing"}stopEdition(){var e;if(!this.state.isEditing)return;this.state.isEditing=!1,this.editionState="initializing",null===(e=this.sheetNameRef.el)||void 0===e||e.blur();const t=this.getInputContent()||"";!function(e,t,i,o){const n=e.model.getters.getSheetName(t);if(null===i||i===n)return;const r=e.model.dispatch("RENAME_SHEET",{sheetId:t,name:i});r.reasons.includes(10)?e.raiseError(s("The sheet name cannot be empty."),o):r.reasons.includes(11)?e.raiseError(s("A sheet with the name %s already exists. Please select another name.",i),o):r.reasons.includes(13)&&e.raiseError(s("Some used characters are not allowed in a sheet name (Forbidden characters are %s).",ne.join(" ")),o)}(this.env,this.props.sheetId,t,(()=>this.startEdition()))}cancelEdition(){var e;this.state.isEditing=!1,this.editionState="initializing",null===(e=this.sheetNameRef.el)||void 0===e||e.blur(),this.setInputContent(this.sheetName)}onIconClick(e){this.isSheetActive||this.activateSheet(),this.props.openContextMenu(this.contextMenuRegistry,e)}onContextMenu(e){this.isSheetActive||this.activateSheet(),this.props.openContextMenu(this.contextMenuRegistry,e)}getInputContent(){var e;return null===(e=this.sheetNameRef.el)||void 0===e?void 0:e.textContent}setInputContent(e){this.sheetNameRef.el&&(this.sheetNameRef.el.textContent=e)}get contextMenuRegistry(){return function(e){const t=new kn;return t.add("delete",{name:s("Delete"),sequence:10,isVisible:e=>e.model.getters.getSheetIds().length>1,action:e=>e.askConfirmation(s("Are you sure you want to delete this sheet ?"),(()=>{e.model.dispatch("DELETE_SHEET",{sheetId:e.model.getters.getActiveSheetId()})}))}).add("duplicate",{name:s("Duplicate"),sequence:20,action:e=>{const t=e.model.getters.getActiveSheetId(),i=e.model.uuidGenerator.uuidv4();e.model.dispatch("DUPLICATE_SHEET",{sheetId:t,sheetIdTo:i}),e.model.dispatch("ACTIVATE_SHEET",{sheetIdFrom:t,sheetIdTo:i})}}).add("rename",{name:s("Rename"),sequence:30,action:()=>e.renameSheetCallback()}).add("move_right",{name:s("Move right"),sequence:40,isVisible:e=>{const t=e.model.getters.getActiveSheetId(),i=e.model.getters.getVisibleSheetIds();return i.indexOf(t)!==i.length-1},action:e=>e.model.dispatch("MOVE_SHEET",{sheetId:e.model.getters.getActiveSheetId(),delta:1})}).add("move_left",{name:s("Move left"),sequence:50,isVisible:e=>{const t=e.model.getters.getActiveSheetId();return e.model.getters.getVisibleSheetIds()[0]!==t},action:e=>e.model.dispatch("MOVE_SHEET",{sheetId:e.model.getters.getActiveSheetId(),delta:-1})}).add("hide_sheet",{name:s("Hide sheet"),sequence:60,isVisible:e=>1!==e.model.getters.getVisibleSheetIds().length,action:e=>e.model.dispatch("HIDE_SHEET",{sheetId:e.model.getters.getActiveSheetId()})}),t}({renameSheetCallback:()=>{this.scrollToSheet(),this.startEdition()}})}get isSheetActive(){return this.env.model.getters.getActiveSheetId()===this.props.sheetId}get sheetName(){return this.env.model.getters.getSheetName(this.props.sheetId)}}Db.template="o-spreadsheet-BottomBarSheet",Db.components={Ripple:Fb},Db.defaultProps={onMouseDown:()=>{},style:""},Db.props={sheetId:String,openContextMenu:Function,style:{type:String,optional:!0},onMouseDown:{type:Function,optional:!0}},ro`
|
|
1425
|
-
.o-selection-statistic {
|
|
1426
|
-
margin-right: 20px;
|
|
1427
|
-
padding: 4px 4px 4px 8px;
|
|
1428
|
-
color: #333;
|
|
1429
|
-
cursor: pointer;
|
|
1430
|
-
&:hover {
|
|
1431
|
-
background-color: rgba(0, 0, 0, 0.08) !important;
|
|
1432
|
-
}
|
|
1433
|
-
}
|
|
1434
|
-
`;class kb extends t.Component{constructor(){super(...arguments),this.selectedStatisticFn="",this.statisticFnResults={}}setup(){this.statisticFnResults=this.env.model.getters.getStatisticFnResults(),t.onWillUpdateProps((()=>{const e=this.env.model.getters.getStatisticFnResults();at(e,this.statisticFnResults)||this.props.closeContextMenu(),this.statisticFnResults=e}))}getSelectedStatistic(){if(!Object.values(this.statisticFnResults).every((e=>void 0===e)))return""===this.selectedStatisticFn&&(this.selectedStatisticFn=Object.keys(this.statisticFnResults)[0]),this.getComposedFnName(this.selectedStatisticFn,this.statisticFnResults[this.selectedStatisticFn])}listSelectionStatistics(e){const t=new kn;let i=0;for(let[e,o]of Object.entries(this.statisticFnResults))t.add(e,{name:this.getComposedFnName(e,o),sequence:i,isReadonlyAllowed:!0,action:()=>{this.selectedStatisticFn=e}}),i++;const o=e.currentTarget,{top:n,left:s,width:r}=o.getBoundingClientRect();this.props.openContextMenu(s+r,n,t)}getComposedFnName(e,t){return e+": "+(void 0!==t?li(t):"__")}}kb.template="o-spreadsheet-BottomBarStatisic",kb.components={Ripple:Fb},kb.props={openContextMenu:Function,closeContextMenu:Function};class Lb{constructor(e){this.edgeScrollOffset=0,this.items=e.items.map((e=>({...e,positionAtStart:e.position}))),this.draggedItemId=e.draggedItemId,this.containerEl=e.containerEl,this.onChange=e.onChange,this.onCancel=e.onCancel,this.onDragEnd=e.onDragEnd,this.initialMousePosition=e.mouseX,this.currentMousePosition=e.mouseX,this.minPosition=this.items[0].position,this.maxPosition=this.items[this.items.length-1].position+this.items[this.items.length-1].size,zs(this.onMouseMove.bind(this),this.onMouseUp.bind(this))}onMouseMove(e){if(0!==e.button)return void this.onCancel();const t=e.clientX;t<this.containerRect.left||t>this.containerRect.right?this.startEdgeScroll(t<this.containerRect.left?-1:1):(this.stopEdgeScroll(),this.moveDraggedItemToPosition(t+this.edgeScrollOffset))}moveDraggedItemToPosition(e){this.currentMousePosition=e;const t=this.getHoveredItemIndex(e,this.items),i=this.items.findIndex((e=>e.id===this.draggedItemId)),o=this.items[i];if(this.deadZone&&this.isInZone(e,this.deadZone))return void this.onChange(this.getItemsPositions());if(this.isInZone(e,{start:o.position,end:o.position+o.size})&&(this.deadZone=void 0),i===t)return void this.onChange(this.getItemsPositions());const n=Math.min(i,t),s=Math.max(i,t),r=Math.sign(t-i);let a=0;for(let e=n;e<=s;e++)e!==i&&(this.items[e].position-=r*o.size,a+=this.items[e].size);o.position+=r*a,this.items.sort(((e,t)=>e.position-t.position)),this.deadZone=r>0?{start:e,end:o.position}:{start:o.position+o.size,end:e},this.onChange(this.getItemsPositions())}onMouseUp(e){0!==e.button&&this.onCancel();const t=this.items.findIndex((e=>e.id===this.draggedItemId));this.onDragEnd(this.draggedItemId,t),this.stopEdgeScroll()}startEdgeScroll(e){this.edgeScrollIntervalId||(this.edgeScrollIntervalId=window.setInterval((()=>{const t=3*e;let i=this.currentMousePosition+t;i<this.minPosition?i=this.minPosition:i>this.maxPosition&&(i=this.maxPosition),this.edgeScrollOffset+=i-this.currentMousePosition,this.moveDraggedItemToPosition(i),this.containerEl.scrollLeft+=t}),5))}stopEdgeScroll(){window.clearInterval(this.edgeScrollIntervalId),this.edgeScrollIntervalId=void 0}getHoveredItemIndex(e,t){return e<=this.minPosition?0:e>=this.maxPosition?t.length-1:t.findIndex((t=>t.position+t.size>=e))}getItemsPositions(){const e={};for(let t of this.items){if(t.id!==this.draggedItemId){e[t.id]=t.position-t.positionAtStart;continue}let i=this.currentMousePosition-this.initialMousePosition;i=Math.max(this.minPosition-t.positionAtStart,i),i=Math.min(this.maxPosition-t.positionAtStart-t.size,i),e[t.id]=i}return e}get containerRect(){return this.containerEl.getBoundingClientRect()}isInZone(e,t){return e>=t.start&&e<=t.end}destroy(){this.stopEdgeScroll()}}ro`
|
|
1435
|
-
.o-spreadsheet-bottom-bar {
|
|
1436
|
-
background-color: ${f};
|
|
1437
|
-
padding-left: ${N}px;
|
|
1438
|
-
font-size: 15px;
|
|
1439
|
-
border-top: 1px solid lightgrey;
|
|
1440
|
-
|
|
1441
|
-
.o-add-sheet.disabled {
|
|
1442
|
-
cursor: not-allowed;
|
|
1443
|
-
}
|
|
1444
|
-
|
|
1445
|
-
.o-sheet-item {
|
|
1446
|
-
cursor: pointer;
|
|
1447
|
-
&:hover {
|
|
1448
|
-
background-color: rgba(0, 0, 0, 0.08);
|
|
1449
|
-
}
|
|
1450
|
-
}
|
|
1451
|
-
|
|
1452
|
-
.o-all-sheets {
|
|
1453
|
-
max-width: 70%;
|
|
1454
|
-
.o-bottom-bar-fade-out {
|
|
1455
|
-
background-image: linear-gradient(-90deg, #cfcfcf, transparent 1%);
|
|
1456
|
-
}
|
|
1457
|
-
|
|
1458
|
-
.o-bottom-bar-fade-in {
|
|
1459
|
-
background-image: linear-gradient(90deg, #cfcfcf, transparent 1%);
|
|
1460
|
-
}
|
|
1461
|
-
}
|
|
1462
|
-
|
|
1463
|
-
.o-bottom-bar-arrows {
|
|
1464
|
-
.o-bottom-bar-arrow {
|
|
1465
|
-
cursor: pointer;
|
|
1466
|
-
&.o-disabled {
|
|
1467
|
-
opacity: 0.4;
|
|
1468
|
-
cursor: default;
|
|
1469
|
-
}
|
|
1470
|
-
&:hover:not([class*="o-disabled"]) {
|
|
1471
|
-
.o-icon {
|
|
1472
|
-
opacity: 0.9;
|
|
1473
|
-
}
|
|
1474
|
-
}
|
|
1475
|
-
|
|
1476
|
-
.o-icon {
|
|
1477
|
-
height: 18px;
|
|
1478
|
-
width: 18px;
|
|
1479
|
-
}
|
|
1480
|
-
}
|
|
1481
|
-
}
|
|
1482
|
-
}
|
|
1483
|
-
`;class Pb extends t.Component{constructor(){super(...arguments),this.bottomBarRef=t.useRef("bottomBar"),this.sheetListRef=t.useRef("sheetList"),this.targetScroll=void 0,this.state=t.useState({isSheetListScrollableLeft:!1,isSheetListScrollableRight:!1}),this.menuMaxHeight=250,this.menuState=t.useState({isOpen:!1,menuId:void 0,position:null,menuItems:[]}),this.sheetState=t.useState({sheetList:this.getVisibleSheets(),isDnd:!1,sheetDndPositions:void 0})}setup(){t.onWillUpdateProps((()=>{this.updateScrollState();const e=this.getVisibleSheets();this.sheetState.isDnd&&!at(this.sheetState.sheetList,e)&&this.stopDragging(),this.sheetState.sheetList=e})),t.onWillUnmount((()=>{var e;null===(e=this.dndHelper)||void 0===e||e.destroy()}))}isDragged(e){var t;return this.sheetState.isDnd&&(null===(t=this.dndHelper)||void 0===t?void 0:t.draggedItemId)===e}clickAddSheet(e){const t=this.env.model.getters.getActiveSheetId(),i=this.env.model.getters.getSheetIds().findIndex((e=>e===t))+1,o=this.env.model.uuidGenerator.uuidv4(),n=this.env.model.getters.getNextSheetName(this.env._t("Sheet"));this.env.model.dispatch("CREATE_SHEET",{sheetId:o,position:i,name:n}),this.env.model.dispatch("ACTIVATE_SHEET",{sheetIdFrom:t,sheetIdTo:o})}getVisibleSheets(){return this.env.model.getters.getVisibleSheetIds().map((e=>{const t=this.env.model.getters.getSheet(e);return{id:t.id,name:t.name}}))}getSheets(){return this.sheetState.sheetList}clickListSheets(e){const t=new kn,i=this.env.model.getters.getActiveSheetId();let o=0;for(const e of this.env.model.getters.getSheetIds()){const n=this.env.model.getters.getSheet(e);t.add(e,{name:n.name,sequence:o,isReadonlyAllowed:!0,textColor:n.isVisible?void 0:"grey",action:t=>{t.model.dispatch("ACTIVATE_SHEET",{sheetIdFrom:i,sheetIdTo:e})}}),o++}const n=e.currentTarget,{left:s}=n.getBoundingClientRect(),r=this.bottomBarRef.el.getBoundingClientRect().top;this.openContextMenu(s,r,"listSheets",t)}openContextMenu(e,t,i,o){this.menuState.isOpen=!0,this.menuState.menuId=i,this.menuState.menuItems=o.getMenuItems(),this.menuState.position={x:e,y:t}}onSheetContextMenu(e,t,i){const o=i.currentTarget,{top:n,left:s}=o.getBoundingClientRect();i.closedMenuId!==e?this.openContextMenu(s,n,e,t):this.closeMenu()}closeMenu(){this.menuState.isOpen=!1,this.menuState.menuId=void 0,this.menuState.menuItems=[],this.menuState.position=null}closeContextMenuWithId(e){this.menuState.menuId===e&&this.closeMenu()}onWheel(e){this.targetScroll=void 0;e.currentTarget.scrollLeft+=.5*e.deltaY}onScroll(){this.updateScrollState(),this.targetScroll===this.sheetListCurrentScroll&&(this.targetScroll=void 0)}onArrowLeft(e){if(!this.state.isSheetListScrollableLeft)return;this.targetScroll||(this.targetScroll=this.sheetListCurrentScroll);const t=this.targetScroll-this.sheetListWidth;this.scrollSheetListTo(Math.max(0,t))}onArrowRight(e){if(!this.state.isSheetListScrollableRight)return;this.targetScroll||(this.targetScroll=this.sheetListCurrentScroll);const t=this.targetScroll+this.sheetListWidth;this.scrollSheetListTo(Math.min(this.sheetListMaxScroll,t))}updateScrollState(){this.state.isSheetListScrollableLeft=this.sheetListCurrentScroll>0,this.state.isSheetListScrollableRight=this.sheetListCurrentScroll<this.sheetListMaxScroll}scrollSheetListTo(e){this.sheetListRef.el&&(this.targetScroll=e,this.sheetListRef.el.scrollTo({top:0,left:e,behavior:"smooth"}))}onSheetMouseDown(e,t){if(0!==t.button)return;this.closeMenu();const i=t.clientX;document.body.style.cursor="move";const o=this.getVisibleSheets(),n=this.getSheetItemRects(),s=o.map(((e,t)=>({id:e.id,size:n[t].width,position:n[t].x})));this.dndHelper=new Lb({draggedItemId:e,mouseX:i,items:s,containerEl:this.sheetListRef.el,onChange:e=>{this.sheetState.isDnd=!0,this.sheetState.sheetDndPositions=e},onCancel:()=>this.stopDragging(),onDragEnd:(e,t)=>this.onDragEnd(e,t)})}onDragEnd(e,t){const i=t-this.sheetState.sheetList.findIndex((t=>t.id===e));e&&0!==i&&this.env.model.dispatch("MOVE_SHEET",{sheetId:e,delta:i}),this.stopDragging()}getSheetStyle(e){var t;const i={};return this.sheetState.isDnd&&(i.position="relative",i.left=((null===(t=this.sheetState.sheetDndPositions)||void 0===t?void 0:t[e])||0)+"px",i.transition="left 0.5s",i.cursor="move"),this.isDragged(e)&&(i.transition="left 0s",i["z-index"]="1000"),ho(i)}stopDragging(){document.body.style.cursor="",this.sheetState.sheetList=this.getVisibleSheets(),this.sheetState.isDnd=!1,this.sheetState.sheetDndPositions=void 0,this.dndHelper=void 0}getSheetItemRects(){return Array.from(this.bottomBarRef.el.querySelectorAll(".o-sheet")).map((e=>e.getBoundingClientRect())).map((e=>({x:e.x,width:e.width-1,y:e.y,height:e.height})))}getSheetClasses(e){let t="";return this.isDragged(e)&&(t+="dragged "),this.sheetState.isDnd&&(t+="dragging "),t}get sheetListCurrentScroll(){return this.sheetListRef.el?this.sheetListRef.el.scrollLeft:0}get sheetListWidth(){return this.sheetListRef.el?this.sheetListRef.el.clientWidth:0}get sheetListMaxScroll(){return this.sheetListRef.el?this.sheetListRef.el.scrollWidth-this.sheetListRef.el.clientWidth:0}}Pb.template="o-spreadsheet-BottomBar",Pb.components={Menu:jn,Ripple:Fb,BottomBarSheet:Db,BottomBarStatistic:kb},Pb.props={onClick:Function},ro`
|
|
1484
|
-
.o-dashboard-clickable-cell {
|
|
1485
|
-
position: absolute;
|
|
1486
|
-
cursor: pointer;
|
|
1487
|
-
}
|
|
1488
|
-
`;let Ub=1;class Vb extends t.Component{setup(){const e=t.useRef("grid");this.canvasPosition=Pn(e),this.hoveredCell=t.useState({col:void 0,row:void 0}),t.useChildSubEnv({getPopoverContainerRect:()=>this.getGridRect()}),Zg("canvas",this.env.model,(()=>this.env.model.getters.getSheetViewDimension())),this.onMouseWheel=jg(((e,t)=>{this.moveCanvas(e,t),this.hoveredCell.col=void 0,this.hoveredCell.row=void 0}))}onCellHovered({col:e,row:t}){this.hoveredCell.col=e,this.hoveredCell.row=t}get gridContainer(){const e=this.env.model.getters.getActiveSheetId(),{right:t}=this.env.model.getters.getSheetZone(e),{end:i}=this.env.model.getters.getColDimensions(e,t);return ho({"max-width":`${i}px`})}get gridOverlayDimensions(){return ho({height:"100%",width:"100%"})}getCellClickableStyle(e){return ho({top:`${e.y}px`,left:`${e.x}px`,width:`${e.width}px`,height:`${e.height}px`})}getClickableCells(){const e=[],t=this.env.model.getters.getActiveSheetId();for(const i of this.env.model.getters.getSheetViewVisibleCols())for(const o of this.env.model.getters.getSheetViewVisibleRows()){const n={sheetId:t,col:i,row:o},s=this.getClickableAction(n);if(!s)continue;let r;r=this.env.model.getters.isInMerge(n)?this.env.model.getters.getMerge(n):Ji({col:i,row:o});const a=this.env.model.getters.getVisibleRect(r);e.push({coordinates:a,position:{col:i,row:o},action:s,tKey:`${Ub}-${i}-${o}`})}return Ub++,e}getClickableAction(e){for(const t of Mb.getAll().sort(((e,t)=>e.sequence-t.sequence)))if(t.condition(e,this.env))return t.action;return!1}selectClickableCell(e){const{position:t,action:i}=e;i({...t,sheetId:this.env.model.getters.getActiveSheetId()},this.env)}onClosePopover(){this.env.model.dispatch("CLOSE_CELL_POPOVER")}onGridResized({height:e,width:t}){this.env.model.dispatch("RESIZE_SHEETVIEW",{width:t,height:e,gridOffsetX:0,gridOffsetY:0})}moveCanvas(e,t){const{scrollX:i,scrollY:o}=this.env.model.getters.getActiveSheetDOMScrollInfo();this.env.model.dispatch("SET_VIEWPORT_OFFSET",{offsetX:i+e,offsetY:o+t})}getGridRect(){return{...this.canvasPosition,...this.env.model.getters.getSheetViewDimensionWithHeaders()}}}Vb.template="o-spreadsheet-SpreadsheetDashboard",Vb.components={GridOverlay:Bg,GridPopover:Hg,Popover:Wn,VerticalScrollBar:tp,HorizontalScrollBar:ep,FilterIconsOverlay:Su},Vb.props={},ro`
|
|
1489
|
-
.o-sidePanel {
|
|
1490
|
-
display: flex;
|
|
1491
|
-
flex-direction: column;
|
|
1492
|
-
overflow-x: hidden;
|
|
1493
|
-
background-color: white;
|
|
1494
|
-
border: 1px solid darkgray;
|
|
1495
|
-
user-select: none;
|
|
1496
|
-
.o-sidePanelHeader {
|
|
1497
|
-
padding: 6px;
|
|
1498
|
-
height: 30px;
|
|
1499
|
-
background-color: ${v};
|
|
1500
|
-
display: flex;
|
|
1501
|
-
align-items: center;
|
|
1502
|
-
justify-content: space-between;
|
|
1503
|
-
border-bottom: 1px solid darkgray;
|
|
1504
|
-
border-top: 1px solid darkgray;
|
|
1505
|
-
font-weight: bold;
|
|
1506
|
-
.o-sidePanelTitle {
|
|
1507
|
-
font-weight: bold;
|
|
1508
|
-
padding: 5px 10px;
|
|
1509
|
-
color: dimgrey;
|
|
1510
|
-
}
|
|
1511
|
-
.o-sidePanelClose {
|
|
1512
|
-
font-size: 1.5rem;
|
|
1513
|
-
padding: 5px 10px;
|
|
1514
|
-
cursor: pointer;
|
|
1515
|
-
&:hover {
|
|
1516
|
-
background-color: WhiteSmoke;
|
|
1517
|
-
}
|
|
1518
|
-
}
|
|
1519
|
-
}
|
|
1520
|
-
.o-sidePanelBody {
|
|
1521
|
-
overflow: auto;
|
|
1522
|
-
width: 100%;
|
|
1523
|
-
height: 100%;
|
|
1524
|
-
|
|
1525
|
-
.o-section {
|
|
1526
|
-
padding: 16px;
|
|
1527
|
-
|
|
1528
|
-
.o-section-title {
|
|
1529
|
-
font-weight: bold;
|
|
1530
|
-
color: dimgrey;
|
|
1531
|
-
margin-bottom: 5px;
|
|
1532
|
-
}
|
|
1533
|
-
|
|
1534
|
-
.o-section-subtitle {
|
|
1535
|
-
color: dimgrey;
|
|
1536
|
-
font-weight: 500;
|
|
1537
|
-
font-size: 12px;
|
|
1538
|
-
line-height: 14px;
|
|
1539
|
-
margin: 8px 0 4px 0;
|
|
1540
|
-
}
|
|
1541
|
-
|
|
1542
|
-
.o-subsection-left {
|
|
1543
|
-
display: inline-block;
|
|
1544
|
-
width: 47%;
|
|
1545
|
-
margin-right: 3%;
|
|
1546
|
-
}
|
|
1547
|
-
|
|
1548
|
-
.o-subsection-right {
|
|
1549
|
-
display: inline-block;
|
|
1550
|
-
width: 47%;
|
|
1551
|
-
margin-left: 3%;
|
|
1552
|
-
}
|
|
1553
|
-
}
|
|
1554
|
-
}
|
|
1555
|
-
|
|
1556
|
-
.o-sidepanel-error {
|
|
1557
|
-
color: red;
|
|
1558
|
-
margin-top: 10px;
|
|
1559
|
-
}
|
|
1560
|
-
|
|
1561
|
-
.o-sidePanelButtons {
|
|
1562
|
-
padding: 16px;
|
|
1563
|
-
text-align: right;
|
|
1564
|
-
}
|
|
1565
|
-
|
|
1566
|
-
.o-sidePanelButton {
|
|
1567
|
-
border: 1px solid lightgrey;
|
|
1568
|
-
padding: 0px 20px 0px 20px;
|
|
1569
|
-
border-radius: 4px;
|
|
1570
|
-
font-weight: 500;
|
|
1571
|
-
font-size: 14px;
|
|
1572
|
-
height: 30px;
|
|
1573
|
-
line-height: 16px;
|
|
1574
|
-
background: white;
|
|
1575
|
-
margin-right: 8px;
|
|
1576
|
-
&:hover:enabled {
|
|
1577
|
-
background-color: rgba(0, 0, 0, 0.08);
|
|
1578
|
-
}
|
|
1579
|
-
}
|
|
1580
|
-
.o-sidePanelButton:enabled {
|
|
1581
|
-
cursor: pointer;
|
|
1582
|
-
}
|
|
1583
|
-
.o-sidePanelButton:last-child {
|
|
1584
|
-
margin-right: 0px;
|
|
1585
|
-
}
|
|
1586
|
-
|
|
1587
|
-
.o-input {
|
|
1588
|
-
color: #666666;
|
|
1589
|
-
border-radius: 4px;
|
|
1590
|
-
min-width: 0px;
|
|
1591
|
-
padding: 4px 6px;
|
|
1592
|
-
box-sizing: border-box;
|
|
1593
|
-
line-height: 1;
|
|
1594
|
-
width: 100%;
|
|
1595
|
-
height: 28px;
|
|
1596
|
-
.o-type-selector {
|
|
1597
|
-
background-position: right 5px top 11px;
|
|
1598
|
-
}
|
|
1599
|
-
}
|
|
1600
|
-
input.o-required,
|
|
1601
|
-
select.o-required {
|
|
1602
|
-
border-color: #4c4c4c;
|
|
1603
|
-
}
|
|
1604
|
-
input.o-optional,
|
|
1605
|
-
select.o-optional {
|
|
1606
|
-
border: 1px solid #a9a9a9;
|
|
1607
|
-
}
|
|
1608
|
-
input.o-invalid {
|
|
1609
|
-
border-color: red;
|
|
1610
|
-
}
|
|
1611
|
-
select.o-input {
|
|
1612
|
-
background-color: white;
|
|
1613
|
-
text-align: left;
|
|
1614
|
-
}
|
|
1615
|
-
|
|
1616
|
-
.o-inflection {
|
|
1617
|
-
table {
|
|
1618
|
-
table-layout: fixed;
|
|
1619
|
-
margin-top: 2%;
|
|
1620
|
-
display: table;
|
|
1621
|
-
text-align: left;
|
|
1622
|
-
font-size: 12px;
|
|
1623
|
-
line-height: 18px;
|
|
1624
|
-
width: 100%;
|
|
1625
|
-
}
|
|
1626
|
-
input,
|
|
1627
|
-
select {
|
|
1628
|
-
width: 100%;
|
|
1629
|
-
height: 100%;
|
|
1630
|
-
box-sizing: border-box;
|
|
1631
|
-
}
|
|
1632
|
-
}
|
|
1633
|
-
|
|
1634
|
-
.o-sidePanel-tools {
|
|
1635
|
-
color: #333;
|
|
1636
|
-
font-size: 13px;
|
|
1637
|
-
cursor: default;
|
|
1638
|
-
display: flex;
|
|
1639
|
-
|
|
1640
|
-
.o-tool {
|
|
1641
|
-
display: flex;
|
|
1642
|
-
align-items: center;
|
|
1643
|
-
margin: 2px;
|
|
1644
|
-
padding: 0 3px;
|
|
1645
|
-
border-radius: 2px;
|
|
1646
|
-
|
|
1647
|
-
&:hover {
|
|
1648
|
-
background-color: rgba(0, 0, 0, 0.08);
|
|
1649
|
-
}
|
|
1650
|
-
}
|
|
1651
|
-
}
|
|
1652
|
-
}
|
|
1653
|
-
`;class zb extends t.Component{setup(){this.state=t.useState({panel:Lg.get(this.props.component)}),t.onWillUpdateProps((e=>this.state.panel=Lg.get(e.component)))}getTitle(){return"function"==typeof this.state.panel.title?this.state.panel.title(this.env):this.state.panel.title}}zb.template="o-spreadsheet-SidePanel",zb.props={component:String,panelProps:{type:Object,optional:!0},onCloseSidePanel:Function};const Bb={MergeIsDestructive:s("Merging these cells will only preserve the top-leftmost value. Merge anyway?"),MergeInFilter:s("You can't merge cells inside of an existing filter.")};ro`
|
|
1654
|
-
.o-topbar-composer {
|
|
1655
|
-
height: fit-content;
|
|
1656
|
-
margin-top: -1px;
|
|
1657
|
-
border: 1px solid;
|
|
1658
|
-
z-index: ${le.TopBarComposer};
|
|
1659
|
-
}
|
|
1660
|
-
`;class Hb extends t.Component{get composerStyle(){const e={padding:"5px 0px 5px 8px","max-height":"100px","line-height":"24px"};return e.height="inactive"===this.props.focus?"34px":"fit-content",ho(e)}get containerStyle(){return"inactive"===this.props.focus?ho({"border-color":A,"border-right":"none"}):ho({"border-color":E})}}Hb.template="o-spreadsheet-TopBarComposer",Hb.components={Composer:gu},Hb.props={focus:{validate:e=>["inactive","cellFocus","contentFocus"].includes(e)},onComposerContentFocused:Function},ro`
|
|
1661
|
-
.o-font-size-editor {
|
|
1662
|
-
input.o-font-size {
|
|
1663
|
-
height: 20px;
|
|
1664
|
-
width: 23px;
|
|
1665
|
-
}
|
|
1666
|
-
input[type="number"] {
|
|
1667
|
-
-moz-appearance: textfield;
|
|
1668
|
-
}
|
|
1669
|
-
input::-webkit-outer-spin-button,
|
|
1670
|
-
input::-webkit-inner-spin-button {
|
|
1671
|
-
-webkit-appearance: none;
|
|
1672
|
-
}
|
|
1673
|
-
}
|
|
1674
|
-
`;class $b extends t.Component{constructor(){super(...arguments),this.fontSizes=he,this.dropdown=t.useState({isOpen:!1}),this.inputRef=t.useRef("inputFontSize"),this.rootEditorRef=t.useRef("FontSizeEditor")}setup(){t.useExternalListener(window,"click",this.onExternalClick,{capture:!0})}onExternalClick(e){Un(this.rootEditorRef.el,e)||this.closeFontList()}get currentFontSize(){return this.env.model.getters.getCurrentStyle().fontSize||G}toggleFontList(){this.dropdown.isOpen?this.closeFontList():(this.props.onToggle(),this.inputRef.el.focus())}closeFontList(){this.dropdown.isOpen=!1}setSize(e){const t=De(Math.floor(parseFloat(e)),1,400);ds(this.env,{fontSize:t}),this.closeFontList()}setSizeFromInput(e){this.setSize(e.target.value)}setSizeFromList(e){this.setSize(e)}onInputFocused(e){this.dropdown.isOpen=!0,e.target.select()}onInputKeydown(e){if("Enter"===e.key||"Escape"===e.key){this.closeFontList();const t=e.target;"Escape"===e.key&&(t.value=`${this.currentFontSize}`),this.props.onToggle()}}}$b.template="o-spreadsheet-FontSizeEditor",$b.components={},$b.props={onToggle:Function,dropdownStyle:String};const Wb=[{name:"automatic",text:Xo.Automatic},{name:"number",text:Xo.Number,description:"1,000.12",value:"#,##0.00"},{name:"percent",text:Xo.Percent,description:"10.12%",value:"0.00%"},{name:"currency",text:Xo.Currency,description:"$1,000.12",value:"[$$]#,##0.00"},{name:"currency_rounded",text:Xo.CurrencyRounded,description:"$1,000",value:"[$$]#,##0"},{name:"date",text:Xo.Date,description:"9/26/2008",value:"m/d/yyyy"},{name:"time",text:Xo.Time,description:"10:43:00 PM",value:"hh:mm:ss a"},{name:"datetime",text:Xo.DateTime,description:"9/26/2008 22:43:00",value:"m/d/yyyy hh:mm:ss"},{name:"duration",text:Xo.Duration,description:"27:51:38",value:"hhhh:mm:ss"}],Gb=[{name:"custom_currency",text:Xo.CustomCurrency,sidePanel:"CustomCurrency"}],qb="#4a4f59";ro`
|
|
1675
|
-
.o-spreadsheet-topbar {
|
|
1676
|
-
background-color: white;
|
|
1677
|
-
line-height: 1.2;
|
|
1678
|
-
display: flex;
|
|
1679
|
-
flex-direction: column;
|
|
1680
|
-
font-size: 13px;
|
|
1681
|
-
line-height: 1.2;
|
|
1682
|
-
user-select: none;
|
|
1683
|
-
font-weight: 500;
|
|
1684
|
-
color: ${qb};
|
|
1685
|
-
|
|
1686
|
-
.o-topbar-top {
|
|
1687
|
-
border-bottom: 1px solid ${A};
|
|
1688
|
-
display: flex;
|
|
1689
|
-
padding: 2px 10px;
|
|
1690
|
-
justify-content: space-between;
|
|
1691
|
-
|
|
1692
|
-
/* Menus */
|
|
1693
|
-
.o-topbar-topleft {
|
|
1694
|
-
display: flex;
|
|
1695
|
-
.o-topbar-menu {
|
|
1696
|
-
padding: 4px 6px;
|
|
1697
|
-
margin: 0 2px;
|
|
1698
|
-
cursor: pointer;
|
|
1699
|
-
}
|
|
1700
|
-
|
|
1701
|
-
.o-topbar-menu:hover,
|
|
1702
|
-
.o-topbar-menu-active {
|
|
1703
|
-
background-color: #f1f3f4;
|
|
1704
|
-
border-radius: 2px;
|
|
1705
|
-
}
|
|
1706
|
-
}
|
|
1707
|
-
|
|
1708
|
-
.o-topbar-topright {
|
|
1709
|
-
display: flex;
|
|
1710
|
-
justify-content: flex-end;
|
|
1711
|
-
}
|
|
1712
|
-
}
|
|
1713
|
-
|
|
1714
|
-
.o-topbar-composer {
|
|
1715
|
-
flex-grow: 1;
|
|
1716
|
-
}
|
|
1717
|
-
|
|
1718
|
-
/* Toolbar */
|
|
1719
|
-
.o-topbar-toolbar {
|
|
1720
|
-
flex-shrink: 0;
|
|
1721
|
-
display: flex;
|
|
1722
|
-
height: ${34}px;
|
|
1723
|
-
|
|
1724
|
-
.o-readonly-toolbar {
|
|
1725
|
-
display: flex;
|
|
1726
|
-
align-items: center;
|
|
1727
|
-
background-color: ${v};
|
|
1728
|
-
padding-left: 18px;
|
|
1729
|
-
padding-right: 18px;
|
|
1730
|
-
}
|
|
1731
|
-
|
|
1732
|
-
/* Toolbar */
|
|
1733
|
-
.o-toolbar-tools {
|
|
1734
|
-
display: flex;
|
|
1735
|
-
flex-shrink: 0;
|
|
1736
|
-
margin-left: 16px;
|
|
1737
|
-
cursor: default;
|
|
1738
|
-
|
|
1739
|
-
.o-tool {
|
|
1740
|
-
display: flex;
|
|
1741
|
-
justify-content: center;
|
|
1742
|
-
align-items: center;
|
|
1743
|
-
margin: 2px;
|
|
1744
|
-
padding: 0px 3px;
|
|
1745
|
-
border-radius: 2px;
|
|
1746
|
-
cursor: pointer;
|
|
1747
|
-
min-width: 20px;
|
|
1748
|
-
svg path,
|
|
1749
|
-
polygon,
|
|
1750
|
-
rect {
|
|
1751
|
-
fill: ${qb};
|
|
1752
|
-
}
|
|
1753
|
-
}
|
|
1754
|
-
|
|
1755
|
-
.o-tool-outlined {
|
|
1756
|
-
background-color: rgba(0, 0, 0, 0.08);
|
|
1757
|
-
}
|
|
1758
|
-
|
|
1759
|
-
.o-filter-tool {
|
|
1760
|
-
margin-right: 8px;
|
|
1761
|
-
}
|
|
1762
|
-
|
|
1763
|
-
.o-tool.active {
|
|
1764
|
-
background-color: ${"#E6F4EA"};
|
|
1765
|
-
svg path,
|
|
1766
|
-
polygon,
|
|
1767
|
-
rect {
|
|
1768
|
-
fill: ${"#188038"};
|
|
1769
|
-
}
|
|
1770
|
-
}
|
|
1771
|
-
.o-tool:not(.o-disabled):hover {
|
|
1772
|
-
background-color: ${"#f6f7fa"};
|
|
1773
|
-
svg path,
|
|
1774
|
-
polygon,
|
|
1775
|
-
rect {
|
|
1776
|
-
fill: ${"#000000"};
|
|
1777
|
-
}
|
|
1778
|
-
}
|
|
1779
|
-
|
|
1780
|
-
.o-border-dropdown {
|
|
1781
|
-
padding: 4px;
|
|
1782
|
-
}
|
|
1783
|
-
|
|
1784
|
-
.o-divider {
|
|
1785
|
-
display: inline-block;
|
|
1786
|
-
border-right: 1px solid ${A};
|
|
1787
|
-
width: 0;
|
|
1788
|
-
margin: 0 6px;
|
|
1789
|
-
}
|
|
1790
|
-
|
|
1791
|
-
.o-disabled {
|
|
1792
|
-
opacity: 0.6;
|
|
1793
|
-
cursor: default;
|
|
1794
|
-
}
|
|
1795
|
-
|
|
1796
|
-
.o-dropdown {
|
|
1797
|
-
position: relative;
|
|
1798
|
-
display: flex;
|
|
1799
|
-
align-items: center;
|
|
1800
|
-
|
|
1801
|
-
.o-dropdown-button {
|
|
1802
|
-
height: 30px;
|
|
1803
|
-
}
|
|
1804
|
-
|
|
1805
|
-
.o-text-icon {
|
|
1806
|
-
line-height: 30px;
|
|
1807
|
-
}
|
|
1808
|
-
|
|
1809
|
-
.o-text-options > div {
|
|
1810
|
-
line-height: 26px;
|
|
1811
|
-
padding: 3px 12px;
|
|
1812
|
-
&:hover {
|
|
1813
|
-
background-color: rgba(0, 0, 0, 0.08);
|
|
1814
|
-
}
|
|
1815
|
-
}
|
|
1816
|
-
|
|
1817
|
-
.o-dropdown-content {
|
|
1818
|
-
position: absolute;
|
|
1819
|
-
top: 100%;
|
|
1820
|
-
left: 0;
|
|
1821
|
-
overflow-y: auto;
|
|
1822
|
-
overflow-x: hidden;
|
|
1823
|
-
z-index: ${le.Dropdown};
|
|
1824
|
-
box-shadow: 1px 2px 5px 2px rgba(51, 51, 51, 0.15);
|
|
1825
|
-
background-color: white;
|
|
1826
|
-
|
|
1827
|
-
.o-dropdown-item {
|
|
1828
|
-
cursor: pointer;
|
|
1829
|
-
}
|
|
1830
|
-
|
|
1831
|
-
.o-dropdown-item:hover {
|
|
1832
|
-
background-color: rgba(0, 0, 0, 0.08);
|
|
1833
|
-
}
|
|
1834
|
-
|
|
1835
|
-
.o-dropdown-line {
|
|
1836
|
-
display: flex;
|
|
1837
|
-
margin: 1px;
|
|
1838
|
-
|
|
1839
|
-
.o-line-item {
|
|
1840
|
-
padding: 4px;
|
|
1841
|
-
width: 18px;
|
|
1842
|
-
height: 18px;
|
|
1843
|
-
cursor: pointer;
|
|
1844
|
-
|
|
1845
|
-
&:hover {
|
|
1846
|
-
background-color: rgba(0, 0, 0, 0.08);
|
|
1847
|
-
}
|
|
1848
|
-
}
|
|
1849
|
-
}
|
|
1850
|
-
|
|
1851
|
-
&.o-format-tool {
|
|
1852
|
-
padding: 5px 0;
|
|
1853
|
-
width: 250px;
|
|
1854
|
-
font-size: 12px;
|
|
1855
|
-
> div {
|
|
1856
|
-
padding: 0 20px;
|
|
1857
|
-
white-space: nowrap;
|
|
1858
|
-
|
|
1859
|
-
&.active:before {
|
|
1860
|
-
content: "✓";
|
|
1861
|
-
font-weight: bold;
|
|
1862
|
-
position: absolute;
|
|
1863
|
-
left: 5px;
|
|
1864
|
-
}
|
|
1865
|
-
}
|
|
1866
|
-
}
|
|
1867
|
-
|
|
1868
|
-
.o-dropdown-align-item {
|
|
1869
|
-
padding: 7px 10px;
|
|
1870
|
-
}
|
|
1871
|
-
}
|
|
1872
|
-
}
|
|
1873
|
-
}
|
|
1874
|
-
}
|
|
1875
|
-
}
|
|
1876
|
-
`;class Zb extends t.Component{constructor(){super(...arguments),this.commonFormats=Wb,this.customFormats=Gb,this.currentFormatName="automatic",this.style={},this.state=t.useState({menuState:{isOpen:!1,position:null,menuItems:[]},activeTool:""}),this.isSelectingMenu=!1,this.openedEl=null,this.inMerge=!1,this.cannotMerge=!1,this.undoTool=!1,this.redoTool=!1,this.paintFormatTool=!1,this.fillColor="#ffffff",this.textColor="#000000",this.menus=[]}get dropdownStyle(){return`max-height:${this.props.dropdownMaxHeight}px`}setup(){t.useExternalListener(window,"click",this.onExternalClick),t.onWillStart((()=>this.updateCellState())),t.onWillUpdateProps((()=>this.updateCellState()))}get topbarComponents(){return Pg.getAll().filter((e=>!e.isVisible||e.isVisible(this.env)))}onExternalClick(e){this.openedEl!==e.target&&this.closeMenus()}onClick(){this.props.onClick(),this.closeMenus()}toggleStyle(e){ds(this.env,{[e]:!this.style[e]})}toggleFormat(e){const t=Wb.find((t=>t.name===e)),i=t&&t.value||"";hs(this.env,i)}toggleHorizontalAlign(e){ds(this.env,{align:e}),this.onClick()}toggleVerticalAlign(e){ds(this.env,{verticalAlign:e}),this.onClick()}toggleTextWrapping(e){ds(this.env,{wrapping:e}),this.onClick()}onMenuMouseOver(e,t){this.isSelectingMenu&&this.openMenu(e,t)}toggleDropdownTool(e,t){const i=this.state.activeTool===e;this.closeMenus(),this.state.activeTool=i?"":e,this.openedEl=i?null:t.target}toggleContextMenu(e,t){this.state.menuState.isOpen?this.closeMenus():this.openMenu(e,t)}openMenu(e,t){const{left:i,top:o,height:n}=t.target.getBoundingClientRect();this.state.menuState.isOpen=!0,this.state.menuState.position={x:i,y:o+n},this.state.menuState.menuItems=e.children(this.env),this.state.menuState.parentMenu=e,this.isSelectingMenu=!0,this.openedEl=t.target}closeMenus(){this.state.activeTool="",this.state.menuState.isOpen=!1,this.state.menuState.parentMenu=void 0,this.isSelectingMenu=!1,this.openedEl=null}updateCellState(){const e=this.env.model.getters.getSelectedZones(),{col:t,row:i,sheetId:o}=this.env.model.getters.getActivePosition();this.inMerge=!1;const{top:n,left:s,right:r,bottom:a}=this.env.model.getters.getSelectedZone(),{xSplit:l,ySplit:c}=this.env.model.getters.getPaneDivisions(o);if(this.cannotMerge=e.length>1||n===a&&s===r||s<l&&l<=r||n<c&&c<=a,!this.cannotMerge){const n=this.env.model.getters.expandZone(o,Ji({col:t,row:i}));this.inMerge=Bi(e[0],n)}this.undoTool=this.env.model.getters.canUndo(),this.redoTool=this.env.model.getters.canRedo(),this.paintFormatTool=this.env.model.getters.isPaintingFormat();const h=this.env.model.getters.getActiveCell();if(h.format){const e=this.commonFormats.find((e=>e.value===h.format));this.currentFormatName=e?e.name:""}else this.currentFormatName="automatic";this.style={...this.env.model.getters.getCurrentStyle()},this.style.align=this.style.align||h.defaultAlign,this.fillColor=this.style.fillColor||"#ffffff",this.textColor=this.style.textColor||"#000000",this.menus=ag.getMenuItems()}getMenuName(e){return e.name(this.env)}toggleMerge(){if(this.cannotMerge)return;const e=this.env.model.getters.getSelectedZones(),t=[e[e.length-1]],i=this.env.model.getters.getActiveSheetId();this.inMerge?this.env.model.dispatch("REMOVE_MERGE",{sheetId:i,target:t}):function(e,t,i){const o=e.model.dispatch("ADD_MERGE",{sheetId:t,target:i});o.isCancelledBecause(80)?e.raiseError(Bb.MergeInFilter):o.isCancelledBecause(3)&&e.askConfirmation(Bb.MergeIsDestructive,(()=>{e.model.dispatch("ADD_MERGE",{sheetId:t,target:i,force:!0})}))}(this.env,i,t)}setColor(e,t){ds(this.env,{[e]:t}),this.onClick()}setBorder(e){this.env.model.dispatch("SET_FORMATTING",{sheetId:this.env.model.getters.getActiveSheetId(),target:this.env.model.getters.getSelectedZones(),border:e}),this.onClick()}setFormat(e,t){t?this.openCustomFormatSidePanel(e):this.toggleFormat(e),this.onClick()}openCustomFormatSidePanel(e){const t=Gb.find((t=>t.name===e)),i=t&&t.sidePanel||"";this.env.openSidePanel(i)}setDecimal(e){this.env.model.dispatch("SET_DECIMAL",{sheetId:this.env.model.getters.getActiveSheetId(),target:this.env.model.getters.getSelectedZones(),step:e})}paintFormat(){this.env.model.dispatch("ACTIVATE_PAINT_FORMAT",{target:this.env.model.getters.getSelectedZones()})}clearFormatting(){this.env.model.dispatch("CLEAR_FORMATTING",{sheetId:this.env.model.getters.getActiveSheetId(),target:this.env.model.getters.getSelectedZones()})}doAction(e){e(this.env),this.closeMenus()}undo(){this.env.model.dispatch("REQUEST_UNDO")}redo(){this.env.model.dispatch("REQUEST_REDO")}get selectionContainsFilter(){const e=this.env.model.getters.getActiveSheetId(),t=this.env.model.getters.getSelectedZones();return this.env.model.getters.doesZonesContainFilter(e,t)}get cannotCreateFilter(){return!io(...this.env.model.getters.getSelectedZones())}createFilter(){if(this.cannotCreateFilter)return;this.env.model.selection.selectTableAroundSelection();const e=this.env.model.getters.getActiveSheetId(),t=this.env.model.getters.getSelectedZones();as(this.env,e,t)}removeFilter(){this.env.model.dispatch("REMOVE_FILTER_TABLE",{sheetId:this.env.model.getters.getActiveSheetId(),target:this.env.model.getters.getSelectedZones()})}}Zb.template="o-spreadsheet-TopBar",Zb.components={ColorPickerWidget:bg,Menu:jn,TopBarComposer:Hb,FontSizeEditor:$b},Zb.props={onClick:Function,focusComposer:String,onComposerContentFocused:Function,dropdownMaxHeight:Number};class jb{constructor(e){this.clipboard=e}async write(e){var t;try{null===(t=this.clipboard)||void 0===t||t.write(this.getClipboardItems(e))}catch(e){}}async writeText(e){var t;try{null===(t=this.clipboard)||void 0===t||t.writeText(e)}catch(e){}}async readText(){let e;try{e=await navigator.permissions.query({name:"clipboard-read"})}catch(e){}try{return{status:"ok",content:await this.clipboard.readText()}}catch(t){return{status:"denied"===(null==e?void 0:e.state)?"permissionDenied":"notImplemented"}}}getClipboardItems(e){return[new ClipboardItem({[Co.PlainText]:this.getBlob(e,Co.PlainText),[Co.Html]:this.getBlob(e,Co.Html)})]}getBlob(e,t){return new Blob([e[t]||""],{type:t})}}ro`
|
|
1877
|
-
.o-spreadsheet {
|
|
1878
|
-
position: relative;
|
|
1879
|
-
display: grid;
|
|
1880
|
-
grid-template-columns: auto 350px;
|
|
1881
|
-
color: #333;
|
|
1882
|
-
input {
|
|
1883
|
-
background-color: white;
|
|
1884
|
-
}
|
|
1885
|
-
.text-muted {
|
|
1886
|
-
color: grey !important;
|
|
1887
|
-
}
|
|
1888
|
-
button {
|
|
1889
|
-
color: #333;
|
|
1890
|
-
}
|
|
1891
|
-
|
|
1892
|
-
* {
|
|
1893
|
-
font-family: "Roboto", "RobotoDraft", Helvetica, Arial, sans-serif;
|
|
1894
|
-
}
|
|
1895
|
-
&,
|
|
1896
|
-
*,
|
|
1897
|
-
*:before,
|
|
1898
|
-
*:after {
|
|
1899
|
-
box-sizing: content-box;
|
|
1900
|
-
}
|
|
1901
|
-
.o-separator {
|
|
1902
|
-
border-bottom: ${1}px solid ${A};
|
|
1903
|
-
margin-top: ${5}px;
|
|
1904
|
-
margin-bottom: ${5}px;
|
|
1905
|
-
}
|
|
1906
|
-
}
|
|
1907
|
-
|
|
1908
|
-
.o-two-columns {
|
|
1909
|
-
grid-column: 1 / 3;
|
|
1910
|
-
}
|
|
1911
|
-
|
|
1912
|
-
.o-icon {
|
|
1913
|
-
width: ${k}px;
|
|
1914
|
-
height: ${k}px;
|
|
1915
|
-
vertical-align: middle;
|
|
1916
|
-
}
|
|
1917
|
-
|
|
1918
|
-
.o-cf-icon {
|
|
1919
|
-
width: ${15}px;
|
|
1920
|
-
height: ${15}px;
|
|
1921
|
-
vertical-align: sub;
|
|
1922
|
-
}
|
|
1923
|
-
`,ro`
|
|
1924
|
-
.o-grid {
|
|
1925
|
-
position: relative;
|
|
1926
|
-
overflow: hidden;
|
|
1927
|
-
background-color: ${f};
|
|
1928
|
-
&:focus {
|
|
1929
|
-
outline: none;
|
|
1930
|
-
}
|
|
1931
|
-
|
|
1932
|
-
> canvas {
|
|
1933
|
-
border-top: 1px solid #e2e3e3;
|
|
1934
|
-
border-bottom: 1px solid #e2e3e3;
|
|
1935
|
-
}
|
|
1936
|
-
.o-scrollbar {
|
|
1937
|
-
&.corner {
|
|
1938
|
-
right: 0px;
|
|
1939
|
-
bottom: 0px;
|
|
1940
|
-
height: ${D}px;
|
|
1941
|
-
width: ${D}px;
|
|
1942
|
-
border-top: 1px solid #e2e3e3;
|
|
1943
|
-
border-left: 1px solid #e2e3e3;
|
|
1944
|
-
}
|
|
1945
|
-
}
|
|
1946
|
-
|
|
1947
|
-
.o-grid-overlay {
|
|
1948
|
-
position: absolute;
|
|
1949
|
-
outline: none;
|
|
1950
|
-
}
|
|
1951
|
-
}
|
|
1952
|
-
`;class Xb extends t.Component{constructor(){super(...arguments),this.isViewportTooSmall=!1}get model(){return this.props.model}getStyle(){return this.env.isDashboard()?"grid-template-rows: auto;":"grid-template-rows: 63px auto 37px"}setup(){this.sidePanel=t.useState({isOpen:!1,panelProps:{}}),this.composer=t.useState({topBarFocus:"inactive",gridFocusMode:"inactive"}),this.keyDownMapping={"CTRL+H":()=>this.toggleSidePanel("FindAndReplace",{}),"CTRL+F":()=>this.toggleSidePanel("FindAndReplace",{})};const e=this.model.config.external.fileStore;t.useSubEnv({model:this.model,imageProvider:e?new Ob(e):void 0,loadCurrencies:this.model.config.external.loadCurrencies,isDashboard:()=>this.model.getters.isDashboard(),openSidePanel:this.openSidePanel.bind(this),toggleSidePanel:this.toggleSidePanel.bind(this),_t:Xb._t,clipboard:this.env.clipboard||new jb(navigator.clipboard),startCellEdition:e=>this.onGridComposerCellFocused(e)}),t.useExternalListener(window,"resize",(()=>this.render(!0))),t.useExternalListener(window,"beforeunload",this.unbindModelEvents.bind(this)),this.bindModelEvents(),t.onMounted((()=>{this.checkViewportSize()})),t.onWillUnmount((()=>this.unbindModelEvents())),t.onPatched((()=>{this.checkViewportSize()}))}get focusTopBarComposer(){return"inactive"===this.model.getters.getEditionMode()?"inactive":this.composer.topBarFocus}get focusGridComposer(){return"inactive"===this.model.getters.getEditionMode()?"inactive":this.composer.gridFocusMode}bindModelEvents(){this.model.on("update",this,(()=>this.render(!0))),this.model.on("notify-ui",this,this.onNotifyUI)}unbindModelEvents(){this.model.off("update",this),this.model.off("notify-ui",this)}checkViewportSize(){const{xRatio:e,yRatio:t}=this.env.model.getters.getFrozenSheetViewRatio(this.env.model.getters.getActiveSheetId());if(t>.85||e>.85){if(this.isViewportTooSmall)return;this.env.notifyUser({text:s("The current window is too small to display this sheet properly. Consider resizing your browser window or adjusting frozen rows and columns."),tag:"viewportTooSmall"}),this.isViewportTooSmall=!0}else this.isViewportTooSmall=!1}onNotifyUI(e){if("ERROR"===e.type)this.env.raiseError(e.text)}openSidePanel(e,t){this.sidePanel.component=e,this.sidePanel.panelProps=t,this.sidePanel.isOpen=!0}closeSidePanel(){this.sidePanel.isOpen=!1,this.focusGrid()}toggleSidePanel(e,t){this.sidePanel.isOpen&&e===this.sidePanel.component?(this.sidePanel.isOpen=!1,this.focusGrid()):this.openSidePanel(e,t)}focusGrid(){if(!this._focusGrid)throw new Error("_focusGrid should be exposed by the grid component");this._focusGrid()}onKeydown(e){let t="";(e.ctrlKey||e.metaKey)&&(t+="CTRL+"),t+=e.key.toUpperCase();let i=this.keyDownMapping[t];if(i)return e.preventDefault(),e.stopPropagation(),void i()}onTopBarComposerFocused(e){this.model.getters.isReadonly()||(this.model.dispatch("UNFOCUS_SELECTION_INPUT"),this.composer.topBarFocus="contentFocus",this.composer.gridFocusMode="inactive",this.setComposerContent({selection:e}||{}))}onGridComposerContentFocused(){this.model.getters.isReadonly()||(this.model.dispatch("UNFOCUS_SELECTION_INPUT"),this.composer.topBarFocus="inactive",this.composer.gridFocusMode="contentFocus",this.setComposerContent({}))}onGridComposerCellFocused(e,t){this.model.getters.isReadonly()||(this.model.dispatch("UNFOCUS_SELECTION_INPUT"),this.composer.topBarFocus="inactive",this.composer.gridFocusMode="cellFocus",this.setComposerContent({content:e,selection:t}||{}))}setComposerContent({content:e,selection:t}){"inactive"===this.model.getters.getEditionMode()?this.model.dispatch("START_EDITION",{text:e,selection:t}):e&&this.model.dispatch("SET_CURRENT_CONTENT",{content:e,selection:t})}get gridHeight(){const{height:e}=this.env.model.getters.getSheetViewDimension();return e}}Xb.template="o-spreadsheet-Spreadsheet",Xb.components={TopBar:Zb,Grid:op,BottomBar:Pb,SidePanel:zb,SpreadsheetDashboard:Vb},Xb._t=e=>e,Xb.props={model:Object};class Yb{constructor(){this.listeners=[]}sendMessage(e){for(const{callback:t}of this.listeners)t(e)}onNewMessage(e,t){this.listeners.push({id:e,callback:t})}leave(e){this.listeners=this.listeners.filter((t=>t.id!==e))}}function Kb(e){return ng.get(e.type)(e)}function Qb(e){if("string"==typeof e)return{};if("number"==typeof e)return[];throw new Error("Cannot create new node")}class Jb{constructor(e,t=[]){this.buildTransformation=e,this.operations=t}getOperations(){return this.operations}getOperation(e){const t=this.operations.find((t=>t.id===e));if(!t)throw new Error(`Operation ${e} not found`);return t}getLastOperationId(){var e;return null===(e=this.operations[this.operations.length-1])||void 0===e?void 0:e.id}getFirstOperationAmong(e,t){for(const i of this.operations){if(i.id===e)return e;if(i.id===t)return t}throw new Error(`Operation ${e} and ${t} not found`)}contains(e){return!!this.operations.find((t=>t.id===e))}prepend(e){const t=this.buildTransformation.with(e.data);this.operations=[e,...this.operations.map((e=>e.transformed(t)))]}insert(e,t){const i=this.buildTransformation.with(e.data),{before:o,operation:n,after:s}=this.locateOperation(t);this.operations=[...o,n,e,...s.map((e=>e.transformed(i)))]}append(e){this.operations.push(e)}appendBranch(e){this.operations=this.operations.concat(e.operations)}fork(e){const{after:t}=this.locateOperation(e);return new Jb(this.buildTransformation,t)}transform(e){this.operations=this.operations.map((t=>t.transformed(e)))}cutBefore(e){this.operations=this.locateOperation(e).before}cutAfter(e){const{before:t,operation:i}=this.locateOperation(e);this.operations=t.concat([i])}locateOperation(e){const t=this.operations.findIndex((t=>t.id===e));if(-1===t)throw new Error(`Operation ${e} not found`);return{before:this.operations.slice(0,t),operation:this.operations[t],after:this.operations.slice(t+1)}}}class eS{constructor(e,t){this.id=e,this.data=t}transformed(e){return new tS(this.id,nt((()=>e(this.data))))}}class tS{constructor(e,t){this.id=e,this.lazyData=t}get data(){return this.lazyData()}transformed(e){return new tS(this.id,this.lazyData.map(e))}}class iS{constructor(e){this.operations=e}[Symbol.iterator](){return this.operations[Symbol.iterator]()}stopWith(e){return new iS(function*(e,t){for(const i of e)if(yield i,i.operation.id===t)return}(this.operations,e))}stopBefore(e){return new iS(function*(e,t){for(const i of e){if(i.operation.id===t)return;yield i}}(this.operations,e))}startAfter(e){return new iS(function*(e,t){let i=!0;for(const o of e)i||(yield o),o.operation.id===t&&(i=!1)}(this.operations,e))}}class oS{constructor(e,t){this.buildTransformation=e,this.branchingOperationIds=new Map,this.branches=[t]}getLastBranch(){return this.branches[this.branches.length-1]}execution(e){return new iS(He(this._execution(e),this._execution(e)))}revertedExecution(e){return new iS(He(this._revertedExecution(e),this._revertedExecution(e)))}insertOperationLast(e,t){var i;const o=e.getLastOperationId()||(null===(i=this.previousBranch(e))||void 0===i?void 0:i.getLastOperationId());e.append(t),o&&this.insertPrevious(e,t,o)}insertOperationAfter(e,t,i){e.insert(t,i),this.updateNextWith(e,t,i),this.insertPrevious(e,t,i)}undo(e,t){const i=this.buildTransformation.without(t.data),o=this.branchingOperationIds.get(e);this.branchingOperationIds.set(e,t.id);const n=e.fork(t.id);o&&this.branchingOperationIds.set(n,o),this.insertBranchAfter(e,n),this.transform(n,i)}redo(e){const t=this.nextBranch(e);if(!t)return;const i=this.nextBranch(t);this.removeBranchFromTree(t);const o=this.branchingOperationIds.get(t);o?this.branchingOperationIds.set(e,o):this.branchingOperationIds.delete(e),i&&this.rebaseUp(i)}drop(e){for(const t of this.branches)t.contains(e)&&t.cutBefore(e)}findOperation(e,t){for(const i of this.revertedExecution(e))if(i.operation.id===t)return i;throw new Error(`Operation ${t} not found`)}rebaseUp(e){const{previousBranch:t,branchingOperation:i}=this.findPreviousBranchingOperation(e);if(!t||!i)return;const o=this.buildTransformation.without(i.data),n=t.fork(i.id);this.branchingOperationIds.set(n,this.branchingOperationIds.get(e)),this.removeBranchFromTree(e),this.insertBranchAfter(t,n),n.transform(o);const s=this.nextBranch(n);s&&this.rebaseUp(s)}removeBranchFromTree(e){const t=this.branches.findIndex((t=>t===e));this.branches.splice(t,1)}insertBranchAfter(e,t){const i=this.branches.findIndex((t=>t===e));this.branches.splice(i+1,0,t)}updateNextWith(e,t,i){const o=this.branchingOperationIds.get(e),n=this.nextBranch(e);if(o&&n)if(e.getFirstOperationAmong(i,o)===o){const s=this.addToNextBranch(e,n,o,t,i);this.updateNextWith(n,s,i)}else{const e=this.buildTransformation.with(t.data);this.transform(n,e)}}addToNextBranch(e,t,i,o,n){let s=o;return n===i?(s=this.getTransformedOperation(e,i,o),t.prepend(s)):t.contains(n)?(s=this.getTransformedOperation(e,i,o),t.insert(s,n)):t.append(o),s}getTransformedOperation(e,t,i){const o=e.getOperation(t),n=this.buildTransformation.without(o.data);return i.transformed(n)}shouldExecute(e,t){return t.id!==this.branchingOperationIds.get(e)}transform(e,t){e.transform(t);const i=this.nextBranch(e);i&&this.transform(i,t)}insertPrevious(e,t,i){const{previousBranch:o,branchingOperation:n}=this.findPreviousBranchingOperation(e);if(!o||!n)return;const s=this.buildTransformation.with(n.data),r=e.fork(i);r.transform(s),o.cutAfter(i),o.appendBranch(r);const a=t.transformed(s);this.insertPrevious(o,a,i)}findPreviousBranchingOperation(e){const t=this.previousBranch(e);if(!t)return{previousBranch:void 0,branchingOperation:void 0};const i=this.branchingOperationIds.get(t);return i?{previousBranch:t,branchingOperation:t.getOperation(i)}:{previousBranch:void 0,branchingOperation:void 0}}nextBranch(e){const t=this.branches.findIndex((t=>t===e));if(-1!==t)return this.branches[t+1]}previousBranch(e){const t=this.branches.findIndex((t=>t===e));if(-1!==t)return this.branches[t-1]}*_revertedExecution(e){const t=this.branchingOperationIds.get(e);let i=!!t;const o=e.getOperations();for(let n=o.length-1;n>=0;n--){const s=o[n];s.id===t&&(i=!1),i||(yield{operation:s,branch:e,isCancelled:!this.shouldExecute(e,s)})}const n=this.previousBranch(e);yield*n?this._revertedExecution(n):[]}*_execution(e){for(const t of e.getOperations())if(yield{operation:t,branch:e,isCancelled:!this.shouldExecute(e,t)},t.id===this.branchingOperationIds.get(e)){const t=this.nextBranch(e);return void(yield*t?this._execution(t):[])}if(!this.branchingOperationIds.get(e)){const t=this.nextBranch(e);yield*t?this._execution(t):[]}}}class nS{constructor(e,t,i,o,n){this.applyOperation=t,this.revertOperation=i,this.buildEmpty=o,this.buildTransformation=n,this.HEAD_BRANCH=new Jb(this.buildTransformation),this.tree=new oS(n,this.HEAD_BRANCH);const s=new eS(e,o(e));this.tree.insertOperationLast(this.HEAD_BRANCH,s),this.HEAD_OPERATION=s}get(e){return this.tree.findOperation(this.HEAD_BRANCH,e).operation.data}append(e,t){const i=new eS(e,t),o=this.tree.getLastBranch();this.tree.insertOperationLast(o,i),this.HEAD_BRANCH=o,this.HEAD_OPERATION=i}insert(e,t,i){const o=new eS(e,t);this.revertTo(i),this.tree.insertOperationAfter(this.HEAD_BRANCH,o,i),this.fastForward()}undo(e,t,i){const{branch:o,operation:n}=this.tree.findOperation(this.HEAD_BRANCH,e);this.revertBefore(e),this.tree.undo(o,n),this.fastForward(),this.insert(t,this.buildEmpty(t),i)}redo(e,t,i){const{branch:o}=this.tree.findOperation(this.HEAD_BRANCH,e);this.revertBefore(e),this.tree.redo(o),this.fastForward(),this.insert(t,this.buildEmpty(t),i)}drop(e){this.revertBefore(e),this.tree.drop(e)}revertBefore(e){const t=this.tree.revertedExecution(this.HEAD_BRANCH).stopWith(e);this.revert(t)}revertTo(e){const t=e?this.tree.revertedExecution(this.HEAD_BRANCH).stopBefore(e):this.tree.revertedExecution(this.HEAD_BRANCH);this.revert(t)}revert(e){for(const{next:t,operation:i,isCancelled:o}of e)o||this.revertOperation(i.data),t&&(this.HEAD_BRANCH=t.branch,this.HEAD_OPERATION=t.operation)}fastForward(){const e=this.HEAD_OPERATION?this.tree.execution(this.HEAD_BRANCH).startAfter(this.HEAD_OPERATION.id):this.tree.execution(this.HEAD_BRANCH);for(const{operation:t,branch:i,isCancelled:o}of e)o||this.applyOperation(t.data),this.HEAD_OPERATION=t,this.HEAD_BRANCH=i}}function sS(e,t,i){return new nS(e,(e=>{const o=e.commands.slice(),{changes:n}=t((()=>{for(const e of o)i(e)}));e.setChanges(n)}),(e=>function(e){for(const t of e.slice().reverse())for(let e=t.changes.length-1;e>=0;e--){rS(t.changes[e],"before")}}([e])),(e=>new ob(e,"empty",[],[])),{with:e=>t=>new ob(t.id,t.clientId,tb(t.commands,e.commands)),without:e=>t=>new ob(t.id,t.clientId,tb(t.commands,e.commands.map(Kb).flat()))})}function rS(e,t){let i=e.root,o=e.path[e.path.length-1];for(let t=0;t<e.path.slice(0,-1).length;t++){const o=e.path[t];if(void 0===i[o]){const n=e.path[t+1];i[o]=Qb(n)}i=i[o]}void 0===e[t]?delete i[o]:i[o]=e[t]}class aS extends t.EventBus{constructor(e,t){super(),this.dispatch=e,this.session=t,this.undoStack=[],this.redoStack=[],this.session.on("new-local-state-update",this,this.onNewLocalStateUpdate),this.session.on("revision-undone",this,(({commands:e})=>this.selectiveUndo(e))),this.session.on("revision-redone",this,(({commands:e})=>this.selectiveRedo(e))),this.session.on("pending-revisions-dropped",this,(({revisionIds:e})=>this.drop(e))),this.session.on("snapshot",this,(()=>{this.undoStack=[],this.redoStack=[]}))}allowDispatch(e){switch(e.type){case"REQUEST_UNDO":if(!this.canUndo())return 6;break;case"REQUEST_REDO":if(!this.canRedo())return 7}return 0}beforeHandle(e){}handle(e){switch(e.type){case"REQUEST_UNDO":case"REQUEST_REDO":this.requestHistoryChange("REQUEST_UNDO"===e.type?"UNDO":"REDO")}}finalize(){}requestHistoryChange(e){const t="UNDO"===e?this.undoStack.pop():this.redoStack.pop();t&&("UNDO"===e?(this.session.undo(t),this.redoStack.push(t)):(this.session.redo(t),this.undoStack.push(t)))}canUndo(){return this.undoStack.length>0}canRedo(){return this.redoStack.length>0}drop(e){this.undoStack=this.undoStack.filter((t=>!e.includes(t))),this.redoStack=[]}onNewLocalStateUpdate({id:e}){this.undoStack.push(e),this.redoStack=[],this.undoStack.length>99&&this.undoStack.shift()}selectiveUndo(e){this.dispatch("UNDO",{commands:e})}selectiveRedo(e){this.dispatch("REDO",{commands:e})}}class lS{constructor(){this.observers=[]}registerAsDefault(e,t){this.defaultSubscription={owner:e,callbacks:t},this.mainSubscription||(this.mainSubscription=this.defaultSubscription)}observe(e,t){this.observers.push({owner:e,callbacks:t})}capture(e,t){var i,o,n;if(this.observers.find((t=>t.owner===e)))throw new Error("You are already subscribed forever");(null===(i=this.mainSubscription)||void 0===i?void 0:i.owner)&&this.mainSubscription.owner!==e&&(null===(n=(o=this.mainSubscription.callbacks).release)||void 0===n||n.call(o)),this.mainSubscription={owner:e,callbacks:t}}release(e){var t;(null===(t=this.mainSubscription)||void 0===t?void 0:t.owner)!==e||this.observers.find((t=>t.owner===e))||(this.mainSubscription=this.defaultSubscription)}getBackToDefault(){var e,t,i;this.mainSubscription!==this.defaultSubscription&&(null===(i=null===(e=this.mainSubscription)||void 0===e?void 0:(t=e.callbacks).release)||void 0===i||i.call(t),this.mainSubscription=this.defaultSubscription)}isListening(e){var t;return(null===(t=this.mainSubscription)||void 0===t?void 0:t.owner)===e}send(e){var t;null===(t=this.mainSubscription)||void 0===t||t.callbacks.handleEvent(e),[...this.observers].forEach((t=>t.callbacks.handleEvent(e)))}}class cS{constructor(e){this.getters=e,this.stream=new lS,this.anchor={cell:{col:0,row:0},zone:Ji({col:0,row:0})},this.defaultAnchor=this.anchor}capture(e,t,i){this.stream.capture(e,i),this.anchor=t}registerAsDefault(e,t,i){this.checkAnchorZoneOrThrow(t),this.stream.registerAsDefault(e,i),this.defaultAnchor=t,this.capture(e,t,i)}resetDefaultAnchor(e,t){this.checkAnchorZoneOrThrow(t),this.stream.isListening(e)&&(this.anchor=t),this.defaultAnchor=t}resetAnchor(e,t){this.checkAnchorZoneOrThrow(t),this.stream.isListening(e)&&(this.anchor=t)}observe(e,t){this.stream.observe(e,t)}release(e){this.stream.isListening(e)&&(this.stream.release(e),this.anchor=this.defaultAnchor)}getBackToDefault(){this.stream.getBackToDefault()}selectZone(e){return this.modifyAnchor(e,"overrideSelection","ZonesSelected")}modifyAnchor(e,t,i){const o=this.getters.getActiveSheetId();return e={...e,zone:this.getters.expandZone(o,e.zone)},this.processEvent({type:i,anchor:e,mode:t})}selectCell(e,t){const i=Ji({col:e,row:t});return this.selectZone({zone:i,cell:{col:e,row:t}})}moveAnchorCell(e,t=1){if("end"!==t&&t<=0)return new Ro(83);const{col:i,row:o}=this.getNextAvailablePosition(e,t);return this.selectCell(i,o)}setAnchorCorner(e,t){const i=this.getters.getActiveSheetId(),{col:o,row:n}=this.anchor.cell,s={left:Math.min(o,e),top:Math.min(n,t),right:Math.max(o,e),bottom:Math.max(n,t)},r={zone:this.getters.expandZone(i,s),cell:{col:o,row:n}};return this.processEvent({type:"AlterZone",mode:"updateAnchor",anchor:r})}addCellToSelection(e,t){const i=this.getters.getActiveSheetId();({col:e,row:t}=this.getters.getMainCellPosition({sheetId:i,col:e,row:t}));const o=this.getters.expandZone(i,Ji({col:e,row:t}));return this.processEvent({type:"ZonesSelected",anchor:{zone:o,cell:{col:e,row:t}},mode:"newAnchor"})}resizeAnchorZone(e,t=1){if("end"!==t&&t<=0)return new Ro(83);const i=this.getters.getActiveSheetId(),o=this.anchor,{col:n,row:s}=o.cell,{left:r,right:a,top:l,bottom:c}=o.zone,h=this.getStartingPosition(e);let[d,u]=this.deltaToTarget(h,e,t);if(0===d&&0===u)return Ro.Success;let g=o.zone;const p=e=>{e=Qi(e);const{left:t,right:o,top:n,bottom:s}=this.getters.expandZone(i,e);return{left:Math.max(0,t),right:Math.min(this.getters.getNumberCols(i)-1,o),top:Math.max(0,n),bottom:Math.min(this.getters.getNumberRows(i)-1,s)}},{col:m,row:f}=this.getReferencePosition();let v=0;for(;null!==g;){if(v++,d<0){const e=this.getNextAvailableCol(d,a-(v-1),f);g=m<=a-v?p({top:l,left:r,bottom:c,right:e}):null}if(d>0){const e=this.getNextAvailableCol(d,r+(v-1),f);g=r+v<=m?p({top:l,left:e,bottom:c,right:a}):null}if(u<0){const e=this.getNextAvailableRow(u,m,c-(v-1));g=f<=c-v?p({top:l,left:r,bottom:e,right:a}):null}if(u>0){const e=this.getNextAvailableRow(u,m,l+(v-1));g=l+v<=f?p({top:e,left:r,bottom:c,right:a}):null}if(g=g?Qi(g):g,g&&!Bi(g,o.zone))return this.processEvent({type:"ZonesSelected",mode:"updateAnchor",anchor:{zone:g,cell:{col:n,row:s}}})}g=p(Vi({top:s,bottom:s,left:n,right:n},Qi({top:this.getNextAvailableRow(u,m,l),left:this.getNextAvailableCol(d,r,f),bottom:this.getNextAvailableRow(u,m,c),right:this.getNextAvailableCol(d,a,f)})));const b={zone:g,cell:{col:n,row:s}};return this.processEvent({type:"ZonesSelected",anchor:b,mode:"updateAnchor"})}selectColumn(e,t){const i=this.getters.getActiveSheetId(),o=this.getters.getNumberRows(i)-1;let n={left:e,right:e,top:0,bottom:o};const s=this.getters.findFirstVisibleColRowIndex(i,"ROW");let r,a;switch(t){case"overrideSelection":case"newAnchor":r=e,a=s;break;case"updateAnchor":({col:r,row:a}=this.anchor.cell),n=Vi(n,{left:r,right:r,top:s,bottom:o})}return this.processEvent({type:"HeadersSelected",anchor:{zone:n,cell:{col:r,row:a}},mode:t})}selectRow(e,t){const i=this.getters.getActiveSheetId(),o=this.getters.getNumberCols(i)-1;let n={top:e,bottom:e,left:0,right:o};const s=this.getters.findFirstVisibleColRowIndex(i,"COL");let r,a;switch(t){case"overrideSelection":case"newAnchor":r=s,a=e;break;case"updateAnchor":({col:r,row:a}=this.anchor.cell),n=Vi(n,{left:s,right:o,top:a,bottom:a})}return this.processEvent({type:"HeadersSelected",anchor:{zone:n,cell:{col:r,row:a}},mode:t})}loopSelection(){const e=this.getters.getActiveSheetId(),t=this.anchor;if(Bi(this.anchor.zone,this.getters.getSheetZone(e)))return this.modifyAnchor({...t,zone:Ji(t.cell)},"updateAnchor","AlterZone");const i=this.expandZoneToTable(t.zone);return at(i,t.zone)?this.selectAll():this.modifyAnchor({...t,zone:i},"updateAnchor","AlterZone")}selectTableAroundSelection(){const e=this.expandZoneToTable(this.anchor.zone);return this.modifyAnchor({...this.anchor,zone:e},"updateAnchor","AlterZone")}selectAll(){const e=this.getters.getActiveSheetId(),t={left:0,top:0,bottom:this.getters.getNumberRows(e)-1,right:this.getters.getNumberCols(e)-1};return this.processEvent({type:"HeadersSelected",mode:"overrideSelection",anchor:{zone:t,cell:this.anchor.cell}})}processEvent(e){const t={...e,previousAnchor:Ne(this.anchor)},i=this.checkEventAnchorZone(t);return 0!==i?new Ro(i):(this.anchor=t.anchor,this.stream.send(t),Ro.Success)}checkEventAnchorZone(e){return this.checkAnchorZone(e.anchor)}checkAnchorZone(e){const{cell:t,zone:i}=e;if(!$i(t.col,t.row,i))return 16;const{left:o,right:n,top:s,bottom:r}=i,a=this.getters.getActiveSheetId(),l=this.getters.findVisibleHeader(a,"COL",ze(o,n+1));return void 0===this.getters.findVisibleHeader(a,"ROW",ze(s,r+1))||void 0===l?17:0}checkAnchorZoneOrThrow(e){if(16===this.checkAnchorZone(e))throw new Error(n("The provided anchor is invalid. The cell must be part of the zone."))}getNextAvailablePosition(e,t=1){const{col:i,row:o}=this.anchor.cell,n=this.deltaToTarget({col:i,row:o},e,t);return{col:this.getNextAvailableCol(n[0],i,o),row:this.getNextAvailableRow(n[1],i,o)}}getNextAvailableCol(e,t,i){const o=this.getters.getActiveSheetId(),n={col:t,row:i};return this.getNextAvailableHeader(e,"COL",t,n,(e=>this.getters.isInSameMerge(o,t,i,e,i)))}getNextAvailableRow(e,t,i){const o=this.getters.getActiveSheetId(),n={col:t,row:i};return this.getNextAvailableHeader(e,"ROW",i,n,(e=>this.getters.isInSameMerge(o,t,i,t,e)))}getNextAvailableHeader(e,t,i,o,n){const s=this.getters.getActiveSheetId();if(0===e)return i;const r=Math.sign(e);let a=i+e;for(;n(a);)a+=r;for(;this.getters.isHeaderHidden(s,t,a);)a+=r;return a<0||a>this.getters.getNumberHeaders(s,t)-1?this.getters.isHeaderHidden(s,t,i)?this.getNextAvailableHeader(-r,t,i,o,n):i:a}getReferencePosition(){const e=this.getters.getActiveSheetId(),t=this.anchor,{left:i,right:o,top:n,bottom:s}=t.zone,{col:r,row:a}=t.cell;return{col:this.getters.isColHidden(e,r)&&this.getters.findVisibleHeader(e,"COL",ze(i,o+1))||r,row:this.getters.isRowHidden(e,a)&&this.getters.findVisibleHeader(e,"ROW",ze(n,s+1))||a}}deltaToTarget(e,t,i){switch(t){case"up":return"end"!==i?[0,-i]:[0,this.getEndOfCluster(e,"rows",-1)-e.row];case"down":return"end"!==i?[0,i]:[0,this.getEndOfCluster(e,"rows",1)-e.row];case"left":return"end"!==i?[-i,0]:[this.getEndOfCluster(e,"cols",-1)-e.col,0];case"right":return"end"!==i?[i,0]:[this.getEndOfCluster(e,"cols",1)-e.col,0]}}getStartingPosition(e){let{col:t,row:i}=this.getPosition();const o=this.anchor.zone;switch(e){case"down":case"up":i=i===o.top?o.bottom:o.top;break;case"left":case"right":t=t===o.right?o.left:o.right}return{col:t,row:i}}getEndOfCluster(e,t,i){const o=this.getters.getActiveSheet();let n=e;const s=this.getNextCellPosition(e,t,i);let r=this.isCellEmpty(n,o.id)||this.isCellEmpty(s,o.id)?"nextCluster":"endOfCluster";for(;;){const e=this.getNextCellPosition(n,t,i);if(n.col===e.col&&n.row===e.row)break;const s=this.isCellEmpty(e,o.id);if("endOfCluster"===r&&s)break;if("nextCluster"===r&&!s){n=e;break}n=e}return"cols"===t?n.col:n.row}isCellEmpty({col:e,row:t},i=this.getters.getActiveSheetId()){const o=this.getters.getMainCellPosition({sheetId:i,col:e,row:t});return this.getters.getEvaluatedCell(o).type===So.empty}getNextCellPosition(e,t,i){const o="cols"===t?"col":"row",n={...e},s="cols"===t?this.getNextAvailableCol(i,n.col,n.row):this.getNextAvailableRow(i,n.col,n.row);return n[o]=s,{col:n.col,row:n.row}}getPosition(){return{...this.anchor.cell}}expandZoneToTable(e){const t=e=>{for(const t of ze(e.left,e.right+1)){if(!this.isCellEmpty({col:t,row:e.top-1}))return{...e,top:e.top-1};if(!this.isCellEmpty({col:t,row:e.bottom+1}))return{...e,bottom:e.bottom+1}}for(const t of ze(e.top,e.bottom+1)){if(!this.isCellEmpty({col:e.left-1,row:t}))return{...e,left:e.left-1};if(!this.isCellEmpty({col:e.right+1,row:t}))return{...e,right:e.right+1}}return e};let i=!1,o=e;do{i=!1;const e=t(o);Bi(o,e)||(i=!0,o=e)}while(i);return o}}class hS{constructor(){this.changes=[],this.commands=[]}recordChanges(e){return this.changes=[],this.commands=[],e(),{changes:this.changes,commands:this.commands}}addCommand(e){this.commands.push(e)}addChange(...e){const t=e.pop(),[i,...o]=e;let n=i,s=o[o.length-1];for(let e=0;e<=o.length-2;e++){const t=o[e];if(void 0===n[t]){const i=o[e+1];n[t]=Qb(i)}n=n[t]}n[s]!==t&&(this.changes.push({root:i,path:o,before:n[s],after:t}),void 0===t?delete n[s]:n[s]=t)}}const dS=17781237,uS=88853993;function gS(e,t,i){const o=[["xmlns:r",gp],["xmlns:a",cp],["xmlns:c",hp]],n=pS({backgroundColor:e.data.backgroundColor,line:{color:"000000"}});let s=Gm``;e.data.title&&(s=Gm`
|
|
1953
|
-
<c:title>
|
|
1954
|
-
${fS(e.data.title,e.data.fontColor)}
|
|
1955
|
-
<c:overlay val="0" />
|
|
1956
|
-
</c:title>
|
|
1957
|
-
`);let r=Gm``;switch(e.data.type){case"bar":r=function(e){const t=new Vo,i=[];for(const[o,n]of Object.entries(e.dataSets)){const s=fo(t.next()),r=pS({backgroundColor:s,line:{color:s}});i.push(Gm`
|
|
1958
|
-
<c:ser>
|
|
1959
|
-
<c:idx val="${o}"/>
|
|
1960
|
-
<c:order val="${o}"/>
|
|
1961
|
-
${n.label?Gm`<c:tx>${CS(n.label)}</c:tx>`:""}
|
|
1962
|
-
${r}
|
|
1963
|
-
${e.labelRange?Gm`<c:cat>${CS(e.labelRange)}</c:cat>`:""} <!-- x-coordinate values -->
|
|
1964
|
-
<c:val> <!-- x-coordinate values -->
|
|
1965
|
-
${ES(n.range)}
|
|
1966
|
-
</c:val>
|
|
1967
|
-
</c:ser>
|
|
1968
|
-
`)}const o="left"===e.verticalAxisPosition?"l":"r",n=e.stacked?"stacked":"clustered",s=e.stacked?100:-20;return Gm`
|
|
1969
|
-
<c:barChart>
|
|
1970
|
-
<c:barDir val="col"/>
|
|
1971
|
-
<c:grouping val="${n}"/>
|
|
1972
|
-
<c:overlap val="${s}"/>
|
|
1973
|
-
<c:gapWidth val="70"/>
|
|
1974
|
-
<!-- each data marker in the series does not have a different color -->
|
|
1975
|
-
<c:varyColors val="0"/>
|
|
1976
|
-
${Wm(i)}
|
|
1977
|
-
<c:axId val="${dS}" />
|
|
1978
|
-
<c:axId val="${uS}" />
|
|
1979
|
-
</c:barChart>
|
|
1980
|
-
${SS("b","c:catAx",dS,uS,{fontColor:e.fontColor})}
|
|
1981
|
-
${SS(o,"c:valAx",uS,dS,{fontColor:e.fontColor})}
|
|
1982
|
-
`}(e.data);break;case"line":r=function(e){const t=new Vo,i=[];for(const[o,n]of Object.entries(e.dataSets)){const s=pS({line:{width:2.5,style:"solid",color:fo(t.next())}});i.push(Gm`
|
|
1983
|
-
<c:ser>
|
|
1984
|
-
<c:idx val="${o}"/>
|
|
1985
|
-
<c:order val="${o}"/>
|
|
1986
|
-
<c:smooth val="0"/>
|
|
1987
|
-
<c:marker>
|
|
1988
|
-
<c:symbol val="circle" />
|
|
1989
|
-
<c:size val="5"/>
|
|
1990
|
-
</c:marker>
|
|
1991
|
-
${n.label?Gm`<c:tx>${CS(n.label)}</c:tx>`:""}
|
|
1992
|
-
${s}
|
|
1993
|
-
${e.labelRange?Gm`<c:cat>${CS(e.labelRange)}</c:cat>`:""} <!-- x-coordinate values -->
|
|
1994
|
-
<c:val> <!-- x-coordinate values -->
|
|
1995
|
-
${ES(n.range)}
|
|
1996
|
-
</c:val>
|
|
1997
|
-
</c:ser>
|
|
1998
|
-
`)}const o="left"===e.verticalAxisPosition?"l":"r",n=e.stacked?"stacked":"standard";return Gm`
|
|
1999
|
-
<c:lineChart>
|
|
2000
|
-
<c:grouping val="${n}"/>
|
|
2001
|
-
<!-- each data marker in the series does not have a different color -->
|
|
2002
|
-
<c:varyColors val="0"/>
|
|
2003
|
-
${Wm(i)}
|
|
2004
|
-
<c:axId val="${dS}" />
|
|
2005
|
-
<c:axId val="${uS}" />
|
|
2006
|
-
</c:lineChart>
|
|
2007
|
-
${SS("b","c:catAx",dS,uS,{fontColor:e.fontColor})}
|
|
2008
|
-
${SS(o,"c:valAx",uS,dS,{fontColor:e.fontColor})}
|
|
2009
|
-
`}(e.data);break;case"pie":r=function(e,t,i,{holeSize:o}={holeSize:50}){const n=new Vo,s=Math.max(...e.dataSets.map((e=>fm(e.range,t,i)))),r=ze(0,s).map((()=>fo(n.next()))),a=[];for(const[o,n]of Object.entries(e.dataSets).reverse()){const s=fm(n.range,t,i),l=[];for(const e of ze(0,s)){const t=pS({backgroundColor:r[e],line:{color:"FFFFFF",width:1.5}});l.push(Gm`
|
|
2010
|
-
<c:dPt>
|
|
2011
|
-
<c:idx val="${e}"/>
|
|
2012
|
-
${t}
|
|
2013
|
-
</c:dPt>
|
|
2014
|
-
`)}a.push(Gm`
|
|
2015
|
-
<c:ser>
|
|
2016
|
-
<c:idx val="${o}"/>
|
|
2017
|
-
<c:order val="${o}"/>
|
|
2018
|
-
${n.label?Gm`<c:tx>${CS(n.label)}</c:tx>`:""}
|
|
2019
|
-
${Wm(l)}
|
|
2020
|
-
${bS({showLeaderLines:!0})}
|
|
2021
|
-
${e.labelRange?Gm`<c:cat>${CS(e.labelRange)}</c:cat>`:""}
|
|
2022
|
-
<c:val>
|
|
2023
|
-
${ES(n.range)}
|
|
2024
|
-
</c:val>
|
|
2025
|
-
</c:ser>
|
|
2026
|
-
`)}return Gm`
|
|
2027
|
-
<c:doughnutChart>
|
|
2028
|
-
<c:varyColors val="1" />
|
|
2029
|
-
<c:holeSize val="${o}" />
|
|
2030
|
-
${bS()}
|
|
2031
|
-
${Wm(a)}
|
|
2032
|
-
</c:doughnutChart>
|
|
2033
|
-
`}(e.data,t,i,{holeSize:0})}let a="t";switch(e.data.legendPosition){case"bottom":a="b";break;case"left":a="l";break;case"right":a="r";break;case"top":a="t"}const l=e.data.fontColor,c=Gm`
|
|
2034
|
-
<c:chartSpace ${Bm(o)}>
|
|
2035
|
-
<c:roundedCorners val="0" />
|
|
2036
|
-
<!-- <manualLayout/> to manually position the chart in the figure container -->
|
|
2037
|
-
${n}
|
|
2038
|
-
<c:chart>
|
|
2039
|
-
${s}
|
|
2040
|
-
<c:autoTitleDeleted val="0" />
|
|
2041
|
-
<c:plotArea>
|
|
2042
|
-
<!-- how the chart element is placed on the chart -->
|
|
2043
|
-
<c:layout />
|
|
2044
|
-
${r}
|
|
2045
|
-
${pS({backgroundColor:e.data.backgroundColor})}
|
|
2046
|
-
</c:plotArea>
|
|
2047
|
-
${function(e,t){return Gm`
|
|
2048
|
-
<c:legend>
|
|
2049
|
-
<c:legendPos val="${e}"/>
|
|
2050
|
-
<c:overlay val="0"/>
|
|
2051
|
-
${vS(10,t)}
|
|
2052
|
-
</c:legend>
|
|
2053
|
-
`}(a,l)}
|
|
2054
|
-
</c:chart>
|
|
2055
|
-
</c:chartSpace>
|
|
2056
|
-
`;return Hm(c)}function pS(e){return Gm`
|
|
2057
|
-
<c:spPr>
|
|
2058
|
-
${e.backgroundColor?mS(e.backgroundColor):""}
|
|
2059
|
-
${e.line?function(e){const t=[["cmpd","sng"]];e.width&&t.push(["w",mm(e.width)]);const i=e.style?Gm`<a:prstDash val="${e.style}"/>`:"";return Gm`
|
|
2060
|
-
<a:ln ${Bm(t)}>
|
|
2061
|
-
${mS(e.color)}
|
|
2062
|
-
${i}
|
|
2063
|
-
</a:ln>
|
|
2064
|
-
`}(e.line):""}
|
|
2065
|
-
</c:spPr>
|
|
2066
|
-
`}function mS(e){return Gm`
|
|
2067
|
-
<a:solidFill>
|
|
2068
|
-
<a:srgbClr val="${e}"/>
|
|
2069
|
-
</a:solidFill>
|
|
2070
|
-
`}function fS(e,t="000000",i=22){return Gm`
|
|
2071
|
-
<c:tx>
|
|
2072
|
-
<c:rich>
|
|
2073
|
-
<a:bodyPr />
|
|
2074
|
-
<a:lstStyle />
|
|
2075
|
-
<a:p>
|
|
2076
|
-
<a:pPr lvl="0">
|
|
2077
|
-
<a:defRPr b="0">
|
|
2078
|
-
${mS(t)}
|
|
2079
|
-
<a:latin typeface="+mn-lt"/>
|
|
2080
|
-
</a:defRPr>
|
|
2081
|
-
</a:pPr>
|
|
2082
|
-
<a:r> <!-- Runs -->
|
|
2083
|
-
<a:rPr sz="${100*i}"/>
|
|
2084
|
-
<a:t>${e}</a:t>
|
|
2085
|
-
</a:r>
|
|
2086
|
-
</a:p>
|
|
2087
|
-
</c:rich>
|
|
2088
|
-
</c:tx>
|
|
2089
|
-
`}function vS(e=12,t="000000",i=!1,o=!1){return Gm`
|
|
2090
|
-
<c:txPr>
|
|
2091
|
-
<a:bodyPr/>
|
|
2092
|
-
<a:lstStyle/>
|
|
2093
|
-
<a:p>
|
|
2094
|
-
<a:pPr lvl="0">
|
|
2095
|
-
<a:defRPr ${Bm([["b",i?"1":"0"],["i",o?"1":"0"],["sz",100*e]])}>
|
|
2096
|
-
${mS(t)}
|
|
2097
|
-
<a:latin typeface="+mn-lt"/>
|
|
2098
|
-
</a:defRPr>
|
|
2099
|
-
</a:pPr>
|
|
2100
|
-
</a:p>
|
|
2101
|
-
</c:txPr>
|
|
2102
|
-
`}function bS({showLeaderLines:e}={showLeaderLines:!1}){return Gm`
|
|
2103
|
-
<dLbls>
|
|
2104
|
-
<c:showLegendKey val="0"/>
|
|
2105
|
-
<c:showVal val="0"/>
|
|
2106
|
-
<c:showCatName val="0"/>
|
|
2107
|
-
<c:showSerName val="0"/>
|
|
2108
|
-
<c:showPercent val="0"/>
|
|
2109
|
-
<c:showBubbleSize val="0"/>
|
|
2110
|
-
<c:showLeaderLines val="${e?"1":"0"}"/>
|
|
2111
|
-
</dLbls>
|
|
2112
|
-
`}function SS(e,t,i,o,{fontColor:n}){return Gm`
|
|
2113
|
-
<${t}>
|
|
2114
|
-
<c:axId val="${i}"/>
|
|
2115
|
-
<c:crossAx val="${o}"/> <!-- reference to the other axe of the chart -->
|
|
2116
|
-
<c:delete val="0"/> <!-- by default, axis are not displayed -->
|
|
2117
|
-
<c:scaling>
|
|
2118
|
-
<c:orientation val="minMax" />
|
|
2119
|
-
</c:scaling>
|
|
2120
|
-
<c:axPos val="${e}" />
|
|
2121
|
-
${function(e="B7B7B7"){return Gm`
|
|
2122
|
-
<c:majorGridlines>
|
|
2123
|
-
${pS({line:{color:e}})}
|
|
2124
|
-
</c:majorGridlines>
|
|
2125
|
-
`}()}
|
|
2126
|
-
<c:majorTickMark val="out" />
|
|
2127
|
-
<c:minorTickMark val="none" />
|
|
2128
|
-
<c:numFmt formatCode="General" sourceLinked="1" />
|
|
2129
|
-
<c:title>
|
|
2130
|
-
${fS("")}
|
|
2131
|
-
</c:title>
|
|
2132
|
-
${vS(10,n)}
|
|
2133
|
-
</${t}>
|
|
2134
|
-
<!-- <tickLblPos/> omitted -->
|
|
2135
|
-
`}function CS(e){return Gm`
|
|
2136
|
-
<c:strRef>
|
|
2137
|
-
<c:f>${e}</c:f>
|
|
2138
|
-
</c:strRef>
|
|
2139
|
-
`}function ES(e){return Gm`
|
|
2140
|
-
<c:numRef>
|
|
2141
|
-
<c:f>${e}</c:f>
|
|
2142
|
-
<c:numCache />
|
|
2143
|
-
</c:numRef>
|
|
2144
|
-
`}function wS(e){const t=e.content,i=iu.content,o=[];let n=Gm``;if(uf(t).filter((e=>"FUNCTION"===e.type)).every((e=>i[e.value.toUpperCase()].isExported))){let i=Gm``;const s=xS(t);return e.value===a.CircularDependency&&(o.push(["t","str"]),i=Gm`<v>${e.value}</v>`),n=Gm`
|
|
2145
|
-
<f>
|
|
2146
|
-
${s}
|
|
2147
|
-
</f>
|
|
2148
|
-
${i}
|
|
2149
|
-
`,{attrs:o,node:n}}{const t=e.value;if(t){const e=function(e){switch(typeof e){case"boolean":return"b";case"string":return"str";case"number":return"n"}}(t);o.push(["t",e]),n=Gm`<v>${t}</v>`}return{attrs:o,node:n}}}function yS(e,t,i=!1){let o=e;const n=[];if(!i&&["TRUE","FALSE"].includes(o.trim()))o="TRUE"===o?"1":"0",n.push(["t","b"]);else if(i||!Yt(o)){const{id:i}=um(e,t);o=i.toString(),n.push(["t","s"])}return{attrs:n,node:Gm`<v>${o}</v>`}}function xS(e){let t;"="===e[0]&&(e=e.slice(1));try{t=iv(e)}catch(t){return e}return t=nv(t,"STRING",IS),t=nv(t,"FUNCALL",(e=>e=function(e){const t=e.value.toUpperCase(),i=e.args,o=Ep[t];if(o){const n=iu.content[t].args.filter((e=>!e.optional)),s=n.length-e.args.length;if(s)for(let t=e.args.length;t<n.length;t++){const e=o[t-s];i.push({type:e.type,value:e.value})}}return{...e,args:i}}(e=function(e){const t=e.value.toUpperCase();return{...e,value:wp.includes(t)?`_xlfn.${t}`:t}}(e={...e,value:e.value.toUpperCase()})))),t?sv(t):e}function IS(e){const t=e.value.replace(new RegExp('"',"g"),""),i=Se(t);if(i){let o=[];return(t.match(fe)||t.match(ve))&&o.push("yyyy-mm-dd"),t.match(be)&&o.push("hh:mm:ss"),{...e,value:li(i.value,o.join(" "))}}return{...e,value:e.value.replace(/\\"/g,'""')}}function RS(e,t){const i=[];for(const o of t)switch(o.rule.type){case"CellIsRule":i.push(TS(o,o.rule,e));break;case"ColorScaleRule":i.push(AS(o,o.rule));break;case"IconSetRule":i.push(MS(o,o.rule));break;default:console.warn(`Conditional formatting ${o.rule.type} not implemented`)}return i}function TS(e,t,i){const o=OS(e),n=sm(t.operator);o.push(...function(e){const t=sm(e.operator);switch(e.operator){case"ContainsText":case"NotContains":case"BeginsWith":case"EndsWith":return[["type",t],["text",e.values[0]]];case"IsEmpty":case"IsNotEmpty":return[["type",t]];case"Equal":case"NotEqual":case"GreaterThan":case"GreaterThanOrEqual":case"LessThan":case"LessThanOrEqual":case"Between":case"NotBetween":return[["type","cellIs"]]}}(t),["operator",n]);const s=function(e,t){const i=e[0].split(":")[0],o=t.values;switch(t.operator){case"ContainsText":return[`NOT(ISERROR(SEARCH("${o[0]}",${i})))`];case"NotContains":return[`ISERROR(SEARCH("${o[0]}",${i}))`];case"BeginsWith":return[`LEFT(${i},LEN("${o[0]}"))="${o[0]}"`];case"EndsWith":return[`RIGHT(${i},LEN("${o[0]}"))="${o[0]}"`];case"IsEmpty":return[`LEN(TRIM(${i}))=0`];case"IsNotEmpty":return[`LEN(TRIM(${i}))>0`];case"Equal":case"NotEqual":case"GreaterThan":case"GreaterThanOrEqual":case"LessThan":case"LessThanOrEqual":return[o[0]];case"Between":case"NotBetween":return[o[0],o[1]]}}(e.ranges,t).map((e=>Gm`<formula>${e}</formula>`)),r={font:{color:{rgb:t.style.textColor},bold:t.style.bold,italic:t.style.italic,strike:t.style.strikethrough,underline:t.style.underline}};t.style.fillColor&&(r.fill={fgColor:{rgb:t.style.fillColor}});const{id:a}=um(r,i);return o.push(["dxfId",a]),Gm`
|
|
2150
|
-
<conditionalFormatting sqref="${e.ranges.join(" ")}">
|
|
2151
|
-
<cfRule ${Bm(o)}>
|
|
2152
|
-
${Wm(s)}
|
|
2153
|
-
</cfRule>
|
|
2154
|
-
</conditionalFormatting>
|
|
2155
|
-
`}function AS(e,t){const i=OS(e);i.push(["type","colorScale"]);const o=[];for(const n of e.ranges){const e=[],s=[];let r=!0;for(let i of["minimum","midpoint","maximum"]){const o=t[i];o&&("formula"!==o.type?(e.push(_S(o,i)),s.push([["rgb",fo(mt(o.color))]])):r=!1)}if(!r){console.warn("Conditional formats with formula rules are not supported at the moment. The rule is therefore skipped.");continue}const a=e.map((e=>Gm`<cfvo ${Bm(e)}/>`)),l=s.map((e=>Gm`<color ${Bm(e)}/>`));o.push(Gm`
|
|
2156
|
-
<conditionalFormatting sqref="${n}">
|
|
2157
|
-
<cfRule ${Bm(i)}>
|
|
2158
|
-
<colorScale>
|
|
2159
|
-
${Wm(a)}
|
|
2160
|
-
${Wm(l)}
|
|
2161
|
-
</colorScale>
|
|
2162
|
-
</cfRule>
|
|
2163
|
-
</conditionalFormatting>
|
|
2164
|
-
`)}return Wm(o)}function MS(e,t){const i=OS(e);i.push(["type","iconSet"]);const o=[];for(const n of e.ranges){const e=[[["type","percent"],["val",0]]];let s=!0;for(let i of["lowerInflectionPoint","upperInflectionPoint"]){if("formula"===t[i].type){s=!1;continue}const o=t[i];e.push([..._S(o,i),["gte","ge"===o.operator?"1":"0"]])}if(!s){console.warn("Conditional formats with formula rules are not supported at the moment. The rule is therefore skipped.");continue}const r=e.map((e=>Gm`<cfvo ${Bm(e)} />`));o.push(Gm`
|
|
2165
|
-
<conditionalFormatting sqref="${n}">
|
|
2166
|
-
<cfRule ${Bm(i)}>
|
|
2167
|
-
<iconSet iconSet="${NS(t.icons)}">
|
|
2168
|
-
${Wm(r)}
|
|
2169
|
-
</iconSet>
|
|
2170
|
-
</cfRule>
|
|
2171
|
-
</conditionalFormatting>
|
|
2172
|
-
`)}return Wm(o)}function OS(e){return[["priority",1],["stopIfTrue",e.stopIfTrue?1:0]]}function NS(e){return ap[Object.keys(ap).find((t=>e.upper.toLowerCase().startsWith(t)))||"dots"]}function _S(e,t){const i=function(e,t){switch(e){case"value":return"minimum"===t?"min":"max";case"number":return"num";case"percentage":return"percent";default:return e}}(e.type,t),o=[["type",i]];if("min"!==i&&"max"!==i){let t=e.value;if("formula"===i)try{t=xS(e.value)}catch(i){t=e.value}o.push(["val",t])}return o}function FS(e,t,i){const o=[["xmlns:xdr",lp.drawing],["xmlns:r",gp],["xmlns:a",cp],["xmlns:c",hp]],n=[];for(const[o,s]of Object.entries(i)){const{from:i,to:r}=DS(s,t),a=pm(s.id),l=[["id",a],["name",`Chart ${a}`],["title","Chart"]];n.push(Gm`
|
|
2173
|
-
<xdr:twoCellAnchor>
|
|
2174
|
-
<xdr:from>
|
|
2175
|
-
<xdr:col>${i.col}</xdr:col>
|
|
2176
|
-
<xdr:colOff>${i.colOff}</xdr:colOff>
|
|
2177
|
-
<xdr:row>${i.row}</xdr:row>
|
|
2178
|
-
<xdr:rowOff>${i.rowOff}</xdr:rowOff>
|
|
2179
|
-
</xdr:from>
|
|
2180
|
-
<xdr:to>
|
|
2181
|
-
<xdr:col>${r.col}</xdr:col>
|
|
2182
|
-
<xdr:colOff>${r.colOff}</xdr:colOff>
|
|
2183
|
-
<xdr:row>${r.row}</xdr:row>
|
|
2184
|
-
<xdr:rowOff>${r.rowOff}</xdr:rowOff>
|
|
2185
|
-
</xdr:to>
|
|
2186
|
-
<xdr:graphicFrame>
|
|
2187
|
-
<xdr:nvGraphicFramePr>
|
|
2188
|
-
<xdr:cNvPr ${Bm(l)} />
|
|
2189
|
-
<xdr:cNvGraphicFramePr />
|
|
2190
|
-
</xdr:nvGraphicFramePr>
|
|
2191
|
-
<xdr:xfrm>
|
|
2192
|
-
<a:off x="0" y="0"/>
|
|
2193
|
-
<a:ext cx="0" cy="0"/>
|
|
2194
|
-
</xdr:xfrm>
|
|
2195
|
-
<a:graphic>
|
|
2196
|
-
<a:graphicData uri="${hp}">
|
|
2197
|
-
<c:chart r:id="${e[o]}" />
|
|
2198
|
-
</a:graphicData>
|
|
2199
|
-
</a:graphic>
|
|
2200
|
-
</xdr:graphicFrame>
|
|
2201
|
-
<xdr:clientData fLocksWithSheet="0"/>
|
|
2202
|
-
</xdr:twoCellAnchor>
|
|
2203
|
-
`)}return Hm(Gm`
|
|
2204
|
-
<xdr:wsDr ${Bm(o)}>
|
|
2205
|
-
${Wm(n)}
|
|
2206
|
-
</xdr:wsDr>
|
|
2207
|
-
`)}function DS(e,t){const{x:i,y:o,height:n,width:s}=e,r=Object.values(t.cols),a=Object.values(t.rows),{index:l,offset:c}=kS(r,i),{index:h,offset:d}=kS(r,i+s),{index:u,offset:g}=kS(a,o),{index:p,offset:m}=kS(a,o+n);return{from:{col:l,colOff:c,row:u,rowOff:g},to:{col:h,colOff:d,row:p,rowOff:m}}}function kS(e,t){let i=0;for(const[o,n]of Object.entries(e)){if(i<=t&&t<i+n.size)return{index:parseInt(o),offset:mm(t-i+$)};i+=n.size}return{index:e.length-1,offset:mm(t-i+$)}}function LS(e){return tt(e)?Gm``:Gm`
|
|
2208
|
-
<font>
|
|
2209
|
-
${e.bold?Gm`<b />`:""}
|
|
2210
|
-
${e.italic?Gm`<i />`:""}
|
|
2211
|
-
${e.underline?Gm`<u />`:""}
|
|
2212
|
-
${e.strike?Gm`<strike />`:""}
|
|
2213
|
-
${e.size?Gm`<sz val="${e.size}" />`:""}
|
|
2214
|
-
${e.color&&e.color.rgb?Gm`<color rgb="${fo(e.color.rgb)}" />`:""}
|
|
2215
|
-
${e.name?Gm`<name val="${e.name}" />`:""}
|
|
2216
|
-
</font>
|
|
2217
|
-
`}function PS(e){return e?Bm([["style",e.style],["color",fo(e.color.rgb)]]):Gm``}const US=Gm`<tableStyleInfo name="TableStyleLight8" showFirstColumn="0" showLastColumn="0" showRowStripes="0" showColumnStripes="0"/>`;function VS(e,t,i){const o=Gm`
|
|
2218
|
-
<table ${Bm([["id",t],["name",`Table${t}`],["displayName",`Table${t}`],["ref",e.range],["xmlns",lp.table],["xmlns:xr",lp.revision],["xmlns:xr3",lp.revision3],["xmlns:mc",lp.markupCompatibility]])}>
|
|
2219
|
-
${function(e){const t=[["ref",e.range]];return Gm`
|
|
2220
|
-
<autoFilter ${Bm(t)}>
|
|
2221
|
-
${Wm(function(e){const t=_i(e.range),i=[];for(const o of ze(0,Zi(t).width)){const t=e.filters[o];if(!t||!t.filteredValues.length)continue;const n=Gm`
|
|
2222
|
-
<filterColumn ${Bm([["colId",o]])}>
|
|
2223
|
-
${zS(t)}
|
|
2224
|
-
</filterColumn>
|
|
2225
|
-
`;i.push(n)}return i}(e))}
|
|
2226
|
-
</autoFilter>
|
|
2227
|
-
`}(e)}
|
|
2228
|
-
${function(e,t){var i;const o=_i(e.range),n=[];for(const e of ze(0,Zi(o).width)){const s=Vt(o.left+e,o.top),r=[["id",e+1],["name",(null===(i=t.cells[s])||void 0===i?void 0:i.content)||`col${e}`]];n.push(Gm`<tableColumn ${Bm(r)}/>`)}return Gm`
|
|
2229
|
-
<tableColumns ${Bm([["count",n.length]])}>
|
|
2230
|
-
${Wm(n)}
|
|
2231
|
-
</tableColumns>
|
|
2232
|
-
`}(e,i)}
|
|
2233
|
-
${US}
|
|
2234
|
-
</table>
|
|
2235
|
-
`;return Hm(o)}function zS(e){return Gm`
|
|
2236
|
-
<filters>
|
|
2237
|
-
${Wm(e.filteredValues.map((e=>Gm`<filter ${Bm([["val",e]])}/>`)))}
|
|
2238
|
-
</filters>
|
|
2239
|
-
`}function BS(e){if(!Object.values(e).length)return Gm``;const t=[];for(let[i,o]of Object.entries(e)){const e=[["min",parseInt(i)+1],["max",parseInt(i)+1],["width",am(o.size||_)],["customWidth",1],["hidden",o.isHidden?1:0]];t.push(Gm`
|
|
2240
|
-
<col ${Bm(e)}/>
|
|
2241
|
-
`)}return Gm`
|
|
2242
|
-
<cols>
|
|
2243
|
-
${Wm(t)}
|
|
2244
|
-
</cols>
|
|
2245
|
-
`}function HS(e,t,i){const o=[];for(let n=0;n<i.rowNumber;n++){const s=[["r",n+1]],r=i.rows[n]||{};s.push(["ht",rm(r.size||F)],["customHeight",1],["hidden",r.isHidden?1:0]);const a=[];for(let o=0;o<i.colNumber;o++){const s=Vt(o,n),r=i.cells[s];if(r){const l=[["r",s]],c=hm(e,cm(r,t));l.push(["s",c]);let h=[],d=Gm``;if(r.isFormula)({attrs:h,node:d}=wS(r));else if(r.content&&qe(r.content)){const{label:t}=Xe(r.content);({attrs:h,node:d}=yS(t,e.sharedStrings))}else if(r.content&&""!==r.content){const t=$S(o,n,i);({attrs:h,node:d}=yS(r.content,e.sharedStrings,t))}l.push(...h),a.push(Gm`
|
|
2246
|
-
<c ${Bm(l)}>
|
|
2247
|
-
${d}
|
|
2248
|
-
</c>
|
|
2249
|
-
`)}}(a.length||r.size!==F||r.isHidden)&&o.push(Gm`
|
|
2250
|
-
<row ${Bm(s)}>
|
|
2251
|
-
${Wm(a)}
|
|
2252
|
-
</row>
|
|
2253
|
-
`)}return Gm`
|
|
2254
|
-
<sheetData>
|
|
2255
|
-
${Wm(o)}
|
|
2256
|
-
</sheetData>
|
|
2257
|
-
`}function $S(e,t,i){return i.filterTables.some((i=>{const o=_i(i.range),n={...o,bottom:o.top};return $i(e,t,n)}))}function WS(e,t,i){var o;const n=t.sheets[i].cells,s=[];for(const r in n){const a=null===(o=n[r])||void 0===o?void 0:o.content;if(a&&qe(a)){const{label:o,url:n}=Xe(a);if(Ke(n)){const e=Je(n),i=t.sheets.find((t=>t.id===e)),a=i?`${i.name}!A1`:Y;s.push(Gm`
|
|
2258
|
-
<hyperlink display="${o}" location="${a}" ref="${r}"/>
|
|
2259
|
-
`)}else{const t=dm(e.relsFiles,`xl/worksheets/_rels/sheet${i}.xml.rels`,{target:Cu(n),type:up.hyperlink,targetMode:"External"});s.push(Gm`
|
|
2260
|
-
<hyperlink r:id="${t}" ref="${r}"/>
|
|
2261
|
-
`)}}}return s.length?Gm`
|
|
2262
|
-
<hyperlinks>
|
|
2263
|
-
${Wm(s)}
|
|
2264
|
-
</hyperlinks>
|
|
2265
|
-
`:Gm``}function GS(e){if(e.length){const t=e.map((e=>Gm`<mergeCell ref="${e}" />`));return Gm`
|
|
2266
|
-
<mergeCells count="${e.length}">
|
|
2267
|
-
${Wm(t)}
|
|
2268
|
-
</mergeCells>
|
|
2269
|
-
`}return Gm``}function qS(e){const t=e.panes;let i=Gm``;if(t&&(t.xSplit||t.ySplit)){const e=Vt(t.xSplit,t.ySplit),o=t.xSplit?Gm`xSplit="${t.xSplit}"`:"",n=t.ySplit?Gm`ySplit="${t.ySplit}"`:"",s=t.xSplit?Gm`<selection pane="topRight"/>`:"",r=t.ySplit?Gm`<selection pane="bottomLeft"/>`:"",a=t.xSplit&&t.ySplit?Gm`<selection pane="bottomRight"/>`:"";i=Gm`
|
|
2270
|
-
<pane
|
|
2271
|
-
${o}
|
|
2272
|
-
${n}
|
|
2273
|
-
topLeftCell="${e}"
|
|
2274
|
-
activePane="${t.xSplit?t.ySplit?"bottomRight":"topRight":"bottomLeft"}"
|
|
2275
|
-
state="frozen"/>
|
|
2276
|
-
${s}
|
|
2277
|
-
${r}
|
|
2278
|
-
${a}
|
|
2279
|
-
`}return Gm`
|
|
2280
|
-
<sheetViews>
|
|
2281
|
-
<sheetView showGridLines="${e.areGridLinesVisible?1:0}" workbookViewId="0">
|
|
2282
|
-
${i}
|
|
2283
|
-
</sheetView>
|
|
2284
|
-
</sheetViews>
|
|
2285
|
-
`}function ZS(e){const t=[],i={relsFiles:[],sharedStrings:[],styles:[{fontId:0,fillId:0,numFmtId:0,borderId:0,alignment:{vertical:"center"}}],fonts:[{size:G,family:2,color:{rgb:"000000"},name:"Calibri"}],fills:[{reservedAttribute:"none"},{reservedAttribute:"gray125"}],borders:[{}],numFmts:[],dxfs:[]};return t.push(function(e,t){const i=[["xmlns",lp.workbook],["xmlns:r",gp]],o=[];for(const[i,n]of Object.entries(e.sheets)){const e=[["state",n.isVisible?"visible":"hidden"],["name",n.name],["sheetId",parseInt(i)+1],["r:id",`rId${parseInt(i)+1}`]];o.push(Gm`
|
|
2286
|
-
<sheet ${Bm(e)} />
|
|
2287
|
-
`),dm(t.relsFiles,"xl/_rels/workbook.xml.rels",{type:up.sheet,target:`worksheets/sheet${i}.xml`})}return Vm(Hm(Gm`
|
|
2288
|
-
<workbook ${Bm(i)}>
|
|
2289
|
-
<sheets>
|
|
2290
|
-
${Wm(o)}
|
|
2291
|
-
</sheets>
|
|
2292
|
-
</workbook>
|
|
2293
|
-
`),"xl/workbook.xml","workbook")}(e,i)),t.push(...function(e,t){const i=[];let o=1;for(const[n,s]of Object.entries(e.sheets)){const r=[["xmlns",lp.worksheet],["xmlns:r",gp]],a=[["defaultRowHeight",rm(F)],["defaultColWidth",am(_)]],l=jS(s,n,o,t,i);o+=s.filterTables.length;let c=Gm``;const h=s.charts;if(h.length){const o=[];for(const s of h){const r=pm(s.id),a=dm(t.relsFiles,`xl/drawings/_rels/drawing${n}.xml.rels`,{target:`../charts/chart${r}.xml`,type:up.chart});o.push(a),i.push(Vm(gS(s,n,e),`xl/charts/chart${r}.xml`,"chart"))}const r=dm(t.relsFiles,`xl/worksheets/_rels/sheet${n}.xml.rels`,{target:`../drawings/drawing${n}.xml`,type:up.drawing});i.push(Vm(FS(o,s,h),`xl/drawings/drawing${n}.xml`,"drawing")),c=Gm`<drawing r:id="${r}" />`}const d=Gm`
|
|
2294
|
-
<worksheet ${Bm(r)}>
|
|
2295
|
-
${qS(s)}
|
|
2296
|
-
<sheetFormatPr ${Bm(a)} />
|
|
2297
|
-
${BS(s.cols)}
|
|
2298
|
-
${HS(t,e,s)}
|
|
2299
|
-
${GS(s.merges)}
|
|
2300
|
-
${Wm(RS(t.dxfs,s.conditionalFormats))}
|
|
2301
|
-
${WS(t,e,n)}
|
|
2302
|
-
${c}
|
|
2303
|
-
${l}
|
|
2304
|
-
</worksheet>
|
|
2305
|
-
`;i.push(Vm(Hm(d),`xl/worksheets/sheet${n}.xml`,"sheet"))}return dm(t.relsFiles,"xl/_rels/workbook.xml.rels",{type:up.sharedStrings,target:"sharedStrings.xml"}),dm(t.relsFiles,"xl/_rels/workbook.xml.rels",{type:up.styles,target:"styles.xml"}),i}(e,i)),t.push(function(e){const t=Gm`
|
|
2306
|
-
<styleSheet ${Bm([["xmlns",lp.styleSheet],["xmlns:r",gp]])}>
|
|
2307
|
-
${function(e){const t=[];for(let[i,o]of Object.entries(e)){const e=[["numFmtId",parseInt(i)+Cp],["formatCode",o.format]];t.push(Gm`
|
|
2308
|
-
<numFmt ${Bm(e)}/>
|
|
2309
|
-
`)}return Gm`
|
|
2310
|
-
<numFmts count="${e.length}">
|
|
2311
|
-
${Wm(t)}
|
|
2312
|
-
</numFmts>
|
|
2313
|
-
`}(e.numFmts)}
|
|
2314
|
-
${i=e.fonts,Gm`
|
|
2315
|
-
<fonts count="${i.length}">
|
|
2316
|
-
${Wm(Object.values(i).map(LS))}
|
|
2317
|
-
</fonts>
|
|
2318
|
-
`}
|
|
2319
|
-
${function(e){const t=[];for(let i of Object.values(e))void 0!==i.reservedAttribute?t.push(Gm`
|
|
2320
|
-
<fill>
|
|
2321
|
-
<patternFill patternType="${i.reservedAttribute}" />
|
|
2322
|
-
</fill>
|
|
2323
|
-
`):t.push(Gm`
|
|
2324
|
-
<fill>
|
|
2325
|
-
<patternFill patternType="solid">
|
|
2326
|
-
<fgColor rgb="${fo(i.fgColor.rgb)}" />
|
|
2327
|
-
<bgColor indexed="64" />
|
|
2328
|
-
</patternFill>
|
|
2329
|
-
</fill>
|
|
2330
|
-
`);return Gm`
|
|
2331
|
-
<fills count="${e.length}">
|
|
2332
|
-
${Wm(t)}
|
|
2333
|
-
</fills>
|
|
2334
|
-
`}(e.fills)}
|
|
2335
|
-
${function(e){const t=[];for(let i of Object.values(e))t.push(Gm`
|
|
2336
|
-
<border>
|
|
2337
|
-
<left ${PS(i.left)} />
|
|
2338
|
-
<right ${PS(i.right)} />
|
|
2339
|
-
<top ${PS(i.top)} />
|
|
2340
|
-
<bottom ${PS(i.bottom)} />
|
|
2341
|
-
<diagonal ${PS(i.diagonal)} />
|
|
2342
|
-
</border>
|
|
2343
|
-
`);return Gm`
|
|
2344
|
-
<borders count="${e.length}">
|
|
2345
|
-
${Wm(t)}
|
|
2346
|
-
</borders>
|
|
2347
|
-
`}(e.borders)}
|
|
2348
|
-
${function(e){const t=[];for(let i of e){const e=[["numFmtId",i.numFmtId],["fillId",i.fillId],["fontId",i.fontId],["borderId",i.borderId]],o=[];i.alignment&&i.alignment.vertical&&o.push(["vertical",i.alignment.vertical]),i.alignment&&i.alignment.horizontal&&o.push(["horizontal",i.alignment.horizontal]),t.push(Gm`
|
|
2349
|
-
<xf ${Bm(e)}>
|
|
2350
|
-
${o?Gm`<alignment ${Bm(o)} />`:""}
|
|
2351
|
-
</xf>
|
|
2352
|
-
`)}return Gm`
|
|
2353
|
-
<cellXfs count="${e.length}">
|
|
2354
|
-
${Wm(t)}
|
|
2355
|
-
</cellXfs>
|
|
2356
|
-
`}(e.styles)}
|
|
2357
|
-
${function(e){const t=[];for(const i of e){let e=Gm``;i.font&&(e=LS(i.font));let o=Gm``;i.fill&&(o=Gm`
|
|
2358
|
-
<fill>
|
|
2359
|
-
<patternFill>
|
|
2360
|
-
<bgColor rgb="${fo(i.fill.fgColor.rgb)}" />
|
|
2361
|
-
</patternFill>
|
|
2362
|
-
</fill>
|
|
2363
|
-
`),t.push(Gm`
|
|
2364
|
-
<dxf>
|
|
2365
|
-
${e}
|
|
2366
|
-
${o}
|
|
2367
|
-
</dxf>
|
|
2368
|
-
`)}return Gm`
|
|
2369
|
-
<dxfs count="${e.length}">
|
|
2370
|
-
${Wm(t)}
|
|
2371
|
-
</dxfs>
|
|
2372
|
-
`}(e.dxfs)}
|
|
2373
|
-
</styleSheet>
|
|
2374
|
-
`;var i;return Vm(Hm(t),"xl/styles.xml","styles")}(i)),t.push(function(e){const t=[["xmlns",lp.sst],["count",e.length],["uniqueCount",e.length]],i=e.map((e=>Gm`<si><t>${e}</t></si>`));return Vm(Hm(Gm`
|
|
2375
|
-
<sst ${Bm(t)}>
|
|
2376
|
-
${Wm(i)}
|
|
2377
|
-
</sst>
|
|
2378
|
-
`),"xl/sharedStrings.xml","sharedStrings")}(i.sharedStrings)),t.push(...function(e){const t=[];for(const i of e){const e=[];for(const t of i.rels){const i=[["Id",t.id],["Target",t.target],["Type",t.type]];t.targetMode&&i.push(["TargetMode",t.targetMode]),e.push(Gm`
|
|
2379
|
-
<Relationship ${Bm(i)} />
|
|
2380
|
-
`)}const o=Gm`
|
|
2381
|
-
<Relationships xmlns="${lp.Relationships}">
|
|
2382
|
-
${Wm(e)}
|
|
2383
|
-
</Relationships>
|
|
2384
|
-
`;t.push(Vm(Hm(o),i.path))}return t}(i.relsFiles)),t.push(function(e){const t=[];for(const i of e)i.contentType&&t.push($m("/"+i.path,dp[i.contentType]));return Vm(Hm(Gm`
|
|
2385
|
-
<Types xmlns="${lp.Types}">
|
|
2386
|
-
<Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml" />
|
|
2387
|
-
<Default Extension="xml" ContentType="application/xml" />
|
|
2388
|
-
${Wm(t)}
|
|
2389
|
-
</Types>
|
|
2390
|
-
`),"[Content_Types].xml")}(t)),t.push(function(){const e=[["Id","rId1"],["Type",up.document],["Target","xl/workbook.xml"]];return Vm(Hm(Gm`
|
|
2391
|
-
<Relationships xmlns="${lp.Relationships}">
|
|
2392
|
-
<Relationship ${Bm(e)} />
|
|
2393
|
-
</Relationships>
|
|
2394
|
-
`),"_rels/.rels")}()),{name:"my_spreadsheet.xlsx",files:t}}function jS(e,t,i,o,n){let s=i;if(!e.filterTables.length)return new np("");const r=`xl/worksheets/_rels/sheet${t}.xml.rels`,a=[];for(const t of e.filterTables){const i=dm(o.relsFiles,r,{target:`../tables/table${s}.xml`,type:up.table});n.push(Vm(VS(t,s,e),`xl/tables/table${s}.xml`,"table")),a.push(Gm`<tablePart r:id="${i}" />`),s++}return Gm`
|
|
2395
|
-
<tableParts count="${e.filterTables.length}">
|
|
2396
|
-
${Wm(a)}
|
|
2397
|
-
</tableParts>
|
|
2398
|
-
`}var XS;!function(e){e[e.Ready=0]="Ready",e[e.Running=1]="Running",e[e.RunningCore=2]="RunningCore",e[e.Finalizing=3]="Finalizing"}(XS||(XS={}));const YS={},KS={MIN_ROW_HEIGHT:10,MIN_COL_WIDTH:5,HEADER_HEIGHT:O,HEADER_WIDTH:N,TOPBAR_HEIGHT:63,BOTTOMBAR_HEIGHT:36,DEFAULT_CELL_WIDTH:_,DEFAULT_CELL_HEIGHT:F,SCROLLBAR_WIDTH:D},QS={autofillModifiersRegistry:Lu,autofillRulesRegistry:Pu,cellMenuRegistry:Ps,colMenuRegistry:Us,linkMenuRegistry:Ku,functionRegistry:iu,featurePluginRegistry:Rb,statefulUIPluginRegistry:Tb,coreViewsPluginRegistry:Ab,corePluginRegistry:Ib,rowMenuRegistry:Vs,sidePanelRegistry:Lg,figureRegistry:og,chartSidePanelComponentRegistry:Tg,chartComponentRegistry:Nn,chartRegistry:On,topbarMenuRegistry:ag,topbarComponentRegistry:Pg,clickableCellRegistry:Mb,otRegistry:cg,inverseCommandRegistry:ng,urlRegistry:Eu,cellPopoverRegistry:eg},JS={arg:Zs,toBoolean:or,toJsDate:nr,toNumber:Qs,toString:er,toXC:Vt,toZone:_i,toCartesian:Ut,numberToLetters:Lt,UuidGenerator:Oi,formatValue:li,computeTextWidth:Le,createEmptyWorkbookData:Uf,createEmptySheet:Pf,createEmptyExcelSheet:Vf,getDefaultChartJsRuntime:on,chartFontColor:zo,ChartColors:Vo,EvaluationError:c,CellErrorLevel:l,getFillingMode:an,rgbaToHex:Et,colorToRGBA:wt,positionToZone:Ji,isDefined:et,lazy:nt},eC={isMarkdownLink:qe,parseMarkdownLink:Xe,markdownLink:je,openLink:Ru,urlRepresentation:Iu},tC={ChartPanel:Ag,ChartFigure:Xn,ChartJsComponent:oo,Grid:op,GridOverlay:Bg,ScorecardChart:go,LineConfigPanel:yg,LineBarPieDesignPanel:Sg,BarConfigPanel:gg,LineBarPieConfigPanel:ug,GaugeChartConfigPanel:Eg,GaugeChartDesignPanel:wg,ScorecardChartConfigPanel:Ig,ScorecardChartDesignPanel:Rg};e.AbstractChart=vo,e.CorePlugin=Bf,e.DATETIME_FORMAT=X,e.DispatchResult=Ro,e.EvaluationError=c,e.Model=class extends Yv{constructor(e={},i={},o=[],n=new Oi,s=!0){super(),this.corePlugins=[],this.featurePlugins=[],this.statefulUIPlugins=[],this.coreViewsPlugins=[],this.isReplayingCommand=!1,this.renderers=[],this.status=0,this.dispatch=(e,t)=>{const i={...t,type:e};let o=this.status;if(this.getters.isReadonly()&&(n=i,!yo.has(n.type)))return new Ro(67);var n;if(!this.session.canApplyOptimisticUpdate())return new Ro(64);switch(o){case 0:const t=this.checkDispatchAllowed(i);if(!t.isSuccessful)return t;this.status=1;const{changes:o,commands:n}=this.state.recordChanges((()=>{Io(i)&&this.state.addCommand(i),this.dispatchToHandlers(this.handlers,i),this.finalize()}));this.session.save(n,o),this.status=0,this.trigger("update");break;case 1:if(Io(i)){const e=this.checkDispatchAllowed(i);if(!e.isSuccessful)return e;this.state.addCommand(i)}this.dispatchToHandlers(this.handlers,i);break;case 3:throw new Error("Cannot dispatch commands in the finalize state");case 2:if(Io(i))throw new Error(`A UI plugin cannot dispatch ${e} while handling a core command`);this.dispatchToHandlers(this.handlers,i)}return Ro.Success},this.dispatchFromCorePlugin=(e,t)=>{const i={...t,type:e},o=this.status;this.status=2;const n=this.isReplayingCommand?[this.range,...this.corePlugins,...this.coreViewsPlugins]:this.handlers;return this.dispatchToHandlers(n,i),this.status=o,Ro.Success},o=kf(e,o);const r=Ff(e,s);this.state=new hS,this.uuidGenerator=n,this.config=this.setupConfig(i),this.session=this.setupSession(r.revisionId),this.history=new aS(this.dispatchFromCorePlugin,this.session),this.coreGetters={},this.range=new Av(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.getSelectionRangeString=this.range.getSelectionRangeString.bind(this.range),this.getters={isReadonly:()=>"readonly"===this.config.mode||"dashboard"===this.config.mode,isDashboard:()=>"dashboard"===this.config.mode,canUndo:this.history.canUndo.bind(this.history),canRedo:this.history.canRedo.bind(this.history),getClient:this.session.getClient.bind(this.session),getConnectedClients:this.session.getConnectedClients.bind(this.session),isFullySynchronized:this.session.isFullySynchronized.bind(this.session)},this.uuidGenerator.setIsFastStrategy(!0),this.selection=new cS(this.getters),this.corePluginConfig=this.setupCorePluginConfig(),this.uiPluginConfig=this.setupUiPluginConfig();for(let e of Ib.getAll())this.setupCorePlugin(e,r);Object.assign(this.getters,this.coreGetters);for(let e of Tb.getAll())this.statefulUIPlugins.push(this.setupUiPlugin(e));for(let e of Ab.getAll())this.coreViewsPlugins.push(this.setupUiPlugin(e));for(let e of Rb.getAll())this.featurePlugins.push(this.setupUiPlugin(e));this.uuidGenerator.setIsFastStrategy(!1),this.dispatch("START"),this.selection.observe(this,{handleEvent:()=>this.trigger("update")}),this.setupSessionEvents(),this.session.loadInitialMessages(o),this.joinSession(),i.snapshotRequested&&(this.session.snapshot(this.exportData()),this.garbageCollectExternalResources()),t.markRaw(this)}get handlers(){return[this.range,...this.corePlugins,...this.allUIPlugins,this.history]}get allUIPlugins(){return[...this.statefulUIPlugins,...this.coreViewsPlugins,...this.featurePlugins]}joinSession(){this.session.join(this.config.client)}leaveSession(){this.session.leave()}setupUiPlugin(e){const t=new e(this.uiPluginConfig);for(let i of e.getters){if(!(i in t))throw new Error(`Invalid getter name: ${i} for plugin ${t.constructor}`);if(i in this.getters)throw new Error(`Getter "${i}" is already defined.`);this.getters[i]=t[i].bind(t)}const i=e.layers.map((e=>[t,e]));return this.renderers.push(...i),this.renderers.sort(((e,t)=>e[1]-t[1])),t}setupCorePlugin(e,t){const i=new e(this.corePluginConfig);for(let t of e.getters){if(!(t in i))throw new Error(`Invalid getter name: ${t} for plugin ${i.constructor}`);if(t in this.coreGetters)throw new Error(`Getter "${t}" is already defined.`);this.coreGetters[t]=i[t].bind(i)}i.import(t),this.corePlugins.push(i)}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 sb(sS(e,this.state.recordChanges.bind(this.state),(e=>{this.checkDispatchAllowed(e).isSuccessful&&(this.isReplayingCommand=!0,this.dispatchToHandlers([this.range,...this.corePlugins,...this.coreViewsPlugins],e),this.isReplayingCommand=!1)})),this.config.transportService,e)}setupSessionEvents(){this.session.on("remote-revision-received",this,this.onRemoteRevisionReceived),this.session.on("revision-redone",this,this.finalize),this.session.on("revision-undone",this,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:s("Anonymous").toString()},i=e.transportService||new Yb;return{...e,mode:e.mode||"normal",custom:e.custom||{},external:e.external||{},transportService:i,client:t,moveClient:()=>{},snapshotRequested:!1,notifyUI:e=>this.trigger("notify-ui",e),lazyEvaluation:!("lazyEvaluation"in e)||e.lazyEvaluation}}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,lazyEvaluation:this.config.lazyEvaluation}}checkDispatchAllowed(e){const t=this.handlers.map((t=>t.allowDispatch(e)));return new Ro(t.flat())}finalize(){this.status=3;for(const e of this.handlers)e.finalize();this.status=0}dispatchToHandlers(e,t){t=Ne(t);for(const i of e)i.beforeHandle(t);for(const i of e)i.handle(t)}drawGrid(e){for(let[t,i]of this.renderers)e.ctx.save(),t.drawGrid(e,i),e.ctx.restore()}exportData(){let e=Uf();for(let t of this.handlers)t instanceof Bf&&t.export(e);return e.revisionId=this.session.getRevisionId()||K,e=JSON.parse(JSON.stringify(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={...Uf(),sheets:[Vf(_f,"Sheet1")]};for(let t of this.handlers)t instanceof zf&&t.exportForExcel(e);return e=JSON.parse(JSON.stringify(e)),ZS(e)}garbageCollectExternalResources(){for(const e of this.corePlugins)e.garbageCollectExternalResources()}},e.Registry=Mn,e.Revision=ob,e.SPREADSHEET_DIMENSIONS=KS,e.Spreadsheet=Xb,e.UIPlugin=Ov,e.__info__=YS,e.addFunction=function(e,t){iu.add(e,t)},e.astToFormula=sv,e.compile=uv,e.components=tC,e.convertAstNodes=nv,e.coreTypes=xo,e.findCellInNewZone=Ki,e.functionCache=dv,e.helpers=JS,e.invalidateEvaluationCommands=Eo,e.links=eC,e.load=Ff,e.parse=iv,e.readonlyAllowedCommands=yo,e.registries=QS,e.setTranslationMethod=function(e){i=e},e.tokenize=uf,Object.defineProperty(e,"__esModule",{value:!0}),YS.version="16.2.0-alpha.3",YS.date="2023-03-06T07:18:09.258Z",YS.hash="ec749cf"}(this.o_spreadsheet=this.o_spreadsheet||{},owl);
|