From 3bc4410df646a866534a09db2d7b72309de0b4d4 Mon Sep 17 00:00:00 2001 From: Jeff Moe Date: Sat, 31 Aug 2024 12:30:08 -0600 Subject: [PATCH] code.libre.is documentation --- Makefile | 96 ++ docs/Makefile | 12 + docs/_source/_static/custom.css | 6 + docs/_source/_static/favicon.ico | Bin 0 -> 6398 bytes .../_source/_static/handsontable.full.min.css | 46 + docs/_source/_static/handsontable.full.min.js | 995 ++++++++++++++++++ docs/_source/_static/logo.png | Bin 0 -> 69730 bytes docs/_source/_templates/latex.tex | 6 + docs/_source/_templates/layout.html | 6 + docs/_source/about.rst | 31 + docs/_source/code-libre-is.rst | 343 ++++++ docs/_source/conf.py | 74 ++ docs/_source/index.rst | 16 + docs/_source/license.rst | 7 + docs/_source/locale/en/LC_MESSAGES/about.po | 73 ++ .../locale/en/LC_MESSAGES/code-libre-is.po | 299 ++++++ docs/_source/locale/en/LC_MESSAGES/index.po | 37 + docs/_source/locale/en/LC_MESSAGES/license.po | 35 + docs/index.html | 26 + 19 files changed, 2108 insertions(+) create mode 100644 Makefile create mode 100644 docs/Makefile create mode 100644 docs/_source/_static/custom.css create mode 100644 docs/_source/_static/favicon.ico create mode 100644 docs/_source/_static/handsontable.full.min.css create mode 100644 docs/_source/_static/handsontable.full.min.js create mode 100644 docs/_source/_static/logo.png create mode 100644 docs/_source/_templates/latex.tex create mode 100644 docs/_source/_templates/layout.html create mode 100644 docs/_source/about.rst create mode 100644 docs/_source/code-libre-is.rst create mode 100644 docs/_source/conf.py create mode 100644 docs/_source/index.rst create mode 100644 docs/_source/license.rst create mode 100644 docs/_source/locale/en/LC_MESSAGES/about.po create mode 100644 docs/_source/locale/en/LC_MESSAGES/code-libre-is.po create mode 100644 docs/_source/locale/en/LC_MESSAGES/index.po create mode 100644 docs/_source/locale/en/LC_MESSAGES/license.po create mode 100644 docs/index.html diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..84bdafd --- /dev/null +++ b/Makefile @@ -0,0 +1,96 @@ +# Makefile + +SPHINXOPTS ?= +SPHINXBUILD ?= sphinx-build +SOURCEDIR = docs/_source +BUILDDIR = docs/_build +AUTOBUILDOPTS = --host 127.0.0.1 --port 8000 --ignore "*.swp" --ignore "*.swx" +GETTEXT_BUILD = gettext_build +UPDATE_LOCALE = sphinx-intl update -p $(BUILDDIR)/locale/gettext -d $(SOURCEDIR)/locale -l +PO_FILES = $(wildcard docs/_source/locale/*/LC_MESSAGES/*.po) +MSGATTRIB = msgattrib +#LANGUAGES = am ar bg bn ca cak cs cy da de el en eo es et eu fa fi fil fr he hi hr hu id it ja ko lkt lt lv mk mr ms ne nl no pl pt ro ru si sk sl sq sr sv ta te th tr uk ur vi zh +LANGUAGES = en + +.PHONY: check help html livehtml clean_sphinx clean gettext_build update_locale build_html all copy clean_po latex latexpdf + +help: + @echo "Please use \`make ' where is one of" + @echo " clean Remove all build files and directories (including translations)" + @echo " all Clean and make all targets" + @echo " gettext_build Build localisation strings for translation" + @echo " update_locale Update localisation" + @echo " update_locale_ Update localisation for " + @echo " html Build the HTML documentation for all languages" + @echo " html_ Build HTML documentation for " + @echo " latex Build the documentation using LaTeX for all languages" + @echo " latex_ Build the documentation using LaTeX for " + @echo " latexpdf Build the PDFS documentation using LaTeX for all languages" + @echo " latexpdf_ Build the PDFS documentation using LaTeX for " + @echo " index Copy static docs/index.html to docs/_build/html/index.html" + @echo " translations Translate from English. Note: needs AI translator set up" + +all: clean gettext_build update_locale html index + +check: + @for po in $(PO_FILES); do \ + echo "Checking $$po..."; \ + msgfmt --check --output-file=- "$$po" || exit 1; \ + done + +index: + cp -p docs/index.html docs/_build/html/index.html + +clean: + for file in $(PO_FILES); do \ + $(MSGATTRIB) --no-obsolete -o $$file $$file; \ + done + cd docs && make clean + find $(SOURCEDIR) -type f -name "*.mo" -delete + rm -rf $(BUILDDIR)/* + +gettext_build: + $(SPHINXBUILD) -b gettext -c $(SOURCEDIR) -d $(BUILDDIR)/doctrees/$(GETTEXT_BUILD) $(SOURCEDIR) $(BUILDDIR)/locale/gettext + +update_locale: + @pids="" ; \ + for lang in $(LANGUAGES); do \ + ( echo "Updating locale for $$lang..." ; $(UPDATE_LOCALE) $$lang ) & pids="$$pids $$!" ; \ + done ; \ + for pid in $$pids; do \ + wait $$pid ; \ + done + +update_locale_%: + $(UPDATE_LOCALE) $* + +html: + @for lang in $(LANGUAGES); do \ + echo "Building HTML documentation for $$lang..."; \ + $(SPHINXBUILD) -b html -d $(BUILDDIR)/doctrees -D language=$$lang $(SOURCEDIR) $(BUILDDIR)/html/$$lang; \ + done + +html_%: gettext_build + $(SPHINXBUILD) -b html -d $(BUILDDIR)/doctrees -D language=$* -c $(SOURCEDIR) $(SOURCEDIR) $(BUILDDIR)/html/$*/ + +latex: + @for lang in $(LANGUAGES); do \ + echo "Building LaTeX documentation for $$lang..."; \ + $(SPHINXBUILD) -b latex -d $(BUILDDIR)/doctrees -D language=$$lang -Dlatex_engine=xelatex $(SOURCEDIR) $(BUILDDIR)/latex/$$lang; \ + done + +latex_%: + $(SPHINXBUILD) -b latex -d $(BUILDDIR)/doctrees -D language=$* -Dlatex_engine=xelatex $(SOURCEDIR) $(BUILDDIR)/latex/$*/; \ + +latexpdf: + @for lang in $(filter-out ar he ja,$(LANGUAGES)); do \ + echo "Building PDF documentation for $$lang..."; \ + $(MAKE) -C $(BUILDDIR)/latex/$$lang ; \ + done + +latexpdf_%: + $(MAKE) -C $(BUILDDIR)/latex/$* ; \ + +translations: + ./scripts/translate-all.sh + diff --git a/docs/Makefile b/docs/Makefile new file mode 100644 index 0000000..9eb331c --- /dev/null +++ b/docs/Makefile @@ -0,0 +1,12 @@ +SPHINXOPTS ?= +SPHINXBUILD ?= sphinx-build +SOURCEDIR = _source +BUILDDIR = _build + +help: + @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) + +.PHONY: help Makefile + +%: Makefile + @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) diff --git a/docs/_source/_static/custom.css b/docs/_source/_static/custom.css new file mode 100644 index 0000000..5978368 --- /dev/null +++ b/docs/_source/_static/custom.css @@ -0,0 +1,6 @@ +div.footer-wrapper { + display: none; +} +.wy-nav-content { + max-width: 95%; +} diff --git a/docs/_source/_static/favicon.ico b/docs/_source/_static/favicon.ico new file mode 100644 index 0000000000000000000000000000000000000000..ea3f68413e909c302f606eff89200efb02e34287 GIT binary patch literal 6398 zcmeI0dsviJ9>>{#_St96a$8L+^Fo-2Au1vy3L=8Kiu$-IB;f_h`xULcZkpy=nwGh) zm8;0z0gWIj9=ws4G(bUw5r%CY zUCuk><@G!K^MBO~*Fj$DL0(?Zd3kyH;?Ey{arh(sPkQM%jy0{G)9E>O6+6id?I%|@ zlDyT^em%L->$SoaH|(DF)A4LBN5=~bc^DTuz0k|%gP^PF^jfh|>%tha65lXDyzh4N zA3o|flD-9l7hRjTs6nqzuOS4wo{jdikK6~a@nj-tY#DaXo8mi}a=oHMY%gt>9(00W zf^jhAb$Ag(okpwu#irG=JqS#6ZjFBppstb-#0#Xe)J;%X5YizfSMvM=d0yON2dRi^4$m{E`ms~ralXLD| zc5aRY|4Fj5&t+$!WoKq)W~67Pr)8w4W~8O2r=BG(Ej1%OEh{r4J1Y}oFg`~j!NgpN z1UDDIEx3Qb61#$ZwohDv1p)*H&q2_r7a%EyVqCZM^@az%ii{0wxEIoicG;Sn&ApkihVe3E{zkxJM7^4;qJto5>T#h6V=U8it+; z0XyD%M_N;ZC9u4~Xhg$*425tI2*SZ3l;Bw?0ac;y=Jjhr#`#YiGy1i0W5R+1XH5&6 z8$B&1Dq==>Xmr>lat)sx9UeM;$|TliMTXCx6%{u>X6d2@i{{OKbJ2pOaSK-@ERKne zj0y`44-Q)T#=`F|erq%u%@(tzz1?g!14WMj;PntWs3auB@Y3mOYipM-j$O4ZevI#k zRY}WMy_FamG=927}Rr zaZL)v{yn=B7RM%UT)SdmreA%g%xJ;FnPL5L5Q zQ51!6Ko5v$Hn&@?4u`#?!}a*_qt4F9v~}XzZhJH`j%#hxrbtr!=J{SJDbA3na*7@J z?B}0JV}miv<#NG-)l&&TJdp!XB(r%GBm80nh{XaFyTcB1j~+ehe9TZDYdFn>RatY_ zZtffPr$0va9W`%M@Ea%oRajzmSOr`#JaToooK7c$AYzyhntw;KvWL{i4t%Cf+*5%ZAXyX?cjjvAFh{d z-nQoJud~YU+)#I|m;e0*4r(ObB|u zu+$}2!a<7+i4V-gKByQxgu!S?csoAp?CFx??@Mo8m)A<~-z~dZT-4N1-vEreWfi4& zE`IZM;>KlKgBB=2M}uEr1lF)CY!92nD!;%%l9oh<2{NKt;1MbYlt3%^pBoWI{ZnqIz=^~)A_sE~+)X(s3W*QC zt}|JLD>>mXjwFl7A$Y{@w6FeZ&D?kYQdE#9t*QV77H*K$T8x~-X4SN+IGv`oSy_3v zEGl_g(z%relYvPBpTe_sR7pkG36=E89JF{a4i=%<7AzXg#u5AdF65?P$VvwX z)&zkOl&b;1pO?X;s^Dw%odQIY0MYqwHb3*@(4u>ekHEGc8JmvRR%}n6)os|MhEEZ(h56 z;KqkaozjDY4-pH|qeqCibC4$k#z8X0Vi7WyqzNn{W7DskL3aFbsi>_*>2%luQCVJo z`kJPuTH07IJCR-g*P>%m>3zAZF0DMxhP0(2!u*0zW1&h)h}+4+Lc)UsG3>zsJ!qWT z5TumjUTvweK~^t)V9;smq}2_wx=OWezzvtA#%kd7moHr|tj@O>4Q8XEN>hy@=FTCe z4DvuvOPPDh@Ej~yL=IX!$nnhb1?9-@bU+Z~U8_=|ZELBnyoaddtnG8EOx{)YVO6#| zz0u`zHppe9gd(?G4p&D9W?>I3Z+p|jfOS3MRN&zF`awgL)DNo_`(PD}xyGQ^B0?+5 zenO6XPRMYT<0@;t6wUPA6~U*dqb+2s3<^4e&!MALB!}0 zp-dI32jigL5w+sI!=l7Y&R%HC(l}RIG%Ee|wO?-ZT_4v!rtI_UowIUnlajY@Pdhr| zyY2s|&nF220s=wLdK&V*mUAqJkP!SrzjL~W2tEJ@&Ec+RRTG4vD7Wt28I~WPb}D1$ z^7tV;b}Y_Q1{}{#{B%=lT4u=25A*L7QyB<4iwWrJ78YI4#w8nmzgUmp%pi zj@^(bnwr2t2Gcr(xx^0rdd-~f0YO~>2|PG>NhlDjC~Uq55RDklY)WswHeB|lk0R^k zmT$aUzk9j0=%1QWy_r5>3j|CCK0DaKp3Q?p{Fpe1PGCDAG{QqR(FQ1Zh_+ay zhL$DruLj8uZ%`FVO>ImDq918=3X?(D7_%>~;*QcghbRo=U=u_dwh}3HCR3fErN*E% znE6oPT|gb-K9}DZ+a6V-8%=i(@#AhY#eP^9{LO#w;-%svfKP{>)0u@XI|38yVZYPy zb-mZg?wwsaF=xBSys%4V*L_ycd(n>g(SOGwPWx?dfc5J*@Qa=(A^TlWeETbIh_zqA z!4?*mCszLVM&nedp?rknt(*JBHCU(kmj2Y&gP^A=+T%8hpTgEcKf8I-&+h;4|BV#* EHxf^sGynhq literal 0 HcmV?d00001 diff --git a/docs/_source/_static/handsontable.full.min.css b/docs/_source/_static/handsontable.full.min.css new file mode 100644 index 0000000..fb19bbe --- /dev/null +++ b/docs/_source/_static/handsontable.full.min.css @@ -0,0 +1,46 @@ +/*! + * Copyright (c) HANDSONCODE sp. z o. o. + * + * HANDSONTABLE is a software distributed by HANDSONCODE sp. z o. o., a Polish corporation based in + * Gdynia, Poland, at Aleja Zwyciestwa 96-98, registered by the District Court in Gdansk under number + * 538651, EU tax ID number: PL5862294002, share capital: PLN 62,800.00. + * + * This software is protected by applicable copyright laws, including international treaties, and dual- + * licensed - depending on whether your use for commercial purposes, meaning intended for or + * resulting in commercial advantage or monetary compensation, or not. + * + * If your use is strictly personal or solely for evaluation purposes, meaning for the purposes of testing + * the suitability, performance, and usefulness of this software outside the production environment, + * you agree to be bound by the terms included in the "handsontable-non-commercial-license.pdf" file. + * + * Your use of this software for commercial purposes is subject to the terms included in an applicable + * license agreement. + * + * In any case, you must not make any such use of this software as to develop software which may be + * considered competitive with this software. + * + * UNLESS EXPRESSLY AGREED OTHERWISE, HANDSONCODE PROVIDES THIS SOFTWARE ON AN "AS IS" + * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, AND IN NO EVENT AND UNDER NO + * LEGAL THEORY, SHALL HANDSONCODE BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY DIRECT, + * INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES OF ANY CHARACTER ARISING FROM + * USE OR INABILITY TO USE THIS SOFTWARE. + * + * Version: 14.5.0 + * Release date: 30/07/2024 (built at 30/07/2024 09:20:07) + */.handsontable .table td,.handsontable .table th{border-top:none}.handsontable tr{background:#fff}.handsontable td{background-color:inherit}.handsontable .table caption+thead tr:first-child td,.handsontable .table caption+thead tr:first-child th,.handsontable .table colgroup+thead tr:first-child td,.handsontable .table colgroup+thead tr:first-child th,.handsontable .table thead:first-child tr:first-child td,.handsontable .table thead:first-child tr:first-child th{border-top:1px solid #ccc}.handsontable .table-bordered{border:0;border-collapse:separate}.handsontable .table-bordered td,.handsontable .table-bordered th{border-left:none}.handsontable .table-bordered td:first-child,.handsontable .table-bordered th:first-child{border-left:1px solid #ccc}.handsontable .table>tbody>tr>td,.handsontable .table>tbody>tr>th,.handsontable .table>tfoot>tr>td,.handsontable .table>tfoot>tr>th,.handsontable .table>thead>tr>td,.handsontable .table>thead>tr>th{line-height:21px;padding:0}.col-lg-1.handsontable,.col-lg-10.handsontable,.col-lg-11.handsontable,.col-lg-12.handsontable,.col-lg-2.handsontable,.col-lg-3.handsontable,.col-lg-4.handsontable,.col-lg-5.handsontable,.col-lg-6.handsontable,.col-lg-7.handsontable,.col-lg-8.handsontable,.col-lg-9.handsontable,.col-md-1.handsontable,.col-md-10.handsontable,.col-md-11.handsontable,.col-md-12.handsontable,.col-md-2.handsontable,.col-md-3.handsontable,.col-md-4.handsontable,.col-md-5.handsontable,.col-md-6.handsontable,.col-md-7.handsontable,.col-md-8.handsontable,.col-md-9.handsontable .col-sm-1.handsontable,.col-sm-10.handsontable,.col-sm-11.handsontable,.col-sm-12.handsontable,.col-sm-2.handsontable,.col-sm-3.handsontable,.col-sm-4.handsontable,.col-sm-5.handsontable,.col-sm-6.handsontable,.col-sm-7.handsontable,.col-sm-8.handsontable,.col-sm-9.handsontable .col-xs-1.handsontable,.col-xs-10.handsontable,.col-xs-11.handsontable,.col-xs-12.handsontable,.col-xs-2.handsontable,.col-xs-3.handsontable,.col-xs-4.handsontable,.col-xs-5.handsontable,.col-xs-6.handsontable,.col-xs-7.handsontable,.col-xs-8.handsontable,.col-xs-9.handsontable{padding-left:0;padding-right:0}.handsontable .table-striped>tbody>tr:nth-of-type(2n){background-color:#fff}.handsontable{position:relative}.handsontable .hide{display:none}.handsontable .relative{position:relative}.handsontable .wtHider{width:0}.handsontable .wtSpreader{height:auto;position:relative;width:0}.handsontable div,.handsontable input,.handsontable table,.handsontable tbody,.handsontable td,.handsontable textarea,.handsontable th,.handsontable thead{box-sizing:content-box;-webkit-box-sizing:content-box;-moz-box-sizing:content-box}.handsontable input,.handsontable textarea{min-height:auto}.handsontable table.htCore{border-collapse:separate;border-spacing:0;border-width:0;cursor:default;margin:0;max-height:none;max-width:none;outline-width:0;table-layout:fixed;width:0}.handsontable col,.handsontable col.rowHeader{width:50px}.handsontable td,.handsontable th{background-color:#fff;border-bottom:1px solid #ccc;border-left-width:0;border-right:1px solid #ccc;border-top-width:0;empty-cells:show;height:22px;line-height:21px;outline:none;outline-width:0;overflow:hidden;padding:0 4px;vertical-align:top;white-space:pre-wrap}[dir=rtl].handsontable td,[dir=rtl].handsontable th{border-left:1px solid #ccc;border-right-width:0}.handsontable th:last-child{border-bottom:1px solid #ccc;border-left:none;border-right:1px solid #ccc}[dir=rtl].handsontable th:last-child{border-left:1px solid #ccc;border-right:none}.handsontable td:first-of-type,.handsontable th:first-child{border-left:1px solid #ccc}[dir=rtl].handsontable td:first-of-type,[dir=rtl].handsontable th:first-child{border-right:1px solid #ccc}.handsontable .ht_clone_top th:nth-child(2){border-left-width:0;border-right:1px solid #ccc}[dir=rtl].handsontable .ht_clone_top th:nth-child(2){border-left:1px solid #ccc;border-right-width:0}.handsontable.htRowHeaders thead tr th:nth-child(2){border-left:1px solid #ccc}[dir=rtl].handsontable.htRowHeaders thead tr th:nth-child(2){border-right:1px solid #ccc}.handsontable tr:first-child td,.handsontable tr:first-child th{border-top:1px solid #ccc}.ht_master:not(.innerBorderInlineStart):not(.emptyColumns) tbody tr th,.ht_master:not(.innerBorderInlineStart):not(.emptyColumns) thead tr th:first-child,.ht_master:not(.innerBorderInlineStart):not(.emptyColumns)~.handsontable:not(.htGhostTable) tbody tr th,.ht_master:not(.innerBorderInlineStart):not(.emptyColumns)~.handsontable:not(.ht_clone_top):not(.htGhostTable) thead tr th:first-child{border-left:1px solid #ccc;border-right-width:0}[dir=rtl].ht_master:not(.innerBorderInlineStart):not(.emptyColumns) tbody tr th,[dir=rtl].ht_master:not(.innerBorderInlineStart):not(.emptyColumns) thead tr th:first-child,[dir=rtl].ht_master:not(.innerBorderInlineStart):not(.emptyColumns)~.handsontable:not(.htGhostTable) tbody tr th,[dir=rtl].ht_master:not(.innerBorderInlineStart):not(.emptyColumns)~.handsontable:not(.ht_clone_top):not(.htGhostTable) thead tr th:first-child{border-left-width:0;border-right:1px solid #ccc}.ht_master:not(.innerBorderTop):not(.innerBorderBottom) thead tr.lastChild th,.ht_master:not(.innerBorderTop):not(.innerBorderBottom) thead tr:last-child th,.ht_master:not(.innerBorderTop):not(.innerBorderBottom)~.handsontable thead tr.lastChild th,.ht_master:not(.innerBorderTop):not(.innerBorderBottom)~.handsontable thead tr:last-child th{border-bottom-width:0}.handsontable th{background-color:#f0f0f0;color:#222;font-weight:400;text-align:center;white-space:nowrap}.handsontable thead th{padding:0}.handsontable th.active{background-color:#ccc}.handsontable thead th .relative{padding:2px 4px}.handsontable span.colHeader{display:inline-block;line-height:1.1}.handsontable .wtBorder{font-size:0;position:absolute}.handsontable .wtBorder.hidden{display:none!important}.handsontable .wtBorder.current{z-index:10}.handsontable .wtBorder.area{z-index:8}.handsontable .wtBorder.fill{z-index:6}.handsontable .wtBorder.corner{cursor:crosshair;font-size:0}.ht_clone_master{z-index:100}.ht_clone_inline_start{z-index:120}.ht_clone_bottom{z-index:130}.ht_clone_bottom_inline_start_corner{z-index:150}.ht_clone_top{z-index:160}.ht_clone_top_inline_start_corner{z-index:180}.handsontable col.hidden{width:0!important}.handsontable tr.hidden,.handsontable tr.hidden td,.handsontable tr.hidden th{display:none}.ht_clone_bottom,.ht_clone_inline_start,.ht_clone_top,.ht_master{overflow:hidden}.ht_master .wtHolder{overflow:auto}.handsontable .ht_clone_inline_start table.htCore>thead,.handsontable .ht_master table.htCore>tbody>tr>th,.handsontable .ht_master table.htCore>thead{visibility:hidden}.ht_clone_bottom .wtHolder,.ht_clone_inline_start .wtHolder,.ht_clone_top .wtHolder{overflow:hidden}.handsontable{color:#373737;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen,Ubuntu,Helvetica Neue,Arial,sans-serif;font-size:13px;font-weight:400;touch-action:manipulation}.handsontable a{color:#104acc}.handsontable.htAutoSize{left:-99000px;position:absolute;top:-99000px;visibility:hidden}.handsontable td.htInvalid{background-color:#ffbeba!important}.handsontable td.htNoWrap{white-space:nowrap}.handsontable td.invisibleSelection,.handsontable th.invisibleSelection{outline:none}.handsontable td.invisibleSelection::selection,.handsontable th.invisibleSelection::selection{background:hsla(0,0%,100%,0)}.hot-display-license-info{color:#373737;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen,Ubuntu,Helvetica Neue,Arial,sans-serif;font-size:10px;font-weight:400;padding:5px 0 3px;text-align:left}.hot-display-license-info a{color:#104acc;font-size:10px}.handsontable .htFocusCatcher{border:0;height:0;margin:0;opacity:0;padding:0;position:absolute;width:0;z-index:-1}.handsontable .manualColumnResizer{cursor:col-resize;height:25px;position:absolute;top:0;width:5px;z-index:210}.handsontable .manualRowResizer{cursor:row-resize;height:5px;left:0;position:absolute;width:50px;z-index:210}.handsontable .manualColumnResizer.active,.handsontable .manualColumnResizer:hover,.handsontable .manualRowResizer.active,.handsontable .manualRowResizer:hover{background-color:#34a9db}.handsontable .manualColumnResizerGuide{background-color:#34a9db;border-left:none;border-right:1px dashed #777;display:none;margin-left:5px;margin-right:unset;position:absolute;right:unset;top:0;width:0}[dir=rtl].handsontable .manualColumnResizerGuide{border-left:1px dashed #777;border-right:none;left:unset;margin-left:unset;margin-right:5px}.handsontable .manualRowResizerGuide{background-color:#34a9db;border-bottom:1px dashed #777;bottom:0;display:none;height:0;left:0;margin-top:5px;position:absolute}.handsontable .manualColumnResizerGuide.active,.handsontable .manualRowResizerGuide.active{display:block;z-index:209}.handsontable td.area,.handsontable td.area-1,.handsontable td.area-2,.handsontable td.area-3,.handsontable td.area-4,.handsontable td.area-5,.handsontable td.area-6,.handsontable td.area-7{position:relative}.handsontable td.area-1:before,.handsontable td.area-2:before,.handsontable td.area-3:before,.handsontable td.area-4:before,.handsontable td.area-5:before,.handsontable td.area-6:before,.handsontable td.area-7:before,.handsontable td.area:before{background:#005eff;bottom:0;bottom:-100%\9;content:"";left:0;position:absolute;right:0;top:0}@media (-ms-high-contrast:none),screen and (-ms-high-contrast:active){.handsontable td.area-1:before,.handsontable td.area-2:before,.handsontable td.area-3:before,.handsontable td.area-4:before,.handsontable td.area-5:before,.handsontable td.area-6:before,.handsontable td.area-7:before,.handsontable td.area:before{bottom:-100%}}.handsontable td.area:before{opacity:.1}.handsontable td.area-1:before{opacity:.2}.handsontable td.area-2:before{opacity:.27}.handsontable td.area-3:before{opacity:.35}.handsontable td.area-4:before{opacity:.41}.handsontable td.area-5:before{opacity:.47}.handsontable td.area-6:before{opacity:.54}.handsontable td.area-7:before{opacity:.58}.handsontable tbody th.current,.handsontable thead th.current{box-shadow:inset 0 0 0 2px #4b89ff}.handsontable tbody th.ht__highlight,.handsontable thead th.ht__highlight{background-color:#dcdcdc}.handsontable tbody th.ht__active_highlight,.handsontable thead th.ht__active_highlight{background-color:#8eb0e7;color:#000}.handsontableInput{background-color:#fff;border:none;border-radius:0;box-shadow:inset 0 0 0 2px #5292f7;color:#000;display:block;font-family:inherit;font-size:inherit;line-height:21px;margin:0;outline-width:0;padding:1px 5px 0;resize:none}.handsontableInput:focus{outline:none}.handsontableInputHolder{left:0;position:absolute;top:0}.htSelectEditor{-webkit-appearance:menulist-button!important;position:absolute;width:auto}.htSelectEditor:focus{outline:none}.handsontable .htDimmed{color:#777}.handsontable .htSubmenu{position:relative}.handsontable .htSubmenu :after{color:#777;content:"▶";font-size:9px;position:absolute;right:5px}[dir=rtl].handsontable .htSubmenu :after{content:""}[dir=rtl].handsontable .htSubmenu :before{color:#777;content:"◀";font-size:9px;left:5px;position:absolute}.handsontable .htLeft{text-align:left}.handsontable .htCenter{text-align:center}.handsontable .htRight{text-align:right}.handsontable .htJustify{text-align:justify}.handsontable .htTop{vertical-align:top}.handsontable .htMiddle{vertical-align:middle}.handsontable .htBottom{vertical-align:bottom}.handsontable .htPlaceholder{color:#999}.handsontable.listbox{margin:0}.handsontable.listbox .ht_master table{background:#fff;border:1px solid #ccc;border-collapse:separate}.handsontable.listbox td,.handsontable.listbox th,.handsontable.listbox tr:first-child td,.handsontable.listbox tr:first-child th,.handsontable.listbox tr:last-child th{border-color:transparent!important}.handsontable.listbox td,.handsontable.listbox th{text-overflow:ellipsis;white-space:nowrap}.handsontable.listbox td.htDimmed{color:inherit;cursor:default;font-style:inherit}.handsontable.listbox .wtBorder{visibility:hidden}.handsontable.listbox tr td.current,.handsontable.listbox tr:hover td{background:#eee}.ht_editor_hidden{z-index:-1}.ht_editor_visible{z-index:200}.handsontable td.htSearchResult{background:#fcedd9;color:#583707}.handsontable.mobile,.handsontable.mobile .wtHolder{-webkit-touch-callout:none;-webkit-user-select:none;-khtml-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;-webkit-tap-highlight-color:rgba(0,0,0,0);-webkit-overflow-scrolling:touch}.handsontable.mobile .handsontableInput:focus{-webkit-appearance:none;-webkit-box-shadow:inset 0 0 0 2px #5292f7;-moz-box-shadow:inset 0 0 0 2px #5292f7;box-shadow:inset 0 0 0 2px #5292f7}.handsontable .bottomSelectionHandle,.handsontable .bottomSelectionHandle-HitArea,.handsontable .topSelectionHandle,.handsontable .topSelectionHandle-HitArea{left:-10000px;right:unset;top:-10000px;z-index:9999}[dir=rtl].handsontable .bottomSelectionHandle,[dir=rtl].handsontable .bottomSelectionHandle-HitArea,[dir=rtl].handsontable .topSelectionHandle,[dir=rtl].handsontable .topSelectionHandle-HitArea{left:unset;right:-10000px}.handsontable.hide-tween{-webkit-animation:opacity-hide .3s;animation:opacity-hide .3s;animation-fill-mode:forwards;-webkit-animation-fill-mode:forwards}.handsontable.show-tween{-webkit-animation:opacity-show .3s;animation:opacity-show .3s;animation-fill-mode:forwards;-webkit-animation-fill-mode:forwards} +/*! + * Pikaday + * Copyright © 2014 David Bushell | BSD & MIT license | https://dbushell.com/ + */.pika-single{background:#fff;border:1px solid;border-color:#ccc #ccc #bbb;color:#333;display:block;font-family:Helvetica Neue,Helvetica,Arial,sans-serif;position:relative;z-index:9999}.pika-single:after,.pika-single:before{content:" ";display:table}.pika-single:after{clear:both}.pika-single.is-hidden{display:none}.pika-single.is-bound{box-shadow:0 5px 15px -5px rgba(0,0,0,.5);position:absolute}.pika-lendar{float:left;margin:8px;width:240px}.pika-title{position:relative;text-align:center}.pika-label{background-color:#fff;display:inline-block;font-size:14px;font-weight:700;line-height:20px;margin:0;overflow:hidden;padding:5px 3px;position:relative;z-index:9999}.pika-title select{cursor:pointer;left:0;margin:0;opacity:0;position:absolute;top:5px;z-index:9998}.pika-next,.pika-prev{background-color:transparent;background-position:50%;background-repeat:no-repeat;background-size:75% 75%;border:0;cursor:pointer;display:block;height:30px;opacity:.5;outline:none;overflow:hidden;padding:0;position:relative;text-indent:20px;white-space:nowrap;width:20px}.pika-next:hover,.pika-prev:hover{opacity:1}.is-rtl .pika-next,.pika-prev{background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAeCAYAAAAsEj5rAAAAUklEQVR42u3VMQoAIBADQf8Pgj+OD9hG2CtONJB2ymQkKe0HbwAP0xucDiQWARITIDEBEnMgMQ8S8+AqBIl6kKgHiXqQqAeJepBo/z38J/U0uAHlaBkBl9I4GwAAAABJRU5ErkJggg==);float:left}.is-rtl .pika-prev,.pika-next{background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAeCAYAAAAsEj5rAAAAU0lEQVR42u3VOwoAMAgE0dwfAnNjU26bYkBCFGwfiL9VVWoO+BJ4Gf3gtsEKKoFBNTCoCAYVwaAiGNQGMUHMkjGbgjk2mIONuXo0nC8XnCf1JXgArVIZAQh5TKYAAAAASUVORK5CYII=);float:right}.pika-next.is-disabled,.pika-prev.is-disabled{cursor:default;opacity:.2}.pika-select{display:inline-block}.pika-table{border:0;border-collapse:collapse;border-spacing:0;width:100%}.pika-table td,.pika-table th{padding:0;width:14.2857142857%}.pika-table th{color:#999;font-weight:700;line-height:25px}.pika-button,.pika-table th{font-size:12px;text-align:center}.pika-button{background:#f5f5f5;border:0;box-sizing:border-box;-moz-box-sizing:border-box;color:#666;cursor:pointer;display:block;height:auto;line-height:15px;margin:0;outline:none;padding:5px;width:100%}.pika-week{color:#999;font-size:11px}.is-today .pika-button{color:#3af;font-weight:700}.has-event .pika-button,.is-selected .pika-button{background:#3af;border-radius:3px;box-shadow:inset 0 1px 3px #178fe5;color:#fff;font-weight:700}.has-event .pika-button{background:#005da9;box-shadow:inset 0 1px 3px #0076c9}.is-disabled .pika-button,.is-inrange .pika-button{background:#d5e9f7}.is-startrange .pika-button{background:#6cb31d;border-radius:3px;box-shadow:none;color:#fff}.is-endrange .pika-button{background:#3af;border-radius:3px;box-shadow:none;color:#fff}.is-disabled .pika-button{color:#999;cursor:default;opacity:.3;pointer-events:none}.is-outside-current-month .pika-button{color:#999;opacity:.3}.is-selection-disabled{cursor:default;pointer-events:none}.pika-button:hover,.pika-row.pick-whole-week:hover .pika-button{background:#ff8000;border-radius:3px;box-shadow:none;color:#fff}.pika-table abbr{border-bottom:none;cursor:help}.handsontable .htAutocompleteArrow{color:#bbb;cursor:default;float:right;font-size:10px;text-align:center;width:16px}[dir=rtl].handsontable .htAutocompleteArrow{float:left}.handsontable td.htInvalid .htAutocompleteArrow{color:#555}.handsontable td.htInvalid .htAutocompleteArrow:hover{color:#1a1a1a}.handsontable td .htAutocompleteArrow:hover{color:#777}.handsontable td.area .htAutocompleteArrow{color:#d3d3d3}.handsontable .htCheckboxRendererInput{display:inline-block}.handsontable .htCheckboxRendererInput.noValue{opacity:.5}.handsontable .htCheckboxRendererLabel{cursor:pointer;display:inline-block;font-size:inherit;vertical-align:middle}.handsontable .htCheckboxRendererLabel.fullWidth{width:100%}.handsontable .collapsibleIndicator{background:#eee;border:1px solid #a6a6a6;border-radius:10px;-webkit-box-shadow:0 0 0 6px #eee;-moz-box-shadow:0 0 0 6px #eee;box-shadow:0 0 0 3px #eee;color:#222;cursor:pointer;font-size:10px;height:10px;left:unset;line-height:8px;position:absolute;right:5px;text-align:center;top:50%;transform:translateY(-50%);width:10px}[dir=rtl].handsontable .collapsibleIndicator{left:5px;right:unset}.handsontable[dir=ltr] thead th:has(.collapsibleIndicator) div.htRight span.colHeader{margin-right:20px}.handsontable[dir=rtl] thead th:has(.collapsibleIndicator) div.htLeft span.colHeader{margin-left:20px}.handsontable .columnSorting{position:relative}.handsontable[dir=ltr] div.htRight span[class*=ascending],.handsontable[dir=ltr] div.htRight span[class*=descending]{margin-left:-10px;margin-right:10px}.handsontable[dir=rtl] div.htLeft span[class*=ascending],.handsontable[dir=rtl] div.htLeft span[class*=descending]{margin-left:10px;margin-right:-10px}.handsontable[dir=ltr] div.htRight span[class*=ascending]:only-child,.handsontable[dir=ltr] div.htRight span[class*=descending]:only-child{margin-left:-15px;margin-right:15px}.handsontable[dir=rtl] div.htLeft span[class*=ascending]:only-child,.handsontable[dir=rtl] div.htLeft span[class*=descending]:only-child{margin-left:15px;margin-right:-15px}.handsontable .columnSorting.sortAction:hover{cursor:pointer;text-decoration:underline}.handsontable span.colHeader.columnSorting:before{background-position-x:right;background-repeat:no-repeat;background-size:contain;content:"";height:10px;left:unset;margin-top:-6px;padding-left:8px;padding-right:0;position:absolute;right:-9px;top:50%;width:5px}[dir=rtl].handsontable span.colHeader.columnSorting:before{background-position-x:left;left:-9px;padding-left:0;padding-right:8px;right:unset}.handsontable span.colHeader.columnSorting.ascending:before{background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAoCAMAAADJ7yrpAAAAKlBMVEUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAKE86IAAAADXRSTlMABBEmRGprlJW72e77tTkTKwAAAFNJREFUeAHtzjkSgCAUBNHPgsoy97+ulGXRqJE5L+xkxoYt2UdsLb5bqFINz+aLuuLn5rIu2RkO3fZpWENimNgiw6iBYRTPMLJjGFxQZ1hxxb/xBI1qC8k39CdKAAAAAElFTkSuQmCC)}.handsontable span.colHeader.columnSorting.descending:before{background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAoCAMAAADJ7yrpAAAAKlBMVEUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAKE86IAAAADXRSTlMABBEmRGprlJW72e77tTkTKwAAAFJJREFUeAHtzjkSgCAQRNFmQYUZ7n9dKUvru0TmvPAn3br0QfgdZ5xx6x+rQn23GqTYnq1FDcnuzZIO2WmedVqIRVxgGKEyjNgYRjKGkZ1hFIZ3I70LyM0VtU8AAAAASUVORK5CYII=)}.htGhostTable .htCore span.colHeader.columnSorting:not(.indicatorDisabled):before{content:"*";display:inline-block;padding-right:20px;position:relative}.handsontable .htCommentCell{position:relative}.handsontable .htCommentCell:after{border-left:6px solid transparent;border-right:none;border-top:6px solid #000;content:"";left:unset;position:absolute;right:0;top:0}[dir=rtl].handsontable .htCommentCell:after{border-left:none;border-right:6px solid transparent;left:0;right:unset}.htCommentsContainer .htComments{display:none;position:absolute;z-index:1059}.htCommentsContainer .htCommentTextArea{-webkit-appearance:none;background-color:#fff;border:none;border-left:3px solid #ccc;box-shadow:0 1px 3px rgba(0,0,0,.118),0 1px 2px rgba(0,0,0,.239);-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;font-size:12px;height:90px;outline:0!important;padding:5px;width:215px}[dir=rtl].htCommentsContainer .htCommentTextArea{border-left:none;border-right:3px solid #ccc}.htCommentsContainer .htCommentTextArea:focus{border-left:3px solid #5292f7;border-right:none;box-shadow:0 1px 3px rgba(0,0,0,.118),0 1px 2px rgba(0,0,0,.239),inset 0 0 0 1px #5292f7}[dir=rtl].htCommentsContainer .htCommentTextArea:focus{border-left:none;border-right:3px solid #5292f7} +/*! + * Handsontable ContextMenu + */.htContextMenu:not(.htGhostTable){display:none;position:absolute;z-index:1060}.htContextMenu .ht_clone_bottom,.htContextMenu .ht_clone_bottom_inline_start_corner,.htContextMenu .ht_clone_inline_start,.htContextMenu .ht_clone_top,.htContextMenu .ht_clone_top_inline_start_corner{display:none}.htContextMenu .ht_master table.htCore{border-color:#ccc;border-style:solid;border-width:1px 2px 2px 1px}[dir=rtl].htContextMenu .ht_master table.htCore{border-left-width:2px;border-right-width:1px}.htContextMenu.handsontable:focus{outline:none}.htContextMenu .wtBorder{visibility:hidden}.htContextMenu table tbody tr td{background:#fff;border-width:0;cursor:pointer;overflow:hidden;padding:4px 6px 0;text-overflow:ellipsis;white-space:nowrap}.htContextMenu table tbody tr td:first-child{border-width:0}[dir=rtl].htContextMenu table tbody tr td:first-child{border-left-width:0;border-right-width:0}.htContextMenu table tbody tr td.htDimmed{color:#323232;font-style:normal}.htContextMenu table tbody tr td.current{background:#f3f3f3}.htContextMenu table tbody tr td.htSeparator{border-top:1px solid #e6e6e6;cursor:default;height:0;padding:0}.htContextMenu table tbody tr td.htDisabled{color:#999;cursor:default}.htContextMenu table tbody tr td.htDisabled:hover{background:#fff;color:#999;cursor:default}.htContextMenu table tbody tr.htHidden{display:none}.htContextMenu table tbody tr td .htItemWrapper{margin-left:10px;margin-right:6px}[dir=rtl].htContextMenu table tbody tr td .htItemWrapper{margin-left:6px;margin-right:10px}.htContextMenu table tbody tr td div span.selected{left:4px;margin-top:-2px;position:absolute;right:0}[dir=rtl].htContextMenu table tbody tr td div span.selected{left:0;right:4px}.htContextMenu .ht_master .wtHolder{overflow:hidden}textarea.HandsontableCopyPaste{opacity:0;outline:0 none!important;overflow:hidden;position:fixed!important;right:100%!important;top:0!important} +/*! + * Handsontable DropdownMenu + */.handsontable .changeType{background:#eee;border:1px solid #bbb;border-radius:2px;color:#bbb;float:right;font-size:9px;line-height:9px;margin:3px 1px 0 5px;padding:2px}[dir=rtl].handsontable .changeType{float:left}.handsontable[dir=rtl] .changeType{margin:3px 5px 0 1px}.handsontable .changeType:before{content:"▼ "}.handsontable .changeType:hover{border:1px solid #777;color:#777;cursor:pointer}.htDropdownMenu:not(.htGhostTable){display:none;position:absolute;z-index:1060}.htDropdownMenu .ht_clone_bottom,.htDropdownMenu .ht_clone_bottom_inline_start_corner,.htDropdownMenu .ht_clone_inline_start,.htDropdownMenu .ht_clone_top,.htDropdownMenu .ht_clone_top_inline_start_corner{display:none}.htDropdownMenu table.htCore{border-color:#ccc;border-style:solid;border-width:1px 2px 2px 1px}[dir=rtl].htDropdownMenu table.htCore{border-left-width:2px;border-right-width:1px}.htDropdownMenu.handsontable:focus{outline:none}.htDropdownMenu .wtBorder{visibility:hidden}.htDropdownMenu table tbody tr td{background:#fff;border-width:0;cursor:pointer;overflow:hidden;padding:4px 6px 0;text-overflow:ellipsis;white-space:nowrap}.htDropdownMenu table tbody tr td:first-child{border-width:0}[dir=rtl].htDropdownMenu table tbody tr td:first-child{border-left-width:0;border-right-width:0}.htDropdownMenu table tbody tr td.htDimmed{color:#323232;font-style:normal}.htDropdownMenu table tbody tr td.current{background:#e9e9e9}.htDropdownMenu table tbody tr td.htSeparator{border-top:1px solid #e6e6e6;cursor:default;height:0;padding:0}.htDropdownMenu table tbody tr td.htDisabled{color:#999}.htDropdownMenu table tbody tr td.htDisabled:hover{background:#fff;color:#999;cursor:default}.htDropdownMenu:not(.htGhostTable) table tbody tr.htHidden{display:none}.htDropdownMenu table tbody tr td .htItemWrapper,[dir=rtl].htDropdownMenu table tbody tr td .htItemWrapper{margin-left:10px;margin-right:10px}.htDropdownMenu table tbody tr td div span.selected{left:4px;margin-top:-2px;position:absolute;right:0}[dir=rtl].htDropdownMenu table tbody tr td div span.selected{left:0;right:4px}.htDropdownMenu .ht_master .wtHolder{overflow:hidden} +/*! + * Handsontable Filters + */.htFiltersConditionsMenu:not(.htGhostTable){display:none;position:absolute;z-index:1070}.htFiltersConditionsMenu .ht_clone_bottom,.htFiltersConditionsMenu .ht_clone_bottom_inline_start_corner,.htFiltersConditionsMenu .ht_clone_inline_start,.htFiltersConditionsMenu .ht_clone_top,.htFiltersConditionsMenu .ht_clone_top_inline_start_corner{display:none}.htFiltersConditionsMenu table.htCore{border-color:#bbb;border-style:solid;border-width:1px 2px 2px 1px}.htFiltersConditionsMenu .wtBorder{visibility:hidden}.htFiltersConditionsMenu table tbody tr td{background:#fff;border-width:0;cursor:pointer;overflow:hidden;padding:4px 6px 0;text-overflow:ellipsis;white-space:nowrap}.htFiltersConditionsMenu table tbody tr td:first-child{border-width:0}[dir=rtl].htFiltersConditionsMenu table tbody tr td:first-child{border-left-width:0;border-right-width:0}.htFiltersConditionsMenu table tbody tr td.htDimmed{color:#323232;font-style:normal}.htFiltersConditionsMenu table tbody tr td.current{background:#e9e9e9}.htFiltersConditionsMenu table tbody tr td.htSeparator{border-top:1px solid #e6e6e6;height:0;padding:0}.htFiltersConditionsMenu table tbody tr td.htDisabled{color:#999}.htFiltersConditionsMenu table tbody tr td.htDisabled:hover{background:#fff;color:#999;cursor:default}.htFiltersConditionsMenu table tbody tr td .htItemWrapper{margin-left:10px;margin-right:10px}.htFiltersConditionsMenu table tbody tr td div span.selected{left:4px;margin-top:-2px;position:absolute}.htFiltersConditionsMenu .ht_master .wtHolder{overflow:hidden}.handsontable .htMenuFiltering{border-bottom:1px dotted #ccc;height:135px;overflow:hidden}.handsontable .ht_master table td.htCustomMenuRenderer{background-color:#fff;cursor:auto}.handsontable .htFiltersMenuLabel{font-size:.75em}.handsontable .htFiltersMenuActionBar{padding-bottom:3px;padding-top:10px;text-align:center}.handsontable .htFiltersMenuCondition.border{border-bottom:1px dotted #ccc!important}.handsontable .htFiltersMenuCondition .htUIInput{padding:0 0 5px}.handsontable .htFiltersMenuValue{border-bottom:1px dotted #ccc!important}.handsontable .htFiltersMenuValue .htUIMultipleSelectSearch{padding:0}.handsontable .htFiltersMenuCondition .htUIInput input,.handsontable .htFiltersMenuValue .htUIMultipleSelectSearch input{box-sizing:border-box;font-family:inherit;font-size:.75em;padding:4px;width:100%}.htUIMultipleSelect .ht_master .wtHolder{overflow-y:scroll}.handsontable .htFiltersActive .changeType{background-color:#d2e0d9;border:1px solid #509272;color:#18804e}.handsontable .htUISelectAll{margin-left:0;margin-right:10px}[dir=rtl].handsontable .htUISelectAll{margin-left:10px;margin-right:0}.handsontable .htUIClearAll,.handsontable .htUISelectAll{display:inline-block}.handsontable .htUIClearAll a,.handsontable .htUISelectAll a{font-size:.75em}.handsontable .htUISelectionControls{text-align:right}[dir=rtl].handsontable .htUISelectionControls{text-align:left}.handsontable .htCheckboxRendererInput{height:1em;margin:0 5px 0 0;vertical-align:middle}[dir=rtl].handsontable .htCheckboxRendererInput{margin-left:5px;margin-right:0}.handsontable .htUIInput{padding:3px 0 7px;position:relative;text-align:center}.handsontable .htUIInput input{border:1px solid #d2d1d1;border-radius:2px}.handsontable .htUIInputIcon{position:absolute}.handsontable .htUIInput.htUIButton{cursor:pointer;display:inline-block}.handsontable .htUIInput.htUIButton input{background-color:#eee;color:#000;cursor:pointer;font-family:inherit;font-size:.75em;font-weight:700;height:19px;min-width:64px}.handsontable .htUIInput.htUIButton input:hover{border-color:#b9b9b9}.handsontable .htUIInput.htUIButtonOK{margin-left:0;margin-right:10px}[dir=rtl].handsontable .htUIInput.htUIButtonOK{margin-left:10px;margin-right:0}.handsontable .htUIInput.htUIButtonOK input{background-color:#0f9d58;border-color:#18804e;color:#fff}.handsontable .htUIInput.htUIButtonOK input:focus-visible{background-color:#92dd8d;border-color:#7cb878;color:#000}.handsontable .htUIInput.htUIButtonOK input:hover{border-color:#1a6f46}.handsontable .htUISelect{cursor:pointer;margin-bottom:7px;position:relative}.handsontable .htUISelectCaption{background-color:#e8e8e8;border:1px solid #d2d1d1;border-radius:2px;font-family:inherit;font-size:.75em;font-weight:700;overflow:hidden;padding:3px 20px 3px 10px;text-overflow:ellipsis;white-space:nowrap}.handsontable .htUISelectCaption:hover{background-color:#e8e8e8;border:1px solid #b9b9b9}.handsontable .htUISelectDropdown:after{content:"▲";font-size:7px;position:absolute;right:10px;top:0}.handsontable .htUISelectDropdown:before{content:"▼";font-size:7px;position:absolute;right:10px;top:8px}.handsontable .htUIMultipleSelect .handsontable .htCore{border:none}.handsontable .htUIMultipleSelect .handsontable .htCore td:hover{background-color:#f5f5f5}.handsontable .htUIMultipleSelectSearch input{border:1px solid #d2d1d1;border-radius:2px;padding:3px}.handsontable .htUIRadio{display:inline-block;height:100%;margin-left:0;margin-right:5px}[dir=rtl].handsontable .htUIRadio{margin-left:5px;margin-right:0}.handsontable .htUIRadio:last-child{margin-right:0}.handsontable .htUIRadio>input[type=radio]{margin-left:0;margin-right:.5ex}[dir=rtl].handsontable .htUIRadio>input[type=radio]{margin-left:.5ex;margin-right:0}.handsontable .htUIRadio label{vertical-align:middle}.handsontable .htFiltersMenuOperators{padding-bottom:5px}.handsontable th.beforeHiddenColumn{position:relative}.handsontable th.afterHiddenColumn:before,.handsontable th.beforeHiddenColumn:after{color:#bbb;font-size:5pt;position:absolute;top:50%;transform:translateY(-50%)}.handsontable th.afterHiddenColumn{position:relative}.handsontable[dir=ltr] th.afterHiddenColumn div.htLeft{margin-left:10px}.handsontable[dir=ltr] th.beforeHiddenColumn div.htRight,.handsontable[dir=rtl] th.afterHiddenColumn div.htRight{margin-right:10px}.handsontable[dir=rtl] th.beforeHiddenColumn div.htLeft{margin-left:10px}.handsontable th.beforeHiddenColumn:after{content:"◀";right:1px}[dir=rtl].handsontable th.beforeHiddenColumn:after{content:"▶";left:1px;right:auto}.handsontable th.afterHiddenColumn:before{content:"▶";left:1px}[dir=rtl].handsontable th.afterHiddenColumn:before{content:"◀";left:auto;right:1px} +/*! + * Handsontable HiddenRows + */.handsontable th.afterHiddenRow:after,.handsontable th.beforeHiddenRow:before{color:#bbb;font-size:6pt;left:2px;line-height:6pt;position:absolute}.handsontable th.afterHiddenRow,.handsontable th.beforeHiddenRow{position:relative}.handsontable th.beforeHiddenRow:before{bottom:2px;content:"▲"}.handsontable th.afterHiddenRow:after{content:"▼";top:2px}.handsontable.ht__selection--rows tbody th.afterHiddenRow.ht__highlight:after,.handsontable.ht__selection--rows tbody th.beforeHiddenRow.ht__highlight:before{color:#eee}.handsontable td.afterHiddenRow.firstVisibleRow,.handsontable th.afterHiddenRow.firstVisibleRow{border-top:1px solid #ccc}.htRowHeaders .ht_master.innerBorderInlineStart~.ht_clone_inline_start td:first-of-type,.htRowHeaders .ht_master.innerBorderInlineStart~.ht_clone_top_inline_start_corner th:nth-child(2){border-left:0}.handsontable.ht__manualColumnMove.after-selection--columns thead th.ht__highlight{cursor:move;cursor:-moz-grab;cursor:-webkit-grab;cursor:grab}.handsontable.ht__manualColumnMove.on-moving--columns *,.handsontable.ht__manualColumnMove.on-moving--columns thead th.ht__highlight{cursor:move;cursor:-moz-grabbing;cursor:-webkit-grabbing;cursor:grabbing}.handsontable.ht__manualColumnMove.on-moving--columns .manualColumnResizer{display:none}.handsontable .ht__manualColumnMove--backlight,.handsontable .ht__manualColumnMove--guideline{display:none;height:100%;position:absolute}.handsontable .ht__manualColumnMove--guideline{background:#757575;margin-inline-end:0;margin-inline-start:-1px;top:0;width:2px;z-index:205}.handsontable .ht__manualColumnMove--backlight{background:#343434;background:rgba(52,52,52,.25);display:none;pointer-events:none;z-index:205}.handsontable.on-moving--columns .ht__manualColumnMove--backlight,.handsontable.on-moving--columns.show-ui .ht__manualColumnMove--guideline{display:block}.handsontable .wtHider{position:relative}.handsontable.ht__manualRowMove.after-selection--rows tbody th.ht__highlight{cursor:move;cursor:-moz-grab;cursor:-webkit-grab;cursor:grab}.handsontable.ht__manualRowMove.on-moving--rows *,.handsontable.ht__manualRowMove.on-moving--rows tbody th.ht__highlight{cursor:move;cursor:-moz-grabbing;cursor:-webkit-grabbing;cursor:grabbing}.handsontable.ht__manualRowMove.on-moving--rows .manualRowResizer{display:none}.handsontable .ht__manualRowMove--backlight,.handsontable .ht__manualRowMove--guideline{display:none;position:absolute;width:100%}.handsontable .ht__manualRowMove--guideline{background:#757575;height:2px;left:0;margin-top:-1px;z-index:205}.handsontable .ht__manualRowMove--backlight{background:#343434;background:rgba(52,52,52,.25);display:none;pointer-events:none;z-index:205}.handsontable.on-moving--rows .ht__manualRowMove--backlight,.handsontable.on-moving--rows.show-ui .ht__manualRowMove--guideline{display:block}.handsontable tbody td[rowspan][class*=area][class*=highlight]:not([class*=fullySelectedMergedCell]):before{opacity:0}.handsontable tbody td[rowspan][class*=area][class*=highlight][class*=fullySelectedMergedCell-0]:before,.handsontable tbody td[rowspan][class*=area][class*=highlight][class*=fullySelectedMergedCell-multiple]:before{opacity:.1}.handsontable tbody td[rowspan][class*=area][class*=highlight][class*=fullySelectedMergedCell-1]:before{opacity:.2}.handsontable tbody td[rowspan][class*=area][class*=highlight][class*=fullySelectedMergedCell-2]:before{opacity:.27}.handsontable tbody td[rowspan][class*=area][class*=highlight][class*=fullySelectedMergedCell-3]:before{opacity:.35}.handsontable tbody td[rowspan][class*=area][class*=highlight][class*=fullySelectedMergedCell-4]:before{opacity:.41}.handsontable tbody td[rowspan][class*=area][class*=highlight][class*=fullySelectedMergedCell-5]:before{opacity:.47}.handsontable tbody td[rowspan][class*=area][class*=highlight][class*=fullySelectedMergedCell-6]:before{opacity:.54}.handsontable tbody td[rowspan][class*=area][class*=highlight][class*=fullySelectedMergedCell-7]:before{opacity:.58}.handsontable[dir=ltr] div.htRight span[class*=sort-]{margin-left:-15px;margin-right:15px}.handsontable[dir=rtl] div.htLeft span[class*=sort-]{margin-left:15px;margin-right:-15px}.handsontable[dir=ltr] div.htRight span[class*=sort-]:only-child{margin-left:-20px;margin-right:20px}.handsontable[dir=rtl] div.htLeft span[class*=sort-]:only-child{margin-left:20px;margin-right:-20px}.handsontable span.colHeader.columnSorting:after{font-size:8px;height:8px;left:unset;line-height:1.1;margin-top:-2px;padding-left:5px;padding-right:unset;position:absolute;right:-15px;text-decoration:underline;top:50%}[dir=rtl].handsontable span.colHeader.columnSorting:after{left:-15px;padding-left:unset;padding-right:5px;right:unset}.handsontable span.colHeader.columnSorting:after{text-decoration:none}.handsontable span.colHeader.columnSorting[class*=" sort-"]:after,.handsontable span.colHeader.columnSorting[class^=sort-]:after{content:"+"}.handsontable span.colHeader.columnSorting.sort-1:after{content:"1"}.handsontable span.colHeader.columnSorting.sort-2:after{content:"2"}.handsontable span.colHeader.columnSorting.sort-3:after{content:"3"}.handsontable span.colHeader.columnSorting.sort-4:after{content:"4"}.handsontable span.colHeader.columnSorting.sort-5:after{content:"5"}.handsontable span.colHeader.columnSorting.sort-6:after{content:"6"}.handsontable span.colHeader.columnSorting.sort-7:after{content:"7"}.htGhostTable th div button.changeType+span.colHeader.columnSorting:not(.indicatorDisabled){padding-right:5px}.handsontable thead th.hiddenHeader:not(:first-of-type){display:none}.handsontable th.ht_nestingLevels{padding-left:7px;text-align:left}[dir=rtl].handsontable th.ht_nestingLevels{padding-right:7px;text-align:right}.handsontable th div.ht_nestingLevels{display:inline-block;left:11px;position:absolute;right:unset}[dir=rtl].handsontable th div.ht_nestingLevels{left:unset;right:11px}.handsontable.innerBorderInlineStart th div.ht_nestingLevels,.handsontable.innerBorderInlineStart~.handsontable th div.ht_nestingLevels{left:unset;right:10px}[dir=rtl].handsontable.innerBorderInlineStart th div.ht_nestingLevels,[dir=rtl].handsontable.innerBorderInlineStart~.handsontable th div.ht_nestingLevels{left:10px;right:unset}.handsontable th span.ht_nestingLevel{display:inline-block}.handsontable th span.ht_nestingLevel_empty{display:inline-block;float:left;height:1px;width:10px}[dir=rtl].handsontable th span.ht_nestingLevel_empty{float:right}.handsontable th span.ht_nestingLevel:after{bottom:3px;content:"┐";display:inline-block;font-size:9px;position:relative}.handsontable th div.ht_nestingButton{cursor:pointer;display:inline-block;left:unset;position:absolute;right:-2px}[dir=rtl].handsontable th div.ht_nestingButton{left:-2px;right:unset}.handsontable th div.ht_nestingButton.ht_nestingExpand:after{content:"+"}.handsontable th div.ht_nestingButton.ht_nestingCollapse:after{content:"-"}.handsontable.innerBorderInlineStart th div.ht_nestingButton,.handsontable.innerBorderInlineStart~.handsontable th div.ht_nestingButton{left:unset;right:0}[dir=rtl].handsontable.innerBorderInlineStart th div.ht_nestingButton,[dir=rtl].handsontable.innerBorderInlineStart~.handsontable th div.ht_nestingButton{left:0;right:unset} \ No newline at end of file diff --git a/docs/_source/_static/handsontable.full.min.js b/docs/_source/_static/handsontable.full.min.js new file mode 100644 index 0000000..87f7981 --- /dev/null +++ b/docs/_source/_static/handsontable.full.min.js @@ -0,0 +1,995 @@ +/*! + * Copyright (c) HANDSONCODE sp. z o. o. + * + * HANDSONTABLE is a software distributed by HANDSONCODE sp. z o. o., a Polish corporation based in + * Gdynia, Poland, at Aleja Zwyciestwa 96-98, registered by the District Court in Gdansk under number + * 538651, EU tax ID number: PL5862294002, share capital: PLN 62,800.00. + * + * This software is protected by applicable copyright laws, including international treaties, and dual- + * licensed - depending on whether your use for commercial purposes, meaning intended for or + * resulting in commercial advantage or monetary compensation, or not. + * + * If your use is strictly personal or solely for evaluation purposes, meaning for the purposes of testing + * the suitability, performance, and usefulness of this software outside the production environment, + * you agree to be bound by the terms included in the "handsontable-non-commercial-license.pdf" file. + * + * Your use of this software for commercial purposes is subject to the terms included in an applicable + * license agreement. + * + * In any case, you must not make any such use of this software as to develop software which may be + * considered competitive with this software. + * + * UNLESS EXPRESSLY AGREED OTHERWISE, HANDSONCODE PROVIDES THIS SOFTWARE ON AN "AS IS" + * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, AND IN NO EVENT AND UNDER NO + * LEGAL THEORY, SHALL HANDSONCODE BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY DIRECT, + * INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES OF ANY CHARACTER ARISING FROM + * USE OR INABILITY TO USE THIS SOFTWARE. + * + * Version: 14.5.0 + * Release date: 30/07/2024 (built at 30/07/2024 09:20:07) + */ +!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("Handsontable",[],t):"object"==typeof exports?exports.Handsontable=t():e.Handsontable=t()}("undefined"!=typeof self?self:this,(()=>(()=>{var e={44820:(e,t,r)=>{"use strict";r.d(t,{iz:()=>lt,Ay:()=>ph});var n,s,i={};r.r(i),r.d(i,{AbsPlugin:()=>eo,AddressPlugin:()=>Zi,ArrayPlugin:()=>Ji,BitShiftPlugin:()=>ro,BitwiseLogicOperationsPlugin:()=>oo,BooleanPlugin:()=>ao,CharPlugin:()=>lo,CodePlugin:()=>ho,ComplexPlugin:()=>Ql,ConditionalAggregationPlugin:()=>ma,CountBlankPlugin:()=>uo,CountUniquePlugin:()=>co,DateTimePlugin:()=>po,DegreesPlugin:()=>Eo,DeltaPlugin:()=>wo,ExpPlugin:()=>Co,FinancialPlugin:()=>vo,FormulaTextPlugin:()=>_o,HyperlinkPlugin:()=>bo,InformationPlugin:()=>Ao,IsEvenPlugin:()=>Oo,IsOddPlugin:()=>Io,LogarithmPlugin:()=>xo,LookupPlugin:()=>va,MathConstantsPlugin:()=>Lo,MathPlugin:()=>$l,MatrixPlugin:()=>Ho,MedianPlugin:()=>Fo,ModuloPlugin:()=>Uo,NumericAggregationPlugin:()=>Wo,PowerPlugin:()=>Go,RadiansPlugin:()=>zo,RadixConversionPlugin:()=>Ko,RandomPlugin:()=>ta,RomanPlugin:()=>Ra,RoundingPlugin:()=>sa,SimpleArithmerticPlugin:()=>Na,SqrtPlugin:()=>ia,StatisticalAggregationPlugin:()=>hh,StatisticalPlugin:()=>zl,SumprodPlugin:()=>ya,TextPlugin:()=>Ea,TrigonometryPlugin:()=>wa}),function(e){e.RELATIVE="RELATIVE",e.ABSOLUTE="ABSOLUTE"}(n||(n={}));class o{constructor(e,t,r){this.type=e,this.col=t,this.sheet=r}static absolute(e,t){return new o(n.ABSOLUTE,e,t)}static relative(e,t){return new o(n.RELATIVE,e,t)}static compareByAbsoluteAddress(e){return(t,r)=>t.toSimpleColumnAddress(e).col-r.toSimpleColumnAddress(e).col}isColumnAbsolute(){return this.type===n.ABSOLUTE}isColumnRelative(){return this.type===n.RELATIVE}isAbsolute(){return this.type===n.ABSOLUTE&&void 0!==this.sheet}moved(e,t,r){const n=void 0===this.sheet?void 0:e;return new o(this.type,this.col+t,n)}shiftedByColumns(e){return new o(this.type,this.col+e,this.sheet)}toSimpleColumnAddress(e){const t=Lr(this,e);let r=this.col;return this.isColumnRelative()&&(r=e.col+this.col),_r(t,r)}shiftRelativeDimensions(e,t){const r=this.isColumnRelative()?this.col+e:this.col;return new o(this.type,r,this.sheet)}shiftAbsoluteDimensions(e,t){const r=this.isColumnAbsolute()?this.col+e:this.col;return new o(this.type,r,this.sheet)}withSheet(e){return new o(this.type,this.col,e)}isInvalid(e){return this.toSimpleColumnAddress(e).col<0}hash(e){const t=e&&void 0!==this.sheet?`#${this.sheet}`:"";switch(this.type){case n.RELATIVE:return`${t}#COLR${this.col}`;case n.ABSOLUTE:return`${t}#COLA${this.col}`}}unparse(e){const t=this.toSimpleColumnAddress(e);if(br(t))return;const r=P(t.col);return`${this.type===n.ABSOLUTE?"$":""}${r}`}exceedsSheetSizeLimits(e){return this.col>=e}} +/** + * @license + * Copyright (c) 2024 Handsoncode. All rights reserved. + */ +class a{constructor(e,t,r){this.type=e,this.row=t,this.sheet=r}static absolute(e,t){return new a(n.ABSOLUTE,e,t)}static relative(e,t){return new a(n.RELATIVE,e,t)}static compareByAbsoluteAddress(e){return(t,r)=>t.toSimpleRowAddress(e).row-r.toSimpleRowAddress(e).row}isRowAbsolute(){return this.type===n.ABSOLUTE}isRowRelative(){return this.type===n.RELATIVE}isAbsolute(){return this.type===n.ABSOLUTE&&void 0!==this.sheet}moved(e,t,r){const n=void 0===this.sheet?void 0:e;return new a(this.type,this.row+r,n)}shiftedByRows(e){return new a(this.type,this.row+e,this.sheet)}toSimpleRowAddress(e){const t=Lr(this,e);let r=this.row;return this.isRowRelative()&&(r=e.row+this.row),Nr(t,r)}shiftRelativeDimensions(e,t){const r=this.isRowRelative()?this.row+t:this.row;return new a(this.type,r,this.sheet)}shiftAbsoluteDimensions(e,t){const r=this.isRowAbsolute()?this.row+t:this.row;return new a(this.type,r,this.sheet)}withSheet(e){return new a(this.type,this.row,e)}isInvalid(e){return this.toSimpleRowAddress(e).row<0}hash(e){const t=e&&void 0!==this.sheet?`#${this.sheet}`:"";switch(this.type){case n.RELATIVE:return`${t}#ROWR${this.row}`;case n.ABSOLUTE:return`${t}#ROWA${this.row}`}}unparse(e){const t=this.toSimpleRowAddress(e);if(Mr(t))return;return`${this.type===n.ABSOLUTE?"$":""}${t.row+1}`}exceedsSheetSizeLimits(e){return this.row>=e}}!function(e){e.CELL_REFERENCE_RELATIVE="CELL_REFERENCE",e.CELL_REFERENCE_ABSOLUTE="CELL_REFERENCE_ABSOLUTE",e.CELL_REFERENCE_ABSOLUTE_COL="CELL_REFERENCE_ABSOLUTE_COL",e.CELL_REFERENCE_ABSOLUTE_ROW="CELL_REFERENCE_ABSOLUTE_ROW"}(s||(s={}));class l{constructor(e,t,r,n){this.col=e,this.row=t,this.type=r,this.sheet=n}static fromColAndRow(e,t,r){return(e.isColumnAbsolute()&&t.isRowAbsolute()?l.absolute.bind(this):e.isColumnAbsolute()?l.absoluteCol.bind(this):t.isRowAbsolute()?l.absoluteRow.bind(this):l.relative.bind(this))(e.col,t.row,r)}static relative(e,t,r){return new l(e,t,s.CELL_REFERENCE_RELATIVE,r)}static absolute(e,t,r){return new l(e,t,s.CELL_REFERENCE_ABSOLUTE,r)}static absoluteCol(e,t,r){return new l(e,t,s.CELL_REFERENCE_ABSOLUTE_COL,r)}static absoluteRow(e,t,r){return new l(e,t,s.CELL_REFERENCE_ABSOLUTE_ROW,r)}toSimpleCellAddress(e){const t=Lr(this,e);return this.type===s.CELL_REFERENCE_ABSOLUTE?Ar(t,this.col,this.row):this.type===s.CELL_REFERENCE_ABSOLUTE_ROW?Ar(t,e.col+this.col,this.row):this.type===s.CELL_REFERENCE_ABSOLUTE_COL?Ar(t,this.col,e.row+this.row):Ar(t,e.col+this.col,e.row+this.row)}toColumnAddress(){const e=this.isColumnRelative()?n.RELATIVE:n.ABSOLUTE;return new o(e,this.col,this.sheet)}toRowAddress(){const e=this.isRowRelative()?n.RELATIVE:n.ABSOLUTE;return new a(e,this.row,this.sheet)}toSimpleColumnAddress(e){const t=Lr(this,e);let r=this.col;return this.isColumnRelative()&&(r+=e.col),_r(t,r)}toSimpleRowAddress(e){const t=Lr(this,e);let r=this.row;return this.isRowRelative()&&(r+=e.row),Nr(t,r)}isRowAbsolute(){return this.type===s.CELL_REFERENCE_ABSOLUTE||this.type===s.CELL_REFERENCE_ABSOLUTE_ROW}isColumnAbsolute(){return this.type===s.CELL_REFERENCE_ABSOLUTE||this.type===s.CELL_REFERENCE_ABSOLUTE_COL}isColumnRelative(){return this.type===s.CELL_REFERENCE_RELATIVE||this.type===s.CELL_REFERENCE_ABSOLUTE_ROW}isRowRelative(){return this.type===s.CELL_REFERENCE_RELATIVE||this.type===s.CELL_REFERENCE_ABSOLUTE_COL}isAbsolute(){return this.type===s.CELL_REFERENCE_ABSOLUTE&&void 0!==this.sheet}shiftedByRows(e){return new l(this.col,this.row+e,this.type,this.sheet)}shiftedByColumns(e){return new l(this.col+e,this.row,this.type,this.sheet)}moved(e,t,r){const n=void 0===this.sheet?void 0:e;return new l(this.col+t,this.row+r,this.type,n)}withSheet(e){return new l(this.col,this.row,this.type,e)}isInvalid(e){return Or(this.toSimpleCellAddress(e))}shiftRelativeDimensions(e,t){const r=this.isColumnAbsolute()?this.col:this.col+e,n=this.isRowAbsolute()?this.row:this.row+t;return new l(r,n,this.type,this.sheet)}shiftAbsoluteDimensions(e,t){const r=this.isColumnRelative()?this.col:this.col+e,n=this.isRowRelative()?this.row:this.row+t;return new l(r,n,this.type,this.sheet)}hash(e){const t=e&&void 0!==this.sheet?`#${this.sheet}`:"";switch(this.type){case s.CELL_REFERENCE_RELATIVE:return`${t}#${this.row}R${this.col}`;case s.CELL_REFERENCE_ABSOLUTE:return`${t}#${this.row}A${this.col}`;case s.CELL_REFERENCE_ABSOLUTE_COL:return`${t}#${this.row}AC${this.col}`;case s.CELL_REFERENCE_ABSOLUTE_ROW:return`${t}#${this.row}AR${this.col}`}}unparse(e){const t=this.toSimpleCellAddress(e);if(Or(t))return;const r=P(t.col),n=this.type===s.CELL_REFERENCE_ABSOLUTE||this.type===s.CELL_REFERENCE_ABSOLUTE_ROW?"$":"";return`${this.type===s.CELL_REFERENCE_ABSOLUTE||this.type===s.CELL_REFERENCE_ABSOLUTE_COL?"$":""}${r}${n}${t.row+1}`}exceedsSheetSizeLimits(e,t){return this.row>=t||this.col>=e}} +/** + * @license + * Copyright (c) 2024 Handsoncode. All rights reserved. + */ +const h=":",u="$",c="A-Za-zÀ-ʯ",d=`${c}0-9_.`,p=`[${c}0-9_]+`,g=`(${p}|'(((?!').|'')*)')!`,f=`(${g})?\\${u}?[A-Za-z]+\\${u}?[0-9]+`,m=`(${g})?\\${u}?[A-Za-z]+`,y=`(${g})?\\${u}?[0-9]+`,E="[rR][0-9]*[cC][0-9]*",w=`(${f})[^${d}]`,C=`[${c}_][${d}]*`,v=["0","1","2","3","4","5","6","7","8","9"],R=[...Array.from(Array(26)).map(((e,t)=>t+"A".charCodeAt(0))),...Array.from(Array(26)).map(((e,t)=>t+"a".charCodeAt(0))),...Array.from(Array(496)).map(((e,t)=>t+192))].map((e=>String.fromCharCode(e))),S=new RegExp(`^(${g})?(\\${u}?)([A-Za-z]+)(\\${u}?)([0-9]+)$`),T=new RegExp(`^(${g})?(\\${u}?)([A-Za-z]+)$`),N=new RegExp(`^(${g})?(\\${u}?)([0-9]+)$`),M=new RegExp(`^${p}$`),_=(e,t,r)=>{const n=S.exec(t),s=x(n[6]);let i=D(n,e);if(void 0===i)return;null===i&&(i=void 0);const o=Number(n[8])-1;return n[5]===u&&n[7]===u?l.absolute(s,o,i):n[5]===u?l.absoluteCol(s,o-r.row,i):n[7]===u?l.absoluteRow(s-r.col,o,i):l.relative(s-r.col,o-r.row,i)},b=(e,t,r)=>{const n=T.exec(t);let s=D(n,e);if(void 0===s)return;null===s&&(s=void 0);const i=x(n[6]);return n[5]===u?o.absolute(i,s):o.relative(i-r.col,s)},A=(e,t,r)=>{const n=N.exec(t);let s=D(n,e);if(void 0===s)return;null===s&&(s=void 0);const i=Number(n[6])-1;return n[5]===u?a.absolute(i,s):a.relative(i-r.row,s)},O=(e,t,r)=>{const n=S.exec(t);if(!n)return;const s=x(n[6]);let i=D(n,e);if(void 0===i)return;null===i&&(i=r);const o=Number(n[8])-1;return Ar(i,s,o)},I=(e,t,r)=>{const n=P(t.col),s=L(t.sheet,e);if(void 0!==s)return r!==t.sheet?`${s}!${n}${t.row+1}`:`${n}${t.row+1}`};function x(e){return 1===e.length?e.toUpperCase().charCodeAt(0)-65:e.split("").reduce(((e,t)=>26*e+(t.toUpperCase().charCodeAt(0)-64)),0)-1}function P(e){let t="";for(;e>=0;)t=String.fromCharCode(e%26+97)+t,e=Math.floor(e/26)-1;return t.toUpperCase()}function L(e,t){let r=t(e);if(void 0!==r)return M.test(r)?r:(r=r.replace(/'/g,"''"),`'${r}'`)}function D(e,t){var r;let n=null!==(r=e[3])&&void 0!==r?r:e[2];return n?(n=n.replace(/''/g,"'"),t(n)):null}var k=r(83012); +/** + * @license + * Copyright (c) 2024 Handsoncode. All rights reserved. + */ +const H=(e,t)=>({type:e,message:t});var F,U,V;!function(e){e.LexingError="LexingError",e.ParserError="ParsingError",e.StaticOffsetError="StaticOffsetError",e.StaticOffsetOutOfRangeError="StaticOffsetOutOfRangeError",e.RangeOffsetNotAllowed="RangeOffsetNotAllowed",e.InvalidRangeSize="InvalidRangeSize"}(F||(F={})),function(e){e.EMPTY="EMPTY",e.NUMBER="NUMBER",e.STRING="STRING",e.MINUS_UNARY_OP="MINUS_UNARY_OP",e.PLUS_UNARY_OP="PLUS_UNARY_OP",e.PERCENT_OP="PERCENT_OP",e.CONCATENATE_OP="CONCATENATE_OP",e.EQUALS_OP="EQUALS_OP",e.NOT_EQUAL_OP="NOT_EQUAL_OP",e.GREATER_THAN_OP="GREATER_THAN_OP",e.LESS_THAN_OP="LESS_THAN_OP",e.GREATER_THAN_OR_EQUAL_OP="GREATER_THAN_OR_EQUAL_OP",e.LESS_THAN_OR_EQUAL_OP="LESS_THAN_OR_EQUAL_OP",e.PLUS_OP="PLUS_OP",e.MINUS_OP="MINUS_OP",e.TIMES_OP="TIMES_OP",e.DIV_OP="DIV_OP",e.POWER_OP="POWER_OP",e.FUNCTION_CALL="FUNCTION_CALL",e.NAMED_EXPRESSION="NAMED_EXPRESSION",e.PARENTHESIS="PARENTHESES",e.CELL_REFERENCE="CELL_REFERENCE",e.CELL_RANGE="CELL_RANGE",e.COLUMN_RANGE="COLUMN_RANGE",e.ROW_RANGE="ROW_RANGE",e.ERROR="ERROR",e.ERROR_WITH_RAW_INPUT="ERROR_WITH_RAW_INPUT",e.ARRAY="ARRAY"}(U||(U={})),function(e){e[e.RELATIVE=0]="RELATIVE",e[e.START_ABSOLUTE=1]="START_ABSOLUTE",e[e.BOTH_ABSOLUTE=2]="BOTH_ABSOLUTE"}(V||(V={}));const B=(e,t)=>({type:U.CELL_REFERENCE,reference:e,leadingWhitespace:null==t?void 0:t.image}),W=(e,t,r,n)=>($(e,t,r),{type:U.CELL_RANGE,start:e,end:t,sheetReferenceType:r,leadingWhitespace:n}),Y=(e,t,r)=>({type:U.ARRAY,args:e,leadingWhitespace:null==t?void 0:t.image,internalWhitespace:null==r?void 0:r.image}),j=(e,t)=>({type:U.ERROR,error:e,leadingWhitespace:null==t?void 0:t.image}),G=(e,t,r)=>({type:U.ERROR_WITH_RAW_INPUT,error:t,rawInput:e,leadingWhitespace:null==r?void 0:r.image}),z=()=>({type:U.ERROR,error:Tr.parsingError()});function $(e,t,r){if(void 0!==e.sheet&&void 0===t.sheet||void 0===e.sheet&&void 0!==t.sheet)throw new Error("Start address inconsistent with end address");if(void 0===e.sheet&&r!==V.RELATIVE||void 0!==e.sheet&&r===V.RELATIVE)throw new Error("Sheet address inconsistent with sheet reference type")}function K(e,t){return(null!=t?t:"")+e} +/** + * @license + * Copyright (c) 2024 Handsoncode. All rights reserved. + */ +const X={[U.PLUS_OP]:"+",[U.MINUS_OP]:"-",[U.TIMES_OP]:"*",[U.DIV_OP]:"/",[U.CONCATENATE_OP]:"&",[U.POWER_OP]:"^",[U.EQUALS_OP]:"=",[U.NOT_EQUAL_OP]:"<>",[U.GREATER_THAN_OP]:">",[U.GREATER_THAN_OR_EQUAL_OP]:">=",[U.LESS_THAN_OP]:"<",[U.LESS_THAN_OR_EQUAL_OP]:"<="};class q{constructor(e){this.functionRegistry=e,this.cache=new Map}set(e,t){const r=((e,t,r,n)=>({ast:e,relativeDependencies:t,hasVolatileFunction:r,hasStructuralChangeFunction:n}))(t,ke(t,this.functionRegistry),Q(t,this.functionRegistry.isFunctionVolatile),Q(t,this.functionRegistry.isFunctionDependentOnSheetStructureChange));return this.cache.set(e,r),r}get(e){return this.cache.get(e)}maybeSetAndThenGet(e,t){const r=this.cache.get(e);return void 0!==r?r.ast:(this.set(e,t),t)}}const Q=(e,t)=>{switch(e.type){case U.EMPTY:case U.NUMBER:case U.STRING:case U.ERROR:case U.ERROR_WITH_RAW_INPUT:case U.CELL_REFERENCE:case U.CELL_RANGE:case U.COLUMN_RANGE:case U.ROW_RANGE:case U.NAMED_EXPRESSION:return!1;case U.PERCENT_OP:case U.PLUS_UNARY_OP:case U.MINUS_UNARY_OP:return Q(e.value,t);case U.CONCATENATE_OP:case U.EQUALS_OP:case U.NOT_EQUAL_OP:case U.LESS_THAN_OP:case U.GREATER_THAN_OP:case U.LESS_THAN_OR_EQUAL_OP:case U.GREATER_THAN_OR_EQUAL_OP:case U.MINUS_OP:case U.PLUS_OP:case U.TIMES_OP:case U.DIV_OP:case U.POWER_OP:return Q(e.left,t)||Q(e.right,t);case U.PARENTHESIS:return Q(e.expression,t);case U.FUNCTION_CALL:return!!t(e.procedureName)||e.args.some((e=>Q(e,t)));case U.ARRAY:return e.args.some((e=>e.some((e=>Q(e,t)))))}}; +/** + * @license + * Copyright (c) 2024 Handsoncode. All rights reserved. + */ +class Z{}Z.DistinctSigns="Distinct signs.",Z.WrongArgNumber="Wrong number of arguments.",Z.EmptyArg="Empty function argument.",Z.EmptyArray="Empty array not allowed.",Z.ArrayDimensions="Array dimensions are not compatible.",Z.NoSpaceForArrayResult="No space for array result.",Z.ValueSmall="Value too small.",Z.ValueLarge="Value too large.",Z.BadCriterion="Incorrect criterion.",Z.RangeManySheets="Range spans more than one sheet.",Z.CellRangeExpected="Cell range expected.",Z.WrongDimension="Wrong range dimension.",Z.ScalarExpected="Cell range not allowed.",Z.NumberCoercion="Value cannot be coerced to number.",Z.NumberExpected="Number argument expected.",Z.IntegerExpected="Value needs to be an integer.",Z.BadMode="Mode not recognized.",Z.DateBounds="Date outside of bounds.",Z.OutOfSheet="Resulting reference is out of the sheet.",Z.WrongType="Wrong type of argument.",Z.NaN="NaN or infinite value encountered.",Z.EqualLength="Ranges need to be of equal length.",Z.Negative="Value cannot be negative.",Z.NotBinary="String does not represent a binary number.",Z.NotOctal="String does not represent an octal number.",Z.NotHex="String does not represent a hexadecimal number.",Z.EndStartPeriod="End period needs to be at least start period.",Z.CellRefExpected="Cell reference expected.",Z.EmptyRange="Empty range not allowed.",Z.BadRef="Address is not correct.",Z.NumberRange="Number-only range expected.",Z.ValueNotFound="Value not found.",Z.ValueBaseLarge="Value in base too large.",Z.ValueBaseSmall="Value in base too small.",Z.ValueBaseLong="Value in base too long.",Z.NegativeLength="Length cannot be negative.",Z.PatternNotFound="Pattern not found.",Z.OneValue="Needs at least one value.",Z.TwoValues="Range needs to contain at least two elements.",Z.ThreeValues="Range needs to contain at least three elements.",Z.IndexBounds="Index out of bounds.",Z.IndexLarge="Index too large.",Z.Formula="Expected formula.",Z.NegativeCount="Count cannot be negative.",Z.ParseError="Parsing error.",Z.SheetRef="Sheet does not exist.",Z.PeriodLong="Period number cannot exceed life length.",Z.InvalidDate="Invalid date.",Z.BitshiftLong="Result of bitshift is too long.",Z.EmptyString="Empty-string argument not allowed.",Z.LengthBounds="Length out of bounds.",Z.NegativeTime="Time cannot be negative.",Z.NoDefault="No default option.",Z.NoConditionMet="None of the conditions were met.",Z.Selector="Selector cannot exceed the number of arguments.",Z.StartEndDate="Start date needs to be earlier than end date.",Z.IncorrectDateTime="String does not represent correct DateTime.",Z.CharacterCodeBounds="Character code out of bounds.",Z.NonZero="Argument cannot be 0.",Z.LessThanOne="Argument cannot be less than 1.",Z.WeekendString="Incorrect weekend bitmask string.",Z.InvalidRoman="Invalid roman numeral.",Z.WrongOrder="Wrong order of values.",Z.ComplexNumberExpected="Complex number expected.",Z.ShouldBeIorJ="Should be 'i' or 'j'.",Z.SizeMismatch="Array dimensions mismatched.",Z.FunctionName=e=>`Function name ${e} not recognized.`,Z.NamedExpressionName=e=>`Named expression ${e} not recognized.`,Z.LicenseKey=e=>`License key is ${e}.`; +/** + * @license + * Copyright (c) 2024 Handsoncode. All rights reserved. + */ +const J=(0,k.createToken)({name:"AdditionOp",pattern:k.Lexer.NA}),ee=(0,k.createToken)({name:"PlusOp",pattern:/\+/,categories:J}),te=(0,k.createToken)({name:"MinusOp",pattern:/-/,categories:J}),re=(0,k.createToken)({name:"MultiplicationOp",pattern:k.Lexer.NA}),ne=(0,k.createToken)({name:"TimesOp",pattern:/\*/,categories:re}),se=(0,k.createToken)({name:"DivOp",pattern:/\//,categories:re}),ie=(0,k.createToken)({name:"PowerOp",pattern:/\^/}),oe=(0,k.createToken)({name:"PercentOp",pattern:/%/}),ae=(0,k.createToken)({name:"BooleanOp",pattern:k.Lexer.NA}),le=(0,k.createToken)({name:"EqualsOp",pattern:/=/,categories:ae}),he=(0,k.createToken)({name:"NotEqualOp",pattern:/<>/,categories:ae}),ue=(0,k.createToken)({name:"GreaterThanOp",pattern:/>/,categories:ae}),ce=(0,k.createToken)({name:"LessThanOp",pattern:/=/,categories:ae}),pe=(0,k.createToken)({name:"LessThanOrEqualOp",pattern:/<=/,categories:ae}),ge=(0,k.createToken)({name:"ConcatenateOp",pattern:/&/}),fe=(0,k.createToken)({name:"LParen",pattern:/\(/}),me=(0,k.createToken)({name:"RParen",pattern:/\)/}),ye=(0,k.createToken)({name:"ArrayLParen",pattern:/{/}),Ee=(0,k.createToken)({name:"ArrayRParen",pattern:/}/}),we=(0,k.createToken)({name:"StringLiteral",pattern:/"([^"\\]*(\\.[^"\\]*)*)"/}),Ce=(0,k.createToken)({name:"ErrorLiteral",pattern:/#[A-Za-z0-9\/]+[?!]?/}),ve=(0,k.createToken)({name:"RangeSeparator",pattern:new RegExp(h)}),Re=(0,k.createToken)({name:"ColumnRange",pattern:new RegExp(`${m}${h}${m}`)}),Se=(0,k.createToken)({name:"RowRange",pattern:new RegExp(`${y}${h}${y}`)}),Te=(0,k.createToken)({name:"ProcedureName",pattern:new RegExp(`([${c}][${d}]*)\\(`)}),Ne=new +/** + * @license + * Copyright (c) 2024 Handsoncode. All rights reserved. + */ +class{constructor(){this.POSSIBLE_START_CHARACTERS=[...R,...v,u,"'","_"],this.cellReferenceRegexp=new RegExp(w,"y")}match(e,t){this.cellReferenceRegexp.lastIndex=t;const r=this.cellReferenceRegexp.exec(e+"@");return null==r||null==r[1]?null:(r[0]=r[1],r)}},Me=(0,k.createToken)({name:"CellReference",pattern:Ne.match.bind(Ne),start_chars_hint:Ne.POSSIBLE_START_CHARACTERS,line_breaks:!1}),_e=new +/** + * @license + * Copyright (c) 2024 Handsoncode. All rights reserved. + */ +class{constructor(){this.POSSIBLE_START_CHARACTERS=[...R,"_"],this.namedExpressionRegexp=new RegExp(C,"y"),this.r1c1CellRefRegexp=new RegExp(`^${E}$`)}match(e,t){this.namedExpressionRegexp.lastIndex=t;const r=this.namedExpressionRegexp.exec(e);return null==r||null==r[0]||this.r1c1CellRefRegexp.test(r[0])?null:r}},be=(0,k.createToken)({name:"NamedExpression",pattern:_e.match.bind(_e),start_chars_hint:_e.POSSIBLE_START_CHARACTERS,line_breaks:!1}),Ae=e=>{const t=e.translationPackage.getFunctionTranslation("OFFSET"),r=e.errorMapping,n=e.translationPackage.buildFunctionMapping(),s=new RegExp("standard"===e.ignoreWhiteSpace?"[ \\t\\n\\r]+":"\\s+"),i=(0,k.createToken)({name:"WhiteSpace",pattern:s}),o=(0,k.createToken)({name:"ArrayRowSep",pattern:e.arrayRowSeparator}),a=(0,k.createToken)({name:"ArrayColSep",pattern:e.arrayColumnSeparator}),l=(0,k.createToken)({name:"NumberLiteral",pattern:new RegExp(`(([${e.decimalSeparator}]\\d+)|(\\d+([${e.decimalSeparator}]\\d*)?))(e[+-]?\\d+)?`)}),h=(0,k.createToken)({name:"OffsetProcedureName",pattern:new RegExp(t,"i")});let u,c;e.functionArgSeparator===e.arrayColumnSeparator?(u=a,c=[]):e.functionArgSeparator===e.arrayRowSeparator?(u=o,c=[]):(u=(0,k.createToken)({name:"ArgSeparator",pattern:e.functionArgSeparator}),c=[u]);return{ArgSeparator:u,NumberLiteral:l,OffsetProcedureName:h,ArrayRowSeparator:o,ArrayColSeparator:a,WhiteSpace:i,allTokens:[i,ee,te,ne,se,ie,le,he,oe,de,pe,ue,ce,fe,me,ye,Ee,h,Te,ve,...c,Re,Se,l,we,Ce,ge,ae,J,re,Me,be,o,a],errorMapping:r,functionMapping:n,decimalSeparator:e.decimalSeparator,maxColumns:e.maxColumns,maxRows:e.maxRows}}; +/** + * @license + * Copyright (c) 2024 Handsoncode. All rights reserved. + */ +class Oe extends k.EmbeddedActionsParser{constructor(e,t){super(e.allTokens,{outputCst:!1,maxLookahead:7}),this.booleanExpressionOrEmpty=this.RULE("booleanExpressionOrEmpty",(()=>{return this.OR([{ALT:()=>this.SUBRULE(this.booleanExpression)},{ALT:(0,k.EMPTY_ALT)({type:U.EMPTY,leadingWhitespace:null==e?void 0:e.image})}]);var e})),this.procedureExpression=this.RULE("procedureExpression",(()=>{var e;const t=this.CONSUME(Te),r=t.image.toUpperCase().slice(0,-1),n=null!==(e=this.lexerConfig.functionMapping[r])&&void 0!==e?e:r,s=[];let i=this.SUBRULE(this.booleanExpressionOrEmpty);this.MANY((()=>{var e;const t=this.CONSUME(this.lexerConfig.ArgSeparator);i.type===U.EMPTY&&(i.leadingWhitespace=null===(e=t.leadingWhitespace)||void 0===e?void 0:e.image),s.push(i),i=this.SUBRULE2(this.booleanExpressionOrEmpty)})),s.push(i),1===s.length&&s[0].type===U.EMPTY&&(s.length=0);const o=this.CONSUME(me);return((e,t,r,n,s)=>({type:U.FUNCTION_CALL,procedureName:e,args:t,leadingWhitespace:null==r?void 0:r.image,internalWhitespace:null==n?void 0:n.image,hyperlink:s}))(n,s,t.leadingWhitespace,o.leadingWhitespace)})),this.namedExpressionExpression=this.RULE("namedExpressionExpression",(()=>{const e=this.CONSUME(be);return t=e.image,r=e.leadingWhitespace,{type:U.NAMED_EXPRESSION,expressionName:t,leadingWhitespace:null==r?void 0:r.image};var t,r})),this.offsetProcedureExpression=this.RULE("offsetProcedureExpression",(()=>{const e=[];return this.CONSUME(this.lexerConfig.OffsetProcedureName),this.CONSUME(fe),this.MANY_SEP({SEP:this.lexerConfig.ArgSeparator,DEF:()=>{e.push(this.SUBRULE(this.booleanExpression))}}),this.CONSUME(me),this.handleOffsetHeuristic(e)})),this.columnRangeExpression=this.RULE("columnRangeExpression",(()=>{const e=this.CONSUME(Re),[t,r]=e.image.split(":"),n=this.ACTION((()=>b(this.sheetMapping,t,this.formulaAddress))),s=this.ACTION((()=>b(this.sheetMapping,r,this.formulaAddress)));if(void 0===n||void 0===s)return j(new Tr(ir.REF));if(n.exceedsSheetSizeLimits(this.lexerConfig.maxColumns)||s.exceedsSheetSizeLimits(this.lexerConfig.maxColumns))return G(e.image,new Tr(ir.NAME),e.leadingWhitespace);if(void 0===n.sheet&&void 0!==s.sheet)return this.parsingError(F.ParserError,"Malformed range expression");const{firstEnd:i,secondEnd:o,sheetRefType:a}=Oe.fixSheetIdsForRangeEnds(n,s);return l=i,h=o,u=a,c=e.leadingWhitespace,$(l,h,u),{type:U.COLUMN_RANGE,start:l,end:h,sheetReferenceType:u,leadingWhitespace:null==c?void 0:c.image};var l,h,u,c})),this.rowRangeExpression=this.RULE("rowRangeExpression",(()=>{const e=this.CONSUME(Se),[t,r]=e.image.split(":"),n=this.ACTION((()=>A(this.sheetMapping,t,this.formulaAddress))),s=this.ACTION((()=>A(this.sheetMapping,r,this.formulaAddress)));if(void 0===n||void 0===s)return j(new Tr(ir.REF));if(n.exceedsSheetSizeLimits(this.lexerConfig.maxRows)||s.exceedsSheetSizeLimits(this.lexerConfig.maxRows))return G(e.image,new Tr(ir.NAME),e.leadingWhitespace);if(void 0===n.sheet&&void 0!==s.sheet)return this.parsingError(F.ParserError,"Malformed range expression");const{firstEnd:i,secondEnd:o,sheetRefType:a}=Oe.fixSheetIdsForRangeEnds(n,s);return l=i,h=o,u=a,c=e.leadingWhitespace,$(l,h,u),{type:U.ROW_RANGE,start:l,end:h,sheetReferenceType:u,leadingWhitespace:null==c?void 0:c.image};var l,h,u,c})),this.cellReference=this.RULE("cellReference",(()=>{const e=this.CONSUME(Me),t=this.ACTION((()=>_(this.sheetMapping,e.image,this.formulaAddress)));return void 0===t?G(e.image,new Tr(ir.REF),e.leadingWhitespace):t.exceedsSheetSizeLimits(this.lexerConfig.maxColumns,this.lexerConfig.maxRows)?G(e.image,new Tr(ir.NAME),e.leadingWhitespace):B(t,e.leadingWhitespace)})),this.endRangeReference=this.RULE("endRangeReference",(e=>{var t;const r=this.CONSUME(Me),n=this.ACTION((()=>_(this.sheetMapping,e.image,this.formulaAddress))),s=this.ACTION((()=>_(this.sheetMapping,r.image,this.formulaAddress)));return void 0===n||void 0===s?this.ACTION((()=>G(`${e.image}:${r.image}`,new Tr(ir.REF),e.leadingWhitespace))):n.exceedsSheetSizeLimits(this.lexerConfig.maxColumns,this.lexerConfig.maxRows)||s.exceedsSheetSizeLimits(this.lexerConfig.maxColumns,this.lexerConfig.maxRows)?this.ACTION((()=>G(`${e.image}:${r.image}`,new Tr(ir.NAME),e.leadingWhitespace))):this.buildCellRange(n,s,null===(t=e.leadingWhitespace)||void 0===t?void 0:t.image)})),this.endOfRangeExpression=this.RULE("endOfRangeExpression",(e=>this.OR([{ALT:()=>this.SUBRULE(this.endRangeReference,{ARGS:[e]})},{ALT:()=>{var t;const r=this.SUBRULE(this.offsetProcedureExpression),n=this.ACTION((()=>_(this.sheetMapping,e.image,this.formulaAddress)));return void 0===n?j(new Tr(ir.REF)):r.type===U.CELL_REFERENCE?this.buildCellRange(n,r.reference,null===(t=e.leadingWhitespace)||void 0===t?void 0:t.image):this.parsingError(F.RangeOffsetNotAllowed,"Range offset not allowed here")}}]))),this.cellRangeExpression=this.RULE("cellRangeExpression",(()=>{const e=this.CONSUME(Me);return this.CONSUME2(ve),this.SUBRULE(this.endOfRangeExpression,{ARGS:[e]})})),this.endRangeWithOffsetStartReference=this.RULE("endRangeWithOffsetStartReference",(e=>{const t=this.CONSUME(Me),r=this.ACTION((()=>_(this.sheetMapping,t.image,this.formulaAddress)));return void 0===r?this.ACTION((()=>j(new Tr(ir.REF)))):this.buildCellRange(e.reference,r,e.leadingWhitespace)})),this.endOfRangeWithOffsetStartExpression=this.RULE("endOfRangeWithOffsetStartExpression",(e=>this.OR([{ALT:()=>this.SUBRULE(this.endRangeWithOffsetStartReference,{ARGS:[e]})},{ALT:()=>{const t=this.SUBRULE(this.offsetProcedureExpression);return t.type===U.CELL_REFERENCE?this.buildCellRange(e.reference,t.reference,e.leadingWhitespace):this.parsingError(F.RangeOffsetNotAllowed,"Range offset not allowed here")}}]))),this.offsetExpression=this.RULE("offsetExpression",(()=>{const e=this.SUBRULE(this.offsetProcedureExpression);let t;return this.OPTION((()=>{this.CONSUME(ve),t=e.type===U.CELL_RANGE?this.parsingError(F.RangeOffsetNotAllowed,"Range offset not allowed here"):this.SUBRULE(this.endOfRangeWithOffsetStartExpression,{ARGS:[e]})})),void 0!==t?t:e})),this.insideArrayExpression=this.RULE("insideArrayExpression",(()=>{const e=[[]];return e[e.length-1].push(this.SUBRULE(this.booleanExpression)),this.MANY((()=>{this.OR([{ALT:()=>{this.CONSUME(this.lexerConfig.ArrayColSeparator),e[e.length-1].push(this.SUBRULE2(this.booleanExpression))}},{ALT:()=>{this.CONSUME(this.lexerConfig.ArrayRowSeparator),e.push([]),e[e.length-1].push(this.SUBRULE3(this.booleanExpression))}}])})),Y(e)})),this.parenthesisExpression=this.RULE("parenthesisExpression",(()=>{const e=this.CONSUME(fe),t=this.SUBRULE(this.booleanExpression),r=this.CONSUME(me);return((e,t,r)=>({type:U.PARENTHESIS,expression:e,leadingWhitespace:null==t?void 0:t.image,internalWhitespace:null==r?void 0:r.image}))(t,e.leadingWhitespace,r.leadingWhitespace)})),this.arrayExpression=this.RULE("arrayExpression",(()=>this.OR([{ALT:()=>{const e=this.CONSUME(ye),t=this.SUBRULE(this.insideArrayExpression),r=this.CONSUME(Ee);return Y(t.args,e.leadingWhitespace,r.leadingWhitespace)}},{ALT:()=>this.SUBRULE(this.parenthesisExpression)}]))),this.numericStringToNumber=e=>{const t=e.replace(this.lexerConfig.decimalSeparator,".");return Number(t)},this.positiveAtomicExpression=this.RULE("positiveAtomicExpression",(()=>{var e;return this.OR(null!==(e=this.atomicExpCache)&&void 0!==e?e:this.atomicExpCache=[{ALT:()=>this.SUBRULE(this.arrayExpression)},{ALT:()=>this.SUBRULE(this.cellRangeExpression)},{ALT:()=>this.SUBRULE(this.columnRangeExpression)},{ALT:()=>this.SUBRULE(this.rowRangeExpression)},{ALT:()=>this.SUBRULE(this.offsetExpression)},{ALT:()=>this.SUBRULE(this.cellReference)},{ALT:()=>this.SUBRULE(this.procedureExpression)},{ALT:()=>this.SUBRULE(this.namedExpressionExpression)},{ALT:()=>{const e=this.CONSUME(this.lexerConfig.NumberLiteral);return t=this.numericStringToNumber(e.image),r=e.leadingWhitespace,{type:U.NUMBER,value:t,leadingWhitespace:null==r?void 0:r.image};var t,r}},{ALT:()=>(e=>{var t;return{type:U.STRING,value:e.image.slice(1,-1),leadingWhitespace:null===(t=e.leadingWhitespace)||void 0===t?void 0:t.image}})(this.CONSUME(we))},{ALT:()=>{const e=this.CONSUME(Ce),t=e.image.toUpperCase(),r=this.lexerConfig.errorMapping[t];return r?j(new Tr(r),e.leadingWhitespace):this.parsingError(F.ParserError,"Unknown error literal")}}])})),this.rightUnaryOpAtomicExpression=this.RULE("rightUnaryOpAtomicExpression",(()=>{const e=this.SUBRULE(this.positiveAtomicExpression),t=this.OPTION((()=>this.CONSUME(oe)));return t?(r=e,n=t.leadingWhitespace,{type:U.PERCENT_OP,value:r,leadingWhitespace:null==n?void 0:n.image}):e;var r,n})),this.atomicExpression=this.RULE("atomicExpression",(()=>this.OR([{ALT:()=>{const e=this.CONSUME(J),t=this.SUBRULE(this.atomicExpression);return(0,k.tokenMatcher)(e,ee)?((e,t)=>({type:U.PLUS_UNARY_OP,value:e,leadingWhitespace:null==t?void 0:t.image}))(t,e.leadingWhitespace):(0,k.tokenMatcher)(e,te)?((e,t)=>({type:U.MINUS_UNARY_OP,value:e,leadingWhitespace:null==t?void 0:t.image}))(t,e.leadingWhitespace):(this.customParsingError=H(F.ParserError,"Mismatched token type"),this.customParsingError)}},{ALT:()=>this.SUBRULE2(this.rightUnaryOpAtomicExpression)}]))),this.powerExpression=this.RULE("powerExpression",(()=>{let e=this.SUBRULE(this.atomicExpression);return this.MANY((()=>{const t=this.CONSUME(ie),r=this.SUBRULE2(this.atomicExpression);var n,s,i;(0,k.tokenMatcher)(t,ie)?(n=e,s=r,i=t.leadingWhitespace,e={type:U.POWER_OP,left:n,right:s,leadingWhitespace:null==i?void 0:i.image}):this.ACTION((()=>{throw Error("Operator not supported")}))})),e})),this.multiplicationExpression=this.RULE("multiplicationExpression",(()=>{let e=this.SUBRULE(this.powerExpression);return this.MANY((()=>{const t=this.CONSUME(re),r=this.SUBRULE2(this.powerExpression);var n,s,i;(0,k.tokenMatcher)(t,ne)?(n=e,s=r,i=t.leadingWhitespace,e={type:U.TIMES_OP,left:n,right:s,leadingWhitespace:null==i?void 0:i.image}):(0,k.tokenMatcher)(t,se)?e=((e,t,r)=>({type:U.DIV_OP,left:e,right:t,leadingWhitespace:null==r?void 0:r.image}))(e,r,t.leadingWhitespace):this.ACTION((()=>{throw Error("Operator not supported")}))})),e})),this.additionExpression=this.RULE("additionExpression",(()=>{let e=this.SUBRULE(this.multiplicationExpression);return this.MANY((()=>{const t=this.CONSUME(J),r=this.SUBRULE2(this.multiplicationExpression);var n,s,i;(0,k.tokenMatcher)(t,ee)?(n=e,s=r,i=t.leadingWhitespace,e={type:U.PLUS_OP,left:n,right:s,leadingWhitespace:null==i?void 0:i.image}):(0,k.tokenMatcher)(t,te)?e=((e,t,r)=>({type:U.MINUS_OP,left:e,right:t,leadingWhitespace:null==r?void 0:r.image}))(e,r,t.leadingWhitespace):this.ACTION((()=>{throw Error("Operator not supported")}))})),e})),this.concatenateExpression=this.RULE("concatenateExpression",(()=>{let e=this.SUBRULE(this.additionExpression);return this.MANY((()=>{const t=this.CONSUME(ge),r=this.SUBRULE2(this.additionExpression);var n,s,i;n=e,s=r,i=t.leadingWhitespace,e={type:U.CONCATENATE_OP,left:n,right:s,leadingWhitespace:null==i?void 0:i.image}})),e})),this.booleanExpression=this.RULE("booleanExpression",(()=>{let e=this.SUBRULE(this.concatenateExpression);return this.MANY((()=>{const t=this.CONSUME(ae),r=this.SUBRULE2(this.concatenateExpression);var n,s,i;(0,k.tokenMatcher)(t,le)?(n=e,s=r,i=t.leadingWhitespace,e={type:U.EQUALS_OP,left:n,right:s,leadingWhitespace:null==i?void 0:i.image}):(0,k.tokenMatcher)(t,he)?e=((e,t,r)=>({type:U.NOT_EQUAL_OP,left:e,right:t,leadingWhitespace:null==r?void 0:r.image}))(e,r,t.leadingWhitespace):(0,k.tokenMatcher)(t,ue)?e=((e,t,r)=>({type:U.GREATER_THAN_OP,left:e,right:t,leadingWhitespace:null==r?void 0:r.image}))(e,r,t.leadingWhitespace):(0,k.tokenMatcher)(t,ce)?e=((e,t,r)=>({type:U.LESS_THAN_OP,left:e,right:t,leadingWhitespace:null==r?void 0:r.image}))(e,r,t.leadingWhitespace):(0,k.tokenMatcher)(t,de)?e=((e,t,r)=>({type:U.GREATER_THAN_OR_EQUAL_OP,left:e,right:t,leadingWhitespace:null==r?void 0:r.image}))(e,r,t.leadingWhitespace):(0,k.tokenMatcher)(t,pe)?e=((e,t,r)=>({type:U.LESS_THAN_OR_EQUAL_OP,left:e,right:t,leadingWhitespace:null==r?void 0:r.image}))(e,r,t.leadingWhitespace):this.ACTION((()=>{throw Error("Operator not supported")}))})),e})),this.formula=this.RULE("formula",(()=>(this.CONSUME(le),this.SUBRULE(this.booleanExpression)))),this.lexerConfig=e,this.sheetMapping=t,this.formulaAddress=Ar(0,0,0),this.performSelfAnalysis()}parseFromTokens(e,t){this.input=e;let r=this.formulaWithContext(t),n=[];return this.customParsingError&&n.push(this.customParsingError),n=n.concat(this.errors.map((e=>({type:F.ParserError,message:e.message})))),n.length>0&&(r=z()),{ast:r,errors:n}}reset(){super.reset(),this.customParsingError=void 0}formulaWithContext(e){return this.formulaAddress=e,this.formula()}buildCellRange(e,t,r){if(void 0===e.sheet&&void 0!==t.sheet)return this.parsingError(F.ParserError,"Malformed range expression");const{firstEnd:n,secondEnd:s,sheetRefType:i}=Oe.fixSheetIdsForRangeEnds(e,t);return W(n,s,i,r)}static fixSheetIdsForRangeEnds(e,t){const r=Oe.rangeSheetReferenceType(e.sheet,t.sheet);return{firstEnd:e,secondEnd:void 0!==e.sheet&&void 0===t.sheet?t.withSheet(e.sheet):t,sheetRefType:r}}handleOffsetHeuristic(e){const t=e[0];if(t.type!==U.CELL_REFERENCE)return this.parsingError(F.StaticOffsetError,"First argument to OFFSET is not a reference");const r=e[1];let n;if(r.type===U.NUMBER&&Number.isInteger(r.value))n=r.value;else if(r.type===U.PLUS_UNARY_OP&&r.value.type===U.NUMBER&&Number.isInteger(r.value.value))n=r.value.value;else{if(r.type!==U.MINUS_UNARY_OP||r.value.type!==U.NUMBER||!Number.isInteger(r.value.value))return this.parsingError(F.StaticOffsetError,"Second argument to OFFSET is not a static number");n=-r.value.value}const i=e[2];let o;if(i.type===U.NUMBER&&Number.isInteger(i.value))o=i.value;else if(i.type===U.PLUS_UNARY_OP&&i.value.type===U.NUMBER&&Number.isInteger(i.value.value))o=i.value.value;else{if(i.type!==U.MINUS_UNARY_OP||i.value.type!==U.NUMBER||!Number.isInteger(i.value.value))return this.parsingError(F.StaticOffsetError,"Third argument to OFFSET is not a static number");o=-i.value.value}const a=e[3];let h;if(void 0===a)h=1;else{if(a.type!==U.NUMBER)return this.parsingError(F.StaticOffsetError,"Fourth argument to OFFSET is not a static number");if(h=a.value,h<1)return this.parsingError(F.StaticOffsetError,"Fourth argument to OFFSET is too small number");if(!Number.isInteger(h))return this.parsingError(F.StaticOffsetError,"Fourth argument to OFFSET is not integer")}const u=e[4];let c;if(void 0===u)c=1;else{if(u.type!==U.NUMBER)return this.parsingError(F.StaticOffsetError,"Fifth argument to OFFSET is not a static number");if(c=u.value,c<1)return this.parsingError(F.StaticOffsetError,"Fifth argument to OFFSET is too small number");if(!Number.isInteger(c))return this.parsingError(F.StaticOffsetError,"Fifth argument to OFFSET is not integer")}const d=new l(t.reference.col+o,t.reference.row+n,t.reference.type);let p=d.col,g=d.row;if(t.reference.type!==s.CELL_REFERENCE_RELATIVE&&t.reference.type!==s.CELL_REFERENCE_ABSOLUTE_COL||(g+=this.formulaAddress.row),t.reference.type!==s.CELL_REFERENCE_RELATIVE&&t.reference.type!==s.CELL_REFERENCE_ABSOLUTE_ROW||(p+=this.formulaAddress.col),p<0||g<0)return j(new Tr(ir.REF,Z.OutOfSheet));if(1===c&&1===h)return B(d);{const e=new l(d.col+c-1,d.row+h-1,d.type);return W(d,e,V.RELATIVE)}}parsingError(e,t){return this.customParsingError=H(e,t),z()}static rangeSheetReferenceType(e,t){return void 0===e?V.RELATIVE:void 0===t?V.START_ABSOLUTE:V.BOTH_ABSOLUTE}}class Ie{constructor(e){this.lexerConfig=e,this.lexer=new k.Lexer(e.allTokens,{ensureOptimizations:!0})}tokenizeFormula(e){const t=this.lexer.tokenize(e);let r=t.tokens;return r=this.trimTrailingWhitespaces(r),r=this.skipWhitespacesInsideRanges(r),r=this.skipWhitespacesBeforeArgSeparators(r),t.tokens=r,t}skipWhitespacesInsideRanges(e){return Ie.filterTokensByNeighbors(e,((e,t,r)=>((0,k.tokenMatcher)(e,Me)||(0,k.tokenMatcher)(e,ve))&&(0,k.tokenMatcher)(t,this.lexerConfig.WhiteSpace)&&((0,k.tokenMatcher)(r,Me)||(0,k.tokenMatcher)(r,ve))))}skipWhitespacesBeforeArgSeparators(e){return Ie.filterTokensByNeighbors(e,((e,t,r)=>!(0,k.tokenMatcher)(e,this.lexerConfig.ArgSeparator)&&(0,k.tokenMatcher)(t,this.lexerConfig.WhiteSpace)&&(0,k.tokenMatcher)(r,this.lexerConfig.ArgSeparator)))}static filterTokensByNeighbors(e,t){if(e.length<3)return e;let r=0;const n=[e[r++]];for(;r0&&(0,k.tokenMatcher)(e[e.length-1],this.lexerConfig.WhiteSpace)&&e.pop(),e}} +/** + * @license + * Copyright (c) 2024 Handsoncode. All rights reserved. + */ +class xe{constructor(e,t,r,n){this.config=e,this.lexerConfig=t,this.sheetMappingFn=r,this.namedExpressions=n}unparse(e,t){return"="+this.unparseAst(e,t)}unparseAst(e,t){var r,n;switch(e.type){case U.EMPTY:return K("",e.leadingWhitespace);case U.NUMBER:return K(Pe(e.value,this.config.decimalSeparator),e.leadingWhitespace);case U.STRING:return K('"'+e.value+'"',e.leadingWhitespace);case U.FUNCTION_CALL:{const r=e.args.map((e=>void 0!==e?this.unparseAst(e,t):"")).join(this.config.functionArgSeparator),n=(this.config.translationPackage.isFunctionTranslated(e.procedureName)?this.config.translationPackage.getFunctionTranslation(e.procedureName):e.procedureName)+"("+r+K(")",e.internalWhitespace);return K(n,e.leadingWhitespace)}case U.NAMED_EXPRESSION:return K((null===(r=this.namedExpressions.nearestNamedExpression(e.expressionName,t.sheet))||void 0===r?void 0:r.displayName)||e.expressionName,e.leadingWhitespace);case U.CELL_REFERENCE:{let r;return r=void 0!==e.reference.sheet?this.unparseSheetName(e.reference.sheet)+"!":"",r+=null!==(n=e.reference.unparse(t))&&void 0!==n?n:this.config.translationPackage.getErrorTranslation(ir.REF),K(r,e.leadingWhitespace)}case U.COLUMN_RANGE:case U.ROW_RANGE:case U.CELL_RANGE:return K(this.formatRange(e,t),e.leadingWhitespace);case U.PLUS_UNARY_OP:{const r=this.unparseAst(e.value,t);return K("+",e.leadingWhitespace)+r}case U.MINUS_UNARY_OP:{const r=this.unparseAst(e.value,t);return K("-",e.leadingWhitespace)+r}case U.PERCENT_OP:return this.unparseAst(e.value,t)+K("%",e.leadingWhitespace);case U.ERROR:return K(this.config.translationPackage.getErrorTranslation(e.error?e.error.type:ir.ERROR),e.leadingWhitespace);case U.ERROR_WITH_RAW_INPUT:return K(e.rawInput,e.leadingWhitespace);case U.PARENTHESIS:{const r="("+this.unparseAst(e.expression,t)+K(")",e.internalWhitespace);return K(r,e.leadingWhitespace)}case U.ARRAY:{const r="{"+e.args.map((e=>e.map((e=>this.unparseAst(e,t))).join(this.config.arrayColumnSeparator))).join(this.config.arrayRowSeparator)+K("}",e.internalWhitespace);return K(r,e.leadingWhitespace)}default:{const r=this.unparseAst(e.left,t),n=this.unparseAst(e.right,t);return r+K(X[e.type],e.leadingWhitespace)+n}}}unparseSheetName(e){const t=L(e,this.sheetMappingFn);if(void 0===t)throw new lt(e);return t}formatRange(e,t){let r="",n="";void 0!==e.start.sheet&&e.sheetReferenceType!==V.RELATIVE&&(r=this.unparseSheetName(e.start.sheet)+"!"),void 0!==e.end.sheet&&e.sheetReferenceType===V.BOTH_ABSOLUTE&&(n=this.unparseSheetName(e.end.sheet)+"!");const s=e.start.unparse(t),i=e.end.unparse(t);return void 0===s||void 0===i?this.config.translationPackage.getErrorTranslation(ir.REF):`${r}${s}:${n}${i}`}}function Pe(e,t){return e.toString().replace(".",t)} +/** + * @license + * Copyright (c) 2024 Handsoncode. All rights reserved. + */ +class Le{constructor(e,t,r){this.config=e,this.functionRegistry=t,this.sheetMapping=r,this.statsCacheUsed=0,this.lexerConfig=Ae(e),this.lexer=new Ie(this.lexerConfig),this.formulaParser=new Oe(this.lexerConfig,this.sheetMapping),this.cache=new q(this.functionRegistry)}parse(e,t){this.formulaAddress=t;const r=this.tokenizeFormula(e);if(r.errors.length>0){const e=r.errors.map((e=>({type:F.LexingError,message:e.message})));return{ast:z(),errors:e,hasVolatileFunction:!1,hasStructuralChangeFunction:!1,dependencies:[]}}const n=this.computeHashFromTokens(r.tokens,t);let s=this.cache.get(n);if(void 0!==s)++this.statsCacheUsed;else{const e=this.bindWhitespacesToTokens(r.tokens),i=this.formulaParser.parseFromTokens(e,t);if(i.errors.length>0)return Object.assign(Object.assign({},i),{hasVolatileFunction:!1,hasStructuralChangeFunction:!1,dependencies:[]});s=this.cache.set(n,i.ast)}const{ast:i,hasVolatileFunction:o,hasStructuralChangeFunction:a}=s,l=this.convertReversedRangesToRegularRanges(i);return{ast:l,errors:[],hasVolatileFunction:o,hasStructuralChangeFunction:a,dependencies:ke(l,this.functionRegistry)}}convertReversedRangesToRegularRanges(e){switch(e.type){case U.EMPTY:case U.NUMBER:case U.STRING:case U.ERROR:case U.ERROR_WITH_RAW_INPUT:case U.CELL_REFERENCE:case U.NAMED_EXPRESSION:return e;case U.CELL_RANGE:{const{start:t,end:r}=e,n=this.orderCellRangeEnds(t,r);return Object.assign(Object.assign({},e),{start:n.start,end:n.end})}case U.COLUMN_RANGE:{const{start:t,end:r}=e,n=this.orderColumnRangeEnds(t,r);return Object.assign(Object.assign({},e),{start:n.start,end:n.end})}case U.ROW_RANGE:{const{start:t,end:r}=e,n=this.orderRowRangeEnds(t,r);return Object.assign(Object.assign({},e),{start:n.start,end:n.end})}case U.PERCENT_OP:case U.PLUS_UNARY_OP:case U.MINUS_UNARY_OP:{const t=this.convertReversedRangesToRegularRanges(e.value);return Object.assign(Object.assign({},e),{value:t})}case U.CONCATENATE_OP:case U.EQUALS_OP:case U.NOT_EQUAL_OP:case U.LESS_THAN_OP:case U.GREATER_THAN_OP:case U.LESS_THAN_OR_EQUAL_OP:case U.GREATER_THAN_OR_EQUAL_OP:case U.MINUS_OP:case U.PLUS_OP:case U.TIMES_OP:case U.DIV_OP:case U.POWER_OP:{const t=this.convertReversedRangesToRegularRanges(e.left),r=this.convertReversedRangesToRegularRanges(e.right);return Object.assign(Object.assign({},e),{left:t,right:r})}case U.PARENTHESIS:{const t=this.convertReversedRangesToRegularRanges(e.expression);return Object.assign(Object.assign({},e),{expression:t})}case U.FUNCTION_CALL:{const t=e.args.map((e=>this.convertReversedRangesToRegularRanges(e)));return Object.assign(Object.assign({},e),{args:t})}case U.ARRAY:{const t=e.args.map((e=>e.map((e=>this.convertReversedRangesToRegularRanges(e)))));return Object.assign(Object.assign({},e),{args:t})}}}orderCellRangeEnds(e,t){const r=[e,t],[n,s]=r.map((e=>e.toColumnAddress())).sort(o.compareByAbsoluteAddress(this.formulaAddress)),[i,h]=r.map((e=>e.toRowAddress())).sort(a.compareByAbsoluteAddress(this.formulaAddress)),[u,c]=r.map((e=>e.sheet)).sort(Le.compareSheetIds.bind(this));return{start:l.fromColAndRow(n,i,u),end:l.fromColAndRow(s,h,c)}}orderColumnRangeEnds(e,t){const r=[e,t],[n,s]=r.sort(o.compareByAbsoluteAddress(this.formulaAddress)),[i,a]=r.map((e=>e.sheet)).sort(Le.compareSheetIds.bind(this));return{start:new o(n.type,n.col,i),end:new o(s.type,s.col,a)}}orderRowRangeEnds(e,t){const r=[e,t],[n,s]=r.sort(a.compareByAbsoluteAddress(this.formulaAddress)),[i,o]=r.map((e=>e.sheet)).sort(Le.compareSheetIds.bind(this));return{start:new a(n.type,n.row,i),end:new a(s.type,s.row,o)}}static compareSheetIds(e,t){return(e=null!=e?e:1/0)-(t=null!=t?t:1/0)}fetchCachedResultForAst(e){const t=this.computeHashFromAst(e);return this.fetchCachedResult(t)}fetchCachedResult(e){const t=this.cache.get(e);if(void 0===t)throw new Error("There is no AST with such key in the cache");{const{ast:e,hasVolatileFunction:r,hasStructuralChangeFunction:n,relativeDependencies:s}=t;return{ast:e,errors:[],hasVolatileFunction:r,hasStructuralChangeFunction:n,dependencies:s}}}computeHashFromTokens(e,t){var r;let n="",s=0;for(;sthis.computeHashOfAstNode(e))).join(this.config.functionArgSeparator),r=e.procedureName+"("+t+K(")",e.internalWhitespace);return K(r,e.leadingWhitespace)}case U.CELL_REFERENCE:return K(e.reference.hash(!0),e.leadingWhitespace);case U.COLUMN_RANGE:case U.ROW_RANGE:case U.CELL_RANGE:return K(e.start.hash(e.sheetReferenceType!==V.RELATIVE)+":"+e.end.hash(e.sheetReferenceType===V.BOTH_ABSOLUTE),e.leadingWhitespace);case U.MINUS_UNARY_OP:return K("-"+this.computeHashOfAstNode(e.value),e.leadingWhitespace);case U.PLUS_UNARY_OP:return K("+"+this.computeHashOfAstNode(e.value),e.leadingWhitespace);case U.PERCENT_OP:return this.computeHashOfAstNode(e.value)+K("%",e.leadingWhitespace);case U.ERROR:return K(this.config.translationPackage.getErrorTranslation(e.error?e.error.type:ir.ERROR),e.leadingWhitespace);case U.ERROR_WITH_RAW_INPUT:return K(e.rawInput,e.leadingWhitespace);case U.ARRAY:return K("{"+e.args.map((e=>e.map((e=>this.computeHashOfAstNode(e))).join(","))).join(";")+K("}",e.internalWhitespace),e.leadingWhitespace);case U.PARENTHESIS:{const t="("+this.computeHashOfAstNode(e.expression)+K(")",e.internalWhitespace);return K(t,e.leadingWhitespace)}default:return this.computeHashOfAstNode(e.left)+K(X[e.type],e.leadingWhitespace)+this.computeHashOfAstNode(e.right)}}bindWhitespacesToTokens(e){const t=[],r=e[0];(0,k.tokenMatcher)(r,this.lexerConfig.WhiteSpace)||t.push(r);for(let r=1;r{switch(e.type){case U.EMPTY:case U.NUMBER:case U.STRING:case U.ERROR:return;case U.NAMED_EXPRESSION:return void(n&&r.push(new Be(e.expressionName)));case U.CELL_REFERENCE:return void(n&&r.push(new He(e.reference)));case U.CELL_RANGE:return void(n&&e.start.sheet===e.end.sheet&&r.push(new Fe(e.start,e.end)));case U.COLUMN_RANGE:return void(n&&e.start.sheet===e.end.sheet&&r.push(new Ue(e.start,e.end)));case U.ROW_RANGE:return void(n&&e.start.sheet===e.end.sheet&&r.push(new Ve(e.start,e.end)));case U.PERCENT_OP:case U.PLUS_UNARY_OP:case U.MINUS_UNARY_OP:return void De(e.value,t,r,!0);case U.CONCATENATE_OP:case U.EQUALS_OP:case U.NOT_EQUAL_OP:case U.LESS_THAN_OP:case U.GREATER_THAN_OP:case U.LESS_THAN_OR_EQUAL_OP:case U.GREATER_THAN_OR_EQUAL_OP:case U.MINUS_OP:case U.PLUS_OP:case U.TIMES_OP:case U.DIV_OP:case U.POWER_OP:return De(e.left,t,r,!0),void De(e.right,t,r,!0);case U.PARENTHESIS:return void De(e.expression,t,r,n);case U.FUNCTION_CALL:{const n=!t.doesFunctionNeedArgumentToBeComputed(e.procedureName);return void e.args.forEach((e=>De(e,t,r,n)))}}},ke=(e,t)=>{const r=new Array;return De(e,t,r,!0),r}; +/** + * @license + * Copyright (c) 2024 Handsoncode. All rights reserved. + */ +class He{constructor(e){this.dependency=e}absolutize(e){return this.dependency.toSimpleCellAddress(e)}}class Fe{constructor(e,t){this.start=e,this.end=t}absolutize(e){return new Fr(this.start.toSimpleCellAddress(e),this.end.toSimpleCellAddress(e))}}class Ue{constructor(e,t){this.start=e,this.end=t}absolutize(e){const t=this.start.toSimpleColumnAddress(e),r=this.end.toSimpleColumnAddress(e);return new Ur(t.sheet,t.col,r.col)}}class Ve{constructor(e,t){this.start=e,this.end=t}absolutize(e){const t=this.start.toSimpleRowAddress(e),r=this.end.toSimpleRowAddress(e);return new Vr(t.sheet,t.row,r.row)}}class Be{constructor(e){this.name=e}absolutize(e){return this}} +/** + * @license + * Copyright (c) 2024 Handsoncode. All rights reserved. + */ +const We=(e,t)=>e.map((e=>e.absolutize(t))),Ye=Symbol("Empty value");function je(e){return e instanceof Ge?e.val:e}class Ge{constructor(e,t){this.val=e,this.format=t}fromNumber(e){return new this.constructor(e)}}function ze(e,t){if("number"==typeof e)return t;{const r=e.fromNumber(t);return r.format=e.format,r}}class $e extends Ge{getDetailedType(){return Je.NUMBER_DATE}}class Ke extends Ge{getDetailedType(){return Je.NUMBER_CURRENCY}}class Xe extends Ge{getDetailedType(){return Je.NUMBER_TIME}}class qe extends Ge{getDetailedType(){return Je.NUMBER_DATETIME}}class Qe extends Ge{getDetailedType(){return Je.NUMBER_PERCENT}}function Ze(e){return"number"==typeof e||e instanceof Ge}var Je,et;function tt(e){return e instanceof Ge?{type:e.getDetailedType(),format:e.format}:{type:Je.NUMBER_RAW}}!function(e){e.NUMBER_RAW="NUMBER_RAW",e.NUMBER_DATE="NUMBER_DATE",e.NUMBER_TIME="NUMBER_TIME",e.NUMBER_DATETIME="NUMBER_DATETIME",e.NUMBER_CURRENCY="NUMBER_CURRENCY",e.NUMBER_PERCENT="NUMBER_PERCENT"}(Je||(Je={})); +/** + * @license + * Copyright (c) 2024 Handsoncode. All rights reserved. + */ +class rt{constructor(e,t,r,n){this._data=e,this.range=t,this.dependencyGraph=r,this._hasOnlyNumbers=n,this.size=void 0===e?new cn(t.effectiveWidth(r),t.effectiveHeight(r)):new cn(e[0].length,e.length)}get data(){return this.ensureThatComputed(),this._data}static fromRange(e,t,r){return new rt(e,t,r,!0)}static onlyNumbers(e){return new rt(e,void 0,void 0,!0)}static onlyValues(e){return new rt(e,void 0,void 0,void 0)}static onlyRange(e,t){return new rt(void 0,e,t,void 0)}static fromScalar(e){return new rt([[e]],void 0,void 0,void 0)}isAdHoc(){return void 0===this.range}width(){return this.size.width}height(){return this.size.height}valuesFromTopLeftCorner(){this.ensureThatComputed();const e=[];for(let t=0;t{const t=this.dependencyGraph.getCellValue(e);return t instanceof rt?(this._hasOnlyNumbers=!1,new Tr(ir.VALUE,Z.ScalarExpected)):(Ze(t)||(this._hasOnlyNumbers=!1),t)})))}} +/** + * @license + * Copyright (c) 2024 Handsoncode. All rights reserved. + */ +class nt{constructor(){this.changes=new Map}static empty(){return new nt}addAll(e){for(const t of e.changes.values())this.add(t.address,t);return this}addChange(e,t,r){this.addInterpreterValue(e,t,r)}exportChanges(e){let t=[];return this.changes.forEach((r=>{const n=e.exportChange(r);Array.isArray(n)?t=t.concat(n):t.push(n)})),t}getChanges(){return Array.from(this.changes.values())}isEmpty(){return 0===this.changes.size}add(e,t){const r=t.value;if(r instanceof rt)for(const t of r.effectiveAddressesFromData(e))this.changes.delete(xr(t));this.changes.set(xr(e),t)}addInterpreterValue(e,t,r){this.add(t,{address:t,value:e,oldValue:r})}} +/** + * @license + * Copyright (c) 2024 Handsoncode. All rights reserved. + */ +class st{constructor(e,t,r){if(this.sheet=e,this.rowStart=t,this.rowEnd=r,t<0)throw Error("Starting row cant be less than 0");if(rr?null:new st(this.sheet,t,r)}firstRow(){return new st(this.sheet,this.rowStart,this.rowStart)}}class it{constructor(e,t,r){if(this.sheet=e,this.columnStart=t,this.columnEnd=r,t<0)throw Error("Starting column cant be less than 0");if(rr?null:new it(this.sheet,t,r)}firstColumn(){return new it(this.sheet,this.columnStart,this.columnStart)}}!function(e){e.BUILD_ENGINE_TOTAL="BUILD_ENGINE_TOTAL",e.PARSER="PARSER",e.GRAPH_BUILD="GRAPH_BUILD",e.COLLECT_DEPENDENCIES="COLLECT_DEPENDENCIES",e.PROCESS_DEPENDENCIES="PROCESS_DEPENDENCIES",e.TOP_SORT="TOP_SORT",e.BUILD_COLUMN_INDEX="BUILD_COLUMN_INDEX",e.EVALUATION="EVALUATION",e.VLOOKUP="VLOOKUP",e.TRANSFORM_ASTS="TRANSFORM_ASTS",e.TRANSFORM_ASTS_POSTPONED="TRANSFORM_ASTS_POSTPONED",e.ADJUSTING_ADDRESS_MAPPING="ADJUSTING_ADDRESS_MAPPING",e.ADJUSTING_ARRAY_MAPPING="ADJUSTING_ARRAY_MAPPING",e.ADJUSTING_RANGES="ADJUSTING_RANGES",e.ADJUSTING_GRAPH="ADJUSTING_GRAPH",e.CRITERION_FUNCTION_FULL_CACHE_USED="CRITERION_FUNCTION_FULL_CACHE_USED",e.CRITERION_FUNCTION_PARTIAL_CACHE_USED="CRITERION_FUNCTION_PARTIAL_CACHE_USED"}(et||(et={})); +/** + * @license + * Copyright (c) 2024 Handsoncode. All rights reserved. + */ +class ot{constructor(){this.stats=new Map([[et.CRITERION_FUNCTION_FULL_CACHE_USED,0],[et.CRITERION_FUNCTION_PARTIAL_CACHE_USED,0]]),this.startTimes=new Map}incrementCriterionFunctionFullCacheUsed(){var e;const t=(null!==(e=this.stats.get(et.CRITERION_FUNCTION_FULL_CACHE_USED))&&void 0!==e?e:0)+1;this.stats.set(et.CRITERION_FUNCTION_FULL_CACHE_USED,t)}incrementCriterionFunctionPartialCacheUsed(){var e;const t=(null!==(e=this.stats.get(et.CRITERION_FUNCTION_PARTIAL_CACHE_USED))&&void 0!==e?e:0)+1;this.stats.set(et.CRITERION_FUNCTION_PARTIAL_CACHE_USED,t)}reset(){this.stats.clear(),this.startTimes.clear(),this.stats.set(et.CRITERION_FUNCTION_FULL_CACHE_USED,0),this.stats.set(et.CRITERION_FUNCTION_PARTIAL_CACHE_USED,0)}start(e){if(this.startTimes.get(e))throw Error(`Statistics ${e} already started`);this.startTimes.set(e,Date.now())}end(e){var t;const r=Date.now(),n=this.startTimes.get(e);if(!n)throw Error(`Statistics ${e} not started`);{let s=null!==(t=this.stats.get(e))&&void 0!==t?t:0;s+=r-n,this.stats.set(e,s),this.startTimes.delete(e)}}measure(e,t){this.start(e);const r=t();return this.end(e),r}snapshot(){return new Map(this.stats)}} +/** + * @license + * Copyright (c) 2024 Handsoncode. All rights reserved. + */ +class at extends ot{incrementCriterionFunctionFullCacheUsed(){}incrementCriterionFunctionPartialCacheUsed(){}start(e){}end(e){}} +/** + * @license + * Copyright (c) 2024 Handsoncode. All rights reserved. + */ +class lt extends Error{constructor(e){super(`There's no sheet with id = ${e}`)}}class ht extends Error{constructor(e){super(`There's no sheet with name '${e}'`)}}class ut extends Error{constructor(e){super(`Sheet with name ${e} already exists`)}}class ct extends Error{constructor(){super("Sheet size limit exceeded")}}class dt extends Error{constructor(){super("This is not a formula")}}class pt extends Error{constructor(e){super(`Address (row = ${e.row}, col = ${e.col}) is invalid`)}}class gt extends Error{constructor(e){super(`Invalid arguments, expected ${e}`)}}class ft extends Error{constructor(e,t){super(`Sheets ${e} and ${t} are not equal.`)}}class mt extends Error{constructor(e){super(`Name of Named Expression '${e}' is already present`)}}class yt extends Error{constructor(e){super(`Name of Named Expression '${e}' is invalid`)}}class Et extends Error{constructor(e){super(`Named Expression '${e}' does not exist`)}}class wt extends Error{constructor(){super("There is no operation to undo")}}class Ct extends Error{constructor(){super("There is no operation to redo")}}class vt extends Error{constructor(){super("There is nothing to paste")}}function Rt(e,t){switch(typeof t){case"function":case"symbol":return t.toString();case"bigint":return"BigInt("+t.toString()+")";default:return t instanceof RegExp?"RegExp("+t.toString()+")":t}}class St extends Error{constructor(e){super(`Unable to parse value: ${JSON.stringify(e,Rt,4)}`)}}class Tt extends Error{constructor(e,t){super(`Expected value of type: ${e} for config parameter: ${t}`)}}class Nt extends Error{constructor(e){super(`Config parameter ${e} cannot be empty.`)}}class Mt extends Error{constructor(e,t){super(`Config parameter ${e} should be at least ${t}`)}}class _t extends Error{constructor(e,t){super(`Config parameter ${e} should be at most ${t}`)}}class bt extends Error{constructor(e,t){super(`Expected one of ${e} for config parameter: ${t}`)}}class At extends Error{constructor(){super("Computations are suspended")}}class Ot extends Error{constructor(e){super(`Translation for ${e} is missing in the translation package you're using.`)}}class It extends Error{constructor(e){super(`Cannot register translation for function with id: ${e}`)}}class xt extends Error{constructor(){super("Language not registered.")}}class Pt extends Error{constructor(){super("Language already registered.")}}class Lt extends Error{static functionNotDeclaredInPlugin(e,t){return new Lt(`Function with id ${e} not declared in plugin ${t}`)}static functionMethodNotFound(e,t){return new Lt(`Function method ${e} not found in plugin ${t}`)}}class Dt extends Error{static cannotRegisterFunctionWithId(e){return new Dt(`Cannot register function with id ${e}`)}static cannotUnregisterFunctionWithId(e){return new Dt(`Cannot unregister function with id ${e}`)}static cannotUnregisterProtectedPlugin(){return new Dt("Cannot unregister protected plugin")}}class kt extends Error{constructor(){super("Cannot perform this operation, source location has an array inside.")}}class Ht extends Error{constructor(){super("Cannot perform this operation, target location has an array inside.")}}class Ft extends Error{constructor(){super("Relative addresses not allowed in named expressions.")}}class Ut extends Error{constructor(e,t){super(`Alias id ${e} in plugin ${t} already defined as a function or alias.`)}} +/** + * @license + * Copyright (c) 2024 Handsoncode. All rights reserved. + */ +class Vt{constructor(e){this.policy=e,this.mapping=new Map}getCell(e){const t=this.mapping.get(e.sheet);if(void 0===t)throw new lt(e.sheet);return t.getCell(e)}fetchCell(e){const t=this.mapping.get(e.sheet);if(void 0===t)throw new lt(e.sheet);const r=t.getCell(e);if(!r)throw Error("Vertex for address missing in AddressMapping");return r}strategyFor(e){const t=this.mapping.get(e);if(void 0===t)throw new lt(e);return t}addSheet(e,t){if(this.mapping.has(e))throw Error("Sheet already added");this.mapping.set(e,t)}autoAddSheet(e,t){const{height:r,width:n,fill:s}=t,i=this.policy.call(s);this.addSheet(e,new i(n,r))}getCellValue(e){const t=this.getCell(e);return void 0===t?Ye:t instanceof zt?t.getArrayCellValue(e):t.getCellValue()}getRawValue(e){const t=this.getCell(e);return t instanceof dr?t.getValues().rawValue:t instanceof zt?t.getArrayCellRawValue(e):null}setCell(e,t){const r=this.mapping.get(e.sheet);if(!r)throw Error("Sheet not initialized");r.setCell(e,t)}moveCell(e,t){const r=this.mapping.get(e.sheet);if(!r)throw Error("Sheet not initialized.");if(e.sheet!==t.sheet)throw Error("Cannot move cells between sheets.");if(r.has(t))throw new Error("Cannot move cell. Destination already occupied.");const n=r.getCell(e);if(void 0===n)throw new Error("Cannot move cell. No cell with such address.");this.setCell(t,n),this.removeCell(e)}removeCell(e){const t=this.mapping.get(e.sheet);if(!t)throw Error("Sheet not initialized");t.removeCell(e)}has(e){const t=this.mapping.get(e.sheet);return void 0!==t&&t.has(e)}getHeight(e){const t=this.mapping.get(e);if(void 0===t)throw new lt(e);return t.getHeight()}getWidth(e){const t=this.mapping.get(e);if(!t)throw new lt(e);return t.getWidth()}addRows(e,t,r){const n=this.mapping.get(e);if(void 0===n)throw new lt(e);n.addRows(t,r)}removeRows(e){const t=this.mapping.get(e.sheet);if(void 0===t)throw new lt(e.sheet);t.removeRows(e)}removeSheet(e){this.mapping.delete(e)}addColumns(e,t,r){const n=this.mapping.get(e);if(void 0===n)throw new lt(e);n.addColumns(t,r)}removeColumns(e){const t=this.mapping.get(e.sheet);if(void 0===t)throw new lt(e.sheet);t.removeColumns(e)}*verticesFromRowsSpan(e){yield*this.mapping.get(e.sheet).verticesFromRowsSpan(e)}*verticesFromColumnsSpan(e){yield*this.mapping.get(e.sheet).verticesFromColumnsSpan(e)}*entriesFromRowsSpan(e){yield*this.mapping.get(e.sheet).entriesFromRowsSpan(e)}*entriesFromColumnsSpan(e){yield*this.mapping.get(e.sheet).entriesFromColumnsSpan(e)}*entries(){for(const[e,t]of this.mapping.entries())yield*t.getEntries(e)}*sheetEntries(e){const t=this.mapping.get(e);if(void 0===t)throw new lt(e);yield*t.getEntries(e)}} +/** + * @license + * Copyright (c) 2024 Handsoncode. All rights reserved. + */ +class Bt{constructor(){this.arrayMapping=new Map}getArray(e){const t=this.getArrayByCorner(e.start);if(null==t?void 0:t.getRange().sameAs(e))return t}getArrayByCorner(e){return this.arrayMapping.get(xr(e))}setArray(e,t){this.arrayMapping.set(xr(e.start),t)}removeArray(e){"string"==typeof e?this.arrayMapping.delete(e):this.arrayMapping.delete(xr(e.start))}count(){return this.arrayMapping.size}*arraysInRows(e){for(const[t,r]of this.arrayMapping.entries())r.spansThroughSheetRows(e.sheet,e.rowStart,e.rowEnd)&&(yield[t,r])}*arraysInCols(e){for(const[t,r]of this.arrayMapping.entries())r.spansThroughSheetColumn(e.sheet,e.columnStart,e.columnEnd)&&(yield[t,r])}isFormulaArrayInRow(e,t){for(const r of this.arrayMapping.values())if(r.spansThroughSheetRows(e,t))return!0;return!1}isFormulaArrayInAllRows(e){let t=!0;for(const r of e.rows())this.isFormulaArrayInRow(e.sheet,r)||(t=!1);return t}isFormulaArrayInColumn(e,t){for(const r of this.arrayMapping.values())if(r.spansThroughSheetColumn(e,t))return!0;return!1}isFormulaArrayInAllColumns(e){let t=!0;for(const r of e.columns())this.isFormulaArrayInColumn(e.sheet,r)||(t=!1);return t}isFormulaArrayInRange(e){for(const t of this.arrayMapping.values())if(t.getRange().doesOverlap(e))return!0;return!1}isFormulaArrayAtAddress(e){for(const t of this.arrayMapping.values())if(t.getRange().addressInRange(e))return!0;return!1}moveArrayVerticesAfterRowByRows(e,t,r){this.updateArrayVerticesInSheet(e,((e,n)=>{const s=n.getRange();return t<=s.start.row?[s.shifted(0,r),n]:void 0}))}moveArrayVerticesAfterColumnByColumns(e,t,r){this.updateArrayVerticesInSheet(e,((e,n)=>{const s=n.getRange();return t<=s.start.col?[s.shifted(r,0),n]:void 0}))}updateArrayVerticesInSheet(e,t){const r=Array();for(const[n,s]of this.arrayMapping.entries()){if(s.sheet!==e)continue;const i=t(n,s);void 0!==i&&(this.removeArray(n),r.push(i))}r.forEach((([e,t])=>{this.setArray(e,t)}))}} +/** + * @license + * Copyright (c) 2024 Handsoncode. All rights reserved. + */ +class Wt{constructor(e){this.size=e}width(){return this.size.width}height(){return this.size.height}get(e,t){throw Error("Array not computed yet.")}simpleRangeValue(){throw Error("Array not computed yet.")}}class Yt{constructor(e){if(this.size=new cn(e.length>0?e[0].length:0,e.length),this.array=e,this.size.width<=0||this.size.height<=0)throw Error("Incorrect array size")}static fromInterpreterValue(e){return new Yt(e instanceof rt?e.data:[[e]])}simpleRangeValue(){return rt.onlyValues(this.array)}addRows(e,t){this.array.splice(e,0,...this.nullArrays(t,this.width())),this.size.height+=t}addColumns(e,t){for(let r=0;re.height)throw Error("Resizing to smaller array");if(this.width()e.width)throw Error("Resizing to smaller array")}outOfBound(e,t){return e<0||t<0||t>this.size.height-1||e>this.size.width-1}}class jt{constructor(e,t){this.error=e,this.size=t}get(e,t){return this.error}width(){return this.size.width}height(){return this.size.height}simpleRangeValue(){return this.error}} +/** + * @license + * Copyright (c) 2024 Handsoncode. All rights reserved. + */ +class Gt{constructor(e,t,r){this.formula=e,this.cellAddress=t,this.version=r}get width(){return 1}get height(){return 1}static fromAst(e,t,r,n){return r.isScalar()?new $t(e,t,n):new zt(e,t,r,n)}getFormula(e){return this.ensureRecentData(e),this.formula}ensureRecentData(e){if(this.version!=e.version()){const[t,r,n]=e.applyTransformations(this.formula,this.cellAddress,this.version);this.formula=t,this.cellAddress=r,this.version=n}}getAddress(e){return this.ensureRecentData(e),this.cellAddress}}class zt extends Gt{constructor(e,t,r,n=0){super(e,t,n),r.isRef?this.array=new jt(new Tr(ir.REF,Z.NoSpaceForArrayResult),cn.error()):this.array=new Wt(r)}get width(){return this.array.width()}get height(){return this.array.height()}get sheet(){return this.cellAddress.sheet}get leftCorner(){return this.cellAddress}setCellValue(e){if(e instanceof Tr)return this.setErrorValue(e),e;const t=Yt.fromInterpreterValue(e);return t.resize(this.array.size),this.array=t,e}getCellValue(){if(this.array instanceof Wt)throw Error("Array not computed yet.");return this.array.simpleRangeValue()}valueOrUndef(){if(!(this.array instanceof Wt))return this.array.simpleRangeValue()}getArrayCellValue(e){const t=e.col-this.cellAddress.col,r=e.row-this.cellAddress.row;try{return this.array.get(t,r)}catch(e){return new Tr(ir.REF)}}getArrayCellRawValue(e){const t=this.getArrayCellValue(e);return t instanceof Tr||t===Ye?void 0:je(t)}setArrayCellValue(e,t){const r=e.col-this.cellAddress.col,n=e.row-this.cellAddress.row;this.array instanceof Yt&&this.array.set(r,n,t)}setNoSpace(){return this.array=new jt(new Tr(ir.SPILL,Z.NoSpaceForArrayResult),cn.error()),this.getCellValue()}getRange(){return Fr.spanFrom(this.cellAddress,this.width,this.height)}getRangeOrUndef(){return Fr.spanFromOrUndef(this.cellAddress,this.width,this.height)}setAddress(e){this.cellAddress=e}setFormula(e){this.formula=e}spansThroughSheetRows(e,t,r=t){return this.cellAddress.sheet===e&&this.cellAddress.row<=r&&te.criterionFunctionCache.clear())),this.dependentCacheRanges.clear()}getStart(){return this.start}getEnd(){return this.end}} +/** + * @license + * Copyright (c) 2024 Handsoncode. All rights reserved. + */ +const Xt=(e,t,r,n,s)=>{if(t instanceof Kt){const e=t.range.intersectionWith(r);return void 0!==e?Array.from(e.addresses(s)):[]}let i,o;return t instanceof Gt?(i=t.getFormula(n),o=t.getAddress(n),ke(i,e).filter((e=>e instanceof He)).map((e=>e.dependency.toSimpleCellAddress(o))).filter((e=>r.addressInRange(e)))):[]}; +/** + * @license + * Copyright (c) 2024 Handsoncode. All rights reserved. + */ +var qt;!function(e){e[e.ON_STACK=0]="ON_STACK",e[e.PROCESSED=1]="PROCESSED",e[e.POPPED=2]="POPPED"}(qt||(qt={}));class Qt{constructor(e=[],t=[]){this.nodesSparseArray=e,this.edgesSparseArray=t,this.entranceTime=[],this.low=[],this.parent=[],this.inSCC=[],this.nodeStatus=[],this.order=[],this.sccNonSingletons=[],this.timeCounter=0}getTopSortedWithSccSubgraphFrom(e,t,r){const n=e.reverse();return n.forEach((e=>this.runDFS(e))),this.postprocess(n,r,t)}getAdjacentNodeIds(e){return this.edgesSparseArray[e].filter((e=>void 0!==e&&this.nodesSparseArray[e]))}runDFS(e){if(void 0!==this.nodeStatus[e])return;this.nodeStatus[e]=qt.ON_STACK;const t=[e],r=[];for(;t.length>0;){const e=t[t.length-1];switch(this.nodeStatus[e]){case qt.ON_STACK:this.handleOnStack(e,r,t);break;case qt.PROCESSED:this.handleProcessed(e,r,t);break;case qt.POPPED:t.pop()}}}handleOnStack(e,t,r){this.entranceTime[e]=this.timeCounter,this.low[e]=this.timeCounter,this.timeCounter++,t.push(e),this.getAdjacentNodeIds(e).forEach((t=>{void 0===this.entranceTime[t]&&(r.push(t),this.parent[t]=e,this.nodeStatus[t]=qt.ON_STACK)})),this.nodeStatus[e]=qt.PROCESSED}handleProcessed(e,t,r){let n=this.entranceTime[e];if(this.getAdjacentNodeIds(e).forEach((t=>{this.inSCC[t]||(n=this.parent[t]===e?Math.min(n,this.low[t]):Math.min(n,this.entranceTime[t]))})),this.low[e]=n,n===this.entranceTime[e]){const r=[];do{r.push(t[t.length-1]),t.pop()}while(r[r.length-1]!==e);r.forEach((e=>{this.inSCC[e]=!0})),this.order.push(...r),r.length>1&&r.forEach((e=>{this.sccNonSingletons[e]=!0}))}r.pop(),this.nodeStatus[e]=qt.POPPED}postprocess(e,t,r){const n=[];e.forEach((e=>{n[e]=!0}));const s=[],i=[];return this.order.reverse(),this.order.forEach((e=>{const o=this.getAdjacentNodeIds(e);this.sccNonSingletons[e]||o.includes(e)?(i.push(this.nodesSparseArray[e]),t(this.nodesSparseArray[e]),o.forEach((e=>n[e]=!0))):(s.push(this.nodesSparseArray[e]),n[e]&&r(this.nodesSparseArray[e])&&o.forEach((e=>n[e]=!0)))})),{sorted:s,cycled:i}}} +/** + * @license + * Copyright (c) 2024 Handsoncode. All rights reserved. + */ +class Zt{constructor(e,t){this.rawValue=e,this.processFn=t,this.processedValue=null}getProcessedValue(){return null===this.processedValue&&(this.processedValue=this.processFn(this.rawValue)),this.processedValue}markAsModified(){this.processedValue=null}} +/** + * @license + * Copyright (c) 2024 Handsoncode. All rights reserved. + */ +class Jt{constructor(e){this.dependencyQuery=e,this.nodesSparseArray=[],this.edgesSparseArray=[],this.nodesIds=new Map,this.dirtyAndVolatileNodeIds=new Zt({dirty:[],volatile:[]},(e=>this.processDirtyAndVolatileNodeIds(e))),this.infiniteRangeIds=new Set,this.changingWithStructureNodeIds=[],this.nextId=0}getNodes(){return this.nodesSparseArray.filter((e=>void 0!==e))}hasNode(e){return this.nodesIds.has(e)}existsEdge(e,t){const r=this.getNodeId(e),n=this.getNodeId(t);return void 0!==r&&void 0!==n&&this.edgesSparseArray[r].includes(n)}adjacentNodes(e){const t=this.getNodeId(e);if(void 0===t)throw this.missingNodeError(e);return new Set(this.edgesSparseArray[t].filter((e=>void 0!==e)).map((e=>this.nodesSparseArray[e])))}adjacentNodesCount(e){const t=this.getNodeId(e);if(void 0===t)throw this.missingNodeError(e);return this.fixEdgesArrayForNode(t).length}addNodeAndReturnId(e){const t=this.nodesIds.get(e);if(void 0!==t)return t;const r=this.nextId;return this.nextId++,this.nodesSparseArray[r]=e,this.edgesSparseArray[r]=[],this.nodesIds.set(e,r),r}addEdge(e,t){const r=this.getNodeIdIfNotNumber(e),n=this.getNodeIdIfNotNumber(t);if(void 0===r)throw this.missingNodeError(e);if(void 0===n)throw this.missingNodeError(t);this.edgesSparseArray[r].includes(n)||this.edgesSparseArray[r].push(n)}removeNode(e){const t=this.getNodeId(e);if(void 0===t)throw this.missingNodeError(e);this.edgesSparseArray[t].length>0&&(this.edgesSparseArray[t].forEach((e=>this.dirtyAndVolatileNodeIds.rawValue.dirty.push(e))),this.dirtyAndVolatileNodeIds.markAsModified());const r=this.removeDependencies(e);return delete this.nodesSparseArray[t],delete this.edgesSparseArray[t],this.infiniteRangeIds.delete(t),this.nodesIds.delete(e),r}removeEdge(e,t){const r=this.getNodeIdIfNotNumber(e),n=this.getNodeIdIfNotNumber(t);if(void 0===r)throw this.missingNodeError(e);if(void 0===n)throw this.missingNodeError(t);const s=this.edgesSparseArray[r].indexOf(n);if(-1===s)throw new Error("Edge does not exist");delete this.edgesSparseArray[r][s]}removeEdgeIfExists(e,t){const r=this.getNodeId(e),n=this.getNodeId(t);if(void 0===r)return;if(void 0===n)return;const s=this.edgesSparseArray[r].indexOf(n);-1!==s&&delete this.edgesSparseArray[r][s]}topSortWithScc(){return this.getTopSortedWithSccSubgraphFrom(this.getNodes(),(()=>!0),(()=>{}))}getTopSortedWithSccSubgraphFrom(e,t,r){const n=new Qt(this.nodesSparseArray,this.edgesSparseArray),s=e.map((e=>this.getNodeId(e))).filter((e=>void 0!==e));return n.getTopSortedWithSccSubgraphFrom(s,t,r)}markNodeAsVolatile(e){const t=this.getNodeId(e);void 0!==t&&(this.dirtyAndVolatileNodeIds.rawValue.volatile.push(t),this.dirtyAndVolatileNodeIds.markAsModified())}markNodeAsDirty(e){const t=this.getNodeId(e);void 0!==t&&(this.dirtyAndVolatileNodeIds.rawValue.dirty.push(t),this.dirtyAndVolatileNodeIds.markAsModified())}getDirtyAndVolatileNodes(){return this.dirtyAndVolatileNodeIds.getProcessedValue()}clearDirtyNodes(){this.dirtyAndVolatileNodeIds.rawValue.dirty=[],this.dirtyAndVolatileNodeIds.markAsModified()}markNodeAsChangingWithStructure(e){const t=this.getNodeId(e);void 0!==t&&this.changingWithStructureNodeIds.push(t)}markChangingWithStructureNodesAsDirty(){this.changingWithStructureNodeIds.length<=0||(this.dirtyAndVolatileNodeIds.rawValue.dirty=[...this.dirtyAndVolatileNodeIds.rawValue.dirty,...this.changingWithStructureNodeIds],this.dirtyAndVolatileNodeIds.markAsModified())}markNodeAsInfiniteRange(e){const t=this.getNodeIdIfNotNumber(e);void 0!==t&&this.infiniteRangeIds.add(t)}getInfiniteRanges(){return[...this.infiniteRangeIds].map((e=>({node:this.nodesSparseArray[e],id:e})))}getNodeId(e){return this.nodesIds.get(e)}getNodeIdIfNotNumber(e){return"number"==typeof e?e:this.nodesIds.get(e)}fixEdgesArrayForNode(e){const t=this.edgesSparseArray[e];return this.edgesSparseArray[e]=t.filter((e=>void 0!==e&&this.nodesSparseArray[e])),this.edgesSparseArray[e]}removeDependencies(e){const t=this.dependencyQuery(e);return t.forEach((([t,r])=>{this.removeEdgeIfExists(r,e)})),t}processDirtyAndVolatileNodeIds({dirty:e,volatile:t}){return[...new Set([...e,...t])].map((e=>this.nodesSparseArray[e])).filter((e=>void 0!==e))}missingNodeError(e){return new Error(`Unknown node ${e}`)}} +/** + * @license + * Copyright (c) 2024 Handsoncode. All rights reserved. + */ +class er{constructor(){this.rangeMapping=new Map}getMappingSize(e){var t,r;return null!==(r=null===(t=this.rangeMapping.get(e))||void 0===t?void 0:t.size)&&void 0!==r?r:0}setRange(e){let t=this.rangeMapping.get(e.getStart().sheet);void 0===t&&(t=new Map,this.rangeMapping.set(e.getStart().sheet,t));const r=tr(e.getStart(),e.getEnd());t.set(r,e)}removeRange(e){const t=e.getStart().sheet,r=this.rangeMapping.get(t);if(void 0===r)return;const n=tr(e.getStart(),e.getEnd());r.delete(n),0===r.size&&this.rangeMapping.delete(t)}getRange(e,t){const r=this.rangeMapping.get(e.sheet),n=tr(e,t);return null==r?void 0:r.get(n)}fetchRange(e,t){const r=this.getRange(e,t);if(!r)throw Error("Range does not exist");return r}truncateRanges(e,t){const r=Array(),n=Array(),s=Array(),i=e.sheet;for(const[o,a]of this.entriesFromSheet(e.sheet)){const l=a.range;e.start<=t(a.range.end)&&(l.removeSpan(e),l.shouldBeRemoved()?(this.removeByKey(i,o),r.push(a)):n.push([o,a]),s.push(a))}const o=[];n.sort(((e,r)=>rr(e[1],r[1],t)));for(const[e,t]of n){const r=tr((a=t.range).start,a.end);if(r===e)continue;const n=this.getByKey(i,r);this.removeByKey(i,e),void 0!==n&&t!=n?o.push([n,t]):this.setRange(t)}var a;return{verticesToRemove:r,verticesToMerge:o,verticesWithChangedSize:s}}moveAllRangesInSheetAfterRowByRows(e,t,r){return this.updateVerticesFromSheet(e,((e,n)=>t<=n.start.row?(n.range.shiftByRows(r),{changedSize:!1,vertex:n}):t>n.start.row&&t<=n.end.row?(n.range.expandByRows(r),{changedSize:!0,vertex:n}):void 0))}moveAllRangesInSheetAfterColumnByColumns(e,t,r){return this.updateVerticesFromSheet(e,((e,n)=>t<=n.start.col?(n.range.shiftByColumns(r),{changedSize:!1,vertex:n}):t>n.start.col&&t<=n.end.col?(n.range.expandByColumns(r),{changedSize:!0,vertex:n}):void 0))}moveRangesInsideSourceRange(e,t,r,n){this.updateVerticesFromSheet(e.sheet,((s,i)=>e.containsRange(i.range)?(i.range.shiftByColumns(t),i.range.shiftByRows(r),i.range.moveToSheet(n),{changedSize:!1,vertex:i}):void 0))}removeRangesInSheet(e){if(this.rangeMapping.has(e)){const t=this.rangeMapping.get(e).values();return this.rangeMapping.delete(e),t}return[][Symbol.iterator]()}*rangesInSheet(e){const t=this.rangeMapping.get(e);t&&(yield*t.values())}*rangeVerticesContainedInRange(e){for(const t of this.rangesInSheet(e.sheet))e.containsRange(t.range)&&(yield t)}findSmallerRange(e){if(e.height()>1&&Number.isFinite(e.height())){const t=Ar(e.end.sheet,e.end.col,e.end.row-1),r=this.getRange(e.start,t);if(void 0!==r){return{smallerRangeVertex:r,restRange:Fr.fromSimpleCellAddresses(Ar(e.start.sheet,e.start.col,e.end.row),e.end)}}}return{restRange:e}}*entriesFromSheet(e){const t=this.rangeMapping.get(e);t&&(yield*t.entries())}removeByKey(e,t){this.rangeMapping.get(e).delete(t)}getByKey(e,t){var r;return null===(r=this.rangeMapping.get(e))||void 0===r?void 0:r.get(t)}updateVerticesFromSheet(e,t){const r=Array();for(const[n,s]of this.entriesFromSheet(e)){const i=t(n,s);void 0!==i&&(this.removeByKey(e,n),r.push(i))}return r.forEach((e=>{this.setRange(e.vertex)})),{verticesWithChangedSize:r.filter((e=>e.changedSize)).map((e=>e.vertex))}}}function tr(e,t){return`${e.col},${e.row},${t.col},${t.row}`}const rr=(e,t,r)=>{const n=r(e.range.start),s=r(e.range.start);if(n===s){return r(e.range.end)-r(t.range.end)}return n-s}; +/** + * @license + * Copyright (c) 2024 Handsoncode. All rights reserved. + */ +class nr{constructor(e,t,r){this.functions=e,this.errors=t,this.ui=r,this._protectedTranslations={VERSION:"VERSION"},this.checkUI(),this.checkErrors(),this.checkFunctionTranslations(this.functions),Object.assign(this.functions,this._protectedTranslations)}extendFunctions(e){this.checkFunctionTranslations(e),Object.assign(this.functions,e)}buildFunctionMapping(){return Object.keys(this.functions).reduce(((e,t)=>(e[this.functions[t]]=t,e)),{})}buildErrorMapping(){return Object.keys(this.errors).reduce(((e,t)=>(e[this.errors[t]]=t,e)),{})}isFunctionTranslated(e){return void 0!==this.functions[e]}getFunctionTranslations(e){const t=[];for(const r of e)this.isFunctionTranslated(r)&&t.push(this.functions[r]);return t}getFunctionTranslation(e){const t=this.functions[e];if(void 0===t)throw new Ot(`functions.${e}`);return t}getMaybeFunctionTranslation(e){return this.functions[e]}getErrorTranslation(e){if(e===ir.LIC)return`#${ir.LIC}!`;const t=this.errors[e];if(void 0===t)throw new Ot(`errors.${e}`);return t}getUITranslation(e){const t=this.ui[e];if(void 0===t)throw new Ot(`ui.${e}`);return t}checkUI(){for(const e of Object.values(sr))if(!(e in this.ui))throw new Ot(`ui.${e}`)}checkErrors(){for(const e of Object.values(ir))if(!(e in this.errors)&&e!==ir.LIC)throw new Ot(`errors.${e}`)}checkFunctionTranslations(e){const t=new Set(Object.getOwnPropertyNames(e));for(const e of Object.getOwnPropertyNames(this._protectedTranslations))if(t.has(e))throw new It(e)}} +/** + * @license + * Copyright (c) 2024 Handsoncode. All rights reserved. + */ +var sr,ir,or; +/** + * @license + * Copyright (c) 2024 Handsoncode. All rights reserved. + */ +function ar(e){return e.toLowerCase()}!function(e){e.NEW_SHEET_PREFIX="NEW_SHEET_PREFIX"}(sr||(sr={}));class lr{constructor(e,t){this.id=e,this.displayName=t}get canonicalName(){return ar(this.displayName)}}class hr{constructor(e){this.languages=e,this.mappingFromCanonicalName=new Map,this.mappingFromId=new Map,this.lastSheetId=-1,this.fetch=e=>{const t=this.mappingFromCanonicalName.get(ar(e));if(void 0===t)throw new ht(e);return t.id},this.get=e=>{var t;return null===(t=this.mappingFromCanonicalName.get(ar(e)))||void 0===t?void 0:t.id},this.fetchDisplayName=e=>this.fetchSheetById(e).displayName,this.sheetNamePrefix=e.getUITranslation(sr.NEW_SHEET_PREFIX)}addSheet(e=`${this.sheetNamePrefix}${this.lastSheetId+2}`){const t=ar(e);if(this.mappingFromCanonicalName.has(t))throw new ut(e);this.lastSheetId++;const r=new lr(this.lastSheetId,e);return this.store(r),r.id}removeSheet(e){const t=this.fetchSheetById(e);e==this.lastSheetId&&--this.lastSheetId,this.mappingFromCanonicalName.delete(t.canonicalName),this.mappingFromId.delete(t.id)}getDisplayName(e){var t;return null===(t=this.mappingFromId.get(e))||void 0===t?void 0:t.displayName}*displayNames(){for(const e of this.mappingFromCanonicalName.values())yield e.displayName}numberOfSheets(){return this.mappingFromCanonicalName.size}hasSheetWithId(e){return this.mappingFromId.has(e)}hasSheetWithName(e){return this.mappingFromCanonicalName.has(ar(e))}renameSheet(e,t){const r=this.fetchSheetById(e),n=r.displayName;if(n===t)return;const s=this.mappingFromCanonicalName.get(ar(t));if(void 0!==s&&s.id!==r.id)throw new ut(t);const i=r.canonicalName;return this.mappingFromCanonicalName.delete(i),r.displayName=t,this.store(r),n}sheetNames(){return Array.from(this.mappingFromId.values()).map((e=>e.displayName))}store(e){this.mappingFromId.set(e.id,e),this.mappingFromCanonicalName.set(e.canonicalName,e)}fetchSheetById(e){const t=this.mappingFromId.get(e);if(void 0===t)throw new lt(e);return t}} +/** + * @license + * Copyright (c) 2024 Handsoncode. All rights reserved. + */ +class ur{constructor(e,t,r,n,s,i,o,a){this.addressMapping=e,this.rangeMapping=t,this.sheetMapping=r,this.arrayMapping=n,this.stats=s,this.lazilyTransformingAstService=i,this.functionRegistry=o,this.namedExpressions=a,this.changes=nt.empty(),this.dependencyQueryAddresses=e=>{if(e instanceof Kt)return this.rangeDependencyQuery(e).map((([e,t])=>e));{const t=this.formulaDependencyQuery(e);if(void 0!==t){const[e,r]=t;return r.map((t=>t instanceof Be?this.namedExpressions.namedExpressionOrPlaceholder(t.name,e.sheet).address:Pr(t)?t:Hr(t.start,t.end)))}return[]}},this.dependencyQueryVertices=e=>{if(e instanceof Kt)return this.rangeDependencyQuery(e);{const t=this.formulaDependencyQuery(e);if(void 0!==t){const[e,r]=t;return r.map((t=>{if(t instanceof Fr)return[t.start,this.rangeMapping.fetchRange(t.start,t.end)];if(t instanceof Be){const r=this.namedExpressions.namedExpressionOrPlaceholder(t.name,e.sheet);return[r.address,this.addressMapping.fetchCell(r.address)]}return[t,this.addressMapping.fetchCell(t)]}))}return[]}},this.rangeDependencyQuery=e=>{const t=[],{smallerRangeVertex:r,restRange:n}=this.rangeMapping.findSmallerRange(e.range);let s;void 0!==r&&this.graph.adjacentNodes(r).has(e)?(s=n,t.push([new Fr(r.start,r.end),r])):s=e.range;for(const e of s.addresses(this)){const r=this.addressMapping.getCell(e);void 0!==r&&t.push([e,r])}return t},this.formulaDependencyQuery=e=>{let t,r;if(!(e instanceof Gt))return;r=e.getAddress(this.lazilyTransformingAstService),t=e.getFormula(this.lazilyTransformingAstService);const n=ke(t,this.functionRegistry);return[r,We(n,r)]},this.graph=new Jt(this.dependencyQueryVertices)}static buildEmpty(e,t,r,n,s){return new ur(new Vt(t.chooseAddressMappingPolicy),new er,new hr(t.translationPackage),new Bt,s,e,r,n)}setFormulaToCell(e,t,r,n,s,i){const o=Gt.fromAst(t,e,n,this.lazilyTransformingAstService.version());return this.exchangeOrAddFormulaVertex(o),this.processCellDependencies(r,o),this.graph.markNodeAsDirty(o),s&&this.markAsVolatile(o),i&&this.markAsDependentOnStructureChange(o),this.correctInfiniteRangesDependency(e),this.getAndClearContentChanges()}setParsingErrorToCell(e,t){const r=this.shrinkPossibleArrayAndGetCell(e);return this.exchangeOrAddGraphNode(r,t),this.addressMapping.setCell(e,t),this.graph.markNodeAsDirty(t),this.correctInfiniteRangesDependency(e),this.getAndClearContentChanges()}setValueToCell(e,t){const r=this.shrinkPossibleArrayAndGetCell(e);if(r instanceof zt&&this.arrayMapping.removeArray(r.getRange()),r instanceof dr){r.getValues().rawValue!==t.rawValue&&(r.setValues(t),this.graph.markNodeAsDirty(r))}else{const n=new dr(t.parsedValue,t.rawValue);this.exchangeOrAddGraphNode(r,n),this.addressMapping.setCell(e,n),this.graph.markNodeAsDirty(n)}return this.correctInfiniteRangesDependency(e),this.getAndClearContentChanges()}setCellEmpty(e){const t=this.shrinkPossibleArrayAndGetCell(e);if(void 0===t)return nt.empty();if(this.graph.adjacentNodes(t).size>0){const r=new cr;this.exchangeGraphNode(t,r),0===this.graph.adjacentNodesCount(r)?(this.removeVertex(r),this.addressMapping.removeCell(e)):(this.graph.markNodeAsDirty(r),this.addressMapping.setCell(e,r))}else this.removeVertex(t),this.addressMapping.removeCell(e);return this.getAndClearContentChanges()}clearDirtyVertices(){this.graph.clearDirtyNodes()}verticesToRecompute(){return this.graph.getDirtyAndVolatileNodes()}processCellDependencies(e,t){const r=this.graph.getNodeId(t);e.forEach((e=>{if(e instanceof Fr){const t=e;let n=this.getRange(t.start,t.end);void 0===n&&(n=new Kt(t),this.rangeMapping.setRange(n)),this.graph.addNodeAndReturnId(n);const s=this.graph.getNodeId(n);t.isFinite()||this.graph.markNodeAsInfiniteRange(s);const{smallerRangeVertex:i,restRange:o}=this.rangeMapping.findSmallerRange(t);if(void 0!==i){if(this.graph.addEdge(i,s),n.bruteForce){n.bruteForce=!1;for(const e of t.addresses(this))this.graph.removeEdge(this.fetchCell(e),s)}}else n.bruteForce=!0;const a=this.arrayMapping.getArray(o);if(void 0!==a)this.graph.addEdge(a,s);else for(const e of o.addresses(this)){const{vertex:t,id:r}=this.fetchCellOrCreateEmpty(e);this.graph.addEdge(null!=r?r:t,s)}this.graph.addEdge(s,r),t.isFinite()&&this.correctInfiniteRangesDependenciesByRangeVertex(n)}else if(e instanceof Be){const n=t.getAddress(this.lazilyTransformingAstService).sheet,{vertex:s,id:i}=this.fetchNamedExpressionVertex(e.name,n);this.graph.addEdge(null!=i?i:s,r)}else{const{vertex:t,id:n}=this.fetchCellOrCreateEmpty(e);this.graph.addEdge(null!=n?n:t,r)}}))}fetchNamedExpressionVertex(e,t){const r=this.namedExpressions.namedExpressionOrPlaceholder(e,t);return this.fetchCellOrCreateEmpty(r.address)}exchangeNode(e,t){const r=this.fetchCellOrCreateEmpty(e).vertex,n=this.fetchCellOrCreateEmpty(t).vertex;this.addressMapping.removeCell(e),this.exchangeGraphNode(r,n)}fetchCellOrCreateEmpty(e){const t=this.addressMapping.getCell(e);if(void 0!==t)return{vertex:t,id:void 0};const r=new cr,n=this.graph.addNodeAndReturnId(r);return this.addressMapping.setCell(e,r),{vertex:r,id:n}}removeRows(e){this.stats.measure(et.ADJUSTING_GRAPH,(()=>{for(const[t,r]of this.addressMapping.entriesFromRowsSpan(e)){for(const e of this.graph.adjacentNodes(r))this.graph.markNodeAsDirty(e);if(r instanceof zt){if(!r.isLeftCorner(t))continue;this.shrinkArrayToCorner(r),this.arrayMapping.removeArray(r.getRange())}this.removeVertex(r)}})),this.stats.measure(et.ADJUSTING_ADDRESS_MAPPING,(()=>{this.addressMapping.removeRows(e)}));const t=this.stats.measure(et.ADJUSTING_RANGES,(()=>{const t=this.truncateRanges(e,(e=>e.row));return this.getArrayVerticesRelatedToRanges(t)}));return this.stats.measure(et.ADJUSTING_ARRAY_MAPPING,(()=>{this.fixArraysAfterRemovingRows(e.sheet,e.rowStart,e.numberOfRows)})),this.addStructuralNodesToChangeSet(),{affectedArrays:t,contentChanges:this.getAndClearContentChanges()}}removeSheet(e){this.clearSheet(e);for(const[t,r]of this.addressMapping.sheetEntries(e)){for(const e of this.graph.adjacentNodes(r))this.graph.markNodeAsDirty(e);this.removeVertex(r),this.addressMapping.removeCell(t)}this.stats.measure(et.ADJUSTING_RANGES,(()=>{const t=this.rangeMapping.removeRangesInSheet(e);for(const e of t)this.removeVertex(e);this.stats.measure(et.ADJUSTING_ADDRESS_MAPPING,(()=>{this.addressMapping.removeSheet(e)}))}))}clearSheet(e){const t=new Set;for(const[r,n]of this.addressMapping.sheetEntries(e))n instanceof zt?t.add(n):this.setCellEmpty(r);for(const e of t.values())this.setArrayEmpty(e);this.addStructuralNodesToChangeSet()}removeColumns(e){this.stats.measure(et.ADJUSTING_GRAPH,(()=>{for(const[t,r]of this.addressMapping.entriesFromColumnsSpan(e)){for(const e of this.graph.adjacentNodes(r))this.graph.markNodeAsDirty(e);if(r instanceof zt){if(!r.isLeftCorner(t))continue;this.shrinkArrayToCorner(r),this.arrayMapping.removeArray(r.getRange())}this.removeVertex(r)}})),this.stats.measure(et.ADJUSTING_ADDRESS_MAPPING,(()=>{this.addressMapping.removeColumns(e)}));const t=this.stats.measure(et.ADJUSTING_RANGES,(()=>{const t=this.truncateRanges(e,(e=>e.col));return this.getArrayVerticesRelatedToRanges(t)}));return this.stats.measure(et.ADJUSTING_ARRAY_MAPPING,(()=>this.fixArraysAfterRemovingColumns(e.sheet,e.columnStart,e.numberOfColumns))),this.addStructuralNodesToChangeSet(),{affectedArrays:t,contentChanges:this.getAndClearContentChanges()}}addRows(e){this.stats.measure(et.ADJUSTING_ADDRESS_MAPPING,(()=>{this.addressMapping.addRows(e.sheet,e.rowStart,e.numberOfRows)}));const t=this.stats.measure(et.ADJUSTING_RANGES,(()=>{const t=this.rangeMapping.moveAllRangesInSheetAfterRowByRows(e.sheet,e.rowStart,e.numberOfRows);return this.fixRangesWhenAddingRows(e.sheet,e.rowStart,e.numberOfRows),this.getArrayVerticesRelatedToRanges(t.verticesWithChangedSize)}));this.stats.measure(et.ADJUSTING_ARRAY_MAPPING,(()=>{this.fixArraysAfterAddingRow(e.sheet,e.rowStart,e.numberOfRows)}));for(const t of this.addressMapping.verticesFromRowsSpan(e))this.graph.markNodeAsDirty(t);return this.addStructuralNodesToChangeSet(),{affectedArrays:t}}addColumns(e){this.stats.measure(et.ADJUSTING_ADDRESS_MAPPING,(()=>{this.addressMapping.addColumns(e.sheet,e.columnStart,e.numberOfColumns)}));const t=this.stats.measure(et.ADJUSTING_RANGES,(()=>{const t=this.rangeMapping.moveAllRangesInSheetAfterColumnByColumns(e.sheet,e.columnStart,e.numberOfColumns);return this.fixRangesWhenAddingColumns(e.sheet,e.columnStart,e.numberOfColumns),this.getArrayVerticesRelatedToRanges(t.verticesWithChangedSize)}));this.stats.measure(et.ADJUSTING_ARRAY_MAPPING,(()=>this.fixArraysAfterAddingColumn(e.sheet,e.columnStart,e.numberOfColumns)));for(const t of this.addressMapping.verticesFromColumnsSpan(e))this.graph.markNodeAsDirty(t);return this.addStructuralNodesToChangeSet(),{affectedArrays:t,contentChanges:this.getAndClearContentChanges()}}isThereSpaceForArray(e){const t=e.getRangeOrUndef();if(void 0===t)return!1;for(const r of t.addresses(this)){const t=this.addressMapping.getCell(r);if(void 0!==t&&!(t instanceof cr)&&t!==e)return!1}return!0}moveCells(e,t,r,n){for(const s of e.addressesWithDirection(t,r,this)){const i=Ar(n,s.col+t,s.row+r);let o=this.addressMapping.getCell(s);const a=this.addressMapping.getCell(i);if(this.addressMapping.removeCell(s),void 0!==o){let t;this.graph.markNodeAsDirty(o),this.addressMapping.setCell(i,o);for(const r of this.graph.adjacentNodes(o))r instanceof Kt&&!e.containsRange(r.range)&&(t=null!=t?t:this.fetchCellOrCreateEmpty(s).vertex,this.graph.addEdge(t,r),this.graph.removeEdge(o,r));t&&(this.graph.markNodeAsDirty(t),this.addressMapping.setCell(s,t))}if(void 0!==a){void 0===o&&this.addressMapping.removeCell(i);for(const e of this.graph.adjacentNodes(a))o=null!=o?o:this.fetchCellOrCreateEmpty(i).vertex,this.graph.addEdge(o,e),this.graph.markNodeAsDirty(o);this.removeVertex(a)}}for(const t of this.rangeMapping.rangeVerticesContainedInRange(e))for(const r of this.graph.adjacentNodes(t))if(r instanceof Kt&&!e.containsRange(r.range)){this.graph.removeEdge(t,r);for(const e of t.range.addresses(this)){const{vertex:t,id:n}=this.fetchCellOrCreateEmpty(e);this.graph.addEdge(null!=n?n:t,r),this.addressMapping.setCell(e,t),this.graph.markNodeAsDirty(t)}}this.rangeMapping.moveRangesInsideSourceRange(e,t,r,n)}setArrayEmpty(e){const t=Fr.spanFrom(e.getAddress(this.lazilyTransformingAstService),e.width,e.height),r=this.graph.adjacentNodes(e);for(const e of t.addresses(this))this.addressMapping.removeCell(e);for(const t of r.values()){const r=Xt(this.functionRegistry,t,e.getRange(),this.lazilyTransformingAstService,this);for(const e of r){const{vertex:r,id:n}=this.fetchCellOrCreateEmpty(e);this.graph.addEdge(null!=n?n:r,t)}r.length>0&&this.graph.markNodeAsDirty(t)}this.removeVertex(e),this.arrayMapping.removeArray(e.getRange())}addVertex(e,t){this.graph.addNodeAndReturnId(t),this.addressMapping.setCell(e,t)}addArrayVertex(e,t){this.graph.addNodeAndReturnId(t),this.setAddressMappingForArrayVertex(t,e)}*arrayFormulaNodes(){for(const e of this.graph.getNodes())e instanceof zt&&(yield e)}*entriesFromRowsSpan(e){yield*this.addressMapping.entriesFromRowsSpan(e)}*entriesFromColumnsSpan(e){yield*this.addressMapping.entriesFromColumnsSpan(e)}fetchCell(e){return this.addressMapping.fetchCell(e)}getCell(e){return this.addressMapping.getCell(e)}getCellValue(e){return this.addressMapping.getCellValue(e)}getRawValue(e){return this.addressMapping.getRawValue(e)}getScalarValue(e){const t=this.addressMapping.getCellValue(e);return t instanceof rt?new Tr(ir.VALUE,Z.ScalarExpected):t}existsEdge(e,t){return this.graph.existsEdge(e,t)}getSheetId(e){return this.sheetMapping.fetch(e)}getSheetHeight(e){return this.addressMapping.getHeight(e)}getSheetWidth(e){return this.addressMapping.getWidth(e)}getArray(e){return this.arrayMapping.getArray(e)}getRange(e,t){return this.rangeMapping.getRange(e,t)}topSortWithScc(){return this.graph.topSortWithScc()}markAsVolatile(e){this.graph.markNodeAsVolatile(e)}markAsDependentOnStructureChange(e){this.graph.markNodeAsChangingWithStructure(e)}forceApplyPostponedTransformations(){for(const e of this.graph.getNodes())e instanceof $t&&e.ensureRecentData(this.lazilyTransformingAstService)}*rawValuesFromRange(e){for(const t of e.addresses(this)){const e=this.getScalarValue(t);e!==Ye&&(yield[je(e),t])}}computeListOfValuesInRange(e){const t=[];for(const r of e.addresses(this)){const e=this.getScalarValue(r);t.push(e)}return t}shrinkArrayToCorner(e){this.cleanAddressMappingUnderArray(e);for(const t of this.adjacentArrayVertices(e)){let r;r=t instanceof Gt?this.formulaDirectDependenciesToArray(t,e):this.rangeDirectDependenciesToArray(t,e);let n=!1;for(const[s,i]of r)e.isLeftCorner(s)&&(n=!0),this.graph.addEdge(i,t),this.graph.markNodeAsDirty(i);n||this.graph.removeEdge(e,t)}this.graph.markNodeAsDirty(e)}isArrayInternalCell(e){const t=this.getCell(e);return t instanceof zt&&!t.isLeftCorner(e)}getAndClearContentChanges(){const e=this.changes;return this.changes=nt.empty(),e}getAdjacentNodesAddresses(e){const t=this.graph.adjacentNodes(e),r=[];return t.forEach((e=>{const t=e;t instanceof Kt?r.push(Hr(t.start,t.end)):r.push(t.getAddress(this.lazilyTransformingAstService))})),r}exchangeGraphNode(e,t){this.graph.addNodeAndReturnId(t);const r=this.graph.adjacentNodes(e);this.removeVertex(e),r.forEach((e=>{this.graph.hasNode(e)&&this.graph.addEdge(t,e)}))}setArray(e,t){this.arrayMapping.setArray(e,t)}correctInfiniteRangesDependency(e){const t=this.graph.getInfiniteRanges().filter((({node:t})=>t.range.addressInRange(e)));if(t.length<=0)return;const{vertex:r,id:n}=this.fetchCellOrCreateEmpty(e),s=null!=n?n:this.graph.getNodeId(r);t.forEach((({id:e})=>{this.graph.addEdge(s,e)}))}exchangeOrAddGraphNode(e,t){e?this.exchangeGraphNode(e,t):this.graph.addNodeAndReturnId(t)}getArrayVerticesRelatedToRanges(e){const t=new Set;return e.forEach((e=>{this.graph.hasNode(e)&&this.graph.adjacentNodes(e).forEach((e=>{e instanceof zt&&t.add(e)}))})),t}correctInfiniteRangesDependenciesByRangeVertex(e){this.graph.getInfiniteRanges().forEach((({id:t,node:r})=>{const n=e.range.intersectionWith(r.range);void 0!==n&&n.addresses(this).forEach((e=>{const{vertex:r,id:n}=this.fetchCellOrCreateEmpty(e);this.graph.addEdge(null!=n?n:r,t)}))}))}cleanAddressMappingUnderArray(e){const t=e.getRange();for(const r of t.addresses(this)){const t=e.getArrayCellValue(r);this.getCell(r)===e?e.isLeftCorner(r)?this.changes.addChange(new Tr(ir.REF),r,t):(this.addressMapping.removeCell(r),this.changes.addChange(Ye,r,t)):this.changes.addChange(Ye,r,t)}}*formulaDirectDependenciesToArray(e,t){var r;const[,n]=null!==(r=this.formulaDependencyQuery(e))&&void 0!==r?r:[];if(void 0!==n)for(const e of n)if(!(e instanceof Be||e instanceof Fr)&&t.getRange().addressInRange(e)){const t=this.fetchCellOrCreateEmpty(e).vertex;yield[e,t]}}*rangeDirectDependenciesToArray(e,t){const{restRange:r}=this.rangeMapping.findSmallerRange(e.range);for(const e of r.addresses(this))if(t.getRange().addressInRange(e)){const t=this.fetchCellOrCreateEmpty(e).vertex;yield[e,t]}}*adjacentArrayVertices(e){const t=this.graph.adjacentNodes(e);for(const e of t)(e instanceof Gt||e instanceof Kt)&&(yield e)}addStructuralNodesToChangeSet(){this.graph.markChangingWithStructureNodesAsDirty()}fixRangesWhenAddingRows(e,t,r){const n=Array.from(this.rangeMapping.rangesInSheet(e));for(const e of n)if(e.range.includesRow(t+r))if(e.bruteForce){const n=e.range.rangeWithSameWidth(t,r);for(const t of n.addresses(this)){const{vertex:r,id:n}=this.fetchCellOrCreateEmpty(t);this.graph.addEdge(null!=n?n:r,e)}}else{let t=e,r=this.rangeMapping.findSmallerRange(t.range);if(void 0!==r.smallerRangeVertex)continue;for(;void 0===r.smallerRangeVertex;){const e=new Kt(Fr.spanFrom(t.range.start,t.range.width(),t.range.height()-1));this.rangeMapping.setRange(e),this.graph.addNodeAndReturnId(e);const n=new Fr(Ar(t.range.start.sheet,t.range.start.col,t.range.end.row),t.range.end);this.addAllFromRange(n,t),this.graph.addEdge(e,t),t=e,r=this.rangeMapping.findSmallerRange(t.range)}this.graph.addEdge(r.smallerRangeVertex,t),this.addAllFromRange(r.restRange,t),this.graph.removeEdge(r.smallerRangeVertex,e)}}addAllFromRange(e,t){for(const r of e.addresses(this)){const{vertex:e,id:n}=this.fetchCellOrCreateEmpty(r);this.graph.addEdge(null!=n?n:e,t)}}fixRangesWhenAddingColumns(e,t,r){for(const n of this.rangeMapping.rangesInSheet(e))if(n.range.includesColumn(t+r)){let s;s=n.bruteForce?n.range.rangeWithSameHeight(t,r):Fr.spanFrom(Ar(e,t,n.range.end.row),r,1);for(const e of s.addresses(this)){const{vertex:t,id:r}=this.fetchCellOrCreateEmpty(e);this.graph.addEdge(null!=r?r:t,n)}}}exchangeOrAddFormulaVertex(e){const t=e.getAddress(this.lazilyTransformingAstService),r=Fr.spanFrom(t,e.width,e.height),n=this.shrinkPossibleArrayAndGetCell(t);if(e instanceof zt&&this.setArray(r,e),this.exchangeOrAddGraphNode(n,e),this.addressMapping.setCell(t,e),e instanceof zt){if(!this.isThereSpaceForArray(e))return;for(const t of r.addresses(this)){if(e.isLeftCorner(t))continue;const r=this.getCell(t);this.exchangeOrAddGraphNode(r,e)}}for(const t of r.addresses(this))this.addressMapping.setCell(t,e)}setAddressMappingForArrayVertex(e,t){if(this.addressMapping.setCell(t,e),!(e instanceof zt))return;const r=Fr.spanFromOrUndef(t,e.width,e.height);if(void 0!==r&&(this.setArray(r,e),this.isThereSpaceForArray(e)))for(const t of r.addresses(this))this.addressMapping.setCell(t,e)}truncateRanges(e,t){const{verticesToRemove:r,verticesToMerge:n,verticesWithChangedSize:s}=this.rangeMapping.truncateRanges(e,t);for(const[e,t]of n)this.mergeRangeVertices(e,t);for(const e of r)this.removeVertexAndCleanupDependencies(e);return s}fixArraysAfterAddingRow(e,t,r){if(this.arrayMapping.moveArrayVerticesAfterRowByRows(e,t,r),!(t<=0))for(const[,n]of this.arrayMapping.arraysInRows(st.fromRowStartAndEnd(e,t-1,t-1))){const s=n.getRange();for(let i=s.start.col;i<=s.end.col;++i)for(let o=t;o<=s.end.row;++o){const t=Ar(e,i,o),s=Ar(e,i,o+r),a=n.getArrayCellValue(t);this.addressMapping.moveCell(s,t),this.changes.addChange(Ye,s,a)}}}fixArraysAfterRemovingRows(e,t,r){if(this.arrayMapping.moveArrayVerticesAfterRowByRows(e,t,-r),!(t<=0))for(const[,r]of this.arrayMapping.arraysInRows(st.fromRowStartAndEnd(e,t-1,t-1)))if(this.isThereSpaceForArray(r))for(const e of r.getRange().addresses(this))this.addressMapping.setCell(e,r);else this.setNoSpaceIfArray(r)}fixArraysAfterAddingColumn(e,t,r){if(this.arrayMapping.moveArrayVerticesAfterColumnByColumns(e,t,r),!(t<=0))for(const[,n]of this.arrayMapping.arraysInCols(it.fromColumnStartAndEnd(e,t-1,t-1))){const s=n.getRange();for(let i=s.start.row;i<=s.end.row;++i)for(let o=t;o<=s.end.col;++o){const t=Ar(e,o,i),s=Ar(e,o+r,i),a=n.getArrayCellValue(t);this.addressMapping.moveCell(s,t),this.changes.addChange(Ye,s,a)}}}fixArraysAfterRemovingColumns(e,t,r){if(this.arrayMapping.moveArrayVerticesAfterColumnByColumns(e,t,-r),!(t<=0))for(const[,r]of this.arrayMapping.arraysInCols(it.fromColumnStartAndEnd(e,t-1,t-1)))if(this.isThereSpaceForArray(r))for(const e of r.getRange().addresses(this))this.addressMapping.setCell(e,r);else this.setNoSpaceIfArray(r)}shrinkPossibleArrayAndGetCell(e){const t=this.getCell(e);return t instanceof zt?(this.setNoSpaceIfArray(t),this.getCell(e)):t}setNoSpaceIfArray(e){e instanceof zt&&(this.shrinkArrayToCorner(e),e.setNoSpace())}removeVertex(e){this.removeVertexAndCleanupDependencies(e),e instanceof Kt&&this.rangeMapping.removeRange(e)}mergeRangeVertices(e,t){const r=this.graph.adjacentNodes(t);this.removeVertexAndCleanupDependencies(t),this.graph.removeEdgeIfExists(e,t),r.forEach((t=>{this.graph.hasNode(t)&&this.graph.addEdge(e,t)}))}removeVertexAndCleanupDependencies(e){const t=new Set(this.graph.removeNode(e));for(;t.size>0;){const e=t.values().next().value;t.delete(e);const[r,n]=e;this.graph.hasNode(n)&&0===this.graph.adjacentNodesCount(n)&&((n instanceof Kt||n instanceof cr)&&this.graph.removeNode(n).forEach((e=>t.add(e))),n instanceof Kt?this.rangeMapping.removeRange(n):n instanceof cr&&this.addressMapping.removeCell(r))}}} +/** + * @license + * Copyright (c) 2024 Handsoncode. All rights reserved. + */ +class cr{constructor(){}getCellValue(){return Ye}} +/** + * @license + * Copyright (c) 2024 Handsoncode. All rights reserved. + */ +class dr{constructor(e,t){this.parsedValue=e,this.rawValue=t}getValues(){return{parsedValue:this.parsedValue,rawValue:this.rawValue}}setValues(e){this.parsedValue=e.parsedValue,this.rawValue=e.rawValue}getCellValue(){return this.parsedValue}setCellValue(e){throw Error("SetCellValue is deprecated for ValueCellVertex")}} +/** + * @license + * Copyright (c) 2024 Handsoncode. All rights reserved. + */ +class pr{constructor(e,t){this.errors=e,this.rawInput=t}getCellValue(){const e=this.errors.map((e=>e.message)).find((e=>e));return Tr.parsingError(e)}getFormula(){return this.rawInput}} +/** + * @license + * Copyright (c) 2024 Handsoncode. All rights reserved. + */ +class gr{constructor(e,t){this.width=e,this.height=t,this.mapping=new Map}getCell(e){var t;return null===(t=this.mapping.get(e.col))||void 0===t?void 0:t.get(e.row)}setCell(e,t){this.width=Math.max(this.width,e.col+1),this.height=Math.max(this.height,e.row+1);let r=this.mapping.get(e.col);r||(r=new Map,this.mapping.set(e.col,r)),r.set(e.row,t)}has(e){var t;return!!(null===(t=this.mapping.get(e.col))||void 0===t?void 0:t.get(e.row))}getHeight(){return this.height}getWidth(){return this.width}removeCell(e){var t;null===(t=this.mapping.get(e.col))||void 0===t||t.delete(e.row)}addRows(e,t){this.mapping.forEach((r=>{const n=new Map;r.forEach(((s,i)=>{i>=e&&(n.set(i+t,s),r.delete(i))})),n.forEach(((e,t)=>{r.set(t,e)}))})),this.height+=t}addColumns(e,t){const r=new Map;this.mapping.forEach(((n,s)=>{s>=e&&(r.set(s+t,n),this.mapping.delete(s))})),r.forEach(((e,t)=>{this.mapping.set(t,e)})),this.width+=t}removeRows(e){this.mapping.forEach((t=>{const r=new Map;t.forEach(((n,s)=>{s>=e.rowStart&&(t.delete(s),s>e.rowEnd&&r.set(s-e.numberOfRows,n))})),r.forEach(((e,r)=>{t.set(r,e)}))}));const t=Math.min(this.height-1,e.rowEnd),r=Math.max(0,t-e.rowStart+1);this.height=Math.max(0,this.height-r)}removeColumns(e){const t=new Map;this.mapping.forEach(((r,n)=>{n>=e.columnStart&&(this.mapping.delete(n),n>e.columnEnd&&t.set(n-e.numberOfColumns,r))})),t.forEach(((e,t)=>{this.mapping.set(t,e)}));const r=Math.min(this.width-1,e.columnEnd),n=Math.max(0,r-e.columnStart+1);this.width=Math.max(0,this.width-n)}*getEntries(e){for(const[t,r]of this.mapping)for(const[n,s]of r)yield[Ar(e,t,n),s]}*verticesFromColumn(e){const t=this.mapping.get(e);if(void 0!==t)for(const[e,r]of t)yield r}*verticesFromRow(e){for(const t of this.mapping.values()){const r=t.get(e);void 0!==r&&(yield r)}}*verticesFromColumnsSpan(e){for(const t of e.columns()){const e=this.mapping.get(t);if(void 0!==e)for(const[t,r]of e)yield r}}*verticesFromRowsSpan(e){for(const t of this.mapping.values())for(const r of e.rows()){const e=t.get(r);void 0!==e&&(yield e)}}*entriesFromRowsSpan(e){for(const[t,r]of this.mapping.entries())for(const n of e.rows()){const s=r.get(n);void 0!==s&&(yield[Ar(e.sheet,t,n),s])}}*entriesFromColumnsSpan(e){for(const t of e.columns()){const r=this.mapping.get(t);if(void 0!==r)for(const[n,s]of r.entries())yield[Ar(e.sheet,t,n),s]}}*vertices(){for(const[e,t]of this.mapping)for(const[e,r]of t)void 0!==r&&(yield r)}} +/** + * @license + * Copyright (c) 2024 Handsoncode. All rights reserved. + */ +class fr{constructor(e,t){this.width=e,this.height=t,this.mapping=new Array(t);for(let r=0;r{switch(e){case Er.EMPTY:return 0;case Er.NUMBER:return 1;case Er.STRING:return 2;case Er.BOOLEAN:return 3;case Er.ERROR:return 4}throw new Error("Cell value not computed")},vr=e=>{if(e===Ye)return Er.EMPTY;if(e instanceof Tr||e instanceof rt)return Er.ERROR;if("string"==typeof e)return Er.STRING;if(Ze(e))return Er.NUMBER;if("boolean"==typeof e)return Er.BOOLEAN;throw new Error("Cell value not computed")},Rr=e=>{return Ze(e)?(t=e)instanceof Ge?t.getDetailedType():Je.NUMBER_RAW:vr(e);var t},Sr=e=>{return Ze(e)&&(t=e)instanceof Ge?t.format:void 0;var t};class Tr{constructor(e,t,r){this.type=e,this.message=t,this.root=r}static parsingError(e){return new Tr(ir.ERROR,`${Z.ParseError}${e?" "+e:""}`)}attachRootVertex(e){return void 0===this.root?new Tr(this.type,this.message,e):this}}const Nr=(e,t)=>({sheet:e,row:t}),Mr=e=>e.row<0,_r=(e,t)=>({sheet:e,col:t}),br=e=>e.col<0,Ar=(e,t,r)=>({sheet:e,col:t,row:r}),Or=e=>e.col<0||e.row<0,Ir=(e,t,r,n)=>Ar(t,e.col+r,e.row+n),xr=e=>`${e.sheet},${e.row},${e.col}`;function Pr(e){var t,r,n;return e&&("object"==typeof e||"function"==typeof e)&&"number"==typeof(null===(t=e)||void 0===t?void 0:t.sheet)&&"number"==typeof(null===(r=e)||void 0===r?void 0:r.col)&&"number"==typeof(null===(n=e)||void 0===n?void 0:n.row)}const Lr=(e,t)=>{var r;return null!==(r=e.sheet)&&void 0!==r?r:t.sheet},Dr=(e,t)=>e.sheet===t.sheet&&e.col===t.col&&e.row===t.row;function kr(e){return!(!e||"object"!=typeof e&&"function"!=typeof e)&&("start"in e&&Pr(e.start)&&"end"in e&&Pr(e.end))}const Hr=(e,t)=>({start:e,end:t});class Fr{constructor(e,t){if(e.sheet!==t.sheet)throw new ft(e.sheet,t.sheet);this.start=Ar(e.sheet,e.col,e.row),this.end=Ar(t.sheet,t.col,t.row)}get sheet(){return this.start.sheet}static fromSimpleCellAddresses(e,t){if(e.sheet!==t.sheet)throw new ft(e.sheet,t.sheet);const r=t.col-e.col,n=t.row-e.row;return Number.isFinite(n)&&Number.isFinite(r)?new Fr(e,t):Number.isFinite(n)?new Vr(e.sheet,e.row,t.row):new Ur(e.sheet,e.col,t.col)}static fromAst(e,t){return e.type===U.CELL_RANGE?Fr.fromCellRange(e,t):e.type===U.COLUMN_RANGE?Ur.fromColumnRange(e,t):Vr.fromRowRangeAst(e,t)}static fromAstOrUndef(e,t){try{return Fr.fromAst(e,t)}catch(e){return}}static fromCellRange(e,t){return new Fr(e.start.toSimpleCellAddress(t),e.end.toSimpleCellAddress(t))}static spanFrom(e,t,r){const n=Fr.spanFromOrUndef(e,t,r);if(void 0===n)throw new Error("AbsoluteCellRange: Wrong range size");return n}static spanFromOrUndef(e,t,r){if(!Number.isFinite(t)&&Number.isFinite(r)){if(0!==e.col)return;return new Vr(e.sheet,e.row,e.row+r-1)}if(!Number.isFinite(r)&&Number.isFinite(t)){if(0!==e.row)return;return new Ur(e.sheet,e.col,e.col+t-1)}if(Number.isFinite(r)&&Number.isFinite(t))return new Fr(e,Ar(e.sheet,e.col+t-1,e.row+r-1))}static fromCoordinates(e,t,r,n,s){return new Fr(Ar(e,t,r),Ar(e,n,s))}isFinite(){return Number.isFinite(this.size())}doesOverlap(e){return this.start.sheet==e.start.sheet&&(!(this.end.rowe.end.row)&&!(this.end.cole.end.col))}addressInRange(e){return this.sheet===e.sheet&&(this.start.row<=e.row&&this.end.row>=e.row&&this.start.col<=e.col&&this.end.col>=e.col)}columnInRange(e){return this.sheet===e.sheet&&(this.start.col<=e.col&&this.end.col>=e.col)}rowInRange(e){return this.sheet===e.sheet&&(this.start.row<=e.row&&this.end.row>=e.row)}containsRange(e){return this.addressInRange(e.start)&&this.addressInRange(e.end)}intersectionWith(e){if(this.sheet!==e.start.sheet)return;const t=Math.max(this.start.row,e.start.row),r=Math.min(this.end.row,e.end.row),n=Math.max(this.start.col,e.start.col),s=Math.min(this.end.col,e.end.col);return t>r||n>s?void 0:new Fr(Ar(this.sheet,n,t),Ar(this.sheet,s,r))}includesRow(e){return this.start.row=e}includesColumn(e){return this.start.col=e}shiftByRows(e){this.start.row+=e,this.end.row+=e}expandByRows(e){this.end.row+=e}shiftByColumns(e){this.start.col+=e,this.end.col+=e}shifted(e,t){return Fr.spanFrom(Ar(this.sheet,this.start.col+e,this.start.row+t),this.width(),this.height())}expandByColumns(e){this.end.col+=e}moveToSheet(e){this.start.sheet=e,this.end.sheet=e}removeSpan(e){e instanceof st?this.removeRows(e.start,e.end):this.removeColumns(e.start,e.end)}shouldBeRemoved(){return this.width()<=0||this.height()<=0}rangeWithSameWidth(e,t){return Fr.spanFrom(Ar(this.sheet,this.start.col,e),this.width(),t)}rangeWithSameHeight(e,t){return Fr.spanFrom(Ar(this.sheet,e,this.start.row),t,this.height())}toString(){return`${this.start.sheet},${this.start.col},${this.start.row},${this.end.col},${this.end.row}`}width(){return this.end.col-this.start.col+1}height(){return this.end.row-this.start.row+1}size(){return this.height()*this.width()}arrayOfAddressesInRange(){const e=[];for(let t=0;t0)if(t>0){let e=this.effectiveEndRow(r);for(;e>=this.start.row;){let t=this.effectiveEndColumn(r);for(;t>=this.start.col;)yield Ar(this.start.sheet,t,e),t-=1;e-=1}}else{let e=this.start.row;for(;e<=this.effectiveEndRow(r);){let t=this.effectiveEndColumn(r);for(;t>=this.start.col;)yield Ar(this.start.sheet,t,e),t-=1;e+=1}}else if(t>0){let e=this.effectiveEndRow(r);for(;e>=this.start.row;){let t=this.start.col;for(;t<=this.effectiveEndColumn(r);)yield Ar(this.start.sheet,t,e),t+=1;e-=1}}else{let e=this.start.row;for(;e<=this.effectiveEndRow(r);){let t=this.start.col;for(;t<=this.effectiveEndColumn(r);)yield Ar(this.start.sheet,t,e),t+=1;e+=1}}}getAddress(e,t){if(e<0||t<0||t>this.height()-1||e>this.width()-1)throw Error("Index out of bound");return Ar(this.start.sheet,this.start.col+e,this.start.row+t)}exceedsSheetSizeLimits(e,t){return this.end.col>=e||this.end.row>=t}effectiveEndColumn(e){return this.end.col}effectiveEndRow(e){return this.end.row}effectiveWidth(e){return this.width()}effectiveHeight(e){return this.height()}removeRows(e,t){if(!(e>this.end.row)){if(tthis.end.col)){if(t=e}effectiveEndRow(e){return this.effectiveHeight(e)-1}effectiveHeight(e){return e.getSheetHeight(this.sheet)}removeRows(e,t){}}class Vr extends Fr{constructor(e,t,r){super(Ar(e,0,t),Ar(e,Number.POSITIVE_INFINITY,r))}static fromRowRangeAst(e,t){const r=e.start.toSimpleRowAddress(t),n=e.end.toSimpleRowAddress(t);if(r.sheet!==n.sheet)throw new ft(r.sheet,n.sheet);return new Vr(r.sheet,r.row,n.row)}shouldBeRemoved(){return this.height()<=0}shiftByColumns(e){}expandByColumns(e){}shifted(e,t){return new Vr(this.sheet,this.start.row+t,this.end.row+t)}rangeWithSameWidth(e,t){return new Vr(this.sheet,e,e+t-1)}exceedsSheetSizeLimits(e,t){return this.end.row>=t}effectiveEndColumn(e){return this.effectiveWidth(e)-1}effectiveWidth(e){return e.getSheetWidth(this.sheet)}removeColumns(e,t){}} +/** + * @license + * Copyright (c) 2024 Handsoncode. All rights reserved. + */ +class Br{constructor(e,t,r){this.formulaAddress=e,this.arraysFlag=t,this.formulaVertex=r}} +/** + * @license + * Copyright (c) 2024 Handsoncode. All rights reserved. + */ +const Wr=/^\s*([+-]?)\s*(([\d\.,]+(e[+-]?\d+)?)\s*([ij]?)|([ij]))\s*(([+-])\s*([+-]?)\s*(([\d\.,]+(e[+-]?\d+)?)\s*([ij]?)|([ij])))?$/;class Yr{constructor(e,t,r){this.config=e,this.dateTimeHelper=t,this.numberLiteralsHelper=r,this.lt=(e,t)=>this.compare(e,t)<0,this.leq=(e,t)=>this.compare(e,t)<=0,this.gt=(e,t)=>this.compare(e,t)>0,this.geq=(e,t)=>this.compare(e,t)>=0,this.eq=(e,t)=>0===this.compare(e,t),this.neq=(e,t)=>0!==this.compare(e,t),this.pow=(e,t)=>Math.pow(je(e),je(t)),this.addWithEpsilonRaw=(e,t)=>{const r=e+t;return Math.abs(r){const r=nn(e,t);return this.ExtendedNumberFactory(this.addWithEpsilonRaw(je(e),je(t)),r)},this.unaryMinus=e=>ze(e,-je(e)),this.unaryPlus=e=>e,this.unaryPercent=e=>new Qe(je(e)/100),this.concat=(e,t)=>e.concat(t),this.nonstrictadd=(e,t)=>e instanceof Tr?e:t instanceof Tr?t:"number"==typeof e?"number"==typeof t?this.addWithEpsilonRaw(e,t):e:"number"==typeof t?t:0,this.subtract=(e,t)=>{const r=nn(e,t),n=je(e);let s=n-je(t);return Math.abs(s){const r=je(e),n=je(t);if(0===n)return new Tr(ir.DIV_BY_ZERO);{const s=sn(e,t);return this.ExtendedNumberFactory(r/n,s)}},this.multiply=(e,t)=>{const r=sn(e,t);return this.ExtendedNumberFactory(je(e)*je(t),r)},this.manyToExactComplex=e=>{const t=[];for(const r of e){if(r instanceof Tr)return r;if(Ze(r)||"string"==typeof r){const e=this.coerceScalarToComplex(r);e instanceof Tr||t.push(e)}}return t},this.coerceNumbersExactRanges=e=>this.manyToNumbers(e,this.manyToExactNumbers),this.coerceNumbersCoerceRangesDropNulls=e=>this.manyToNumbers(e,this.manyToCoercedNumbersDropNulls),this.manyToExactNumbers=e=>{const t=[];for(const r of e){if(r instanceof Tr)return r;Ze(r)&&t.push(je(r))}return t},this.manyToOnlyNumbersDropNulls=e=>{const t=[];for(const r of e){if(r instanceof Tr)return r;if(Ze(r))t.push(je(r));else if(r!==Ye)return new Tr(ir.VALUE,Z.NumberExpected)}return t},this.manyToCoercedNumbersDropNulls=e=>{const t=[];for(const r of e){if(r instanceof Tr)return r;if(r===Ye)continue;const e=this.coerceScalarToNumberOrError(r);Ze(e)&&t.push(je(e))}return t},this.collator= +/** + * @license + * Copyright (c) 2024 Handsoncode. All rights reserved. + */ +function(e){const t=e.caseSensitive?e.accentSensitive?"variant":"case":e.accentSensitive?"accent":"base",r=e.caseFirst,n=e.ignorePunctuation;return new Intl.Collator(e.localeLang,{sensitivity:t,caseFirst:r,ignorePunctuation:n})}(e),this.actualEps=e.smartRounding?e.precisionEpsilon:0}eqMatcherFunction(e){const t=this.buildRegex(e);return e=>"string"==typeof e&&t.test(this.normalizeString(e))}neqMatcherFunction(e){const t=this.buildRegex(e);return e=>!("string"==typeof e&&t.test(this.normalizeString(e)))}searchString(e,t){var r;const n=this.buildRegex(e,!1).exec(t);return null!==(r=null==n?void 0:n.index)&&void 0!==r?r:-1}requiresRegex(e){if(!this.config.useRegularExpressions&&!this.config.useWildcards)return!this.config.matchWholeCell;for(let t=0;t=0&&r*s>=n&&r<=n*s||n<=0&&r*s<=n&&r>=n*s?0:r>n?1:-1}coerceScalarToNumberOrError(e){var t;return e instanceof Tr?e:null!==(t=this.coerceToMaybeNumber(e))&&void 0!==t?t:new Tr(ir.VALUE,Z.NumberCoercion)}coerceToMaybeNumber(e){var t;return null!==(t=this.coerceNonDateScalarToMaybeNumber(e))&&void 0!==t?t:"string"==typeof e?this.dateTimeHelper.dateStringToDateNumber(e):void 0}coerceNonDateScalarToMaybeNumber(e){if(e===Ye)return 0;if("string"==typeof e){if(""===e)return 0;const t=this.coerceStringToMaybePercentNumber(e);if(void 0!==t)return t;const r=this.coerceStringToMaybeCurrencyNumber(e);return void 0!==r?r:this.numberLiteralsHelper.numericStringToMaybeNumber(e.trim())}return Ze(e)?e:"boolean"==typeof e?Number(e):void 0}coerceStringToMaybePercentNumber(e){const t=e.trim();if(t.endsWith("%")){const e=t.slice(0,t.length-1).trim(),r=this.numberLiteralsHelper.numericStringToMaybeNumber(e);if(void 0!==r)return new Qe(r/100)}}coerceStringToMaybeCurrencyNumber(e){const t=this.currencyMatcher(e.trim());if(void 0!==t){const[e,r]=t,n=this.numberLiteralsHelper.numericStringToMaybeNumber(r);if(void 0!==n)return new Ke(n,e)}}currencyMatcher(e){for(const t of this.config.currencySymbol){if(e.startsWith(t))return[t,e.slice(t.length).trim()];if(e.endsWith(t))return[t,e.slice(0,e.length-t.length).trim()]}}coerceComplexExactRanges(e){const t=[];for(const r of e)if(r instanceof rt)t.push(r);else if(r!==Ye){const e=this.coerceScalarToComplex(r);if(e instanceof Tr)return e;t.push(e)}const r=[];for(const e of t)if(e instanceof rt){const t=this.manyToExactComplex(e.valuesFromTopLeftCorner());if(t instanceof Tr)return t;r.push(...t)}else r.push(e);return r}coerceScalarToComplex(e){return e instanceof Tr?e:e===Ye?[0,0]:Ze(e)?[je(e),0]:"string"==typeof e?this.coerceStringToComplex(e):new Tr(ir.NUM,Z.ComplexNumberExpected)}ExtendedNumberFactory(e,t){const{type:r,format:n}=t;switch(r){case Je.NUMBER_RAW:return e;case Je.NUMBER_CURRENCY:return new Ke(e,null!=n?n:this.config.currencySymbol[0]);case Je.NUMBER_DATE:return new $e(e,n);case Je.NUMBER_DATETIME:return new qe(e,n);case Je.NUMBER_TIME:return new Xe(e,n);case Je.NUMBER_PERCENT:return new Qe(e,n)}}buildRegex(e,t=!0){let r;e=this.normalizeString(e);let n=this.config.useWildcards,s=this.config.useRegularExpressions;if(s)try{RegExp(e)}catch(e){s=!1,n=!1}return r=s?function(e,t){let r="";for(let n=0;nn?1:r","=",".","+","-",",","\\","$","^","!"];function rn(e){return tn.includes(e)}function nn(e,t){const{type:r,format:n}=tt(e),{type:s,format:i}=tt(t);if(r===Je.NUMBER_RAW)return{type:s,format:i};if(s===Je.NUMBER_RAW)return{type:r,format:n};if(!(r!==Je.NUMBER_DATETIME&&r!==Je.NUMBER_DATE||s!==Je.NUMBER_DATETIME&&s!==Je.NUMBER_DATE))return{type:Je.NUMBER_RAW};if(r===Je.NUMBER_TIME){if(s===Je.NUMBER_DATE)return{type:Je.NUMBER_DATETIME,format:`${i} ${n}`};if(s===Je.NUMBER_DATETIME)return{type:Je.NUMBER_DATETIME,format:i}}if(s===Je.NUMBER_TIME){if(r===Je.NUMBER_DATE)return{type:Je.NUMBER_DATETIME,format:`${n} ${i}`};if(r===Je.NUMBER_DATETIME)return{type:Je.NUMBER_DATETIME,format:n}}return{type:r,format:n}}function sn(e,t){let{type:r,format:n}=tt(e),{type:s,format:i}=tt(t);return r===Je.NUMBER_PERCENT&&(r=Je.NUMBER_RAW,n=void 0),s===Je.NUMBER_PERCENT&&(s=Je.NUMBER_RAW,i=void 0),r===Je.NUMBER_RAW?{type:s,format:i}:s===Je.NUMBER_RAW?{type:r,format:n}:{type:Je.NUMBER_RAW}}function on(e){return ln(e.toLowerCase(),"nfd").replace(/[\u0300-\u036f]/g,"")}function an(e,t){var r;if(e.isAdHoc())return null===(r=e.data[0])||void 0===r?void 0:r[0];const n=e.range;if(t.formulaAddress.sheet===n.sheet)if(1===n.width()){const r=t.formulaAddress.row-n.start.row;if(r>=0&&r=0&&rthis.arithmeticHelper.coerceScalarToNumberOrError(e),this.runFunction=(e,t,r,n)=>{const s=this.evaluateArguments(e,t,r),i=s.map((([e,t])=>e)),o=s.map((([e,t])=>t)),a=this.buildMetadataForEachArgumentValue(i.length,r),l=t.arraysFlag&&!r.vectorizationForbidden;if(!this.isNumberOfArgumentValuesValid(a,i.length))return new Tr(ir.NA,Z.WrongArgNumber);const[h,u]=l?this.calculateSizeOfVectorizedResultArray(i,a):[1,1];if(1===h&&1===u){const e=this.vectorizeAndBroadcastArgumentsIfNecessary(l,i,a,0,0);return this.calculateSingleCellOfResultArray(t,e,a,o,n,r.returnNumberType)}const c=[...Array(h).keys()].map((e=>[...Array(u).keys()].map((s=>{const h=this.vectorizeAndBroadcastArgumentsIfNecessary(l,i,a,e,s),u=this.calculateSingleCellOfResultArray(t,h,a,o,n,r.returnNumberType);if(u instanceof rt)throw new Error("Function returning array cannot be vectorized.");return u}))));return rt.onlyValues(c)},this.runFunctionWithReferenceArgument=(e,t,r,n,s,i=()=>new Tr(ir.NA,Z.CellRefExpected))=>{if(0===e.length)return this.returnNumberWrapper(n(),r.returnNumberType);if(e.length>1)return new Tr(ir.NA,Z.WrongArgNumber);let o,a=e[0];for(;a.type===U.PARENTHESIS;)a=a.expression;if(a.type===U.CELL_REFERENCE)o=a.reference.toSimpleCellAddress(t.formulaAddress);else if(a.type===U.CELL_RANGE||a.type===U.COLUMN_RANGE||a.type===U.ROW_RANGE)try{o=Fr.fromAst(a,t.formulaAddress).start}catch(e){return new Tr(ir.REF,Z.CellRefExpected)}return void 0!==o?this.returnNumberWrapper(s(o),r.returnNumberType):this.runFunction(e,t,r,i)},this.interpreter=e,this.dependencyGraph=e.dependencyGraph,this.columnSearch=e.columnSearch,this.config=e.config,this.serialization=e.serialization,this.arraySizePredictor=e.arraySizePredictor,this.dateTimeHelper=e.dateTimeHelper,this.arithmeticHelper=e.arithmeticHelper}evaluateAst(e,t){return this.interpreter.evaluateAst(e,t)}arraySizeForAst(e,t){return this.arraySizePredictor.checkArraySizeForAst(e,t)}listOfScalarValues(e,t){const r=[];for(const n of e){const e=this.evaluateAst(n,t);if(e instanceof rt)for(const t of e.valuesFromTopLeftCorner())r.push([t,!0]);else r.push([e,!1])}return r}coerceToType(e,t,r){let n;if(e instanceof rt)switch(t.argumentType){case hn.RANGE:case hn.ANY:n=e;break;default:{const t=an(e,r);if(void 0===t)return;e=t}}if(!(e instanceof rt))switch(t.argumentType){case hn.INTEGER:case hn.NUMBER:const r=this.coerceScalarToNumberOrError(e);if(!Ze(r)){n=r;break}const s=je(r);if(void 0!==t.maxValue&&s>t.maxValue)return new Tr(ir.NUM,Z.ValueLarge);if(void 0!==t.minValue&&s=t.lessThan)return new Tr(ir.NUM,Z.ValueLarge);if(void 0!==t.greaterThan&&s<=t.greaterThan)return new Tr(ir.NUM,Z.ValueSmall);if(t.argumentType===hn.INTEGER&&!Number.isInteger(s))return new Tr(ir.NUM,Z.IntegerExpected);n=r;break;case hn.STRING:n=Xr(e);break;case hn.BOOLEAN:n=Kr(e);break;case hn.SCALAR:case hn.NOERROR:case hn.ANY:n=e;break;case hn.RANGE:if(e instanceof Tr)return e;n=Gr(e);break;case hn.COMPLEX:return this.arithmeticHelper.coerceScalarToComplex(je(e))}return t.passSubtype||void 0===n?n:je(n)}calculateSingleCellOfResultArray(e,t,r,n,s,i){const o=this.coerceArgumentsToRequiredTypes(e,t,r,n);if(o instanceof Tr)return o;const a=s(...o);return this.returnNumberWrapper(a,i)}coerceArgumentsToRequiredTypes(e,t,r,n){const s=[];for(let i=0;ie&&this.isRangePassedAsAScalarArgument(t,r[i])?this.vectorizeAndBroadcastRangeArgument(t,n,s):t))}vectorizeAndBroadcastRangeArgument(e,t,r){var n;const s=1===e.height()?0:t,i=1===e.width()?0:r;return null===(n=e.data[s])||void 0===n?void 0:n[i]}evaluateArguments(e,t,r){return r.expandRanges?this.listOfScalarValues(e,t):e.map((e=>[this.evaluateAst(e,t),!1]))}buildMetadataForEachArgumentValue(e,t){const r=t.parameters?[...t.parameters]:[];if(void 0!==t.repeatLastArgs&&Number.isInteger(t.repeatLastArgs)&&t.repeatLastArgs>0)for(;e>r.length;)r.push(...r.slice(r.length-t.repeatLastArgs));return r}isNumberOfArgumentValuesValid(e,t){if(t>e.length)return!1;if(t(null==e?void 0:e.optionalArg)||void 0!==(null==e?void 0:e.defaultValue)))}return!0}calculateSizeOfVectorizedResultArray(e,t){const r=e.filter(((e,r)=>this.isRangePassedAsAScalarArgument(e,t[r])));return[Math.max(1,...r.map((e=>e.height()))),Math.max(1,...r.map((e=>e.width())))]}isRangePassedAsAScalarArgument(e,t){return null!=e&&null!=t&&(e instanceof rt&&![hn.RANGE,hn.ANY].includes(t.argumentType))}metadata(e){const t=this.constructor.implementedFunctions[e];if(void 0!==t)return t;throw new Error(`No metadata for function ${e}.`)}returnNumberWrapper(e,t,r){return void 0!==t&&Ze(e)?this.arithmeticHelper.ExtendedNumberFactory(je(e),{type:t,format:r}):e}} +/** + * @license + * Copyright (c) 2024 Handsoncode. All rights reserved. + */ +class cn{constructor(e,t,r=!1){this.width=e,this.height=t,this.isRef=r}static error(){return new cn(1,1,!0)}static scalar(){return new cn(1,1,!1)}isScalar(){return 1===this.width&&1===this.height||this.isRef}}class dn{constructor(e,t){this.config=e,this.functionRegistry=t}checkArraySize(e,t){return this.checkArraySizeForAst(e,{formulaAddress:t,arraysFlag:this.config.useArrayArithmetic})}checkArraySizeForAst(e,t){switch(e.type){case U.FUNCTION_CALL:return this.checkArraySizeForFunction(e,t);case U.COLUMN_RANGE:case U.ROW_RANGE:case U.CELL_RANGE:{const r=Fr.fromAstOrUndef(e,t.formulaAddress);return void 0===r?cn.error():new cn(r.width(),r.height(),!0)}case U.ARRAY:{const r=[],n=[];for(const s of e.args){const e=s.map((e=>this.checkArraySizeForAst(e,t))),i=Math.min(...e.map((e=>e.height))),o=e.reduce(((e,t)=>e+t.width),0);r.push(i),n.push(o)}const s=r.reduce(((e,t)=>e+t),0),i=Math.min(...n);return new cn(i,s)}case U.STRING:case U.NUMBER:return cn.scalar();case U.CELL_REFERENCE:return new cn(1,1,!0);case U.DIV_OP:case U.CONCATENATE_OP:case U.EQUALS_OP:case U.GREATER_THAN_OP:case U.GREATER_THAN_OR_EQUAL_OP:case U.LESS_THAN_OP:case U.LESS_THAN_OR_EQUAL_OP:case U.MINUS_OP:case U.NOT_EQUAL_OP:case U.PLUS_OP:case U.POWER_OP:case U.TIMES_OP:{const r=this.checkArraySizeForAst(e.left,t),i=this.checkArraySizeForAst(e.right,t);return!t.arraysFlag&&(r.height>1||r.width>1||i.height>1||i.width>1)?cn.error():(n=r,s=i,new cn(Math.max(n.width,s.width),Math.max(n.height,s.height)))}case U.MINUS_UNARY_OP:case U.PLUS_UNARY_OP:case U.PERCENT_OP:{const n=this.checkArraySizeForAst(e.value,t);return!t.arraysFlag&&(n.height>1||n.width>1)?cn.error():new cn((r=n).width,r.height)}case U.PARENTHESIS:return this.checkArraySizeForAst(e.expression,t);case U.EMPTY:default:return cn.error()}var r,n,s}checkArraySizeForFunction(e,t){const r=this.functionRegistry.getArraySizeFunction(e.procedureName);if(void 0!==r)return r(e,t);const n=this.functionRegistry.getMetadata(e.procedureName);if(void 0===n||n.expandRanges||!t.arraysFlag||n.vectorizationForbidden||void 0===n.parameters)return new cn(1,1);const s=e.args.map((e=>{var r;return this.checkArraySizeForAst(e,new Br(t.formulaAddress,t.arraysFlag||null!==(r=null==n?void 0:n.arrayFunction)&&void 0!==r&&r))})),i=[...n.parameters];if(void 0!==n.repeatLastArgs&&i.length`'${e}'`)).join(" "),r)}function fn(e,t,r){if(e{const r=t.get(e.value)||[];r.push(e.name),t.set(e.value,r)}));const r=[];for(const e of t.values())e.length>1&&r.push(e);if(r.length>0){r.forEach((e=>e.sort()));const e=r.map((e=>`[${e}]`)).join("; ");throw new Error(`Config initialization failed. Parameters in conflict: ${e}`)}}function En(e,t,r){if(typeof e!==t)throw new Tt(t,r)} +/** + * @license + * Copyright (c) 2024 Handsoncode. All rights reserved. + */ +const wn=new RegExp("^ss(\\.(s+|0+))?$"),Cn=new RegExp("^[0-9/.\\-: ]+[ap]?m?$"),vn=new RegExp("\\s+"),Rn=new RegExp("[ /.-]"),Sn=1e3,Tn=bn((function(e){const t=e.toLowerCase().trim(),r=(t.endsWith("am/pm")?t.substring(0,t.length-5):t.endsWith("a/p")?t.substring(0,e.length-3):t).trim().split(":");return{itemsCount:r.length,hourItem:r.indexOf("hh"),minuteItem:r.indexOf("mm"),secondItem:r.findIndex((e=>wn.test(e)))}})),Nn=bn((function(e){const t=e.toLowerCase().trim().split(Rn);return{itemsCount:t.length,dayItem:t.indexOf("dd"),monthItem:t.indexOf("mm"),shortYearItem:t.indexOf("yy"),longYearItem:t.indexOf("yyyy")}}));function Mn(e,t){var r,n,s;if(void 0===t)return;const{itemsCount:i,hourItem:o,minuteItem:a,secondItem:l}=Tn(t);let h;if("am"===e[e.length-1]||"a"===e[e.length-1]?(h=!1,e.pop()):"pm"!==e[e.length-1]&&"p"!==e[e.length-1]||(h=!0,e.pop()),e.length!==i)return;const u=Number(null!==(r=e[l])&&void 0!==r?r:"0");if(!Number.isFinite(u))return;const c=Math.round(u*Sn)/Sn,d=Number(null!==(n=e[a])&&void 0!==n?n:"0");if(!Number.isFinite(d)||!Number.isInteger(d))return;const p=Number(null!==(s=e[o])&&void 0!==s?s:"0");if(!Number.isFinite(p)||!Number.isInteger(p))return;if(void 0!==h&&(p<0||p>12))return;return{hours:void 0!==h?p%12+(h?12:0):p,minutes:d,seconds:c}}function _n(e,t){var r;if(void 0===t)return;const{itemsCount:n,dayItem:s,monthItem:i,shortYearItem:o,longYearItem:a}=Nn(t);if(e.length!==n)return;const l=Number(e[s]);if(!Number.isFinite(l)||!Number.isInteger(l))return;const h=Number(e[i]);if(!Number.isFinite(h)||!Number.isInteger(h))return;if(e[a]&&e[o])return;const u=Number(null!==(r=e[a])&&void 0!==r?r:e[o]);return Number.isFinite(u)&&Number.isInteger(u)&&!(e[a]&&(u<1e3||u>9999)||e[o]&&(u<0||u>99))?{year:u,month:h,day:l}:void 0}function bn(e){const t={};return r=>{const n=t[r];if(void 0!==n)return n;const s=e(r);return t[r]=s,s}} +/** + * @license + * Copyright (c) 2024 Handsoncode. All rights reserved. + */ +const An=[31,28,31,30,31,30,31,31,30,31,30,31],On=[0,31,59,90,120,151,181,212,243,273,304,334],In=60,xn=60,Pn=24;function Ln(e){return!(!e||"object"!=typeof e&&"function"!=typeof e)&&("year"in e&&"number"==typeof e.year&&"month"in e&&"number"==typeof e.month&&"day"in e&&"number"==typeof e.day)}function Dn(e){return!(!e||"object"!=typeof e&&"function"!=typeof e)&&("hours"in e&&"number"==typeof e.hours&&"minutes"in e&&"number"==typeof e.minutes&&"seconds"in e&&"number"==typeof e.seconds)}const kn={year:9999,month:12,day:31};class Hn{constructor(e){this.config=e,this.minDateAbsoluteValue=this.dateToNumberFromZero(e.nullDate),this.maxDateValue=this.dateToNumber(kn),this.leapYear1900=e.leapYear1900,!this.leapYear1900&&0<=this.dateToNumber({year:1900,month:2,day:28})?this.epochYearZero=this.numberToSimpleDate(2).year:this.epochYearZero=this.numberToSimpleDate(1).year,this.parseDateTime=e.parseDateTime}getWithinBounds(e){return e<=this.maxDateValue&&e>=0?e:void 0}dateStringToDateNumber(e){const{dateTime:t,dateFormat:r="",timeFormat:n=""}=this.parseDateTimeFromConfigFormats(e);if(void 0!==t)return Dn(t)?Ln(t)?new qe(Bn(t)+this.dateToNumber(t),r+" "+n):new Xe(Bn(t),n):Ln(t)?new $e(this.dateToNumber(t),r):0}parseDateTimeFromConfigFormats(e){return this.parseDateTimeFromFormats(e,this.config.dateFormats,this.config.timeFormats)}getNullYear(){return this.config.nullYear}getEpochYearZero(){return this.epochYearZero}isValidDate(e){return!(isNaN(e.year)||isNaN(e.month)||isNaN(e.day))&&(e.day===Math.round(e.day)&&e.month===Math.round(e.month)&&e.year===Math.round(e.year)&&(!(e.year<1582)&&(!(e.month<1||e.month>12)&&(!(e.day<1)&&(this.isLeapYear(e.year)&&2===e.month?e.day<=29:e.day<=An[e.month-1])))))}dateToNumber(e){return this.dateToNumberFromZero(e)-this.minDateAbsoluteValue}relativeNumberToAbsoluteNumber(e){return e+this.minDateAbsoluteValue-(this.leapYear1900?1:0)}numberToSimpleDate(e){const t=Math.floor(e)+this.minDateAbsoluteValue;let r=Math.floor(t/365.2425);this.dateToNumberFromZero({year:r+1,month:1,day:1})<=t?r++:this.dateToNumberFromZero({year:r-1,month:1,day:1})>t&&r--;const n=t-this.dateToNumberFromZero({year:r,month:1,day:1}),s=function(e){let t=0;On[t+6]<=e&&(t+=6);On[t+3]<=e&&(t+=3);On[t+2]<=e?t+=2:On[t+1]<=e&&(t+=1);return t}(n-(this.isLeapYear(r)&&n>=59?1:0));return{year:r,month:s+1,day:n-On[s]-(this.isLeapYear(r)&&s>1?1:0)+1}}numberToSimpleDateTime(e){const t=Vn(e%1),r=Math.floor(t.hours/Pn);t.hours=t.hours%Pn;const n=this.numberToSimpleDate(Math.floor(e)+r);return Object.assign(Object.assign({},n),t)}leapYearsCount(e){return Math.floor(e/4)-Math.floor(e/100)+Math.floor(e/400)+(this.config.leapYear1900&&e>=1900?1:0)}daysInMonth(e,t){return this.isLeapYear(e)&&2===t?29:An[t-1]}endOfMonth(e){return{year:e.year,month:e.month,day:this.daysInMonth(e.year,e.month)}}toBasisUS(e,t){return 31===e.day&&(e.day=30),30===e.day&&31===t.day&&(t.day=30),2===e.month&&e.day===this.daysInMonth(e.year,e.month)&&(e.day=30,2===t.month&&t.day===this.daysInMonth(t.year,t.month)&&(t.day=30)),[e,t]}yearLengthForBasis(e,t){return e.year!==t.year?e.year+1!==t.year||e.month=0&&n.year<100&&(n.year2||2===e.month&&e.day>=29?this.leapYearsCount(e.year):this.leapYearsCount(e.year-1)}dateToNumberFromZero(e){return 365*e.year+On[e.month-1]+e.day-1+(e.month<=2?this.leapYearsCount(e.year-1):this.leapYearsCount(e.year))}isLeapYear(e){return!(e%4)&&(!!(e%100)||(!(e%400)||1900===e&&this.config.leapYear1900))}}function Fn(e,t){const r=12*e.year+e.month-1+t;return{year:Math.floor(r/12),month:r%12+1,day:e.day}}function Un(e){return Math.round(3600*e*24)/86400}function Vn(e){const t=e*Pn*xn*In,r=function(e,t=1){return Math.round(e*t)/t}(t%In,1e5)%In,n=(t-r)/In,s=Math.round(n%xn)%xn,i=(n-s)/xn;return{hours:Math.round(i),minutes:s,seconds:r}}function Bn(e){return((e.seconds/60+e.minutes)/60+e.hours)/24}function Wn(e){return{year:e.year,month:e.month,day:Math.min(30,e.day)}} +/** + * @license + * Copyright (c) 2024 Handsoncode. All rights reserved. + */ +const Yn=/(\\.|dd|DD|d|D|mm|MM|m|M|YYYY|YY|yyyy|yy|HH|hh|H|h|ss(\.(0+|s+))?|s|AM\/PM|am\/pm|A\/P|a\/p|\[mm]|\[MM]|\[hh]|\[HH])/g,jn=/(\\.|[#0]+(\.[#0]*)?)/g;var Gn,zn;function $n(e,t){return{type:e,value:t}}function Kn(e,t){const r=[];let n=0;for(let s=0;sQn(e)))?void 0:{type:zn.DATE,tokens:Kn(t,e)}}function qn(e){const t=function(e){jn.lastIndex=0;const t=jn.exec(e);return null!==t?[t]:[]}(e);return t.every((e=>Qn(e)))?void 0:{type:zn.NUMBER,tokens:Kn(t,e)}}function Qn(e){return e[0].startsWith("\\")} +/** + * @license + * Copyright (c) 2024 Handsoncode. All rights reserved. + */ +function Zn(e,t,r,n){const s=r.stringifyDateTime(n.numberToSimpleDateTime(e),t);if(void 0!==s)return s;const i=r.stringifyDuration(Vn(e),t);if(void 0!==i)return i;const o=qn(t);return void 0!==o?function(e,t){let r="";for(let n=0;nu.length){u=Jn(u,ts(o.substr(0,o.length-u.length),"0")+u.length)}c=es(c,ts(a.substr(c.length,a.length-c.length),"0")+c.length),r+=u+l+c}return r}(o.tokens,e):t}function Jn(e,t){let r=`${e}`;for(;r.lengthparseInt(e,16),ss=e=>parseInt(e,10),is=e=>(e+"").replace(/\-/g,""),os=(e,t,r)=>e.substr(t,r),as=e=>e.codePointAt(0)-65; +/** + * @license + * Copyright (c) 2024 Handsoncode. All rights reserved. + */ +const ls={invalid:()=>"The license key for HyperFormula is invalid.",expired:({keyValidityDate:e})=>`The license key for HyperFormula expired on ${e}, and is not valid for the installed version.`,missing:()=>"The license key for HyperFormula is missing."};let hs=!1;function us(e){const t={template:"missing",vars:{}};if("gpl-v3"===e||"internal-use-in-handsontable"===e)t.template="valid";else if("string"==typeof e&&function(e){if((e=(e+"").replace(/\-/g,""))[rs]!==as("Z"))return!1;let t=0;return[[0,as("G")+1],[as("H"),as("H")-1],[as("G")+as("H"),as("G")]].reduce(((r,[n,s],i)=>(r|=(ss(`${ss(ns(os(e,t+n-(0===i?0:2),s+(i?2:0)))+(ns(os(e,t+n+s,2))+[]).padStart(2,"0"))}`)%97||2)>>1,t+=2,r)),as("A"))===[]+1>>1}(e)){const[n,s,i]="10/04/2024".split("/"),o=Math.floor(new Date(`${s}/${n}/${i}`).getTime()/864e5),a=25===is(r=e)[rs]?ns(os(is(r),ns("12"),as("F")))/(ns(os(is(r),as("C"),as("Y")>>4))||1+(![][rs]<<3)):0;t.vars.keyValidityDate=function(e){const t=["January","February","March","April","May","June","July","August","September","October","November","December"][e.getMonth()],r=e.getDate(),n=e.getFullYear();return`${t} ${r}, ${n}`}(new Date(864e5*(a+1))),t.template=o>a?"expired":"valid"}else""!==e&&(t.template="invalid");var r;return hs||"valid"===t.template||(console.warn(ls[t.template](t.vars)),hs=!0),t.template} +/** + * @license + * Copyright (c) 2024 Handsoncode. All rights reserved. + */ +var cs,ds,ps;!function(e){e.Number=class{constructor(e){this.value=e,this.value=ze(this.value,Jr(je(this.value)))}};e.String=class{constructor(e){this.value=e}};e.Boolean=class{constructor(e){this.value=e}};class t{static getSingletonInstance(){return t.instance||(t.instance=new t),t.instance}}e.Empty=t;e.Formula=class{constructor(e){this.formula=e}};e.Error=class{constructor(e,t){this.value=new Tr(e,t)}}}(cs||(cs={}));class gs{constructor(e,t,r){this.config=e,this.dateHelper=t,this.numberLiteralsHelper=r}parse(e){if(null==e)return cs.Empty.getSingletonInstance();if("number"==typeof e)return Zr(e)?new cs.Error(ir.NUM,Z.ValueLarge):new cs.Number(e);if("boolean"==typeof e)return new cs.Boolean(e);if(e instanceof Date){const t=this.dateHelper.dateToNumber({day:e.getDate(),month:e.getMonth()+1,year:e.getFullYear()})+Bn({hours:e.getHours(),minutes:e.getMinutes(),seconds:e.getSeconds()+e.getMilliseconds()/1e3});return t<0?new cs.Error(ir.NUM,Z.DateBounds):t%1==0?new cs.Number(new $e(t,"Date()")):t<1?new cs.Number(new Xe(t,"Date()")):new cs.Number(new qe(t,"Date()"))}if("string"==typeof e){if(function(e){const t=e.toLowerCase();return"true"===t||"false"===t}(e))return new cs.Boolean("true"===e.toLowerCase());if(e.startsWith("="))return new cs.Formula(e);if(function(e,t){const r=e.toUpperCase();return/#[A-Za-z0-9\/]+[?!]?/.test(r)&&Object.prototype.hasOwnProperty.call(t,r)}(e,this.config.errorMapping))return new cs.Error(this.config.errorMapping[e.toUpperCase()]);{let t,r=e.trim(),n=0;if(r.endsWith("%"))n=1,r=r.slice(0,r.length-1);else{const e=this.currencyMatcher(r);void 0!==e&&(n=2,[t,r]=e)}const s=this.numberLiteralsHelper.numericStringToMaybeNumber(r);if(void 0!==s){let e;return e=1===n?new Qe(s/100):2===n?new Ke(s,t):s,new cs.Number(e)}const i=this.dateHelper.dateStringToDateNumber(r);return void 0!==i?new cs.Number(i):new cs.String(e.startsWith("'")?e.slice(1):e)}}throw new St(e)}currencyMatcher(e){for(const t of this.config.currencySymbol){if(e.startsWith(t))return[t,e.slice(t.length)];if(e.endsWith(t))return[t,e.slice(0,e.length-t.length)]}}}!function(e){e[e.COPY=0]="COPY",e[e.CUT=1]="CUT"}(ds||(ds={})),function(e){e[e.VALUE=0]="VALUE",e[e.EMPTY=1]="EMPTY",e[e.FORMULA=2]="FORMULA",e[e.PARSING_ERROR=3]="PARSING_ERROR"}(ps||(ps={}));class fs{constructor(e,t,r,n,s){this.sourceLeftCorner=e,this.width=t,this.height=r,this.type=n,this.content=s}*getContent(e){if(void 0!==this.content)for(let t=0;te.added))}normalizeExpressionName(e){return e.toLowerCase()}}class ws{constructor(){this.mapping=new Map}add(e){this.mapping.set(this.normalizeExpressionName(e.displayName),e)}get(e){return this.mapping.get(this.normalizeExpressionName(e))}has(e){return this.mapping.has(this.normalizeExpressionName(e))}getAllNamedExpressions(){return Array.from(this.mapping.values()).filter((e=>e.added))}isNameAvailable(e){const t=this.normalizeExpressionName(e);return!this.mapping.has(t)}remove(e){const t=this.normalizeExpressionName(e);this.mapping.get(t)&&this.mapping.delete(t)}normalizeExpressionName(e){return e.toLowerCase()}}class Cs{constructor(){this.nextNamedExpressionRow=0,this.workbookStore=new Es,this.worksheetStores=new Map,this.addressCache=new Map}isNameAvailable(e,t){var r,n;return void 0===t?this.workbookStore.isNameAvailable(e):null===(n=null===(r=this.worksheetStore(t))||void 0===r?void 0:r.isNameAvailable(e))||void 0===n||n}namedExpressionInAddress(e){const t=this.addressCache.get(e);return t&&t.added?t:void 0}namedExpressionForScope(e,t){var r;return void 0===t?this.workbookStore.getExisting(e):null===(r=this.worksheetStore(t))||void 0===r?void 0:r.get(e)}nearestNamedExpression(e,t){var r,n;return null!==(n=null===(r=this.worksheetStore(t))||void 0===r?void 0:r.get(e))&&void 0!==n?n:this.workbookStore.getExisting(e)}isExpressionInScope(e,t){var r,n;return null!==(n=null===(r=this.worksheetStore(t))||void 0===r?void 0:r.has(e))&&void 0!==n&&n}isNameValid(e){const t=new RegExp(`^${f}$`),r=new RegExp(`^${E}$`),n=new RegExp(`^${C}$`);return!t.test(e)&&!r.test(e)&&n.test(e)}addNamedExpression(e,t,r){const n=void 0===t?this.workbookStore:this.worksheetStoreOrCreate(t);let s=n.get(e);return void 0!==s?(s.added=!0,s.displayName=e,s.options=r):(s=new ys(e,this.nextAddress(),!0,r),n.add(s)),this.addressCache.set(s.address.row,s),s}restoreNamedExpression(e,t){const r=void 0===t?this.workbookStore:this.worksheetStoreOrCreate(t);return e.added=!0,r.add(e),this.addressCache.set(e.address.row,e),e}namedExpressionOrPlaceholder(e,t){var r;return null!==(r=this.worksheetStoreOrCreate(t).get(e))&&void 0!==r?r:this.workbookNamedExpressionOrPlaceholder(e)}workbookNamedExpressionOrPlaceholder(e){let t=this.workbookStore.get(e);return void 0===t&&(t=new ys(e,this.nextAddress(),!1),this.workbookStore.add(t)),t}remove(e,t){let r;r=void 0===t?this.workbookStore:this.worksheetStore(t);const n=null==r?void 0:r.get(e);if(void 0===r||void 0===n||!n.added)throw Error("Named expression does not exist");r.remove(e),r instanceof ws&&0===r.mapping.size&&this.worksheetStores.delete(t),this.addressCache.delete(n.address.row)}getAllNamedExpressionsNamesInScope(e){return this.getAllNamedExpressions().filter((({scope:t})=>t===e)).map((e=>e.expression.displayName))}getAllNamedExpressionsNames(){return this.getAllNamedExpressions().map((e=>e.expression.displayName))}getAllNamedExpressions(){const e=[];return this.workbookStore.getAllNamedExpressions().forEach((t=>{e.push({expression:t,scope:void 0})})),this.worksheetStores.forEach(((t,r)=>{t.getAllNamedExpressions().forEach((t=>{e.push({expression:t,scope:r})}))})),e}getAllNamedExpressionsForScope(e){var t,r;return void 0===e?this.workbookStore.getAllNamedExpressions():null!==(r=null===(t=this.worksheetStores.get(e))||void 0===t?void 0:t.getAllNamedExpressions())&&void 0!==r?r:[]}worksheetStoreOrCreate(e){let t=this.worksheetStores.get(e);return t||(t=new ws,this.worksheetStores.set(e,t)),t}worksheetStore(e){return this.worksheetStores.get(e)}nextAddress(){return Ar(Cs.SHEET_FOR_WORKBOOK_EXPRESSIONS,0,this.nextNamedExpressionRow++)}}Cs.SHEET_FOR_WORKBOOK_EXPRESSIONS=-1;const vs=e=>{switch(e.type){case U.EMPTY:case U.NUMBER:case U.STRING:case U.ERROR:case U.ERROR_WITH_RAW_INPUT:return!1;case U.CELL_REFERENCE:return!e.reference.isAbsolute();case U.CELL_RANGE:case U.COLUMN_RANGE:case U.ROW_RANGE:return!e.start.isAbsolute();case U.NAMED_EXPRESSION:return!1;case U.PERCENT_OP:case U.PLUS_UNARY_OP:case U.MINUS_UNARY_OP:return vs(e.value);case U.CONCATENATE_OP:case U.EQUALS_OP:case U.NOT_EQUAL_OP:case U.LESS_THAN_OP:case U.GREATER_THAN_OP:case U.LESS_THAN_OR_EQUAL_OP:case U.GREATER_THAN_OR_EQUAL_OP:case U.MINUS_OP:case U.PLUS_OP:case U.TIMES_OP:case U.DIV_OP:case U.POWER_OP:return vs(e.left)||vs(e.right);case U.PARENTHESIS:return vs(e.expression);case U.FUNCTION_CALL:return e.args.some((e=>vs(e)));case U.ARRAY:return e.args.some((e=>e.some((e=>vs(e)))))}}; +/** + * @license + * Copyright (c) 2024 Handsoncode. All rights reserved. + */ +class Rs{performEagerTransformations(e,t){for(const r of e.arrayFormulaNodes()){const[n,s]=this.transformSingleAst(r.getFormula(e.lazilyTransformingAstService),r.getAddress(e.lazilyTransformingAstService)),i=t.rememberNewAst(n);r.setFormula(i),r.setAddress(s)}}transformSingleAst(e,t){return[this.transformAst(e,t),this.fixNodeAddress(t)]}transformAst(e,t){switch(e.type){case U.CELL_REFERENCE:return this.transformCellReferenceAst(e,t);case U.CELL_RANGE:return this.transformCellRangeAst(e,t);case U.COLUMN_RANGE:return this.transformColumnRangeAst(e,t);case U.ROW_RANGE:return this.transformRowRangeAst(e,t);case U.EMPTY:case U.ERROR:case U.NUMBER:case U.NAMED_EXPRESSION:case U.ERROR_WITH_RAW_INPUT:case U.STRING:return e;case U.PERCENT_OP:case U.MINUS_UNARY_OP:case U.PLUS_UNARY_OP:return Object.assign(Object.assign({},e),{value:this.transformAst(e.value,t)});case U.FUNCTION_CALL:return Object.assign(Object.assign({},e),{procedureName:e.procedureName,args:e.args.map((e=>this.transformAst(e,t)))});case U.PARENTHESIS:return Object.assign(Object.assign({},e),{expression:this.transformAst(e.expression,t)});case U.ARRAY:return Object.assign(Object.assign({},e),{args:e.args.map((e=>e.map((e=>this.transformAst(e,t)))))});default:return Object.assign(Object.assign({},e),{left:this.transformAst(e.left,t),right:this.transformAst(e.right,t)})}}transformCellReferenceAst(e,t){const r=this.transformCellAddress(e.reference,t);return r instanceof l?Object.assign(Object.assign({},e),{reference:r}):r===ir.REF?j(new Tr(ir.REF)):e}transformCellRangeAst(e,t){const r=this.transformCellRange(e.start,e.end,t);return Array.isArray(r)?Object.assign(Object.assign({},e),{start:r[0],end:r[1]}):r===ir.REF?j(new Tr(ir.REF)):e}transformColumnRangeAst(e,t){const r=this.transformColumnRange(e.start,e.end,t);return Array.isArray(r)?Object.assign(Object.assign({},e),{start:r[0],end:r[1]}):r===ir.REF?j(new Tr(ir.REF)):e}transformRowRangeAst(e,t){const r=this.transformRowRange(e.start,e.end,t);return Array.isArray(r)?Object.assign(Object.assign({},e),{start:r[0],end:r[1]}):r===ir.REF?j(new Tr(ir.REF)):e}} +/** + * @license + * Copyright (c) 2024 Handsoncode. All rights reserved. + */ +class Ss extends Rs{constructor(e){super(),this.columnsSpan=e}get sheet(){return this.columnsSpan.sheet}isIrreversible(){return!1}transformRowRangeAst(e,t){return e}transformCellRange(e,t,r){return this.transformRange(e,t,r)}transformRowRange(e,t,r){throw Error("Not implemented")}transformColumnRange(e,t,r){return this.transformRange(e,t,r)}transformCellAddress(e,t){const r=Lr(e,t);if(r!==this.columnsSpan.sheet&&t.sheet!==this.columnsSpan.sheet)return!1;const n=e.toSimpleColumnAddress(t);if(r===this.columnsSpan.sheet&&t.sheet!==this.columnsSpan.sheet)return this.columnsSpan.columnStart<=n.col&&e.shiftedByColumns(this.columnsSpan.numberOfColumns);if(t.sheet===this.columnsSpan.sheet&&r!==this.columnsSpan.sheet)return!e.isColumnAbsolute()&&(!(t.colthis.columnsSpan.columnEnd)return e.shiftedByColumns(-this.columnsSpan.numberOfColumns)}if(this.columnsSpan.sheet===t.sheet&&this.columnsSpan.sheet!==r){if(e.isColumnAbsolute())return!1;if(t.colthis.columnsSpan.columnEnd)return e.shiftedByColumns(this.columnsSpan.numberOfColumns)}if(this.columnsSpan.sheet===t.sheet&&this.columnsSpan.sheet===r)if(e.isColumnAbsolute()){if(e.colthis.columnsSpan.columnEnd)return e.shiftedByColumns(-this.columnsSpan.numberOfColumns)}else{const r=e.toSimpleColumnAddress(t);if(r.colthis.columnsSpan.columnEnd)return e.shiftedByColumns(this.columnsSpan.numberOfColumns)}else if(r.col>this.columnsSpan.columnEnd){if(t.colthis.columnsSpan.columnEnd)return!1}}return ir.REF}fixNodeAddress(e){return this.columnsSpan.sheet===e.sheet&&this.columnsSpan.columnStart<=e.col?Object.assign(Object.assign({},e),{col:e.col-this.columnsSpan.numberOfColumns}):e}transformRange(e,t,r){const n=Lr(e,r);let s=e,i=t;if(this.columnsSpan.sheet===n){const n=e.toSimpleColumnAddress(r),o=t.toSimpleColumnAddress(r);if(this.columnsSpan.columnStart<=n.col&&this.columnsSpan.columnEnd>=o.col)return ir.REF;n.col>=this.columnsSpan.columnStart&&n.col<=this.columnsSpan.columnEnd&&(s=e.shiftedByColumns(this.columnsSpan.columnEnd-n.col+1)),o.col>=this.columnsSpan.columnStart&&o.col<=this.columnsSpan.columnEnd&&(i=t.shiftedByColumns(-(o.col-this.columnsSpan.columnStart+1)))}const o=this.transformCellAddress(s,r),a=this.transformCellAddress(i,r);if(!1===o&&!1===a)return[s,i];if(o===ir.REF||a===ir.REF)throw Error("Cannot happen");return[o||s,a||i]}} +/** + * @license + * Copyright (c) 2024 Handsoncode. All rights reserved. + */ +class As extends Rs{constructor(e){super(),this.rowsSpan=e}get sheet(){return this.rowsSpan.sheet}isIrreversible(){return!0}transformColumnRangeAst(e,t){return e}transformCellAddress(e,t){const r=Lr(e,t);if(this.rowsSpan.sheet!==t.sheet&&this.rowsSpan.sheet!==r)return!1;if(this.rowsSpan.sheet!==t.sheet&&this.rowsSpan.sheet===r){const r=e.toSimpleRowAddress(t);if(r.rowthis.rowsSpan.rowEnd)return e.shiftedByRows(-this.rowsSpan.numberOfRows)}if(this.rowsSpan.sheet===t.sheet&&this.rowsSpan.sheet!==r){if(e.isRowAbsolute())return!1;if(t.rowthis.rowsSpan.rowEnd)return e.shiftedByRows(this.rowsSpan.numberOfRows)}if(this.rowsSpan.sheet===t.sheet&&this.rowsSpan.sheet===r)if(e.isRowAbsolute()){if(e.rowthis.rowsSpan.rowEnd)return e.shiftedByRows(-this.rowsSpan.numberOfRows)}else{const r=e.toSimpleRowAddress(t);if(r.rowthis.rowsSpan.rowEnd)return e.shiftedByRows(this.rowsSpan.numberOfRows)}else if(r.row>this.rowsSpan.rowEnd){if(t.rowthis.rowsSpan.rowEnd)return!1}}return ir.REF}transformCellRange(e,t,r){return this.transformRange(e,t,r)}transformRowRange(e,t,r){return this.transformRange(e,t,r)}transformColumnRange(e,t,r){throw Error("Not implemented")}fixNodeAddress(e){return this.rowsSpan.sheet===e.sheet&&this.rowsSpan.rowStart<=e.row?Object.assign(Object.assign({},e),{row:e.row-this.rowsSpan.numberOfRows}):e}transformRange(e,t,r){const n=Lr(e,r);let s=e,i=t;if(this.rowsSpan.sheet===n){const n=e.toSimpleRowAddress(r),o=t.toSimpleRowAddress(r);if(this.rowsSpan.rowStart<=n.row&&this.rowsSpan.rowEnd>=o.row)return ir.REF;n.row>=this.rowsSpan.rowStart&&n.row<=this.rowsSpan.rowEnd&&(s=e.shiftedByRows(this.rowsSpan.rowEnd-n.row+1)),o.row>=this.rowsSpan.rowStart&&o.row<=this.rowsSpan.rowEnd&&(i=t.shiftedByRows(-(o.row-this.rowsSpan.rowStart+1)))}const o=this.transformCellAddress(s,r),a=this.transformCellAddress(i,r);return!1===o&&!1===a?[s,i]:o===ir.REF||a===ir.REF?ir.REF:[o||s,a||i]}} +/** + * @license + * Copyright (c) 2024 Handsoncode. All rights reserved. + */ +class Os extends Rs{constructor(e){super(),this.sheet=e}isIrreversible(){return!0}performEagerTransformations(e,t){for(const t of e.arrayFormulaNodes()){const[r]=this.transformSingleAst(t.getFormula(e.lazilyTransformingAstService),t.getAddress(e.lazilyTransformingAstService));t.setFormula(r)}}fixNodeAddress(e){return e}transformCellAddress(e,t){return this.transformAddress(e)}transformCellRange(e,t,r){return this.transformAddress(e)}transformColumnRange(e,t,r){return this.transformAddress(e)}transformRowRange(e,t,r){return this.transformAddress(e)}transformAddress(e){return e.sheet===this.sheet&&ir.REF}} +/** + * @license + * Copyright (c) 2024 Handsoncode. All rights reserved. + */ +function Is(e){if(!Array.isArray(e))throw new gt("an array of arrays.");for(let t=0;t0&&(r=s+1)}const s=t*r;return{height:r,width:t,fill:0===s?0:n/s}} +/** + * @license + * Copyright (c) 2024 Handsoncode. All rights reserved. + */ +class Ps{constructor(e,t){this.sheet=e,this.indexes=t}normalizedIndexes(){return Fs(this.indexes)}rowsSpans(){return this.normalizedIndexes().map((e=>st.fromNumberOfRows(this.sheet,e[0],e[1])))}}class Ls{constructor(e,t){this.sheet=e,this.indexes=t}normalizedIndexes(){return Us(this.indexes)}rowsSpans(){return this.normalizedIndexes().map((e=>st.fromNumberOfRows(this.sheet,e[0],e[1])))}}class Ds{constructor(e,t){this.sheet=e,this.indexes=t}normalizedIndexes(){return Us(this.indexes)}columnsSpans(){return this.normalizedIndexes().map((e=>it.fromNumberOfColumns(this.sheet,e[0],e[1])))}}class ks{constructor(e,t){this.sheet=e,this.indexes=t}normalizedIndexes(){return Fs(this.indexes)}columnsSpans(){return this.normalizedIndexes().map((e=>it.fromNumberOfColumns(this.sheet,e[0],e[1])))}}class Hs{constructor(e,t,r,n,s,i,o,a,l){this.dependencyGraph=t,this.columnSearch=r,this.cellContentParser=n,this.parser=s,this.stats=i,this.lazilyTransformingAstService=o,this.namedExpressions=a,this.arraySizePredictor=l,this.changes=nt.empty(),this.allocateNamedExpressionAddressSpace(),this.maxColumns=e.maxColumns,this.maxRows=e.maxRows}get sheetMapping(){return this.dependencyGraph.sheetMapping}get addressMapping(){return this.dependencyGraph.addressMapping}removeRows(e){const t=[];for(const r of e.rowsSpans()){const e=this.doRemoveRows(r);e&&t.push(e)}return t}addRows(e){for(const t of e.rowsSpans())this.doAddRows(t)}addColumns(e){for(const t of e.columnsSpans())this.doAddColumns(t)}removeColumns(e){const t=[];for(const r of e.columnsSpans()){const e=this.doRemoveColumns(r);e&&t.push(e)}return t}removeSheet(e){this.dependencyGraph.removeSheet(e);let t=0;this.stats.measure(et.TRANSFORM_ASTS,(()=>{const r=new Os(e);r.performEagerTransformations(this.dependencyGraph,this.parser),t=this.lazilyTransformingAstService.addTransformation(r)})),this.sheetMapping.removeSheet(e),this.columnSearch.removeSheet(e);const r=this.namedExpressions.getAllNamedExpressionsForScope(e).map((t=>this.removeNamedExpression(t.normalizeExpressionName(),e)));return{version:t,scopedNamedExpressions:r}}removeSheetByName(e){const t=this.sheetMapping.fetch(e);return this.removeSheet(t)}clearSheet(e){this.dependencyGraph.clearSheet(e),this.columnSearch.removeSheet(e)}addSheet(e){const t=this.sheetMapping.addSheet(e);return this.dependencyGraph.addressMapping.autoAddSheet(t,xs([])),this.sheetMapping.fetchDisplayName(t)}renameSheet(e,t){return this.sheetMapping.renameSheet(e,t)}moveRows(e,t,r,n){const s=st.fromNumberOfRows(e,n,r);this.lazilyTransformingAstService.beginCombinedMode(e),this.doAddRows(s),n{const e=new Ms(s,o,a,l);e.performEagerTransformations(this.dependencyGraph,this.parser),d=this.lazilyTransformingAstService.addTransformation(e)})),this.dependencyGraph.moveCells(s,o,a,l);const p=this.updateNamedExpressionsForMovedCells(e,t,r,n);return{version:d,overwrittenCellsData:h,addedGlobalNamedExpressions:p}}setRowOrder(e,t){const r=[];let n=[];for(const[s,i]of t)if(s!==i){const t=Fr.spanFrom({sheet:e,col:0,row:s},1/0,1),o=this.getRangeClipboardCells(t);n=n.concat(o),r.push(o.map((([{sheet:e,col:t},r])=>[{sheet:e,col:t,row:i},r])))}return r.forEach((t=>this.restoreClipboardCells(e,t.values()))),n}setColumnOrder(e,t){const r=[];let n=[];for(const[s,i]of t)if(s!==i){const t=Fr.spanFrom({sheet:e,col:s,row:0},1,1/0),o=this.getRangeClipboardCells(t);n=n.concat(o),r.push(o.map((([{sheet:e,col:t,row:r},n])=>[{sheet:e,col:i,row:r},n])))}return r.forEach((t=>this.restoreClipboardCells(e,t.values()))),n}addNamedExpression(e,t,r,n){const s=this.namedExpressions.addNamedExpression(e,r,n);this.storeNamedExpressionInCell(s.address,t),this.adjustNamedExpressionEdges(s,e,r)}restoreNamedExpression(e,t,r){const n=e.displayName;this.restoreCell(e.address,t);const s=this.namedExpressions.restoreNamedExpression(e,r);this.adjustNamedExpressionEdges(s,n,r)}changeNamedExpressionExpression(e,t,r,n){const s=this.namedExpressions.namedExpressionForScope(e,r);if(!s)throw new Et(e);const i=s.copy();s.options=n;const o=this.getClipboardCell(s.address);return this.storeNamedExpressionInCell(s.address,t),[i,o]}removeNamedExpression(e,t){const r=this.namedExpressions.namedExpressionForScope(e,t);if(!r)throw new Et(e);this.namedExpressions.remove(r.displayName,t);const n=this.getClipboardCell(r.address);if(void 0!==t){const t=this.namedExpressions.workbookNamedExpressionOrPlaceholder(e);this.dependencyGraph.exchangeNode(r.address,t.address)}else this.dependencyGraph.setCellEmpty(r.address);return[r,n]}ensureItIsPossibleToMoveCells(e,t,r,n){if(Or(e)||!(Vs(t)&&Vs(r)||function(e,t,r){return 0===e.row&&Vs(t)&&r===Number.POSITIVE_INFINITY||0===e.col&&Vs(r)&&t===Number.POSITIVE_INFINITY}(e,t,r))||Or(n)||!this.sheetMapping.hasSheetWithId(e.sheet)||!this.sheetMapping.hasSheetWithId(n.sheet))throw new gt("a valid range of cells to move.");const s=Fr.spanFrom(e,t,r),i=Fr.spanFrom(n,t,r);if(i.exceedsSheetSizeLimits(this.maxColumns,this.maxRows))throw new ct;if(this.dependencyGraph.arrayMapping.isFormulaArrayInRange(s))throw new kt;if(this.dependencyGraph.arrayMapping.isFormulaArrayInRange(i))throw new Ht}restoreClipboardCells(e,t){const r=[];for(const[n,s]of t)if(this.restoreCell(n,s),s.type===ps.FORMULA){const{dependencies:t}=this.parser.fetchCachedResult(s.hash);r.push(...this.updateNamedExpressionsForTargetAddress(e,n,t))}return r}restoreCell(e,t){switch(t.type){case ps.VALUE:this.setValueToCell(t,e);break;case ps.FORMULA:this.setFormulaToCellFromCache(t.hash,e);break;case ps.EMPTY:this.setCellEmpty(e);break;case ps.PARSING_ERROR:this.setParsingErrorToCell(t.rawInput,t.errors,e)}}getOldContent(e){const t=this.dependencyGraph.getCell(e);if(void 0===t||t instanceof cr)return[e,{type:ps.EMPTY}];if(t instanceof dr)return[e,Object.assign({type:ps.VALUE},t.getValues())];if(t instanceof Gt)return[t.getAddress(this.lazilyTransformingAstService),{type:ps.FORMULA,hash:this.parser.computeHashFromAst(t.getFormula(this.lazilyTransformingAstService))}];if(t instanceof pr)return[e,{type:ps.PARSING_ERROR,rawInput:t.rawInput,errors:t.errors}];throw Error("Trying to copy unsupported type")}getClipboardCell(e){const t=this.dependencyGraph.getCell(e);if(void 0===t||t instanceof cr)return{type:ps.EMPTY};if(t instanceof dr)return Object.assign({type:ps.VALUE},t.getValues());if(t instanceof zt){const r=t.getArrayCellValue(e);return r===Ye?{type:ps.EMPTY}:{type:ps.VALUE,parsedValue:r,rawValue:t.getArrayCellRawValue(e)}}if(t instanceof $t)return{type:ps.FORMULA,hash:this.parser.computeHashFromAst(t.getFormula(this.lazilyTransformingAstService))};if(t instanceof pr)return{type:ps.PARSING_ERROR,rawInput:t.rawInput,errors:t.errors};throw Error("Trying to copy unsupported type")}getSheetClipboardCells(e){const t=this.dependencyGraph.getSheetHeight(e),r=this.dependencyGraph.getSheetWidth(e),n=new Array(t);for(let s=0;s0)this.setParsingErrorToCell(r.formula,s,e);else try{const r=this.arraySizePredictor.checkArraySize(n,e);if(r.width<=0||r.height<=0)throw Error("Incorrect array size");this.setFormulaToCell(e,r,t)}catch(t){if(!t.message)throw t;const n={type:F.InvalidRangeSize,message:"Invalid range size."};this.setParsingErrorToCell(r.formula,[n],e)}}else r instanceof cs.Empty?this.setCellEmpty(e):this.setValueToCell({parsedValue:r.value,rawValue:t},e);return n}setSheetContent(e,t){this.clearSheet(e);for(let r=0;r!Dr(e.address,t)))),this.changes.addAll(n),this.changes.addChange(e.parsedValue,t)}setCellEmpty(e){if(this.dependencyGraph.isArrayInternalCell(e))return;const t=this.dependencyGraph.getCellValue(e),r=this.dependencyGraph.setCellEmpty(e);this.columnSearch.remove(je(t),e),this.columnSearch.applyChanges(r.getChanges()),this.changes.addAll(r),this.changes.addChange(Ye,e)}setFormulaToCellFromCache(e,t){const{ast:r,hasVolatileFunction:n,hasStructuralChangeFunction:s,dependencies:i}=this.parser.fetchCachedResult(e),o=We(i,t),[a]=new Ns(t.sheet).transformSingleAst(r,t);this.parser.rememberNewAst(a);const l=o.filter((e=>e instanceof Be||(e instanceof Fr?!(Or(e.start)||Or(e.end)):!Or(e))));const h=this.arraySizePredictor.checkArraySize(r,t);this.dependencyGraph.setFormulaToCell(t,a,l,h,n,s)}rowEffectivelyNotInSheet(e,t){return e>=this.dependencyGraph.addressMapping.getHeight(t)}getAndClearContentChanges(){const e=this.changes;return this.changes=nt.empty(),e}forceApplyPostponedTransformations(){this.dependencyGraph.forceApplyPostponedTransformations()}doRemoveRows(e){if(this.rowEffectivelyNotInSheet(e.rowStart,e.sheet))return;const t=[];for(const[r]of this.dependencyGraph.entriesFromRowsSpan(e))t.push({address:r,cellType:this.getClipboardCell(r)});const{affectedArrays:r,contentChanges:n}=this.dependencyGraph.removeRows(e);this.columnSearch.applyChanges(n.getChanges());let s=0;return this.stats.measure(et.TRANSFORM_ASTS,(()=>{const t=new As(e);t.performEagerTransformations(this.dependencyGraph,this.parser),s=this.lazilyTransformingAstService.addTransformation(t)})),this.rewriteAffectedArrays(r),{version:s,removedCells:t,rowFrom:e.rowStart,rowCount:e.numberOfRows}}doRemoveColumns(e){if(this.columnEffectivelyNotInSheet(e.columnStart,e.sheet))return;const t=[];for(const[r]of this.dependencyGraph.entriesFromColumnsSpan(e))t.push({address:r,cellType:this.getClipboardCell(r)});const{affectedArrays:r,contentChanges:n}=this.dependencyGraph.removeColumns(e);this.columnSearch.applyChanges(n.getChanges()),this.columnSearch.removeColumns(e);let s=0;return this.stats.measure(et.TRANSFORM_ASTS,(()=>{const t=new bs(e);t.performEagerTransformations(this.dependencyGraph,this.parser),s=this.lazilyTransformingAstService.addTransformation(t)})),this.rewriteAffectedArrays(r),{version:s,removedCells:t,columnFrom:e.columnStart,columnCount:e.numberOfColumns}}doAddRows(e){if(this.rowEffectivelyNotInSheet(e.rowStart,e.sheet))return;const{affectedArrays:t}=this.dependencyGraph.addRows(e);this.stats.measure(et.TRANSFORM_ASTS,(()=>{const t=new Ts(e);t.performEagerTransformations(this.dependencyGraph,this.parser),this.lazilyTransformingAstService.addTransformation(t)})),this.rewriteAffectedArrays(t)}rewriteAffectedArrays(e){for(const t of e.values()){if(t.array.size.isRef)continue;const e=t.getFormula(this.lazilyTransformingAstService),r=t.getAddress(this.lazilyTransformingAstService),n=this.parser.computeHashFromAst(e);this.setFormulaToCellFromCache(n,r)}}doAddColumns(e){if(this.columnEffectivelyNotInSheet(e.columnStart,e.sheet))return;const{affectedArrays:t,contentChanges:r}=this.dependencyGraph.addColumns(e);this.columnSearch.addColumns(e),this.columnSearch.applyChanges(r.getChanges()),this.stats.measure(et.TRANSFORM_ASTS,(()=>{const t=new Ss(e);t.performEagerTransformations(this.dependencyGraph,this.parser),this.lazilyTransformingAstService.addTransformation(t)})),this.rewriteAffectedArrays(t)}columnEffectivelyNotInSheet(e,t){return e>=this.dependencyGraph.addressMapping.getWidth(t)}adjustNamedExpressionEdges(e,t,r){if(void 0===r)return;const{vertex:n,id:s}=this.dependencyGraph.fetchCellOrCreateEmpty(e.address),i=null!=s?s:this.dependencyGraph.graph.getNodeId(n),o=this.namedExpressions.workbookNamedExpressionOrPlaceholder(t),{vertex:a,id:l}=this.dependencyGraph.fetchCellOrCreateEmpty(o.address),h=null!=l?l:this.dependencyGraph.graph.getNodeId(a);for(const t of this.dependencyGraph.graph.adjacentNodes(a))if(t instanceof $t&&t.getAddress(this.lazilyTransformingAstService).sheet===r){const r=t.getFormula(this.lazilyTransformingAstService),n=t.getAddress(this.lazilyTransformingAstService),{dependencies:s}=this.parser.fetchCachedResultForAst(r);for(const r of We(s,n))r instanceof Be&&r.name.toLowerCase()===e.displayName.toLowerCase()&&(this.dependencyGraph.graph.removeEdge(h,t),this.dependencyGraph.graph.addEdge(i,t))}}storeNamedExpressionInCell(e,t){const r=this.cellContentParser.parse(t);if(r instanceof cs.Formula){const t=this.parser.parse(r.formula,Ar(-1,0,0));if(vs(t.ast))throw new Ft;const{ast:n,hasVolatileFunction:s,hasStructuralChangeFunction:i,dependencies:o}=t;this.dependencyGraph.setFormulaToCell(e,n,We(o,e),cn.scalar(),s,i)}else r instanceof cs.Empty?this.setCellEmpty(e):this.setValueToCell({parsedValue:r.value,rawValue:t},e)}updateNamedExpressionsForMovedCells(e,t,r,n){if(e.sheet===n.sheet)return[];const s=[],i=Fr.spanFrom(n,t,r);for(const t of i.addresses(this.dependencyGraph)){const r=this.addressMapping.fetchCell(t);if(r instanceof $t&&t.sheet!==e.sheet){const n=r.getFormula(this.lazilyTransformingAstService),{dependencies:i}=this.parser.fetchCachedResultForAst(n);s.push(...this.updateNamedExpressionsForTargetAddress(e.sheet,t,i))}}return s}updateNamedExpressionsForTargetAddress(e,t,r){if(e===t.sheet)return[];const n=[],s=this.addressMapping.fetchCell(t);for(const i of We(r,t)){if(!(i instanceof Be))continue;const r=i.name,o=this.dependencyGraph.fetchNamedExpressionVertex(r,e).vertex,a=this.namedExpressions.isExpressionInScope(r,t.sheet)?this.dependencyGraph.fetchNamedExpressionVertex(r,t.sheet).vertex:this.copyOrFetchGlobalNamedExpressionVertex(r,o,n);a!==o&&(this.dependencyGraph.graph.removeEdgeIfExists(o,s),this.dependencyGraph.graph.addEdge(a,s))}return n}allocateNamedExpressionAddressSpace(){this.dependencyGraph.addressMapping.addSheet(Cs.SHEET_FOR_WORKBOOK_EXPRESSIONS,new gr(0,0))}copyOrFetchGlobalNamedExpressionVertex(e,t,r){let n=this.namedExpressions.namedExpressionForScope(e);if(void 0===n)if(n=this.namedExpressions.addNamedExpression(e),r.push(n.normalizeExpressionName()),t instanceof $t){const e=this.parser.fetchCachedResultForAst(t.getFormula(this.lazilyTransformingAstService)),{ast:r,hasVolatileFunction:s,hasStructuralChangeFunction:i,dependencies:o}=e;this.dependencyGraph.setFormulaToCell(n.address,r,We(o,n.address),cn.scalar(),s,i)}else t instanceof cr?this.setCellEmpty(n.address):t instanceof dr&&this.setValueToCell(t.getValues(),n.address);return this.dependencyGraph.fetchCellOrCreateEmpty(n.address).vertex}}function Fs(e){if(e.length<=1)return e;const t=[...e].sort((([e],[t])=>e-t)),r=t.reduce(((e,[t,r])=>{const n=e[e.length-1],s=n[0]+n[1];return t<=s?n[1]+=Math.max(0,r-(s-t)):e.push([t,r]),e}),[t[0]]);let n=0;for(let e=0;ee-t)),r=t.reduce(((e,[t,r])=>{const n=e[e.length-1];return t===n[0]?n[1]=Math.max(n[1],r):e.push([t,r]),e}),[t[0]]);let n=0;for(let e=0;e0} +/** + * @license + * Copyright (c) 2024 Handsoncode. All rights reserved. + */ +class Bs{}class Ws extends Bs{constructor(e,t){super(),this.command=e,this.rowsRemovals=t}doUndo(e){e.undoRemoveRows(this)}doRedo(e){e.redoRemoveRows(this)}}class Ys extends Bs{constructor(e,t,r,n,s,i,o){super(),this.sourceLeftCorner=e,this.width=t,this.height=r,this.destinationLeftCorner=n,this.overwrittenCellsData=s,this.addedGlobalNamedExpressions=i,this.version=o}doUndo(e){e.undoMoveCells(this)}doRedo(e){e.redoMoveCells(this)}}class js extends Bs{constructor(e){super(),this.command=e}doUndo(e){e.undoAddRows(this)}doRedo(e){e.redoAddRows(this)}}class Gs extends Bs{constructor(e,t,r){super(),this.sheetId=e,this.rowMapping=t,this.oldContent=r}doUndo(e){e.undoSetRowOrder(this)}doRedo(e){e.redoSetRowOrder(this)}}class zs extends Bs{constructor(e,t,r){super(),this.sheetId=e,this.columnMapping=t,this.oldContent=r}doUndo(e){e.undoSetColumnOrder(this)}doRedo(e){e.redoSetColumnOrder(this)}}class $s extends Bs{constructor(e,t,r){super(),this.sheetId=e,this.oldSheetContent=t,this.newSheetContent=r}doUndo(e){e.undoSetSheetContent(this)}doRedo(e){e.redoSetSheetContent(this)}}class Ks extends Bs{constructor(e,t,r,n,s){super(),this.sheet=e,this.startRow=t,this.numberOfRows=r,this.targetRow=n,this.version=s,this.undoStart=this.startRowthis.targetRow?this.startRow+this.numberOfRows:this.startRow}doUndo(e){e.undoMoveRows(this)}doRedo(e){e.redoMoveRows(this)}}class Xs extends Bs{constructor(e,t,r,n,s){super(),this.sheet=e,this.startColumn=t,this.numberOfColumns=r,this.targetColumn=n,this.version=s,this.undoStart=this.startColumnthis.targetColumn?this.startColumn+this.numberOfColumns:this.startColumn}doUndo(e){e.undoMoveColumns(this)}doRedo(e){e.redoMoveColumns(this)}}class qs extends Bs{constructor(e){super(),this.command=e}doUndo(e){e.undoAddColumns(this)}doRedo(e){e.redoAddColumns(this)}}class Qs extends Bs{constructor(e,t){super(),this.command=e,this.columnsRemovals=t}doUndo(e){e.undoRemoveColumns(this)}doRedo(e){e.redoRemoveColumns(this)}}class Zs extends Bs{constructor(e){super(),this.sheetName=e}doUndo(e){e.undoAddSheet(this)}doRedo(e){e.redoAddSheet(this)}}class Js extends Bs{constructor(e,t,r,n,s){super(),this.sheetName=e,this.sheetId=t,this.oldSheetContent=r,this.scopedNamedExpressions=n,this.version=s}doUndo(e){e.undoRemoveSheet(this)}doRedo(e){e.redoRemoveSheet(this)}}class ei extends Bs{constructor(e,t,r){super(),this.sheetId=e,this.oldName=t,this.newName=r}doUndo(e){e.undoRenameSheet(this)}doRedo(e){e.redoRenameSheet(this)}}class ti extends Bs{constructor(e,t){super(),this.sheetId=e,this.oldSheetContent=t}doUndo(e){e.undoClearSheet(this)}doRedo(e){e.redoClearSheet(this)}}class ri extends Bs{constructor(e){super(),this.cellContents=e}doUndo(e){e.undoSetCellContents(this)}doRedo(e){e.redoSetCellContents(this)}}class ni extends Bs{constructor(e,t,r,n){super(),this.targetLeftCorner=e,this.oldContent=t,this.newContent=r,this.addedGlobalNamedExpressions=n}doUndo(e){e.undoPaste(this)}doRedo(e){e.redoPaste(this)}}class si extends Bs{constructor(e,t,r,n){super(),this.name=e,this.newContent=t,this.scope=r,this.options=n}doUndo(e){e.undoAddNamedExpression(this)}doRedo(e){e.redoAddNamedExpression(this)}}class ii extends Bs{constructor(e,t,r){super(),this.namedExpression=e,this.content=t,this.scope=r}doUndo(e){e.undoRemoveNamedExpression(this)}doRedo(e){e.redoRemoveNamedExpression(this)}}class oi extends Bs{constructor(e,t,r,n,s){super(),this.namedExpression=e,this.newContent=t,this.oldContent=r,this.scope=n,this.options=s}doUndo(e){e.undoChangeNamedExpression(this)}doRedo(e){e.redoChangeNamedExpression(this)}}class ai extends Bs{constructor(){super(...arguments),this.operations=[]}add(e){this.operations.push(e)}*reversedOperations(){for(let e=this.operations.length-1;e>=0;e--)yield this.operations[e]}doUndo(e){e.undoBatch(this)}doRedo(e){e.redoBatch(this)}}class li{constructor(e,t){this.operations=t,this.oldData=new Map,this.undoStack=[],this.redoStack=[],this.undoLimit=e.undoLimit}saveOperation(e){void 0!==this.batchUndoEntry?this.batchUndoEntry.add(e):this.addUndoEntry(e)}beginBatchMode(){this.batchUndoEntry=new ai}commitBatchMode(){if(void 0===this.batchUndoEntry)throw Error("Batch mode wasn't started");this.addUndoEntry(this.batchUndoEntry),this.batchUndoEntry=void 0}storeDataForVersion(e,t,r){this.oldData.has(e)||this.oldData.set(e,[]);this.oldData.get(e).push([t,r])}clearRedoStack(){this.redoStack=[]}clearUndoStack(){this.undoStack=[]}isUndoStackEmpty(){return 0===this.undoStack.length}isRedoStackEmpty(){return 0===this.redoStack.length}undo(){const e=this.undoStack.pop();if(!e)throw Error("Attempted to undo without operation on stack");this.undoEntry(e),this.redoStack.push(e)}undoBatch(e){for(const t of e.reversedOperations())this.undoEntry(t)}undoRemoveRows(e){this.operations.forceApplyPostponedTransformations();const{command:{sheet:t},rowsRemovals:r}=e;for(let e=r.length-1;e>=0;--e){const n=r[e];this.operations.addRows(new Ls(t,[[n.rowFrom,n.rowCount]]));for(const{address:e,cellType:t}of n.removedCells)this.operations.restoreCell(e,t);this.restoreOldDataFromVersion(n.version-1)}}undoRemoveColumns(e){this.operations.forceApplyPostponedTransformations();const{command:{sheet:t},columnsRemovals:r}=e;for(let e=r.length-1;e>=0;--e){const n=r[e];this.operations.addColumns(new Ds(t,[[n.columnFrom,n.columnCount]]));for(const{address:e,cellType:t}of n.removedCells)this.operations.restoreCell(e,t);this.restoreOldDataFromVersion(n.version-1)}}undoAddRows(e){const t=e.command.rowsSpans();for(let r=t.length-1;r>=0;--r){const n=t[r];this.operations.removeRows(new Ps(e.command.sheet,[[n.rowStart,n.numberOfRows]]))}}undoAddColumns(e){const t=e.command.columnsSpans();for(let r=t.length-1;r>=0;--r){const n=t[r];this.operations.removeColumns(new ks(e.command.sheet,[[n.columnStart,n.numberOfColumns]]))}}undoSetCellContents(e){for(const t of e.cellContents){const e=t.address,[r,n]=t.oldContent;Dr(e,r)||this.operations.setCellEmpty(e),this.operations.restoreCell(r,n)}}undoPaste(e){this.restoreOperationOldContent(e.oldContent);for(const t of e.addedGlobalNamedExpressions)this.operations.removeNamedExpression(t)}undoMoveRows(e){const{sheet:t}=e;this.operations.moveRows(t,e.undoStart,e.numberOfRows,e.undoEnd),this.restoreOldDataFromVersion(e.version-1)}undoMoveColumns(e){const{sheet:t}=e;this.operations.moveColumns(t,e.undoStart,e.numberOfColumns,e.undoEnd),this.restoreOldDataFromVersion(e.version-1)}undoMoveCells(e){this.operations.forceApplyPostponedTransformations(),this.operations.moveCells(e.destinationLeftCorner,e.width,e.height,e.sourceLeftCorner),this.restoreOperationOldContent(e.overwrittenCellsData),this.restoreOldDataFromVersion(e.version-1);for(const t of e.addedGlobalNamedExpressions)this.operations.removeNamedExpression(t)}undoAddSheet(e){const{sheetName:t}=e;this.operations.removeSheetByName(t)}undoRemoveSheet(e){this.operations.forceApplyPostponedTransformations();const{oldSheetContent:t,sheetId:r}=e;this.operations.addSheet(e.sheetName);for(let e=0;ee[1])).reduce(((e,t)=>e+t),0)>this.maxRows)throw new ct;for(const[e,r]of t)if(!ci(e)||!ui(r))throw new gt("row number to be nonnegative and number of rows to add to be positive.")}ensureItIsPossibleToRemoveRows(e,...t){for(const[r,n]of t){const t=r+n-1;if(!ci(r)||!ci(t))throw new gt("starting and ending row to be nonnegative.");if(te[1])).reduce(((e,t)=>e+t),0)>this.maxColumns)throw new ct;for(const[e,r]of t)if(!ci(e)||!ui(r))throw new gt("column number to be nonnegative and number of columns to add to be positive.")}ensureItIsPossibleToRemoveColumns(e,...t){for(const[r,n]of t){const t=r+n-1;if(!ci(r)||!ci(t))throw new gt("starting and ending column to be nonnegative.");if(t=t)throw new gt("a valid range of rows to move.");const o=this.dependencyGraph.getSheetWidth(e),a=Fr.spanFrom(s,o,r);if(this.dependencyGraph.arrayMapping.isFormulaArrayInRange(a))throw new kt;if(n>0&&this.dependencyGraph.arrayMapping.isFormulaArrayInAllRows(st.fromNumberOfRows(e,n-1,2)))throw new Ht}ensureItIsPossibleToMoveColumns(e,t,r,n){this.ensureItIsPossibleToAddColumns(e,[n,r]);const s=Ar(e,t,0),i=Ar(e,n,0);if(!this.sheetMapping.hasSheetWithId(e)||Or(s)||Or(i)||!ui(r)||n<=t+r&&n>=t)throw new gt("a valid range of columns to move.");const o=this.dependencyGraph.getSheetHeight(e),a=Fr.spanFrom(s,r,o);if(this.dependencyGraph.arrayMapping.isFormulaArrayInRange(a))throw new kt;if(n>0&&this.dependencyGraph.arrayMapping.isFormulaArrayInAllColumns(it.fromNumberOfColumns(e,n-1,2)))throw new Ht}ensureItIsPossibleToAddSheet(e){if(this.sheetMapping.hasSheetWithName(e))throw new ut(e)}ensureItIsPossibleToRenameSheet(e,t){if(!this.sheetMapping.hasSheetWithId(e))throw new lt(e);const r=this.sheetMapping.get(t);if(void 0!==r&&r!==e)throw new ut(t)}ensureItIsPossibleToChangeContent(e){if(Or(e))throw new pt(e);if(!this.sheetMapping.hasSheetWithId(e.sheet))throw new lt(e.sheet)}ensureItIsPossibleToChangeCellContents(e,t){const r=xs(t),n=Fr.spanFrom(e,r.width,r.height);this.ensureRangeInSizeLimits(n);for(const e of n.addresses(this.dependencyGraph))this.ensureItIsPossibleToChangeContent(e)}ensureItIsPossibleToChangeSheetContents(e,t){const r=xs(t),n=Fr.spanFrom(Ar(e,0,0),r.width,r.height);this.ensureRangeInSizeLimits(n)}ensureRangeInSizeLimits(e){if(e.exceedsSheetSizeLimits(this.maxColumns,this.maxRows))throw new ct}isThereSomethingToUndo(){return!this.undoRedo.isUndoStackEmpty()}isThereSomethingToRedo(){return!this.undoRedo.isRedoStackEmpty()}getAndClearContentChanges(){return this.operations.getAndClearContentChanges()}ensureScopeIdIsValid(e){if(void 0!==e&&!this.sheetMapping.hasSheetWithId(e))throw new lt(e)}validateRowOrColumnMapping(e,t,r){const n="row"===r?this.dependencyGraph.getSheetHeight(e):this.dependencyGraph.getSheetWidth(e),s=t.map((([e,t])=>e)).sort(((e,t)=>e-t)),i=t.map((([e,t])=>t)).sort(((e,t)=>e-t));for(let e=0;e=n)throw new gt(`${r} numbers to be nonnegative integers and less than sheet ${"row"===r?"height":"width"}.`);if(s[e]===s[e+1])throw new gt(`source ${r} numbers to be unique.`);if(s[e]!==i[e])throw new gt(`target ${r} numbers to be permutation of source ${r} numbers.`)}}ensureNamedExpressionNameIsValid(e,t){if(!this.namedExpressions.isNameValid(e))throw new yt(e);if(!this.namedExpressions.isNameAvailable(e,t))throw new mt(e)}ensureNamedExpressionIsValid(e){const t=this.cellContentParser.parse(e);if(t instanceof cs.Formula){const e=this.parser.parse(t.formula,Ar(-1,0,0));if(vs(e.ast))throw new Ft}}}function ui(e){return Number.isInteger(e)&&e>0}function ci(e){return Number.isInteger(e)&&e>=0} +/** + * @license + * Copyright (c) 2024 Handsoncode. All rights reserved. + */ +class di{constructor(e,t,r,n,s,i){this.config=e,this.stats=t,this.interpreter=r,this.lazilyTransformingAstService=n,this.dependencyGraph=s,this.columnSearch=i}run(){this.stats.start(et.TOP_SORT);const{sorted:e,cycled:t}=this.dependencyGraph.topSortWithScc();this.stats.end(et.TOP_SORT),this.stats.measure(et.EVALUATION,(()=>{this.recomputeFormulas(t,e)}))}partialRun(e){const t=nt.empty();return this.stats.measure(et.EVALUATION,(()=>{this.dependencyGraph.graph.getTopSortedWithSccSubgraphFrom(e,(e=>{if(e instanceof Gt){const r=e.isComputed()?e.getCellValue():void 0,n=this.recomputeFormulaVertexValue(e);if(n!==r){const s=e.getAddress(this.lazilyTransformingAstService);return t.addChange(n,s),this.columnSearch.change(je(r),je(n),s),!0}return!1}return!(e instanceof Kt)||(e.clearCache(),!0)}),(e=>{if(e instanceof Kt)e.clearCache();else if(e instanceof Gt){const r=e.getAddress(this.lazilyTransformingAstService);this.columnSearch.remove(je(e.valueOrUndef()),r);const n=new Tr(ir.CYCLE,void 0,e);e.setCellValue(n),t.addChange(n,r)}}))})),t}runAndForget(e,t,r){const n=[];for(const e of We(r,t))if(e instanceof Fr){const t=e;if(void 0===this.dependencyGraph.getRange(t.start,t.end)){const e=new Kt(t);this.dependencyGraph.rangeMapping.setRange(e),n.push(e)}}const s=this.evaluateAstToCellValue(e,new Br(t,this.config.useArrayArithmetic));return n.forEach((e=>{this.dependencyGraph.rangeMapping.removeRange(e)})),s}recomputeFormulas(e,t){e.forEach((e=>{e instanceof Gt&&e.setCellValue(new Tr(ir.CYCLE,void 0,e))})),t.forEach((e=>{if(e instanceof Gt){const t=this.recomputeFormulaVertexValue(e),r=e.getAddress(this.lazilyTransformingAstService);this.columnSearch.add(je(t),r)}else e instanceof Kt&&e.clearCache()}))}recomputeFormulaVertexValue(e){const t=e.getAddress(this.lazilyTransformingAstService);if(e instanceof zt&&(e.array.size.isRef||!this.dependencyGraph.isThereSpaceForArray(e)))return e.setNoSpace();{const r=e.getFormula(this.lazilyTransformingAstService),n=this.evaluateAstToCellValue(r,new Br(t,this.config.useArrayArithmetic,e));return e.setCellValue(n)}}evaluateAstToCellValue(e,t){const r=this.interpreter.evaluateAst(e,t);return r instanceof rt?r:r===Ye&&this.config.evaluateNullToZero?0:r}} +/** + * @license + * Copyright (c) 2024 Handsoncode. All rights reserved. + */ +class pi{constructor(e,t){this.address=e,this.newValue=t}get col(){return this.address.col}get row(){return this.address.row}get sheet(){return this.address.sheet}get value(){return this.newValue}}class gi{constructor(e,t){this.name=e,this.newValue=t}}class fi{constructor(e,t,r,n){this.config=e,this.namedExpressions=t,this.sheetIndexMapping=r,this.lazilyTransformingService=n}exportChange(e){const t=e.value,r=e.address;if(r.sheet===Cs.SHEET_FOR_WORKBOOK_EXPRESSIONS){const e=this.namedExpressions.namedExpressionInAddress(r.row);if(!e)throw new Error("Missing named expression");return new gi(e.displayName,this.exportScalarOrRange(t))}if(t instanceof rt){const e=[];for(const[n,s]of t.entriesFromTopLeftCorner(r))e.push(new pi(s,this.exportValue(n)));return e}return new pi(r,this.exportValue(t))}exportValue(e){return e instanceof rt?this.detailedError(new Tr(ir.VALUE,Z.ScalarExpected)):this.config.smartRounding&&Ze(e)?this.cellValueRounding(je(e)):e instanceof Tr?this.detailedError(e):e===Ye?null:je(e)}exportScalarOrRange(e){return e instanceof rt?e.rawData().map((e=>e.map((e=>this.exportValue(e))))):this.exportValue(e)}detailedError(e){var t,r;let n;const s=null===(t=e.root)||void 0===t?void 0:t.getAddress(this.lazilyTransformingService);return void 0!==s&&(n=s.sheet===Cs.SHEET_FOR_WORKBOOK_EXPRESSIONS?null===(r=this.namedExpressions.namedExpressionInAddress(s.row))||void 0===r?void 0:r.displayName:I(this.sheetIndexMapping,s,-1)),new pn(e,this.config.translationPackage.getErrorTranslation(e.type),n)}cellValueRounding(e){if(0===e)return e;const t=Math.floor(Math.log10(Math.abs(e))),r=Math.pow(10,this.config.precisionRounding-t);return e<0?-Math.round(-e*r)/r:Math.round(e*r)/r}} +/** + * @license + * Copyright (c) 2024 Handsoncode. All rights reserved. + */ +class mi{constructor(e,t,r,n,s,i){this.dependencyGraph=e,this.columnSearch=t,this.parser=r,this.cellContentParser=n,this.stats=s,this.arraySizePredictor=i,this.buildStrategy=new yi(e,t,r,s,n,i)}buildGraph(e,t){const r=t.measure(et.COLLECT_DEPENDENCIES,(()=>this.buildStrategy.run(e)));this.dependencyGraph.getAndClearContentChanges(),t.measure(et.PROCESS_DEPENDENCIES,(()=>this.processDependencies(r)))}processDependencies(e){e.forEach(((e,t)=>{this.dependencyGraph.processCellDependencies(e,t)}))}}class yi{constructor(e,t,r,n,s,i){this.dependencyGraph=e,this.columnIndex=t,this.parser=r,this.stats=n,this.cellContentParser=s,this.arraySizePredictor=i}run(e){const t=new Map;for(const r in e){const n=this.dependencyGraph.getSheetId(r),s=e[r];for(let e=0;ethis.parser.parse(a.formula,o)));if(e.errors.length>0){this.shrinkArrayIfNeeded(o);const t=new pr(e.errors,a.formula);this.dependencyGraph.addVertex(o,t)}else{this.shrinkArrayIfNeeded(o);const r=this.arraySizePredictor.checkArraySize(e.ast,o);if(r.isScalar()){const r=new $t(e.ast,o,0);t.set(r,We(e.dependencies,o)),this.dependencyGraph.addVertex(o,r),e.hasVolatileFunction&&this.dependencyGraph.markAsVolatile(r),e.hasStructuralChangeFunction&&this.dependencyGraph.markAsDependentOnStructureChange(r)}else{const n=new zt(e.ast,o,new cn(r.width,r.height));t.set(n,We(e.dependencies,o)),this.dependencyGraph.addArrayVertex(o,n)}}}else if(a instanceof cs.Empty);else{this.shrinkArrayIfNeeded(o);const e=new dr(a.value,i);this.columnIndex.add(je(a.value),o),this.dependencyGraph.addVertex(o,e)}}}}return t}shrinkArrayIfNeeded(e){const t=this.dependencyGraph.getCell(e);t instanceof zt&&this.dependencyGraph.shrinkArrayToCorner(t)}} +/** + * @license + * Copyright (c) 2024 Handsoncode. All rights reserved. + */ +const Ei=new Map([["gpl-v3",1],["missing",2],["invalid",3],["expired",4]]);class wi extends un{version(e,t){return this.runFunction(e.args,t,this.metadata("VERSION"),(()=>{const{licenseKeyValidityState:e,licenseKey:t}=this.config;let r;return Ei.has(t)?r=Ei.get(t):Ei.has(e)?r=Ei.get(e):"valid"===e&&(r=t.slice(-5)),`HyperFormula v${zi.version}, ${r}`}))}} +/** + * @license + * Copyright (c) 2024 Handsoncode. All rights reserved. + */ +function Ci(e,t){var r;let n=t.implementedFunctions[e];const s=null===(r=t.aliases)||void 0===r?void 0:r[e];if(void 0!==s){if(void 0!==n)throw new Ut(e,t.name);n=t.implementedFunctions[s]}if(void 0===n)throw Lt.functionNotDeclaredInPlugin(e,t.name);return n}wi.implementedFunctions={VERSION:{method:"version",parameters:[]}};class vi{constructor(e){if(this.config=e,this.functions=new Map,this.arraySizeFunctions=new Map,this.volatileFunctions=new Set,this.arrayFunctions=new Set,this.structuralChangeFunctions=new Set,this.functionsWhichDoesNotNeedArgumentsToBeComputed=new Set,this.functionsMetadata=new Map,this.doesFunctionNeedArgumentToBeComputed=e=>this.functionsWhichDoesNotNeedArgumentsToBeComputed.has(e),this.isFunctionVolatile=e=>this.volatileFunctions.has(e),this.isArrayFunction=e=>this.arrayFunctions.has(e),this.isFunctionDependentOnSheetStructureChange=e=>this.structuralChangeFunctions.has(e),e.functionPlugins.length>0){this.instancePlugins=new Map;for(const t of e.functionPlugins)vi.loadPluginFunctions(t,this.instancePlugins)}else this.instancePlugins=new Map(vi.plugins);for(const[e,t]of vi.protectedFunctions())vi.loadFunctionUnprotected(t,e,this.instancePlugins);for(const[e,t]of this.instancePlugins.entries())this.categorizeFunction(e,Ci(e,t))}static registerFunctionPlugin(e,t){this.loadPluginFunctions(e,this.plugins),void 0!==t&&this.loadTranslations(t)}static registerFunction(e,t,r){this.loadPluginFunction(t,e,this.plugins),void 0!==r&&this.loadTranslations(r)}static unregisterFunction(e){if(this.functionIsProtected(e))throw Dt.cannotUnregisterFunctionWithId(e);this.plugins.delete(e)}static unregisterFunctionPlugin(e){for(const t of this.protectedPlugins())if(t===e)throw Dt.cannotUnregisterProtectedPlugin();for(const[t,r]of this.plugins.entries())r===e&&this.plugins.delete(t)}static unregisterAll(){this.plugins.clear()}static getRegisteredFunctionIds(){return[...Array.from(this.plugins.keys()),...Array.from(this._protectedPlugins.keys())]}static getPlugins(){return Array.from(new Set(this.plugins.values()).values())}static getFunctionPlugin(e){return this.functionIsProtected(e)?void 0:this.plugins.get(e)}static functionIsProtected(e){return this._protectedPlugins.has(e)}static loadTranslations(e){const t=new Set(zi.getRegisteredLanguagesCodes());Object.keys(e).forEach((r=>{t.has(r)&&zi.getLanguage(r).extendFunctions(e[r])}))}static loadPluginFunctions(e,t){Object.keys(e.implementedFunctions).forEach((r=>{this.loadPluginFunction(e,r,t)})),void 0!==e.aliases&&Object.keys(e.aliases).forEach((r=>{this.loadPluginFunction(e,r,t)}))}static loadPluginFunction(e,t,r){if(this.functionIsProtected(t))throw Dt.cannotRegisterFunctionWithId(t);this.loadFunctionUnprotected(e,t,r)}static loadFunctionUnprotected(e,t,r){const n=Ci(t,e).method;if(!Object.prototype.hasOwnProperty.call(e.prototype,n))throw Lt.functionMethodNotFound(n,e.name);r.set(t,e)}static*protectedFunctions(){for(const[e,t]of this._protectedPlugins)void 0!==t&&(yield[e,t])}static*protectedPlugins(){for(const[,e]of this._protectedPlugins)void 0!==e&&(yield e)}initializePlugins(e){const t=[];for(const[r,n]of this.instancePlugins.entries()){let s=t.find((e=>e instanceof n));void 0===s&&(s=new n(e),t.push(s));const i=Ci(r,n),o=i.method;this.functions.set(r,[o,s]);const a=i.arraySizeMethod;void 0!==a&&this.arraySizeFunctions.set(r,[a,s])}}getFunctionPlugin(e){if(!vi.functionIsProtected(e))return this.instancePlugins.get(e)}getFunction(e){const t=this.functions.get(e);if(void 0!==t&&this.config.translationPackage.isFunctionTranslated(e)){const[e,r]=t;return(t,n)=>r[e](t,n)}}getArraySizeFunction(e){const t=this.arraySizeFunctions.get(e);if(void 0!==t&&this.config.translationPackage.isFunctionTranslated(e)){const[e,r]=t;return(t,n)=>r[e](t,n)}}getMetadata(e){return this.functionsMetadata.get(e)}getPlugins(){const e=new Set;for(const[t,r]of this.instancePlugins)vi.functionIsProtected(t)||e.add(r);return Array.from(e)}getRegisteredFunctionIds(){return Array.from(this.functions.keys())}categorizeFunction(e,t){t.isVolatile&&this.volatileFunctions.add(e),t.arrayFunction&&this.arrayFunctions.add(e),t.doesNotNeedArgumentsToBeComputed&&this.functionsWhichDoesNotNeedArgumentsToBeComputed.add(e),t.isDependentOnSheetStructureChange&&this.structuralChangeFunctions.add(e),this.functionsMetadata.set(e,t)}} +/** + * @license + * Copyright (c) 2024 Handsoncode. All rights reserved. + */ +var Ri;vi.plugins=new Map,vi._protectedPlugins=new Map([["VERSION",wi],["OFFSET",void 0]]),function(e){e.GREATER_THAN="GREATER_THAN",e.GREATER_THAN_OR_EQUAL="GREATER_THAN_OR_EQUAL",e.LESS_THAN="LESS_THAN",e.LESS_THAN_OR_EQUAL="LESS_THAN_OR_EQUAL",e.NOT_EQUAL="NOT_EQUAL",e.EQUAL="EQUAL"}(Ri||(Ri={}));const Si=(e,t)=>({operator:e,value:t});class Ti{constructor(e){var t,r,n,s;this.trueString=null!==(r=null===(t=e.translationPackage.getMaybeFunctionTranslation("TRUE"))||void 0===t?void 0:t.toLowerCase())&&void 0!==r?r:"true",this.falseString=null!==(s=null===(n=e.translationPackage.getMaybeFunctionTranslation("FALSE"))||void 0===n?void 0:n.toLowerCase())&&void 0!==s?s:"false"}fromCellValue(e,t){if("string"!=typeof e&&"boolean"!=typeof e&&"number"!=typeof e)return;const r=this.parseCriterion(e,t);return void 0!==r?{raw:e,lambda:Mi(r,t)}:void 0}parseCriterion(e,t){if("number"==typeof e||"boolean"==typeof e)return Si(Ri.EQUAL,e);if("string"==typeof e){const r=Ni.exec(e);let n,s;r?(s=function(e){switch(e){case">":return Ri.GREATER_THAN;case">=":return Ri.GREATER_THAN_OR_EQUAL;case"<":return Ri.LESS_THAN;case"<=":return Ri.LESS_THAN_OR_EQUAL;case"<>":return Ri.NOT_EQUAL;case"=":return Ri.EQUAL;default:return}}(r[1]),n=r[2]):(s=Ri.EQUAL,n=e);const i=t.coerceToMaybeNumber(n),o=n.toLowerCase()===this.trueString||n.toLowerCase()!==this.falseString&&void 0;if(void 0===s)return;if(""===n)return Si(s,null);if(void 0!==i)return Si(s,je(i));if(s===Ri.EQUAL||s===Ri.NOT_EQUAL)return Si(s,null!=o?o:n)}}}const Ni=/([<>=]+)(.*)/;const Mi=(e,t)=>{switch(e.operator){case Ri.GREATER_THAN:return"number"==typeof e.value?r=>"number"==typeof r&&t.floatCmp(r,e.value)>0:e=>!1;case Ri.GREATER_THAN_OR_EQUAL:return"number"==typeof e.value?r=>"number"==typeof r&&t.floatCmp(r,e.value)>=0:e=>!1;case Ri.LESS_THAN:return"number"==typeof e.value?r=>"number"==typeof r&&t.floatCmp(r,e.value)<0:e=>!1;case Ri.LESS_THAN_OR_EQUAL:return"number"==typeof e.value?r=>"number"==typeof r&&t.floatCmp(r,e.value)<=0:e=>!1;case Ri.EQUAL:return"number"==typeof e.value?r=>{if("number"==typeof r)return 0===t.floatCmp(r,e.value);if("string"==typeof r){if(""===r)return!1;const n=t.coerceToMaybeNumber(r);return void 0!==n&&0===t.floatCmp(n,e.value)}return!1}:"string"==typeof e.value?t.eqMatcherFunction(e.value):"boolean"==typeof e.value?t=>"boolean"==typeof t&&t===e.value:e=>e===Ye;case Ri.NOT_EQUAL:return"number"==typeof e.value?r=>{if("number"==typeof r)return 0!==t.floatCmp(r,e.value);if("string"==typeof r){if(""===r)return!0;const n=t.coerceToMaybeNumber(r);return void 0===n||0!==t.floatCmp(n,e.value)}return!0}:"string"==typeof e.value?t.neqMatcherFunction(e.value):"boolean"==typeof e.value?t=>"boolean"!=typeof t||t!==e.value:e=>e!==Ye}}; +/** + * @license + * Copyright (c) 2024 Handsoncode. All rights reserved. + */ +class _i{constructor(e,t,r,n,s,i,o,a,l,h){this.config=e,this.dependencyGraph=t,this.columnSearch=r,this.stats=n,this.arithmeticHelper=s,this.functionRegistry=i,this.namedExpressions=o,this.serialization=a,this.arraySizePredictor=l,this.dateTimeHelper=h,this.equalOp=(e,t)=>Ai(this.arithmeticHelper.eq,e,t),this.notEqualOp=(e,t)=>Ai(this.arithmeticHelper.neq,e,t),this.greaterThanOp=(e,t)=>Ai(this.arithmeticHelper.gt,e,t),this.lessThanOp=(e,t)=>Ai(this.arithmeticHelper.lt,e,t),this.greaterThanOrEqualOp=(e,t)=>Ai(this.arithmeticHelper.geq,e,t),this.lessThanOrEqualOp=(e,t)=>Ai(this.arithmeticHelper.leq,e,t),this.concatOp=(e,t)=>Ai(this.arithmeticHelper.concat,Xr(e),Xr(t)),this.plusOp=(e,t)=>Ai(this.arithmeticHelper.addWithEpsilon,this.arithmeticHelper.coerceScalarToNumberOrError(e),this.arithmeticHelper.coerceScalarToNumberOrError(t)),this.minusOp=(e,t)=>Ai(this.arithmeticHelper.subtract,this.arithmeticHelper.coerceScalarToNumberOrError(e),this.arithmeticHelper.coerceScalarToNumberOrError(t)),this.timesOp=(e,t)=>Ai(this.arithmeticHelper.multiply,this.arithmeticHelper.coerceScalarToNumberOrError(e),this.arithmeticHelper.coerceScalarToNumberOrError(t)),this.powerOp=(e,t)=>Ai(this.arithmeticHelper.pow,this.arithmeticHelper.coerceScalarToNumberOrError(e),this.arithmeticHelper.coerceScalarToNumberOrError(t)),this.divOp=(e,t)=>Ai(this.arithmeticHelper.divide,this.arithmeticHelper.coerceScalarToNumberOrError(e),this.arithmeticHelper.coerceScalarToNumberOrError(t)),this.unaryMinusOp=e=>bi(this.arithmeticHelper.unaryMinus,this.arithmeticHelper.coerceScalarToNumberOrError(e)),this.percentOp=e=>bi(this.arithmeticHelper.unaryPercent,this.arithmeticHelper.coerceScalarToNumberOrError(e)),this.unaryPlusOp=e=>this.arithmeticHelper.unaryPlus(e),this.functionRegistry.initializePlugins(this),this.criterionBuilder=new Ti(e)}evaluateAst(e,t){let r=this.evaluateAstWithoutPostprocessing(e,t);if(Ze(r)){if(Zr(je(r)))return new Tr(ir.NUM,Z.NaN);r=ze(r,Jr(je(r)))}return r instanceof rt&&1===r.height()&&1===r.width()&&([[r]]=r.data),function(e,t){if(e instanceof Tr&&void 0!==t)return e.attachRootVertex(t);return e}(r,t.formulaVertex)}evaluateAstWithoutPostprocessing(e,t){switch(e.type){case U.EMPTY:return Ye;case U.CELL_REFERENCE:{const r=e.reference.toSimpleCellAddress(t.formulaAddress);return Or(r)?new Tr(ir.REF,Z.BadRef):this.dependencyGraph.getCellValue(r)}case U.NUMBER:case U.STRING:return e.value;case U.CONCATENATE_OP:{const r=this.evaluateAst(e.left,t),n=this.evaluateAst(e.right,t);return this.binaryRangeWrapper(this.concatOp,r,n,t)}case U.EQUALS_OP:{const r=this.evaluateAst(e.left,t),n=this.evaluateAst(e.right,t);return this.binaryRangeWrapper(this.equalOp,r,n,t)}case U.NOT_EQUAL_OP:{const r=this.evaluateAst(e.left,t),n=this.evaluateAst(e.right,t);return this.binaryRangeWrapper(this.notEqualOp,r,n,t)}case U.GREATER_THAN_OP:{const r=this.evaluateAst(e.left,t),n=this.evaluateAst(e.right,t);return this.binaryRangeWrapper(this.greaterThanOp,r,n,t)}case U.LESS_THAN_OP:{const r=this.evaluateAst(e.left,t),n=this.evaluateAst(e.right,t);return this.binaryRangeWrapper(this.lessThanOp,r,n,t)}case U.GREATER_THAN_OR_EQUAL_OP:{const r=this.evaluateAst(e.left,t),n=this.evaluateAst(e.right,t);return this.binaryRangeWrapper(this.greaterThanOrEqualOp,r,n,t)}case U.LESS_THAN_OR_EQUAL_OP:{const r=this.evaluateAst(e.left,t),n=this.evaluateAst(e.right,t);return this.binaryRangeWrapper(this.lessThanOrEqualOp,r,n,t)}case U.PLUS_OP:{const r=this.evaluateAst(e.left,t),n=this.evaluateAst(e.right,t);return this.binaryRangeWrapper(this.plusOp,r,n,t)}case U.MINUS_OP:{const r=this.evaluateAst(e.left,t),n=this.evaluateAst(e.right,t);return this.binaryRangeWrapper(this.minusOp,r,n,t)}case U.TIMES_OP:{const r=this.evaluateAst(e.left,t),n=this.evaluateAst(e.right,t);return this.binaryRangeWrapper(this.timesOp,r,n,t)}case U.POWER_OP:{const r=this.evaluateAst(e.left,t),n=this.evaluateAst(e.right,t);return this.binaryRangeWrapper(this.powerOp,r,n,t)}case U.DIV_OP:{const r=this.evaluateAst(e.left,t),n=this.evaluateAst(e.right,t);return this.binaryRangeWrapper(this.divOp,r,n,t)}case U.PLUS_UNARY_OP:{const r=this.evaluateAst(e.value,t);return this.unaryRangeWrapper(this.unaryPlusOp,r,t)}case U.MINUS_UNARY_OP:{const r=this.evaluateAst(e.value,t);return this.unaryRangeWrapper(this.unaryMinusOp,r,t)}case U.PERCENT_OP:{const r=this.evaluateAst(e.value,t);return this.unaryRangeWrapper(this.percentOp,r,t)}case U.FUNCTION_CALL:{if("valid"!==this.config.licenseKeyValidityState&&!vi.functionIsProtected(e.procedureName))return new Tr(ir.LIC,Z.LicenseKey(this.config.licenseKeyValidityState));const r=this.functionRegistry.getFunction(e.procedureName);return void 0!==r?r(e,new Br(t.formulaAddress,t.arraysFlag||this.functionRegistry.isArrayFunction(e.procedureName),t.formulaVertex)):new Tr(ir.NAME,Z.FunctionName(e.procedureName))}case U.NAMED_EXPRESSION:{const r=this.namedExpressions.nearestNamedExpression(e.expressionName,t.formulaAddress.sheet);return r?this.dependencyGraph.getCellValue(r.address):new Tr(ir.NAME,Z.NamedExpressionName(e.expressionName))}case U.CELL_RANGE:{if(!this.rangeSpansOneSheet(e))return new Tr(ir.REF,Z.RangeManySheets);const r=Fr.fromCellRange(e,t.formulaAddress),n=this.dependencyGraph.getArray(r);if(n){const e=n.array;if(e instanceof Wt)throw new Error("Array should be already computed");if(e instanceof Tr)return e;if(e instanceof Yt)return rt.fromRange(e.raw(),r,this.dependencyGraph);throw new Error("Unknown array")}return rt.onlyRange(r,this.dependencyGraph)}case U.COLUMN_RANGE:{if(!this.rangeSpansOneSheet(e))return new Tr(ir.REF,Z.RangeManySheets);const r=Ur.fromColumnRange(e,t.formulaAddress);return rt.onlyRange(r,this.dependencyGraph)}case U.ROW_RANGE:{if(!this.rangeSpansOneSheet(e))return new Tr(ir.REF,Z.RangeManySheets);const r=Vr.fromRowRangeAst(e,t.formulaAddress);return rt.onlyRange(r,this.dependencyGraph)}case U.PARENTHESIS:return this.evaluateAst(e.expression,t);case U.ARRAY:{let r;const n=[];for(const s of e.args){let e;const i=[];for(const r of s){const n=Gr(this.evaluateAst(r,t)),s=n.height();if(void 0===e)e=s,i.push(...n.data);else{if(e!==s)return new Tr(ir.REF,Z.SizeMismatch);for(let e=0;et.map(e)));return rt.onlyValues(r)}return e(t)}binaryRangeWrapper(e,t,r,n){var s,i;if(t instanceof rt&&!n.arraysFlag&&(t=null!==(s=an(t,n))&&void 0!==s?s:new Tr(ir.VALUE,Z.ScalarExpected)),t instanceof Tr)return t;if(r instanceof rt&&!n.arraysFlag&&(r=null!==(i=an(r,n))&&void 0!==i?i:new Tr(ir.VALUE,Z.ScalarExpected)),r instanceof Tr)return r;if(t instanceof rt||r instanceof rt){if(!(t instanceof rt)){if(r.isAdHoc()){const n=r.data;for(let r=0;rr.performEagerTransformations(e,t)))}transformSingleAst(e,t){let[r,n]=[e,t];return this.transformations.forEach((e=>{[r,n]=e.transformSingleAst(r,n)})),[r,n]}isIrreversible(){return!0}} +/** + * @license + * Copyright (c) 2024 Handsoncode. All rights reserved. + */ +class Ii{constructor(e){this.stats=e,this.transformations=[]}version(){return this.transformations.length}addTransformation(e){return void 0!==this.combinedTransformer?this.combinedTransformer.add(e):this.transformations.push(e),this.version()}beginCombinedMode(e){this.combinedTransformer=new Oi(e)}commitCombinedMode(){if(void 0===this.combinedTransformer)throw Error("Combined mode wasn't started");return this.transformations.push(this.combinedTransformer),this.combinedTransformer=void 0,this.version()}applyTransformations(e,t,r){this.stats.start(et.TRANSFORM_ASTS_POSTPONED);for(let n=r;nt?1:0:e===Ye?-1:t===Ye?1:t instanceof Tr||"number"==typeof e&&"string"==typeof t||"number"==typeof e&&"boolean"==typeof t?-1:"string"==typeof e&&"number"==typeof t?1:"string"==typeof e&&"boolean"==typeof t?-1:1} +/** + * @license + * Copyright (c) 2024 Handsoncode. All rights reserved. + */ +class Di{constructor(e){this.dependencyGraph=e}advancedFind(e,t){let r;const n=t.range;r=void 0===n?t.valuesFromTopLeftCorner():this.dependencyGraph.computeListOfValuesInRange(n);for(let t=0;tje(i.getCellValue(Ar(t.sheet,e,t.start.row))):e=>je(i.getCellValue(Ar(t.sheet,t.start.col,e))),h="asc"===n?(e,t)=>Li(e,t):(e,t)=>-Li(e,t),u=Pi((t=>h(e,l(t))>=0),o,a),c=l(u);return u===xi||typeof c!=typeof e||s&&c!==e?xi:u-o}(i,o,{searchCoordinate:r,orderingDirection:n,matchExactly:s},this.dependencyGraph)}findNormalizedValue(e,t){return t.map(je).map((e=>"string"==typeof e?on(e):e)).indexOf(e)}} +/** + * @license + * Copyright (c) 2024 Handsoncode. All rights reserved. + */ +class ki extends Di{constructor(e){super(e),this.dependencyGraph=e}add(e,t){}remove(e,t){}change(e,t,r){}applyChanges(e){}addColumns(e){}removeColumns(e){}removeSheet(e){}moveValues(e,t,r,n){}removeValues(e){}find(e,t,r){return this.basicFind(e,t,"row",r)}} +/** + * @license + * Copyright (c) 2024 Handsoncode. All rights reserved. + */ +class Hi{constructor(e,t,r){this.dependencyGraph=e,this.config=t,this.stats=r,this.index=new Map,this.transformingService=this.dependencyGraph.lazilyTransformingAstService,this.binarySearchStrategy=new ki(e)}add(e,t){if(!(e===Ye||e instanceof Tr))if(e instanceof rt)for(const[r,n]of e.entriesFromTopLeftCorner(t))this.addSingleCellValue(je(r),n);else this.addSingleCellValue(e,t)}remove(e,t){if(void 0!==e)if(e instanceof rt)for(const[r,n]of e.entriesFromTopLeftCorner(t))this.removeSingleValue(je(r),n);else this.removeSingleValue(e,t)}change(e,t,r){e!==t&&(this.remove(e,r),this.add(t,r))}applyChanges(e){for(const t of e)void 0!==t.oldValue&&this.change(je(t.oldValue),je(t.value),t.address)}moveValues(e,t,r,n){for(const[s,i]of e){const e=Ir(i,n,t,r);this.remove(s,i),this.add(s,e)}}removeValues(e){for(const[t,r]of e)this.remove(t,r)}find(e,t,{ordering:r,matchExactly:n}){const s=!0===n?"findFirst":"findLast",i=this.findUsingColumnIndex(e,t,s);return void 0!==i?i:this.binarySearchStrategy.find(e,t,{ordering:r,matchExactly:n})}findUsingColumnIndex(e,t,r){const n=t.range;if(void 0===n)return;this.ensureRecentData(n.sheet,n.start.col,e);const s=this.getColumnMap(n.sheet,n.start.col);if(!s)return-1;const i="string"==typeof e?on(e):e,o=s.get(i);if(!o||!o.index||0===o.index.length)return;const a=Hi.findRowBelongingToRange(o,n,r);return void 0!==a?a-n.start.row:void 0}static findRowBelongingToRange(e,t,r){const n=t.start.row,s=t.end.row,i="findFirst"===r?Fi(n,e.index,"upperBound"):Fi(s,e.index,"lowerBound");if(-1===i)return;const o=e.index[i];return o>=n&&o<=s?o:void 0}advancedFind(e,t){return this.binarySearchStrategy.advancedFind(e,t)}addColumns(e){const t=this.index.get(e.sheet);t&&t.splice(e.columnStart,0,...Array(e.numberOfColumns))}removeColumns(e){const t=this.index.get(e.sheet);t&&t.splice(e.columnStart,e.numberOfColumns)}removeSheet(e){this.index.delete(e)}getColumnMap(e,t){this.index.has(e)||this.index.set(e,[]);const r=this.index.get(e);let n=r[t];return n||(n=new Map,r[t]=n),n}getValueIndex(e,t,r){const n=this.getColumnMap(e,t);let s=this.getColumnMap(e,t).get(r);return s||(s={version:this.transformingService.version(),index:[]},n.set(r,s)),s}ensureRecentData(e,t,r){const n=this.getValueIndex(e,t,r),s=this.transformingService.version();if(n.version===s)return;const i=this.transformingService.getTransformationsFrom(n.version,(t=>t.sheet===e&&(t instanceof Ts||t instanceof As)));for(const e of i)e instanceof Ts?this.addRows(t,e.rowsSpan,r):e instanceof As&&this.removeRows(t,e.rowsSpan,r);n.version=s}addSingleCellValue(e,t){this.stats.measure(et.BUILD_COLUMN_INDEX,(()=>{this.ensureRecentData(t.sheet,t.col,e),"string"==typeof e&&(e=on(e));const r=this.getValueIndex(t.sheet,t.col,e);Hi.addValue(r,t.row)}))}removeSingleValue(e,t){this.stats.measure(et.BUILD_COLUMN_INDEX,(()=>{this.ensureRecentData(t.sheet,t.col,e);const r=this.getColumnMap(t.sheet,t.col);"string"==typeof e&&(e=on(e));const n=r.get(e);if(!n)return;const s=Fi(t.row,n.index);s>-1&&n.index.splice(s,1),0===n.index.length&&r.delete(e),0===r.size&&delete this.index.get(t.sheet)[t.col]}))}addRows(e,t,r){const n=this.getValueIndex(t.sheet,e,r);Hi.shiftRows(n,t.rowStart,t.numberOfRows)}removeRows(e,t,r){const n=this.getValueIndex(t.sheet,e,r);Hi.removeRowsFromValues(n,t),Hi.shiftRows(n,t.rowEnd+1,-t.numberOfRows)}static addValue(e,t){const r=Fi(t,e.index,"lowerBound");e.index[r]===t||e.index.splice(r+1,0,t)}static removeRowsFromValues(e,t){const r=Fi(t.rowStart,e.index,"upperBound"),n=Fi(t.rowEnd,e.index,"lowerBound");r>-1&&n>-1&&r<=n&&e.index[r]<=t.rowEnd&&e.index.splice(r,n-r+1)}static shiftRows(e,t,r){const n=Fi(t,e.index,"upperBound");if(-1!==n)for(let t=n;tt[r])n=r+1;else{if(!(e=0&&i<=t.length?i:-1} +/** + * @license + * Copyright (c) 2024 Handsoncode. All rights reserved. + */ +class Ui{constructor(e){this.config=e;const t="."===this.config.thousandSeparator?`\\${this.config.thousandSeparator}`:this.config.thousandSeparator,r="."===this.config.decimalSeparator?`\\${this.config.decimalSeparator}`:this.config.decimalSeparator;this.numberPattern=new RegExp(`^([+-]?((${r}\\d+)|(\\d+(${t}\\d{3,})*(${r}\\d*)?)))(e[+-]?\\d+)?$`),this.allThousandSeparatorsRegex=new RegExp(`${t}`,"g")}numericStringToMaybeNumber(e){if(this.numberPattern.test(e)){const t=this.numericStringToNumber(e);if(isNaN(t))return;return t}}numericStringToNumber(e){const t=e.replace(this.allThousandSeparatorsRegex,"").replace(this.config.decimalSeparator,".");return Number(t)}} +/** + * @license + * Copyright (c) 2024 Handsoncode. All rights reserved. + */ +class Vi{constructor(e,t,r){this.dependencyGraph=e,this.unparser=t,this.exporter=r}getCellHyperlink(e){const t=this.dependencyGraph.getCell(e);if(t instanceof $t){const e=t.getFormula(this.dependencyGraph.lazilyTransformingAstService);if("HYPERLINK"===e.procedureName)return e.hyperlink}}getCellFormula(e,t){const r=this.dependencyGraph.getCell(e);if(r instanceof $t){const n=r.getFormula(this.dependencyGraph.lazilyTransformingAstService);return t=null!=t?t:e,this.unparser.unparse(n,t)}if(r instanceof zt){const n=r.getAddress(this.dependencyGraph.lazilyTransformingAstService);if(n.row!==e.row||n.col!==e.col||n.sheet!==e.sheet)return;t=null!=t?t:e;const s=r.getFormula(this.dependencyGraph.lazilyTransformingAstService);if(void 0!==s)return this.unparser.unparse(s,t)}else if(r instanceof pr)return r.getFormula()}getCellSerialized(e,t){var r;return null!==(r=this.getCellFormula(e,t))&&void 0!==r?r:this.getRawValue(e)}getCellValue(e){return this.exporter.exportValue(this.dependencyGraph.getScalarValue(e))}getRawValue(e){return this.dependencyGraph.getRawValue(e)}getSheetValues(e){return this.genericSheetGetter(e,(e=>this.getCellValue(e)))}getSheetFormulas(e){return this.genericSheetGetter(e,(e=>this.getCellFormula(e)))}genericSheetGetter(e,t){const r=this.dependencyGraph.getSheetHeight(e),n=this.dependencyGraph.getSheetWidth(e),s=new Array(r);for(let i=0;i=0&&(null===s[i][e]||void 0===s[i][e]);e--)s[i].pop()}for(let e=r-1;e>=0&&0===s[e].length;e--)s.pop();return s}genericAllSheetsGetter(e){const t={};for(const r of this.dependencyGraph.sheetMapping.displayNames()){const n=this.dependencyGraph.sheetMapping.fetch(r);t[r]=e(n)}return t}getSheetSerialized(e){return this.genericSheetGetter(e,(e=>this.getCellSerialized(e)))}getAllSheetsValues(){return this.genericAllSheetsGetter((e=>this.getSheetValues(e)))}getAllSheetsFormulas(){return this.genericAllSheetsGetter((e=>this.getSheetFormulas(e)))}getAllSheetsSerialized(){return this.genericAllSheetsGetter((e=>this.getSheetSerialized(e)))}getAllNamedExpressionsSerialized(){const e=[];let t=0;for(const r of this.dependencyGraph.sheetMapping.displayNames()){const n=this.dependencyGraph.sheetMapping.fetch(r);e[n]=t,t++}return this.dependencyGraph.namedExpressions.getAllNamedExpressions().map((t=>({name:t.expression.displayName,expression:this.getCellSerialized(t.expression.address),scope:void 0!==t.scope?e[t.scope]:void 0,options:t.expression.options})))}withNewConfig(e,t){const r=new xe(e,Ae(e),this.dependencyGraph.sheetMapping.fetchDisplayName,t);return new Vi(this.dependencyGraph,r,this.exporter)}} +/** + * @license + * Copyright (c) 2024 Handsoncode. All rights reserved. + */ +class Bi{static buildFromSheets(e,t={},r=[]){const n=new Ki(t);return this.buildEngine(n,e,r)}static buildFromSheet(e,t={},r=[]){const n=new Ki(t),s=n.translationPackage.getUITranslation(sr.NEW_SHEET_PREFIX)+"1";return this.buildEngine(n,{[s]:e},r)}static buildEmpty(e={},t=[]){return this.buildEngine(new Ki(e),{},t)}static rebuildWithConfig(e,t,r,n){return this.buildEngine(e,t,r,n)}static buildEngine(e,t={},r=[],n=(e.useStats?new ot:new at)){n.start(et.BUILD_ENGINE_TOTAL);const s=new Cs,i=new vi(e),o=new Ii(n),a=ur.buildEmpty(o,e,i,s,n),l= +/** + * @license + * Copyright (c) 2024 Handsoncode. All rights reserved. + */ +function(e,t,r){return t.useColumnIndex?new Hi(e,t,r):new ki(e)}(a,e,n),h=a.sheetMapping,u=a.addressMapping;for(const r in t)if(Object.prototype.hasOwnProperty.call(t,r)){const n=t[r];Is(n);const s=xs(n);if(s.height>e.maxRows||s.width>e.maxColumns)throw new ct;const i=h.addSheet(r);u.autoAddSheet(i,s)}const c=new Le(e,i,h.get);o.parser=c;const d=new xe(e,Ae(e),h.fetchDisplayName,s),p=new Hn(e),g=new Ui(e),f=new Yr(e,p,g),m=new gs(e,p,g),y=new dn(e,i),E=new Hs(e,a,l,m,c,n,o,s,y),w=new li(e,E);o.undoRedo=w;const C=new ms(e,a,E),v=new hi(e,E,w,C,a,l,c,m,o,s);r.forEach((e=>{v.ensureItIsPossibleToAddNamedExpression(e.name,e.expression,e.scope),v.operations.addNamedExpression(e.name,e.expression,e.scope,e.options)}));const R=new fi(e,s,h.fetchDisplayName,o),S=new Vi(a,d,R),T=new _i(e,a,l,n,f,i,s,S,y,p);n.measure(et.GRAPH_BUILD,(()=>{new mi(a,l,c,m,n,y).buildGraph(t,n)}));const N=new di(e,n,T,o,a,l);return N.run(),n.end(et.BUILD_ENGINE_TOTAL),{config:e,stats:n,dependencyGraph:a,columnSearch:l,parser:c,unparser:d,cellContentParser:m,evaluator:N,lazilyTransformingAstService:o,crudOperations:v,exporter:R,namedExpressions:s,serialization:S,functionRegistry:i}}}function Wi(e){return()=>{throw new Error(`The "${e}" method cannot be called because this HyperFormula instance has been destroyed`)}}var Yi,ji=r(23420);!function(e){e.SheetAdded="sheetAdded",e.SheetRemoved="sheetRemoved",e.SheetRenamed="sheetRenamed",e.NamedExpressionAdded="namedExpressionAdded",e.NamedExpressionRemoved="namedExpressionRemoved",e.ValuesUpdated="valuesUpdated",e.EvaluationSuspended="evaluationSuspended",e.EvaluationResumed="evaluationResumed"}(Yi||(Yi={}));class Gi extends ji.TinyEmitter{emit(e,...t){return super.emit(e,...t),this}} +/** + * @license + * Copyright (c) 2024 Handsoncode. All rights reserved. + */ +class zi{constructor(e,t,r,n,s,i,o,a,l,h,u,c,d,p){this._config=e,this._stats=t,this._dependencyGraph=r,this._columnSearch=n,this._parser=s,this._unparser=i,this._cellContentParser=o,this._evaluator=a,this._lazilyTransformingAstService=l,this._crudOperations=h,this._exporter=u,this._namedExpressions=c,this._serialization=d,this._functionRegistry=p,this._emitter=new Gi,this._evaluationSuspended=!1}static get defaultConfig(){return Xi({})}get graph(){return this.dependencyGraph.graph}get rangeMapping(){return this.dependencyGraph.rangeMapping}get arrayMapping(){return this.dependencyGraph.arrayMapping}get sheetMapping(){return this.dependencyGraph.sheetMapping}get addressMapping(){return this.dependencyGraph.addressMapping}get dependencyGraph(){return this._dependencyGraph}get evaluator(){return this._evaluator}get columnSearch(){return this._columnSearch}get lazilyTransformingAstService(){return this._lazilyTransformingAstService}get licenseKeyValidityState(){return this._config.licenseKeyValidityState}static buildFromArray(e,t={},r=[]){return this.buildFromEngineState(Bi.buildFromSheet(e,t,r))}static buildFromSheets(e,t={},r=[]){return this.buildFromEngineState(Bi.buildFromSheets(e,t,r))}static buildEmpty(e={},t=[]){return this.buildFromEngineState(Bi.buildEmpty(e,t))}static getLanguage(e){En(e,"string","languageCode");const t=this.registeredLanguages.get(e);if(void 0===t)throw new xt;return t}static registerLanguage(e,t){if(En(e,"string","languageCode"),this.registeredLanguages.has(e))throw new Pt;var r;this.registeredLanguages.set(e,(r=t,new nr(Object.assign({},r.functions),Object.assign({},r.errors),Object.assign({},r.ui))))}static unregisterLanguage(e){if(En(e,"string","languageCode"),!this.registeredLanguages.has(e))throw new xt;this.registeredLanguages.delete(e)}static getRegisteredLanguagesCodes(){return Array.from(this.registeredLanguages.keys())}static registerFunctionPlugin(e,t){vi.registerFunctionPlugin(e,t)}static unregisterFunctionPlugin(e){vi.unregisterFunctionPlugin(e)}static registerFunction(e,t,r){En(e,"string","functionId"),vi.registerFunction(e,t,r)}static unregisterFunction(e){En(e,"string","functionId"),vi.unregisterFunction(e)}static unregisterAllFunctions(){vi.unregisterAll()}static getRegisteredFunctionNames(e){En(e,"string","code");const t=vi.getRegisteredFunctionIds();return this.getLanguage(e).getFunctionTranslations(t)}static getFunctionPlugin(e){return En(e,"string","functionId"),vi.getFunctionPlugin(e)}static getAllFunctionPlugins(){return vi.getPlugins()}static buildFromEngineState(e){return new zi(e.config,e.stats,e.dependencyGraph,e.columnSearch,e.parser,e.unparser,e.cellContentParser,e.evaluator,e.lazilyTransformingAstService,e.crudOperations,e.exporter,e.namedExpressions,e.serialization,e.functionRegistry)}getCellValue(e){if(!Pr(e))throw new Tt("SimpleCellAddress","cellAddress");return this.ensureEvaluationIsNotSuspended(),this._serialization.getCellValue(e)}getCellFormula(e){if(!Pr(e))throw new Tt("SimpleCellAddress","cellAddress");return this._serialization.getCellFormula(e)}getCellHyperlink(e){if(!Pr(e))throw new Tt("SimpleCellAddress","cellAddress");return this.ensureEvaluationIsNotSuspended(),this._serialization.getCellHyperlink(e)}getCellSerialized(e){if(!Pr(e))throw new Tt("SimpleCellAddress","cellAddress");return this.ensureEvaluationIsNotSuspended(),this._serialization.getCellSerialized(e)}getSheetValues(e){return En(e,"number","sheetId"),this.ensureEvaluationIsNotSuspended(),this._serialization.getSheetValues(e)}getSheetFormulas(e){return En(e,"number","sheetId"),this._serialization.getSheetFormulas(e)}getSheetSerialized(e){return En(e,"number","sheetId"),this.ensureEvaluationIsNotSuspended(),this._serialization.getSheetSerialized(e)}getAllSheetsDimensions(){return this._serialization.genericAllSheetsGetter((e=>this.getSheetDimensions(e)))}getSheetDimensions(e){return En(e,"number","sheetId"),{width:this.dependencyGraph.getSheetWidth(e),height:this.dependencyGraph.getSheetHeight(e)}}getAllSheetsValues(){return this.ensureEvaluationIsNotSuspended(),this._serialization.getAllSheetsValues()}getAllSheetsFormulas(){return this._serialization.getAllSheetsFormulas()}getAllSheetsSerialized(){return this.ensureEvaluationIsNotSuspended(),this._serialization.getAllSheetsSerialized()}updateConfig(e){Object.entries(e).every((([e,t])=>this._config[e]===t))||this.rebuildWithConfig(e)}getConfig(){return this._config.getConfig()}rebuildAndRecalculate(){this.rebuildWithConfig({})}getStats(){return this._stats.snapshot()}undo(){return this._crudOperations.undo(),this.recomputeIfDependencyGraphNeedsIt()}redo(){return this._crudOperations.redo(),this.recomputeIfDependencyGraphNeedsIt()}isThereSomethingToUndo(){return this._crudOperations.isThereSomethingToUndo()}isThereSomethingToRedo(){return this._crudOperations.isThereSomethingToRedo()}isItPossibleToSetCellContents(e){let t;if(Pr(e))t=new Fr(e,e);else{if(!kr(e))throw new Tt("SimpleCellAddress | SimpleCellRange","address");t=new Fr(e.start,e.end)}try{this._crudOperations.ensureRangeInSizeLimits(t);for(const e of t.addresses(this._dependencyGraph))this._crudOperations.ensureItIsPossibleToChangeContent(e)}catch(e){return!1}return!0}setCellContents(e,t){return this._crudOperations.setCellContents(e,t),this.recomputeIfDependencyGraphNeedsIt()}swapRowIndexes(e,t){return En(e,"number","sheetId"),this._crudOperations.setRowOrder(e,t),this.recomputeIfDependencyGraphNeedsIt()}isItPossibleToSwapRowIndexes(e,t){En(e,"number","sheetId");try{return this._crudOperations.validateSwapRowIndexes(e,t),this._crudOperations.testRowOrderForArrays(e,t),!0}catch(e){return!1}}setRowOrder(e,t){En(e,"number","sheetId");const r=this._crudOperations.mappingFromOrder(e,t,"row");return this.swapRowIndexes(e,r)}isItPossibleToSetRowOrder(e,t){En(e,"number","sheetId");try{const r=this._crudOperations.mappingFromOrder(e,t,"row");return this._crudOperations.validateSwapRowIndexes(e,r),this._crudOperations.testRowOrderForArrays(e,r),!0}catch(e){return!1}}swapColumnIndexes(e,t){return En(e,"number","sheetId"),this._crudOperations.setColumnOrder(e,t),this.recomputeIfDependencyGraphNeedsIt()}isItPossibleToSwapColumnIndexes(e,t){En(e,"number","sheetId");try{return this._crudOperations.validateSwapColumnIndexes(e,t),this._crudOperations.testColumnOrderForArrays(e,t),!0}catch(e){return!1}}setColumnOrder(e,t){En(e,"number","sheetId");const r=this._crudOperations.mappingFromOrder(e,t,"column");return this.swapColumnIndexes(e,r)}isItPossibleToSetColumnOrder(e,t){En(e,"number","sheetId");try{const r=this._crudOperations.mappingFromOrder(e,t,"column");return this._crudOperations.validateSwapColumnIndexes(e,r),this._crudOperations.testColumnOrderForArrays(e,r),!0}catch(e){return!1}}isItPossibleToAddRows(e,...t){En(e,"number","sheetId");const r=Us(t);try{return this._crudOperations.ensureItIsPossibleToAddRows(e,...r),!0}catch(e){return!1}}addRows(e,...t){return En(e,"number","sheetId"),this._crudOperations.addRows(e,...t),this.recomputeIfDependencyGraphNeedsIt()}isItPossibleToRemoveRows(e,...t){En(e,"number","sheetId");const r=Fs(t);try{return this._crudOperations.ensureItIsPossibleToRemoveRows(e,...r),!0}catch(e){return!1}}removeRows(e,...t){return En(e,"number","sheetId"),this._crudOperations.removeRows(e,...t),this.recomputeIfDependencyGraphNeedsIt()}isItPossibleToAddColumns(e,...t){En(e,"number","sheetId");const r=Us(t);try{return this._crudOperations.ensureItIsPossibleToAddColumns(e,...r),!0}catch(e){return!1}}addColumns(e,...t){return En(e,"number","sheetId"),this._crudOperations.addColumns(e,...t),this.recomputeIfDependencyGraphNeedsIt()}isItPossibleToRemoveColumns(e,...t){En(e,"number","sheetId");const r=Fs(t);try{return this._crudOperations.ensureItIsPossibleToRemoveColumns(e,...r),!0}catch(e){return!1}}removeColumns(e,...t){return En(e,"number","sheetId"),this._crudOperations.removeColumns(e,...t),this.recomputeIfDependencyGraphNeedsIt()}isItPossibleToMoveCells(e,t){if(!Pr(t))throw new Tt("SimpleCellAddress","destinationLeftCorner");if(!kr(e))throw new Tt("SimpleCellRange","source");try{const r=new Fr(e.start,e.end);return this._crudOperations.operations.ensureItIsPossibleToMoveCells(r.start,r.width(),r.height(),t),!0}catch(e){return!1}}moveCells(e,t){if(!Pr(t))throw new Tt("SimpleCellAddress","destinationLeftCorner");if(!kr(e))throw new Tt("SimpleCellRange","source");const r=new Fr(e.start,e.end);return this._crudOperations.moveCells(r.start,r.width(),r.height(),t),this.recomputeIfDependencyGraphNeedsIt()}isItPossibleToMoveRows(e,t,r,n){En(e,"number","sheetId"),En(t,"number","startRow"),En(r,"number","numberOfRows"),En(n,"number","targetRow");try{return this._crudOperations.ensureItIsPossibleToMoveRows(e,t,r,n),!0}catch(e){return!1}}moveRows(e,t,r,n){return En(e,"number","sheetId"),En(t,"number","startRow"),En(r,"number","numberOfRows"),En(n,"number","targetRow"),this._crudOperations.moveRows(e,t,r,n),this.recomputeIfDependencyGraphNeedsIt()}isItPossibleToMoveColumns(e,t,r,n){En(e,"number","sheetId"),En(t,"number","startColumn"),En(r,"number","numberOfColumns"),En(n,"number","targetColumn");try{return this._crudOperations.ensureItIsPossibleToMoveColumns(e,t,r,n),!0}catch(e){return!1}}moveColumns(e,t,r,n){return En(e,"number","sheetId"),En(t,"number","startColumn"),En(r,"number","numberOfColumns"),En(n,"number","targetColumn"),this._crudOperations.moveColumns(e,t,r,n),this.recomputeIfDependencyGraphNeedsIt()}copy(e){if(!kr(e))throw new Tt("SimpleCellRange","source");const t=new Fr(e.start,e.end);return this._crudOperations.copy(t.start,t.width(),t.height()),this.getRangeValues(e)}cut(e){if(!kr(e))throw new Tt("SimpleCellRange","source");const t=new Fr(e.start,e.end);return this._crudOperations.cut(t.start,t.width(),t.height()),this.getRangeValues(e)}paste(e){if(!Pr(e))throw new Tt("SimpleCellAddress","targetLeftCorner");return this.ensureEvaluationIsNotSuspended(),this._crudOperations.paste(e),this.recomputeIfDependencyGraphNeedsIt()}isClipboardEmpty(){return this._crudOperations.isClipboardEmpty()}clearClipboard(){this._crudOperations.clearClipboard()}clearRedoStack(){this._crudOperations.undoRedo.clearRedoStack()}clearUndoStack(){this._crudOperations.undoRedo.clearUndoStack()}getRangeValues(e){if(!kr(e))throw new Tt("SimpleCellRange","source");return new Fr(e.start,e.end).arrayOfAddressesInRange().map((e=>e.map((e=>this.getCellValue(e)))))}getRangeFormulas(e){if(!kr(e))throw new Tt("SimpleCellRange","source");return new Fr(e.start,e.end).arrayOfAddressesInRange().map((e=>e.map((e=>this.getCellFormula(e)))))}getRangeSerialized(e){if(!kr(e))throw new Tt("SimpleCellRange","source");return new Fr(e.start,e.end).arrayOfAddressesInRange().map((e=>e.map((e=>this.getCellSerialized(e)))))}getFillRangeData(e,t,r=!1){if(!kr(e))throw new Tt("SimpleCellRange","source");if(!kr(t))throw new Tt("SimpleCellRange","target");const n=new Fr(e.start,e.end),s=new Fr(t.start,t.end);return this.ensureEvaluationIsNotSuspended(),s.arrayOfAddressesInRange().map((s=>s.map((s=>{const i=((s.row-(r?t:e).start.row)%n.height()+n.height())%n.height()+e.start.row,o=((s.col-(r?t:e).start.col)%n.width()+n.width())%n.width()+e.start.col;return this._serialization.getCellSerialized({row:i,col:o,sheet:n.sheet},s)}))))}isItPossibleToAddSheet(e){En(e,"string","sheetName");try{return this._crudOperations.ensureItIsPossibleToAddSheet(e),!0}catch(e){return!1}}addSheet(e){void 0!==e&&En(e,"string","sheetName");const t=this._crudOperations.addSheet(e);return this._emitter.emit(Yi.SheetAdded,t),t}isItPossibleToRemoveSheet(e){En(e,"number","sheetId");try{return this._crudOperations.ensureScopeIdIsValid(e),!0}catch(e){return!1}}removeSheet(e){En(e,"number","sheetId");const t=this.sheetMapping.getDisplayName(e);this._crudOperations.removeSheet(e);const r=this.recomputeIfDependencyGraphNeedsIt();return this._emitter.emit(Yi.SheetRemoved,t,r),r}isItPossibleToClearSheet(e){En(e,"number","sheetId");try{return this._crudOperations.ensureScopeIdIsValid(e),!0}catch(e){return!1}}clearSheet(e){return En(e,"number","sheetId"),this._crudOperations.clearSheet(e),this.recomputeIfDependencyGraphNeedsIt()}isItPossibleToReplaceSheetContent(e,t){En(e,"number","sheetId");try{return this._crudOperations.ensureScopeIdIsValid(e),this._crudOperations.ensureItIsPossibleToChangeSheetContents(e,t),!0}catch(e){return!1}}setSheetContent(e,t){return En(e,"number","sheetId"),this._crudOperations.setSheetContent(e,t),this.recomputeIfDependencyGraphNeedsIt()}simpleCellAddressFromString(e,t){return En(e,"string","cellAddress"),En(t,"number","sheetId"),O(this.sheetMapping.get,e,t)}simpleCellRangeFromString(e,t){return En(e,"string","cellRange"),En(t,"number","sheetId"),((e,t,r)=>{const n=t.split(h);if(2!==n.length)return;const[s,i]=n,o=O(e,s,r);if(void 0===o)return;const a=O(e,i,o.sheet);return void 0!==a&&o.sheet===a.sheet?Hr(o,a):void 0})(this.sheetMapping.get,e,t)}simpleCellAddressToString(e,t){if(!Pr(e))throw new Tt("SimpleCellAddress","cellAddress");return En(t,"number","sheetId"),I(this.sheetMapping.fetchDisplayName,e,t)}simpleCellRangeToString(e,t){if(!kr(e))throw new Tt("SimpleCellRange","cellRange");return En(t,"number","sheetId"),((e,t,r)=>{const n=I(e,t.start,r),s=I(e,t.end,t.start.sheet);return void 0===n||void 0===s?void 0:`${n}${h}${s}`})(this.sheetMapping.fetchDisplayName,e,t)}getCellDependents(e){let t;if(Pr(e))t=this._dependencyGraph.addressMapping.getCell(e);else{if(!kr(e))throw new Tt("SimpleCellAddress | SimpleCellRange",e);t=this._dependencyGraph.rangeMapping.getRange(e.start,e.end)}return void 0===t?[]:this._dependencyGraph.getAdjacentNodesAddresses(t)}getCellPrecedents(e){let t;if(Pr(e))t=this._dependencyGraph.addressMapping.getCell(e);else{if(!kr(e))throw new Tt("SimpleCellAddress | SimpleCellRange",e);t=this._dependencyGraph.rangeMapping.getRange(e.start,e.end)}return void 0===t?[]:this._dependencyGraph.dependencyQueryAddresses(t)}getSheetName(e){return En(e,"number","sheetId"),this.sheetMapping.getDisplayName(e)}getSheetNames(){return this.sheetMapping.sheetNames()}getSheetId(e){return En(e,"string","sheetName"),this.sheetMapping.get(e)}doesSheetExist(e){return En(e,"string","sheetName"),this.sheetMapping.hasSheetWithName(e)}getCellType(e){if(!Pr(e))throw new Tt("SimpleCellAddress","cellAddress");return((e,t)=>e instanceof zt?e.isLeftCorner(t)?or.ARRAYFORMULA:or.ARRAY:e instanceof $t||e instanceof pr?or.FORMULA:e instanceof dr?or.VALUE:or.EMPTY)(this.dependencyGraph.getCell(e),e)}doesCellHaveSimpleValue(e){if(!Pr(e))throw new Tt("SimpleCellAddress","cellAddress");return this.getCellType(e)===or.VALUE}doesCellHaveFormula(e){if(!Pr(e))throw new Tt("SimpleCellAddress","cellAddress");const t=this.getCellType(e);return t===or.FORMULA||t===or.ARRAYFORMULA}isCellEmpty(e){if(!Pr(e))throw new Tt("SimpleCellAddress","cellAddress");return this.getCellType(e)===or.EMPTY}isCellPartOfArray(e){if(!Pr(e))throw new Tt("SimpleCellAddress","cellAddress");const t=this.getCellType(e);return t===or.ARRAY||t===or.ARRAYFORMULA}getCellValueType(e){if(!Pr(e))throw new Tt("SimpleCellAddress","cellAddress");this.ensureEvaluationIsNotSuspended();const t=this.dependencyGraph.getCellValue(e);return vr(t)}getCellValueDetailedType(e){if(!Pr(e))throw new Tt("SimpleCellAddress","cellAddress");this.ensureEvaluationIsNotSuspended();const t=this.dependencyGraph.getCellValue(e);return Rr(t)}getCellValueFormat(e){if(!Pr(e))throw new Tt("SimpleCellAddress","cellAddress");this.ensureEvaluationIsNotSuspended();const t=this.dependencyGraph.getCellValue(e);return Sr(t)}countSheets(){return this.sheetMapping.numberOfSheets()}isItPossibleToRenameSheet(e,t){En(e,"number","sheetId"),En(t,"string","newName");try{return this._crudOperations.ensureItIsPossibleToRenameSheet(e,t),!0}catch(e){return!1}}renameSheet(e,t){En(e,"number","sheetId"),En(t,"string","newName");const r=this._crudOperations.renameSheet(e,t);void 0!==r&&this._emitter.emit(Yi.SheetRenamed,r,t)}batch(e){this.suspendEvaluation(),this._crudOperations.beginUndoRedoBatchMode();try{e()}catch(e){throw this._crudOperations.commitUndoRedoBatchMode(),this.resumeEvaluation(),e}return this._crudOperations.commitUndoRedoBatchMode(),this.resumeEvaluation()}suspendEvaluation(){this._evaluationSuspended=!0,this._emitter.emit(Yi.EvaluationSuspended)}resumeEvaluation(){this._evaluationSuspended=!1;const e=this.recomputeIfDependencyGraphNeedsIt();return this._emitter.emit(Yi.EvaluationResumed,e),e}isEvaluationSuspended(){return this._evaluationSuspended}isItPossibleToAddNamedExpression(e,t,r){En(e,"string","expressionName"),void 0!==r&&En(r,"number","scope");try{return this._crudOperations.ensureItIsPossibleToAddNamedExpression(e,t,r),!0}catch(e){return!1}}addNamedExpression(e,t,r,n){En(e,"string","expressionName"),void 0!==r&&En(r,"number","scope"),this._crudOperations.addNamedExpression(e,t,r,n);const s=this.recomputeIfDependencyGraphNeedsIt();return this._emitter.emit(Yi.NamedExpressionAdded,e,s),s}getNamedExpressionValue(e,t){En(e,"string","expressionName"),void 0!==t&&En(t,"number","scope"),this.ensureEvaluationIsNotSuspended(),this._crudOperations.ensureScopeIdIsValid(t);const r=this._namedExpressions.namedExpressionForScope(e,t);return r?this._serialization.getCellValue(r.address):void 0}getNamedExpressionFormula(e,t){En(e,"string","expressionName"),void 0!==t&&En(t,"number","scope"),this._crudOperations.ensureScopeIdIsValid(t);const r=this._namedExpressions.namedExpressionForScope(e,t);return void 0===r?void 0:this._serialization.getCellFormula(r.address)}getNamedExpression(e,t){En(e,"string","expressionName"),void 0!==t&&En(t,"number","scope");const r=this._namedExpressions.namedExpressionForScope(e,t);if(void 0===r)return;return{name:e,scope:t,expression:this._serialization.getCellFormula(r.address),options:r.options}}isItPossibleToChangeNamedExpression(e,t,r){En(e,"string","expressionName"),void 0!==r&&En(r,"number","scope");try{return this._crudOperations.ensureItIsPossibleToChangeNamedExpression(e,t,r),!0}catch(e){return!1}}changeNamedExpression(e,t,r,n){return En(e,"string","expressionName"),void 0!==r&&En(r,"number","scope"),this._crudOperations.changeNamedExpressionExpression(e,r,t,n),this.recomputeIfDependencyGraphNeedsIt()}isItPossibleToRemoveNamedExpression(e,t){En(e,"string","expressionName"),void 0!==t&&En(t,"number","scope");try{return this._crudOperations.isItPossibleToRemoveNamedExpression(e,t),!0}catch(e){return!1}}removeNamedExpression(e,t){En(e,"string","expressionName"),void 0!==t&&En(t,"number","scope");const r=this._crudOperations.removeNamedExpression(e,t);if(r){const e=this.recomputeIfDependencyGraphNeedsIt();return this._emitter.emit(Yi.NamedExpressionRemoved,r.displayName,e),e}return[]}listNamedExpressions(e){return void 0!==e&&En(e,"number","scope"),this._crudOperations.ensureScopeIdIsValid(e),this._namedExpressions.getAllNamedExpressionsNamesInScope(e)}getAllNamedExpressionsSerialized(){return this._serialization.getAllNamedExpressionsSerialized()}normalizeFormula(e){En(e,"string","formulaString");const{ast:t,address:r}=this.extractTemporaryFormula(e);if(void 0===t)throw new dt;return this._unparser.unparse(t,r)}calculateFormula(e,t){En(e,"string","formulaString"),En(t,"number","sheetId"),this._crudOperations.ensureScopeIdIsValid(t);const{ast:r,address:n,dependencies:s}=this.extractTemporaryFormula(e,t);if(void 0===r)throw new dt;const i=this.evaluator.runAndForget(r,n,s);return this._exporter.exportScalarOrRange(i)}getNamedExpressionsFromFormula(e){En(e,"string","formulaString");const{ast:t,dependencies:r}=this.extractTemporaryFormula(e);if(void 0===t)throw new dt;const n=r.filter((e=>e instanceof Be)).map((e=>e.name));return[...new Set(n)]}validateFormula(e){En(e,"string","formulaString");const{ast:t}=this.extractTemporaryFormula(e);return void 0!==t}getRegisteredFunctionNames(){return zi.getLanguage(this._config.language).getFunctionTranslations(this._functionRegistry.getRegisteredFunctionIds())}getFunctionPlugin(e){return En(e,"string","functionId"),this._functionRegistry.getFunctionPlugin(e)}getAllFunctionPlugins(){return this._functionRegistry.getPlugins()}numberToDateTime(e){return En(e,"number","val"),this._evaluator.interpreter.dateTimeHelper.numberToSimpleDateTime(e)}numberToDate(e){return En(e,"number","val"),this._evaluator.interpreter.dateTimeHelper.numberToSimpleDate(e)}numberToTime(e){return En(e,"number","val"),Vn(e)}on(e,t){this._emitter.on(e,t)}once(e,t){this._emitter.once(e,t)}off(e,t){this._emitter.off(e,t)}destroy(){! +/** + * @license + * Copyright (c) 2024 Handsoncode. All rights reserved. + */ +function(e){for(const[t,r]of Object.entries(e))r instanceof Function?e[t]=Wi(r):delete e[t]}(this)}ensureEvaluationIsNotSuspended(){if(this._evaluationSuspended)throw new At}extractTemporaryFormula(e,t=1){const r=this._cellContentParser.parse(e),n={sheet:t,col:0,row:0};if(!(r instanceof cs.Formula))return{address:n,dependencies:[]};const{ast:s,errors:i,dependencies:o}=this._parser.parse(r.formula,n);return i.length>0?{address:n,dependencies:[]}:{ast:s,address:n,dependencies:o}}rebuildWithConfig(e){const t=this._config.mergeConfig(e),r=this._config.mergeConfig({language:e.language}),n=this._serialization.withNewConfig(r,this._namedExpressions).getAllSheetsSerialized(),s=this._serialization.getAllNamedExpressionsSerialized(),i=Bi.rebuildWithConfig(t,n,s,this._stats);this._config=i.config,this._stats=i.stats,this._dependencyGraph=i.dependencyGraph,this._columnSearch=i.columnSearch,this._parser=i.parser,this._unparser=i.unparser,this._cellContentParser=i.cellContentParser,this._evaluator=i.evaluator,this._lazilyTransformingAstService=i.lazilyTransformingAstService,this._crudOperations=i.crudOperations,this._exporter=i.exporter,this._namedExpressions=i.namedExpressions,this._serialization=i.serialization,this._functionRegistry=i.functionRegistry}recomputeIfDependencyGraphNeedsIt(){if(this._evaluationSuspended)return[];{const e=this._crudOperations.getAndClearContentChanges(),t=this.dependencyGraph.verticesToRecompute();this.dependencyGraph.clearDirtyVertices(),t.length>0&&e.addAll(this.evaluator.partialRun(t));const r=e.exportChanges(this._exporter);return e.isEmpty()||this._emitter.emit(Yi.ValuesUpdated,r),r}}}zi.version="2.7.0",zi.buildDate="10/04/2024 11:28:07",zi.releaseDate="10/04/2024",zi.languages={},zi.registeredLanguages=new Map; +/** + * @license + * Copyright (c) 2024 Handsoncode. All rights reserved. + */ +const $i=new WeakMap;class Ki{constructor(e={},t=!0){const{accentSensitive:r,binarySearchThreshold:n,caseSensitive:s,caseFirst:i,chooseAddressMappingPolicy:o,context:a,currencySymbol:l,dateFormats:h,decimalSeparator:u,evaluateNullToZero:c,functionArgSeparator:d,functionPlugins:p,ignorePunctuation:g,leapYear1900:f,localeLang:m,language:y,ignoreWhiteSpace:E,licenseKey:w,matchWholeCell:C,arrayColumnSeparator:v,arrayRowSeparator:R,maxRows:S,maxColumns:T,nullYear:N,nullDate:M,parseDateTime:_,precisionEpsilon:b,precisionRounding:A,stringifyDateTime:O,stringifyDuration:I,smartRounding:x,timeFormats:P,thousandSeparator:L,useArrayArithmetic:D,useStats:k,undoLimit:H,useColumnIndex:F,useRegularExpressions:U,useWildcards:V}=e;t&&Ki.warnDeprecatedOptions(e),this.useArrayArithmetic=gn(D,"boolean","useArrayArithmetic"),this.accentSensitive=gn(r,"boolean","accentSensitive"),this.caseSensitive=gn(s,"boolean","caseSensitive"),this.caseFirst=gn(i,["upper","lower","false"],"caseFirst"),this.ignorePunctuation=gn(g,"boolean","ignorePunctuation"),this.chooseAddressMappingPolicy=null!=o?o:Ki.defaultConfig.chooseAddressMappingPolicy,this.dateFormats=[...mn(h,Array.isArray,"array","dateFormats")],this.timeFormats=[...mn(P,Array.isArray,"array","timeFormats")],this.functionArgSeparator=gn(d,"string","functionArgSeparator"),this.decimalSeparator=gn(u,[".",","],"decimalSeparator"),this.language=gn(y,"string","language"),this.ignoreWhiteSpace=gn(E,["standard","any"],"ignoreWhiteSpace"),this.licenseKey=gn(w,"string","licenseKey"),this.thousandSeparator=gn(L,["",","," ","."],"thousandSeparator"),this.arrayColumnSeparator=gn(v,[",",";"],"arrayColumnSeparator"),this.arrayRowSeparator=gn(R,[";","|"],"arrayRowSeparator"),this.localeLang=gn(m,"string","localeLang"),this.functionPlugins=[...null!=p?p:Ki.defaultConfig.functionPlugins],this.smartRounding=gn(x,"boolean","smartRounding"),this.evaluateNullToZero=gn(c,"boolean","evaluateNullToZero"),this.nullYear=gn(N,"number","nullYear"),fn(this.nullYear,"nullYear",0),function(e,t,r){if(e>r)throw new _t(t,r)}(this.nullYear,"nullYear",100),this.precisionRounding=gn(A,"number","precisionRounding"),fn(this.precisionRounding,"precisionRounding",0),this.precisionEpsilon=gn(b,"number","precisionEpsilon"),fn(this.precisionEpsilon,"precisionEpsilon",0),this.useColumnIndex=gn(F,"boolean","useColumnIndex"),this.useStats=gn(k,"boolean","useStats"),this.binarySearchThreshold=null!=n?n:Ki.defaultConfig.binarySearchThreshold,this.parseDateTime=gn(_,"function","parseDateTime"),this.stringifyDateTime=gn(O,"function","stringifyDateTime"),this.stringifyDuration=gn(I,"function","stringifyDuration"),this.translationPackage=zi.getLanguage(this.language),this.errorMapping=this.translationPackage.buildErrorMapping(),this.nullDate=mn(M,Ln,"IDate","nullDate"),this.leapYear1900=gn(f,"boolean","leapYear1900"),this.undoLimit=gn(H,"number","undoLimit"),this.useRegularExpressions=gn(U,"boolean","useRegularExpressions"),this.useWildcards=gn(V,"boolean","useWildcards"),this.matchWholeCell=gn(C,"boolean","matchWholeCell"),fn(this.undoLimit,"undoLimit",0),this.maxRows=gn(S,"number","maxRows"),fn(this.maxRows,"maxRows",1),this.maxColumns=gn(T,"number","maxColumns"),this.currencySymbol=this.setupCurrencySymbol(l),fn(this.maxColumns,"maxColumns",1),this.context=a,$i.set(this,{licenseKeyValidityState:us(this.licenseKey)}),yn({value:this.decimalSeparator,name:"decimalSeparator"},{value:this.functionArgSeparator,name:"functionArgSeparator"},{value:this.thousandSeparator,name:"thousandSeparator"}),yn({value:this.arrayRowSeparator,name:"arrayRowSeparator"},{value:this.arrayColumnSeparator,name:"arrayColumnSeparator"})}setupCurrencySymbol(e){const t=[...mn(e,Array.isArray,"array","currencySymbol")];return t.forEach((e=>{if("string"!=typeof e)throw new Tt("string[]","currencySymbol");if(""===e)throw new Nt("currencySymbol")})),t}get licenseKeyValidityState(){return $i.get(this).licenseKeyValidityState}getConfig(){return Xi(this)}mergeConfig(e){const t=Object.assign({},this.getConfig(),e);return Ki.warnDeprecatedOptions(e),new Ki(t,!1)}static warnDeprecatedOptions(e){Ki.warnDeprecatedIfUsed(e.binarySearchThreshold,"binarySearchThreshold","1.1")}static warnDeprecatedIfUsed(e,t,r,n){void 0!==e&&(void 0===n?console.warn(`${t} option is deprecated since ${r}`):console.warn(`${t} option is deprecated since ${r}, please use ${n}`))}}function Xi(e){var t;const r={};for(const n in Ki.defaultConfig){const s=null!==(t=e[n])&&void 0!==t?t:Ki.defaultConfig[n];Array.isArray(s)?r[n]=[...s]:r[n]=s}return r}Ki.defaultConfig={accentSensitive:!1,binarySearchThreshold:20,currencySymbol:["$"],caseSensitive:!1,caseFirst:"lower",context:void 0,chooseAddressMappingPolicy:new class{call(){return fr}},dateFormats:["DD/MM/YYYY","DD/MM/YY"],decimalSeparator:".",evaluateNullToZero:!1,functionArgSeparator:",",functionPlugins:[],ignorePunctuation:!1,language:"enGB",ignoreWhiteSpace:"standard",licenseKey:"",leapYear1900:!1,localeLang:"en",matchWholeCell:!0,arrayColumnSeparator:",",arrayRowSeparator:";",maxRows:4e4,maxColumns:18278,nullYear:30,nullDate:{year:1899,month:12,day:30},parseDateTime:function(e,t,r){if(void 0===t&&void 0===r)return;let n=e.replace(vn," ").trim().toLowerCase();if(!function(e){return Cn.test(e)}(n))return;let s=n.substring(n.length-2);"am"===s||"pm"===s?n=n.substring(0,n.length-2).trim():(s=n.substring(n.length-1),"a"===s||"p"===s?n=n.substring(0,n.length-1).trim():s=void 0);const i=n.split(Rn);i.length>=2&&i[i.length-2].includes(":")&&(i[i.length-2]=i[i.length-2]+"."+i[i.length-1],i.pop());const o=i[i.length-1].split(":");if(void 0!==s&&o.push(s),1===i.length)return Mn(o,r);if(1===o.length)return _n(i,t);const a=_n(i.slice(0,i.length-1),t),l=Mn(o,r);return void 0===a||void 0===l?void 0:Object.assign(Object.assign({},a),l)},precisionEpsilon:1e-13,precisionRounding:14,smartRounding:!0,stringifyDateTime:function(e,t){const r=Xn(t);if(void 0===r)return;const n=r.tokens;let s="",i=!1;const o=n.some((e=>e.type===Gn.FORMAT&&("a/p"===e.value||"A/P"===e.value||"am/pm"===e.value||"AM/PM"===e.value)));for(let t=0;t{const i=this.verifyAddressArguments(e,t,r,n);if(void 0!==i)return i;const o=P(t-1);let a="";null!=s&&(a=`${s}!`);const l=0==t?"C":`C[${t}]`,h=0==e?"R":`R[${e}]`;return Qi.FullyRelative==r?n?`${a}${o}${e}`:`${a}${h}${l}`:Qi.RowRelativeColAbsolute==r?n?`${a}$${o}${e}`:`${a}${h}C${t}`:Qi.RowAbsoluteColRelative==r?n?`${a}${o}$${e}`:`${a}R${e}${l}`:n?`${a}$${o}$${e}`:`${a}R${e}C${t}`}))}}Zi.implementedFunctions={ADDRESS:{method:"address",parameters:[{argumentType:hn.NUMBER},{argumentType:hn.NUMBER},{argumentType:hn.NUMBER,optionalArg:!0,defaultValue:1,minValue:1,maxValue:4},{argumentType:hn.BOOLEAN,optionalArg:!0,defaultValue:!0},{argumentType:hn.STRING,optionalArg:!0}]}}; +/** + * @license + * Copyright (c) 2024 Handsoncode. All rights reserved. + */ +class Ji extends un{arrayformula(e,t){return this.runFunction(e.args,t,this.metadata("ARRAYFORMULA"),(e=>e))}arrayformulaArraySize(e,t){if(1!==e.args.length)return cn.error();const r=this.metadata("ARRAYFORMULA");return e.args.map((e=>{var n;return this.arraySizeForAst(e,new Br(t.formulaAddress,t.arraysFlag||null!==(n=null==r?void 0:r.arrayFunction)&&void 0!==n&&n))}))[0]}arrayconstrain(e,t){return this.runFunction(e.args,t,this.metadata("ARRAY_CONSTRAIN"),((e,t,r)=>{t=Math.min(t,e.height()),r=Math.min(r,e.width());const n=e.data,s=[];for(let e=0;e{var n;return this.arraySizeForAst(e,new Br(t.formulaAddress,t.arraysFlag||null!==(n=null==r?void 0:r.arrayFunction)&&void 0!==n&&n))}));let{height:s,width:i}=n[0];return e.args[1].type===U.NUMBER&&(s=Math.min(s,e.args[1].value)),e.args[2].type===U.NUMBER&&(i=Math.min(i,e.args[2].value)),s<1||i<1||!Number.isInteger(s)||!Number.isInteger(i)?cn.error():new cn(i,s)}filter(e,t){return this.runFunction(e.args,t,this.metadata("FILTER"),((e,...t)=>{for(const r of t)if(e.width()!==r.width()||e.height()!==r.height())return new Tr(ir.NA,Z.EqualLength);if(e.width()>1&&e.height()>1)return new Tr(ir.NA,Z.WrongDimension);const r=e.data,n=[];for(let s=0;s0&&n.push(i)}return n.length>0?rt.onlyValues(n):new Tr(ir.NA,Z.EmptyRange)}))}filterArraySize(e,t){if(e.args.length<=1)return cn.error();const r=this.metadata("FILTER"),n=e.args.map((e=>{var n;return this.arraySizeForAst(e,new Br(t.formulaAddress,t.arraysFlag||null!==(n=null==r?void 0:r.arrayFunction)&&void 0!==n&&n))})),s=Math.max(...n.map((e=>e.width))),i=Math.max(...n.map((e=>e.height)));return new cn(s,i)}}Ji.implementedFunctions={ARRAYFORMULA:{method:"arrayformula",arraySizeMethod:"arrayformulaArraySize",arrayFunction:!0,parameters:[{argumentType:hn.ANY}]},ARRAY_CONSTRAIN:{method:"arrayconstrain",arraySizeMethod:"arrayconstrainArraySize",parameters:[{argumentType:hn.RANGE},{argumentType:hn.INTEGER,minValue:1},{argumentType:hn.INTEGER,minValue:1}],vectorizationForbidden:!0},FILTER:{method:"filter",arraySizeMethod:"filterArraySize",arrayFunction:!0,parameters:[{argumentType:hn.RANGE},{argumentType:hn.RANGE}],repeatLastArgs:1}}; +/** + * @license + * Copyright (c) 2024 Handsoncode. All rights reserved. + */ +class eo extends un{abs(e,t){return this.runFunction(e.args,t,this.metadata("ABS"),Math.abs)}}eo.implementedFunctions={ABS:{method:"abs",parameters:[{argumentType:hn.NUMBER}]}}; +/** + * @license + * Copyright (c) 2024 Handsoncode. All rights reserved. + */ +const to=0xffffffffffff;class ro extends un{bitlshift(e,t){return this.runFunction(e.args,t,this.metadata("BITLSHIFT"),no)}bitrshift(e,t){return this.runFunction(e.args,t,this.metadata("BITRSHIFT"),so)}}function no(e,t){return t<0?so(e,-t):io(e*Math.pow(2,t))}function so(e,t){return t<0?no(e,-t):io(Math.floor(e/Math.pow(2,t)))}function io(e){return e>to?new Tr(ir.NUM,Z.BitshiftLong):e}ro.implementedFunctions={BITLSHIFT:{method:"bitlshift",parameters:[{argumentType:hn.INTEGER,minValue:0},{argumentType:hn.INTEGER,minValue:-53,maxValue:53}]},BITRSHIFT:{method:"bitrshift",parameters:[{argumentType:hn.INTEGER,minValue:0},{argumentType:hn.INTEGER,minValue:-53,maxValue:53}]}}; +/** + * @license + * Copyright (c) 2024 Handsoncode. All rights reserved. + */ +class oo extends un{bitand(e,t){return this.runFunction(e.args,t,this.metadata("BITAND"),((e,t)=>e&t))}bitor(e,t){return this.runFunction(e.args,t,this.metadata("BITOR"),((e,t)=>e|t))}bitxor(e,t){return this.runFunction(e.args,t,this.metadata("BITXOR"),((e,t)=>e^t))}}oo.implementedFunctions={BITAND:{method:"bitand",parameters:[{argumentType:hn.INTEGER,minValue:0},{argumentType:hn.INTEGER,minValue:0}]},BITOR:{method:"bitor",parameters:[{argumentType:hn.INTEGER,minValue:0},{argumentType:hn.INTEGER,minValue:0}]},BITXOR:{method:"bitxor",parameters:[{argumentType:hn.INTEGER,minValue:0},{argumentType:hn.INTEGER,minValue:0}]}}; +/** + * @license + * Copyright (c) 2024 Handsoncode. All rights reserved. + */ +class ao extends un{literalTrue(e,t){return this.runFunction(e.args,t,this.metadata("TRUE"),(()=>!0))}literalFalse(e,t){return this.runFunction(e.args,t,this.metadata("FALSE"),(()=>!1))}conditionalIf(e,t){return this.runFunction(e.args,t,this.metadata("IF"),((e,t,r)=>e?t:r))}ifs(e,t){return this.runFunction(e.args,t,this.metadata("IFS"),((...e)=>{for(let t=0;te.filter((e=>void 0!==e)).every((e=>!!e))))}or(e,t){return this.runFunction(e.args,t,this.metadata("OR"),((...e)=>e.filter((e=>void 0!==e)).some((e=>e))))}not(e,t){return this.runFunction(e.args,t,this.metadata("NOT"),(e=>!e))}xor(e,t){return this.runFunction(e.args,t,this.metadata("XOR"),((...e)=>{let t=0;return e.filter((e=>void 0!==e)).forEach((e=>{e&&t++})),t%2==1}))}switch(e,t){return this.runFunction(e.args,t,this.metadata("SWITCH"),((e,...t)=>{const r=t.length;let n=0;for(;n+1e instanceof Tr?t:e))}ifna(e,t){return this.runFunction(e.args,t,this.metadata("IFNA"),((e,t)=>e instanceof Tr&&e.type===ir.NA?t:e))}choose(e,t){return this.runFunction(e.args,t,this.metadata("CHOOSE"),((e,...t)=>e>t.length?new Tr(ir.NUM,Z.Selector):t[e-1]))}}ao.implementedFunctions={TRUE:{method:"literalTrue",parameters:[]},FALSE:{method:"literalFalse",parameters:[]},IF:{method:"conditionalIf",parameters:[{argumentType:hn.BOOLEAN},{argumentType:hn.SCALAR,passSubtype:!0},{argumentType:hn.SCALAR,defaultValue:!1,passSubtype:!0}]},IFS:{method:"ifs",parameters:[{argumentType:hn.BOOLEAN},{argumentType:hn.SCALAR,passSubtype:!0}],repeatLastArgs:2},AND:{method:"and",parameters:[{argumentType:hn.BOOLEAN}],repeatLastArgs:1,expandRanges:!0},OR:{method:"or",parameters:[{argumentType:hn.BOOLEAN}],repeatLastArgs:1,expandRanges:!0},XOR:{method:"xor",parameters:[{argumentType:hn.BOOLEAN}],repeatLastArgs:1,expandRanges:!0},NOT:{method:"not",parameters:[{argumentType:hn.BOOLEAN}]},SWITCH:{method:"switch",parameters:[{argumentType:hn.NOERROR},{argumentType:hn.SCALAR,passSubtype:!0},{argumentType:hn.SCALAR,passSubtype:!0}],repeatLastArgs:1},IFERROR:{method:"iferror",parameters:[{argumentType:hn.SCALAR,passSubtype:!0},{argumentType:hn.SCALAR,passSubtype:!0}]},IFNA:{method:"ifna",parameters:[{argumentType:hn.SCALAR,passSubtype:!0},{argumentType:hn.SCALAR,passSubtype:!0}]},CHOOSE:{method:"choose",parameters:[{argumentType:hn.INTEGER,minValue:1},{argumentType:hn.SCALAR,passSubtype:!0}],repeatLastArgs:1}}; +/** + * @license + * Copyright (c) 2024 Handsoncode. All rights reserved. + */ +class lo extends un{char(e,t){return this.runFunction(e.args,t,this.metadata("CHAR"),(e=>e<1||e>=256?new Tr(ir.VALUE,Z.CharacterCodeBounds):String.fromCharCode(Math.trunc(e))))}unichar(e,t){return this.runFunction(e.args,t,this.metadata("CHAR"),(e=>e<1||e>=1114112?new Tr(ir.VALUE,Z.CharacterCodeBounds):String.fromCodePoint(Math.trunc(e))))}}lo.implementedFunctions={CHAR:{method:"char",parameters:[{argumentType:hn.NUMBER}]},UNICHAR:{method:"unichar",parameters:[{argumentType:hn.NUMBER}]}}; +/** + * @license + * Copyright (c) 2024 Handsoncode. All rights reserved. + */ +class ho extends un{code(e,t){return this.runFunction(e.args,t,this.metadata("CODE"),(e=>0===e.length?new Tr(ir.VALUE,Z.EmptyString):e.charCodeAt(0)))}unicode(e,t){return this.runFunction(e.args,t,this.metadata("UNICODE"),(e=>{var t;return null!==(t=e.codePointAt(0))&&void 0!==t?t:new Tr(ir.VALUE,Z.EmptyString)}))}}ho.implementedFunctions={CODE:{method:"code",parameters:[{argumentType:hn.STRING}]},UNICODE:{method:"unicode",parameters:[{argumentType:hn.STRING}]}}; +/** + * @license + * Copyright (c) 2024 Handsoncode. All rights reserved. + */ +class uo extends un{countblank(e,t){return this.runFunction(e.args,t,this.metadata("COUNTBLANK"),((...e)=>{let t=0;return e.forEach((e=>{e===Ye&&t++})),t}))}}uo.implementedFunctions={COUNTBLANK:{method:"countblank",parameters:[{argumentType:hn.SCALAR}],repeatLastArgs:1,expandRanges:!0}}; +/** + * @license + * Copyright (c) 2024 Handsoncode. All rights reserved. + */ +class co extends un{countunique(e,t){return this.runFunction(e.args,t,this.metadata("COUNTUNIQUE"),((...e)=>{const t=new Set,r=new Set;for(const n of e)n instanceof Tr?r.add(n.type):""!==n&&t.add(n);return t.size+r.size}))}}co.implementedFunctions={COUNTUNIQUE:{method:"countunique",parameters:[{argumentType:hn.SCALAR}],repeatLastArgs:1,expandRanges:!0}}; +/** + * @license + * Copyright (c) 2024 Handsoncode. All rights reserved. + */ +class po extends un{constructor(){super(...arguments),this.isoweeknumCore=e=>{const t=Math.floor(this.dateTimeHelper.relativeNumberToAbsoluteNumber(e)),r=this.dateTimeHelper.numberToSimpleDate(e),n=this.dateTimeHelper.dateToNumber({year:r.year,month:1,day:1}),s=this.dateTimeHelper.relativeNumberToAbsoluteNumber(n),i=s+((4-s)%7+7)%7,o=Math.floor((t-1)/7)-Math.floor((i-1)/7)+1;return 0===o?this.isoweeknumCore(e-7)+1:o},this.days360Core=(e,t,r)=>{const n=this.dateTimeHelper.numberToSimpleDate(e),s=this.dateTimeHelper.numberToSimpleDate(t);let i,o;return r?(i=Wn(n),o=Wn(s)):[i,o]=this.dateTimeHelper.toBasisUS(n,s),360*(o.year-i.year)+30*(o.month-i.month)+o.day-i.day}}date(e,t){return this.runFunction(e.args,t,this.metadata("DATE"),((e,t,r)=>{const n=Math.trunc(r);let s=Math.trunc(t),i=Math.trunc(e);i{const n=Bn({hours:Math.trunc(e),minutes:Math.trunc(t),seconds:Math.trunc(r)});return n<0?new Tr(ir.NUM,Z.NegativeTime):n%1}))}eomonth(e,t){return this.runFunction(e.args,t,this.metadata("EOMONTH"),((e,t)=>{const r=this.dateTimeHelper.numberToSimpleDate(e);let n=this.dateTimeHelper.dateToNumber(this.dateTimeHelper.endOfMonth(Fn(r,t)));return n=this.dateTimeHelper.getWithinBounds(n),void 0===n?new Tr(ir.NUM,Z.DateBounds):n}))}day(e,t){return this.runFunction(e.args,t,this.metadata("DAY"),(e=>this.dateTimeHelper.numberToSimpleDate(e).day))}days(e,t){return this.runFunction(e.args,t,this.metadata("DAYS"),((e,t)=>Math.trunc(e)-Math.trunc(t)))}month(e,t){return this.runFunction(e.args,t,this.metadata("MONTH"),(e=>this.dateTimeHelper.numberToSimpleDate(e).month))}year(e,t){return this.runFunction(e.args,t,this.metadata("YEAR"),(e=>this.dateTimeHelper.numberToSimpleDate(e).year))}hour(e,t){return this.runFunction(e.args,t,this.metadata("HOUR"),(e=>Vn(Un(e)%1).hours))}minute(e,t){return this.runFunction(e.args,t,this.metadata("MINUTE"),(e=>Vn(Un(e)%1).minutes))}second(e,t){return this.runFunction(e.args,t,this.metadata("SECOND"),(e=>Vn(Un(e)%1).seconds))}text(e,t){return this.runFunction(e.args,t,this.metadata("TEXT"),((e,t)=>Zn(e,t,this.config,this.dateTimeHelper)))}weekday(e,t){return this.runFunction(e.args,t,this.metadata("WEEKDAY"),((e,t)=>{const r=Math.floor(this.dateTimeHelper.relativeNumberToAbsoluteNumber(e));if(3===t)return(r-1)%7;const n=mo.get(t);return void 0===n?new Tr(ir.NUM,Z.BadMode):(r-n)%7+1}))}weeknum(e,t){return this.runFunction(e.args,t,this.metadata("WEEKNUM"),((e,t)=>{const r=Math.floor(this.dateTimeHelper.relativeNumberToAbsoluteNumber(e)),n=this.dateTimeHelper.numberToSimpleDate(e),s=this.dateTimeHelper.dateToNumber({year:n.year,month:1,day:1}),i=this.dateTimeHelper.relativeNumberToAbsoluteNumber(s);if(21===t)return this.isoweeknumCore(e);const o=mo.get(t);return void 0===o?new Tr(ir.NUM,Z.BadMode):Math.floor((r-o)/7)-Math.floor((i-o)/7)+1}))}isoweeknum(e,t){return this.runFunction(e.args,t,this.metadata("ISOWEEKNUM"),this.isoweeknumCore)}datevalue(e,t){return this.runFunction(e.args,t,this.metadata("DATEVALUE"),(e=>{const{dateTime:t}=this.dateTimeHelper.parseDateTimeFromConfigFormats(e);return void 0===t?new Tr(ir.VALUE,Z.IncorrectDateTime):Ln(t)?(Dn(t)?Math.trunc(Bn(t)):0)+this.dateTimeHelper.dateToNumber(t):0}))}timevalue(e,t){return this.runFunction(e.args,t,this.metadata("TIMEVALUE"),(e=>{const t=this.dateTimeHelper.dateStringToDateNumber(e);return void 0===t?new Tr(ir.VALUE,Z.IncorrectDateTime):je(t)%1}))}now(e,t){return this.runFunction(e.args,t,this.metadata("NOW"),(()=>{const e=new Date(Date.now());return Bn({hours:e.getHours(),minutes:e.getMinutes(),seconds:e.getSeconds()})+this.dateTimeHelper.dateToNumber({year:e.getFullYear(),month:e.getMonth()+1,day:e.getDate()})}))}today(e,t){return this.runFunction(e.args,t,this.metadata("TODAY"),(()=>{const e=new Date(Date.now());return this.dateTimeHelper.dateToNumber({year:e.getFullYear(),month:e.getMonth()+1,day:e.getDate()})}))}edate(e,t){return this.runFunction(e.args,t,this.metadata("EDATE"),((e,t)=>{const r=function(e){return{year:e.year,month:e.month,day:Math.min(e.day,An[e.month-1])}}(Fn(this.dateTimeHelper.numberToSimpleDate(e),t));let n=this.dateTimeHelper.dateToNumber(r);return n=this.dateTimeHelper.getWithinBounds(n),void 0===n?new Tr(ir.NUM,Z.DateBounds):n}))}datedif(e,t){return this.runFunction(e.args,t,this.metadata("DATEDIF"),((e,t,r)=>{if(e>t)return new Tr(ir.NUM,Z.StartEndDate);if("D"===r)return Math.floor(t)-Math.floor(e);const n=this.dateTimeHelper.numberToSimpleDate(e),s=this.dateTimeHelper.numberToSimpleDate(t);switch(r){case"M":return 12*(s.year-n.year)+(s.month-n.month)-(s.dayn.month||s.month===n.month&&s.day>=n.day?s.year-n.year:s.year-n.year-1;case"MD":if(s.day>=n.day)return s.day-n.day;{const e=1===s.month?12:s.month-1,t=1===s.month?s.year-1:s.year;return this.dateTimeHelper.daysInMonth(t,e)+s.day-n.day}case"YD":return s.month>n.month||s.month===n.month&&s.day>=n.day?Math.floor(t)-this.dateTimeHelper.dateToNumber({year:s.year,month:n.month,day:n.day}):Math.floor(t)-Math.floor(e)-365*(s.year-n.year-1)-this.dateTimeHelper.leapYearsCount(s.year-1)+this.dateTimeHelper.leapYearsCount(n.year);default:return new Tr(ir.NUM,Z.BadMode)}}))}days360(e,t){return this.runFunction(e.args,t,this.metadata("DAYS360"),this.days360Core)}yearfrac(e,t){return this.runFunction(e.args,t,this.metadata("YEARFRAC"),((e,t,r)=>{switch((e=Math.trunc(e))>(t=Math.trunc(t))&&([e,t]=[t,e]),r){case 0:return this.days360Core(e,t,!1)/360;case 1:return(t-e)/this.dateTimeHelper.yearLengthForBasis(this.dateTimeHelper.numberToSimpleDate(e),this.dateTimeHelper.numberToSimpleDate(t));case 2:return(t-e)/360;case 3:return(t-e)/365;case 4:return this.days360Core(e,t,!0)/360}throw new Error("Should not be reachable.")}))}interval(e,t){return this.runFunction(e.args,t,this.metadata("INTERVAL"),(e=>{const t=(e=Math.trunc(e))%60,r=(e=Math.trunc(e/60))%60,n=(e=Math.trunc(e/60))%24,s=(e=Math.trunc(e/24))%30,i=(e=Math.trunc(e/30))%12,o=Math.trunc(e/12);return"P"+(o>0?`${o}Y`:"")+(i>0?`${i}M`:"")+(s>0?`${s}D`:"")+"T"+(n>0?`${n}H`:"")+(r>0?`${r}M`:"")+(t>0?`${t}S`:"")}))}networkdays(e,t){return this.runFunction(e.args,t,this.metadata("NETWORKDAYS"),((e,t,r)=>this.networkdayscore(e,t,1,r)))}networkdaysintl(e,t){return this.runFunction(e.args,t,this.metadata("NETWORKDAYS.INTL"),((e,t,r,n)=>this.networkdayscore(e,t,r,n)))}workday(e,t){return this.runFunction(e.args,t,this.metadata("WORKDAY"),((e,t,r)=>this.workdaycore(e,t,1,r)))}workdayintl(e,t){return this.runFunction(e.args,t,this.metadata("WORKDAY.INTL"),((e,t,r,n)=>this.workdaycore(e,t,r,n)))}networkdayscore(e,t,r,n){let s=1;(e=Math.trunc(e))>(t=Math.trunc(t))&&([e,t]=[t,e],s=-1);const i=fo(r);if(i instanceof Tr)return i;const o=this.simpleRangeToFilteredHolidays(i,n);return o instanceof Tr?o:s*this.countWorkdays(e,t,i,o)}workdaycore(e,t,r,n){e=Math.trunc(e),t=Math.trunc(t);const s=fo(r);if(s instanceof Tr)return s;const i=this.simpleRangeToFilteredHolidays(s,n);if(i instanceof Tr)return i;if(t>0){let r=1;for(;this.countWorkdays(e+1,e+r,s,i)e-t)).filter((t=>{const r=(this.dateTimeHelper.relativeNumberToAbsoluteNumber(t)-1)%7;return"0"===e.charAt(r)}))}}function go(e,t){if(0===t.length)return 0;if(e<=t[0])return 0;if(t[t.length-1]=e?n=s:r=s}return n}function fo(e){var t;return"number"!=typeof e&&"string"!=typeof e?new Tr(ir.VALUE,Z.WrongType):"string"==typeof e?7===e.length&&/^(0|1)*$/.test(e)&&"1111111"!==e?e:new Tr(ir.NUM,Z.WeekendString):null!==(t=yo.get(e))&&void 0!==t?t:new Tr(ir.NUM,Z.BadMode)}po.implementedFunctions={DATE:{method:"date",parameters:[{argumentType:hn.NUMBER},{argumentType:hn.NUMBER},{argumentType:hn.NUMBER}],returnNumberType:Je.NUMBER_DATE},TIME:{method:"time",parameters:[{argumentType:hn.NUMBER},{argumentType:hn.NUMBER},{argumentType:hn.NUMBER}],returnNumberType:Je.NUMBER_TIME},MONTH:{method:"month",parameters:[{argumentType:hn.NUMBER,minValue:0}]},YEAR:{method:"year",parameters:[{argumentType:hn.NUMBER,minValue:0}]},HOUR:{method:"hour",parameters:[{argumentType:hn.NUMBER,minValue:0}]},MINUTE:{method:"minute",parameters:[{argumentType:hn.NUMBER,minValue:0}]},SECOND:{method:"second",parameters:[{argumentType:hn.NUMBER,minValue:0}]},TEXT:{method:"text",parameters:[{argumentType:hn.NUMBER},{argumentType:hn.STRING}]},EOMONTH:{method:"eomonth",parameters:[{argumentType:hn.NUMBER,minValue:0},{argumentType:hn.NUMBER}],returnNumberType:Je.NUMBER_DATE},DAY:{method:"day",parameters:[{argumentType:hn.NUMBER,minValue:0}]},DAYS:{method:"days",parameters:[{argumentType:hn.NUMBER,minValue:0},{argumentType:hn.NUMBER,minValue:0}]},WEEKDAY:{method:"weekday",parameters:[{argumentType:hn.NUMBER,minValue:0},{argumentType:hn.NUMBER,defaultValue:1}]},WEEKNUM:{method:"weeknum",parameters:[{argumentType:hn.NUMBER,minValue:0},{argumentType:hn.NUMBER,defaultValue:1}]},ISOWEEKNUM:{method:"isoweeknum",parameters:[{argumentType:hn.NUMBER,minValue:0}]},DATEVALUE:{method:"datevalue",parameters:[{argumentType:hn.STRING}],returnNumberType:Je.NUMBER_DATE},TIMEVALUE:{method:"timevalue",parameters:[{argumentType:hn.STRING}],returnNumberType:Je.NUMBER_TIME},NOW:{method:"now",parameters:[],isVolatile:!0,returnNumberType:Je.NUMBER_DATETIME},TODAY:{method:"today",parameters:[],isVolatile:!0,returnNumberType:Je.NUMBER_DATE},EDATE:{method:"edate",parameters:[{argumentType:hn.NUMBER,minValue:0},{argumentType:hn.NUMBER}],returnNumberType:Je.NUMBER_DATE},DAYS360:{method:"days360",parameters:[{argumentType:hn.NUMBER,minValue:0},{argumentType:hn.NUMBER,minValue:0},{argumentType:hn.BOOLEAN,defaultValue:!1}]},DATEDIF:{method:"datedif",parameters:[{argumentType:hn.NUMBER,minValue:0},{argumentType:hn.NUMBER,minValue:0},{argumentType:hn.STRING}]},YEARFRAC:{method:"yearfrac",parameters:[{argumentType:hn.NUMBER,minValue:0},{argumentType:hn.NUMBER,minValue:0},{argumentType:hn.INTEGER,defaultValue:0,minValue:0,maxValue:4}]},INTERVAL:{method:"interval",parameters:[{argumentType:hn.NUMBER,minValue:0}]},NETWORKDAYS:{method:"networkdays",parameters:[{argumentType:hn.NUMBER,minValue:0},{argumentType:hn.NUMBER,minValue:0},{argumentType:hn.RANGE,optionalArg:!0}]},"NETWORKDAYS.INTL":{method:"networkdaysintl",parameters:[{argumentType:hn.NUMBER,minValue:0},{argumentType:hn.NUMBER,minValue:0},{argumentType:hn.NOERROR,defaultValue:1},{argumentType:hn.RANGE,optionalArg:!0}]},WORKDAY:{method:"workday",parameters:[{argumentType:hn.NUMBER,minValue:0},{argumentType:hn.NUMBER},{argumentType:hn.RANGE,optionalArg:!0}]},"WORKDAY.INTL":{method:"workdayintl",parameters:[{argumentType:hn.NUMBER,minValue:0},{argumentType:hn.NUMBER},{argumentType:hn.NOERROR,defaultValue:1},{argumentType:hn.RANGE,optionalArg:!0}]}};const mo=new Map([[1,0],[2,1],[11,1],[12,2],[13,3],[14,4],[15,5],[16,6],[17,0]]),yo=new Map([[1,"0000011"],[2,"1000001"],[3,"1100000"],[4,"0110000"],[5,"0011000"],[6,"0001100"],[7,"0000110"],[11,"0000001"],[12,"1000000"],[13,"0100000"],[14,"0010000"],[15,"0001000"],[16,"0000100"],[17,"0000010"]]); +/** + * @license + * Copyright (c) 2024 Handsoncode. All rights reserved. + */ +class Eo extends un{degrees(e,t){return this.runFunction(e.args,t,this.metadata("DEGREES"),(e=>e*(180/Math.PI)))}}Eo.implementedFunctions={DEGREES:{method:"degrees",parameters:[{argumentType:hn.NUMBER}]}}; +/** + * @license + * Copyright (c) 2024 Handsoncode. All rights reserved. + */ +class wo extends un{delta(e,t){return this.runFunction(e.args,t,this.metadata("DELTA"),((e,t)=>e===t?1:0))}}wo.implementedFunctions={DELTA:{method:"delta",parameters:[{argumentType:hn.NUMBER},{argumentType:hn.NUMBER,defaultValue:0}]}}; +/** + * @license + * Copyright (c) 2024 Handsoncode. All rights reserved. + */ +class Co extends un{exp(e,t){return this.runFunction(e.args,t,this.metadata("EXP"),Math.exp)}}Co.implementedFunctions={EXP:{method:"exp",parameters:[{argumentType:hn.NUMBER}]}}; +/** + * @license + * Copyright (c) 2024 Handsoncode. All rights reserved. + */ +class vo extends un{pmt(e,t){return this.runFunction(e.args,t,this.metadata("PMT"),Ro)}ipmt(e,t){return this.runFunction(e.args,t,this.metadata("IPMT"),So)}ppmt(e,t){return this.runFunction(e.args,t,this.metadata("PPMT"),No)}fv(e,t){return this.runFunction(e.args,t,this.metadata("FV"),To)}cumipmt(e,t){return this.runFunction(e.args,t,this.metadata("CUMIPMT"),((e,t,r,n,s,i)=>{if(n>s)return new Tr(ir.NUM,Z.EndStartPeriod);let o=0;for(let a=n;a<=s;a++)o+=So(e,a,t,r,0,i);return o}))}cumprinc(e,t){return this.runFunction(e.args,t,this.metadata("CUMPRINC"),((e,t,r,n,s,i)=>{if(n>s)return new Tr(ir.NUM,Z.EndStartPeriod);let o=0;for(let a=n;a<=s;a++)o+=No(e,a,t,r,0,i);return o}))}db(e,t){return this.runFunction(e.args,t,this.metadata("DB"),((e,t,r,n,s)=>{if(12===s&&n>r||n>r+1)return new Tr(ir.NUM,Z.PeriodLong);if(t>=e)return 0;const i=Math.round(1e3*(1-Math.pow(t/e,1/r)))/1e3,o=e*i*s/12;if(1===n)return o;let a=o;for(let t=0;t{if(n>r)return new Tr(ir.NUM);let i,o=s/r;o>=1?(o=1,i=1===n?e:0):i=e*Math.pow(1-o,n-1);const a=e*Math.pow(1-o,n);return Math.max(i-Math.max(t,a),0)}))}dollarde(e,t){return this.runFunction(e.args,t,this.metadata("DOLLARDE"),((e,t)=>{if(t<1)return new Tr(ir.DIV_BY_ZERO);for(t=Math.trunc(t);t>10;)t/=10;return Math.trunc(e)+10*(e-Math.trunc(e))/t}))}dollarfr(e,t){return this.runFunction(e.args,t,this.metadata("DOLLARFR"),((e,t)=>{if(t<1)return new Tr(ir.DIV_BY_ZERO);for(t=Math.trunc(t);t>10;)t/=10;return Math.trunc(e)+(e-Math.trunc(e))*t/10}))}effect(e,t){return this.runFunction(e.args,t,this.metadata("EFFECT"),((e,t)=>(t=Math.trunc(t),Math.pow(1+e/t,t)-1)))}ispmt(e,t){return this.runFunction(e.args,t,this.metadata("ISPMT"),((e,t,r,n)=>0===r?new Tr(ir.DIV_BY_ZERO):n*e*(t/r-1)))}nominal(e,t){return this.runFunction(e.args,t,this.metadata("NOMINAL"),((e,t)=>(t=Math.trunc(t),(Math.pow(e+1,1/t)-1)*t)))}nper(e,t){return this.runFunction(e.args,t,this.metadata("NPER"),((e,t,r,n,s)=>0===e?0===t?new Tr(ir.DIV_BY_ZERO):(-r-n)/t:(s&&(t*=1+e),Math.log((t-n*e)/(r*e+t))/Math.log(1+e))))}rate(e,t){return this.runFunction(e.args,t,this.metadata("RATE"),((e,t,r,n,s,i)=>{if(i<=-1)return new Tr(ir.VALUE);const o=1e-7;let a=i;s=s?1:0;for(let i=0;i<50;i++){if(a<=-1)return new Tr(ir.NUM);let i,l;if(Math.abs(a)(s=s?1:0,-1===e?new Tr(0===t?ir.NUM:ir.DIV_BY_ZERO):0===e?-r*t-n:((1-Math.pow(1+e,t))*r*(1+e*s)/e-n)/Math.pow(1+e,t))))}rri(e,t){return this.runFunction(e.args,t,this.metadata("RRI"),((e,t,r)=>0===t||r<0&&t>0||r>0&&t<0?new Tr(ir.NUM):Math.pow(r/t,1/e)-1))}sln(e,t){return this.runFunction(e.args,t,this.metadata("SLN"),((e,t,r)=>0===r?new Tr(ir.DIV_BY_ZERO):(e-t)/r))}syd(e,t){return this.runFunction(e.args,t,this.metadata("SYD"),((e,t,r,n)=>n>r?new Tr(ir.NUM):(e-t)*(r-n+1)*2/(r*(r+1))))}tbilleq(e,t){return this.runFunction(e.args,t,this.metadata("TBILLEQ"),((e,t,r)=>{if((e=Math.round(e))>=(t=Math.round(t)))return new Tr(ir.NUM);const n=this.dateTimeHelper.numberToSimpleDate(e),s=this.dateTimeHelper.numberToSimpleDate(t);if(s.year>n.year+1||s.year===n.year+1&&(s.month>n.month||s.month===n.month&&s.day>n.day))return new Tr(ir.NUM);const i=360-r*(t-e);return 0===i?0:i<0?new Tr(ir.NUM):365*r/i}))}tbillprice(e,t){return this.runFunction(e.args,t,this.metadata("TBILLPRICE"),((e,t,r)=>{if((e=Math.round(e))>=(t=Math.round(t)))return new Tr(ir.NUM);const n=this.dateTimeHelper.numberToSimpleDate(e),s=this.dateTimeHelper.numberToSimpleDate(t);if(s.year>n.year+1||s.year===n.year+1&&(s.month>n.month||s.month===n.month&&s.day>n.day))return new Tr(ir.NUM);const i=360-r*(t-e);return 0===i?0:i<0?new Tr(ir.NUM):100*(1-r*(t-e)/360)}))}tbillyield(e,t){return this.runFunction(e.args,t,this.metadata("TBILLYIELD"),((e,t,r)=>{if((e=Math.round(e))>=(t=Math.round(t)))return new Tr(ir.NUM);const n=this.dateTimeHelper.numberToSimpleDate(e),s=this.dateTimeHelper.numberToSimpleDate(t);return s.year>n.year+1||s.year===n.year+1&&(s.month>n.month||s.month===n.month&&s.day>n.day)?new Tr(ir.NUM):360*(100-r)/(r*(t-e))}))}fvschedule(e,t){return this.runFunction(e.args,t,this.metadata("FVSCHEDULE"),((e,t)=>{const r=t.valuesFromTopLeftCorner();for(const e of r)if(e instanceof Tr)return e;for(const t of r)if(Ze(t))e*=1+je(t);else if(t!==Ye)return new Tr(ir.VALUE,Z.NumberExpected);return e}))}npv(e,t){return this.runFunction(e.args,t,this.metadata("NPV"),((e,...t)=>{const r=this.arithmeticHelper.coerceNumbersExactRanges(t);return r instanceof Tr?r:Mo(e,r)}))}mirr(e,t){return this.runFunction(e.args,t,this.metadata("MIRR"),((e,t,r)=>{const n=this.arithmeticHelper.manyToExactNumbers(e.valuesFromTopLeftCorner());if(n instanceof Tr)return n;let s=!1,i=!1;const o=[],a=[];for(const e of n)e>0?(s=!0,o.push(e),a.push(0)):e<0?(i=!0,a.push(e),o.push(0)):(a.push(0),o.push(0));if(!s||!i)return new Tr(ir.DIV_BY_ZERO);const l=n.length,h=Mo(r,o);if(h instanceof Tr)return h;const u=Mo(t,a);return u instanceof Tr?u:Math.pow(-h*Math.pow(1+r,l)/u/(1+t),1/(l-1))-1}))}pduration(e,t){return this.runFunction(e.args,t,this.metadata("PDURATION"),((e,t,r)=>(Math.log(r)-Math.log(t))/Math.log(1+e)))}xnpv(e,t){return this.runFunction(e.args,t,this.metadata("XNPV"),((e,t,r)=>{const n=t.valuesFromTopLeftCorner();for(const e of n)if("number"!=typeof e)return new Tr(ir.VALUE,Z.NumberExpected);const s=n,i=r.valuesFromTopLeftCorner();for(const e of i)if("number"!=typeof e)return new Tr(ir.VALUE,Z.NumberExpected);const o=i;if(o.length!==s.length)return new Tr(ir.NUM,Z.EqualLength);const a=o.length;let l=0;if(o[0]<0)return new Tr(ir.NUM,Z.ValueSmall);for(let t=0;t=0;n--){if(r+=t[n],-1===e){if(0===r)continue;return new Tr(ir.DIV_BY_ZERO)}r/=1+e}return r}vo.implementedFunctions={PMT:{method:"pmt",parameters:[{argumentType:hn.NUMBER},{argumentType:hn.NUMBER},{argumentType:hn.NUMBER},{argumentType:hn.NUMBER,defaultValue:0},{argumentType:hn.NUMBER,defaultValue:0}],returnNumberType:Je.NUMBER_CURRENCY},IPMT:{method:"ipmt",parameters:[{argumentType:hn.NUMBER},{argumentType:hn.NUMBER},{argumentType:hn.NUMBER},{argumentType:hn.NUMBER},{argumentType:hn.NUMBER,defaultValue:0},{argumentType:hn.NUMBER,defaultValue:0}],returnNumberType:Je.NUMBER_CURRENCY},PPMT:{method:"ppmt",parameters:[{argumentType:hn.NUMBER},{argumentType:hn.NUMBER},{argumentType:hn.NUMBER},{argumentType:hn.NUMBER},{argumentType:hn.NUMBER,defaultValue:0},{argumentType:hn.NUMBER,defaultValue:0}],returnNumberType:Je.NUMBER_CURRENCY},FV:{method:"fv",parameters:[{argumentType:hn.NUMBER},{argumentType:hn.NUMBER},{argumentType:hn.NUMBER},{argumentType:hn.NUMBER,defaultValue:0},{argumentType:hn.NUMBER,defaultValue:0}],returnNumberType:Je.NUMBER_CURRENCY},CUMIPMT:{method:"cumipmt",parameters:[{argumentType:hn.NUMBER,greaterThan:0},{argumentType:hn.NUMBER,greaterThan:0},{argumentType:hn.NUMBER,greaterThan:0},{argumentType:hn.INTEGER,minValue:1},{argumentType:hn.INTEGER,minValue:1},{argumentType:hn.INTEGER,minValue:0,maxValue:1}],returnNumberType:Je.NUMBER_CURRENCY},CUMPRINC:{method:"cumprinc",parameters:[{argumentType:hn.NUMBER,greaterThan:0},{argumentType:hn.NUMBER,greaterThan:0},{argumentType:hn.NUMBER,greaterThan:0},{argumentType:hn.INTEGER,minValue:1},{argumentType:hn.INTEGER,minValue:1},{argumentType:hn.INTEGER,minValue:0,maxValue:1}],returnNumberType:Je.NUMBER_CURRENCY},DB:{method:"db",parameters:[{argumentType:hn.NUMBER,minValue:0},{argumentType:hn.NUMBER,minValue:0},{argumentType:hn.INTEGER,minValue:0},{argumentType:hn.INTEGER,minValue:0},{argumentType:hn.INTEGER,minValue:1,maxValue:12,defaultValue:12}],returnNumberType:Je.NUMBER_CURRENCY},DDB:{method:"ddb",parameters:[{argumentType:hn.NUMBER,minValue:0},{argumentType:hn.NUMBER,minValue:0},{argumentType:hn.INTEGER,minValue:0},{argumentType:hn.NUMBER,minValue:0},{argumentType:hn.NUMBER,greaterThan:0,defaultValue:2}],returnNumberType:Je.NUMBER_CURRENCY},DOLLARDE:{method:"dollarde",parameters:[{argumentType:hn.NUMBER},{argumentType:hn.NUMBER,minValue:0}]},DOLLARFR:{method:"dollarfr",parameters:[{argumentType:hn.NUMBER},{argumentType:hn.NUMBER,minValue:0}]},EFFECT:{method:"effect",parameters:[{argumentType:hn.NUMBER,minValue:0},{argumentType:hn.NUMBER,minValue:1}],returnNumberType:Je.NUMBER_PERCENT},ISPMT:{method:"ispmt",parameters:[{argumentType:hn.NUMBER},{argumentType:hn.NUMBER},{argumentType:hn.NUMBER},{argumentType:hn.NUMBER}]},NOMINAL:{method:"nominal",parameters:[{argumentType:hn.NUMBER,minValue:0},{argumentType:hn.NUMBER,minValue:1}],returnNumberType:Je.NUMBER_PERCENT},NPER:{method:"nper",parameters:[{argumentType:hn.NUMBER},{argumentType:hn.NUMBER},{argumentType:hn.NUMBER},{argumentType:hn.NUMBER,defaultValue:0},{argumentType:hn.NUMBER,defaultValue:0}]},PV:{method:"pv",parameters:[{argumentType:hn.NUMBER},{argumentType:hn.NUMBER},{argumentType:hn.NUMBER},{argumentType:hn.NUMBER,defaultValue:0},{argumentType:hn.NUMBER,defaultValue:0}],returnNumberType:Je.NUMBER_CURRENCY},RATE:{method:"rate",parameters:[{argumentType:hn.NUMBER,greaterThan:0},{argumentType:hn.NUMBER},{argumentType:hn.NUMBER},{argumentType:hn.NUMBER,defaultValue:0},{argumentType:hn.NUMBER,defaultValue:0},{argumentType:hn.NUMBER,defaultValue:.1}],returnNumberType:Je.NUMBER_PERCENT},RRI:{method:"rri",parameters:[{argumentType:hn.NUMBER,greaterThan:0},{argumentType:hn.NUMBER},{argumentType:hn.NUMBER}],returnNumberType:Je.NUMBER_PERCENT},SLN:{method:"sln",parameters:[{argumentType:hn.NUMBER},{argumentType:hn.NUMBER},{argumentType:hn.NUMBER}],returnNumberType:Je.NUMBER_CURRENCY},SYD:{method:"syd",parameters:[{argumentType:hn.NUMBER},{argumentType:hn.NUMBER},{argumentType:hn.NUMBER,greaterThan:0},{argumentType:hn.NUMBER,greaterThan:0}],returnNumberType:Je.NUMBER_CURRENCY},TBILLEQ:{method:"tbilleq",parameters:[{argumentType:hn.NUMBER,minValue:0},{argumentType:hn.NUMBER,minValue:0},{argumentType:hn.NUMBER,greaterThan:0}],returnNumberType:Je.NUMBER_PERCENT},TBILLPRICE:{method:"tbillprice",parameters:[{argumentType:hn.NUMBER,minValue:0},{argumentType:hn.NUMBER,minValue:0},{argumentType:hn.NUMBER,greaterThan:0}],returnNumberType:Je.NUMBER_CURRENCY},TBILLYIELD:{method:"tbillyield",parameters:[{argumentType:hn.NUMBER,minValue:0},{argumentType:hn.NUMBER,minValue:0},{argumentType:hn.NUMBER,greaterThan:0}],returnNumberType:Je.NUMBER_PERCENT},FVSCHEDULE:{method:"fvschedule",parameters:[{argumentType:hn.NUMBER},{argumentType:hn.RANGE}],returnNumberType:Je.NUMBER_CURRENCY},NPV:{method:"npv",parameters:[{argumentType:hn.NUMBER},{argumentType:hn.ANY}],repeatLastArgs:1,returnNumberType:Je.NUMBER_CURRENCY},MIRR:{method:"mirr",parameters:[{argumentType:hn.RANGE},{argumentType:hn.NUMBER},{argumentType:hn.NUMBER}],returnNumberType:Je.NUMBER_PERCENT},PDURATION:{method:"pduration",parameters:[{argumentType:hn.NUMBER,greaterThan:0},{argumentType:hn.NUMBER,greaterThan:0},{argumentType:hn.NUMBER,greaterThan:0}]},XNPV:{method:"xnpv",parameters:[{argumentType:hn.NUMBER,greaterThan:-1},{argumentType:hn.RANGE},{argumentType:hn.RANGE}]}}; +/** + * @license + * Copyright (c) 2024 Handsoncode. All rights reserved. + */ +class _o extends un{formulatext(e,t){return this.runFunctionWithReferenceArgument(e.args,t,this.metadata("FORMULATEXT"),(()=>new Tr(ir.NA,Z.WrongArgNumber)),(e=>{var t;return null!==(t=this.serialization.getCellFormula(e))&&void 0!==t?t:new Tr(ir.NA,Z.Formula)}))}}_o.implementedFunctions={FORMULATEXT:{method:"formulatext",parameters:[{argumentType:hn.NOERROR}],doesNotNeedArgumentsToBeComputed:!0,isDependentOnSheetStructureChange:!0,vectorizationForbidden:!0}}; +/** + * @license + * Copyright (c) 2024 Handsoncode. All rights reserved. + */ +class bo extends un{hyperlink(e,t){return this.runFunction(e.args,t,this.metadata("HYPERLINK"),((t,r)=>(e.hyperlink=t,null!=r?r:t)))}}bo.implementedFunctions={HYPERLINK:{method:"hyperlink",parameters:[{argumentType:hn.STRING},{argumentType:hn.STRING,optionalArg:!0}]}}; +/** + * @license + * Copyright (c) 2024 Handsoncode. All rights reserved. + */ +class Ao extends un{isbinary(e,t){return this.runFunction(e.args,t,this.metadata("ISBINARY"),(e=>/^[01]{1,10}$/.test(e)))}iserr(e,t){return this.runFunction(e.args,t,this.metadata("ISERR"),(e=>e instanceof Tr&&e.type!==ir.NA))}iserror(e,t){return this.runFunction(e.args,t,this.metadata("ISERROR"),(e=>e instanceof Tr))}isformula(e,t){return this.runFunctionWithReferenceArgument(e.args,t,this.metadata("ISFORMULA"),(()=>new Tr(ir.NA,Z.WrongArgNumber)),(e=>this.dependencyGraph.addressMapping.getCell(e)instanceof Gt))}isblank(e,t){return this.runFunction(e.args,t,this.metadata("ISBLANK"),(e=>e===Ye))}isna(e,t){return this.runFunction(e.args,t,this.metadata("ISNA"),(e=>e instanceof Tr&&e.type==ir.NA))}isnumber(e,t){return this.runFunction(e.args,t,this.metadata("ISNUMBER"),Ze)}islogical(e,t){return this.runFunction(e.args,t,this.metadata("ISLOGICAL"),(e=>"boolean"==typeof e))}isref(e,t){return this.runFunction(e.args,t,this.metadata("ISREF"),(e=>e instanceof Tr&&(e.type==ir.REF||e.type==ir.CYCLE)))}istext(e,t){return this.runFunction(e.args,t,this.metadata("ISTEXT"),(e=>"string"==typeof e))}isnontext(e,t){return this.runFunction(e.args,t,this.metadata("ISNONTEXT"),(e=>!("string"==typeof e)))}column(e,t){return this.runFunctionWithReferenceArgument(e.args,t,this.metadata("COLUMN"),(()=>t.formulaAddress.col+1),(e=>e.col+1))}columns(e,t){if(1!==e.args.length)return new Tr(ir.NA,Z.WrongArgNumber);if(e.args.some((e=>e.type===U.EMPTY)))return new Tr(ir.NUM,Z.EmptyArg);let r=e.args[0];for(;r.type===U.PARENTHESIS;)r=r.expression;if(r.type===U.CELL_RANGE||r.type===U.COLUMN_RANGE)return r.end.col-r.start.col+1;if(r.type===U.CELL_REFERENCE)return 1;if(r.type===U.ROW_RANGE)return this.config.maxColumns;{const e=this.evaluateAst(r,t);return e instanceof rt?e.width():e instanceof Tr?e:1}}row(e,t){return this.runFunctionWithReferenceArgument(e.args,t,this.metadata("ROW"),(()=>t.formulaAddress.row+1),(e=>e.row+1))}rows(e,t){if(1!==e.args.length)return new Tr(ir.NA,Z.WrongArgNumber);if(e.args.some((e=>e.type===U.EMPTY)))return new Tr(ir.NUM,Z.EmptyArg);let r=e.args[0];for(;r.type===U.PARENTHESIS;)r=r.expression;if(r.type===U.CELL_RANGE||r.type===U.ROW_RANGE)return r.end.row-r.start.row+1;if(r.type===U.CELL_REFERENCE)return 1;if(r.type===U.COLUMN_RANGE)return this.config.maxRows;{const e=this.evaluateAst(r,t);return e instanceof rt?e.height():e instanceof Tr?e:1}}index(e,t){return this.runFunction(e.args,t,this.metadata("INDEX"),((e,t,r)=>{var n,s,i,o,a,l;return r<1||t<1?new Tr(ir.VALUE,Z.LessThanOne):r>e.width()||t>e.height()?new Tr(ir.NUM,Z.ValueLarge):null!==(l=null!==(i=null===(s=null===(n=null==e?void 0:e.data)||void 0===n?void 0:n[t-1])||void 0===s?void 0:s[r-1])&&void 0!==i?i:null===(a=null===(o=null==e?void 0:e.data)||void 0===o?void 0:o[0])||void 0===a?void 0:a[0])&&void 0!==l?l:new Tr(ir.VALUE,Z.CellRangeExpected)}))}na(e,t){return new Tr(ir.NA)}sheet(e,t){return this.runFunctionWithReferenceArgument(e.args,t,this.metadata("SHEET"),(()=>t.formulaAddress.sheet+1),(e=>e.sheet+1),(e=>{const t=this.dependencyGraph.sheetMapping.get(e);return void 0!==t?t+1:new Tr(ir.NA,Z.SheetRef)}))}sheets(e,t){return this.runFunctionWithReferenceArgument(e.args,t,this.metadata("SHEETS"),(()=>this.dependencyGraph.sheetMapping.numberOfSheets()),(()=>1),(()=>new Tr(ir.VALUE,Z.CellRefExpected)))}}Ao.implementedFunctions={COLUMN:{method:"column",parameters:[{argumentType:hn.NOERROR,optionalArg:!0}],isDependentOnSheetStructureChange:!0,doesNotNeedArgumentsToBeComputed:!0,vectorizationForbidden:!0},COLUMNS:{method:"columns",parameters:[{argumentType:hn.RANGE}],isDependentOnSheetStructureChange:!0,doesNotNeedArgumentsToBeComputed:!0,vectorizationForbidden:!0},ISBINARY:{method:"isbinary",parameters:[{argumentType:hn.STRING}]},ISERR:{method:"iserr",parameters:[{argumentType:hn.SCALAR}]},ISFORMULA:{method:"isformula",parameters:[{argumentType:hn.NOERROR}],doesNotNeedArgumentsToBeComputed:!0,vectorizationForbidden:!0},ISNA:{method:"isna",parameters:[{argumentType:hn.SCALAR}]},ISREF:{method:"isref",parameters:[{argumentType:hn.SCALAR}],vectorizationForbidden:!0},ISERROR:{method:"iserror",parameters:[{argumentType:hn.SCALAR}]},ISBLANK:{method:"isblank",parameters:[{argumentType:hn.SCALAR}]},ISNUMBER:{method:"isnumber",parameters:[{argumentType:hn.SCALAR}]},ISLOGICAL:{method:"islogical",parameters:[{argumentType:hn.SCALAR}]},ISTEXT:{method:"istext",parameters:[{argumentType:hn.SCALAR}]},ISNONTEXT:{method:"isnontext",parameters:[{argumentType:hn.SCALAR}]},INDEX:{method:"index",parameters:[{argumentType:hn.RANGE},{argumentType:hn.NUMBER},{argumentType:hn.NUMBER,defaultValue:1}]},NA:{method:"na",parameters:[]},ROW:{method:"row",parameters:[{argumentType:hn.NOERROR,optionalArg:!0}],isDependentOnSheetStructureChange:!0,doesNotNeedArgumentsToBeComputed:!0,vectorizationForbidden:!0},ROWS:{method:"rows",parameters:[{argumentType:hn.RANGE}],isDependentOnSheetStructureChange:!0,doesNotNeedArgumentsToBeComputed:!0,vectorizationForbidden:!0},SHEET:{method:"sheet",parameters:[{argumentType:hn.STRING}],doesNotNeedArgumentsToBeComputed:!0,vectorizationForbidden:!0},SHEETS:{method:"sheets",parameters:[{argumentType:hn.STRING}],doesNotNeedArgumentsToBeComputed:!0,vectorizationForbidden:!0}}; +/** + * @license + * Copyright (c) 2024 Handsoncode. All rights reserved. + */ +class Oo extends un{iseven(e,t){return this.runFunction(e.args,t,this.metadata("ISEVEN"),(e=>e%2==0))}}Oo.implementedFunctions={ISEVEN:{method:"iseven",parameters:[{argumentType:hn.NUMBER}]}}; +/** + * @license + * Copyright (c) 2024 Handsoncode. All rights reserved. + */ +class Io extends un{isodd(e,t){return this.runFunction(e.args,t,this.metadata("ISODD"),(e=>e%2==1))}}Io.implementedFunctions={ISODD:{method:"isodd",parameters:[{argumentType:hn.NUMBER}]}}; +/** + * @license + * Copyright (c) 2024 Handsoncode. All rights reserved. + */ +class xo extends un{log10(e,t){return this.runFunction(e.args,t,this.metadata("LOG10"),Math.log10)}log(e,t){return this.runFunction(e.args,t,this.metadata("LOG"),((e,t)=>Math.log(e)/Math.log(t)))}ln(e,t){return this.runFunction(e.args,t,this.metadata("LN"),Math.log)}}xo.implementedFunctions={LOG10:{method:"log10",parameters:[{argumentType:hn.NUMBER}]},LOG:{method:"log",parameters:[{argumentType:hn.NUMBER,greaterThan:0},{argumentType:hn.NUMBER,defaultValue:10,greaterThan:0}]},LN:{method:"ln",parameters:[{argumentType:hn.NUMBER}]}}; +/** + * @license + * Copyright (c) 2024 Handsoncode. All rights reserved. + */ +const Po=parseFloat(Math.PI.toFixed(14));class Lo extends un{pi(e,t){return this.runFunction(e.args,t,this.metadata("PI"),(()=>Po))}sqrtpi(e,t){return this.runFunction(e.args,t,this.metadata("SQRTPI"),(e=>Math.sqrt(Po*e)))}} +/** + * @license + * Copyright (c) 2024 Handsoncode. All rights reserved. + */ +function Do(e,t){return new cn(t.width,e.height)}function ko(e,t,r){return new cn(1+(e.width-t)/r,1+(e.height-t)/r)}Lo.implementedFunctions={PI:{method:"pi",parameters:[]},SQRTPI:{method:"sqrtpi",parameters:[{argumentType:hn.NUMBER,minValue:0}]}};class Ho extends un{mmult(e,t){return this.runFunction(e.args,t,this.metadata("MMULT"),((e,t)=>{if(!e.hasOnlyNumbers()||!t.hasOnlyNumbers())return new Tr(ir.VALUE,Z.NumberRange);if(t.height()!==e.width())return new Tr(ir.VALUE,Z.ArrayDimensions);const r=Do(e.size,t.size),n=this.createKernel((function(e,t,r){let n=0;for(let s=0;s{var n;return this.arraySizeForAst(e,new Br(t.formulaAddress,t.arraysFlag||null!==(n=null==r?void 0:r.arrayFunction)&&void 0!==n&&n))})),[s,i]=n;return Do(s,i)}maxpool(e,t){return this.runFunction(e.args,t,this.metadata("MAXPOOL"),((e,t,r=t)=>{if(!e.hasOnlyNumbers())return new Tr(ir.VALUE,Z.NumberRange);const n=ko(e.size,t,r),s=this.createKernel((function(e,t,r){const n=this.thread.x*r,s=this.thread.y*r;let i=e[s][n];for(let r=0;r{if(!e.hasOnlyNumbers())return new Tr(ir.VALUE,Z.NumberRange);const n=ko(e.size,t,r),s=this.createKernel((function(e,t,r){const n=this.thread.x*r,s=this.thread.y*r;let i=e[s][n];for(let r=0;rr&&i++;if(t%2==0){if(i===a/2){u=r;break}i>a/2?l=r:h=r}else{if(i===(a-1)/2){u=r;break}i>(a-1)/2?l=r:h=r}}return u}),n)(e.rawNumbers(),t,r);return rt.onlyNumbers(s)}))}maxpoolArraySize(e,t){if(e.args.length<2||e.args.length>3)return cn.error();const r=this.metadata("MAXPOOL"),n=e.args.map((e=>{var n;return this.arraySizeForAst(e,new Br(t.formulaAddress,t.arraysFlag||null!==(n=null==r?void 0:r.arrayFunction)&&void 0!==n&&n))}))[0],s=e.args[1];let i;i=s.type===U.NUMBER?s.value:1;let o=i;if(3===e.args.length){const t=e.args[2];o=t.type===U.NUMBER?t.value:1}return i>n.width||i>n.height||o>i||(n.width-i)%o!=0||(n.height-i)%o!=0?cn.error():ko(n,i,o)}medianpoolArraySize(e,t){return this.maxpoolArraySize(e,t)}transpose(e,t){return this.runFunction(e.args,t,this.metadata("TRANSPOSE"),(e=>{const t=e.rawData(),r=e.size,n=[];for(let e=0;e{var n;return this.arraySizeForAst(e,new Br(t.formulaAddress,t.arraysFlag||null!==(n=null==r?void 0:r.arrayFunction)&&void 0!==n&&n))})),[s]=n;return new cn(s.height,s.width)}createKernel(e,t){return function(...r){const n=[];for(let s=0;s{const t=this.arithmeticHelper.coerceNumbersExactRanges(e);return t instanceof Tr?t:0===t.length?new Tr(ir.NUM,Z.OneValue):(t.sort(((e,t)=>e-t)),t.length%2==0?(t[t.length/2-1]+t[t.length/2])/2:t[Math.floor(t.length/2)])}))}large(e,t){return this.runFunction(e.args,t,this.metadata("LARGE"),((e,t)=>{const r=this.arithmeticHelper.manyToExactNumbers(e.valuesFromTopLeftCorner());return r instanceof Tr?r:(r.sort(((e,t)=>e-t)),(t=Math.trunc(t))>r.length?new Tr(ir.NUM,Z.ValueLarge):r[r.length-t])}))}small(e,t){return this.runFunction(e.args,t,this.metadata("SMALL"),((e,t)=>{const r=this.arithmeticHelper.manyToExactNumbers(e.valuesFromTopLeftCorner());return r instanceof Tr?r:(r.sort(((e,t)=>e-t)),(t=Math.trunc(t))>r.length?new Tr(ir.NUM,Z.ValueLarge):r[t-1])}))}}Fo.implementedFunctions={MEDIAN:{method:"median",parameters:[{argumentType:hn.ANY}],repeatLastArgs:1},LARGE:{method:"large",parameters:[{argumentType:hn.RANGE},{argumentType:hn.NUMBER,minValue:1}]},SMALL:{method:"small",parameters:[{argumentType:hn.RANGE},{argumentType:hn.NUMBER,minValue:1}]}}; +/** + * @license + * Copyright (c) 2024 Handsoncode. All rights reserved. + */ +class Uo extends un{mod(e,t){return this.runFunction(e.args,t,this.metadata("MOD"),((e,t)=>0===t?new Tr(ir.DIV_BY_ZERO):e%t))}} +/** + * @license + * Copyright (c) 2024 Handsoncode. All rights reserved. + */ +function Vo(e){return Ze(e)&&!Number.isFinite(je(e))?0:e}Uo.implementedFunctions={MOD:{method:"mod",parameters:[{argumentType:hn.NUMBER},{argumentType:hn.NUMBER}]}};class Bo{constructor(e,t,r){this.sumsq=e,this.sum=t,this.count=r}static single(e){return new Bo(e*e,e,1)}compose(e){return new Bo(this.sumsq+e.sumsq,this.sum+e.sum,this.count+e.count)}averageValue(){return this.count>0?this.sum/this.count:void 0}varSValue(){return this.count>1?(this.sumsq-this.sum*this.sum/this.count)/(this.count-1):void 0}varPValue(){return this.count>0?(this.sumsq-this.sum*this.sum/this.count)/this.count:void 0}}Bo.empty=new Bo(0,0,0);class Wo extends un{constructor(){super(...arguments),this.addWithEpsilonRaw=(e,t)=>this.arithmeticHelper.addWithEpsilonRaw(e,t)}sum(e,t){return this.doSum(e.args,t)}sumsq(e,t){return this.reduce(e.args,t,0,"SUMSQ",this.addWithEpsilonRaw,(e=>Math.pow(je(e),2)),Yo)}max(e,t){return this.doMax(e.args,t)}maxa(e,t){return Vo(this.reduce(e.args,t,Number.NEGATIVE_INFINITY,"MAXA",((e,t)=>Math.max(e,t)),je,jo))}min(e,t){return this.doMin(e.args,t)}mina(e,t){return Vo(this.reduce(e.args,t,Number.POSITIVE_INFINITY,"MINA",((e,t)=>Math.min(e,t)),je,jo))}count(e,t){return this.doCount(e.args,t)}counta(e,t){return this.doCounta(e.args,t)}average(e,t){return this.doAverage(e.args,t)}averagea(e,t){var r;const n=this.reduce(e.args,t,Bo.empty,"_AGGREGATE_A",((e,t)=>e.compose(t)),(e=>Bo.single(je(e))),jo);return n instanceof Tr?n:null!==(r=n.averageValue())&&void 0!==r?r:new Tr(ir.DIV_BY_ZERO)}vars(e,t){return this.doVarS(e.args,t)}varp(e,t){return this.doVarP(e.args,t)}vara(e,t){var r;const n=this.reduceAggregateA(e.args,t);return n instanceof Tr?n:null!==(r=n.varSValue())&&void 0!==r?r:new Tr(ir.DIV_BY_ZERO)}varpa(e,t){var r;const n=this.reduceAggregateA(e.args,t);return n instanceof Tr?n:null!==(r=n.varPValue())&&void 0!==r?r:new Tr(ir.DIV_BY_ZERO)}stdevs(e,t){return this.doStdevS(e.args,t)}stdevp(e,t){return this.doStdevP(e.args,t)}stdeva(e,t){const r=this.reduceAggregateA(e.args,t);if(r instanceof Tr)return r;{const e=r.varSValue();return void 0===e?new Tr(ir.DIV_BY_ZERO):Math.sqrt(e)}}stdevpa(e,t){const r=this.reduceAggregateA(e.args,t);if(r instanceof Tr)return r;{const e=r.varPValue();return void 0===e?new Tr(ir.DIV_BY_ZERO):Math.sqrt(e)}}product(e,t){return this.doProduct(e.args,t)}subtotal(e,t){if(e.args.length<2)return new Tr(ir.NA,Z.WrongArgNumber);const r=this.coerceToType(this.evaluateAst(e.args[0],t),{argumentType:hn.NUMBER},t),n=e.args.slice(1);switch(r){case 1:case 101:return this.doAverage(n,t);case 2:case 102:return this.doCount(n,t);case 3:case 103:return this.doCounta(n,t);case 4:case 104:return this.doMax(n,t);case 5:case 105:return this.doMin(n,t);case 6:case 106:return this.doProduct(n,t);case 7:case 107:return this.doStdevS(n,t);case 8:case 108:return this.doStdevP(n,t);case 9:case 109:return this.doSum(n,t);case 10:case 110:return this.doVarS(n,t);case 11:case 111:return this.doVarP(n,t);default:return new Tr(ir.VALUE,Z.BadMode)}}reduceAggregate(e,t){return this.reduce(e,t,Bo.empty,"_AGGREGATE",((e,t)=>e.compose(t)),(e=>Bo.single(je(e))),Yo)}reduceAggregateA(e,t){return this.reduce(e,t,Bo.empty,"_AGGREGATE_A",((e,t)=>e.compose(t)),(e=>Bo.single(je(e))),jo)}doAverage(e,t){var r;const n=this.reduceAggregate(e,t);return n instanceof Tr?n:null!==(r=n.averageValue())&&void 0!==r?r:new Tr(ir.DIV_BY_ZERO)}doVarS(e,t){var r;const n=this.reduceAggregate(e,t);return n instanceof Tr?n:null!==(r=n.varSValue())&&void 0!==r?r:new Tr(ir.DIV_BY_ZERO)}doVarP(e,t){var r;const n=this.reduceAggregate(e,t);return n instanceof Tr?n:null!==(r=n.varPValue())&&void 0!==r?r:new Tr(ir.DIV_BY_ZERO)}doStdevS(e,t){const r=this.reduceAggregate(e,t);if(r instanceof Tr)return r;{const e=r.varSValue();return void 0===e?new Tr(ir.DIV_BY_ZERO):Math.sqrt(e)}}doStdevP(e,t){const r=this.reduceAggregate(e,t);if(r instanceof Tr)return r;{const e=r.varPValue();return void 0===e?new Tr(ir.DIV_BY_ZERO):Math.sqrt(e)}}doCount(e,t){return this.reduce(e,t,0,"COUNT",((e,t)=>e+t),je,(e=>Ze(e)?1:0))}doCounta(e,t){return this.reduce(e,t,0,"COUNTA",((e,t)=>e+t),je,(e=>e===Ye?0:1))}doMax(e,t){return Vo(this.reduce(e,t,Number.NEGATIVE_INFINITY,"MAX",((e,t)=>Math.max(e,t)),je,Yo))}doMin(e,t){return Vo(this.reduce(e,t,Number.POSITIVE_INFINITY,"MIN",((e,t)=>Math.min(e,t)),je,Yo))}doSum(e,t){return this.reduce(e,t,0,"SUM",this.addWithEpsilonRaw,je,Yo)}doProduct(e,t){return this.reduce(e,t,1,"PRODUCT",((e,t)=>e*t),je,Yo)}reduce(e,t,r,n,s,i,o){return e.length<1?new Tr(ir.NA,Z.WrongArgNumber):e.reduce(((e,a)=>{if(e instanceof Tr)return e;if(a.type===U.CELL_RANGE||a.type===U.COLUMN_RANGE||a.type===U.ROW_RANGE){const l=this.evaluateRange(a,t,r,n,s,i,o);return l instanceof Tr?l:s(l,e)}let l;if(l=this.evaluateAst(a,t),l instanceof rt){const t=Array.from(l.valuesFromTopLeftCorner()).map(o).filter((e=>void 0!==e));return t.map((e=>e instanceof Tr?e:i(e))).reduce(((e,t)=>e instanceof Tr?e:t instanceof Tr?t:s(e,t)),e)}if(a.type===U.CELL_REFERENCE){if(l=o(l),void 0===l)return e}else if(l=this.coerceScalarToNumberOrError(l),l=o(l),void 0===l)return e;return l instanceof Tr?l:s(e,i(l))}),r)}evaluateRange(e,t,r,n,s,i,o){let a;try{a=Fr.fromAst(e,t.formulaAddress)}catch(e){if(e instanceof ft)return new Tr(ir.REF,Z.RangeManySheets);throw e}const l=this.dependencyGraph.getRange(a.start,a.end);if(void 0===l)throw new Error("Range does not exists in graph");let h=l.getFunctionValue(n);if(void 0===h){h=this.getRangeValues(n,a,l,i,o).reduce(((e,t)=>e instanceof Tr?e:t instanceof Tr?t:s(e,t)),r),l.setFunctionValue(n,h)}return h}getRangeValues(e,t,r,n,s){const i=[],{smallerRangeVertex:o,restRange:a}=this.dependencyGraph.rangeMapping.findSmallerRange(t);let l;if(void 0!==o&&this.dependencyGraph.existsEdge(o,r)){const t=o.getFunctionValue(e);if(void 0!==t)i.push(t);else for(const e of o.range.addresses(this.dependencyGraph)){const t=s(this.dependencyGraph.getScalarValue(e));t instanceof Tr?i.push(t):void 0!==t&&i.push(n(t))}l=a}else l=t;for(const e of l.addresses(this.dependencyGraph)){const t=s(this.dependencyGraph.getScalarValue(e));t instanceof Tr?i.push(t):void 0!==t&&i.push(n(t))}return i}}function Yo(e){return Ze(e)||e instanceof Tr?e:void 0}function jo(e){return"boolean"==typeof e?zr(e):Ze(e)||e instanceof Tr?e:"string"==typeof e?0:void 0}Wo.implementedFunctions={SUM:{method:"sum",parameters:[{argumentType:hn.ANY}],repeatLastArgs:1},SUMSQ:{method:"sumsq",parameters:[{argumentType:hn.ANY}],repeatLastArgs:1},MAX:{method:"max",parameters:[{argumentType:hn.ANY}],repeatLastArgs:1},MIN:{method:"min",parameters:[{argumentType:hn.ANY}],repeatLastArgs:1},MAXA:{method:"maxa",parameters:[{argumentType:hn.ANY}],repeatLastArgs:1},MINA:{method:"mina",parameters:[{argumentType:hn.ANY}],repeatLastArgs:1},COUNT:{method:"count",parameters:[{argumentType:hn.ANY}],repeatLastArgs:1},COUNTA:{method:"counta",parameters:[{argumentType:hn.ANY}],repeatLastArgs:1},AVERAGE:{method:"average",parameters:[{argumentType:hn.ANY}],repeatLastArgs:1},AVERAGEA:{method:"averagea",parameters:[{argumentType:hn.ANY}],repeatLastArgs:1},PRODUCT:{method:"product",parameters:[{argumentType:hn.ANY}],repeatLastArgs:1},"VAR.S":{method:"vars",parameters:[{argumentType:hn.ANY}],repeatLastArgs:1},"VAR.P":{method:"varp",parameters:[{argumentType:hn.ANY}],repeatLastArgs:1},VARA:{method:"vara",parameters:[{argumentType:hn.ANY}],repeatLastArgs:1},VARPA:{method:"varpa",parameters:[{argumentType:hn.ANY}],repeatLastArgs:1},"STDEV.S":{method:"stdevs",parameters:[{argumentType:hn.ANY}],repeatLastArgs:1},"STDEV.P":{method:"stdevp",parameters:[{argumentType:hn.ANY}],repeatLastArgs:1},STDEVA:{method:"stdeva",parameters:[{argumentType:hn.ANY}],repeatLastArgs:1},STDEVPA:{method:"stdevpa",parameters:[{argumentType:hn.ANY}],repeatLastArgs:1},SUBTOTAL:{method:"subtotal",parameters:[{argumentType:hn.NUMBER},{argumentType:hn.ANY}],repeatLastArgs:1}},Wo.aliases={VAR:"VAR.S",VARP:"VAR.P",STDEV:"STDEV.S",STDEVP:"STDEV.P",VARS:"VAR.S",STDEVS:"STDEV.S"}; +/** + * @license + * Copyright (c) 2024 Handsoncode. All rights reserved. + */ +class Go extends un{power(e,t){return this.runFunction(e.args,t,this.metadata("POWER"),Math.pow)}}Go.implementedFunctions={POWER:{method:"power",parameters:[{argumentType:hn.NUMBER},{argumentType:hn.NUMBER}]}}; +/** + * @license + * Copyright (c) 2024 Handsoncode. All rights reserved. + */ +class zo extends un{radians(e,t){return this.runFunction(e.args,t,this.metadata("RADIANS"),(e=>e*(Math.PI/180)))}}zo.implementedFunctions={RADIANS:{method:"radians",parameters:[{argumentType:hn.NUMBER}]}}; +/** + * @license + * Copyright (c) 2024 Handsoncode. All rights reserved. + */ +const $o=10;class Ko extends un{dec2bin(e,t){return this.runFunction(e.args,t,this.metadata("DEC2BIN"),((e,t)=>qo(e,2,t)))}dec2oct(e,t){return this.runFunction(e.args,t,this.metadata("DEC2OCT"),((e,t)=>qo(e,8,t)))}dec2hex(e,t){return this.runFunction(e.args,t,this.metadata("DEC2HEX"),((e,t)=>qo(e,16,t)))}bin2dec(e,t){return this.runFunction(e.args,t,this.metadata("BIN2DEC"),(e=>{const t=Xo(e,2,$o);return void 0===t?new Tr(ir.NUM,Z.NotBinary):ea(t,2)}))}bin2oct(e,t){return this.runFunction(e.args,t,this.metadata("BIN2OCT"),((e,t)=>{const r=Xo(e,2,$o);return void 0===r?new Tr(ir.NUM,Z.NotBinary):qo(ea(r,2),8,t)}))}bin2hex(e,t){return this.runFunction(e.args,t,this.metadata("BIN2HEX"),((e,t)=>{const r=Xo(e,2,$o);return void 0===r?new Tr(ir.NUM,Z.NotBinary):qo(ea(r,2),16,t)}))}oct2dec(e,t){return this.runFunction(e.args,t,this.metadata("OCT2DEC"),(e=>{const t=Xo(e,8,$o);return void 0===t?new Tr(ir.NUM,Z.NotOctal):ea(t,8)}))}oct2bin(e,t){return this.runFunction(e.args,t,this.metadata("OCT2BIN"),((e,t)=>{const r=Xo(e,8,$o);return void 0===r?new Tr(ir.NUM,Z.NotOctal):qo(ea(r,8),2,t)}))}oct2hex(e,t){return this.runFunction(e.args,t,this.metadata("OCT2HEX"),((e,t)=>{const r=Xo(e,8,$o);return void 0===r?new Tr(ir.NUM,Z.NotOctal):qo(ea(r,8),16,t)}))}hex2dec(e,t){return this.runFunction(e.args,t,this.metadata("HEX2DEC"),(e=>{const t=Xo(e,16,$o);return void 0===t?new Tr(ir.NUM,Z.NotHex):ea(t,16)}))}hex2bin(e,t){return this.runFunction(e.args,t,this.metadata("HEX2BIN"),((e,t)=>{const r=Xo(e,16,$o);return void 0===r?new Tr(ir.NUM,Z.NotHex):qo(ea(r,16),2,t)}))}hex2oct(e,t){return this.runFunction(e.args,t,this.metadata("HEX2OCT"),((e,t)=>{const r=Xo(e,16,$o);return void 0===r?new Tr(ir.NUM,Z.NotHex):qo(ea(r,16),8,t)}))}base(e,t){return this.runFunction(e.args,t,this.metadata("BASE"),Zo)}decimal(e,t){return this.runFunction(e.args,t,this.metadata("DECIMAL"),((e,t)=>{const r=Xo(e,t,255);return void 0===r?new Tr(ir.NUM,Z.NotHex):parseInt(r,t)}))}}function Xo(e,t,r){const n="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ".substr(0,t),s=new RegExp(`^[${n}]+$`);if(!(e.length>r)&&s.test(e))return e}function qo(e,t,r){if(e>function(e){return-Qo(e)-1}(t))return new Tr(ir.NUM,Z.ValueBaseLarge);if(er?new Tr(ir.NUM,Z.ValueBaseLong):Jn(n,r)}function Qo(e){return-Math.pow(e,$o)/2}function Zo(e,t,r){const n=Jo(e,t);return void 0!==r&&r>n.length?Jn(n,r):n}function Jo(e,t){return(e+(e<0?Math.pow(t,$o):0)).toString(t).toUpperCase()}function ea(e,t){const r=parseInt(e,t),n=Math.pow(t,$o);return r>=n/2?r-n:r}Ko.implementedFunctions={DEC2BIN:{method:"dec2bin",parameters:[{argumentType:hn.NUMBER},{argumentType:hn.NUMBER,optionalArg:!0,minValue:1,maxValue:10}]},DEC2OCT:{method:"dec2oct",parameters:[{argumentType:hn.NUMBER},{argumentType:hn.NUMBER,optionalArg:!0,minValue:1,maxValue:10}]},DEC2HEX:{method:"dec2hex",parameters:[{argumentType:hn.NUMBER},{argumentType:hn.NUMBER,optionalArg:!0,minValue:1,maxValue:10}]},BIN2DEC:{method:"bin2dec",parameters:[{argumentType:hn.STRING}]},BIN2OCT:{method:"bin2oct",parameters:[{argumentType:hn.STRING},{argumentType:hn.NUMBER,optionalArg:!0,minValue:0,maxValue:$o}]},BIN2HEX:{method:"bin2hex",parameters:[{argumentType:hn.STRING},{argumentType:hn.NUMBER,optionalArg:!0,minValue:0,maxValue:$o}]},OCT2DEC:{method:"oct2dec",parameters:[{argumentType:hn.STRING}]},OCT2BIN:{method:"oct2bin",parameters:[{argumentType:hn.STRING},{argumentType:hn.NUMBER,optionalArg:!0,minValue:0,maxValue:$o}]},OCT2HEX:{method:"oct2hex",parameters:[{argumentType:hn.STRING},{argumentType:hn.NUMBER,optionalArg:!0,minValue:0,maxValue:$o}]},HEX2DEC:{method:"hex2dec",parameters:[{argumentType:hn.STRING}]},HEX2BIN:{method:"hex2bin",parameters:[{argumentType:hn.STRING},{argumentType:hn.NUMBER,optionalArg:!0,minValue:0,maxValue:$o}]},HEX2OCT:{method:"hex2oct",parameters:[{argumentType:hn.STRING},{argumentType:hn.NUMBER,optionalArg:!0,minValue:0,maxValue:$o}]},DECIMAL:{method:"decimal",parameters:[{argumentType:hn.STRING},{argumentType:hn.NUMBER,minValue:2,maxValue:36}]},BASE:{method:"base",parameters:[{argumentType:hn.NUMBER,minValue:0},{argumentType:hn.NUMBER,minValue:2,maxValue:36},{argumentType:hn.NUMBER,optionalArg:!0,minValue:0,maxValue:255}]}}; +/** + * @license + * Copyright (c) 2024 Handsoncode. All rights reserved. + */ +class ta extends un{rand(e,t){return this.runFunction(e.args,t,this.metadata("RAND"),Math.random)}randbetween(e,t){return this.runFunction(e.args,t,this.metadata("RANDBETWEEN"),((e,t)=>t{const r=Math.pow(10,t);return e<0?-Math.ceil(-e*r)/r:Math.ceil(e*r)/r}))}rounddown(e,t){return this.runFunction(e.args,t,this.metadata("ROUNDDOWN"),((e,t)=>{const r=Math.pow(10,t);return e<0?-Math.floor(-e*r)/r:Math.floor(e*r)/r}))}round(e,t){return this.runFunction(e.args,t,this.metadata("ROUND"),((e,t)=>{const r=Math.pow(10,t);return e<0?-Math.round(-e*r)/r:Math.round(e*r)/r}))}intFunc(e,t){return this.runFunction(e.args,t,this.metadata("INT"),(e=>e<0?-Math.floor(-e):Math.floor(e)))}even(e,t){return this.runFunction(e.args,t,this.metadata("EVEN"),(e=>e<0?-na(-e):na(e)))}odd(e,t){return this.runFunction(e.args,t,this.metadata("ODD"),(e=>e<0?-ra(-e):ra(e)))}ceilingmath(e,t){return this.runFunction(e.args,t,this.metadata("CEILING.MATH"),((e,t,r)=>0===t||0===e?0:(t=Math.abs(t),1===r&&e<0&&(t=-t),Math.ceil(e/t)*t)))}ceiling(e,t){return this.runFunction(e.args,t,this.metadata("CEILING"),((e,t)=>0===e?0:0===t?new Tr(ir.DIV_BY_ZERO):e>0&&t<0?new Tr(ir.NUM,Z.DistinctSigns):Math.ceil(e/t)*t))}ceilingprecise(e,t){return this.runFunction(e.args,t,this.metadata("CEILING.PRECISE"),((e,t)=>0===t||0===e?0:(t=Math.abs(t),Math.ceil(e/t)*t)))}floormath(e,t){return this.runFunction(e.args,t,this.metadata("FLOOR.MATH"),((e,t,r)=>0===t||0===e?0:(t=Math.abs(t),1===r&&e<0&&(t*=-1),Math.floor(e/t)*t)))}floor(e,t){return this.runFunction(e.args,t,this.metadata("FLOOR"),((e,t)=>0===e?0:0===t?new Tr(ir.DIV_BY_ZERO):e>0&&t<0?new Tr(ir.NUM,Z.DistinctSigns):Math.floor(e/t)*t))}floorprecise(e,t){return this.runFunction(e.args,t,this.metadata("FLOOR.PRECISE"),((e,t)=>0===t||0===e?0:(t=Math.abs(t),Math.floor(e/t)*t)))}}sa.implementedFunctions={ROUNDUP:{method:"roundup",parameters:[{argumentType:hn.NUMBER},{argumentType:hn.NUMBER,defaultValue:0}]},ROUNDDOWN:{method:"rounddown",parameters:[{argumentType:hn.NUMBER},{argumentType:hn.NUMBER,defaultValue:0}]},ROUND:{method:"round",parameters:[{argumentType:hn.NUMBER},{argumentType:hn.NUMBER,defaultValue:0}]},INT:{method:"intFunc",parameters:[{argumentType:hn.NUMBER}]},EVEN:{method:"even",parameters:[{argumentType:hn.NUMBER}]},ODD:{method:"odd",parameters:[{argumentType:hn.NUMBER}]},"CEILING.MATH":{method:"ceilingmath",parameters:[{argumentType:hn.NUMBER},{argumentType:hn.NUMBER,defaultValue:1},{argumentType:hn.NUMBER,defaultValue:0}]},CEILING:{method:"ceiling",parameters:[{argumentType:hn.NUMBER},{argumentType:hn.NUMBER}]},"CEILING.PRECISE":{method:"ceilingprecise",parameters:[{argumentType:hn.NUMBER},{argumentType:hn.NUMBER,defaultValue:1}]},"FLOOR.MATH":{method:"floormath",parameters:[{argumentType:hn.NUMBER},{argumentType:hn.NUMBER,defaultValue:1},{argumentType:hn.NUMBER,defaultValue:0}]},FLOOR:{method:"floor",parameters:[{argumentType:hn.NUMBER},{argumentType:hn.NUMBER}]},"FLOOR.PRECISE":{method:"floorprecise",parameters:[{argumentType:hn.NUMBER},{argumentType:hn.NUMBER,defaultValue:1}]}},sa.aliases={"ISO.CEILING":"CEILING.PRECISE",TRUNC:"ROUNDDOWN"}; +/** + * @license + * Copyright (c) 2024 Handsoncode. All rights reserved. + */ +class ia extends un{sqrt(e,t){return this.runFunction(e.args,t,this.metadata("SQRT"),Math.sqrt)}} +/** + * @license + * Copyright (c) 2024 Handsoncode. All rights reserved. + */ +function*oa(){}function aa(e){const t=e[Symbol.iterator](),{done:r,value:n}=t.next();return r?{rest:oa()}:{value:n,rest:t}}ia.implementedFunctions={SQRT:{method:"sqrt",parameters:[{argumentType:hn.NUMBER}]}};class la{constructor(e,t,r,n,s){this.interpreter=e,this.cacheKey=t,this.reduceInitialValue=r,this.composeFunction=n,this.mapFunction=s,this.dependencyGraph=this.interpreter.dependencyGraph}compute(e,t){for(const r of t)if(!r.conditionRange.sameDimensionsAs(e))return new Tr(ir.VALUE,Z.EqualLength);const r=this.tryToGetRangeVertexForRangeValue(e),n=t.map((e=>this.tryToGetRangeVertexForRangeValue(e.conditionRange)));if(r&&n.every((e=>void 0!==e))){const s=t.map((e=>e.criterionPackage.raw)).join(","),i=this.findAlreadyComputedValueInCache(r,this.cacheKey(t),s);if(void 0!==i)return this.interpreter.stats.incrementCriterionFunctionFullCacheUsed(),i;const o=this.buildNewCriterionCache(this.cacheKey(t),t.map((e=>e.conditionRange.range)),e.range);return o.has(s)||o.set(s,[this.evaluateRangeValue(e,t),t.map((e=>e.criterionPackage.lambda))]),r.setCriterionFunctionValues(this.cacheKey(t),o),n.forEach((e=>{void 0!==e&&e.addDependentCacheRange(r)})),o.get(s)[0]}return this.evaluateRangeValue(e,t)}tryToGetRangeVertexForRangeValue(e){const t=e.range;return void 0===t?void 0:this.dependencyGraph.getRange(t.start,t.end)}reduceFunction(e){let t=this.reduceInitialValue;for(const r of e)t=this.composeFunction(t,r);return t}findAlreadyComputedValueInCache(e,t,r){return e.getCriterionFunctionValue(t,r)}evaluateRangeValue(e,t){const r=t.map((e=>e.criterionPackage.lambda)),n=Array.from(e.valuesFromTopLeftCorner()).map(this.mapFunction)[Symbol.iterator](),s=ca(r,t.map((e=>e.conditionRange.iterateValuesFromTopLeftCorner())),n);return this.reduceFunction(s)}buildNewCriterionCache(e,t,r){const n=this.dependencyGraph.getRange(r.start,r.end),{smallerRangeVertex:s,restConditionRanges:i,restValuesRange:o}=((e,t,r)=>{if(r.end.row>r.start.row){const n=Ar(r.end.sheet,r.end.col,r.end.row-1),s=e.getRange(r.start,n);if(void 0!==s)return{smallerRangeVertex:s,restValuesRange:r.withStart(Ar(r.start.sheet,r.start.col,r.end.row)),restConditionRanges:t.map((e=>e.withStart(Ar(e.start.sheet,e.start.col,e.end.row))))}}return{restValuesRange:r,restConditionRanges:t}})(this.dependencyGraph,t,r);let a;a=void 0!==s&&this.dependencyGraph.existsEdge(s,n)?s.getCriterionFunctionValues(e):new Map;const l=new Map;return a.forEach((([e,t],r)=>{const n=ca(t,i.map((e=>ua(this.dependencyGraph,e))),Array.from(ua(this.dependencyGraph,o)).map(this.mapFunction)[Symbol.iterator]()),s=this.composeFunction(e,this.reduceFunction(n));this.interpreter.stats.incrementCriterionFunctionPartialCacheUsed(),l.set(r,[s,t])})),l}}class ha{constructor(e,t){this.conditionRange=e,this.criterionPackage=t}}function*ua(e,t){for(const r of t.addresses(e))yield je(e.getScalarValue(r))}function*ca(e,t,r){for(const n of r){const r=t.map((e=>aa(e)));if(!r.every((e=>Object.prototype.hasOwnProperty.call(e,"value"))))return;da(r.map((e=>je(e.value))),e).every((([e,t])=>t(e)))&&(yield n),t=r.map((e=>e.rest))}}function da(e,t){const r=[];for(let n=0;n0?this.sum/this.count:void 0}}function ga(e){return Ze(e)&&!Number.isFinite(je(e))?0:e}function fa(e){return e instanceof Tr?e:Ze(e)?je(e):void 0}pa.empty=new pa(0,0);class ma extends un{sumif(e,t){const r="SUMIF";return this.runFunction(e.args,t,this.metadata(r),((e,t,n)=>this.computeConditionalAggregationFunction(null!=n?n:e,[e,t],r,0,((e,t)=>this.arithmeticHelper.nonstrictadd(e,t)),fa)))}sumifs(e,t){const r="SUMIFS";return this.runFunction(e.args,t,this.metadata(r),((e,...t)=>this.computeConditionalAggregationFunction(e,t,r,0,((e,t)=>this.arithmeticHelper.nonstrictadd(e,t)),fa)))}averageif(e,t){const r="AVERAGEIF";return this.runFunction(e.args,t,this.metadata(r),((e,t,n)=>{const s=this.computeConditionalAggregationFunction(null!=n?n:e,[e,t],r,pa.empty,((e,t)=>e.compose(t)),(e=>Ze(e)?pa.single(je(e)):pa.empty));return s instanceof Tr?s:s.averageValue()||new Tr(ir.DIV_BY_ZERO)}))}countif(e,t){const r="COUNTIF";return this.runFunction(e.args,t,this.metadata(r),((e,t)=>this.computeConditionalAggregationFunction(e,[e,t],r,0,((e,t)=>e+t),(()=>1))))}countifs(e,t){const r="COUNTIFS";return this.runFunction(e.args,t,this.metadata(r),((...e)=>this.computeConditionalAggregationFunction(e[0],e,r,0,((e,t)=>e+t),(()=>1))))}minifs(e,t){const r="MINIFS",n=(e,t)=>void 0===t||void 0===e?void 0===t?e:t:Math.min(e,t);return this.runFunction(e.args,t,this.metadata(r),((e,...t)=>ga(this.computeConditionalAggregationFunction(e,t,r,Number.POSITIVE_INFINITY,n,fa))))}maxifs(e,t){const r="MAXIFS",n=(e,t)=>void 0===t||void 0===e?void 0===t?e:t:Math.max(e,t);return this.runFunction(e.args,t,this.metadata(r),((e,...t)=>ga(this.computeConditionalAggregationFunction(e,t,r,Number.NEGATIVE_INFINITY,n,fa))))}computeConditionalAggregationFunction(e,t,r,n,s,i){const o=[];for(let e=0;e{const r=t.map((e=>`${e.conditionRange.range.sheet},${e.conditionRange.range.start.col},${e.conditionRange.range.start.row}`));return[e,...r].join(",")}}(r),n,s,i).compute(e,o)}}ma.implementedFunctions={SUMIF:{method:"sumif",parameters:[{argumentType:hn.RANGE},{argumentType:hn.NOERROR},{argumentType:hn.RANGE,optionalArg:!0}]},COUNTIF:{method:"countif",parameters:[{argumentType:hn.RANGE},{argumentType:hn.NOERROR}]},AVERAGEIF:{method:"averageif",parameters:[{argumentType:hn.RANGE},{argumentType:hn.NOERROR},{argumentType:hn.RANGE,optionalArg:!0}]},SUMIFS:{method:"sumifs",parameters:[{argumentType:hn.RANGE},{argumentType:hn.RANGE},{argumentType:hn.NOERROR}],repeatLastArgs:2},COUNTIFS:{method:"countifs",parameters:[{argumentType:hn.RANGE},{argumentType:hn.NOERROR}],repeatLastArgs:2},MINIFS:{method:"minifs",parameters:[{argumentType:hn.RANGE},{argumentType:hn.RANGE},{argumentType:hn.NOERROR}],repeatLastArgs:2},MAXIFS:{method:"maxifs",parameters:[{argumentType:hn.RANGE},{argumentType:hn.RANGE},{argumentType:hn.NOERROR}],repeatLastArgs:2}}; +/** + * @license + * Copyright (c) 2024 Handsoncode. All rights reserved. + */ +class ya extends un{sumproduct(e,t){return this.runFunction(e.args,t,this.metadata("SUMPRODUCT"),((...e)=>{const t=e[0].width(),r=e[0].height();for(const n of e)if(n.width()!==t||n.height()!==r)return new Tr(ir.VALUE,Z.EqualLength);let n=0;const s=e.map((e=>e.iterateValuesFromTopLeftCorner()));for(let e=0;e"".concat(...e)))}split(e,t){return this.runFunction(e.args,t,this.metadata("SPLIT"),((e,t)=>{const r=e.split(" ");return t>=r.length||t<0?new Tr(ir.VALUE,Z.IndexBounds):r[t]}))}len(e,t){return this.runFunction(e.args,t,this.metadata("LEN"),(e=>e.length))}lower(e,t){return this.runFunction(e.args,t,this.metadata("LOWER"),(e=>e.toLowerCase()))}trim(e,t){return this.runFunction(e.args,t,this.metadata("TRIM"),(e=>e.replace(/^ +| +$/g,"").replace(/ +/g," ")))}proper(e,t){return this.runFunction(e.args,t,this.metadata("PROPER"),(e=>e.replace(/\p{L}+/gu,(e=>e.charAt(0).toUpperCase()+e.substring(1).toLowerCase()))))}clean(e,t){return this.runFunction(e.args,t,this.metadata("CLEAN"),(e=>e.replace(/[\u0000-\u001F]/g,"")))}exact(e,t){return this.runFunction(e.args,t,this.metadata("EXACT"),((e,t)=>e===t))}rept(e,t){return this.runFunction(e.args,t,this.metadata("REPT"),((e,t)=>t<0?new Tr(ir.VALUE,Z.NegativeCount):e.repeat(t)))}right(e,t){return this.runFunction(e.args,t,this.metadata("RIGHT"),((e,t)=>t<0?new Tr(ir.VALUE,Z.NegativeLength):0===t?"":e.slice(-t)))}left(e,t){return this.runFunction(e.args,t,this.metadata("LEFT"),((e,t)=>t<0?new Tr(ir.VALUE,Z.NegativeLength):e.slice(0,t)))}mid(e,t){return this.runFunction(e.args,t,this.metadata("MID"),((e,t,r)=>t<1?new Tr(ir.VALUE,Z.LessThanOne):r<0?new Tr(ir.VALUE,Z.NegativeLength):e.substring(t-1,t+r-1)))}replace(e,t){return this.runFunction(e.args,t,this.metadata("REPLACE"),((e,t,r,n)=>t<1?new Tr(ir.VALUE,Z.LessThanOne):r<0?new Tr(ir.VALUE,Z.NegativeLength):e.substring(0,t-1)+n+e.substring(t+r-1)))}search(e,t){return this.runFunction(e.args,t,this.metadata("SEARCH"),((e,t,r)=>{if(r<1||r>t.length)return new Tr(ir.VALUE,Z.LengthBounds);const n=e.toLowerCase(),s=t.substring(r-1).toLowerCase(),i=this.arithmeticHelper.requiresRegex(n)?this.arithmeticHelper.searchString(n,s):s.indexOf(n);return i>-1?i+r:new Tr(ir.VALUE,Z.PatternNotFound)}))}substitute(e,t){return this.runFunction(e.args,t,this.metadata("SUBSTITUTE"),((e,t,r,n)=>{const s=this.escapeRegExpSpecialCharacters(t),i=new RegExp(s,"g");if(void 0===n)return e.replace(i,r);if(n<1)return new Tr(ir.VALUE,Z.LessThanOne);let o,a=0;for(;null!==(o=i.exec(e));)if(n===++a)return e.substring(0,o.index)+r+e.substring(i.lastIndex);return e}))}find(e,t){return this.runFunction(e.args,t,this.metadata("FIND"),((e,t,r)=>{if(r<1||r>t.length)return new Tr(ir.VALUE,Z.IndexBounds);const n=t.substring(r-1).indexOf(e)+r;return n>0?n:new Tr(ir.VALUE,Z.PatternNotFound)}))}t(e,t){return this.runFunction(e.args,t,this.metadata("T"),(e=>e instanceof Tr||"string"==typeof e?e:""))}upper(e,t){return this.runFunction(e.args,t,this.metadata("UPPER"),(e=>e.toUpperCase()))}escapeRegExpSpecialCharacters(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}}Ea.implementedFunctions={CONCATENATE:{method:"concatenate",parameters:[{argumentType:hn.STRING}],repeatLastArgs:1,expandRanges:!0},EXACT:{method:"exact",parameters:[{argumentType:hn.STRING},{argumentType:hn.STRING}]},SPLIT:{method:"split",parameters:[{argumentType:hn.STRING},{argumentType:hn.NUMBER}]},LEN:{method:"len",parameters:[{argumentType:hn.STRING}]},LOWER:{method:"lower",parameters:[{argumentType:hn.STRING}]},MID:{method:"mid",parameters:[{argumentType:hn.STRING},{argumentType:hn.NUMBER},{argumentType:hn.NUMBER}]},TRIM:{method:"trim",parameters:[{argumentType:hn.STRING}]},T:{method:"t",parameters:[{argumentType:hn.SCALAR}]},PROPER:{method:"proper",parameters:[{argumentType:hn.STRING}]},CLEAN:{method:"clean",parameters:[{argumentType:hn.STRING}]},REPT:{method:"rept",parameters:[{argumentType:hn.STRING},{argumentType:hn.NUMBER}]},RIGHT:{method:"right",parameters:[{argumentType:hn.STRING},{argumentType:hn.NUMBER,defaultValue:1}]},LEFT:{method:"left",parameters:[{argumentType:hn.STRING},{argumentType:hn.NUMBER,defaultValue:1}]},REPLACE:{method:"replace",parameters:[{argumentType:hn.STRING},{argumentType:hn.NUMBER},{argumentType:hn.NUMBER},{argumentType:hn.STRING}]},SEARCH:{method:"search",parameters:[{argumentType:hn.STRING},{argumentType:hn.STRING},{argumentType:hn.NUMBER,defaultValue:1}]},SUBSTITUTE:{method:"substitute",parameters:[{argumentType:hn.STRING},{argumentType:hn.STRING},{argumentType:hn.STRING},{argumentType:hn.NUMBER,optionalArg:!0}]},FIND:{method:"find",parameters:[{argumentType:hn.STRING},{argumentType:hn.STRING},{argumentType:hn.NUMBER,defaultValue:1}]},UPPER:{method:"upper",parameters:[{argumentType:hn.STRING}]}}; +/** + * @license + * Copyright (c) 2024 Handsoncode. All rights reserved. + */ +class wa extends un{acos(e,t){return this.runFunction(e.args,t,this.metadata("ACOS"),Math.acos)}asin(e,t){return this.runFunction(e.args,t,this.metadata("ASIN"),Math.asin)}cos(e,t){return this.runFunction(e.args,t,this.metadata("COS"),Math.cos)}sin(e,t){return this.runFunction(e.args,t,this.metadata("SIN"),Math.sin)}tan(e,t){return this.runFunction(e.args,t,this.metadata("TAN"),Math.tan)}atan(e,t){return this.runFunction(e.args,t,this.metadata("ATAN"),Math.atan)}atan2(e,t){return this.runFunction(e.args,t,this.metadata("ATAN2"),((e,t)=>0===e&&0===t?new Tr(ir.DIV_BY_ZERO):Math.atan2(t,e)))}cot(e,t){return this.runFunction(e.args,t,this.metadata("COT"),(e=>0===e?new Tr(ir.DIV_BY_ZERO):1/Math.tan(e)))}acot(e,t){return this.runFunction(e.args,t,this.metadata("ACOT"),(e=>0===e?Po/2:Math.atan(1/e)))}sec(e,t){return this.runFunction(e.args,t,this.metadata("SEC"),(e=>1/Math.cos(e)))}csc(e,t){return this.runFunction(e.args,t,this.metadata("CSC"),(e=>0===e?new Tr(ir.DIV_BY_ZERO):1/Math.sin(e)))}sinh(e,t){return this.runFunction(e.args,t,this.metadata("SINH"),Math.sinh)}asinh(e,t){return this.runFunction(e.args,t,this.metadata("ASINH"),Math.asinh)}cosh(e,t){return this.runFunction(e.args,t,this.metadata("COSH"),Math.cosh)}acosh(e,t){return this.runFunction(e.args,t,this.metadata("ACOSH"),Math.acosh)}tanh(e,t){return this.runFunction(e.args,t,this.metadata("TANH"),Math.tanh)}atanh(e,t){return this.runFunction(e.args,t,this.metadata("ATANH"),Math.atanh)}coth(e,t){return this.runFunction(e.args,t,this.metadata("COTH"),(e=>0===e?new Tr(ir.DIV_BY_ZERO):1/Math.tanh(e)))}acoth(e,t){return this.runFunction(e.args,t,this.metadata("ACOTH"),(e=>0===e?new Tr(ir.NUM,Z.NonZero):Math.atanh(1/e)))}sech(e,t){return this.runFunction(e.args,t,this.metadata("SECH"),(e=>1/Math.cosh(e)))}csch(e,t){return this.runFunction(e.args,t,this.metadata("CSCH"),(e=>0===e?new Tr(ir.DIV_BY_ZERO):1/Math.sinh(e)))}}wa.implementedFunctions={ACOS:{method:"acos",parameters:[{argumentType:hn.NUMBER}]},ASIN:{method:"asin",parameters:[{argumentType:hn.NUMBER}]},COS:{method:"cos",parameters:[{argumentType:hn.NUMBER}]},SIN:{method:"sin",parameters:[{argumentType:hn.NUMBER}]},TAN:{method:"tan",parameters:[{argumentType:hn.NUMBER}]},ATAN:{method:"atan",parameters:[{argumentType:hn.NUMBER}]},ATAN2:{method:"atan2",parameters:[{argumentType:hn.NUMBER},{argumentType:hn.NUMBER}]},COT:{method:"cot",parameters:[{argumentType:hn.NUMBER}]},SEC:{method:"sec",parameters:[{argumentType:hn.NUMBER}]},CSC:{method:"csc",parameters:[{argumentType:hn.NUMBER}]},SINH:{method:"sinh",parameters:[{argumentType:hn.NUMBER}]},COSH:{method:"cosh",parameters:[{argumentType:hn.NUMBER}]},TANH:{method:"tanh",parameters:[{argumentType:hn.NUMBER}]},COTH:{method:"coth",parameters:[{argumentType:hn.NUMBER}]},SECH:{method:"sech",parameters:[{argumentType:hn.NUMBER}]},CSCH:{method:"csch",parameters:[{argumentType:hn.NUMBER}]},ACOT:{method:"acot",parameters:[{argumentType:hn.NUMBER}]},ASINH:{method:"asinh",parameters:[{argumentType:hn.NUMBER}]},ACOSH:{method:"acosh",parameters:[{argumentType:hn.NUMBER}]},ATANH:{method:"atanh",parameters:[{argumentType:hn.NUMBER}]},ACOTH:{method:"acoth",parameters:[{argumentType:hn.NUMBER}]}}; +/** + * @license + * Copyright (c) 2024 Handsoncode. All rights reserved. + */ +class Ca extends Di{constructor(e){super(e),this.dependencyGraph=e}find(e,t,r){return this.basicFind(e,t,"col",r)}} +/** + * @license + * Copyright (c) 2024 Handsoncode. All rights reserved. + */ +class va extends un{constructor(){super(...arguments),this.rowSearch=new Ca(this.dependencyGraph)}vlookup(e,t){return this.runFunction(e.args,t,this.metadata("VLOOKUP"),((e,t,r,n)=>{const s=t.range;return void 0===s?new Tr(ir.VALUE,Z.WrongType):r<1?new Tr(ir.VALUE,Z.LessThanOne):r>s.width()?new Tr(ir.REF,Z.IndexLarge):this.doVlookup(qr(e),t,r-1,n)}))}hlookup(e,t){return this.runFunction(e.args,t,this.metadata("HLOOKUP"),((e,t,r,n)=>{const s=t.range;return void 0===s?new Tr(ir.VALUE,Z.WrongType):r<1?new Tr(ir.VALUE,Z.LessThanOne):r>s.height()?new Tr(ir.REF,Z.IndexLarge):this.doHlookup(qr(e),t,r-1,n)}))}match(e,t){return this.runFunction(e.args,t,this.metadata("MATCH"),((e,t,r)=>this.doMatch(qr(e),t,r)))}searchInRange(e,t,r,n){if(!r&&"string"==typeof e&&this.arithmeticHelper.requiresRegex(e))return n.advancedFind(this.arithmeticHelper.eqMatcherFunction(e),t);{const s=r?{ordering:"asc"}:{ordering:"none",matchExactly:!0};return n.find(e,t,s)}}doVlookup(e,t,r,n){this.dependencyGraph.stats.start(et.VLOOKUP);const s=t.range;let i;i=void 0===s?rt.onlyValues(t.data.map((e=>[e[0]]))):rt.onlyRange(Fr.spanFrom(s.start,1,s.height()),this.dependencyGraph);const o=this.searchInRange(e,i,n,this.columnSearch);if(this.dependencyGraph.stats.end(et.VLOOKUP),-1===o)return new Tr(ir.NA,Z.ValueNotFound);let a;if(void 0===s)a=t.data[o][r];else{const e=Ar(s.sheet,s.start.col+r,s.start.row+o);a=this.dependencyGraph.getCellValue(e)}return a instanceof rt?new Tr(ir.VALUE,Z.WrongType):a}doHlookup(e,t,r,n){const s=t.range;let i;i=void 0===s?rt.onlyValues([t.data[0]]):rt.onlyRange(Fr.spanFrom(s.start,s.width(),1),this.dependencyGraph);const o=this.searchInRange(e,i,n,this.rowSearch);if(-1===o)return new Tr(ir.NA,Z.ValueNotFound);let a;if(void 0===s)a=t.data[r][o];else{const e=Ar(s.sheet,s.start.col+o,s.start.row+r);a=this.dependencyGraph.getCellValue(e)}return a instanceof rt?new Tr(ir.VALUE,Z.WrongType):a}doMatch(e,t,r){if(![-1,0,1].includes(r))return new Tr(ir.VALUE,Z.BadMode);if(t.width()>1&&t.height()>1)return new Tr(ir.NA);const n=0===r?{ordering:"none",matchExactly:!0}:{ordering:-1===r?"desc":"asc"},s=(1===t.width()?this.columnSearch:this.rowSearch).find(e,t,n);return-1===s?new Tr(ir.NA,Z.ValueNotFound):s+1}}va.implementedFunctions={VLOOKUP:{method:"vlookup",parameters:[{argumentType:hn.NOERROR},{argumentType:hn.RANGE},{argumentType:hn.NUMBER},{argumentType:hn.BOOLEAN,defaultValue:!0}]},HLOOKUP:{method:"hlookup",parameters:[{argumentType:hn.NOERROR},{argumentType:hn.RANGE},{argumentType:hn.NUMBER},{argumentType:hn.BOOLEAN,defaultValue:!0}]},MATCH:{method:"match",parameters:[{argumentType:hn.NOERROR},{argumentType:hn.RANGE},{argumentType:hn.NUMBER,defaultValue:1}]}}; +/** + * @license + * Copyright (c) 2024 Handsoncode. All rights reserved. + */ +class Ra extends un{roman(e,t){return this.runFunction(e.args,t,this.metadata("ROMAN"),((e,t)=>(e=Math.trunc(e),!1===t?t=4:!0===t&&(t=0),(t=je(this.coerceScalarToNumberOrError(t)))instanceof Tr?t:(t=Math.trunc(t))<0?new Tr(ir.VALUE,Z.ValueSmall):t>4?new Tr(ir.VALUE,Z.ValueLarge):function(e,t){const r={val:e%1e3,acc:"M".repeat(Math.floor(e/1e3))};4===t&&(Ta(r,"IM",999,1e3),Ta(r,"ID",499,500));t>=3&&(Ta(r,"VM",995,1e3),Ta(r,"VD",495,500));t>=2&&(Ta(r,"XM",990,1e3),Ta(r,"XD",490,500));t>=1&&(Ta(r,"LM",950,1e3),Ta(r,"LD",450,500));Ta(r,"CM",900,1e3),Ta(r,"CD",400,500),Ta(r,"D",500,900),r.acc+="C".repeat(Math.floor(r.val/100)),r.val%=100,t>=2&&(Ta(r,"IC",99,100),Ta(r,"IL",49,50));t>=1&&(Ta(r,"VC",95,100),Ta(r,"VL",45,50));return Ta(r,"XC",90,100),Ta(r,"XL",40,50),Ta(r,"L",50,90),r.acc+="X".repeat(Math.floor(r.val/10)),r.val%=10,Ta(r,"IX",9,10),Ta(r,"IV",4,5),Ta(r,"V",5,9),r.acc+="I".repeat(r.val),r.acc}(e,t))))}arabic(e,t){return this.runFunction(e.args,t,this.metadata("ARABIC"),(e=>{let t=!1;if((e=e.trim().toUpperCase()).startsWith("-")&&(t=!0,""===(e=e.slice(1))))return new Tr(ir.VALUE,Z.InvalidRoman);const r={input:e,acc:0};return Sa(r,{token:"MMM",val:3e3},{token:"MM",val:2e3},{token:"M",val:1e3}),Sa(r,{token:"IM",val:999},{token:"VM",val:995},{token:"XM",val:990},{token:"LM",val:950},{token:"CM",val:900}),Sa(r,{token:"D",val:500},{token:"ID",val:499},{token:"VD",val:495},{token:"XD",val:490},{token:"LD",val:450},{token:"CD",val:400}),Sa(r,{token:"CCC",val:300},{token:"CC",val:200},{token:"C",val:100}),Sa(r,{token:"IC",val:99},{token:"VC",val:95},{token:"XC",val:90}),Sa(r,{token:"L",val:50},{token:"IL",val:49},{token:"VL",val:45},{token:"XL",val:40}),Sa(r,{token:"XXX",val:30},{token:"XX",val:20},{token:"X",val:10}),Sa(r,{token:"IX",val:9}),Sa(r,{token:"V",val:5},{token:"IV",val:4}),Sa(r,{token:"III",val:3},{token:"II",val:2},{token:"I",val:1}),""!==r.input?new Tr(ir.VALUE,Z.InvalidRoman):t?-r.acc:r.acc}))}}function Sa(e,...t){for(const r of t)if(e.input.startsWith(r.token)){e.input=e.input.slice(r.token.length),e.acc+=r.val;break}}function Ta(e,t,r,n){e.val>=r&&e.valr)n=ba(t,r,i(t),u(t),-1);else{for(var s=!1,o=0,a=0,l=1,h=0,c=2/t,d=2*Ma.floor((r+Ma.floor(Ma.sqrt(40*r)))/2);d>0;d--)h=d*c*l-o,o=l,l=h,Ma.abs(l)>1e10&&(l*=1e-10,o*=1e-10,n*=1e-10,a*=1e-10),s&&(a+=l),s=!s,d==r&&(n=o);n/=a=2*a-l}return n}}(),ja=(Oa=.636619772,Ia=[-2957821389,7062834065,-512359803.6,10879881.29,-86327.92757,228.4622733].reverse(),xa=[40076544269,745249964.8,7189466.438,47447.2647,226.1030244,1].reverse(),Pa=[1,-.001098628627,2734510407e-14,-2073370639e-15,2.093887211e-7].reverse(),La=[-.01562499995,.0001430488765,-6911147651e-15,7.621095161e-7,-9.34945152e-8].reverse(),Da=[-4900604943e3,127527439e4,-51534381390,734926455.1,-4237922.726,8511.937935].reverse(),ka=[249958057e5,424441966400,3733650367,22459040.02,102042.605,354.9632885,1].reverse(),Ha=[1,.00183105,-3516396496e-14,2457520174e-15,-2.40337019e-7].reverse(),Fa=[.04687499995,-.0002002690873,8449199096e-15,-8.8228987e-7,1.05787412e-7].reverse(),Aa((function(e){var t=0,r=0,n=0,s=e*e,i=e-.785398164;return e<8?t=(r=_a(Ia,s))/(n=_a(xa,s))+Oa*Ya(e,0)*Ma.log(e):(r=_a(Pa,s=64/s),n=_a(La,s),t=Ma.sqrt(Oa/e)*(Ma.sin(i)*r+Ma.cos(i)*n*8/e)),t}),(function(e){var t=0,r=0,n=0,s=e*e,i=e-2.356194491;return e<8?t=(r=e*_a(Da,s))/(n=_a(ka,s))+Oa*(Ya(e,1)*Ma.log(e)-1/e):(r=_a(Ha,s=64/s),n=_a(Fa,s),t=Ma.sqrt(Oa/e)*(Ma.sin(i)*r+Ma.cos(i)*n*8/e)),t}),0,1,-1)),Ga=(Ua=[1,3.5156229,3.0899424,1.2067492,.2659732,.0360768,.0045813].reverse(),Va=[.39894228,.01328592,.00225319,-.00157565,.00916281,-.02057706,.02635537,-.01647633,.00392377].reverse(),Ba=[.5,.87890594,.51498869,.15084934,.02658733,.00301532,32411e-8].reverse(),Wa=[.39894228,-.03988024,-.00362018,.00163801,-.01031555,.02282967,-.02895312,.01787654,-.00420059].reverse(),function e(t,r){if(0===(r=Math.round(r)))return function(e){return e<=3.75?_a(Ua,e*e/14.0625):Ma.exp(Ma.abs(e))/Ma.sqrt(Ma.abs(e))*_a(Va,3.75/Ma.abs(e))}(t);if(1===r)return function(e){return e<3.75?e*_a(Ba,e*e/14.0625):(e<0?-1:1)*Ma.exp(Ma.abs(e))/Ma.sqrt(Ma.abs(e))*_a(Wa,3.75/Ma.abs(e))}(t);if(r<0)return NaN;if(0===Ma.abs(t))return 0;if(t==1/0)return 1/0;var n,s=0,i=2/Ma.abs(t),o=0,a=1,l=0;for(n=2*Ma.round((r+Ma.round(Ma.sqrt(40*r)))/2);n>0;n--)l=n*i*a+o,o=a,a=l,Ma.abs(a)>1e10&&(a*=1e-10,o*=1e-10,s*=1e-10),n==r&&(s=o);return s*=e(t,0)/a,t<0&&r%2?-s:s}),za=function(){var e=[-.57721566,.4227842,.23069756,.0348859,.00262698,1075e-7,74e-7].reverse(),t=[1.25331414,-.07832358,.02189568,-.01062446,.00587872,-.0025154,53208e-8].reverse();var r=[1,.15443144,-.67278579,-.18156897,-.01919402,-.00110404,-4686e-8].reverse(),n=[1.25331414,.23498619,-.0365562,.01504268,-.00780353,.00325614,-68245e-8].reverse();return Aa((function(r){return r<=2?-Ma.log(r/2)*Ga(r,0)+_a(e,r*r/4):Ma.exp(-r)/Ma.sqrt(r)*_a(t,2/r)}),(function(e){return e<=2?Ma.log(e/2)*Ga(e,1)+1/e*_a(r,e*e/4):Ma.exp(-e)/Ma.sqrt(e)*_a(n,2/e)}),0,2,1)}(); +/** + * @license + Copyright (c) 2013 jStat + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + */ +function $a(e){const t=[-1.3026537197817094,.6419697923564902,.019476473204185836,-.00956151478680863,-.000946595344482036,.000366839497852761,42523324806907e-18,-20278578112534e-18,-1624290004647e-18,130365583558e-17,1.5626441722e-8,-8.5238095915e-8,6.529054439e-9,5.059343495e-9,-9.91364156e-10,-2.27365122e-10,96467911e-18,2394038e-18,-6886027e-18,894487e-18,313092e-18,-112708e-18,381e-18,7106e-18,-1523e-18,-94e-18,121e-18,-28e-18];let r,n,s,i,o=t.length-1,a=!1,l=0,h=0;if(0===e)return 0;for(e<0&&(e=-e,a=!0),r=2/(2+e),n=4*r-2;o>0;o--)s=l,l=n*l-h+t[o],h=s;return i=r*Math.exp(-e*e+.5*(t[0]+n*l)-h),a?i-1:1-i}function Ka(e){return 1-$a(e)}function Xa(e){let t,r,n,s,i=0;if(e>=2)return-100;if(e<=0)return 100;for(s=e<1?e:2-e,n=Math.sqrt(-2*Math.log(s/2)),t=-.70711*((2.30753+.27061*n)/(1+n*(.99229+.04481*n))-n);i<2;i++)r=Ka(t)-s,t+=r/(1.1283791670955126*Math.exp(-t*t)-t*r);return e<1?t:-t}const qa=(e,t)=>e<0?0:t*Math.exp(-t*e),Qa=(e,t)=>e<0?0:1-Math.exp(-t*e);function Za(e){const t=[-1.716185138865495,24.76565080557592,-379.80425647094563,629.3311553128184,866.9662027904133,-31451.272968848367,-36144.413418691176,66456.14382024054],r=[-30.8402300119739,315.35062697960416,-1015.1563674902192,-3107.771671572311,22538.11842098015,4755.846277527881,-134659.9598649693,-115132.2596755535];let n,s,i,o,a=!1,l=0,h=0,u=0,c=e;if(e>171.6243769536076)return 1/0;if(c<=0){if(o=c%1,!o)return 1/0;a=(1&c?-1:1)*Math.PI/Math.sin(Math.PI*o),c=1-c}for(i=c,s=c<1?c++:(c-=l=(0|c)-1)-1,n=0;n<8;++n)u=(u+t[n])*s,h=h*s+r[n];if(o=u/h+1,ic)for(n=0;n=1?e:1/e)+.4*e+17);let d;if(t<0||e<=0)return NaN;if(t=1)return Math.max(100,t+100*Math.sqrt(t));if(e<=0)return 0;for(t>1?(u=Math.log(n),c=Math.exp(n*(u-1)-s),h=e<.5?e:1-e,a=Math.sqrt(-2*Math.log(h)),i=(2.30753+.27061*a)/(1+a*(.99229+.04481*a))-a,e<.5&&(i=-i),i=Math.max(.001,t*Math.pow(1-1/(9*t)-i/(3*Math.sqrt(t)),3))):(a=1-t*(.253+.12*t),i=e1?c*Math.exp(-(i-n)+n*(Math.log(i)-u)):Math.exp(-i+n*Math.log(i)-s),l=o/a,i-=a=l/(1-.5*Math.min(1,l*((t-1)/i-1))),i<=0&&(i=.5*(i+a)),Math.abs(a)<1e-8*i)break}return i}const il=function(e,t,r){return Math.exp(-.5*Math.log(2*Math.PI)-Math.log(r)-Math.pow(e-t,2)/(2*r*r))},ol=function(e,t,r){return.5*(1+$a((e-t)/Math.sqrt(2*r*r)))},al=function(e,t,r){return-1.4142135623730951*r*Xa(2*e)+t},ll=function(e,t,r){return e>1||e<0?0:1==t&&1==r?1:t<512&&r<512?Math.pow(e,t-1)*Math.pow(1-e,r-1)/cl(t,r):Math.exp((t-1)*Math.log(e)+(r-1)*Math.log(1-e)-dl(t,r))},hl=function(e,t,r){return e>1||e<0?+(e>1):gl(e,t,r)},ul=function(e,t,r){return pl(e,t,r)};function cl(e,t){if(!(e<=0||t<=0))return e+t>170?Math.exp(dl(e,t)):Za(e)*Za(t)/Za(e+t)}function dl(e,t){return rl(e)+rl(t)-rl(e+t)}function pl(e,t,r){var n,s,i,o,a,l,h,u,c,d,p=t-1,g=r-1,f=0;if(e<=0)return 0;if(e>=1)return 1;for(t>=1&&r>=1?(i=e<.5?e:1-e,l=(2.30753+.27061*(o=Math.sqrt(-2*Math.log(i))))/(1+o*(.99229+.04481*o))-o,e<.5&&(l=-l),h=(l*l-3)/6,u=2/(1/(2*t-1)+1/(2*r-1)),c=l*Math.sqrt(h+u)/u-(1/(2*r-1)-1/(2*t-1))*(h+5/6-2/(3*u)),l=t/(t+r*Math.exp(2*c))):(n=Math.log(t/(t+r)),s=Math.log(r/(t+r)),l=e<(o=Math.exp(t*n)/t)/(c=o+(a=Math.exp(r*s)/r))?Math.pow(t*c*e,1/t):1-Math.pow(r*c*(1-e),1/r)),d=-rl(t)-rl(r)+rl(t+r);f<10;f++){if(0===l||1===l)return l;if((l-=o=(a=(gl(l,t,r)-e)/(o=Math.exp(p*Math.log(l)+g*Math.log(1-l)+d)))/(1-.5*Math.min(1,a*(p/l-g/(1-l)))))<=0&&(l=.5*(l+o)),l>=1&&(l=.5*(l+o+1)),Math.abs(o)<1e-8*l&&f>0)break}return l}function gl(e,t,r){var n=0===e||1===e?0:Math.exp(rl(t+r)-rl(t)-rl(r)+t*Math.log(e)+r*Math.log(1-e));return!(e<0||e>1)&&(e<(t+1)/(t+r+2)?n*fl(e,t,r)/t:1-n*fl(1-e,r,t)/r)}function fl(e,t,r){var n,s,i,o,a=1e-30,l=1,h=t+r,u=t+1,c=t-1,d=1,p=1-h*e/u;for(Math.abs(p)=t)return 1;if(r<0||r>1||t<=0)return NaN;var i=r,o=(e=Math.floor(e))+1,a=t-e,l=o+a,h=Math.exp(rl(l)-rl(a)-rl(o)+o*Math.log(i)+a*Math.log(1-i));return n=i<(o+1)/(l+2)?h*El(i,o,a,s):1-h*El(1-i,a,o,s),Math.round(1/s*(1-n))/(1/s)};function El(e,t,r,n){for(var s,i=0,o=1,a=1,l=1,h=0,u=0;Math.abs((a-u)/a)>n;)u=a,o=l+(s=-(t+h)*(t+r+h)*e/(t+2*h)/(t+2*h+1))*o,a=(i=a+s*i)+(s=(h+=1)*(r-h)*e/(t+2*h-1)/(t+2*h))*a,i/=l=o+s*l,o/=l,a/=l,l=1;return a/t}function wl(e,t){return e>170||t>170?Math.exp(function(e,t){return Cl(e)-Cl(t)-Cl(e-t)}(e,t)):vl(e)/vl(t)/vl(e-t)}function Cl(e){return e<0?NaN:rl(e+1)}function vl(e){return e<0?NaN:Za(e+1)}const Rl=function(e,t){return e<0?0:0===e&&2===t?.5:Math.exp((t/2-1)*Math.log(e)-e/2-t/2*Math.log(2)-rl(t/2))},Sl=function(e,t){return e<0?0:nl(t/2,e/2)},Tl=function(e,t){return 2*sl(e,.5*t)},Nl=function(e,t,r){return e<0?0:t<=2?0===e&&t<2?1/0:0===e&&2===t?1:1/cl(t/2,r/2)*Math.pow(t/r,t/2)*Math.pow(e,t/2-1)*Math.pow(1+t/r*e,-(t+r)/2):t*(r/(r+e*t))/2*ml((t-2)/2,(t+r-2)/2,t*e/(r+e*t))},Ml=function(e,t,r){return e<0?0:gl(t*e/(t*e+r),t/2,r/2)},_l=function(e,t,r){return r/(t*(1/pl(e,t/2,r/2)-1))},bl=function(e,t,r){return e<0||t<0||r<0?0:r/t*Math.pow(e/t,r-1)*Math.exp(-Math.pow(e/t,r))},Al=function(e,t,r){return e<0?0:1-Math.exp(-Math.pow(e/t,r))},Ol={pdf:function(e,t){return t<0||e%1!=0||e<0?0:Math.pow(t,e)*Math.exp(-t)/vl(e)},cdf:function(e,t){var r=0;if(e<0)return 0;for(var n=0;r<=e;r++)n+=Ol.pdf(r,t);return n}},Il={pdf:function(e,t,r,n){if(e<0||en||e>r)return 0;if(2*r>t)return 2*n>t?Il.pdf(t-r-n+e,t,t-r,t-n):Il.pdf(n-e,t,t-r,n);if(2*n>t)return Il.pdf(r-e,t,r,t-n);if(r1&&i=s||t>=n)return 1;if(2*n>r)return 2*s>r?e(r-n-s+t,r,r-n,r-s):1-Il.cdf(s-t-1,r,r-n,s);if(2*s>r)return 1-Il.cdf(n-t-1,r,n,r-s);if(n1&&a1e100?1e100:t,1/(Math.sqrt(t)*cl(.5,t/2))*Math.pow(1+e*e/t,-(t+1)/2)},Pl=function(e,t){var r=t/2;return gl((e+Math.sqrt(e*e+t))/(2*Math.sqrt(e*e+t)),r,r)},Ll=function(e,t){var r=pl(2*Math.min(e,1-e),.5*t,.5);return r=Math.sqrt(t*(1-r)/r),e>.5?r:-r},Dl=function(e,t,r){return e<=0?0:Math.exp(-Math.log(e)-.5*Math.log(2*Math.PI)-Math.log(r)-Math.pow(Math.log(e)-t,2)/(2*r*r))},kl=function(e,t,r){return e<0?0:.5+.5*$a((Math.log(e)-t)/Math.sqrt(2*r*r))},Hl=function(e,t,r){return Math.exp(-1.4142135623730951*r*Xa(2*e)+t)},Fl={pdf:function(e,t,r){return e===e>>>0&&(e<0?0:wl(e+t-1,t-1)*Math.pow(1-r,e)*Math.pow(r,t))},cdf:function(e,t,r){var n=0,s=0;if(e<0)return 0;for(;s<=e;s++)n+=Fl.pdf(s,t,r);return n}};function Ul(e){for(var t=0,r=e.length;--r>=0;)t+=e[r];return t}function Vl(e){return Ul(e)/e.length}function Bl(e){for(var t,r=Vl(e),n=0,s=e.length;--s>=0;)n+=(t=e[s]-r)*t;return n}function Wl(e,t){return Bl(e)/(e.length-(t?1:0))}function Yl(e,t){return Math.sqrt(Wl(e,t))}function jl(e,t){var r,n=Vl(e),s=Vl(t),i=e.length,o=new Array(i);for(r=0;rvoid 0===t?$a(e):$a(t)-$a(e)))}erfc(e,t){return this.runFunction(e.args,t,this.metadata("ERFC"),Ka)}expondist(e,t){return this.runFunction(e.args,t,this.metadata("EXPON.DIST"),((e,t,r)=>r?Qa(e,t):qa(e,t)))}fisher(e,t){return this.runFunction(e.args,t,this.metadata("FISHER"),(e=>Math.log((1+e)/(1-e))/2))}fisherinv(e,t){return this.runFunction(e.args,t,this.metadata("FISHERINV"),(e=>1-2/(Math.exp(2*e)+1)))}gamma(e,t){return this.runFunction(e.args,t,this.metadata("GAMMA"),Za)}gammadist(e,t){return this.runFunction(e.args,t,this.metadata("GAMMA.DIST"),((e,t,r,n)=>n?el(e,t,r):Ja(e,t,r)))}gammaln(e,t){return this.runFunction(e.args,t,this.metadata("GAMMALN"),rl)}gammainv(e,t){return this.runFunction(e.args,t,this.metadata("GAMMA.INV"),tl)}gauss(e,t){return this.runFunction(e.args,t,this.metadata("GAUSS"),(e=>ol(e,0,1)-.5))}betadist(e,t){return this.runFunction(e.args,t,this.metadata("BETA.DIST"),((e,t,r,n,s,i)=>e<=s?new Tr(ir.NUM,Z.ValueSmall):e>=i?new Tr(ir.NUM,Z.ValueLarge):(e=(e-s)/(i-s),n?hl(e,t,r):ll(e,t,r))))}betainv(e,t){return this.runFunction(e.args,t,this.metadata("BETA.INV"),((e,t,r,n,s)=>n>=s?new Tr(ir.NUM,Z.WrongOrder):ul(e,t,r)*(s-n)+n))}binomialdist(e,t){return this.runFunction(e.args,t,this.metadata("BINOM.DIST"),((e,t,r,n)=>e>t?new Tr(ir.NUM,Z.WrongOrder):(e=Math.trunc(e),t=Math.trunc(t),n?yl(e,t,r):ml(e,t,r))))}binomialinv(e,t){return this.runFunction(e.args,t,this.metadata("BINOM.INV"),((e,t,r)=>{let n=-1,s=e=Math.trunc(e);for(;s>n+1;){const i=Math.trunc((n+s)/2);yl(i,e,t)>=r?s=i:n=i}return s}))}besselifn(e,t){return this.runFunction(e.args,t,this.metadata("BESSELI"),((e,t)=>Ga(e,Math.trunc(t))))}besseljfn(e,t){return this.runFunction(e.args,t,this.metadata("BESSELJ"),((e,t)=>Ya(e,Math.trunc(t))))}besselkfn(e,t){return this.runFunction(e.args,t,this.metadata("BESSELK"),((e,t)=>za(e,Math.trunc(t))))}besselyfn(e,t){return this.runFunction(e.args,t,this.metadata("BESSELY"),((e,t)=>ja(e,Math.trunc(t))))}chisqdist(e,t){return this.runFunction(e.args,t,this.metadata("CHISQ.DIST"),((e,t,r)=>(t=Math.trunc(t),r?Sl(e,t):Rl(e,t))))}chisqdistrt(e,t){return this.runFunction(e.args,t,this.metadata("CHISQ.DIST.RT"),((e,t)=>1-Sl(e,Math.trunc(t))))}chisqinv(e,t){return this.runFunction(e.args,t,this.metadata("CHISQ.INV"),((e,t)=>Tl(e,Math.trunc(t))))}chisqinvrt(e,t){return this.runFunction(e.args,t,this.metadata("CHISQ.INV.RT"),((e,t)=>Tl(1-e,Math.trunc(t))))}fdist(e,t){return this.runFunction(e.args,t,this.metadata("F.DIST"),((e,t,r,n)=>(t=Math.trunc(t),r=Math.trunc(r),n?Ml(e,t,r):Nl(e,t,r))))}fdistrt(e,t){return this.runFunction(e.args,t,this.metadata("F.DIST.RT"),((e,t,r)=>1-Ml(e,Math.trunc(t),Math.trunc(r))))}finv(e,t){return this.runFunction(e.args,t,this.metadata("F.INV"),((e,t,r)=>_l(e,Math.trunc(t),Math.trunc(r))))}finvrt(e,t){return this.runFunction(e.args,t,this.metadata("F.INV.RT"),((e,t,r)=>_l(1-e,Math.trunc(t),Math.trunc(r))))}weibulldist(e,t){return this.runFunction(e.args,t,this.metadata("WEIBULL.DIST"),((e,t,r,n)=>n?Al(e,r,t):bl(e,r,t)))}poissondist(e,t){return this.runFunction(e.args,t,this.metadata("POISSON.DIST"),((e,t,r)=>(e=Math.trunc(e),r?Ol.cdf(e,t):Ol.pdf(e,t))))}hypgeomdist(e,t){return this.runFunction(e.args,t,this.metadata("HYPGEOM.DIST"),((e,t,r,n,s)=>e>t||e>r||t>n||r>n||e+n(t=Math.trunc(t),r?Pl(e,t):xl(e,t))))}tdist2t(e,t){return this.runFunction(e.args,t,this.metadata("T.DIST.2T"),((e,t)=>2*(1-Pl(e,Math.trunc(t)))))}tdistrt(e,t){return this.runFunction(e.args,t,this.metadata("T.DIST.RT"),((e,t)=>1-Pl(e,Math.trunc(t))))}tdistold(e,t){return this.runFunction(e.args,t,this.metadata("TDIST"),((e,t,r)=>r*(1-Pl(e,Math.trunc(t)))))}tinv(e,t){return this.runFunction(e.args,t,this.metadata("T.INV"),((e,t)=>Ll(e,Math.trunc(t))))}tinv2t(e,t){return this.runFunction(e.args,t,this.metadata("T.INV.2T"),((e,t)=>Ll(1-e/2,Math.trunc(t))))}lognormdist(e,t){return this.runFunction(e.args,t,this.metadata("LOGNORM.DIST"),((e,t,r,n)=>n?kl(e,t,r):Dl(e,t,r)))}lognorminv(e,t){return this.runFunction(e.args,t,this.metadata("LOGNORM.INV"),((e,t,r)=>Hl(e,t,r)))}normdist(e,t){return this.runFunction(e.args,t,this.metadata("NORM.DIST"),((e,t,r,n)=>n?ol(e,t,r):il(e,t,r)))}norminv(e,t){return this.runFunction(e.args,t,this.metadata("NORM.INV"),((e,t,r)=>al(e,t,r)))}normsdist(e,t){return this.runFunction(e.args,t,this.metadata("NORM.S.DIST"),((e,t)=>t?ol(e,0,1):il(e,0,1)))}normsinv(e,t){return this.runFunction(e.args,t,this.metadata("NORM.S.INV"),(e=>al(e,0,1)))}phi(e,t){return this.runFunction(e.args,t,this.metadata("PHI"),(e=>il(e,0,1)))}negbinomdist(e,t){return this.runFunction(e.args,t,this.metadata("NEGBINOM.DIST"),((e,t,r,n)=>(e=Math.trunc(e),t=Math.trunc(t),n?Fl.cdf(e,t,r):Fl.pdf(e,t,r))))}confidencenorm(e,t){return this.runFunction(e.args,t,this.metadata("CONFIDENCE.NORM"),((e,t,r)=>function(){var e,t=[].slice.call(arguments),r=new Array(2);return e=4===t.length?Math.abs(al(t[1]/2,0,1)*t[2]/Math.sqrt(t[3])):Math.abs(al(t[1]/2,0,1)*Yl(t[2])/Math.sqrt(t[2].length)),r[0]=t[0]-e,r[1]=t[0]+e,r}(1,e,t,Math.trunc(r))[1]-1))}confidencet(e,t){return this.runFunction(e.args,t,this.metadata("CONFIDENCE.T"),((e,t,r)=>1===(r=Math.trunc(r))?new Tr(ir.DIV_BY_ZERO):function(){var e,t=[].slice.call(arguments),r=new Array(2);return e=4===t.length?Math.abs(Ll(t[1]/2,t[3]-1)*t[2]/Math.sqrt(t[3])):Math.abs(Ll(t[1]/2,t[2].length-1)*Yl(t[2],!0)/Math.sqrt(t[2].length)),r[0]=t[0]-e,r[1]=t[0]+e,r}(1,e,t,r)[1]-1))}standardize(e,t){return this.runFunction(e.args,t,this.metadata("STANDARDIZE"),((e,t,r)=>(e-t)/r))}}zl.implementedFunctions={ERF:{method:"erf",parameters:[{argumentType:hn.NUMBER},{argumentType:hn.NUMBER,optionalArg:!0}]},ERFC:{method:"erfc",parameters:[{argumentType:hn.NUMBER}]},"EXPON.DIST":{method:"expondist",parameters:[{argumentType:hn.NUMBER,minValue:0},{argumentType:hn.NUMBER,greaterThan:0},{argumentType:hn.BOOLEAN}]},FISHER:{method:"fisher",parameters:[{argumentType:hn.NUMBER,greaterThan:-1,lessThan:1}]},FISHERINV:{method:"fisherinv",parameters:[{argumentType:hn.NUMBER}]},GAMMA:{method:"gamma",parameters:[{argumentType:hn.NUMBER}]},"GAMMA.DIST":{method:"gammadist",parameters:[{argumentType:hn.NUMBER,minValue:0},{argumentType:hn.NUMBER,greaterThan:0},{argumentType:hn.NUMBER,greaterThan:0},{argumentType:hn.BOOLEAN}]},GAMMALN:{method:"gammaln",parameters:[{argumentType:hn.NUMBER,greaterThan:0}]},"GAMMA.INV":{method:"gammainv",parameters:[{argumentType:hn.NUMBER,minValue:0,lessThan:1},{argumentType:hn.NUMBER,greaterThan:0},{argumentType:hn.NUMBER,greaterThan:0}]},GAUSS:{method:"gauss",parameters:[{argumentType:hn.NUMBER}]},"BETA.DIST":{method:"betadist",parameters:[{argumentType:hn.NUMBER},{argumentType:hn.NUMBER,greaterThan:0},{argumentType:hn.NUMBER,greaterThan:0},{argumentType:hn.BOOLEAN},{argumentType:hn.NUMBER,defaultValue:0},{argumentType:hn.NUMBER,defaultValue:1}]},"BETA.INV":{method:"betainv",parameters:[{argumentType:hn.NUMBER,greaterThan:0,maxValue:1},{argumentType:hn.NUMBER,greaterThan:0},{argumentType:hn.NUMBER,greaterThan:0},{argumentType:hn.NUMBER,defaultValue:0},{argumentType:hn.NUMBER,defaultValue:1}]},"BINOM.DIST":{method:"binomialdist",parameters:[{argumentType:hn.NUMBER,minValue:0},{argumentType:hn.NUMBER,minValue:0},{argumentType:hn.NUMBER,minValue:0,maxValue:1},{argumentType:hn.BOOLEAN}]},"BINOM.INV":{method:"binomialinv",parameters:[{argumentType:hn.NUMBER,minValue:0},{argumentType:hn.NUMBER,minValue:0,maxValue:1},{argumentType:hn.NUMBER,greaterThan:0,lessThan:1}]},BESSELI:{method:"besselifn",parameters:[{argumentType:hn.NUMBER},{argumentType:hn.NUMBER,minValue:0}]},BESSELJ:{method:"besseljfn",parameters:[{argumentType:hn.NUMBER},{argumentType:hn.NUMBER,minValue:0}]},BESSELK:{method:"besselkfn",parameters:[{argumentType:hn.NUMBER},{argumentType:hn.NUMBER,minValue:0}]},BESSELY:{method:"besselyfn",parameters:[{argumentType:hn.NUMBER},{argumentType:hn.NUMBER,minValue:0}]},"CHISQ.DIST":{method:"chisqdist",parameters:[{argumentType:hn.NUMBER},{argumentType:hn.NUMBER,minValue:1,maxValue:1e10},{argumentType:hn.BOOLEAN}]},"CHISQ.DIST.RT":{method:"chisqdistrt",parameters:[{argumentType:hn.NUMBER},{argumentType:hn.NUMBER,minValue:1,maxValue:1e10}]},"CHISQ.INV":{method:"chisqinv",parameters:[{argumentType:hn.NUMBER,minValue:0,maxValue:1},{argumentType:hn.NUMBER,minValue:1,maxValue:1e10}]},"CHISQ.INV.RT":{method:"chisqinvrt",parameters:[{argumentType:hn.NUMBER,minValue:0,maxValue:1},{argumentType:hn.NUMBER,minValue:1}]},"F.DIST":{method:"fdist",parameters:[{argumentType:hn.NUMBER,minValue:0},{argumentType:hn.NUMBER,minValue:1},{argumentType:hn.NUMBER,minValue:1},{argumentType:hn.BOOLEAN}]},"F.DIST.RT":{method:"fdistrt",parameters:[{argumentType:hn.NUMBER,minValue:0},{argumentType:hn.NUMBER,minValue:1},{argumentType:hn.NUMBER,minValue:1}]},"F.INV":{method:"finv",parameters:[{argumentType:hn.NUMBER,minValue:0,maxValue:1},{argumentType:hn.NUMBER,minValue:1},{argumentType:hn.NUMBER,minValue:1}]},"F.INV.RT":{method:"finvrt",parameters:[{argumentType:hn.NUMBER,minValue:0,maxValue:1},{argumentType:hn.NUMBER,minValue:1},{argumentType:hn.NUMBER,minValue:1}]},"WEIBULL.DIST":{method:"weibulldist",parameters:[{argumentType:hn.NUMBER,minValue:0},{argumentType:hn.NUMBER,greaterThan:0},{argumentType:hn.NUMBER,greaterThan:0},{argumentType:hn.BOOLEAN}]},"POISSON.DIST":{method:"poissondist",parameters:[{argumentType:hn.NUMBER,minValue:0},{argumentType:hn.NUMBER,minValue:0},{argumentType:hn.BOOLEAN}]},"HYPGEOM.DIST":{method:"hypgeomdist",parameters:[{argumentType:hn.NUMBER,minValue:0},{argumentType:hn.NUMBER,greaterThan:0},{argumentType:hn.NUMBER,greaterThan:0},{argumentType:hn.NUMBER,greaterThan:0},{argumentType:hn.BOOLEAN}]},"T.DIST":{method:"tdist",parameters:[{argumentType:hn.NUMBER},{argumentType:hn.NUMBER,minValue:1},{argumentType:hn.BOOLEAN}]},"T.DIST.2T":{method:"tdist2t",parameters:[{argumentType:hn.NUMBER,minValue:0},{argumentType:hn.NUMBER,minValue:1}]},"T.DIST.RT":{method:"tdistrt",parameters:[{argumentType:hn.NUMBER},{argumentType:hn.NUMBER,minValue:1}]},TDIST:{method:"tdistold",parameters:[{argumentType:hn.NUMBER,minValue:0},{argumentType:hn.NUMBER,minValue:1},{argumentType:hn.INTEGER,minValue:1,maxValue:2}]},"T.INV":{method:"tinv",parameters:[{argumentType:hn.NUMBER,greaterThan:0,lessThan:1},{argumentType:hn.NUMBER,minValue:1}]},"T.INV.2T":{method:"tinv2t",parameters:[{argumentType:hn.NUMBER,greaterThan:0,maxValue:1},{argumentType:hn.NUMBER,minValue:1}]},"LOGNORM.DIST":{method:"lognormdist",parameters:[{argumentType:hn.NUMBER,greaterThan:0},{argumentType:hn.NUMBER},{argumentType:hn.NUMBER,greaterThan:0},{argumentType:hn.BOOLEAN}]},"LOGNORM.INV":{method:"lognorminv",parameters:[{argumentType:hn.NUMBER,greaterThan:0,lessThan:1},{argumentType:hn.NUMBER},{argumentType:hn.NUMBER,greaterThan:0}]},"NORM.DIST":{method:"normdist",parameters:[{argumentType:hn.NUMBER},{argumentType:hn.NUMBER},{argumentType:hn.NUMBER,greaterThan:0},{argumentType:hn.BOOLEAN}]},"NORM.INV":{method:"norminv",parameters:[{argumentType:hn.NUMBER,greaterThan:0,lessThan:1},{argumentType:hn.NUMBER},{argumentType:hn.NUMBER,greaterThan:0}]},"NORM.S.DIST":{method:"normsdist",parameters:[{argumentType:hn.NUMBER},{argumentType:hn.BOOLEAN}]},"NORM.S.INV":{method:"normsinv",parameters:[{argumentType:hn.NUMBER,greaterThan:0,lessThan:1}]},PHI:{method:"phi",parameters:[{argumentType:hn.NUMBER}]},"NEGBINOM.DIST":{method:"negbinomdist",parameters:[{argumentType:hn.NUMBER,minValue:0},{argumentType:hn.NUMBER,minValue:1},{argumentType:hn.NUMBER,minValue:0,maxValue:1},{argumentType:hn.BOOLEAN}]},"CONFIDENCE.NORM":{method:"confidencenorm",parameters:[{argumentType:hn.NUMBER,greaterThan:0,lessThan:1},{argumentType:hn.NUMBER,greaterThan:0},{argumentType:hn.NUMBER,minValue:1}]},"CONFIDENCE.T":{method:"confidencet",parameters:[{argumentType:hn.NUMBER,greaterThan:0,lessThan:1},{argumentType:hn.NUMBER,greaterThan:0},{argumentType:hn.NUMBER,minValue:1}]},STANDARDIZE:{method:"standardize",parameters:[{argumentType:hn.NUMBER},{argumentType:hn.NUMBER},{argumentType:hn.NUMBER,greaterThan:0}]}},zl.aliases={NEGBINOMDIST:"NEGBINOM.DIST",EXPONDIST:"EXPON.DIST",BETADIST:"BETA.DIST",NORMDIST:"NORM.DIST",NORMINV:"NORM.INV",NORMSDIST:"NORM.S.DIST",NORMSINV:"NORM.S.INV",LOGNORMDIST:"LOGNORM.DIST",LOGINV:"LOGNORM.INV",TINV:"T.INV.2T",HYPGEOMDIST:"HYPGEOM.DIST",POISSON:"POISSON.DIST",WEIBULL:"WEIBULL.DIST",FINV:"F.INV.RT",FDIST:"F.DIST.RT",CHIDIST:"CHISQ.DIST.RT",CHIINV:"CHISQ.INV.RT",GAMMADIST:"GAMMA.DIST","GAMMALN.PRECISE":"GAMMALN",GAMMAINV:"GAMMA.INV",BETAINV:"BETA.INV",BINOMDIST:"BINOM.DIST",CONFIDENCE:"CONFIDENCE.NORM",CRITBINOM:"BINOM.INV",WEIBULLDIST:"WEIBULL.DIST",TINV2T:"T.INV.2T",TDISTRT:"T.DIST.RT",TDIST2T:"T.DIST.2T",FINVRT:"F.INV.RT",FDISTRT:"F.DIST.RT",CHIDISTRT:"CHISQ.DIST.RT",CHIINVRT:"CHISQ.INV.RT",LOGNORMINV:"LOGNORM.INV",POISSONDIST:"POISSON.DIST"}; +/** + * @license + * Copyright (c) 2024 Handsoncode. All rights reserved. + */ +class $l extends un{fact(e,t){return this.runFunction(e.args,t,this.metadata("FACT"),(e=>{e=Math.trunc(e);let t=1;for(let r=1;r<=e;r++)t*=r;return t}))}factdouble(e,t){return this.runFunction(e.args,t,this.metadata("FACTDOUBLE"),(e=>{let t=1;for(let r=e=Math.trunc(e);r>=1;r-=2)t*=r;return t}))}combin(e,t){return this.runFunction(e.args,t,this.metadata("COMBIN"),((e,t)=>t>e?new Tr(ir.NUM,Z.WrongOrder):Kl(e=Math.trunc(e),t=Math.trunc(t))))}combina(e,t){return this.runFunction(e.args,t,this.metadata("COMBINA"),((e,t)=>(e=Math.trunc(e))+(t=Math.trunc(t))-1>=1030?new Tr(ir.NUM,Z.ValueLarge):0===e&&0===t?1:Kl(e+t-1,t)))}gcd(e,t){return this.runFunction(e.args,t,this.metadata("GCD"),((...e)=>{const t=this.arithmeticHelper.coerceNumbersCoerceRangesDropNulls(e);if(t instanceof Tr)return t;let r=0;for(const e of t){if(e<0)return new Tr(ir.NUM,Z.ValueSmall);r=Xl(r,Math.trunc(e))}return r>Number.MAX_SAFE_INTEGER?new Tr(ir.NUM,Z.ValueLarge):r}))}lcm(e,t){return this.runFunction(e.args,t,this.metadata("LCM"),((...e)=>{const t=this.arithmeticHelper.coerceNumbersCoerceRangesDropNulls(e);if(t instanceof Tr)return t;let r=1;for(const e of t){if(e<0)return new Tr(ir.NUM,Z.ValueSmall);r=ql(r,Math.trunc(e))}return r>Number.MAX_SAFE_INTEGER?new Tr(ir.NUM,Z.ValueLarge):r}))}mround(e,t){return this.runFunction(e.args,t,this.metadata("MROUND"),((e,t)=>0===t?0:e>0&&t<0||e<0&&t>0?new Tr(ir.NUM,Z.DistinctSigns):Math.round(e/t)*t))}multinomial(e,t){return this.runFunction(e.args,t,this.metadata("MULTINOMIAL"),((...e)=>{let t=0,r=1;for(let n of e){if(n<0)return new Tr(ir.NUM,Z.ValueSmall);n=Math.trunc(n);for(let e=1;e<=n;e++)r*=(t+e)/e;t+=n}return Math.round(r)}))}quotient(e,t){return this.runFunction(e.args,t,this.metadata("QUOTIENT"),((e,t)=>0===t?new Tr(ir.DIV_BY_ZERO):Math.trunc(e/t)))}seriessum(e,t){return this.runFunction(e.args,t,this.metadata("SERIESSUM"),((e,t,r,n)=>{const s=this.arithmeticHelper.manyToOnlyNumbersDropNulls(n.valuesFromTopLeftCorner());if(s instanceof Tr)return s;let i=0;s.reverse();for(const t of s)i*=Math.pow(e,r),i+=t;return i*Math.pow(e,t)}))}sign(e,t){return this.runFunction(e.args,t,this.metadata("SIGN"),(e=>e>0?1:e<0?-1:0))}sumx2my2(e,t){return this.runFunction(e.args,t,this.metadata("SUMX2MY2"),((e,t)=>{const r=e.valuesFromTopLeftCorner(),n=t.valuesFromTopLeftCorner();if(r.length!==n.length)return new Tr(ir.NA,Z.EqualLength);const s=r.length;let i=0;for(let e=0;e{const r=e.valuesFromTopLeftCorner(),n=t.valuesFromTopLeftCorner();if(r.length!==n.length)return new Tr(ir.NA,Z.EqualLength);const s=r.length;let i=0;for(let e=0;e{const r=e.valuesFromTopLeftCorner(),n=t.valuesFromTopLeftCorner();if(r.length!==n.length)return new Tr(ir.NA,Z.EqualLength);const s=r.length;let i=0;for(let e=0;ee&&(t=e-t);let r=1;for(let n=1;n<=t;n++)r*=(e-t+n)/n;return Math.round(r)}function Xl(e,t){for(e0;)[e,t]=[t,e%t];return e}function ql(e,t){return 0===e||0===t?0:e*(t/Xl(e,t))}$l.implementedFunctions={FACT:{method:"fact",parameters:[{argumentType:hn.NUMBER,minValue:0,maxValue:170}]},FACTDOUBLE:{method:"factdouble",parameters:[{argumentType:hn.NUMBER,minValue:0,maxValue:288}]},COMBIN:{method:"combin",parameters:[{argumentType:hn.NUMBER,minValue:0,lessThan:1030},{argumentType:hn.NUMBER,minValue:0}]},COMBINA:{method:"combina",parameters:[{argumentType:hn.NUMBER,minValue:0},{argumentType:hn.NUMBER,minValue:0}]},GCD:{method:"gcd",parameters:[{argumentType:hn.ANY}],repeatLastArgs:1},LCM:{method:"lcm",parameters:[{argumentType:hn.ANY}],repeatLastArgs:1},MROUND:{method:"mround",parameters:[{argumentType:hn.NUMBER},{argumentType:hn.NUMBER}]},MULTINOMIAL:{method:"multinomial",parameters:[{argumentType:hn.NUMBER}],repeatLastArgs:1,expandRanges:!0},QUOTIENT:{method:"quotient",parameters:[{argumentType:hn.NUMBER},{argumentType:hn.NUMBER}]},SERIESSUM:{method:"seriessum",parameters:[{argumentType:hn.NUMBER},{argumentType:hn.NUMBER},{argumentType:hn.NUMBER},{argumentType:hn.RANGE}]},SIGN:{method:"sign",parameters:[{argumentType:hn.NUMBER}]},SUMX2MY2:{method:"sumx2my2",parameters:[{argumentType:hn.RANGE},{argumentType:hn.RANGE}]},SUMX2PY2:{method:"sumx2py2",parameters:[{argumentType:hn.RANGE},{argumentType:hn.RANGE}]},SUMXMY2:{method:"sumxmy2",parameters:[{argumentType:hn.RANGE},{argumentType:hn.RANGE}]}}; +/** + * @license + * Copyright (c) 2024 Handsoncode. All rights reserved. + */ +class Ql extends un{complex(e,t){return this.runFunction(e.args,t,this.metadata("COMPLEX"),((e,t,r)=>"i"!==r&&"j"!==r?new Tr(ir.VALUE,Z.ShouldBeIorJ):jr([e,t],r)))}imabs(e,t){return this.runFunction(e.args,t,this.metadata("IMABS"),oh)}imaginary(e,t){return this.runFunction(e.args,t,this.metadata("IMAGINARY"),(([e,t])=>t))}imreal(e,t){return this.runFunction(e.args,t,this.metadata("IMREAL"),(([e,t])=>e))}imargument(e,t){return this.runFunction(e.args,t,this.metadata("IMARGUMENT"),(([e,t])=>0===e&&0===t?new Tr(ir.DIV_BY_ZERO):Math.atan2(t,e)))}imconjugate(e,t){return this.runFunction(e.args,t,this.metadata("IMCONJUGATE"),(([e,t])=>jr([e,-t])))}imcos(e,t){return this.runFunction(e.args,t,this.metadata("IMCOS"),(e=>jr(th(e))))}imcosh(e,t){return this.runFunction(e.args,t,this.metadata("IMCOSH"),(e=>jr(rh(e))))}imcot(e,t){return this.runFunction(e.args,t,this.metadata("IMCOT"),(e=>jr(eh(th(e),nh(e)))))}imcsc(e,t){return this.runFunction(e.args,t,this.metadata("IMCSC"),(e=>jr(eh([1,0],nh(e)))))}imcsch(e,t){return this.runFunction(e.args,t,this.metadata("IMCSCH"),(e=>jr(eh([1,0],sh(e)))))}imsec(e,t){return this.runFunction(e.args,t,this.metadata("IMSEC"),(e=>jr(eh([1,0],th(e)))))}imsech(e,t){return this.runFunction(e.args,t,this.metadata("IMSECH"),(e=>jr(eh([1,0],rh(e)))))}imsin(e,t){return this.runFunction(e.args,t,this.metadata("IMSIN"),(e=>jr(nh(e))))}imsinh(e,t){return this.runFunction(e.args,t,this.metadata("IMSINH"),(e=>jr(sh(e))))}imtan(e,t){return this.runFunction(e.args,t,this.metadata("IMTAN"),(e=>jr(eh(nh(e),th(e)))))}imdiv(e,t){return this.runFunction(e.args,t,this.metadata("IMDIV"),((e,t)=>jr(eh(e,t))))}improduct(e,t){return this.runFunction(e.args,t,this.metadata("IMPRODUCT"),((...e)=>{const t=this.arithmeticHelper.coerceComplexExactRanges(e);if(t instanceof Tr)return t;let r=[1,0];for(const e of t)r=Jl(r,e);return jr(r)}))}imsum(e,t){return this.runFunction(e.args,t,this.metadata("IMSUM"),((...e)=>{const t=this.arithmeticHelper.coerceComplexExactRanges(e);if(t instanceof Tr)return t;let r=[0,0];for(const e of t)r=Zl(r,e);return jr(r)}))}imsub(e,t){return this.runFunction(e.args,t,this.metadata("IMSUB"),((e,t)=>jr(function([e,t],[r,n]){return[e-r,t-n]}(e,t))))}imexp(e,t){return this.runFunction(e.args,t,this.metadata("IMEXP"),(e=>jr(ih(e))))}imln(e,t){return this.runFunction(e.args,t,this.metadata("IMLN"),(e=>jr(ah(e))))}imlog10(e,t){return this.runFunction(e.args,t,this.metadata("IMLOG10"),(e=>{const[t,r]=ah(e),n=Math.log(10);return jr([t/n,r/n])}))}imlog2(e,t){return this.runFunction(e.args,t,this.metadata("IMLOG2"),(e=>{const[t,r]=ah(e),n=Math.log(2);return jr([t/n,r/n])}))}impower(e,t){return this.runFunction(e.args,t,this.metadata("IMPOWER"),((e,t)=>jr(lh(e,t))))}imsqrt(e,t){return this.runFunction(e.args,t,this.metadata("IMSQRT"),(e=>jr(lh(e,.5))))}}function Zl([e,t],[r,n]){return[e+r,t+n]}function Jl([e,t],[r,n]){return[e*r-t*n,e*n+r*t]}function eh([e,t],[r,n]){const s=Math.pow(r,2)+Math.pow(n,2),[i,o]=Jl([e,t],[r,-n]);return[i/s,o/s]}function th([e,t]){return[Math.cos(e)*Math.cosh(t),-Math.sin(e)*Math.sinh(t)]}function rh([e,t]){return[Math.cosh(e)*Math.cos(t),Math.sinh(e)*Math.sin(t)]}function nh([e,t]){return[Math.sin(e)*Math.cosh(t),Math.cos(e)*Math.sinh(t)]}function sh([e,t]){return[Math.sinh(e)*Math.cos(t),Math.cosh(e)*Math.sin(t)]}function ih([e,t]){return[Math.exp(e)*Math.cos(t),Math.exp(e)*Math.sin(t)]}function oh([e,t]){return Math.sqrt(e*e+t*t)}function ah([e,t]){return[Math.log(oh([e,t])),Math.atan2(t,e)]}function lh(e,t){const[r,n]=ah(e);return ih([t*r,t*n])}Ql.implementedFunctions={COMPLEX:{method:"complex",parameters:[{argumentType:hn.NUMBER},{argumentType:hn.NUMBER},{argumentType:hn.STRING,defaultValue:"i"}]},IMABS:{method:"imabs",parameters:[{argumentType:hn.COMPLEX}]},IMAGINARY:{method:"imaginary",parameters:[{argumentType:hn.COMPLEX}]},IMREAL:{method:"imreal",parameters:[{argumentType:hn.COMPLEX}]},IMARGUMENT:{method:"imargument",parameters:[{argumentType:hn.COMPLEX}]},IMCONJUGATE:{method:"imconjugate",parameters:[{argumentType:hn.COMPLEX}]},IMCOS:{method:"imcos",parameters:[{argumentType:hn.COMPLEX}]},IMCOSH:{method:"imcosh",parameters:[{argumentType:hn.COMPLEX}]},IMCOT:{method:"imcot",parameters:[{argumentType:hn.COMPLEX}]},IMCSC:{method:"imcsc",parameters:[{argumentType:hn.COMPLEX}]},IMCSCH:{method:"imcsch",parameters:[{argumentType:hn.COMPLEX}]},IMSEC:{method:"imsec",parameters:[{argumentType:hn.COMPLEX}]},IMSECH:{method:"imsech",parameters:[{argumentType:hn.COMPLEX}]},IMSIN:{method:"imsin",parameters:[{argumentType:hn.COMPLEX}]},IMSINH:{method:"imsinh",parameters:[{argumentType:hn.COMPLEX}]},IMTAN:{method:"imtan",parameters:[{argumentType:hn.COMPLEX}]},IMDIV:{method:"imdiv",parameters:[{argumentType:hn.COMPLEX},{argumentType:hn.COMPLEX}]},IMPRODUCT:{method:"improduct",parameters:[{argumentType:hn.ANY}],repeatLastArgs:1},IMSUM:{method:"imsum",parameters:[{argumentType:hn.ANY}],repeatLastArgs:1},IMSUB:{method:"imsub",parameters:[{argumentType:hn.COMPLEX},{argumentType:hn.COMPLEX}]},IMEXP:{method:"imexp",parameters:[{argumentType:hn.COMPLEX}]},IMLN:{method:"imln",parameters:[{argumentType:hn.COMPLEX}]},IMLOG10:{method:"imlog10",parameters:[{argumentType:hn.COMPLEX}]},IMLOG2:{method:"imlog2",parameters:[{argumentType:hn.COMPLEX}]},IMPOWER:{method:"impower",parameters:[{argumentType:hn.COMPLEX},{argumentType:hn.NUMBER}]},IMSQRT:{method:"imsqrt",parameters:[{argumentType:hn.COMPLEX}]}}; +/** + * @license + * Copyright (c) 2024 Handsoncode. All rights reserved. + */ +class hh extends un{avedev(e,t){return this.runFunction(e.args,t,this.metadata("AVEDEV"),((...e)=>{const t=this.arithmeticHelper.coerceNumbersExactRanges(e);if(t instanceof Tr)return t;if(0===t.length)return new Tr(ir.DIV_BY_ZERO);const r=Vl(t);return t.reduce(((e,t)=>e+Math.abs(t-r)),0)/t.length}))}devsq(e,t){return this.runFunction(e.args,t,this.metadata("DEVSQ"),((...e)=>{const t=this.arithmeticHelper.coerceNumbersExactRanges(e);return t instanceof Tr?t:0===t.length?0:Bl(t)}))}geomean(e,t){return this.runFunction(e.args,t,this.metadata("GEOMEAN"),((...e)=>{const t=this.arithmeticHelper.coerceNumbersExactRanges(e);if(t instanceof Tr)return t;if(0===t.length)return new Tr(ir.NUM,Z.OneValue);for(const e of t)if(e<=0)return new Tr(ir.NUM,Z.ValueSmall);return r=t,Math.pow(function(e){for(var t=1,r=e.length;--r>=0;)t*=e[r];return t}(r),1/r.length);var r}))}harmean(e,t){return this.runFunction(e.args,t,this.metadata("HARMEAN"),((...e)=>{const t=this.arithmeticHelper.coerceNumbersExactRanges(e);if(t instanceof Tr)return t;if(0===t.length)return new Tr(ir.NUM,Z.OneValue);for(const e of t)if(e<=0)return new Tr(ir.NUM,Z.ValueSmall);return t.length/t.reduce(((e,t)=>e+1/t),0)}))}correl(e,t){return this.runFunction(e.args,t,this.metadata("CORREL"),((e,t)=>{if(e.numberOfElements()!==t.numberOfElements())return new Tr(ir.NA,Z.EqualLength);const r=uh(e,t);if(r instanceof Tr)return r;return r[0].length<=1?new Tr(ir.DIV_BY_ZERO,Z.TwoValues):Gl(r[0],r[1])}))}rsq(e,t){return this.runFunction(e.args,t,this.metadata("RSQ"),((e,t)=>{if(e.numberOfElements()!==t.numberOfElements())return new Tr(ir.NA,Z.EqualLength);const r=uh(e,t);if(r instanceof Tr)return r;return r[0].length<=1?new Tr(ir.DIV_BY_ZERO,Z.TwoValues):Math.pow(Gl(r[0],r[1]),2)}))}covariancep(e,t){return this.runFunction(e.args,t,this.metadata("COVARIANCE.P"),((e,t)=>{if(e.numberOfElements()!==t.numberOfElements())return new Tr(ir.NA,Z.EqualLength);const r=uh(e,t);if(r instanceof Tr)return r;const n=r[0].length;return n<1?new Tr(ir.DIV_BY_ZERO,Z.OneValue):1===n?0:jl(r[0],r[1])*(n-1)/n}))}covariances(e,t){return this.runFunction(e.args,t,this.metadata("COVARIANCE.S"),((e,t)=>{if(e.numberOfElements()!==t.numberOfElements())return new Tr(ir.NA,Z.EqualLength);const r=uh(e,t);if(r instanceof Tr)return r;return r[0].length<=1?new Tr(ir.DIV_BY_ZERO,Z.TwoValues):jl(r[0],r[1])}))}ztest(e,t){return this.runFunction(e.args,t,this.metadata("Z.TEST"),((e,t,r)=>{const n=this.arithmeticHelper.manyToExactNumbers(e.valuesFromTopLeftCorner());if(n instanceof Tr)return n;const s=n.length;if(void 0===r){if(s<2)return new Tr(ir.DIV_BY_ZERO,Z.TwoValues);r=Yl(n,!0)}return s<1?new Tr(ir.NA,Z.OneValue):0===r?new Tr(ir.DIV_BY_ZERO):1-ol((Vl(n)-t)/(r/Math.sqrt(s)),0,1)}))}ftest(e,t){return this.runFunction(e.args,t,this.metadata("F.TEST"),((e,t)=>{const r=this.arithmeticHelper.manyToExactNumbers(e.valuesFromTopLeftCorner()),n=this.arithmeticHelper.manyToExactNumbers(t.valuesFromTopLeftCorner());if(r instanceof Tr)return r;if(n instanceof Tr)return n;if(r.length<=1||n.length<=1)return new Tr(ir.DIV_BY_ZERO);const s=Wl(r,!0),i=Wl(n,!0);if(0===s||0===i)return new Tr(ir.DIV_BY_ZERO);const o=Ml(s/i,r.length-1,n.length-1);return 2*Math.min(o,1-o)}))}steyx(e,t){return this.runFunction(e.args,t,this.metadata("STEYX"),((e,t)=>{if(e.numberOfElements()!==t.numberOfElements())return new Tr(ir.NA,Z.EqualLength);const r=uh(e,t);if(r instanceof Tr)return r;const n=r[0].length;return n<=2?new Tr(ir.DIV_BY_ZERO,Z.ThreeValues):Math.sqrt((Bl(r[0])-Math.pow(jl(r[0],r[1])*(n-1),2)/Bl(r[1]))/(n-2))}))}slope(e,t){return this.runFunction(e.args,t,this.metadata("SLOPE"),((e,t)=>{if(e.numberOfElements()!==t.numberOfElements())return new Tr(ir.NA,Z.EqualLength);const r=uh(e,t);if(r instanceof Tr)return r;const n=r[0].length;return n<=1?new Tr(ir.DIV_BY_ZERO,Z.TwoValues):jl(r[0],r[1])*(n-1)/Bl(r[1])}))}chisqtest(e,t){return this.runFunction(e.args,t,this.metadata("CHISQ.TEST"),((e,t)=>{const r=e.height(),n=e.width();if(t.height()!==r||t.width()!==n)return new Tr(ir.NA,Z.EqualLength);const s=uh(e,t);if(s instanceof Tr)return s;if(s[0].length<=1)return new Tr(ir.DIV_BY_ZERO,Z.TwoValues);let i=0;for(let e=0;e1&&n>1?(r-1)*(n-1):r*n-1)}))}ttest(e,t){return this.runFunction(e.args,t,this.metadata("T.TEST"),((e,t,r,n)=>{const s=this.arithmeticHelper.manyToExactNumbers(e.valuesFromTopLeftCorner()),i=this.arithmeticHelper.manyToExactNumbers(t.valuesFromTopLeftCorner());if(s instanceof Tr)return s;if(i instanceof Tr)return i;const o=s.length,a=i.length;if(1===n){if(a!==o)return new Tr(ir.NA,Z.EqualLength);if(o<=1)return new Tr(ir.DIV_BY_ZERO,Z.TwoValues);const e=Array(o);for(let t=0;t{const t=this.arithmeticHelper.coerceNumbersExactRanges(e);if(t instanceof Tr)return t;const r=t.length;if(r<3)return new Tr(ir.DIV_BY_ZERO,Z.ThreeValues);const n=Vl(t),s=Yl(t,!0);return 0===s?new Tr(ir.DIV_BY_ZERO):t.reduce(((e,t)=>e+Math.pow((t-n)/s,3)),0)*r/(r-1)/(r-2)}))}skewp(e,t){return this.runFunction(e.args,t,this.metadata("SKEW.P"),((...e)=>{const t=this.arithmeticHelper.coerceNumbersExactRanges(e);if(t instanceof Tr)return t;const r=t.length;if(r<3)return new Tr(ir.DIV_BY_ZERO,Z.ThreeValues);const n=Vl(t),s=Yl(t,!1);return 0===s?new Tr(ir.DIV_BY_ZERO):t.reduce(((e,t)=>e+Math.pow((t-n)/s,3)),0)/r}))}}function uh(e,t){const r=e.iterateValuesFromTopLeftCorner(),n=t.iterateValuesFromTopLeftCorner();let s,i;const o=[],a=[];for(;s=r.next(),i=n.next(),!s.done&&!i.done;){const e=s.value,t=i.value;if(e instanceof Tr)return e;if(t instanceof Tr)return t;Ze(e)&&Ze(t)&&(o.push(je(e)),a.push(je(t)))}return[o,a]}hh.implementedFunctions={AVEDEV:{method:"avedev",parameters:[{argumentType:hn.ANY}],repeatLastArgs:1},DEVSQ:{method:"devsq",parameters:[{argumentType:hn.ANY}],repeatLastArgs:1},GEOMEAN:{method:"geomean",parameters:[{argumentType:hn.ANY}],repeatLastArgs:1},HARMEAN:{method:"harmean",parameters:[{argumentType:hn.ANY}],repeatLastArgs:1},CORREL:{method:"correl",parameters:[{argumentType:hn.RANGE},{argumentType:hn.RANGE}]},RSQ:{method:"rsq",parameters:[{argumentType:hn.RANGE},{argumentType:hn.RANGE}]},"COVARIANCE.P":{method:"covariancep",parameters:[{argumentType:hn.RANGE},{argumentType:hn.RANGE}]},"COVARIANCE.S":{method:"covariances",parameters:[{argumentType:hn.RANGE},{argumentType:hn.RANGE}]},"Z.TEST":{method:"ztest",parameters:[{argumentType:hn.RANGE},{argumentType:hn.NUMBER},{argumentType:hn.NUMBER,optionalArg:!0}]},"F.TEST":{method:"ftest",parameters:[{argumentType:hn.RANGE},{argumentType:hn.RANGE}]},STEYX:{method:"steyx",parameters:[{argumentType:hn.RANGE},{argumentType:hn.RANGE}]},SLOPE:{method:"slope",parameters:[{argumentType:hn.RANGE},{argumentType:hn.RANGE}]},"CHISQ.TEST":{method:"chisqtest",parameters:[{argumentType:hn.RANGE},{argumentType:hn.RANGE}]},"T.TEST":{method:"ttest",parameters:[{argumentType:hn.RANGE},{argumentType:hn.RANGE},{argumentType:hn.INTEGER,minValue:1,maxValue:2},{argumentType:hn.INTEGER,minValue:1,maxValue:3}]},SKEW:{method:"skew",parameters:[{argumentType:hn.ANY}],repeatLastArgs:1},"SKEW.P":{method:"skewp",parameters:[{argumentType:hn.ANY}],repeatLastArgs:1}},hh.aliases={COVAR:"COVARIANCE.P",FTEST:"F.TEST",PEARSON:"CORREL",ZTEST:"Z.TEST",CHITEST:"CHISQ.TEST",TTEST:"T.TEST",COVARIANCEP:"COVARIANCE.P",COVARIANCES:"COVARIANCE.S",SKEWP:"SKEW.P"}; +/** + * @license + * Copyright (c) 2024 Handsoncode. All rights reserved. + */ +class ch extends zi{}ch.HyperFormula=zi,ch.ErrorType=ir,ch.CellError=Tr,ch.CellType=or,ch.CellValueType=Er,ch.CellValueDetailedType=wr,ch.DetailedCellError=pn,ch.ExportedCellChange=pi,ch.ExportedNamedExpressionChange=gi,ch.ConfigValueTooBigError=_t,ch.ConfigValueTooSmallError=Mt,ch.EvaluationSuspendedError=At,ch.ExpectedOneOfValuesError=bt,ch.ExpectedValueOfTypeError=Tt,ch.ArraySize=cn,ch.SimpleRangeValue=rt,ch.EmptyValue=Ye,ch.FunctionPlugin=un,ch.FunctionArgumentType=hn,ch.FunctionPluginValidationError=Lt,ch.InvalidAddressError=pt,ch.InvalidArgumentsError=gt,ch.LanguageNotRegisteredError=xt,ch.LanguageAlreadyRegisteredError=Pt,ch.MissingTranslationError=Ot,ch.NamedExpressionDoesNotExistError=Et,ch.NamedExpressionNameIsAlreadyTakenError=mt,ch.NamedExpressionNameIsInvalidError=yt,ch.NoOperationToRedoError=Ct,ch.NoOperationToUndoError=wt,ch.NoRelativeAddressesAllowedError=Ft,ch.NoSheetWithIdError=lt,ch.NoSheetWithNameError=ht,ch.NotAFormulaError=dt,ch.NothingToPasteError=vt,ch.ProtectedFunctionTranslationError=It,ch.SheetNameAlreadyTakenError=ut,ch.SheetSizeLimitExceededError=ct,ch.SourceLocationHasArrayError=kt,ch.TargetLocationHasArrayError=Ht,ch.UnableToParseError=St;const dh=Ki.defaultConfig.language;zi.registerLanguage(dh,qi),zi.languages[qi.langCode]=qi;for(const e of Object.getOwnPropertyNames(i))e.startsWith("_")||zi.registerFunctionPlugin(i[e]);const ph=ch;window.HyperFormula=r(44820).Ay},14130:function(e,t,r){e.exports=function(){"use strict";function e(t){return e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e(t)}function t(e,r){return t=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},t(e,r)}function r(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}function n(e,s,i){return n=r()?Reflect.construct:function(e,r,n){var s=[null];s.push.apply(s,r);var i=new(Function.bind.apply(e,s));return n&&t(i,n.prototype),i},n.apply(null,arguments)}function s(e){return i(e)||o(e)||a(e)||h()}function i(e){if(Array.isArray(e))return l(e)}function o(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}function a(e,t){if(e){if("string"==typeof e)return l(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?l(e,t):void 0}}function l(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r1?r-1:0),s=1;s/gm),q=m(/\${[\w\W]*}/gm),Q=m(/^data-[\-\w.\u00B7-\uFFFF]/),Z=m(/^aria-[\-\w]+$/),J=m(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),ee=m(/^(?:\w+script|data):/i),te=m(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),re=m(/^html$/i),ne=m(/^[a-z][.\w]*(-[.\w]+)+$/i),se=function(){return"undefined"==typeof window?null:window},ie=function(t,r){if("object"!==e(t)||"function"!=typeof t.createPolicy)return null;var n=null,s="data-tt-policy-suffix";r.currentScript&&r.currentScript.hasAttribute(s)&&(n=r.currentScript.getAttribute(s));var i="dompurify"+(n?"#"+n:"");try{return t.createPolicy(i,{createHTML:function(e){return e},createScriptURL:function(e){return e}})}catch(e){return console.warn("TrustedTypes policy "+i+" could not be created."),null}};function oe(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:se(),r=function(e){return oe(e)};if(r.version="2.5.6",r.removed=[],!t||!t.document||9!==t.document.nodeType)return r.isSupported=!1,r;var n=t.document,i=t.document,o=t.DocumentFragment,a=t.HTMLTemplateElement,l=t.Node,h=t.Element,u=t.NodeFilter,c=t.NamedNodeMap,d=void 0===c?t.NamedNodeMap||t.MozNamedAttrMap:c,p=t.HTMLFormElement,g=t.DOMParser,m=t.trustedTypes,y=h.prototype,E=k(y,"cloneNode"),w=k(y,"nextSibling"),C=k(y,"childNodes"),x=k(y,"parentNode");if("function"==typeof a){var P=i.createElement("template");P.content&&P.content.ownerDocument&&(i=P.content.ownerDocument)}var ae=ie(m,n),le=ae?ae.createHTML(""):"",he=i,ue=he.implementation,ce=he.createNodeIterator,de=he.createDocumentFragment,pe=he.getElementsByTagName,ge=n.importNode,fe={};try{fe=D(i).documentMode?i.documentMode:{}}catch(e){}var me={};r.isSupported="function"==typeof x&&ue&&void 0!==ue.createHTMLDocument&&9!==fe;var ye,Ee,we=K,Ce=X,ve=q,Re=Q,Se=Z,Te=ee,Ne=te,Me=ne,_e=J,be=null,Ae=L({},[].concat(s(H),s(F),s(U),s(B),s(Y))),Oe=null,Ie=L({},[].concat(s(j),s(G),s(z),s($))),xe=Object.seal(Object.create(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),Pe=null,Le=null,De=!0,ke=!0,He=!1,Fe=!0,Ue=!1,Ve=!0,Be=!1,We=!1,Ye=!1,je=!1,Ge=!1,ze=!1,$e=!0,Ke=!1,Xe="user-content-",qe=!0,Qe=!1,Ze={},Je=null,et=L({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]),tt=null,rt=L({},["audio","video","img","source","image","track"]),nt=null,st=L({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),it="http://www.w3.org/1998/Math/MathML",ot="http://www.w3.org/2000/svg",at="http://www.w3.org/1999/xhtml",lt=at,ht=!1,ut=null,ct=L({},[it,ot,at],N),dt=["application/xhtml+xml","text/html"],pt="text/html",gt=null,ft=i.createElement("form"),mt=function(e){return e instanceof RegExp||e instanceof Function},yt=function(t){gt&>===t||(t&&"object"===e(t)||(t={}),t=D(t),ye=ye=-1===dt.indexOf(t.PARSER_MEDIA_TYPE)?pt:t.PARSER_MEDIA_TYPE,Ee="application/xhtml+xml"===ye?N:T,be="ALLOWED_TAGS"in t?L({},t.ALLOWED_TAGS,Ee):Ae,Oe="ALLOWED_ATTR"in t?L({},t.ALLOWED_ATTR,Ee):Ie,ut="ALLOWED_NAMESPACES"in t?L({},t.ALLOWED_NAMESPACES,N):ct,nt="ADD_URI_SAFE_ATTR"in t?L(D(st),t.ADD_URI_SAFE_ATTR,Ee):st,tt="ADD_DATA_URI_TAGS"in t?L(D(rt),t.ADD_DATA_URI_TAGS,Ee):rt,Je="FORBID_CONTENTS"in t?L({},t.FORBID_CONTENTS,Ee):et,Pe="FORBID_TAGS"in t?L({},t.FORBID_TAGS,Ee):{},Le="FORBID_ATTR"in t?L({},t.FORBID_ATTR,Ee):{},Ze="USE_PROFILES"in t&&t.USE_PROFILES,De=!1!==t.ALLOW_ARIA_ATTR,ke=!1!==t.ALLOW_DATA_ATTR,He=t.ALLOW_UNKNOWN_PROTOCOLS||!1,Fe=!1!==t.ALLOW_SELF_CLOSE_IN_ATTR,Ue=t.SAFE_FOR_TEMPLATES||!1,Ve=!1!==t.SAFE_FOR_XML,Be=t.WHOLE_DOCUMENT||!1,je=t.RETURN_DOM||!1,Ge=t.RETURN_DOM_FRAGMENT||!1,ze=t.RETURN_TRUSTED_TYPE||!1,Ye=t.FORCE_BODY||!1,$e=!1!==t.SANITIZE_DOM,Ke=t.SANITIZE_NAMED_PROPS||!1,qe=!1!==t.KEEP_CONTENT,Qe=t.IN_PLACE||!1,_e=t.ALLOWED_URI_REGEXP||_e,lt=t.NAMESPACE||at,xe=t.CUSTOM_ELEMENT_HANDLING||{},t.CUSTOM_ELEMENT_HANDLING&&mt(t.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(xe.tagNameCheck=t.CUSTOM_ELEMENT_HANDLING.tagNameCheck),t.CUSTOM_ELEMENT_HANDLING&&mt(t.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(xe.attributeNameCheck=t.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),t.CUSTOM_ELEMENT_HANDLING&&"boolean"==typeof t.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements&&(xe.allowCustomizedBuiltInElements=t.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),Ue&&(ke=!1),Ge&&(je=!0),Ze&&(be=L({},s(Y)),Oe=[],!0===Ze.html&&(L(be,H),L(Oe,j)),!0===Ze.svg&&(L(be,F),L(Oe,G),L(Oe,$)),!0===Ze.svgFilters&&(L(be,U),L(Oe,G),L(Oe,$)),!0===Ze.mathMl&&(L(be,B),L(Oe,z),L(Oe,$))),t.ADD_TAGS&&(be===Ae&&(be=D(be)),L(be,t.ADD_TAGS,Ee)),t.ADD_ATTR&&(Oe===Ie&&(Oe=D(Oe)),L(Oe,t.ADD_ATTR,Ee)),t.ADD_URI_SAFE_ATTR&&L(nt,t.ADD_URI_SAFE_ATTR,Ee),t.FORBID_CONTENTS&&(Je===et&&(Je=D(Je)),L(Je,t.FORBID_CONTENTS,Ee)),qe&&(be["#text"]=!0),Be&&L(be,["html","head","body"]),be.table&&(L(be,["tbody"]),delete Pe.tbody),f&&f(t),gt=t)},Et=L({},["mi","mo","mn","ms","mtext"]),wt=L({},["foreignobject","annotation-xml"]),Ct=L({},["title","style","font","a","script"]),vt=L({},F);L(vt,U),L(vt,V);var Rt=L({},B);L(Rt,W);var St=function(e){var t=x(e);t&&t.tagName||(t={namespaceURI:lt,tagName:"template"});var r=T(e.tagName),n=T(t.tagName);return!!ut[e.namespaceURI]&&(e.namespaceURI===ot?t.namespaceURI===at?"svg"===r:t.namespaceURI===it?"svg"===r&&("annotation-xml"===n||Et[n]):Boolean(vt[r]):e.namespaceURI===it?t.namespaceURI===at?"math"===r:t.namespaceURI===ot?"math"===r&&wt[n]:Boolean(Rt[r]):e.namespaceURI===at?!(t.namespaceURI===ot&&!wt[n])&&!(t.namespaceURI===it&&!Et[n])&&!Rt[r]&&(Ct[r]||!vt[r]):!("application/xhtml+xml"!==ye||!ut[e.namespaceURI]))},Tt=function(e){S(r.removed,{element:e});try{e.parentNode.removeChild(e)}catch(t){try{e.outerHTML=le}catch(t){e.remove()}}},Nt=function(e,t){try{S(r.removed,{attribute:t.getAttributeNode(e),from:t})}catch(e){S(r.removed,{attribute:null,from:t})}if(t.removeAttribute(e),"is"===e&&!Oe[e])if(je||Ge)try{Tt(t)}catch(e){}else try{t.setAttribute(e,"")}catch(e){}},Mt=function(e){var t,r;if(Ye)e=""+e;else{var n=M(e,/^[\r\n\t ]+/);r=n&&n[0]}"application/xhtml+xml"===ye&<===at&&(e=''+e+"");var s=ae?ae.createHTML(e):e;if(lt===at)try{t=(new g).parseFromString(s,ye)}catch(e){}if(!t||!t.documentElement){t=ue.createDocument(lt,"template",null);try{t.documentElement.innerHTML=ht?le:s}catch(e){}}var o=t.body||t.documentElement;return e&&r&&o.insertBefore(i.createTextNode(r),o.childNodes[0]||null),lt===at?pe.call(t,Be?"html":"body")[0]:Be?t.documentElement:o},_t=function(e){return ce.call(e.ownerDocument||e,e,u.SHOW_ELEMENT|u.SHOW_COMMENT|u.SHOW_TEXT|u.SHOW_PROCESSING_INSTRUCTION|u.SHOW_CDATA_SECTION,null,!1)},bt=function(e){return e instanceof p&&("string"!=typeof e.nodeName||"string"!=typeof e.textContent||"function"!=typeof e.removeChild||!(e.attributes instanceof d)||"function"!=typeof e.removeAttribute||"function"!=typeof e.setAttribute||"string"!=typeof e.namespaceURI||"function"!=typeof e.insertBefore||"function"!=typeof e.hasChildNodes)},At=function(t){return"object"===e(l)?t instanceof l:t&&"object"===e(t)&&"number"==typeof t.nodeType&&"string"==typeof t.nodeName},Ot=function(e,t,n){me[e]&&v(me[e],(function(e){e.call(r,t,n,gt)}))},It=function(e){var t;if(Ot("beforeSanitizeElements",e,null),bt(e))return Tt(e),!0;if(O(/[\u0080-\uFFFF]/,e.nodeName))return Tt(e),!0;var n=Ee(e.nodeName);if(Ot("uponSanitizeElement",e,{tagName:n,allowedTags:be}),e.hasChildNodes()&&!At(e.firstElementChild)&&(!At(e.content)||!At(e.content.firstElementChild))&&O(/<[/\w]/g,e.innerHTML)&&O(/<[/\w]/g,e.textContent))return Tt(e),!0;if("select"===n&&O(/