@grid-is/agent-tools 0.3.0 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/dist-DvOtcg7Y.js +5 -0
- package/dist/{dist-B8AoRnKf.js → dist-Dx48XsYY.js} +1 -1
- package/dist/{index-DlMJis5l.d.ts → index-DtYMYL_H.d.ts} +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -2
- package/dist/tools.d.ts +1 -1
- package/dist/tools.js +1 -1
- package/package.json +5 -2
- package/dist/dist-RYXWtRir.js +0 -5
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{C as e,_ as t,a as n,b as r,d as i,f as a,h as o,i as s,m as c,o as l,p as u,r as d,s as f,t as p,u as m,w as h}from"./dist-BJH7vBTb.js";import{Cell as g,CellVertexId as _,FormulaError as v,Matrix as y,NameVertexId as b,RangeVertexId as ee,Reference as x,ValueSnapshot as te,a1ToRowColumn as ne,colFromOffs as re,describeWorkbook as ie,parseReference as ae,unbox as oe,vertexIdToCell as se,vertexIdToReference as ce}from"@grid-is/apiary";import{z as S}from"zod";var C=`operator`,le=`operator-trim`,ue=`bool`,de=`error`,fe=`number`,pe=`func`,me=`newline`,he=`whitespace`,ge=`string`,w=`context_quote`,T=`context`,E=`range`,D=`range_beam`,O=`range_ternary`,k=`range_named`,_e=`structured`,A=`cell`,ve=`fx_prefix`,ye=`unknown`,be=`UnaryExpression`,xe=`BinaryExpression`,Se=`ReferenceIdentifier`,Ce=`Literal`,we=`ErrorLiteral`,Te=`CallExpression`,Ee=`LambdaExpression`,De=`LetExpression`,Oe=`ArrayExpression`,ke=`Identifier`,Ae=`LetDeclarator`,je=2**14-1,j=2**20-1,Me=`$`,Ne=[[A,`:`,A],[A,`.:`,A],[A,`:.`,A],[A,`.:.`,A],[E],[D],[O],[T,`!`,A,`:`,A],[T,`!`,A,`.:`,A],[T,`!`,A,`:.`,A],[T,`!`,A,`.:.`,A],[T,`!`,A],[T,`!`,E],[T,`!`,D],[T,`!`,O],[w,`!`,A,`:`,A],[w,`!`,A,`.:`,A],[w,`!`,A,`:.`,A],[w,`!`,A,`.:.`,A],[w,`!`,A],[w,`!`,E],[w,`!`,D],[w,`!`,O],[k],[T,`!`,k],[w,`!`,k],[_e],[k,_e],[T,`!`,k,_e],[w,`!`,k,_e]],Pe={};function Fe(e,t){if(e.length){let n=e[0];t[n]||(t[n]={}),Fe(e.slice(1),t[n])}else t[Me]=!0}Ne.forEach(e=>Fe(e.concat().reverse(),Pe));var Ie=(e,t,n,r=0)=>{let i=r,a=t,o=e.length-r;for(;i<=o;){let t=e[n-i];if(t){let e=t.value,n=t.type===C?e:t.type;if(n===E&&!e.includes(`:`)&&(n=A),n in a){a=a[n],i+=1;continue}}return a[Me]?i:0}};function Le(e){let t=[];for(let n=e.length-1;n>=0;n--){let r=e[n],i=r.type;if(i===E||i===D||i===O||i===k||i===_e){let t=Ie(e,Pe,n);if(t>1){r={...r,value:``};let i=n-t+1;for(let t=i;t<=n;t++)r.value+=e[t].value;r.loc&&e[i].loc&&(r.loc[0]=e[i].loc[0]),n-=t-1}}t[t.length]=r}return t.reverse()}var Re=/#(?:NAME\?|FIELD!|CALC!|VALUE!|REF!|DIV\/0!|NULL!|NUM!|N\/A|GETTING_DATA\b|SPILL!|UNKNOWN!|SYNTAX\?|ERROR!|CONNECT!|BLOCKED!|EXTERNAL!)/iy,ze=35;function Be(e,t){if(e.charCodeAt(t)===ze){Re.lastIndex=t;let n=Re.exec(e);if(n)return{type:de,value:n[0]}}}var Ve=46,He=58;function Ue(e,t){let n=e.charCodeAt(t);if(n===Ve||n===He){let r=e.charCodeAt(t+1);if(n!==r){if(r===He)return{type:le,value:e.slice(t,t+(e.charCodeAt(t+2)===Ve?3:2))};if(r===Ve)return{type:le,value:e.slice(t,t+2)}}}}function We(e,t){let n=e.charCodeAt(t),r=e.charCodeAt(t+1);if(n===60&&r===61||n===62&&r===61||n===60&&r===62)return{type:C,value:e.slice(t,t+2)};if(n===123||n===125||n===33||n===35||n===37||n===38||n>=40&&n<=45||n===47||n>=58&&n<=62||n===64||n===94)return{type:C,value:e[t]}}function Ge(e){return e>=65&&e<=90||e>=97&&e<=122||e>=48&&e<=57||e===95||e===92||e===40||e===46||e===63||e>160}function Ke(e,t){let n=e.charCodeAt(t);if(n===84||n===116){let n=e.charCodeAt(t+1);if(n===82||n===114){let n=e.charCodeAt(t+2);if(n===85||n===117){let n=e.charCodeAt(t+3);if((n===69||n===101)&&!Ge(e.charCodeAt(t+4)))return{type:ue,value:e.slice(t,t+4)}}}}if(n===70||n===102){let n=e.charCodeAt(t+1);if(n===65||n===97){let n=e.charCodeAt(t+2);if(n===76||n===108){let n=e.charCodeAt(t+3);if(n===83||n===115){let n=e.charCodeAt(t+4);if((n===69||n===101)&&!Ge(e.charCodeAt(t+5)))return{type:ue,value:e.slice(t,t+5)}}}}}}function qe(e,t){let n=t;for(;e.charCodeAt(t)===10;)t++;if(t!==n)return{type:me,value:e.slice(n,t)}}function Je(e){return e===9||e===11||e===12||e===13||e===32||e===160||e===5760||e===8232||e===8233||e===8239||e===8287||e===12288||e===65279||e>=8192&&e<=8202}function Ye(e,t){let n=t;for(;Je(e.charCodeAt(t));)t++;if(t!==n)return{type:he,value:e.slice(n,t)}}var Xe=34;function Ze(e,t){let n=t;if(e.charCodeAt(t)===Xe){for(t++;t<e.length;){if(e.charCodeAt(t)===Xe&&(t++,e.charCodeAt(t)!==Xe))return{type:ge,value:e.slice(n,t)};t++}return{type:ge,value:e.slice(n,t),unterminated:!0}}}var Qe=39,$e=91,et=93,tt=33;function nt(e,t,n){let r=e.charCodeAt(t),i,a;if(r===Qe){let r=t;for(t++;t<e.length;){let o=e.charCodeAt(t);if(o===$e){if(i)return;i=t}else if(o===et){if(a)return;a=t}else if(o===Qe&&(t++,e.charCodeAt(t)!==Qe)){let o=i==null&&a==null;return n.xlsx&&i===r+1&&a===t-2&&(o=!0),i>=r+1&&a<t-2&&a>i+1&&(o=!0),o&&e.charCodeAt(t)===tt?{type:w,value:e.slice(r,t)}:void 0}t++}}}function rt(e,t,n){let r=e.charCodeAt(t),i,a;if(r!==Qe&&r!==tt){let r=t;for(;t<e.length;){let o=e.charCodeAt(t);if(o===$e){if(i)return;i=t}else if(o===et){if(a)return;a=t}else if(o===tt){let o=i==null&&a==null;if(n.xlsx&&i===r&&a===t-1&&(o=!0),i>=r&&a<t-1&&a>i+1&&(o=!0),o)return{type:T,value:e.slice(r,t)}}else if((i==null||a!=null)&&!(o>=65&&o<=90||o>=97&&o<=122||o>=48&&o<=57||o===46||o===95||o===161||o===164||o===167||o===168||o===170||o===173||o>=175))return;t++}}}var it=46,at=58;function ot(e,t){let n=e.charCodeAt(t);if(n===it){if(e.charCodeAt(t+1)===at)return e.charCodeAt(t+2)===it?3:2}else if(n===at)return e.charCodeAt(t+1)===it?2:1;return 0}function st(e,t){let n=e.charCodeAt(t);return!(n>=65&&n<=90||n>=97&&n<=122||n>=48&&n<=57||n===95||n===40||n>160)}function ct(e,t){let n=e.charCodeAt(t);return!(n>=65&&n<=90||n>=97&&n<=122||n>=48&&n<=57||n===95||n===40||n===36||n===46||n===33)}function lt(e,t){let n=t;e.charCodeAt(t)===36&&t++;let r=t+3,i=0;do{let n=e.charCodeAt(t);if(n>=65&&n<=90)i=26*i+n-64,t++;else if(n>=97&&n<=122)i=26*i+n-96,t++;else break}while(t<r&&t<e.length);return i&&i<=je+1?t-n:0}function ut(e,t){let n=t;e.charCodeAt(t)===36&&t++;let r=t+7,i=0,a=e.charCodeAt(t);if(a>=49&&a<=57){i=i*10+a-48,t++;do if(a=e.charCodeAt(t),a>=48&&a<=57)i=i*10+a-48,t++;else break;while(t<r&&t<e.length)}return i&&i<=j+1?t-n:0}function dt(e,t,n){let r=t,i=lt(e,r),a=0,o=0;if(i){r+=i;let s=ut(e,r);r+=s;let c=ot(e,r),l=r;if(c){if(r+=c,a=lt(e,r),r+=a,o=ut(e,r),r+=o,s&&o&&a){if(st(e,r)&&n.mergeRefs)return{type:E,value:e.slice(t,r)}}else if(!s&&!o){if(st(e,r))return{type:D,value:e.slice(t,r)}}else if(n.allowTernary&&(o||a)&&ct(e,r))return{type:O,value:e.slice(t,r)}}if(s&&st(e,l)&&e.charCodeAt(l)!==33)return{type:E,value:e.slice(t,l)}}else{let i=ut(e,r);if(i){r+=i;let s=ot(e,r);if(s){if(r+=s,a=lt(e,r),a&&(r+=a),o=ut(e,r),r+=o,a&&o&&n.allowTernary&&ct(e,r))return{type:O,value:e.slice(t,r)};if(!a&&o&&st(e,r))return{type:D,value:e.slice(t,r)}}}}}var ft=91,pt=93,mt=82,ht=114,gt=67,_t=99,vt=43,yt=45,bt=33;function xt(e,t,n=!1){let r=t,i=e.charCodeAt(t);if(n?i===mt||i===ht:i===gt||i===_t){t++;let i=0,a=0,o=e.length,s=e.charCodeAt(t),c,l=1,u=s===ft;if(u)o=Math.min(o,t+(n?8:6)),t++,c=e.charCodeAt(t),(c===vt||c===yt)&&(t++,o++,l=c===yt?-1:1);else if(s<49||s>57||isNaN(s))return 1;do{let n=e.charCodeAt(t);if(n>=48&&n<=57)a=a*10+n-48,i++,t++;else break}while(t<o);let d=n?j:je;return u?e.charCodeAt(t)===pt?(t++,a*=l,i&&-d<=a&&a<=d?t-r:0):0:i&&a<=d+1?t-r:0}return 0}function St(e,t,n){let r=t,i=xt(e,r,!0);r+=i;let a=xt(e,r);if(r+=a,(a||i)&&e.charCodeAt(r)!==bt){let o=ot(e,r),s=r;if(o){r+=o;let s=xt(e,r,!0);r+=s;let c=xt(e,r);if(r+=c,i&&!a&&s&&c||!i&&a&&s&&c||i&&a&&s&&!c||i&&a&&!s&&c){if(n.allowTernary&&st(e,r))return{type:O,value:e.slice(t,r)}}else if((a&&c&&!i&&!s||!a&&!c&&i&&s)&&st(e,r))return{type:D,value:e.slice(t,r)}}if(st(e,s))return{type:i&&a?E:D,value:e.slice(t,s)}}}function Ct(e,t,n){return n.r1c1?St(e,t,n):dt(e,t,n)}var wt=64,Tt=93,Et=91,Dt=58,Ot=44,kt=35,At=39,jt={headers:1,data:2,totals:4,all:8,"this row":16,"@":16},Mt=(...e)=>Object.freeze(e),Nt={0:Mt(),1:Mt(`headers`),2:Mt(`data`),4:Mt(`totals`),8:Mt(`all`),16:Mt(`this row`),3:Mt(`headers`,`data`),6:Mt(`data`,`totals`)};function Pt(e,t){let n=t;if(e.charCodeAt(n++)===Et&&e.charCodeAt(n++)===kt){do{let t=e.charCodeAt(n);if(t>=65&&t<=90||t>=97&&t<=122||t===32)n++;else break}while(n<t+11);if(e.charCodeAt(n++)===Tt)return n-t}}function Ft(e,t){let n=t;for(;Je(e.charCodeAt(n));)n++;return n-t}function It(e,t,n=!0){let r=t,i=``;if(e.charCodeAt(r)===Et){r++;let n;do if(n=e.charCodeAt(r),n===At)if(r++,n=e.charCodeAt(r),n===At||n===kt||n===wt||n===Et||n===Tt)i+=String.fromCharCode(n),r++;else return;else if(n===At||n===kt||n===wt||n===Et)return;else if(n===Tt)return r++,[e.slice(t,r),i];else i+=String.fromCharCode(n),r++;while(r<e.length)}else if(n){let n;do{if(n=e.charCodeAt(r),n===At||n===kt||n===wt||n===Et||n===Tt||n===Dt)break;i+=String.fromCharCode(n),r++}while(r<e.length);if(r!==t)return[i,i]}}function Lt(e,t=0){let n=[],r=t,i,a=0;if(e.charCodeAt(t)!==Et)return;if(i=Pt(e,t)){let n=e.slice(t+2,t+i-1);t+=i;let r=jt[n.toLowerCase()];if(!r)return;a|=r}else if(i=It(e,t,!1))t+=i[0].length,i[1]&&n.push(i[1]);else{let r=!0;for(t++,t+=Ft(e,t);r&&(i=Pt(e,t));){let n=jt[e.slice(t+2,t+i-1).toLowerCase()];if(!n)return;a|=n,t+=i,t+=Ft(e,t),r=e.charCodeAt(t)===Ot,r&&(t++,t+=Ft(e,t))}if(r&&e.charCodeAt(t)===wt&&(a|=jt[`@`],t+=1,r=e.charCodeAt(t)!==Tt),!Nt[a])return;let o=r&&It(e,t,!0);if(o){if(t+=o[0].length,n.push(o[1]),e.charCodeAt(t)===Dt){t++;let r=It(e,t,!0);if(r)t+=r[0].length,n.push(r[1]);else return}r=!1}if(t+=Ft(e,t),r||e.charCodeAt(t)!==Tt)return;t++}let o=Nt[a];return{columns:n,sections:o&&o.concat(),length:t-r,token:e.slice(r,t)}}var Rt=33;function zt(e,t){let n=Lt(e,t);if(n&&n.length){let r=n.length;for(;Je(e.charCodeAt(t+r));)r++;if(e.charCodeAt(t+r)!==Rt)return{type:_e,value:n.token}}}function Bt(e,t){let n=t;do{let n=e.charCodeAt(t);if(n<48||n>57)break;t++}while(t<e.length);return t-n}function Vt(e,t){let n=t,r=Bt(e,t);if(!r)return;if(t+=r,e.charCodeAt(t)===46){t++;let n=Bt(e,t);if(!n)return;t+=n}let i=e.charCodeAt(t);if(i===69||i===101){t++;let n=e.charCodeAt(t);(n===43||n===45)&&t++;let r=Bt(e,t);if(!r)return;t+=r}return{type:fe,value:e.slice(n,t)}}function Ht(e,t){let n=t,r=e.charCodeAt(t);if(r>=65&&r<=90||r>=97&&r<=122||r===95||r===92||r>160)t++;else return;let i;do if(i=e.charCodeAt(t),i>=65&&i<=90||i>=97&&i<=122||i>=48&&i<=57||i===95||i===92||i===46||i===63||i>160)t++;else break;while(isFinite(i));let a=t-n;if(a&&a<255)return r===92&&a<3||a===1&&(r===114||r===82||r===99||r===67)?void 0:{type:k,value:e.slice(n,t)}}var Ut=33;function Wt(e,t,n){if(e.charCodeAt(t)===Ut)return{type:C,value:e[t]};if(!n.r1c1){let n=ot(e,t);if(n)return{type:C,value:e.slice(t,t+n)}}}var Gt=91,Kt=40,qt=33,Jt=32,Yt=new Uint8Array(180-Jt),Xt=1,Zt=2,Qt=4,$t=8,en=16,tn=32,nn=Xt|Zt|Qt,rn=$t|en|tn,an=Xt|$t|Qt|tn;for(let e=Jt;e<180;e++){let t=String.fromCharCode(e),n=/^[a-zA-Z_\\\u00a1-\uffff]$/.test(t),r=/^[a-zA-Z_]$/.test(t),i=/^[a-zA-Z0-9_.\\?\u00a1-\uffff]$/.test(t),a=/^[a-zA-Z0-9_.]$/.test(t),o=/^[a-zA-Z0-9_.¡¤§¨ª\u00ad¯-\uffff]$/.test(t);Yt[e-Jt]=(n?Xt:0)|(i?$t:0)|(r?Zt:0)|(a?en:0)|(o?Qt:0)|(o?tn:0)}function on(e,t,n,r,i){let a=r-n;return i&&a&&a<255?t===92&&a<3||a===1&&(t===114||t===82||t===99||t===67)?void 0:{type:k,value:e.slice(n,r)}:{type:ye,value:e.slice(n,r)}}function sn(e,t,n){let r=t,i=e.charCodeAt(t),a=i>180?an:Yt[i-Jt];if(a&Qt&&!(a&Xt)&&!(a&Zt)||i===Gt)return rt(e,t,n);if(!(a&nn))return;let o=a&Xt?1:0,s=a&Zt?1:0,c=a&Qt?1:0;t++;let l;do{l=e.charCodeAt(t);let n=i>180?an:Yt[l-Jt]??0;if(n&rn)o&&!(n&$t)&&(o=0),s&&!(n&en)&&(s=0),c&&!(n&tn)&&(c=0);else return l===Kt&&s?{type:pe,value:e.slice(r,t)}:l===qt&&c?{type:T,value:e.slice(r,t)}:on(e,i,r,t,o);t++}while((o||s||c)&&t<e.length);if(r!==t)return on(e,i,r,t,o)}var cn=[Be,Ue,We,qe,Ye,Ze,Ct,Vt,Ke,nt,sn,zt],ln=[Wt,nt,rt,Ct,zt,Ht];function un(e){return e===`r`||e===`R`||e===`c`||e===`C`}var dn=/^l(?:ambda|et)$/i,fn=(e,t)=>e&&e.type===t,pn=e=>e===k||e===pe,mn=e=>!fn(e,C)||e.value===`%`||e.value===`}`||e.value===`)`||e.value===`#`;function hn(e,t){let n=0,r=0,i;for(let a of e){let e=a.type;e===C?a.value===`(`?(r++,i.type===pe&&dn.test(i.value)&&(n=r)):a.value===`)`&&(r--,r<n&&(n=0)):(n&&e===ye&&un(a.value)||n&&t&&e===D&&un(a.value))&&(a.type=k),i=a}return e}function gn(e,t,n={}){let{withLocation:r=!1,mergeRefs:i=!0,negativeNumbers:a=!0}=n,o={withLocation:r,mergeRefs:i,allowTernary:n.allowTernary??!1,negativeNumbers:a,r1c1:n.r1c1??!1,xlsx:n.xlsx??!1},s=[],c=0,l=0,u=0,d=[],f,p,m,h=e=>{let t=e.type,n=t===ye,i=m&&m.type===ye;m&&(n&&i||n&&pn(m.type)||i&&pn(t))?(m.value+=e.value,m.type=ye,r&&(m.loc[1]=e.loc[1])):(t===le&&(d.push(s.length),t=ye,e.type=ye),s[s.length]=e,m=e,t!==he&&t!==me&&(p=f,f=e))};if(e.startsWith(`=`)){let e={type:ve,value:`=`};r&&(e.loc=[0,1]),c++,h(e)}let g=t.length;for(;c<e.length;){let n=c,i;for(let n=0;n<g;n++)if(i=t[n](e,c,o),i){c+=i.value.length;break}if(i||(i={type:ye,value:e[c]},c++),r&&(i.loc=[n,c]),m&&i.value===`(`&&m.type===pe&&dn.test(m.value)&&l++,i.value.length===1&&(i.type===ye||o.r1c1&&i.type===D)&&(u+=+!!un(i.value)),a&&i.type===fe){let e=m;if(e?.type===C&&e.value===`-`&&(!p||p.type===ve||!mn(p))){let e=s.pop();i.value=`-`+i.value,i.loc&&(i.loc[0]=e.loc[0]),f=p,m=s[s.length-1]}}h(i)}u&&l&&hn(s,o.r1c1);for(let e of d){let t=s[e-1],n=s[e+1];s[e].type=t?.type===E&&n?.type===E?C:ye}return i?Le(s):s}function _n(e,t={}){return gn(e,cn,{withLocation:t.withLocation??!1,mergeRefs:t.mergeRefs??!0,allowTernary:t.allowTernary??!1,negativeNumbers:t.negativeNumbers??!0,r1c1:t.r1c1??!1,xlsx:!0})}function vn(e){return!!e&&(e.type===E||e.type===D||e.type===O||e.type===_e||e.type===k)}function yn(e){return!!e&&(e.type===ue||e.type===de||e.type===fe||e.type===ge)}function bn(e){return!!e&&e.type===de}function xn(e){return!!e&&(e.type===he||e.type===me)}function Sn(e){return!!e&&e.type===pe}function Cn(e){return!!e&&e.type===C}var wn=`(END)`,Tn=`(FUNCTION)`,En=`(WHITESPACE)`,Dn=[`ANCHORARRAY`,`CHOOSE`,`DROP`,`IF`,`IFS`,`INDEX`,`INDIRECT`,`LAMBDA`,`LET`,`OFFSET`,`REDUCE`,`SINGLE`,`SWITCH`,`TAKE`,`TRIMRANGE`,`XLOOKUP`],On={},M,kn,N,An=!1,jn=e=>An||Dn.includes(e.toUpperCase()),Mn=(e,t=!1)=>{let n=(e&&e.value)+``;return!!(vn(e)||t&&Cn(e)&&(n===`:`||n===`,`||!n.trim())||Sn(e)&&jn(n)||bn(e)&&n===`#REF!`)},Nn=e=>!!e&&(e.type===Se||(e.type===we||e.type===de)&&e.value===`#REF!`||e.type===xe&&(e.operator===`:`||e.operator===` `||e.operator===`,`)||vn(e)||e.type===Te&&jn(e.callee.name));function P(e,t=null){let n=Error(e);throw n.source=kn.map(e=>e.value).join(``),n.sourceOffset=kn.slice(0,t??N).reduce((e,t)=>e+t.value.length,0),n}function Pn(e=!1){let t=N,n;do n=kn[++t];while(n&&(xn(n)||Cn(n)&&n.value===`(`));return Mn(n,e)}function F(e=null,t=null){if(e&&e!==M.id&&P(`Expected ${e} but got ${M.id}`),xn(kn[N])){let e=Nn(t),n=e&&Pn(!1),r=e&&kn[N+1]&&kn[N+1].value===`(`;if(!n&&!r)for(;xn(kn[N]);)N++}if(N>=kn.length){M=On[wn];return}let n=kn[N];N+=1,n.unterminated&&P(`Encountered an unterminated token`);let r;return Cn(n)?(r=On[n.value],r||P(`Unknown operator ${n.value}`)):xn(n)?r=On[En]:yn(n)?r=On[Ce]:vn(n)?r=On[Se]:Sn(n)?r=On[Tn]:P(`Unexpected ${n.type} token: ${n.value}`),M=Object.create(r),M.type=n.type,M.value=n.value,n.loc&&(M.loc=[...n.loc]),M}function Fn(e){let t=M;F(null,t);let n=t.nud();for(;e<M.lbp;)t=M,F(null,t),n=t.led(n);return n}var In={nud:()=>P(`Invalid syntax`),led:()=>P(`Missing operator`)};function Ln(e,t=0){let n=On[e];return n?t>=n.lbp&&(n.lbp=t):(n={...In},n.id=e,n.value=e,n.lbp=t,On[e]=n),n}function I(e,t,n){let r=Ln(e,t);return r.led=n||function(e){this.type=xe,this.operator=this.value,delete this.value;let n=Fn(t);return this.arguments=[e,n],this.loc&&=[e.loc[0],n.loc[1]],this},r}function Rn(e,t){let n=Ln(e,0);return n.lbp=70,n.led=t||function(e){return this.type=be,this.operator=this.value,delete this.value,this.arguments=[e],this.loc&&(this.loc[0]=e.loc[0]),this},n}function zn(e,t){let n=Ln(e);return n.nud=t||function(){this.type=be,this.operator=this.value,delete this.value;let e=Fn(70);return this.arguments=[e],this.loc&&(this.loc[1]=e.loc[1]),this},n}function Bn(e,t){return I(e,t,function(n){Nn(n)||P(`Unexpected ${e} operator`);let r=Fn(t);return Nn(r)||P(`Unexpected ${M.type} following ${this.id}`),this.type=xe,this.operator=this.value.trim()?this.value:` `,delete this.value,this.arguments=[n,r],this.loc&&=[n.loc[0],r.loc[1]],this})}Ln(wn),Bn(`:`,80);var Vn=Bn(`,`,80);Bn(En,80);var L=e=>{let t=Vn.lbp>0;return e!=null&&(Vn.lbp=e?80:0),t};Rn(`%`),Rn(`#`,function(e){return Nn(e)||P(`# expects a reference`),this.type=be,this.operator=this.value,delete this.value,this.arguments=[e],this}),zn(`+`),zn(`-`),zn(`@`),I(`^`,50),I(`*`,40),I(`/`,40),I(`+`,30),I(`-`,30),I(`&`,20),I(`=`,10),I(`<`,10),I(`>`,10),I(`<=`,10),I(`>=`,10),I(`<>`,10),Ln(Ce).nud=function(){let{type:e,value:t}=this;if(this.type=Ce,this.raw=t,e===fe)this.value=+t;else if(e===ue)this.value=t.toUpperCase()===`TRUE`;else if(e===de)this.type=we,this.value=t.toUpperCase();else if(e===ge)this.value=t.slice(1,-1).replace(/""/g,`"`);else throw Error(`Unsupported literal type: `+e);return this},Ln(Se).nud=function(){return this.type===k?this.kind=`name`:this.type===_e?this.kind=`table`:this.type===D?this.kind=`beam`:this.kind=`range`,this.type=Se,this},Ln(`)`),zn(`(`,function(){let e=L(!0),t=Fn(0);return F(`)`,t),L(e),t}),Ln(Tn).nud=function(){return this},I(`(`,90,function(e){let t={type:ke,name:e.value};e.id!==Tn&&(e.type===Ee||e.type===Te||e.type===De||e.type===Se||e.type===be&&e.value===`#`||e.type===we&&e.value===`#REF!`?t=e:P(`Unexpected call`,N-1));let n=e.value.toLowerCase();if(n===`lambda`)return Hn.call(this,e);if(n===`let`)return Un.call(this,e);let r=[],i=!1;if(M.id!==`)`){let e=L(!1);for(;M.id!==`)`;)if(xn(M)&&F(),M.id===`,`)r.push(null),i=!0,F();else{let e=Fn(0);r.push(e),i=!1,M.id===`,`&&(F(`,`),i=!0)}L(e)}i&&r.push(null);let a=M;return delete this.value,this.type=Te,this.callee=t,e.loc&&(this.callee.loc=[...e.loc]),this.arguments=r,e.loc&&(this.loc=[e.loc[0],a.loc[1]]),F(`)`,this),this});function Hn(e){let t=[],n={},r,i=!1,a=L(!1);if(M.id!==`)`)for(;!i;){xn(M)&&F();let e=N,a=Fn(0);if(M.id===`,`){if(a.type===Se&&a.kind===`name`){let e=a.value.toLowerCase();e in n&&P(`Duplicate name: `+a.value),n[e]=1;let r={type:ke,name:a.value};a.loc&&(r.loc=a.loc),t.push(r)}else N=e,P(`LAMBDA argument is not a name`);F(`,`)}else r=a,i=!0}return L(a),delete this.value,this.type=Ee,this.params=t,this.body=r||null,e.loc&&(this.loc=[e.loc[0],M.loc[1]]),F(`)`,this),this}function Un(e){let t=[],n=[],r={},i,a=0,o=(e,o)=>{if(i&&P(`Unexpected argument following calculation`),o&&a>=2)i=e;else if(a%2)n.push(e);else if(e&&e.type===Se&&e.kind===`name`){let n=e.value.toLowerCase();n in r&&P(`Duplicate name: `+e.value),r[n]=1,t.push({type:ke,name:e.value,loc:e.loc})}else a>=2?i=e:P(`Argument is not a name`);a++},s=L(!1),c=!1;if(M.id!==`)`){for(;M.id!==`)`;)xn(M)&&F(),M.id===`,`?(o(null),c=!0,F()):(o(Fn(0),M.id!==`,`),c=!1,M.id===`,`&&(F(`,`),c=!0));L(s)}c&&o(null,!0),i===void 0&&P(`Unexpected end of arguments`),L(s),delete this.value,this.type=De,this.declarations=[],t.length||P(`Unexpected end of arguments`);for(let e=0;e<t.length;e++){let r={type:Ae,id:t[e],init:n[e],loc:t[e].loc&&[t[e].loc[0],n[e].loc[1]]};this.declarations.push(r)}return this.body=i,e.loc&&(this.loc=[e.loc[0],M.loc[1]]),F(`)`,this),this}Ln(`}`),Ln(`;`),zn(`{`,function(){M.id===`}`&&P(`Unexpected empty array`);let e=[],t=!1,n=[e],r=L(!1);for(;!t;)xn(M)&&F(),yn(M)?(e.push(On[Ce].nud.call(M)),F()):P(`Unexpected ${M.type} in array: ${M.value}`),M.id===`,`?F(`,`):M.id===`;`?(F(`;`),e=[],n.push(e)):t=!0;let i=M;return F(`}`),L(r),this.type=Oe,this.elements=n,this.loc&&(this.loc[1]=i.loc[1]),delete this.value,this});var Wn=/[^0-9A-Za-z._¡¤§¨ª\u00ad¯-\uffff]/,Gn=/^(R|C|RC|[A-Z]{1,3}\d{1,7})$/i;function Kn(e,t=0){return t||e&&(Wn.test(e)||Gn.test(e)||/^\d/.test(e))?1:0}function qn(e){return`'`+e.replace(/'/g,`''`)+`'`}function Jn(e){let t=``,n=0,{workbookName:r,sheetName:i}=e;return r&&(t+=`[`+r+`]`,n+=Kn(r)),i&&(t+=i,n+=Kn(i)),n&&(t=qn(t)),t&&t+`!`}function Yn(e){return e===`both`?`.:.`:e===`head`?`.:`:e===`tail`?`:.`:`:`}var Xn=(e,t,n)=>Math.min(Math.max(t,e),n);function Zn(e,t){return t?String(e+1):e?`[`+e+`]`:``}function Qn(e){let{r0:t,c0:n,r1:r,c1:i}=e,{$c0:a,$c1:o,$r0:s,$r1:c}=e,l=t==null,u=n==null,d=r==null,f=i==null,p=Yn(e.trim),m=!!e.trim;if(t=Xn(s?0:-j,t|0,j),n=Xn(a?0:-je,n|0,je),!l&&d&&!u&&f?(r=t,d=!1,i=n,f=!1):(r=Xn(c?0:-j,r|0,j),i=Xn(o?0:-je,i|0,je)),t===0&&r>=j&&!u&&!f||l&&d){let e=Zn(n,a),t=Zn(i,o);return`C`+(e===t&&!m?e:e+p+`C`+t)}if(n===0&&i>=je&&!l&&!d||u&&f){let e=Zn(t,s),n=Zn(r,c);return`R`+(e===n&&!m?e:e+p+`R`+n)}let h=Zn(t,s),g=Zn(r,c),_=Zn(n,a),v=Zn(i,o);return l||d||u||f?(l?``:`R`+h)+(u?``:`C`+_)+p+(d?``:`R`+g)+(f?``:`C`+v):h!==g||_!==v?`R`+h+`C`+_+p+`R`+g+`C`+v:`R`+h+`C`+_}function $n(e){return Jn(e)+(`name`in e?e.name:Qn(e.range))}var er=36,tr=46,nr=58,rr=97,ir=65,ar=122,or=90,sr=48,cr=49,lr=57;function ur(e,t){let n=e.charCodeAt(t);if(n===tr){if(e.charCodeAt(t+1)===nr)return e.charCodeAt(t+2)===tr?[3,`both`]:[2,`head`]}else if(n===nr)return e.charCodeAt(t+1)===tr?[2,`tail`]:[1,``];return[0,``]}function dr(e,t){let n=t,r=e.charCodeAt(t)===er;r&&t++;let i=t+3,a=0;do{let n=e.charCodeAt(t);if(n>=ir&&n<=or)a=26*a+n-(ir-1),t++;else if(n>=rr&&n<=ar)a=26*a+n-(rr-1),t++;else break}while(t<i&&t<e.length);return a&&a<=je+1?[t-n,a-1,r]:[0,0,!1]}function fr(e,t){let n=t,r=e.charCodeAt(t)===er;r&&t++;let i=t+7,a=0,o=e.charCodeAt(t);if(o>=cr&&o<=lr){a=a*10+o-sr,t++;do if(o=e.charCodeAt(t),o>=sr&&o<=lr)a=a*10+o-sr,t++;else break;while(t<i&&t<e.length)}return a&&a<=j+1?[t-n,a-1,r]:[0,0,!1]}function pr(e,t,n,r,i,a,o,s,c){o!=null&&(n==null||n!=null&&o<n)&&([n,o,r,s]=[o,n,s,r]),i!=null&&(e==null||e!=null&&i<e)&&([e,i,t,a]=[i,e,a,t]);let l={top:e,left:n,bottom:i,right:o,$top:t,$left:r,$bottom:a,$right:s};return c&&(l.trim=c),l}function mr(e,t=!0){let n=0,[r,i,a]=dr(e,n),o=0,s=!1,c=0,l=!1,u,d;if(r){n+=r;let[f,p,m]=fr(e,n);n+=f;let[h,g]=ur(e,n);if(h){if(n+=h,[u,o,s]=dr(e,n),n+=u,[d,c,l]=fr(e,n),n+=d,f&&d&&u){if(n===e.length)return pr(p,m,i,a,c,l,o,s,g)}else if(!f&&!d){if(n===e.length)return pr(null,!1,i,a,null,!1,o,s,g)}else if(t&&(d||u)&&n===e.length)return f?d?pr(p,m,i,a,c,l,null,!1,g):pr(p,m,i,a,null,!1,o,s,g):pr(null,!1,i,a,c,l,o,s,g)}if(f&&n===e.length)return pr(p,m,i,a,p,m,i,a,g)}else{let[r,i,a]=fr(e,n);if(r){n+=r;let[f,p]=ur(e,n);if(f){if(n+=f,[u,o,s]=dr(e,n),n+=u,[d,c,l]=fr(e,n),n+=d,u&&d&&t){if(n===e.length)return pr(i,a,null,!1,c,l,o,s,p)}else if(!u&&d&&n===e.length)return pr(i,a,null,!1,c,l,null,!1,p)}}}}function hr(e){let t=``;for(let n of e)t+=n.value;return t}function gr(e){let t={type:e.type,value:e.value};return e.loc&&(t.loc=[e.loc[0],e.loc[1]]),e.unterminated!=null&&(t.unterminated=e.unterminated),typeof e.index==`number`&&(t.index=e.index,typeof e.groupId==`string`&&(t.groupId=e.groupId),typeof e.depth==`number`&&(t.depth=e.depth),typeof e.error==`boolean`&&(t.error=e.error)),t}function _r(e,t=!1){let n=!1,r=``,i=[],a=()=>{r&&i.push(t?r:{value:r,braced:n}),r=``};for(let t=0;t<e.length;t++){let i=e[t];i===`[`?(a(),n=!0):i===`]`?(a(),n=!1):r+=i}return a(),i}function vr(e,t,n){let r=_r(e,!n);if(n){if(r.length>1)t.workbookName=r[r.length-2].value,t.sheetName=r[r.length-1].value;else if(r.length===1){let e=r[0];e.braced?t.workbookName=e.value:t.sheetName=e.value}}else t.context=r}var yr=e=>e.slice(1,-1).replace(/''/g,`'`),br=(e,t)=>{let n=e?.value;if(n===`:`||n===`.:`||n===`:.`||n===`.:.`)return t.operator=n,1},xr=(e,t)=>{if(e?.type===E)return t.r0=e.value,1},Sr=(e,t)=>{if(e?.type===O)return t.r0=e.value,1},Cr=(e,t)=>{if(e?.type===E)return t.r1=e.value,1},wr=e=>{if(e?.type===C&&e.value===`!`)return 1},Tr=(e,t)=>{if(e?.type===D)return t.r0=e.value,1},Er=(e,t)=>{if(e.type===_e)return t.struct=e.value,1},Dr=(e,t,n)=>{let r=e?.type;if(r===T)return vr(e.value,t,n),1;if(r===w)return vr(yr(e.value),t,n),1},Or=(e,t)=>{if(e?.type===k)return t.name=e.value,1},kr=[[Sr],[xr,br,Cr],[xr],[Tr],[Dr,wr,Sr],[Dr,wr,xr,br,Cr],[Dr,wr,xr],[Dr,wr,Tr]],Ar=kr.concat([[Or],[Dr,wr,Or],[Er],[Or,Er],[Dr,wr,Or,Er]]);function jr(e,t={}){let n={withLocation:t.withLocation??!1,mergeRefs:t.mergeRefs??!1,allowTernary:t.allowTernary??!1,allowNamed:t.allowNamed??!0,r1c1:t.r1c1??!1,xlsx:!0},r=gn(e,ln,n);r.length&&r[0].type===ve&&r.shift();let i=n.allowNamed?Ar:kr;for(let e of i)if(e.length===r.length){let t={workbookName:``,sheetName:``,r0:``,r1:``,name:``,struct:``,operator:``};if(e.every((e,n)=>e(r[n],t,!0)))return t}}var Mr=/^l(?:ambda|et)$/i,Nr=(e,t,n)=>t==null?null:e?t:t-n,Pr=e=>e.slice(1,-1).replace(/''/g,`'`);function Fr(e){let t=e.lastIndexOf(`!`),n={};return t>-1?(e.startsWith(`'`)?vr(Pr(e.slice(0,t)),n,!0):vr(e.slice(0,t),n,!0),n.range=mr(e.slice(t+1))):n.range=mr(e),n}function Ir(e,t){let n=mr(t);if(!n)throw Error(`translateTokensToR1C1 got an invalid anchorCell: `+t);let{top:r,left:i}=n,a=0,o=0,s=0,c=[];for(let t of e){let e=t?.type;if(e===C)if(t.value===`(`){o++;let e=c[c.length-1];e&&e.type===pe&&Mr.test(e.value)&&(a=o)}else t.value===`)`&&(o--,o<a&&(a=0));if(e===E||e===D||e===O){t=gr(t);let e=t.value,n=Fr(e);if(n){let e=n.range,o={};o.r0=Nr(e.$top,e.top,r),o.r1=Nr(e.$bottom,e.bottom,r),o.c0=Nr(e.$left,e.left,i),o.c1=Nr(e.$right,e.right,i),o.$r0=e.$top,o.$r1=e.$bottom,o.$c0=e.$left,o.$c1=e.$right,e.trim&&(o.trim=e.trim),n.range=o;let s=$n(n);un(s)&&a&&(s+=`[0]`),t.value=s}t.loc&&(t.loc[0]+=s,s+=t.value.length-e.length,t.loc[1]+=s)}else s&&t.loc&&(t=gr(t),t.loc[0]+=s,t.loc[1]+=s);c[c.length]=t}return c}function Lr(e,t,n={}){if(typeof e==`string`)return hr(Ir(_n(e,{mergeRefs:!1,allowTernary:n.allowTernary??!0}),t));throw Error(`translateFormulaToA1 expects a formula string`)}var Rr=String.fromCharCode;function zr(e){return(e>=702?Rr(((e-702)/676-0)%26+65):``)+(e>=26?Rr((e/26-1)%26+65):``)+Rr(e%26+65)}var Br=(e,t,n)=>Math.min(Math.max(t,e),n),R=(e,t)=>(t?`$`:``)+zr(e),z=(e,t)=>(t?`$`:``)+Vr(e),Vr=e=>String(e+1);function Hr(e){let{top:t,left:n,bottom:r,right:i,trim:a}=e,{$left:o,$right:s,$top:c,$bottom:l}=e,u=n==null,d=i==null,f=t==null,p=r==null;t=Br(0,t|0,j),n=Br(0,n|0,je),!u&&!f&&d&&p?(r=t,i=n):(r=Br(0,r|0,j),i=Br(0,i|0,je));let m=Yn(a);return t===0&&r>=j&&!u&&!d&&(!(o&&!u||s&&!d)||n===i)||f&&p?R(n,o)+m+R(i,s):n===0&&i>=je&&!f&&!p&&(!(c&&!f||l&&!p)||t===r)||u&&d?z(t,c)+m+z(r,l):!u&&!f&&!d&&p?R(n,o)+z(t,c)+m+R(i,s):!u&&f&&!d&&!p?R(n,o)+z(r,l)+m+R(i,s):!u&&!f&&d&&!p?R(n,o)+z(t,c)+m+z(r,l):u&&!f&&!d&&!p?R(i,s)+z(t,c)+m+z(r,l):i!==n||r!==t||s!==o||l!==c?R(n,o)+z(t,c)+m+R(i,s)+z(r,l):R(n,o)+z(t,c)}function Ur(e){return Jn(e)+(`name`in e?e.name:Hr(e.range))}function Wr(e,{allowNamed:t=!0,allowTernary:n=!1}={}){let r=jr(e,{allowNamed:t,allowTernary:n,r1c1:!1});if(r){if(r.name)return{workbookName:r.workbookName,sheetName:r.sheetName,name:r.name};if(r.r0&&r.r0){let e=mr(r.r1?r.r0+r.operator+r.r1:r.r0);if(e)return{workbookName:r.workbookName,sheetName:r.sheetName,range:e}}}}Object.freeze({OPERATOR:C,BOOLEAN:ue,ERROR:de,NUMBER:fe,FUNCTION:pe,NEWLINE:me,WHITESPACE:he,STRING:ge,CONTEXT:T,CONTEXT_QUOTE:w,REF_RANGE:E,REF_BEAM:D,REF_TERNARY:O,REF_NAMED:k,REF_STRUCT:_e,FX_PREFIX:ve,UNKNOWN:ye}),Object.freeze({UNARY:be,BINARY:xe,REFERENCE:Se,LITERAL:Ce,ERROR:we,CALL:Te,ARRAY:Oe,IDENTIFIER:ke,LAMBDA:Ee,LET:De,LET_DECL:Ae});var Gr={"\n":.28,"\r":.28," ":.28,"\xA0":.28," ":.28,"":0," ":.5," ":1," ":.5," ":1," ":.33," ":.25," ":.16," ":.56," ":.28," ":.2," ":.15,"":0," ":.16," ":.22," ":1,"":0},Kr=/^((?:[a-z\d-]+\s+)*)([\d.]+(%|em|px)|(?:x+-)?large|(?:x+-)?small|medium)(?:\s*\/\s*(normal|[\d.]+(%|px|em)?))?(\s.+)?$/,qr=/\bsmall-caps\b/,Jr=/\b(?:italic|oblique)\b/,Yr=/\bbold(?:er)?\b/,Xr=16,Zr=13.3333333,Qr=.01*Xr,$r={"xx-small":9,"x-small":10,smaller:13.3333,small:13,medium:16,large:18,larger:19.2,"x-large":24,"xx-large":32},ei=new Map;function ti(e){if(ei.has(e))return ei.get(e);let t=Kr.exec(e);if(!t)return{};let n=(t[6]||``).trim(),r=$r[t[2]]||parseFloat(t[2]);t[3]===`%`?r*=Qr:t[3]===`em`?r*=Xr:t[3]===`pt`&&(r*=Zr);let i;i=t[4]===`normal`||t[4]===`inherit`||!t[4]?Math.round(7/6*r):!t[5]||t[5]===`em`?parseFloat(t[4]||``)*r:t[5]===`pt`?parseFloat(t[4]||``)*Zr:t[5]===`%`?r*.01:parseFloat(t[4]||``);let a=qr.test(t[1])?`small-caps`:`normal`,o=Jr.test(t[1])?`italic`:`normal`,s=400;if(Yr.test(t[1]))s=700;else{let e=/\b(\d+)\b/.exec(t[1]),n=e?parseInt(e[1],10):400;s=n>=100&&n!==400?n:400}let c={family:n,size:r,height:i??7/6*r,weight:s,variant:a,style:o};return ei.set(e,c),c}function ni(e,t){let n=``;if(e.style&&e.style!==`normal`&&(n+=e.style),e.variant&&e.variant!==`normal`&&(n+=(n?` `:``)+e.variant),e.weight&&e.weight!==400&&(n+=n?` `:``,e.weight===700?n+=`bold`:n+=e.weight),e.size){let r=e.size;!t&&e.sizeAdjust&&e.sizeAdjust!==1&&(r*=e.sizeAdjust),n+=(n?` `:``)+r+`px`,e.height!==e.size&&(n+=`/`+e.height+`px`)}return e.family&&(n+=(n?` `:``)+e.family),t&&(n+=`::`+e.baseline),t&&(n+=`::`+e.color),t&&(n+=`::`+e.tracking),t&&(n+=`::`+(e.sizeAdjust??``)),n}var ri=ti(`12px/14px sans-serif`),ii={trim:!0,collapse:!0},ai={};function oi(){return(e,t)=>{let n=typeof t==`string`?ti(t):t,r=n.size??12;return n.family&&/\bmonospace\b/.test(n.family)?r*=.6:(r*=.45,n.weight&&n.weight>400&&(r*=1.18)),e.length*r}}function si(e){if(e&&e.getContext){let t=e.getContext(`2d`);if(t&&typeof t.measureText==`function`)return(e,n)=>(t.font=String(n),t.measureText(e).width)}}function ci(){let e=typeof document<`u`?document:null;return typeof OffscreenCanvas<`u`&&new OffscreenCanvas(100,100)||e&&e.createElement&&e.createElement(`canvas`)||null}var li=si(ci())||oi();function ui(e){if(e==null)li=si(ci())||oi();else if(e)li=si(e)||oi();else throw Error(`setMeasureCanvas argument is not a canvas or null`)}function di(e,t,n=ii){t=typeof t==`string`?ti(t):{...ri,...t};let r=Object.assign({},ii,n),i=String(e);if(!i)return 0;if(i in Gr){let e=ni(t,!0)+`/`+i;return e in ai||(ai[e]=li(`_${i}_`,ni(t))-li(`__`,ni(t))),ai[e]}!r.trim||!r.collapse?i=i.replace(/\n/g,` `):r.trim?i=i.replace(/\n/g,` `).trim():r.collapse&&(i=i.replace(/\s+/g,` `));let a=typeof e==`string`?0:e.font.tracking||0;return li(i,ni(t))+(t.size??12)*a}var B=class{value;width;whitespace;font;line;constructor(e=``,t={}){this.value=e,this.font=t,this.width=0}valueOf(){return this.value}toString(){return this.value}toJSON(){let e=this,t={type:`TK`,val:e.value??``};return e.font.style===`italic`&&(t.style=e.font.style),e.font.family&&e.font.family!==`sans-serif`&&(t.font=e.font.family),e.font.weight&&e.font.weight!==400&&(t.weight=e.font.weight),e.font.baseline&&(t[e.font.baseline<0?`sub`:`sup`]=!0),[`href`,`color`,`class`,`target`,`rel`].forEach(n=>{e.font[n]&&(t[n]=e.font[n])}),t}},fi=class extends B{toJSON(){let e=super.toJSON();return e.type=`BR`,delete e.val,e}},V=class extends B{toJSON(){let e=super.toJSON();return e.type=`NL`,delete e.val,e}},pi=class extends B{toJSON(){let e=super.toJSON();return e.type=`SH`,delete e.val,e}},mi=/[\r\n\xA0]+/g;function hi(e,t){return{family:t.family??e.family??`sans-serif`,style:t.style??e.style??`normal`,variant:t.variant??e.variant??`normal`,weight:t.weight??e.weight??400,height:t.height??e.height??14,size:t.size??e.size??12,sizeAdjust:t.sizeAdjust??e.sizeAdjust??void 0,baseline:t.baseline??e.baseline??0,tracking:t.tracking??e.tracking??0,href:t.href??e.href??``,color:t.color??e.color??``,rel:t.rel??e.rel??``,target:t.target??e.target??``,class:t.class??e.class??``}}function gi(e,t,n){let r=e.width,i,a;for(;r+n.width>t&&e.length;)i=e[e.length-1],a=i.width??0,i.width&&i.width>n.width?(i.value=i.value.slice(0,-1),i.width=di(i,i.font),r+=i.width):e.pop(),r-=a;e[e.length-1]instanceof pi&&e.pop(),i&&(i=e[e.length-1]||i||{},n.font=Object.create(i.font),n.font.href=e.length?i.font.href:void 0,n.font.rel=e.length?i.font.rel:void 0,n.font.target=e.length?i.font.target:void 0,e.push(n))}function _i(e){return Object.assign([],{height:0,font:e,width:0,hasOverflow:!1,hasLineOverflow:!1})}function vi(e){let t=new B(e.value);return t.width=e.width??0,t.whitespace=e.whitespace,t.font=e.font,t}function yi(e,t){let n=ti(t.font);if(!e.length)return _i(n);let r=typeof t.height==`function`?t.height:()=>t.height,i=typeof t.width==`function`?t.width:()=>t.width,a=t.overflowLine,o=t.overflowWrap,s={...n,weight:700},c=n.height??n.size??12,l=isFinite(r())?Math.floor(r()/c):1/0;if(!r()&&!i(0)||!l)return _i(n);let u=0,d=0,f=0,p=[],m=[],h=!1;for(;u<e.length&&d<l;){let t=e[u],r=hi(n,t.font);if(t.width=di(t,r),t.font=r,t.line=d,t.whitespace=t.value in Gr,t.value&&=t.value.replace(mi,` `),!(!f&&t.whitespace||h&&t.whitespace))if(t instanceof V)f=0,m=[],p.push(u+1),d++;else if(t instanceof fi||t instanceof pi)m.push({index:u,width:f});else if(t.whitespace||f+t.width<i(d))f+=t.width;else if(m.length){let t,r;do{r=!0,t=m.pop();let a=e[t.index],o;a instanceof pi&&(o=di(`-`,a.font||n),t.width+o>i(d)&&(r=!m.length))}while(!r);p.push(t.index+1),f=0,d++,u=t.index,m=[]}else if(o===`break-word`){let r=i(d);if(f+t.width>r){let i=vi(t);do t.value=t.value.slice(0,-1),t.width=di(t,t.font||n),f+=t.width;while(t.value&&t.width>r);i.value=i.value.slice(t.value.length),e.splice(u+1,0,new fi,i)}p.push(u+1),f=0,d++}else f+=t.width;u++,h=t.whitespace}u!==p[p.length-1]&&p.push(u);let g=0,_=0,v=p.map(t=>{let r=g,i;for(;(i=e[r])&&(i.whitespace||!i.value);)r++;let a=t,o=null;for(;a>r&&(i=e[a-1])&&(i.whitespace||!(i.value||i instanceof pi));)i instanceof V&&(o=i),a--;i instanceof pi&&(i.value=`-`,i.width=di(`-`,i.font||n)),g=t;let s=Object.assign(e.slice(r,a).filter(e=>e.value),{width:0});return o&&s.push(o),s.width=s.reduce((e,t)=>e+(t.width||0),0),s.width>_&&(_=s.width),s}),y=!1;if(a){let e=a===`ellipsis`?`…`:a;v.forEach((t,r)=>{let a=i(r);if(t.width>a){let r=new B(e);r.font=n,r.width=di(e,s),gi(t,a,r),y=!0}})}let b=!1,ee=t.overflow===`ellipsis`?`…`:t.overflow;if(ee&&u!==e.length){let e=i(v.length-1),t=v[v.length-1],r=new B(ee);r.font=n,r.width=di(ee,s),gi(t,e,r),b=!0}else b=!1;return Object.assign(v,{height:v.length*c,font:n,width:_,hasOverflow:b,hasLineOverflow:y})}function bi(e){return Math.round(e*1e6)/1e6}var xi={center:`middle`,right:`end`},Si={middle:.5,center:.5,bottom:1,end:1},Ci=(e,t)=>!e&&!t||e===t;function wi(e,t){let n=[],r=ti(t.font),i=r.size??12,a=r.family??`sans-serif`,o=t.align??`left`,s=t.createElement;if(e.length){let c=r.height??7/6*i,l=t.valign,u=typeof t.height==`function`?t.height():t.height,d=typeof t.width==`function`?t.width(0):t.width,f=typeof t.x==`function`?t.x:()=>t.x,p=!isFinite(d)&&e.length===1,m=bi(c/i)??0,h=p?0:bi(c/(i*1.15+(c-i)/2));if(Si[l]&&isFinite(u)){let t=l===`bottom`?1:.5;h=(h||0)+(u*t-c*e.length*t)/i}let g=o===`justify`,_=0;o===`right`?_=d:o===`center`&&(_=d/2);let v=[],y=`tspan`,b=null,ee=``,x=()=>{if(ee){let e=s(y,b,ee);v.push(e)}y=`tspan`,b=null,ee=``};for(let t=0,r=e.length;t<r;t++){let o=``,c=``,l=0,u=e[t];if(!u.length){n.push(s(`tspan`,{x:f(t),dy:bi(t?m:h)+`em`},`\xA0`));continue}v=[];let te=0,ne=0,re=``;for(let e=0,t=u.length;e<t;e++){let t=u[e],n=t.font,r=ni(n,!0);if(t.whitespace&&te++,ne+=t.width,e&&!t.font.tracking&&!l&&Ci(r,o)&&Ci(t.font.class,c)&&Ci(re,t.font.href))ee+=t.value;else{x();let e=(n.size??i)*(n.sizeAdjust??1);ee=t.value,b={fontFamily:n.family!==a&&n.family||null,fontSize:e===i?null:e,fontWeight:n.weight===400?null:n.weight||null,fontStyle:n.style===`normal`?null:n.style||null,fontVariant:n.variant===`normal`?null:n.variant||null,fill:n.color||null,baselineShift:n.baseline?n.baseline*100+`%`:null,className:t.font.class||null,dx:0,href:null,rel:null,target:null},l&&=(b.dx=bi(l),0),t.font.tracking&&(l=e*t.font.tracking),t.font.href&&!re?(re=t.font.href,y=`a`,b.href=re,b.rel=t.font.rel,b.target=t.font.target):re=``,o=r,c=t.font.class??``}}if(x(),p)n.push(...v);else{let e=null,i=t===r-1||u[u.length-1]instanceof V;g&&u.length>1&&!i&&(e=bi((d-ne)/te)),n.push(s(`tspan`,{wordSpacing:e,x:f(t)+_,dy:bi(t?m:h)+`em`},...v))}}}return s(`text`,{fontFamily:a,fontSize:i,textAnchor:xi[o]||`start`},...n)}var Ti={middle:.5,center:.5,bottom:1,end:1};function Ei(e){return e.color||(e.href?`#00C`:`#000`)}function Di(e,t,n){if(!e.length)return;n.textBaseline=`middle`;let r=ti(t.font),i=r.size??12,a=r.height??7/6*i,o=t.valign,s=typeof t.height==`function`?t.height():t.height,c=typeof t.width==`function`?t.width(0):t.width,l=typeof t.x==`function`?t.x:()=>t.x,u=t.align,d=u===`justify`,f=a*.5,p=Ti[o];if(p&&isFinite(s)){let t=e.length*a;f+=s*p-t*p}let m;e.forEach((t,r)=>{m=null;let o=l(r),s=r*a+f,p=0,h=0;t.forEach(e=>{e.whitespace&&p++,h+=e.width});let g=0,_=r===e.length-1||t[t.length-1]instanceof V;d&&t.length>1&&!_&&(g=(c-h)/p);for(let e of t){n.font=ni(e.font);let t=e.font,r=t.baseline?i*-t.baseline+i*.15:0;n.fillStyle=Ei(t);let a=0;if(u===`right`?a+=c-h:u===`center`?a+=c/2-h/2:u===`justify`&&(e.whitespace||e instanceof V)&&(o+=g),n.fillText(e.value,o+a,s+r),e.font.href){n.beginPath(),n.strokeStyle=n.fillStyle;let t=Math.floor(s+i*.45)+.5;m||=[o+a,t],n.moveTo(...m),n.lineTo(o+a+e.width,t),n.stroke()}else m=null;o+=e.width}})}var Oi=Object.prototype.hasOwnProperty,ki={};function Ai(e){return ki[e]||(ki[e]=e.replace(/([a-z])([A-Z])/g,(e,t,n)=>t+`-`+n.toLowerCase())),ki[e]}function ji(e,t){if(Array.isArray(t))t.forEach(t=>ji(e,t));else if(typeof t==`string`){let n=document.createTextNode(t);e.appendChild(n)}else e.appendChild(t)}function Mi(e,t,...n){if(typeof document>`u`)throw Error(`No document found, cannot create elements`);let r=typeof e==`string`?document.createElementNS(`http://www.w3.org/2000/svg`,e):e;if(t&&r.setAttribute)for(let e in t)Oi.call(t,e)&&t[e]!=null&&r.setAttribute(e===`className`?`class`:Ai(e),String(t[e]));return n!=null&&n.length&&n.forEach(e=>{e&&ji(r,e)}),r}var Ni=/^[\n\r\t\x20\xA0\u2000-\u200B\u205F\u3000]/,Pi=/^[^\n\r\t\u0020\u2000-\u200B\u205F\u3000]{2,}/,Fi=/^[\xA0\u2011\u202F\u2060\uFEFF]/,Ii=/^(?:[;\xAD%?…]|,(?!\d))/,Li=/^[´±°¢£¤$¥\u2212]/,Ri=`'“‘[「【﹝〔<‹«{『((<《`.split(``),zi=`',,,!!??”]」】》>’»﹞〕〗〉}))』。`.split(``),Bi=e=>{let t=e.charCodeAt(0);return t>=19968&&t<=40959};function Vi(e){e||=``;let t=[],n=e.charAt(0),r=``,i=``,a=0;for(let o=1,s=e.length;o<s;o++){r=e.charAt(o),i=e.charAt(o+1);let s=Ni.test(n),c=Ni.test(r),l=c||s||Bi(n)||Bi(r);if((Li.test(r)&&!Fi.test(n)||Ii.test(n+i)&&!Fi.test(r))&&(l=!0),l&&(zi.includes(r)||Ri.includes(n))&&(l=!1),n===`-`||n===`‐`||n===`–`||n===`—`){let t=Ni.test(e.charAt(o-2));t&&!c&&(l=!1),!t&&Pi.test(r+i)&&(l=!0)}if(l){let n=e.slice(a,o);n.endsWith(``)?(t.push(new B(n.slice(0,-1))),t.push(new pi)):(t.push(new B(n)),t.push(new fi)),a=o}n=r}return t.push(new B(e.slice(a))),t}var Hi={nbsp:`\xA0`,iexcl:`¡`,cent:`¢`,pound:`£`,curren:`¤`,yen:`¥`,brvbar:`¦`,sect:`§`,uml:`¨`,copy:`©`,ordf:`ª`,laquo:`«`,not:`¬`,shy:``,reg:`®`,macr:`¯`,deg:`°`,plusmn:`±`,sup2:`²`,sup3:`³`,acute:`´`,micro:`µ`,para:`¶`,middot:`·`,cedil:`¸`,sup1:`¹`,ordm:`º`,raquo:`»`,frac14:`¼`,frac12:`½`,frac34:`¾`,iquest:`¿`,Agrave:`À`,Aacute:`Á`,Acirc:`Â`,Atilde:`Ã`,Auml:`Ä`,Aring:`Å`,AElig:`Æ`,Ccedil:`Ç`,Egrave:`È`,Eacute:`É`,Ecirc:`Ê`,Euml:`Ë`,Igrave:`Ì`,Iacute:`Í`,Icirc:`Î`,Iuml:`Ï`,ETH:`Ð`,Ntilde:`Ñ`,Ograve:`Ò`,Oacute:`Ó`,Ocirc:`Ô`,Otilde:`Õ`,Ouml:`Ö`,times:`×`,Oslash:`Ø`,Ugrave:`Ù`,Uacute:`Ú`,Ucirc:`Û`,Uuml:`Ü`,Yacute:`Ý`,THORN:`Þ`,szlig:`ß`,agrave:`à`,aacute:`á`,acirc:`â`,atilde:`ã`,auml:`ä`,aring:`å`,aelig:`æ`,ccedil:`ç`,egrave:`è`,eacute:`é`,ecirc:`ê`,euml:`ë`,igrave:`ì`,iacute:`í`,icirc:`î`,iuml:`ï`,eth:`ð`,ntilde:`ñ`,ograve:`ò`,oacute:`ó`,ocirc:`ô`,otilde:`õ`,ouml:`ö`,divide:`÷`,oslash:`ø`,ugrave:`ù`,uacute:`ú`,ucirc:`û`,uuml:`ü`,yacute:`ý`,thorn:`þ`,yuml:`ÿ`,fnof:`ƒ`,Alpha:`Α`,Beta:`Β`,Gamma:`Γ`,Delta:`Δ`,Epsilon:`Ε`,Zeta:`Ζ`,Eta:`Η`,Theta:`Θ`,Iota:`Ι`,Kappa:`Κ`,Lambda:`Λ`,Mu:`Μ`,Nu:`Ν`,Xi:`Ξ`,Omicron:`Ο`,Pi:`Π`,Rho:`Ρ`,Sigma:`Σ`,Tau:`Τ`,Upsilon:`Υ`,Phi:`Φ`,Chi:`Χ`,Psi:`Ψ`,Omega:`Ω`,alpha:`α`,beta:`β`,gamma:`γ`,delta:`δ`,epsilon:`ε`,zeta:`ζ`,eta:`η`,theta:`θ`,iota:`ι`,kappa:`κ`,lambda:`λ`,mu:`μ`,nu:`ν`,xi:`ξ`,omicron:`ο`,pi:`π`,rho:`ρ`,sigmaf:`ς`,sigma:`σ`,tau:`τ`,upsilon:`υ`,phi:`φ`,chi:`χ`,psi:`ψ`,omega:`ω`,thetasym:`ϑ`,upsih:`ϒ`,piv:`ϖ`,bull:`•`,hellip:`…`,prime:`′`,Prime:`″`,oline:`‾`,frasl:`⁄`,weierp:`℘`,image:`ℑ`,real:`ℜ`,trade:`™`,alefsym:`ℵ`,larr:`←`,uarr:`↑`,rarr:`→`,darr:`↓`,harr:`↔`,crarr:`↵`,lArr:`⇐`,uArr:`⇑`,rArr:`⇒`,dArr:`⇓`,hArr:`⇔`,forall:`∀`,part:`∂`,exist:`∃`,empty:`∅`,nabla:`∇`,isin:`∈`,notin:`∉`,ni:`∋`,prod:`∏`,sum:`∑`,minus:`−`,lowast:`∗`,radic:`√`,prop:`∝`,infin:`∞`,ang:`∠`,and:`⊥`,or:`⊦`,cap:`∩`,cup:`∪`,int:`∫`,there4:`∴`,sim:`∼`,cong:`≅`,asymp:`≈`,ne:`≠`,equiv:`≡`,le:`≤`,ge:`≥`,sub:`⊂`,sup:`⊃`,nsub:`⊄`,sube:`⊆`,supe:`⊇`,oplus:`⊕`,otimes:`⊗`,perp:`⊥`,sdot:`⋅`,lceil:`⌈`,rceil:`⌉`,lfloor:`⌊`,rfloor:`⌋`,lang:`〈`,rang:`〉`,loz:`◊`,spades:`♠`,clubs:`♣`,hearts:`♥`,diams:`♦`,quot:`"`,amp:`&`,lt:`<`,gt:`>`,OElig:`Œ`,oelig:`œ`,Scaron:`Š`,scaron:`š`,Yuml:`Ÿ`,circ:`ˆ`,tilde:`˜`,ensp:` `,emsp:` `,thinsp:` `,zwnj:``,zwj:``,lrm:``,rlm:``,ndash:`–`,mdash:`—`,lsquo:`‘`,rsquo:`’`,sbquo:`‚`,ldquo:`“`,rdquo:`”`,bdquo:`„`,dagger:`†`,Dagger:`‡`,permil:`‰`,lsaquo:`‹`,rsaquo:`›`},Ui=-.3,Wi=.45,Gi=.7,Ki={weight:400,style:`normal`,variant:`normal`,baseline:0,tracking:0,href:``},qi=/^[\n\r\x20\u2000-\u200B\u205F\u3000]/,Ji=class{tokens;stack;props;constructor(){this.tokens=[],this.stack=[],this.props={...Ki}}add_token(e){return e.font=this.props,this.tokens.push(e),e}open_context(){this.stack.push(this.props),this.props=Object.create(this.props)}close_context(){if(!this.stack.length)throw Error(`Unexpected }`);this.props=this.stack.pop()}trimEnd(){let e=this.tokens[this.tokens.length-1];for(;e instanceof V;)this.tokens.pop(),e=this.tokens[this.tokens.length-1]}setProps(e){for(let[t,n]of Object.entries(e))n!=null&&(this.props[t]=n)}maybeLineBreak(e){let t=this.tokens.length;if(t>0&&e&&e>0){let n=t-1;for(;this.tokens[n]&&(this.tokens[n]instanceof fi||qi.test(this.tokens[n].value));)n--;for(;e&&this.tokens[n]&&this.tokens[n]instanceof V;)n--,e--;for(;e-->0;)this.tokens.push(new V)}}},Yi=/^<\/([a-zA-Z0-9]+)([^>]*)>/,Xi=/^<([a-zA-Z0-9]+)((?:\s[^=\s/]+(?:\s*=\s*(?:"[^"]+"|'[^']+'|[^>\\s]+))?)+)?\s*(\/?)>(\n*)/,Zi=/^<!--(.+?)-->/,Qi=/&(?:#(\d\d{2,})|#x([\da-fA-F]{2,})|([a-zA-Z][a-zA-Z1-4]{1,8}));/g,$i={b:e=>e.weight=700,strong:e=>e.weight=700,i:e=>e.style=`italic`,em:e=>e.style=`italic`,dfn:e=>e.style=`italic`,cite:e=>e.style=`italic`,code:e=>e.family=`monospace`,kbd:e=>e.family=`monospace`,samp:e=>e.family=`monospace`,var:e=>e.family=`monospace`,tt:e=>e.family=`monospace`,sub:e=>{e.baseline=Ui,e.sizeAdjust=Gi},sup:e=>{e.baseline=Wi,e.sizeAdjust=Gi}},ea={div:1,li:1,blockquote:2,h1:2,h2:2,h3:2,h4:2,h5:2,h6:2,ul:2,ol:2,hr:2,p:2};function ta(e){return e.replace(Qi,function(e,t,n,r){if(t||n){let e=t?10:16;return String.fromCharCode(parseInt(t||n,e))}else if(r in Hi)return Hi[r];return e})}function na(e){return e&&e.length>1&&(e.startsWith(`"`)&&e.endsWith(`"`)||e.startsWith(`'`)&&e.endsWith(`'`))?e.slice(1,-1):e}var ra=/^\s*([^=\s&]+)(?:\s*=\s*("[^"]+"|'[^']+'|[^>\s]+))?/;function ia(e){let t,n={};if(e){do if(t=ra.exec(e),t){let r=ta(na(t[2]||``)).replace(/[ \r\n\t]+/g,` `).trim();if(n[t[1]]=r,e=e.slice(t[0].length),e.length&&/^\S/.test(e[0]))throw Error(`Attribute error`)}while(t&&e.length);if(/\S/.test(e))throw Error(`Attribute error`)}return n}function aa(e){e=String(e||``).trim();let t,n,r=new Ji;for(;e.length;){if(t=/^[^<]+/.exec(e))Vi(ta(t[0])).forEach(e=>r.add_token(e));else if(!(t=Zi.exec(e)))if(t=Yi.exec(e))r.close_context(),r.maybeLineBreak(ea[t[1]]);else if(t=Xi.exec(e)){let e=t[1];r.maybeLineBreak(ea[e]),r.open_context(),$i[e]&&$i[e].call(r,r.props);let i=ia(t[2]);e===`a`&&r.setProps({href:i.href,rel:i.rel,target:i.target}),i.class&&(r.props.class=r.props.class?r.props.class+` `+i.class:i.class),i.style&&(n=/(?:^|\s|;)color\s*:\s*([^;\s"']+)/.exec(i.style),n&&n[1]&&(r.props.color=n[1])),e===`br`&&r.tokens.push(new V)}else t=[e.slice(0,1)],r.add_token(new B(t[0]));e=e.slice(t[0].length)}return r.trimEnd(),r.tokens}var oa={copyright:`©`,textcopyright:`©`,dag:`†`,textdagger:`†`,ddag:`‡`,textdaggerdbl:`‡`,guillemotleft:`«`,guillemotright:`»`,guilsinglleft:`‹`,guilsinglright:`›`,ldots:`…`,dots:`…`,textellipsis:`…`,lq:`‘`,P:`¶`,textparagraph:`¶`,pounds:`£`,textsterling:`£`,quotedblbase:`„`,quotesinglbase:`‚`,rq:`’`,S:`§`,sim:`~`,textasciicircum:`^`,textasciitilde:`˜`,texttildelow:`~`,textasteriskcentered:`*`,textbackslash:`'`,textbar:`|`,textbardbl:`╎`,textbigcircle:`◯`,textbraceleft:`{`,textbraceright:`}`,textbullet:`•`,textdollar:`$`,textemdash:`—`,textendash:`—`,texteuro:`€`,eurosym:`€`,euro:`€`,textexclamdown:`¡`,textgreater:`>`,textless:`<`,textordfeminine:`ª`,textordmasculine:`º`,textperiodcentered:`·`,cdot:`·`,textquestiondown:`¿`,textquotedblleft:`“`,textquotedblright:`”`,textquoteleft:`‘`,textquoteright:`’`,textquotestraightbase:`‚`,textquotestraightdblbase:`„`,textregistered:`®`,textthreequartersemdash:`-`,texttrademark:`™`,texttwelveudash:`-`,textunderscore:`_`,textvisiblespace:`␣`,gets:`←`,textleftarrow:`←`,to:`→`,textrightarrow:`→`,textdegree:`°`,infty:`∞`,triangle:`△`,triangledown:`▽`,blacktriangle:`▲`,blacktriangledown:`▼`,angle:`∠`,sphericalangle:`∢`,aleph:`ℵ`,hbar:`ħ`,imath:`𝚤`,jmath:`𝚥`,ell:`ℓ`,wp:`℘`,Re:`ℜ`,Im:`ℑ`,mho:`℧`,prime:`′`,emptyset:`∅`,nabla:`∇`,surd:`√`,partial:`∂`,top:`⟙`,bot:`⟂`,vdash:`⟝`,dashv:`⟞`,forall:`∀`,exists:`∃`,nexists:`∄`,neg:`¬`,lnot:`¬`,flat:`♭`,natural:`♮`,sharp:`♯`,backslash:`\\`,Box:`□`,Diamond:`♢`,clubsuit:`♣`,diamondsuit:`♦`,heartsuit:`♥`,spadesuit:`♠`,Join:`⨝`,blacksquare:`■`,bigstar:`★`,diagdown:`╲`,diagup:`╱`,blacklozenge:`⧫`,rfloor:`⌋`,lfloor:`⌊`,rceil:`⌉`,lceil:`⌈`,rangle:`⟩`,langle:`⟨`,sum:`∑`,int:`∫`,oint:`∮`,prod:`∏`,coprod:`∏`,bigcap:`∩`,bigcup:`∪`,bigsqcup:`⊔`,bigvee:`∨`,bigwedge:`∧`,bigodot:`⊙`,bigotimes:`⊗`,bigoplus:`⊕`,biguplus:`⊎`,alpha:`α`,beta:`β`,chi:`χ`,delta:`δ`,epsilon:`ε`,eta:`η`,gamma:`γ`,iota:`ι`,kappa:`κ`,lambda:`λ`,mu:`μ`,nu:`ν`,omega:`ω`,phi:`φ`,pi:`π`,psi:`ψ`,rho:`ρ`,sigma:`σ`,tau:`τ`,theta:`θ`,upsilon:`υ`,xi:`ξ`,zeta:`ζ`,Alpha:`Α`,Beta:`Β`,Chi:`Χ`,Delta:`Δ`,Epsilon:`Ε`,Eta:`Η`,Gamma:`Γ`,Iota:`Ι`,Kappa:`Κ`,Lambda:`Λ`,Mu:`Μ`,Nu:`Ν`,Omega:`Ω`,Phi:`Φ`,Pi:`Π`,Psi:`Ψ`,Rho:`Ρ`,Sigma:`Σ`,Tau:`Τ`,Theta:`Θ`,Upsilon:`Υ`,Xi:`Ξ`,Zeta:`Ζ`,aa:`å`,AA:`Å`,ae:`æ`,AE:`Æ`,dh:`ð`,DH:`Ð`,dj:`đ`,DJ:`Đ`,ij:`ij`,IJ:`IJ`,l:`ł`,L:`Ł`,ng:`ŋ`,NG:`Ŋ`,o:`ø`,O:`Ø`,oe:`œ`,OE:`Œ`,ss:`ß`,SS:`SS`,th:`þ`,TH:`Þ`},sa=/^(\^|_|\\[^#$%&~_^\\{}()\s]+)(\{)?/,ca=/^%[^\n]+(?:\n|$)/,la=/^[^#$%&~_^\\{}]+/,ua=/^\\([&{}$%#_])/,da=/(?:\\[\\@,!:;-]|-{2,3}|[!?]`|``?|,,|''?|~|<<|>>)/g,fa={"---":`—`,"--":`–`,"!`":`¡`,"?`":`¿`,"``":`“`,",,":`„`,"''":`”`,"`":`‘`,"'":`’`,"<<":`«`,">>":`»`,"~":`\xA0`,"\\-":``,"\\,":` `,"\\;":` `,"\\:":` `,"\\!":` `,"\\@":``,"\\\\":`\\newline{}`},H={bf:e=>e.weight=700,emph:e=>{e.style===`italic`?e.style=`normal`:e.style=`italic`},it:e=>e.style=`italic`,sl:e=>e.style=`italic`,color:(e,t)=>e.color=t,href:(e,t)=>e.href=t,"^":e=>{e.baseline=Wi,e.sizeAdjust=Gi},_:e=>{e.baseline=Ui,e.sizeAdjust=Gi},par:function(){this.tokens.push(new V,new V)},newline:function(){this.tokens.push(new V)},url:function(e,t){this.open_context(),this.props.href=t,this.add_token(new B(t)),this.close_context()}};H.textsuperscript=H[`^`],H.textsubscript=H._,H.textsl=H.sl,H.mathbf=H.bf,H.mathit=H.it,H.textbf=H.bf,H.textit=H.it,H.textcolor=H.color;function pa(e){e=String(e||``).trim();let t=[``];e=e.replace(/\\verb,(.*?),/,(e,n)=>(t.push(n),`\\verb,`+(t.length-1)+`,`)).replace(/\\\\\n/g,()=>`\\\\`).replace(da,(e,t,n)=>n.charAt(t-1)===`\\`?e:fa[e]).replace(/\n\s+/g,e=>e.slice(1).includes(`
|
|
1
|
+
import{C as e,_ as t,a as n,b as r,d as i,f as a,h as o,i as s,m as c,o as l,p as u,r as d,s as f,t as p,u as m,w as h}from"./dist-BJH7vBTb.js";import{Cell as g,CellVertexId as _,FormulaError as v,Matrix as y,NameVertexId as b,RangeVertexId as ee,Reference as x,ValueSnapshot as te,a1ToRowColumn as ne,colFromOffs as re,describeWorkbook as ie,parseReference as ae,unbox as oe,vertexIdToCell as se,vertexIdToReference as ce}from"@grid-is/spreadsheet-engine";import{z as S}from"zod";var C=`operator`,le=`operator-trim`,ue=`bool`,de=`error`,fe=`number`,pe=`func`,me=`newline`,he=`whitespace`,ge=`string`,w=`context_quote`,T=`context`,E=`range`,D=`range_beam`,O=`range_ternary`,k=`range_named`,_e=`structured`,A=`cell`,ve=`fx_prefix`,ye=`unknown`,be=`UnaryExpression`,xe=`BinaryExpression`,Se=`ReferenceIdentifier`,Ce=`Literal`,we=`ErrorLiteral`,Te=`CallExpression`,Ee=`LambdaExpression`,De=`LetExpression`,Oe=`ArrayExpression`,ke=`Identifier`,Ae=`LetDeclarator`,je=2**14-1,j=2**20-1,Me=`$`,Ne=[[A,`:`,A],[A,`.:`,A],[A,`:.`,A],[A,`.:.`,A],[E],[D],[O],[T,`!`,A,`:`,A],[T,`!`,A,`.:`,A],[T,`!`,A,`:.`,A],[T,`!`,A,`.:.`,A],[T,`!`,A],[T,`!`,E],[T,`!`,D],[T,`!`,O],[w,`!`,A,`:`,A],[w,`!`,A,`.:`,A],[w,`!`,A,`:.`,A],[w,`!`,A,`.:.`,A],[w,`!`,A],[w,`!`,E],[w,`!`,D],[w,`!`,O],[k],[T,`!`,k],[w,`!`,k],[_e],[k,_e],[T,`!`,k,_e],[w,`!`,k,_e]],Pe={};function Fe(e,t){if(e.length){let n=e[0];t[n]||(t[n]={}),Fe(e.slice(1),t[n])}else t[Me]=!0}Ne.forEach(e=>Fe(e.concat().reverse(),Pe));var Ie=(e,t,n,r=0)=>{let i=r,a=t,o=e.length-r;for(;i<=o;){let t=e[n-i];if(t){let e=t.value,n=t.type===C?e:t.type;if(n===E&&!e.includes(`:`)&&(n=A),n in a){a=a[n],i+=1;continue}}return a[Me]?i:0}};function Le(e){let t=[];for(let n=e.length-1;n>=0;n--){let r=e[n],i=r.type;if(i===E||i===D||i===O||i===k||i===_e){let t=Ie(e,Pe,n);if(t>1){r={...r,value:``};let i=n-t+1;for(let t=i;t<=n;t++)r.value+=e[t].value;r.loc&&e[i].loc&&(r.loc[0]=e[i].loc[0]),n-=t-1}}t[t.length]=r}return t.reverse()}var Re=/#(?:NAME\?|FIELD!|CALC!|VALUE!|REF!|DIV\/0!|NULL!|NUM!|N\/A|GETTING_DATA\b|SPILL!|UNKNOWN!|SYNTAX\?|ERROR!|CONNECT!|BLOCKED!|EXTERNAL!)/iy,ze=35;function Be(e,t){if(e.charCodeAt(t)===ze){Re.lastIndex=t;let n=Re.exec(e);if(n)return{type:de,value:n[0]}}}var Ve=46,He=58;function Ue(e,t){let n=e.charCodeAt(t);if(n===Ve||n===He){let r=e.charCodeAt(t+1);if(n!==r){if(r===He)return{type:le,value:e.slice(t,t+(e.charCodeAt(t+2)===Ve?3:2))};if(r===Ve)return{type:le,value:e.slice(t,t+2)}}}}function We(e,t){let n=e.charCodeAt(t),r=e.charCodeAt(t+1);if(n===60&&r===61||n===62&&r===61||n===60&&r===62)return{type:C,value:e.slice(t,t+2)};if(n===123||n===125||n===33||n===35||n===37||n===38||n>=40&&n<=45||n===47||n>=58&&n<=62||n===64||n===94)return{type:C,value:e[t]}}function Ge(e){return e>=65&&e<=90||e>=97&&e<=122||e>=48&&e<=57||e===95||e===92||e===40||e===46||e===63||e>160}function Ke(e,t){let n=e.charCodeAt(t);if(n===84||n===116){let n=e.charCodeAt(t+1);if(n===82||n===114){let n=e.charCodeAt(t+2);if(n===85||n===117){let n=e.charCodeAt(t+3);if((n===69||n===101)&&!Ge(e.charCodeAt(t+4)))return{type:ue,value:e.slice(t,t+4)}}}}if(n===70||n===102){let n=e.charCodeAt(t+1);if(n===65||n===97){let n=e.charCodeAt(t+2);if(n===76||n===108){let n=e.charCodeAt(t+3);if(n===83||n===115){let n=e.charCodeAt(t+4);if((n===69||n===101)&&!Ge(e.charCodeAt(t+5)))return{type:ue,value:e.slice(t,t+5)}}}}}}function qe(e,t){let n=t;for(;e.charCodeAt(t)===10;)t++;if(t!==n)return{type:me,value:e.slice(n,t)}}function Je(e){return e===9||e===11||e===12||e===13||e===32||e===160||e===5760||e===8232||e===8233||e===8239||e===8287||e===12288||e===65279||e>=8192&&e<=8202}function Ye(e,t){let n=t;for(;Je(e.charCodeAt(t));)t++;if(t!==n)return{type:he,value:e.slice(n,t)}}var Xe=34;function Ze(e,t){let n=t;if(e.charCodeAt(t)===Xe){for(t++;t<e.length;){if(e.charCodeAt(t)===Xe&&(t++,e.charCodeAt(t)!==Xe))return{type:ge,value:e.slice(n,t)};t++}return{type:ge,value:e.slice(n,t),unterminated:!0}}}var Qe=39,$e=91,et=93,tt=33;function nt(e,t,n){let r=e.charCodeAt(t),i,a;if(r===Qe){let r=t;for(t++;t<e.length;){let o=e.charCodeAt(t);if(o===$e){if(i)return;i=t}else if(o===et){if(a)return;a=t}else if(o===Qe&&(t++,e.charCodeAt(t)!==Qe)){let o=i==null&&a==null;return n.xlsx&&i===r+1&&a===t-2&&(o=!0),i>=r+1&&a<t-2&&a>i+1&&(o=!0),o&&e.charCodeAt(t)===tt?{type:w,value:e.slice(r,t)}:void 0}t++}}}function rt(e,t,n){let r=e.charCodeAt(t),i,a;if(r!==Qe&&r!==tt){let r=t;for(;t<e.length;){let o=e.charCodeAt(t);if(o===$e){if(i)return;i=t}else if(o===et){if(a)return;a=t}else if(o===tt){let o=i==null&&a==null;if(n.xlsx&&i===r&&a===t-1&&(o=!0),i>=r&&a<t-1&&a>i+1&&(o=!0),o)return{type:T,value:e.slice(r,t)}}else if((i==null||a!=null)&&!(o>=65&&o<=90||o>=97&&o<=122||o>=48&&o<=57||o===46||o===95||o===161||o===164||o===167||o===168||o===170||o===173||o>=175))return;t++}}}var it=46,at=58;function ot(e,t){let n=e.charCodeAt(t);if(n===it){if(e.charCodeAt(t+1)===at)return e.charCodeAt(t+2)===it?3:2}else if(n===at)return e.charCodeAt(t+1)===it?2:1;return 0}function st(e,t){let n=e.charCodeAt(t);return!(n>=65&&n<=90||n>=97&&n<=122||n>=48&&n<=57||n===95||n===40||n>160)}function ct(e,t){let n=e.charCodeAt(t);return!(n>=65&&n<=90||n>=97&&n<=122||n>=48&&n<=57||n===95||n===40||n===36||n===46||n===33)}function lt(e,t){let n=t;e.charCodeAt(t)===36&&t++;let r=t+3,i=0;do{let n=e.charCodeAt(t);if(n>=65&&n<=90)i=26*i+n-64,t++;else if(n>=97&&n<=122)i=26*i+n-96,t++;else break}while(t<r&&t<e.length);return i&&i<=je+1?t-n:0}function ut(e,t){let n=t;e.charCodeAt(t)===36&&t++;let r=t+7,i=0,a=e.charCodeAt(t);if(a>=49&&a<=57){i=i*10+a-48,t++;do if(a=e.charCodeAt(t),a>=48&&a<=57)i=i*10+a-48,t++;else break;while(t<r&&t<e.length)}return i&&i<=j+1?t-n:0}function dt(e,t,n){let r=t,i=lt(e,r),a=0,o=0;if(i){r+=i;let s=ut(e,r);r+=s;let c=ot(e,r),l=r;if(c){if(r+=c,a=lt(e,r),r+=a,o=ut(e,r),r+=o,s&&o&&a){if(st(e,r)&&n.mergeRefs)return{type:E,value:e.slice(t,r)}}else if(!s&&!o){if(st(e,r))return{type:D,value:e.slice(t,r)}}else if(n.allowTernary&&(o||a)&&ct(e,r))return{type:O,value:e.slice(t,r)}}if(s&&st(e,l)&&e.charCodeAt(l)!==33)return{type:E,value:e.slice(t,l)}}else{let i=ut(e,r);if(i){r+=i;let s=ot(e,r);if(s){if(r+=s,a=lt(e,r),a&&(r+=a),o=ut(e,r),r+=o,a&&o&&n.allowTernary&&ct(e,r))return{type:O,value:e.slice(t,r)};if(!a&&o&&st(e,r))return{type:D,value:e.slice(t,r)}}}}}var ft=91,pt=93,mt=82,ht=114,gt=67,_t=99,vt=43,yt=45,bt=33;function xt(e,t,n=!1){let r=t,i=e.charCodeAt(t);if(n?i===mt||i===ht:i===gt||i===_t){t++;let i=0,a=0,o=e.length,s=e.charCodeAt(t),c,l=1,u=s===ft;if(u)o=Math.min(o,t+(n?8:6)),t++,c=e.charCodeAt(t),(c===vt||c===yt)&&(t++,o++,l=c===yt?-1:1);else if(s<49||s>57||isNaN(s))return 1;do{let n=e.charCodeAt(t);if(n>=48&&n<=57)a=a*10+n-48,i++,t++;else break}while(t<o);let d=n?j:je;return u?e.charCodeAt(t)===pt?(t++,a*=l,i&&-d<=a&&a<=d?t-r:0):0:i&&a<=d+1?t-r:0}return 0}function St(e,t,n){let r=t,i=xt(e,r,!0);r+=i;let a=xt(e,r);if(r+=a,(a||i)&&e.charCodeAt(r)!==bt){let o=ot(e,r),s=r;if(o){r+=o;let s=xt(e,r,!0);r+=s;let c=xt(e,r);if(r+=c,i&&!a&&s&&c||!i&&a&&s&&c||i&&a&&s&&!c||i&&a&&!s&&c){if(n.allowTernary&&st(e,r))return{type:O,value:e.slice(t,r)}}else if((a&&c&&!i&&!s||!a&&!c&&i&&s)&&st(e,r))return{type:D,value:e.slice(t,r)}}if(st(e,s))return{type:i&&a?E:D,value:e.slice(t,s)}}}function Ct(e,t,n){return n.r1c1?St(e,t,n):dt(e,t,n)}var wt=64,Tt=93,Et=91,Dt=58,Ot=44,kt=35,At=39,jt={headers:1,data:2,totals:4,all:8,"this row":16,"@":16},Mt=(...e)=>Object.freeze(e),Nt={0:Mt(),1:Mt(`headers`),2:Mt(`data`),4:Mt(`totals`),8:Mt(`all`),16:Mt(`this row`),3:Mt(`headers`,`data`),6:Mt(`data`,`totals`)};function Pt(e,t){let n=t;if(e.charCodeAt(n++)===Et&&e.charCodeAt(n++)===kt){do{let t=e.charCodeAt(n);if(t>=65&&t<=90||t>=97&&t<=122||t===32)n++;else break}while(n<t+11);if(e.charCodeAt(n++)===Tt)return n-t}}function Ft(e,t){let n=t;for(;Je(e.charCodeAt(n));)n++;return n-t}function It(e,t,n=!0){let r=t,i=``;if(e.charCodeAt(r)===Et){r++;let n;do if(n=e.charCodeAt(r),n===At)if(r++,n=e.charCodeAt(r),n===At||n===kt||n===wt||n===Et||n===Tt)i+=String.fromCharCode(n),r++;else return;else if(n===At||n===kt||n===wt||n===Et)return;else if(n===Tt)return r++,[e.slice(t,r),i];else i+=String.fromCharCode(n),r++;while(r<e.length)}else if(n){let n;do{if(n=e.charCodeAt(r),n===At||n===kt||n===wt||n===Et||n===Tt||n===Dt)break;i+=String.fromCharCode(n),r++}while(r<e.length);if(r!==t)return[i,i]}}function Lt(e,t=0){let n=[],r=t,i,a=0;if(e.charCodeAt(t)!==Et)return;if(i=Pt(e,t)){let n=e.slice(t+2,t+i-1);t+=i;let r=jt[n.toLowerCase()];if(!r)return;a|=r}else if(i=It(e,t,!1))t+=i[0].length,i[1]&&n.push(i[1]);else{let r=!0;for(t++,t+=Ft(e,t);r&&(i=Pt(e,t));){let n=jt[e.slice(t+2,t+i-1).toLowerCase()];if(!n)return;a|=n,t+=i,t+=Ft(e,t),r=e.charCodeAt(t)===Ot,r&&(t++,t+=Ft(e,t))}if(r&&e.charCodeAt(t)===wt&&(a|=jt[`@`],t+=1,r=e.charCodeAt(t)!==Tt),!Nt[a])return;let o=r&&It(e,t,!0);if(o){if(t+=o[0].length,n.push(o[1]),e.charCodeAt(t)===Dt){t++;let r=It(e,t,!0);if(r)t+=r[0].length,n.push(r[1]);else return}r=!1}if(t+=Ft(e,t),r||e.charCodeAt(t)!==Tt)return;t++}let o=Nt[a];return{columns:n,sections:o&&o.concat(),length:t-r,token:e.slice(r,t)}}var Rt=33;function zt(e,t){let n=Lt(e,t);if(n&&n.length){let r=n.length;for(;Je(e.charCodeAt(t+r));)r++;if(e.charCodeAt(t+r)!==Rt)return{type:_e,value:n.token}}}function Bt(e,t){let n=t;do{let n=e.charCodeAt(t);if(n<48||n>57)break;t++}while(t<e.length);return t-n}function Vt(e,t){let n=t,r=Bt(e,t);if(!r)return;if(t+=r,e.charCodeAt(t)===46){t++;let n=Bt(e,t);if(!n)return;t+=n}let i=e.charCodeAt(t);if(i===69||i===101){t++;let n=e.charCodeAt(t);(n===43||n===45)&&t++;let r=Bt(e,t);if(!r)return;t+=r}return{type:fe,value:e.slice(n,t)}}function Ht(e,t){let n=t,r=e.charCodeAt(t);if(r>=65&&r<=90||r>=97&&r<=122||r===95||r===92||r>160)t++;else return;let i;do if(i=e.charCodeAt(t),i>=65&&i<=90||i>=97&&i<=122||i>=48&&i<=57||i===95||i===92||i===46||i===63||i>160)t++;else break;while(isFinite(i));let a=t-n;if(a&&a<255)return r===92&&a<3||a===1&&(r===114||r===82||r===99||r===67)?void 0:{type:k,value:e.slice(n,t)}}var Ut=33;function Wt(e,t,n){if(e.charCodeAt(t)===Ut)return{type:C,value:e[t]};if(!n.r1c1){let n=ot(e,t);if(n)return{type:C,value:e.slice(t,t+n)}}}var Gt=91,Kt=40,qt=33,Jt=32,Yt=new Uint8Array(180-Jt),Xt=1,Zt=2,Qt=4,$t=8,en=16,tn=32,nn=Xt|Zt|Qt,rn=$t|en|tn,an=Xt|$t|Qt|tn;for(let e=Jt;e<180;e++){let t=String.fromCharCode(e),n=/^[a-zA-Z_\\\u00a1-\uffff]$/.test(t),r=/^[a-zA-Z_]$/.test(t),i=/^[a-zA-Z0-9_.\\?\u00a1-\uffff]$/.test(t),a=/^[a-zA-Z0-9_.]$/.test(t),o=/^[a-zA-Z0-9_.¡¤§¨ª\u00ad¯-\uffff]$/.test(t);Yt[e-Jt]=(n?Xt:0)|(i?$t:0)|(r?Zt:0)|(a?en:0)|(o?Qt:0)|(o?tn:0)}function on(e,t,n,r,i){let a=r-n;return i&&a&&a<255?t===92&&a<3||a===1&&(t===114||t===82||t===99||t===67)?void 0:{type:k,value:e.slice(n,r)}:{type:ye,value:e.slice(n,r)}}function sn(e,t,n){let r=t,i=e.charCodeAt(t),a=i>180?an:Yt[i-Jt];if(a&Qt&&!(a&Xt)&&!(a&Zt)||i===Gt)return rt(e,t,n);if(!(a&nn))return;let o=a&Xt?1:0,s=a&Zt?1:0,c=a&Qt?1:0;t++;let l;do{l=e.charCodeAt(t);let n=i>180?an:Yt[l-Jt]??0;if(n&rn)o&&!(n&$t)&&(o=0),s&&!(n&en)&&(s=0),c&&!(n&tn)&&(c=0);else return l===Kt&&s?{type:pe,value:e.slice(r,t)}:l===qt&&c?{type:T,value:e.slice(r,t)}:on(e,i,r,t,o);t++}while((o||s||c)&&t<e.length);if(r!==t)return on(e,i,r,t,o)}var cn=[Be,Ue,We,qe,Ye,Ze,Ct,Vt,Ke,nt,sn,zt],ln=[Wt,nt,rt,Ct,zt,Ht];function un(e){return e===`r`||e===`R`||e===`c`||e===`C`}var dn=/^l(?:ambda|et)$/i,fn=(e,t)=>e&&e.type===t,pn=e=>e===k||e===pe,mn=e=>!fn(e,C)||e.value===`%`||e.value===`}`||e.value===`)`||e.value===`#`;function hn(e,t){let n=0,r=0,i;for(let a of e){let e=a.type;e===C?a.value===`(`?(r++,i.type===pe&&dn.test(i.value)&&(n=r)):a.value===`)`&&(r--,r<n&&(n=0)):(n&&e===ye&&un(a.value)||n&&t&&e===D&&un(a.value))&&(a.type=k),i=a}return e}function gn(e,t,n={}){let{withLocation:r=!1,mergeRefs:i=!0,negativeNumbers:a=!0}=n,o={withLocation:r,mergeRefs:i,allowTernary:n.allowTernary??!1,negativeNumbers:a,r1c1:n.r1c1??!1,xlsx:n.xlsx??!1},s=[],c=0,l=0,u=0,d=[],f,p,m,h=e=>{let t=e.type,n=t===ye,i=m&&m.type===ye;m&&(n&&i||n&&pn(m.type)||i&&pn(t))?(m.value+=e.value,m.type=ye,r&&(m.loc[1]=e.loc[1])):(t===le&&(d.push(s.length),t=ye,e.type=ye),s[s.length]=e,m=e,t!==he&&t!==me&&(p=f,f=e))};if(e.startsWith(`=`)){let e={type:ve,value:`=`};r&&(e.loc=[0,1]),c++,h(e)}let g=t.length;for(;c<e.length;){let n=c,i;for(let n=0;n<g;n++)if(i=t[n](e,c,o),i){c+=i.value.length;break}if(i||(i={type:ye,value:e[c]},c++),r&&(i.loc=[n,c]),m&&i.value===`(`&&m.type===pe&&dn.test(m.value)&&l++,i.value.length===1&&(i.type===ye||o.r1c1&&i.type===D)&&(u+=+!!un(i.value)),a&&i.type===fe){let e=m;if(e?.type===C&&e.value===`-`&&(!p||p.type===ve||!mn(p))){let e=s.pop();i.value=`-`+i.value,i.loc&&(i.loc[0]=e.loc[0]),f=p,m=s[s.length-1]}}h(i)}u&&l&&hn(s,o.r1c1);for(let e of d){let t=s[e-1],n=s[e+1];s[e].type=t?.type===E&&n?.type===E?C:ye}return i?Le(s):s}function _n(e,t={}){return gn(e,cn,{withLocation:t.withLocation??!1,mergeRefs:t.mergeRefs??!0,allowTernary:t.allowTernary??!1,negativeNumbers:t.negativeNumbers??!0,r1c1:t.r1c1??!1,xlsx:!0})}function vn(e){return!!e&&(e.type===E||e.type===D||e.type===O||e.type===_e||e.type===k)}function yn(e){return!!e&&(e.type===ue||e.type===de||e.type===fe||e.type===ge)}function bn(e){return!!e&&e.type===de}function xn(e){return!!e&&(e.type===he||e.type===me)}function Sn(e){return!!e&&e.type===pe}function Cn(e){return!!e&&e.type===C}var wn=`(END)`,Tn=`(FUNCTION)`,En=`(WHITESPACE)`,Dn=[`ANCHORARRAY`,`CHOOSE`,`DROP`,`IF`,`IFS`,`INDEX`,`INDIRECT`,`LAMBDA`,`LET`,`OFFSET`,`REDUCE`,`SINGLE`,`SWITCH`,`TAKE`,`TRIMRANGE`,`XLOOKUP`],On={},M,kn,N,An=!1,jn=e=>An||Dn.includes(e.toUpperCase()),Mn=(e,t=!1)=>{let n=(e&&e.value)+``;return!!(vn(e)||t&&Cn(e)&&(n===`:`||n===`,`||!n.trim())||Sn(e)&&jn(n)||bn(e)&&n===`#REF!`)},Nn=e=>!!e&&(e.type===Se||(e.type===we||e.type===de)&&e.value===`#REF!`||e.type===xe&&(e.operator===`:`||e.operator===` `||e.operator===`,`)||vn(e)||e.type===Te&&jn(e.callee.name));function P(e,t=null){let n=Error(e);throw n.source=kn.map(e=>e.value).join(``),n.sourceOffset=kn.slice(0,t??N).reduce((e,t)=>e+t.value.length,0),n}function Pn(e=!1){let t=N,n;do n=kn[++t];while(n&&(xn(n)||Cn(n)&&n.value===`(`));return Mn(n,e)}function F(e=null,t=null){if(e&&e!==M.id&&P(`Expected ${e} but got ${M.id}`),xn(kn[N])){let e=Nn(t),n=e&&Pn(!1),r=e&&kn[N+1]&&kn[N+1].value===`(`;if(!n&&!r)for(;xn(kn[N]);)N++}if(N>=kn.length){M=On[wn];return}let n=kn[N];N+=1,n.unterminated&&P(`Encountered an unterminated token`);let r;return Cn(n)?(r=On[n.value],r||P(`Unknown operator ${n.value}`)):xn(n)?r=On[En]:yn(n)?r=On[Ce]:vn(n)?r=On[Se]:Sn(n)?r=On[Tn]:P(`Unexpected ${n.type} token: ${n.value}`),M=Object.create(r),M.type=n.type,M.value=n.value,n.loc&&(M.loc=[...n.loc]),M}function Fn(e){let t=M;F(null,t);let n=t.nud();for(;e<M.lbp;)t=M,F(null,t),n=t.led(n);return n}var In={nud:()=>P(`Invalid syntax`),led:()=>P(`Missing operator`)};function Ln(e,t=0){let n=On[e];return n?t>=n.lbp&&(n.lbp=t):(n={...In},n.id=e,n.value=e,n.lbp=t,On[e]=n),n}function I(e,t,n){let r=Ln(e,t);return r.led=n||function(e){this.type=xe,this.operator=this.value,delete this.value;let n=Fn(t);return this.arguments=[e,n],this.loc&&=[e.loc[0],n.loc[1]],this},r}function Rn(e,t){let n=Ln(e,0);return n.lbp=70,n.led=t||function(e){return this.type=be,this.operator=this.value,delete this.value,this.arguments=[e],this.loc&&(this.loc[0]=e.loc[0]),this},n}function zn(e,t){let n=Ln(e);return n.nud=t||function(){this.type=be,this.operator=this.value,delete this.value;let e=Fn(70);return this.arguments=[e],this.loc&&(this.loc[1]=e.loc[1]),this},n}function Bn(e,t){return I(e,t,function(n){Nn(n)||P(`Unexpected ${e} operator`);let r=Fn(t);return Nn(r)||P(`Unexpected ${M.type} following ${this.id}`),this.type=xe,this.operator=this.value.trim()?this.value:` `,delete this.value,this.arguments=[n,r],this.loc&&=[n.loc[0],r.loc[1]],this})}Ln(wn),Bn(`:`,80);var Vn=Bn(`,`,80);Bn(En,80);var L=e=>{let t=Vn.lbp>0;return e!=null&&(Vn.lbp=e?80:0),t};Rn(`%`),Rn(`#`,function(e){return Nn(e)||P(`# expects a reference`),this.type=be,this.operator=this.value,delete this.value,this.arguments=[e],this}),zn(`+`),zn(`-`),zn(`@`),I(`^`,50),I(`*`,40),I(`/`,40),I(`+`,30),I(`-`,30),I(`&`,20),I(`=`,10),I(`<`,10),I(`>`,10),I(`<=`,10),I(`>=`,10),I(`<>`,10),Ln(Ce).nud=function(){let{type:e,value:t}=this;if(this.type=Ce,this.raw=t,e===fe)this.value=+t;else if(e===ue)this.value=t.toUpperCase()===`TRUE`;else if(e===de)this.type=we,this.value=t.toUpperCase();else if(e===ge)this.value=t.slice(1,-1).replace(/""/g,`"`);else throw Error(`Unsupported literal type: `+e);return this},Ln(Se).nud=function(){return this.type===k?this.kind=`name`:this.type===_e?this.kind=`table`:this.type===D?this.kind=`beam`:this.kind=`range`,this.type=Se,this},Ln(`)`),zn(`(`,function(){let e=L(!0),t=Fn(0);return F(`)`,t),L(e),t}),Ln(Tn).nud=function(){return this},I(`(`,90,function(e){let t={type:ke,name:e.value};e.id!==Tn&&(e.type===Ee||e.type===Te||e.type===De||e.type===Se||e.type===be&&e.value===`#`||e.type===we&&e.value===`#REF!`?t=e:P(`Unexpected call`,N-1));let n=e.value.toLowerCase();if(n===`lambda`)return Hn.call(this,e);if(n===`let`)return Un.call(this,e);let r=[],i=!1;if(M.id!==`)`){let e=L(!1);for(;M.id!==`)`;)if(xn(M)&&F(),M.id===`,`)r.push(null),i=!0,F();else{let e=Fn(0);r.push(e),i=!1,M.id===`,`&&(F(`,`),i=!0)}L(e)}i&&r.push(null);let a=M;return delete this.value,this.type=Te,this.callee=t,e.loc&&(this.callee.loc=[...e.loc]),this.arguments=r,e.loc&&(this.loc=[e.loc[0],a.loc[1]]),F(`)`,this),this});function Hn(e){let t=[],n={},r,i=!1,a=L(!1);if(M.id!==`)`)for(;!i;){xn(M)&&F();let e=N,a=Fn(0);if(M.id===`,`){if(a.type===Se&&a.kind===`name`){let e=a.value.toLowerCase();e in n&&P(`Duplicate name: `+a.value),n[e]=1;let r={type:ke,name:a.value};a.loc&&(r.loc=a.loc),t.push(r)}else N=e,P(`LAMBDA argument is not a name`);F(`,`)}else r=a,i=!0}return L(a),delete this.value,this.type=Ee,this.params=t,this.body=r||null,e.loc&&(this.loc=[e.loc[0],M.loc[1]]),F(`)`,this),this}function Un(e){let t=[],n=[],r={},i,a=0,o=(e,o)=>{if(i&&P(`Unexpected argument following calculation`),o&&a>=2)i=e;else if(a%2)n.push(e);else if(e&&e.type===Se&&e.kind===`name`){let n=e.value.toLowerCase();n in r&&P(`Duplicate name: `+e.value),r[n]=1,t.push({type:ke,name:e.value,loc:e.loc})}else a>=2?i=e:P(`Argument is not a name`);a++},s=L(!1),c=!1;if(M.id!==`)`){for(;M.id!==`)`;)xn(M)&&F(),M.id===`,`?(o(null),c=!0,F()):(o(Fn(0),M.id!==`,`),c=!1,M.id===`,`&&(F(`,`),c=!0));L(s)}c&&o(null,!0),i===void 0&&P(`Unexpected end of arguments`),L(s),delete this.value,this.type=De,this.declarations=[],t.length||P(`Unexpected end of arguments`);for(let e=0;e<t.length;e++){let r={type:Ae,id:t[e],init:n[e],loc:t[e].loc&&[t[e].loc[0],n[e].loc[1]]};this.declarations.push(r)}return this.body=i,e.loc&&(this.loc=[e.loc[0],M.loc[1]]),F(`)`,this),this}Ln(`}`),Ln(`;`),zn(`{`,function(){M.id===`}`&&P(`Unexpected empty array`);let e=[],t=!1,n=[e],r=L(!1);for(;!t;)xn(M)&&F(),yn(M)?(e.push(On[Ce].nud.call(M)),F()):P(`Unexpected ${M.type} in array: ${M.value}`),M.id===`,`?F(`,`):M.id===`;`?(F(`;`),e=[],n.push(e)):t=!0;let i=M;return F(`}`),L(r),this.type=Oe,this.elements=n,this.loc&&(this.loc[1]=i.loc[1]),delete this.value,this});var Wn=/[^0-9A-Za-z._¡¤§¨ª\u00ad¯-\uffff]/,Gn=/^(R|C|RC|[A-Z]{1,3}\d{1,7})$/i;function Kn(e,t=0){return t||e&&(Wn.test(e)||Gn.test(e)||/^\d/.test(e))?1:0}function qn(e){return`'`+e.replace(/'/g,`''`)+`'`}function Jn(e){let t=``,n=0,{workbookName:r,sheetName:i}=e;return r&&(t+=`[`+r+`]`,n+=Kn(r)),i&&(t+=i,n+=Kn(i)),n&&(t=qn(t)),t&&t+`!`}function Yn(e){return e===`both`?`.:.`:e===`head`?`.:`:e===`tail`?`:.`:`:`}var Xn=(e,t,n)=>Math.min(Math.max(t,e),n);function Zn(e,t){return t?String(e+1):e?`[`+e+`]`:``}function Qn(e){let{r0:t,c0:n,r1:r,c1:i}=e,{$c0:a,$c1:o,$r0:s,$r1:c}=e,l=t==null,u=n==null,d=r==null,f=i==null,p=Yn(e.trim),m=!!e.trim;if(t=Xn(s?0:-j,t|0,j),n=Xn(a?0:-je,n|0,je),!l&&d&&!u&&f?(r=t,d=!1,i=n,f=!1):(r=Xn(c?0:-j,r|0,j),i=Xn(o?0:-je,i|0,je)),t===0&&r>=j&&!u&&!f||l&&d){let e=Zn(n,a),t=Zn(i,o);return`C`+(e===t&&!m?e:e+p+`C`+t)}if(n===0&&i>=je&&!l&&!d||u&&f){let e=Zn(t,s),n=Zn(r,c);return`R`+(e===n&&!m?e:e+p+`R`+n)}let h=Zn(t,s),g=Zn(r,c),_=Zn(n,a),v=Zn(i,o);return l||d||u||f?(l?``:`R`+h)+(u?``:`C`+_)+p+(d?``:`R`+g)+(f?``:`C`+v):h!==g||_!==v?`R`+h+`C`+_+p+`R`+g+`C`+v:`R`+h+`C`+_}function $n(e){return Jn(e)+(`name`in e?e.name:Qn(e.range))}var er=36,tr=46,nr=58,rr=97,ir=65,ar=122,or=90,sr=48,cr=49,lr=57;function ur(e,t){let n=e.charCodeAt(t);if(n===tr){if(e.charCodeAt(t+1)===nr)return e.charCodeAt(t+2)===tr?[3,`both`]:[2,`head`]}else if(n===nr)return e.charCodeAt(t+1)===tr?[2,`tail`]:[1,``];return[0,``]}function dr(e,t){let n=t,r=e.charCodeAt(t)===er;r&&t++;let i=t+3,a=0;do{let n=e.charCodeAt(t);if(n>=ir&&n<=or)a=26*a+n-(ir-1),t++;else if(n>=rr&&n<=ar)a=26*a+n-(rr-1),t++;else break}while(t<i&&t<e.length);return a&&a<=je+1?[t-n,a-1,r]:[0,0,!1]}function fr(e,t){let n=t,r=e.charCodeAt(t)===er;r&&t++;let i=t+7,a=0,o=e.charCodeAt(t);if(o>=cr&&o<=lr){a=a*10+o-sr,t++;do if(o=e.charCodeAt(t),o>=sr&&o<=lr)a=a*10+o-sr,t++;else break;while(t<i&&t<e.length)}return a&&a<=j+1?[t-n,a-1,r]:[0,0,!1]}function pr(e,t,n,r,i,a,o,s,c){o!=null&&(n==null||n!=null&&o<n)&&([n,o,r,s]=[o,n,s,r]),i!=null&&(e==null||e!=null&&i<e)&&([e,i,t,a]=[i,e,a,t]);let l={top:e,left:n,bottom:i,right:o,$top:t,$left:r,$bottom:a,$right:s};return c&&(l.trim=c),l}function mr(e,t=!0){let n=0,[r,i,a]=dr(e,n),o=0,s=!1,c=0,l=!1,u,d;if(r){n+=r;let[f,p,m]=fr(e,n);n+=f;let[h,g]=ur(e,n);if(h){if(n+=h,[u,o,s]=dr(e,n),n+=u,[d,c,l]=fr(e,n),n+=d,f&&d&&u){if(n===e.length)return pr(p,m,i,a,c,l,o,s,g)}else if(!f&&!d){if(n===e.length)return pr(null,!1,i,a,null,!1,o,s,g)}else if(t&&(d||u)&&n===e.length)return f?d?pr(p,m,i,a,c,l,null,!1,g):pr(p,m,i,a,null,!1,o,s,g):pr(null,!1,i,a,c,l,o,s,g)}if(f&&n===e.length)return pr(p,m,i,a,p,m,i,a,g)}else{let[r,i,a]=fr(e,n);if(r){n+=r;let[f,p]=ur(e,n);if(f){if(n+=f,[u,o,s]=dr(e,n),n+=u,[d,c,l]=fr(e,n),n+=d,u&&d&&t){if(n===e.length)return pr(i,a,null,!1,c,l,o,s,p)}else if(!u&&d&&n===e.length)return pr(i,a,null,!1,c,l,null,!1,p)}}}}function hr(e){let t=``;for(let n of e)t+=n.value;return t}function gr(e){let t={type:e.type,value:e.value};return e.loc&&(t.loc=[e.loc[0],e.loc[1]]),e.unterminated!=null&&(t.unterminated=e.unterminated),typeof e.index==`number`&&(t.index=e.index,typeof e.groupId==`string`&&(t.groupId=e.groupId),typeof e.depth==`number`&&(t.depth=e.depth),typeof e.error==`boolean`&&(t.error=e.error)),t}function _r(e,t=!1){let n=!1,r=``,i=[],a=()=>{r&&i.push(t?r:{value:r,braced:n}),r=``};for(let t=0;t<e.length;t++){let i=e[t];i===`[`?(a(),n=!0):i===`]`?(a(),n=!1):r+=i}return a(),i}function vr(e,t,n){let r=_r(e,!n);if(n){if(r.length>1)t.workbookName=r[r.length-2].value,t.sheetName=r[r.length-1].value;else if(r.length===1){let e=r[0];e.braced?t.workbookName=e.value:t.sheetName=e.value}}else t.context=r}var yr=e=>e.slice(1,-1).replace(/''/g,`'`),br=(e,t)=>{let n=e?.value;if(n===`:`||n===`.:`||n===`:.`||n===`.:.`)return t.operator=n,1},xr=(e,t)=>{if(e?.type===E)return t.r0=e.value,1},Sr=(e,t)=>{if(e?.type===O)return t.r0=e.value,1},Cr=(e,t)=>{if(e?.type===E)return t.r1=e.value,1},wr=e=>{if(e?.type===C&&e.value===`!`)return 1},Tr=(e,t)=>{if(e?.type===D)return t.r0=e.value,1},Er=(e,t)=>{if(e.type===_e)return t.struct=e.value,1},Dr=(e,t,n)=>{let r=e?.type;if(r===T)return vr(e.value,t,n),1;if(r===w)return vr(yr(e.value),t,n),1},Or=(e,t)=>{if(e?.type===k)return t.name=e.value,1},kr=[[Sr],[xr,br,Cr],[xr],[Tr],[Dr,wr,Sr],[Dr,wr,xr,br,Cr],[Dr,wr,xr],[Dr,wr,Tr]],Ar=kr.concat([[Or],[Dr,wr,Or],[Er],[Or,Er],[Dr,wr,Or,Er]]);function jr(e,t={}){let n={withLocation:t.withLocation??!1,mergeRefs:t.mergeRefs??!1,allowTernary:t.allowTernary??!1,allowNamed:t.allowNamed??!0,r1c1:t.r1c1??!1,xlsx:!0},r=gn(e,ln,n);r.length&&r[0].type===ve&&r.shift();let i=n.allowNamed?Ar:kr;for(let e of i)if(e.length===r.length){let t={workbookName:``,sheetName:``,r0:``,r1:``,name:``,struct:``,operator:``};if(e.every((e,n)=>e(r[n],t,!0)))return t}}var Mr=/^l(?:ambda|et)$/i,Nr=(e,t,n)=>t==null?null:e?t:t-n,Pr=e=>e.slice(1,-1).replace(/''/g,`'`);function Fr(e){let t=e.lastIndexOf(`!`),n={};return t>-1?(e.startsWith(`'`)?vr(Pr(e.slice(0,t)),n,!0):vr(e.slice(0,t),n,!0),n.range=mr(e.slice(t+1))):n.range=mr(e),n}function Ir(e,t){let n=mr(t);if(!n)throw Error(`translateTokensToR1C1 got an invalid anchorCell: `+t);let{top:r,left:i}=n,a=0,o=0,s=0,c=[];for(let t of e){let e=t?.type;if(e===C)if(t.value===`(`){o++;let e=c[c.length-1];e&&e.type===pe&&Mr.test(e.value)&&(a=o)}else t.value===`)`&&(o--,o<a&&(a=0));if(e===E||e===D||e===O){t=gr(t);let e=t.value,n=Fr(e);if(n){let e=n.range,o={};o.r0=Nr(e.$top,e.top,r),o.r1=Nr(e.$bottom,e.bottom,r),o.c0=Nr(e.$left,e.left,i),o.c1=Nr(e.$right,e.right,i),o.$r0=e.$top,o.$r1=e.$bottom,o.$c0=e.$left,o.$c1=e.$right,e.trim&&(o.trim=e.trim),n.range=o;let s=$n(n);un(s)&&a&&(s+=`[0]`),t.value=s}t.loc&&(t.loc[0]+=s,s+=t.value.length-e.length,t.loc[1]+=s)}else s&&t.loc&&(t=gr(t),t.loc[0]+=s,t.loc[1]+=s);c[c.length]=t}return c}function Lr(e,t,n={}){if(typeof e==`string`)return hr(Ir(_n(e,{mergeRefs:!1,allowTernary:n.allowTernary??!0}),t));throw Error(`translateFormulaToA1 expects a formula string`)}var Rr=String.fromCharCode;function zr(e){return(e>=702?Rr(((e-702)/676-0)%26+65):``)+(e>=26?Rr((e/26-1)%26+65):``)+Rr(e%26+65)}var Br=(e,t,n)=>Math.min(Math.max(t,e),n),R=(e,t)=>(t?`$`:``)+zr(e),z=(e,t)=>(t?`$`:``)+Vr(e),Vr=e=>String(e+1);function Hr(e){let{top:t,left:n,bottom:r,right:i,trim:a}=e,{$left:o,$right:s,$top:c,$bottom:l}=e,u=n==null,d=i==null,f=t==null,p=r==null;t=Br(0,t|0,j),n=Br(0,n|0,je),!u&&!f&&d&&p?(r=t,i=n):(r=Br(0,r|0,j),i=Br(0,i|0,je));let m=Yn(a);return t===0&&r>=j&&!u&&!d&&(!(o&&!u||s&&!d)||n===i)||f&&p?R(n,o)+m+R(i,s):n===0&&i>=je&&!f&&!p&&(!(c&&!f||l&&!p)||t===r)||u&&d?z(t,c)+m+z(r,l):!u&&!f&&!d&&p?R(n,o)+z(t,c)+m+R(i,s):!u&&f&&!d&&!p?R(n,o)+z(r,l)+m+R(i,s):!u&&!f&&d&&!p?R(n,o)+z(t,c)+m+z(r,l):u&&!f&&!d&&!p?R(i,s)+z(t,c)+m+z(r,l):i!==n||r!==t||s!==o||l!==c?R(n,o)+z(t,c)+m+R(i,s)+z(r,l):R(n,o)+z(t,c)}function Ur(e){return Jn(e)+(`name`in e?e.name:Hr(e.range))}function Wr(e,{allowNamed:t=!0,allowTernary:n=!1}={}){let r=jr(e,{allowNamed:t,allowTernary:n,r1c1:!1});if(r){if(r.name)return{workbookName:r.workbookName,sheetName:r.sheetName,name:r.name};if(r.r0&&r.r0){let e=mr(r.r1?r.r0+r.operator+r.r1:r.r0);if(e)return{workbookName:r.workbookName,sheetName:r.sheetName,range:e}}}}Object.freeze({OPERATOR:C,BOOLEAN:ue,ERROR:de,NUMBER:fe,FUNCTION:pe,NEWLINE:me,WHITESPACE:he,STRING:ge,CONTEXT:T,CONTEXT_QUOTE:w,REF_RANGE:E,REF_BEAM:D,REF_TERNARY:O,REF_NAMED:k,REF_STRUCT:_e,FX_PREFIX:ve,UNKNOWN:ye}),Object.freeze({UNARY:be,BINARY:xe,REFERENCE:Se,LITERAL:Ce,ERROR:we,CALL:Te,ARRAY:Oe,IDENTIFIER:ke,LAMBDA:Ee,LET:De,LET_DECL:Ae});var Gr={"\n":.28,"\r":.28," ":.28,"\xA0":.28," ":.28,"":0," ":.5," ":1," ":.5," ":1," ":.33," ":.25," ":.16," ":.56," ":.28," ":.2," ":.15,"":0," ":.16," ":.22," ":1,"":0},Kr=/^((?:[a-z\d-]+\s+)*)([\d.]+(%|em|px)|(?:x+-)?large|(?:x+-)?small|medium)(?:\s*\/\s*(normal|[\d.]+(%|px|em)?))?(\s.+)?$/,qr=/\bsmall-caps\b/,Jr=/\b(?:italic|oblique)\b/,Yr=/\bbold(?:er)?\b/,Xr=16,Zr=13.3333333,Qr=.01*Xr,$r={"xx-small":9,"x-small":10,smaller:13.3333,small:13,medium:16,large:18,larger:19.2,"x-large":24,"xx-large":32},ei=new Map;function ti(e){if(ei.has(e))return ei.get(e);let t=Kr.exec(e);if(!t)return{};let n=(t[6]||``).trim(),r=$r[t[2]]||parseFloat(t[2]);t[3]===`%`?r*=Qr:t[3]===`em`?r*=Xr:t[3]===`pt`&&(r*=Zr);let i;i=t[4]===`normal`||t[4]===`inherit`||!t[4]?Math.round(7/6*r):!t[5]||t[5]===`em`?parseFloat(t[4]||``)*r:t[5]===`pt`?parseFloat(t[4]||``)*Zr:t[5]===`%`?r*.01:parseFloat(t[4]||``);let a=qr.test(t[1])?`small-caps`:`normal`,o=Jr.test(t[1])?`italic`:`normal`,s=400;if(Yr.test(t[1]))s=700;else{let e=/\b(\d+)\b/.exec(t[1]),n=e?parseInt(e[1],10):400;s=n>=100&&n!==400?n:400}let c={family:n,size:r,height:i??7/6*r,weight:s,variant:a,style:o};return ei.set(e,c),c}function ni(e,t){let n=``;if(e.style&&e.style!==`normal`&&(n+=e.style),e.variant&&e.variant!==`normal`&&(n+=(n?` `:``)+e.variant),e.weight&&e.weight!==400&&(n+=n?` `:``,e.weight===700?n+=`bold`:n+=e.weight),e.size){let r=e.size;!t&&e.sizeAdjust&&e.sizeAdjust!==1&&(r*=e.sizeAdjust),n+=(n?` `:``)+r+`px`,e.height!==e.size&&(n+=`/`+e.height+`px`)}return e.family&&(n+=(n?` `:``)+e.family),t&&(n+=`::`+e.baseline),t&&(n+=`::`+e.color),t&&(n+=`::`+e.tracking),t&&(n+=`::`+(e.sizeAdjust??``)),n}var ri=ti(`12px/14px sans-serif`),ii={trim:!0,collapse:!0},ai={};function oi(){return(e,t)=>{let n=typeof t==`string`?ti(t):t,r=n.size??12;return n.family&&/\bmonospace\b/.test(n.family)?r*=.6:(r*=.45,n.weight&&n.weight>400&&(r*=1.18)),e.length*r}}function si(e){if(e&&e.getContext){let t=e.getContext(`2d`);if(t&&typeof t.measureText==`function`)return(e,n)=>(t.font=String(n),t.measureText(e).width)}}function ci(){let e=typeof document<`u`?document:null;return typeof OffscreenCanvas<`u`&&new OffscreenCanvas(100,100)||e&&e.createElement&&e.createElement(`canvas`)||null}var li=si(ci())||oi();function ui(e){if(e==null)li=si(ci())||oi();else if(e)li=si(e)||oi();else throw Error(`setMeasureCanvas argument is not a canvas or null`)}function di(e,t,n=ii){t=typeof t==`string`?ti(t):{...ri,...t};let r=Object.assign({},ii,n),i=String(e);if(!i)return 0;if(i in Gr){let e=ni(t,!0)+`/`+i;return e in ai||(ai[e]=li(`_${i}_`,ni(t))-li(`__`,ni(t))),ai[e]}!r.trim||!r.collapse?i=i.replace(/\n/g,` `):r.trim?i=i.replace(/\n/g,` `).trim():r.collapse&&(i=i.replace(/\s+/g,` `));let a=typeof e==`string`?0:e.font.tracking||0;return li(i,ni(t))+(t.size??12)*a}var B=class{value;width;whitespace;font;line;constructor(e=``,t={}){this.value=e,this.font=t,this.width=0}valueOf(){return this.value}toString(){return this.value}toJSON(){let e=this,t={type:`TK`,val:e.value??``};return e.font.style===`italic`&&(t.style=e.font.style),e.font.family&&e.font.family!==`sans-serif`&&(t.font=e.font.family),e.font.weight&&e.font.weight!==400&&(t.weight=e.font.weight),e.font.baseline&&(t[e.font.baseline<0?`sub`:`sup`]=!0),[`href`,`color`,`class`,`target`,`rel`].forEach(n=>{e.font[n]&&(t[n]=e.font[n])}),t}},fi=class extends B{toJSON(){let e=super.toJSON();return e.type=`BR`,delete e.val,e}},V=class extends B{toJSON(){let e=super.toJSON();return e.type=`NL`,delete e.val,e}},pi=class extends B{toJSON(){let e=super.toJSON();return e.type=`SH`,delete e.val,e}},mi=/[\r\n\xA0]+/g;function hi(e,t){return{family:t.family??e.family??`sans-serif`,style:t.style??e.style??`normal`,variant:t.variant??e.variant??`normal`,weight:t.weight??e.weight??400,height:t.height??e.height??14,size:t.size??e.size??12,sizeAdjust:t.sizeAdjust??e.sizeAdjust??void 0,baseline:t.baseline??e.baseline??0,tracking:t.tracking??e.tracking??0,href:t.href??e.href??``,color:t.color??e.color??``,rel:t.rel??e.rel??``,target:t.target??e.target??``,class:t.class??e.class??``}}function gi(e,t,n){let r=e.width,i,a;for(;r+n.width>t&&e.length;)i=e[e.length-1],a=i.width??0,i.width&&i.width>n.width?(i.value=i.value.slice(0,-1),i.width=di(i,i.font),r+=i.width):e.pop(),r-=a;e[e.length-1]instanceof pi&&e.pop(),i&&(i=e[e.length-1]||i||{},n.font=Object.create(i.font),n.font.href=e.length?i.font.href:void 0,n.font.rel=e.length?i.font.rel:void 0,n.font.target=e.length?i.font.target:void 0,e.push(n))}function _i(e){return Object.assign([],{height:0,font:e,width:0,hasOverflow:!1,hasLineOverflow:!1})}function vi(e){let t=new B(e.value);return t.width=e.width??0,t.whitespace=e.whitespace,t.font=e.font,t}function yi(e,t){let n=ti(t.font);if(!e.length)return _i(n);let r=typeof t.height==`function`?t.height:()=>t.height,i=typeof t.width==`function`?t.width:()=>t.width,a=t.overflowLine,o=t.overflowWrap,s={...n,weight:700},c=n.height??n.size??12,l=isFinite(r())?Math.floor(r()/c):1/0;if(!r()&&!i(0)||!l)return _i(n);let u=0,d=0,f=0,p=[],m=[],h=!1;for(;u<e.length&&d<l;){let t=e[u],r=hi(n,t.font);if(t.width=di(t,r),t.font=r,t.line=d,t.whitespace=t.value in Gr,t.value&&=t.value.replace(mi,` `),!(!f&&t.whitespace||h&&t.whitespace))if(t instanceof V)f=0,m=[],p.push(u+1),d++;else if(t instanceof fi||t instanceof pi)m.push({index:u,width:f});else if(t.whitespace||f+t.width<i(d))f+=t.width;else if(m.length){let t,r;do{r=!0,t=m.pop();let a=e[t.index],o;a instanceof pi&&(o=di(`-`,a.font||n),t.width+o>i(d)&&(r=!m.length))}while(!r);p.push(t.index+1),f=0,d++,u=t.index,m=[]}else if(o===`break-word`){let r=i(d);if(f+t.width>r){let i=vi(t);do t.value=t.value.slice(0,-1),t.width=di(t,t.font||n),f+=t.width;while(t.value&&t.width>r);i.value=i.value.slice(t.value.length),e.splice(u+1,0,new fi,i)}p.push(u+1),f=0,d++}else f+=t.width;u++,h=t.whitespace}u!==p[p.length-1]&&p.push(u);let g=0,_=0,v=p.map(t=>{let r=g,i;for(;(i=e[r])&&(i.whitespace||!i.value);)r++;let a=t,o=null;for(;a>r&&(i=e[a-1])&&(i.whitespace||!(i.value||i instanceof pi));)i instanceof V&&(o=i),a--;i instanceof pi&&(i.value=`-`,i.width=di(`-`,i.font||n)),g=t;let s=Object.assign(e.slice(r,a).filter(e=>e.value),{width:0});return o&&s.push(o),s.width=s.reduce((e,t)=>e+(t.width||0),0),s.width>_&&(_=s.width),s}),y=!1;if(a){let e=a===`ellipsis`?`…`:a;v.forEach((t,r)=>{let a=i(r);if(t.width>a){let r=new B(e);r.font=n,r.width=di(e,s),gi(t,a,r),y=!0}})}let b=!1,ee=t.overflow===`ellipsis`?`…`:t.overflow;if(ee&&u!==e.length){let e=i(v.length-1),t=v[v.length-1],r=new B(ee);r.font=n,r.width=di(ee,s),gi(t,e,r),b=!0}else b=!1;return Object.assign(v,{height:v.length*c,font:n,width:_,hasOverflow:b,hasLineOverflow:y})}function bi(e){return Math.round(e*1e6)/1e6}var xi={center:`middle`,right:`end`},Si={middle:.5,center:.5,bottom:1,end:1},Ci=(e,t)=>!e&&!t||e===t;function wi(e,t){let n=[],r=ti(t.font),i=r.size??12,a=r.family??`sans-serif`,o=t.align??`left`,s=t.createElement;if(e.length){let c=r.height??7/6*i,l=t.valign,u=typeof t.height==`function`?t.height():t.height,d=typeof t.width==`function`?t.width(0):t.width,f=typeof t.x==`function`?t.x:()=>t.x,p=!isFinite(d)&&e.length===1,m=bi(c/i)??0,h=p?0:bi(c/(i*1.15+(c-i)/2));if(Si[l]&&isFinite(u)){let t=l===`bottom`?1:.5;h=(h||0)+(u*t-c*e.length*t)/i}let g=o===`justify`,_=0;o===`right`?_=d:o===`center`&&(_=d/2);let v=[],y=`tspan`,b=null,ee=``,x=()=>{if(ee){let e=s(y,b,ee);v.push(e)}y=`tspan`,b=null,ee=``};for(let t=0,r=e.length;t<r;t++){let o=``,c=``,l=0,u=e[t];if(!u.length){n.push(s(`tspan`,{x:f(t),dy:bi(t?m:h)+`em`},`\xA0`));continue}v=[];let te=0,ne=0,re=``;for(let e=0,t=u.length;e<t;e++){let t=u[e],n=t.font,r=ni(n,!0);if(t.whitespace&&te++,ne+=t.width,e&&!t.font.tracking&&!l&&Ci(r,o)&&Ci(t.font.class,c)&&Ci(re,t.font.href))ee+=t.value;else{x();let e=(n.size??i)*(n.sizeAdjust??1);ee=t.value,b={fontFamily:n.family!==a&&n.family||null,fontSize:e===i?null:e,fontWeight:n.weight===400?null:n.weight||null,fontStyle:n.style===`normal`?null:n.style||null,fontVariant:n.variant===`normal`?null:n.variant||null,fill:n.color||null,baselineShift:n.baseline?n.baseline*100+`%`:null,className:t.font.class||null,dx:0,href:null,rel:null,target:null},l&&=(b.dx=bi(l),0),t.font.tracking&&(l=e*t.font.tracking),t.font.href&&!re?(re=t.font.href,y=`a`,b.href=re,b.rel=t.font.rel,b.target=t.font.target):re=``,o=r,c=t.font.class??``}}if(x(),p)n.push(...v);else{let e=null,i=t===r-1||u[u.length-1]instanceof V;g&&u.length>1&&!i&&(e=bi((d-ne)/te)),n.push(s(`tspan`,{wordSpacing:e,x:f(t)+_,dy:bi(t?m:h)+`em`},...v))}}}return s(`text`,{fontFamily:a,fontSize:i,textAnchor:xi[o]||`start`},...n)}var Ti={middle:.5,center:.5,bottom:1,end:1};function Ei(e){return e.color||(e.href?`#00C`:`#000`)}function Di(e,t,n){if(!e.length)return;n.textBaseline=`middle`;let r=ti(t.font),i=r.size??12,a=r.height??7/6*i,o=t.valign,s=typeof t.height==`function`?t.height():t.height,c=typeof t.width==`function`?t.width(0):t.width,l=typeof t.x==`function`?t.x:()=>t.x,u=t.align,d=u===`justify`,f=a*.5,p=Ti[o];if(p&&isFinite(s)){let t=e.length*a;f+=s*p-t*p}let m;e.forEach((t,r)=>{m=null;let o=l(r),s=r*a+f,p=0,h=0;t.forEach(e=>{e.whitespace&&p++,h+=e.width});let g=0,_=r===e.length-1||t[t.length-1]instanceof V;d&&t.length>1&&!_&&(g=(c-h)/p);for(let e of t){n.font=ni(e.font);let t=e.font,r=t.baseline?i*-t.baseline+i*.15:0;n.fillStyle=Ei(t);let a=0;if(u===`right`?a+=c-h:u===`center`?a+=c/2-h/2:u===`justify`&&(e.whitespace||e instanceof V)&&(o+=g),n.fillText(e.value,o+a,s+r),e.font.href){n.beginPath(),n.strokeStyle=n.fillStyle;let t=Math.floor(s+i*.45)+.5;m||=[o+a,t],n.moveTo(...m),n.lineTo(o+a+e.width,t),n.stroke()}else m=null;o+=e.width}})}var Oi=Object.prototype.hasOwnProperty,ki={};function Ai(e){return ki[e]||(ki[e]=e.replace(/([a-z])([A-Z])/g,(e,t,n)=>t+`-`+n.toLowerCase())),ki[e]}function ji(e,t){if(Array.isArray(t))t.forEach(t=>ji(e,t));else if(typeof t==`string`){let n=document.createTextNode(t);e.appendChild(n)}else e.appendChild(t)}function Mi(e,t,...n){if(typeof document>`u`)throw Error(`No document found, cannot create elements`);let r=typeof e==`string`?document.createElementNS(`http://www.w3.org/2000/svg`,e):e;if(t&&r.setAttribute)for(let e in t)Oi.call(t,e)&&t[e]!=null&&r.setAttribute(e===`className`?`class`:Ai(e),String(t[e]));return n!=null&&n.length&&n.forEach(e=>{e&&ji(r,e)}),r}var Ni=/^[\n\r\t\x20\xA0\u2000-\u200B\u205F\u3000]/,Pi=/^[^\n\r\t\u0020\u2000-\u200B\u205F\u3000]{2,}/,Fi=/^[\xA0\u2011\u202F\u2060\uFEFF]/,Ii=/^(?:[;\xAD%?…]|,(?!\d))/,Li=/^[´±°¢£¤$¥\u2212]/,Ri=`'“‘[「【﹝〔<‹«{『((<《`.split(``),zi=`',,,!!??”]」】》>’»﹞〕〗〉}))』。`.split(``),Bi=e=>{let t=e.charCodeAt(0);return t>=19968&&t<=40959};function Vi(e){e||=``;let t=[],n=e.charAt(0),r=``,i=``,a=0;for(let o=1,s=e.length;o<s;o++){r=e.charAt(o),i=e.charAt(o+1);let s=Ni.test(n),c=Ni.test(r),l=c||s||Bi(n)||Bi(r);if((Li.test(r)&&!Fi.test(n)||Ii.test(n+i)&&!Fi.test(r))&&(l=!0),l&&(zi.includes(r)||Ri.includes(n))&&(l=!1),n===`-`||n===`‐`||n===`–`||n===`—`){let t=Ni.test(e.charAt(o-2));t&&!c&&(l=!1),!t&&Pi.test(r+i)&&(l=!0)}if(l){let n=e.slice(a,o);n.endsWith(``)?(t.push(new B(n.slice(0,-1))),t.push(new pi)):(t.push(new B(n)),t.push(new fi)),a=o}n=r}return t.push(new B(e.slice(a))),t}var Hi={nbsp:`\xA0`,iexcl:`¡`,cent:`¢`,pound:`£`,curren:`¤`,yen:`¥`,brvbar:`¦`,sect:`§`,uml:`¨`,copy:`©`,ordf:`ª`,laquo:`«`,not:`¬`,shy:``,reg:`®`,macr:`¯`,deg:`°`,plusmn:`±`,sup2:`²`,sup3:`³`,acute:`´`,micro:`µ`,para:`¶`,middot:`·`,cedil:`¸`,sup1:`¹`,ordm:`º`,raquo:`»`,frac14:`¼`,frac12:`½`,frac34:`¾`,iquest:`¿`,Agrave:`À`,Aacute:`Á`,Acirc:`Â`,Atilde:`Ã`,Auml:`Ä`,Aring:`Å`,AElig:`Æ`,Ccedil:`Ç`,Egrave:`È`,Eacute:`É`,Ecirc:`Ê`,Euml:`Ë`,Igrave:`Ì`,Iacute:`Í`,Icirc:`Î`,Iuml:`Ï`,ETH:`Ð`,Ntilde:`Ñ`,Ograve:`Ò`,Oacute:`Ó`,Ocirc:`Ô`,Otilde:`Õ`,Ouml:`Ö`,times:`×`,Oslash:`Ø`,Ugrave:`Ù`,Uacute:`Ú`,Ucirc:`Û`,Uuml:`Ü`,Yacute:`Ý`,THORN:`Þ`,szlig:`ß`,agrave:`à`,aacute:`á`,acirc:`â`,atilde:`ã`,auml:`ä`,aring:`å`,aelig:`æ`,ccedil:`ç`,egrave:`è`,eacute:`é`,ecirc:`ê`,euml:`ë`,igrave:`ì`,iacute:`í`,icirc:`î`,iuml:`ï`,eth:`ð`,ntilde:`ñ`,ograve:`ò`,oacute:`ó`,ocirc:`ô`,otilde:`õ`,ouml:`ö`,divide:`÷`,oslash:`ø`,ugrave:`ù`,uacute:`ú`,ucirc:`û`,uuml:`ü`,yacute:`ý`,thorn:`þ`,yuml:`ÿ`,fnof:`ƒ`,Alpha:`Α`,Beta:`Β`,Gamma:`Γ`,Delta:`Δ`,Epsilon:`Ε`,Zeta:`Ζ`,Eta:`Η`,Theta:`Θ`,Iota:`Ι`,Kappa:`Κ`,Lambda:`Λ`,Mu:`Μ`,Nu:`Ν`,Xi:`Ξ`,Omicron:`Ο`,Pi:`Π`,Rho:`Ρ`,Sigma:`Σ`,Tau:`Τ`,Upsilon:`Υ`,Phi:`Φ`,Chi:`Χ`,Psi:`Ψ`,Omega:`Ω`,alpha:`α`,beta:`β`,gamma:`γ`,delta:`δ`,epsilon:`ε`,zeta:`ζ`,eta:`η`,theta:`θ`,iota:`ι`,kappa:`κ`,lambda:`λ`,mu:`μ`,nu:`ν`,xi:`ξ`,omicron:`ο`,pi:`π`,rho:`ρ`,sigmaf:`ς`,sigma:`σ`,tau:`τ`,upsilon:`υ`,phi:`φ`,chi:`χ`,psi:`ψ`,omega:`ω`,thetasym:`ϑ`,upsih:`ϒ`,piv:`ϖ`,bull:`•`,hellip:`…`,prime:`′`,Prime:`″`,oline:`‾`,frasl:`⁄`,weierp:`℘`,image:`ℑ`,real:`ℜ`,trade:`™`,alefsym:`ℵ`,larr:`←`,uarr:`↑`,rarr:`→`,darr:`↓`,harr:`↔`,crarr:`↵`,lArr:`⇐`,uArr:`⇑`,rArr:`⇒`,dArr:`⇓`,hArr:`⇔`,forall:`∀`,part:`∂`,exist:`∃`,empty:`∅`,nabla:`∇`,isin:`∈`,notin:`∉`,ni:`∋`,prod:`∏`,sum:`∑`,minus:`−`,lowast:`∗`,radic:`√`,prop:`∝`,infin:`∞`,ang:`∠`,and:`⊥`,or:`⊦`,cap:`∩`,cup:`∪`,int:`∫`,there4:`∴`,sim:`∼`,cong:`≅`,asymp:`≈`,ne:`≠`,equiv:`≡`,le:`≤`,ge:`≥`,sub:`⊂`,sup:`⊃`,nsub:`⊄`,sube:`⊆`,supe:`⊇`,oplus:`⊕`,otimes:`⊗`,perp:`⊥`,sdot:`⋅`,lceil:`⌈`,rceil:`⌉`,lfloor:`⌊`,rfloor:`⌋`,lang:`〈`,rang:`〉`,loz:`◊`,spades:`♠`,clubs:`♣`,hearts:`♥`,diams:`♦`,quot:`"`,amp:`&`,lt:`<`,gt:`>`,OElig:`Œ`,oelig:`œ`,Scaron:`Š`,scaron:`š`,Yuml:`Ÿ`,circ:`ˆ`,tilde:`˜`,ensp:` `,emsp:` `,thinsp:` `,zwnj:``,zwj:``,lrm:``,rlm:``,ndash:`–`,mdash:`—`,lsquo:`‘`,rsquo:`’`,sbquo:`‚`,ldquo:`“`,rdquo:`”`,bdquo:`„`,dagger:`†`,Dagger:`‡`,permil:`‰`,lsaquo:`‹`,rsaquo:`›`},Ui=-.3,Wi=.45,Gi=.7,Ki={weight:400,style:`normal`,variant:`normal`,baseline:0,tracking:0,href:``},qi=/^[\n\r\x20\u2000-\u200B\u205F\u3000]/,Ji=class{tokens;stack;props;constructor(){this.tokens=[],this.stack=[],this.props={...Ki}}add_token(e){return e.font=this.props,this.tokens.push(e),e}open_context(){this.stack.push(this.props),this.props=Object.create(this.props)}close_context(){if(!this.stack.length)throw Error(`Unexpected }`);this.props=this.stack.pop()}trimEnd(){let e=this.tokens[this.tokens.length-1];for(;e instanceof V;)this.tokens.pop(),e=this.tokens[this.tokens.length-1]}setProps(e){for(let[t,n]of Object.entries(e))n!=null&&(this.props[t]=n)}maybeLineBreak(e){let t=this.tokens.length;if(t>0&&e&&e>0){let n=t-1;for(;this.tokens[n]&&(this.tokens[n]instanceof fi||qi.test(this.tokens[n].value));)n--;for(;e&&this.tokens[n]&&this.tokens[n]instanceof V;)n--,e--;for(;e-->0;)this.tokens.push(new V)}}},Yi=/^<\/([a-zA-Z0-9]+)([^>]*)>/,Xi=/^<([a-zA-Z0-9]+)((?:\s[^=\s/]+(?:\s*=\s*(?:"[^"]+"|'[^']+'|[^>\\s]+))?)+)?\s*(\/?)>(\n*)/,Zi=/^<!--(.+?)-->/,Qi=/&(?:#(\d\d{2,})|#x([\da-fA-F]{2,})|([a-zA-Z][a-zA-Z1-4]{1,8}));/g,$i={b:e=>e.weight=700,strong:e=>e.weight=700,i:e=>e.style=`italic`,em:e=>e.style=`italic`,dfn:e=>e.style=`italic`,cite:e=>e.style=`italic`,code:e=>e.family=`monospace`,kbd:e=>e.family=`monospace`,samp:e=>e.family=`monospace`,var:e=>e.family=`monospace`,tt:e=>e.family=`monospace`,sub:e=>{e.baseline=Ui,e.sizeAdjust=Gi},sup:e=>{e.baseline=Wi,e.sizeAdjust=Gi}},ea={div:1,li:1,blockquote:2,h1:2,h2:2,h3:2,h4:2,h5:2,h6:2,ul:2,ol:2,hr:2,p:2};function ta(e){return e.replace(Qi,function(e,t,n,r){if(t||n){let e=t?10:16;return String.fromCharCode(parseInt(t||n,e))}else if(r in Hi)return Hi[r];return e})}function na(e){return e&&e.length>1&&(e.startsWith(`"`)&&e.endsWith(`"`)||e.startsWith(`'`)&&e.endsWith(`'`))?e.slice(1,-1):e}var ra=/^\s*([^=\s&]+)(?:\s*=\s*("[^"]+"|'[^']+'|[^>\s]+))?/;function ia(e){let t,n={};if(e){do if(t=ra.exec(e),t){let r=ta(na(t[2]||``)).replace(/[ \r\n\t]+/g,` `).trim();if(n[t[1]]=r,e=e.slice(t[0].length),e.length&&/^\S/.test(e[0]))throw Error(`Attribute error`)}while(t&&e.length);if(/\S/.test(e))throw Error(`Attribute error`)}return n}function aa(e){e=String(e||``).trim();let t,n,r=new Ji;for(;e.length;){if(t=/^[^<]+/.exec(e))Vi(ta(t[0])).forEach(e=>r.add_token(e));else if(!(t=Zi.exec(e)))if(t=Yi.exec(e))r.close_context(),r.maybeLineBreak(ea[t[1]]);else if(t=Xi.exec(e)){let e=t[1];r.maybeLineBreak(ea[e]),r.open_context(),$i[e]&&$i[e].call(r,r.props);let i=ia(t[2]);e===`a`&&r.setProps({href:i.href,rel:i.rel,target:i.target}),i.class&&(r.props.class=r.props.class?r.props.class+` `+i.class:i.class),i.style&&(n=/(?:^|\s|;)color\s*:\s*([^;\s"']+)/.exec(i.style),n&&n[1]&&(r.props.color=n[1])),e===`br`&&r.tokens.push(new V)}else t=[e.slice(0,1)],r.add_token(new B(t[0]));e=e.slice(t[0].length)}return r.trimEnd(),r.tokens}var oa={copyright:`©`,textcopyright:`©`,dag:`†`,textdagger:`†`,ddag:`‡`,textdaggerdbl:`‡`,guillemotleft:`«`,guillemotright:`»`,guilsinglleft:`‹`,guilsinglright:`›`,ldots:`…`,dots:`…`,textellipsis:`…`,lq:`‘`,P:`¶`,textparagraph:`¶`,pounds:`£`,textsterling:`£`,quotedblbase:`„`,quotesinglbase:`‚`,rq:`’`,S:`§`,sim:`~`,textasciicircum:`^`,textasciitilde:`˜`,texttildelow:`~`,textasteriskcentered:`*`,textbackslash:`'`,textbar:`|`,textbardbl:`╎`,textbigcircle:`◯`,textbraceleft:`{`,textbraceright:`}`,textbullet:`•`,textdollar:`$`,textemdash:`—`,textendash:`—`,texteuro:`€`,eurosym:`€`,euro:`€`,textexclamdown:`¡`,textgreater:`>`,textless:`<`,textordfeminine:`ª`,textordmasculine:`º`,textperiodcentered:`·`,cdot:`·`,textquestiondown:`¿`,textquotedblleft:`“`,textquotedblright:`”`,textquoteleft:`‘`,textquoteright:`’`,textquotestraightbase:`‚`,textquotestraightdblbase:`„`,textregistered:`®`,textthreequartersemdash:`-`,texttrademark:`™`,texttwelveudash:`-`,textunderscore:`_`,textvisiblespace:`␣`,gets:`←`,textleftarrow:`←`,to:`→`,textrightarrow:`→`,textdegree:`°`,infty:`∞`,triangle:`△`,triangledown:`▽`,blacktriangle:`▲`,blacktriangledown:`▼`,angle:`∠`,sphericalangle:`∢`,aleph:`ℵ`,hbar:`ħ`,imath:`𝚤`,jmath:`𝚥`,ell:`ℓ`,wp:`℘`,Re:`ℜ`,Im:`ℑ`,mho:`℧`,prime:`′`,emptyset:`∅`,nabla:`∇`,surd:`√`,partial:`∂`,top:`⟙`,bot:`⟂`,vdash:`⟝`,dashv:`⟞`,forall:`∀`,exists:`∃`,nexists:`∄`,neg:`¬`,lnot:`¬`,flat:`♭`,natural:`♮`,sharp:`♯`,backslash:`\\`,Box:`□`,Diamond:`♢`,clubsuit:`♣`,diamondsuit:`♦`,heartsuit:`♥`,spadesuit:`♠`,Join:`⨝`,blacksquare:`■`,bigstar:`★`,diagdown:`╲`,diagup:`╱`,blacklozenge:`⧫`,rfloor:`⌋`,lfloor:`⌊`,rceil:`⌉`,lceil:`⌈`,rangle:`⟩`,langle:`⟨`,sum:`∑`,int:`∫`,oint:`∮`,prod:`∏`,coprod:`∏`,bigcap:`∩`,bigcup:`∪`,bigsqcup:`⊔`,bigvee:`∨`,bigwedge:`∧`,bigodot:`⊙`,bigotimes:`⊗`,bigoplus:`⊕`,biguplus:`⊎`,alpha:`α`,beta:`β`,chi:`χ`,delta:`δ`,epsilon:`ε`,eta:`η`,gamma:`γ`,iota:`ι`,kappa:`κ`,lambda:`λ`,mu:`μ`,nu:`ν`,omega:`ω`,phi:`φ`,pi:`π`,psi:`ψ`,rho:`ρ`,sigma:`σ`,tau:`τ`,theta:`θ`,upsilon:`υ`,xi:`ξ`,zeta:`ζ`,Alpha:`Α`,Beta:`Β`,Chi:`Χ`,Delta:`Δ`,Epsilon:`Ε`,Eta:`Η`,Gamma:`Γ`,Iota:`Ι`,Kappa:`Κ`,Lambda:`Λ`,Mu:`Μ`,Nu:`Ν`,Omega:`Ω`,Phi:`Φ`,Pi:`Π`,Psi:`Ψ`,Rho:`Ρ`,Sigma:`Σ`,Tau:`Τ`,Theta:`Θ`,Upsilon:`Υ`,Xi:`Ξ`,Zeta:`Ζ`,aa:`å`,AA:`Å`,ae:`æ`,AE:`Æ`,dh:`ð`,DH:`Ð`,dj:`đ`,DJ:`Đ`,ij:`ij`,IJ:`IJ`,l:`ł`,L:`Ł`,ng:`ŋ`,NG:`Ŋ`,o:`ø`,O:`Ø`,oe:`œ`,OE:`Œ`,ss:`ß`,SS:`SS`,th:`þ`,TH:`Þ`},sa=/^(\^|_|\\[^#$%&~_^\\{}()\s]+)(\{)?/,ca=/^%[^\n]+(?:\n|$)/,la=/^[^#$%&~_^\\{}]+/,ua=/^\\([&{}$%#_])/,da=/(?:\\[\\@,!:;-]|-{2,3}|[!?]`|``?|,,|''?|~|<<|>>)/g,fa={"---":`—`,"--":`–`,"!`":`¡`,"?`":`¿`,"``":`“`,",,":`„`,"''":`”`,"`":`‘`,"'":`’`,"<<":`«`,">>":`»`,"~":`\xA0`,"\\-":``,"\\,":` `,"\\;":` `,"\\:":` `,"\\!":` `,"\\@":``,"\\\\":`\\newline{}`},H={bf:e=>e.weight=700,emph:e=>{e.style===`italic`?e.style=`normal`:e.style=`italic`},it:e=>e.style=`italic`,sl:e=>e.style=`italic`,color:(e,t)=>e.color=t,href:(e,t)=>e.href=t,"^":e=>{e.baseline=Wi,e.sizeAdjust=Gi},_:e=>{e.baseline=Ui,e.sizeAdjust=Gi},par:function(){this.tokens.push(new V,new V)},newline:function(){this.tokens.push(new V)},url:function(e,t){this.open_context(),this.props.href=t,this.add_token(new B(t)),this.close_context()}};H.textsuperscript=H[`^`],H.textsubscript=H._,H.textsl=H.sl,H.mathbf=H.bf,H.mathit=H.it,H.textbf=H.bf,H.textit=H.it,H.textcolor=H.color;function pa(e){e=String(e||``).trim();let t=[``];e=e.replace(/\\verb,(.*?),/,(e,n)=>(t.push(n),`\\verb,`+(t.length-1)+`,`)).replace(/\\\\\n/g,()=>`\\\\`).replace(da,(e,t,n)=>n.charAt(t-1)===`\\`?e:fa[e]).replace(/\n\s+/g,e=>e.slice(1).includes(`
|
|
2
2
|
`)?`\\par `:e).replace(/\\symbol\{(\d+)\}/,(e,t,n,r)=>r.charAt(n-1)===`\\`?e:String.fromCharCode(1*t)).replace(/(^|[^\\])(\^|_)(\d|[^{]\S*)/g,(e,t,n,r)=>t+n+`{`+r+`}`).replace(/\\verb,(.*?),/,(e,n)=>`\\verb,${t[+n]},`);let n=new Ji,r;for(;e.length;){if(r=la.exec(e))Vi(r[0]).forEach(e=>n.add_token(e));else if(r=ua.exec(e))n.add_token(new B(r[1]));else if(!(r=ca.exec(e))){if(r=/^\{/.exec(e))n.open_context();else if(r=/^\}/.exec(e))n.close_context();else if(!(r=/^\$/.exec(e)))if(r=/^\\verb,([^,]+),/.exec(e))n.add_token(new B(r[1]));else if(r=sa.exec(e)){let t=r[1].slice(1)||r[1],i=!!r[2];if(/^(La)?TeX$/i.test(t)){n.open_context(),n.props.family=`serif`;let e;t===`LaTeX`&&(e=n.add_token(new B(`L`)),e.font=Object.create(e.font),e.font.tracking=-.25,e=n.add_token(new B(`A`)),e.font=Object.create(e.font),e.font.sizeAdjust=.7,e.font.baseline=.3,e.font.tracking=-.1),e=n.add_token(new B(`T`)),e.font=Object.create(e.font),e.font.tracking=-.17,e=n.add_token(new B(`E`)),e.font=Object.create(e.font),e.font.baseline=-.22,e.font.tracking=-.13,e=n.add_token(new B(`X`)),n.close_context()}else if(t in oa)n.add_token(new B(oa[t])),i&&n.open_context();else if(t in H){let a=[],o=Math.max(0,H[t].length-1),s;if(o){for(i=!1,e=e.slice(r[0].length-1);o--;)if(s=/^\{([^}]+)\}/.exec(e))a.push(s[1]),e=e.slice(s[0].length);else throw Error(t+` is missing an argument`);r[0]=/^\{/.exec(e)?`{`:``,i=!!r[0]}i&&n.open_context(),H[t].apply(n,[n.props,...a])}else n.add_token(new B(r[1])),i&&n.open_context()}else r=[e.slice(0,1)],n.add_token(new B(r[0]))}e=e.slice(r[0].length)}return n.tokens}var U={overflow:`ellipsis`,overflowWrap:`normal`,overflowLine:``,align:`left`,valign:`top`,width:1/0,height:1/0,x:0,font:`12px/14px sans-serif`},ma=class e{static createElement=Mi;static defaultparser=Vi;static measureText=di;static setMeasureCanvas=ui;props;constructor(t){this.props={overflow:t?.overflow??U.overflow,overflowWrap:t?.overflowWrap??U.overflowWrap,overflowLine:t?.overflowLine??U.overflowLine,align:t?.align??U.align,valign:t?.valign??U.valign,width:t?.width??U.width,height:t?.height??U.height,x:t?.x??U.x,font:t?.font??U.font,parser:t?.parser??e.defaultparser,createElement:t?.createElement??e.createElement},t?.parser&&this.parser(t.parser)}linebreak(e){return yi(this.props.parser(String(e).trim()),this.props)}font(e){return arguments.length?(this.props.font=e??U.font,this):this.props.font||U.font}overflow(e){return arguments.length?(this.props.overflow=e??U.overflow,this):this.props.overflow}overflowLine(e){return arguments.length?(this.props.overflowLine=e??U.overflowLine,this):this.props.overflowLine}overflowWrap(e){if(!arguments.length)return this.props.overflowWrap;let t=String(e).toLowerCase();return this.props.overflowWrap=t===`break-word`?t:U.overflowWrap,this}valign(e){return arguments.length?(this.props.valign=e??U.valign,this):this.props.valign}align(e){return arguments.length?(this.props.align=e??U.align,this):this.props.align}width(e){return arguments.length?(this.props.width=e??U.width,this):this.props.width}height(e){return arguments.length?(this.props.height=e??U.height,this):this.props.height}x(e){return arguments.length?(this.props.x=e??U.x,this):this.props.height}parser(t){return arguments.length?(t===`html`?this.props.parser=aa:t===`text`?this.props.parser=Vi:t===`latex`?this.props.parser=pa:this.props.parser=t??e.defaultparser,this):this.props.parser}createElement(t){return arguments.length?(this.props.createElement=t??e.createElement,this):this.props.createElement}renderSVG(e){return wi(typeof e==`string`?this.linebreak(e):e,this.props)}renderCanvas(e,t){let n=typeof e==`string`?this.linebreak(e):e;if(t instanceof CanvasRenderingContext2D)Di(n,this.props,t);else{let e=t.getContext(`2d`);e instanceof CanvasRenderingContext2D&&Di(n,this.props,e)}}render(e,t){let n=typeof e==`string`?this.linebreak(e):e;return t?this.renderCanvas(n,t):this.renderSVG(n)}},ha=[`sans-serif`,`serif`,`cursive`,`monospace`,`fantasy`],ga=`Abadi,Arial,Abadi Extra Light,Helvetica Light,Abadi MT Condensed Extra Bold,Abadi MT Condensed Light,Academy Engraved LET,Colonna MT,Academy Engraved LET PLAIN:1.0,Akzidenz Grotesk,Helvetica Neue,AkzidenzGroteskBQ-Ext,Amatic SC,Chalkboard,American Typewriter,Courier,American Typewriter Condensed,American Typewriter Light,Andale Mono,Lucida Console,Andale Mono WT,Angsana New,Times New Roman,Apple Chancery,Bradley Hand ITC,Apple SD Gothic Neo,MS Gothic,Apple SD Gothic Neo Regular,AppleGothic,Century Gothic,Apple Gothic,AppleGothic Regular,AppleMyungio,Aptos,Aptos Display,Aptos Mono,Aptos Narrow,Calibri,Aptos Serif,Century,Arial Nova,Arial Black,Arial Narrow,Arial Rounded,Arial Rounded MT,Arial Rounded MT Bold,Arvo,Roboto Slab,Avant Garde,Avantgarde,Avenir,Museo Sans,Avenir Next,Avenir Next Regular,Avenir Book,Avenir Next Condensed Regular,Bahnschrift,DIN 1451,Baskerville,Big Caslon,Baskerville Old Face,Bauhaus 93,Futura,Beirut,Beirut Regular,Bell MT,Bodoni MT,Berlin Sans FB,Verdana,Bernard MT Condensed,Big Caslon Medium,Bitstream Vera Sans Mono,Consolas,BlinkMacSystemFont,Roboto,Bodoni Moda,Didot,Bodoni,Bodoni 72 Book,Bodoni 72 Oldstyle Book,Bodoni 72 Smallcaps Book,Book Antiqua,Palatino,Bookman Old Style,PT Serif,Tempus Sans ITC,Bradley Hand Bold,Braggadocio,Britannic,Lucida Grande,Britannic Bold,Brush Script,Brush Script MT,Brush Script MT Italic,Cabin,Tahoma,Caladea,Hoefler Text,Carlito,Calibri Light,Carlito Light,Calisto MT,Cambria,Cambria Math,Candara,Segoe,Canela Text,Canela Text Regular,Caveat,CenturyGothic,Century Schoolbook,Comic Sans MS,Chalkboard SE Regular,Chalkboard SE,Chalkduster,Charcoal,Helvetica Inserat,Charter Roman,Chivo,Helvetica,Cochin,Comfortaa,ComicSansMS,Comic Sans MS Bold,Comic Sans Pro,monaco,Constantia,Lucida Bright,Constantina,Cooper Black,Cooper,Copperplate,Copperplate Gothic Light,Copperplate Gothic Bold,Copperplate Light,Corbel,Cordia New,CordiaUPC,Corsiva,Lucida Handwriting,Corsiva Hebrew,Liberation Mono,Courier New,Courier Prime,Curlz MT,Party LET,Damascus,Damascus Regular,David,DecoType Naskh,DecoType Naskh Regular,Dejavu Sans,DejaVu Sans Condensed,DejaVu Sans Mono,Desdemona,Didot LT STD,DIN,DIN Alternate,DIN Alternate Bold,DIN Condensed,DIN Condensed Bold,DM Sans,Domine,Droid Sans,Myriad,Droid Serif,Liberation Serif,Edwardian Script ITC,Savoye LET,Engravers MT,Eurostile,Franklin Gothic,Fira Sans,Footlight MT,Footlight MT Light,Franklin Gothic Medium,ITC Franklin Gothic,Franklin Gothic Book,Frutiger,Frutiger Linotype,Trebuchet MS,Futura Medium,Gabriola,Garamond,EB Garamond,Geneva,Georgia,Georgia Pro,Gigi,Gill Sans,Gill Sans MT,Gill Sans Nova,Gill Sans Condensed,Gill Sans MT Condensed,Gill Sans Nova Cond,Gill Sans MT Ext Condensed Bold,Gill Sans Light,Gill Sans MT Light,Gill Sans Nova Light,Gill Sans Ultra Bold,Gill Sans Nova Ultra Bold,Gloucester MT,Lucida Sans,Gloucester MT Extra Condensed,Gotham Rounded,GothamRounded-Medium,Goudy Old Style,Haettenschweiler,Harrington,Liberation Sans,Helvetica Neue Condensed,Helvetica Neue Condensed Bold,Helvetica Neue Light,Herculanum,Papyrus,Impact,Imprint MT Shadow,Ink Free,Segoe Print,Inter,helvetica,Jokerman,Josefin Sans,futura,Juice ITC,Jumble,Kannada MN,Optima,Kefa,Rockwell Nova,Kefa Regular,Kino MN,Kristen ITC,Latha,Libre Baskerville,Libre Franklin,Lobster,Lora,Lucida Blackletter,Lucidabright,Lucida Calligraphy,Lucida Calligraphy Italic,Lucida Fax,Lucida Fax Regular,Lucida Sans Unicode,Monotype Corsiva,Lucida Handwriting Italic,Lucida Sans Regular,Lucida Sans Typewriter,Lucida Sans Typewriter Regular,Luminari,Marker Felt,Mistral,Marker Felt Thin,Marlett,Matura MT Script Capitals,Zapfino,Menlo,Menlo Regular,Merriweather,Microsoft Himalaya,Microsoft Sans Serif,Modern No. 20,Moderne Fractur,Monaco,Montserrat,Roboto Sans,MS Mincho,MS UI Gothic,Myriad Pro,Neue Haas Grotesk Text Pro,News Gothic MT,Noteworthy,Noteworthy Light,Nunito,Onyx,Open Sans,Segoe UI,Open Sans Medium,Optima Regular,Oswald,Overpass,Pacifico,Palatino Linotype,Party LET Plain,Perpetua,Phosphate,Playfair Display,Poppins,Proxima Nova,Proxima Nova Extrabold,Proxima Nova Light,PT Mono,PT Sans,PT Sans Caption,PT Serif Caption,Publico Text,PublicoText-Roman,Raleway,Roboto Mono,Rockwell Condensed,Rockwell Extra Bold,Rockwell,Rockwell Nova Cond,Rockwell Nova Extra Bold,Rockwell Nova Light,Rubik,Savoye LET Plain:1.0,Script MT,Script MT Bold,Segoe Historic,Segoe Print Bold,Segoe Script,Segoe Script Bold,Segoe Symbol,SignPainter,SignPainter-HouseScript,Skia,Snap ITC,Snell Roundhand,Source Sans Pro,Source Sans Pro Regular,Source Serif Pro,Space Mono,Spectral,Stencil,Symbol,Syncopate,Times,Trattatello,Ubuntu,Univers,Univers Condensed,Univers Light,Verdana Pro,Verdana Pro Black,Verdana Pro Cond,Westminster,OCR-A,Wide Latin,Work Sans`.split(`,`),_a=[[0,1,0],[2,3,0],[4,null,0],[5,1,0],[6,7,1,8],[8,7,1,6],[9,10,0,9,11],[9,10,0,9,11],[11,10,0,9,9],[12,13,2],[14,15,3],[16,null,3],[17,15,3],[18,19,3,20],[20,19,3,18],[21,22,1],[23,24,2],[25,26,0,27],[27,26,0,25],[28,29,0,30,31],[30,29,0,28,31],[31,29,0,28,30],[32,22,1],[33,1,0],[34,26,0],[35,18,3],[36,37,0],[38,39,1],[1,10,0,40],[40,10,0,1],[41,1,0],[42,1,0],[40,1,0],[43,1,0,44,45],[44,1,0,43,45],[45,1,0,43,44],[46,47,0],[48,29,0,49],[49,29,0,48],[50,51,0,52,53,54],[52,51,0,50,53,54],[53,51,0,50,52,54],[54,51,0,50,52,53],[55,null,0],[56,57,0],[58,59,1],[60,58,1],[61,62,0],[63,null,1,64],[64,null,1,63],[65,66,1],[67,68,0],[69,57,0],[59,22,1],[70,59,1],[71,72,3],[73,74,0],[75,66,1],[66,76,1,77,78,79,80],[77,76,1,66,78,79,80],[78,76,1,66,77,79,80],[79,76,1,66,77,78,80],[80,76,1,66,77,78,79],[81,82,1],[83,84,1],[24,85,2,86],[86,85,2,24],[87,null,0],[88,89,0,90],[90,89,0,88],[91,null,2,92,93],[92,null,2,91,93],[93,null,2,91,92],[94,95,0],[96,97,1],[37,98,0],[99,100,0],[101,82,1],[102,96,1,103],[103,96,1,102],[104,105,0],[106,81,1,107],[107,81,1,106],[98,104,0],[108,13,2],[39,null,1],[29,28,0,109],[109,28,0,29],[110,39,1],[13,111,2,112,113],[112,111,2,13,113],[113,111,2,13,112],[114,13,2],[115,116,0],[117,null,1],[118,119,0],[120,58,1],[7,6,1],[121,62,0],[111,13,2,122,123,124],[122,13,2,111,123,124],[123,13,2,111,122,124],[124,13,2,111,122,123],[72,125,3],[126,127,1],[128,127,1],[129,null,1,130],[130,null,1,129],[131,132,4],[133,131,4],[132,131,4],[134,132,4],[135,89,0],[136,119,0,137],[137,119,0,136],[138,139,2,140],[140,139,2,138],[15,141,3,142],[142,141,3,15],[143,15,3],[144,145,4],[146,null,0,147],[147,null,0,146],[148,22,1],[149,null,1,150],[150,null,1,149],[151,10,0],[152,68,0],[153,71,3],[154,null,4],[76,97,1,155],[155,97,1,76],[57,56,0,156,157,158],[156,56,0,57,157,158],[157,56,0,57,156,158],[158,56,0,57,156,157],[159,57,0,160],[160,57,0,159],[161,73,0],[162,101,1],[163,164,0],[165,166,1],[167,168,2],[169,null,1],[170,171,0],[172,119,0],[173,null,1,174],[174,null,1,173],[171,30,0,175,176,177],[175,30,0,171,176,177],[176,30,0,171,175,177],[177,30,0,171,175,176],[178,151,0,179],[179,151,0,178],[62,180,0,181],[181,180,0,62],[182,139,2],[183,81,1,184],[184,81,1,183],[185,95,0],[186,22,1,187],[187,22,1,186],[188,null,2],[189,37,0,190,191],[190,37,0,189,191],[191,37,0,189,190],[192,null,0,193,194,195],[193,null,0,192,194,195],[194,null,0,192,193,195],[195,null,0,192,193,194],[196,null,0,197,198],[197,null,0,196,198],[198,null,0,196,197],[199,null,0,200],[200,null,0,199],[201,202,1,203],[203,202,1,201],[204,43,0,205],[205,43,0,204],[206,183,1],[207,115,0],[208,144,4],[119,209,0],[116,41,0],[3,null,0],[10,119,0],[210,null,0,211],[211,null,0,210],[212,3,0],[213,214,4],[97,166,1],[215,207,0],[216,6,1],[217,218,2],[219,220,0],[221,145,2],[222,223,0],[224,null,1],[225,111,2],[226,227,0],[228,229,1,230],[230,229,1,228],[231,null,0],[232,218,2],[233,null,0],[141,125,3],[209,1,0],[166,22,0],[234,58,1],[235,171,0],[236,91,2],[237,82,1],[238,null,4],[127,38,1,239],[239,38,1,127],[240,139,2,241],[241,139,2,240],[19,71,3],[242,127,1,243],[243,127,1,242],[89,244,0],[139,245,2,246],[246,245,2,139],[202,185,0,247],[247,185,0,202],[248,19,3,249],[249,19,3,248],[244,202,0],[250,null,4],[251,252,2,253],[253,252,2,251],[254,92,2],[255,256,4],[257,19,0,258],[258,19,0,257],[259,82,1],[260,22,1],[261,10,0],[252,92,2],[262,110,1],[263,238,4],[264,19,3],[245,24,2],[265,266,0],[26,null,0],[267,null,1],[268,null,0],[51,29,0],[164,178,0,269],[269,178,0,164],[270,10,0],[271,171,0],[272,218,4,273],[273,218,4,272],[274,74,0],[275,null,1],[276,277,0],[278,277,0],[227,105,0,279],[279,105,0,227],[280,5,0],[281,119,0],[282,null,2],[82,283,1],[283,183,1],[214,null,4],[284,221,4,145],[145,221,4,284],[285,58,1],[286,62,0],[287,66,1],[288,89,0],[289,265,0],[290,null,0],[291,null,0],[292,18,3],[293,null,0],[294,null,0],[84,null,1],[295,null,1],[296,null,1,297],[297,null,1,296],[298,1,0],[74,119,0,266],[266,119,0,74],[299,72,3],[47,229,0],[300,null,1],[301,null,1],[229,171,1,302],[302,171,1,229],[303,null,1],[304,null,1],[305,null,1],[306,1,0],[168,139,2,307],[307,139,2,168],[308,139,2,309],[309,139,2,308],[310,119,0],[218,218,2,311],[311,218,2,218],[312,111,2,313],[313,111,2,312],[314,null,0],[277,178,0,105],[105,178,0,277],[315,null,2,316],[316,null,2,315],[317,null,0],[318,null,1],[319,168,2],[320,74,0,321],[321,74,0,320],[322,186,1],[323,15,3],[324,22,0],[325,null,1],[326,22,1],[327,62,0],[95,152,0],[85,139,2],[328,22,0],[22,166,1,328],[328,166,1,22],[329,null,4],[180,89,0],[330,37,0],[331,null,0],[332,null,0],[333,null,0],[68,185,0],[334,185,0],[335,null,0],[336,null,0],[337,338,3],[339,null,1],[340,89,0],[256,null,2]].map(e=>({name:ga[e[0]],next:e[1]?ga[e[1]]:null,type:ha[e[2]],alt:e.slice(3).filter(e=>e!==null).map(e=>ga[e])})),va=new Map;function ya(e,t=`sans-serif`){if(!e)return t;let n=va.get(e);if(n)return n;let r=ba(e);return va.set(e,r),r}function ba(e){e=e.replace(/\(\w+\)/i,``).trim();let t=``,n=new Set,r=e=>{let i=e&&_a.find(t=>t.name.toLowerCase()===e.toLowerCase());i&&(t||=i.type,n.add(i.name),i.alt&&i.alt.forEach(e=>n.add(e)),i.next&&!n.has(i.next)&&r(i.next))};return r(e),t&&n.add(t),n.size||n.add(e),Array.from(n).map(e=>/[ ,]/.test(e)?`"`+e+`"`:e).join(`, `)}var W=class e{x;y;width;height;constructor(e,t,n,r){if(!isFinite(e)||!isFinite(t)||!isFinite(n)||!isFinite(r))throw Error(`Invalid Rect coords: x=${e}, y=${t}, w=${n}, h=${r}`);this.x=e,this.y=t,this.width=n,this.height=r}get top(){return this.y}get left(){return this.x}get bottom(){return this.y+this.height}get right(){return this.x+this.width}get size(){return[this.width,this.height]}equals(e){return this.x===e.x&&this.y===e.y&&this.width===e.width&&this.height===e.height}intersects(e){return!(this.x>e.right||this.right<e.x||this.y>e.bottom||this.bottom<e.y)}contains(e){return e.x>=this.x&&e.y>=this.y&&e.right<=this.right&&e.bottom<=this.bottom}resize(t,n){return new e(this.x,this.y,t,n)}translate(t=0,n=0){return new e(this.x+t,this.y+n,this.width,this.height)}getTopEdge(){return[[this.x,this.y],[this.x+this.width,this.y]]}getBottomEdge(){return[[this.x,this.y+this.height],[this.x+this.width,this.y+this.height]]}getLeftEdge(){return[[this.x,this.y],[this.x,this.y+this.height]]}getRightEdge(){return[[this.x+this.width,this.y],[this.x+this.width,this.y+this.height]]}getBorders(){let{x:e,y:t}=this,n=e+this.width,r=t+this.height;return[[[e,t],[n,t],[12,6]],[[n,t],[n,r],[3,6]],[[e,r],[n,r],[9,3]],[[e,t],[e,r],[9,12]]]}};const G=2**14-1,xa=2**20-1;var Sa=class e{range;workbookName;sheetName;constructor(t,n){if(t instanceof e)this.workbookName=t.workbookName||n?.workbookName||``,this.sheetName=t.sheetName||n?.sheetName||``,this.range=Object.assign({},t.range);else if(typeof t==`string`){let e=Wr(t);if(!e||!(`range`in e)||!e.range)throw Error(`Not a valid reference: ${t}`);this.workbookName=e.workbookName||n?.workbookName||``,this.sheetName=e.sheetName||n?.sheetName||``,this.range={top:e.range.top||0,left:e.range.left||0,bottom:e.range.bottom||e.range.top||0,right:e.range.right||e.range.left||0}}else this.workbookName=n?.workbookName||``,this.sheetName=n?.sheetName||``,this.range=Object.assign({top:0,left:0,right:0,bottom:0},t);let r=this.range;if(r.left<0||r.left>G||r.right<0||r.right>G||r.top<0||r.top>xa||r.bottom<0||r.bottom>xa)throw Error(`Not a valid reference: ${String(t)}`)}get left(){return this.range.left}get right(){return this.range.right}get top(){return this.range.top}get bottom(){return this.range.bottom}get height(){return this.range.bottom-this.range.top+1}get width(){return this.range.right-this.range.left+1}toString(){return Ur({range:this.range,workbookName:this.workbookName,sheetName:this.sheetName})}};const Ca=65536,wa=16383,Ta=1048575;function K(e,t){return(e&wa)*1+(t&Ta)*Ca}function Ea(e){return[e/1&wa,e/Ca&Ta]}const Da={style:`none`,color:`none`},Oa={style:`hair`,color:`#d8d9e5`};var q=class e{static TOP=`T`;static LEFT=`L`;static BOTTOM=`B`;static RIGHT=`R`;_;constructor(){this._=new Map}clear(){this._.clear()}set(t,n,r){let[i,a]=t;if(n===e.BOTTOM)this.set([i,a+1],e.TOP,r);else if(n===e.RIGHT)this.set([i+1,a],e.LEFT,r);else if(n===e.LEFT||n===e.TOP){let i=K(t[0],t[1]),a=this._.get(i);a||(a={[e.TOP]:Da,[e.LEFT]:Da},this._.set(i,a)),r==null||r.style===`none`?a[n]=Da:a[n]=r}}get(t,n){if(n===e.BOTTOM)return this.get([t[0],t[1]+1],e.TOP);if(n===e.RIGHT)return this.get([t[0]+1,t[1]],e.LEFT);if(n===e.LEFT||n===e.TOP){let e=K(t[0],t[1]),r=this._.get(e);if(r&&r[n])return r[n]}return Da}isSet(e,t){let n=this.get(e,t).style;return n!==`none`&&n!==`hair`}getJoin(t,n){let r=0;return this.isSet([t,n],e.TOP)&&(r|=8),this.isSet([t,n],e.LEFT)&&(r|=4),this.isSet([t-1,n],e.TOP)&&(r|=2),this.isSet([t,n-1],e.LEFT)&&(r|=1),r}forEach(t){for(let[n,r]of this._.entries()){let i=Ea(n),a=r[e.TOP];a&&a.color!==`none`&&a.style!==`none`&&t(i,e.TOP,a);let o=r[e.LEFT];o&&o.color!==`none`&&o.style!==`none`&&t(i,e.LEFT,o)}}*[Symbol.iterator](){for(let[t,n]of this._.entries()){let r=Ea(t),i=n[e.TOP];i&&i.color!==`none`&&i.style!==`none`&&(yield[r,e.TOP,i]);let a=n[e.LEFT];a&&a.color!==`none`&&a.style!==`none`&&(yield[r,e.LEFT,a])}}fillGridLines(t){let[n,r]=t[0],[i,a]=t[1];for(let t=n;t<=i;t++)for(let n=r;n<=a;n++)this.set([t,n],e.TOP,Oa),this.set([t,n],e.LEFT,Oa)}};function ka(e){return Aa(e.v)}function Aa(e){return e&&typeof e==`object`}const ja=`#282b3e`,Ma=`#f5f5f5`,Na=`#d8d9e5`,Pa={fontFamily:`Calibri`,fontSize:11},Fa={...Pa,color:ja},Ia={...Pa,fillColor:Ma,color:ja,borderTopColor:Na,borderTopStyle:`medium`,borderBottomColor:Na,borderBottomStyle:`medium`,borderLeftColor:Na,borderLeftStyle:`medium`,borderRightColor:Na,borderRightStyle:`medium`,horizontalAlignment:`center`,verticalAlignment:`bottom`,fontSize:11},La={fillColor:Ma,patternColor:Na,patternStyle:`lightDown`},Ra={name:`Office`,colorScheme:{name:`Office`,dk1:{type:`system`,value:`windowText`},lt1:{type:`system`,value:`window`},dk2:{type:`srgb`,value:`44546A`},lt2:{type:`srgb`,value:`E7E6E6`},accent1:{type:`srgb`,value:`4472C4`},accent2:{type:`srgb`,value:`ED7D31`},accent3:{type:`srgb`,value:`A5A5A5`},accent4:{type:`srgb`,value:`FFC000`},accent5:{type:`srgb`,value:`5B9BD5`},accent6:{type:`srgb`,value:`70AD47`},hlink:{type:`srgb`,value:`0563C1`},folHlink:{type:`srgb`,value:`954F72`}},fontScheme:{name:`Office`,major:{latin:{typeface:`Aptos Display`},eastAsian:{typeface:``},complexScript:{typeface:``}},minor:{latin:{typeface:`Aptos Narrow`},eastAsian:{typeface:``},complexScript:{typeface:``}}}},za=[`color`,`fillColor`,`patternColor`,`borderTopColor`,`borderLeftColor`,`borderBottomColor`,`borderRightColor`];var Ba=class{_;constructor(){this._=new Map}clear(){this._.clear()}setMerges(e){this.clear();for(let t of e){let e=c(t);if(!e||e.left==null||e.top==null||e.bottom==null||e.right==null)continue;let n=K(e.left,e.top),r=Object.freeze({top:e.top,left:e.left,bottom:e.bottom,right:e.right});this._.set(n,r)}}find(e,t){for(let n of this)if(n.left<=e&&n.right>=e&&n.top<=t&&n.bottom>=t)return n}*[Symbol.iterator](){for(let e of this._.values())yield e}getByCellId(e){if(e){let t=c(e);if(t&&t.left!=null&&t.top!=null){let e=K(t.left,t.top);return this._.get(e)??null}}return null}};function Va(e,t=!1){let[n,r]=e.getSize();if(e.merged_cells.forEach(e=>{let t=c(e);t&&t.right!=null&&t.right>=n&&(n=t.right+1),t&&t.bottom!=null&&t.bottom>=r&&(r=t.bottom+1)}),t){if(e.columns&&e.columns.length){let t=e.columns.at(-1)?.end??1;t>n&&(n=t)}if(e.rows&&e.rows.length){let t=e.rows.at(-1)?.end??1;t>r&&(r=t)}}return[n,r]}const Ha=1.17,Ua=1.3;function Wa(e,t,n,r=1,i=!1){let a=[],o=(e,t,n,r)=>{let i={index:e-1,start:t,size:n,hidden:!1,end:t+n};return r!=null&&(i.style=r),a[e-1]=i},s=0,c=1,l=n*r;for(let t of e){for(;c<t.start;)o(c,s,l),c++,s+=l;for(c=t.start;c<=t.end;c++){let e=!t.size&&i?l:(t.size??n)*r,a=o(c,s,e,t.s);t.size||(a.hidden=!0),s+=e}}for(;c<=t;)o(c,s,l),c++,s+=l;return a}function Ga(e){for(let t=e.length-1;t>=0;t--)if(e[t].size>0)return t;return-1}var Ka=class e{defaultCellHeight=21;defaultCellWidth=76;tilt=[0,0];viewBox={top:0,left:0,bottom:xa,right:G};renderBox={top:0,left:0,bottom:xa,right:G};col;row;width;height;lastSizedColIndex=-1;lastSizedRowIndex=-1;constructor(){this.col=[],this.width=0,this.row=[],this.height=0}get viewWidth(){let e=this.getCellRect(this.viewBox.left,this.viewBox.top);return this.getCellRect(this.viewBox.right,this.viewBox.bottom).right-e.left}get viewHeight(){let e=this.getCellRect(this.viewBox.left,this.viewBox.top);return this.getCellRect(this.viewBox.right,this.viewBox.bottom).bottom-e.top}get viewLeft(){return this.getCol(this.viewBox.left).start}get viewTop(){return this.getCol(this.viewBox.left).start}get rows(){return this.row.length}get columns(){return this.col.length}_offsetDims(e,t,n){let r=Array(e);for(let i=e-1;i>=0;i--){let a=t[i]||n;i===e-1?r[i]=a:r[i]=a+r[i+1]}return r}toMeasure(e,t,n,r=10,i=1/0){if((e<0||!isFinite(e))&&(e=0),e<=n){let n=t.find(t=>e>=t.start&&e<=t.end);if(n)return n}let a=t[t.length-1],o=r<1?100:r;if(!a){let t=Math.floor(e/o);return{index:t,start:t*o,size:r,end:(t+1)*o,hidden:!1}}if(r<1||a.index>=i)return a;let s=e-a.end,c=Math.ceil(s/o)+a.index;return{index:c,start:c*o-o,size:r,end:c*o,hidden:!1}}getCol(e){let t=this.columns;if(e<t)return this.col[e];let n=0;t&&(n=this.col[t-1].end);let r=n+(e-t)*this.defaultCellWidth;return{index:e,size:this.defaultCellWidth,start:r,end:r+this.defaultCellWidth,hidden:!1}}toCol(e){return this.toMeasure(e,this.col,this.width,this.defaultCellWidth,G)}getRow(e){let t=this.rows;if(e<t)return this.row[e];let n=0;t&&(n=this.row[t-1].end);let r=n+(e-t)*this.defaultCellHeight;return{index:e,size:this.defaultCellHeight,start:r,end:r+this.defaultCellHeight,hidden:!1}}toRow(e){return this.toMeasure(e,this.row,this.height,this.defaultCellHeight,xa)}dims(e,t){let n=this.getCol(e),r=this.getRow(t);return{index:[e,t],size:[n.size,r.size],start:[n.start,r.start],end:[n.end,r.end]}}getCellRect(e,t){let n=this.getCol(e),r=this.getRow(t),i=this.getCol(this.viewBox.left),a=this.getRow(this.viewBox.top);return new W(n.start-i.start,r.start-a.start,n.size,r.size)}getColSize(e){let t=this.getCol(e),n=this.getCol(this.viewBox.left);return{index:t.index,size:t.size,hidden:!!t.hidden,start:t.start-n.start,end:t.end-n.start}}getRowSize(e){let t=this.getRow(e),n=this.getRow(this.viewBox.top);return{index:t.index,size:t.size,hidden:!!t.hidden,start:t.start-n.start,end:t.end-n.start}}rangeToRect(e){let t=this.getCol(e.left),n=e.right===e.left?t:this.getCol(e.right),r=this.getRow(e.top),i=e.top===e.bottom?r:this.getRow(e.bottom),a=this.getCol(this.viewBox.left),o=this.getRow(this.viewBox.top);return new W(t.start-a.start,r.start-o.start,n.end-t.start,i.end-r.start)}rectToRange(e){let t=this.toRow(e.top).index,n=this.toCol(e.left).index;return{top:t,left:n,bottom:e.bottom===e.top?t:Math.max(0,this.toRow(e.bottom).index),right:e.right===e.left?n:Math.max(0,this.toCol(e.right).index)}}setView(e,t,n,r){let i=new W(e,t,n,r);this.viewBox=this.rectToRange(i),this.renderBox={top:this.viewBox.top,left:this.viewBox.left,right:this._clampTail(this.viewBox.right,this.col,this.lastSizedColIndex,this.defaultCellWidth,G),bottom:this._clampTail(this.viewBox.bottom,this.row,this.lastSizedRowIndex,this.defaultCellHeight,xa)},this.tilt=[this.getCol(this.viewBox.left).start-e,this.getRow(this.viewBox.top).start-t]}_clampTail(e,t,n,r,i){let a=t[t.length-1];return r<1||a&&a.index>=i?Math.min(e,Math.max(n,0)):e}addHeights(e,t,n=16,r=!1){this.row=Wa(e,t,n,Ua,r),this.defaultCellHeight=n*Ua,this.height=this.row.at(-1)?.end||0,this.lastSizedRowIndex=Ga(this.row)}addWidths(e,t,n=65,r=!1){this.col=Wa(e,t,n,Ha,r),this.defaultCellWidth=n*Ha,this.width=this.col.at(-1)?.end||0,this.lastSizedColIndex=Ga(this.col)}static from(t,n,r=!1){let i=new e,a=n.getSheet(t.sheetName);if(a){let[e,t]=Va(a,!0);i.addHeights(a.rows??[],t,a.defaults?.rowHeight,r),i.addWidths(a.columns??[],e,a.defaults?.colWidth,r)}return i}};function*qa(e){for(let t=e.left;t<=e.right;t++)for(let n=e.top;n<=e.bottom;n++)yield[t,n]}const Ja={dashDot:{lineWidth:.5,lineDash:[7,3,3,3]},dashDotDot:{lineWidth:.5,lineDash:[7,3,3,3,3,3]},dashed:{lineWidth:.5,lineDash:[3,3,3,3]},dotted:{lineWidth:.5,lineDash:[3,3,3,3]},double:{lineWidth:.8,lineDash:null,gap:1,slant:0},hair:{lineWidth:.5,lineDash:null},medium:{lineWidth:1.5,lineDash:null},mediumDashDot:{lineWidth:2,lineDash:[7,3,3,3]},mediumDashDotDot:{lineWidth:1.5,lineDash:[7,3,3,3,3,3]},mediumDashed:{lineWidth:1.5,lineDash:[7,3]},slantDashDot:{lineWidth:1,lineDash:[7,1,3,1],gap:0,slant:.5},thick:{lineWidth:3,lineDash:null},thin:{lineWidth:.5,lineDash:null},none:{lineWidth:0,lineDash:null},default:{lineWidth:1,lineDash:null}},Ya=e=>e&&typeof e==`object`;function Xa(e){return e==null||e===``?`left`:typeof e==`boolean`||Ya(e)?`center`:typeof e==`number`?`right`:`left`}function Za(e,t){let n;if(typeof window<`u`&&`OffscreenCanvas`in window)n=new OffscreenCanvas(e,t);else if(typeof OffscreenCanvas<`u`)n=new OffscreenCanvas(e,t);else if(typeof Canvas<`u`)n=new Canvas(e,t);else if(typeof document<`u`)n=document.createElement(`canvas`),n.width=e,n.height=t;else throw Error(`No canvas implementation available`);return n}const Qa=new Map;Qa.set(`none`,[0,0,0,0]);function $a(e){let t=e.toLowerCase(),n=Qa.get(t);if(n)return n;let r=Za(1,1).getContext(`2d`);if(!r)return[0,0,0,0];r.clearRect(0,0,1,1),r.fillStyle=`#000`,r.fillStyle=e;let i=r.fillStyle;if(r.fillStyle=`#fff`,r.fillStyle=e,i!==r.fillStyle)return[0,0,0,0];r.fillRect(0,0,1,1);let a=r.getImageData(0,0,1,1).data,o=[a[0],a[1],a[2],a[3]];return Qa.set(t,o),o}function eo(e,t=null,n=null){let r=Za(8,8),i=r.getContext(`2d`);if(i){let r=p(e,$a(t??`rgba(0,0,0,1)`),$a(n??`rgba(0,0,0,0)`)),a=i.createImageData(8,8);a.data.set(r),i.putImageData(a,0,0)}return r}let J,to=1.2;const no=1.4;function ro(e=null){return e&&(J=e),J}function io(e){to=e}function ao(e,t,n=null){return e&&e[t]?e[t]:n}function oo(e){let t=ao(e,`fontSize`,11);return Math.round(t*to)}function so(e){let t=``;ao(e,`italic`,!1)===!0&&(t+=`italic `),ao(e,`bold`,!1)===!0&&(t+=`bold `);let n=oo(e);t+=n+`px/`+Math.round(n*no)+`px `;let r=ao(e,`fontFamily`,`Calibri`);return t+=ya(String(r)),t}function co(e,t){return lo(e&&typeof e==`object`?e.v:e,e?.z??``,t)}function lo(e,t,r){let i,a=typeof e;if(e==null||e===``)i=``;else if(a===`boolean`||Aa(e))i=String(e).toUpperCase();else try{i=n(t||`General`,e,{locale:r})}catch{i=`#########`}return i}function uo(e,t){if(t)try{return l(t,e,{indexColors:!0})}catch{return null}return null}function fo(e,t,n){J.restore();let r=co(e,n);return J.font=so(t||Fa),J.measureText(r).width}function po(e,t,n,r){let i=ao(r,`underline`,`none`);if(i!==`none`){let a=ao(r,`color`,ja),[o,s]=e;J.beginPath(),J.strokeStyle=String(a),J.lineWidth=.7,i===`single`?(J.translate(0,.5),J.moveTo(o,s+1),J.lineTo(o+t,s+1)):i===`singleAccounting`?(J.translate(0,.5),J.moveTo(8,s+1),J.lineTo(8+n-16,s+1)):i===`double`?(J.moveTo(o,s+2),J.lineTo(o+t,s+2),J.moveTo(o,s+.5),J.lineTo(o+t,s+.5)):i===`doubleAccounting`&&(J.moveTo(8,s+2),J.lineTo(8+n-16,s+2),J.moveTo(8,s+.5),J.lineTo(8+n-16,s+.5)),J.stroke(),J.closePath()}}function mo(e,t,n,r,i){let a=t.width-8;J.beginPath(),J.rect(.5,.5,t.width,t.height),J.clip();let o=oo(n),s=Math.round(o*no),c=new ma({width:a,font:so(n||Fa),align:r,valign:i}).linebreak(e),l=4,u=0;r===`right`?l=t.width-c.width-4:r===`center`&&(l=(t.width-c.width)/2),i===`bottom`?u=t.height-c.height:i===`center`&&(u=(t.height-c.height)/2),c.forEach((e,i)=>{let a=u+i*s+s*.5,d=0,f=e.width;r===`right`?d+=c.width-f:r===`center`&&(d+=c.width/2-f/2);let p=a+Math.floor(o*.35)+.5;po([l+d,p],f,t.width,n),J.textBaseline=`middle`,e.reduce((e,t)=>{J.font=String(t.font);let n=t.font.baseline?o*-t.font.baseline+o*.15:0;return J.fillText(t.value,e+d,a+n),e+t.width},l)})}function ho(e,t,n){let r=n.cellRect,i=n.clipRect||r,a=n.locale||`en-US`;J.save();let o=ao(t,`numberFormat`,`General`),s=lo(e,o,a);if(s){let n=Xa(e),a=ao(t,`horizontalAlignment`,n);a.toLowerCase()===`general`&&(a=n);let c=ao(t,`verticalAlignment`,`bottom`);if(J.font=so(t),J.fillStyle=uo(e,o)??String(ao(t,`color`,`#282b3e`)),ao(t,`wrapText`,!1))J.translate(r.x,r.y),mo(s,r,t,a,c);else{J.translate(i.x,i.y),J.save(),J.beginPath(),J.rect(.5,.5,i.width,i.height),J.clip(),J.closePath(),J.textBaseline=`middle`;let e=J.measureText(s).width,n=oo(t),o=n*no,l=o*.5;c===`bottom`?l=r.height-o*.5:c===`center`&&(l=r.height/2);let u=4;a===`center`?u=r.x-i.x+r.width/2-e/2:a===`right`&&(u=i.width-e-4),J.fillText(s,u,l),J.closePath();let d=l+Math.floor(n*.35)+.5;po([u,d],e,r.width,t),J.restore()}}J.restore()}function go(e,t,n,r=1,i=[],a=1){J.save(),J.globalAlpha=a??1,J.beginPath(),J.strokeStyle=n||`#d8d9e5`,J.lineWidth=r,J.setLineDash(i),J.moveTo(e[0],e[1]),J.lineTo(t[0],t[1]),J.stroke(),J.setLineDash([]),J.closePath(),J.globalAlpha=1,J.restore()}function _o(e){J.save(),J.translate(e.x,e.y),(e.width<6||e.height<6)&&(J.beginPath(),J.rect(0,0,e.width,e.height),J.clip()),J.fillStyle=`#d93025`,J.beginPath(),J.moveTo(0,0),J.lineTo(6,0),J.lineTo(0,6),J.fill(),J.restore()}function vo(e){J.save(),J.translate(e.x+e.width,e.y),(e.width<6||e.height<6)&&(J.beginPath(),J.rect(-e.width,0,e.width,e.height),J.clip()),J.fillStyle=`#fcbc03`,J.beginPath(),J.moveTo(0,0),J.lineTo(-6,0),J.lineTo(0,6),J.fill(),J.restore()}function yo(e,t,n,r,i){let a=n+r*.5,o=i?1:2,s=i?4:8,c=n,l=n,u=-n,d=-n;return e&o&&!(e&s)?l=-a:e&s&&!(e&o)?c=-a:!(e&o)&&!(e&s)&&(c=0,l=0),t&o&&!(t&s)?d=a:t&s&&!(t&o)?u=a:!(t&o)&&!(t&s)&&(u=0,d=0),[c,l,u,d]}function bo(e,t,n,r,i=0,a=0,o=1){let s=Ja[n]||Ja.thin,c=s.lineDash||[],l=s.lineWidth,u=s.slant||0,d=s.gap||(u?l*.5:0),f=r||`#282b3e`;if(d||u){let[n,r]=e,[s,p]=t;if(r===p){let[e,t,m,h]=u?[0,0,0,0]:yo(i,a,l,d,!0);go([n+u+e,r-d],[s+u+m,p-d],f,l,c,o),go([n-u+t,r+d],[s-u+h,p+d],f,l,c,o)}else{let[e,t,m,h]=u?[0,0,0,0]:yo(i,a,l,d,!1);go([n-d,r+u+e],[s-d,p+u+m],f,l,c,o),go([n+d,r-u+t],[s+d,p-u+h],f,l,c,o)}}else go(e,t,f,l,c,o)}function xo(e,t){J.save(),t.fillColor&&(J.globalAlpha=t.fillOpacity??1,J.fillStyle=t.fillColor||`transparent`,J.fillRect(e.x,e.y,e.width,e.height),J.globalAlpha=1),J.restore()}function So(e,t){J.save(),t||={};let n=eo(t.patternStyle,t.patternColor,t.fillColor),r=J.createPattern(n,`repeat`);r&&(J.fillStyle=r),J.fillRect(e.x,e.y,e.width,e.height),J.restore()}function Co(e,t){J.save(),J.translate(e.x,e.y),t&&(J.fillStyle=t,J.fillRect(-.2,-.2,e.width+.4,e.height+.4)),J.restore()}function wo(e){let t=c(e);if(t&&t.top!=null&&t.left!=null)return[t.top,t.left];throw Error(`Invalid A1-reference`)}function Y(e){return{type:`srgb`,value:e}}function X(e,t=`thin`){return{borderTopColor:e,borderTopStyle:t,borderBottomColor:e,borderBottomStyle:t,borderLeftColor:e,borderLeftStyle:t,borderRightColor:e,borderRightStyle:t}}function To(e,t,n){return{table:{borderTopColor:e,borderTopStyle:`thin`,borderBottomColor:e,borderBottomStyle:`thin`},header:{borderBottomColor:e,borderBottomStyle:`thin`,color:n??e,bold:!0},footer:{borderTopColor:e,borderTopStyle:`thin`,color:n??e,bold:!0},cell:{color:n??e},altRow:{fillColor:t},altCol:{fillColor:t},emFirst:{bold:!0},emLast:{bold:!0}}}function Eo(e){return{table:X(e),header:{fillColor:e,color:Y(`ffffff`),bold:!0},footer:{borderTopColor:e,borderTopStyle:`double`,bold:!0},altRow:{borderTopColor:e,borderTopStyle:`thin`,borderBottomColor:e,borderBottomStyle:`thin`},altCol:{borderLeftColor:e,borderLeftStyle:`thin`,borderRightColor:e,borderRightStyle:`thin`},emFirst:{bold:!0},emLast:{bold:!0}}}function Do(e,t){return{table:X(e),header:{bold:!0,fillColor:Y(`ffffff`),...X(e),borderBottomColor:e,borderBottomStyle:`medium`},cell:{...X(e)},footer:{...X(e),borderTopColor:e,borderTopStyle:`double`,bold:!0},altRow:{fillColor:t},altCol:{fillColor:t},emFirst:{bold:!0},emLast:{bold:!0}}}function Oo(e,t,n){return{table:X(n),header:{borderBottomColor:n,borderBottomStyle:`thin`,fillColor:e,color:Y(`ffffff`),bold:!0},footer:{borderTopColor:n,borderTopStyle:`double`,bold:!0},cell:{borderTopColor:n,borderTopStyle:`thin`,borderBottomColor:n,borderBottomStyle:`thin`},altRow:{fillColor:t},altCol:{fillColor:t},emFirst:{bold:!0},emLast:{bold:!0}}}function ko(e,t,n){return{header:{...X(Y(`ffffff`)),borderBottomColor:Y(`ffffff`),borderBottomStyle:`thick`,fillColor:e,color:Y(`ffffff`),bold:!0},footer:{...X(Y(`ffffff`)),borderTopStyle:`thick`,fillColor:e,color:Y(`ffffff`),bold:!0},cell:{...X(Y(`ffffff`)),fillColor:t},altRow:{fillColor:n},altCol:{fillColor:n},emFirst:{fillColor:e,color:Y(`ffffff`),bold:!0},emLast:{fillColor:e,color:Y(`ffffff`),bold:!0}}}function Ao(e){return{table:{borderTopColor:Y(`000000`),borderTopStyle:`medium`,borderBottomColor:Y(`000000`),borderBottomStyle:`medium`},header:{fillColor:e,color:Y(`ffffff`),bold:!0},cell:{...X(Y(`000000`))},altRow:{fillColor:Y(`dddddd`)},altCol:{fillColor:Y(`dddddd`)},footer:{...X(Y(`000000`)),borderTopColor:Y(`000000`),borderTopStyle:`double`},emFirst:{fillColor:e,color:Y(`ffffff`),bold:!0},emLast:{fillColor:e,color:Y(`ffffff`),bold:!0}}}function jo(e,t,n){return{cell:{...X(n),fillColor:e},header:{...X(n),fillColor:e,bold:!0},footer:{...X(n),borderTopStyle:`medium`,fillColor:e,bold:!0},altRow:{fillColor:t},altCol:{fillColor:t},emFirst:{bold:!0},emLast:{bold:!0}}}function Mo(e,t){return{header:{borderBottomColor:Y(`ffffff`),borderBottomStyle:`medium`,fillColor:Y(`000000`),color:Y(`ffffff`),bold:!0},footer:{borderTopColor:Y(`ffffff`),borderTopStyle:`medium`,fillColor:Y(`000000`),color:Y(`ffffff`),bold:!0},cell:{color:Y(`ffffff`),fillColor:e},altRow:{fillColor:t},altCol:{fillColor:t},emFirst:{fillColor:t,borderRightColor:Y(`ffffff`),borderRightStyle:`medium`,bold:!0},emLast:{fillColor:t,borderLeftColor:Y(`ffffff`),borderLeftStyle:`medium`,bold:!0}}}function No(e,t,n){return{header:{fillColor:e,color:Y(`ffffff`)},footer:{borderTopColor:Y(`000000`),borderTopStyle:`double`,fillColor:t,bold:!0},cell:{fillColor:t},altRow:{fillColor:n},altCol:{fillColor:n},emFirst:{bold:!0},emLast:{bold:!0}}}const Po={TableStyleLight1:To(Y(`000000`),Y(`dddddd`)),TableStyleLight2:To(Y(`134c6f`),Y(`b4e1f3`)),TableStyleLight3:To(Y(`e25a26`),Y(`f9dccc`),Y(`ae3c11`)),TableStyleLight4:To(Y(`165a1a`),Y(`b6efbc`)),TableStyleLight5:To(Y(`168ccc`),Y(`c0e9fb`),Y(`10628d`)),TableStyleLight6:To(Y(`8c1180`),Y(`efc1ec`),Y(`63105d`)),TableStyleLight7:To(Y(`409b23`),Y(`d2f1c6`),Y(`306d1a`)),TableStyleLight8:Eo(Y(`000000`)),TableStyleLight9:Eo(Y(`134c6f`)),TableStyleLight10:Eo(Y(`e25a26`)),TableStyleLight11:Eo(Y(`165a1a`)),TableStyleLight12:Eo(Y(`168ccc`)),TableStyleLight13:Eo(Y(`8c1180`)),TableStyleLight14:Eo(Y(`409b23`)),TableStyleLight15:Do(Y(`000000`),Y(`dddddd`)),TableStyleLight16:Do(Y(`134c6f`),Y(`b4e1f3`)),TableStyleLight17:Do(Y(`e25a26`),Y(`f9dccc`)),TableStyleLight18:Do(Y(`165a1a`),Y(`b6efbc`)),TableStyleLight19:Do(Y(`168ccc`),Y(`c0e9fb`)),TableStyleLight20:Do(Y(`8c1180`),Y(`efc1ec`)),TableStyleLight21:Do(Y(`409b23`),Y(`d2f1c6`)),TableStyleMedium1:Oo(Y(`000000`),Y(`dddddd`),Y(`000000`)),TableStyleMedium2:Oo(Y(`134c6f`),Y(`b4e1f3`),Y(`39a3da`)),TableStyleMedium3:Oo(Y(`e25a26`),Y(`f9dccc`),Y(`ec9870`)),TableStyleMedium4:Oo(Y(`165a1a`),Y(`b6efbc`),Y(`3ece47`)),TableStyleMedium5:Oo(Y(`168ccc`),Y(`c0e9fb`),Y(`52c0f0`)),TableStyleMedium6:Oo(Y(`8c1180`),Y(`efc1ec`),Y(`cd50c2`)),TableStyleMedium7:Oo(Y(`409b23`),Y(`d2f1c6`),Y(`7ed560`)),TableStyleMedium8:ko(Y(`000000`),Y(`dddddd`),Y(`bbbbbb`)),TableStyleMedium9:ko(Y(`134c6f`),Y(`b4e1f3`),Y(`73c0e7`)),TableStyleMedium10:ko(Y(`e25a26`),Y(`f9dccc`),Y(`f4ba9c`)),TableStyleMedium11:ko(Y(`165a1a`),Y(`b6efbc`),Y(`74df7b`)),TableStyleMedium12:ko(Y(`168ccc`),Y(`c0e9fb`),Y(`84d5f7`)),TableStyleMedium13:ko(Y(`8c1180`),Y(`efc1ec`),Y(`dc87d6`)),TableStyleMedium14:ko(Y(`409b23`),Y(`d2f1c6`),Y(`a9e391`)),TableStyleMedium15:Ao(Y(`000000`)),TableStyleMedium16:Ao(Y(`134c6f`)),TableStyleMedium17:Ao(Y(`e25a26`)),TableStyleMedium18:Ao(Y(`165a1a`)),TableStyleMedium19:Ao(Y(`168ccc`)),TableStyleMedium20:Ao(Y(`8c1180`)),TableStyleMedium21:Ao(Y(`409b23`)),TableStyleMedium22:jo(Y(`dddddd`),Y(`bbbbbb`),Y(`000000`)),TableStyleMedium23:jo(Y(`b4e1f3`),Y(`73c0e7`),Y(`39a4da`)),TableStyleMedium24:jo(Y(`f9dccc`),Y(`f4ba9c`),Y(`ed9870`)),TableStyleMedium25:jo(Y(`b6efbc`),Y(`74df7b`),Y(`3ecf47`)),TableStyleMedium26:jo(Y(`c0e9fb`),Y(`84d5f7`),Y(`52c0f1`)),TableStyleMedium27:jo(Y(`efc1ec`),Y(`dc87d6`),Y(`cd50c2`)),TableStyleMedium28:jo(Y(`d2f1c6`),Y(`a9e391`),Y(`7ed560`)),TableStyleDark1:Mo(Y(`606060`),Y(`313131`)),TableStyleDark2:Mo(Y(`134d6f`),Y(`0f384e`)),TableStyleDark3:Mo(Y(`e25b26`),Y(`af3b11`)),TableStyleDark4:Mo(Y(`175a1b`),Y(`114113`)),TableStyleDark5:Mo(Y(`158ccc`),Y(`11628d`)),TableStyleDark6:Mo(Y(`8d1181`),Y(`640f5d`)),TableStyleDark7:Mo(Y(`409b22`),Y(`306c19`)),TableStyleDark8:No(Y(`000000`),Y(`dddddd`),Y(`bbbbbb`)),TableStyleDark9:No(Y(`e25b26`),Y(`b5e0f3`),Y(`73c0e7`)),TableStyleDark10:No(Y(`158ccc`),Y(`b5f0bc`),Y(`74df7b`)),TableStyleDark11:No(Y(`409b22`),Y(`eec0eb`),Y(`dc87d6`))},Fo=[[`font-name`,`fontFamily`],[`font-size`,`fontSize`],[`font-color`,`color`],[`bold`,`bold`],[`italic`,`italic`],[`underline`,`underline`],[`fill-color`,`fillColor`],[`border-left-style`,`borderLeftStyle`],[`border-left-color`,`borderLeftColor`],[`border-right-style`,`borderRightStyle`],[`border-right-color`,`borderRightColor`],[`border-top-style`,`borderTopStyle`],[`border-top-color`,`borderTopColor`],[`border-bottom-style`,`borderBottomStyle`],[`border-bottom-color`,`borderBottomColor`],[`horizontal-alignment`,`horizontalAlignment`],[`vertical-alignment`,`verticalAlignment`],[`wrap-text`,`wrapText`],[`shrink-to-fit`,`shrinkToFit`],[`number-format`,`numberFormat`],[`stroke-opacity`,`strokeOpacity`],[`fill-opacity`,`fillOpacity`]];function Io(e){if(typeof e==`object`&&e){let t=e;for(let[e,n]of Fo)t[e]!=null&&(t[n]=t[e])}return e}const Lo=(e,t,n)=>Math.max(e,Math.min(t,n)),Ro=[[`top`,q.TOP],[`left`,q.LEFT],[`bottom`,q.BOTTOM],[`right`,q.RIGHT]],zo={top:[`borderTopColor`,`borderTopStyle`],bottom:[`borderBottomColor`,`borderBottomStyle`],left:[`borderLeftColor`,`borderLeftStyle`],right:[`borderRightColor`,`borderRightStyle`]},Bo={color:{type:`srgb`,value:`999999`},horizontalAlignment:`left`,verticalAlignment:`bottom`,fillColor:void 0,numberFormat:`@`,wrapText:!1,bold:!1,italic:!1,underline:`none`};function Vo(e){return e===`centerContinuous`?e=`center`:(e===`distributed`||e===`justify`||e===`fill`||e===`general`)&&(e=`left`),e}var Ho=class{workbook;sheetName;highlightColor;locale;viewRef;headers;headerStyle={...Ia};hiddenStyle={...Ia,...La};allowRangeSelections;allowHeaderSelections;showHidden=!1;showValuelessFormulas=!1;showAnnotations=!0;skipCells;borders;merges;fontAdjust;scale;tables=new Map;annotatedCells;onCellContent;constructor(e={}){this.workbook=null,this.sheetName=``,this.highlightColor=`#39c6d9`,this.viewRef=new Sa(`A1`),this.headers=!0,this.allowRangeSelections=!0,this.allowHeaderSelections=!0,this.locale=`en-us`,this.setOptions(e),this.skipCells=new Map,this.borders=new q,this.merges=new Ba,this.scale=new Ka,this.fontAdjust=1.2,this.annotatedCells=new Set,this.onCellContent=e.onCellContent}setOptions(e){this.headers=e.headers??this.headers,this.locale=e.locale??this.locale,this.highlightColor=e.highlightColor??this.highlightColor,this.headerStyle=Object.assign({},Ia,e.headerStyle),this.hiddenStyle=Object.assign({},this.headerStyle,La,e.hiddenStyle),this.allowRangeSelections=e.allowRangeSelections??!0,this.allowHeaderSelections=e.allowHeaderSelections??!0,this.showHidden=e.showHidden??!1,this.showValuelessFormulas=e.showValuelessFormulas??!1,this.showAnnotations=e.showAnnotations??!0}getFullSheetRef(){let e=this.workbook?.getSheet(this.sheetName);if(!e)throw Error(`sheet "${this.sheetName}" not found`);let t=Va(e);return new Sa({top:0,left:0,right:Math.max(0,t[0]-1),bottom:Math.max(0,t[1]-1)},{workbookName:this.workbook?.name,sheetName:e.name})}updateTables(){let e=new Map;this.workbook?.tables.getAll().map(t=>{if(t.sheetName===this.sheetName){let n=new Sa(t.ref);if(n){let r=n.range;for(let[n,i]of qa(r))e.set(K(n,i),[t.name,r])}}}),this.tables=e}updateAnnotatedCells(){let e=this.getCurrentSheet(),t=new Set;if(e&&this.workbook){if(this.workbook.comments)for(let n of this.workbook.comments.get(e.name,{excludeReplies:!0,excludeResolved:!0})){let[e,r]=wo(n.ref);t.add(K(r,e))}if(this.workbook.notes)for(let n of this.workbook.notes.get(e.name)){let[e,r]=wo(n.ref);t.add(K(r,e))}}this.annotatedCells=t}updateScale(){this.workbook&&(this.viewRef=this.getFullSheetRef(),this.scale=Ka.from(this.viewRef,this.workbook,this.showHidden),this.updateTables(),this.updateAnnotatedCells())}getVisibleColumns(){let e=[],t=this.getHeadersSize(),n=this.scale.renderBox,[r]=this.scale.tilt;for(let i=n.left;i<=n.right;i++){let n=this.scale.getColSize(i);e.push({index:i,offset:t.width+n.start+r,height:t.height,width:n.size})}return e}getColumnSize(e){return e<0||e>G||e!==Math.trunc(e)?0:this.scale.getColSize(e).size}setColumnSize(e,t){e>=0&&e<=G&&e===Math.trunc(e)&&(this.workbook?.setColumnWidth(this.sheetName,e,t),this.updateScale())}getVisibleRows(){let e=[],t=this.getHeadersSize(),n=this.scale.renderBox,[,r]=this.scale.tilt;for(let i=n.top;i<=n.bottom;i++){let n=this.scale.getRowSize(i);e.push({index:i,offset:t.height+n.start+r,height:n.size,width:t.width})}return e}getRowSize(e){return e<0||e>xa||e!==Math.trunc(e)?0:this.scale.getRowSize(e).size}setRowSize(e,t){e>=0&&e<=xa&&e===Math.trunc(e)&&(this.workbook?.setRowHeight(this.sheetName,e,t/1.3),this.updateScale())}setWorkbook(e){this.workbook=e;let t=e.getSheet(null);if(!t)throw Error(`workbook has no sheets`);this.setSheet(t.name)}setSheet(e){this.sheetName=e,this.viewRef.sheetName=e,this.updateScale()}refToRect(e,t=!0){let n=this.scale.rangeToRect(e.range);if(t){let e=this.getHeadersSize();return new W(n.x,n.y,n.width+e.width,n.height+e.height)}return n}getHeadersSize(){let e=this.headerStyle.fontSize||11;return{height:this.headers?Math.round(e*1.64):0,width:this.headers?Math.round(e*2.27):0}}getCurrentSheet(){return this.workbook?.getSheet(this.viewRef?.sheetName)??null}getColumnStyle(e){let t=this.getCurrentSheet();if(t&&t.columns){let n=e+1,r=t.columns.find(e=>e.start<=n&&n<=e.end);if(r?.s!=null)return this.workbook?.styles.get(r.s)??null}return null}getTableStyle(e,t){let n={},r=this.tables.get(K(e,t));if(r){let[i,a]=r,o=this.workbook?.tables.get(i);if(o){let r=o.jsf.style??{name:`TableStyleMedium2`,showRowStripes:!0},i=Po[r.name??``]??{},s=t-a.top<(o.headerRowCount??0),c=a.bottom-t<(o.totalsRowCount??0);if(s)Object.assign(n,i.header);else if(c)Object.assign(n,i.footer);else{let s=t-a.top-(o.headerRowCount??0),c=s%2,l=(e-a.left)%2;Object.assign(n,i.cell,c||!r.showRowStripes?null:i.altRow,l||!r.showColumnStripes?null:i.altCol,e===a.left&&r.showFirstColumn?i.emFirst:null,e===a.right&&r.showLastColumn?i.emLast:null),s===0&&i.header?.borderBottomStyle&&(n.borderTopColor=i.header.borderBottomColor,n.borderTopStyle=i.header.borderBottomStyle)}if(i.table){let r=[[`top`,t===a.top],[`bottom`,t===a.bottom],[`left`,e===a.left],[`right`,e===a.right]];for(let[e,t]of r)if(t){let[t,r]=zo[e];i.table[r]&&(n[t]=i.table[t],n[r]=i.table[r])}}}}return n}getStyles(e,t){let n=this.getCurrentSheet(),r=n&&n.getCellByCoords(t,e)||null,i=this.getTableStyle(e,t),a=this.workbook?.styles.get(r?.s??0)??{},o=this.getColumnStyle(e),c={...i,...o,...a};r&&r.f!=null&&r.v==null&&this.showValuelessFormulas&&Object.assign(c,Bo);let l=this.workbook?.theme?.get()??Ra;!c.fontFamily&&c.fontScheme&&(c.fontFamily=l.fontScheme[c.fontScheme].latin.typeface||`Aptos Narrow`);let u={};return za.forEach(e=>{if(e in c){let t=c[e];t&&typeof t!=`string`&&(u[e]=`#`+d(s(t,l.colorScheme)))}}),{...c,...u}}getMergeRange(e){return this.merges.getByCellId(e?.M)}resize(e,t){if(!e)return;let n=e.getContext(`2d`,{alpha:!1});if(!n)return;let r,i;if(t)r=t.width,i=t.height;else{let e=this.getHeadersSize(),t=this.scale.rangeToRect(this.viewRef.range);r=t.width+e.width,i=t.height+e.height}r>1e4&&(r=1e4),i>1e4&&(i=1e4);let a=(typeof window>`u`?1:window.devicePixelRatio)||1;e.style&&(e.style.height=i+`px`,e.style.width=r+`px`),e.height=i*a,e.width=r*a,n.scale(a,a)}getCellAt(e,t){let n=this.getCurrentSheet();return n&&n.getCellByCoords(t,e)||null}shouldRenderGridLines(){let e=this.getCurrentSheet();return e?.views?e.views.find(e=>!e.activeLayout||e.activeLayout===`normal`)?.showGridLines??!0:!0}detectBorders(){let e=this.shouldRenderGridLines(),{renderBox:t}=this.scale,n=Lo(0,t.left,G),r=Lo(0,t.right,G),i=Lo(0,t.top,xa),a=Lo(0,t.bottom,xa);if(e){for(let e=n;e<=r+1;e++)for(let t=i;t<=a+1;t++){let n=[e,t];this.borders.set(n,q.TOP,Oa),this.borders.set(n,q.LEFT,Oa)}for(let e=n;e<=r+1;e++)for(let t=i;t<=a+1;t++){let n=this.getStyles(e,t);if(n&&n.fillColor){let n=[e,t];this.borders.set(n,q.TOP,null),this.borders.set(n,q.LEFT,null),this.borders.set(n,q.BOTTOM,null),this.borders.set(n,q.RIGHT,null)}}for(let e of this.merges)for(let t=e.left;t<=e.right;t++)for(let n=e.top;n<=e.bottom;n++){let r=[t,n];n>e.top&&this.borders.set(r,q.TOP,null),t>e.left&&this.borders.set(r,q.LEFT,null)}}for(let e=n;e<=r;e++)for(let t=i;t<=a;t++){let n=this.getStyles(e,t);if(n)for(let[r,i]of Ro){let[a,o]=zo[r],s=n[o],c=n[a]||`#000`;s&&s!==`none`&&this.borders.set([e,t],i,{style:s,color:c})}}}getCellAlignment(e){let t=(this.workbook?.styles.get(e.s??0)??{}).horizontalAlignment;return(t===`general`||!t)&&(t=Xa(e?e.v:null)),t}canOverflow(e){if(!e||typeof e.v!=`string`||!e.v||e.M||(this.workbook?.styles.get(e.s??0)??{}).wrapText)return 0;let t=Vo(this.getCellAlignment(e));return t===`center`||t===`left`?1:-1}absolutePosition(e){let{scale:t}=this,n=t.dims(e.left,e.top),r=t.dims(e.right,e.bottom);return new W(n.start[0],n.start[1],r.end[0]-n.start[0],r.end[1]-n.start[1])}renderCellText(e,t,n=!1){let{scale:r}=this,i=this.getCurrentSheet();if(!i)return;let{skipCells:a,borders:o}=this,s=this.getCellAt(e,t),c=s&&s.v==null&&s.f!=null;if(!s||c&&!this.showValuelessFormulas||s.v===``)return;let l=r.getCol(e),u=this.getStyles(e,t),d=fo(s,u,this.locale)+8,f=Vo(this.getCellAlignment(s)),p=f===`left`||f===`center`?1:-1,m=(d>l.size?p:0)&&this.canOverflow(s);if(n&&!m)return;let h=r.renderBox.left,g=r.renderBox.right;if(m||(h=e,g=e),m&&(f===`left`||f===`center`)){let n=i.nextValueCellByCoords(t,e,`right`);n&&(g=wo(n.id)[1]-1)}if(m&&(f===`right`||f===`center`)){let n=i.nextValueCellByCoords(t,e,`left`);n&&(h=wo(n.id)[1]+1)}let _=l.start,v=l.end;if(m){if(f===`left`&&g>e){let n=r.toCol(l.start+d).index,i=Math.min(g,n??G);v=r.getCol(i).end;for(let n=e+1;n<=i;n++)o.set([n,t],q.LEFT,null),a.set(K(n,t),1)}else if(f===`right`&&h<e){let n=r.toCol(l.end-d).index,i=Math.max(h,n||0);_=r.getCol(i).start;for(let n=e;n>=i;n--)o.set([n,t],q.LEFT,null),a.set(K(n,t),1)}else if(f===`center`){let n=l.start+l.size/2,i=r.toCol(n+d/2).index,s=Math.min(g,i??G);v=r.getCol(s).end;for(let n=e+1;n<=s;n++)o.set([n,t],q.LEFT,null),a.set(K(n,t),1);let c=r.toCol(n-d/2).index,u=Math.max(h,c||0);_=r.getCol(u).start;for(let n=e;n>u;n--)o.set([n,t],q.LEFT,null),a.set(K(n,t),1)}}let y=this.getHeadersSize(),b=r.getCellRect(e,t).translate(y.width,y.height),ee=new W(y.width+_-r.viewLeft,b.y,v-_,b.height),x=s.v;c&&this.showValuelessFormulas&&(x=`=${s.f}`),ho(x,u,{cellRect:b.translate(...r.tilt),clipRect:ee.translate(...r.tilt),locale:this.locale})}renderBackgrounds(){let{scale:e}=this,t=this.getHeadersSize();for(let n of qa(e.renderBox)){let[r,i]=n,a=this.getMergeRange(this.getCellAt(r,i)),o=a?this.getStyles(a.left,a.top):this.getStyles(r,i),s=e.getCellRect(r,i).translate(t.width,t.height).translate(...e.tilt),c=o.fillColor?String(o.fillColor):null,{patternStyle:l}=o;l?So(s,{...o,patternStyle:l}):c&&Co(s,c)}}renderContent(){let{scale:e}=this,t=this.getCurrentSheet();if(!t)return;let n=this.getHeadersSize(),r=e.renderBox;for(let i=r.top;i<=r.bottom;i++){if(r.left>0){let e=t.nextValueCellByCoords(i,r.left,`left`);if(e&&this.canOverflow(e)){let t=c(e.id);t&&t.left!=null&&this.renderCellText(t.left,i,!0)}}if(r.right<G){let e=t.nextValueCellByCoords(i,r.right,`right`);if(e&&this.canOverflow(e)){let t=c(e.id);t&&t.left!=null&&this.renderCellText(t.left,i,!0)}}for(let t=r.left;t<=r.right;t++){if(this.skipCells.has(K(t,i)))continue;let r=this.getCellAt(t,i),a=this.getMergeRange(r);a&&r?.M!==r?.id&&(r=this.getCellAt(a.left,a.top));let o=r?.v==null&&r?.f!=null;if(!r||o&&!this.showValuelessFormulas||r.v===``)continue;let s;if(a){s=e.rangeToRect(a).translate(n.width,n.height).translate(...e.tilt);for(let[e,t]of qa(a))this.skipCells.set(K(e,t),1)}else s=e.getCellRect(t,i).translate(n.width,n.height).translate(...e.tilt);let c=!0;if(s.width>0&&s.height>0){if(this.onCellContent)try{c=this.onCellContent.call(this,{rect:s,cell:r,ctx:ro()})}catch(e){console.error(e)}}else c=!1;c!==!1&&(a?ho(r.v,this.getStyles(t,i),{cellRect:s,locale:this.locale}):this.renderCellText(t,i),this.showAnnotations&&s.width>0&&s.height>0&&this.annotatedCells.has(K(t,i))&&vo(s),ka(r)&&s.width>0&&s.height>0&&_o(s))}}}renderBorders(e){e||=this.borders;let{scale:t}=this,[n,r]=t.tilt,i=this.getHeadersSize();e.forEach((a,o,s)=>{let c=t.getCellRect(a[0],a[1]).translate(i.width,i.height);o===q.TOP?bo([c.x+n,c.y+r],[c.right+n,c.y+r],s.style||`none`,s.color,e.getJoin(a[0],a[1]),e.getJoin(a[0]+1,a[1])):o===q.LEFT&&bo([c.x+n,c.y+r],[c.x+n,c.bottom+r],s.style||`none`,s.color,e.getJoin(a[0],a[1]),e.getJoin(a[0],a[1]+1))})}renderHighlight(e){if(e&&e.range&&(!e.workbookName||e.workbookName===this.workbook?.name)&&(!e.sheetName||e.sheetName===this.sheetName)){Io(e);let t=e.fill||`none`,n=Lo(0,e.fillOpacity??1,1),r=e.stroke||this.highlightColor||`#39c6d9`,i=e.style||`medium`,a=Lo(0,e.strokeOpacity??1,1),o=this.getHeadersSize(),s=this.scale.rangeToRect(e.range).translate(o.width,o.height).translate(...this.scale.tilt);t&&t!==`none`&&t!==`transparent`&&xo(s,{fillOpacity:n,fillColor:t}),s.getBorders().forEach(([e,t,n])=>{bo(e,t,i,r,n[0],n[1],a)})}}renderHeaderBorders(e){let{scale:t}=this,[n,r]=t.tilt,i=this.getHeadersSize(),a=t.renderBox,o=i.height,s=i.width,c=(t,n,r)=>{let[i,a]=t,o=e.getJoin(i,a),s=e.getJoin(i+1,a),c=e.getJoin(i,a+1),l=e.getJoin(i+1,a+1);if(n.includes(q.TOP)){let n=e.get(t,q.TOP),i=r.getTopEdge();bo(i[0],i[1],n.style,n.color,o,s)}if(n.includes(q.BOTTOM)){let n=e.get(t,q.BOTTOM),i=r.getBottomEdge();bo(i[0],i[1],n.style,n.color,c,l)}if(n.includes(q.LEFT)){let n=e.get(t,q.LEFT),i=r.getLeftEdge();bo(i[0],i[1],n.style,n.color,o,c)}if(n.includes(q.RIGHT)){let n=e.get(t,q.RIGHT),i=r.getRightEdge();bo(i[0],i[1],n.style,n.color,s,l)}};for(let e=a.left;e<=a.right;e++){let r=t.getColSize(e);r.size&&c([e+1,0],[q.BOTTOM,q.TOP,q.RIGHT],new W(s+r.start+n+0,0,r.size,o))}for(let e=a.top;e<=a.bottom;e++){let n=t.getRowSize(e);n.size&&c([0,e+1],[q.BOTTOM,q.LEFT,q.RIGHT],new W(0,0+o+n.start+r,s,n.size))}c([0,0],[q.TOP,q.BOTTOM,q.LEFT,q.RIGHT],new W(0,0,s,o))}renderHeaders(){if(!this.headers)return;let e=(e,t,n=!1)=>{if(n){let{patternStyle:n}=this.hiddenStyle;n&&So(e,{...this.hiddenStyle,patternStyle:n}),ho(t,this.hiddenStyle,{cellRect:e})}else xo(e,this.headerStyle),ho(t,this.headerStyle,{cellRect:e})},t=this.headerStyle,n=new q,i=(e,r)=>{for(let[i,a]of Ro){let[o,s]=zo[i],c=t[s]||`none`,l=t[o]||`#000`;c!==`none`&&l!==`transparent`&&n.set([e,r],a,{style:c,color:l})}},a=this.getHeadersSize(),{scale:o}=this,s=o.renderBox,[c,l]=o.tilt;for(let t=s.top;t<=s.bottom;t++){let n=o.getRowSize(t);n.size&&(e(new W(0,a.height+n.start-1+l,a.width,n.size),String(t+1),n.hidden),i(0,t+1))}for(let t=s.left;t<=s.right;t++){let n=o.getColSize(t);n.size&&(e(new W(a.width+n.start+c,0,n.size,a.height),r(t),n.hidden),i(t+1,0))}e(new W(0,0,a.width,a.height),``),i(0,0),this.renderHeaderBorders(n)}toRect(e){let t=this.getHeadersSize(),n=this.scale.tilt;return this.scale.rangeToRect(e).translate(t.width,t.height).translate(n[0],n[1])}invert(e,t=null){let n=this.getHeadersSize();e[0]<n.width&&(e=[n.width+1,e[1]]),e[1]<n.height&&(e=[e[0],n.height+1]);let r=e[0]+(t?.left||0),i=e[1]+(t?.top||0),a=new W(r-n.width,i-n.height,0,0),o=Object.freeze(this.scale.rectToRange(a));return{cellPos:this.merges.find(o.left,o.top)||o,gridPos:o}}rectToRanges(e,t,n){let r=this.allowRangeSelections,i=this.allowHeaderSelections,a=this.getHeadersSize(),o=r&&i&&e[0]<a.width,s=r&&i&&e[1]<a.height,c=this.invert(e,n);if(c){let e=this.invert(t,n);r||(c=e);let i=s||o?c.gridPos:c.cellPos,a=s||o?e.gridPos:e.cellPos;return{focus:e.cellPos,anchor:c.cellPos,selection:{top:s?0:Math.min(i.top,a.top),bottom:s?1048575:Math.max(i.bottom,a.bottom),left:o?0:Math.min(i.left,a.left),right:o?16383:Math.max(i.right,a.right)}}}return null}render(e,t=null,n){if(!e)return;let r=e.getContext(`2d`,{alpha:!1});if(!r)return;let i=(typeof window>`u`?1:window.devicePixelRatio)||1,a=(e.width||e.clientWidth||0)/i,o=(e.height||e.clientHeight||0)/i;if(a<=0||o<=0)return;if(!isFinite(a))throw Error(`Canvas width cannot be infinite: `+a);if(!isFinite(o))throw Error(`Canvas height cannot be infinite: `+o);this.scale.setView(t?.left||0,t?.top||0,a,o),r.fillStyle=`#fff`,r.fillRect(0,0,a,o),ro(r),io(this.fontAdjust),this.skipCells.clear(),this.merges.clear();let s=this.getCurrentSheet();if(s&&this.merges.setMerges(s.merged_cells),this.borders.clear(),this.detectBorders(),this.renderBackgrounds(),this.renderContent(),this.renderBorders(),n)for(let e of n)e&&this.renderHighlight(e);this.renderHeaders(),this.borders.clear(),this.skipCells.clear()}};function Uo(e){return e._recalcState}function Wo(e){return typeof e==`object`&&!!e&&`error`in e&&typeof e.error==`string`}var Z=class{name;description;parameters;_run;constructor(e){this.name=e.name,this.description=e.description,this.parameters=e.parameters,this._run=e.run}execute(e,t){try{return this._run(e,t)}catch(e){return{error:e instanceof Error?e.message:String(e)}}}};function Go(e){if(!e)return{error:`Workbook not found`};let t=e.getWorkbook();return t?{workbook:t}:{error:`Model has no workbook`}}function Ko(e){return ne(`${e}1`)[1]}function qo(e){let t=e.lastIndexOf(`!`);return t>=0?e.slice(t+1):e}function Jo(e){return e instanceof v?`Unable to solve goalSeek: ${e.detail}`:null}var Yo=class extends Error{sheetRef;availableSheets;constructor(e,t){super(`Sheet "${e}" not found. Available sheets: ${t.join(`, `)}`),this.name=`SheetNotFoundError`,this.sheetRef=e,this.availableSheets=t}};function Xo(e){let t=e.match(/^\[([^\]]+)\](.*)$/);return t?{workbookName:t[1]??``,sheetName:t[2]??``}:{workbookName:null,sheetName:e}}function Zo(e,t){let{workbookName:n,sheetName:r}=Xo(e),i=t.resolveSheet(r,n);return i?n?{workbookName:t.resolveWorkbook(n)?.name??n,sheetName:i.name}:{workbookName:null,sheetName:i.name}:null}function Qo(e){let t=e.getWorkbook(),n=[];for(let r of e.getWorkbooks()){let e=t!=null&&r===t;for(let t of r.getSheets())n.push(e?t.name:`[${r.name}]${t.name}`)}return n}function Q(e,n){let r=o(e);if(r){if(r.context&&r.context.length>0){let e=r.context[r.context.length-1]??``,i=r.context.length>1?r.context[0]??null:null,a=i?`[${i}]${e}`:e,o=Zo(a,n);if(o){let e=o.workbookName?[o.workbookName,o.sheetName]:[o.sheetName];return t({...r,context:e})}throw $o(a,n)}return t(r)}let i=e.lastIndexOf(`!`);if(i===-1)return e;let a=e.slice(0,i),s=e.slice(i+1),c=Zo(a,n);if(!c&&a.startsWith(`'`)&&a.endsWith(`'`)&&(c=Zo(a.slice(1,-1),n)),c){let n=c.workbookName?[c.workbookName,c.sheetName]:[c.sheetName],r=o(s);if(r)return t({...r,context:n});let i=o(`X!${s}`);return i?t({...i,context:n}):e}throw $o(a,n)}function $o(e,t){return new Yo(e,Qo(t))}function es(e,t){return e.people.find(e=>e.id===t)?.displayName??t}function ts(e,t){return new x(t,{sheetName:e}).toString()}function ns(e){let t=e.replace(/\s+/g,` `).trim(),n=[...t];return n.length<=100?{preview:t,truncated:!1}:{preview:`${n.slice(0,99).join(``)}…`,truncated:!0}}function rs(e){let t=new Map;for(let n of e)n.parentId===void 0&&t.set(n.id,{root:n,replies:[]});for(let n of e)n.parentId!==void 0&&t.get(n.parentId)?.replies.push(n);return[...t.values()]}function is(e,t){let n=[];for(let r of rs(e.comments.get(t))){let{preview:i,truncated:a}=ns(r.root.text),o={address:ts(t,r.root.ref),kind:`thread`,author:es(e,r.root.personId),preview:i};r.root.datetime!==void 0&&(o.datetime=r.root.datetime),r.replies.length>0&&(o.replyCount=r.replies.length),r.root.resolved!==void 0&&(o.resolved=r.root.resolved),a&&(o.truncated=!0),n.push(o)}for(let r of e.notes.get(t)){let{preview:e,truncated:i}=ns(r.text),a={address:ts(t,r.ref),kind:`note`,author:r.author,preview:e};i&&(a.truncated=!0),n.push(a)}return n}const as=new Z({name:`getComment`,description:'Read the full text of the comment or note on a specific cell, including all replies for threaded comments. Returns kind="none" if the cell has neither. Use after `getComments` to see the body of an entry whose preview was truncated, or when an agent message refers to a specific cell with a TODO/question on it.',parameters:S.object({address:S.string().describe(`Sheet-qualified cell reference, e.g. "'LBO Model'!E46" or "Sheet1!B2". For non-default sheets you must include the sheet name; otherwise the first sheet is assumed.`)}),run:(e,t)=>{let n=Go(e.model);if(`error`in n)return n;let{workbook:r}=n,i=new x(Q(t.address,e.model));if(!i.range)return{error:`Address "${t.address}" is a name reference, not a cell reference.`};let a=i.sheetName||r.getSheets()[0]?.name;if(!a)return{error:`Workbook has no sheets.`};let o=i.getCellId(),s=ts(a,o),c=r.comments.getByCell(a,o);if(c.length>0){let e=c.find(e=>e.parentId===void 0),t={address:s,kind:`thread`,entries:(e?[e,...c.filter(t=>t.parentId===e.id)]:c).map(e=>{let t={author:es(r,e.personId),text:e.text,isReply:e.parentId!==void 0};return e.datetime!==void 0&&(t.datetime=e.datetime),t})};return e?.resolved!==void 0&&(t.resolved=e.resolved),t}let l=r.notes.getByCell(a,o);return l?{address:s,kind:`note`,author:l.author,text:l.text}:{address:s,kind:`none`}}}),os=new Z({name:`getComments`,description:"List the cells in the workbook that have a comment or note attached, with author, kind (threaded comment vs. legacy note), reply count, and a short text preview. Comments are how a reviewer flags TODOs, justifies a number, or asks a question on a specific cell — read them when auditing, debugging, or completing a partly-built workbook. Returns up to 25 entries; pass `offset` to page. Use `getComment` to read the full text or thread for a specific cell.",parameters:S.object({sheet:S.string().optional().describe(`Restrict to a single sheet by name. Omit to list across the whole workbook.`),offset:S.number().int().nonnegative().optional().describe(`Pagination offset; results are returned in pages of 25.`)}),run:(e,t)=>{let n=Go(e.model);if(`error`in n)return n;let{workbook:r}=n,i;if(t.sheet!==void 0){if(!r.getSheet(t.sheet))return{error:`Sheet "${t.sheet}" not found.`};i=[t.sheet]}else i=r.getSheets().map(e=>e.name);let a=[];for(let e of i)a.push(...is(r,e));let o=t.offset??0,s=a.slice(o,o+25),c=o+s.length<a.length,l={comments:s,total:a.length,offset:o,hasMore:c};return c&&(l.nextOffset=o+s.length),l}});function ss(e){let t=e.getWorkbook();if(!t)return{};let n={};for(let e of t.getSheets()){let t=0;for(let n of e.getCells())n.v instanceof v&&t++;t>0&&(n[e.name]=t)}return n}function cs(e,t){let n=new Map,r=e.getWorkbook();if(!r)return{};for(let i of t){let t=new x(i,{ctx:e}),a=t.sheetName||r.getSheets()[0]?.name,o=a?r.getSheet(a):null;if(o&&!t.name?.startsWith(`_xlnm.`))for(let e of t){let t=o.getCellByRange({top:e.top,left:e.left});if(t&&t.v instanceof v){let e=`${t.v}: ${t.v.detail}`,r=n.get(e);r?r.push(t.id):n.set(e,[t.id])}}}return Object.fromEntries(n)}function ls(e,t){return t.map(t=>{let n=new x(t);if(!n.isAddress)throw Error(`Defined-name references are not supported as write targets: "${t}".`);if(n.size!==1)throw Error(`Range references are not supported as write targets: "${t}". Target a single cell.`);let r=n.getCellId(),i=e.getCell(r,n.sheetName||null,n.workbookName||null);return{refId:n.getRefId(),cellId:r,sheetName:n.sheetName,workbookName:n.workbookName,existed:i!==null,f:i?.f??null}})}function us(e,t){for(let n of t){let t=e.getCell(n.cellId,n.sheetName||null,n.workbookName||null);n.existed?(t?.f??null)!==n.f&&e.getWorkbook(n.workbookName||null)?.editCell(n.refId,{f:n.f}):t!==null&&e.clearCells(n.refId)}}function ds(e,t,n=[]){let r=ls(e,n),i=te.capture(e);try{return t(e)}finally{us(e,r),i.applyTo(e)}}function fs(e){let t=new Map;for(let n of e.getCells()){if(!(n.v instanceof v))continue;let r=new x(n.id,{sheetName:e.name}).toString(),i=n.v.detail?`${n.v.name} (${n.v.detail})`:n.v.name,a=t.get(i);a||(a={key:i,cells:[]},t.set(i,a)),a.cells.push(r)}return Array.from(t.values()).sort((e,t)=>t.cells.length-e.cells.length).slice(0,3).map(e=>({key:e.key,count:e.cells.length,cells:e.cells.slice(0,5)}))}const ps=new Z({name:`describeStructure`,description:`Analyzes the spreadsheet and returns a structured description of all data regions, headers, and labels.
|
|
3
3
|
This helps you understand:
|
|
4
4
|
- Where data tables are located (islands/regions)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Cell, CellValue, FormulaError, Model, WorkbookDescription } from "@grid-is/
|
|
1
|
+
import { Cell, CellValue, FormulaError, Model, WorkbookDescription } from "@grid-is/spreadsheet-engine";
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
//#region node_modules/@jsfkit/types/dist/index.d.ts
|
|
4
4
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as runFormula, D as whatIf, E as viewRange, S as readCalculatedValues, T as symbols, _ as isToolError, a as dependents, b as manageSheets, c as editCells, d as generateWorkbookContext, f as getComment, g as inspect, h as goalSeek, i as captureRange, l as fillCells, m as getStyles, n as ToolContext, o as describeStructure, p as getComments, s as editCellStyles, t as SpreadsheetTool, u as findCells, v as listErrors, x as precedents, y as manageRowsAndColumns } from "./index-
|
|
1
|
+
import { C as runFormula, D as whatIf, E as viewRange, S as readCalculatedValues, T as symbols, _ as isToolError, a as dependents, b as manageSheets, c as editCells, d as generateWorkbookContext, f as getComment, g as inspect, h as goalSeek, i as captureRange, l as fillCells, m as getStyles, n as ToolContext, o as describeStructure, p as getComments, s as editCellStyles, t as SpreadsheetTool, u as findCells, v as listErrors, x as precedents, y as manageRowsAndColumns } from "./index-DtYMYL_H.js";
|
|
2
2
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
3
3
|
import { z } from "zod";
|
|
4
4
|
//#region src/session.d.ts
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{C as e,T as t,_ as n,a as r,b as i,c as a,d as o,f as s,g as c,h as l,i as u,l as d,m as f,n as p,o as m,p as h,r as g,s as _,u as v,v as y,w as b,x,y as S}from"./dist-
|
|
1
|
+
import{C as e,T as t,_ as n,a as r,b as i,c as a,d as o,f as s,g as c,h as l,i as u,l as d,m as f,n as p,o as m,p as h,r as g,s as _,u as v,v as y,w as b,x,y as S}from"./dist-Dx48XsYY.js";import{McpServer as C}from"@modelcontextprotocol/sdk/server/mcp.js";import{StdioServerTransport as w}from"@modelcontextprotocol/sdk/server/stdio.js";import{existsSync as T,readFileSync as E,readdirSync as D,writeFileSync as O}from"node:fs";import{basename as k,join as A,resolve as j}from"node:path";import{fileURLToPath as M}from"node:url";import{Model as N}from"@grid-is/spreadsheet-engine";import{z as P}from"zod";let F;function I(){return F??=(async()=>{try{let{FontLibrary:e}=await import(`skia-canvas`),t=M(new URL(`../assets/fonts`,import.meta.url));for(let n of D(t)){let r=A(t,n),i=D(r).filter(e=>e.endsWith(`.ttf`)).map(e=>A(r,e));i.length>0&&e.use(i)}}catch{}})(),F}function L(e){return e instanceof Error?e.message:String(e)}function R(C=process.cwd()){let w=new Map,D=null,A={text:`No workbook loaded. Use loadWorkbook first.`,isError:!0};function F(){if(D==null)return null;let e=w.get(D);return e?{path:D,model:e}:null}function R(e){return e.getWorkbooks().flatMap(e=>e.getSheets().map(t=>`${e.workbookName||`workbook`}/${t.name}`))}function z(e){let t=e.parameters;return{name:e.name,description:e.description,inputSchema:t instanceof P.ZodObject?t.shape:{},async run(n){let r=F();if(!r)return A;e.name===`captureRange`&&await I();let i={model:r.model},a=await e.execute(i,t.parse(n));return l(a)?{text:`Error: ${a.error}`,isError:!0}:a instanceof Uint8Array?{text:`Rendered ${a.length}-byte PNG.`,image:{data:Buffer.from(a).toString(`base64`),mimeType:`image/png`},isError:!1}:{text:JSON.stringify(a,null,2),isError:!1}}}}let B=P.object({path:P.string().describe(`Absolute or relative path to the .xlsx file.`)}),V={name:`loadWorkbook`,description:`Load an .xlsx file into memory and make it the active workbook. A session starts with this or createWorkbook. Returns the sheet names.`,inputSchema:B.shape,async run(e){let{path:t}=B.parse(e),n=j(C,t);try{await N.preconditions;let e=await N.fromXLSXFile(n);w.set(n,e),D=n;let t=R(e);return{text:`Loaded "${n}" (${e.getWorkbooks().length} workbook(s), ${t.length} sheet(s)).\nSheets: ${t.join(`, `)}`,isError:!1}}catch(e){return{text:`Failed to load "${n}": ${L(e)}`,isError:!0}}}},H=M(new URL(`../assets/blank.xlsx`,import.meta.url)),U=P.object({path:P.string().describe(`Path for the new .xlsx file. saveWorkbook writes it here by default.`)}),W={name:`createWorkbook`,description:`Create a blank single-sheet workbook in memory and make it the active workbook. Nothing is written to disk until saveWorkbook.`,inputSchema:U.shape,async run(e){let{path:t}=U.parse(e),n=j(C,t);if(w.has(n))return{text:`"${n}" is already loaded. Use selectWorkbook.`,isError:!0};if(T(n))return{text:`"${n}" already exists. Use loadWorkbook.`,isError:!0};try{await N.preconditions;let e=await N.fromXLSX(E(H),k(n));return w.set(n,e),D=n,{text:`Created blank workbook "${n}" (1 sheet: Sheet1). Use saveWorkbook to write it to disk.`,isError:!1}}catch(e){return{text:`Failed to create workbook: ${L(e)}`,isError:!0}}}},G=P.object({path:P.string().optional().describe(`Output path. Defaults to the source path.`),overwrite:P.boolean().optional().describe(`Overwrite an existing file. Default false.`)}),K={name:`saveWorkbook`,description:`Save the active workbook to an .xlsx file. Provide a new path, or set overwrite: true to write over an existing file (including the source).`,inputSchema:G.shape,async run(e){let{path:t,overwrite:n}=G.parse(e),r=F();if(!r)return A;let i=t?j(C,t):r.path;if(T(i)&&!n)return{text:`"${i}" exists. Set overwrite: true or choose a new path.`,isError:!0};try{let e=r.model.getWorkbooks();return e.length===0?{text:`No workbooks to save.`,isError:!0}:(O(i,await e[0].toXLSX()),{text:`Saved to "${i}".`,isError:!1})}catch(e){return{text:`Failed to save: ${L(e)}`,isError:!0}}}},q=P.object({path:P.string().describe(`Path of a previously loaded workbook, as shown by listWorkbooks.`)}),J={name:`selectWorkbook`,description:`Make a previously loaded workbook the active one for all other spreadsheet tools. Switching keeps in-memory state, so unsaved edits survive. Use listWorkbooks to see what is loaded; use loadWorkbook to (re)load from disk.`,inputSchema:q.shape,async run(e){let{path:t}=q.parse(e),n=j(C,t),r=w.get(n);if(!r){let e=[...w.keys()];return{text:e.length?`"${n}" is not loaded. Loaded workbooks:\n${e.join(`
|
|
2
2
|
`)}`:`"${n}" is not loaded. No workbooks loaded — use loadWorkbook first.`,isError:!0}}return D=n,{text:`Active workbook: "${n}".\nSheets: ${R(r).join(`, `)}`,isError:!1}}},Y=P.object({}),X={name:`listWorkbooks`,description:`List all loaded workbooks and their sheet names.`,inputSchema:Y.shape,async run(){if(w.size===0)return{text:`No workbooks loaded.`,isError:!1};let e=[];for(let[t,n]of w){let r=t===D?` [active]`:``;e.push(`${t}${r}: ${R(n).join(`, `)}`)}return{text:e.join(`
|
|
3
|
-
`),isError:!1}}},Z={name:`generateWorkbookContext`,description:`Generate a comprehensive natural-language description of the active workbook: sheet structures, data regions, labels, and relationships. More detailed than describeStructure.`,inputSchema:Y.shape,async run(){let e=F();if(!e)return A;let t=d(e.model);return t==null?{text:`Could not generate context.`,isError:!0}:{text:t,isError:!1}}},Q=P.object({code:P.string().describe("Office.js JavaScript to run against the active workbook. `context` (RequestContext) and `Excel` are in scope; call `await context.sync()` to flush writes.")}),$={name:`executeOfficeJs`,description:`Execute an Office.js code snippet directly against the active workbook. Returns any error plus the list of Office.js APIs the code used that are not yet implemented. Edits synced before a script error remain applied.`,inputSchema:Q.shape,async run(e){let{code:t}=Q.parse(e),n=F();if(!n)return A;if(n.model.getWorkbooks().length===0)return{text:`No workbooks in the active model.`,isError:!0};try{let{ApiaryOfficeJs:e}=await import(`./dist-
|
|
3
|
+
`),isError:!1}}},Z={name:`generateWorkbookContext`,description:`Generate a comprehensive natural-language description of the active workbook: sheet structures, data regions, labels, and relationships. More detailed than describeStructure.`,inputSchema:Y.shape,async run(){let e=F();if(!e)return A;let t=d(e.model);return t==null?{text:`Could not generate context.`,isError:!0}:{text:t,isError:!1}}},Q=P.object({code:P.string().describe("Office.js JavaScript to run against the active workbook. `context` (RequestContext) and `Excel` are in scope; call `await context.sync()` to flush writes.")}),$={name:`executeOfficeJs`,description:`Execute an Office.js code snippet directly against the active workbook. Returns any error plus the list of Office.js APIs the code used that are not yet implemented. Edits synced before a script error remain applied.`,inputSchema:Q.shape,async run(e){let{code:t}=Q.parse(e),n=F();if(!n)return A;if(n.model.getWorkbooks().length===0)return{text:`No workbooks in the active model.`,isError:!0};try{let{ApiaryOfficeJs:e}=await import(`./dist-DvOtcg7Y.js`),r=new e;await r.attach(n.model);let i=await r.runString(t);return i.error?{text:JSON.stringify({error:{name:i.error.name,message:i.error.message},unimplementedAccesses:i.unimplementedAccesses},null,2),isError:!0}:{text:JSON.stringify({ok:!0,returnValue:i.returnValue,unimplementedAccesses:i.unimplementedAccesses},null,2),isError:!1}}catch(e){return{text:`executeOfficeJs failed: ${L(e)}`,isError:!0}}}};return[V,W,K,X,J,...[u,i,m,_,r,y,n,x,h,t,s,v,o,g,S,f,c,e,b,a,p].map(z),Z,$]}function z(e=R(),t={}){let n=new C({name:t.name??`agent-tools`,version:t.version??`0.1.0`});for(let t of e)n.registerTool(t.name,{description:t.description,inputSchema:t.inputSchema},async e=>{let n=await t.run(e),r=[{type:`text`,text:n.text}];return n.image&&r.push({type:`image`,data:n.image.data,mimeType:n.image.mimeType}),{content:r,isError:n.isError}});return n}async function B(e={}){await z(e.tools,{name:e.name,version:e.version}).connect(new w)}export{p as captureRange,R as createGridTools,g as dependents,u as describeStructure,r as editCellStyles,m as editCells,_ as fillCells,a as findCells,d as generateWorkbookContext,v as getComment,o as getComments,s as getStyles,h as goalSeek,f as inspect,l as isToolError,c as listErrors,n as manageRowsAndColumns,y as manageSheets,S as precedents,i as readCalculatedValues,x as runFormula,B as serveStdio,e as symbols,z as toMcpServer,b as viewRange,t as whatIf};
|
package/dist/tools.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { C as runFormula, D as whatIf, E as viewRange, S as readCalculatedValues, T as symbols, _ as isToolError, a as dependents, b as manageSheets, c as editCells, d as generateWorkbookContext, f as getComment, g as inspect, h as goalSeek, i as captureRange, l as fillCells, m as getStyles, n as ToolContext, o as describeStructure, p as getComments, r as ToolError, s as editCellStyles, t as SpreadsheetTool, u as findCells, v as listErrors, w as spreadsheetTools, x as precedents, y as manageRowsAndColumns } from "./index-
|
|
1
|
+
import { C as runFormula, D as whatIf, E as viewRange, S as readCalculatedValues, T as symbols, _ as isToolError, a as dependents, b as manageSheets, c as editCells, d as generateWorkbookContext, f as getComment, g as inspect, h as goalSeek, i as captureRange, l as fillCells, m as getStyles, n as ToolContext, o as describeStructure, p as getComments, r as ToolError, s as editCellStyles, t as SpreadsheetTool, u as findCells, v as listErrors, w as spreadsheetTools, x as precedents, y as manageRowsAndColumns } from "./index-DtYMYL_H.js";
|
|
2
2
|
export { SpreadsheetTool, type ToolContext, type ToolError, captureRange, dependents, describeStructure, editCellStyles, editCells, fillCells, findCells, generateWorkbookContext, getComment, getComments, getStyles, goalSeek, inspect, isToolError, listErrors, manageRowsAndColumns, manageSheets, precedents, readCalculatedValues, runFormula, spreadsheetTools, symbols, viewRange, whatIf };
|
package/dist/tools.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{C as e,S as t,T as n,_ as r,a as i,b as a,c as o,d as s,f as c,g as l,h as u,i as d,l as f,m as p,n as m,o as h,p as g,r as _,s as v,t as y,u as b,v as x,w as S,x as C,y as w}from"./dist-
|
|
1
|
+
import{C as e,S as t,T as n,_ as r,a as i,b as a,c as o,d as s,f as c,g as l,h as u,i as d,l as f,m as p,n as m,o as h,p as g,r as _,s as v,t as y,u as b,v as x,w as S,x as C,y as w}from"./dist-Dx48XsYY.js";export{y as SpreadsheetTool,m as captureRange,_ as dependents,d as describeStructure,i as editCellStyles,h as editCells,v as fillCells,o as findCells,f as generateWorkbookContext,b as getComment,s as getComments,c as getStyles,g as goalSeek,p as inspect,u as isToolError,l as listErrors,r as manageRowsAndColumns,x as manageSheets,w as precedents,a as readCalculatedValues,C as runFormula,t as spreadsheetTools,e as symbols,S as viewRange,n as whatIf};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@grid-is/agent-tools",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"description": "GRID spreadsheet tools for AI agents. Load, read, edit, and recalculate .xlsx workbooks — headless, no Excel required. Wire the tools into your own agent SDK, or run them as an MCP server.",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"repository": {
|
|
@@ -44,16 +44,19 @@
|
|
|
44
44
|
"test:hosts": "tsx test/host-smoke.ts"
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"@grid-is/apiary": "npm:@grid-is/spreadsheet-engine@^17.0.0",
|
|
48
47
|
"@modelcontextprotocol/sdk": "^1.12.0",
|
|
49
48
|
"zod": "^4.4.3"
|
|
50
49
|
},
|
|
50
|
+
"peerDependencies": {
|
|
51
|
+
"@grid-is/spreadsheet-engine": "^17.0.0"
|
|
52
|
+
},
|
|
51
53
|
"optionalDependencies": {
|
|
52
54
|
"skia-canvas": "^3.0.8"
|
|
53
55
|
},
|
|
54
56
|
"devDependencies": {
|
|
55
57
|
"@changesets/cli": "^2.31.0",
|
|
56
58
|
"@changesets/get-github-info": "^0.8.0",
|
|
59
|
+
"@grid-is/apiary": "npm:@grid-is/spreadsheet-engine@^17.0.0",
|
|
57
60
|
"@grid-is/apiary-officejs": "^0.11.0",
|
|
58
61
|
"@grid-is/grid-prompt-tools": "^2.5.0",
|
|
59
62
|
"@types/node": "^22.0.0",
|