chunk-QRYBFJ3R.js 1000 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906
  1. import {
  2. $R,
  3. AC,
  4. BehaviorSubject,
  5. Ct,
  6. DC,
  7. De,
  8. Fe,
  9. J0,
  10. KC,
  11. Mf,
  12. Mt,
  13. Observable,
  14. Op,
  15. Ot,
  16. Pt,
  17. Qr,
  18. Ra,
  19. SC,
  20. SE,
  21. SR,
  22. Subject,
  23. Vr,
  24. Ze,
  25. _n,
  26. ar,
  27. dn,
  28. en,
  29. filter,
  30. firstValueFrom,
  31. isObservable,
  32. jC,
  33. kt,
  34. ln,
  35. nf,
  36. nt,
  37. nu,
  38. of,
  39. ot,
  40. re,
  41. shareReplay,
  42. st,
  43. take,
  44. takeUntil,
  45. tt,
  46. ur,
  47. vC,
  48. we,
  49. xC,
  50. yC
  51. } from "./chunk-23V3HWTR.js";
  52. // node_modules/.pnpm/@univerjs+rpc@0.5.5_@grpc+grpc-js@1.13.4_react@18.3.1_rxjs@7.8.1/node_modules/@univerjs/rpc/lib/es/index.js
  53. var X = Object.defineProperty;
  54. var Z = (r, t, e) => t in r ? X(r, t, { enumerable: true, configurable: true, writable: true, value: e }) : r[t] = e;
  55. var a = (r, t, e) => Z(r, typeof t != "symbol" ? t + "" : t, e);
  56. var he = "rpc.main-thread.config";
  57. var D = {};
  58. var _e = "rpc.worker-thread.config";
  59. var N = {};
  60. var le = Object.defineProperty;
  61. var ue = Object.getOwnPropertyDescriptor;
  62. var G = (r, t, e, n) => {
  63. for (var s = n > 1 ? void 0 : n ? ue(t, e) : t, i = r.length - 1, c; i >= 0; i--)
  64. (c = r[i]) && (s = (n ? c(t, e, s) : c(s)) || s);
  65. return n && s && le(t, e, s), s;
  66. };
  67. var p = (r, t) => (e, n) => t(e, n, r);
  68. var T = "rpc.remote-sync.service";
  69. var f = Ct(T);
  70. var M = class {
  71. constructor(r) {
  72. this._commandService = r;
  73. }
  74. async syncMutation(r) {
  75. return this._commandService.syncExecuteCommand(r.mutationInfo.id, r.mutationInfo.params, {
  76. onlyLocal: true,
  77. fromSync: true
  78. });
  79. }
  80. };
  81. M = G([
  82. p(0, Pt)
  83. ], M);
  84. var W = "univer.remote-instance-service";
  85. var m = Ct(W);
  86. var q = class {
  87. constructor(r, t, e) {
  88. this._univerInstanceService = r, this._commandService = t, this._logService = e;
  89. }
  90. whenReady() {
  91. return Promise.resolve(true);
  92. }
  93. async syncMutation(r) {
  94. return this._applyMutation(r.mutationInfo);
  95. }
  96. async createInstance(r) {
  97. const { type: t, snapshot: e } = r;
  98. try {
  99. switch (t) {
  100. case Fe.UNIVER_SHEET:
  101. return this._univerInstanceService.createUnit(Fe.UNIVER_SHEET, e), true;
  102. default:
  103. throw new Error(
  104. `[WebWorkerRemoteInstanceService]: cannot create replica for document type: ${t}.`
  105. );
  106. }
  107. } catch (n) {
  108. throw n instanceof Error ? n : new TypeError(`${n}`);
  109. }
  110. }
  111. async disposeInstance(r) {
  112. return this._univerInstanceService.disposeUnit(r.unitID);
  113. }
  114. _applyMutation(r) {
  115. const { id: t, params: e } = r;
  116. return this._commandService.syncExecuteCommand(t, e, {
  117. onlyLocal: true,
  118. fromSync: true
  119. });
  120. }
  121. };
  122. q = G([
  123. p(0, _n),
  124. p(1, Pt),
  125. p(2, Mt)
  126. ], q);
  127. function Y(r) {
  128. const t = r;
  129. return new class {
  130. call(e, n) {
  131. const s = t[e];
  132. if (typeof s == "function") {
  133. let i = n ? s.apply(t, n) : s.call(t);
  134. return i instanceof Promise || (i = Promise.resolve(i)), i;
  135. }
  136. throw new Error(`[RPC]: method not found for ${e}!`);
  137. }
  138. subscribe(e, n) {
  139. const s = t[e];
  140. if (typeof s == "function") {
  141. const i = n ? s.apply(t, n) : s.call(t);
  142. return isObservable(i) ? i : of(i);
  143. }
  144. throw new Error(`[RPC]: observable method not found for ${e}!`);
  145. }
  146. }();
  147. }
  148. function B(r) {
  149. return new Proxy({}, {
  150. get(t, e) {
  151. if (e !== "dispose")
  152. return function(...n) {
  153. return de(e) ? r.subscribe(e, n) : r.call(e, n);
  154. };
  155. }
  156. });
  157. }
  158. function de(r) {
  159. return r.endsWith("$");
  160. }
  161. var pe = class extends J0 {
  162. constructor(e) {
  163. super();
  164. a(this, "_initialized", new BehaviorSubject(false));
  165. a(this, "_lastRequestCounter", 0);
  166. a(this, "_pendingRequests", /* @__PURE__ */ new Map());
  167. this._protocol = e, this._protocol.send({
  168. type: 50
  169. /* REQUEST_INITIALIZATION */
  170. }), this._protocol.onMessage.pipe(takeUntil(this.dispose$)).subscribe((n) => this._onMessage(n));
  171. }
  172. dispose() {
  173. this._pendingRequests.clear();
  174. }
  175. getChannel(e) {
  176. const n = this;
  177. return {
  178. call(s, i) {
  179. return n._disposed ? Promise.reject() : n._remoteCall(e, s, i);
  180. },
  181. subscribe(s, i) {
  182. if (n._disposed)
  183. throw new Error("[ChannelClient]: client is disposed!");
  184. return n._remoteSubscribe(e, s, i);
  185. }
  186. };
  187. }
  188. _whenReady() {
  189. return firstValueFrom(
  190. this._initialized.pipe(
  191. filter((e) => e),
  192. take(1)
  193. )
  194. );
  195. }
  196. async _remoteCall(e, n, s) {
  197. await this._whenReady();
  198. const i = ++this._lastRequestCounter, h = { seq: i, type: 100, channelName: e, method: n, args: s }, o = this;
  199. return new Promise((w, _) => {
  200. const Q = {
  201. handle(P) {
  202. switch (P.type) {
  203. case 201:
  204. o._pendingRequests.delete(i), w(P.data);
  205. break;
  206. case 202:
  207. o._pendingRequests.delete(i), _(P.data);
  208. break;
  209. default:
  210. throw new Error("[ChannelClient]: unknown response type!");
  211. }
  212. }
  213. };
  214. this._pendingRequests.set(i, Q), this._sendRequest(h);
  215. });
  216. }
  217. _remoteSubscribe(e, n, s) {
  218. return new Observable((i) => {
  219. let c = -1;
  220. return this._whenReady().then(() => {
  221. c = ++this._lastRequestCounter;
  222. const o = { seq: c, type: 101, channelName: e, method: n, args: s }, w = {
  223. handle(_) {
  224. switch (_.type) {
  225. case 300:
  226. i.next(_.data);
  227. break;
  228. case 301:
  229. i.error(_.data);
  230. break;
  231. case 302:
  232. i.complete();
  233. break;
  234. default:
  235. throw new Error("[ChannelClient]: unknown response type!");
  236. }
  237. }
  238. };
  239. this._pendingRequests.set(c, w), this._sendRequest(o);
  240. }), () => {
  241. if (c === -1)
  242. return;
  243. const h = {
  244. type: 102,
  245. seq: c,
  246. channelName: e,
  247. method: n
  248. };
  249. this._sendRequest(h);
  250. };
  251. });
  252. }
  253. _sendRequest(e) {
  254. this._protocol.send(e);
  255. }
  256. _onMessage(e) {
  257. var n;
  258. switch (e.type) {
  259. case 0:
  260. this._initialized.next(true);
  261. break;
  262. case 201:
  263. case 202:
  264. case 300:
  265. case 302:
  266. case 301:
  267. (n = this._pendingRequests.get(e.seq)) == null || n.handle(e);
  268. break;
  269. }
  270. }
  271. };
  272. var ve = class extends J0 {
  273. constructor(e) {
  274. super();
  275. a(this, "_channels", /* @__PURE__ */ new Map());
  276. a(this, "_subscriptions", /* @__PURE__ */ new Map());
  277. this._protocol = e, this._protocol.onMessage.pipe(takeUntil(this.dispose$)).subscribe((n) => this._onRequest(n)), this._sendInitialize();
  278. }
  279. dispose() {
  280. super.dispose(), this._subscriptions.clear(), this._channels.clear();
  281. }
  282. registerChannel(e, n) {
  283. this._channels.set(e, n);
  284. }
  285. _onRequest(e) {
  286. switch (e.type) {
  287. case 50:
  288. this._sendInitialize();
  289. break;
  290. case 100:
  291. this._onMethodCall(e);
  292. break;
  293. case 101:
  294. this._onSubscribe(e);
  295. break;
  296. case 102:
  297. this._onUnsubscribe(e);
  298. break;
  299. }
  300. }
  301. _sendInitialize() {
  302. this._sendResponse({
  303. seq: -1,
  304. type: 0
  305. /* INITIALIZE */
  306. });
  307. }
  308. _onMethodCall(e) {
  309. const { channelName: n, method: s, args: i } = e, c = this._channels.get(n);
  310. let h;
  311. try {
  312. if (!c)
  313. throw new Error(`[ChannelServer]: Channel ${n} not found!`);
  314. h = i ? c.call(s, i) : c.call(s);
  315. } catch (o) {
  316. h = Promise.reject(o);
  317. }
  318. h.then((o) => {
  319. this._sendResponse({ seq: e.seq, type: 201, data: o });
  320. }).catch((o) => {
  321. o instanceof Error ? this._sendResponse({ seq: e.seq, type: 202, data: o.message }) : this._sendResponse({ seq: e.seq, type: 202, data: String(o) });
  322. });
  323. }
  324. _onSubscribe(e) {
  325. const { channelName: n, seq: s } = e, i = this._channels.get(n);
  326. try {
  327. if (!i)
  328. throw new Error(`[ChannelServer]: Channel ${n} not found!`);
  329. const h = i.subscribe(e.method, e.args).subscribe({
  330. next: (o) => {
  331. this._sendResponse({ seq: s, type: 300, data: o });
  332. },
  333. error: (o) => {
  334. this._sendResponse({ seq: s, type: 301, data: o.message }), this._sendResponse({
  335. seq: s,
  336. type: 302
  337. /* SUBSCRIBE_COMPLETE */
  338. });
  339. },
  340. complete: () => {
  341. this._sendResponse({
  342. seq: s,
  343. type: 302
  344. /* SUBSCRIBE_COMPLETE */
  345. });
  346. }
  347. });
  348. this._subscriptions.set(e.seq, h);
  349. } catch (c) {
  350. c instanceof Error ? this._sendResponse({ seq: e.seq, type: 301, data: c.message }) : this._sendResponse({ seq: e.seq, type: 301, data: String(c) });
  351. }
  352. }
  353. _onUnsubscribe(e) {
  354. const n = this._subscriptions.get(e.seq);
  355. n && (n.unsubscribe(), this._subscriptions.delete(e.seq));
  356. }
  357. _sendResponse(e) {
  358. this._protocol.send(e);
  359. }
  360. };
  361. var I = Ct("IRPCChannelService");
  362. var K = class {
  363. constructor(t) {
  364. a(this, "_client");
  365. a(this, "_server");
  366. this._client = new pe(t), this._server = new ve(t);
  367. }
  368. dispose() {
  369. this._client.dispose(), this._server.dispose();
  370. }
  371. requestChannel(t) {
  372. return this._client.getChannel(t);
  373. }
  374. registerChannel(t, e) {
  375. this._server.registerChannel(t, e);
  376. }
  377. };
  378. var fe = Object.defineProperty;
  379. var me = Object.getOwnPropertyDescriptor;
  380. var ge = (r, t, e, n) => {
  381. for (var s = n > 1 ? void 0 : n ? me(t, e) : t, i = r.length - 1, c; i >= 0; i--)
  382. (c = r[i]) && (s = (n ? c(t, e, s) : c(s)) || s);
  383. return n && s && fe(t, e, s), s;
  384. };
  385. var l = (r, t) => (e, n) => t(e, n, r);
  386. var g = class extends J0 {
  387. constructor(t, e, n, s, i) {
  388. super();
  389. a(this, "_remoteInstanceService");
  390. a(this, "_syncingUnits", /* @__PURE__ */ new Set());
  391. a(this, "_syncingMutations", /* @__PURE__ */ new Set());
  392. this._injector = t, this._commandService = e, this._univerInstanceService = n, this._rpcChannelService = s, this._remoteSyncService = i, this._initRPCChannels(), this._init();
  393. }
  394. registerSyncingMutations(t) {
  395. this._syncingMutations.add(t.id);
  396. }
  397. /**
  398. * Only spreadsheets would be synced to the web worker in normal situations. If you would like to
  399. * sync other types of documents, you should manually call this method with that document's id.
  400. */
  401. syncUnit(t) {
  402. return this._syncingUnits.add(t), Ze(() => this._syncingUnits.delete(t));
  403. }
  404. _initRPCChannels() {
  405. this._rpcChannelService.registerChannel(T, Y(this._remoteSyncService)), this._injector.add([
  406. m,
  407. { useFactory: () => B(this._rpcChannelService.requestChannel(W)) }
  408. ]), this._remoteInstanceService = this._injector.get(m);
  409. }
  410. _init() {
  411. this._univerInstanceService.getTypeOfUnitAdded$(Fe.UNIVER_SHEET).pipe(takeUntil(this.dispose$)).subscribe((t) => {
  412. this._syncingUnits.add(t.getUnitId()), this._remoteInstanceService.createInstance({
  413. unitID: t.getUnitId(),
  414. type: Fe.UNIVER_SHEET,
  415. snapshot: t.getSnapshot()
  416. });
  417. }), this._univerInstanceService.getTypeOfUnitDisposed$(Fe.UNIVER_SHEET).pipe(takeUntil(this.dispose$)).subscribe((t) => {
  418. this._syncingUnits.delete(t.getUnitId()), this._remoteInstanceService.disposeInstance({
  419. unitID: t.getUnitId()
  420. });
  421. }), this.disposeWithMe(this._commandService.onCommandExecuted((t, e) => {
  422. const { type: n, params: s, id: i } = t, c = (s == null ? void 0 : s.unitId) || "";
  423. n === ar.MUTATION && // only sync mutations to the worker thread
  424. (!c || this._syncingUnits.has(c)) && // do not sync mutations from the web worker back to the web worker
  425. !(e != null && e.fromSync) && // do not sync mutations those are not meant to be synced
  426. this._syncingMutations.has(i) && this._remoteInstanceService.syncMutation({ mutationInfo: t });
  427. }));
  428. }
  429. };
  430. g = ge([
  431. l(0, ot(Ot)),
  432. l(1, Pt),
  433. l(2, _n),
  434. l(3, I),
  435. l(4, f)
  436. ], g);
  437. var ye = Object.defineProperty;
  438. var Se = Object.getOwnPropertyDescriptor;
  439. var be = (r, t, e, n) => {
  440. for (var s = n > 1 ? void 0 : n ? Se(t, e) : t, i = r.length - 1, c; i >= 0; i--)
  441. (c = r[i]) && (s = (n ? c(t, e, s) : c(s)) || s);
  442. return n && s && ye(t, e, s), s;
  443. };
  444. var d = (r, t) => (e, n) => t(e, n, r);
  445. var y = class extends nt {
  446. constructor(t, e, n, s) {
  447. super();
  448. a(this, "_remoteSyncService");
  449. this._injector = t, this._remoteInstanceService = e, this._commandService = n, this._rpcChannelService = s, this._initRPCChannels(), this._init();
  450. }
  451. _initRPCChannels() {
  452. this._rpcChannelService.registerChannel(W, Y(this._remoteInstanceService)), this._injector.add([
  453. f,
  454. { useFactory: () => B(this._rpcChannelService.requestChannel(T)) }
  455. ]), this._remoteSyncService = this._injector.get(f);
  456. }
  457. _init() {
  458. this.disposeWithMe(
  459. // Mutations executed on the main thread should be synced to the worker thread.
  460. this._commandService.onCommandExecuted((t, e) => {
  461. t.type === ar.MUTATION && !(e != null && e.fromSync) && this._remoteSyncService.syncMutation({
  462. mutationInfo: t
  463. });
  464. })
  465. );
  466. }
  467. };
  468. y = be([
  469. d(0, ot(Ot)),
  470. d(1, m),
  471. d(2, Pt),
  472. d(3, I)
  473. ], y);
  474. function Ce() {
  475. return {
  476. send(r) {
  477. postMessage(r);
  478. },
  479. onMessage: new Observable((r) => {
  480. const t = (e) => {
  481. r.next(e.data);
  482. };
  483. return addEventListener("message", t), () => removeEventListener("message", t);
  484. }).pipe(shareReplay(1))
  485. };
  486. }
  487. function Re(r) {
  488. return {
  489. send(t) {
  490. r.postMessage(t);
  491. },
  492. onMessage: new Observable((t) => {
  493. const e = (n) => {
  494. t.next(n.data);
  495. };
  496. return r.addEventListener("message", e), () => r.removeEventListener("message", e);
  497. }).pipe(shareReplay(1))
  498. };
  499. }
  500. var Ie = Object.defineProperty;
  501. var we2 = Object.getOwnPropertyDescriptor;
  502. var J = (r, t, e, n) => {
  503. for (var s = n > 1 ? void 0 : n ? we2(t, e) : t, i = r.length - 1, c; i >= 0; i--)
  504. (c = r[i]) && (s = (n ? c(t, e, s) : c(s)) || s);
  505. return n && s && Ie(t, e, s), s;
  506. };
  507. var S = (r, t) => (e, n) => t(e, n, r);
  508. var E;
  509. var x = (E = class extends Ra {
  510. constructor(t = D, e, n) {
  511. super();
  512. a(this, "_internalWorker", null);
  513. this._config = t, this._injector = e, this._configService = n;
  514. const { ...s } = nu(
  515. {},
  516. D,
  517. this._config
  518. );
  519. this._configService.setConfig(he, s);
  520. }
  521. dispose() {
  522. super.dispose(), this._internalWorker && (this._internalWorker.terminate(), this._internalWorker = null);
  523. }
  524. onStarting() {
  525. const { workerURL: t } = this._config;
  526. if (!t)
  527. throw new Error("[UniverRPCMainThreadPlugin]: The workerURL is required for the RPC main thread plugin.");
  528. const e = t instanceof Worker ? t : new Worker(t);
  529. this._internalWorker = t instanceof Worker ? null : e;
  530. const n = Re(e);
  531. [
  532. [
  533. I,
  534. {
  535. useFactory: () => new K(n)
  536. }
  537. ],
  538. [g],
  539. [f, { useClass: M }]
  540. ].forEach((i) => this._injector.add(i)), this._injector.get(g);
  541. }
  542. }, a(E, "pluginName", "UNIVER_RPC_MAIN_THREAD_PLUGIN"), E);
  543. x = J([
  544. S(1, ot(Ot)),
  545. S(2, SE)
  546. ], x);
  547. var U;
  548. var L = (U = class extends Ra {
  549. constructor(r = N, t, e) {
  550. super(), this._config = r, this._injector = t, this._configService = e;
  551. const { ...n } = nu(
  552. {},
  553. N,
  554. this._config
  555. );
  556. this._configService.setConfig(_e, n);
  557. }
  558. onStarting() {
  559. [
  560. [y],
  561. [
  562. I,
  563. {
  564. useFactory: () => new K(Ce())
  565. }
  566. ],
  567. [m, { useClass: q }]
  568. ].forEach((r) => this._injector.add(r)), this._injector.get(y);
  569. }
  570. }, a(U, "pluginName", "UNIVER_RPC_WORKER_THREAD_PLUGIN"), U);
  571. L = J([
  572. S(1, ot(Ot)),
  573. S(2, SE)
  574. ], L);
  575. // node_modules/.pnpm/@univerjs+engine-formula@0.5.5_@grpc+grpc-js@1.13.4_react@18.3.1_rxjs@7.8.1/node_modules/@univerjs/engine-formula/lib/es/index.js
  576. var vu = Object.defineProperty;
  577. var Tu = (i, a2, e) => a2 in i ? vu(i, a2, { enumerable: true, configurable: true, writable: true, value: e }) : i[a2] = e;
  578. var A = (i, a2, e) => Tu(i, typeof a2 != "symbol" ? a2 + "" : a2, e);
  579. var er = ((i) => (i.FALSE = "FALSE", i.TRUE = "TRUE", i))(er || {});
  580. var xt = ((i) => (i[i.SUCCESS = 0] = "SUCCESS", i[i.ERROR = 1] = "ERROR", i))(xt || {});
  581. var it = ((i) => (i[i.FRONT = 0] = "FRONT", i[i.BACK = 1] = "BACK", i))(it || {});
  582. function zu(i, a2, e, t, r) {
  583. for (let n = 0, s = i.length; n < s; n++) {
  584. const o = i[n];
  585. if (a2 !== o.unitId || e !== o.sheetId)
  586. continue;
  587. const { startRow: u, startColumn: c, endRow: l2, endColumn: f2 } = o.range;
  588. if (t >= u && t <= l2 && r >= c && r <= f2)
  589. return true;
  590. }
  591. return false;
  592. }
  593. var m2 = ((i) => (i.DIV_BY_ZERO = "#DIV/0!", i.NAME = "#NAME?", i.VALUE = "#VALUE!", i.NUM = "#NUM!", i.NA = "#N/A", i.CYCLE = "#CYCLE!", i.REF = "#REF!", i.SPILL = "#SPILL!", i.CALC = "#CALC!", i.ERROR = "#ERROR!", i.CONNECT = "#GETTING_DATA", i.NULL = "#NULL!", i))(m2 || {});
  594. var yr = new Set(Object.values(m2));
  595. var Ga = [...new Set(Object.values(m2).map((i) => i.length))];
  596. var Ju = ((i) => (i[i.Financial = 0] = "Financial", i[i.Date = 1] = "Date", i[i.Math = 2] = "Math", i[i.Statistical = 3] = "Statistical", i[i.Lookup = 4] = "Lookup", i[i.Database = 5] = "Database", i[i.Text = 6] = "Text", i[i.Logical = 7] = "Logical", i[i.Information = 8] = "Information", i[i.Engineering = 9] = "Engineering", i[i.Cube = 10] = "Cube", i[i.Compatibility = 11] = "Compatibility", i[i.Web = 12] = "Web", i[i.Array = 13] = "Array", i[i.Univer = 14] = "Univer", i[i.User = 15] = "User", i[i.DefinedName = 16] = "DefinedName", i))(Ju || {});
  597. var X2 = ((i) => (i.PLUS = "+", i.MINUS = "-", i.MULTIPLY = "*", i.DIVIDED = "/", i.CONCATENATE = "&", i.POWER = "^", i.EQUALS = "=", i.NOT_EQUAL = "<>", i.GREATER_THAN = ">", i.GREATER_THAN_OR_EQUAL = ">=", i.LESS_THAN = "<", i.LESS_THAN_OR_EQUAL = "<=", i))(X2 || {});
  598. var $ = ((i) => (i.EQUALS = "=", i.NOT_EQUAL = "<>", i.GREATER_THAN = ">", i.GREATER_THAN_OR_EQUAL = ">=", i.LESS_THAN = "<", i.LESS_THAN_OR_EQUAL = "<=", i))($ || {});
  599. var Jr = /* @__PURE__ */ new Map([
  600. ["<>", 4],
  601. ["<", 4],
  602. [">=", 4],
  603. ["=", 4],
  604. [">", 4],
  605. ["<=", 4],
  606. ["&", 3],
  607. ["+", 2],
  608. ["-", 2],
  609. ["/", 1],
  610. ["*", 1],
  611. ["^", 0]
  612. ]);
  613. var Dt = new Set(Jr.keys());
  614. var ec = /* @__PURE__ */ new Set([
  615. "=",
  616. "<>",
  617. ">",
  618. ">=",
  619. "<",
  620. "<="
  621. /* LESS_THAN_OR_EQUAL */
  622. ]);
  623. var K2 = ((i) => (i.OPEN_BRACKET = "(", i.CLOSE_BRACKET = ")", i.COMMA = ",", i.SINGLE_QUOTATION = "'", i.DOUBLE_QUOTATION = '"', i.OPEN_BRACES = "{", i.CLOSE_BRACES = "}", i.COLON = ":", i.OPEN_SQUARE_BRACKET = "[", i.CLOSE_SQUARE_BRACKET = "]", i))(K2 || {});
  624. var ze = ((i) => (i.PERCENTAGE = "%", i.POUND = "#", i))(ze || {});
  625. var rs = /* @__PURE__ */ new Set([
  626. "%",
  627. "#"
  628. /* POUND */
  629. ]);
  630. var Oe = ((i) => (i.AT = "@", i.MINUS = "-", i.PLUS = "+", i))(Oe || {});
  631. var tc = " ";
  632. var $i = [
  633. ...Object.values($),
  634. ...Object.values(X2),
  635. ...Object.values(K2),
  636. ...Object.values(ze),
  637. ...Object.values(Oe)
  638. ];
  639. function en2(i) {
  640. return $i.includes(i);
  641. }
  642. function rc(i) {
  643. for (const a2 of $i)
  644. if (i.indexOf(a2) > -1)
  645. return true;
  646. return false;
  647. }
  648. function Ib(i) {
  649. return i[0] === "'" && i[i.length - 1] === "'" ? i.substring(1, i.length - 1) : i;
  650. }
  651. function Fb(i) {
  652. return en2(i) && i !== K2.CLOSE_BRACES && i !== K2.CLOSE_BRACKET && i !== K2.SINGLE_QUOTATION && i !== K2.DOUBLE_QUOTATION || i === " ";
  653. }
  654. var nc = /* @__PURE__ */ new Set([
  655. X2.PLUS,
  656. X2.MINUS,
  657. X2.MULTIPLY,
  658. X2.DIVIDED,
  659. X2.CONCATENATE,
  660. X2.POWER,
  661. X2.EQUALS,
  662. X2.NOT_EQUAL,
  663. X2.GREATER_THAN,
  664. X2.GREATER_THAN_OR_EQUAL,
  665. X2.LESS_THAN,
  666. X2.LESS_THAN_OR_EQUAL,
  667. K2.OPEN_BRACKET,
  668. K2.COMMA,
  669. K2.COLON,
  670. K2.OPEN_BRACES,
  671. K2.OPEN_SQUARE_BRACKET
  672. ]);
  673. function sc(i) {
  674. return nc.has(i);
  675. }
  676. var ac = /* @__PURE__ */ new Set([
  677. X2.PLUS,
  678. X2.MINUS,
  679. X2.MULTIPLY,
  680. X2.DIVIDED,
  681. X2.CONCATENATE,
  682. X2.POWER,
  683. X2.EQUALS,
  684. X2.NOT_EQUAL,
  685. X2.GREATER_THAN,
  686. X2.GREATER_THAN_OR_EQUAL,
  687. X2.LESS_THAN,
  688. X2.LESS_THAN_OR_EQUAL,
  689. K2.OPEN_BRACKET,
  690. K2.COMMA,
  691. K2.COLON,
  692. K2.OPEN_BRACES,
  693. K2.OPEN_SQUARE_BRACKET,
  694. ze.PERCENTAGE,
  695. ze.POUND
  696. ]);
  697. function ic(i) {
  698. return ac.has(i);
  699. }
  700. function oc(i) {
  701. const a2 = {};
  702. return Object.keys(i).forEach((e) => {
  703. const t = i[e];
  704. if (t == null)
  705. return true;
  706. a2[e] == null && (a2[e] = {}), Object.keys(t).forEach((r) => {
  707. const n = t[r];
  708. a2[e][r] = new kt(n);
  709. });
  710. }), a2;
  711. }
  712. function uc(i) {
  713. const a2 = {};
  714. for (const e in i) {
  715. const t = i[e];
  716. if (t != null) {
  717. a2[e] == null && (a2[e] = {});
  718. for (const r in t) {
  719. const n = t[r], s = {};
  720. n.forValue((o, u, c) => {
  721. s[o] === void 0 && (s[o] = {}), s[o][u] = c;
  722. }), a2[e][r] = s;
  723. }
  724. }
  725. }
  726. return a2;
  727. }
  728. var Yi = '\\[([^\\[\\]\\/?:"<>|*\\\\]+)\\]';
  729. var Qa = new RegExp(Yi);
  730. var cc = "((?![\\[\\]\\/?*\\\\]).)*!";
  731. var Tt = "$";
  732. var ra = "\\s*?:\\s*?";
  733. var cn = "[A-Za-z]+";
  734. var ln2 = "[1-9][0-9]*";
  735. var Rr = `'?(${Yi})?(${cc})?'?`;
  736. var Es = `\\${Tt}?${cn}\\${Tt}?${ln2}`;
  737. var lc = `^(${Oe.AT})?${Rr}${Es}${ra}${Es}$`;
  738. var Wa = new RegExp(lc);
  739. var fc = `^${Rr}\\s*?${Es}(${ze.POUND})?$`;
  740. var qa = new RegExp(fc);
  741. var hc = `^${Rr}\\${Tt}?${ln2}${ra}\\${Tt}?${ln2}$`;
  742. var Ka = new RegExp(hc);
  743. var mc = `^${Rr}\\${Tt}?${cn}${ra}\\${Tt}?${cn}$`;
  744. var Xa = new RegExp(mc);
  745. var gc = `^${Rr}\\s*?\\${Tt}?${ln2}$`;
  746. var Za = new RegExp(gc);
  747. var dc = `^${Rr}\\s*?\\${Tt}?${cn}$`;
  748. var za = new RegExp(dc);
  749. var Cc = "{.*?}";
  750. var Ja = new RegExp(Cc, "g");
  751. function vr(i) {
  752. return qa.lastIndex = 0, qa.test(i);
  753. }
  754. function _c(i) {
  755. return Wa.lastIndex = 0, Wa.test(i);
  756. }
  757. function Hi(i) {
  758. return Ka.lastIndex = 0, Ka.test(i);
  759. }
  760. function Gi(i) {
  761. return Xa.lastIndex = 0, Xa.test(i);
  762. }
  763. function Qi(i) {
  764. return Za.lastIndex = 0, Za.test(i);
  765. }
  766. function Wi(i) {
  767. return za.lastIndex = 0, za.test(i);
  768. }
  769. function Ac(i) {
  770. return Ja.lastIndex = 0, Ja.test(i);
  771. }
  772. function Ec(i) {
  773. return vr(i) || _c(i) || Hi(i) || Gi(i);
  774. }
  775. var bc = {
  776. id: "formula.mutation.register-function",
  777. type: ar.MUTATION,
  778. handler: () => true
  779. };
  780. var bs = {
  781. id: "formula.mutation.set-array-formula-data",
  782. type: ar.MUTATION,
  783. handler: (i, a2) => true
  784. };
  785. var yc = /[^0-9]/g;
  786. var Rc = /[^A-Za-z]/g;
  787. function tn(i) {
  788. let a2 = i[0] === "$";
  789. const e = i.substring(1);
  790. let t = e.indexOf("$") > -1;
  791. return re.isStringNumber(e) && a2 && !t && (a2 = false, t = true), a2 && t ? tt.ALL : a2 ? tt.COLUMN : t ? tt.ROW : tt.NONE;
  792. }
  793. function kb(i) {
  794. const a2 = i.split("!");
  795. a2.length > 1 && (i = a2[a2.length - 1]);
  796. const e = i.split(":");
  797. return e.length > 1 ? {
  798. startAbsoluteRefType: tn(e[0]),
  799. endAbsoluteRefType: tn(e[1])
  800. } : { startAbsoluteRefType: tn(e[0]) };
  801. }
  802. function ei(i = tt.NONE) {
  803. let a2 = "", e = "";
  804. return i === tt.ROW ? a2 = "$" : i === tt.COLUMN ? e = "$" : i === tt.ALL && (a2 = "$", e = "$"), {
  805. rowAbsoluteString: a2,
  806. columnAbsoluteString: e
  807. };
  808. }
  809. function fr(i) {
  810. const {
  811. startColumn: a2,
  812. startRow: e,
  813. endColumn: t,
  814. endRow: r,
  815. startAbsoluteRefType: n,
  816. endAbsoluteRefType: s,
  817. rangeType: o = De.NORMAL
  818. } = i, u = ei(n), c = ei(s);
  819. if (o === De.ROW || o === De.ALL) {
  820. const h = `${u.rowAbsoluteString}${e + 1}`, d2 = `${c.rowAbsoluteString}${r + 1}`;
  821. return `${h}:${d2}`;
  822. }
  823. if (o === De.COLUMN) {
  824. const h = `${u.columnAbsoluteString}${re.chatAtABC(a2)}`, d2 = `${c.columnAbsoluteString}${re.chatAtABC(t)}`;
  825. return `${h}:${d2}`;
  826. }
  827. const l2 = `${u.columnAbsoluteString}${re.chatAtABC(a2)}${u.rowAbsoluteString}${e + 1}`, f2 = `${c.columnAbsoluteString}${re.chatAtABC(t)}${c.rowAbsoluteString}${r + 1}`;
  828. return l2 === f2 ? l2 : `${l2}:${f2}`;
  829. }
  830. function pc(i, a2) {
  831. return `${Ki(i)}!${fr(a2)}`;
  832. }
  833. function Vc(i, a2, e) {
  834. return Rs(i) || Rs(a2) ? `'[${ps(i)}]${ps(a2)}'!${fr(e)}` : `[${i}]${a2}!${fr(e)}`;
  835. }
  836. function ys(i) {
  837. const { unitId: a2, sheetName: e, range: t } = i;
  838. return a2 != null && a2.length > 0 && e != null && e.length > 0 ? Vc(a2, e, t) : e != null && e.length > 0 ? pc(e, t) : fr(t);
  839. }
  840. function ns(i) {
  841. const a2 = Number.parseInt(i.replace(yc, "")) - 1, e = re.ABCatNum(i.replace(Rc, "")), t = tn(i);
  842. return {
  843. row: a2,
  844. column: e,
  845. absoluteRefType: t
  846. };
  847. }
  848. function na(i) {
  849. const a2 = Qa.exec(i);
  850. let e = "";
  851. a2 != null && (e = a2[0].trim(), e = ti(e.slice(1, e.length - 1)), i = i.replace(Qa, ""));
  852. const t = i.indexOf("!");
  853. let r = "", n = "";
  854. return t > -1 ? (r = i.substring(0, t), r[0] === "'" && r[r.length - 1] === "'" && (r = r.substring(1, r.length - 1)), r = ti(r), n = i.substring(t + 1)) : n = i, {
  855. refBody: n,
  856. sheetName: r,
  857. unitId: e
  858. };
  859. }
  860. function fn(i) {
  861. const { refBody: a2, sheetName: e, unitId: t } = na(i), r = a2.indexOf(":");
  862. if (r === -1) {
  863. const _ = ns(a2), C = _.row, E2 = _.column, b = _.absoluteRefType;
  864. return {
  865. unitId: t,
  866. sheetName: e,
  867. range: {
  868. startRow: C,
  869. startColumn: E2,
  870. endRow: C,
  871. endColumn: E2,
  872. startAbsoluteRefType: b,
  873. endAbsoluteRefType: b
  874. }
  875. };
  876. }
  877. const n = a2.substring(0, r), s = a2.substring(r + 1), o = ns(n), u = ns(s), c = o.row > u.row ? u.row : o.row, l2 = o.column > u.column ? u.column : o.column, f2 = o.row > u.row ? o.row : u.row, h = o.column > u.column ? o.column : u.column;
  878. let d2 = De.NORMAL;
  879. return Number.isNaN(c) && Number.isNaN(f2) ? d2 = De.COLUMN : Number.isNaN(l2) && Number.isNaN(h) && (d2 = De.ROW), {
  880. unitId: t,
  881. sheetName: e,
  882. range: {
  883. startRow: c,
  884. startColumn: l2,
  885. endRow: f2,
  886. endColumn: h,
  887. startAbsoluteRefType: o.absoluteRefType,
  888. endAbsoluteRefType: u.absoluteRefType,
  889. rangeType: d2
  890. }
  891. };
  892. }
  893. var Nc = ["LOG10"];
  894. function rn(i) {
  895. const a2 = qi(i);
  896. if (!Ec(a2) || Nc.includes(a2.toUpperCase().trim()))
  897. return false;
  898. const { range: e } = fn(a2);
  899. return !(e.endColumn >= 16384);
  900. }
  901. function qi(i) {
  902. const a2 = [];
  903. let e = false;
  904. for (let t = 0, r = i.length; t < r; t++) {
  905. const n = i[t];
  906. if (n === tc && !e)
  907. a2.push(n);
  908. else {
  909. if (!e && (n === Oe.AT || n === Oe.MINUS || n === Oe.PLUS))
  910. continue;
  911. a2.push(n), e = true;
  912. }
  913. }
  914. return a2.join("");
  915. }
  916. function $b(i, a2) {
  917. const e = (i == null ? void 0 : i.split(",")) || [];
  918. return i === "" || e.length === 0 ? [] : Oc(i) ? e.map((n) => {
  919. const s = fn(n);
  920. return {
  921. unitId: s.unitId,
  922. sheetId: a2(s.sheetName),
  923. range: s.range,
  924. sheetName: s.sheetName
  925. };
  926. }) : [];
  927. }
  928. function Oc(i) {
  929. return ((i == null ? void 0 : i.split(",")) || []).every((e) => rn(e.trim()));
  930. }
  931. function Rs(i) {
  932. return i.length === 0 ? false : !!(rc(i) || Mc(i) || wc(i) || Dc(i) || /[\s!$%^&*()+\-=\[\]{};':"\\|,.<>\/?()]/.test(i));
  933. }
  934. function Ki(i) {
  935. return Rs(i) ? `'${ps(i)}'` : i;
  936. }
  937. function ps(i) {
  938. return i.replace(/'/g, "''");
  939. }
  940. function ti(i) {
  941. return i.replace(/''/g, "'");
  942. }
  943. function Mc(i) {
  944. const a2 = i.match(/[1-9][0-9]{0,6}/);
  945. return /^[A-Z]+[1-9][0-9]{0,6}$/.test(i) && a2 !== null;
  946. }
  947. function wc(i) {
  948. return /^(R(-?[0-9]+)?C(-?[0-9]+)?|C(-?[0-9]+)?|R(-?[0-9]+)?)$/.test(i);
  949. }
  950. function Dc(i) {
  951. return !new RegExp("^\\p{Letter}", "u").test(i.charAt(0));
  952. }
  953. var Sc = Object.defineProperty;
  954. var Pc = Object.getOwnPropertyDescriptor;
  955. var Lc = (i, a2, e, t) => {
  956. for (var r = t > 1 ? void 0 : t ? Pc(a2, e) : a2, n = i.length - 1, s; n >= 0; n--)
  957. (s = i[n]) && (r = (t ? s(a2, e, r) : s(r)) || r);
  958. return t && r && Sc(a2, e, r), r;
  959. };
  960. var xc = (i, a2) => (e, t) => a2(e, t, i);
  961. var Vs = class extends nt {
  962. constructor(a2) {
  963. super();
  964. A(this, "_definedNameMap", {});
  965. A(this, "_update$", new Subject());
  966. A(this, "update$", this._update$.asObservable());
  967. A(this, "_currentRange", {
  968. unitId: "",
  969. sheetId: "",
  970. range: {
  971. startRow: 0,
  972. endRow: 0,
  973. startColumn: 0,
  974. endColumn: 0
  975. }
  976. });
  977. A(this, "_currentRange$", new Subject());
  978. A(this, "currentRange$", this._currentRange$.asObservable());
  979. A(this, "_focusRange$", new Subject());
  980. A(this, "focusRange$", this._focusRange$.asObservable());
  981. this._univerInstanceService = a2;
  982. }
  983. dispose() {
  984. this._definedNameMap = {};
  985. }
  986. getWorksheetByRef(a2, e) {
  987. var r;
  988. const { sheetName: t } = na(e);
  989. return (r = this._univerInstanceService.getUnit(a2)) == null ? void 0 : r.getSheetBySheetName(t);
  990. }
  991. focusRange(a2, e) {
  992. const t = this.getValueById(a2, e);
  993. t != null && this._focusRange$.next({ ...t, unitId: a2 });
  994. }
  995. setCurrentRange(a2) {
  996. this._currentRange = a2, this._currentRange$.next(a2);
  997. }
  998. getCurrentRange() {
  999. return this._currentRange;
  1000. }
  1001. getCurrentRangeForString() {
  1002. return fr(this._currentRange.range);
  1003. }
  1004. registerDefinedNames(a2, e) {
  1005. this._definedNameMap[a2] = e, this._update();
  1006. }
  1007. registerDefinedName(a2, e) {
  1008. this._definedNameMap[a2] == null && (this._definedNameMap[a2] = {}), this._definedNameMap[a2][e.id] = e, this._update();
  1009. }
  1010. removeDefinedName(a2, e) {
  1011. var t;
  1012. (t = this._definedNameMap[a2]) == null || delete t[e], this._update();
  1013. }
  1014. removeUnitDefinedName(a2) {
  1015. delete this._definedNameMap[a2], this._update();
  1016. }
  1017. getDefinedNameMap(a2) {
  1018. return this._definedNameMap[a2];
  1019. }
  1020. getValueByName(a2, e) {
  1021. var r;
  1022. const t = this._definedNameMap[a2];
  1023. return t == null ? null : (r = Array.from(Object.values(t)).filter((n) => n.name === e)) == null ? void 0 : r[0];
  1024. }
  1025. getValueById(a2, e) {
  1026. var t;
  1027. return (t = this._definedNameMap[a2]) == null ? void 0 : t[e];
  1028. }
  1029. hasDefinedName(a2) {
  1030. return this._definedNameMap[a2] == null ? false : (Array.from(Object.values(this._definedNameMap[a2])).length || 0) !== 0;
  1031. }
  1032. _update() {
  1033. this._update$.next(null);
  1034. }
  1035. };
  1036. Vs = Lc([
  1037. xc(0, _n)
  1038. ], Vs);
  1039. var pr = Ct("univer.formula.defined-names.service");
  1040. var Yb = (i, a2) => {
  1041. const { unitId: e, id: t } = a2;
  1042. return {
  1043. ...i.get(pr).getValueById(e, t),
  1044. unitId: e
  1045. };
  1046. };
  1047. var sa = {
  1048. id: "formula.mutation.set-defined-name",
  1049. type: ar.MUTATION,
  1050. handler: (i, a2) => {
  1051. if (a2 == null)
  1052. return false;
  1053. const e = i.get(pr), { id: t, unitId: r, name: n, formulaOrRefString: s, comment: o, hidden: u, localSheetId: c } = a2;
  1054. return e.registerDefinedName(r, {
  1055. id: t,
  1056. name: n.trim(),
  1057. formulaOrRefString: s.trim(),
  1058. comment: o == null ? void 0 : o.trim(),
  1059. hidden: u,
  1060. localSheetId: c
  1061. }), true;
  1062. }
  1063. };
  1064. var Xi = {
  1065. id: "formula.mutation.remove-defined-name",
  1066. type: ar.MUTATION,
  1067. handler: (i, a2) => {
  1068. if (a2 == null)
  1069. return false;
  1070. const e = i.get(pr), { unitId: t, id: r } = a2;
  1071. return e.removeDefinedName(t, r), true;
  1072. }
  1073. };
  1074. var aa = {
  1075. id: "formula.mutation.set-feature-calculation",
  1076. type: ar.MUTATION,
  1077. handler: () => true
  1078. };
  1079. var ia = {
  1080. id: "formula.mutation.remove-feature-calculation",
  1081. type: ar.MUTATION,
  1082. handler: () => true
  1083. };
  1084. var Zi = {
  1085. id: "formula.mutation.set-formula-calculation-start",
  1086. type: ar.MUTATION,
  1087. handler: () => true
  1088. };
  1089. var zi = {
  1090. id: "formula.mutation.set-formula-calculation-stop",
  1091. type: ar.MUTATION,
  1092. handler: () => true
  1093. };
  1094. var Ns = {
  1095. id: "formula.mutation.set-formula-calculation-notification",
  1096. type: ar.MUTATION,
  1097. handler: () => true
  1098. };
  1099. var Ji = {
  1100. id: "formula.mutation.set-formula-calculation-result",
  1101. type: ar.MUTATION,
  1102. handler: () => true
  1103. };
  1104. var eo = {
  1105. id: "formula.mutation.set-formula-data",
  1106. type: ar.MUTATION,
  1107. handler: (i, a2) => true
  1108. };
  1109. var oa = {
  1110. id: "formula.mutation.set-other-formula",
  1111. type: ar.MUTATION,
  1112. handler: () => true
  1113. };
  1114. var ua = {
  1115. id: "formula.mutation.remove-other-formula",
  1116. type: ar.MUTATION,
  1117. handler: () => true
  1118. };
  1119. var jc = {
  1120. id: "formula.mutation.set-super-table",
  1121. type: ar.MUTATION,
  1122. handler: () => true
  1123. };
  1124. var Uc = {
  1125. id: "formula.mutation.remove-super-table",
  1126. type: ar.MUTATION,
  1127. handler: () => true
  1128. };
  1129. var to = {
  1130. id: "formula.mutation.set-super-table-option",
  1131. type: ar.MUTATION,
  1132. handler: () => true
  1133. };
  1134. var Vt = class {
  1135. constructor(a2) {
  1136. A(this, "_cache");
  1137. this._cache = new Qr(a2);
  1138. }
  1139. set(a2, e) {
  1140. const t = this._hash(a2);
  1141. this._cache.set(t, e);
  1142. }
  1143. get(a2) {
  1144. const e = this._hash(a2);
  1145. return this._cache.get(e);
  1146. }
  1147. clear() {
  1148. this._cache.clear();
  1149. }
  1150. _hash(a2) {
  1151. return a2.length <= 64 ? a2 : xC(a2).toString();
  1152. }
  1153. };
  1154. var ht = "P_1";
  1155. var Ut = "R_1";
  1156. var hr = "L_1";
  1157. var Tr = "LR_1";
  1158. var ro = "LO_1";
  1159. var vc = "LET";
  1160. var Sr = "LAMBDA";
  1161. var Tc = "CUBE";
  1162. var Bc = /* @__PURE__ */ new Set(["RAND", "RANDBETWEEN", "NOW", "TODAY"]);
  1163. var Os = new Vt(1e5);
  1164. function mr(i) {
  1165. const a2 = Os.get(i);
  1166. if (a2)
  1167. return a2;
  1168. const e = fn(i);
  1169. return Os.set(i, e), fn(i);
  1170. }
  1171. function Ic() {
  1172. Os.clear();
  1173. }
  1174. var $e = ((i) => (i[i.NORMAL = 0] = "NORMAL", i[i.NUMBER = 1] = "NUMBER", i[i.STRING = 2] = "STRING", i[i.FUNCTION = 3] = "FUNCTION", i[i.REFERENCE = 4] = "REFERENCE", i[i.ARRAY = 5] = "ARRAY", i[i.DEFINED_NAME = 6] = "DEFINED_NAME", i))($e || {});
  1175. function ri(i) {
  1176. let a2 = "";
  1177. for (const e of i)
  1178. typeof e == "string" ? a2 += e : a2 += e.token;
  1179. return a2;
  1180. }
  1181. var ae = class _ae {
  1182. constructor() {
  1183. A(this, "_parent");
  1184. A(this, "_token", Ut);
  1185. A(this, "_children", []);
  1186. A(this, "_lambdaId");
  1187. A(this, "_functionDefinitionPrivacyVar");
  1188. A(this, "_lambdaParameter", "");
  1189. A(this, "_startIndex", -1);
  1190. A(this, "_endIndex", -1);
  1191. A(this, "_definedNames", []);
  1192. }
  1193. dispose() {
  1194. var a2;
  1195. this._children.forEach((e) => {
  1196. typeof e != "string" && e.dispose();
  1197. }), (a2 = this._functionDefinitionPrivacyVar) == null || a2.clear(), this._functionDefinitionPrivacyVar = null, this._children = [], this._parent = null, this._definedNames = [];
  1198. }
  1199. getDefinedNames() {
  1200. return this._definedNames;
  1201. }
  1202. getStartIndex() {
  1203. return this._startIndex;
  1204. }
  1205. getLambdaId() {
  1206. return this._lambdaId;
  1207. }
  1208. setLambdaId(a2) {
  1209. this._lambdaId = a2;
  1210. }
  1211. getFunctionDefinitionPrivacyVar() {
  1212. return this._functionDefinitionPrivacyVar;
  1213. }
  1214. setLambdaPrivacyVar(a2) {
  1215. this._functionDefinitionPrivacyVar = a2;
  1216. }
  1217. getLambdaParameter() {
  1218. return this._lambdaParameter;
  1219. }
  1220. setLambdaParameter(a2) {
  1221. this._lambdaParameter = a2;
  1222. }
  1223. getParent() {
  1224. return this._parent;
  1225. }
  1226. setParent(a2) {
  1227. this._parent = a2;
  1228. }
  1229. getChildren() {
  1230. return this._children;
  1231. }
  1232. setChildren(a2) {
  1233. this._children = a2;
  1234. }
  1235. addChildren(a2) {
  1236. this._children.push(a2);
  1237. }
  1238. addChildrenFirst(a2) {
  1239. this._children.unshift(a2);
  1240. }
  1241. getToken() {
  1242. return this._token;
  1243. }
  1244. setToken(a2) {
  1245. this._token = a2;
  1246. }
  1247. setIndex(a2, e) {
  1248. this._startIndex = a2, this._endIndex = e;
  1249. }
  1250. setDefinedNames(a2) {
  1251. this._definedNames = a2;
  1252. }
  1253. hasDefinedNames() {
  1254. return this._definedNames.length > 0;
  1255. }
  1256. replaceChild(a2, e) {
  1257. const t = this._getIndexInParent(a2);
  1258. t != null && (this.getChildren().splice(t, 1, e), e.setParent(this));
  1259. }
  1260. changeToParent(a2) {
  1261. const e = this.getParent();
  1262. e && e.removeChild(this), this.setParent(a2), a2.getChildren().push(this);
  1263. }
  1264. removeChild(a2) {
  1265. const e = this._getIndexInParent(a2);
  1266. e != null && this.getChildren().splice(e, 1);
  1267. }
  1268. serialize() {
  1269. const a2 = this.getToken(), e = this.getChildren(), t = [], r = e.length;
  1270. for (let n = 0; n < r; n++) {
  1271. const s = e[n];
  1272. s instanceof _ae ? t.push(s.serialize()) : t.push(s);
  1273. }
  1274. return {
  1275. token: a2,
  1276. st: this._startIndex,
  1277. ed: this._endIndex,
  1278. children: t
  1279. };
  1280. }
  1281. _getIndexInParent(a2) {
  1282. const e = this.getChildren(), t = e.length;
  1283. for (let r = 0; r < t; r++)
  1284. if (e[r] === a2)
  1285. return r;
  1286. }
  1287. };
  1288. var no = 2e3;
  1289. var ss = new Vt(no);
  1290. var as = new Vt(no);
  1291. var ca = class extends nt {
  1292. constructor() {
  1293. super(...arguments);
  1294. A(this, "_currentLexerNode", new ae());
  1295. A(this, "_upLevel", 0);
  1296. A(this, "_segment", "");
  1297. A(this, "_bracketState", []);
  1298. A(this, "_squareBracketState", 0);
  1299. A(this, "_bracesState", 0);
  1300. A(this, "_singleQuotationState", 0);
  1301. A(this, "_doubleQuotationState", 0);
  1302. A(this, "_lambdaState", false);
  1303. A(this, "_colonState", false);
  1304. A(this, "_formulaErrorCount", 0);
  1305. A(this, "_tableBracketState", false);
  1306. }
  1307. // Table3[[#All],[Column1]:[Column2]]
  1308. dispose() {
  1309. this._resetTemp(), this._currentLexerNode.dispose(), ss.clear(), as.clear();
  1310. }
  1311. getUpLevel() {
  1312. return this._upLevel;
  1313. }
  1314. isColonClose() {
  1315. return this._colonState === false;
  1316. }
  1317. isColonOpen() {
  1318. return this._colonState === true;
  1319. }
  1320. isDoubleQuotationClose() {
  1321. return this._doubleQuotationState === 0;
  1322. }
  1323. isLambdaOpen() {
  1324. return this._lambdaState === true;
  1325. }
  1326. isLambdaClose() {
  1327. return this._lambdaState === false;
  1328. }
  1329. isSingleQuotationClose() {
  1330. return this._singleQuotationState === 0;
  1331. }
  1332. isBracesClose() {
  1333. return this._bracesState === 0;
  1334. }
  1335. isBracketClose() {
  1336. return this._bracketState.length === 0;
  1337. }
  1338. isSquareBracketClose() {
  1339. return this._squareBracketState === 0;
  1340. }
  1341. getCurrentLexerNode() {
  1342. return this._currentLexerNode;
  1343. }
  1344. getFunctionAndParameter(e, t) {
  1345. const r = this._getCurrentParamIndex(e, t);
  1346. if (r == null || r === m2.VALUE)
  1347. return;
  1348. const n = r[0];
  1349. if (typeof n == "string")
  1350. return;
  1351. let s = n.getParent(), o = n;
  1352. for (; s; ) {
  1353. const u = s.getToken();
  1354. if (u !== ht && !en2(u) && s.getStartIndex() !== -1) {
  1355. const c = s.getChildren().indexOf(o);
  1356. return {
  1357. functionName: u,
  1358. paramIndex: c
  1359. };
  1360. }
  1361. o = s, s = s.getParent();
  1362. }
  1363. }
  1364. /**
  1365. * Estimate the number of right brackets that need to be automatically added to the end of the formula.
  1366. * @param formulaString
  1367. */
  1368. checkIfAddBracket(e) {
  1369. let t = 0, r = e.length - 1, n = e[r];
  1370. for (; (n === K2.CLOSE_BRACKET || n === " ") && r >= 0; )
  1371. n === K2.CLOSE_BRACKET && t++, n = e[--r];
  1372. const s = this._getCurrentParamIndex(e, e.length - 2);
  1373. if (s == null || s === m2.VALUE)
  1374. return 0;
  1375. const o = s[0];
  1376. if (typeof o == "string")
  1377. return 0;
  1378. let u = o.getParent(), c = 0;
  1379. for (s[1] === K2.OPEN_BRACKET && c++; u; ) {
  1380. const l2 = u.getToken();
  1381. l2 !== ht && l2 !== K2.COLON && u.getStartIndex() !== -1 && l2.toUpperCase() !== Sr && (t === 0 ? c += 1 : t--), u = u.getParent();
  1382. }
  1383. return c;
  1384. }
  1385. sequenceNodesBuilder(e) {
  1386. const t = as.get(e);
  1387. if (t)
  1388. return [...t];
  1389. const r = this._getSequenceArray(e);
  1390. if (r.length === 0)
  1391. return;
  1392. const n = this.getSequenceNode(r);
  1393. return as.set(e, [...n]), n;
  1394. }
  1395. convertRefersToAbsolute(e, t, r, n = "") {
  1396. const s = this.sequenceNodesBuilder(e);
  1397. if (s == null)
  1398. return e;
  1399. let o = "";
  1400. e.substring(0, 1) === X2.EQUALS && (o = X2.EQUALS);
  1401. for (let u = 0, c = s.length; u < c; u++) {
  1402. const l2 = s[u];
  1403. if (typeof l2 != "string" && l2.nodeType === $e.REFERENCE) {
  1404. const { token: f2, endIndex: h } = l2, d2 = mr(f2);
  1405. if (d2 == null)
  1406. continue;
  1407. const { range: _, sheetName: C, unitId: E2 } = d2, b = {
  1408. ..._,
  1409. startAbsoluteRefType: t,
  1410. endAbsoluteRefType: r
  1411. }, R = ys({
  1412. range: b,
  1413. unitId: E2,
  1414. sheetName: C || n
  1415. }), p2 = R.length - f2.length;
  1416. s[u] = {
  1417. ...l2,
  1418. token: R,
  1419. endIndex: h + p2
  1420. };
  1421. for (let N2 = u + 1; N2 < c; N2++) {
  1422. const M2 = s[N2];
  1423. typeof M2 != "string" && (M2.startIndex += p2, M2.endIndex += p2);
  1424. }
  1425. }
  1426. }
  1427. return `${o}${ri(s)}`;
  1428. }
  1429. moveFormulaRefOffset(e, t, r, n = false) {
  1430. const s = this.sequenceNodesBuilder(e);
  1431. if (s == null)
  1432. return e;
  1433. const o = [];
  1434. for (let u = 0, c = s.length; u < c; u++) {
  1435. const l2 = s[u];
  1436. if (typeof l2 == "string" || l2.nodeType !== $e.REFERENCE) {
  1437. o.push(l2);
  1438. continue;
  1439. }
  1440. const { token: f2 } = l2, h = mr(f2), { sheetName: d2, unitId: _ } = h;
  1441. let C = h.range;
  1442. if (!n && C.startAbsoluteRefType === tt.ALL && C.endAbsoluteRefType === tt.ALL) {
  1443. o.push(l2);
  1444. continue;
  1445. } else
  1446. C = jC(C, t, r, n);
  1447. let E2 = "";
  1448. SC(C) ? E2 = ys({
  1449. range: C,
  1450. unitId: _,
  1451. sheetName: d2
  1452. }) : E2 = m2.REF, o.push({
  1453. ...l2,
  1454. token: E2
  1455. });
  1456. }
  1457. return `=${ri(o)}`;
  1458. }
  1459. /**
  1460. * univer-pro/issues/1684
  1461. * =sum({}{})
  1462. */
  1463. _formulaSpellCheck() {
  1464. if (this._currentLexerNode.getChildren().length === 0)
  1465. return true;
  1466. const e = this._currentLexerNode.getChildren()[0];
  1467. return !!(e instanceof ae || Dt.has(e) || rs.has(e) || e === Oe.AT || e === K2.COMMA || e === K2.COLON || e === K2.OPEN_BRACKET);
  1468. }
  1469. // eslint-disable-next-line complexity
  1470. getSequenceNode(e) {
  1471. const t = [];
  1472. let r = false;
  1473. for (let n = 0, s = e.length; n < s; n++) {
  1474. const o = e[n], u = e[n - 1], { segment: c, currentString: l2 } = o;
  1475. if (l2 === K2.DOUBLE_QUOTATION && (r = true), (c !== "" || n === 0) && n !== s - 1) {
  1476. t.push(l2);
  1477. continue;
  1478. }
  1479. let f2 = (u == null ? void 0 : u.segment) || "";
  1480. const h = n - f2.length;
  1481. let d2 = n - 1;
  1482. const _ = n - 1;
  1483. if (n === s - 1 && this._isLastMergeString(l2) && (f2 += l2, d2 += 1), f2 === "" || Jr.has(f2)) {
  1484. t.push(l2);
  1485. continue;
  1486. }
  1487. const C = f2.trim(), E2 = qi(C);
  1488. r === true && C[C.length - 1] === K2.DOUBLE_QUOTATION && C[0] !== K2.OPEN_BRACES ? (r = false, this._processPushSequenceNode(t, $e.STRING, f2, h, d2, _)) : vr(E2) && rn(E2) ? this._processPushSequenceNode(t, $e.REFERENCE, f2, h, d2, _) : re.isStringNumber(C) ? this._processPushSequenceNode(t, $e.NUMBER, f2, h, d2, _) : C.length > 0 && this._processPushSequenceNode(t, $e.FUNCTION, f2, h, d2, _), (n !== s - 1 || !this._isLastMergeString(l2)) && t.push(l2);
  1489. }
  1490. return this._mergeSequenceNodeReference(t);
  1491. }
  1492. _processPushSequenceNode(e, t, r, n, s, o) {
  1493. this._pushSequenceNode(
  1494. e,
  1495. {
  1496. nodeType: t,
  1497. token: r,
  1498. startIndex: n,
  1499. endIndex: s
  1500. },
  1501. o
  1502. );
  1503. }
  1504. _getCurrentParamIndex(e, t) {
  1505. return this._nodeMaker(e, void 0, t);
  1506. }
  1507. _isLastMergeString(e) {
  1508. return e === K2.DOUBLE_QUOTATION || re.isStringNumber(e) || !en2(e);
  1509. }
  1510. /**
  1511. * Merge array and handle ref operations
  1512. *
  1513. */
  1514. _mergeSequenceNodeReference(e) {
  1515. const t = [], r = e.length;
  1516. let n = 0;
  1517. for (; n < r; ) {
  1518. const s = e[n];
  1519. if (typeof s == "string") {
  1520. const o = e[n - 1];
  1521. if (s.trim() === K2.CLOSE_BRACES && o != null && typeof o != "string" && o.nodeType === $e.FUNCTION && o.token.trim().substring(0, 1) === K2.OPEN_BRACES) {
  1522. o.nodeType = $e.ARRAY, o.token += s, o.endIndex += s.length, n++;
  1523. continue;
  1524. }
  1525. t.push(s);
  1526. } else {
  1527. const o = e[n + 1], u = e[n + 2];
  1528. o === K2.COLON && typeof s != "string" && u != null && typeof u != "string" && rn((s.token + o + u.token).trim()) && (s.nodeType = $e.REFERENCE, s.token += o + u.token, s.endIndex = u.endIndex, n += 2), t.push(s);
  1529. }
  1530. n++;
  1531. }
  1532. return this._minusSplitSequenceNode(t);
  1533. }
  1534. /**
  1535. * =-A1 Separate the negative sign from the ref string.
  1536. */
  1537. _minusSplitSequenceNode(e) {
  1538. const t = [];
  1539. for (const r of e) {
  1540. if (typeof r != "string") {
  1541. const s = r.token.match(/^(\s*([-@+]\s*)+)(.*)$/);
  1542. if (s) {
  1543. const o = s[1], u = s[3];
  1544. if (rn(u.trim())) {
  1545. const c = o.length, l2 = r.startIndex, f2 = r.startIndex + c - 1, h = {
  1546. nodeType: $e.NORMAL,
  1547. // Use appropriate nodeType for operators
  1548. token: o,
  1549. startIndex: l2,
  1550. endIndex: f2
  1551. }, d2 = {
  1552. nodeType: $e.REFERENCE,
  1553. token: u,
  1554. startIndex: f2 + 1,
  1555. endIndex: r.endIndex
  1556. };
  1557. t.push(h), t.push(d2);
  1558. continue;
  1559. }
  1560. }
  1561. }
  1562. t.push(r);
  1563. }
  1564. return t;
  1565. }
  1566. _pushSequenceNode(e, t, r) {
  1567. const n = r - t.startIndex + 1;
  1568. e.splice(e.length - n, n, t);
  1569. }
  1570. nodeMakerTest(e) {
  1571. return this._nodeMaker(e);
  1572. }
  1573. treeBuilder(e, t = true, r, n) {
  1574. if (t === true) {
  1575. const h = ss.get(e), d2 = n == null ? void 0 : n(e);
  1576. if (h && !d2)
  1577. return h;
  1578. }
  1579. this._resetCurrentLexerNode(), this._currentLexerNode.setToken(Ut);
  1580. const s = [];
  1581. let o = this._nodeMaker(e, s);
  1582. if (o === m2.VALUE || s.length === 0)
  1583. return o;
  1584. let u = false, c = "", l2 = [];
  1585. if (r) {
  1586. const { hasDefinedName: h, sequenceString: d2, definedNames: _ } = r(s);
  1587. u = h, c = d2, l2 = _;
  1588. }
  1589. if (u && (this._resetCurrentLexerNode(), this._currentLexerNode.setToken(Ut), o = this._nodeMaker(`=${c}`), o === m2.VALUE))
  1590. return o;
  1591. const f2 = this._getTopNode(this._currentLexerNode);
  1592. if (f2 && (this._currentLexerNode = f2), t) {
  1593. if (!this._suffixExpressionHandler(this._currentLexerNode))
  1594. return m2.VALUE;
  1595. ss.set(e, this._currentLexerNode);
  1596. }
  1597. return u && this._currentLexerNode.setDefinedNames(l2), this._currentLexerNode;
  1598. }
  1599. // eslint-disable-next-line complexity
  1600. _suffixExpressionHandler(e) {
  1601. var u;
  1602. const t = e.getChildren();
  1603. if (!t)
  1604. return false;
  1605. const r = t.length, n = [], s = [];
  1606. let o = true;
  1607. for (let c = 0; c < r; c++) {
  1608. const l2 = t[c];
  1609. if (l2 instanceof ae)
  1610. o = this._suffixExpressionHandler(l2), n.push(l2);
  1611. else {
  1612. const f2 = l2.trim();
  1613. if (f2 === "")
  1614. continue;
  1615. if (Dt.has(f2)) {
  1616. if (f2 === X2.PLUS && this._deletePlusForPreNode(t[c - 1]))
  1617. continue;
  1618. if (f2 !== X2.PLUS && f2 !== X2.MINUS && this._deletePlusForPreNode(t[c - 1]))
  1619. return false;
  1620. for (; s.length > 0; ) {
  1621. const h = (u = s[s.length - 1]) == null ? void 0 : u.trim();
  1622. if (!h || h === K2.OPEN_BRACKET)
  1623. break;
  1624. const d2 = Jr.get(h), _ = Jr.get(f2);
  1625. if (!d2 || !_)
  1626. break;
  1627. if (_ >= d2)
  1628. n.push(s.pop());
  1629. else
  1630. break;
  1631. }
  1632. s.push(l2);
  1633. } else if (f2 === K2.OPEN_BRACKET)
  1634. s.push(l2);
  1635. else if (f2 === K2.CLOSE_BRACKET)
  1636. this._processSuffixExpressionCloseBracket(n, s, t, c);
  1637. else {
  1638. if (this._checkCloseBracket(t[c - 1]))
  1639. return false;
  1640. n.push(l2);
  1641. }
  1642. }
  1643. }
  1644. return o ? this._processSuffixExpressionRemain(n, s, e) : false;
  1645. }
  1646. _processSuffixExpressionRemain(e, t, r) {
  1647. const n = e.length, s = e[n - 1];
  1648. for (; t.length > 0; ) {
  1649. const o = t.pop();
  1650. if (!(s instanceof ae) && (o === K2.OPEN_BRACKET || o === K2.CLOSE_BRACKET))
  1651. return false;
  1652. e.push(o);
  1653. }
  1654. return r.setChildren(e), true;
  1655. }
  1656. _processSuffixExpressionCloseBracket(e, t, r, n) {
  1657. var s;
  1658. if (this._checkOpenBracket(r[n - 1]) || this._checkOperator(r[n - 1]))
  1659. return false;
  1660. for (; t.length > 0; ) {
  1661. const o = (s = t[t.length - 1]) == null ? void 0 : s.trim();
  1662. if (!o)
  1663. break;
  1664. if (o === K2.OPEN_BRACKET) {
  1665. t.pop();
  1666. break;
  1667. }
  1668. e.push(t.pop());
  1669. }
  1670. }
  1671. _checkCloseBracket(e) {
  1672. return e === K2.CLOSE_BRACKET || e instanceof ae;
  1673. }
  1674. _checkOpenBracket(e) {
  1675. return e === K2.OPEN_BRACKET;
  1676. }
  1677. _checkOperator(e) {
  1678. return e == null || e instanceof ae ? false : Dt.has(e);
  1679. }
  1680. _deletePlusForPreNode(e) {
  1681. if (e == null)
  1682. return true;
  1683. if (!(e instanceof ae)) {
  1684. const t = e.trim();
  1685. if (Dt.has(t) || t === K2.OPEN_BRACKET)
  1686. return true;
  1687. }
  1688. return false;
  1689. }
  1690. _resetCurrentLexerNode() {
  1691. this._currentLexerNode = new ae();
  1692. }
  1693. _resetSegment() {
  1694. this._segment = "";
  1695. }
  1696. _openBracket(e = 0) {
  1697. this._bracketState.push(e);
  1698. }
  1699. _closeBracket() {
  1700. this._bracketState.pop();
  1701. }
  1702. _openSquareBracket() {
  1703. this._squareBracketState += 1;
  1704. }
  1705. _closeSquareBracket() {
  1706. this._squareBracketState -= 1;
  1707. }
  1708. _getCurrentBracket() {
  1709. const e = this._bracketState;
  1710. return e[e.length - 1];
  1711. }
  1712. _changeCurrentBracket(e) {
  1713. const t = this._bracketState;
  1714. t[t.length - 1] = e;
  1715. }
  1716. _openBraces() {
  1717. this._bracesState += 1;
  1718. }
  1719. _closeBraces() {
  1720. this._bracesState -= 1;
  1721. }
  1722. _openSingleQuotation() {
  1723. this._singleQuotationState += 1;
  1724. }
  1725. _closeSingleQuotation() {
  1726. this._singleQuotationState -= 1;
  1727. }
  1728. _openDoubleQuotation() {
  1729. this._doubleQuotationState += 1;
  1730. }
  1731. _closeDoubleQuotation() {
  1732. this._doubleQuotationState -= 1;
  1733. }
  1734. _openLambda() {
  1735. this._lambdaState = true;
  1736. }
  1737. _closeLambda() {
  1738. this._lambdaState = false;
  1739. }
  1740. _openColon(e) {
  1741. this._upLevel = e, this._colonState = true;
  1742. }
  1743. _closeColon() {
  1744. this._upLevel = 0, this._colonState = false;
  1745. }
  1746. _isTableBracket() {
  1747. return this._tableBracketState;
  1748. }
  1749. _openTableBracket() {
  1750. this._tableBracketState = true;
  1751. }
  1752. _closeTableBracket() {
  1753. this._tableBracketState = false;
  1754. }
  1755. _formalErrorOccurred() {
  1756. this._formulaErrorCount += 1;
  1757. }
  1758. _hasFormalError() {
  1759. return this._formulaErrorCount > 0;
  1760. }
  1761. _getLastChildCurrentLexerNode() {
  1762. const e = this._currentLexerNode.getChildren();
  1763. if (e && e.length > 0) {
  1764. const t = e[e.length - 1];
  1765. if (t instanceof ae)
  1766. return t;
  1767. }
  1768. return false;
  1769. }
  1770. _getLastChildCurrent() {
  1771. const e = this._currentLexerNode.getChildren();
  1772. return e && e.length > 0 ? e[e.length - 1] : false;
  1773. }
  1774. _setParentCurrentLexerNode() {
  1775. const e = this._currentLexerNode.getParent();
  1776. return e ? (this._currentLexerNode = e, true) : false;
  1777. }
  1778. _setAncestorCurrentLexerNode() {
  1779. var r, n, s, o, u, c;
  1780. const e = (r = this._currentLexerNode) == null ? void 0 : r.getParent();
  1781. let t = false;
  1782. if (e && e.getToken() === hr) {
  1783. if ((n = e == null ? void 0 : e.getParent()) != null && n.getParent()) {
  1784. const l2 = (o = (s = this._currentLexerNode.getParent()) == null ? void 0 : s.getParent()) == null ? void 0 : o.getParent();
  1785. l2 && (this._currentLexerNode = l2), t = true;
  1786. }
  1787. } else if (e != null && e.getParent()) {
  1788. const l2 = (u = this._currentLexerNode.getParent()) == null ? void 0 : u.getParent();
  1789. l2 && (this._currentLexerNode = l2), t = true;
  1790. }
  1791. for (let l2 = 0; l2 < this._upLevel; l2++) {
  1792. const f2 = (c = this._currentLexerNode) == null ? void 0 : c.getParent();
  1793. f2 && (this._currentLexerNode = f2), this._currentLexerNode ? t = true : t = false;
  1794. }
  1795. return t;
  1796. }
  1797. _segmentCount() {
  1798. return this._segment.trim().length;
  1799. }
  1800. _pushSegment(e) {
  1801. this._segment += e;
  1802. }
  1803. _pushNodeToChildren(e, t = false) {
  1804. let r = e;
  1805. if (r !== "") {
  1806. const n = this._currentLexerNode.getChildren();
  1807. if (!(r instanceof ae) && this.isColonOpen()) {
  1808. const s = new ae();
  1809. s.setToken(r), s.setParent(this._currentLexerNode), r = s;
  1810. }
  1811. t ? n.unshift(r) : n.push(r);
  1812. }
  1813. this.isColonOpen() && (this._setAncestorCurrentLexerNode(), this._closeColon());
  1814. }
  1815. _setCurrentLexerNode(e, t = false) {
  1816. this._pushNodeToChildren(e, t), e.setParent(this._currentLexerNode), this._currentLexerNode = e;
  1817. }
  1818. _newAndPushCurrentLexerNode(e, t, r = false) {
  1819. const n = new ae();
  1820. n.setToken(e), n.setIndex(t - e.length, t - 1), this._setCurrentLexerNode(n, r);
  1821. }
  1822. _getTopNode(e) {
  1823. let t = e;
  1824. for (; t != null && t.getParent(); )
  1825. t = t.getParent();
  1826. return t;
  1827. }
  1828. _removeLastChild() {
  1829. this._currentLexerNode.getChildren().splice(-1);
  1830. }
  1831. /**
  1832. * fix univer-pro/issues/2447
  1833. * =1/3+
  1834. * =+
  1835. * =sum(A1+)
  1836. */
  1837. _formulaErrorLastTokenCheck(e, t) {
  1838. const r = this._findPreviousToken(e, t) || "", n = e.length - 1 === t;
  1839. if (!n && this._isOperatorToken(r) || n && sc(r))
  1840. return true;
  1841. if (rs.has(r)) {
  1842. const s = this._findSecondLastNonSpaceToken(e, t);
  1843. if (s == null || ic(s))
  1844. return true;
  1845. }
  1846. return false;
  1847. }
  1848. _findPreviousToken(e, t) {
  1849. let r = t;
  1850. for (; r >= 0; ) {
  1851. const n = e[r];
  1852. if (n !== " ")
  1853. return n;
  1854. r--;
  1855. }
  1856. }
  1857. _findSecondLastNonSpaceToken(e, t) {
  1858. let r = t, n = 0;
  1859. for (; r >= 0; ) {
  1860. const s = e[r];
  1861. if (s !== " " && (n++, n === 2))
  1862. return s;
  1863. r--;
  1864. }
  1865. return null;
  1866. }
  1867. _findNextToken(e, t) {
  1868. let r = t;
  1869. for (; r >= 0; ) {
  1870. const n = e[r];
  1871. if (n !== " ")
  1872. return n;
  1873. r++;
  1874. }
  1875. }
  1876. _unexpectedEndingTokenExcludeOperator(e) {
  1877. return (
  1878. // OPERATOR_TOKEN_SET.has(prevString) ||
  1879. e === K2.OPEN_BRACKET || e === K2.COMMA || e === X2.EQUALS || e === ""
  1880. );
  1881. }
  1882. _unexpectedEndingToken(e) {
  1883. return !!(this._isOperatorToken(e) || this._unexpectedEndingTokenExcludeOperator(e));
  1884. }
  1885. _isOperatorToken(e) {
  1886. return !!Dt.has(e);
  1887. }
  1888. _getSequenceArray(e) {
  1889. const t = [];
  1890. return this._nodeMaker(e, t), t;
  1891. }
  1892. _resetTemp() {
  1893. this._currentLexerNode = new ae(), this._upLevel = 0, this._segment = "", this._bracketState = [], this._bracesState = 0, this._singleQuotationState = 0, this._doubleQuotationState = 0, this._lambdaState = false, this._colonState = false, this._formulaErrorCount = 0;
  1894. }
  1895. _checkErrorState() {
  1896. return !!(this._bracketState.length > 0 || this._bracesState > 0 || this._singleQuotationState > 0 || this._doubleQuotationState > 0 || this._hasFormalError());
  1897. }
  1898. _checkSimilarErrorToken(e, t, r) {
  1899. let n = t;
  1900. if (e !== ze.POUND)
  1901. return true;
  1902. let s = r[++n];
  1903. for (; s === " "; )
  1904. s = r[++n];
  1905. return !!en2(s);
  1906. }
  1907. _checkIfErrorObject(e, t) {
  1908. return !!this._findErrorObject(e, t);
  1909. }
  1910. _findErrorObject(e, t) {
  1911. for (let r = 0; r < Ga.length; r++) {
  1912. const n = Ga[r], s = t.slice(e, e + n).join("").toUpperCase();
  1913. if (yr.has(s))
  1914. return s;
  1915. }
  1916. }
  1917. // eslint-disable-next-line max-lines-per-function, complexity
  1918. _nodeMaker(e, t, r) {
  1919. let n = e.replace(/\r\n$/, "").replace(/\r/g, " ").replace(/\n/g, " ");
  1920. n.substring(0, 1) === X2.EQUALS && (n = n.substring(1));
  1921. const s = n.split(""), o = s.length;
  1922. let u = 0;
  1923. for (this._resetTemp(), this._formulaErrorLastTokenCheck(s, o - 1) && this._formalErrorOccurred(); u < o; ) {
  1924. const c = s[u];
  1925. if (r === u)
  1926. return [this._currentLexerNode, c];
  1927. if (c === ze.POUND && this.isSingleQuotationClose() && this.isDoubleQuotationClose() && this.isBracesClose() && this.isSquareBracketClose() && this._checkIfErrorObject(u, s)) {
  1928. const l2 = this._findErrorObject(u, s);
  1929. if (l2 == null)
  1930. return m2.VALUE;
  1931. this._pushNodeToChildren(l2);
  1932. for (let f2 = 0; f2 < l2.length; f2++) {
  1933. const h = s[u];
  1934. this._pushSegment(h), this._addSequenceArray(t, h, u), u++;
  1935. }
  1936. this._resetSegment();
  1937. continue;
  1938. } else if (c === K2.OPEN_BRACKET && this.isSingleQuotationClose() && this.isDoubleQuotationClose())
  1939. if (this._segmentCount() > 0 || this.isLambdaOpen()) {
  1940. this.isLambdaClose() && (this._newAndPushCurrentLexerNode(this._segment, u), this._resetSegment()), this._openBracket(
  1941. 1
  1942. /* FUNCTION */
  1943. ), this._closeLambda();
  1944. const l2 = s[u + 1];
  1945. if (l2 && l2 === K2.CLOSE_BRACKET) {
  1946. if (!this._setParentCurrentLexerNode() && u !== o - 1)
  1947. return m2.VALUE;
  1948. this._addSequenceArray(t, c, u), u++, this._addSequenceArray(t, l2, u), u++, this._closeBracket();
  1949. continue;
  1950. } else
  1951. l2 && this._newAndPushCurrentLexerNode(ht, u);
  1952. } else
  1953. this._pushNodeToChildren(c), this._openBracket(
  1954. 0
  1955. /* NORMAL */
  1956. ), this._resetSegment();
  1957. else if (c === K2.CLOSE_BRACKET && this.isSingleQuotationClose() && this.isDoubleQuotationClose()) {
  1958. this._formulaErrorLastTokenCheck(s, u - 1) && this._formalErrorOccurred(), this._pushNodeToChildren(this._segment), this._resetSegment();
  1959. const l2 = this._getCurrentBracket();
  1960. if (l2 === 0)
  1961. this._pushNodeToChildren(c);
  1962. else if (l2 === 1) {
  1963. const f2 = s[u + 1];
  1964. if (f2 && f2 === K2.OPEN_BRACKET) {
  1965. if (!this._setParentCurrentLexerNode() && u !== o - 1)
  1966. return m2.VALUE;
  1967. this._newAndPushCurrentLexerNode(hr, u, true), this._openLambda();
  1968. } else if (!this._setAncestorCurrentLexerNode() && u !== o - 1)
  1969. return m2.VALUE;
  1970. } else
  1971. return m2.VALUE;
  1972. this._closeBracket();
  1973. } else if (c === K2.OPEN_BRACES && this.isSingleQuotationClose() && this.isDoubleQuotationClose()) {
  1974. if (this._pushSegment(c), this._openBraces(), !this._formulaSpellCheck())
  1975. return m2.VALUE;
  1976. } else if (c === K2.CLOSE_BRACES && this.isSingleQuotationClose() && this.isDoubleQuotationClose())
  1977. this._pushSegment(c), this._pushNodeToChildren(this._segment), this._resetSegment(), this._closeBraces();
  1978. else if (c === K2.OPEN_SQUARE_BRACKET && this.isSingleQuotationClose() && this.isDoubleQuotationClose())
  1979. this._segment.length > 0 && this._openTableBracket(), this._pushSegment(c), this._openSquareBracket();
  1980. else if (c === K2.CLOSE_SQUARE_BRACKET && this.isSingleQuotationClose() && this.isDoubleQuotationClose())
  1981. this._closeSquareBracket(), this.isSquareBracketClose() ? (this._pushSegment(c), this._isTableBracket() && (this._pushNodeToChildren(this._segment), this._resetSegment()), this._closeTableBracket()) : this._pushSegment(c);
  1982. else if (c === K2.DOUBLE_QUOTATION && this.isSingleQuotationClose() && this.isSquareBracketClose()) {
  1983. if (this.isDoubleQuotationClose())
  1984. this._openDoubleQuotation();
  1985. else {
  1986. const l2 = s[u + 1];
  1987. l2 && l2 === K2.DOUBLE_QUOTATION ? u++ : this._closeDoubleQuotation();
  1988. }
  1989. this._pushSegment(c);
  1990. } else if (c === K2.SINGLE_QUOTATION && this.isDoubleQuotationClose()) {
  1991. if (this.isSingleQuotationClose())
  1992. this._openSingleQuotation(), this._segmentCount() === 0 && this._resetSegment();
  1993. else {
  1994. const l2 = s[u + 1];
  1995. if (l2 && l2 === K2.SINGLE_QUOTATION) {
  1996. this._pushSegment(c), this._addSequenceArray(t, c, u), u++, this._pushSegment(l2), this._addSequenceArray(t, l2, u), u++;
  1997. continue;
  1998. } else
  1999. this._closeSingleQuotation();
  2000. }
  2001. this._pushSegment(c);
  2002. } else if (c === K2.COMMA && this.isSingleQuotationClose() && this.isDoubleQuotationClose() && this.isBracesClose() && this.isSquareBracketClose()) {
  2003. this._formulaErrorLastTokenCheck(s, u - 1) && this._formalErrorOccurred();
  2004. const l2 = this._getCurrentBracket();
  2005. if (l2 === 1 || l2 == null) {
  2006. if (this._pushNodeToChildren(this._segment), this._resetSegment(), !this._setParentCurrentLexerNode() && u !== o - 1 && l2 != null)
  2007. return m2.VALUE;
  2008. this._newAndPushCurrentLexerNode(ht, u);
  2009. } else {
  2010. const f2 = new ae();
  2011. f2.setToken(Tc);
  2012. const h = new ae();
  2013. h.setToken(ht), h.changeToParent(f2);
  2014. const d2 = this._currentLexerNode.getParent();
  2015. if (d2 && d2.getToken() === K2.COLON) {
  2016. const _ = d2.getParent();
  2017. if (!_)
  2018. return m2.VALUE;
  2019. d2.changeToParent(h), _.setChildren([]), f2.changeToParent(_);
  2020. } else
  2021. return m2.VALUE;
  2022. this._changeCurrentBracket(
  2023. 1
  2024. /* FUNCTION */
  2025. ), this._pushNodeToChildren(this._segment), this._resetSegment(), this._currentLexerNode = f2, this._newAndPushCurrentLexerNode(ht, u);
  2026. }
  2027. } else if (c === K2.COLON && this.isSingleQuotationClose() && this.isDoubleQuotationClose() && this.isBracesClose() && this.isSquareBracketClose()) {
  2028. const l2 = new ae();
  2029. l2.setToken(c);
  2030. const f2 = new ae();
  2031. f2.setToken(ht), f2.setParent(l2);
  2032. const h = new ae();
  2033. h.setToken(ht), h.setParent(l2), l2.getChildren().push(f2, h);
  2034. let d2 = l2, _ = 0;
  2035. if (this._segmentCount() > 0) {
  2036. let C, E2, b = 0;
  2037. const R = this._segment.trim(), p2 = R[0], N2 = R[1];
  2038. if (p2 === Oe.MINUS && (C = new ae(), C.setToken(Oe.MINUS), b++), (p2 === Oe.AT || N2 === Oe.AT) && (E2 = new ae(), E2.setToken(Oe.AT), C && (C.addChildren(E2), E2.setParent(C)), b++), b > 0 && (this._segment = R.slice(b)), _ = b, E2)
  2039. if (E2.addChildren(l2), l2.setParent(E2), E2.getParent()) {
  2040. const w = E2.getParent();
  2041. w && (d2 = w);
  2042. } else
  2043. d2 = E2;
  2044. else
  2045. C && (d2 = C, C.addChildren(l2), l2.setParent(C));
  2046. const M2 = new ae();
  2047. M2.setToken(this._segment), M2.setParent(f2), f2.getChildren().push(M2), this._resetSegment();
  2048. } else {
  2049. const C = this._getLastChildCurrentLexerNode();
  2050. C && C.changeToParent(f2);
  2051. }
  2052. this._setCurrentLexerNode(d2), this._currentLexerNode = h, this._openColon(_);
  2053. } else if (rs.has(c) && this._checkSimilarErrorToken(c, u, s) && this.isSingleQuotationClose() && this.isDoubleQuotationClose() && this.isSquareBracketClose() && this.isBracesClose()) {
  2054. this._pushNodeToChildren(this._segment);
  2055. const l2 = new ae();
  2056. l2.setToken(c);
  2057. const f2 = this._getLastChildCurrent();
  2058. f2 instanceof ae ? f2.changeToParent(l2) : f2 !== false && (l2.getChildren().push(f2), this._removeLastChild()), this._pushNodeToChildren(l2), l2.setParent(this._currentLexerNode), this._resetSegment();
  2059. } else if (Dt.has(c) && this.isSingleQuotationClose() && this.isDoubleQuotationClose() && this.isSquareBracketClose() && this.isBracesClose()) {
  2060. let l2 = this._segment.trim();
  2061. if (c === X2.MINUS && l2 === "") {
  2062. const f2 = this._findPreviousToken(s, u - 1) || "", h = this._findNextToken(s, u + 1) || "";
  2063. if (this._unexpectedEndingTokenExcludeOperator(f2) && this._isOperatorToken(h)) {
  2064. this._pushNodeToChildren("0"), this._pushNodeToChildren(X2.MINUS), this._addSequenceArray(t, c, u), this._resetSegment(), u++;
  2065. continue;
  2066. } else if (this._unexpectedEndingToken(f2))
  2067. if (h === X2.PLUS) {
  2068. this._pushSegment(X2.MINUS), this._addSequenceArray(t, c, u), this._addSequenceArray(t, X2.PLUS, u + 1), u += 2;
  2069. continue;
  2070. } else {
  2071. this._pushSegment(X2.MINUS), this._addSequenceArray(t, c, u), u++;
  2072. continue;
  2073. }
  2074. } else if (this._segment.length > 0 && this._isScientificNotation(s, u, c)) {
  2075. this._pushSegment(c), this._addSequenceArray(t, c, u), u++;
  2076. continue;
  2077. } else
  2078. this._segment.length > 0 && l2 === "" ? l2 = this._segment : (this._pushNodeToChildren(this._segment), l2 = "");
  2079. if (c === X2.LESS_THAN || c === X2.GREATER_THAN) {
  2080. const f2 = s[u + 1];
  2081. if (f2 && Dt.has(c + f2)) {
  2082. this._pushNodeToChildren(l2 + c + f2), this._resetSegment(), this._addSequenceArray(t, c, u), u++, this._addSequenceArray(t, f2, u), u++;
  2083. continue;
  2084. } else
  2085. this._pushNodeToChildren(l2 + c);
  2086. } else
  2087. this._pushNodeToChildren(l2 + c);
  2088. this._resetSegment();
  2089. } else
  2090. this._pushSegment(c);
  2091. this._addSequenceArray(t, c, u), u++;
  2092. }
  2093. if (this._pushNodeToChildren(this._segment), this._checkErrorState())
  2094. return m2.VALUE;
  2095. }
  2096. _isScientificNotation(e, t, r) {
  2097. const n = e[t - 2];
  2098. if (n && Number.isNaN(Number(n)) || !(r === X2.MINUS || r === X2.PLUS))
  2099. return false;
  2100. const s = e[t + 1];
  2101. if (s && Number.isNaN(Number(s)))
  2102. return false;
  2103. const o = e[t - 1];
  2104. return o && o.toUpperCase() === "E";
  2105. }
  2106. _addSequenceArray(e, t, r) {
  2107. e == null || e.push({
  2108. segment: this._segment,
  2109. currentString: t,
  2110. cur: r,
  2111. currentLexerNode: this._currentLexerNode
  2112. });
  2113. }
  2114. };
  2115. function Fc(i, a2, e, t, r, n, s) {
  2116. const o = (s == null ? void 0 : s.f) || "", u = (s == null ? void 0 : s.si) || "", c = vC(o), l2 = yC(u), f2 = i.getValue(r, n), h = (f2 == null ? void 0 : f2.f) || "", d2 = (f2 == null ? void 0 : f2.si) || "";
  2117. function _() {
  2118. var C;
  2119. if (vC(h) && yC(d2)) {
  2120. const E2 = (C = e == null ? void 0 : e[d2]) == null ? void 0 : C.f;
  2121. E2 ? t.set(d2, E2) : t.set(d2, h);
  2122. }
  2123. }
  2124. c && l2 ? (d2 !== u && _(), i.setValue(r, n, {
  2125. f: o,
  2126. si: u
  2127. }), e[u] = { f: o, r, c: n }, a2.setValue(r, n, {
  2128. f: o,
  2129. si: u
  2130. })) : c && !l2 ? (h !== o && _(), i.setValue(r, n, {
  2131. f: o
  2132. }), a2.setValue(r, n, {
  2133. f: o
  2134. })) : !c && l2 ? (d2 !== u && _(), i.setValue(r, n, {
  2135. f: "",
  2136. si: u
  2137. })) : !c && !l2 && i.getValue(r, n) && (_(), i.realDeleteValue(r, n), a2.setValue(r, n, null));
  2138. }
  2139. function kc(i, a2, e, t) {
  2140. const r = i == null ? void 0 : i.getValue(e, t);
  2141. if (r == null)
  2142. return true;
  2143. const n = [];
  2144. i.forValue((l2, f2, h) => {
  2145. l2 === e && f2 === t || en.intersects(h, r) && n.push(h);
  2146. });
  2147. const { startRow: s, startColumn: o, endRow: u, endColumn: c } = r;
  2148. for (let l2 = s; l2 <= u; l2++)
  2149. for (let f2 = o; f2 <= c; f2++) {
  2150. let h = false;
  2151. const d2 = AC(l2, f2);
  2152. n.some((_) => en.contains(_, d2) ? (h = true, true) : false), h || a2.realDeleteValue(l2, f2);
  2153. }
  2154. }
  2155. var $c = Object.defineProperty;
  2156. var Yc = Object.getOwnPropertyDescriptor;
  2157. var Hc = (i, a2, e, t) => {
  2158. for (var r = t > 1 ? void 0 : t ? Yc(a2, e) : a2, n = i.length - 1, s; n >= 0; n--)
  2159. (s = i[n]) && (r = (t ? s(a2, e, r) : s(r)) || r);
  2160. return t && r && $c(a2, e, r), r;
  2161. };
  2162. var ni = (i, a2) => (e, t) => a2(e, t, i);
  2163. var Pr = class extends nt {
  2164. constructor(a2, e) {
  2165. super();
  2166. A(this, "_arrayFormulaRange", {});
  2167. A(this, "_arrayFormulaCellData", {});
  2168. this._univerInstanceService = a2, this._lexerTreeBuilder = e;
  2169. }
  2170. dispose() {
  2171. super.dispose(), this._arrayFormulaRange = {}, this._arrayFormulaCellData = {};
  2172. }
  2173. clearPreviousArrayFormulaCellData(a2) {
  2174. Object.keys(a2).forEach((e) => {
  2175. const t = a2[e];
  2176. if (t == null)
  2177. return true;
  2178. Object.keys(t).forEach((r) => {
  2179. var c, l2, f2, h;
  2180. const n = t[r], s = (l2 = (c = this._arrayFormulaRange) == null ? void 0 : c[e]) == null ? void 0 : l2[r];
  2181. if (s == null)
  2182. return true;
  2183. const o = new kt(s);
  2184. let u = new kt();
  2185. ((f2 = this._arrayFormulaCellData[e]) == null ? void 0 : f2[r]) != null && (u = new kt(
  2186. (h = this._arrayFormulaCellData[e]) == null ? void 0 : h[r]
  2187. )), n.forValue((d2, _) => {
  2188. const C = o.getValue(d2, _);
  2189. if (C == null)
  2190. return true;
  2191. const { startRow: E2, startColumn: b, endRow: R, endColumn: p2 } = C;
  2192. for (let N2 = E2; N2 <= R; N2++)
  2193. for (let M2 = b; M2 <= p2; M2++)
  2194. u.setValue(N2, M2, null);
  2195. o.realDeleteValue(d2, _);
  2196. }), this._arrayFormulaCellData[e] && (this._arrayFormulaCellData[e][r] = u.getData());
  2197. });
  2198. });
  2199. }
  2200. mergeArrayFormulaCellData(a2) {
  2201. Object.keys(a2).forEach((e) => {
  2202. const t = a2[e];
  2203. if (t == null)
  2204. return true;
  2205. this._arrayFormulaRange[e] == null && (this._arrayFormulaRange[e] = {}), this._arrayFormulaCellData[e] == null && (this._arrayFormulaCellData[e] = {}), Object.keys(t).forEach((r) => {
  2206. var u, c;
  2207. const n = t[r], s = new kt((u = this._arrayFormulaRange[e]) == null ? void 0 : u[r]), o = new kt((c = this._arrayFormulaCellData[e]) == null ? void 0 : c[r]);
  2208. n.forValue((l2, f2) => {
  2209. const h = s == null ? void 0 : s.getValue(l2, f2);
  2210. if (h == null)
  2211. return true;
  2212. const { startRow: d2, startColumn: _, endRow: C, endColumn: E2 } = h;
  2213. for (let b = d2; b <= C; b++)
  2214. for (let R = _; R <= E2; R++)
  2215. o.setValue(b, R, null);
  2216. }), n.forValue((l2, f2, h) => {
  2217. o.setValue(l2, f2, h);
  2218. }), this._arrayFormulaCellData[e] && (this._arrayFormulaCellData[e][r] = o.getData());
  2219. });
  2220. });
  2221. }
  2222. getFormulaData() {
  2223. const a2 = {}, e = this._univerInstanceService.getAllUnitsForType(Fe.UNIVER_SHEET);
  2224. return e.length === 0 || e.forEach((t) => {
  2225. const r = t.getUnitId();
  2226. a2[r] = {}, t.getSheets().forEach((s) => {
  2227. const o = s.getCellMatrix(), u = s.getSheetId();
  2228. si(a2, r, u, o);
  2229. });
  2230. }), a2;
  2231. }
  2232. getSheetFormulaData(a2, e) {
  2233. const t = {}, r = this._univerInstanceService.getUnit(a2);
  2234. if (r == null)
  2235. return {};
  2236. t[a2] = {};
  2237. const n = r.getSheetBySheetId(e);
  2238. if (n == null)
  2239. return {};
  2240. const s = n.getCellMatrix();
  2241. return si(t, a2, e, s), t[a2][e];
  2242. }
  2243. getArrayFormulaRange() {
  2244. return this._arrayFormulaRange;
  2245. }
  2246. setArrayFormulaRange(a2) {
  2247. this._arrayFormulaRange = a2;
  2248. }
  2249. getArrayFormulaCellData() {
  2250. return this._arrayFormulaCellData;
  2251. }
  2252. setArrayFormulaCellData(a2) {
  2253. this._arrayFormulaCellData = a2;
  2254. }
  2255. mergeArrayFormulaRange(a2) {
  2256. Object.keys(a2).forEach((e) => {
  2257. const t = a2[e];
  2258. if (t == null)
  2259. return true;
  2260. this._arrayFormulaRange[e] || (this._arrayFormulaRange[e] = {}), Object.keys(t).forEach((r) => {
  2261. var o;
  2262. const n = new kt(t[r]), s = new kt((o = this._arrayFormulaRange[e]) == null ? void 0 : o[r]);
  2263. n.forValue((u, c, l2) => {
  2264. s.setValue(u, c, l2);
  2265. }), this._arrayFormulaRange[e] && (this._arrayFormulaRange[e][r] = s.getData());
  2266. });
  2267. });
  2268. }
  2269. deleteArrayFormulaRange(a2, e, t, r) {
  2270. var o;
  2271. const n = (o = this._arrayFormulaRange[a2]) == null ? void 0 : o[e];
  2272. if (n == null)
  2273. return;
  2274. const s = new kt(n);
  2275. s.getValue(t, r) && (s.realDeleteValue(t, r), this._arrayFormulaRange[a2] && (this._arrayFormulaRange[a2][e] = s.getData()));
  2276. }
  2277. getCalculateData() {
  2278. const a2 = this._univerInstanceService.getAllUnitsForType(Fe.UNIVER_SHEET), e = {}, t = {};
  2279. for (const r of a2) {
  2280. const n = r.getUnitId(), s = r.getSheets(), o = {}, u = {};
  2281. for (const c of s) {
  2282. const l2 = c.getSheetId(), f2 = c.getConfig();
  2283. o[l2] = {
  2284. cellData: new kt(f2.cellData),
  2285. rowCount: f2.rowCount,
  2286. columnCount: f2.columnCount,
  2287. rowData: f2.rowData,
  2288. columnData: f2.columnData,
  2289. defaultRowHeight: f2.defaultRowHeight,
  2290. defaultColumnWidth: f2.defaultColumnWidth
  2291. }, u[c.getName()] = c.getSheetId();
  2292. }
  2293. e[n] = o, t[n] = u;
  2294. }
  2295. return {
  2296. allUnitData: e,
  2297. unitSheetNameMap: t
  2298. };
  2299. }
  2300. updateFormulaData(a2, e, t) {
  2301. const r = new kt(t), n = this._getSheetFormulaIdMap(a2, e), s = /* @__PURE__ */ new Map(), o = this.getFormulaData();
  2302. o[a2] == null && (o[a2] = {});
  2303. const u = o[a2];
  2304. u[e] == null && (u[e] = {});
  2305. const c = new kt(u[e] || {}), l2 = new kt();
  2306. return r.forValue((f2, h, d2) => {
  2307. Fc(c, l2, n, s, f2, h, d2);
  2308. }), c.forValue((f2, h, d2) => {
  2309. const _ = (d2 == null ? void 0 : d2.f) || "", C = (d2 == null ? void 0 : d2.si) || "";
  2310. if (yC(C)) {
  2311. const E2 = n == null ? void 0 : n[C], b = s.get(C);
  2312. if (E2 && !vC(_)) {
  2313. const R = E2.f, p2 = h - E2.c, N2 = f2 - E2.r;
  2314. c.setValue(f2, h, { f: R, si: C, x: p2, y: N2 }), l2.setValue(f2, h, { f: R, si: C, x: p2, y: N2 });
  2315. } else if (typeof b == "string") {
  2316. const R = (d2 == null ? void 0 : d2.x) || 0, p2 = (d2 == null ? void 0 : d2.y) || 0, N2 = this._lexerTreeBuilder.moveFormulaRefOffset(b, R, p2);
  2317. s.set(C, { r: f2, c: h, f: N2 }), c.setValue(f2, h, { f: N2, si: C }), l2.setValue(f2, h, { f: N2, si: C });
  2318. } else if (typeof b == "object") {
  2319. const R = h - b.c, p2 = f2 - b.r;
  2320. c.setValue(f2, h, { f: b.f, si: C, x: R, y: p2 }), l2.setValue(f2, h, { f: b.f, si: C, x: R, y: p2 });
  2321. }
  2322. }
  2323. }), l2.getMatrix();
  2324. }
  2325. updateArrayFormulaRange(a2, e, t) {
  2326. var o;
  2327. const r = (o = this._arrayFormulaRange[a2]) == null ? void 0 : o[e];
  2328. if (!r)
  2329. return;
  2330. const n = new kt(r);
  2331. new kt(t).forValue((u, c, l2) => {
  2332. n.realDeleteValue(u, c);
  2333. });
  2334. }
  2335. updateArrayFormulaCellData(a2, e, t) {
  2336. var c, l2;
  2337. const r = (c = this._arrayFormulaRange[a2]) == null ? void 0 : c[e];
  2338. if (!r)
  2339. return;
  2340. const n = new kt(r), s = (l2 = this._arrayFormulaCellData[a2]) == null ? void 0 : l2[e];
  2341. if (!s)
  2342. return;
  2343. const o = new kt(s);
  2344. new kt(t).forValue((f2, h, d2) => {
  2345. kc(n, o, f2, h);
  2346. });
  2347. }
  2348. getFormulaStringByCell(a2, e, t, r) {
  2349. const n = this._univerInstanceService.getUnit(r);
  2350. if (n == null)
  2351. return null;
  2352. const s = n.getSheetBySheetId(t);
  2353. if (s == null)
  2354. return null;
  2355. const o = s.getCellMatrix(), u = o.getValue(a2, e);
  2356. if (u == null)
  2357. return null;
  2358. const { f: c, si: l2 } = u;
  2359. if (vC(c))
  2360. return c;
  2361. if (yC(l2)) {
  2362. let f2 = null;
  2363. return o.forValue((h, d2, _) => {
  2364. if (_ == null)
  2365. return true;
  2366. const { f: C, si: E2 } = _;
  2367. if (vC(C) && l2 === E2)
  2368. return f2 = this._lexerTreeBuilder.moveFormulaRefOffset(
  2369. C,
  2370. e - d2,
  2371. a2 - h
  2372. ), false;
  2373. }), f2;
  2374. }
  2375. return null;
  2376. }
  2377. /**
  2378. * Function to get all formula ranges
  2379. * @returns
  2380. */
  2381. getFormulaDirtyRanges() {
  2382. const a2 = this.getFormulaData(), e = [];
  2383. for (const t in a2) {
  2384. const r = a2[t];
  2385. if (!r)
  2386. continue;
  2387. const n = this._univerInstanceService.getUnit(t);
  2388. if (n)
  2389. for (const s in r) {
  2390. const o = r[s];
  2391. if (!o)
  2392. continue;
  2393. const u = n.getSheetBySheetId(s);
  2394. if (!u)
  2395. continue;
  2396. const c = {};
  2397. for (const l2 of Object.keys(o)) {
  2398. const f2 = Number(l2);
  2399. for (const h in o[f2]) {
  2400. const d2 = Number(h), _ = u.getCellRaw(f2, d2), C = vC(_ == null ? void 0 : _.f) || yC(_ == null ? void 0 : _.si), E2 = (_ == null ? void 0 : _.v) === void 0;
  2401. if (!(C && E2))
  2402. continue;
  2403. c[d2] || (c[d2] = []);
  2404. const b = c[d2].slice(-1)[0];
  2405. b && b.endRow === f2 - 1 ? b.endRow = f2 : c[d2].push({ startRow: f2, endRow: f2 });
  2406. }
  2407. }
  2408. for (const l2 in c) {
  2409. const f2 = c[l2];
  2410. for (let h = 0; h < f2.length; h++) {
  2411. const d2 = f2[h];
  2412. e.push({
  2413. unitId: t,
  2414. sheetId: s,
  2415. range: {
  2416. rangeType: De.NORMAL,
  2417. startRow: d2.startRow,
  2418. endRow: d2.endRow,
  2419. // Use endRow as the inclusive end row
  2420. startColumn: Number(l2),
  2421. endColumn: Number(l2)
  2422. }
  2423. });
  2424. }
  2425. }
  2426. }
  2427. }
  2428. return e;
  2429. }
  2430. _getSheetFormulaIdMap(a2, e) {
  2431. const t = {}, r = this._univerInstanceService.getUnit(a2);
  2432. if (r == null)
  2433. return t;
  2434. const n = r.getSheetBySheetId(e);
  2435. return n == null || n.getCellMatrix().forValue((o, u, c) => {
  2436. if (c == null)
  2437. return true;
  2438. const { f: l2, si: f2 } = c;
  2439. vC(l2) && yC(f2) && (t[f2] = { f: l2, r: o, c: u });
  2440. }), t;
  2441. }
  2442. };
  2443. Pr = Hc([
  2444. ni(0, _n),
  2445. ni(1, ot(ca))
  2446. ], Pr);
  2447. function si(i, a2, e, t) {
  2448. i[a2] || (i[a2] = {}), i[a2][e] || (i[a2][e] = {});
  2449. const r = /* @__PURE__ */ new Map(), n = new kt(i[a2][e]);
  2450. t.forValue((o, u, c) => {
  2451. const l2 = (c == null ? void 0 : c.f) || "", f2 = (c == null ? void 0 : c.si) || "", h = vC(l2), d2 = yC(f2);
  2452. h && d2 ? (n.setValue(o, u, {
  2453. f: l2,
  2454. si: f2
  2455. }), r.set(f2, { f: l2, r: o, c: u })) : h && !d2 ? n.setValue(o, u, {
  2456. f: l2
  2457. }) : !h && d2 && n.setValue(o, u, {
  2458. f: "",
  2459. si: f2
  2460. });
  2461. }), n.forValue((o, u, c) => {
  2462. const l2 = (c == null ? void 0 : c.f) || "", f2 = (c == null ? void 0 : c.si) || "";
  2463. if (yC(f2) && !vC(l2)) {
  2464. const h = r.get(f2);
  2465. if (h) {
  2466. const d2 = h.f, _ = u - h.c, C = o - h.r;
  2467. n.setValue(o, u, { f: d2, si: f2, x: _, y: C });
  2468. } else
  2469. n.realDeleteValue(o, u);
  2470. }
  2471. });
  2472. const s = n.getMatrix();
  2473. return {
  2474. [a2]: {
  2475. [e]: s
  2476. }
  2477. };
  2478. }
  2479. var Gc = class Ms {
  2480. /**
  2481. * Accept two comparable values and creates new instance of interval
  2482. * Predicate Interval.comparable_less(low, high) supposed to return true on these values
  2483. * @param low
  2484. * @param high
  2485. */
  2486. constructor(a2, e) {
  2487. this.low = a2, this.high = e;
  2488. }
  2489. /**
  2490. * Clone interval
  2491. * @returns {Interval}
  2492. */
  2493. clone() {
  2494. return new Ms(this.low, this.high);
  2495. }
  2496. /**
  2497. * Propery max returns clone of this interval
  2498. * @returns {Interval}
  2499. */
  2500. get max() {
  2501. return this.clone();
  2502. }
  2503. /**
  2504. * Predicate returns true is this interval less than other interval
  2505. * @param other_interval
  2506. * @returns {boolean}
  2507. */
  2508. less_than(a2) {
  2509. return this.low < a2.low || this.low === a2.low && this.high < a2.high;
  2510. }
  2511. /**
  2512. * Predicate returns true is this interval equals to other interval
  2513. * @param other_interval
  2514. * @returns {boolean}
  2515. */
  2516. equal_to(a2) {
  2517. return this.low === a2.low && this.high === a2.high;
  2518. }
  2519. /**
  2520. * Predicate returns true if this interval intersects other interval
  2521. * @param other_interval
  2522. * @returns {boolean}
  2523. */
  2524. intersect(a2) {
  2525. return !this.not_intersect(a2);
  2526. }
  2527. /**
  2528. * Predicate returns true if this interval does not intersect other interval
  2529. * @param other_interval
  2530. * @returns {boolean}
  2531. */
  2532. not_intersect(a2) {
  2533. return this.high < a2.low || a2.high < this.low;
  2534. }
  2535. /**
  2536. * Returns new interval merged with other interval
  2537. * @param {Interval} other_interval - Other interval to merge with
  2538. * @returns {Interval}
  2539. */
  2540. merge(a2) {
  2541. return new Ms(
  2542. this.low === void 0 ? a2.low : this.low < a2.low ? this.low : a2.low,
  2543. this.high === void 0 ? a2.high : this.high > a2.high ? this.high : a2.high
  2544. );
  2545. }
  2546. /**
  2547. * Returns how key should return
  2548. */
  2549. output() {
  2550. return [this.low, this.high];
  2551. }
  2552. /**
  2553. * Function returns maximum between two comparable values
  2554. * @param interval1
  2555. * @param interval2
  2556. * @returns {Interval}
  2557. */
  2558. static comparable_max(a2, e) {
  2559. return a2.merge(e);
  2560. }
  2561. /**
  2562. * Predicate returns true if first value less than second value
  2563. * @param val1
  2564. * @param val2
  2565. * @returns {boolean}
  2566. */
  2567. static comparable_less_than(a2, e) {
  2568. return a2 < e;
  2569. }
  2570. };
  2571. var je = 0;
  2572. var Ae = 1;
  2573. var Ht = class {
  2574. constructor(a2 = void 0, e = void 0, t = null, r = null, n = null, s = Ae) {
  2575. if (this.left = t, this.right = r, this.parent = n, this.color = s, this.item = { key: a2, value: e }, a2 && a2 instanceof Array && a2.length === 2 && !Number.isNaN(a2[0]) && !Number.isNaN(a2[1])) {
  2576. let [o, u] = a2;
  2577. o > u && ([o, u] = [u, o]), this.item.key = new Gc(o, u);
  2578. }
  2579. this.max = this.item.key ? this.item.key.max : void 0;
  2580. }
  2581. isNil() {
  2582. return this.item.key === void 0 && this.item.value === void 0 && this.left === null && this.right === null && this.color === Ae;
  2583. }
  2584. _value_less_than(a2) {
  2585. return this.item.value && a2.item.value && this.item.value.less_than ? this.item.value.less_than(a2.item.value) : this.item.value < a2.item.value;
  2586. }
  2587. less_than(a2) {
  2588. return this.item.value === this.item.key && a2.item.value === a2.item.key ? this.item.key.less_than(a2.item.key) : this.item.key.less_than(a2.item.key) || this.item.key.equal_to(a2.item.key) && this._value_less_than(a2);
  2589. }
  2590. _value_equal(a2) {
  2591. return this.item.value && a2.item.value && this.item.value.equal_to ? this.item.value.equal_to(a2.item.value) : this.item.value === a2.item.value;
  2592. }
  2593. equal_to(a2) {
  2594. return this.item.value === this.item.key && a2.item.value === a2.item.key ? this.item.key.equal_to(a2.item.key) : this.item.key.equal_to(a2.item.key) && this._value_equal(a2);
  2595. }
  2596. intersect(a2) {
  2597. return this.item.key.intersect(a2.item.key);
  2598. }
  2599. copy_data(a2) {
  2600. this.item.key = a2.item.key, this.item.value = a2.item.value;
  2601. }
  2602. update_max() {
  2603. if (this.max = this.item.key ? this.item.key.max : void 0, this.right && this.right.max) {
  2604. const a2 = this.item.key.constructor.comparable_max;
  2605. this.max = a2(this.max, this.right.max);
  2606. }
  2607. if (this.left && this.left.max) {
  2608. const a2 = this.item.key.constructor.comparable_max;
  2609. this.max = a2(this.max, this.left.max);
  2610. }
  2611. }
  2612. // Other_node does not intersect any node of left subtree, if this.left.max < other_node.item.key.low
  2613. not_intersect_left_subtree(a2) {
  2614. const e = this.item.key.constructor.comparable_less_than;
  2615. let t = this.left.max.high !== void 0 ? this.left.max.high : this.left.max;
  2616. return e(t, a2.item.key.low);
  2617. }
  2618. // Other_node does not intersect right subtree if other_node.item.key.high < this.right.key.low
  2619. not_intersect_right_subtree(a2) {
  2620. const e = this.item.key.constructor.comparable_less_than;
  2621. let t = this.right.max.low !== void 0 ? this.right.max.low : this.right.item.key.low;
  2622. return e(a2.item.key.high, t);
  2623. }
  2624. };
  2625. var la = class _la {
  2626. /**
  2627. * Construct new empty instance of IntervalTree
  2628. */
  2629. constructor() {
  2630. this.root = null, this.nil_node = new Ht();
  2631. }
  2632. /**
  2633. * Returns number of items stored in the interval tree
  2634. * @returns {number}
  2635. */
  2636. get size() {
  2637. let a2 = 0;
  2638. return this.tree_walk(this.root, () => a2++), a2;
  2639. }
  2640. /**
  2641. * Returns array of sorted keys in the ascending order
  2642. * @returns {Array}
  2643. */
  2644. get keys() {
  2645. let a2 = [];
  2646. return this.tree_walk(this.root, (e) => a2.push(
  2647. e.item.key.output ? e.item.key.output() : e.item.key
  2648. )), a2;
  2649. }
  2650. /**
  2651. * Return array of values in the ascending keys order
  2652. * @returns {Array}
  2653. */
  2654. get values() {
  2655. let a2 = [];
  2656. return this.tree_walk(this.root, (e) => a2.push(e.item.value)), a2;
  2657. }
  2658. /**
  2659. * Returns array of items (<key,value> pairs) in the ascended keys order
  2660. * @returns {Array}
  2661. */
  2662. get items() {
  2663. let a2 = [];
  2664. return this.tree_walk(this.root, (e) => a2.push({
  2665. key: e.item.key.output ? e.item.key.output() : e.item.key,
  2666. value: e.item.value
  2667. })), a2;
  2668. }
  2669. /**
  2670. * Returns true if tree is empty
  2671. * @returns {boolean}
  2672. */
  2673. isEmpty() {
  2674. return this.root == null || this.root === this.nil_node;
  2675. }
  2676. /**
  2677. * Clear tree
  2678. */
  2679. clear() {
  2680. this.root = null;
  2681. }
  2682. /**
  2683. * Insert new item into interval tree
  2684. * @param {Interval} key - interval object or array of two numbers [low, high]
  2685. * @param {any} value - value representing any object (optional)
  2686. * @returns {Node} returns reference to inserted node as an object {key:interval, value: value}
  2687. */
  2688. insert(a2, e = a2) {
  2689. if (a2 === void 0)
  2690. return;
  2691. let t = new Ht(a2, e, this.nil_node, this.nil_node, null, je);
  2692. return this.tree_insert(t), this.recalc_max(t), t;
  2693. }
  2694. /**
  2695. * Returns true if item {key,value} exist in the tree
  2696. * @param {Interval} key - interval correspondent to keys stored in the tree
  2697. * @param {any} value - value object to be checked
  2698. * @returns {boolean} true if item {key, value} exist in the tree, false otherwise
  2699. */
  2700. exist(a2, e = a2) {
  2701. let t = new Ht(a2, e);
  2702. return !!this.tree_search(this.root, t);
  2703. }
  2704. /**
  2705. * Remove entry {key, value} from the tree
  2706. * @param {Interval} key - interval correspondent to keys stored in the tree
  2707. * @param {any} value - value object
  2708. * @returns {boolean} true if item {key, value} deleted, false if not found
  2709. */
  2710. remove(a2, e = a2) {
  2711. let t = new Ht(a2, e), r = this.tree_search(this.root, t);
  2712. return r && this.tree_delete(r), r;
  2713. }
  2714. /**
  2715. * Returns array of entry values which keys intersect with given interval <br/>
  2716. * If no values stored in the tree, returns array of keys which intersect given interval
  2717. * @param {Interval} interval - search interval, or tuple [low, high]
  2718. * @param outputMapperFn(value,key) - optional function that maps (value, key) to custom output
  2719. * @returns {Array}
  2720. */
  2721. search(a2, e = (t, r) => t === r ? r.output() : t) {
  2722. let t = new Ht(a2), r = [];
  2723. return this.tree_search_interval(this.root, t, r), r.map((n) => e(n.item.value, n.item.key));
  2724. }
  2725. /**
  2726. * Returns true if intersection between given and any interval stored in the tree found
  2727. * @param {Interval} interval - search interval or tuple [low, high]
  2728. * @returns {boolean}
  2729. */
  2730. intersect_any(a2) {
  2731. let e = new Ht(a2);
  2732. return this.tree_find_any_interval(this.root, e);
  2733. }
  2734. /**
  2735. * Tree visitor. For each node implement a callback function. <br/>
  2736. * Method calls a callback function with two parameters (key, value)
  2737. * @param visitor(key,value) - function to be called for each tree item
  2738. */
  2739. forEach(a2) {
  2740. this.tree_walk(this.root, (e) => a2(e.item.key, e.item.value));
  2741. }
  2742. /**
  2743. * Value Mapper. Walk through every node and map node value to another value
  2744. * @param callback(value,key) - function to be called for each tree item
  2745. */
  2746. map(a2) {
  2747. const e = new _la();
  2748. return this.tree_walk(this.root, (t) => e.insert(t.item.key, a2(t.item.value, t.item.key))), e;
  2749. }
  2750. /**
  2751. * @param {Interval} interval - optional if the iterator is intended to start from the beginning
  2752. * @param outputMapperFn(value,key) - optional function that maps (value, key) to custom output
  2753. * @returns {Iterator}
  2754. */
  2755. *iterate(a2, e = (t, r) => t === r ? r.output() : t) {
  2756. let t;
  2757. for (a2 ? t = this.tree_search_nearest_forward(this.root, new Ht(a2)) : this.root && (t = this.local_minimum(this.root)); t; )
  2758. yield e(t.item.value, t.item.key), t = this.tree_successor(t);
  2759. }
  2760. recalc_max(a2) {
  2761. let e = a2;
  2762. for (; e.parent != null; )
  2763. e.parent.update_max(), e = e.parent;
  2764. }
  2765. tree_insert(a2) {
  2766. let e = this.root, t = null;
  2767. if (this.root == null || this.root === this.nil_node)
  2768. this.root = a2;
  2769. else {
  2770. for (; e !== this.nil_node; )
  2771. t = e, a2.less_than(e) ? e = e.left : e = e.right;
  2772. a2.parent = t, a2.less_than(t) ? t.left = a2 : t.right = a2;
  2773. }
  2774. this.insert_fixup(a2);
  2775. }
  2776. // After insertion insert_node may have red-colored parent, and this is a single possible violation
  2777. // Go upwords to the root and re-color until violation will be resolved
  2778. insert_fixup(a2) {
  2779. let e, t;
  2780. for (e = a2; e !== this.root && e.parent.color === je; )
  2781. e.parent === e.parent.parent.left ? (t = e.parent.parent.right, t.color === je ? (e.parent.color = Ae, t.color = Ae, e.parent.parent.color = je, e = e.parent.parent) : (e === e.parent.right && (e = e.parent, this.rotate_left(e)), e.parent.color = Ae, e.parent.parent.color = je, this.rotate_right(e.parent.parent))) : (t = e.parent.parent.left, t.color === je ? (e.parent.color = Ae, t.color = Ae, e.parent.parent.color = je, e = e.parent.parent) : (e === e.parent.left && (e = e.parent, this.rotate_right(e)), e.parent.color = Ae, e.parent.parent.color = je, this.rotate_left(e.parent.parent)));
  2782. this.root.color = Ae;
  2783. }
  2784. tree_delete(a2) {
  2785. let e, t;
  2786. a2.left === this.nil_node || a2.right === this.nil_node ? e = a2 : e = this.tree_successor(a2), e.left !== this.nil_node ? t = e.left : t = e.right, t.parent = e.parent, e === this.root ? this.root = t : (e === e.parent.left ? e.parent.left = t : e.parent.right = t, e.parent.update_max()), this.recalc_max(t), e !== a2 && (a2.copy_data(e), a2.update_max(), this.recalc_max(a2)), /*fix_node != this.nil_node && */
  2787. e.color === Ae && this.delete_fixup(t);
  2788. }
  2789. delete_fixup(a2) {
  2790. let e = a2, t;
  2791. for (; e !== this.root && e.parent != null && e.color === Ae; )
  2792. e === e.parent.left ? (t = e.parent.right, t.color === je && (t.color = Ae, e.parent.color = je, this.rotate_left(e.parent), t = e.parent.right), t.left.color === Ae && t.right.color === Ae ? (t.color = je, e = e.parent) : (t.right.color === Ae && (t.color = je, t.left.color = Ae, this.rotate_right(t), t = e.parent.right), t.color = e.parent.color, e.parent.color = Ae, t.right.color = Ae, this.rotate_left(e.parent), e = this.root)) : (t = e.parent.left, t.color === je && (t.color = Ae, e.parent.color = je, this.rotate_right(e.parent), t = e.parent.left), t.left.color === Ae && t.right.color === Ae ? (t.color = je, e = e.parent) : (t.left.color === Ae && (t.color = je, t.right.color = Ae, this.rotate_left(t), t = e.parent.left), t.color = e.parent.color, e.parent.color = Ae, t.left.color = Ae, this.rotate_right(e.parent), e = this.root));
  2793. e.color = Ae;
  2794. }
  2795. tree_search(a2, e) {
  2796. if (!(a2 == null || a2 === this.nil_node))
  2797. return e.equal_to(a2) ? a2 : e.less_than(a2) ? this.tree_search(a2.left, e) : this.tree_search(a2.right, e);
  2798. }
  2799. tree_search_nearest_forward(a2, e) {
  2800. let t, r = a2;
  2801. for (; r && r !== this.nil_node; )
  2802. r.less_than(e) ? r.intersect(e) ? (t = r, r = r.left) : r = r.right : ((!t || r.less_than(t)) && (t = r), r = r.left);
  2803. return t || null;
  2804. }
  2805. // Original search_interval method; container res support push() insertion
  2806. // Search all intervals intersecting given one
  2807. tree_search_interval(a2, e, t) {
  2808. a2 != null && a2 !== this.nil_node && (a2.left !== this.nil_node && !a2.not_intersect_left_subtree(e) && this.tree_search_interval(a2.left, e, t), a2.intersect(e) && t.push(a2), a2.right !== this.nil_node && !a2.not_intersect_right_subtree(e) && this.tree_search_interval(a2.right, e, t));
  2809. }
  2810. tree_find_any_interval(a2, e) {
  2811. let t = false;
  2812. return a2 != null && a2 !== this.nil_node && (a2.left !== this.nil_node && !a2.not_intersect_left_subtree(e) && (t = this.tree_find_any_interval(a2.left, e)), t || (t = a2.intersect(e)), !t && a2.right !== this.nil_node && !a2.not_intersect_right_subtree(e) && (t = this.tree_find_any_interval(a2.right, e))), t;
  2813. }
  2814. local_minimum(a2) {
  2815. let e = a2;
  2816. for (; e.left != null && e.left !== this.nil_node; )
  2817. e = e.left;
  2818. return e;
  2819. }
  2820. // not in use
  2821. local_maximum(a2) {
  2822. let e = a2;
  2823. for (; e.right != null && e.right !== this.nil_node; )
  2824. e = e.right;
  2825. return e;
  2826. }
  2827. tree_successor(a2) {
  2828. let e, t, r;
  2829. if (a2.right !== this.nil_node)
  2830. e = this.local_minimum(a2.right);
  2831. else {
  2832. for (t = a2, r = a2.parent; r != null && r.right === t; )
  2833. t = r, r = r.parent;
  2834. e = r;
  2835. }
  2836. return e;
  2837. }
  2838. // | right-rotate(T,y) |
  2839. // y ---------------. x
  2840. // / \ / \
  2841. // x c left-rotate(T,x) a y
  2842. // / \ <--------------- / \
  2843. // a b b c
  2844. rotate_left(a2) {
  2845. let e = a2.right;
  2846. a2.right = e.left, e.left !== this.nil_node && (e.left.parent = a2), e.parent = a2.parent, a2 === this.root ? this.root = e : a2 === a2.parent.left ? a2.parent.left = e : a2.parent.right = e, e.left = a2, a2.parent = e, a2 != null && a2 !== this.nil_node && a2.update_max(), e = a2.parent, e != null && e !== this.nil_node && e.update_max();
  2847. }
  2848. rotate_right(a2) {
  2849. let e = a2.left;
  2850. a2.left = e.right, e.right !== this.nil_node && (e.right.parent = a2), e.parent = a2.parent, a2 === this.root ? this.root = e : a2 === a2.parent.left ? a2.parent.left = e : a2.parent.right = e, e.right = a2, a2.parent = e, a2 !== null && a2 !== this.nil_node && a2.update_max(), e = a2.parent, e != null && e !== this.nil_node && e.update_max();
  2851. }
  2852. tree_walk(a2, e) {
  2853. a2 != null && a2 !== this.nil_node && (this.tree_walk(a2.left, e), e(a2), this.tree_walk(a2.right, e));
  2854. }
  2855. /* Return true if all red nodes have exactly two black child nodes */
  2856. testRedBlackProperty() {
  2857. let a2 = true;
  2858. return this.tree_walk(this.root, function(e) {
  2859. e.color === je && (e.left.color === Ae && e.right.color === Ae || (a2 = false));
  2860. }), a2;
  2861. }
  2862. /* Throw error if not every path from root to bottom has same black height */
  2863. testBlackHeightProperty(a2) {
  2864. let e = 0, t = 0, r = 0;
  2865. if (a2.color === Ae && e++, a2.left !== this.nil_node ? t = this.testBlackHeightProperty(a2.left) : t = 1, a2.right !== this.nil_node ? r = this.testBlackHeightProperty(a2.right) : r = 1, t !== r)
  2866. throw new Error("Red-black height property violated");
  2867. return e += t, e;
  2868. }
  2869. };
  2870. var Qc = class {
  2871. constructor() {
  2872. A(this, "_cache", /* @__PURE__ */ new Map());
  2873. A(this, "_continueBuildingCache", /* @__PURE__ */ new Map());
  2874. }
  2875. set(a2, e, t, r, n) {
  2876. if (!this.shouldContinueBuildingCache(a2, e, t, n))
  2877. return;
  2878. let s = this._cache.get(a2);
  2879. s == null && (s = /* @__PURE__ */ new Map(), this._cache.set(a2, s));
  2880. let o = s.get(e);
  2881. o == null && (o = /* @__PURE__ */ new Map(), s.set(e, o));
  2882. let u = o.get(t);
  2883. u == null && (u = /* @__PURE__ */ new Map(), o.set(t, u));
  2884. let c = u.get(r);
  2885. c == null && (c = /* @__PURE__ */ new Set(), u.set(r, c)), c.add(n);
  2886. }
  2887. getCellValuePositions(a2, e, t) {
  2888. var r, n;
  2889. return (n = (r = this._cache.get(a2)) == null ? void 0 : r.get(e)) == null ? void 0 : n.get(t);
  2890. }
  2891. getCellPositions(a2, e, t, r, n) {
  2892. var o, u, c;
  2893. const s = (c = (u = (o = this._cache.get(a2)) == null ? void 0 : o.get(e)) == null ? void 0 : u.get(t)) == null ? void 0 : c.get(r);
  2894. return s && [...s].filter((l2) => n.some(([f2, h]) => l2 >= f2 && l2 <= h));
  2895. }
  2896. setContinueBuildingCache(a2, e, t, r, n) {
  2897. if (t === -1 || r === -1 || n === -1)
  2898. return;
  2899. let s = this._continueBuildingCache.get(a2);
  2900. s == null && (s = /* @__PURE__ */ new Map(), this._continueBuildingCache.set(a2, s));
  2901. let o = s.get(e);
  2902. o == null && (o = /* @__PURE__ */ new Map(), s.set(e, o));
  2903. let u = o.get(t);
  2904. if (u == null) {
  2905. u = new la(), u.insert([r, n]), o.set(t, u);
  2906. return;
  2907. }
  2908. this._handleNewInterval(u, r, n);
  2909. }
  2910. shouldContinueBuildingCache(a2, e, t, r) {
  2911. var o, u;
  2912. if (t === -1 || r === -1)
  2913. return false;
  2914. const n = (u = (o = this._continueBuildingCache.get(a2)) == null ? void 0 : o.get(e)) == null ? void 0 : u.get(t);
  2915. return n ? n.search([r, r]).length === 0 : true;
  2916. }
  2917. canUseCache(a2, e, t, r, n) {
  2918. var f2, h;
  2919. const s = (h = (f2 = this._continueBuildingCache.get(a2)) == null ? void 0 : f2.get(e)) == null ? void 0 : h.get(t);
  2920. if (t === -1 || r === -1 || n === -1 || !s)
  2921. return {
  2922. rowsInCache: [],
  2923. rowsNotInCache: []
  2924. };
  2925. const o = s.search([r, n]);
  2926. if (o.length === 0)
  2927. return {
  2928. rowsInCache: [],
  2929. rowsNotInCache: []
  2930. };
  2931. o.sort((d2, _) => d2[0] - _[0]);
  2932. const u = [], c = [];
  2933. let l2 = r;
  2934. for (let d2 = 0; d2 < o.length; d2++) {
  2935. const [_, C] = o[d2];
  2936. if (l2 >= _) {
  2937. if (n <= C) {
  2938. u.push([l2, n]);
  2939. break;
  2940. }
  2941. u.push([l2, C]), l2 = C + 1, d2 === o.length - 1 && l2 <= n && c.push([l2, n]);
  2942. } else {
  2943. if (n > C) {
  2944. u.push([_, C]), c.push([l2, _ - 1]), l2 = C + 1, d2 === o.length - 1 && l2 <= n && c.push([l2, n]);
  2945. continue;
  2946. }
  2947. u.push([_, n]), c.push([l2, _ - 1]);
  2948. }
  2949. }
  2950. return {
  2951. rowsInCache: u,
  2952. rowsNotInCache: c
  2953. };
  2954. }
  2955. clear() {
  2956. this._cache.clear(), this._continueBuildingCache.clear();
  2957. }
  2958. _handleNewInterval(a2, e, t) {
  2959. let r = a2.search([e, t]);
  2960. if (r.length === 0) {
  2961. const o = [e - 1 < 0 ? 0 : e - 1, t + 1];
  2962. if (r = a2.search(o), r.length === 0) {
  2963. a2.insert([e, t]);
  2964. return;
  2965. }
  2966. }
  2967. let n = e, s = t;
  2968. for (const o of r)
  2969. n = Math.min(n, o[0]), s = Math.max(s, o[1]), a2.remove(o);
  2970. a2.insert([n, s]);
  2971. }
  2972. };
  2973. var St = new Qc();
  2974. var fa = "engine-formula.config";
  2975. var so = 1;
  2976. var Hb = "CYCLE_REFERENCE_COUNT";
  2977. var ai = {};
  2978. var Wc = Object.defineProperty;
  2979. var qc = Object.getOwnPropertyDescriptor;
  2980. var Kc = (i, a2, e, t) => {
  2981. for (var r = t > 1 ? void 0 : t ? qc(a2, e) : a2, n = i.length - 1, s; n >= 0; n--)
  2982. (s = i[n]) && (r = (t ? s(a2, e, r) : s(r)) || r);
  2983. return t && r && Wc(a2, e, r), r;
  2984. };
  2985. var ii = (i, a2) => (e, t) => a2(e, t, i);
  2986. var ws = class extends nt {
  2987. constructor(a2, e) {
  2988. super();
  2989. A(this, "_unitData", {});
  2990. A(this, "_unitStylesData", {});
  2991. A(this, "_arrayFormulaCellData", {});
  2992. A(this, "_arrayFormulaRange", {});
  2993. A(this, "_formulaData", {});
  2994. A(this, "_sheetNameMap", {});
  2995. A(this, "_forceCalculate", false);
  2996. A(this, "_clearDependencyTreeCache", {});
  2997. A(this, "_dirtyRanges", []);
  2998. A(this, "_dirtyNameMap", {});
  2999. A(this, "_dirtyDefinedNameMap", {});
  3000. A(this, "_dirtyUnitFeatureMap", {});
  3001. A(this, "_dirtyUnitOtherFormulaMap", {});
  3002. A(this, "_excludedCell");
  3003. A(this, "_sheetIdToNameMap", {});
  3004. A(this, "_executeUnitId", "");
  3005. A(this, "_executeSubUnitId", "");
  3006. this._univerInstanceService = a2, this._localeService = e;
  3007. }
  3008. dispose() {
  3009. this._unitData = {}, this._unitStylesData = {}, this._formulaData = {}, this._arrayFormulaCellData = {}, this._arrayFormulaRange = {}, this._sheetNameMap = {}, this._dirtyRanges = [], this._dirtyNameMap = {}, this._dirtyDefinedNameMap = {}, this._dirtyUnitFeatureMap = {}, this._excludedCell = {}, this._sheetIdToNameMap = {}, this._dirtyUnitOtherFormulaMap = {};
  3010. }
  3011. getExecuteUnitId() {
  3012. return this._executeUnitId;
  3013. }
  3014. getExecuteSubUnitId() {
  3015. return this._executeSubUnitId;
  3016. }
  3017. setExecuteUnitId(a2) {
  3018. this._executeUnitId = a2;
  3019. }
  3020. setExecuteSubUnitId(a2) {
  3021. this._executeSubUnitId = a2;
  3022. }
  3023. getExcludedRange() {
  3024. return this._excludedCell;
  3025. }
  3026. getUnitData() {
  3027. return this._unitData;
  3028. }
  3029. getUnitStylesData() {
  3030. return this._unitStylesData;
  3031. }
  3032. getFormulaData() {
  3033. return this._formulaData;
  3034. }
  3035. getArrayFormulaCellData() {
  3036. return this._arrayFormulaCellData;
  3037. }
  3038. getArrayFormulaRange() {
  3039. return this._arrayFormulaRange;
  3040. }
  3041. getSheetNameMap() {
  3042. return this._sheetNameMap;
  3043. }
  3044. isForceCalculate() {
  3045. return this._forceCalculate;
  3046. }
  3047. getDirtyRanges() {
  3048. return this._dirtyRanges;
  3049. }
  3050. getDirtyNameMap() {
  3051. return this._dirtyNameMap;
  3052. }
  3053. getDirtyDefinedNameMap() {
  3054. return this._dirtyDefinedNameMap;
  3055. }
  3056. getDirtyUnitFeatureMap() {
  3057. return this._dirtyUnitFeatureMap;
  3058. }
  3059. getDirtyUnitOtherFormulaMap() {
  3060. return this._dirtyUnitOtherFormulaMap;
  3061. }
  3062. getSheetName(a2, e) {
  3063. return this._sheetIdToNameMap[a2] == null ? "" : this._sheetIdToNameMap[a2][e] || "";
  3064. }
  3065. getClearDependencyTreeCache() {
  3066. return this._clearDependencyTreeCache;
  3067. }
  3068. getLocale() {
  3069. return this._localeService.getCurrentLocale();
  3070. }
  3071. getSheetsInfo() {
  3072. const a2 = this._univerInstanceService.getCurrentUnitForType(Fe.UNIVER_SHEET), { id: e, sheetOrder: t } = a2.getSnapshot();
  3073. return {
  3074. sheetOrder: t,
  3075. sheetNameMap: this._sheetIdToNameMap[e]
  3076. };
  3077. }
  3078. getSheetRowColumnCount(a2, e) {
  3079. const t = this._univerInstanceService.getUnit(a2), r = t == null ? void 0 : t.getSheetBySheetId(e), n = r == null ? void 0 : r.getSnapshot();
  3080. if (!n)
  3081. return { rowCount: 0, columnCount: 0 };
  3082. const { rowCount: s, columnCount: o } = n;
  3083. return { rowCount: s, columnCount: o };
  3084. }
  3085. load(a2) {
  3086. if (a2.allUnitData && a2.unitSheetNameMap && a2.unitStylesData)
  3087. this._unitData = a2.allUnitData, this._unitStylesData = a2.unitStylesData, this._sheetNameMap = a2.unitSheetNameMap;
  3088. else {
  3089. const { allUnitData: e, unitSheetNameMap: t, unitStylesData: r } = this._loadSheetData();
  3090. this._unitData = e, this._unitStylesData = r, this._sheetNameMap = t;
  3091. }
  3092. this._formulaData = a2.formulaData, this._arrayFormulaCellData = oc(a2.arrayFormulaCellData), this._arrayFormulaRange = a2.arrayFormulaRange, this._forceCalculate = a2.forceCalculate, this._clearDependencyTreeCache = a2.clearDependencyTreeCache || {}, this._dirtyRanges = a2.dirtyRanges, this._dirtyNameMap = a2.dirtyNameMap, this._dirtyDefinedNameMap = a2.dirtyDefinedNameMap, this._dirtyUnitFeatureMap = a2.dirtyUnitFeatureMap, this._dirtyUnitOtherFormulaMap = a2.dirtyUnitOtherFormulaMap, this._excludedCell = a2.excludedCell, this._mergeNameMap(this._sheetNameMap, this._dirtyNameMap);
  3093. }
  3094. getDirtyData() {
  3095. return {
  3096. forceCalculation: this._forceCalculate,
  3097. dirtyRanges: this._dirtyRanges,
  3098. dirtyNameMap: this._dirtyNameMap,
  3099. dirtyDefinedNameMap: this._dirtyDefinedNameMap,
  3100. dirtyUnitFeatureMap: this._dirtyUnitFeatureMap,
  3101. dirtyUnitOtherFormulaMap: this._dirtyUnitOtherFormulaMap,
  3102. clearDependencyTreeCache: this._clearDependencyTreeCache
  3103. };
  3104. }
  3105. loadDirtyRangesAndExcludedCell(a2, e) {
  3106. this._dirtyRanges = a2, this._excludedCell = e, this._dirtyNameMap = {};
  3107. }
  3108. registerUnitData(a2) {
  3109. this._unitData = a2;
  3110. }
  3111. registerFormulaData(a2) {
  3112. this._formulaData = a2;
  3113. }
  3114. registerSheetNameMap(a2) {
  3115. this._sheetNameMap = a2;
  3116. }
  3117. // private _loadOtherFormulaData() {
  3118. // const unitAllDoc = this._univerInstanceService.getAllUniverDocsInstance();
  3119. // const unitAllSlide = this._univerInstanceService.getAllUniverSlidesInstance();
  3120. // const otherFormulaData: IOtherFormulaData = {};
  3121. // for (const documentDataModel of unitAllDoc) {
  3122. // const unitId = documentDataModel.getUnitId();
  3123. // if (otherFormulaData[unitId] == null) {
  3124. // otherFormulaData[unitId] = {};
  3125. // }
  3126. // if (otherFormulaData[unitId][DEFAULT_DOCUMENT_SUB_COMPONENT_ID] == null) {
  3127. // otherFormulaData[unitId][DEFAULT_DOCUMENT_SUB_COMPONENT_ID] = {};
  3128. // }
  3129. // const subComponent = otherFormulaData[unitId][DEFAULT_DOCUMENT_SUB_COMPONENT_ID];
  3130. // const customRanges = documentDataModel.getBody()?.customRanges;
  3131. // if (customRanges == null) {
  3132. // continue;
  3133. // }
  3134. // for (const customRange of customRanges) {
  3135. // subComponent[customRange.rangeId] = {
  3136. // f: customRange.endIndex.toString(),
  3137. // };
  3138. // }
  3139. // }
  3140. // for (const slide of unitAllSlide) {
  3141. // const unitId = slide.getUnitId();
  3142. // if (otherFormulaData[unitId] == null) {
  3143. // otherFormulaData[unitId] = {};
  3144. // }
  3145. // if (otherFormulaData[unitId][DEFAULT_DOCUMENT_SUB_COMPONENT_ID] == null) {
  3146. // otherFormulaData[unitId][DEFAULT_DOCUMENT_SUB_COMPONENT_ID] = {};
  3147. // }
  3148. // const pages = slide.getPages();
  3149. // if (pages == null) {
  3150. // continue;
  3151. // }
  3152. // const pageIds = Object.keys(pages);
  3153. // for (const pageId of pageIds) {
  3154. // const page = pages[pageId];
  3155. // const subComponent = otherFormulaData[unitId][pageId];
  3156. // const pageElements = page.pageElements;
  3157. // if (pageElements == null) {
  3158. // continue;
  3159. // }
  3160. // const pageElementIds = Object.keys(pageElements);
  3161. // for (const pageElementId of pageElementIds) {
  3162. // const pageElement = pageElements[pageElementId];
  3163. // subComponent[pageElementId] = {
  3164. // f: pageElement.title,
  3165. // };
  3166. // }
  3167. // }
  3168. // }
  3169. // return otherFormulaData;
  3170. // }
  3171. _mergeNameMap(a2, e) {
  3172. Object.keys(e).forEach((t) => {
  3173. e[t] && Object.keys(e[t]).forEach((r) => {
  3174. a2[t] == null && (a2[t] = {}), a2[t][e[t][r]] = r;
  3175. });
  3176. }), this._sheetIdToNameMap = {}, Object.keys(a2).forEach((t) => {
  3177. Object.keys(a2[t]).forEach((r) => {
  3178. this._sheetIdToNameMap[t] == null && (this._sheetIdToNameMap[t] = {}), this._sheetIdToNameMap[t][a2[t][r]] = r;
  3179. });
  3180. });
  3181. }
  3182. _loadSheetData() {
  3183. const a2 = this._univerInstanceService.getAllUnitsForType(Fe.UNIVER_SHEET), e = this._univerInstanceService.getCurrentUnitForType(Fe.UNIVER_SHEET), t = e == null ? void 0 : e.getActiveSheet();
  3184. this._executeUnitId = e == null ? void 0 : e.getUnitId(), this._executeSubUnitId = t == null ? void 0 : t.getSheetId();
  3185. const r = {}, n = {}, s = {};
  3186. for (const o of a2) {
  3187. const u = o.getUnitId(), c = o.getSheets(), l2 = {}, f2 = {};
  3188. for (const h of c) {
  3189. const d2 = h.getSheetId(), _ = h.getConfig();
  3190. l2[d2] = {
  3191. cellData: new kt(_.cellData),
  3192. rowCount: _.rowCount,
  3193. columnCount: _.columnCount,
  3194. rowData: _.rowData,
  3195. columnData: _.columnData,
  3196. defaultRowHeight: _.defaultRowHeight,
  3197. defaultColumnWidth: _.defaultColumnWidth
  3198. }, f2[h.getName()] = h.getSheetId();
  3199. }
  3200. r[u] = l2, n[u] = o.getStyles(), s[u] = f2;
  3201. }
  3202. return {
  3203. allUnitData: r,
  3204. unitStylesData: n,
  3205. unitSheetNameMap: s
  3206. };
  3207. }
  3208. };
  3209. ws = Kc([
  3210. ii(0, _n),
  3211. ii(1, ot(Vr))
  3212. ], ws);
  3213. var Ft = Ct(
  3214. "univer.formula.current-data.service"
  3215. );
  3216. var Xc = Object.defineProperty;
  3217. var Zc = Object.getOwnPropertyDescriptor;
  3218. var zc = (i, a2, e, t) => {
  3219. for (var r = t > 1 ? void 0 : t ? Zc(a2, e) : a2, n = i.length - 1, s; n >= 0; n--)
  3220. (s = i[n]) && (r = (t ? s(a2, e, r) : s(r)) || r);
  3221. return t && r && Xc(a2, e, r), r;
  3222. };
  3223. var is = (i, a2) => (e, t) => a2(e, t, i);
  3224. var gr = class extends nt {
  3225. constructor(i, a2, e) {
  3226. super(), this._definedNamesService = i, this._lexerTreeBuilder = a2, this._formulaCurrentConfigService = e;
  3227. }
  3228. treeBuilder(i, a2 = true) {
  3229. return this._lexerTreeBuilder.treeBuilder(i, a2, this._injectDefinedName.bind(this), this._simpleCheckDefinedName.bind(this));
  3230. }
  3231. _simpleCheckDefinedName(i) {
  3232. const a2 = this._formulaCurrentConfigService.getDirtyDefinedNameMap(), e = this._formulaCurrentConfigService.getExecuteUnitId();
  3233. if (e != null && a2[e] != null) {
  3234. const t = Object.keys(a2[e]);
  3235. for (let r = 0, n = t.length; r < n; r++) {
  3236. const s = t[r];
  3237. if (i.indexOf(s) > -1)
  3238. return true;
  3239. }
  3240. }
  3241. return false;
  3242. }
  3243. _checkDefinedNameDirty(i) {
  3244. const a2 = this._formulaCurrentConfigService.getDirtyDefinedNameMap(), e = this._formulaCurrentConfigService.getExecuteUnitId();
  3245. if (e != null && a2[e] != null) {
  3246. const t = Object.keys(a2[e]);
  3247. for (let r = 0, n = t.length; r < n; r++)
  3248. if (t[r] === i)
  3249. return true;
  3250. }
  3251. return false;
  3252. }
  3253. _injectDefinedName(i) {
  3254. const a2 = this._formulaCurrentConfigService.getExecuteUnitId();
  3255. if (a2 == null)
  3256. return {
  3257. sequenceString: "",
  3258. hasDefinedName: false,
  3259. definedNames: []
  3260. };
  3261. const e = this._lexerTreeBuilder.getSequenceNode(i);
  3262. let t = "", r = false;
  3263. const n = [];
  3264. for (let s = 0, o = e.length; s < o; s++) {
  3265. const u = e[s];
  3266. if (typeof u == "string") {
  3267. t += u;
  3268. continue;
  3269. }
  3270. const { nodeType: c, token: l2 } = u;
  3271. if (c === $e.REFERENCE || c === $e.FUNCTION) {
  3272. const f2 = this._definedNamesService.getValueByName(a2, l2);
  3273. if (f2) {
  3274. let h = f2.formulaOrRefString;
  3275. h.substring(0, 1) === X2.EQUALS && (h = h.substring(1)), t += h, n.push(f2.name), r = true;
  3276. } else
  3277. this._checkDefinedNameDirty(l2) ? (t += m2.NAME, r = true, n.push(l2)) : t += l2;
  3278. } else
  3279. t += l2;
  3280. }
  3281. return {
  3282. sequenceString: t,
  3283. hasDefinedName: r,
  3284. definedNames: n
  3285. };
  3286. }
  3287. };
  3288. gr = zc([
  3289. is(0, pr),
  3290. is(1, ot(ca)),
  3291. is(2, Ft)
  3292. ], gr);
  3293. function nn(i) {
  3294. if (i == null)
  3295. return true;
  3296. const { v: a2, f: e, si: t, p: r } = i;
  3297. return !(!(a2 == null || typeof a2 == "string" && a2.length === 0) || e != null && e.length > 0 || t != null && t.length > 0 || r != null);
  3298. }
  3299. function ao(i, a2, e, t, r) {
  3300. var s;
  3301. const n = Object.keys(r);
  3302. for (const o of n) {
  3303. const u = r[o], c = (s = u == null ? void 0 : u[t]) == null ? void 0 : s[e];
  3304. if (c == null)
  3305. continue;
  3306. const l2 = c.getValue(i, a2);
  3307. if (l2 != null)
  3308. return l2;
  3309. }
  3310. }
  3311. var Jc = [
  3312. "$",
  3313. "£",
  3314. "¥",
  3315. "¤",
  3316. "֏",
  3317. "؋",
  3318. "৳",
  3319. "฿",
  3320. "៛",
  3321. "₡",
  3322. "₦",
  3323. "₩",
  3324. "₪",
  3325. "₫",
  3326. "€",
  3327. "₭",
  3328. "₮",
  3329. "₱",
  3330. "₲",
  3331. "₴",
  3332. "₸",
  3333. "₹",
  3334. "₺",
  3335. "₼",
  3336. "₽",
  3337. "₾",
  3338. "₿"
  3339. ];
  3340. var el = {
  3341. currency: 2,
  3342. date: 4,
  3343. datetime: 5,
  3344. error: 11,
  3345. fraction: 7,
  3346. general: 0,
  3347. grouped: 11,
  3348. number: 1,
  3349. percent: 6,
  3350. scientific: 8,
  3351. text: 9,
  3352. time: 5,
  3353. unknown: 11
  3354. /* Custom */
  3355. };
  3356. function Gb(i, a2, e) {
  3357. var u, c;
  3358. if (i == null || a2 == null)
  3359. return a2;
  3360. const t = (e == null ? void 0 : e.getStyleByCell(i)) || i.s, r = (e == null ? void 0 : e.getStyleByCell(a2)) || a2.s;
  3361. if (t == null || r == null || typeof t != "object" || typeof r != "object")
  3362. return a2;
  3363. const n = (u = t == null ? void 0 : t.n) == null ? void 0 : u.pattern, s = (c = r == null ? void 0 : r.n) == null ? void 0 : c.pattern;
  3364. if (n == null || s == null)
  3365. return a2;
  3366. const o = n || s;
  3367. return r.n.pattern = o, a2;
  3368. }
  3369. var Ds = new Vt(1e5);
  3370. function oi(i) {
  3371. const a2 = Ds.get(i);
  3372. if (a2 !== void 0)
  3373. return a2;
  3374. const e = rl(i);
  3375. return Ds.set(i, e), e;
  3376. }
  3377. function tl() {
  3378. Ds.clear();
  3379. }
  3380. function rl(i) {
  3381. if (nl(i))
  3382. return 3;
  3383. const a2 = Op.getInfo(i).type || "unknown";
  3384. return el[a2];
  3385. }
  3386. function nl(i) {
  3387. return !!Jc.find((a2) => i.includes(a2)) && i.startsWith("_(");
  3388. }
  3389. function Wr(i, a2, e) {
  3390. if (i === "")
  3391. return a2;
  3392. if (a2 === "")
  3393. return i;
  3394. const t = oi(i), r = oi(a2);
  3395. return e === X2.PLUS || e === X2.MINUS ? t === 4 && r === 4 || t === 11 && r === 11 ? "" : a2 : e === X2.MULTIPLY || e === X2.DIVIDED ? t === 6 && r === 6 || t === 7 && r === 7 || t === 8 && r === 8 || t === 9 && r === 9 ? a2 : "" : i || a2;
  3396. }
  3397. var sl = /* @__PURE__ */ new Map([
  3398. [ur.EN_US, "$"],
  3399. // [LocaleType.JA_JP, '¥'],
  3400. [ur.RU_RU, "₽"],
  3401. [ur.VI_VN, "₫"],
  3402. [ur.ZH_CN, "¥"],
  3403. [ur.ZH_TW, "NT$"]
  3404. ]);
  3405. function ui(i) {
  3406. return sl.get(i) || "$";
  3407. }
  3408. function Ke(i, a2 = 2) {
  3409. let e = a2;
  3410. a2 > 127 && (e = 127);
  3411. let t = "";
  3412. return e > 0 && (t = `.${"0".repeat(e)}`), `"${ui(i)}"#,##0${t}_);[Red]("${ui(i)}"#,##0${t})`;
  3413. }
  3414. function al(i, a2, e = 2) {
  3415. return Op.format(Ke(i, e), a2);
  3416. }
  3417. var ha = new Vt(1e5);
  3418. function il(i) {
  3419. let a2 = i;
  3420. a2.startsWith('"') && a2.endsWith('"') && (a2 = a2.slice(1, -1));
  3421. const e = ha.get(a2);
  3422. if (e)
  3423. return {
  3424. isNumberPattern: true,
  3425. value: e.value,
  3426. pattern: e.pattern
  3427. };
  3428. const t = Op.parseNumber(a2);
  3429. if (t && t.z)
  3430. return os(a2, t.v, t.z);
  3431. const r = Op.parseDate(a2);
  3432. if (r && r.z)
  3433. return os(a2, r.v, r.z);
  3434. const n = Op.parseTime(a2);
  3435. return n && n.z ? os(a2, n.v, n.z) : {
  3436. isNumberPattern: false
  3437. };
  3438. }
  3439. function os(i, a2, e) {
  3440. return ha.set(i, {
  3441. value: a2,
  3442. pattern: e
  3443. }), {
  3444. isNumberPattern: true,
  3445. value: a2,
  3446. pattern: e
  3447. };
  3448. }
  3449. function ol() {
  3450. ha.clear();
  3451. }
  3452. var jn = class {
  3453. constructor() {
  3454. A(this, "pattern", "");
  3455. }
  3456. dispose() {
  3457. }
  3458. getPattern() {
  3459. return this.pattern;
  3460. }
  3461. /**
  3462. * Only used in NumberValueObject
  3463. * @param pattern
  3464. */
  3465. setPattern(a2) {
  3466. this.pattern = a2;
  3467. }
  3468. isError() {
  3469. return false;
  3470. }
  3471. isAsyncObject() {
  3472. return false;
  3473. }
  3474. isAsyncArrayObject() {
  3475. return false;
  3476. }
  3477. isReferenceObject() {
  3478. return false;
  3479. }
  3480. isArray() {
  3481. return false;
  3482. }
  3483. isValueObject() {
  3484. return false;
  3485. }
  3486. isEqualType(a2) {
  3487. return false;
  3488. }
  3489. };
  3490. var kt2 = class extends jn {
  3491. constructor(a2) {
  3492. super(), this._rawValue = a2;
  3493. }
  3494. isValueObject() {
  3495. return true;
  3496. }
  3497. toUnitRange() {
  3498. return {
  3499. range: {
  3500. startColumn: -1,
  3501. startRow: -1,
  3502. endRow: -1,
  3503. endColumn: -1
  3504. },
  3505. sheetId: "",
  3506. unitId: ""
  3507. };
  3508. }
  3509. getValue() {
  3510. return 0;
  3511. }
  3512. getArrayValue() {
  3513. return [];
  3514. }
  3515. setValue(a2) {
  3516. }
  3517. setArrayValue(a2) {
  3518. }
  3519. isCube() {
  3520. return false;
  3521. }
  3522. isString() {
  3523. return false;
  3524. }
  3525. isNumber() {
  3526. return false;
  3527. }
  3528. isBoolean() {
  3529. return false;
  3530. }
  3531. isLambda() {
  3532. return false;
  3533. }
  3534. isError() {
  3535. return false;
  3536. }
  3537. isNull() {
  3538. return false;
  3539. }
  3540. sum() {
  3541. return g2.create(m2.VALUE);
  3542. }
  3543. max() {
  3544. return g2.create(m2.VALUE);
  3545. }
  3546. min() {
  3547. return g2.create(m2.VALUE);
  3548. }
  3549. count() {
  3550. return g2.create(m2.VALUE);
  3551. }
  3552. countA() {
  3553. return g2.create(m2.VALUE);
  3554. }
  3555. countBlank() {
  3556. return g2.create(m2.VALUE);
  3557. }
  3558. getNegative() {
  3559. return g2.create(m2.VALUE);
  3560. }
  3561. getReciprocal() {
  3562. return g2.create(m2.VALUE);
  3563. }
  3564. plus(a2) {
  3565. return g2.create(m2.VALUE);
  3566. }
  3567. minus(a2) {
  3568. return g2.create(m2.VALUE);
  3569. }
  3570. multiply(a2) {
  3571. return g2.create(m2.VALUE);
  3572. }
  3573. divided(a2) {
  3574. return g2.create(m2.VALUE);
  3575. }
  3576. mod(a2) {
  3577. return g2.create(m2.VALUE);
  3578. }
  3579. /**
  3580. * return every value in the array after the callback function, excluding the error value
  3581. * @param callbackFn
  3582. * @returns
  3583. */
  3584. map(a2) {
  3585. return g2.create(m2.NAME);
  3586. }
  3587. /**
  3588. * return every value in the array after the callback function
  3589. * @param callbackFn
  3590. * @returns
  3591. */
  3592. mapValue(a2) {
  3593. return g2.create(m2.NAME);
  3594. }
  3595. compare(a2, e, t = false) {
  3596. return g2.create(m2.NAME);
  3597. }
  3598. isEqual(a2) {
  3599. return this.compare(a2, $.EQUALS);
  3600. }
  3601. isNotEqual(a2) {
  3602. return this.compare(a2, $.NOT_EQUAL);
  3603. }
  3604. isGreaterThanOrEqual(a2) {
  3605. return this.compare(a2, $.GREATER_THAN_OR_EQUAL);
  3606. }
  3607. isLessThanOrEqual(a2) {
  3608. return this.compare(a2, $.LESS_THAN_OR_EQUAL);
  3609. }
  3610. isLessThan(a2) {
  3611. return this.compare(a2, $.LESS_THAN);
  3612. }
  3613. isGreaterThan(a2) {
  3614. return this.compare(a2, $.GREATER_THAN);
  3615. }
  3616. concatenateFront(a2) {
  3617. return g2.create(m2.NAME);
  3618. }
  3619. concatenateBack(a2) {
  3620. return g2.create(m2.NAME);
  3621. }
  3622. plusBy(a2) {
  3623. return g2.create(m2.VALUE);
  3624. }
  3625. minusBy(a2) {
  3626. return g2.create(m2.VALUE);
  3627. }
  3628. multiplyBy(a2) {
  3629. return g2.create(m2.VALUE);
  3630. }
  3631. dividedBy(a2) {
  3632. return g2.create(m2.VALUE);
  3633. }
  3634. modInverse(a2) {
  3635. return g2.create(m2.VALUE);
  3636. }
  3637. compareBy(a2, e) {
  3638. return g2.create(m2.NAME);
  3639. }
  3640. concatenate(a2, e = it.FRONT) {
  3641. let t = this.getValue().toString();
  3642. if (typeof a2 == "string")
  3643. e === it.FRONT ? t = a2 + t : t += a2;
  3644. else if (typeof a2 == "number")
  3645. e === it.FRONT ? t = a2.toString() + t : t += a2.toString();
  3646. else if (typeof a2 == "boolean") {
  3647. const r = a2 ? "TRUE" : "FALSE";
  3648. e === it.FRONT ? t = r + t : t += r;
  3649. }
  3650. return t;
  3651. }
  3652. pow(a2) {
  3653. return g2.create(m2.VALUE);
  3654. }
  3655. powInverse(a2) {
  3656. return g2.create(m2.VALUE);
  3657. }
  3658. sqrt() {
  3659. return g2.create(m2.VALUE);
  3660. }
  3661. cbrt() {
  3662. return g2.create(m2.VALUE);
  3663. }
  3664. cos() {
  3665. return g2.create(m2.VALUE);
  3666. }
  3667. cosh() {
  3668. return g2.create(m2.VALUE);
  3669. }
  3670. acos() {
  3671. return g2.create(m2.VALUE);
  3672. }
  3673. acosh() {
  3674. return g2.create(m2.VALUE);
  3675. }
  3676. sin() {
  3677. return g2.create(m2.VALUE);
  3678. }
  3679. sinh() {
  3680. return g2.create(m2.VALUE);
  3681. }
  3682. asin() {
  3683. return g2.create(m2.VALUE);
  3684. }
  3685. asinh() {
  3686. return g2.create(m2.VALUE);
  3687. }
  3688. tan() {
  3689. return g2.create(m2.VALUE);
  3690. }
  3691. tanh() {
  3692. return g2.create(m2.VALUE);
  3693. }
  3694. atan() {
  3695. return g2.create(m2.VALUE);
  3696. }
  3697. atan2(a2) {
  3698. return g2.create(m2.VALUE);
  3699. }
  3700. atan2Inverse(a2) {
  3701. return g2.create(m2.VALUE);
  3702. }
  3703. atanh() {
  3704. return g2.create(m2.VALUE);
  3705. }
  3706. /**
  3707. * Calculate the mean of the entire array.
  3708. *
  3709. * reference https://numpy.org/doc/stable/reference/generated/numpy.mean.html#numpy.mean
  3710. *
  3711. */
  3712. mean() {
  3713. return this;
  3714. }
  3715. /**
  3716. * Calculate the median of the entire array.
  3717. *
  3718. * reference https://numpy.org/doc/stable/reference/generated/numpy.median.html
  3719. *
  3720. */
  3721. median() {
  3722. return this;
  3723. }
  3724. /**
  3725. * Calculate the variance of the entire array.
  3726. *
  3727. * reference https://numpy.org/doc/stable/reference/generated/numpy.var.html
  3728. */
  3729. var() {
  3730. return this;
  3731. }
  3732. /**
  3733. * Calculate the standard deviation of the entire array.
  3734. *
  3735. * reference https://numpy.org/doc/stable/reference/generated/numpy.std.html
  3736. */
  3737. std() {
  3738. return this;
  3739. }
  3740. log() {
  3741. return g2.create(m2.VALUE);
  3742. }
  3743. log10() {
  3744. return g2.create(m2.VALUE);
  3745. }
  3746. exp() {
  3747. return g2.create(m2.VALUE);
  3748. }
  3749. abs() {
  3750. return g2.create(m2.VALUE);
  3751. }
  3752. round(a2) {
  3753. return g2.create(m2.VALUE);
  3754. }
  3755. roundInverse(a2) {
  3756. return g2.create(m2.VALUE);
  3757. }
  3758. floor(a2) {
  3759. return g2.create(m2.VALUE);
  3760. }
  3761. floorInverse(a2) {
  3762. return g2.create(m2.VALUE);
  3763. }
  3764. ceil(a2) {
  3765. return g2.create(m2.VALUE);
  3766. }
  3767. ceilInverse(a2) {
  3768. return g2.create(m2.VALUE);
  3769. }
  3770. convertToNumberObjectValue() {
  3771. return g2.create(m2.VALUE);
  3772. }
  3773. convertToBooleanObjectValue() {
  3774. return g2.create(m2.VALUE);
  3775. }
  3776. };
  3777. var ul = 1e3;
  3778. var ci = new Vt(ul);
  3779. var g2 = class _g2 extends kt2 {
  3780. constructor(a2, e = "") {
  3781. super(a2), this._errorType = a2, this._errorContent = e;
  3782. }
  3783. static create(a2, e = "") {
  3784. const t = `${a2}-${e}`, r = ci.get(t);
  3785. if (r)
  3786. return r;
  3787. const n = new _g2(a2, e);
  3788. return ci.set(t, n), n;
  3789. }
  3790. getValue() {
  3791. return this._errorType;
  3792. }
  3793. getErrorType() {
  3794. return this._errorType;
  3795. }
  3796. getErrorContent() {
  3797. return this._errorContent;
  3798. }
  3799. isEqualType(a2) {
  3800. return a2.getErrorType() === this.getErrorType();
  3801. }
  3802. isError() {
  3803. return true;
  3804. }
  3805. };
  3806. function cl(i) {
  3807. if (i === null)
  3808. return 0;
  3809. if (i != null && i.p) {
  3810. const a2 = i == null ? void 0 : i.p.body;
  3811. if (a2 == null)
  3812. return 0;
  3813. const e = a2.dataStream;
  3814. return st.transform.getPlainText(e);
  3815. }
  3816. return (i == null ? void 0 : i.v) || 0;
  3817. }
  3818. var Wt = ((i) => (i[i.MIN = 0] = "MIN", i[i.MAX = 1] = "MAX", i))(Wt || {});
  3819. var Pe = ((i) => (i[i.NORMAL = 0] = "NORMAL", i[i.MIN = 1] = "MIN", i[i.MAX = 2] = "MAX", i))(Pe || {});
  3820. function hn() {
  3821. return Intl && Intl.Collator ? new Intl.Collator(void 0, { numeric: false }).compare : (i, a2) => i.localeCompare(a2);
  3822. }
  3823. function ll(i) {
  3824. return i.indexOf("*") > -1 || i.indexOf("?") > -1;
  3825. }
  3826. function us(i, a2) {
  3827. const e = hl(a2).replace(/~?[*?]/g, (r) => r.startsWith("~") ? `\\${r.substring(1)}` : r === "*" ? ".*" : r === "?" ? "." : r);
  3828. return new RegExp(`^${e}$`).test(i);
  3829. }
  3830. function li(i) {
  3831. return i.replace(/~?[*?]/g, (a2) => a2.startsWith("~") ? a2.substring(1) : " ");
  3832. }
  3833. function fl(i, a2, e) {
  3834. let t = false;
  3835. switch (e) {
  3836. case $.EQUALS:
  3837. t = us(i, a2);
  3838. break;
  3839. case $.NOT_EQUAL:
  3840. t = !us(i, a2);
  3841. break;
  3842. case $.GREATER_THAN:
  3843. case $.GREATER_THAN_OR_EQUAL:
  3844. t = us(i, a2) || i > li(a2);
  3845. break;
  3846. case $.LESS_THAN:
  3847. case $.LESS_THAN_OR_EQUAL:
  3848. t = i < li(a2);
  3849. break;
  3850. }
  3851. return t;
  3852. }
  3853. function hl(i) {
  3854. return i.replace(/[.+^${}()|[\]\\]/g, "\\$&");
  3855. }
  3856. function Ss(i) {
  3857. switch (i) {
  3858. case 1:
  3859. return 2;
  3860. case 0:
  3861. return 0;
  3862. case -1:
  3863. return 1;
  3864. default:
  3865. return 0;
  3866. }
  3867. }
  3868. function Ps(i) {
  3869. return i === -2 ? 1 : 0;
  3870. }
  3871. function ma(i) {
  3872. let a2;
  3873. switch (i) {
  3874. case $.EQUALS:
  3875. a2 = $.EQUALS;
  3876. break;
  3877. case $.GREATER_THAN:
  3878. a2 = $.LESS_THAN;
  3879. break;
  3880. case $.GREATER_THAN_OR_EQUAL:
  3881. a2 = $.LESS_THAN_OR_EQUAL;
  3882. break;
  3883. case $.LESS_THAN:
  3884. a2 = $.GREATER_THAN;
  3885. break;
  3886. case $.LESS_THAN_OR_EQUAL:
  3887. a2 = $.GREATER_THAN_OR_EQUAL;
  3888. break;
  3889. case $.NOT_EQUAL:
  3890. a2 = $.NOT_EQUAL;
  3891. break;
  3892. }
  3893. return a2;
  3894. }
  3895. var Ls = 9e15;
  3896. var $t = 1e9;
  3897. var xs = "0123456789abcdef";
  3898. var mn = "2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058";
  3899. var gn = "3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789";
  3900. var js = {
  3901. // These values must be integers within the stated ranges (inclusive).
  3902. // Most of these values can be changed at run-time using the `Decimal.config` method.
  3903. // The maximum number of significant digits of the result of a calculation or base conversion.
  3904. // E.g. `Decimal.config({ precision: 20 });`
  3905. precision: 20,
  3906. // 1 to MAX_DIGITS
  3907. // The rounding mode used when rounding to `precision`.
  3908. //
  3909. // ROUND_UP 0 Away from zero.
  3910. // ROUND_DOWN 1 Towards zero.
  3911. // ROUND_CEIL 2 Towards +Infinity.
  3912. // ROUND_FLOOR 3 Towards -Infinity.
  3913. // ROUND_HALF_UP 4 Towards nearest neighbour. If equidistant, up.
  3914. // ROUND_HALF_DOWN 5 Towards nearest neighbour. If equidistant, down.
  3915. // ROUND_HALF_EVEN 6 Towards nearest neighbour. If equidistant, towards even neighbour.
  3916. // ROUND_HALF_CEIL 7 Towards nearest neighbour. If equidistant, towards +Infinity.
  3917. // ROUND_HALF_FLOOR 8 Towards nearest neighbour. If equidistant, towards -Infinity.
  3918. //
  3919. // E.g.
  3920. // `Decimal.rounding = 4;`
  3921. // `Decimal.rounding = Decimal.ROUND_HALF_UP;`
  3922. rounding: 4,
  3923. // 0 to 8
  3924. // The modulo mode used when calculating the modulus: a mod n.
  3925. // The quotient (q = a / n) is calculated according to the corresponding rounding mode.
  3926. // The remainder (r) is calculated as: r = a - n * q.
  3927. //
  3928. // UP 0 The remainder is positive if the dividend is negative, else is negative.
  3929. // DOWN 1 The remainder has the same sign as the dividend (JavaScript %).
  3930. // FLOOR 3 The remainder has the same sign as the divisor (Python %).
  3931. // HALF_EVEN 6 The IEEE 754 remainder function.
  3932. // EUCLID 9 Euclidian division. q = sign(n) * floor(a / abs(n)). Always positive.
  3933. //
  3934. // Truncated division (1), floored division (3), the IEEE 754 remainder (6), and Euclidian
  3935. // division (9) are commonly used for the modulus operation. The other rounding modes can also
  3936. // be used, but they may not give useful results.
  3937. modulo: 1,
  3938. // 0 to 9
  3939. // The exponent value at and beneath which `toString` returns exponential notation.
  3940. // JavaScript numbers: -7
  3941. toExpNeg: -7,
  3942. // 0 to -EXP_LIMIT
  3943. // The exponent value at and above which `toString` returns exponential notation.
  3944. // JavaScript numbers: 21
  3945. toExpPos: 21,
  3946. // 0 to EXP_LIMIT
  3947. // The minimum exponent value, beneath which underflow to zero occurs.
  3948. // JavaScript numbers: -324 (5e-324)
  3949. minE: -9e15,
  3950. // -1 to -EXP_LIMIT
  3951. // The maximum exponent value, above which overflow to Infinity occurs.
  3952. // JavaScript numbers: 308 (1.7976931348623157e+308)
  3953. maxE: Ls,
  3954. // 1 to EXP_LIMIT
  3955. // Whether to use cryptographically-secure random number generation, if available.
  3956. crypto: false
  3957. // true/false
  3958. };
  3959. var io;
  3960. var Rt;
  3961. var ue2 = true;
  3962. var Un = "[DecimalError] ";
  3963. var Bt = Un + "Invalid argument: ";
  3964. var oo = Un + "Precision limit exceeded";
  3965. var uo = Un + "crypto unavailable";
  3966. var co = "[object Decimal]";
  3967. var Be = Math.floor;
  3968. var Le = Math.pow;
  3969. var ml = /^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i;
  3970. var gl = /^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i;
  3971. var dl = /^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i;
  3972. var lo = /^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i;
  3973. var ut = 1e7;
  3974. var te = 7;
  3975. var Cl = 9007199254740991;
  3976. var _l = mn.length - 1;
  3977. var Us = gn.length - 1;
  3978. var B2 = { toStringTag: co };
  3979. B2.absoluteValue = B2.abs = function() {
  3980. var i = new this.constructor(this);
  3981. return i.s < 0 && (i.s = 1), J2(i);
  3982. };
  3983. B2.ceil = function() {
  3984. return J2(new this.constructor(this), this.e + 1, 2);
  3985. };
  3986. B2.clampedTo = B2.clamp = function(i, a2) {
  3987. var e, t = this, r = t.constructor;
  3988. if (i = new r(i), a2 = new r(a2), !i.s || !a2.s)
  3989. return new r(NaN);
  3990. if (i.gt(a2))
  3991. throw Error(Bt + a2);
  3992. return e = t.cmp(i), e < 0 ? i : t.cmp(a2) > 0 ? a2 : new r(t);
  3993. };
  3994. B2.comparedTo = B2.cmp = function(i) {
  3995. var a2, e, t, r, n = this, s = n.d, o = (i = new n.constructor(i)).d, u = n.s, c = i.s;
  3996. if (!s || !o)
  3997. return !u || !c ? NaN : u !== c ? u : s === o ? 0 : !s ^ u < 0 ? 1 : -1;
  3998. if (!s[0] || !o[0])
  3999. return s[0] ? u : o[0] ? -c : 0;
  4000. if (u !== c)
  4001. return u;
  4002. if (n.e !== i.e)
  4003. return n.e > i.e ^ u < 0 ? 1 : -1;
  4004. for (t = s.length, r = o.length, a2 = 0, e = t < r ? t : r; a2 < e; ++a2)
  4005. if (s[a2] !== o[a2])
  4006. return s[a2] > o[a2] ^ u < 0 ? 1 : -1;
  4007. return t === r ? 0 : t > r ^ u < 0 ? 1 : -1;
  4008. };
  4009. B2.cosine = B2.cos = function() {
  4010. var i, a2, e = this, t = e.constructor;
  4011. return e.d ? e.d[0] ? (i = t.precision, a2 = t.rounding, t.precision = i + Math.max(e.e, e.sd()) + te, t.rounding = 1, e = Al(t, Co(t, e)), t.precision = i, t.rounding = a2, J2(Rt == 2 || Rt == 3 ? e.neg() : e, i, a2, true)) : new t(1) : new t(NaN);
  4012. };
  4013. B2.cubeRoot = B2.cbrt = function() {
  4014. var i, a2, e, t, r, n, s, o, u, c, l2 = this, f2 = l2.constructor;
  4015. if (!l2.isFinite() || l2.isZero())
  4016. return new f2(l2);
  4017. for (ue2 = false, n = l2.s * Le(l2.s * l2, 1 / 3), !n || Math.abs(n) == 1 / 0 ? (e = Ue(l2.d), i = l2.e, (n = (i - e.length + 1) % 3) && (e += n == 1 || n == -2 ? "0" : "00"), n = Le(e, 1 / 3), i = Be((i + 1) / 3) - (i % 3 == (i < 0 ? -1 : 2)), n == 1 / 0 ? e = "5e" + i : (e = n.toExponential(), e = e.slice(0, e.indexOf("e") + 1) + i), t = new f2(e), t.s = l2.s) : t = new f2(n.toString()), s = (i = f2.precision) + 3; ; )
  4018. if (o = t, u = o.times(o).times(o), c = u.plus(l2), t = pe2(c.plus(l2).times(o), c.plus(u), s + 2, 1), Ue(o.d).slice(0, s) === (e = Ue(t.d)).slice(0, s))
  4019. if (e = e.slice(s - 3, s + 1), e == "9999" || !r && e == "4999") {
  4020. if (!r && (J2(o, i + 1, 0), o.times(o).times(o).eq(l2))) {
  4021. t = o;
  4022. break;
  4023. }
  4024. s += 4, r = 1;
  4025. } else {
  4026. (!+e || !+e.slice(1) && e.charAt(0) == "5") && (J2(t, i + 1, 1), a2 = !t.times(t).times(t).eq(l2));
  4027. break;
  4028. }
  4029. return ue2 = true, J2(t, i, f2.rounding, a2);
  4030. };
  4031. B2.decimalPlaces = B2.dp = function() {
  4032. var i, a2 = this.d, e = NaN;
  4033. if (a2) {
  4034. if (i = a2.length - 1, e = (i - Be(this.e / te)) * te, i = a2[i], i)
  4035. for (; i % 10 == 0; i /= 10)
  4036. e--;
  4037. e < 0 && (e = 0);
  4038. }
  4039. return e;
  4040. };
  4041. B2.dividedBy = B2.div = function(i) {
  4042. return pe2(this, new this.constructor(i));
  4043. };
  4044. B2.dividedToIntegerBy = B2.divToInt = function(i) {
  4045. var a2 = this, e = a2.constructor;
  4046. return J2(pe2(a2, new e(i), 0, 1, 1), e.precision, e.rounding);
  4047. };
  4048. B2.equals = B2.eq = function(i) {
  4049. return this.cmp(i) === 0;
  4050. };
  4051. B2.floor = function() {
  4052. return J2(new this.constructor(this), this.e + 1, 3);
  4053. };
  4054. B2.greaterThan = B2.gt = function(i) {
  4055. return this.cmp(i) > 0;
  4056. };
  4057. B2.greaterThanOrEqualTo = B2.gte = function(i) {
  4058. var a2 = this.cmp(i);
  4059. return a2 == 1 || a2 === 0;
  4060. };
  4061. B2.hyperbolicCosine = B2.cosh = function() {
  4062. var i, a2, e, t, r, n = this, s = n.constructor, o = new s(1);
  4063. if (!n.isFinite())
  4064. return new s(n.s ? 1 / 0 : NaN);
  4065. if (n.isZero())
  4066. return o;
  4067. e = s.precision, t = s.rounding, s.precision = e + Math.max(n.e, n.sd()) + 4, s.rounding = 1, r = n.d.length, r < 32 ? (i = Math.ceil(r / 3), a2 = (1 / Tn(4, i)).toString()) : (i = 16, a2 = "2.3283064365386962890625e-10"), n = dr(s, 1, n.times(a2), new s(1), true);
  4068. for (var u, c = i, l2 = new s(8); c--; )
  4069. u = n.times(n), n = o.minus(u.times(l2.minus(u.times(l2))));
  4070. return J2(n, s.precision = e, s.rounding = t, true);
  4071. };
  4072. B2.hyperbolicSine = B2.sinh = function() {
  4073. var i, a2, e, t, r = this, n = r.constructor;
  4074. if (!r.isFinite() || r.isZero())
  4075. return new n(r);
  4076. if (a2 = n.precision, e = n.rounding, n.precision = a2 + Math.max(r.e, r.sd()) + 4, n.rounding = 1, t = r.d.length, t < 3)
  4077. r = dr(n, 2, r, r, true);
  4078. else {
  4079. i = 1.4 * Math.sqrt(t), i = i > 16 ? 16 : i | 0, r = r.times(1 / Tn(5, i)), r = dr(n, 2, r, r, true);
  4080. for (var s, o = new n(5), u = new n(16), c = new n(20); i--; )
  4081. s = r.times(r), r = r.times(o.plus(s.times(u.times(s).plus(c))));
  4082. }
  4083. return n.precision = a2, n.rounding = e, J2(r, a2, e, true);
  4084. };
  4085. B2.hyperbolicTangent = B2.tanh = function() {
  4086. var i, a2, e = this, t = e.constructor;
  4087. return e.isFinite() ? e.isZero() ? new t(e) : (i = t.precision, a2 = t.rounding, t.precision = i + 7, t.rounding = 1, pe2(e.sinh(), e.cosh(), t.precision = i, t.rounding = a2)) : new t(e.s);
  4088. };
  4089. B2.inverseCosine = B2.acos = function() {
  4090. var i, a2 = this, e = a2.constructor, t = a2.abs().cmp(1), r = e.precision, n = e.rounding;
  4091. return t !== -1 ? t === 0 ? a2.isNeg() ? ot2(e, r, n) : new e(0) : new e(NaN) : a2.isZero() ? ot2(e, r + 4, n).times(0.5) : (e.precision = r + 6, e.rounding = 1, a2 = a2.asin(), i = ot2(e, r + 4, n).times(0.5), e.precision = r, e.rounding = n, i.minus(a2));
  4092. };
  4093. B2.inverseHyperbolicCosine = B2.acosh = function() {
  4094. var i, a2, e = this, t = e.constructor;
  4095. return e.lte(1) ? new t(e.eq(1) ? 0 : NaN) : e.isFinite() ? (i = t.precision, a2 = t.rounding, t.precision = i + Math.max(Math.abs(e.e), e.sd()) + 4, t.rounding = 1, ue2 = false, e = e.times(e).minus(1).sqrt().plus(e), ue2 = true, t.precision = i, t.rounding = a2, e.ln()) : new t(e);
  4096. };
  4097. B2.inverseHyperbolicSine = B2.asinh = function() {
  4098. var i, a2, e = this, t = e.constructor;
  4099. return !e.isFinite() || e.isZero() ? new t(e) : (i = t.precision, a2 = t.rounding, t.precision = i + 2 * Math.max(Math.abs(e.e), e.sd()) + 6, t.rounding = 1, ue2 = false, e = e.times(e).plus(1).sqrt().plus(e), ue2 = true, t.precision = i, t.rounding = a2, e.ln());
  4100. };
  4101. B2.inverseHyperbolicTangent = B2.atanh = function() {
  4102. var i, a2, e, t, r = this, n = r.constructor;
  4103. return r.isFinite() ? r.e >= 0 ? new n(r.abs().eq(1) ? r.s / 0 : r.isZero() ? r : NaN) : (i = n.precision, a2 = n.rounding, t = r.sd(), Math.max(t, i) < 2 * -r.e - 1 ? J2(new n(r), i, a2, true) : (n.precision = e = t - r.e, r = pe2(r.plus(1), new n(1).minus(r), e + i, 1), n.precision = i + 4, n.rounding = 1, r = r.ln(), n.precision = i, n.rounding = a2, r.times(0.5))) : new n(NaN);
  4104. };
  4105. B2.inverseSine = B2.asin = function() {
  4106. var i, a2, e, t, r = this, n = r.constructor;
  4107. return r.isZero() ? new n(r) : (a2 = r.abs().cmp(1), e = n.precision, t = n.rounding, a2 !== -1 ? a2 === 0 ? (i = ot2(n, e + 4, t).times(0.5), i.s = r.s, i) : new n(NaN) : (n.precision = e + 6, n.rounding = 1, r = r.div(new n(1).minus(r.times(r)).sqrt().plus(1)).atan(), n.precision = e, n.rounding = t, r.times(2)));
  4108. };
  4109. B2.inverseTangent = B2.atan = function() {
  4110. var i, a2, e, t, r, n, s, o, u, c = this, l2 = c.constructor, f2 = l2.precision, h = l2.rounding;
  4111. if (c.isFinite()) {
  4112. if (c.isZero())
  4113. return new l2(c);
  4114. if (c.abs().eq(1) && f2 + 4 <= Us)
  4115. return s = ot2(l2, f2 + 4, h).times(0.25), s.s = c.s, s;
  4116. } else {
  4117. if (!c.s)
  4118. return new l2(NaN);
  4119. if (f2 + 4 <= Us)
  4120. return s = ot2(l2, f2 + 4, h).times(0.5), s.s = c.s, s;
  4121. }
  4122. for (l2.precision = o = f2 + 10, l2.rounding = 1, e = Math.min(28, o / te + 2 | 0), i = e; i; --i)
  4123. c = c.div(c.times(c).plus(1).sqrt().plus(1));
  4124. for (ue2 = false, a2 = Math.ceil(o / te), t = 1, u = c.times(c), s = new l2(c), r = c; i !== -1; )
  4125. if (r = r.times(u), n = s.minus(r.div(t += 2)), r = r.times(u), s = n.plus(r.div(t += 2)), s.d[a2] !== void 0)
  4126. for (i = a2; s.d[i] === n.d[i] && i--; )
  4127. ;
  4128. return e && (s = s.times(2 << e - 1)), ue2 = true, J2(s, l2.precision = f2, l2.rounding = h, true);
  4129. };
  4130. B2.isFinite = function() {
  4131. return !!this.d;
  4132. };
  4133. B2.isInteger = B2.isInt = function() {
  4134. return !!this.d && Be(this.e / te) > this.d.length - 2;
  4135. };
  4136. B2.isNaN = function() {
  4137. return !this.s;
  4138. };
  4139. B2.isNegative = B2.isNeg = function() {
  4140. return this.s < 0;
  4141. };
  4142. B2.isPositive = B2.isPos = function() {
  4143. return this.s > 0;
  4144. };
  4145. B2.isZero = function() {
  4146. return !!this.d && this.d[0] === 0;
  4147. };
  4148. B2.lessThan = B2.lt = function(i) {
  4149. return this.cmp(i) < 0;
  4150. };
  4151. B2.lessThanOrEqualTo = B2.lte = function(i) {
  4152. return this.cmp(i) < 1;
  4153. };
  4154. B2.logarithm = B2.log = function(i) {
  4155. var a2, e, t, r, n, s, o, u, c = this, l2 = c.constructor, f2 = l2.precision, h = l2.rounding, d2 = 5;
  4156. if (i == null)
  4157. i = new l2(10), a2 = true;
  4158. else {
  4159. if (i = new l2(i), e = i.d, i.s < 0 || !e || !e[0] || i.eq(1))
  4160. return new l2(NaN);
  4161. a2 = i.eq(10);
  4162. }
  4163. if (e = c.d, c.s < 0 || !e || !e[0] || c.eq(1))
  4164. return new l2(e && !e[0] ? -1 / 0 : c.s != 1 ? NaN : e ? 0 : 1 / 0);
  4165. if (a2)
  4166. if (e.length > 1)
  4167. n = true;
  4168. else {
  4169. for (r = e[0]; r % 10 === 0; )
  4170. r /= 10;
  4171. n = r !== 1;
  4172. }
  4173. if (ue2 = false, o = f2 + d2, s = jt(c, o), t = a2 ? dn2(l2, o + 10) : jt(i, o), u = pe2(s, t, o, 1), Lr(u.d, r = f2, h))
  4174. do
  4175. if (o += 10, s = jt(c, o), t = a2 ? dn2(l2, o + 10) : jt(i, o), u = pe2(s, t, o, 1), !n) {
  4176. +Ue(u.d).slice(r + 1, r + 15) + 1 == 1e14 && (u = J2(u, f2 + 1, 0));
  4177. break;
  4178. }
  4179. while (Lr(u.d, r += 10, h));
  4180. return ue2 = true, J2(u, f2, h);
  4181. };
  4182. B2.minus = B2.sub = function(i) {
  4183. var a2, e, t, r, n, s, o, u, c, l2, f2, h, d2 = this, _ = d2.constructor;
  4184. if (i = new _(i), !d2.d || !i.d)
  4185. return !d2.s || !i.s ? i = new _(NaN) : d2.d ? i.s = -i.s : i = new _(i.d || d2.s !== i.s ? d2 : NaN), i;
  4186. if (d2.s != i.s)
  4187. return i.s = -i.s, d2.plus(i);
  4188. if (c = d2.d, h = i.d, o = _.precision, u = _.rounding, !c[0] || !h[0]) {
  4189. if (h[0])
  4190. i.s = -i.s;
  4191. else if (c[0])
  4192. i = new _(d2);
  4193. else
  4194. return new _(u === 3 ? -0 : 0);
  4195. return ue2 ? J2(i, o, u) : i;
  4196. }
  4197. if (e = Be(i.e / te), l2 = Be(d2.e / te), c = c.slice(), n = l2 - e, n) {
  4198. for (f2 = n < 0, f2 ? (a2 = c, n = -n, s = h.length) : (a2 = h, e = l2, s = c.length), t = Math.max(Math.ceil(o / te), s) + 2, n > t && (n = t, a2.length = 1), a2.reverse(), t = n; t--; )
  4199. a2.push(0);
  4200. a2.reverse();
  4201. } else {
  4202. for (t = c.length, s = h.length, f2 = t < s, f2 && (s = t), t = 0; t < s; t++)
  4203. if (c[t] != h[t]) {
  4204. f2 = c[t] < h[t];
  4205. break;
  4206. }
  4207. n = 0;
  4208. }
  4209. for (f2 && (a2 = c, c = h, h = a2, i.s = -i.s), s = c.length, t = h.length - s; t > 0; --t)
  4210. c[s++] = 0;
  4211. for (t = h.length; t > n; ) {
  4212. if (c[--t] < h[t]) {
  4213. for (r = t; r && c[--r] === 0; )
  4214. c[r] = ut - 1;
  4215. --c[r], c[t] += ut;
  4216. }
  4217. c[t] -= h[t];
  4218. }
  4219. for (; c[--s] === 0; )
  4220. c.pop();
  4221. for (; c[0] === 0; c.shift())
  4222. --e;
  4223. return c[0] ? (i.d = c, i.e = vn(c, e), ue2 ? J2(i, o, u) : i) : new _(u === 3 ? -0 : 0);
  4224. };
  4225. B2.modulo = B2.mod = function(i) {
  4226. var a2, e = this, t = e.constructor;
  4227. return i = new t(i), !e.d || !i.s || i.d && !i.d[0] ? new t(NaN) : !i.d || e.d && !e.d[0] ? J2(new t(e), t.precision, t.rounding) : (ue2 = false, t.modulo == 9 ? (a2 = pe2(e, i.abs(), 0, 3, 1), a2.s *= i.s) : a2 = pe2(e, i, 0, t.modulo, 1), a2 = a2.times(i), ue2 = true, e.minus(a2));
  4228. };
  4229. B2.naturalExponential = B2.exp = function() {
  4230. return vs(this);
  4231. };
  4232. B2.naturalLogarithm = B2.ln = function() {
  4233. return jt(this);
  4234. };
  4235. B2.negated = B2.neg = function() {
  4236. var i = new this.constructor(this);
  4237. return i.s = -i.s, J2(i);
  4238. };
  4239. B2.plus = B2.add = function(i) {
  4240. var a2, e, t, r, n, s, o, u, c, l2, f2 = this, h = f2.constructor;
  4241. if (i = new h(i), !f2.d || !i.d)
  4242. return !f2.s || !i.s ? i = new h(NaN) : f2.d || (i = new h(i.d || f2.s === i.s ? f2 : NaN)), i;
  4243. if (f2.s != i.s)
  4244. return i.s = -i.s, f2.minus(i);
  4245. if (c = f2.d, l2 = i.d, o = h.precision, u = h.rounding, !c[0] || !l2[0])
  4246. return l2[0] || (i = new h(f2)), ue2 ? J2(i, o, u) : i;
  4247. if (n = Be(f2.e / te), t = Be(i.e / te), c = c.slice(), r = n - t, r) {
  4248. for (r < 0 ? (e = c, r = -r, s = l2.length) : (e = l2, t = n, s = c.length), n = Math.ceil(o / te), s = n > s ? n + 1 : s + 1, r > s && (r = s, e.length = 1), e.reverse(); r--; )
  4249. e.push(0);
  4250. e.reverse();
  4251. }
  4252. for (s = c.length, r = l2.length, s - r < 0 && (r = s, e = l2, l2 = c, c = e), a2 = 0; r; )
  4253. a2 = (c[--r] = c[r] + l2[r] + a2) / ut | 0, c[r] %= ut;
  4254. for (a2 && (c.unshift(a2), ++t), s = c.length; c[--s] == 0; )
  4255. c.pop();
  4256. return i.d = c, i.e = vn(c, t), ue2 ? J2(i, o, u) : i;
  4257. };
  4258. B2.precision = B2.sd = function(i) {
  4259. var a2, e = this;
  4260. if (i !== void 0 && i !== !!i && i !== 1 && i !== 0)
  4261. throw Error(Bt + i);
  4262. return e.d ? (a2 = fo(e.d), i && e.e + 1 > a2 && (a2 = e.e + 1)) : a2 = NaN, a2;
  4263. };
  4264. B2.round = function() {
  4265. var i = this, a2 = i.constructor;
  4266. return J2(new a2(i), i.e + 1, a2.rounding);
  4267. };
  4268. B2.sine = B2.sin = function() {
  4269. var i, a2, e = this, t = e.constructor;
  4270. return e.isFinite() ? e.isZero() ? new t(e) : (i = t.precision, a2 = t.rounding, t.precision = i + Math.max(e.e, e.sd()) + te, t.rounding = 1, e = bl(t, Co(t, e)), t.precision = i, t.rounding = a2, J2(Rt > 2 ? e.neg() : e, i, a2, true)) : new t(NaN);
  4271. };
  4272. B2.squareRoot = B2.sqrt = function() {
  4273. var i, a2, e, t, r, n, s = this, o = s.d, u = s.e, c = s.s, l2 = s.constructor;
  4274. if (c !== 1 || !o || !o[0])
  4275. return new l2(!c || c < 0 && (!o || o[0]) ? NaN : o ? s : 1 / 0);
  4276. for (ue2 = false, c = Math.sqrt(+s), c == 0 || c == 1 / 0 ? (a2 = Ue(o), (a2.length + u) % 2 == 0 && (a2 += "0"), c = Math.sqrt(a2), u = Be((u + 1) / 2) - (u < 0 || u % 2), c == 1 / 0 ? a2 = "5e" + u : (a2 = c.toExponential(), a2 = a2.slice(0, a2.indexOf("e") + 1) + u), t = new l2(a2)) : t = new l2(c.toString()), e = (u = l2.precision) + 3; ; )
  4277. if (n = t, t = n.plus(pe2(s, n, e + 2, 1)).times(0.5), Ue(n.d).slice(0, e) === (a2 = Ue(t.d)).slice(0, e))
  4278. if (a2 = a2.slice(e - 3, e + 1), a2 == "9999" || !r && a2 == "4999") {
  4279. if (!r && (J2(n, u + 1, 0), n.times(n).eq(s))) {
  4280. t = n;
  4281. break;
  4282. }
  4283. e += 4, r = 1;
  4284. } else {
  4285. (!+a2 || !+a2.slice(1) && a2.charAt(0) == "5") && (J2(t, u + 1, 1), i = !t.times(t).eq(s));
  4286. break;
  4287. }
  4288. return ue2 = true, J2(t, u, l2.rounding, i);
  4289. };
  4290. B2.tangent = B2.tan = function() {
  4291. var i, a2, e = this, t = e.constructor;
  4292. return e.isFinite() ? e.isZero() ? new t(e) : (i = t.precision, a2 = t.rounding, t.precision = i + 10, t.rounding = 1, e = e.sin(), e.s = 1, e = pe2(e, new t(1).minus(e.times(e)).sqrt(), i + 10, 0), t.precision = i, t.rounding = a2, J2(Rt == 2 || Rt == 4 ? e.neg() : e, i, a2, true)) : new t(NaN);
  4293. };
  4294. B2.times = B2.mul = function(i) {
  4295. var a2, e, t, r, n, s, o, u, c, l2 = this, f2 = l2.constructor, h = l2.d, d2 = (i = new f2(i)).d;
  4296. if (i.s *= l2.s, !h || !h[0] || !d2 || !d2[0])
  4297. return new f2(!i.s || h && !h[0] && !d2 || d2 && !d2[0] && !h ? NaN : !h || !d2 ? i.s / 0 : i.s * 0);
  4298. for (e = Be(l2.e / te) + Be(i.e / te), u = h.length, c = d2.length, u < c && (n = h, h = d2, d2 = n, s = u, u = c, c = s), n = [], s = u + c, t = s; t--; )
  4299. n.push(0);
  4300. for (t = c; --t >= 0; ) {
  4301. for (a2 = 0, r = u + t; r > t; )
  4302. o = n[r] + d2[t] * h[r - t - 1] + a2, n[r--] = o % ut | 0, a2 = o / ut | 0;
  4303. n[r] = (n[r] + a2) % ut | 0;
  4304. }
  4305. for (; !n[--s]; )
  4306. n.pop();
  4307. return a2 ? ++e : n.shift(), i.d = n, i.e = vn(n, e), ue2 ? J2(i, f2.precision, f2.rounding) : i;
  4308. };
  4309. B2.toBinary = function(i, a2) {
  4310. return ga(this, 2, i, a2);
  4311. };
  4312. B2.toDecimalPlaces = B2.toDP = function(i, a2) {
  4313. var e = this, t = e.constructor;
  4314. return e = new t(e), i === void 0 ? e : (He(i, 0, $t), a2 === void 0 ? a2 = t.rounding : He(a2, 0, 8), J2(e, i + e.e + 1, a2));
  4315. };
  4316. B2.toExponential = function(i, a2) {
  4317. var e, t = this, r = t.constructor;
  4318. return i === void 0 ? e = Ct2(t, true) : (He(i, 0, $t), a2 === void 0 ? a2 = r.rounding : He(a2, 0, 8), t = J2(new r(t), i + 1, a2), e = Ct2(t, true, i + 1)), t.isNeg() && !t.isZero() ? "-" + e : e;
  4319. };
  4320. B2.toFixed = function(i, a2) {
  4321. var e, t, r = this, n = r.constructor;
  4322. return i === void 0 ? e = Ct2(r) : (He(i, 0, $t), a2 === void 0 ? a2 = n.rounding : He(a2, 0, 8), t = J2(new n(r), i + r.e + 1, a2), e = Ct2(t, false, i + t.e + 1)), r.isNeg() && !r.isZero() ? "-" + e : e;
  4323. };
  4324. B2.toFraction = function(i) {
  4325. var a2, e, t, r, n, s, o, u, c, l2, f2, h, d2 = this, _ = d2.d, C = d2.constructor;
  4326. if (!_)
  4327. return new C(d2);
  4328. if (c = e = new C(1), t = u = new C(0), a2 = new C(t), n = a2.e = fo(_) - d2.e - 1, s = n % te, a2.d[0] = Le(10, s < 0 ? te + s : s), i == null)
  4329. i = n > 0 ? a2 : c;
  4330. else {
  4331. if (o = new C(i), !o.isInt() || o.lt(c))
  4332. throw Error(Bt + o);
  4333. i = o.gt(a2) ? n > 0 ? a2 : c : o;
  4334. }
  4335. for (ue2 = false, o = new C(Ue(_)), l2 = C.precision, C.precision = n = _.length * te * 2; f2 = pe2(o, a2, 0, 1, 1), r = e.plus(f2.times(t)), r.cmp(i) != 1; )
  4336. e = t, t = r, r = c, c = u.plus(f2.times(r)), u = r, r = a2, a2 = o.minus(f2.times(r)), o = r;
  4337. return r = pe2(i.minus(e), t, 0, 1, 1), u = u.plus(r.times(c)), e = e.plus(r.times(t)), u.s = c.s = d2.s, h = pe2(c, t, n, 1).minus(d2).abs().cmp(pe2(u, e, n, 1).minus(d2).abs()) < 1 ? [c, t] : [u, e], C.precision = l2, ue2 = true, h;
  4338. };
  4339. B2.toHexadecimal = B2.toHex = function(i, a2) {
  4340. return ga(this, 16, i, a2);
  4341. };
  4342. B2.toNearest = function(i, a2) {
  4343. var e = this, t = e.constructor;
  4344. if (e = new t(e), i == null) {
  4345. if (!e.d)
  4346. return e;
  4347. i = new t(1), a2 = t.rounding;
  4348. } else {
  4349. if (i = new t(i), a2 === void 0 ? a2 = t.rounding : He(a2, 0, 8), !e.d)
  4350. return i.s ? e : i;
  4351. if (!i.d)
  4352. return i.s && (i.s = e.s), i;
  4353. }
  4354. return i.d[0] ? (ue2 = false, e = pe2(e, i, 0, a2, 1).times(i), ue2 = true, J2(e)) : (i.s = e.s, e = i), e;
  4355. };
  4356. B2.toNumber = function() {
  4357. return +this;
  4358. };
  4359. B2.toOctal = function(i, a2) {
  4360. return ga(this, 8, i, a2);
  4361. };
  4362. B2.toPower = B2.pow = function(i) {
  4363. var a2, e, t, r, n, s, o = this, u = o.constructor, c = +(i = new u(i));
  4364. if (!o.d || !i.d || !o.d[0] || !i.d[0])
  4365. return new u(Le(+o, c));
  4366. if (o = new u(o), o.eq(1))
  4367. return o;
  4368. if (t = u.precision, n = u.rounding, i.eq(1))
  4369. return J2(o, t, n);
  4370. if (a2 = Be(i.e / te), a2 >= i.d.length - 1 && (e = c < 0 ? -c : c) <= Cl)
  4371. return r = ho(u, o, e, t), i.s < 0 ? new u(1).div(r) : J2(r, t, n);
  4372. if (s = o.s, s < 0) {
  4373. if (a2 < i.d.length - 1)
  4374. return new u(NaN);
  4375. if (i.d[a2] & 1 || (s = 1), o.e == 0 && o.d[0] == 1 && o.d.length == 1)
  4376. return o.s = s, o;
  4377. }
  4378. return e = Le(+o, c), a2 = e == 0 || !isFinite(e) ? Be(c * (Math.log("0." + Ue(o.d)) / Math.LN10 + o.e + 1)) : new u(e + "").e, a2 > u.maxE + 1 || a2 < u.minE - 1 ? new u(a2 > 0 ? s / 0 : 0) : (ue2 = false, u.rounding = o.s = 1, e = Math.min(12, (a2 + "").length), r = vs(i.times(jt(o, t + e)), t), r.d && (r = J2(r, t + 5, 1), Lr(r.d, t, n) && (a2 = t + 10, r = J2(vs(i.times(jt(o, a2 + e)), a2), a2 + 5, 1), +Ue(r.d).slice(t + 1, t + 15) + 1 == 1e14 && (r = J2(r, t + 1, 0)))), r.s = s, ue2 = true, u.rounding = n, J2(r, t, n));
  4379. };
  4380. B2.toPrecision = function(i, a2) {
  4381. var e, t = this, r = t.constructor;
  4382. return i === void 0 ? e = Ct2(t, t.e <= r.toExpNeg || t.e >= r.toExpPos) : (He(i, 1, $t), a2 === void 0 ? a2 = r.rounding : He(a2, 0, 8), t = J2(new r(t), i, a2), e = Ct2(t, i <= t.e || t.e <= r.toExpNeg, i)), t.isNeg() && !t.isZero() ? "-" + e : e;
  4383. };
  4384. B2.toSignificantDigits = B2.toSD = function(i, a2) {
  4385. var e = this, t = e.constructor;
  4386. return i === void 0 ? (i = t.precision, a2 = t.rounding) : (He(i, 1, $t), a2 === void 0 ? a2 = t.rounding : He(a2, 0, 8)), J2(new t(e), i, a2);
  4387. };
  4388. B2.toString = function() {
  4389. var i = this, a2 = i.constructor, e = Ct2(i, i.e <= a2.toExpNeg || i.e >= a2.toExpPos);
  4390. return i.isNeg() && !i.isZero() ? "-" + e : e;
  4391. };
  4392. B2.truncated = B2.trunc = function() {
  4393. return J2(new this.constructor(this), this.e + 1, 1);
  4394. };
  4395. B2.valueOf = B2.toJSON = function() {
  4396. var i = this, a2 = i.constructor, e = Ct2(i, i.e <= a2.toExpNeg || i.e >= a2.toExpPos);
  4397. return i.isNeg() ? "-" + e : e;
  4398. };
  4399. function Ue(i) {
  4400. var a2, e, t, r = i.length - 1, n = "", s = i[0];
  4401. if (r > 0) {
  4402. for (n += s, a2 = 1; a2 < r; a2++)
  4403. t = i[a2] + "", e = te - t.length, e && (n += Pt2(e)), n += t;
  4404. s = i[a2], t = s + "", e = te - t.length, e && (n += Pt2(e));
  4405. } else if (s === 0)
  4406. return "0";
  4407. for (; s % 10 === 0; )
  4408. s /= 10;
  4409. return n + s;
  4410. }
  4411. function He(i, a2, e) {
  4412. if (i !== ~~i || i < a2 || i > e)
  4413. throw Error(Bt + i);
  4414. }
  4415. function Lr(i, a2, e, t) {
  4416. var r, n, s, o;
  4417. for (n = i[0]; n >= 10; n /= 10)
  4418. --a2;
  4419. return --a2 < 0 ? (a2 += te, r = 0) : (r = Math.ceil((a2 + 1) / te), a2 %= te), n = Le(10, te - a2), o = i[r] % n | 0, t == null ? a2 < 3 ? (a2 == 0 ? o = o / 100 | 0 : a2 == 1 && (o = o / 10 | 0), s = e < 4 && o == 99999 || e > 3 && o == 49999 || o == 5e4 || o == 0) : s = (e < 4 && o + 1 == n || e > 3 && o + 1 == n / 2) && (i[r + 1] / n / 100 | 0) == Le(10, a2 - 2) - 1 || (o == n / 2 || o == 0) && (i[r + 1] / n / 100 | 0) == 0 : a2 < 4 ? (a2 == 0 ? o = o / 1e3 | 0 : a2 == 1 ? o = o / 100 | 0 : a2 == 2 && (o = o / 10 | 0), s = (t || e < 4) && o == 9999 || !t && e > 3 && o == 4999) : s = ((t || e < 4) && o + 1 == n || !t && e > 3 && o + 1 == n / 2) && (i[r + 1] / n / 1e3 | 0) == Le(10, a2 - 3) - 1, s;
  4420. }
  4421. function sn(i, a2, e) {
  4422. for (var t, r = [0], n, s = 0, o = i.length; s < o; ) {
  4423. for (n = r.length; n--; )
  4424. r[n] *= a2;
  4425. for (r[0] += xs.indexOf(i.charAt(s++)), t = 0; t < r.length; t++)
  4426. r[t] > e - 1 && (r[t + 1] === void 0 && (r[t + 1] = 0), r[t + 1] += r[t] / e | 0, r[t] %= e);
  4427. }
  4428. return r.reverse();
  4429. }
  4430. function Al(i, a2) {
  4431. var e, t, r;
  4432. if (a2.isZero())
  4433. return a2;
  4434. t = a2.d.length, t < 32 ? (e = Math.ceil(t / 3), r = (1 / Tn(4, e)).toString()) : (e = 16, r = "2.3283064365386962890625e-10"), i.precision += e, a2 = dr(i, 1, a2.times(r), new i(1));
  4435. for (var n = e; n--; ) {
  4436. var s = a2.times(a2);
  4437. a2 = s.times(s).minus(s).times(8).plus(1);
  4438. }
  4439. return i.precision -= e, a2;
  4440. }
  4441. var pe2 = function() {
  4442. function i(t, r, n) {
  4443. var s, o = 0, u = t.length;
  4444. for (t = t.slice(); u--; )
  4445. s = t[u] * r + o, t[u] = s % n | 0, o = s / n | 0;
  4446. return o && t.unshift(o), t;
  4447. }
  4448. function a2(t, r, n, s) {
  4449. var o, u;
  4450. if (n != s)
  4451. u = n > s ? 1 : -1;
  4452. else
  4453. for (o = u = 0; o < n; o++)
  4454. if (t[o] != r[o]) {
  4455. u = t[o] > r[o] ? 1 : -1;
  4456. break;
  4457. }
  4458. return u;
  4459. }
  4460. function e(t, r, n, s) {
  4461. for (var o = 0; n--; )
  4462. t[n] -= o, o = t[n] < r[n] ? 1 : 0, t[n] = o * s + t[n] - r[n];
  4463. for (; !t[0] && t.length > 1; )
  4464. t.shift();
  4465. }
  4466. return function(t, r, n, s, o, u) {
  4467. var c, l2, f2, h, d2, _, C, E2, b, R, p2, N2, M2, w, D2, S2, P, U2, x2, F, W2 = t.constructor, ne = t.s == r.s ? 1 : -1, z = t.d, G2 = r.d;
  4468. if (!z || !z[0] || !G2 || !G2[0])
  4469. return new W2(
  4470. // Return NaN if either NaN, or both Infinity or 0.
  4471. !t.s || !r.s || (z ? G2 && z[0] == G2[0] : !G2) ? NaN : (
  4472. // Return ±0 if x is 0 or y is ±Infinity, or return ±Infinity as y is 0.
  4473. z && z[0] == 0 || !G2 ? ne * 0 : ne / 0
  4474. )
  4475. );
  4476. for (u ? (d2 = 1, l2 = t.e - r.e) : (u = ut, d2 = te, l2 = Be(t.e / d2) - Be(r.e / d2)), x2 = G2.length, P = z.length, b = new W2(ne), R = b.d = [], f2 = 0; G2[f2] == (z[f2] || 0); f2++)
  4477. ;
  4478. if (G2[f2] > (z[f2] || 0) && l2--, n == null ? (w = n = W2.precision, s = W2.rounding) : o ? w = n + (t.e - r.e) + 1 : w = n, w < 0)
  4479. R.push(1), _ = true;
  4480. else {
  4481. if (w = w / d2 + 2 | 0, f2 = 0, x2 == 1) {
  4482. for (h = 0, G2 = G2[0], w++; (f2 < P || h) && w--; f2++)
  4483. D2 = h * u + (z[f2] || 0), R[f2] = D2 / G2 | 0, h = D2 % G2 | 0;
  4484. _ = h || f2 < P;
  4485. } else {
  4486. for (h = u / (G2[0] + 1) | 0, h > 1 && (G2 = i(G2, h, u), z = i(z, h, u), x2 = G2.length, P = z.length), S2 = x2, p2 = z.slice(0, x2), N2 = p2.length; N2 < x2; )
  4487. p2[N2++] = 0;
  4488. F = G2.slice(), F.unshift(0), U2 = G2[0], G2[1] >= u / 2 && ++U2;
  4489. do
  4490. h = 0, c = a2(G2, p2, x2, N2), c < 0 ? (M2 = p2[0], x2 != N2 && (M2 = M2 * u + (p2[1] || 0)), h = M2 / U2 | 0, h > 1 ? (h >= u && (h = u - 1), C = i(G2, h, u), E2 = C.length, N2 = p2.length, c = a2(C, p2, E2, N2), c == 1 && (h--, e(C, x2 < E2 ? F : G2, E2, u))) : (h == 0 && (c = h = 1), C = G2.slice()), E2 = C.length, E2 < N2 && C.unshift(0), e(p2, C, N2, u), c == -1 && (N2 = p2.length, c = a2(G2, p2, x2, N2), c < 1 && (h++, e(p2, x2 < N2 ? F : G2, N2, u))), N2 = p2.length) : c === 0 && (h++, p2 = [0]), R[f2++] = h, c && p2[0] ? p2[N2++] = z[S2] || 0 : (p2 = [z[S2]], N2 = 1);
  4491. while ((S2++ < P || p2[0] !== void 0) && w--);
  4492. _ = p2[0] !== void 0;
  4493. }
  4494. R[0] || R.shift();
  4495. }
  4496. if (d2 == 1)
  4497. b.e = l2, io = _;
  4498. else {
  4499. for (f2 = 1, h = R[0]; h >= 10; h /= 10)
  4500. f2++;
  4501. b.e = f2 + l2 * d2 - 1, J2(b, o ? n + b.e + 1 : n, s, _);
  4502. }
  4503. return b;
  4504. };
  4505. }();
  4506. function J2(i, a2, e, t) {
  4507. var r, n, s, o, u, c, l2, f2, h, d2 = i.constructor;
  4508. e:
  4509. if (a2 != null) {
  4510. if (f2 = i.d, !f2)
  4511. return i;
  4512. for (r = 1, o = f2[0]; o >= 10; o /= 10)
  4513. r++;
  4514. if (n = a2 - r, n < 0)
  4515. n += te, s = a2, l2 = f2[h = 0], u = l2 / Le(10, r - s - 1) % 10 | 0;
  4516. else if (h = Math.ceil((n + 1) / te), o = f2.length, h >= o)
  4517. if (t) {
  4518. for (; o++ <= h; )
  4519. f2.push(0);
  4520. l2 = u = 0, r = 1, n %= te, s = n - te + 1;
  4521. } else
  4522. break e;
  4523. else {
  4524. for (l2 = o = f2[h], r = 1; o >= 10; o /= 10)
  4525. r++;
  4526. n %= te, s = n - te + r, u = s < 0 ? 0 : l2 / Le(10, r - s - 1) % 10 | 0;
  4527. }
  4528. if (t = t || a2 < 0 || f2[h + 1] !== void 0 || (s < 0 ? l2 : l2 % Le(10, r - s - 1)), c = e < 4 ? (u || t) && (e == 0 || e == (i.s < 0 ? 3 : 2)) : u > 5 || u == 5 && (e == 4 || t || e == 6 && // Check whether the digit to the left of the rounding digit is odd.
  4529. (n > 0 ? s > 0 ? l2 / Le(10, r - s) : 0 : f2[h - 1]) % 10 & 1 || e == (i.s < 0 ? 8 : 7)), a2 < 1 || !f2[0])
  4530. return f2.length = 0, c ? (a2 -= i.e + 1, f2[0] = Le(10, (te - a2 % te) % te), i.e = -a2 || 0) : f2[0] = i.e = 0, i;
  4531. if (n == 0 ? (f2.length = h, o = 1, h--) : (f2.length = h + 1, o = Le(10, te - n), f2[h] = s > 0 ? (l2 / Le(10, r - s) % Le(10, s) | 0) * o : 0), c)
  4532. for (; ; )
  4533. if (h == 0) {
  4534. for (n = 1, s = f2[0]; s >= 10; s /= 10)
  4535. n++;
  4536. for (s = f2[0] += o, o = 1; s >= 10; s /= 10)
  4537. o++;
  4538. n != o && (i.e++, f2[0] == ut && (f2[0] = 1));
  4539. break;
  4540. } else {
  4541. if (f2[h] += o, f2[h] != ut)
  4542. break;
  4543. f2[h--] = 0, o = 1;
  4544. }
  4545. for (n = f2.length; f2[--n] === 0; )
  4546. f2.pop();
  4547. }
  4548. return ue2 && (i.e > d2.maxE ? (i.d = null, i.e = NaN) : i.e < d2.minE && (i.e = 0, i.d = [0])), i;
  4549. }
  4550. function Ct2(i, a2, e) {
  4551. if (!i.isFinite())
  4552. return go(i);
  4553. var t, r = i.e, n = Ue(i.d), s = n.length;
  4554. return a2 ? (e && (t = e - s) > 0 ? n = n.charAt(0) + "." + n.slice(1) + Pt2(t) : s > 1 && (n = n.charAt(0) + "." + n.slice(1)), n = n + (i.e < 0 ? "e" : "e+") + i.e) : r < 0 ? (n = "0." + Pt2(-r - 1) + n, e && (t = e - s) > 0 && (n += Pt2(t))) : r >= s ? (n += Pt2(r + 1 - s), e && (t = e - r - 1) > 0 && (n = n + "." + Pt2(t))) : ((t = r + 1) < s && (n = n.slice(0, t) + "." + n.slice(t)), e && (t = e - s) > 0 && (r + 1 === s && (n += "."), n += Pt2(t))), n;
  4555. }
  4556. function vn(i, a2) {
  4557. var e = i[0];
  4558. for (a2 *= te; e >= 10; e /= 10)
  4559. a2++;
  4560. return a2;
  4561. }
  4562. function dn2(i, a2, e) {
  4563. if (a2 > _l)
  4564. throw ue2 = true, e && (i.precision = e), Error(oo);
  4565. return J2(new i(mn), a2, 1, true);
  4566. }
  4567. function ot2(i, a2, e) {
  4568. if (a2 > Us)
  4569. throw Error(oo);
  4570. return J2(new i(gn), a2, e, true);
  4571. }
  4572. function fo(i) {
  4573. var a2 = i.length - 1, e = a2 * te + 1;
  4574. if (a2 = i[a2], a2) {
  4575. for (; a2 % 10 == 0; a2 /= 10)
  4576. e--;
  4577. for (a2 = i[0]; a2 >= 10; a2 /= 10)
  4578. e++;
  4579. }
  4580. return e;
  4581. }
  4582. function Pt2(i) {
  4583. for (var a2 = ""; i--; )
  4584. a2 += "0";
  4585. return a2;
  4586. }
  4587. function ho(i, a2, e, t) {
  4588. var r, n = new i(1), s = Math.ceil(t / te + 4);
  4589. for (ue2 = false; ; ) {
  4590. if (e % 2 && (n = n.times(a2), hi(n.d, s) && (r = true)), e = Be(e / 2), e === 0) {
  4591. e = n.d.length - 1, r && n.d[e] === 0 && ++n.d[e];
  4592. break;
  4593. }
  4594. a2 = a2.times(a2), hi(a2.d, s);
  4595. }
  4596. return ue2 = true, n;
  4597. }
  4598. function fi(i) {
  4599. return i.d[i.d.length - 1] & 1;
  4600. }
  4601. function mo(i, a2, e) {
  4602. for (var t, r = new i(a2[0]), n = 0; ++n < a2.length; )
  4603. if (t = new i(a2[n]), t.s)
  4604. r[e](t) && (r = t);
  4605. else {
  4606. r = t;
  4607. break;
  4608. }
  4609. return r;
  4610. }
  4611. function vs(i, a2) {
  4612. var e, t, r, n, s, o, u, c = 0, l2 = 0, f2 = 0, h = i.constructor, d2 = h.rounding, _ = h.precision;
  4613. if (!i.d || !i.d[0] || i.e > 17)
  4614. return new h(i.d ? i.d[0] ? i.s < 0 ? 0 : 1 / 0 : 1 : i.s ? i.s < 0 ? 0 : i : NaN);
  4615. for (a2 == null ? (ue2 = false, u = _) : u = a2, o = new h(0.03125); i.e > -2; )
  4616. i = i.times(o), f2 += 5;
  4617. for (t = Math.log(Le(2, f2)) / Math.LN10 * 2 + 5 | 0, u += t, e = n = s = new h(1), h.precision = u; ; ) {
  4618. if (n = J2(n.times(i), u, 1), e = e.times(++l2), o = s.plus(pe2(n, e, u, 1)), Ue(o.d).slice(0, u) === Ue(s.d).slice(0, u)) {
  4619. for (r = f2; r--; )
  4620. s = J2(s.times(s), u, 1);
  4621. if (a2 == null)
  4622. if (c < 3 && Lr(s.d, u - t, d2, c))
  4623. h.precision = u += 10, e = n = o = new h(1), l2 = 0, c++;
  4624. else
  4625. return J2(s, h.precision = _, d2, ue2 = true);
  4626. else
  4627. return h.precision = _, s;
  4628. }
  4629. s = o;
  4630. }
  4631. }
  4632. function jt(i, a2) {
  4633. var e, t, r, n, s, o, u, c, l2, f2, h, d2 = 1, _ = 10, C = i, E2 = C.d, b = C.constructor, R = b.rounding, p2 = b.precision;
  4634. if (C.s < 0 || !E2 || !E2[0] || !C.e && E2[0] == 1 && E2.length == 1)
  4635. return new b(E2 && !E2[0] ? -1 / 0 : C.s != 1 ? NaN : E2 ? 0 : C);
  4636. if (a2 == null ? (ue2 = false, l2 = p2) : l2 = a2, b.precision = l2 += _, e = Ue(E2), t = e.charAt(0), Math.abs(n = C.e) < 15e14) {
  4637. for (; t < 7 && t != 1 || t == 1 && e.charAt(1) > 3; )
  4638. C = C.times(i), e = Ue(C.d), t = e.charAt(0), d2++;
  4639. n = C.e, t > 1 ? (C = new b("0." + e), n++) : C = new b(t + "." + e.slice(1));
  4640. } else
  4641. return c = dn2(b, l2 + 2, p2).times(n + ""), C = jt(new b(t + "." + e.slice(1)), l2 - _).plus(c), b.precision = p2, a2 == null ? J2(C, p2, R, ue2 = true) : C;
  4642. for (f2 = C, u = s = C = pe2(C.minus(1), C.plus(1), l2, 1), h = J2(C.times(C), l2, 1), r = 3; ; ) {
  4643. if (s = J2(s.times(h), l2, 1), c = u.plus(pe2(s, new b(r), l2, 1)), Ue(c.d).slice(0, l2) === Ue(u.d).slice(0, l2))
  4644. if (u = u.times(2), n !== 0 && (u = u.plus(dn2(b, l2 + 2, p2).times(n + ""))), u = pe2(u, new b(d2), l2, 1), a2 == null)
  4645. if (Lr(u.d, l2 - _, R, o))
  4646. b.precision = l2 += _, c = s = C = pe2(f2.minus(1), f2.plus(1), l2, 1), h = J2(C.times(C), l2, 1), r = o = 1;
  4647. else
  4648. return J2(u, b.precision = p2, R, ue2 = true);
  4649. else
  4650. return b.precision = p2, u;
  4651. u = c, r += 2;
  4652. }
  4653. }
  4654. function go(i) {
  4655. return String(i.s * i.s / 0);
  4656. }
  4657. function Ts(i, a2) {
  4658. var e, t, r;
  4659. for ((e = a2.indexOf(".")) > -1 && (a2 = a2.replace(".", "")), (t = a2.search(/e/i)) > 0 ? (e < 0 && (e = t), e += +a2.slice(t + 1), a2 = a2.substring(0, t)) : e < 0 && (e = a2.length), t = 0; a2.charCodeAt(t) === 48; t++)
  4660. ;
  4661. for (r = a2.length; a2.charCodeAt(r - 1) === 48; --r)
  4662. ;
  4663. if (a2 = a2.slice(t, r), a2) {
  4664. if (r -= t, i.e = e = e - t - 1, i.d = [], t = (e + 1) % te, e < 0 && (t += te), t < r) {
  4665. for (t && i.d.push(+a2.slice(0, t)), r -= te; t < r; )
  4666. i.d.push(+a2.slice(t, t += te));
  4667. a2 = a2.slice(t), t = te - a2.length;
  4668. } else
  4669. t -= r;
  4670. for (; t--; )
  4671. a2 += "0";
  4672. i.d.push(+a2), ue2 && (i.e > i.constructor.maxE ? (i.d = null, i.e = NaN) : i.e < i.constructor.minE && (i.e = 0, i.d = [0]));
  4673. } else
  4674. i.e = 0, i.d = [0];
  4675. return i;
  4676. }
  4677. function El(i, a2) {
  4678. var e, t, r, n, s, o, u, c, l2;
  4679. if (a2.indexOf("_") > -1) {
  4680. if (a2 = a2.replace(/(\d)_(?=\d)/g, "$1"), lo.test(a2))
  4681. return Ts(i, a2);
  4682. } else if (a2 === "Infinity" || a2 === "NaN")
  4683. return +a2 || (i.s = NaN), i.e = NaN, i.d = null, i;
  4684. if (gl.test(a2))
  4685. e = 16, a2 = a2.toLowerCase();
  4686. else if (ml.test(a2))
  4687. e = 2;
  4688. else if (dl.test(a2))
  4689. e = 8;
  4690. else
  4691. throw Error(Bt + a2);
  4692. for (n = a2.search(/p/i), n > 0 ? (u = +a2.slice(n + 1), a2 = a2.substring(2, n)) : a2 = a2.slice(2), n = a2.indexOf("."), s = n >= 0, t = i.constructor, s && (a2 = a2.replace(".", ""), o = a2.length, n = o - n, r = ho(t, new t(e), n, n * 2)), c = sn(a2, e, ut), l2 = c.length - 1, n = l2; c[n] === 0; --n)
  4693. c.pop();
  4694. return n < 0 ? new t(i.s * 0) : (i.e = vn(c, l2), i.d = c, ue2 = false, s && (i = pe2(i, r, o * 4)), u && (i = i.times(Math.abs(u) < 54 ? Le(2, u) : L2.pow(2, u))), ue2 = true, i);
  4695. }
  4696. function bl(i, a2) {
  4697. var e, t = a2.d.length;
  4698. if (t < 3)
  4699. return a2.isZero() ? a2 : dr(i, 2, a2, a2);
  4700. e = 1.4 * Math.sqrt(t), e = e > 16 ? 16 : e | 0, a2 = a2.times(1 / Tn(5, e)), a2 = dr(i, 2, a2, a2);
  4701. for (var r, n = new i(5), s = new i(16), o = new i(20); e--; )
  4702. r = a2.times(a2), a2 = a2.times(n.plus(r.times(s.times(r).minus(o))));
  4703. return a2;
  4704. }
  4705. function dr(i, a2, e, t, r) {
  4706. var n, s, o, u, c = i.precision, l2 = Math.ceil(c / te);
  4707. for (ue2 = false, u = e.times(e), o = new i(t); ; ) {
  4708. if (s = pe2(o.times(u), new i(a2++ * a2++), c, 1), o = r ? t.plus(s) : t.minus(s), t = pe2(s.times(u), new i(a2++ * a2++), c, 1), s = o.plus(t), s.d[l2] !== void 0) {
  4709. for (n = l2; s.d[n] === o.d[n] && n--; )
  4710. ;
  4711. if (n == -1)
  4712. break;
  4713. }
  4714. n = o, o = t, t = s, s = n;
  4715. }
  4716. return ue2 = true, s.d.length = l2 + 1, s;
  4717. }
  4718. function Tn(i, a2) {
  4719. for (var e = i; --a2; )
  4720. e *= i;
  4721. return e;
  4722. }
  4723. function Co(i, a2) {
  4724. var e, t = a2.s < 0, r = ot2(i, i.precision, 1), n = r.times(0.5);
  4725. if (a2 = a2.abs(), a2.lte(n))
  4726. return Rt = t ? 4 : 1, a2;
  4727. if (e = a2.divToInt(r), e.isZero())
  4728. Rt = t ? 3 : 2;
  4729. else {
  4730. if (a2 = a2.minus(e.times(r)), a2.lte(n))
  4731. return Rt = fi(e) ? t ? 2 : 3 : t ? 4 : 1, a2;
  4732. Rt = fi(e) ? t ? 1 : 4 : t ? 3 : 2;
  4733. }
  4734. return a2.minus(r).abs();
  4735. }
  4736. function ga(i, a2, e, t) {
  4737. var r, n, s, o, u, c, l2, f2, h, d2 = i.constructor, _ = e !== void 0;
  4738. if (_ ? (He(e, 1, $t), t === void 0 ? t = d2.rounding : He(t, 0, 8)) : (e = d2.precision, t = d2.rounding), !i.isFinite())
  4739. l2 = go(i);
  4740. else {
  4741. for (l2 = Ct2(i), s = l2.indexOf("."), _ ? (r = 2, a2 == 16 ? e = e * 4 - 3 : a2 == 8 && (e = e * 3 - 2)) : r = a2, s >= 0 && (l2 = l2.replace(".", ""), h = new d2(1), h.e = l2.length - s, h.d = sn(Ct2(h), 10, r), h.e = h.d.length), f2 = sn(l2, 10, r), n = u = f2.length; f2[--u] == 0; )
  4742. f2.pop();
  4743. if (!f2[0])
  4744. l2 = _ ? "0p+0" : "0";
  4745. else {
  4746. if (s < 0 ? n-- : (i = new d2(i), i.d = f2, i.e = n, i = pe2(i, h, e, t, 0, r), f2 = i.d, n = i.e, c = io), s = f2[e], o = r / 2, c = c || f2[e + 1] !== void 0, c = t < 4 ? (s !== void 0 || c) && (t === 0 || t === (i.s < 0 ? 3 : 2)) : s > o || s === o && (t === 4 || c || t === 6 && f2[e - 1] & 1 || t === (i.s < 0 ? 8 : 7)), f2.length = e, c)
  4747. for (; ++f2[--e] > r - 1; )
  4748. f2[e] = 0, e || (++n, f2.unshift(1));
  4749. for (u = f2.length; !f2[u - 1]; --u)
  4750. ;
  4751. for (s = 0, l2 = ""; s < u; s++)
  4752. l2 += xs.charAt(f2[s]);
  4753. if (_) {
  4754. if (u > 1)
  4755. if (a2 == 16 || a2 == 8) {
  4756. for (s = a2 == 16 ? 4 : 3, --u; u % s; u++)
  4757. l2 += "0";
  4758. for (f2 = sn(l2, r, a2), u = f2.length; !f2[u - 1]; --u)
  4759. ;
  4760. for (s = 1, l2 = "1."; s < u; s++)
  4761. l2 += xs.charAt(f2[s]);
  4762. } else
  4763. l2 = l2.charAt(0) + "." + l2.slice(1);
  4764. l2 = l2 + (n < 0 ? "p" : "p+") + n;
  4765. } else if (n < 0) {
  4766. for (; ++n; )
  4767. l2 = "0" + l2;
  4768. l2 = "0." + l2;
  4769. } else if (++n > u)
  4770. for (n -= u; n--; )
  4771. l2 += "0";
  4772. else
  4773. n < u && (l2 = l2.slice(0, n) + "." + l2.slice(n));
  4774. }
  4775. l2 = (a2 == 16 ? "0x" : a2 == 2 ? "0b" : a2 == 8 ? "0o" : "") + l2;
  4776. }
  4777. return i.s < 0 ? "-" + l2 : l2;
  4778. }
  4779. function hi(i, a2) {
  4780. if (i.length > a2)
  4781. return i.length = a2, true;
  4782. }
  4783. function yl(i) {
  4784. return new this(i).abs();
  4785. }
  4786. function Rl(i) {
  4787. return new this(i).acos();
  4788. }
  4789. function pl(i) {
  4790. return new this(i).acosh();
  4791. }
  4792. function Vl(i, a2) {
  4793. return new this(i).plus(a2);
  4794. }
  4795. function Nl(i) {
  4796. return new this(i).asin();
  4797. }
  4798. function Ol(i) {
  4799. return new this(i).asinh();
  4800. }
  4801. function Ml(i) {
  4802. return new this(i).atan();
  4803. }
  4804. function wl(i) {
  4805. return new this(i).atanh();
  4806. }
  4807. function Dl(i, a2) {
  4808. i = new this(i), a2 = new this(a2);
  4809. var e, t = this.precision, r = this.rounding, n = t + 4;
  4810. return !i.s || !a2.s ? e = new this(NaN) : !i.d && !a2.d ? (e = ot2(this, n, 1).times(a2.s > 0 ? 0.25 : 0.75), e.s = i.s) : !a2.d || i.isZero() ? (e = a2.s < 0 ? ot2(this, t, r) : new this(0), e.s = i.s) : !i.d || a2.isZero() ? (e = ot2(this, n, 1).times(0.5), e.s = i.s) : a2.s < 0 ? (this.precision = n, this.rounding = 1, e = this.atan(pe2(i, a2, n, 1)), a2 = ot2(this, n, 1), this.precision = t, this.rounding = r, e = i.s < 0 ? e.minus(a2) : e.plus(a2)) : e = this.atan(pe2(i, a2, n, 1)), e;
  4811. }
  4812. function Sl(i) {
  4813. return new this(i).cbrt();
  4814. }
  4815. function Pl(i) {
  4816. return J2(i = new this(i), i.e + 1, 2);
  4817. }
  4818. function Ll(i, a2, e) {
  4819. return new this(i).clamp(a2, e);
  4820. }
  4821. function xl(i) {
  4822. if (!i || typeof i != "object")
  4823. throw Error(Un + "Object expected");
  4824. var a2, e, t, r = i.defaults === true, n = [
  4825. "precision",
  4826. 1,
  4827. $t,
  4828. "rounding",
  4829. 0,
  4830. 8,
  4831. "toExpNeg",
  4832. -9e15,
  4833. 0,
  4834. "toExpPos",
  4835. 0,
  4836. Ls,
  4837. "maxE",
  4838. 0,
  4839. Ls,
  4840. "minE",
  4841. -9e15,
  4842. 0,
  4843. "modulo",
  4844. 0,
  4845. 9
  4846. ];
  4847. for (a2 = 0; a2 < n.length; a2 += 3)
  4848. if (e = n[a2], r && (this[e] = js[e]), (t = i[e]) !== void 0)
  4849. if (Be(t) === t && t >= n[a2 + 1] && t <= n[a2 + 2])
  4850. this[e] = t;
  4851. else
  4852. throw Error(Bt + e + ": " + t);
  4853. if (e = "crypto", r && (this[e] = js[e]), (t = i[e]) !== void 0)
  4854. if (t === true || t === false || t === 0 || t === 1)
  4855. if (t)
  4856. if (typeof crypto < "u" && crypto && (crypto.getRandomValues || crypto.randomBytes))
  4857. this[e] = true;
  4858. else
  4859. throw Error(uo);
  4860. else
  4861. this[e] = false;
  4862. else
  4863. throw Error(Bt + e + ": " + t);
  4864. return this;
  4865. }
  4866. function jl(i) {
  4867. return new this(i).cos();
  4868. }
  4869. function Ul(i) {
  4870. return new this(i).cosh();
  4871. }
  4872. function _o(i) {
  4873. var a2, e, t;
  4874. function r(n) {
  4875. var s, o, u, c = this;
  4876. if (!(c instanceof r))
  4877. return new r(n);
  4878. if (c.constructor = r, mi(n)) {
  4879. c.s = n.s, ue2 ? !n.d || n.e > r.maxE ? (c.e = NaN, c.d = null) : n.e < r.minE ? (c.e = 0, c.d = [0]) : (c.e = n.e, c.d = n.d.slice()) : (c.e = n.e, c.d = n.d ? n.d.slice() : n.d);
  4880. return;
  4881. }
  4882. if (u = typeof n, u === "number") {
  4883. if (n === 0) {
  4884. c.s = 1 / n < 0 ? -1 : 1, c.e = 0, c.d = [0];
  4885. return;
  4886. }
  4887. if (n < 0 ? (n = -n, c.s = -1) : c.s = 1, n === ~~n && n < 1e7) {
  4888. for (s = 0, o = n; o >= 10; o /= 10)
  4889. s++;
  4890. ue2 ? s > r.maxE ? (c.e = NaN, c.d = null) : s < r.minE ? (c.e = 0, c.d = [0]) : (c.e = s, c.d = [n]) : (c.e = s, c.d = [n]);
  4891. return;
  4892. } else if (n * 0 !== 0) {
  4893. n || (c.s = NaN), c.e = NaN, c.d = null;
  4894. return;
  4895. }
  4896. return Ts(c, n.toString());
  4897. } else if (u !== "string")
  4898. throw Error(Bt + n);
  4899. return (o = n.charCodeAt(0)) === 45 ? (n = n.slice(1), c.s = -1) : (o === 43 && (n = n.slice(1)), c.s = 1), lo.test(n) ? Ts(c, n) : El(c, n);
  4900. }
  4901. if (r.prototype = B2, r.ROUND_UP = 0, r.ROUND_DOWN = 1, r.ROUND_CEIL = 2, r.ROUND_FLOOR = 3, r.ROUND_HALF_UP = 4, r.ROUND_HALF_DOWN = 5, r.ROUND_HALF_EVEN = 6, r.ROUND_HALF_CEIL = 7, r.ROUND_HALF_FLOOR = 8, r.EUCLID = 9, r.config = r.set = xl, r.clone = _o, r.isDecimal = mi, r.abs = yl, r.acos = Rl, r.acosh = pl, r.add = Vl, r.asin = Nl, r.asinh = Ol, r.atan = Ml, r.atanh = wl, r.atan2 = Dl, r.cbrt = Sl, r.ceil = Pl, r.clamp = Ll, r.cos = jl, r.cosh = Ul, r.div = vl, r.exp = Tl, r.floor = Bl, r.hypot = Il, r.ln = Fl, r.log = kl, r.log10 = Yl, r.log2 = $l, r.max = Hl, r.min = Gl, r.mod = Ql, r.mul = Wl, r.pow = ql, r.random = Kl, r.round = Xl, r.sign = Zl, r.sin = zl, r.sinh = Jl, r.sqrt = ef, r.sub = tf, r.sum = rf, r.tan = nf2, r.tanh = sf, r.trunc = af, i === void 0 && (i = {}), i && i.defaults !== true)
  4902. for (t = ["precision", "rounding", "toExpNeg", "toExpPos", "maxE", "minE", "modulo", "crypto"], a2 = 0; a2 < t.length; )
  4903. i.hasOwnProperty(e = t[a2++]) || (i[e] = this[e]);
  4904. return r.config(i), r;
  4905. }
  4906. function vl(i, a2) {
  4907. return new this(i).div(a2);
  4908. }
  4909. function Tl(i) {
  4910. return new this(i).exp();
  4911. }
  4912. function Bl(i) {
  4913. return J2(i = new this(i), i.e + 1, 3);
  4914. }
  4915. function Il() {
  4916. var i, a2, e = new this(0);
  4917. for (ue2 = false, i = 0; i < arguments.length; )
  4918. if (a2 = new this(arguments[i++]), a2.d)
  4919. e.d && (e = e.plus(a2.times(a2)));
  4920. else {
  4921. if (a2.s)
  4922. return ue2 = true, new this(1 / 0);
  4923. e = a2;
  4924. }
  4925. return ue2 = true, e.sqrt();
  4926. }
  4927. function mi(i) {
  4928. return i instanceof L2 || i && i.toStringTag === co || false;
  4929. }
  4930. function Fl(i) {
  4931. return new this(i).ln();
  4932. }
  4933. function kl(i, a2) {
  4934. return new this(i).log(a2);
  4935. }
  4936. function $l(i) {
  4937. return new this(i).log(2);
  4938. }
  4939. function Yl(i) {
  4940. return new this(i).log(10);
  4941. }
  4942. function Hl() {
  4943. return mo(this, arguments, "lt");
  4944. }
  4945. function Gl() {
  4946. return mo(this, arguments, "gt");
  4947. }
  4948. function Ql(i, a2) {
  4949. return new this(i).mod(a2);
  4950. }
  4951. function Wl(i, a2) {
  4952. return new this(i).mul(a2);
  4953. }
  4954. function ql(i, a2) {
  4955. return new this(i).pow(a2);
  4956. }
  4957. function Kl(i) {
  4958. var a2, e, t, r, n = 0, s = new this(1), o = [];
  4959. if (i === void 0 ? i = this.precision : He(i, 1, $t), t = Math.ceil(i / te), this.crypto)
  4960. if (crypto.getRandomValues)
  4961. for (a2 = crypto.getRandomValues(new Uint32Array(t)); n < t; )
  4962. r = a2[n], r >= 429e7 ? a2[n] = crypto.getRandomValues(new Uint32Array(1))[0] : o[n++] = r % 1e7;
  4963. else if (crypto.randomBytes) {
  4964. for (a2 = crypto.randomBytes(t *= 4); n < t; )
  4965. r = a2[n] + (a2[n + 1] << 8) + (a2[n + 2] << 16) + ((a2[n + 3] & 127) << 24), r >= 214e7 ? crypto.randomBytes(4).copy(a2, n) : (o.push(r % 1e7), n += 4);
  4966. n = t / 4;
  4967. } else
  4968. throw Error(uo);
  4969. else
  4970. for (; n < t; )
  4971. o[n++] = Math.random() * 1e7 | 0;
  4972. for (t = o[--n], i %= te, t && i && (r = Le(10, te - i), o[n] = (t / r | 0) * r); o[n] === 0; n--)
  4973. o.pop();
  4974. if (n < 0)
  4975. e = 0, o = [0];
  4976. else {
  4977. for (e = -1; o[0] === 0; e -= te)
  4978. o.shift();
  4979. for (t = 1, r = o[0]; r >= 10; r /= 10)
  4980. t++;
  4981. t < te && (e -= te - t);
  4982. }
  4983. return s.e = e, s.d = o, s;
  4984. }
  4985. function Xl(i) {
  4986. return J2(i = new this(i), i.e + 1, this.rounding);
  4987. }
  4988. function Zl(i) {
  4989. return i = new this(i), i.d ? i.d[0] ? i.s : 0 * i.s : i.s || NaN;
  4990. }
  4991. function zl(i) {
  4992. return new this(i).sin();
  4993. }
  4994. function Jl(i) {
  4995. return new this(i).sinh();
  4996. }
  4997. function ef(i) {
  4998. return new this(i).sqrt();
  4999. }
  5000. function tf(i, a2) {
  5001. return new this(i).sub(a2);
  5002. }
  5003. function rf() {
  5004. var i = 0, a2 = arguments, e = new this(a2[i]);
  5005. for (ue2 = false; e.s && ++i < a2.length; )
  5006. e = e.plus(a2[i]);
  5007. return ue2 = true, J2(e, this.precision, this.rounding);
  5008. }
  5009. function nf2(i) {
  5010. return new this(i).tan();
  5011. }
  5012. function sf(i) {
  5013. return new this(i).tanh();
  5014. }
  5015. function af(i) {
  5016. return J2(i = new this(i), i.e + 1, 1);
  5017. }
  5018. B2[Symbol.for("nodejs.util.inspect.custom")] = B2.toString;
  5019. B2[Symbol.toStringTag] = "Decimal";
  5020. var L2 = B2.constructor = _o(js);
  5021. mn = new L2(mn);
  5022. gn = new L2(gn);
  5023. function of2(i, a2) {
  5024. const e = i + a2;
  5025. return Number.isSafeInteger(e) ? e : new L2(i).add(a2).toNumber();
  5026. }
  5027. function uf(i, a2) {
  5028. const e = i - a2;
  5029. return Number.isSafeInteger(e) ? e : new L2(i).sub(a2).toNumber();
  5030. }
  5031. function Vr2(i, a2) {
  5032. const e = i * a2;
  5033. return Number.isSafeInteger(e) ? e : new L2(i).mul(a2).toNumber();
  5034. }
  5035. function cf(i, a2) {
  5036. const e = i / a2;
  5037. return Number.isSafeInteger(e) ? e : new L2(i).div(a2).toNumber();
  5038. }
  5039. function vt(i, a2) {
  5040. const e = 10 ** Math.trunc(a2), t = Bn(i, e);
  5041. return Math.round(Vr2(i, e) + t) / e;
  5042. }
  5043. function We(i, a2) {
  5044. const e = 10 ** Math.trunc(a2), t = Bn(i, e);
  5045. return Math.floor(Vr2(i, e) + t) / e;
  5046. }
  5047. function Ye(i, a2) {
  5048. const e = 10 ** Math.trunc(a2), t = Bn(i, e);
  5049. return Math.ceil(Vr2(i, e) - t) / e;
  5050. }
  5051. function Bn(i, a2) {
  5052. return Number.EPSILON * Math.max(1, Math.abs(Vr2(i, a2)));
  5053. }
  5054. function gi(i, a2) {
  5055. return i - a2 * Math.floor(i / a2);
  5056. }
  5057. function lf(i, a2) {
  5058. return i ** a2;
  5059. }
  5060. function ff(i) {
  5061. return Math.sqrt(i);
  5062. }
  5063. function di(i, a2) {
  5064. return i === a2;
  5065. }
  5066. function hf(i, a2) {
  5067. return i > a2;
  5068. }
  5069. function mf(i, a2) {
  5070. return i >= a2;
  5071. }
  5072. function gf(i, a2) {
  5073. return i < a2;
  5074. }
  5075. function df(i, a2) {
  5076. return i <= a2;
  5077. }
  5078. function Ci(i, a2 = 15) {
  5079. return Number.parseFloat(i.toPrecision(a2));
  5080. }
  5081. function Cf(i, a2, e = Number.EPSILON) {
  5082. return Math.abs(i - a2) < e;
  5083. }
  5084. function _f(i, a2 = 12, e = 1e-10) {
  5085. const t = Ci(i, a2);
  5086. return Cf(i, t, e) ? t : Ci(i);
  5087. }
  5088. function Af(i) {
  5089. return i - Math.trunc(i);
  5090. }
  5091. var xn = class xn2 extends kt2 {
  5092. static create() {
  5093. return this._instance = this._instance || new xn2(0), this._instance;
  5094. }
  5095. isNull() {
  5096. return true;
  5097. }
  5098. plus(a2) {
  5099. return y2.create(0).plus(a2);
  5100. }
  5101. minus(a2) {
  5102. return y2.create(0).minus(a2);
  5103. }
  5104. multiply(a2) {
  5105. return y2.create(0).multiply(a2);
  5106. }
  5107. divided(a2) {
  5108. return y2.create(0).divided(a2);
  5109. }
  5110. mod(a2) {
  5111. return y2.create(0).mod(a2);
  5112. }
  5113. compare(a2, e) {
  5114. return a2.isString() ? j.create("").compare(a2, e) : a2.isBoolean() ? T2.create(false).compare(a2, e) : y2.create(0).compare(a2, e);
  5115. }
  5116. concatenateFront(a2) {
  5117. return a2.isArray() ? a2.concatenateBack(j.create("")) : j.create(this.concatenate(a2.getValue(), it.FRONT));
  5118. }
  5119. concatenateBack(a2) {
  5120. return a2.isArray() ? a2.concatenateFront(j.create("")) : j.create(this.concatenate(a2.getValue(), it.BACK));
  5121. }
  5122. plusBy(a2) {
  5123. return y2.create(0).plusBy(a2);
  5124. }
  5125. minusBy(a2) {
  5126. return y2.create(0).minusBy(a2);
  5127. }
  5128. multiplyBy(a2) {
  5129. return y2.create(0).multiplyBy(a2);
  5130. }
  5131. dividedBy(a2) {
  5132. return y2.create(0).dividedBy(a2);
  5133. }
  5134. compareBy(a2, e) {
  5135. return typeof a2 == "string" ? j.create("").compareBy(a2, e) : typeof a2 == "boolean" ? T2.create(false).compareBy(a2, e) : y2.create(0).compareBy(a2, e);
  5136. }
  5137. pow(a2) {
  5138. return y2.create(0).pow(a2);
  5139. }
  5140. sqrt() {
  5141. return y2.create(0).sqrt();
  5142. }
  5143. cbrt() {
  5144. return y2.create(0).cbrt();
  5145. }
  5146. cos() {
  5147. return y2.create(0).cos();
  5148. }
  5149. cosh() {
  5150. return y2.create(0).cosh();
  5151. }
  5152. acos() {
  5153. return y2.create(0).acos();
  5154. }
  5155. acosh() {
  5156. return y2.create(0).acosh();
  5157. }
  5158. sin() {
  5159. return y2.create(0).sin();
  5160. }
  5161. sinh() {
  5162. return y2.create(0).sinh();
  5163. }
  5164. asin() {
  5165. return y2.create(0).asin();
  5166. }
  5167. asinh() {
  5168. return y2.create(0).asinh();
  5169. }
  5170. tan() {
  5171. return y2.create(0).tan();
  5172. }
  5173. tanh() {
  5174. return y2.create(0).tanh();
  5175. }
  5176. atan() {
  5177. return y2.create(0).atan();
  5178. }
  5179. atan2(a2) {
  5180. return y2.create(0).atan2(a2);
  5181. }
  5182. atanh() {
  5183. return y2.create(0).atanh();
  5184. }
  5185. log() {
  5186. return g2.create(m2.NUM);
  5187. }
  5188. log10() {
  5189. return g2.create(m2.NUM);
  5190. }
  5191. exp() {
  5192. return y2.create(0).exp();
  5193. }
  5194. abs() {
  5195. return y2.create(0).abs();
  5196. }
  5197. round(a2) {
  5198. return y2.create(0).round(a2);
  5199. }
  5200. floor(a2) {
  5201. return y2.create(0).floor(a2);
  5202. }
  5203. ceil(a2) {
  5204. return y2.create(0).ceil(a2);
  5205. }
  5206. convertToNumberObjectValue() {
  5207. return y2.create(0);
  5208. }
  5209. convertToBooleanObjectValue() {
  5210. return T2.create(false);
  5211. }
  5212. };
  5213. A(xn, "_instance");
  5214. var ie = xn;
  5215. var qt = class qt2 extends kt2 {
  5216. constructor(e) {
  5217. super(e);
  5218. A(this, "_value", false);
  5219. this._value = e;
  5220. }
  5221. static create(e) {
  5222. return e ? (this._instanceTrue = this._instanceTrue || new qt2(true), this._instanceTrue) : (this._instanceFalse = this._instanceFalse || new qt2(false), this._instanceFalse);
  5223. }
  5224. getValue() {
  5225. return this._value;
  5226. }
  5227. isBoolean() {
  5228. return true;
  5229. }
  5230. getNegative() {
  5231. const e = this.getValue();
  5232. let t = 0;
  5233. return e && (t = 1), y2.create(-t);
  5234. }
  5235. getReciprocal() {
  5236. return this.getValue() ? y2.create(1) : g2.create(m2.DIV_BY_ZERO);
  5237. }
  5238. plus(e) {
  5239. return this._convertToNumber().plus(e);
  5240. }
  5241. minus(e) {
  5242. return this._convertToNumber().minus(e);
  5243. }
  5244. multiply(e) {
  5245. return this._convertToNumber().multiply(e);
  5246. }
  5247. divided(e) {
  5248. return this._convertToNumber().divided(e);
  5249. }
  5250. mod(e) {
  5251. return this._convertToNumber().mod(e);
  5252. }
  5253. compare(e, t) {
  5254. return e.isArray() ? e.compare(this, ma(t)) : e.isNull() ? this._convertToNumber().compare(e, t) : this.compareBy(e.getValue(), t);
  5255. }
  5256. compareBy(e, t) {
  5257. let r = false;
  5258. if (typeof e == "string" || typeof e == "number")
  5259. r = this._compareString(t);
  5260. else if (typeof e == "boolean") {
  5261. const n = y2.create(e ? 1 : 0);
  5262. return this._convertToNumber().compare(n, t);
  5263. }
  5264. return qt2.create(r);
  5265. }
  5266. _compareString(e) {
  5267. switch (e) {
  5268. case $.GREATER_THAN:
  5269. case $.GREATER_THAN_OR_EQUAL:
  5270. return true;
  5271. case $.EQUALS:
  5272. case $.LESS_THAN:
  5273. case $.LESS_THAN_OR_EQUAL:
  5274. case $.NOT_EQUAL:
  5275. return false;
  5276. }
  5277. }
  5278. concatenateFront(e) {
  5279. return this._convertToNumber().concatenateFront(e);
  5280. }
  5281. concatenateBack(e) {
  5282. return this._convertToNumber().concatenateBack(e);
  5283. }
  5284. _convertToNumber() {
  5285. const e = this.getValue();
  5286. let t = 0;
  5287. return e && (t = 1), y2.create(t);
  5288. }
  5289. pow(e) {
  5290. return this._convertToNumber().pow(e);
  5291. }
  5292. sqrt() {
  5293. return this._convertToNumber().sqrt();
  5294. }
  5295. cbrt() {
  5296. return this._convertToNumber().cbrt();
  5297. }
  5298. cos() {
  5299. return this._convertToNumber().cos();
  5300. }
  5301. cosh() {
  5302. return this._convertToNumber().cosh();
  5303. }
  5304. acos() {
  5305. return this._convertToNumber().acos();
  5306. }
  5307. acosh() {
  5308. return this._convertToNumber().acosh();
  5309. }
  5310. sin() {
  5311. return this._convertToNumber().sin();
  5312. }
  5313. sinh() {
  5314. return this._convertToNumber().sinh();
  5315. }
  5316. asin() {
  5317. return this._convertToNumber().asin();
  5318. }
  5319. asinh() {
  5320. return this._convertToNumber().asinh();
  5321. }
  5322. tan() {
  5323. return this._convertToNumber().tan();
  5324. }
  5325. tanh() {
  5326. return this._convertToNumber().tanh();
  5327. }
  5328. atan() {
  5329. return this._convertToNumber().atan();
  5330. }
  5331. atan2(e) {
  5332. return this._convertToNumber().atan2(e);
  5333. }
  5334. atanh() {
  5335. return this._convertToNumber().atanh();
  5336. }
  5337. log() {
  5338. return this._convertToNumber().log();
  5339. }
  5340. log10() {
  5341. return this._convertToNumber().log10();
  5342. }
  5343. exp() {
  5344. return this._convertToNumber().exp();
  5345. }
  5346. abs() {
  5347. return this._convertToNumber().abs();
  5348. }
  5349. round(e) {
  5350. return this._convertToNumber().round(e);
  5351. }
  5352. floor(e) {
  5353. return this._convertToNumber().floor(e);
  5354. }
  5355. ceil(e) {
  5356. return this._convertToNumber().ceil(e);
  5357. }
  5358. convertToNumberObjectValue() {
  5359. return Fn(this.getValue());
  5360. }
  5361. convertToBooleanObjectValue() {
  5362. return this;
  5363. }
  5364. };
  5365. A(qt, "_instanceTrue"), A(qt, "_instanceFalse");
  5366. var T2 = qt;
  5367. var y2 = class _y extends kt2 {
  5368. constructor(e) {
  5369. super(e);
  5370. A(this, "_value", 0);
  5371. this._value = Number(e);
  5372. }
  5373. static create(e, t = "") {
  5374. const r = new _y(e);
  5375. return t && r.setPattern(t), r;
  5376. }
  5377. getValue() {
  5378. return this._value;
  5379. }
  5380. setValue(e) {
  5381. this._value = e;
  5382. }
  5383. isNumber() {
  5384. return true;
  5385. }
  5386. getNegative() {
  5387. return _y.create(0).minus(this);
  5388. }
  5389. getReciprocal() {
  5390. return _y.create(1).divided(this);
  5391. }
  5392. plus(e) {
  5393. if (e.isArray())
  5394. return e.plus(this);
  5395. let t = this.plusBy(e.getValue());
  5396. if (t.isError())
  5397. return t;
  5398. const r = Wr(this.getPattern(), e.getPattern(), X2.PLUS);
  5399. return t = _y.create(Number(t.getValue()), r), t;
  5400. }
  5401. equalZero() {
  5402. return this._value === 0;
  5403. }
  5404. minus(e) {
  5405. if (e.isArray()) {
  5406. const n = e.getNegative();
  5407. return n.isError() ? n : n.plus(this);
  5408. }
  5409. let t = this.minusBy(e.getValue());
  5410. if (t.isError())
  5411. return t;
  5412. const r = Wr(this.getPattern(), e.getPattern(), X2.MINUS);
  5413. return t = _y.create(Number(t.getValue()), r), t;
  5414. }
  5415. multiply(e) {
  5416. if (e.isArray())
  5417. return e.multiply(this);
  5418. let t = this.multiplyBy(e.getValue());
  5419. if (t.isError())
  5420. return t;
  5421. const r = Wr(this.getPattern(), e.getPattern(), X2.MULTIPLY);
  5422. return t = _y.create(Number(t.getValue()), r), t;
  5423. }
  5424. divided(e) {
  5425. if (e.isArray()) {
  5426. const n = e.getReciprocal();
  5427. return n.isError() ? n : n.multiply(this);
  5428. }
  5429. let t = this.dividedBy(e.getValue());
  5430. if (t.isError())
  5431. return t;
  5432. const r = Wr(this.getPattern(), e.getPattern(), X2.DIVIDED);
  5433. return t = _y.create(Number(t.getValue()), r), t;
  5434. }
  5435. mod(e) {
  5436. if (e.isArray())
  5437. return e.modInverse(this);
  5438. const t = this.getValue(), r = e.getValue();
  5439. if (e.isNull())
  5440. return g2.create(m2.DIV_BY_ZERO);
  5441. if (typeof r == "string")
  5442. return g2.create(m2.VALUE);
  5443. if (typeof r == "number") {
  5444. if (r === 0)
  5445. return g2.create(m2.DIV_BY_ZERO);
  5446. if (!Number.isFinite(t) || !Number.isFinite(r) || Math.abs(r) * 11259e8 <= Math.abs(t))
  5447. return g2.create(m2.NUM);
  5448. const n = gi(t, r);
  5449. return Number.isFinite(n) ? _y.create(n) : g2.create(m2.NUM);
  5450. }
  5451. if (typeof r == "boolean") {
  5452. const n = r ? 1 : 0;
  5453. return n === 0 ? g2.create(m2.DIV_BY_ZERO) : _y.create(gi(t, n));
  5454. }
  5455. return this;
  5456. }
  5457. concatenateFront(e) {
  5458. return e.isArray() ? e.concatenateBack(this) : j.create(this.concatenate(e.getValue(), it.FRONT));
  5459. }
  5460. concatenateBack(e) {
  5461. return e.isArray() ? e.concatenateFront(this) : j.create(this.concatenate(e.getValue(), it.BACK));
  5462. }
  5463. compare(e, t) {
  5464. return e.isArray() ? e.compare(this, ma(t)) : this.compareBy(e.getValue(), t);
  5465. }
  5466. plusBy(e) {
  5467. const t = +this.getValue(), r = +e;
  5468. if (Number.isNaN(t) || Number.isNaN(r))
  5469. return g2.create(m2.VALUE);
  5470. if (!Number.isFinite(t) || !Number.isFinite(r))
  5471. return g2.create(m2.NUM);
  5472. const n = of2(t, r);
  5473. return Number.isFinite(n) ? _y.create(n) : g2.create(m2.NUM);
  5474. }
  5475. minusBy(e) {
  5476. const t = +this.getValue(), r = +e;
  5477. if (Number.isNaN(t) || Number.isNaN(r))
  5478. return g2.create(m2.VALUE);
  5479. if (!Number.isFinite(t) || !Number.isFinite(r))
  5480. return g2.create(m2.NUM);
  5481. const n = uf(t, r);
  5482. return Number.isFinite(n) ? _y.create(n) : g2.create(m2.NUM);
  5483. }
  5484. multiplyBy(e) {
  5485. const t = +this.getValue(), r = +e;
  5486. if (Number.isNaN(t) || Number.isNaN(r))
  5487. return g2.create(m2.VALUE);
  5488. if (!Number.isFinite(t) || !Number.isFinite(r))
  5489. return g2.create(m2.NUM);
  5490. const n = Vr2(t, r);
  5491. return Number.isFinite(n) ? _y.create(n) : g2.create(m2.NUM);
  5492. }
  5493. dividedBy(e) {
  5494. const t = +this.getValue(), r = +e;
  5495. if (Number.isNaN(t) || Number.isNaN(r))
  5496. return g2.create(m2.VALUE);
  5497. if (!Number.isFinite(t) || !Number.isFinite(r))
  5498. return g2.create(m2.NUM);
  5499. if (r === 0)
  5500. return g2.create(m2.DIV_BY_ZERO);
  5501. const n = cf(t, r);
  5502. return Number.isFinite(n) ? _y.create(n) : g2.create(m2.NUM);
  5503. }
  5504. compareBy(e, t) {
  5505. const r = this.getValue();
  5506. let n = false;
  5507. return typeof e == "string" ? n = this._compareString(t) : typeof e == "number" ? n = this._compareNumber(r, e, t) : typeof e == "boolean" && (n = this._compareBoolean(t)), T2.create(n);
  5508. }
  5509. _compareString(e) {
  5510. switch (e) {
  5511. case $.EQUALS:
  5512. case $.GREATER_THAN:
  5513. case $.GREATER_THAN_OR_EQUAL:
  5514. return false;
  5515. case $.LESS_THAN:
  5516. case $.LESS_THAN_OR_EQUAL:
  5517. case $.NOT_EQUAL:
  5518. return true;
  5519. }
  5520. }
  5521. _compareNumber(e, t, r) {
  5522. return !Number.isFinite(e) || !Number.isFinite(t) ? this._compareInfinity(e, t, r) : this._compareFiniteNumber(e, t, r);
  5523. }
  5524. _compareFiniteNumber(e, t, r) {
  5525. switch (r) {
  5526. case $.EQUALS:
  5527. return di(e, t);
  5528. case $.GREATER_THAN:
  5529. return hf(e, t);
  5530. case $.GREATER_THAN_OR_EQUAL:
  5531. return mf(e, t);
  5532. case $.LESS_THAN:
  5533. return gf(e, t);
  5534. case $.LESS_THAN_OR_EQUAL:
  5535. return df(e, t);
  5536. case $.NOT_EQUAL:
  5537. return !di(e, t);
  5538. }
  5539. }
  5540. _compareBoolean(e) {
  5541. switch (e) {
  5542. case $.EQUALS:
  5543. case $.GREATER_THAN:
  5544. case $.GREATER_THAN_OR_EQUAL:
  5545. return false;
  5546. case $.LESS_THAN:
  5547. case $.LESS_THAN_OR_EQUAL:
  5548. case $.NOT_EQUAL:
  5549. return true;
  5550. }
  5551. }
  5552. pow(e) {
  5553. if (e.isArray())
  5554. return e.powInverse(this);
  5555. if (this.isError())
  5556. return this;
  5557. const t = this.getValue();
  5558. let r = e;
  5559. if (e.isString() && (r = e.convertToNumberObjectValue()), r.isError())
  5560. return r;
  5561. const n = +r.getValue();
  5562. if (Number.isNaN(n))
  5563. return g2.create(m2.VALUE);
  5564. if (!Number.isFinite(t) || !Number.isFinite(n))
  5565. return g2.create(m2.NUM);
  5566. if (t === 0)
  5567. return n < 0 ? g2.create(m2.DIV_BY_ZERO) : n === 0 ? g2.create(m2.NUM) : _y.create(0);
  5568. const s = lf(t, n);
  5569. return Number.isFinite(s) ? _y.create(s) : g2.create(m2.NUM);
  5570. }
  5571. sqrt() {
  5572. const e = this.getValue();
  5573. if (!Number.isFinite(e))
  5574. return g2.create(m2.NUM);
  5575. const t = ff(e);
  5576. return Number.isFinite(t) ? _y.create(t) : g2.create(m2.NUM);
  5577. }
  5578. cbrt() {
  5579. const e = this.getValue();
  5580. if (!Number.isFinite(e))
  5581. return g2.create(m2.NUM);
  5582. const t = Math.cbrt(e);
  5583. return Number.isFinite(t) ? _y.create(t) : g2.create(m2.NUM);
  5584. }
  5585. cos() {
  5586. const e = this.getValue();
  5587. if (!Number.isFinite(e))
  5588. return g2.create(m2.NUM);
  5589. const t = Math.cos(e);
  5590. return Number.isFinite(t) ? _y.create(t) : g2.create(m2.NUM);
  5591. }
  5592. cosh() {
  5593. const e = this.getValue();
  5594. if (!Number.isFinite(e))
  5595. return g2.create(m2.NUM);
  5596. const t = Math.cosh(e);
  5597. return Number.isFinite(t) ? _y.create(t) : g2.create(m2.NUM);
  5598. }
  5599. acos() {
  5600. const e = this.getValue();
  5601. if (!Number.isFinite(e))
  5602. return g2.create(m2.NUM);
  5603. const t = Math.acos(e);
  5604. return Number.isNaN(t) ? g2.create(m2.NUM) : _y.create(t);
  5605. }
  5606. acosh() {
  5607. const e = this.getValue();
  5608. if (!Number.isFinite(e))
  5609. return g2.create(m2.NUM);
  5610. const t = Math.acosh(e);
  5611. return Number.isNaN(t) ? g2.create(m2.NUM) : _y.create(t);
  5612. }
  5613. sin() {
  5614. const e = this.getValue();
  5615. if (!Number.isFinite(e))
  5616. return g2.create(m2.NUM);
  5617. const t = Math.sin(e);
  5618. return Number.isFinite(t) ? _y.create(t) : g2.create(m2.NUM);
  5619. }
  5620. sinh() {
  5621. const e = this.getValue();
  5622. if (!Number.isFinite(e))
  5623. return g2.create(m2.NUM);
  5624. const t = Math.sinh(e);
  5625. return Number.isFinite(t) ? _y.create(t) : g2.create(m2.NUM);
  5626. }
  5627. asin() {
  5628. const e = this.getValue();
  5629. if (!Number.isFinite(e))
  5630. return g2.create(m2.NUM);
  5631. const t = Math.asin(e);
  5632. return Number.isNaN(t) ? g2.create(m2.NUM) : _y.create(t);
  5633. }
  5634. asinh() {
  5635. const e = this.getValue();
  5636. if (!Number.isFinite(e))
  5637. return g2.create(m2.NUM);
  5638. const t = Math.asinh(e);
  5639. return Number.isNaN(t) ? g2.create(m2.NUM) : _y.create(t);
  5640. }
  5641. tan() {
  5642. const e = this.getValue();
  5643. if (!Number.isFinite(e))
  5644. return g2.create(m2.NUM);
  5645. const t = Math.tan(e);
  5646. return Number.isFinite(t) ? _y.create(t) : g2.create(m2.NUM);
  5647. }
  5648. tanh() {
  5649. const e = this.getValue();
  5650. if (!Number.isFinite(e))
  5651. return g2.create(m2.NUM);
  5652. const t = Math.tanh(e);
  5653. return Number.isFinite(t) ? _y.create(t) : g2.create(m2.NUM);
  5654. }
  5655. atan() {
  5656. const e = this.getValue();
  5657. if (!Number.isFinite(e))
  5658. return g2.create(m2.NUM);
  5659. const t = Math.atan(e);
  5660. return Number.isFinite(t) ? _y.create(t) : g2.create(m2.NUM);
  5661. }
  5662. atan2(e) {
  5663. if (e.isArray())
  5664. return e.atan2Inverse(this);
  5665. const t = this.getValue(), r = e.getValue();
  5666. if (typeof r == "string")
  5667. return g2.create(m2.VALUE);
  5668. if (typeof r == "number") {
  5669. if (!Number.isFinite(t) || !Number.isFinite(r))
  5670. return g2.create(m2.NUM);
  5671. if (t === 0 && r === 0)
  5672. return g2.create(m2.DIV_BY_ZERO);
  5673. const n = Math.atan2(t, r);
  5674. return Number.isFinite(n) ? _y.create(n) : g2.create(m2.NUM);
  5675. }
  5676. return typeof r == "boolean" ? _y.create(Math.atan2(t, r ? 1 : 0)) : this;
  5677. }
  5678. atanh() {
  5679. const e = this.getValue();
  5680. if (!Number.isFinite(e))
  5681. return g2.create(m2.NUM);
  5682. const t = Math.atanh(e);
  5683. return Number.isFinite(t) ? _y.create(t) : g2.create(m2.NUM);
  5684. }
  5685. log() {
  5686. const e = this.getValue();
  5687. if (typeof e == "number" && e <= 0 || !Number.isFinite(e))
  5688. return g2.create(m2.NUM);
  5689. const t = Math.log(e);
  5690. return Number.isFinite(t) ? _y.create(t) : g2.create(m2.NUM);
  5691. }
  5692. log10() {
  5693. const e = this.getValue();
  5694. if (typeof e == "number" && e <= 0 || !Number.isFinite(e))
  5695. return g2.create(m2.NUM);
  5696. const t = Math.log10(e);
  5697. return Number.isFinite(t) ? _y.create(t) : g2.create(m2.NUM);
  5698. }
  5699. exp() {
  5700. const e = this.getValue();
  5701. if (!Number.isFinite(e))
  5702. return g2.create(m2.NUM);
  5703. const t = Math.exp(e);
  5704. return Number.isFinite(t) ? _y.create(t) : g2.create(m2.NUM);
  5705. }
  5706. abs() {
  5707. const e = this.getValue();
  5708. if (!Number.isFinite(e))
  5709. return g2.create(m2.NUM);
  5710. const t = Math.abs(e);
  5711. return Number.isFinite(t) ? _y.create(t) : g2.create(m2.NUM);
  5712. }
  5713. round(e) {
  5714. if (e.isArray())
  5715. return e.roundInverse(this);
  5716. const t = this.getValue(), r = e.getValue();
  5717. if (typeof r == "string")
  5718. return g2.create(m2.VALUE);
  5719. if (typeof r == "number") {
  5720. if (!Number.isFinite(t) || !Number.isFinite(r))
  5721. return g2.create(m2.NUM);
  5722. const n = t < 0 ? -vt(Math.abs(t), r) : vt(t, r);
  5723. return Number.isFinite(n) ? _y.create(n) : g2.create(m2.NUM);
  5724. }
  5725. return typeof r == "boolean" ? _y.create(vt(t, r ? 1 : 0)) : this;
  5726. }
  5727. floor(e) {
  5728. if (e.isArray())
  5729. return e.floorInverse(this);
  5730. const t = this.getValue(), r = e.getValue();
  5731. if (typeof r == "string")
  5732. return g2.create(m2.VALUE);
  5733. if (typeof r == "number") {
  5734. if (!Number.isFinite(t) || !Number.isFinite(r))
  5735. return g2.create(m2.NUM);
  5736. const n = t < 0 ? -We(Math.abs(t), r) : We(t, r);
  5737. return Number.isFinite(n) ? _y.create(n) : g2.create(m2.NUM);
  5738. }
  5739. return typeof r == "boolean" ? _y.create(We(t, r ? 1 : 0)) : this;
  5740. }
  5741. ceil(e) {
  5742. if (e.isArray())
  5743. return e.ceilInverse(this);
  5744. const t = this.getValue(), r = e.getValue();
  5745. if (typeof r == "string")
  5746. return g2.create(m2.VALUE);
  5747. if (typeof r == "number") {
  5748. if (!Number.isFinite(t) || !Number.isFinite(r))
  5749. return g2.create(m2.NUM);
  5750. const n = t < 0 ? -Ye(Math.abs(t), r) : Ye(t, r);
  5751. return Number.isFinite(n) ? _y.create(n) : g2.create(m2.NUM);
  5752. }
  5753. return typeof r == "boolean" ? _y.create(Ye(t, r ? 1 : 0)) : this;
  5754. }
  5755. convertToNumberObjectValue() {
  5756. return this;
  5757. }
  5758. convertToBooleanObjectValue() {
  5759. return In(true);
  5760. }
  5761. _compareInfinity(e, t, r) {
  5762. let n = false;
  5763. switch (r) {
  5764. case $.EQUALS:
  5765. n = e === t;
  5766. break;
  5767. case $.GREATER_THAN:
  5768. n = e > t;
  5769. break;
  5770. case $.GREATER_THAN_OR_EQUAL:
  5771. n = e >= t;
  5772. break;
  5773. case $.LESS_THAN:
  5774. n = e < t;
  5775. break;
  5776. case $.LESS_THAN_OR_EQUAL:
  5777. n = e <= t;
  5778. break;
  5779. case $.NOT_EQUAL:
  5780. n = e !== t;
  5781. break;
  5782. }
  5783. return n;
  5784. }
  5785. };
  5786. var Ef = 1e5;
  5787. var _i = new Vt(Ef);
  5788. var j = class _j extends kt2 {
  5789. constructor(e) {
  5790. super(e);
  5791. A(this, "_value");
  5792. this._value = e;
  5793. }
  5794. static create(e) {
  5795. const t = _i.get(e);
  5796. if (t)
  5797. return t;
  5798. const r = new _j(e);
  5799. return _i.set(e, r), r;
  5800. }
  5801. getValue() {
  5802. return this._value;
  5803. }
  5804. isString() {
  5805. return true;
  5806. }
  5807. concatenateFront(e) {
  5808. return e.isArray() ? e.concatenateBack(this) : _j.create(this.concatenate(e.getValue(), it.FRONT));
  5809. }
  5810. concatenateBack(e) {
  5811. return e.isArray() ? e.concatenateFront(this) : _j.create(this.concatenate(e.getValue(), it.BACK));
  5812. }
  5813. plus(e) {
  5814. return this.convertToNumberObjectValue().plus(e);
  5815. }
  5816. minus(e) {
  5817. return this.convertToNumberObjectValue().minus(e);
  5818. }
  5819. multiply(e) {
  5820. return this.convertToNumberObjectValue().multiply(e);
  5821. }
  5822. divided(e) {
  5823. return this.convertToNumberObjectValue().divided(e);
  5824. }
  5825. compare(e, t, r) {
  5826. return e.isArray() ? e.compare(this, ma(t), r) : this.compareBy(e.getValue(), t, r);
  5827. }
  5828. compareBy(e, t, r = false) {
  5829. let n = this.getValue(), s = false;
  5830. if (typeof e == "string") {
  5831. let o = e;
  5832. if (r || (n = n.toLocaleLowerCase(), o = o.toLocaleLowerCase()), ll(o))
  5833. return this._checkWildcard(o, t);
  5834. s = this._compareString(n, o, t);
  5835. } else
  5836. typeof e == "number" ? s = this._compareNumber(t) : typeof e == "boolean" && (s = this._compareBoolean(t));
  5837. return T2.create(s);
  5838. }
  5839. _compareString(e, t, r) {
  5840. switch (r) {
  5841. case $.EQUALS:
  5842. return e === t;
  5843. case $.GREATER_THAN:
  5844. return e > t;
  5845. case $.GREATER_THAN_OR_EQUAL:
  5846. return e >= t;
  5847. case $.LESS_THAN:
  5848. return e < t;
  5849. case $.LESS_THAN_OR_EQUAL:
  5850. return e <= t;
  5851. case $.NOT_EQUAL:
  5852. return e !== t;
  5853. }
  5854. }
  5855. _compareNumber(e) {
  5856. switch (e) {
  5857. case $.NOT_EQUAL:
  5858. case $.GREATER_THAN:
  5859. case $.GREATER_THAN_OR_EQUAL:
  5860. return true;
  5861. case $.EQUALS:
  5862. case $.LESS_THAN:
  5863. case $.LESS_THAN_OR_EQUAL:
  5864. return false;
  5865. }
  5866. }
  5867. _compareBoolean(e) {
  5868. switch (e) {
  5869. case $.EQUALS:
  5870. case $.GREATER_THAN:
  5871. case $.GREATER_THAN_OR_EQUAL:
  5872. return false;
  5873. case $.LESS_THAN:
  5874. case $.LESS_THAN_OR_EQUAL:
  5875. case $.NOT_EQUAL:
  5876. return true;
  5877. }
  5878. }
  5879. convertToNumberObjectValue() {
  5880. return Fn(this.getValue());
  5881. }
  5882. convertToBooleanObjectValue() {
  5883. return T2.create(true);
  5884. }
  5885. _checkWildcard(e, t) {
  5886. const r = this.getValue().toLocaleLowerCase(), n = fl(r, e, t);
  5887. return T2.create(n);
  5888. }
  5889. };
  5890. function In(i) {
  5891. if (typeof i == "boolean")
  5892. return T2.create(i);
  5893. let a2 = false;
  5894. if (typeof i == "string") {
  5895. const e = i.toLocaleUpperCase();
  5896. e === er.TRUE ? a2 = true : e === er.FALSE && (a2 = false);
  5897. } else
  5898. i === 1 ? a2 = true : a2 = false;
  5899. return T2.create(a2);
  5900. }
  5901. function bf(i) {
  5902. let a2 = i.toString();
  5903. return a2.charAt(0) === '"' && a2.charAt(a2.length - 1) === '"' && (a2 = a2.slice(1, -1), a2 = a2.replace(/""/g, '"')), j.create(a2);
  5904. }
  5905. function Fn(i, a2 = "") {
  5906. if (typeof i == "boolean") {
  5907. let e = 0;
  5908. return i && (e = 1), y2.create(e, a2);
  5909. } else {
  5910. if (typeof i == "number")
  5911. return Number.isFinite(i) ? y2.create(i, a2) : g2.create(m2.NUM);
  5912. if (DC(i))
  5913. return y2.create(Number(i), a2);
  5914. }
  5915. return g2.create(m2.VALUE);
  5916. }
  5917. function yf(i) {
  5918. return "";
  5919. }
  5920. function Ao(i = []) {
  5921. const a2 = [];
  5922. for (let e = 0; e < i.length; e++) {
  5923. const t = i[e];
  5924. a2[e] == null && (a2[e] = []);
  5925. for (let r = 0; r < t.length; r++) {
  5926. const n = t[r];
  5927. a2[e][r] = pt.create(n);
  5928. }
  5929. }
  5930. return a2;
  5931. }
  5932. function Rf(i = []) {
  5933. const a2 = [];
  5934. for (let e = 0; e < i.length; e++) {
  5935. const t = i[e];
  5936. a2[e] == null && (a2[e] = []);
  5937. for (let r = 0; r < t.length; r++) {
  5938. const n = t[r];
  5939. n == null ? a2[e][r] = null : n.isError() ? a2[e][r] = n.getErrorType() : a2[e][r] = n.getValue();
  5940. }
  5941. }
  5942. return a2;
  5943. }
  5944. var q2 = class _q extends kt2 {
  5945. constructor(e) {
  5946. super(typeof e == "string" ? e : yf());
  5947. A(this, "_values", []);
  5948. A(this, "_rowCount", -1);
  5949. A(this, "_columnCount", -1);
  5950. A(this, "_unitId", "");
  5951. A(this, "_sheetId", "");
  5952. A(this, "_currentRow", -1);
  5953. A(this, "_currentColumn", -1);
  5954. A(this, "_sliceCache", /* @__PURE__ */ new Map());
  5955. A(this, "_flattenCache");
  5956. A(this, "_defaultValue", null);
  5957. A(this, "_flattenPosition");
  5958. this._values = this._formatValue(e);
  5959. }
  5960. /**
  5961. * Create an array value object based on the string or IArrayValueObject data.
  5962. * @param rawValue
  5963. * @returns
  5964. */
  5965. static create(e) {
  5966. return new _q(e);
  5967. }
  5968. /**
  5969. * Create an array value object based on the array data.
  5970. * @param array
  5971. * @returns
  5972. */
  5973. static createByArray(e) {
  5974. const r = {
  5975. calculateValueList: Ao(e),
  5976. rowCount: e.length,
  5977. columnCount: e[0].length || 0,
  5978. unitId: "",
  5979. sheetId: "",
  5980. row: -1,
  5981. column: -1
  5982. };
  5983. return new _q(r);
  5984. }
  5985. dispose() {
  5986. this._values = [], this._defaultValue = null, this._flattenPosition = null, this._clearCache();
  5987. }
  5988. clone() {
  5989. return this.map((e) => e);
  5990. }
  5991. getRowCount() {
  5992. return this._rowCount;
  5993. }
  5994. setRowCount(e) {
  5995. this._rowCount = e;
  5996. }
  5997. getColumnCount() {
  5998. return this._columnCount;
  5999. }
  6000. setColumnCount(e) {
  6001. this._columnCount = e;
  6002. }
  6003. setCurrent(e, t) {
  6004. this._currentRow = e, this._currentColumn = t;
  6005. }
  6006. setUnitId(e) {
  6007. this._unitId = e;
  6008. }
  6009. getUnitId() {
  6010. return this._unitId;
  6011. }
  6012. setSheetId(e) {
  6013. this._sheetId = e;
  6014. }
  6015. getSheetId() {
  6016. return this._sheetId;
  6017. }
  6018. getCurrentRow() {
  6019. return this._currentRow;
  6020. }
  6021. getCurrentColumn() {
  6022. return this._currentColumn;
  6023. }
  6024. getArrayValue() {
  6025. return this._values;
  6026. }
  6027. setArrayValue(e) {
  6028. this._clearCache(), this._values = e;
  6029. }
  6030. isArray() {
  6031. return true;
  6032. }
  6033. setDefaultValue(e) {
  6034. this._defaultValue = e;
  6035. }
  6036. get(e, t) {
  6037. var r;
  6038. return ((r = this._values[e]) == null ? void 0 : r[t]) || this._defaultValue;
  6039. }
  6040. getRealValue(e, t) {
  6041. const r = this._values[e];
  6042. if (r == null)
  6043. return null;
  6044. const n = r[t];
  6045. return n == null ? null : n;
  6046. }
  6047. getValueOrDefault(e, t) {
  6048. return this.get(e, t) || this._defaultValue;
  6049. }
  6050. set(e, t, r) {
  6051. if (e >= this._rowCount || t >= this._columnCount)
  6052. throw new Error("Exceeding array bounds.");
  6053. this._clearCache(), this._values[e][t] = r;
  6054. }
  6055. getRangePosition() {
  6056. const t = this.getRowCount(), r = 0, n = this.getColumnCount();
  6057. return {
  6058. startRow: 0,
  6059. endRow: t - 1,
  6060. startColumn: r,
  6061. endColumn: n - 1
  6062. };
  6063. }
  6064. iterator(e) {
  6065. var u;
  6066. const { startRow: t, endRow: r, startColumn: n, endColumn: s } = this.getRangePosition(), o = this.getArrayValue();
  6067. for (let c = t; c <= r; c++)
  6068. for (let l2 = n; l2 <= s; l2++)
  6069. if (e(((u = o[c]) == null ? void 0 : u[l2]) || this._defaultValue, c, l2) === false)
  6070. return;
  6071. }
  6072. iteratorReverse(e) {
  6073. var u;
  6074. const { startRow: t, endRow: r, startColumn: n, endColumn: s } = this.getRangePosition(), o = this.getArrayValue();
  6075. for (let c = r; c >= t; c--)
  6076. for (let l2 = s; l2 >= n; l2--)
  6077. if (e(((u = o[c]) == null ? void 0 : u[l2]) || this._defaultValue, c, l2) === false)
  6078. return;
  6079. }
  6080. getLastTruePosition() {
  6081. let e;
  6082. return this.iteratorReverse((t, r, n) => {
  6083. if (t != null && t.isBoolean() && t.getValue() === true)
  6084. return e = {
  6085. row: r,
  6086. column: n
  6087. }, false;
  6088. }), e;
  6089. }
  6090. getFirstTruePosition() {
  6091. let e;
  6092. return this.iterator((t, r, n) => {
  6093. if (t != null && t.isBoolean() && t.getValue() === true)
  6094. return e = {
  6095. row: r,
  6096. column: n
  6097. }, false;
  6098. }), e;
  6099. }
  6100. getFirstCell() {
  6101. const { startRow: e, startColumn: t } = this.getRangePosition();
  6102. return this.get(e, t) || this._defaultValue || ie.create();
  6103. }
  6104. getLastCell() {
  6105. const { endRow: e, endColumn: t } = this.getRangePosition();
  6106. return this.get(e, t) || this._defaultValue || ie.create();
  6107. }
  6108. /**
  6109. * Referring to matrix calculations,
  6110. * extract the matching values from a true/false matrix based on parameters and store them in a two-dimensional array.
  6111. * implement x[x<10]
  6112. * https://numpy.org/doc/stable/user/basics.indexing.html
  6113. * @param takeArray
  6114. */
  6115. pick(e) {
  6116. const t = this.pickRaw(e);
  6117. return this._createNewArray(t, 1, t[0].length);
  6118. }
  6119. pickRaw(e) {
  6120. const t = e.getRowCount(), r = e.getColumnCount();
  6121. if (t !== this._rowCount || r !== this._columnCount)
  6122. return [[ie.create()]];
  6123. const n = [];
  6124. n[0] = [];
  6125. for (let s = 0; s < t; s++)
  6126. for (let o = 0; o < r; o++) {
  6127. const u = e.get(s, o);
  6128. if (!(u == null || u.isError()) && u.getValue() === true) {
  6129. const c = this.get(s, o);
  6130. n[0].push(c);
  6131. }
  6132. }
  6133. return n;
  6134. }
  6135. /**
  6136. * Flatten a 2D array.
  6137. * https://numpy.org/doc/stable/reference/generated/numpy.chararray.flatten.html#numpy.chararray.flatten
  6138. */
  6139. flatten() {
  6140. if (this._flattenCache != null)
  6141. return this._flattenCache;
  6142. const e = [];
  6143. e[0] = [];
  6144. for (let r = 0; r < this._rowCount; r++)
  6145. for (let n = 0; n < this._columnCount; n++) {
  6146. const s = this.get(r, n);
  6147. e[0].push(s);
  6148. }
  6149. const t = this._createNewArray(e, 1, e[0].length);
  6150. return t.setDefaultValue(this._defaultValue), this._flattenCache = t, t;
  6151. }
  6152. /**
  6153. * Flatten a 2D array.
  6154. * In Excel, errors and blank cells are ignored, which results in a binary search that cannot strictly adhere to the number of cells.
  6155. */
  6156. flattenPosition() {
  6157. if (this._flattenPosition != null)
  6158. return this._flattenPosition;
  6159. const e = [], t = [], r = [], n = [];
  6160. let s = 0;
  6161. for (let u = 0; u < this._rowCount; u++)
  6162. for (let c = 0; c < this._columnCount; c++) {
  6163. const l2 = this.get(u, c);
  6164. if (l2 == null || l2.isError() || l2.isNull()) {
  6165. s++;
  6166. continue;
  6167. }
  6168. l2.isString() ? (e.push(l2), r.push(s++)) : (t.push(l2), n.push(s++));
  6169. }
  6170. const o = {
  6171. stringArray: e,
  6172. numberArray: t,
  6173. stringPosition: r,
  6174. numberPosition: n
  6175. };
  6176. return this._flattenPosition = o, o;
  6177. }
  6178. /**
  6179. * I'm looking to perform slicing operations on 2D arrays, similar to the functionality provided by NumPy.
  6180. * https://numpy.org/doc/stable/user/basics.indexing.html
  6181. * @rowParam start:stop:step
  6182. * @columnParam start:stop:step
  6183. * @param takeArray
  6184. */
  6185. slice(e, t) {
  6186. let r = 0, n = this._rowCount, s = 1, o = 0, u = this._columnCount, c = 1;
  6187. if (e != null && (r = e[0] || 0, n = e[1] || this._rowCount, s = e[2] || 1), t != null && (o = t[0] || 0, u = t[1] || this._columnCount, c = t[2] || 1), r >= this._rowCount || o >= this._columnCount)
  6188. return;
  6189. const l2 = `${r}_${n}_${s}_${o}_${u}_${c}`, f2 = this._sliceCache.get(l2);
  6190. if (f2 != null)
  6191. return f2;
  6192. const h = [], d2 = this._values;
  6193. let _ = 0, C = 0;
  6194. for (let p2 = r; p2 < n; p2 += s) {
  6195. C = 0, h[_] == null && (h[_] = []);
  6196. for (let N2 = o; N2 < u; N2 += c) {
  6197. if (!d2[p2])
  6198. return;
  6199. let M2 = d2[p2][N2] || this._defaultValue;
  6200. M2 == null && (M2 = ie.create()), h[_][C] = M2, C++;
  6201. }
  6202. _++;
  6203. }
  6204. if (h.length === 0 || h[0].length === 0)
  6205. return;
  6206. const E2 = s > 1 ? -1 : r + this._currentRow, b = c > 1 ? -1 : o + this._currentColumn, R = this._createNewArray(h, h.length, h[0].length, E2, b);
  6207. return R.setDefaultValue(this._defaultValue), this._sliceCache.set(l2, R), R;
  6208. }
  6209. sortByRow(e) {
  6210. const t = this._transposeArray(this._values);
  6211. t.sort(this._sort(e)), this._clearCache(), this._values = this._transposeArray(t);
  6212. }
  6213. sortByColumn(e) {
  6214. this._clearCache(), this._values.sort(this._sort(e));
  6215. }
  6216. transpose() {
  6217. const e = this._transposeArray(this._values), t = this._rowCount, r = this._columnCount, n = this._createNewArray(e, r, t);
  6218. return n.setDefaultValue(this._defaultValue), n;
  6219. }
  6220. /**
  6221. * Due to the inability to effectively utilize the cache,
  6222. * the sequential matching approach is only used for special matches in XLOOKUP and XMATCH.
  6223. * For example, when match_mode is set to 1 and -1 for an exact match. If not found, it returns the next smaller item.
  6224. */
  6225. orderSearch(e, t = Pe.MIN, r = false, n = false) {
  6226. let s, o, u, c;
  6227. const l2 = (f2, h, d2) => {
  6228. if (f2 == null)
  6229. return true;
  6230. let _;
  6231. if (n === true ? _ = f2.compare(e, $.EQUALS) : _ = f2.isEqual(e), (_ == null ? void 0 : _.getValue()) === true)
  6232. return s = f2, u = { row: h, column: d2 }, false;
  6233. t === Pe.MAX ? f2.isGreaterThan(e).getValue() === true && (o == null || f2.minus(e).abs().isLessThanOrEqual(o.minus(e).abs()).getValue() === true) && (o = f2, c = { row: h, column: d2 }) : t === Pe.MIN && f2.isLessThan(e).getValue() === true && (o == null || f2.minus(e).abs().isLessThanOrEqual(o.minus(e).abs()).getValue() === true) && (o = f2, c = { row: h, column: d2 });
  6234. };
  6235. if (r ? this.iteratorReverse((f2, h, d2) => l2(f2, h, d2)) : this.iterator((f2, h, d2) => l2(f2, h, d2)), s != null)
  6236. return u;
  6237. if (o != null)
  6238. return c;
  6239. }
  6240. binarySearch(e, t = Wt.MIN, r = Pe.MIN) {
  6241. if (e.isError())
  6242. return;
  6243. const { stringArray: n, stringPosition: s, numberArray: o, numberPosition: u } = this.flattenPosition();
  6244. return e.isString() ? this._binarySearch(e, n, s, t, r) : this._binarySearch(e, o, u, t, r);
  6245. }
  6246. /**
  6247. * searchType defaults to ascending order
  6248. *
  6249. * matchType defaults to the maximum value less than the search value, which is used for the default matching mode of VLOOKUP/LOOKUP/HLOOKUP.
  6250. * @param valueObject
  6251. * @param searchArray
  6252. * @param positionArray
  6253. * @param searchType
  6254. * @param matchType
  6255. * @returns
  6256. */
  6257. _binarySearch(e, t, r, n = Wt.MIN, s = Pe.MIN) {
  6258. const o = hn(), u = Number(e.getValue()), c = !Number.isNaN(u);
  6259. let l2 = 0, f2 = t.length - 1, h = -1, d2 = -1, _ = -1;
  6260. for (; l2 <= f2; ) {
  6261. const C = Math.floor((l2 + f2) / 2), E2 = t[C];
  6262. let b;
  6263. if (E2.isNull())
  6264. b = n === Wt.MIN ? 1 : -1;
  6265. else {
  6266. const R = E2.getValue();
  6267. if (c) {
  6268. const p2 = Number(R);
  6269. b = Number.isNaN(p2) ? 1 : Math.sign(p2 - u);
  6270. } else
  6271. b = o(R.toString().toLocaleLowerCase(), e.getValue().toString().toLocaleLowerCase());
  6272. }
  6273. if (n === Wt.MAX && (b = -b), b === 0) {
  6274. h = C;
  6275. break;
  6276. }
  6277. b < 0 ? (d2 = C, l2 = C + 1) : (_ = C, f2 = C - 1);
  6278. }
  6279. if (s === Pe.NORMAL)
  6280. return h !== -1 ? r[h] : void 0;
  6281. if (s === Pe.MIN)
  6282. return h !== -1 ? r[h] : n === Wt.MIN ? r[d2] : r[_];
  6283. if (s === Pe.MAX)
  6284. return h !== -1 ? r[h] : n === Wt.MIN ? r[_] : r[d2];
  6285. }
  6286. sum() {
  6287. let e = y2.create(0);
  6288. return this.iterator((t) => {
  6289. if (t == null || t.isString() || t.isBoolean() || t.isNull())
  6290. return true;
  6291. if (t.isError())
  6292. return e = t, false;
  6293. e = e.plus(
  6294. t
  6295. );
  6296. }), e;
  6297. }
  6298. max() {
  6299. let e = y2.create(Number.NEGATIVE_INFINITY);
  6300. return this.iterator((t) => {
  6301. if (t == null)
  6302. return true;
  6303. if (t.isError())
  6304. return e = t, false;
  6305. if (t.isString() || t.isNull() || t.isBoolean())
  6306. return true;
  6307. e.isLessThan(t).getValue() && (e = t);
  6308. }), e;
  6309. }
  6310. min() {
  6311. let e = y2.create(Number.POSITIVE_INFINITY);
  6312. return this.iterator((t) => {
  6313. if (t == null)
  6314. return true;
  6315. if (t.isError())
  6316. return e = t, false;
  6317. if (t.isString() || t.isNull() || t.isBoolean())
  6318. return true;
  6319. e.isGreaterThan(t).getValue() && (e = t);
  6320. }), e;
  6321. }
  6322. count() {
  6323. let e = y2.create(0);
  6324. return this.iterator((t) => {
  6325. if (t == null || t.isError() || t.isString() || t.isNull() || t.isBoolean())
  6326. return true;
  6327. e = e.plusBy(1);
  6328. }), e;
  6329. }
  6330. countA() {
  6331. let e = y2.create(0);
  6332. return this.iterator((t) => {
  6333. if (t == null || t.isNull())
  6334. return true;
  6335. e = e.plusBy(1);
  6336. }), e;
  6337. }
  6338. countBlank() {
  6339. let e = y2.create(0);
  6340. return this.iterator((t) => {
  6341. (t == null || t.isNull() || t.getValue() === "") && (e = e.plusBy(1));
  6342. }), e;
  6343. }
  6344. getNegative() {
  6345. return _q.create("{0}").minus(this);
  6346. }
  6347. getReciprocal() {
  6348. return _q.create("{1}").divided(this);
  6349. }
  6350. plus(e) {
  6351. return this._batchOperator(
  6352. e,
  6353. 1
  6354. /* PLUS */
  6355. );
  6356. }
  6357. minus(e) {
  6358. return this._batchOperator(
  6359. e,
  6360. 0
  6361. /* MINUS */
  6362. );
  6363. }
  6364. multiply(e) {
  6365. return this._batchOperator(
  6366. e,
  6367. 2
  6368. /* MULTIPLY */
  6369. );
  6370. }
  6371. divided(e) {
  6372. return this._batchOperator(
  6373. e,
  6374. 3
  6375. /* DIVIDED */
  6376. );
  6377. }
  6378. mod(e) {
  6379. return this._batchOperator(
  6380. e,
  6381. 4
  6382. /* MOD */
  6383. );
  6384. }
  6385. modInverse(e) {
  6386. return this.map((t) => t.isError() ? t : e.mod(t));
  6387. }
  6388. compare(e, t, r) {
  6389. return this._batchOperator(e, 5, t, r);
  6390. }
  6391. concatenateFront(e) {
  6392. return this._batchOperator(
  6393. e,
  6394. 6
  6395. /* CONCATENATE_FRONT */
  6396. );
  6397. }
  6398. concatenateBack(e) {
  6399. return this._batchOperator(
  6400. e,
  6401. 7
  6402. /* CONCATENATE_BACK */
  6403. );
  6404. }
  6405. map(e) {
  6406. const t = (r, n, s) => r == null ? ie.create() : r.isError() ? r : e(r, n, s);
  6407. return this.mapValue(t);
  6408. }
  6409. mapValue(e) {
  6410. var s;
  6411. const t = this._rowCount, r = this._columnCount, n = [];
  6412. for (let o = 0; o < t; o++) {
  6413. const u = [];
  6414. for (let c = 0; c < r; c++) {
  6415. const l2 = (s = this._values) == null ? void 0 : s[o];
  6416. if (l2 == null)
  6417. u[c] = g2.create(m2.VALUE);
  6418. else {
  6419. const f2 = l2[c] || this._defaultValue;
  6420. f2 ? u[c] = e(f2, o, c) : u[c] = ie.create();
  6421. }
  6422. }
  6423. n.push(u);
  6424. }
  6425. return this._createNewArray(n, t, r);
  6426. }
  6427. pow(e) {
  6428. return this._batchOperator(
  6429. e,
  6430. 8
  6431. /* POW */
  6432. );
  6433. }
  6434. /**
  6435. *
  6436. * @param valueObject In the case of an inverse, it is certainly not an array.
  6437. * @returns
  6438. */
  6439. powInverse(e) {
  6440. return this.map((t) => t.isError() ? t : e.pow(t));
  6441. }
  6442. sqrt() {
  6443. return this.map((e) => e.isError() ? e : e.sqrt());
  6444. }
  6445. cbrt() {
  6446. return this.map((e) => e.isError() ? e : e.cbrt());
  6447. }
  6448. cos() {
  6449. return this.map((e) => e.isError() ? e : e.cos());
  6450. }
  6451. cosh() {
  6452. return this.map((e) => e.isError() ? e : e.cosh());
  6453. }
  6454. acos() {
  6455. return this.map((e) => e.isError() ? e : e.acos());
  6456. }
  6457. acosh() {
  6458. return this.map((e) => e.isError() ? e : e.acosh());
  6459. }
  6460. sin() {
  6461. return this.map((e) => e.isError() ? e : e.sin());
  6462. }
  6463. sinh() {
  6464. return this.map((e) => e.isError() ? e : e.sinh());
  6465. }
  6466. asin() {
  6467. return this.map((e) => e.isError() ? e : e.asin());
  6468. }
  6469. asinh() {
  6470. return this.map((e) => e.isError() ? e : e.asinh());
  6471. }
  6472. tan() {
  6473. return this.map((e) => e.isError() ? e : e.tan());
  6474. }
  6475. tanh() {
  6476. return this.map((e) => e.isError() ? e : e.tanh());
  6477. }
  6478. atan() {
  6479. return this.map((e) => e.isError() ? e : e.atan());
  6480. }
  6481. atanh() {
  6482. return this.map((e) => e.isError() ? e : e.atanh());
  6483. }
  6484. atan2(e) {
  6485. return this._batchOperator(
  6486. e,
  6487. 12
  6488. /* ATAN2 */
  6489. );
  6490. }
  6491. atan2Inverse(e) {
  6492. return this.map((t) => t.isError() ? t : e.atan2(t));
  6493. }
  6494. mean(e = 0) {
  6495. const t = this.sum(), r = this.count();
  6496. return t.divided(e === 0 ? r : r.minusBy(1));
  6497. }
  6498. median() {
  6499. const e = this.flattenPosition().numberArray, t = this._createNewArray([e], 1, e.length), r = t.getColumnCount();
  6500. if (r <= 1)
  6501. return t.get(0, 0) || ie.create();
  6502. if (t.sortByRow(0), r % 2 === 0) {
  6503. const n = t.get(0, r / 2) || ie.create(), s = t.get(0, r / 2 - 1) || ie.create();
  6504. return n.plus(s).divided(y2.create(2));
  6505. }
  6506. return t.get(0, (r - 1) / 2) || ie.create();
  6507. }
  6508. /**
  6509. * ┌──────────────┬────────────────────────────────┬───────────────────┐
  6510. * │ Function │ Ignore logical values and text │ Type │
  6511. * ├──────────────┼────────────────────────────────┼───────────────────┤
  6512. * │ VAR.S (VAR) │ TRUE │ sample │
  6513. * │ VAR.P (VARP) │ TRUE │ entire population │
  6514. * │ VARA │ FALSE │ sample │
  6515. * │ VARPA │ FALSE │ entire population │
  6516. * └──────────────┴────────────────────────────────┴───────────────────┘
  6517. *
  6518. * for VARPA and VARA, strings and FALSE are counted as 0, TRUE is counted as 1
  6519. * for VAR.S/VAR, or VAR.P/VARP, strings,TRUE and FALSE are ignored
  6520. * Since sum ignores strings and booleans, they are ignored here too, and VAR.S and VAR.P are used more
  6521. *
  6522. * VAR.S assumes that its arguments are a sample of the population, like numpy.var(data, ddof=1)
  6523. * VAR.P assumes that its arguments are the entire population, like numpy.var(data, ddof=0)
  6524. * numpy.var uses ddof=0 (Delta Degrees of Freedom) by default, so we use ddof=0 here
  6525. *
  6526. */
  6527. var(e = 0) {
  6528. const t = this.mean(), r = [[]];
  6529. this.iterator((l2) => {
  6530. if (l2 == null || l2.isError() || l2.isString() || l2.isBoolean() || l2.isNull())
  6531. return;
  6532. const f2 = l2.minus(t).pow(y2.create(2));
  6533. f2.isError() || r[0].push(f2);
  6534. });
  6535. const { _unitId: n, _sheetId: s, _currentRow: o, _currentColumn: u } = this;
  6536. return _q.create({
  6537. calculateValueList: r,
  6538. rowCount: 1,
  6539. columnCount: r[0].length,
  6540. unitId: n,
  6541. sheetId: s,
  6542. row: o,
  6543. column: u
  6544. }).mean(e);
  6545. }
  6546. /**
  6547. * STDEV.P (STDEVP): ddof=0, ignore strings and booleans
  6548. * STDEV.S (STDEV): ddof=1, ignore strings and booleans
  6549. *
  6550. * STDEVPA: ddof=0,
  6551. * STDEVA: ddof=1,
  6552. * @returns
  6553. */
  6554. std(e = 0) {
  6555. const t = this.var(e);
  6556. return t.isError() ? t : t.sqrt();
  6557. }
  6558. log() {
  6559. return this.map((e) => e.isError() ? e : e.log());
  6560. }
  6561. log10() {
  6562. return this.map((e) => e.isError() ? e : e.log10());
  6563. }
  6564. exp() {
  6565. return this.map((e) => e.isError() ? e : e.exp());
  6566. }
  6567. abs() {
  6568. return this.map((e) => e.isError() ? e : e.abs());
  6569. }
  6570. round(e) {
  6571. return this._batchOperator(
  6572. e,
  6573. 9
  6574. /* ROUND */
  6575. );
  6576. }
  6577. roundInverse(e) {
  6578. return this.map((t) => t.isError() ? t : e.round(t));
  6579. }
  6580. floor(e) {
  6581. return this._batchOperator(
  6582. e,
  6583. 10
  6584. /* FLOOR */
  6585. );
  6586. }
  6587. floorInverse(e) {
  6588. return this.map((t) => t.isError() ? t : e.floor(t));
  6589. }
  6590. ceil(e) {
  6591. return this._batchOperator(
  6592. e,
  6593. 11
  6594. /* CEIL */
  6595. );
  6596. }
  6597. ceilInverse(e) {
  6598. return this.map((t) => t.isError() ? t : e.ceil(t));
  6599. }
  6600. toValue() {
  6601. return Rf(this._values);
  6602. }
  6603. _clearCache() {
  6604. this._flattenCache = null, this._sliceCache.clear();
  6605. }
  6606. _sort(e) {
  6607. const t = hn();
  6608. return (r, n) => {
  6609. const s = r[e], o = n[e];
  6610. return s == null ? 1 : o == null ? -1 : s.isError() && s.isError() ? 0 : s.isError() ? 1 : o.isError() ? -1 : t(
  6611. s.getValue(),
  6612. o.getValue()
  6613. );
  6614. };
  6615. }
  6616. _transposeArray(e) {
  6617. const t = e.length, r = e[0].length, n = [];
  6618. for (let s = 0; s < r; s++) {
  6619. n[s] = [];
  6620. for (let o = 0; o < t; o++)
  6621. n[s][o] = e[o][s];
  6622. }
  6623. return n;
  6624. }
  6625. _batchOperator(e, t, r, n) {
  6626. const s = [];
  6627. let o = this._rowCount, u = this._columnCount;
  6628. if (e.isArray()) {
  6629. const f2 = e.getRowCount(), h = e.getColumnCount();
  6630. if (o = Math.max(f2, o), u = Math.max(h, u), f2 === 1 && h === 1) {
  6631. const d2 = e.getFirstCell();
  6632. for (let _ = 0; _ < u; _++)
  6633. s.push(d2);
  6634. } else if (f2 === 1 && this._columnCount > 1) {
  6635. const d2 = e.getArrayValue();
  6636. for (let _ = 0; _ < u; _++)
  6637. s.push(d2[0][_]);
  6638. } else
  6639. return this._batchOperatorArray(e, t, r, n);
  6640. } else
  6641. for (let f2 = 0; f2 < u; f2++)
  6642. s.push(e);
  6643. const c = [];
  6644. for (let f2 = 0; f2 < u; f2++) {
  6645. const h = s[f2];
  6646. this._batchOperatorValue(h, f2, c, t, r, n);
  6647. }
  6648. const l2 = this._createNewArray(c, o, u);
  6649. return l2.setDefaultValue(T2.create(false)), l2;
  6650. }
  6651. // eslint-disable-next-line max-lines-per-function
  6652. _batchOperatorValue(e, t, r, n, s, o) {
  6653. const u = this._rowCount, c = this.getUnitId(), l2 = this.getSheetId(), f2 = this.getCurrentRow(), h = this.getCurrentColumn();
  6654. if (n === 5) {
  6655. const { rowsInCache: d2, rowsNotInCache: _ } = St.canUseCache(
  6656. c,
  6657. l2,
  6658. t + h,
  6659. f2,
  6660. f2 + u - 1
  6661. );
  6662. if (d2.length > 0) {
  6663. if (s === $.EQUALS) {
  6664. const C = St.getCellPositions(
  6665. c,
  6666. l2,
  6667. t + h,
  6668. e.getValue(),
  6669. d2
  6670. );
  6671. C != null && C.forEach((E2) => {
  6672. if (E2 < f2 || E2 > f2 + u - 1)
  6673. return;
  6674. const b = E2 - f2;
  6675. r[b] == null && (r[b] = []), r[b][t] = T2.create(true);
  6676. });
  6677. } else {
  6678. const C = St.getCellValuePositions(
  6679. c,
  6680. l2,
  6681. t + h
  6682. );
  6683. C != null && C.forEach((E2, b) => {
  6684. let R = ie.create();
  6685. yr.has(b) ? R = g2.create(b) : typeof b == "string" ? R = j.create(b) : typeof b == "number" ? R = y2.create(b) : typeof b == "boolean" && (R = T2.create(b));
  6686. let p2;
  6687. R.isError() ? p2 = R : e.isError() ? p2 = e : p2 = R.compare(e, s, o), (p2.isError() || p2.getValue() === true) && E2.forEach((N2) => {
  6688. N2 >= f2 && N2 <= f2 + u - 1 && (r[N2 - f2] == null && (r[N2 - f2] = []), r[N2 - f2][t] = p2);
  6689. });
  6690. });
  6691. }
  6692. if (_.length > 0)
  6693. for (const C of _) {
  6694. const [E2, b] = C;
  6695. for (let R = E2; R <= b; R++)
  6696. this.__batchOperatorRowValue(
  6697. e,
  6698. t,
  6699. r,
  6700. n,
  6701. R - f2,
  6702. c,
  6703. l2,
  6704. f2,
  6705. h,
  6706. s,
  6707. o
  6708. );
  6709. St.setContinueBuildingCache(
  6710. c,
  6711. l2,
  6712. t + h,
  6713. E2,
  6714. b
  6715. );
  6716. }
  6717. return;
  6718. }
  6719. }
  6720. for (let d2 = 0; d2 < u; d2++)
  6721. this.__batchOperatorRowValue(
  6722. e,
  6723. t,
  6724. r,
  6725. n,
  6726. d2,
  6727. c,
  6728. l2,
  6729. f2,
  6730. h,
  6731. s,
  6732. o
  6733. );
  6734. St.setContinueBuildingCache(
  6735. c,
  6736. l2,
  6737. t + h,
  6738. f2,
  6739. f2 + u - 1
  6740. );
  6741. }
  6742. // eslint-disable-next-line
  6743. __batchOperatorRowValue(e, t, r, n, s, o, u, c, l2, f2, h) {
  6744. const d2 = this.getValueOrDefault(s, t);
  6745. if (r[s] == null && (r[s] = []), d2 && e)
  6746. if (d2.isError())
  6747. r[s][t] = d2;
  6748. else if (e.isError())
  6749. r[s][t] = e;
  6750. else
  6751. switch (n) {
  6752. case 1:
  6753. r[s][t] = d2.plus(e);
  6754. break;
  6755. case 0:
  6756. r[s][t] = d2.minus(e);
  6757. break;
  6758. case 2:
  6759. r[s][t] = d2.multiply(e);
  6760. break;
  6761. case 3:
  6762. r[s][t] = d2.divided(e);
  6763. break;
  6764. case 4:
  6765. r[s][t] = d2.mod(e);
  6766. break;
  6767. case 5:
  6768. f2 ? r[s][t] = d2.compare(e, f2, h) : r[s][t] = g2.create(m2.VALUE);
  6769. break;
  6770. case 6:
  6771. r[s][t] = d2.concatenateFront(e);
  6772. break;
  6773. case 7:
  6774. r[s][t] = d2.concatenateBack(e);
  6775. break;
  6776. case 8:
  6777. r[s][t] = d2.pow(e);
  6778. break;
  6779. case 9:
  6780. r[s][t] = d2.round(e);
  6781. break;
  6782. case 10:
  6783. r[s][t] = d2.floor(e);
  6784. break;
  6785. case 12:
  6786. r[s][t] = d2.atan2(e);
  6787. break;
  6788. case 11:
  6789. r[s][t] = d2.ceil(e);
  6790. break;
  6791. }
  6792. else
  6793. r[s][t] = g2.create(m2.NA);
  6794. d2 != null && (d2.isError() ? St.set(
  6795. o,
  6796. u,
  6797. t + l2,
  6798. d2.getErrorType(),
  6799. s + c
  6800. ) : St.set(
  6801. o,
  6802. u,
  6803. t + l2,
  6804. d2.getValue(),
  6805. s + c
  6806. ));
  6807. }
  6808. // eslint-disable-next-line max-lines-per-function, complexity
  6809. _batchOperatorArray(e, t, r, n) {
  6810. let s = e.getRowCount(), o = e.getColumnCount();
  6811. s < this._rowCount && (s = this._rowCount), o < this._columnCount && (o = this._columnCount);
  6812. const u = [], c = this._checkArrayCalculateType(this), l2 = this._checkArrayCalculateType(e);
  6813. for (let f2 = 0; f2 < s; f2++) {
  6814. const h = [];
  6815. for (let d2 = 0; d2 < o; d2++) {
  6816. let _;
  6817. c === 3 ? _ = this.getValueOrDefault(0, 0) : c === 1 ? _ = this.getValueOrDefault(0, d2) : c === 2 ? _ = this.getValueOrDefault(f2, 0) : _ = this.getValueOrDefault(f2, d2);
  6818. let C;
  6819. if (l2 === 3 ? C = e.getValueOrDefault(0, 0) : l2 === 1 ? C = e.getValueOrDefault(0, d2) : l2 === 2 ? C = e.getValueOrDefault(f2, 0) : C = e.getValueOrDefault(f2, d2), _ && C)
  6820. if (_.isError())
  6821. h[d2] = _;
  6822. else if (C.isError())
  6823. h[d2] = C;
  6824. else
  6825. switch (t) {
  6826. case 1:
  6827. h[d2] = _.plus(C);
  6828. break;
  6829. case 0:
  6830. h[d2] = _.minus(C);
  6831. break;
  6832. case 2:
  6833. h[d2] = _.multiply(C);
  6834. break;
  6835. case 3:
  6836. h[d2] = _.divided(C);
  6837. break;
  6838. case 4:
  6839. h[d2] = _.mod(C);
  6840. break;
  6841. case 5:
  6842. r ? h[d2] = _.compare(C, r, n) : h[d2] = g2.create(m2.VALUE);
  6843. break;
  6844. case 6:
  6845. h[d2] = _.concatenateFront(C);
  6846. break;
  6847. case 7:
  6848. h[d2] = _.concatenateBack(C);
  6849. break;
  6850. case 8:
  6851. h[d2] = _.pow(C);
  6852. break;
  6853. case 9:
  6854. h[d2] = _.round(C);
  6855. break;
  6856. case 12:
  6857. h[d2] = _.atan2(C);
  6858. break;
  6859. case 10:
  6860. h[d2] = _.floor(C);
  6861. break;
  6862. case 11:
  6863. h[d2] = _.ceil(C);
  6864. break;
  6865. }
  6866. else
  6867. h[d2] = g2.create(m2.NA);
  6868. }
  6869. u.push(h);
  6870. }
  6871. return this._createNewArray(u, s, o);
  6872. }
  6873. _checkArrayCalculateType(e) {
  6874. return e.getRowCount() === 1 && e.getColumnCount() === 1 ? 3 : e.getRowCount() === 1 ? 1 : e.getColumnCount() === 1 ? 2 : 0;
  6875. }
  6876. _formatValue(e) {
  6877. if (typeof e != "string")
  6878. return e = e, this._rowCount = e.rowCount, this._columnCount = e.columnCount, this._unitId = e.unitId, this._sheetId = e.sheetId, this._currentRow = e.row, this._currentColumn = e.column, e.calculateValueList;
  6879. e = e.slice(1, -1);
  6880. const t = e.split(";"), r = t.length, n = [];
  6881. let s = 0;
  6882. for (let o = 0; o < r; o++) {
  6883. const c = t[o].split(","), l2 = c.length;
  6884. s < l2 && (s = l2);
  6885. const f2 = [];
  6886. for (let h = 0; h < l2; h++) {
  6887. const d2 = c[h].trim();
  6888. f2.push(pt.create(d2));
  6889. }
  6890. n.push(f2);
  6891. }
  6892. return this._rowCount = r, this._columnCount = s, n;
  6893. }
  6894. _createNewArray(e, t, r, n = -1, s = -1) {
  6895. (this._currentColumn === -1 || this._currentRow === -1) && (n = -1, s = -1);
  6896. const o = {
  6897. calculateValueList: e,
  6898. rowCount: t,
  6899. columnCount: r,
  6900. unitId: this.getUnitId(),
  6901. sheetId: this.getSheetId(),
  6902. row: n,
  6903. column: s
  6904. };
  6905. return _q.create(o);
  6906. }
  6907. };
  6908. var pt = class {
  6909. static create(a2) {
  6910. if (a2 == null)
  6911. return ie.create();
  6912. if (typeof a2 == "boolean")
  6913. return T2.create(a2);
  6914. if (typeof a2 == "string") {
  6915. const e = a2.toLocaleUpperCase().trim();
  6916. if (yr.has(e))
  6917. return g2.create(e);
  6918. if (e === er.TRUE || e === er.FALSE)
  6919. return In(a2);
  6920. if (DC(a2))
  6921. return y2.create(Number(a2));
  6922. const { isNumberPattern: t, value: r, pattern: n } = il(a2);
  6923. if (t)
  6924. return y2.create(r, n);
  6925. const s = a2.replace(/\n/g, "").replace(/\r/g, "");
  6926. return !pf(s) && Ac(s) ? q2.create(s) : bf(a2);
  6927. }
  6928. return typeof a2 == "number" ? Fn(a2) : g2.create(m2.VALUE);
  6929. }
  6930. };
  6931. function pf(i) {
  6932. const a2 = i.trim();
  6933. return a2.startsWith('"') && a2.endsWith('"');
  6934. }
  6935. var Vf = 1e4;
  6936. var Bs = new Vt(Vf);
  6937. var kn = class extends jn {
  6938. constructor(e) {
  6939. super();
  6940. A(this, "_forcedSheetId", "");
  6941. A(this, "_forcedSheetName", "");
  6942. A(this, "_defaultSheetId", "");
  6943. A(this, "_rangeData", {
  6944. startColumn: -1,
  6945. startRow: -1,
  6946. endRow: -1,
  6947. endColumn: -1
  6948. });
  6949. A(this, "_unitData", {});
  6950. A(this, "_unitStylesData", {});
  6951. A(this, "_defaultUnitId", "");
  6952. A(this, "_forcedUnitId", "");
  6953. A(this, "_runtimeData", {});
  6954. A(this, "_arrayFormulaCellData", {});
  6955. A(this, "_runtimeArrayFormulaCellData", {});
  6956. A(this, "_runtimeFeatureCellData", {});
  6957. A(this, "_refOffsetX", 0);
  6958. A(this, "_refOffsetY", 0);
  6959. this._token = e;
  6960. }
  6961. dispose() {
  6962. this._unitData = {}, this._unitStylesData = {}, this._runtimeData = {};
  6963. }
  6964. getToken() {
  6965. return this._token;
  6966. }
  6967. setToken(e) {
  6968. this._token = e;
  6969. }
  6970. isExceedRange() {
  6971. const { startRow: e, endRow: t, startColumn: r, endColumn: n } = this.getRangePosition();
  6972. return e < 0 || r < 0 || t >= this.getActiveSheetRowCount() || n >= this.getActiveSheetColumnCount();
  6973. }
  6974. setRefOffset(e = 0, t = 0) {
  6975. this._refOffsetX = e, this._refOffsetY = t;
  6976. }
  6977. getRefOffset() {
  6978. return {
  6979. x: this._refOffsetX,
  6980. y: this._refOffsetY
  6981. };
  6982. }
  6983. getRangePosition() {
  6984. let { startRow: e, startColumn: t, endRow: r, endColumn: n } = jC(this._rangeData, this._refOffsetX, this._refOffsetY);
  6985. return Number.isNaN(e) && (e = 0), Number.isNaN(t) && (t = 0), Number.isNaN(r) && (r = this.getActiveSheetRowCount() - 1), Number.isNaN(n) && (n = this.getActiveSheetColumnCount() - 1), {
  6986. ...this._rangeData,
  6987. startRow: e,
  6988. endRow: r,
  6989. startColumn: t,
  6990. endColumn: n
  6991. };
  6992. }
  6993. isReferenceObject() {
  6994. return true;
  6995. }
  6996. iterator(e) {
  6997. const { startRow: t, endRow: r, startColumn: n, endColumn: s } = this.getRangePosition();
  6998. if (this._checkIfWorksheetMiss())
  6999. return e(g2.create(m2.VALUE), t, n);
  7000. const o = this._forcedUnitId || this._defaultUnitId, u = this._forcedSheetId || this._defaultSheetId;
  7001. for (let c = t; c <= r; c++)
  7002. for (let l2 = n; l2 <= s; l2++) {
  7003. if (c < 0 || l2 < 0)
  7004. return e(g2.create(m2.REF), c, l2);
  7005. const f2 = this.getCellData(c, l2);
  7006. let h = false;
  7007. if (nn(f2)) {
  7008. h = e(null, c, l2);
  7009. continue;
  7010. }
  7011. let d2 = this.getCellValueObject(f2);
  7012. if (c === t && l2 === n) {
  7013. const _ = this.getCellPattern(o, u, c, l2);
  7014. if (_ && d2.isNumber()) {
  7015. const C = Number(d2.getValue());
  7016. d2 = y2.create(C, _);
  7017. }
  7018. }
  7019. if (h = e(d2, c, l2), h === false)
  7020. return;
  7021. }
  7022. }
  7023. getFirstCell() {
  7024. const { startRow: e, startColumn: t } = this.getRangePosition(), r = this.getCellData(e, t);
  7025. if (!r)
  7026. return y2.create(0);
  7027. let n = this.getCellValueObject(r);
  7028. const s = this._forcedUnitId || this._defaultUnitId, o = this._forcedSheetId || this._defaultSheetId, u = this.getCellPattern(s, o, e, t);
  7029. if (u && n.isNumber()) {
  7030. const c = Number(n.getValue());
  7031. n = y2.create(c, u);
  7032. }
  7033. return n;
  7034. }
  7035. getRangeData() {
  7036. return this._rangeData;
  7037. }
  7038. setRangeData(e) {
  7039. this._rangeData = e;
  7040. }
  7041. getUnitId() {
  7042. return this._forcedUnitId && this._forcedUnitId.length > 0 ? this._forcedUnitId : this._defaultUnitId;
  7043. }
  7044. getSheetId() {
  7045. return this._forcedSheetId && this._forcedSheetId.length > 0 ? this._forcedSheetId : this._defaultSheetId;
  7046. }
  7047. setForcedUnitIdDirect(e) {
  7048. e.length > 0 && (this._forcedUnitId = e);
  7049. }
  7050. getForcedUnitId() {
  7051. return this._forcedUnitId;
  7052. }
  7053. setForcedSheetId(e) {
  7054. var t;
  7055. this._forcedSheetId = (t = e[this.getUnitId()]) == null ? void 0 : t[this._forcedSheetName];
  7056. }
  7057. setForcedSheetIdDirect(e) {
  7058. this._forcedSheetId = e;
  7059. }
  7060. getForcedSheetId() {
  7061. return this._forcedSheetId;
  7062. }
  7063. setForcedSheetName(e) {
  7064. e.length > 0 && (this._forcedSheetName = e);
  7065. }
  7066. getForcedSheetName() {
  7067. return this._forcedSheetName;
  7068. }
  7069. setDefaultSheetId(e) {
  7070. this._defaultSheetId = e;
  7071. }
  7072. getDefaultSheetId() {
  7073. return this._defaultSheetId;
  7074. }
  7075. setDefaultUnitId(e) {
  7076. this._defaultUnitId = e;
  7077. }
  7078. getDefaultUnitId() {
  7079. return this._defaultUnitId;
  7080. }
  7081. getUnitData() {
  7082. return this._unitData;
  7083. }
  7084. setUnitData(e) {
  7085. this._unitData = e;
  7086. }
  7087. getUnitStylesData() {
  7088. return this._unitStylesData;
  7089. }
  7090. setUnitStylesData(e) {
  7091. this._unitStylesData = e;
  7092. }
  7093. getRuntimeData() {
  7094. return this._runtimeData;
  7095. }
  7096. setRuntimeData(e) {
  7097. this._runtimeData = e;
  7098. }
  7099. getArrayFormulaCellData() {
  7100. return this._arrayFormulaCellData;
  7101. }
  7102. setArrayFormulaCellData(e) {
  7103. this._arrayFormulaCellData = e;
  7104. }
  7105. getRuntimeArrayFormulaCellData() {
  7106. return this._runtimeArrayFormulaCellData;
  7107. }
  7108. setRuntimeArrayFormulaCellData(e) {
  7109. this._runtimeArrayFormulaCellData = e;
  7110. }
  7111. getRuntimeFeatureCellData() {
  7112. return this._runtimeFeatureCellData;
  7113. }
  7114. setRuntimeFeatureCellData(e) {
  7115. this._runtimeFeatureCellData = e;
  7116. }
  7117. getActiveSheetRowCount() {
  7118. var e;
  7119. return ((e = this.getCurrentActiveSheetData()) == null ? void 0 : e.rowCount) || 0;
  7120. }
  7121. getActiveSheetColumnCount() {
  7122. var e;
  7123. return ((e = this.getCurrentActiveSheetData()) == null ? void 0 : e.columnCount) || 0;
  7124. }
  7125. getRowCount() {
  7126. return this._rangeData.endRow - this._rangeData.startRow + 1;
  7127. }
  7128. getColumnCount() {
  7129. return this._rangeData.endColumn - this._rangeData.startColumn + 1;
  7130. }
  7131. getRowData() {
  7132. var e;
  7133. return ((e = this.getCurrentActiveSheetData()) == null ? void 0 : e.rowData) || {};
  7134. }
  7135. getColumnData() {
  7136. var e;
  7137. return ((e = this.getCurrentActiveSheetData()) == null ? void 0 : e.columnData) || {};
  7138. }
  7139. isCell() {
  7140. return false;
  7141. }
  7142. isColumn() {
  7143. return false;
  7144. }
  7145. isRow() {
  7146. return false;
  7147. }
  7148. isRange() {
  7149. return false;
  7150. }
  7151. isTable() {
  7152. return false;
  7153. }
  7154. unionBy(e) {
  7155. return g2.create(m2.REF);
  7156. }
  7157. unionRange(e, t) {
  7158. return {
  7159. startRow: -1,
  7160. startColumn: -1,
  7161. endRow: -1,
  7162. endColumn: -1
  7163. };
  7164. }
  7165. getCellValueObject(e) {
  7166. const t = cl(e);
  7167. if (yr.has(t))
  7168. return g2.create(t);
  7169. if (e.t === dn.NUMBER) {
  7170. const r = this._getPatternByCell(e);
  7171. return Fn(t, r);
  7172. }
  7173. return e.t === dn.STRING || e.t === dn.FORCE_STRING ? j.create(t.toString()) : e.t === dn.BOOLEAN ? In(t) : pt.create(t);
  7174. }
  7175. _getPatternByCell(e) {
  7176. var n;
  7177. const t = this._unitStylesData[this.getUnitId()];
  7178. if (!t)
  7179. return "";
  7180. const r = t.getStyleByCell(e);
  7181. return ((n = r == null ? void 0 : r.n) == null ? void 0 : n.pattern) || "";
  7182. }
  7183. getCellByRow(e) {
  7184. return this.getCellByPosition(e);
  7185. }
  7186. getCellByColumn(e) {
  7187. return this.getCellByPosition(void 0, e);
  7188. }
  7189. getCurrentActiveSheetData() {
  7190. var e;
  7191. return (e = this._unitData[this.getUnitId()]) == null ? void 0 : e[this.getSheetId()];
  7192. }
  7193. getCurrentStylesData() {
  7194. return this._unitStylesData[this.getUnitId()];
  7195. }
  7196. getCurrentRuntimeSheetData() {
  7197. var e, t;
  7198. return (t = (e = this._runtimeData) == null ? void 0 : e[this.getUnitId()]) == null ? void 0 : t[this.getSheetId()];
  7199. }
  7200. getCurrentActiveArrayFormulaCellData() {
  7201. var e, t;
  7202. return (t = (e = this._arrayFormulaCellData) == null ? void 0 : e[this.getUnitId()]) == null ? void 0 : t[this.getSheetId()];
  7203. }
  7204. getCurrentRuntimeActiveArrayFormulaCellData() {
  7205. var e, t;
  7206. return (t = (e = this._runtimeArrayFormulaCellData) == null ? void 0 : e[this.getUnitId()]) == null ? void 0 : t[this.getSheetId()];
  7207. }
  7208. getCellData(e, t) {
  7209. const r = this.getCurrentActiveSheetData(), n = this.getCurrentRuntimeSheetData(), s = this.getCurrentActiveArrayFormulaCellData(), o = this.getCurrentRuntimeActiveArrayFormulaCellData();
  7210. return (n == null ? void 0 : n.getValue(e, t)) || (o == null ? void 0 : o.getValue(e, t)) || this.getRuntimeFeatureCellValue(e, t) || (s == null ? void 0 : s.getValue(e, t)) || (r == null ? void 0 : r.cellData.getValue(e, t));
  7211. }
  7212. getRuntimeFeatureCellValue(e, t) {
  7213. return ao(e, t, this.getSheetId(), this.getUnitId(), this._runtimeFeatureCellData);
  7214. }
  7215. getCellByPosition(e, t) {
  7216. let r = e, n = t;
  7217. r || (r = this._rangeData.startRow), n || (n = this._rangeData.startColumn);
  7218. const s = this.getCellData(r, n);
  7219. return s ? this.getCellValueObject(s) : g2.create(m2.VALUE);
  7220. }
  7221. /**
  7222. * Get the pattern of the cell
  7223. * @param unitId
  7224. * @param sheetId
  7225. * @param row
  7226. * @param column
  7227. * @returns
  7228. */
  7229. getCellPattern(e, t, r, n) {
  7230. var c, l2, f2, h;
  7231. const s = this._unitStylesData[e];
  7232. if (!s)
  7233. return "";
  7234. const o = (f2 = (l2 = (c = this._unitData[e]) == null ? void 0 : c[t]) == null ? void 0 : l2.cellData) == null ? void 0 : f2.getValue(r, n);
  7235. if (!o)
  7236. return "";
  7237. const u = s.getStyleByCell(o);
  7238. return ((h = u == null ? void 0 : u.n) == null ? void 0 : h.pattern) || "";
  7239. }
  7240. toArrayValueObject(e = true) {
  7241. var _;
  7242. const { startRow: t, endRow: r, startColumn: n, endColumn: s } = this.getRangePosition(), o = `${this.getUnitId()}_${this.getSheetId()}_${t}_${r}_${n}_${s}`, u = Bs.get(o);
  7243. if (u && e)
  7244. return u;
  7245. const c = r - t + 1, l2 = s - n + 1;
  7246. if (c < 0 || l2 < 0)
  7247. return this._getBlankArrayValueObject();
  7248. const f2 = new Array(c);
  7249. this.iterator((C, E2, b) => {
  7250. const R = E2 - t, p2 = b - n;
  7251. f2[R] || (f2[R] = new Array(l2)), C == null && (C = ie.create()), f2[R][p2] = C;
  7252. });
  7253. const h = {
  7254. calculateValueList: f2,
  7255. rowCount: f2.length,
  7256. columnCount: ((_ = f2[0]) == null ? void 0 : _.length) || 0,
  7257. unitId: this.getUnitId(),
  7258. sheetId: this.getSheetId(),
  7259. row: t,
  7260. column: n
  7261. }, d2 = q2.create(h);
  7262. return e && Bs.set(o, d2), d2;
  7263. }
  7264. toUnitRange() {
  7265. return {
  7266. range: this.getRangePosition(),
  7267. sheetId: this.getSheetId(),
  7268. unitId: this.getUnitId()
  7269. };
  7270. }
  7271. _checkIfWorksheetMiss() {
  7272. return (this._forcedSheetId == null || this._forcedSheetId.length === 0) && this._forcedSheetName.length > 0;
  7273. }
  7274. _getBlankArrayValueObject() {
  7275. const e = {
  7276. calculateValueList: [],
  7277. rowCount: 0,
  7278. columnCount: 0,
  7279. unitId: this.getUnitId(),
  7280. sheetId: this.getSheetId(),
  7281. row: 0,
  7282. column: 0
  7283. };
  7284. return q2.create(e);
  7285. }
  7286. };
  7287. var Nf = class extends jn {
  7288. constructor(a2) {
  7289. super(), this._promise = a2;
  7290. }
  7291. isAsyncObject() {
  7292. return true;
  7293. }
  7294. async getValue() {
  7295. return this._promise;
  7296. }
  7297. };
  7298. var Of = class extends jn {
  7299. constructor(a2) {
  7300. super(), this._promiseList = a2;
  7301. }
  7302. isAsyncArrayObject() {
  7303. return true;
  7304. }
  7305. async getValue() {
  7306. var t;
  7307. const a2 = [];
  7308. for (let r = 0; r < this._promiseList.length; r++) {
  7309. const n = this._promiseList[r];
  7310. a2[r] == null && (a2[r] = []);
  7311. for (let s = 0; s < n.length; s++) {
  7312. const o = n[s];
  7313. o.isAsyncObject() ? a2[r][s] = await o.getValue() : a2[r][s] = o;
  7314. }
  7315. }
  7316. const e = {
  7317. calculateValueList: a2,
  7318. rowCount: a2.length,
  7319. columnCount: ((t = a2[0]) == null ? void 0 : t.length) || 0,
  7320. unitId: "",
  7321. sheetId: "",
  7322. row: 0,
  7323. column: 0
  7324. };
  7325. return q2.create(e);
  7326. }
  7327. };
  7328. var Cn = class extends kn {
  7329. constructor(a2, e, t) {
  7330. super(""), this.setRangeData(a2), e && this.setForcedSheetIdDirect(e), t && this.setForcedUnitIdDirect(t);
  7331. }
  7332. isRange() {
  7333. return true;
  7334. }
  7335. };
  7336. var da = class extends kn {
  7337. constructor(a2) {
  7338. super(a2);
  7339. const e = mr(a2);
  7340. this.setForcedUnitIdDirect(e.unitId), this.setForcedSheetName(e.sheetName), this.setRangeData(e.range);
  7341. }
  7342. isCell() {
  7343. return true;
  7344. }
  7345. unionBy(a2) {
  7346. if (!a2.isCell())
  7347. return g2.create(m2.REF);
  7348. const e = a2, t = this.unionRange(this.getRangeData(), e.getRangeData());
  7349. return this._createRange(t);
  7350. }
  7351. unionRange(a2, e) {
  7352. const t = a2.startRow, r = a2.startColumn, n = e.startRow, s = e.startColumn, o = {
  7353. startRow: -1,
  7354. startColumn: -1,
  7355. endRow: -1,
  7356. endColumn: -1
  7357. };
  7358. return t > n ? (o.startRow = n, o.endRow = t) : (o.startRow = t, o.endRow = n), r > s ? (o.startColumn = s, o.endColumn = r) : (o.startColumn = r, o.endColumn = s), a2.startAbsoluteRefType && (o.startAbsoluteRefType = a2.startAbsoluteRefType), e.startAbsoluteRefType && (o.endAbsoluteRefType = e.startAbsoluteRefType), o;
  7359. }
  7360. _createRange(a2) {
  7361. const e = new Cn(
  7362. a2,
  7363. this.getForcedSheetId(),
  7364. this.getForcedUnitId()
  7365. );
  7366. e.setUnitData(this.getUnitData()), e.setDefaultSheetId(this.getDefaultSheetId()), e.setDefaultUnitId(this.getDefaultUnitId()), e.setRuntimeData(this.getRuntimeData()), e.setUnitStylesData(this.getUnitStylesData()), e.setArrayFormulaCellData(this.getArrayFormulaCellData()), e.setRuntimeArrayFormulaCellData(this.getRuntimeArrayFormulaCellData()), e.setRuntimeFeatureCellData(this.getRuntimeFeatureCellData());
  7367. const { x: t, y: r } = this.getRefOffset();
  7368. e.setRefOffset(t, r);
  7369. const n = this.getForcedSheetId();
  7370. e.setForcedSheetName(this.getForcedSheetName()), n != null && e.setForcedSheetIdDirect(n);
  7371. const s = this.getForcedUnitId();
  7372. return s && e.setForcedUnitIdDirect(s), e;
  7373. }
  7374. };
  7375. var Ca = class extends kn {
  7376. constructor(a2) {
  7377. super(a2);
  7378. const e = mr(a2);
  7379. this.setForcedUnitIdDirect(e.unitId), this.setForcedSheetName(e.sheetName);
  7380. const t = {
  7381. ...e.range,
  7382. startColumn: e.range.startColumn,
  7383. startRow: Number.NaN,
  7384. endColumn: e.range.endColumn,
  7385. endRow: Number.NaN,
  7386. rangeType: De.COLUMN
  7387. };
  7388. this.setRangeData(t);
  7389. }
  7390. isColumn() {
  7391. return true;
  7392. }
  7393. unionBy(a2) {
  7394. if (!a2.isColumn())
  7395. return g2.create(m2.REF);
  7396. const e = a2;
  7397. if (e.getForcedSheetName() !== void 0 && e.getForcedSheetName() !== "")
  7398. return g2.create(m2.REF);
  7399. const t = this.getRangeData(), r = e.getRangeData(), n = r.startColumn;
  7400. if (n >= t.startColumn && n <= t.endColumn)
  7401. return this;
  7402. const s = t.startColumn;
  7403. return n > s ? t.endColumn = n : (t.startColumn = n, t.endColumn = s), r.startAbsoluteRefType && (t.endAbsoluteRefType = r.startAbsoluteRefType), t.rangeType = De.COLUMN, this.setToken(`${this.getToken()}${K2.COLON}${e.getToken()}`), this;
  7404. }
  7405. };
  7406. var _a = class extends kn {
  7407. constructor(a2) {
  7408. super(a2);
  7409. const e = mr(a2);
  7410. this.setForcedUnitIdDirect(e.unitId), this.setForcedSheetName(e.sheetName);
  7411. const t = {
  7412. ...e.range,
  7413. startColumn: Number.NaN,
  7414. startRow: e.range.startRow,
  7415. endColumn: Number.NaN,
  7416. endRow: e.range.endRow,
  7417. rangeType: De.ROW
  7418. };
  7419. this.setRangeData(t);
  7420. }
  7421. isRow() {
  7422. return true;
  7423. }
  7424. unionBy(a2) {
  7425. if (!a2.isRow())
  7426. return g2.create(m2.REF);
  7427. const e = a2;
  7428. if (e.getForcedSheetName() !== void 0 && e.getForcedSheetName() !== "")
  7429. return g2.create(m2.REF);
  7430. const t = this.getRangeData(), r = e.getRangeData(), n = r.startRow;
  7431. if (n >= t.startRow && n <= t.endRow)
  7432. return this;
  7433. const s = t.startRow;
  7434. return n > s ? t.endRow = n : (t.startRow = n, t.endRow = s), r.startAbsoluteRefType && (t.endAbsoluteRefType = r.startAbsoluteRefType), t.rangeType = De.ROW, this.setToken(`${this.getToken()}${K2.COLON}${e.getToken()}`), this;
  7435. }
  7436. };
  7437. function O(i, a2, e, t) {
  7438. const r = e.isArray() ? e.getRowCount() : 1, n = e.isArray() ? e.getColumnCount() : 1, s = [];
  7439. for (let o = 0; o < i; o++) {
  7440. const u = [];
  7441. for (let c = 0; c < a2; c++) {
  7442. if (r === 1 && n === 1) {
  7443. const f2 = e.isArray() ? e.get(0, 0) : e;
  7444. u.push(f2);
  7445. continue;
  7446. }
  7447. if (r === 1 && c < n) {
  7448. const f2 = e.get(0, c);
  7449. u.push(f2);
  7450. continue;
  7451. }
  7452. if (n === 1 && o < r) {
  7453. const f2 = e.get(o, 0);
  7454. u.push(f2);
  7455. continue;
  7456. }
  7457. if (o >= r || c >= n) {
  7458. u.push(t != null ? t : ie.create());
  7459. continue;
  7460. }
  7461. const l2 = e.get(o, c);
  7462. u.push(l2);
  7463. }
  7464. s.push(u);
  7465. }
  7466. return tr(s, i, a2);
  7467. }
  7468. function tr(i, a2, e, t = "", r = "") {
  7469. const n = {
  7470. calculateValueList: i,
  7471. rowCount: a2,
  7472. columnCount: e,
  7473. unitId: t,
  7474. sheetId: r,
  7475. row: -1,
  7476. column: -1
  7477. };
  7478. return q2.create(n);
  7479. }
  7480. function Aa(i) {
  7481. const a2 = [
  7482. $.EQUALS,
  7483. $.NOT_EQUAL,
  7484. $.GREATER_THAN_OR_EQUAL,
  7485. $.GREATER_THAN,
  7486. $.LESS_THAN_OR_EQUAL,
  7487. $.LESS_THAN
  7488. ];
  7489. for (const e of a2)
  7490. if (i.startsWith(e)) {
  7491. const t = i.substring(e.length);
  7492. return [e, pt.create(t)];
  7493. }
  7494. return [$.EQUALS, pt.create(i)];
  7495. }
  7496. function $n(i, a2, e, t) {
  7497. if (!e)
  7498. if (a2.isString()) {
  7499. const r = `${a2.getValue()}`, [n, s] = Aa(r);
  7500. e = n, a2 = s;
  7501. } else
  7502. e = $.EQUALS;
  7503. return i.compare(a2, e, t);
  7504. }
  7505. function Mf2(i, a2) {
  7506. const e = Math.max(i.isArray() ? i.getRowCount() : 1, a2.isArray() ? a2.getRowCount() : 1), t = Math.max(i.isArray() ? i.getColumnCount() : 1, a2.isArray() ? a2.getColumnCount() : 1), r = O(e, t, i), n = O(e, t, a2);
  7507. return r.mapValue((s, o, u) => {
  7508. const c = n.get(o, u);
  7509. return s != null && s.isError() ? s : c != null && c.isError() ? c : s != null && s.isBoolean() && (c != null && c.isBoolean()) ? In(s.getValue() && c.getValue()) : T2.create(false);
  7510. });
  7511. }
  7512. function wf(i) {
  7513. const a2 = i.getValue();
  7514. let e = 0;
  7515. return a2 && (e = 1), y2.create(e);
  7516. }
  7517. function Ai(i) {
  7518. return i.isArray() && i.getRowCount() === 1 && i.getColumnCount() === 1 ? true : i.isReferenceObject() ? !!(i.isCell() || i.getRowCount() === 1 && i.getColumnCount() === 1) : (i = i, !!(i.isString() || i.isNumber() || i.isBoolean() || i.isError() || i.isNull()));
  7519. }
  7520. function Gt(i) {
  7521. const a2 = i == null ? void 0 : i.getPattern();
  7522. let e = {};
  7523. if (a2 && (e = {
  7524. s: {
  7525. n: {
  7526. pattern: a2
  7527. }
  7528. }
  7529. }), i == null)
  7530. return {
  7531. v: null,
  7532. ...e
  7533. };
  7534. if (i.isError())
  7535. return {
  7536. v: i.getErrorType(),
  7537. t: dn.STRING,
  7538. ...e
  7539. };
  7540. if (i.isValueObject()) {
  7541. const t = i, r = t.getValue();
  7542. return t.isNumber() ? {
  7543. v: r,
  7544. t: dn.NUMBER,
  7545. ...e
  7546. } : t.isBoolean() ? {
  7547. v: r ? 1 : 0,
  7548. t: dn.BOOLEAN,
  7549. ...e
  7550. } : t.isString() ? {
  7551. v: r,
  7552. t: dn.STRING,
  7553. ...e
  7554. } : t.isNull() ? {
  7555. v: null,
  7556. ...e
  7557. } : {
  7558. v: r,
  7559. t: dn.STRING,
  7560. ...e
  7561. };
  7562. }
  7563. }
  7564. function Nr(i) {
  7565. let a2 = 0, e = 0;
  7566. return i.forEach((t, r) => {
  7567. if (r % 2 === 1)
  7568. if (t.isArray()) {
  7569. const n = t;
  7570. a2 = Math.max(a2, n.getRowCount()), e = Math.max(e, n.getColumnCount());
  7571. } else
  7572. a2 = Math.max(a2, 1), e = Math.max(e, 1);
  7573. }), { maxRowLength: a2, maxColumnLength: e };
  7574. }
  7575. function Br(i, a2, e, t) {
  7576. const r = a2.getRowCount(), n = a2.getColumnCount();
  7577. for (let s = 0; s < i.length; s++) {
  7578. if (s % 2 === 1)
  7579. continue;
  7580. const o = i[s], u = o.getRowCount(), c = o.getColumnCount();
  7581. if (u !== r || c !== n)
  7582. return O(e, t, g2.create(m2.VALUE));
  7583. }
  7584. return null;
  7585. }
  7586. function Ir(i, a2, e, t = false) {
  7587. const r = [];
  7588. for (let n = 0; n < i.length; n++) {
  7589. if (n % 2 === 1)
  7590. continue;
  7591. const s = i[n], o = i[n + 1];
  7592. O(a2, e, o, g2.create(m2.NA)).iterator((c, l2, f2) => {
  7593. if (!c)
  7594. return;
  7595. let h = $n(s, c);
  7596. if (t && (h = Yn(h, s, c)), r[l2] === void 0 && (r[l2] = []), r[l2][f2] === void 0) {
  7597. r[l2][f2] = h;
  7598. return;
  7599. }
  7600. r[l2][f2] = Mf2(r[l2][f2], h);
  7601. });
  7602. }
  7603. return r;
  7604. }
  7605. function Yn(i, a2, e) {
  7606. const [t, r] = Aa(`${e.getValue()}`);
  7607. return i.mapValue((n, s, o) => {
  7608. const u = a2.get(s, o);
  7609. if (u && Df(u, r))
  7610. return n;
  7611. if (u != null && u.isNumber()) {
  7612. if (r.isString()) {
  7613. const c = r.convertToNumberObjectValue();
  7614. if (c.isNumber())
  7615. return u.compare(c, t);
  7616. }
  7617. return T2.create(false);
  7618. } else if (r.isNumber()) {
  7619. if (u != null && u.isString()) {
  7620. const c = u.convertToNumberObjectValue();
  7621. if (c.isNumber())
  7622. return c.compare(r, t);
  7623. }
  7624. return T2.create(false);
  7625. } else
  7626. return u != null && u.isError() && r.isError() && u.getValue() === r.getValue() ? T2.create(true) : T2.create(false);
  7627. });
  7628. }
  7629. function Df(i, a2) {
  7630. if (i.isNumber() && a2.isNumber() || i.isBoolean() && a2.isBoolean())
  7631. return true;
  7632. const e = i.isString() && i.getValue() === "", t = a2.isString() && a2.getValue() === "";
  7633. return !!((e || i.isNull()) && (t || a2.isNull()) || i.isString() && !e && a2.isString() && !t);
  7634. }
  7635. var an = ((i) => (i[i.CELL = 0] = "CELL", i[i.COLUMN = 1] = "COLUMN", i[i.ROW = 2] = "ROW", i))(an || {});
  7636. function Sf(i, a2) {
  7637. let e;
  7638. switch (a2) {
  7639. case 0:
  7640. e = new da(i);
  7641. break;
  7642. case 1:
  7643. e = new Ca(i);
  7644. break;
  7645. case 2:
  7646. e = new _a(i);
  7647. break;
  7648. default:
  7649. throw new Error("Unknown reference object type");
  7650. }
  7651. return e;
  7652. }
  7653. function Pf(i, a2) {
  7654. let e = g2.create(m2.NAME);
  7655. return (i.isCell() && a2.isCell() || i.isRow() && a2.isRow() || i.isColumn() && a2.isColumn()) && (e = i.unionBy(a2)), e;
  7656. }
  7657. var Lf = Object.defineProperty;
  7658. var xf = Object.getOwnPropertyDescriptor;
  7659. var jf = (i, a2, e, t) => {
  7660. for (var r = t > 1 ? void 0 : t ? xf(a2, e) : a2, n = i.length - 1, s; n >= 0; n--)
  7661. (s = i[n]) && (r = (t ? s(a2, e, r) : s(r)) || r);
  7662. return t && r && Lf(a2, e, r), r;
  7663. };
  7664. var Uf = (i, a2) => (e, t) => a2(e, t, i);
  7665. var ft = ((i) => (i[i.IDLE = 0] = "IDLE", i[i.START = 1] = "START", i[i.START_DEPENDENCY = 2] = "START_DEPENDENCY", i[i.START_CALCULATION = 3] = "START_CALCULATION", i[i.CURRENTLY_CALCULATING = 4] = "CURRENTLY_CALCULATING", i[i.START_DEPENDENCY_ARRAY_FORMULA = 5] = "START_DEPENDENCY_ARRAY_FORMULA", i[i.START_CALCULATION_ARRAY_FORMULA = 6] = "START_CALCULATION_ARRAY_FORMULA", i[i.CURRENTLY_CALCULATING_ARRAY_FORMULA = 7] = "CURRENTLY_CALCULATING_ARRAY_FORMULA", i[i.CALCULATION_COMPLETED = 8] = "CALCULATION_COMPLETED", i))(ft || {});
  7666. var wr = ((i) => (i[i.INITIAL = 0] = "INITIAL", i[i.STOP_EXECUTION = 1] = "STOP_EXECUTION", i[i.NOT_EXECUTED = 2] = "NOT_EXECUTED", i[i.SUCCESS = 3] = "SUCCESS", i))(wr || {});
  7667. var Is = class extends nt {
  7668. constructor(a2) {
  7669. super();
  7670. A(this, "_formulaExecuteStage", 0);
  7671. A(this, "_stopState", false);
  7672. A(this, "_currentRow", -1);
  7673. A(this, "_currentColumn", -1);
  7674. A(this, "_currentRowCount", Number.NEGATIVE_INFINITY);
  7675. A(this, "_currentColumnCount", Number.NEGATIVE_INFINITY);
  7676. A(this, "_currentSubUnitId", "");
  7677. A(this, "_currentUnitId", "");
  7678. A(this, "_runtimeData", {});
  7679. A(this, "_runtimeOtherData", {});
  7680. A(this, "_unitArrayFormulaRange", {});
  7681. A(this, "_runtimeArrayFormulaCellData", {});
  7682. A(this, "_runtimeClearArrayFormulaCellData", {});
  7683. A(this, "_runtimeFeatureRange", {});
  7684. A(this, "_runtimeFeatureCellData", {});
  7685. A(this, "_functionsExecutedState", 0);
  7686. A(this, "_functionDefinitionPrivacyVar", /* @__PURE__ */ new Map());
  7687. A(this, "_totalFormulasToCalculate", 0);
  7688. A(this, "_completedFormulasCount", 0);
  7689. A(this, "_totalArrayFormulasToCalculate", 0);
  7690. A(this, "_completedArrayFormulasCount", 0);
  7691. A(this, "_formulaCycleIndex", 0);
  7692. A(this, "_isCycleDependency", false);
  7693. this._currentConfigService = a2;
  7694. }
  7695. get currentRow() {
  7696. return this._currentRow;
  7697. }
  7698. get currentColumn() {
  7699. return this._currentColumn;
  7700. }
  7701. get currentRowCount() {
  7702. return this._currentRowCount;
  7703. }
  7704. get currentColumnCount() {
  7705. return this._currentColumnCount;
  7706. }
  7707. get currentSubUnitId() {
  7708. return this._currentSubUnitId;
  7709. }
  7710. get currentUnitId() {
  7711. return this._currentUnitId;
  7712. }
  7713. dispose() {
  7714. this.reset(), this._runtimeFeatureCellData = {}, this._runtimeFeatureRange = {}, this.clearReferenceAndNumberformatCache();
  7715. }
  7716. enableCycleDependency() {
  7717. this._isCycleDependency = true;
  7718. }
  7719. disableCycleDependency() {
  7720. this._isCycleDependency = false;
  7721. }
  7722. isCycleDependency() {
  7723. return this._isCycleDependency;
  7724. }
  7725. setFormulaCycleIndex(a2) {
  7726. this._formulaCycleIndex = a2;
  7727. }
  7728. getFormulaCycleIndex() {
  7729. return this._formulaCycleIndex;
  7730. }
  7731. setTotalArrayFormulasToCalculate(a2) {
  7732. this._totalArrayFormulasToCalculate = a2;
  7733. }
  7734. getTotalArrayFormulasToCalculate() {
  7735. return this._totalArrayFormulasToCalculate;
  7736. }
  7737. setCompletedArrayFormulasCount(a2) {
  7738. this._completedArrayFormulasCount = a2;
  7739. }
  7740. getCompletedArrayFormulasCount() {
  7741. return this._completedArrayFormulasCount;
  7742. }
  7743. setTotalFormulasToCalculate(a2) {
  7744. this._totalFormulasToCalculate = a2;
  7745. }
  7746. getTotalFormulasToCalculate() {
  7747. return this._totalFormulasToCalculate;
  7748. }
  7749. setCompletedFormulasCount(a2) {
  7750. this._completedFormulasCount = a2;
  7751. }
  7752. getCompletedFormulasCount() {
  7753. return this._completedFormulasCount;
  7754. }
  7755. markedAsSuccessfullyExecuted() {
  7756. this._functionsExecutedState = 3;
  7757. }
  7758. markedAsNoFunctionsExecuted() {
  7759. this._functionsExecutedState = 2;
  7760. }
  7761. markedAsStopFunctionsExecuted() {
  7762. this._functionsExecutedState = 1;
  7763. }
  7764. markedAsInitialFunctionsExecuted() {
  7765. this._functionsExecutedState = 0;
  7766. }
  7767. stopExecution() {
  7768. this._stopState = true, this.setFormulaExecuteStage(
  7769. 0
  7770. /* IDLE */
  7771. );
  7772. }
  7773. isStopExecution() {
  7774. return this._stopState;
  7775. }
  7776. setFormulaExecuteStage(a2) {
  7777. this._formulaExecuteStage = a2;
  7778. }
  7779. getFormulaExecuteStage() {
  7780. return this._formulaExecuteStage;
  7781. }
  7782. reset() {
  7783. this._formulaExecuteStage = 0, this._runtimeData = {}, this._runtimeOtherData = {}, this._unitArrayFormulaRange = {}, this._runtimeArrayFormulaCellData = {}, this._runtimeClearArrayFormulaCellData = {}, this._functionDefinitionPrivacyVar.clear(), this.markedAsInitialFunctionsExecuted(), this._stopState = false, this._isCycleDependency = false, this._totalFormulasToCalculate = 0, this._completedFormulasCount = 0, this.clearReferenceAndNumberformatCache();
  7784. }
  7785. clearReferenceAndNumberformatCache() {
  7786. tl(), ol(), Ic();
  7787. }
  7788. setCurrent(a2, e, t, r, n, s) {
  7789. this._currentRow = a2, this._currentColumn = e, this._currentRowCount = t, this._currentColumnCount = r, this._currentSubUnitId = n, this._currentUnitId = s;
  7790. }
  7791. clearFunctionDefinitionPrivacyVar() {
  7792. this._functionDefinitionPrivacyVar.clear();
  7793. }
  7794. registerFunctionDefinitionPrivacyVar(a2, e) {
  7795. this._functionDefinitionPrivacyVar.set(a2, e);
  7796. }
  7797. getFunctionDefinitionPrivacyVar(a2) {
  7798. return this._functionDefinitionPrivacyVar.get(a2);
  7799. }
  7800. setRuntimeOtherData(a2, e, t, r) {
  7801. const n = this._currentSubUnitId, s = this._currentUnitId;
  7802. this._runtimeOtherData[s] === void 0 && (this._runtimeOtherData[s] = {});
  7803. const o = this._runtimeOtherData[s];
  7804. (o[n] === void 0 || o[n] === null) && (o[n] = {});
  7805. const u = o[n];
  7806. let c = [];
  7807. if (r.isReferenceObject() || r.isValueObject() && r.isArray()) {
  7808. const l2 = r, { startRow: f2, startColumn: h } = l2.getRangePosition();
  7809. l2.iterator((d2, _, C) => {
  7810. const E2 = Gt(d2), b = _ - f2, R = C - h;
  7811. c[b] == null && (c[b] = []), c[b][R] = E2;
  7812. });
  7813. } else
  7814. c = [[Gt(r)]];
  7815. (u[a2] === void 0 || u[a2] === null) && (u[a2] = {}), (u[a2][t] === void 0 || u[a2][t] === null) && (u[a2][t] = {}), u[a2][t][e] = c;
  7816. }
  7817. // eslint-disable-next-line max-lines-per-function
  7818. setRuntimeData(a2) {
  7819. const e = this._currentRow, t = this._currentColumn, r = this._currentRowCount, n = this.currentColumnCount, s = this._currentSubUnitId, o = this._currentUnitId;
  7820. this._runtimeData[o] == null && (this._runtimeData[o] = {});
  7821. const u = this._runtimeData[o];
  7822. u[s] == null && (u[s] = new kt()), this._unitArrayFormulaRange[o] == null && (this._unitArrayFormulaRange[o] = {});
  7823. const c = this._unitArrayFormulaRange[o];
  7824. (c[s] === null || c[s] === void 0) && (c[s] = {});
  7825. const l2 = new kt(c[s]);
  7826. this._runtimeArrayFormulaCellData[o] === void 0 && (this._runtimeArrayFormulaCellData[o] = {});
  7827. const f2 = this._runtimeArrayFormulaCellData[o];
  7828. f2[s] == null && (f2[s] = new kt()), this._runtimeClearArrayFormulaCellData[o] === void 0 && (this._runtimeClearArrayFormulaCellData[o] = {});
  7829. const h = this._runtimeClearArrayFormulaCellData[o];
  7830. h[s] == null && (h[s] = new kt());
  7831. const d2 = u[s], _ = f2[s], C = h[s];
  7832. if (a2.isReferenceObject() || a2.isValueObject() && a2.isArray()) {
  7833. const E2 = a2, { startRow: b, startColumn: R, endRow: p2, endColumn: N2 } = E2.getRangePosition();
  7834. if (b === p2 && R === N2) {
  7835. const w = E2.getFirstCell(), D2 = Gt(w);
  7836. d2.setValue(e, t, D2), C.setValue(e, t, D2);
  7837. return;
  7838. }
  7839. const M2 = {
  7840. startRow: e,
  7841. startColumn: t,
  7842. endRow: p2 - b + e,
  7843. endColumn: N2 - R + t
  7844. };
  7845. if (l2.setValue(e, t, M2), this._checkIfArrayFormulaRangeHasData(o, s, e, t, M2) || this._checkIfArrayFormulaExceeded(r, n, M2)) {
  7846. const w = Gt(g2.create(m2.SPILL));
  7847. d2.setValue(e, t, w), C.setValue(e, t, w);
  7848. const D2 = this._currentConfigService.getUnitData();
  7849. E2.iterator((S2, P, U2) => {
  7850. var ne, z;
  7851. const x2 = P - b + e, F = U2 - R + t, W2 = (z = (ne = D2[o]) == null ? void 0 : ne[s]) == null ? void 0 : z.cellData.getValue(x2, F);
  7852. if (P === b && U2 === R)
  7853. _.setValue(e, t, w);
  7854. else if (W2 != null)
  7855. W2.v == null && (W2.v = ""), _.setValue(x2, F, W2);
  7856. else {
  7857. if (this._isInOtherArrayFormulaRange(o, s, e, t, x2, F))
  7858. return true;
  7859. _.setValue(x2, F, { v: "" });
  7860. }
  7861. });
  7862. } else {
  7863. const w = g2.create(m2.SPILL);
  7864. E2.iterator((D2, S2, P) => {
  7865. const U2 = Gt(D2);
  7866. if (S2 === b && P === R) {
  7867. if (D2 != null && D2.isError() && D2.isEqualType(w))
  7868. return C.setValue(e, t, {}), d2.setValue(e, t, { ...Gt(w) }), false;
  7869. d2.setValue(e, t, { ...U2 });
  7870. }
  7871. const x2 = S2 - b + e, F = P - R + t;
  7872. _.setValue(x2, F, U2);
  7873. });
  7874. }
  7875. } else {
  7876. const E2 = Gt(a2);
  7877. d2.setValue(e, t, E2), C.setValue(e, t, E2);
  7878. }
  7879. }
  7880. getUnitData() {
  7881. return this._runtimeData;
  7882. }
  7883. getUnitArrayFormula() {
  7884. return this._unitArrayFormulaRange;
  7885. }
  7886. getRuntimeOtherData() {
  7887. return this._runtimeOtherData;
  7888. }
  7889. getRuntimeArrayFormulaCellData() {
  7890. return this._runtimeArrayFormulaCellData;
  7891. }
  7892. getRuntimeClearArrayFormulaCellData() {
  7893. return this._runtimeClearArrayFormulaCellData;
  7894. }
  7895. getRuntimeFeatureRange() {
  7896. return this._runtimeFeatureRange;
  7897. }
  7898. setRuntimeFeatureRange(a2, e) {
  7899. this._runtimeFeatureRange[a2] = e;
  7900. }
  7901. getRuntimeFeatureCellData() {
  7902. return this._runtimeFeatureCellData;
  7903. }
  7904. setRuntimeFeatureCellData(a2, e) {
  7905. this._runtimeFeatureCellData[a2] = e;
  7906. }
  7907. getAllRuntimeData() {
  7908. return {
  7909. unitData: this.getUnitData(),
  7910. arrayFormulaRange: this.getUnitArrayFormula(),
  7911. unitOtherData: this.getRuntimeOtherData(),
  7912. functionsExecutedState: this._functionsExecutedState,
  7913. arrayFormulaCellData: this.getRuntimeArrayFormulaCellData(),
  7914. clearArrayFormulaCellData: this.getRuntimeClearArrayFormulaCellData(),
  7915. runtimeFeatureRange: this.getRuntimeFeatureRange(),
  7916. runtimeFeatureCellData: this.getRuntimeFeatureCellData()
  7917. };
  7918. }
  7919. getRuntimeState() {
  7920. return {
  7921. totalFormulasToCalculate: this.getTotalFormulasToCalculate(),
  7922. completedFormulasCount: this.getCompletedFormulasCount(),
  7923. totalArrayFormulasToCalculate: this.getTotalArrayFormulasToCalculate(),
  7924. completedArrayFormulasCount: this.getCompletedArrayFormulasCount(),
  7925. stage: this.getFormulaExecuteStage(),
  7926. formulaCycleIndex: this.getFormulaCycleIndex()
  7927. };
  7928. }
  7929. // eslint-disable-next-line complexity
  7930. _checkIfArrayFormulaRangeHasData(a2, e, t, r, n) {
  7931. var h, d2, _, C, E2, b, R, p2, N2, M2, w;
  7932. const { startRow: s, startColumn: o, endRow: u, endColumn: c } = n, l2 = this._currentConfigService.getUnitData(), f2 = this._currentConfigService.getArrayFormulaCellData();
  7933. (_ = (d2 = (h = this._unitArrayFormulaRange[a2]) == null ? void 0 : h[e]) == null ? void 0 : d2[t]) == null || _[r];
  7934. for (let D2 = s; D2 <= u; D2++)
  7935. for (let S2 = o; S2 <= c; S2++) {
  7936. if (D2 === t && r === S2)
  7937. continue;
  7938. const P = (b = (E2 = (C = this._runtimeData) == null ? void 0 : C[a2]) == null ? void 0 : E2[e]) == null ? void 0 : b.getValue(D2, S2);
  7939. (p2 = (R = f2 == null ? void 0 : f2[a2]) == null ? void 0 : R[e]) == null || p2.getValue(
  7940. D2,
  7941. S2
  7942. );
  7943. const U2 = (w = (M2 = (N2 = l2 == null ? void 0 : l2[a2]) == null ? void 0 : N2[e]) == null ? void 0 : M2.cellData) == null ? void 0 : w.getValue(D2, S2), x2 = this._getRuntimeFeatureCellValue(D2, S2, e, a2);
  7944. if (!nn(P) || this._isInOtherArrayFormulaRange(a2, e, t, r, D2, S2) || !nn(U2) || !nn(x2))
  7945. return true;
  7946. }
  7947. return false;
  7948. }
  7949. _getRuntimeFeatureCellValue(a2, e, t, r) {
  7950. return ao(a2, e, t, r, this._runtimeFeatureCellData);
  7951. }
  7952. _arrayCellHasData(a2) {
  7953. return a2 == null ? false : a2.v !== void 0;
  7954. }
  7955. /**
  7956. * If the current array formula in the extended area intersects with the existing array formula, a #SPILL! error will be reported. Note that if other array formulas are already #SPILL!, they will not conflict with the current array formula
  7957. * @param formulaUnitId
  7958. * @param formulaSheetId
  7959. * @param formulaRow
  7960. * @param formulaColumn
  7961. * @param r
  7962. * @param c
  7963. * @returns
  7964. */
  7965. _isInOtherArrayFormulaRange(a2, e, t, r, n, s) {
  7966. var l2;
  7967. const o = (l2 = this._currentConfigService.getArrayFormulaRange()[a2]) == null ? void 0 : l2[e];
  7968. if (o == null)
  7969. return false;
  7970. let u = false;
  7971. return new kt(o).forValue((f2, h, d2) => {
  7972. var E2, b;
  7973. if (f2 === t && h === r)
  7974. return;
  7975. const _ = this._isInArrayFormulaRange(d2, n, s), C = (b = (E2 = this._runtimeData[a2]) == null ? void 0 : E2[e]) == null ? void 0 : b.getValue(f2, h);
  7976. _ && (C == null ? void 0 : C.v) !== m2.SPILL && (u = true);
  7977. }), u;
  7978. }
  7979. _isInArrayFormulaRange(a2, e, t) {
  7980. if (a2 == null)
  7981. return false;
  7982. const { startRow: r, startColumn: n, endRow: s, endColumn: o } = a2;
  7983. return e >= r && e <= s && t >= n && t <= o;
  7984. }
  7985. _checkIfArrayFormulaExceeded(a2, e, t) {
  7986. return t.endRow >= a2 || t.endColumn >= e;
  7987. }
  7988. _isInDirtyRange(a2, e, t, r) {
  7989. const n = this._currentConfigService.getDirtyRanges();
  7990. return n.length === 0 ? true : zu(n, a2, e, t, r);
  7991. }
  7992. };
  7993. Is = jf([
  7994. Uf(0, Ft)
  7995. ], Is);
  7996. var Nt = Ct("univer.formula.runtime.service");
  7997. var oe = ((i) => (i[i.REFERENCE = 1] = "REFERENCE", i[i.VALUE = 2] = "VALUE", i[i.OPERATOR = 3] = "OPERATOR", i[i.FUNCTION = 4] = "FUNCTION", i[i.LAMBDA = 5] = "LAMBDA", i[i.LAMBDA_PARAMETER = 6] = "LAMBDA_PARAMETER", i[i.ERROR = 7] = "ERROR", i[i.BASE = 8] = "BASE", i[i.ROOT = 9] = "ROOT", i[i.UNION = 10] = "UNION", i[i.PREFIX = 11] = "PREFIX", i[i.SUFFIX = 12] = "SUFFIX", i[i.NULL = 13] = "NULL", i))(oe || {});
  7998. var _t = /* @__PURE__ */ new Map([
  7999. [1, 7],
  8000. [2, 9],
  8001. [3, 8],
  8002. [4, 6],
  8003. [5, 1],
  8004. [6, 2],
  8005. [9, 10],
  8006. [10, 3],
  8007. [11, 4],
  8008. [12, 5]
  8009. ]);
  8010. var Ge = class {
  8011. constructor(a2) {
  8012. A(this, "_children", []);
  8013. A(this, "_definedNames");
  8014. A(this, "_parent");
  8015. A(this, "_valueObject");
  8016. A(this, "_calculateState", false);
  8017. A(this, "_async", false);
  8018. A(this, "_address", false);
  8019. A(this, "_isForcedCalculateFunction", false);
  8020. this._token = a2;
  8021. }
  8022. dispose() {
  8023. var a2;
  8024. this._children.forEach((e) => {
  8025. e.dispose();
  8026. }), (a2 = this._valueObject) == null || a2.dispose(), this._valueObject = null, this._children = [], this._definedNames = null, this._parent = null;
  8027. }
  8028. get nodeType() {
  8029. return oe.BASE;
  8030. }
  8031. isAsync() {
  8032. return this._async;
  8033. }
  8034. isAddress() {
  8035. return this._address;
  8036. }
  8037. isForcedCalculateFunction() {
  8038. return this._isForcedCalculateFunction;
  8039. }
  8040. setAsync() {
  8041. this._async = true;
  8042. }
  8043. setAddress() {
  8044. this._address = true;
  8045. }
  8046. getParent() {
  8047. return this._parent;
  8048. }
  8049. setParent(a2) {
  8050. this._parent = a2, a2.addChildren(this);
  8051. }
  8052. setForcedCalculateFunction() {
  8053. this._isForcedCalculateFunction = true;
  8054. }
  8055. getChildren() {
  8056. return this._children;
  8057. }
  8058. addChildren(...a2) {
  8059. this._children.push(...a2);
  8060. }
  8061. getToken() {
  8062. return this._token;
  8063. }
  8064. setValue(a2) {
  8065. this._valueObject = a2;
  8066. }
  8067. getValue() {
  8068. return this._valueObject;
  8069. }
  8070. isCalculated() {
  8071. return this._calculateState;
  8072. }
  8073. setCalculated() {
  8074. this._calculateState = true;
  8075. }
  8076. execute() {
  8077. }
  8078. setNotEmpty(a2 = true) {
  8079. }
  8080. async executeAsync() {
  8081. return Promise.resolve(xt.SUCCESS);
  8082. }
  8083. serialize() {
  8084. const a2 = this.getToken(), e = this.getChildren(), t = [], r = e.length;
  8085. for (let s = 0; s < r; s++) {
  8086. const o = e[s];
  8087. t.push(o.serialize());
  8088. }
  8089. const n = {
  8090. token: a2,
  8091. nodeType: this.nodeType
  8092. };
  8093. return r > 0 && (n.children = t), n;
  8094. }
  8095. hasDefinedName(a2) {
  8096. var e;
  8097. return ((e = this._definedNames) == null ? void 0 : e.includes(a2)) || false;
  8098. }
  8099. setDefinedNames(a2) {
  8100. this._definedNames = a2;
  8101. }
  8102. getDefinedNames() {
  8103. return this._definedNames;
  8104. }
  8105. };
  8106. var xe = class _xe extends Ge {
  8107. constructor(e) {
  8108. super(e);
  8109. A(this, "_errorValueObject");
  8110. this._errorValueObject = g2.create(e);
  8111. }
  8112. get nodeType() {
  8113. return oe.ERROR;
  8114. }
  8115. static create(e) {
  8116. return new _xe(e);
  8117. }
  8118. getValue() {
  8119. return this._errorValueObject;
  8120. }
  8121. };
  8122. var At = 100;
  8123. var Et = class {
  8124. get zIndex() {
  8125. return 0;
  8126. }
  8127. dispose() {
  8128. }
  8129. create(a2, e, t) {
  8130. let r;
  8131. return a2 instanceof ae ? r = a2.getToken() : r = a2, new Ge(r);
  8132. }
  8133. };
  8134. var Fs = class extends Ge {
  8135. get nodeType() {
  8136. return oe.ROOT;
  8137. }
  8138. execute() {
  8139. const a2 = this.getChildren();
  8140. if (a2.length > 1) {
  8141. this.setValue(g2.create(m2.VALUE));
  8142. return;
  8143. }
  8144. const e = a2[0];
  8145. e == null ? this.setValue(g2.create(m2.VALUE)) : this.setValue(e.getValue());
  8146. }
  8147. };
  8148. var Eo = class extends Et {
  8149. get zIndex() {
  8150. return _t.get(oe.ROOT) || At;
  8151. }
  8152. checkAndCreateNodeType(a2) {
  8153. if (!(a2 instanceof ae))
  8154. return;
  8155. if (a2.getToken() === Ut)
  8156. return new Fs(Ut);
  8157. }
  8158. };
  8159. var Yt = Ct("univer.formula-function.service");
  8160. var vf = class extends nt {
  8161. constructor() {
  8162. super(...arguments);
  8163. A(this, "_functionExecutors", /* @__PURE__ */ new Map());
  8164. A(this, "_functionDescriptions", /* @__PURE__ */ new Map());
  8165. }
  8166. dispose() {
  8167. this._functionExecutors.clear(), this._functionDescriptions.clear();
  8168. }
  8169. registerExecutors(...e) {
  8170. for (let t = 0; t < e.length; t++) {
  8171. const r = e[t];
  8172. this._functionExecutors.set(r.name, r);
  8173. }
  8174. }
  8175. getExecutors() {
  8176. return this._functionExecutors;
  8177. }
  8178. getExecutor(e) {
  8179. return this._functionExecutors.get(e);
  8180. }
  8181. hasExecutor(e) {
  8182. return this._functionExecutors.has(e);
  8183. }
  8184. unregisterExecutors(...e) {
  8185. for (let t = 0; t < e.length; t++) {
  8186. const r = e[t];
  8187. this._functionExecutors.delete(r);
  8188. }
  8189. }
  8190. registerDescriptions(...e) {
  8191. for (let t = 0; t < e.length; t++) {
  8192. const r = e[t];
  8193. this._functionDescriptions.set(r.functionName, r);
  8194. }
  8195. return Ze(() => {
  8196. for (let t = 0; t < e.length; t++) {
  8197. const r = e[t];
  8198. this._functionDescriptions.delete(r.functionName);
  8199. }
  8200. });
  8201. }
  8202. getDescriptions() {
  8203. return this._functionDescriptions;
  8204. }
  8205. getDescription(e) {
  8206. return this._functionDescriptions.get(e);
  8207. }
  8208. hasDescription(e) {
  8209. return this._functionDescriptions.has(e);
  8210. }
  8211. unregisterDescriptions(...e) {
  8212. for (let t = 0; t < e.length; t++) {
  8213. const r = e[t];
  8214. this._functionDescriptions.delete(r);
  8215. }
  8216. }
  8217. };
  8218. var Te = ((i) => (i.COMPARE = "COMPARE", i.DIVIDED = "DIVIDED", i.MINUS = "MINUS", i.MULTIPLY = "MULTIPLY", i.PLUS = "PLUS", i.UNION = "UNION", i.CUBE = "CUBE", i))(Te || {});
  8219. var Tf = Object.defineProperty;
  8220. var Bf = Object.getOwnPropertyDescriptor;
  8221. var If = (i, a2, e, t) => {
  8222. for (var r = t > 1 ? void 0 : t ? Bf(a2, e) : a2, n = i.length - 1, s; n >= 0; n--)
  8223. (s = i[n]) && (r = (t ? s(a2, e, r) : s(r)) || r);
  8224. return t && r && Tf(a2, e, r), r;
  8225. };
  8226. var Ei = (i, a2) => (e, t) => a2(e, t, i);
  8227. var _n2 = class extends Ge {
  8228. constructor(a2, e, t) {
  8229. super(e), this._runtimeService = a2, this._operatorString = e, this._functionExecutor = t;
  8230. }
  8231. get nodeType() {
  8232. return oe.PREFIX;
  8233. }
  8234. execute() {
  8235. let e = this.getChildren()[0].getValue(), t;
  8236. if (e == null)
  8237. throw new Error("object is null");
  8238. this._operatorString === Oe.MINUS ? (e.isReferenceObject() && (e = e.toArrayValueObject()), t = this._functionExecutor.calculate(
  8239. y2.create(0),
  8240. e
  8241. )) : this._operatorString === Oe.AT ? t = this._handlerAT(e) : t = g2.create(m2.VALUE), this.setValue(t);
  8242. }
  8243. _handlerAT(a2) {
  8244. if (!a2.isReferenceObject())
  8245. return g2.create(m2.VALUE);
  8246. const e = a2;
  8247. if (e.isCell())
  8248. return g2.create(m2.VALUE);
  8249. const t = this._runtimeService, r = t.currentRow || 0, n = t.currentColumn || 0, s = e.getRangePosition(), { startRow: o, startColumn: u, endRow: c, endColumn: l2 } = s;
  8250. return l2 !== u && c !== o || o === c && u === l2 ? g2.create(m2.VALUE) : c === o && n >= u && n <= l2 ? e.getCellByColumn(n) : u === l2 && r >= o && r <= c ? e.getCellByRow(r) : e.isTable() ? e.getCellByPosition(r) : g2.create(m2.VALUE);
  8251. }
  8252. };
  8253. var An = class extends Et {
  8254. constructor(i, a2) {
  8255. super(), this._functionService = i, this._runtimeService = a2;
  8256. }
  8257. get zIndex() {
  8258. return _t.get(oe.PREFIX) || At;
  8259. }
  8260. checkAndCreateNodeType(i) {
  8261. if (!(i instanceof ae))
  8262. return;
  8263. const a2 = i.getToken(), e = a2.trim();
  8264. if (e.charAt(0) === '"' && e.charAt(e.length - 1) === '"')
  8265. return;
  8266. let t = "";
  8267. if (e === Oe.MINUS)
  8268. t = Te.MINUS;
  8269. else
  8270. return e === Oe.AT ? new _n2(this._runtimeService, e) : void 0;
  8271. const r = this._functionService.getExecutor(t);
  8272. return r ? new _n2(this._runtimeService, e, r) : (console.error(`No function ${a2}`), xe.create(m2.NAME));
  8273. }
  8274. };
  8275. An = If([
  8276. Ei(0, Yt),
  8277. Ei(1, Nt)
  8278. ], An);
  8279. new RegExp(Oe.MINUS, "g");
  8280. new RegExp(Oe.AT, "g");
  8281. function bo(i, a2, e) {
  8282. let t, r, n = i;
  8283. const s = n.slice(0, 2);
  8284. let o = 0;
  8285. if (s[0] === Oe.MINUS) {
  8286. const u = a2.getExecutor(Te.MINUS);
  8287. t = new _n2(e, Oe.MINUS, u), o++;
  8288. }
  8289. return s[0] === Oe.AT && (r = new _n2(e, Oe.AT), t && r.setParent(t), o++), o > 0 && (n = n.slice(o)), { tokenTrim: n, minusPrefixNode: t, atPrefixNode: r };
  8290. }
  8291. var Ff = Object.defineProperty;
  8292. var kf = Object.getOwnPropertyDescriptor;
  8293. var $f = (i, a2, e, t) => {
  8294. for (var r = t > 1 ? void 0 : t ? kf(a2, e) : a2, n = i.length - 1, s; n >= 0; n--)
  8295. (s = i[n]) && (r = (t ? s(a2, e, r) : s(r)) || r);
  8296. return t && r && Ff(a2, e, r), r;
  8297. };
  8298. var ir = (i, a2) => (e, t) => a2(e, t, i);
  8299. var Yf = class extends Ge {
  8300. constructor(a2, e, t, r, n, s) {
  8301. super(a2), this._functionExecutor = e, this._currentConfigService = t, this._runtimeService = r, this._definedNamesService = n, this._formulaDataModel = s, this._functionExecutor.isAsync() && this.setAsync(), this._functionExecutor.isAddress() && this.setAddress(), this._functionExecutor.needsLocale && this._setLocale(), this._functionExecutor.needsSheetsInfo && this._setSheetsInfo(), this._functionExecutor.needsFormulaDataModel && this._functionExecutor.setFormulaDataModel(this._formulaDataModel);
  8302. }
  8303. get nodeType() {
  8304. return oe.FUNCTION;
  8305. }
  8306. async executeAsync() {
  8307. const a2 = [], e = this.getChildren(), t = e.length;
  8308. this._compatibility();
  8309. for (let s = 0; s < t; s++) {
  8310. const u = e[s].getValue();
  8311. u != null && (u.isReferenceObject() && !this._functionExecutor.needsReferenceObject ? a2.push(u.toArrayValueObject()) : a2.push(u));
  8312. }
  8313. const r = await this._calculateAsync(a2);
  8314. let n;
  8315. return r.isAsyncObject() || r.isAsyncArrayObject() ? n = await r.getValue() : n = r, this._setRefData(n), this.setValue(n), Promise.resolve(xt.SUCCESS);
  8316. }
  8317. execute() {
  8318. const a2 = [], e = this.getChildren(), t = e.length;
  8319. this._compatibility();
  8320. for (let n = 0; n < t; n++) {
  8321. const o = e[n].getValue();
  8322. o != null && (o.isReferenceObject() && !this._functionExecutor.needsReferenceObject ? a2.push(o.toArrayValueObject()) : a2.push(o));
  8323. }
  8324. const r = this._calculate(a2);
  8325. this._setRefData(r), this.setValue(r);
  8326. }
  8327. /**
  8328. * Compatibility handling for special functions.
  8329. */
  8330. _compatibility() {
  8331. this._lookupCompatibility();
  8332. }
  8333. /**
  8334. * The LOOKUP function follows the following rules when dealing with vectors of different sizes:
  8335. * If the lookup_vector is larger than the result_vector,
  8336. * the LOOKUP function will ignore the extra portion of the lookup_vector and only use the portion of the result_vector that is the same size as the lookup_vector for lookup and returning results.
  8337. * If the lookup_vector is smaller than the result_vector,
  8338. * the LOOKUP function will continue using the last value of the result_vector for lookup and returning results after the last value of the lookup_vector.
  8339. */
  8340. _lookupCompatibility() {
  8341. const a2 = this.getChildren(), e = a2.length;
  8342. if (!this._functionExecutor.needsExpandParams || e !== 3)
  8343. return;
  8344. const t = a2[1].getValue(), r = a2[2].getValue();
  8345. if (!(t != null && t.isReferenceObject()) && !(r != null && r.isReferenceObject()))
  8346. return;
  8347. let n, s;
  8348. if (t != null && t.isReferenceObject()) {
  8349. const _ = t.getRangeData(), { startRow: C, startColumn: E2, endRow: b, endColumn: R } = _;
  8350. n = b - C + 1, s = R - E2 + 1;
  8351. } else
  8352. n = t != null && t.isArray() ? t.getRowCount() : 1, s = t != null && t.isArray() ? t.getColumnCount() : 1;
  8353. const o = r.getRangeData(), { startRow: u, startColumn: c, endRow: l2, endColumn: f2 } = o, h = l2 - u + 1, d2 = f2 - c + 1;
  8354. n !== h && (o.endRow += n - h), s !== d2 && (o.endColumn += s - d2);
  8355. }
  8356. /**
  8357. * Transform the result of a custom function to a NodeValueType.
  8358. */
  8359. _handleCustomResult(a2) {
  8360. var t;
  8361. if (typeof a2 != "object" || a2 == null)
  8362. return pt.create(a2);
  8363. const e = Ao(a2);
  8364. return q2.create({
  8365. calculateValueList: e,
  8366. rowCount: e.length,
  8367. columnCount: ((t = e[0]) == null ? void 0 : t.length) || 0,
  8368. unitId: "",
  8369. sheetId: "",
  8370. row: -1,
  8371. column: -1
  8372. });
  8373. }
  8374. _handleAddressFunction() {
  8375. this._functionExecutor.isAddress() && this._setDefinedNamesForFunction();
  8376. }
  8377. _mapVariantsToValues(a2) {
  8378. return a2.map((e) => e.isArray() ? e.toValue() : e.isLambda() ? e : e.getValue());
  8379. }
  8380. _calculate(a2) {
  8381. const { minParams: e, maxParams: t } = this._functionExecutor;
  8382. if (e !== -1 && t !== -1 && (a2.length < e || a2.length > t))
  8383. return g2.create(m2.NA);
  8384. let r;
  8385. if (this._setRefInfo(), this._functionExecutor.isCustom()) {
  8386. const n = this._functionExecutor.calculateCustom(
  8387. ...this._mapVariantsToValues(a2)
  8388. );
  8389. r = this._handleCustomResult(n);
  8390. } else
  8391. this._handleAddressFunction(), r = this._functionExecutor.calculate(...a2);
  8392. return r;
  8393. }
  8394. async _calculateAsync(a2) {
  8395. const { minParams: e, maxParams: t } = this._functionExecutor;
  8396. if (e !== -1 && t !== -1 && (a2.length < e || a2.length > t))
  8397. return g2.create(m2.NA);
  8398. let r;
  8399. if (this._setRefInfo(), this._functionExecutor.isCustom()) {
  8400. const n = await this._functionExecutor.calculateCustom(
  8401. ...this._mapVariantsToValues(a2)
  8402. );
  8403. r = this._handleCustomResult(n);
  8404. } else
  8405. this._handleAddressFunction(), r = this._functionExecutor.calculate(...a2);
  8406. return r;
  8407. }
  8408. _setDefinedNamesForFunction() {
  8409. const a2 = this._currentConfigService.getExecuteUnitId();
  8410. if (a2 == null)
  8411. return;
  8412. const e = this._definedNamesService.getDefinedNameMap(a2);
  8413. e != null && this._functionExecutor.setDefinedNames(e);
  8414. }
  8415. _setRefInfo() {
  8416. const { currentUnitId: a2, currentSubUnitId: e, currentRow: t, currentColumn: r } = this._runtimeService;
  8417. if (this._functionExecutor.setRefInfo(a2, e, t, r), this._functionExecutor.needsSheetRowColumnCount) {
  8418. const { rowCount: n, columnCount: s } = this._currentConfigService.getSheetRowColumnCount(a2, e);
  8419. this._functionExecutor.setSheetRowColumnCount(n, s);
  8420. }
  8421. }
  8422. _setRefData(a2) {
  8423. if (!a2.isReferenceObject())
  8424. return;
  8425. const e = a2;
  8426. e.setForcedSheetId(this._currentConfigService.getSheetNameMap()), e.setUnitData(this._currentConfigService.getUnitData()), e.setArrayFormulaCellData(this._currentConfigService.getArrayFormulaCellData()), e.setRuntimeData(this._runtimeService.getUnitData()), e.setRuntimeArrayFormulaCellData(this._runtimeService.getRuntimeArrayFormulaCellData()), e.setRuntimeFeatureCellData(this._runtimeService.getRuntimeFeatureCellData());
  8427. }
  8428. _setLocale() {
  8429. this._functionExecutor.setLocale(this._currentConfigService.getLocale());
  8430. }
  8431. _setSheetsInfo() {
  8432. this._functionExecutor.setSheetsInfo(this._currentConfigService.getSheetsInfo());
  8433. }
  8434. };
  8435. var Hf = class extends Ge {
  8436. constructor(a2 = "Error") {
  8437. super(a2);
  8438. }
  8439. get nodeType() {
  8440. return oe.FUNCTION;
  8441. }
  8442. async executeAsync() {
  8443. return this.setValue(g2.create(m2.NAME)), Promise.resolve(xt.SUCCESS);
  8444. }
  8445. execute() {
  8446. this.setValue(g2.create(m2.NAME));
  8447. }
  8448. };
  8449. var En = class extends Et {
  8450. constructor(i, a2, e, t, r, n) {
  8451. super(), this._functionService = i, this._currentConfigService = a2, this._runtimeService = e, this._definedNamesService = t, this._injector = r, this._formulaDataModel = n;
  8452. }
  8453. get zIndex() {
  8454. return _t.get(oe.FUNCTION) || At;
  8455. }
  8456. create(i) {
  8457. const a2 = this._functionService.getExecutor(i);
  8458. return a2 ? new Yf(
  8459. i,
  8460. a2,
  8461. this._currentConfigService,
  8462. this._runtimeService,
  8463. this._definedNamesService,
  8464. this._formulaDataModel
  8465. ) : (console.error(`No function ${i}`), xe.create(m2.NAME));
  8466. }
  8467. checkAndCreateNodeType(i) {
  8468. if (typeof i == "string")
  8469. return;
  8470. const a2 = i.getToken(), { tokenTrim: e, minusPrefixNode: t, atPrefixNode: r } = bo(a2.trim(), this._functionService, this._runtimeService);
  8471. if (!Number.isNaN(Number(e)) && !this._isParentUnionNode(i))
  8472. return xe.create(m2.VALUE);
  8473. const n = e.toUpperCase();
  8474. if (this._functionService.hasExecutor(n)) {
  8475. const s = this.create(n);
  8476. return r ? s.setParent(r) : t && s.setParent(t), s;
  8477. }
  8478. }
  8479. _isParentUnionNode(i) {
  8480. var a2, e;
  8481. return ((e = (a2 = i.getParent()) == null ? void 0 : a2.getParent()) == null ? void 0 : e.getToken()) === K2.COLON;
  8482. }
  8483. };
  8484. En = $f([
  8485. ir(0, Yt),
  8486. ir(1, Ft),
  8487. ir(2, Nt),
  8488. ir(3, pr),
  8489. ir(4, ot(Ot)),
  8490. ir(5, ot(Pr))
  8491. ], En);
  8492. var Gf = Object.defineProperty;
  8493. var Qf = Object.getOwnPropertyDescriptor;
  8494. var Wf = (i, a2, e, t) => {
  8495. for (var r = t > 1 ? void 0 : t ? Qf(a2, e) : a2, n = i.length - 1, s; n >= 0; n--)
  8496. (s = i[n]) && (r = (t ? s(a2, e, r) : s(r)) || r);
  8497. return t && r && Gf(a2, e, r), r;
  8498. };
  8499. var qf = (i, a2) => (e, t) => a2(e, t, i);
  8500. var Cr = class extends nt {
  8501. constructor(i) {
  8502. super(), this._runtimeService = i;
  8503. }
  8504. async executeAsync(i) {
  8505. if (!i || !i.node)
  8506. return Promise.resolve(g2.create(m2.VALUE));
  8507. const a2 = i.node, e = i.refOffsetX, t = i.refOffsetY;
  8508. await this._executeAsync(a2, e, t);
  8509. const r = a2.getValue();
  8510. return r == null ? Promise.resolve(g2.create(m2.VALUE)) : Promise.resolve(r);
  8511. }
  8512. execute(i) {
  8513. if (!i || !i.node)
  8514. return g2.create(m2.VALUE);
  8515. const a2 = i.node, e = i.refOffsetX, t = i.refOffsetY;
  8516. this._execute(a2, e, t);
  8517. const r = a2.getValue();
  8518. return r == null ? g2.create(m2.VALUE) : r;
  8519. }
  8520. executePreCalculateNode(i) {
  8521. return i.execute(), i.getValue();
  8522. }
  8523. checkAsyncNode(i) {
  8524. if (i == null)
  8525. return false;
  8526. const a2 = [];
  8527. this._checkAsyncNode(i, a2);
  8528. for (let e = 0, t = a2.length; e < t; e++)
  8529. if (a2[e] === true)
  8530. return true;
  8531. return false;
  8532. }
  8533. _checkAsyncNode(i, a2) {
  8534. const e = i.getChildren(), t = e.length;
  8535. for (let r = 0; r < t; r++) {
  8536. const n = e[r];
  8537. a2.push(n.isAsync()), this._checkAsyncNode(n, a2);
  8538. }
  8539. }
  8540. async _executeAsync(i, a2 = 0, e = 0) {
  8541. if (this._runtimeService.isStopExecution())
  8542. return Promise.resolve(xt.ERROR);
  8543. const t = i.getChildren(), r = t.length;
  8544. for (let n = 0; n < r; n++) {
  8545. const s = t[n];
  8546. if (s.getToken().toUpperCase() === Sr && s.isEmptyParamFunction()) {
  8547. s.execute();
  8548. continue;
  8549. }
  8550. await this._executeAsync(s, a2, e);
  8551. }
  8552. return i.nodeType === oe.REFERENCE && i.setRefOffset(a2, e), i.nodeType === oe.FUNCTION && i.isAsync() ? await i.executeAsync() : i.execute(), Promise.resolve(xt.SUCCESS);
  8553. }
  8554. _execute(i, a2 = 0, e = 0) {
  8555. if (this._runtimeService.isStopExecution())
  8556. return xt.ERROR;
  8557. const t = i.getChildren(), r = t.length;
  8558. for (let n = 0; n < r; n++) {
  8559. const s = t[n];
  8560. if (s.getToken().toUpperCase() === Sr && s.isEmptyParamFunction()) {
  8561. s.execute();
  8562. continue;
  8563. }
  8564. this._execute(s, a2, e);
  8565. }
  8566. return i.nodeType === oe.REFERENCE && i.setRefOffset(a2, e), i.execute(), xt.SUCCESS;
  8567. }
  8568. };
  8569. Cr = Wf([
  8570. qf(0, Nt)
  8571. ], Cr);
  8572. function yo(i) {
  8573. return i instanceof ae ? i.getToken() === hr : false;
  8574. }
  8575. function Kf(i) {
  8576. return i instanceof ae ? i.getToken() === ro : false;
  8577. }
  8578. function Ea(i, a2, e) {
  8579. const t = i.getChildren(), r = t.length, n = t[0];
  8580. for (let s = 0; s < r; s++) {
  8581. const o = t[s];
  8582. if (!(yo(n) && s !== 0))
  8583. if (o instanceof ae)
  8584. Ea(o, a2, e);
  8585. else {
  8586. const u = o.trim();
  8587. if (e.has(u)) {
  8588. const c = new ae();
  8589. c.setToken(Tr), c.setLambdaId(a2), c.setLambdaPrivacyVar(e), c.setLambdaParameter(u), t[s] = c;
  8590. }
  8591. }
  8592. }
  8593. }
  8594. function Xf(i) {
  8595. let a2 = i;
  8596. for (; a2 != null && a2.getParent(); )
  8597. a2 = a2.getParent();
  8598. return a2;
  8599. }
  8600. function bi(i, a2 = 0, e = 0) {
  8601. return {
  8602. node: i,
  8603. refOffsetX: a2,
  8604. refOffsetY: e
  8605. };
  8606. }
  8607. function Ro(i) {
  8608. if (!i)
  8609. return;
  8610. if (i.getToken() !== Tr)
  8611. return i;
  8612. const a2 = i, e = a2.getCurrentLambdaPrivacyVar(), t = a2.getLambdaParameter();
  8613. if (!e)
  8614. return;
  8615. const r = e.get(t);
  8616. return r == null && i.getValue() ? i : Ro(r);
  8617. }
  8618. var ba = class _ba extends kt2 {
  8619. constructor(e, t, r) {
  8620. super(0);
  8621. A(this, "_lambdaPrivacyValueMap", /* @__PURE__ */ new Map());
  8622. this._lambdaNode = e, this._interpreter = t, this._lambdaPrivacyVarKeys = r, this._lambdaPrivacyValueMap.clear();
  8623. }
  8624. static create(e, t, r) {
  8625. return new _ba(e, t, r);
  8626. }
  8627. dispose() {
  8628. this._lambdaPrivacyValueMap.clear(), this._lambdaPrivacyValueMap = /* @__PURE__ */ new Map(), this._lambdaNode = null, this._interpreter = null, this._lambdaPrivacyVarKeys = [];
  8629. }
  8630. isLambda() {
  8631. return true;
  8632. }
  8633. execute(...e) {
  8634. const t = this._lambdaPrivacyVarKeys.length;
  8635. if (e.length !== t || !this._interpreter || !this._lambdaNode)
  8636. return g2.create(m2.VALUE);
  8637. this._setLambdaPrivacyValueMap(e), this._setLambdaNodeValue(this._lambdaNode), this._lambdaNode.setNotEmpty(false);
  8638. let r;
  8639. if (this._interpreter.checkAsyncNode(this._lambdaNode))
  8640. r = new Nf(this._interpreter.executeAsync(bi(this._lambdaNode)));
  8641. else {
  8642. const n = this._interpreter.execute(bi(this._lambdaNode));
  8643. n.isReferenceObject() ? r = n.toArrayValueObject() : r = n;
  8644. }
  8645. return this._lambdaNode.setNotEmpty(true), r;
  8646. }
  8647. /**
  8648. * Execute custom lambda function, handle basic types
  8649. * @param variants
  8650. */
  8651. executeCustom(...e) {
  8652. const t = e.map((r) => pt.create(r));
  8653. return this.execute(...t);
  8654. }
  8655. _setLambdaNodeValue(e) {
  8656. if (!e)
  8657. return;
  8658. const t = e.getChildren(), r = t.length;
  8659. for (let n = 0; n < r; n++) {
  8660. const s = t[n];
  8661. if (s.getToken() === Tr) {
  8662. const u = s.getLambdaParameter(), c = this._lambdaPrivacyValueMap.get(u);
  8663. if (c)
  8664. s.setValue(c);
  8665. else {
  8666. const l2 = s.getCurrentLambdaPrivacyVar(), f2 = Ro(l2.get(u));
  8667. f2 != null && s.setValue(f2.getValue());
  8668. }
  8669. continue;
  8670. }
  8671. this._setLambdaNodeValue(s);
  8672. }
  8673. }
  8674. _setLambdaPrivacyValueMap(e) {
  8675. for (let t = 0; t < e.length; t++) {
  8676. const r = e[t], n = this._lambdaPrivacyVarKeys[t];
  8677. this._lambdaPrivacyValueMap.set(n, r);
  8678. }
  8679. }
  8680. getLambdaPrivacyVarKeys() {
  8681. return this._lambdaPrivacyVarKeys;
  8682. }
  8683. };
  8684. var Zf = Object.defineProperty;
  8685. var zf = Object.getOwnPropertyDescriptor;
  8686. var Jf = (i, a2, e, t) => {
  8687. for (var r = t > 1 ? void 0 : t ? zf(a2, e) : a2, n = i.length - 1, s; n >= 0; n--)
  8688. (s = i[n]) && (r = (t ? s(a2, e, r) : s(r)) || r);
  8689. return t && r && Zf(a2, e, r), r;
  8690. };
  8691. var yi = (i, a2) => (e, t) => a2(e, t, i);
  8692. var eh = class extends Ge {
  8693. constructor(e, t, r, n) {
  8694. super(e);
  8695. A(this, "_isNotEmpty", true);
  8696. this._lambdaId = t, this._interpreter = r, this._lambdaPrivacyVarKeys = n;
  8697. }
  8698. get nodeType() {
  8699. return oe.LAMBDA;
  8700. }
  8701. setNotEmpty(e = false) {
  8702. this._isNotEmpty = e;
  8703. }
  8704. isEmptyParamFunction() {
  8705. return this.getChildren().length < 2 && this._isNotEmpty;
  8706. }
  8707. isFunctionParameter() {
  8708. return this._lambdaId === null;
  8709. }
  8710. getLambdaId() {
  8711. return this._lambdaId;
  8712. }
  8713. execute() {
  8714. if (this.isEmptyParamFunction())
  8715. this.setValue(ba.create(this, this._interpreter, this._lambdaPrivacyVarKeys));
  8716. else {
  8717. const e = this.getChildren(), t = e.length;
  8718. this.setValue(e[t - 1].getValue());
  8719. }
  8720. }
  8721. // override async executeAsync() {
  8722. // if (this.isEmptyParamFunction()) {
  8723. // await this.setValue(LambdaValueObjectObject.create(this, this._interpreter, this._lambdaPrivacyVarKeys));
  8724. // } else {
  8725. // const children = this.getChildren();
  8726. // const childrenCount = children.length;
  8727. // await this.setValue(children[childrenCount - 1].getValue());
  8728. // }
  8729. // return Promise.resolve(AstNodePromiseType.SUCCESS);
  8730. // }
  8731. };
  8732. var bn = class extends Et {
  8733. constructor(i, a2) {
  8734. super(), this._runtimeService = i, this._interpreter = a2;
  8735. }
  8736. get zIndex() {
  8737. return _t.get(oe.LAMBDA) || At;
  8738. }
  8739. create(i) {
  8740. const a2 = i.getChildren(), e = a2[0];
  8741. let t = a2.slice(1, -1);
  8742. const r = a2[a2.length - 1];
  8743. if (!(e instanceof ae && r instanceof ae))
  8744. return xe.create(m2.NAME);
  8745. if (e.getToken() === hr) {
  8746. const o = e.getChildren();
  8747. if (t.length !== o.length)
  8748. return xe.create(m2.VALUE);
  8749. } else
  8750. t = a2.slice(0, -1);
  8751. const n = re.generateRandomId(8), s = /* @__PURE__ */ new Map();
  8752. for (let o = 0; o < t.length; o++) {
  8753. const u = t[o];
  8754. if (u instanceof ae) {
  8755. const c = u.getChildren()[0];
  8756. u.setToken(ro), s.set(c.trim(), void 0);
  8757. } else
  8758. return xe.create(m2.VALUE);
  8759. }
  8760. return this._runtimeService.registerFunctionDefinitionPrivacyVar(n, s), this._updateLambdaStatement(r, n, s), new eh(i.getToken(), n, this._interpreter, [...s.keys()]);
  8761. }
  8762. checkAndCreateNodeType(i) {
  8763. if (!(!(i instanceof ae) || i.getToken().trim().toUpperCase() !== Sr))
  8764. return this.create(i);
  8765. }
  8766. _updateLambdaStatement(i, a2, e) {
  8767. Ea(i, a2, e);
  8768. }
  8769. };
  8770. bn = Jf([
  8771. yi(0, Nt),
  8772. yi(1, ot(Cr))
  8773. ], bn);
  8774. function po(i) {
  8775. if (!i)
  8776. return;
  8777. if (i.getToken() !== Tr)
  8778. return i;
  8779. const a2 = i, e = a2.getCurrentLambdaPrivacyVar(), t = a2.getLambdaParameter();
  8780. if (e)
  8781. return po(e.get(t));
  8782. }
  8783. var th = class extends Ge {
  8784. constructor(a2, e, t) {
  8785. super(a2), this._lambdaParameter = e, this._currentLambdaPrivacyVar = t;
  8786. }
  8787. getLambdaParameter() {
  8788. return this._lambdaParameter;
  8789. }
  8790. getCurrentLambdaPrivacyVar() {
  8791. return this._currentLambdaPrivacyVar;
  8792. }
  8793. get nodeType() {
  8794. return oe.LAMBDA_PARAMETER;
  8795. }
  8796. execute() {
  8797. const a2 = po(this._currentLambdaPrivacyVar.get(this._lambdaParameter));
  8798. if (a2)
  8799. this.setValue(a2.getValue());
  8800. else {
  8801. const e = this.getValue();
  8802. (e == null || e.isError()) && this.setValue(g2.create(m2.NAME));
  8803. }
  8804. }
  8805. };
  8806. var Vo = class extends Et {
  8807. get zIndex() {
  8808. return _t.get(oe.LAMBDA_PARAMETER) || At;
  8809. }
  8810. create(a2) {
  8811. const e = a2.getFunctionDefinitionPrivacyVar(), t = a2.getLambdaParameter();
  8812. return e ? new th(a2.getToken(), t, e) : new xe(m2.NAME);
  8813. }
  8814. checkAndCreateNodeType(a2) {
  8815. if (!(!(a2 instanceof ae) || a2.getToken().trim() !== Tr))
  8816. return this.create(a2);
  8817. }
  8818. };
  8819. var rh = class extends Ge {
  8820. constructor(a2) {
  8821. super(a2), this._operatorString = a2;
  8822. }
  8823. get nodeType() {
  8824. return oe.NULL;
  8825. }
  8826. execute() {
  8827. this.setValue(ie.create());
  8828. }
  8829. };
  8830. var Y2 = ((i) => (i.ABS = "ABS", i.ACOS = "ACOS", i.ACOSH = "ACOSH", i.ACOT = "ACOT", i.ACOTH = "ACOTH", i.AGGREGATE = "AGGREGATE", i.ARABIC = "ARABIC", i.ASIN = "ASIN", i.ASINH = "ASINH", i.ATAN = "ATAN", i.ATAN2 = "ATAN2", i.ATANH = "ATANH", i.BASE = "BASE", i.CEILING = "CEILING", i.CEILING_MATH = "CEILING.MATH", i.CEILING_PRECISE = "CEILING.PRECISE", i.COMBIN = "COMBIN", i.COMBINA = "COMBINA", i.COS = "COS", i.COSH = "COSH", i.COT = "COT", i.COTH = "COTH", i.CSC = "CSC", i.CSCH = "CSCH", i.DECIMAL = "DECIMAL", i.DEGREES = "DEGREES", i.EVEN = "EVEN", i.EXP = "EXP", i.FACT = "FACT", i.FACTDOUBLE = "FACTDOUBLE", i.FLOOR = "FLOOR", i.FLOOR_MATH = "FLOOR.MATH", i.FLOOR_PRECISE = "FLOOR.PRECISE", i.GCD = "GCD", i.INT = "INT", i.ISO_CEILING = "ISO.CEILING", i.LCM = "LCM", i.LET = "LET", i.LN = "LN", i.LOG = "LOG", i.LOG10 = "LOG10", i.MDETERM = "MDETERM", i.MINVERSE = "MINVERSE", i.MMULT = "MMULT", i.MOD = "MOD", i.MROUND = "MROUND", i.MULTINOMIAL = "MULTINOMIAL", i.MUNIT = "MUNIT", i.ODD = "ODD", i.PI = "PI", i.POWER = "POWER", i.PRODUCT = "PRODUCT", i.QUOTIENT = "QUOTIENT", i.RADIANS = "RADIANS", i.RAND = "RAND", i.RANDARRAY = "RANDARRAY", i.RANDBETWEEN = "RANDBETWEEN", i.ROMAN = "ROMAN", i.ROUND = "ROUND", i.ROUNDBANK = "ROUNDBANK", i.ROUNDDOWN = "ROUNDDOWN", i.ROUNDUP = "ROUNDUP", i.SEC = "SEC", i.SECH = "SECH", i.SERIESSUM = "SERIESSUM", i.SEQUENCE = "SEQUENCE", i.SIGN = "SIGN", i.SIN = "SIN", i.SINH = "SINH", i.SQRT = "SQRT", i.SQRTPI = "SQRTPI", i.SUBTOTAL = "SUBTOTAL", i.SUM = "SUM", i.SUMIF = "SUMIF", i.SUMIFS = "SUMIFS", i.SUMPRODUCT = "SUMPRODUCT", i.SUMSQ = "SUMSQ", i.SUMX2MY2 = "SUMX2MY2", i.SUMX2PY2 = "SUMX2PY2", i.SUMXMY2 = "SUMXMY2", i.TAN = "TAN", i.TANH = "TANH", i.TRUNC = "TRUNC", i))(Y2 || {});
  8831. var se = ((i) => (i.ASC = "ASC", i.ARRAYTOTEXT = "ARRAYTOTEXT", i.BAHTTEXT = "BAHTTEXT", i.CHAR = "CHAR", i.CLEAN = "CLEAN", i.CODE = "CODE", i.CONCAT = "CONCAT", i.CONCATENATE = "CONCATENATE", i.DBCS = "DBCS", i.DOLLAR = "DOLLAR", i.EXACT = "EXACT", i.FIND = "FIND", i.FINDB = "FINDB", i.FIXED = "FIXED", i.LEFT = "LEFT", i.LEFTB = "LEFTB", i.LEN = "LEN", i.LENB = "LENB", i.LOWER = "LOWER", i.MID = "MID", i.MIDB = "MIDB", i.NUMBERVALUE = "NUMBERVALUE", i.PHONETIC = "PHONETIC", i.PROPER = "PROPER", i.REGEXEXTRACT = "REGEXEXTRACT", i.REGEXMATCH = "REGEXMATCH", i.REGEXREPLACE = "REGEXREPLACE", i.REPLACE = "REPLACE", i.REPLACEB = "REPLACEB", i.REPT = "REPT", i.RIGHT = "RIGHT", i.RIGHTB = "RIGHTB", i.SEARCH = "SEARCH", i.SEARCHB = "SEARCHB", i.SUBSTITUTE = "SUBSTITUTE", i.T = "T", i.TEXT = "TEXT", i.TEXTAFTER = "TEXTAFTER", i.TEXTBEFORE = "TEXTBEFORE", i.TEXTJOIN = "TEXTJOIN", i.TEXTSPLIT = "TEXTSPLIT", i.TRIM = "TRIM", i.UNICHAR = "UNICHAR", i.UNICODE = "UNICODE", i.UPPER = "UPPER", i.VALUE = "VALUE", i.VALUETOTEXT = "VALUETOTEXT", i.CALL = "CALL", i.EUROCONVERT = "EUROCONVERT", i.REGISTER_ID = "REGISTER.ID", i))(se || {});
  8832. var nh = Object.defineProperty;
  8833. var sh = Object.getOwnPropertyDescriptor;
  8834. var ah = (i, a2, e, t) => {
  8835. for (var r = t > 1 ? void 0 : t ? sh(a2, e) : a2, n = i.length - 1, s; n >= 0; n--)
  8836. (s = i[n]) && (r = (t ? s(a2, e, r) : s(r)) || r);
  8837. return t && r && nh(a2, e, r), r;
  8838. };
  8839. var ih = (i, a2) => (e, t) => a2(e, t, i);
  8840. var oh = class extends Ge {
  8841. constructor(a2, e) {
  8842. super(a2), this._functionExecutor = e;
  8843. }
  8844. get nodeType() {
  8845. return oe.OPERATOR;
  8846. }
  8847. execute() {
  8848. const a2 = this.getChildren();
  8849. this._functionExecutor.name === Te.COMPARE && this._functionExecutor.setCompareType(this.getToken());
  8850. const e = a2[0], t = a2[1];
  8851. let r = e == null ? void 0 : e.getValue(), n = t == null ? void 0 : t.getValue();
  8852. const s = this.getToken();
  8853. if ((r == null || n == null) && s !== X2.MINUS && s !== X2.PLUS) {
  8854. this.setValue(g2.create(m2.VALUE));
  8855. return;
  8856. }
  8857. r == null && (r = ie.create()), n == null && (n = ie.create()), r.isReferenceObject() && (r = r.toArrayValueObject()), n.isReferenceObject() && (n = n.toArrayValueObject()), this.setValue(
  8858. this._functionExecutor.calculate(
  8859. r,
  8860. n
  8861. )
  8862. );
  8863. }
  8864. };
  8865. var yn = class extends Et {
  8866. constructor(i) {
  8867. super(), this._functionService = i;
  8868. }
  8869. get zIndex() {
  8870. return _t.get(oe.OPERATOR) || At;
  8871. }
  8872. create(i) {
  8873. let a2 = "";
  8874. const e = i;
  8875. e === X2.PLUS ? a2 = Te.PLUS : e === X2.MINUS ? a2 = Te.MINUS : e === X2.MULTIPLY ? a2 = Te.MULTIPLY : e === X2.DIVIDED ? a2 = Te.DIVIDED : e === X2.CONCATENATE ? a2 = se.CONCATENATE : e === X2.POWER ? a2 = Y2.POWER : ec.has(e) && (a2 = Te.COMPARE);
  8876. const t = this._functionService.getExecutor(a2);
  8877. return t ? new oh(e, t) : (console.error(`No function ${i}`), xe.create(m2.NAME));
  8878. }
  8879. checkAndCreateNodeType(i) {
  8880. if (i instanceof ae)
  8881. return;
  8882. const a2 = i.trim();
  8883. if (!(a2.charAt(0) === '"' && a2.charAt(a2.length - 1) === '"') && Dt.has(a2))
  8884. return this.create(a2);
  8885. }
  8886. };
  8887. yn = ah([
  8888. ih(0, Yt)
  8889. ], yn);
  8890. var uh = Object.defineProperty;
  8891. var ch = Object.getOwnPropertyDescriptor;
  8892. var lh = (i, a2, e, t) => {
  8893. for (var r = t > 1 ? void 0 : t ? ch(a2, e) : a2, n = i.length - 1, s; n >= 0; n--)
  8894. (s = i[n]) && (r = (t ? s(a2, e, r) : s(r)) || r);
  8895. return t && r && uh(a2, e, r), r;
  8896. };
  8897. var cs = (i, a2) => (e, t) => a2(e, t, i);
  8898. var ls = class extends Ge {
  8899. constructor(e, t, r, n, s = false) {
  8900. super(r);
  8901. A(this, "_refOffsetX", 0);
  8902. A(this, "_refOffsetY", 0);
  8903. this._currentConfigService = e, this._runtimeService = t, this._referenceObjectType = n, this._isPrepareMerge = s;
  8904. }
  8905. get nodeType() {
  8906. return oe.REFERENCE;
  8907. }
  8908. execute() {
  8909. const e = this._currentConfigService, t = this._runtimeService, r = Sf(this.getToken(), this._referenceObjectType);
  8910. r.setDefaultUnitId(t.currentUnitId), r.setDefaultSheetId(t.currentSubUnitId), r.setForcedSheetId(e.getSheetNameMap()), r.setUnitData(e.getUnitData()), r.setArrayFormulaCellData(e.getArrayFormulaCellData()), r.setRuntimeData(t.getUnitData()), r.setUnitStylesData(e.getUnitStylesData()), r.setRuntimeArrayFormulaCellData(t.getRuntimeArrayFormulaCellData()), r.setRuntimeFeatureCellData(t.getRuntimeFeatureCellData());
  8911. const { x: n, y: s } = this.getRefOffset();
  8912. r.setRefOffset(n, s), !this._isPrepareMerge && r.isExceedRange() ? this.setValue(g2.create(m2.NAME)) : this.setValue(r);
  8913. }
  8914. setRefOffset(e = 0, t = 0) {
  8915. this._refOffsetX = e, this._refOffsetY = t;
  8916. }
  8917. getRefOffset() {
  8918. return {
  8919. x: this._refOffsetX,
  8920. y: this._refOffsetY
  8921. };
  8922. }
  8923. };
  8924. var Rn = class extends Et {
  8925. constructor(i, a2, e) {
  8926. super(), this._currentConfigService = i, this._formulaRuntimeService = a2, this._functionService = e;
  8927. }
  8928. get zIndex() {
  8929. return _t.get(oe.REFERENCE) || At;
  8930. }
  8931. checkAndCreateNodeType(i) {
  8932. var l2, f2;
  8933. let a2 = false, e, t = false;
  8934. i instanceof ae ? (a2 = true, e = i.getToken().trim(), ((f2 = (l2 = i.getParent()) == null ? void 0 : l2.getParent()) == null ? void 0 : f2.getToken().trim()) === K2.COLON && (t = true)) : e = i.trim();
  8935. const r = this._currentConfigService, n = this._formulaRuntimeService, { tokenTrim: s, minusPrefixNode: o, atPrefixNode: u } = bo(e, this._functionService, n);
  8936. if (!a2 && s.charAt(0) === '"' && s.charAt(s.length - 1) === '"')
  8937. return;
  8938. let c;
  8939. if (vr(s) ? c = new ls(r, n, s, an.CELL, t) : a2 && this._checkParentIsUnionOperator(i) && (Qi(s) ? c = new ls(r, n, s, an.ROW, t) : Wi(s) && (c = new ls(r, n, s, an.COLUMN, t))), c)
  8940. return u ? c.setParent(u) : o && c.setParent(o), c;
  8941. }
  8942. _checkParentIsUnionOperator(i) {
  8943. var a2, e;
  8944. return ((e = (a2 = i.getParent()) == null ? void 0 : a2.getParent()) == null ? void 0 : e.getToken().trim()) === K2.COLON;
  8945. }
  8946. };
  8947. Rn = lh([
  8948. cs(0, Ft),
  8949. cs(1, Nt),
  8950. cs(2, Yt)
  8951. ], Rn);
  8952. var fh = Object.defineProperty;
  8953. var hh = Object.getOwnPropertyDescriptor;
  8954. var mh = (i, a2, e, t) => {
  8955. for (var r = t > 1 ? void 0 : t ? hh(a2, e) : a2, n = i.length - 1, s; n >= 0; n--)
  8956. (s = i[n]) && (r = (t ? s(a2, e, r) : s(r)) || r);
  8957. return t && r && fh(a2, e, r), r;
  8958. };
  8959. var fs = (i, a2) => (e, t) => a2(e, t, i);
  8960. var Ri = class extends Ge {
  8961. constructor(a2, e, t, r) {
  8962. super(t), this._currentConfigService = a2, this._lexer = e, this._operatorString = t, this._functionExecutor = r;
  8963. }
  8964. get nodeType() {
  8965. return oe.SUFFIX;
  8966. }
  8967. execute() {
  8968. let e = this.getChildren()[0].getValue(), t;
  8969. if (e == null)
  8970. throw new Error("object is null");
  8971. if (this._operatorString === ze.PERCENTAGE) {
  8972. if (e.isReferenceObject() && (e = e.toArrayValueObject()), t = this._functionExecutor.calculate(
  8973. e,
  8974. y2.create(100)
  8975. ), t.isNumber()) {
  8976. const r = Number(t.getValue());
  8977. t = y2.create(r, "0.00%");
  8978. }
  8979. } else
  8980. this._operatorString === ze.POUND ? t = this._handlerPound(e) : t = g2.create(m2.VALUE);
  8981. this.setValue(t);
  8982. }
  8983. _handlerPound(a2) {
  8984. var u, c, l2, f2;
  8985. if (!a2.isReferenceObject() || !a2.isCell())
  8986. return g2.create(m2.VALUE);
  8987. const e = a2, t = e.getRangePosition(), r = e.getUnitId(), n = e.getSheetId(), s = this._currentConfigService.getFormulaData(), o = (f2 = (l2 = (c = (u = s == null ? void 0 : s[r]) == null ? void 0 : u[n]) == null ? void 0 : c[t.startRow]) == null ? void 0 : l2[t.startColumn]) == null ? void 0 : f2.f;
  8988. return o && this._lexer.treeBuilder(o), g2.create(m2.VALUE);
  8989. }
  8990. };
  8991. var pn = class extends Et {
  8992. constructor(i, a2, e) {
  8993. super(), this._functionService = i, this._lexer = a2, this._currentConfigService = e;
  8994. }
  8995. get zIndex() {
  8996. return _t.get(oe.SUFFIX) || At;
  8997. }
  8998. checkAndCreateNodeType(i) {
  8999. if (!(i instanceof ae))
  9000. return;
  9001. const a2 = i.getToken().trim();
  9002. if (a2.charAt(0) === '"' && a2.charAt(a2.length - 1) === '"')
  9003. return;
  9004. let e = "";
  9005. if (a2 === ze.PERCENTAGE)
  9006. e = Te.DIVIDED;
  9007. else
  9008. return a2 === ze.POUND ? new Ri(this._currentConfigService, this._lexer, a2) : void 0;
  9009. const t = this._functionService.getExecutor(e);
  9010. return t ? new Ri(this._currentConfigService, this._lexer, a2, t) : (console.error(`No function ${i}`), xe.create(m2.NAME));
  9011. }
  9012. };
  9013. pn = mh([
  9014. fs(0, Yt),
  9015. fs(1, ot(gr)),
  9016. fs(2, Ft)
  9017. ], pn);
  9018. var gh = Object.defineProperty;
  9019. var dh = Object.getOwnPropertyDescriptor;
  9020. var Ch = (i, a2, e, t) => {
  9021. for (var r = t > 1 ? void 0 : t ? dh(a2, e) : a2, n = i.length - 1, s; n >= 0; n--)
  9022. (s = i[n]) && (r = (t ? s(a2, e, r) : s(r)) || r);
  9023. return t && r && gh(a2, e, r), r;
  9024. };
  9025. var _h = (i, a2) => (e, t) => a2(e, t, i);
  9026. var Ah = class extends Ge {
  9027. constructor(a2) {
  9028. super(a2);
  9029. }
  9030. get nodeType() {
  9031. return oe.UNION;
  9032. }
  9033. execute() {
  9034. const a2 = this.getChildren(), e = a2[0], t = a2[1], r = e.getValue(), n = t.getValue();
  9035. if (r == null || n == null)
  9036. throw new Error("leftNode and rightNode");
  9037. let s;
  9038. this.getToken() === K2.COLON ? s = this._unionFunction(r, n) : s = g2.create(m2.NAME), this.setValue(s);
  9039. }
  9040. _unionFunction(a2, e) {
  9041. return a2.isError() || e.isError() || !a2.isReferenceObject() || !e.isReferenceObject() ? g2.create(m2.REF) : (a2 = a2, e = e, Pf(a2, e));
  9042. }
  9043. };
  9044. var Vn = class extends Et {
  9045. constructor(i) {
  9046. super(), this._functionService = i;
  9047. }
  9048. get zIndex() {
  9049. return _t.get(oe.UNION) || At;
  9050. }
  9051. create(i) {
  9052. return new Ah(i);
  9053. }
  9054. checkAndCreateNodeType(i) {
  9055. if (!(i instanceof ae))
  9056. return;
  9057. const e = i.getToken().trim();
  9058. if (!(e.charAt(0) === '"' && e.charAt(e.length - 1) === '"') && e === K2.COLON)
  9059. return this.create(e);
  9060. }
  9061. };
  9062. Vn = Ch([
  9063. _h(0, Yt)
  9064. ], Vn);
  9065. var Eh = class extends Ge {
  9066. constructor(a2) {
  9067. super(a2);
  9068. }
  9069. get nodeType() {
  9070. return oe.VALUE;
  9071. }
  9072. execute() {
  9073. this.setValue(pt.create(this.getToken()));
  9074. }
  9075. };
  9076. var No = class extends Et {
  9077. get zIndex() {
  9078. return _t.get(oe.VALUE) || At;
  9079. }
  9080. _checkValueNode(a2) {
  9081. if (Number.isNaN(Number(a2))) {
  9082. const e = a2.trim(), t = e.charAt(0), r = e.charAt(e.length - 1);
  9083. if (yr.has(e))
  9084. return this.create(e);
  9085. if (t === '"' && r === '"')
  9086. return this.create(e);
  9087. if (t === "{" && r === "}")
  9088. return this.create(e);
  9089. const n = e.toUpperCase();
  9090. if (n === er.TRUE || n === er.FALSE)
  9091. return this.create(n);
  9092. } else
  9093. return this.create(a2);
  9094. }
  9095. create(a2) {
  9096. return new Eh(a2);
  9097. }
  9098. checkAndCreateNodeType(a2) {
  9099. if (!(a2 instanceof ae))
  9100. return this._checkValueNode(a2);
  9101. }
  9102. };
  9103. var bh = Object.defineProperty;
  9104. var yh = Object.getOwnPropertyDescriptor;
  9105. var Rh = (i, a2, e, t) => {
  9106. for (var r = t > 1 ? void 0 : t ? yh(a2, e) : a2, n = i.length - 1, s; n >= 0; n--)
  9107. (s = i[n]) && (r = (t ? s(a2, e, r) : s(r)) || r);
  9108. return t && r && bh(a2, e, r), r;
  9109. };
  9110. var at = (i, a2) => (e, t) => a2(e, t, i);
  9111. var xr = class extends nt {
  9112. constructor(a2, e, t, r, n, s, o, u, c, l2, f2) {
  9113. super();
  9114. A(this, "_astNodeFactoryList", []);
  9115. this._runtimeService = a2, this._astRootNodeFactory = e, this._functionNodeFactory = t, this._lambdaNodeFactory = r, this._lambdaParameterNodeFactory = n, this._operatorNodeFactory = s, this._prefixNodeFactory = o, this._referenceNodeFactory = u, this._suffixNodeFactory = c, this._unionNodeFactory = l2, this._valueNodeFactory = f2, this._initializeAstNode();
  9116. }
  9117. dispose() {
  9118. this._astNodeFactoryList.forEach((a2) => {
  9119. a2.dispose();
  9120. }), this._astNodeFactoryList = [];
  9121. }
  9122. parse(a2) {
  9123. const e = new Fs(Ut), t = this._parse(a2, e);
  9124. return a2.hasDefinedNames() && (t == null || t.setDefinedNames(a2.getDefinedNames())), t;
  9125. }
  9126. _lambdaParameterHandler(a2, e) {
  9127. if (e.getLambdaId == null)
  9128. return xe.create(m2.VALUE);
  9129. const t = e.getLambdaId(), r = new Fs(Ut), n = this._runtimeService.getFunctionDefinitionPrivacyVar(t);
  9130. if (!n)
  9131. return false;
  9132. const s = [...n.keys()], o = a2.getChildren(), u = o.length;
  9133. for (let c = 0; c < u; c++) {
  9134. const l2 = o[c];
  9135. if (l2 instanceof ae) {
  9136. Ea(l2, t, n), this._parse(l2, r);
  9137. const h = r.getChildren()[c];
  9138. h != null && n.set(s[c], h);
  9139. } else
  9140. return false;
  9141. }
  9142. return r.setParent(e), e;
  9143. }
  9144. _changeLetToLambda(a2) {
  9145. const e = a2.getChildren(), t = e.length;
  9146. if (t % 2 !== 1 || t === 0)
  9147. return;
  9148. const r = new ae();
  9149. r.setToken(Sr);
  9150. const n = new ae();
  9151. n.setToken(hr);
  9152. const s = [...e];
  9153. for (let u = 0; u < t; u++) {
  9154. const c = s[u];
  9155. if (!(c instanceof ae))
  9156. return;
  9157. u % 2 === 0 ? c.changeToParent(r) : c.changeToParent(n);
  9158. }
  9159. r.addChildrenFirst(n), n.setParent(r);
  9160. const o = a2.getParent();
  9161. return o == null || o.replaceChild(a2, r), r;
  9162. }
  9163. // eslint-disable-next-line max-lines-per-function, complexity
  9164. _parse(a2, e) {
  9165. var l2;
  9166. const t = a2.getChildren(), r = t.length, n = [];
  9167. let s = null;
  9168. const o = a2.getToken().trim().toUpperCase();
  9169. if (o === vc) {
  9170. const f2 = this._changeLetToLambda(a2);
  9171. return f2 != null ? this._parse(f2, e) : xe.create(m2.ERROR);
  9172. }
  9173. if (o === ht) {
  9174. if (s = e, r === 0)
  9175. return new rh(Ut).setParent(e), s;
  9176. } else {
  9177. if (o === hr) {
  9178. let f2 = this._lambdaParameterHandler(a2, e);
  9179. return f2 === false && (f2 = xe.create(m2.ERROR)), f2;
  9180. }
  9181. if (s = this._checkAstNode(a2), s == null)
  9182. return xe.create(m2.NAME);
  9183. }
  9184. const u = t[0];
  9185. for (let f2 = 0; f2 < r; f2++) {
  9186. const h = t[f2];
  9187. if (yo(u)) {
  9188. if (f2 !== 0 && f2 !== r - 1)
  9189. continue;
  9190. } else if (Kf(h) && f2 !== r - 1)
  9191. continue;
  9192. let d2 = null;
  9193. if (h instanceof ae) {
  9194. if (h.getToken() === ht && h.getChildren().length === 0) {
  9195. const _ = (l2 = h.getParent()) == null ? void 0 : l2.getChildren();
  9196. if (_ && _.length === 1)
  9197. return xe.create(m2.NAME);
  9198. }
  9199. if (d2 = this._parse(h, s), d2 === s)
  9200. continue;
  9201. } else
  9202. d2 = this._checkAstNode(h);
  9203. if (d2 == null)
  9204. return xe.create(m2.NAME);
  9205. if (d2 = Xf(d2), d2 == null || (d2 == null ? void 0 : d2.nodeType) === oe.ERROR)
  9206. return d2;
  9207. switch (d2.nodeType) {
  9208. case oe.FUNCTION: {
  9209. const _ = d2.getToken().trim().toUpperCase();
  9210. Bc.has(_) && d2.setForcedCalculateFunction(), n.push(d2);
  9211. break;
  9212. }
  9213. case oe.LAMBDA:
  9214. n.push(d2);
  9215. break;
  9216. case oe.LAMBDA_PARAMETER:
  9217. n.push(d2);
  9218. break;
  9219. case oe.OPERATOR: {
  9220. const _ = n.pop(), C = n.pop();
  9221. C && C.setParent(d2), _ && _.setParent(d2), n.push(d2);
  9222. break;
  9223. }
  9224. case oe.REFERENCE:
  9225. n.push(d2);
  9226. break;
  9227. case oe.ROOT:
  9228. n.push(d2);
  9229. break;
  9230. case oe.UNION:
  9231. n.push(d2);
  9232. break;
  9233. case oe.VALUE:
  9234. n.push(d2);
  9235. break;
  9236. case oe.PREFIX:
  9237. n.push(d2);
  9238. break;
  9239. case oe.SUFFIX:
  9240. n.push(d2);
  9241. break;
  9242. }
  9243. }
  9244. const c = n.length;
  9245. for (let f2 = 0; f2 < c; f2++)
  9246. n[f2].setParent(s);
  9247. return s;
  9248. }
  9249. // private _setPrefixRefOffset(astNode: BaseAstNode) {
  9250. // const children = astNode.getChildren();
  9251. // const childrenCount = children.length;
  9252. // for (let i = 0; i < childrenCount; i++) {
  9253. // const item = children[i];
  9254. // if (item.nodeType === NodeType.REFERENCE) {
  9255. // item.setRefOffset(this._refOffsetX, this._refOffsetY);
  9256. // }
  9257. // }
  9258. // }
  9259. _checkAstNode(a2) {
  9260. let e = null;
  9261. const t = this._astNodeFactoryList.length;
  9262. for (let r = 0; r < t && (e = this._astNodeFactoryList[r].checkAndCreateNodeType(a2), e == null); r++)
  9263. ;
  9264. return e == null ? new Hf() : e;
  9265. }
  9266. _initializeAstNode() {
  9267. this._astNodeFactoryList = [
  9268. this._astRootNodeFactory,
  9269. this._functionNodeFactory,
  9270. this._lambdaNodeFactory,
  9271. this._lambdaParameterNodeFactory,
  9272. this._operatorNodeFactory,
  9273. this._prefixNodeFactory,
  9274. this._referenceNodeFactory,
  9275. this._suffixNodeFactory,
  9276. this._unionNodeFactory,
  9277. this._valueNodeFactory
  9278. ].sort(KC);
  9279. }
  9280. };
  9281. xr = Rh([
  9282. at(0, Nt),
  9283. at(1, ot(Eo)),
  9284. at(2, ot(En)),
  9285. at(3, ot(bn)),
  9286. at(4, ot(Vo)),
  9287. at(5, ot(yn)),
  9288. at(6, ot(An)),
  9289. at(7, ot(Rn)),
  9290. at(8, ot(pn)),
  9291. at(9, ot(Vn)),
  9292. at(10, ot(No))
  9293. ], xr);
  9294. var ph = class extends nt {
  9295. constructor() {
  9296. super(...arguments);
  9297. A(this, "_otherFormulaData", /* @__PURE__ */ new Map());
  9298. A(this, "_featureFormulaData", /* @__PURE__ */ new Map());
  9299. A(this, "_formulaData", /* @__PURE__ */ new Map());
  9300. A(this, "_definedNameMap", /* @__PURE__ */ new Map());
  9301. A(this, "_otherFormulaDataMainData", /* @__PURE__ */ new Set());
  9302. A(this, "_dependencyRTreeCache", new $R());
  9303. A(this, "_dependencyTreeIdLast", 0);
  9304. }
  9305. buildDependencyTree(e, t) {
  9306. throw new Error("Method not implemented.");
  9307. }
  9308. getTreeById(e) {
  9309. throw new Error("Method not implemented.");
  9310. }
  9311. getAllTree() {
  9312. throw new Error("Method not implemented.");
  9313. }
  9314. reset() {
  9315. throw new Error("Method not implemented.");
  9316. }
  9317. addOtherFormulaDependency(e, t, r, n) {
  9318. throw new Error("Method not implemented.");
  9319. }
  9320. removeOtherFormulaDependency(e, t, r) {
  9321. throw new Error("Method not implemented.");
  9322. }
  9323. clearOtherFormulaDependency(e, t) {
  9324. throw new Error("Method not implemented.");
  9325. }
  9326. addFeatureFormulaDependency(e, t, r, n) {
  9327. throw new Error("Method not implemented.");
  9328. }
  9329. removeFeatureFormulaDependency(e, t, r) {
  9330. throw new Error("Method not implemented.");
  9331. }
  9332. clearFeatureFormulaDependency(e, t) {
  9333. throw new Error("Method not implemented.");
  9334. }
  9335. addFormulaDependency(e, t, r, n, s) {
  9336. throw new Error("Method not implemented.");
  9337. }
  9338. removeFormulaDependency(e, t, r, n) {
  9339. throw new Error("Method not implemented.");
  9340. }
  9341. clearFormulaDependency(e, t) {
  9342. throw new Error("Method not implemented.");
  9343. }
  9344. removeFormulaDependencyByDefinedName(e, t) {
  9345. throw new Error("Method not implemented.");
  9346. }
  9347. searchDependency(e, t) {
  9348. return this._dependencyRTreeCache.bulkSearch(e, t);
  9349. }
  9350. _restDependencyTreeId() {
  9351. this._dependencyTreeIdLast = 0;
  9352. }
  9353. getOtherFormulaDependency(e, t, r) {
  9354. var n, s;
  9355. return (s = (n = this._otherFormulaData.get(e)) == null ? void 0 : n.get(t)) == null ? void 0 : s.get(r);
  9356. }
  9357. addOtherFormulaDependencyMainData(e) {
  9358. this._otherFormulaDataMainData.add(e);
  9359. }
  9360. hasOtherFormulaDataMainData(e) {
  9361. return this._otherFormulaDataMainData.has(e);
  9362. }
  9363. _removeDependencyRTreeCacheById(e, t) {
  9364. this._dependencyRTreeCache.removeById(e, t);
  9365. }
  9366. getFeatureFormulaDependency(e, t, r) {
  9367. var n, s;
  9368. return (s = (n = this._featureFormulaData.get(e)) == null ? void 0 : n.get(t)) == null ? void 0 : s.get(r);
  9369. }
  9370. getFormulaDependency(e, t, r, n) {
  9371. var s, o;
  9372. return (o = (s = this._formulaData.get(e)) == null ? void 0 : s.get(t)) == null ? void 0 : o.getValue(r, n);
  9373. }
  9374. addDependencyRTreeCache(e) {
  9375. const t = [];
  9376. for (let r = 0; r < e.rangeList.length; r++) {
  9377. const n = e.rangeList[r], { unitId: s, sheetId: o, range: u } = n;
  9378. t.push({
  9379. unitId: s,
  9380. sheetId: o,
  9381. range: u,
  9382. id: e.treeId
  9383. });
  9384. }
  9385. this._dependencyRTreeCache.bulkInsert(t), this._addAllTreeMap(e);
  9386. }
  9387. getLastTreeId() {
  9388. const e = this._dependencyTreeIdLast;
  9389. return this._dependencyTreeIdLast++, e;
  9390. }
  9391. _addAllTreeMap(e) {
  9392. throw new Error("Method not implemented.");
  9393. }
  9394. _addDefinedName(e, t, r) {
  9395. this._definedNameMap.has(e) || this._definedNameMap.set(e, /* @__PURE__ */ new Map());
  9396. const n = this._definedNameMap.get(e);
  9397. n.has(t) || n.set(t, /* @__PURE__ */ new Set()), n.get(t).add(r);
  9398. }
  9399. addFormulaDependencyByDefinedName(e, t) {
  9400. const r = e.treeId, n = (t == null ? void 0 : t.getDefinedNames()) || [];
  9401. for (const s of n)
  9402. this._addDefinedName(e.unitId, s, r);
  9403. }
  9404. };
  9405. var Vh = class extends ph {
  9406. constructor() {
  9407. super(...arguments);
  9408. A(this, "_allTreeMap", /* @__PURE__ */ new Map());
  9409. }
  9410. dispose() {
  9411. this.reset();
  9412. }
  9413. buildDependencyTree(e, t = []) {
  9414. const r = this.getAllTree();
  9415. return e.length === 0 ? (this._buildReverseDependency(r, t), r) : (this._buildDependencyTree(r, e), this._buildReverseDependency(r, e), r);
  9416. }
  9417. /**
  9418. * Build the dependency relationship between the trees.
  9419. * @param allTrees all FormulaDependencyTree
  9420. * @param shouldBeBuildTrees FormulaDependencyTree[] | FormulaDependencyTreeCache
  9421. */
  9422. _buildDependencyTree(e, t) {
  9423. const r = /* @__PURE__ */ new Map();
  9424. for (let n = 0; n < t.length; n++) {
  9425. const s = t[n];
  9426. r.set(s.treeId, s);
  9427. }
  9428. for (let n = 0; n < e.length; n++) {
  9429. const s = e[n], o = s.toRTreeItem(), u = this._dependencyRTreeCache.bulkSearch(o);
  9430. for (const c of u) {
  9431. const l2 = r.get(c);
  9432. l2 && s !== l2 && !l2.hasChildren(s.treeId) && l2.pushChildren(s);
  9433. }
  9434. }
  9435. r.clear();
  9436. }
  9437. /**
  9438. * Build the reverse dependency relationship between the trees.
  9439. * @param allTrees
  9440. * @param dependencyTrees
  9441. */
  9442. _buildReverseDependency(e, t) {
  9443. const r = /* @__PURE__ */ new Map();
  9444. for (let n = 0; n < e.length; n++) {
  9445. const s = e[n];
  9446. r.set(s.treeId, s);
  9447. }
  9448. for (let n = 0; n < t.length; n++) {
  9449. const s = t[n], o = s.toRTreeItem(), u = this._dependencyRTreeCache.bulkSearch(o);
  9450. for (const c of u) {
  9451. const l2 = r.get(c);
  9452. l2 && s !== l2 && !l2.hasChildren(s.treeId) && l2.pushChildren(s);
  9453. }
  9454. }
  9455. r.clear();
  9456. }
  9457. /**
  9458. * Get all FormulaDependencyTree from _otherFormulaData, _featureFormulaData, _formulaData
  9459. * return FormulaDependencyTree[]
  9460. */
  9461. getAllTree() {
  9462. const e = [];
  9463. return this._allTreeMap.forEach((t) => {
  9464. t.resetState(), e.push(t);
  9465. }), e;
  9466. }
  9467. getTreeById(e) {
  9468. return this._allTreeMap.get(e);
  9469. }
  9470. reset() {
  9471. this._otherFormulaData.clear(), this._featureFormulaData.clear(), this._formulaData.clear(), this._dependencyRTreeCache.clear(), this._allTreeMap.clear(), this._restDependencyTreeId(), this._otherFormulaDataMainData.clear();
  9472. }
  9473. addOtherFormulaDependency(e, t, r, n) {
  9474. this._otherFormulaData.has(e) || this._otherFormulaData.set(e, /* @__PURE__ */ new Map());
  9475. const s = this._otherFormulaData.get(e);
  9476. s.has(t) || s.set(t, /* @__PURE__ */ new Map());
  9477. const o = s.get(t);
  9478. o.has(r) || o.set(r, new kt()), o.get(r).setValue(n.refOffsetX, n.refOffsetY, n.treeId), this._addAllTreeMap(n);
  9479. }
  9480. removeOtherFormulaDependency(e, t, r) {
  9481. const n = this._otherFormulaData.get(e);
  9482. if (n && n.has(t)) {
  9483. const s = n.get(t);
  9484. r.forEach((o) => {
  9485. const u = s.get(o);
  9486. u != null && (u.forValue((c, l2, f2) => {
  9487. this._removeDependencyRTreeCache(f2), this.clearDependencyForTree(this._allTreeMap.get(f2)), this._removeAllTreeMap(f2);
  9488. }), s.delete(o), this._otherFormulaDataMainData.delete(o));
  9489. }), s.size === 0 && n.delete(t), n.size === 0 && this._otherFormulaData.delete(e);
  9490. }
  9491. }
  9492. clearOtherFormulaDependency(e, t) {
  9493. const r = this._otherFormulaData.get(e);
  9494. if (t && r && r.has(t)) {
  9495. const n = r.get(t);
  9496. this._removeDependencyRTreeCacheById(e, t);
  9497. for (const s of n.keys()) {
  9498. const o = n.get(s);
  9499. o != null && (o.forValue((u, c, l2) => {
  9500. const f2 = this._allTreeMap.get(l2);
  9501. f2 && (this.clearDependencyForTree(f2), this._removeAllTreeMap(l2));
  9502. }), this._otherFormulaDataMainData.delete(s));
  9503. }
  9504. n.clear();
  9505. } else if (r) {
  9506. for (const n of r.keys()) {
  9507. const s = r.get(n);
  9508. this._removeDependencyRTreeCacheById(e, n);
  9509. for (const o of s.keys()) {
  9510. const u = s.get(o);
  9511. u != null && (u.forValue((c, l2, f2) => {
  9512. const h = this._allTreeMap.get(f2);
  9513. h && (this.clearDependencyForTree(h), this._removeAllTreeMap(f2));
  9514. }), this._otherFormulaDataMainData.delete(o));
  9515. }
  9516. }
  9517. this._otherFormulaData.delete(e);
  9518. }
  9519. }
  9520. addFeatureFormulaDependency(e, t, r, n) {
  9521. this._featureFormulaData.has(e) || this._featureFormulaData.set(e, /* @__PURE__ */ new Map());
  9522. const s = this._featureFormulaData.get(e);
  9523. s.has(t) || s.set(t, /* @__PURE__ */ new Map()), s.get(t).set(r, n.treeId), this._addAllTreeMap(n);
  9524. }
  9525. removeFeatureFormulaDependency(e, t, r) {
  9526. const n = this._featureFormulaData.get(e);
  9527. if (n && n.has(t)) {
  9528. const s = n.get(t);
  9529. r.forEach((o) => {
  9530. const u = s.get(o);
  9531. u != null && (this._removeDependencyRTreeCache(u), s.delete(o), this.clearDependencyForTree(this._allTreeMap.get(u)), this._removeAllTreeMap(u));
  9532. });
  9533. }
  9534. }
  9535. clearFeatureFormulaDependency(e, t) {
  9536. const r = this._featureFormulaData.get(e);
  9537. if (t && r && r.has(t)) {
  9538. const n = r.get(t);
  9539. this._removeDependencyRTreeCacheById(e, t), n.forEach((s) => {
  9540. s != null && (this.clearDependencyForTree(this._allTreeMap.get(s)), this._removeAllTreeMap(s));
  9541. }), n.clear();
  9542. } else
  9543. r && (r.forEach((n, s) => {
  9544. this._removeDependencyRTreeCacheById(e, s), n.forEach((o) => {
  9545. o != null && (this.clearDependencyForTree(this._allTreeMap.get(o)), this._removeAllTreeMap(o));
  9546. });
  9547. }), this._featureFormulaData.delete(e));
  9548. }
  9549. addFormulaDependency(e, t, r, n, s) {
  9550. this._formulaData.has(e) || this._formulaData.set(e, /* @__PURE__ */ new Map());
  9551. const o = this._formulaData.get(e);
  9552. o.has(t) || o.set(t, new kt()), o.get(t).setValue(r, n, s.treeId), this._addAllTreeMap(s);
  9553. }
  9554. removeFormulaDependency(e, t, r, n) {
  9555. const s = this._formulaData.get(e);
  9556. if (s && s.has(t)) {
  9557. const o = s.get(t), u = o.getValue(r, n);
  9558. if (u == null)
  9559. return;
  9560. this._removeDependencyRTreeCache(u), o.realDeleteValue(r, n), this.clearDependencyForTree(this._allTreeMap.get(u)), this._removeAllTreeMap(u);
  9561. }
  9562. }
  9563. clearFormulaDependency(e, t) {
  9564. const r = this._formulaData.get(e);
  9565. if (t && r && r.has(t)) {
  9566. const n = r.get(t);
  9567. this._removeDependencyRTreeCacheById(e, t), n.forValue((s, o, u) => {
  9568. if (u == null)
  9569. return true;
  9570. this.clearDependencyForTree(this._allTreeMap.get(u)), this._removeAllTreeMap(u);
  9571. }), n.reset();
  9572. } else
  9573. r && (r.forEach((n, s) => {
  9574. this._removeDependencyRTreeCacheById(e, s), n.forValue((o, u, c) => {
  9575. if (c == null)
  9576. return true;
  9577. this.clearDependencyForTree(this._allTreeMap.get(c)), this._removeAllTreeMap(c);
  9578. });
  9579. }), this._formulaData.delete(e));
  9580. }
  9581. /**
  9582. * Clear the dependency relationship of the tree.
  9583. * establish the relationship between the parent and the child.
  9584. * @param shouldBeClearTree
  9585. */
  9586. clearDependencyForTree(e) {
  9587. if (e == null)
  9588. return;
  9589. const t = e.parents, r = e.children, n = this._allTreeMap;
  9590. for (const s of t) {
  9591. const o = n.get(s);
  9592. o == null || o.children.delete(e.treeId);
  9593. }
  9594. for (const s of r) {
  9595. const o = n.get(s);
  9596. o == null || o.parents.delete(e.treeId);
  9597. }
  9598. e.dispose();
  9599. }
  9600. _removeDependencyRTreeCache(e) {
  9601. if (e == null)
  9602. return;
  9603. const t = this._allTreeMap.get(e);
  9604. if (t) {
  9605. const r = [];
  9606. for (let n = 0; n < t.rangeList.length; n++) {
  9607. const s = t.rangeList[n], { unitId: o, sheetId: u, range: c } = s;
  9608. r.push({
  9609. unitId: o,
  9610. sheetId: u,
  9611. range: c,
  9612. id: e
  9613. });
  9614. }
  9615. this._dependencyRTreeCache.bulkRemove(r);
  9616. }
  9617. }
  9618. removeFormulaDependencyByDefinedName(e, t) {
  9619. const r = this._definedNameMap.get(e);
  9620. if (r) {
  9621. const n = r.get(t);
  9622. if (n) {
  9623. for (const s of n)
  9624. this._removeDependencyRTreeCache(s), this.clearDependencyForTree(this._allTreeMap.get(s)), this._removeAllTreeMap(s);
  9625. n.clear();
  9626. }
  9627. }
  9628. }
  9629. _removeAllTreeMap(e) {
  9630. e != null && this._allTreeMap.delete(e);
  9631. }
  9632. _addAllTreeMap(e) {
  9633. this._allTreeMap.set(e.treeId, e);
  9634. }
  9635. };
  9636. var Hn = Ct(
  9637. "univer.formula.dependency-manager.service"
  9638. );
  9639. var Nh = class extends nt {
  9640. constructor() {
  9641. super(...arguments);
  9642. A(this, "_referenceExecutorMap", /* @__PURE__ */ new Map());
  9643. A(this, "_onChanged$", new Subject());
  9644. A(this, "onChanged$", this._onChanged$.asObservable());
  9645. }
  9646. dispose() {
  9647. this._referenceExecutorMap.clear();
  9648. }
  9649. remove(e, t, r) {
  9650. r.forEach((n) => {
  9651. var s, o;
  9652. (o = (s = this._referenceExecutorMap.get(e)) == null ? void 0 : s.get(t)) == null || o.delete(n);
  9653. }), this._onChanged$.next({
  9654. unitId: e,
  9655. subUnitId: t,
  9656. featureIds: r
  9657. });
  9658. }
  9659. get(e, t, r) {
  9660. var n, s;
  9661. return (s = (n = this._referenceExecutorMap.get(e)) == null ? void 0 : n.get(t)) == null ? void 0 : s.get(r);
  9662. }
  9663. has(e, t, r) {
  9664. var n, s;
  9665. return !!((s = (n = this._referenceExecutorMap.get(e)) == null ? void 0 : n.get(t)) != null && s.has(r));
  9666. }
  9667. register(e, t, r, n) {
  9668. let s = this._referenceExecutorMap.get(e);
  9669. s || (s = /* @__PURE__ */ new Map(), this._referenceExecutorMap.set(e, s));
  9670. let o = s.get(t);
  9671. o || (o = /* @__PURE__ */ new Map(), s.set(t, o)), this._onChanged$.next({
  9672. unitId: e,
  9673. subUnitId: t,
  9674. featureIds: [r]
  9675. }), o.set(r, n);
  9676. }
  9677. getReferenceExecutorMap() {
  9678. return this._referenceExecutorMap;
  9679. }
  9680. };
  9681. var jr = Ct(
  9682. "univer.formula.feature-calculation-manager.service"
  9683. );
  9684. var Oh = class extends nt {
  9685. constructor() {
  9686. super(...arguments);
  9687. A(this, "_otherFormulaData", {});
  9688. }
  9689. dispose() {
  9690. this._otherFormulaData = {};
  9691. }
  9692. remove(e) {
  9693. var s, o, u;
  9694. const { unitId: t, subUnitId: r, formulaId: n } = e;
  9695. (u = (o = (s = this._otherFormulaData) == null ? void 0 : s[t]) == null ? void 0 : o[r]) == null || delete u[n];
  9696. }
  9697. get(e) {
  9698. var s, o;
  9699. const { unitId: t, subUnitId: r, formulaId: n } = e;
  9700. return (o = (s = this._otherFormulaData[t]) == null ? void 0 : s[r]) == null ? void 0 : o[n];
  9701. }
  9702. has(e) {
  9703. var s, o;
  9704. const { unitId: t, subUnitId: r, formulaId: n } = e;
  9705. return ((o = (s = this._otherFormulaData[t]) == null ? void 0 : s[r]) == null ? void 0 : o[n]) != null;
  9706. }
  9707. register(e) {
  9708. const { unitId: t, subUnitId: r, formulaId: n, item: s } = e;
  9709. this._otherFormulaData[t] || (this._otherFormulaData[t] = {}), this._otherFormulaData[t][r] || (this._otherFormulaData[t][r] = {}), this._otherFormulaData[t][r][n] = s;
  9710. }
  9711. batchRegister(e) {
  9712. Object.keys(e).forEach((t) => {
  9713. const r = e[t];
  9714. if (r == null)
  9715. return true;
  9716. Object.keys(r).forEach((n) => {
  9717. const s = r[n];
  9718. if (s == null)
  9719. return true;
  9720. Object.keys(s).forEach((o) => {
  9721. const u = s[o];
  9722. if (u == null)
  9723. return true;
  9724. this.register({
  9725. unitId: t,
  9726. subUnitId: n,
  9727. formulaId: o,
  9728. item: u
  9729. });
  9730. });
  9731. });
  9732. });
  9733. }
  9734. batchRemove(e) {
  9735. Object.keys(e).forEach((t) => {
  9736. const r = e[t];
  9737. if (r == null)
  9738. return true;
  9739. Object.keys(r).forEach((n) => {
  9740. const s = r[n];
  9741. if (s == null)
  9742. return true;
  9743. Object.keys(s).forEach((o) => {
  9744. this.remove({
  9745. unitId: t,
  9746. subUnitId: n,
  9747. formulaId: o
  9748. });
  9749. });
  9750. });
  9751. });
  9752. }
  9753. getOtherFormulaData() {
  9754. return this._otherFormulaData;
  9755. }
  9756. };
  9757. var ya = Ct(
  9758. "univer.formula.other-formula-manager.service"
  9759. );
  9760. var Mh = 5e3;
  9761. var ks = new Vt(Mh);
  9762. function pi(i, a2, e, t, r) {
  9763. let n = ks.get(`${i}${a2}`);
  9764. if (n && !Oo(n, r))
  9765. return n;
  9766. const s = e.treeBuilder(a2);
  9767. if (yr.has(s))
  9768. return xe.create(s);
  9769. if (n = t.parse(s), n == null)
  9770. throw new Error("astNode is null");
  9771. return ks.set(`${i}${a2}`, n), n;
  9772. }
  9773. function Oo(i, a2) {
  9774. const e = a2.getDirtyDefinedNameMap(), t = a2.getExecuteUnitId();
  9775. if (t != null && e[t] != null) {
  9776. const r = Object.keys(e[t]);
  9777. for (let n = 0, s = r.length; n < s; n++) {
  9778. const o = r[n];
  9779. if (i.hasDefinedName(o))
  9780. return true;
  9781. }
  9782. }
  9783. return false;
  9784. }
  9785. function wh(i, a2, e) {
  9786. return !!(a2 != null && Oo(a2, e));
  9787. }
  9788. var $s = ((i) => (i[i.NORMAL_FORMULA = 0] = "NORMAL_FORMULA", i[i.OTHER_FORMULA = 1] = "OTHER_FORMULA", i[i.FEATURE_FORMULA = 2] = "FEATURE_FORMULA", i))($s || {});
  9789. var Mo = class {
  9790. constructor() {
  9791. A(this, "_state", 0);
  9792. A(this, "treeId");
  9793. A(this, "children", /* @__PURE__ */ new Set());
  9794. A(this, "parents", /* @__PURE__ */ new Set());
  9795. }
  9796. resetState() {
  9797. this._state = 0;
  9798. }
  9799. setAdded() {
  9800. this._state = 1;
  9801. }
  9802. isAdded() {
  9803. return this._state === 1;
  9804. }
  9805. setSkip() {
  9806. this._state = 2;
  9807. }
  9808. isSkip() {
  9809. return this._state === 2;
  9810. }
  9811. pushChildren(a2) {
  9812. this.children.add(a2.treeId), a2._pushParent(this);
  9813. }
  9814. hasChildren(a2) {
  9815. return this.children.has(a2);
  9816. }
  9817. _pushParent(a2) {
  9818. this.parents.add(a2.treeId);
  9819. }
  9820. };
  9821. var Vi = class extends Mo {
  9822. constructor() {
  9823. super(...arguments);
  9824. A(this, "refTree");
  9825. A(this, "refOffsetX", -1);
  9826. A(this, "refOffsetY", -1);
  9827. A(this, "isCache", false);
  9828. A(this, "isDirty", false);
  9829. A(this, "addressFunctionNodes", []);
  9830. A(this, "getDirtyData");
  9831. A(this, "featureId");
  9832. }
  9833. get isVirtual() {
  9834. return true;
  9835. }
  9836. get row() {
  9837. return this.refTree == null ? -1 : this.refTree.row + this.refOffsetY;
  9838. }
  9839. get column() {
  9840. return this.refTree == null ? -1 : this.refTree.column + this.refOffsetX;
  9841. }
  9842. get rowCount() {
  9843. return this.refTree == null ? 0 : this.refTree.rowCount;
  9844. }
  9845. get columnCount() {
  9846. return this.refTree == null ? 0 : this.refTree.columnCount;
  9847. }
  9848. get unitId() {
  9849. return this.refTree == null ? "" : this.refTree.unitId;
  9850. }
  9851. get subUnitId() {
  9852. return this.refTree == null ? "" : this.refTree.subUnitId;
  9853. }
  9854. get formula() {
  9855. var e, t;
  9856. return (t = (e = this.refTree) == null ? void 0 : e.formula) != null ? t : "";
  9857. }
  9858. get nodeData() {
  9859. return {
  9860. node: this.node,
  9861. refOffsetX: this.refOffsetX,
  9862. refOffsetY: this.refOffsetY
  9863. };
  9864. }
  9865. get node() {
  9866. var e;
  9867. return (e = this.refTree) == null ? void 0 : e.node;
  9868. }
  9869. dispose() {
  9870. this.refTree = null;
  9871. }
  9872. get rangeList() {
  9873. const e = [];
  9874. if (this.refTree == null)
  9875. return [];
  9876. for (let t = 0; t < this.refTree.rangeList.length; t++) {
  9877. const r = this.refTree.rangeList[t];
  9878. e.push({
  9879. unitId: r.unitId,
  9880. sheetId: r.sheetId,
  9881. range: jC(r.range, this.refOffsetX, this.refOffsetY)
  9882. });
  9883. }
  9884. return e;
  9885. }
  9886. toRTreeItem() {
  9887. const e = this.row, t = this.column;
  9888. return [{
  9889. unitId: this.unitId,
  9890. sheetId: this.subUnitId,
  9891. range: {
  9892. startRow: e,
  9893. startColumn: t,
  9894. endRow: e,
  9895. endColumn: t
  9896. }
  9897. }];
  9898. }
  9899. inRangeData(e) {
  9900. const t = e.startRow, r = e.startColumn, n = e.endRow, s = e.endColumn, o = this.row, u = this.column;
  9901. return !(o < t || o > n || u < r || u > s);
  9902. }
  9903. dependencySheetName(e) {
  9904. return this.refTree == null ? false : this.refTree.dependencySheetName(e);
  9905. }
  9906. isExcludeRange(e) {
  9907. var r;
  9908. const t = this.rangeList;
  9909. if (t.length === 0)
  9910. return false;
  9911. for (let n = 0, s = t.length; n < s; n++) {
  9912. const o = t[n], { unitId: u, sheetId: c, range: l2 } = o, f2 = (r = e == null ? void 0 : e[u]) == null ? void 0 : r[c];
  9913. let { startRow: h, endRow: d2, startColumn: _, endColumn: C } = l2;
  9914. Number.isNaN(h) && (h = 0), Number.isNaN(_) && (_ = 0), Number.isNaN(d2) && (d2 = Number.POSITIVE_INFINITY), Number.isNaN(C) && (C = Number.POSITIVE_INFINITY);
  9915. let E2 = false;
  9916. if (f2 == null || f2.forValue((b, R) => {
  9917. if (b >= h && b <= d2 && R >= _ && R <= C)
  9918. return E2 = true, false;
  9919. }), E2)
  9920. return true;
  9921. }
  9922. return false;
  9923. }
  9924. get formulaId() {
  9925. return this.refTree == null ? "" : this.refTree.formulaId;
  9926. }
  9927. };
  9928. var hs = class extends Mo {
  9929. constructor(e) {
  9930. super();
  9931. A(this, "isCache", false);
  9932. A(this, "featureId");
  9933. A(this, "featureDirtyRanges", []);
  9934. A(this, "refOffsetX", 0);
  9935. A(this, "refOffsetY", 0);
  9936. A(this, "type", 0);
  9937. A(this, "formulaId");
  9938. A(this, "subUnitId", "");
  9939. A(this, "unitId", "");
  9940. A(this, "rangeList", []);
  9941. A(this, "formula", "");
  9942. A(this, "row", -1);
  9943. A(this, "column", -1);
  9944. A(this, "rowCount", Number.NEGATIVE_INFINITY);
  9945. A(this, "columnCount", Number.NEGATIVE_INFINITY);
  9946. A(this, "isDirty", false);
  9947. A(this, "node");
  9948. A(this, "addressFunctionNodes", []);
  9949. A(this, "getDirtyData");
  9950. this.treeId = e;
  9951. }
  9952. get isVirtual() {
  9953. return false;
  9954. }
  9955. get nodeData() {
  9956. return {
  9957. node: this.node,
  9958. refOffsetX: 0,
  9959. refOffsetY: 0
  9960. };
  9961. }
  9962. toJson() {
  9963. return {
  9964. formula: this.formula,
  9965. refOffsetX: this.refOffsetX,
  9966. refOffsetY: this.refOffsetY
  9967. };
  9968. }
  9969. dispose() {
  9970. this.featureDirtyRanges = [], this.rangeList = [], this.addressFunctionNodes = [], this.getDirtyData = null;
  9971. }
  9972. inRangeData(e) {
  9973. const t = e.startRow, r = e.startColumn, n = e.endRow, s = e.endColumn, o = this.row, u = this.column;
  9974. return !(o < t || o > n || u < r || u > s);
  9975. }
  9976. dependencySheetName(e) {
  9977. var r;
  9978. const t = this.rangeList;
  9979. if (t.length === 0 || e == null)
  9980. return false;
  9981. for (let n = 0, s = t.length; n < s; n++) {
  9982. const o = t[n], { unitId: u, sheetId: c } = o;
  9983. if (((r = e[u]) == null ? void 0 : r[c]) != null)
  9984. return true;
  9985. }
  9986. return false;
  9987. }
  9988. isExcludeRange(e) {
  9989. var r;
  9990. const t = this.rangeList;
  9991. if (t.length === 0)
  9992. return false;
  9993. for (let n = 0, s = t.length; n < s; n++) {
  9994. const o = t[n], { unitId: u, sheetId: c, range: l2 } = o, f2 = (r = e == null ? void 0 : e[u]) == null ? void 0 : r[c];
  9995. let { startRow: h, endRow: d2, startColumn: _, endColumn: C } = l2;
  9996. Number.isNaN(h) && (h = 0), Number.isNaN(_) && (_ = 0), Number.isNaN(d2) && (d2 = Number.POSITIVE_INFINITY), Number.isNaN(C) && (C = Number.POSITIVE_INFINITY);
  9997. let E2 = false;
  9998. if (f2 == null || f2.forValue((b, R) => {
  9999. if (b >= h && b <= d2 && R >= _ && R <= C)
  10000. return E2 = true, false;
  10001. }), E2)
  10002. return true;
  10003. }
  10004. return false;
  10005. }
  10006. // pushChildren(tree: FormulaDependencyTree) {
  10007. // this.children.add(tree.treeId);
  10008. // tree._pushParent(this);
  10009. // }
  10010. /**
  10011. * Add the range corresponding to the current ast node.
  10012. * @param range
  10013. */
  10014. pushRangeList(e) {
  10015. this.rangeList.push(...e);
  10016. }
  10017. shouldBePushRangeList() {
  10018. return this.rangeList.length === 0 && this.type !== 2;
  10019. }
  10020. // hasChildren(treeId: number) {
  10021. // return this.children.has(treeId);
  10022. // }
  10023. toRTreeItem() {
  10024. if (this.featureId != null)
  10025. return this.featureDirtyRanges;
  10026. const e = this.row, t = this.column;
  10027. return [{
  10028. unitId: this.unitId,
  10029. sheetId: this.subUnitId,
  10030. range: {
  10031. startRow: e,
  10032. startColumn: t,
  10033. endRow: e,
  10034. endColumn: t
  10035. }
  10036. }];
  10037. }
  10038. /**
  10039. * Determine whether it is dependent on other trees.
  10040. * @param dependenceTree
  10041. */
  10042. // dependency(dependenceTree: FormulaDependencyTree) {
  10043. // if (this.rangeList.length === 0) {
  10044. // return false;
  10045. // }
  10046. // for (let r = 0, len = this.rangeList.length; r < len; r++) {
  10047. // const unitRange = this.rangeList[r];
  10048. // const unitId = unitRange.unitId;
  10049. // const sheetId = unitRange.sheetId;
  10050. // const range = unitRange.range;
  10051. // if (
  10052. // dependenceTree.unitId === unitId &&
  10053. // dependenceTree.subUnitId === sheetId &&
  10054. // dependenceTree.inRangeData(range)
  10055. // ) {
  10056. // return true;
  10057. // }
  10058. // }
  10059. // return false;
  10060. // }
  10061. // private _pushParent(tree: FormulaDependencyTree) {
  10062. // this.parents.add(tree.treeId);
  10063. // }
  10064. };
  10065. var Dh = Object.defineProperty;
  10066. var Sh = Object.getOwnPropertyDescriptor;
  10067. var Ph = (i, a2, e, t) => {
  10068. for (var r = t > 1 ? void 0 : t ? Sh(a2, e) : a2, n = i.length - 1, s; n >= 0; n--)
  10069. (s = i[n]) && (r = (t ? s(a2, e, r) : s(r)) || r);
  10070. return t && r && Dh(a2, e, r), r;
  10071. };
  10072. var wt = (i, a2) => (e, t) => a2(e, t, i);
  10073. function or(i) {
  10074. return i.getLastTreeId() || 0;
  10075. }
  10076. var Ys = Ct("engine-formula.dependency-generator");
  10077. var Hs = class extends nt {
  10078. constructor(a2, e, t, r, n, s, o, u) {
  10079. super();
  10080. A(this, "_updateRangeFlattenCache", /* @__PURE__ */ new Map());
  10081. A(this, "_dependencyRTreeCacheForAddressFunction", new $R());
  10082. A(this, "_executedAddressFunctionNodeIds", /* @__PURE__ */ new Set());
  10083. this._currentConfigService = a2, this._runtimeService = e, this._otherFormulaManagerService = t, this._featureCalculationManagerService = r, this._interpreter = n, this._astTreeBuilder = s, this._lexer = o, this._dependencyManagerService = u;
  10084. }
  10085. dispose() {
  10086. this._updateRangeFlattenCache.clear(), this._dependencyRTreeCacheForAddressFunction.clear(), ks.clear();
  10087. }
  10088. async generate() {
  10089. this._updateRangeFlatten();
  10090. const a2 = this._currentConfigService.getFormulaData(), e = this._otherFormulaManagerService.getOtherFormulaData(), t = this._currentConfigService.getClearDependencyTreeCache();
  10091. t != null && Object.keys(t).forEach((l2) => {
  10092. l2 != null && Object.keys(t[l2]).forEach((f2) => {
  10093. f2 != null && (this._dependencyManagerService.clearOtherFormulaDependency(l2, f2), this._dependencyManagerService.clearFeatureFormulaDependency(l2, f2), this._dependencyManagerService.clearFormulaDependency(l2, f2));
  10094. });
  10095. });
  10096. const r = this._currentConfigService.getUnitData(), n = await this._generateTreeList(a2, e, r), s = this._getUpdateTreeListAndMakeDependency(n);
  10097. let o = this._calculateRunList(s);
  10098. return this._dependencyFeatureCalculation(o) && (o.forEach((l2) => {
  10099. l2.resetState();
  10100. }), o = this._calculateRunList(o)), this._checkIsCycleDependency(o) && this._runtimeService.enableCycleDependency(), this._dependencyRTreeCacheForAddressFunction.clear(), Promise.resolve(o);
  10101. }
  10102. _dependencyFeatureCalculation(a2) {
  10103. const e = this._featureCalculationManagerService.getReferenceExecutorMap();
  10104. if (e.size === 0)
  10105. return;
  10106. this._clearFeatureCalculationNode(a2);
  10107. let t = false;
  10108. return e.forEach((r, n) => {
  10109. r.forEach((s, o) => {
  10110. s.forEach((u, c) => {
  10111. const { unitId: l2, subUnitId: f2, getDirtyData: h } = u, d2 = h(this._currentConfigService.getDirtyData(), this._runtimeService.getAllRuntimeData()), _ = this._convertDirtyRangesToUnitRange(d2.dirtyRanges), C = this._intersectFeatureCalculation(_, a2, { unitId: l2, subUnitId: f2, featureId: c });
  10112. if (C.length > 0) {
  10113. let E2 = this._getExistTreeList({ unitId: l2, subUnitId: f2, featureId: c }, a2);
  10114. E2 == null && (E2 = this._getFeatureFormulaTree(c, or(this._dependencyManagerService), u), a2.push(E2)), E2.parents = /* @__PURE__ */ new Set(), C.forEach((b) => {
  10115. b.hasChildren(E2.treeId) || b.pushChildren(E2);
  10116. }), t = true;
  10117. }
  10118. });
  10119. });
  10120. }), t;
  10121. }
  10122. _clearFeatureCalculationNode(a2) {
  10123. const e = this._featureCalculationManagerService.getReferenceExecutorMap();
  10124. a2.forEach((t) => {
  10125. var s, o, u, c;
  10126. const r = /* @__PURE__ */ new Set();
  10127. for (const l2 of t.children) {
  10128. const f2 = this._dependencyManagerService.getTreeById(l2);
  10129. f2 && (f2.featureId && (o = (s = e.get(t.unitId)) == null ? void 0 : s.get(t.subUnitId)) != null && o.has(f2.featureId) || r.add(l2));
  10130. }
  10131. t.children = r;
  10132. const n = /* @__PURE__ */ new Set();
  10133. for (const l2 of t.parents) {
  10134. const f2 = this._dependencyManagerService.getTreeById(l2);
  10135. f2 && (f2.featureId && (c = (u = e.get(t.unitId)) == null ? void 0 : u.get(t.subUnitId)) != null && c.has(f2.featureId) || n.add(l2));
  10136. }
  10137. t.parents = n;
  10138. });
  10139. }
  10140. /**
  10141. * TODO @DR-Univer: The next step will be to try changing the incoming dirtyRanges to an array, thus avoiding conversion.
  10142. * @param dirtyRanges
  10143. * @returns
  10144. */
  10145. _convertDirtyRangesToUnitRange(a2) {
  10146. const e = [];
  10147. for (const t in a2) {
  10148. const r = a2[t];
  10149. for (const n in r) {
  10150. const s = r[n];
  10151. for (const o of s)
  10152. e.push({
  10153. unitId: t,
  10154. sheetId: n,
  10155. range: o
  10156. });
  10157. }
  10158. }
  10159. return e;
  10160. }
  10161. _intersectFeatureCalculation(a2, e, t) {
  10162. const r = [], n = this._dependencyManagerService.searchDependency(a2);
  10163. for (let s = 0, o = e.length; s < o; s++) {
  10164. const u = e[s];
  10165. if (u.unitId === t.unitId && u.subUnitId === t.subUnitId && u.featureId === t.featureId)
  10166. continue;
  10167. n.has(u.treeId) && r.push(u);
  10168. }
  10169. return r;
  10170. }
  10171. _getExistTreeList(a2, e) {
  10172. const { unitId: t, subUnitId: r, featureId: n } = a2;
  10173. for (let s = 0, o = e.length; s < o; s++) {
  10174. const u = e[s];
  10175. if (u.unitId === t && u.subUnitId === r && u.featureId === n)
  10176. return u;
  10177. }
  10178. }
  10179. _isCyclicUtil(a2, e, t) {
  10180. const r = this._dependencyManagerService.getTreeById(a2);
  10181. if (r == null)
  10182. return false;
  10183. if (!e.has(r.treeId)) {
  10184. e.add(r.treeId), t.add(r.treeId);
  10185. for (const n of r.children)
  10186. if (!e.has(n) && this._isCyclicUtil(n, e, t) || t.has(n))
  10187. return true;
  10188. }
  10189. return t.delete(r.treeId), false;
  10190. }
  10191. _checkIsCycleDependency(a2) {
  10192. const e = /* @__PURE__ */ new Set(), t = /* @__PURE__ */ new Set();
  10193. for (let r = 0, n = a2.length; r < n; r++) {
  10194. const s = a2[r];
  10195. if (this._isCyclicUtil(s.treeId, e, t) === true)
  10196. return true;
  10197. }
  10198. return false;
  10199. }
  10200. /**
  10201. * Generate nodes for the dependency tree, where each node contains all the reference data ranges included in each formula.
  10202. * @param formulaData
  10203. */
  10204. async _generateTreeList(a2, e, t) {
  10205. const r = Object.keys(a2), n = Object.keys(e), s = [];
  10206. this._currentConfigService.isForceCalculate() && this._dependencyManagerService.reset(), this._registerFormulas(r, a2, t, s), this._registerOtherFormulas(e, n, s), this._registerFeatureFormulas(s);
  10207. for (let u = 0, c = s.length; u < c; u++) {
  10208. const l2 = s[u], f2 = this._getTreeNode(l2);
  10209. l2.isDirty = this._includeTree(l2, f2);
  10210. const h = this._getAddressFunctionNodeList(f2);
  10211. if (h.length > 0 && (l2.addressFunctionNodes = h), l2.isVirtual)
  10212. continue;
  10213. this._runtimeService.setCurrent(
  10214. l2.row,
  10215. l2.column,
  10216. l2.rowCount,
  10217. l2.columnCount,
  10218. l2.subUnitId,
  10219. l2.unitId
  10220. );
  10221. const d2 = await this._getRangeListByNode({
  10222. node: f2,
  10223. refOffsetX: l2.refOffsetX,
  10224. refOffsetY: l2.refOffsetY
  10225. });
  10226. l2.pushRangeList(d2);
  10227. }
  10228. for (let u = 0, c = s.length; u < c; u++) {
  10229. const l2 = s[u];
  10230. l2.isCache || this._dependencyManagerService.addDependencyRTreeCache(l2);
  10231. }
  10232. return await this._calculateListByFunctionRefNode(s), s;
  10233. }
  10234. // private _moveRangeList(tree: FormulaDependencyTree, refOffsetX: number, refOffsetY: number) {
  10235. // const rangeList = tree.rangeList;
  10236. // const newRangeList = [];
  10237. // for (let i = 0, len = rangeList.length; i < len; i++) {
  10238. // const unitRange = rangeList[i];
  10239. // const newRange = {
  10240. // unitId: tree.unitId,
  10241. // sheetId: tree.subUnitId,
  10242. // range: moveRangeByOffset(unitRange.range, refOffsetX, refOffsetY),
  10243. // };
  10244. // newRangeList.push(newRange);
  10245. // }
  10246. // return newRangeList;
  10247. // }
  10248. _registerFeatureFormulas(a2) {
  10249. this._featureCalculationManagerService.getReferenceExecutorMap().forEach((t, r) => {
  10250. t.forEach((n, s) => {
  10251. n.forEach((o, u) => {
  10252. const c = this._dependencyManagerService.getFeatureFormulaDependency(o.unitId, o.subUnitId, u);
  10253. a2.push(this._getFeatureFormulaTree(u, c, o));
  10254. });
  10255. });
  10256. });
  10257. }
  10258. _getFeatureFormulaTree(a2, e, t) {
  10259. const { unitId: r, subUnitId: n, dependencyRanges: s, getDirtyData: o } = t, u = e || or(this._dependencyManagerService), c = new hs(u);
  10260. c.unitId = r, c.subUnitId = n, c.rangeList = s, c.getDirtyData = o;
  10261. const l2 = o(this._currentConfigService.getDirtyData(), this._runtimeService.getAllRuntimeData()), f2 = this._convertDirtyRangesToUnitRange(l2.dirtyRanges);
  10262. return c.featureDirtyRanges = f2, c.featureId = a2, c.type = $s.FEATURE_FORMULA, this._dependencyManagerService.addFeatureFormulaDependency(r, n, a2, c), this._dependencyManagerService.getFeatureFormulaDependency(t.unitId, t.subUnitId, a2) && (c.isCache = true), c;
  10263. }
  10264. _registerOtherFormulas(a2, e, t) {
  10265. for (const r of e) {
  10266. const n = a2[r];
  10267. if (n == null)
  10268. continue;
  10269. const s = Object.keys(n);
  10270. for (const o of s) {
  10271. const u = n[o];
  10272. if (u == null)
  10273. continue;
  10274. const c = Object.keys(u);
  10275. for (const l2 of c) {
  10276. const f2 = this._dependencyManagerService.hasOtherFormulaDataMainData(l2), h = u[l2], { f: d2, ranges: _ } = h;
  10277. let C = false;
  10278. f2 && (C = true);
  10279. const E2 = pi(r, d2, this._lexer, this._astTreeBuilder, this._currentConfigService), { firstRow: b, firstColumn: R } = this._getFirstCellOfRange(_), p2 = this._dependencyManagerService.getOtherFormulaDependency(r, o, l2), N2 = (p2 == null ? void 0 : p2.getValue(0, 0)) || or(this._dependencyManagerService), M2 = new hs(N2);
  10280. for (let w = 0; w < _.length; w++) {
  10281. const D2 = _[w], { startRow: S2, startColumn: P, endRow: U2, endColumn: x2 } = D2;
  10282. for (let F = S2; F <= U2; F++)
  10283. for (let W2 = P; W2 <= x2; W2++) {
  10284. const ne = W2 - R, z = F - b;
  10285. if (ne === 0 && z === 0) {
  10286. M2.node = E2, M2.formula = d2, M2.unitId = r, M2.subUnitId = o, M2.formulaId = l2, M2.type = $s.OTHER_FORMULA, M2.isCache = C, t.push(M2), this._dependencyManagerService.addOtherFormulaDependency(r, o, l2, M2), this._dependencyManagerService.addFormulaDependencyByDefinedName(M2);
  10287. continue;
  10288. }
  10289. const G2 = new Vi();
  10290. G2.treeId = (p2 == null ? void 0 : p2.getValue(ne, z)) || or(this._dependencyManagerService), G2.refTree = M2, G2.refOffsetX = ne, G2.refOffsetY = z, G2.isCache = C, this._dependencyManagerService.addOtherFormulaDependency(r, o, l2, G2), this._dependencyManagerService.addFormulaDependencyByDefinedName(G2), t.push(G2);
  10291. }
  10292. }
  10293. this._dependencyManagerService.addOtherFormulaDependencyMainData(l2);
  10294. }
  10295. }
  10296. }
  10297. }
  10298. _getFirstCellOfRange(a2) {
  10299. const e = a2[0];
  10300. return {
  10301. firstRow: e.startRow,
  10302. firstColumn: e.startColumn
  10303. };
  10304. }
  10305. _registerFormulas(a2, e, t, r) {
  10306. for (const n of a2) {
  10307. const s = e[n];
  10308. if (s == null)
  10309. continue;
  10310. const o = Object.keys(s);
  10311. for (const u of o) {
  10312. const c = new kt(s[u] || {}), l2 = /* @__PURE__ */ new Map();
  10313. c.forValue((f2, h, d2) => {
  10314. if (d2 == null)
  10315. return true;
  10316. const { x: _ = 0, y: C = 0, si: E2 } = d2;
  10317. if (!(_ === 0 && C === 0 && E2 != null))
  10318. return true;
  10319. const b = this._createFDtree(n, u, f2, h, t, d2), R = this._dependencyManagerService.getFormulaDependency(n, u, f2, h);
  10320. R != null ? b.treeId = R : (this._dependencyManagerService.addFormulaDependency(n, u, f2, h, b), this._dependencyManagerService.addFormulaDependencyByDefinedName(b)), l2.set(E2, b), r.push(b);
  10321. }), c.forValue((f2, h, d2) => {
  10322. if (d2 == null)
  10323. return true;
  10324. const { x: _ = 0, y: C = 0, si: E2 } = d2;
  10325. if (_ === 0 && C === 0 && E2 != null)
  10326. return true;
  10327. let b;
  10328. if (E2 && l2.has(E2)) {
  10329. const p2 = l2.get(E2);
  10330. b = this._createVirtualFDtree(p2, d2);
  10331. } else
  10332. b = this._createFDtree(n, u, f2, h, t, d2);
  10333. const R = this._dependencyManagerService.getFormulaDependency(n, u, f2, h);
  10334. R != null ? b.treeId = R : (this._dependencyManagerService.addFormulaDependency(n, u, f2, h, b), this._dependencyManagerService.addFormulaDependencyByDefinedName(b)), r.push(b);
  10335. }), l2.clear();
  10336. }
  10337. }
  10338. }
  10339. _createFDtree(a2, e, t, r, n, s) {
  10340. const { f: o, x: u = 0, y: c = 0 } = s, l2 = new hs(or(this._dependencyManagerService)), f2 = n[a2][e], h = pi(a2, o, this._lexer, this._astTreeBuilder, this._currentConfigService);
  10341. return l2.node = h, l2.formula = o, l2.unitId = a2, l2.subUnitId = e, l2.row = t, l2.column = r, l2.rowCount = f2.rowCount, l2.columnCount = f2.columnCount, l2;
  10342. }
  10343. _createVirtualFDtree(a2, e) {
  10344. const { x: t = 0, y: r = 0 } = e, n = new Vi();
  10345. return n.treeId = or(this._dependencyManagerService), n.refTree = a2, n.refOffsetX = t, n.refOffsetY = r, n;
  10346. }
  10347. /**
  10348. * Break down the dirty areas into ranges for subsequent matching.
  10349. */
  10350. _updateRangeFlatten() {
  10351. const a2 = this._currentConfigService.isForceCalculate(), e = this._currentConfigService.getDirtyRanges();
  10352. if (!a2) {
  10353. this._updateRangeFlattenCache.clear();
  10354. for (let t = 0; t < e.length; t++) {
  10355. const r = e[t], n = r.range, s = r.sheetId, o = r.unitId;
  10356. this._addFlattenCache(o, s, n);
  10357. }
  10358. }
  10359. }
  10360. _addFlattenCache(a2, e, t) {
  10361. let r = this._updateRangeFlattenCache.get(a2);
  10362. r == null && (r = /* @__PURE__ */ new Map(), this._updateRangeFlattenCache.set(a2, r));
  10363. let n = r.get(e);
  10364. n == null && (n = [], r.set(e, n)), n.push(t);
  10365. }
  10366. _isPreCalculateNode(a2) {
  10367. return a2.nodeType === oe.UNION || a2.nodeType === oe.PREFIX && a2.getToken() === Oe.AT || a2.nodeType === oe.SUFFIX && a2.getToken() === ze.POUND;
  10368. }
  10369. _nodeTraversalRef(a2, e) {
  10370. const t = a2.getChildren(), r = t.length;
  10371. for (let n = 0; n < r; n++) {
  10372. const s = t[n];
  10373. if (this._isPreCalculateNode(s)) {
  10374. if (e.push(s), s.nodeType === oe.UNION)
  10375. for (const o of s.getChildren())
  10376. o.nodeType === oe.FUNCTION && o.isAddress() && this._nodeTraversalRef(o, e);
  10377. continue;
  10378. } else
  10379. s.nodeType === oe.REFERENCE && e.push(s);
  10380. this._nodeTraversalRef(s, e);
  10381. }
  10382. }
  10383. _nodeTraversalReferenceFunction(a2, e) {
  10384. const t = a2.getChildren(), r = t.length;
  10385. for (let n = 0; n < r; n++) {
  10386. const s = t[n];
  10387. if (s.nodeType === oe.FUNCTION && s.isAddress()) {
  10388. e.push(s);
  10389. continue;
  10390. }
  10391. this._nodeTraversalReferenceFunction(s, e);
  10392. }
  10393. }
  10394. async _executeNode(a2, e = 0, t = 0) {
  10395. let r;
  10396. const n = {
  10397. node: a2,
  10398. refOffsetX: e,
  10399. refOffsetY: t
  10400. };
  10401. return this._interpreter.checkAsyncNode(a2) ? r = await this._interpreter.executeAsync(n) : r = this._interpreter.execute(n), r;
  10402. }
  10403. /**
  10404. * Calculate the range required for collection in advance,
  10405. * including references and location functions (such as OFFSET, INDIRECT, INDEX, etc.).
  10406. * @param node
  10407. */
  10408. async _getRangeListByNode(a2) {
  10409. const e = [], t = a2.refOffsetX, r = a2.refOffsetY, n = a2.node;
  10410. if (n == null)
  10411. return [];
  10412. this._nodeTraversalRef(n, e);
  10413. const s = [];
  10414. for (let o = 0, u = e.length; o < u; o++) {
  10415. const c = e[o], f2 = (await this._executeNode(c, t, r)).toUnitRange();
  10416. s.push(f2), c.setValue(null);
  10417. }
  10418. return s;
  10419. }
  10420. _getAddressFunctionNodeList(a2) {
  10421. const e = [];
  10422. return a2 == null ? [] : (this._nodeTraversalReferenceFunction(a2, e), e);
  10423. }
  10424. _getTreeNode(a2) {
  10425. return a2.node;
  10426. }
  10427. async _buildDirtyRangesByAddressFunction(a2, e) {
  10428. const t = e.addressFunctionNodes;
  10429. if (t.length === 0)
  10430. return;
  10431. const r = e.refOffsetX, n = e.refOffsetY, s = await this._getRangeListByFunctionRefNode(t, r, n);
  10432. e.addressFunctionNodes = [], this._addDependencyTreeByAddressFunction(e, s);
  10433. const o = a2.bulkSearch(s), u = this._buildTreeNodeById(o);
  10434. u.length !== 0 && await this._calculateAddressFunctionRuntimeData(a2, u);
  10435. }
  10436. async _calculateListByFunctionRefNode(a2) {
  10437. const e = new $R();
  10438. for (let t = 0, r = a2.length; t < r; t++) {
  10439. const n = a2[t];
  10440. e.insert({
  10441. unitId: n.unitId,
  10442. sheetId: n.subUnitId,
  10443. range: {
  10444. startRow: n.row,
  10445. startColumn: n.column,
  10446. endRow: n.row,
  10447. endColumn: n.column
  10448. },
  10449. id: n.treeId
  10450. });
  10451. }
  10452. this._executedAddressFunctionNodeIds.clear();
  10453. for (let t = 0, r = a2.length; t < r; t++) {
  10454. const n = a2[t];
  10455. await this._calculateAddressFunction(e, n);
  10456. }
  10457. }
  10458. async _calculateAddressFunction(a2, e) {
  10459. const t = e.addressFunctionNodes;
  10460. if (t.length === 0)
  10461. return;
  10462. const r = e.refOffsetX, n = e.refOffsetY;
  10463. this._runtimeService.setCurrent(
  10464. e.row,
  10465. e.column,
  10466. e.rowCount,
  10467. e.columnCount,
  10468. e.subUnitId,
  10469. e.unitId
  10470. );
  10471. const s = [];
  10472. for (let c = 0, l2 = t.length; c < l2; c++) {
  10473. const f2 = await this._getRangeListByNode({
  10474. node: t[c],
  10475. refOffsetX: r,
  10476. refOffsetY: n
  10477. });
  10478. s.push(...f2);
  10479. }
  10480. const o = /* @__PURE__ */ new Set();
  10481. this._searchDependencyByAddressFunction(a2, s, o);
  10482. const u = this._buildTreeNodeById(o);
  10483. if (u.length === 0) {
  10484. await this._buildDirtyRangesByAddressFunction(a2, e);
  10485. return;
  10486. }
  10487. await this._calculateAddressFunctionRuntimeData(a2, u), await this._buildDirtyRangesByAddressFunction(a2, e);
  10488. }
  10489. async _calculateAddressFunctionRuntimeData(a2, e) {
  10490. for (; e.length > 0; ) {
  10491. const t = e.pop(), n = {
  10492. node: this._getTreeNode(t),
  10493. refOffsetX: t.refOffsetX,
  10494. refOffsetY: t.refOffsetY
  10495. };
  10496. await this._calculateAddressFunction(a2, t), this._runtimeService.setCurrent(
  10497. t.row,
  10498. t.column,
  10499. t.rowCount,
  10500. t.columnCount,
  10501. t.subUnitId,
  10502. t.unitId
  10503. );
  10504. let s;
  10505. this._interpreter.checkAsyncNode(n.node) ? s = await this._interpreter.executeAsync(n) : s = this._interpreter.execute(n), t.formulaId != null ? this._runtimeService.setRuntimeOtherData(t.formulaId, t.refOffsetX, t.refOffsetY, s) : this._runtimeService.setRuntimeData(s);
  10506. }
  10507. }
  10508. _buildTreeNodeById(a2) {
  10509. const e = [];
  10510. for (const t of a2) {
  10511. const r = this._getTreeById(t);
  10512. !r || this._executedAddressFunctionNodeIds.has(t) || (this._executedAddressFunctionNodeIds.add(t), e.push(r));
  10513. }
  10514. return e;
  10515. }
  10516. _searchDependencyByAddressFunction(a2, e, t) {
  10517. const r = a2.bulkSearch(e), n = this._dependencyRTreeCacheForAddressFunction.bulkSearch(e);
  10518. for (const o of n)
  10519. t.has(o) || t.add(o);
  10520. const s = [];
  10521. for (const o of r) {
  10522. const u = this._getTreeById(o);
  10523. u && !t.has(o) && (s.push(...u.rangeList), t.add(o));
  10524. }
  10525. return s.length > 0 && this._searchDependencyByAddressFunction(a2, s, t), t;
  10526. }
  10527. _getTreeById(a2) {
  10528. return this._dependencyManagerService.getTreeById(a2);
  10529. }
  10530. _addDependencyTreeByAddressFunction(a2, e) {
  10531. const t = [];
  10532. for (let r = 0; r < e.length; r++) {
  10533. const n = e[r], { unitId: s, sheetId: o, range: u } = n;
  10534. t.push({
  10535. unitId: s,
  10536. sheetId: o,
  10537. range: u,
  10538. id: a2.treeId
  10539. });
  10540. }
  10541. this._dependencyRTreeCacheForAddressFunction.bulkInsert(t);
  10542. }
  10543. /**
  10544. * Calculate the range required for collection in advance,
  10545. * including references and location functions (such as OFFSET, INDIRECT, INDEX, etc.).
  10546. * @param node
  10547. */
  10548. async _getRangeListByFunctionRefNode(a2, e, t) {
  10549. const r = [];
  10550. for (let n = 0, s = a2.length; n < s; n++) {
  10551. const o = a2[n], c = (await this._executeNode(o, e, t)).toUnitRange();
  10552. r.push(c), o.setValue(null);
  10553. }
  10554. return r;
  10555. }
  10556. /**
  10557. * Build a formula dependency tree based on the dependency relationships.
  10558. * @param treeList
  10559. */
  10560. _getUpdateTreeListAndMakeDependency(a2) {
  10561. const e = [], t = /* @__PURE__ */ new Set(), r = this._currentConfigService.isForceCalculate(), n = this._currentConfigService.getDirtyRanges(), s = this._dependencyManagerService.searchDependency(n), o = this._dependencyRTreeCacheForAddressFunction.bulkSearch(n);
  10562. for (const c of o)
  10563. s.add(c);
  10564. const u = this._dependencyManagerService.buildDependencyTree(a2);
  10565. for (const c of u) {
  10566. const l2 = c.treeId;
  10567. (r || c.isDirty || c.dependencySheetName(this._currentConfigService.getDirtyNameMap()) || //O(n) n=tree.rangeList.length
  10568. s.has(l2) && !c.isExcludeRange(this._currentConfigService.getExcludedRange())) && !t.has(l2) && (e.push(c), t.add(l2));
  10569. }
  10570. return e;
  10571. }
  10572. _includeTreeFeature(a2) {
  10573. var n, s;
  10574. const e = a2.unitId, t = a2.subUnitId, r = a2.featureId;
  10575. if (r != null) {
  10576. const o = this._currentConfigService.getDirtyUnitFeatureMap();
  10577. if (((s = (n = o == null ? void 0 : o[e]) == null ? void 0 : n[t]) == null ? void 0 : s[r]) != null)
  10578. return true;
  10579. }
  10580. return false;
  10581. }
  10582. _includeOtherFormula(a2) {
  10583. var n, s;
  10584. const e = a2.unitId, t = a2.subUnitId, r = a2.formulaId;
  10585. if (r != null) {
  10586. const o = this._currentConfigService.getDirtyUnitOtherFormulaMap();
  10587. if (((s = (n = o == null ? void 0 : o[e]) == null ? void 0 : n[t]) == null ? void 0 : s[r]) != null)
  10588. return true;
  10589. }
  10590. return false;
  10591. }
  10592. _detectForcedRecalculationNode(a2, e) {
  10593. return e == null ? false : this._detectForcedRecalculationNodeRecursion(e);
  10594. }
  10595. _detectForcedRecalculationNodeRecursion(a2) {
  10596. if (a2.isForcedCalculateFunction())
  10597. return true;
  10598. const e = a2.getChildren();
  10599. for (let t = 0, r = e.length; t < r; t++) {
  10600. const n = e[t];
  10601. if (this._detectForcedRecalculationNodeRecursion(n))
  10602. return true;
  10603. }
  10604. return false;
  10605. }
  10606. /**
  10607. * Determine whether all ranges of the current node exist within the dirty area.
  10608. * If they are within the dirty area, return true, indicating that this node needs to be calculated.
  10609. * @param tree
  10610. */
  10611. _includeTree(a2, e) {
  10612. var c, l2, f2;
  10613. const t = a2.unitId, r = a2.subUnitId;
  10614. if (this._detectForcedRecalculationNode(a2, e) === true || this._includeTreeFeature(a2) === true || this._includeOtherFormula(a2) === true || wh(a2, e, this._currentConfigService) === true)
  10615. return true;
  10616. const n = (l2 = (c = this._currentConfigService.getExcludedRange()) == null ? void 0 : c[t]) == null ? void 0 : l2[r];
  10617. if ((n == null ? void 0 : n.getValue(a2.row, a2.column)) != null)
  10618. return false;
  10619. if (((f2 = this._currentConfigService.getDirtyNameMap()[t]) == null ? void 0 : f2[r]) != null)
  10620. return true;
  10621. if (!this._updateRangeFlattenCache.has(t))
  10622. return false;
  10623. const o = this._updateRangeFlattenCache.get(t);
  10624. if (!o.has(r))
  10625. return false;
  10626. const u = o.get(r);
  10627. for (const h of u)
  10628. if (a2.inRangeData(h))
  10629. return true;
  10630. return false;
  10631. }
  10632. /**
  10633. * Generate the final formula calculation order array by traversing the dependency tree established via depth-first search.
  10634. * @param treeList
  10635. */
  10636. _calculateRunList(a2) {
  10637. const e = a2, t = [], r = [];
  10638. for (; e.length > 0; ) {
  10639. const n = e.pop();
  10640. if (n === void 0 || n.isSkip())
  10641. continue;
  10642. if (n.isAdded()) {
  10643. t.push(n), n.setSkip();
  10644. continue;
  10645. }
  10646. r.length = 0;
  10647. for (const o of n.parents) {
  10648. const u = this._dependencyManagerService.getTreeById(o);
  10649. if (!u)
  10650. throw new Error("ParentDependencyTree object is null");
  10651. u.isAdded() || n.isSkip() || r.push(u);
  10652. }
  10653. const s = this._dependencyRTreeCacheForAddressFunction.bulkSearch(n.toRTreeItem());
  10654. for (const o of s) {
  10655. const u = this._dependencyManagerService.getTreeById(o);
  10656. if (!u)
  10657. throw new Error("ParentDependencyTree object is null");
  10658. u.isAdded() || n.isSkip() || r.push(u);
  10659. }
  10660. r.length === 0 ? (t.push(n), n.setSkip()) : (n.setAdded(), e.push(n, ...r));
  10661. }
  10662. return t;
  10663. }
  10664. };
  10665. Hs = Ph([
  10666. wt(0, Ft),
  10667. wt(1, Nt),
  10668. wt(2, ya),
  10669. wt(3, jr),
  10670. wt(4, ot(Cr)),
  10671. wt(5, ot(xr)),
  10672. wt(6, ot(gr)),
  10673. wt(7, Hn)
  10674. ], Hs);
  10675. var Lh = Object.defineProperty;
  10676. var xh = Object.getOwnPropertyDescriptor;
  10677. var jh = (i, a2, e, t) => {
  10678. for (var r = t > 1 ? void 0 : t ? xh(a2, e) : a2, n = i.length - 1, s; n >= 0; n--)
  10679. (s = i[n]) && (r = (t ? s(a2, e, r) : s(r)) || r);
  10680. return t && r && Lh(a2, e, r), r;
  10681. };
  10682. var Qt = (i, a2) => (e, t) => a2(e, t, i);
  10683. var Uh = 500;
  10684. var Gs = Ct("engine-formula.calculate-formula.service");
  10685. var Qs = class extends nt {
  10686. constructor(a2, e, t, r, n, s, o) {
  10687. super();
  10688. A(this, "_executionInProgressListener$", new Subject());
  10689. A(this, "executionInProgressListener$", this._executionInProgressListener$.asObservable());
  10690. A(this, "_executionCompleteListener$", new Subject());
  10691. A(this, "executionCompleteListener$", this._executionCompleteListener$.asObservable());
  10692. this._configService = a2, this._lexer = e, this._currentConfigService = t, this._runtimeService = r, this._formulaDependencyGenerator = n, this._interpreter = s, this._astTreeBuilder = o;
  10693. }
  10694. /**
  10695. * Stop the execution of the formula.
  10696. */
  10697. stopFormulaExecution() {
  10698. this._runtimeService.stopExecution();
  10699. }
  10700. /**
  10701. * When the feature is loading,
  10702. * the pre-calculated content needs to be input to the formula engine in advance,
  10703. * so that the formula can read the correct values.
  10704. * @param featureId
  10705. * @param featureData
  10706. */
  10707. setRuntimeFeatureCellData(a2, e) {
  10708. this._runtimeService.setRuntimeFeatureCellData(a2, e);
  10709. }
  10710. setRuntimeFeatureRange(a2, e) {
  10711. this._runtimeService.setRuntimeFeatureRange(a2, e);
  10712. }
  10713. async execute(a2) {
  10714. this._runtimeService.setFormulaExecuteStage(ft.START), this._executionInProgressListener$.next(this._runtimeService.getRuntimeState()), this._currentConfigService.load(a2), this._runtimeService.reset();
  10715. const e = a2.maxIteration || so;
  10716. for (let t = 0; t < e && (this._runtimeService.setFormulaCycleIndex(t), await this._execute(), Bs.clear(), !!this._runtimeService.isCycleDependency()); t++)
  10717. ;
  10718. this._runtimeService.setFormulaExecuteStage(ft.CALCULATION_COMPLETED), this._executionInProgressListener$.next(this._runtimeService.getRuntimeState()), this._executionCompleteListener$.next(this._runtimeService.getAllRuntimeData()), St.clear(), this._runtimeService.reset();
  10719. }
  10720. async _execute() {
  10721. const a2 = await this._apply();
  10722. if (a2 == null)
  10723. return;
  10724. const { arrayFormulaRange: e, runtimeFeatureRange: t } = a2, { dirtyRanges: r, excludedCell: n } = this._getArrayFormulaDirtyRangeAndExcludedRange(
  10725. e,
  10726. t
  10727. );
  10728. return r == null || r.length === 0 || (this._currentConfigService.loadDirtyRangesAndExcludedCell(r, n), await this._apply(true)), true;
  10729. }
  10730. _getArrayFormulaDirtyRangeAndExcludedRange(a2, e) {
  10731. const t = [], r = {};
  10732. return Object.keys(a2).forEach((n) => {
  10733. const s = a2[n];
  10734. if (s == null)
  10735. return true;
  10736. Object.keys(s).forEach((o) => {
  10737. const u = new kt(s[o]);
  10738. if (u == null)
  10739. return true;
  10740. const c = new kt();
  10741. u.forValue((l2, f2, h) => {
  10742. c.setValue(l2, f2, true), t.push({ unitId: n, sheetId: o, range: h });
  10743. }), r[n] == null && (r[n] = {}), r[n][o] = c;
  10744. });
  10745. }), Object.keys(e).forEach((n) => {
  10746. const s = e[n];
  10747. Object.keys(s).forEach((o) => {
  10748. const u = s[o];
  10749. if (u == null)
  10750. return true;
  10751. Object.keys(u).forEach((c) => {
  10752. const l2 = u[c];
  10753. if (l2 == null)
  10754. return true;
  10755. for (const f2 of l2)
  10756. t.push({ unitId: o, sheetId: c, range: f2 });
  10757. });
  10758. });
  10759. }), { dirtyRanges: t, excludedCell: r };
  10760. }
  10761. // eslint-disable-next-line max-lines-per-function
  10762. async _apply(a2 = false) {
  10763. a2 ? this._runtimeService.setFormulaExecuteStage(ft.START_DEPENDENCY_ARRAY_FORMULA) : this._runtimeService.setFormulaExecuteStage(ft.START_DEPENDENCY), this._executionInProgressListener$.next(this._runtimeService.getRuntimeState());
  10764. const e = (await this._formulaDependencyGenerator.generate()).reverse(), t = this._interpreter;
  10765. a2 ? (this._runtimeService.setFormulaExecuteStage(ft.START_CALCULATION_ARRAY_FORMULA), this._runtimeService.setTotalArrayFormulasToCalculate(e.length)) : (this._runtimeService.setFormulaExecuteStage(ft.START_CALCULATION), this._runtimeService.setTotalFormulasToCalculate(e.length)), this._executionInProgressListener$.next(this._runtimeService.getRuntimeState());
  10766. let r = [];
  10767. const n = this._configService.getConfig(fa), s = (n == null ? void 0 : n.intervalCount) || Uh, o = e.length;
  10768. for (let u = 0; u < o; u++) {
  10769. const c = e[u], l2 = c.nodeData, f2 = c.getDirtyData;
  10770. if (u % s === 0 && (await new Promise((d2) => {
  10771. const _ = SR(d2);
  10772. r.push(_);
  10773. }), a2 ? (this._runtimeService.setFormulaExecuteStage(
  10774. ft.CURRENTLY_CALCULATING_ARRAY_FORMULA
  10775. ), this._runtimeService.setCompletedArrayFormulasCount(u + 1)) : (this._runtimeService.setFormulaExecuteStage(ft.CURRENTLY_CALCULATING), this._runtimeService.setCompletedFormulasCount(u + 1)), this._executionInProgressListener$.next(this._runtimeService.getRuntimeState()), this._runtimeService.isStopExecution() || l2 == null && f2 == null)) {
  10776. this._runtimeService.setFormulaExecuteStage(ft.IDLE), this._runtimeService.markedAsStopFunctionsExecuted(), this._executionCompleteListener$.next(this._runtimeService.getAllRuntimeData());
  10777. return;
  10778. }
  10779. this._runtimeService.setCurrent(
  10780. c.row,
  10781. c.column,
  10782. c.rowCount,
  10783. c.columnCount,
  10784. c.subUnitId,
  10785. c.unitId
  10786. );
  10787. let h;
  10788. if (f2 != null && c.featureId != null) {
  10789. const { runtimeCellData: d2, dirtyRanges: _ } = f2(this._currentConfigService.getDirtyData(), this._runtimeService.getAllRuntimeData());
  10790. this._runtimeService.setRuntimeFeatureCellData(c.featureId, d2), this._runtimeService.setRuntimeFeatureRange(c.featureId, _);
  10791. } else
  10792. l2 != null && (t.checkAsyncNode(l2.node) ? h = await t.executeAsync(l2) : h = t.execute(l2), c.formulaId != null ? this._runtimeService.setRuntimeOtherData(c.formulaId, c.refOffsetX, c.refOffsetY, h) : this._runtimeService.setRuntimeData(h));
  10793. }
  10794. return r.forEach((u) => u()), r = [], o > 0 ? this._runtimeService.markedAsSuccessfullyExecuted() : a2 || this._runtimeService.markedAsNoFunctionsExecuted(), this._runtimeService.getAllRuntimeData();
  10795. }
  10796. calculate(a2, e = true) {
  10797. const t = this._lexer.treeBuilder(a2, e);
  10798. if (Object.values(m2).includes(t))
  10799. return xe.create(t);
  10800. const r = this._astTreeBuilder.parse(t);
  10801. r == null || r.serialize();
  10802. }
  10803. };
  10804. Qs = jh([
  10805. Qt(0, SE),
  10806. Qt(1, ot(gr)),
  10807. Qt(2, Ft),
  10808. Qt(3, Nt),
  10809. Qt(4, Ys),
  10810. Qt(5, ot(Cr)),
  10811. Qt(6, ot(xr))
  10812. ], Qs);
  10813. var vh = Object.defineProperty;
  10814. var Th = Object.getOwnPropertyDescriptor;
  10815. var Bh = (i, a2, e, t) => {
  10816. for (var r = t > 1 ? void 0 : t ? Th(a2, e) : a2, n = i.length - 1, s; n >= 0; n--)
  10817. (s = i[n]) && (r = (t ? s(a2, e, r) : s(r)) || r);
  10818. return t && r && vh(a2, e, r), r;
  10819. };
  10820. var ms = (i, a2) => (e, t) => a2(e, t, i);
  10821. var Nn = class extends nt {
  10822. constructor(i, a2, e) {
  10823. super(), this._commandService = i, this._calculateFormulaService = a2, this._formulaDataModel = e, this._initialize();
  10824. }
  10825. _initialize() {
  10826. this._commandExecutedListener(), this._initialExecuteFormulaListener();
  10827. }
  10828. _commandExecutedListener() {
  10829. this.disposeWithMe(
  10830. this._commandService.onCommandExecuted((i) => {
  10831. if (i.id === zi.id)
  10832. this._calculateFormulaService.stopFormulaExecution();
  10833. else if (i.id === Zi.id) {
  10834. const a2 = i.params;
  10835. this._calculate(a2);
  10836. } else if (i.id === bs.id) {
  10837. const a2 = i.params;
  10838. if (a2 == null)
  10839. return;
  10840. const { arrayFormulaRange: e, arrayFormulaCellData: t } = a2;
  10841. this._formulaDataModel.setArrayFormulaRange(e), this._formulaDataModel.setArrayFormulaCellData(t);
  10842. }
  10843. })
  10844. );
  10845. }
  10846. async _calculate(i) {
  10847. const { forceCalculation: a2 = false, dirtyRanges: e = [], dirtyNameMap: t = {}, dirtyDefinedNameMap: r = {}, dirtyUnitFeatureMap: n = {}, dirtyUnitOtherFormulaMap: s = {}, clearDependencyTreeCache: o = {}, maxIteration: u = so } = i, c = this._formulaDataModel.getFormulaData(), l2 = this._formulaDataModel.getArrayFormulaCellData(), f2 = this._formulaDataModel.getArrayFormulaRange();
  10848. this._calculateFormulaService.execute({
  10849. formulaData: c,
  10850. arrayFormulaCellData: l2,
  10851. arrayFormulaRange: f2,
  10852. forceCalculate: a2,
  10853. dirtyRanges: e,
  10854. dirtyNameMap: t,
  10855. dirtyDefinedNameMap: r,
  10856. dirtyUnitFeatureMap: n,
  10857. dirtyUnitOtherFormulaMap: s,
  10858. clearDependencyTreeCache: o,
  10859. maxIteration: u
  10860. });
  10861. }
  10862. // Notification
  10863. _initialExecuteFormulaListener() {
  10864. this._calculateFormulaService.executionCompleteListener$.subscribe((i) => {
  10865. const a2 = i.functionsExecutedState;
  10866. switch (a2) {
  10867. case wr.NOT_EXECUTED:
  10868. break;
  10869. case wr.STOP_EXECUTION:
  10870. break;
  10871. case wr.SUCCESS:
  10872. this._applyResult(i);
  10873. break;
  10874. case wr.INITIAL:
  10875. break;
  10876. }
  10877. this._commandService.executeCommand(
  10878. Ns.id,
  10879. {
  10880. functionsExecutedState: a2
  10881. },
  10882. {
  10883. onlyLocal: true
  10884. }
  10885. );
  10886. }), this._calculateFormulaService.executionInProgressListener$.subscribe((i) => {
  10887. this._commandService.executeCommand(
  10888. Ns.id,
  10889. {
  10890. stageInfo: i
  10891. },
  10892. {
  10893. onlyLocal: true
  10894. }
  10895. );
  10896. });
  10897. }
  10898. async _applyResult(i) {
  10899. const { unitData: a2, unitOtherData: e, arrayFormulaRange: t, arrayFormulaCellData: r, clearArrayFormulaCellData: n } = i;
  10900. if (!a2) {
  10901. console.error("No sheetData from Formula Engine!");
  10902. return;
  10903. }
  10904. t && (this._formulaDataModel.clearPreviousArrayFormulaCellData(n), this._formulaDataModel.mergeArrayFormulaCellData(r), this._formulaDataModel.mergeArrayFormulaRange(t), this._commandService.executeCommand(
  10905. bs.id,
  10906. {
  10907. arrayFormulaRange: this._formulaDataModel.getArrayFormulaRange(),
  10908. arrayFormulaCellData: this._formulaDataModel.getArrayFormulaCellData()
  10909. },
  10910. {
  10911. onlyLocal: true
  10912. }
  10913. )), this._commandService.executeCommand(
  10914. Ji.id,
  10915. {
  10916. unitData: uc(a2),
  10917. unitOtherData: e
  10918. },
  10919. {
  10920. onlyLocal: true
  10921. }
  10922. );
  10923. }
  10924. };
  10925. Nn = Bh([
  10926. ms(0, Pt),
  10927. ms(1, Gs),
  10928. ms(2, ot(Pr))
  10929. ], Nn);
  10930. var Ni = /[\[\]]/g;
  10931. function Oi(i, a2) {
  10932. if (Ni.test(i)) {
  10933. const e = Number(i.replace(Ni, ""));
  10934. return a2 + e;
  10935. }
  10936. return Number(i) - 1;
  10937. }
  10938. function gs(i, a2 = 0, e = 0) {
  10939. i = i.toLocaleUpperCase();
  10940. const t = i.split(/[RC]/), r = t[1], n = t[2], s = Oi(r, a2), o = Oi(n, e);
  10941. return {
  10942. row: s,
  10943. column: o,
  10944. absoluteRefType: tt.NONE
  10945. };
  10946. }
  10947. function Ih(i, a2 = 0, e = 0) {
  10948. const { refBody: t, sheetName: r, unitId: n } = na(i), s = t.indexOf(":");
  10949. if (s === -1) {
  10950. const C = gs(t, a2, e), E2 = C.row, b = C.column, R = C.absoluteRefType;
  10951. return {
  10952. unitId: n,
  10953. sheetName: r,
  10954. range: {
  10955. startRow: E2,
  10956. startColumn: b,
  10957. endRow: E2,
  10958. endColumn: b,
  10959. startAbsoluteRefType: R,
  10960. endAbsoluteRefType: R
  10961. }
  10962. };
  10963. }
  10964. const o = t.substring(0, s), u = t.substring(s + 1), c = gs(o, a2, e), l2 = gs(u, a2, e), f2 = c.row, h = c.column, d2 = l2.row, _ = l2.column;
  10965. return {
  10966. unitId: n,
  10967. sheetName: r,
  10968. range: {
  10969. startRow: f2,
  10970. startColumn: h,
  10971. endRow: d2,
  10972. endColumn: _,
  10973. startAbsoluteRefType: c.absoluteRefType,
  10974. endAbsoluteRefType: l2.absoluteRefType
  10975. }
  10976. };
  10977. }
  10978. function Fh(i) {
  10979. const a2 = qr(i.startRow, i.startAbsoluteRefType, true), e = qr(i.startColumn, i.startAbsoluteRefType, false), t = qr(i.endRow, i.endAbsoluteRefType, true), r = qr(i.endColumn, i.endAbsoluteRefType, false);
  10980. return a2 === t && e === r ? `R${a2}C${e}` : `R${a2}C${e}:R${t}C${r}`;
  10981. }
  10982. function qr(i, a2 = tt.ALL, e) {
  10983. switch (i += 1, a2) {
  10984. case tt.ALL:
  10985. return `${i}`;
  10986. case tt.ROW:
  10987. return e ? `${i}` : `[${i}]`;
  10988. case tt.COLUMN:
  10989. return e ? `[${i}]` : `${i}`;
  10990. case tt.NONE:
  10991. return `[${i}]`;
  10992. }
  10993. }
  10994. function Xt(i) {
  10995. let a2 = i;
  10996. if (i.isArray()) {
  10997. const e = i.getRowCount(), t = i.getColumnCount();
  10998. if (e > 1 || t > 1)
  10999. return g2.create(m2.VALUE);
  11000. a2 = i.get(0, 0);
  11001. }
  11002. return a2.isError(), a2;
  11003. }
  11004. function Fr(...i) {
  11005. for (let a2 = 0; a2 < i.length; a2++) {
  11006. const e = Xt(i[a2]);
  11007. if (e.isError())
  11008. return {
  11009. isError: true,
  11010. errorObject: e
  11011. };
  11012. i[a2] = e;
  11013. }
  11014. return {
  11015. isError: false,
  11016. variants: i
  11017. };
  11018. }
  11019. function H(...i) {
  11020. for (let a2 = 0; a2 < i.length; a2++) {
  11021. const e = Xt(i[a2]);
  11022. if (e.isError())
  11023. return {
  11024. isError: true,
  11025. errorObject: e
  11026. };
  11027. if (e.isBoolean())
  11028. return {
  11029. isError: true,
  11030. errorObject: g2.create(m2.VALUE)
  11031. };
  11032. i[a2] = e;
  11033. }
  11034. return {
  11035. isError: false,
  11036. variants: i
  11037. };
  11038. }
  11039. function Fe2(...i) {
  11040. for (let a2 = 0; a2 < i.length; a2++) {
  11041. let e = i[a2];
  11042. if (e.isError())
  11043. return {
  11044. isError: true,
  11045. errorObject: e
  11046. };
  11047. if (e.isNull())
  11048. return {
  11049. isError: true,
  11050. errorObject: g2.create(m2.NA)
  11051. };
  11052. if (e = Xt(i[a2]), e.isError())
  11053. return {
  11054. isError: true,
  11055. errorObject: e
  11056. };
  11057. if (e.isBoolean())
  11058. return {
  11059. isError: true,
  11060. errorObject: g2.create(m2.VALUE)
  11061. };
  11062. i[a2] = e;
  11063. }
  11064. return {
  11065. isError: false,
  11066. variants: i
  11067. };
  11068. }
  11069. function I2(...i) {
  11070. for (let a2 = 0; a2 < i.length; a2++) {
  11071. let e = i[a2];
  11072. if (e.isString() && (e = e.convertToNumberObjectValue()), e.isError())
  11073. return {
  11074. isError: true,
  11075. errorObject: e
  11076. };
  11077. i[a2] = e;
  11078. }
  11079. return {
  11080. isError: false,
  11081. variants: i
  11082. };
  11083. }
  11084. var V = class {
  11085. constructor(a2) {
  11086. A(this, "_unitId");
  11087. A(this, "_subUnitId");
  11088. A(this, "_row", -1);
  11089. A(this, "_column", -1);
  11090. A(this, "_definedNames");
  11091. A(this, "_locale");
  11092. A(this, "_sheetOrder");
  11093. A(this, "_sheetNameMap");
  11094. A(this, "_formulaDataModel");
  11095. A(this, "_rowCount", -1);
  11096. A(this, "_columnCount", -1);
  11097. A(this, "needsExpandParams", false);
  11098. A(this, "needsReferenceObject", false);
  11099. A(this, "needsLocale", false);
  11100. A(this, "needsSheetsInfo", false);
  11101. A(this, "needsFormulaDataModel", false);
  11102. A(this, "needsSheetRowColumnCount", false);
  11103. A(this, "minParams", -1);
  11104. A(this, "maxParams", -1);
  11105. this._name = a2;
  11106. }
  11107. get name() {
  11108. return this._name;
  11109. }
  11110. get unitId() {
  11111. return this._unitId;
  11112. }
  11113. get subUnitId() {
  11114. return this._subUnitId;
  11115. }
  11116. get row() {
  11117. return this._row;
  11118. }
  11119. get column() {
  11120. return this._column;
  11121. }
  11122. dispose() {
  11123. }
  11124. /**
  11125. * In Excel, to inject a defined name into a function that has positioning capabilities,
  11126. * such as using the INDIRECT function to reference a named range,
  11127. * you can write it as follows:
  11128. * =INDIRECT("DefinedName1")
  11129. */
  11130. getDefinedName(a2) {
  11131. var t;
  11132. const e = this._definedNames;
  11133. return e == null ? null : (t = Array.from(Object.values(e)).filter((r) => r.name === a2)) == null ? void 0 : t[0];
  11134. }
  11135. setDefinedNames(a2) {
  11136. this._definedNames = a2;
  11137. }
  11138. getLocale() {
  11139. return this._locale;
  11140. }
  11141. setLocale(a2) {
  11142. this._locale = a2;
  11143. }
  11144. getSheetsInfo() {
  11145. return {
  11146. sheetOrder: this._sheetOrder,
  11147. sheetNameMap: this._sheetNameMap
  11148. };
  11149. }
  11150. setSheetsInfo({
  11151. sheetOrder: a2,
  11152. sheetNameMap: e
  11153. }) {
  11154. this._sheetOrder = a2, this._sheetNameMap = e;
  11155. }
  11156. setFormulaDataModel(a2) {
  11157. this._formulaDataModel = a2;
  11158. }
  11159. setSheetRowColumnCount(a2, e) {
  11160. this._rowCount = a2, this._columnCount = e;
  11161. }
  11162. isAsync() {
  11163. return false;
  11164. }
  11165. isAddress() {
  11166. return false;
  11167. }
  11168. isCustom() {
  11169. return false;
  11170. }
  11171. setRefInfo(a2, e, t, r) {
  11172. this._unitId = a2, this._subUnitId = e, this._row = t, this._column = r;
  11173. }
  11174. calculateCustom(...a2) {
  11175. return null;
  11176. }
  11177. calculate(...a2) {
  11178. return g2.create(m2.VALUE);
  11179. }
  11180. checkArrayType(a2) {
  11181. return a2.isReferenceObject() || a2.isValueObject() && a2.isArray();
  11182. }
  11183. /**
  11184. * Starting with 1
  11185. * For instance, The column number (starting with 1 for the left-most column of table_array) that contains the return value.
  11186. * https://support.microsoft.com/en-us/office/vlookup-function-0bbc8083-26fe-4963-8ab8-93a18ad188a1
  11187. * @param indexNum
  11188. */
  11189. getIndexNumValue(a2, e = 1) {
  11190. let t = a2;
  11191. if (t.isArray() && (t = t.getFirstCell()), t.isBoolean())
  11192. return t.getValue() === false ? g2.create(m2.VALUE) : e;
  11193. if (t.isString()) {
  11194. const r = Number(t.getValue());
  11195. return Number.isNaN(r) ? g2.create(m2.REF) : r;
  11196. } else if (t.isNumber())
  11197. return t.getValue();
  11198. return g2.create(m2.VALUE);
  11199. }
  11200. /**
  11201. * A logical value that specifies 1/TRUE , 0/FALSE, default 1
  11202. * For instance range_lookup, A logical value that specifies whether you want VLOOKUP to find an approximate or an exact match
  11203. * Approximate match - 1/TRUE
  11204. * Exact match - 0/FALSE
  11205. * https://support.microsoft.com/en-us/office/vlookup-function-0bbc8083-26fe-4963-8ab8-93a18ad188a1
  11206. * For instance A1, A logical value that specifies what type of reference is contained in the cell ref_text.
  11207. * If a1 is TRUE or omitted, ref_text is interpreted as an A1-style reference.
  11208. * If a1 is FALSE, ref_text is interpreted as an R1C1-style reference.
  11209. * https://support.microsoft.com/zh-cn/office/indirect-%E5%87%BD%E6%95%B0-474b3a3a-8a26-4f44-b491-92b6306fa261
  11210. * @param logicValueObject
  11211. */
  11212. getZeroOrOneByOneDefault(a2) {
  11213. if (a2 == null)
  11214. return 1;
  11215. let e = 1;
  11216. if (a2.isArray() && (a2 = a2.getFirstCell()), a2.isBoolean())
  11217. a2.getValue() === false && (e = 0);
  11218. else {
  11219. if (a2.isString())
  11220. return;
  11221. a2.isNumber() && a2.getValue() === 0 && (e = 0);
  11222. }
  11223. return e;
  11224. }
  11225. /**
  11226. * A logical value that specifies 1/TRUE , 0/FALSE, -1, default 1.
  11227. * The difference from getZeroOrOneByOneDefault is that we need to get -1
  11228. * @param logicValueObject
  11229. */
  11230. getMatchTypeValue(a2) {
  11231. if (a2 == null)
  11232. return 1;
  11233. let e = 1;
  11234. if (a2.isArray() && (a2 = a2.getFirstCell()), a2.isBoolean())
  11235. a2.getValue() === false && (e = 0);
  11236. else {
  11237. if (a2.isString())
  11238. return;
  11239. if (a2.isNumber()) {
  11240. const t = a2.getValue();
  11241. t <= 0 && (e = t);
  11242. }
  11243. }
  11244. return e;
  11245. }
  11246. binarySearch(a2, e, t, r, n) {
  11247. const s = e.binarySearch(a2, r, n);
  11248. if (s == null)
  11249. return g2.create(m2.NA);
  11250. let o;
  11251. return t.getRowCount() === 1 ? o = t.get(0, s) || ie.create() : o = t.get(s, 0) || ie.create(), o.isNull() ? y2.create(0) : o;
  11252. }
  11253. _getOneFirstByRaw(a2) {
  11254. return a2.length === 0 ? g2.create(m2.NA) : a2[0][0] || g2.create(m2.NA);
  11255. }
  11256. _getOneLastByRaw(a2) {
  11257. return a2.length === 0 ? g2.create(m2.NA) : a2[a2.length - 1][a2[0].length - 1] || g2.create(m2.NA);
  11258. }
  11259. equalSearch(a2, e, t, r = true) {
  11260. const n = t.pickRaw(e.isEqual(a2));
  11261. return r ? this._getOneFirstByRaw(n) : this._getOneLastByRaw(n);
  11262. }
  11263. fuzzySearch(a2, e, t, r = true) {
  11264. const n = t.pickRaw(e.compare(a2, $.EQUALS));
  11265. return r ? this._getOneFirstByRaw(n) : this._getOneLastByRaw(n);
  11266. }
  11267. orderSearch(a2, e, t, r = Pe.MIN, n = false) {
  11268. const s = e.orderSearch(a2, r, n);
  11269. if (s == null)
  11270. return g2.create(m2.NA);
  11271. const o = t.get(s.row, s.column) || ie.create();
  11272. return o.isNull() ? g2.create(m2.NA) : o;
  11273. }
  11274. binarySearchExpand(a2, e, t, r = 0, n, s) {
  11275. const o = e.binarySearch(a2, n, s);
  11276. return o == null ? g2.create(m2.NA) : r === 0 ? t.slice([o, o + 1]) : t.slice(void 0, [o, o + 1]);
  11277. }
  11278. equalSearchExpand(a2, e, t, r = true, n = 0) {
  11279. const s = e.isEqual(a2);
  11280. let o;
  11281. return r ? o = s.getFirstTruePosition() : o = s.getLastTruePosition(), o == null ? g2.create(m2.NA) : n === 0 ? t.slice([o.row, o.row + 1]) : t.slice(void 0, [o.column, o.column + 1]);
  11282. }
  11283. fuzzySearchExpand(a2, e, t, r = true, n = 0) {
  11284. const s = e.compare(a2, $.EQUALS);
  11285. let o;
  11286. return r ? o = s.getFirstTruePosition() : o = s.getLastTruePosition(), o == null ? g2.create(m2.NA) : n === 0 ? t.slice([o.row, o.row + 1]) : t.slice(void 0, [o.column, o.column + 1]);
  11287. }
  11288. orderSearchExpand(a2, e, t, r = Pe.MIN, n = false, s = 0) {
  11289. const o = e.orderSearch(a2, r, n);
  11290. return o == null ? g2.create(m2.NA) : s === 0 ? t.slice([o.row, o.row + 1]) : t.slice(void 0, [o.column, o.column + 1]);
  11291. }
  11292. flattenArray(a2, e = true) {
  11293. const t = [];
  11294. t[0] = [];
  11295. for (let r = 0; r < a2.length; r++) {
  11296. let n = a2[r];
  11297. if ((n.isString() || n.isBoolean() || n.isNull()) && (n = n.convertToNumberObjectValue()), n.isError())
  11298. return n;
  11299. if (n.isArray()) {
  11300. let s;
  11301. if (n.iterator((o) => {
  11302. if (o == null || o.isNull() || e && (o.isString() || o.isBoolean()))
  11303. return true;
  11304. if (o = this._includingLogicalValuesAndText(o), o.isError())
  11305. return s = o, false;
  11306. t[0].push(o);
  11307. }), s != null && s.isError())
  11308. return s;
  11309. } else
  11310. t[0].push(n);
  11311. }
  11312. return tr(t, 1, t[0].length);
  11313. }
  11314. _includingLogicalValuesAndText(a2) {
  11315. if (a2.isBoolean() && (a2 = wf(a2)), a2.isString()) {
  11316. const e = Number(a2.getValue());
  11317. a2 = y2.create(Number.isNaN(e) ? 0 : e);
  11318. }
  11319. return a2;
  11320. }
  11321. createReferenceObject(a2, e) {
  11322. const t = a2.getForcedUnitId(), r = a2.getForcedSheetId() || "", n = a2.getForcedSheetName(), o = ys({
  11323. unitId: t,
  11324. sheetName: n,
  11325. range: e
  11326. });
  11327. let u;
  11328. return vr(o) ? u = new da(o) : Qi(o) ? u = new _a(o) : Wi(o) ? u = new Ca(o) : u = new Cn(e, r, t), this._setReferenceDefault(a2, u);
  11329. }
  11330. _setReferenceDefault(a2, e) {
  11331. return this.unitId == null || this.subUnitId == null ? g2.create(m2.REF) : (e.setDefaultUnitId(this.unitId), e.setDefaultSheetId(this.subUnitId), e.setUnitData(a2.getUnitData()), e.setRuntimeData(a2.getRuntimeData()), e.setArrayFormulaCellData(a2.getArrayFormulaCellData()), e.setRuntimeArrayFormulaCellData(a2.getRuntimeArrayFormulaCellData()), e);
  11332. }
  11333. };
  11334. var kh = class extends V {
  11335. constructor() {
  11336. super(...arguments);
  11337. A(this, "minParams", 3);
  11338. A(this, "maxParams", 3);
  11339. }
  11340. calculate(e, t, r) {
  11341. if (e.isError())
  11342. return e;
  11343. const { isError: n, errorObject: s, variants: o } = Fr(t, r);
  11344. if (n)
  11345. return s;
  11346. const { isError: u, errorObject: c, variants: l2 } = I2(...o);
  11347. if (u)
  11348. return c;
  11349. const [f2, h] = l2, d2 = Math.floor(+f2.getValue()), _ = Math.floor(+h.getValue());
  11350. if (d2 < 0 || _ < 0)
  11351. return g2.create(m2.NUM);
  11352. if (d2 === 0 || _ === 0)
  11353. return g2.create(m2.REF);
  11354. const C = e.isArray() ? e.getRowCount() : 1, E2 = e.isArray() ? e.getColumnCount() : 1;
  11355. if (C === 1 && E2 === 1)
  11356. return e.isArray() ? e.get(0, 0) : e;
  11357. const b = d2 > C ? C : d2, R = _ > E2 ? E2 : _;
  11358. return e.slice([0, b], [0, R]);
  11359. }
  11360. };
  11361. var $h = class extends V {
  11362. constructor() {
  11363. super(...arguments);
  11364. A(this, "minParams", 1);
  11365. A(this, "maxParams", 255);
  11366. }
  11367. calculate(...e) {
  11368. const t = [];
  11369. for (let r = 0; r < e.length; r++) {
  11370. const n = e[r], s = n.isArray() ? n.getRowCount() : 1, o = n.isArray() ? n.getColumnCount() : 1;
  11371. for (let u = 0; u < s; u++)
  11372. for (let c = 0; c < o; c++) {
  11373. const l2 = n.isArray() ? n.get(u, c) : n;
  11374. t.push([l2]);
  11375. }
  11376. }
  11377. return q2.create({
  11378. calculateValueList: t,
  11379. rowCount: t.length,
  11380. columnCount: 1,
  11381. unitId: this.unitId,
  11382. sheetId: this.subUnitId,
  11383. row: this.row,
  11384. column: this.column
  11385. });
  11386. }
  11387. };
  11388. var Ws = ((i) => (i.ARRAY_CONSTRAIN = "ARRAY_CONSTRAIN", i.FLATTEN = "FLATTEN", i))(Ws || {});
  11389. var Yh = [
  11390. [kh, Ws.ARRAY_CONSTRAIN],
  11391. [$h, Ws.FLATTEN]
  11392. ];
  11393. var _r;
  11394. ((i) => {
  11395. const a2 = 0.636619772;
  11396. function e(n, s) {
  11397. let o = 0;
  11398. for (let u = 0; u < n.length; ++u)
  11399. o = s * o + n[u];
  11400. return o;
  11401. }
  11402. function t(n, s, o, u, c) {
  11403. if (s === 0)
  11404. return o;
  11405. if (s === 1)
  11406. return u;
  11407. const l2 = 2 / n;
  11408. let f2 = o, h = u, d2 = u;
  11409. for (let _ = 1; _ < s; ++_)
  11410. d2 = h * _ * l2 + c * f2, f2 = h, h = d2;
  11411. return d2;
  11412. }
  11413. function r(n, s, o, u) {
  11414. return function(l2, f2) {
  11415. if (o) {
  11416. if (l2 === 0)
  11417. return o === 1 ? -1 / 0 : 1 / 0;
  11418. if (l2 < 0)
  11419. return Number.NaN;
  11420. }
  11421. if (f2 === 0)
  11422. return n(l2);
  11423. if (f2 === 1)
  11424. return s(l2);
  11425. if (f2 < 0)
  11426. return Number.NaN;
  11427. const h = f2 | 0, d2 = n(l2), _ = s(l2);
  11428. return t(l2, h, d2, _, u);
  11429. };
  11430. }
  11431. i.besselj = (() => {
  11432. const n = [-184.9052456, 77392.33017, -1121442418e-2, 6516196407e-1, -13362590354, 57568490574], s = [1, 267.8532712, 59272.64853, 9494680718e-3, 1029532985, 57568490411], o = [2093887211e-16, -2073370639e-15, 2734510407e-14, -0.001098628627, 1], u = [-934935152e-16, 7621095161e-16, -6911147651e-15, 1430488765e-13, -0.01562499995];
  11433. function c(C) {
  11434. let E2 = 0, b = 0, R = 0, p2 = C * C;
  11435. if (C < 8)
  11436. b = e(n, p2), R = e(s, p2), E2 = b / R;
  11437. else {
  11438. const N2 = C - 0.785398164;
  11439. p2 = 64 / p2, b = e(o, p2), R = e(u, p2), E2 = Math.sqrt(a2 / C) * (Math.cos(N2) * b - Math.sin(N2) * R * 8 / C);
  11440. }
  11441. return E2;
  11442. }
  11443. const l2 = [-30.16036606, 15704.4826, -2972611439e-3, 2423968531e-1, -7895059235, 72362614232], f2 = [1, 376.9991397, 99447.43394, 1858330474e-2, 2300535178, 144725228442], h = [-240337019e-15, 2457520174e-15, -3516396496e-14, 183105e-8, 1], d2 = [105787412e-15, -88228987e-14, 8449199096e-15, -2002690873e-13, 0.04687499995];
  11444. function _(C) {
  11445. let E2 = 0, b = 0, R = 0, p2 = C * C;
  11446. const N2 = Math.abs(C) - 2.356194491;
  11447. return Math.abs(C) < 8 ? (b = C * e(l2, p2), R = e(f2, p2), E2 = b / R) : (p2 = 64 / p2, b = e(h, p2), R = e(d2, p2), E2 = Math.sqrt(a2 / Math.abs(C)) * (Math.cos(N2) * b - Math.sin(N2) * R * 8 / Math.abs(C)), C < 0 && (E2 = -E2)), E2;
  11448. }
  11449. return function C(E2, b) {
  11450. const R = Math.round(b);
  11451. if (!Number.isFinite(E2))
  11452. return Number.isNaN(E2) ? E2 : 0;
  11453. if (R < 0)
  11454. return (R % 2 ? -1 : 1) * C(E2, -R);
  11455. if (E2 < 0)
  11456. return (R % 2 ? -1 : 1) * C(-E2, R);
  11457. if (R === 0)
  11458. return c(E2);
  11459. if (R === 1)
  11460. return _(E2);
  11461. if (E2 === 0)
  11462. return 0;
  11463. let p2 = 0;
  11464. if (E2 > R)
  11465. p2 = t(E2, R, c(E2), _(E2), -1);
  11466. else {
  11467. const N2 = 2 * Math.floor((R + Math.floor(Math.sqrt(40 * R))) / 2);
  11468. let M2 = false, w = 0, D2 = 0, S2 = 1, P = 0;
  11469. const U2 = 2 / E2;
  11470. for (let x2 = N2; x2 > 0; x2--)
  11471. if (P = x2 * U2 * S2 - w, w = S2, S2 = P, Math.abs(S2) > 1e10 && (S2 *= 1e-10, w *= 1e-10, p2 *= 1e-10, D2 *= 1e-10), M2 && (D2 += S2), M2 = !M2, x2 === R && (p2 = w), N2 - x2 > 100 && p2 === 0)
  11472. return Number.NaN;
  11473. D2 = 2 * D2 - S2, p2 /= D2;
  11474. }
  11475. return p2;
  11476. };
  11477. })(), i.bessely = (() => {
  11478. const n = [228.4622733, -86327.92757, 1087988129e-2, -5123598036e-1, 7062834065, -2957821389], s = [1, 226.1030244, 47447.2647, 7189466438e-3, 7452499648e-1, 40076544269], o = [2093887211e-16, -2073370639e-15, 2734510407e-14, -0.001098628627, 1], u = [-934945152e-16, 7621095161e-16, -6911147651e-15, 1430488765e-13, -0.01562499995];
  11479. function c(C) {
  11480. let E2 = 0, b = 0, R = 0, p2 = C * C;
  11481. const N2 = C - 0.785398164;
  11482. return C < 8 ? (b = e(n, p2), R = e(s, p2), E2 = b / R + a2 * (0, i.besselj)(C, 0) * Math.log(C)) : (p2 = 64 / p2, b = e(o, p2), R = e(u, p2), E2 = Math.sqrt(a2 / C) * (Math.sin(N2) * b + Math.cos(N2) * R * 8 / C)), E2;
  11483. }
  11484. const l2 = [8511.937935, -4237922726e-3, 7349264551e-1, -51534381390, 127527439e4, -4900604943e3], f2 = [1, 354.9632885, 102042.605, 2245904002e-2, 3733650367, 424441966400, 249958057e5], h = [-240337019e-15, 2457520174e-15, -3516396496e-14, 183105e-8, 1], d2 = [105787412e-15, -88228987e-14, 8449199096e-15, -2002690873e-13, 0.04687499995];
  11485. function _(C) {
  11486. let E2 = 0, b = 0, R = 0, p2 = C * C;
  11487. const N2 = C - 2.356194491;
  11488. return C < 8 ? (b = C * e(l2, p2), R = e(f2, p2), E2 = b / R + a2 * ((0, i.besselj)(C, 1) * Math.log(C) - 1 / C)) : (p2 = 64 / p2, b = e(h, p2), R = e(d2, p2), E2 = Math.sqrt(a2 / C) * (Math.sin(N2) * b + Math.cos(N2) * R * 8 / C)), E2;
  11489. }
  11490. return r(c, _, 1, -1);
  11491. })(), i.besseli = (() => {
  11492. const n = [45813e-7, 0.0360768, 0.2659732, 1.2067492, 3.0899424, 3.5156229, 1], s = [392377e-8, -0.01647633, 0.02635537, -0.02057706, 916281e-8, -157565e-8, 225319e-8, 0.01328592, 0.39894228];
  11493. function o(f2) {
  11494. return f2 <= 3.75 ? e(n, f2 * f2 / (3.75 * 3.75)) : Math.exp(Math.abs(f2)) / Math.sqrt(Math.abs(f2)) * e(s, 3.75 / Math.abs(f2));
  11495. }
  11496. const u = [32411e-8, 301532e-8, 0.02658733, 0.15084934, 0.51498869, 0.87890594, 0.5], c = [-420059e-8, 0.01787654, -0.02895312, 0.02282967, -0.01031555, 163801e-8, -362018e-8, -0.03988024, 0.39894228];
  11497. function l2(f2) {
  11498. return f2 < 3.75 ? f2 * e(u, f2 * f2 / (3.75 * 3.75)) : (f2 < 0 ? -1 : 1) * Math.exp(Math.abs(f2)) / Math.sqrt(Math.abs(f2)) * e(c, 3.75 / Math.abs(f2));
  11499. }
  11500. return function f2(h, d2) {
  11501. const _ = Math.round(d2);
  11502. if (_ === 0)
  11503. return o(h);
  11504. if (_ === 1)
  11505. return l2(h);
  11506. if (_ < 0)
  11507. return Number.NaN;
  11508. if (Math.abs(h) === 0)
  11509. return 0;
  11510. if (h === 1 / 0)
  11511. return 1 / 0;
  11512. let C = 0, E2;
  11513. const b = 2 / Math.abs(h);
  11514. let R = 0, p2 = 1, N2 = 0;
  11515. const M2 = 2 * Math.round((_ + Math.round(Math.sqrt(40 * _))) / 2);
  11516. for (E2 = M2; E2 > 0; E2--)
  11517. if (N2 = E2 * b * p2 + R, R = p2, p2 = N2, Math.abs(p2) > 1e10 && (p2 *= 1e-10, R *= 1e-10, C *= 1e-10), E2 === _ && (C = R), M2 - E2 > 100 && C === 0)
  11518. return Number.NaN;
  11519. return C *= f2(h, 0) / p2, h < 0 && _ % 2 ? -C : C;
  11520. };
  11521. })(), i.besselk = (() => {
  11522. const n = [74e-7, 1075e-7, 262698e-8, 0.0348859, 0.23069756, 0.4227842, -0.57721566], s = [53208e-8, -25154e-7, 587872e-8, -0.01062446, 0.02189568, -0.07832358, 1.25331414];
  11523. function o(f2) {
  11524. return f2 <= 2 ? -Math.log(f2 / 2) * (0, i.besseli)(f2, 0) + e(n, f2 * f2 / 4) : Math.exp(-f2) / Math.sqrt(f2) * e(s, 2 / f2);
  11525. }
  11526. const u = [-4686e-8, -110404e-8, -0.01919402, -0.18156897, -0.67278579, 0.15443144, 1], c = [-68245e-8, 325614e-8, -780353e-8, 0.01504268, -0.0365562, 0.23498619, 1.25331414];
  11527. function l2(f2) {
  11528. return f2 <= 2 ? Math.log(f2 / 2) * (0, i.besseli)(f2, 1) + 1 / f2 * e(u, f2 * f2 / 4) : Math.exp(-f2) / Math.sqrt(f2) * e(c, 2 / f2);
  11529. }
  11530. return r(o, l2, 2, 1);
  11531. })();
  11532. })(_r || (_r = {}));
  11533. function Ra2(i) {
  11534. return /^[01]{1,10}$/.test(i);
  11535. }
  11536. function pa(i) {
  11537. return /^[0-7]{1,10}$/.test(i);
  11538. }
  11539. function Va(i) {
  11540. return /^[0-9A-Fa-f]{1,10}$/.test(i);
  11541. }
  11542. function Zt(i) {
  11543. if (i === 0)
  11544. return 0;
  11545. const a2 = [
  11546. -1.3026537197817094,
  11547. 0.6419697923564902,
  11548. 0.019476473204185836,
  11549. -0.00956151478680863,
  11550. -946595344482036e-18,
  11551. 366839497852761e-18,
  11552. 42523324806907e-18,
  11553. -20278578112534e-18,
  11554. -1624290004647e-18,
  11555. 130365583558e-17,
  11556. 15626441722e-18,
  11557. -85238095915e-18,
  11558. 6529054439e-18,
  11559. 5059343495e-18,
  11560. -991364156e-18,
  11561. -227365122e-18,
  11562. 96467911e-18,
  11563. 2394038e-18,
  11564. -6886027e-18,
  11565. 894487e-18,
  11566. 313092e-18,
  11567. -112708e-18,
  11568. 381e-18,
  11569. 7106e-18,
  11570. -1523e-18,
  11571. -94e-18,
  11572. 121e-18,
  11573. -28e-18
  11574. ];
  11575. let e = i, t = false;
  11576. e < 0 && (e = -e, t = true);
  11577. const r = 2 / (2 + e), n = 4 * r - 2;
  11578. let s = 0, o = 0, u;
  11579. for (let l2 = a2.length - 1; l2 > 0; l2--)
  11580. u = s, s = n * s - o + a2[l2], o = u;
  11581. const c = r * Math.exp(-e * e + 0.5 * (a2[0] + n * s) - o);
  11582. return t ? c - 1 : 1 - c;
  11583. }
  11584. function Na(i) {
  11585. return 1 - Zt(i);
  11586. }
  11587. function Hh(i) {
  11588. if (i >= 2)
  11589. return -100;
  11590. if (i <= 0)
  11591. return 100;
  11592. const a2 = i < 1 ? i : 2 - i, e = Math.sqrt(-2 * Math.log(a2 / 2));
  11593. let t = -0.70711 * ((2.30753 + e * 0.27061) / (1 + e * (0.99229 + e * 0.04481)) - e);
  11594. for (let r = 0; r < 2; r++) {
  11595. const n = Na(t) - a2;
  11596. t += n / (1.1283791670955126 * Math.exp(-t * t) - t * n);
  11597. }
  11598. return i < 1 ? t : -t;
  11599. }
  11600. function cr(i, a2 = 1) {
  11601. let e = Math.floor(i);
  11602. if (i < 0)
  11603. return Number.NaN;
  11604. let t = 1;
  11605. for (; e > 1 && Number.isFinite(t); )
  11606. t *= e, e -= a2;
  11607. return t;
  11608. }
  11609. function zt(i, a2) {
  11610. const e = Math.min(i - a2, a2);
  11611. let t = 1;
  11612. for (let r = 1; r <= e && Number.isFinite(t); r++)
  11613. t *= i - r + 1, t /= r;
  11614. return t;
  11615. }
  11616. function qs(i, a2) {
  11617. let e = Math.floor(i), t = Math.floor(a2);
  11618. for (; t !== 0; ) {
  11619. const r = t;
  11620. t = e % t, e = r;
  11621. }
  11622. return e;
  11623. }
  11624. function Mi(i, a2) {
  11625. const e = qs(i, a2);
  11626. return e === 0 ? 0 : Math.abs(i * a2) / e;
  11627. }
  11628. function Gn(i) {
  11629. const a2 = i.length;
  11630. if (a2 === 1)
  11631. return i[0][0];
  11632. if (a2 === 2)
  11633. return i[0][0] * i[1][1] - i[0][1] * i[1][0];
  11634. let e = 0;
  11635. for (let t = 0; t < a2; t++)
  11636. e += (t % 2 === 0 ? 1 : -1) * i[0][t] * Gn(wo(i, 0, t));
  11637. return e;
  11638. }
  11639. function Gh(i) {
  11640. const a2 = Gn(i);
  11641. return a2 === 0 ? null : i.length === 1 ? [[1 / a2]] : Qh(i).map((r) => r.map((n) => n / a2));
  11642. }
  11643. function wo(i, a2, e) {
  11644. return i.filter((t, r) => r !== a2).map((t) => t.filter((r, n) => n !== e));
  11645. }
  11646. function Qh(i) {
  11647. const a2 = i.length, e = Array.from({ length: a2 }, () => new Array(a2).fill(0));
  11648. for (let t = 0; t < a2; t++)
  11649. for (let r = 0; r < a2; r++) {
  11650. const n = (t + r) % 2 === 0 ? 1 : -1;
  11651. e[r][t] = n * Gn(wo(i, t, r));
  11652. }
  11653. return e;
  11654. }
  11655. function lr(i, a2) {
  11656. return i.map((e) => a2[0].map(
  11657. (t, r) => e.reduce((n, s, o) => n + s * a2[o][r], 0)
  11658. ));
  11659. }
  11660. function mt(i) {
  11661. return i[0].map((a2, e) => i.map((t) => t[e]));
  11662. }
  11663. function Wh(i) {
  11664. const { smallPivotDetected: a2, luMatrix: e, permutation: t } = qh(i);
  11665. return a2 ? null : Kh(e, t);
  11666. }
  11667. function qh(i) {
  11668. const a2 = mt(i), e = a2.length, t = a2[0].length;
  11669. let r = true, n = false;
  11670. const s = Ks(e, t, 0), o = new Array(t).fill(0).map((u, c) => c);
  11671. for (let u = 0; u < t; u++) {
  11672. for (let h = 0; h < u; h++) {
  11673. let d2 = a2[h][u];
  11674. for (let _ = 0; _ < h; _++)
  11675. d2 -= s[h][_] * s[_][u];
  11676. s[h][u] = d2;
  11677. }
  11678. let c = -1 / 0, l2 = u;
  11679. for (let h = u; h < e; h++) {
  11680. let d2 = a2[h][u];
  11681. for (let C = 0; C < u; C++)
  11682. d2 -= s[h][C] * s[C][u];
  11683. s[h][u] = d2;
  11684. const _ = Math.abs(d2);
  11685. _ > c && (c = _, l2 = h);
  11686. }
  11687. if (Math.abs(s[l2][u]) < 1e-11) {
  11688. n = true;
  11689. break;
  11690. }
  11691. l2 !== u && ([s[u], s[l2]] = [s[l2], s[u]], [a2[u], a2[l2]] = [a2[l2], a2[u]], [o[u], o[l2]] = [o[l2], o[u]], r = !r);
  11692. const f2 = s[u][u];
  11693. for (let h = u + 1; h < e; h++)
  11694. s[h][u] /= f2;
  11695. }
  11696. return {
  11697. rowSwap: r,
  11698. smallPivotDetected: n,
  11699. luMatrix: s,
  11700. permutation: o
  11701. };
  11702. }
  11703. function Kh(i, a2) {
  11704. const e = a2.length, t = Ks(e, e, 0);
  11705. for (let n = 0; n < e; n++)
  11706. t[n][n] = 1;
  11707. const r = Ks(e, e, 0);
  11708. for (let n = 0; n < e; n++) {
  11709. const s = a2[n];
  11710. for (let o = 0; o < e; o++)
  11711. r[n][o] = t[s][o];
  11712. }
  11713. for (let n = 0; n < e; n++) {
  11714. const s = r[n];
  11715. for (let o = n + 1; o < e; o++) {
  11716. const u = i[o][n];
  11717. for (let c = 0; c < e; c++)
  11718. r[o][c] -= s[c] * u;
  11719. }
  11720. }
  11721. for (let n = e - 1; n >= 0; n--) {
  11722. const s = r[n], o = i[n][n];
  11723. for (let u = 0; u < e; u++)
  11724. s[u] /= o;
  11725. for (let u = 0; u < n; u++) {
  11726. const c = i[u][n];
  11727. for (let l2 = 0; l2 < e; l2++)
  11728. r[u][l2] -= s[l2] * c;
  11729. }
  11730. }
  11731. return r;
  11732. }
  11733. function Ks(i, a2, e) {
  11734. const t = [];
  11735. for (let r = 0; r < i; r++) {
  11736. t[r] = [];
  11737. for (let n = 0; n < a2; n++)
  11738. t[r].push(e);
  11739. }
  11740. return t;
  11741. }
  11742. function Xh(i) {
  11743. const a2 = Zh(i);
  11744. if (!a2)
  11745. return null;
  11746. const { matrixU: e, matrixS: t, matrixV: r } = a2, n = mt(e), s = Array.from({ length: t.length }, () => new Array(i[0].length).fill(0)), o = Math.max(i.length, i[0].length) * Number.EPSILON * t[0];
  11747. for (let u = 0; u < t.length; u++)
  11748. Math.abs(t[u]) > o && (s[u][u] = 1 / t[u]);
  11749. return lr(r, lr(s, n));
  11750. }
  11751. function Zh(i) {
  11752. const a2 = mt(i), e = a2.length, t = a2[0].length;
  11753. if (e < t)
  11754. return null;
  11755. const r = new Array(t).fill(0), n = new Array(t).fill(0), s = Array.from({ length: t }, () => new Array(t).fill(0));
  11756. let o = Number.EPSILON, u = 0, c = 0, l2 = 0;
  11757. for (let C = 0; C < t; C++) {
  11758. if (r[C] = u, c = ds(a2, C, e, C, C), c <= 1e-64 / o)
  11759. u = 0;
  11760. else {
  11761. u = Math.sqrt(c), a2[C][C] >= 0 && (u = -u);
  11762. const b = a2[C][C] * u - c;
  11763. a2[C][C] -= u;
  11764. for (let R = C + 1; R < t; R++) {
  11765. c = ds(a2, C, e, C, R);
  11766. for (let p2 = C; p2 < e; p2++)
  11767. a2[p2][R] += c / b * a2[p2][C];
  11768. }
  11769. }
  11770. if (n[C] = u, c = wi(a2, C + 1, t, C, C), c <= 1e-64 / o)
  11771. u = 0;
  11772. else {
  11773. u = Math.sqrt(c), a2[C][C + 1] >= 0 && (u = -u);
  11774. const b = a2[C][C + 1] * u - c;
  11775. a2[C][C + 1] -= u;
  11776. for (let R = C + 1; R < t; R++)
  11777. r[R] = a2[C][R] / b;
  11778. for (let R = C + 1; R < e; R++) {
  11779. c = wi(a2, C + 1, t, R, C);
  11780. for (let p2 = C + 1; p2 < t; p2++)
  11781. a2[R][p2] += c * r[p2];
  11782. }
  11783. }
  11784. const E2 = Math.abs(n[C]) + Math.abs(r[C]);
  11785. E2 > l2 && (l2 = E2);
  11786. }
  11787. let f2 = 0;
  11788. for (let C = t - 1; C >= 0; C--) {
  11789. if (u !== 0) {
  11790. for (let E2 = f2; E2 < t; E2++)
  11791. s[E2][C] = a2[C][E2] / (u * a2[C][C + 1]);
  11792. for (let E2 = f2; E2 < t; E2++) {
  11793. c = 0;
  11794. for (let b = f2; b < t; b++)
  11795. c += a2[C][b] * s[b][E2];
  11796. for (let b = f2; b < t; b++)
  11797. s[b][E2] += c * s[b][C];
  11798. }
  11799. }
  11800. for (let E2 = f2; E2 < t; E2++)
  11801. s[C][E2] = 0, s[E2][C] = 0;
  11802. s[C][C] = 1, u = r[C], f2 = C;
  11803. }
  11804. for (let C = t - 1; C >= 0; C--) {
  11805. u = n[C];
  11806. for (let E2 = C + 1; E2 < t; E2++)
  11807. a2[C][E2] = 0;
  11808. if (u !== 0) {
  11809. for (let E2 = C + 1; E2 < t; E2++) {
  11810. c = ds(a2, C + 1, e, C, E2);
  11811. for (let b = C; b < e; b++)
  11812. a2[b][E2] += c / (a2[C][C] * u) * a2[b][C];
  11813. }
  11814. for (let E2 = C; E2 < e; E2++)
  11815. a2[E2][C] /= u;
  11816. } else
  11817. for (let E2 = C; E2 < e; E2++)
  11818. a2[E2][C] = 0;
  11819. a2[C][C] += 1;
  11820. }
  11821. o *= l2;
  11822. let h = 0, d2 = 0, _ = 0;
  11823. for (let C = t - 1; C >= 0; C--)
  11824. for (let E2 = 0; E2 < 50; E2++) {
  11825. let b = false, R = C;
  11826. for (; R >= 0; R--) {
  11827. if (Math.abs(r[R]) <= o) {
  11828. b = true;
  11829. break;
  11830. }
  11831. if (Math.abs(n[R - 1]) <= o)
  11832. break;
  11833. }
  11834. if (!b) {
  11835. let w = 0, D2 = 1;
  11836. for (let S2 = R; S2 < C + 1 && (h = D2 * r[S2], d2 = n[S2], r[S2] *= w, !(Math.abs(h) <= o)); S2++) {
  11837. _ = Kr(h, d2), n[S2] = _, w = d2 / _, D2 = -h / _;
  11838. for (let P = 0; P < e; P++) {
  11839. const U2 = a2[P][R - 1], x2 = a2[P][S2];
  11840. a2[P][R - 1] = U2 * w + x2 * D2, a2[P][S2] = -U2 * D2 + x2 * w;
  11841. }
  11842. }
  11843. }
  11844. if (R === C) {
  11845. if (n[C] < 0) {
  11846. n[C] = -n[C];
  11847. for (let w = 0; w < t; w++)
  11848. s[w][C] = -s[w][C];
  11849. }
  11850. break;
  11851. }
  11852. if (E2 >= 49)
  11853. return null;
  11854. let p2 = n[R];
  11855. h = ((n[C - 1] - n[C]) * (n[C - 1] + n[C]) + (r[C - 1] - r[C]) * (r[C - 1] + r[C])) / (2 * r[C] * n[C - 1]), _ = Kr(h, 1), h < 0 ? h = ((p2 - n[C]) * (p2 + n[C]) + r[C] * (n[C - 1] / (h - _) - r[C])) / p2 : h = ((p2 - n[C]) * (p2 + n[C]) + r[C] * (n[C - 1] / (h + _) - r[C])) / p2;
  11856. let N2 = 1, M2 = 1;
  11857. for (let w = R + 1; w < C + 1; w++) {
  11858. let D2 = r[w], S2 = n[w];
  11859. d2 = M2 * D2, D2 *= N2, _ = Kr(h, d2), r[w - 1] = _, N2 = h / _, M2 = d2 / _, h = p2 * N2 + D2 * M2, d2 = S2 * M2, D2 = -p2 * M2 + D2 * N2, S2 *= N2;
  11860. for (let P = 0; P < t; P++) {
  11861. const U2 = s[P][w - 1], x2 = s[P][w];
  11862. s[P][w - 1] = U2 * N2 + x2 * M2, s[P][w] = -U2 * M2 + x2 * N2;
  11863. }
  11864. _ = Kr(h, d2), n[w - 1] = _, N2 = h / _, M2 = d2 / _, h = N2 * D2 + M2 * S2, p2 = -M2 * D2 + N2 * S2;
  11865. for (let P = 0; P < e; P++) {
  11866. const U2 = a2[P][w - 1], x2 = a2[P][w];
  11867. a2[P][w - 1] = U2 * N2 + x2 * M2, a2[P][w] = -U2 * M2 + x2 * N2;
  11868. }
  11869. }
  11870. r[R] = 0, r[C] = h, n[C] = p2;
  11871. }
  11872. for (let C = 0; C < n.length; C++)
  11873. n[C] < o && (n[C] = 0);
  11874. for (let C = 0; C < t; C++)
  11875. for (let E2 = C - 1; E2 >= 0; E2--)
  11876. if (n[E2] < n[C]) {
  11877. const b = n[E2];
  11878. n[E2] = n[C], n[C] = b;
  11879. for (let R = 0; R < a2.length; R++) {
  11880. const p2 = a2[R][C];
  11881. a2[R][C] = a2[R][E2], a2[R][E2] = p2;
  11882. }
  11883. for (let R = 0; R < s.length; R++) {
  11884. const p2 = s[R][C];
  11885. s[R][C] = s[R][E2], s[R][E2] = p2;
  11886. }
  11887. C = E2;
  11888. }
  11889. return {
  11890. matrixU: a2,
  11891. matrixS: n,
  11892. matrixV: s
  11893. };
  11894. }
  11895. function Kr(i, a2) {
  11896. let e = 0;
  11897. return Math.abs(i) > Math.abs(a2) ? (e = a2 / i, Math.abs(i) * Math.sqrt(1 + e * e)) : a2 !== 0 ? (e = i / a2, Math.abs(a2) * Math.sqrt(1 + e * e)) : 0;
  11898. }
  11899. function ds(i, a2, e, t, r) {
  11900. let n = 0;
  11901. for (let s = a2; s < e; s++)
  11902. n += i[s][t] * i[s][r];
  11903. return n;
  11904. }
  11905. function wi(i, a2, e, t, r) {
  11906. let n = 0;
  11907. for (let s = a2; s < e; s++)
  11908. n += i[t][s] * i[r][s];
  11909. return n;
  11910. }
  11911. var Xr = /* @__PURE__ */ new Map([
  11912. ["I", 1],
  11913. ["V", 5],
  11914. ["X", 10],
  11915. ["L", 50],
  11916. ["C", 100],
  11917. ["D", 500],
  11918. ["M", 1e3]
  11919. ]);
  11920. var zh = /* @__PURE__ */ new Map([
  11921. [1, "I"],
  11922. [4, "IV"],
  11923. [5, "V"],
  11924. [9, "IX"],
  11925. [10, "X"],
  11926. [40, "XL"],
  11927. [45, "VL"],
  11928. [49, "IL"],
  11929. [50, "L"],
  11930. [90, "XC"],
  11931. [95, "VC"],
  11932. [99, "IC"],
  11933. [100, "C"],
  11934. [400, "CD"],
  11935. [450, "LD"],
  11936. [490, "XD"],
  11937. [495, "VD"],
  11938. [499, "ID"],
  11939. [500, "D"],
  11940. [900, "CM"],
  11941. [950, "LM"],
  11942. [990, "XM"],
  11943. [995, "VM"],
  11944. [999, "IM"],
  11945. [1e3, "M"]
  11946. ]);
  11947. var Jh = [
  11948. [1, 4, 5, 9, 10, 40, 50, 90, 100, 400, 500, 900, 1e3, 4e3],
  11949. [1, 4, 5, 9, 10, 40, 45, 50, 90, 95, 100, 400, 450, 500, 900, 950, 1e3, 4e3],
  11950. [1, 4, 5, 9, 10, 40, 45, 49, 50, 90, 95, 99, 100, 400, 450, 490, 500, 900, 950, 990, 1e3, 4e3],
  11951. [1, 4, 5, 9, 10, 40, 45, 49, 50, 90, 95, 99, 100, 400, 450, 490, 495, 500, 900, 950, 990, 995, 1e3, 4e3],
  11952. [1, 4, 5, 9, 10, 40, 45, 49, 50, 90, 95, 99, 100, 400, 450, 490, 495, 499, 500, 900, 950, 990, 995, 999, 1e3, 4e3]
  11953. ];
  11954. function Do(i, a2, e) {
  11955. return i <= 0 ? 0 : i >= 1 ? 1 : Qn(i, a2, e);
  11956. }
  11957. function em(i, a2, e) {
  11958. return i <= 0 || i >= 1 ? 0 : a2 === 1 && e === 1 ? 1 : a2 < 512 && e < 512 ? i ** (a2 - 1) * (1 - i) ** (e - 1) / Ma(a2, e) : Math.exp((a2 - 1) * Math.log(i) + (e - 1) * Math.log(1 - i) - wa(a2, e));
  11959. }
  11960. function Oa(i, a2, e) {
  11961. if (i <= 0)
  11962. return 0;
  11963. if (i >= 1)
  11964. return 1;
  11965. const t = 1e-8;
  11966. let r;
  11967. if (a2 >= 1 && e >= 1) {
  11968. const c = i < 0.5 ? i : 1 - i, l2 = Math.sqrt(-2 * Math.log(c));
  11969. r = (2.30753 + l2 * 0.27061) / (1 + l2 * (0.99229 + l2 * 0.04481)) - l2, i < 0.5 && (r = -r);
  11970. const f2 = (r * r - 3) / 6, h = 2 / (1 / (2 * a2 - 1) + 1 / (2 * e - 1)), d2 = r * Math.sqrt(f2 + h) / h - (1 / (2 * e - 1) - 1 / (2 * a2 - 1)) * (f2 + 5 / 6 - 2 / (3 * h));
  11971. r = a2 / (a2 + e * Math.exp(2 * d2));
  11972. } else {
  11973. const c = Math.exp(a2 * Math.log(a2 / (a2 + e))) / a2, l2 = Math.exp(e * Math.log(e / (a2 + e))) / e, f2 = c + l2;
  11974. i < c / f2 ? r = (a2 * f2 * i) ** (1 / a2) : r = 1 - (e * f2 * (1 - i)) ** (1 / e);
  11975. }
  11976. const n = -wa(a2, e);
  11977. let s, o, u;
  11978. for (let c = 0; c < 10; c++) {
  11979. if (r === 0 || r === 1)
  11980. return r;
  11981. if (s = Qn(r, a2, e) - i, o = Math.exp((a2 - 1) * Math.log(r) + (e - 1) * Math.log(1 - r) + n), u = s / o, r -= o = u / (1 - 0.5 * Math.min(1, u * ((a2 - 1) / r - (e - 1) / (1 - r)))), r <= 0 && (r = 0.5 * (r + o)), r >= 1 && (r = 0.5 * (r + o + 1)), Math.abs(o) < t * r && c > 0)
  11982. break;
  11983. }
  11984. return r;
  11985. }
  11986. function Qn(i, a2, e) {
  11987. const t = i === 0 || i === 1 ? 0 : Math.exp(ct(a2 + e) - ct(a2) - ct(e) + a2 * Math.log(i) + e * Math.log(1 - i));
  11988. return i < (a2 + 1) / (a2 + e + 2) ? t * Di(i, a2, e) / a2 : 1 - t * Di(1 - i, e, a2) / e;
  11989. }
  11990. function Di(i, a2, e) {
  11991. let n = 1 - (a2 + e) * i / (a2 + 1);
  11992. Math.abs(n) < 1e-8 && (n = 1e-8), n = 1 / n;
  11993. let s = 1, o = n;
  11994. for (let u = 1; u <= 100; u++) {
  11995. let c = u * (e - u) * i / ((a2 - 1 + u * 2) * (a2 + u * 2));
  11996. if (n = 1 + c * n, Math.abs(n) < 1e-8 && (n = 1e-8), s = 1 + c / s, Math.abs(s) < 1e-8 && (s = 1e-8), n = 1 / n, o *= n * s, c = -(a2 + u) * (a2 + e + u) * i / ((a2 + u * 2) * (a2 + 1 + u * 2)), n = 1 + c * n, Math.abs(n) < 1e-8 && (n = 1e-8), s = 1 + c / s, Math.abs(s) < 1e-8 && (s = 1e-8), n = 1 / n, o *= n * s, Math.abs(n * s - 1) < 1e-8)
  11997. break;
  11998. }
  11999. return o;
  12000. }
  12001. function Ma(i, a2) {
  12002. return i + a2 > 170 ? Math.exp(wa(i, a2)) : on(i) * on(a2) / on(i + a2);
  12003. }
  12004. function wa(i, a2) {
  12005. return ct(i) + ct(a2) - ct(i + a2);
  12006. }
  12007. function So(i, a2, e) {
  12008. if (i < 0)
  12009. return 0;
  12010. if (i >= a2)
  12011. return 1;
  12012. if (e < 0 || e > 1 || a2 <= 0)
  12013. return Number.NaN;
  12014. let t = 0;
  12015. for (let r = 0; r <= i; r++)
  12016. t += Da(r, a2, e);
  12017. return t;
  12018. }
  12019. function Da(i, a2, e) {
  12020. return e === 0 || e === 1 ? a2 * e === i ? 1 : 0 : zt(a2, i) * e ** i * (1 - e) ** (a2 - i);
  12021. }
  12022. function Sa(i, a2) {
  12023. return i <= 0 ? 0 : La(a2 / 2, i / 2);
  12024. }
  12025. function tm(i, a2) {
  12026. return i < 0 ? 0 : i === 0 && a2 === 2 ? 0.5 : Math.exp((a2 / 2 - 1) * Math.log(i) - i / 2 - a2 / 2 * Math.log(2) - ct(a2 / 2));
  12027. }
  12028. function Po(i, a2) {
  12029. return i <= 0 ? 0 : i >= 1 ? 1 / 0 : 2 * jo(i, a2 / 2);
  12030. }
  12031. function Pa(i, a2, e) {
  12032. return i < 0 ? 0 : Qn(a2 * i / (a2 * i + e), a2 / 2, e / 2);
  12033. }
  12034. function rm(i, a2, e) {
  12035. if (i < 0)
  12036. return 0;
  12037. if (i === 0 && a2 < 2)
  12038. return 1 / 0;
  12039. if (i === 0 && a2 === 2)
  12040. return 1;
  12041. let t = 1 / Ma(a2 / 2, e / 2);
  12042. return t *= (a2 / e) ** (a2 / 2), t *= i ** (a2 / 2 - 1), t *= (1 + a2 / e * i) ** (-(a2 + e) / 2), t;
  12043. }
  12044. function Lo(i, a2, e) {
  12045. return i <= 0 ? 0 : i >= 1 ? 1 / 0 : e / (a2 * (1 / Oa(i, a2 / 2, e / 2) - 1));
  12046. }
  12047. function nm(i, a2) {
  12048. return i < 0 ? 0 : 1 - Math.exp(-a2 * i);
  12049. }
  12050. function sm(i, a2) {
  12051. return i < 0 ? 0 : a2 * Math.exp(-a2 * i);
  12052. }
  12053. function xo(i, a2, e) {
  12054. const t = a2.length;
  12055. let r = 0, n = 0;
  12056. for (let h = 0; h < t; h++)
  12057. r += a2[h], n += e[h];
  12058. const s = r / t, o = n / t;
  12059. let u = 0, c = 0;
  12060. for (let h = 0; h < t; h++)
  12061. u += (a2[h] - s) * (e[h] - o), c += (e[h] - o) ** 2;
  12062. if (c === 0)
  12063. return 1 / 0;
  12064. const l2 = u / c;
  12065. return s - l2 * o + l2 * i;
  12066. }
  12067. function on(i) {
  12068. const a2 = [
  12069. -1.716185138865495,
  12070. 24.76565080557592,
  12071. -379.80425647094563,
  12072. 629.3311553128184,
  12073. 866.9662027904133,
  12074. -31451.272968848367,
  12075. -36144.413418691176,
  12076. 66456.14382024054
  12077. ], e = [
  12078. -30.8402300119739,
  12079. 315.35062697960416,
  12080. -1015.1563674902192,
  12081. -3107.771671572311,
  12082. 22538.11842098015,
  12083. 4755.846277527881,
  12084. // eslint-disable-line
  12085. -134659.9598649693,
  12086. -115132.2596755535
  12087. ];
  12088. let t = 0, r = i;
  12089. if (i > 171.6243769536076)
  12090. return 1 / 0;
  12091. if (r <= 0) {
  12092. const f2 = r % 1 + 36e-17;
  12093. if (f2)
  12094. t = (r & 1 ? -1 : 1) * Math.PI / Math.sin(Math.PI * f2), r = 1 - r;
  12095. else
  12096. return 1 / 0;
  12097. }
  12098. const n = r;
  12099. let s = 0, o;
  12100. r < 1 ? o = r++ : o = (r -= s = (r | 0) - 1) - 1;
  12101. let u = 0, c = 0;
  12102. for (let f2 = 0; f2 < 8; ++f2)
  12103. u = (u + a2[f2]) * o, c = c * o + e[f2];
  12104. let l2 = u / c + 1;
  12105. if (n < r)
  12106. l2 /= n;
  12107. else if (n > r)
  12108. for (let f2 = 0; f2 < s; ++f2)
  12109. l2 *= r, r++;
  12110. return t && (l2 = t / l2), l2;
  12111. }
  12112. function am(i, a2, e) {
  12113. return i <= 0 ? 0 : La(a2, i / e);
  12114. }
  12115. function im(i, a2, e) {
  12116. return i < 0 ? 0 : i === 0 && a2 === 1 ? 1 / e : Math.exp((a2 - 1) * Math.log(i) - i / e - ct(a2) - a2 * Math.log(e));
  12117. }
  12118. function om(i, a2, e) {
  12119. return i <= 0 ? 0 : i >= 1 ? 1 / 0 : e * jo(i, a2);
  12120. }
  12121. function ct(i) {
  12122. const a2 = [
  12123. 76.18009172947146,
  12124. -86.50532032941678,
  12125. 24.01409824083091,
  12126. // eslint-disable-line
  12127. -1.231739572450155,
  12128. 0.001208650973866179,
  12129. -5395239384953e-18
  12130. ];
  12131. let e = i, t = i + 5.5;
  12132. t -= (i + 0.5) * Math.log(t);
  12133. let r = 1.000000000190015;
  12134. for (let n = 0; n < 6; n++)
  12135. r += a2[n] / ++e;
  12136. return -t + Math.log(2.5066282746310007 * r / i);
  12137. }
  12138. function La(i, a2) {
  12139. if (a2 < 0 || i <= 0)
  12140. return Number.NaN;
  12141. const e = 1e-30, t = -~(Math.log(i >= 1 ? i : 1 / i) * 8.5 + i * 0.4 + 17), r = ct(i), n = Math.exp(-a2 + i * Math.log(a2) - r);
  12142. let s = i, o = 1 / i, u = o;
  12143. if (a2 < i + 1) {
  12144. if (n === 0)
  12145. return 0;
  12146. for (let d2 = 1; d2 <= t && (o += u *= a2 / ++s, !(Math.abs(u) < Math.abs(o) * e)); d2++)
  12147. ;
  12148. return o * n;
  12149. }
  12150. if (n === 0)
  12151. return 1;
  12152. let c = a2 + 1 - i, l2 = 1 / e, f2 = 1 / c, h = f2;
  12153. for (let d2 = 1; d2 <= t; d2++) {
  12154. const _ = -d2 * (d2 - i);
  12155. if (c += 2, f2 = _ * f2 + c, Math.abs(f2) < e && (f2 = e), l2 = c + _ / l2, Math.abs(l2) < e && (l2 = e), f2 = 1 / f2, h *= f2 * l2, Math.abs(f2 * l2 - 1) < e)
  12156. break;
  12157. }
  12158. return 1 - h * n;
  12159. }
  12160. function jo(i, a2) {
  12161. if (i <= 0)
  12162. return 0;
  12163. if (i >= 1)
  12164. return Math.max(100, a2 + 100 * Math.sqrt(a2));
  12165. let e;
  12166. if (a2 > 1) {
  12167. const o = i < 0.5 ? i : 1 - i, u = Math.sqrt(-2 * Math.log(o));
  12168. e = (2.30753 + u * 0.27061) / (1 + u * (0.99229 + u * 0.04481)) - u, i < 0.5 && (e = -e), e = Math.max(1e-3, a2 * (1 - 1 / (9 * a2) - e / (3 * Math.sqrt(a2))) ** 3);
  12169. } else {
  12170. const o = 1 - a2 * (0.253 + a2 * 0.12);
  12171. i < o ? e = (i / o) ** (1 / a2) : e = 1 - Math.log(1 - (i - o) / (1 - o));
  12172. }
  12173. const t = 1e-8, r = ct(a2);
  12174. let n, s;
  12175. for (let o = 0; o < 12; o++) {
  12176. if (e <= 0)
  12177. return 0;
  12178. if (n = La(a2, e) - i, a2 > 1 ? s = Math.exp((a2 - 1) * (Math.log(a2 - 1) - 1) - r) * Math.exp(-(e - (a2 - 1)) + (a2 - 1) * (Math.log(e) - Math.log(a2 - 1))) : s = Math.exp(-e + (a2 - 1) * Math.log(e) - r), s !== 0 && (s = n / s / (1 - 0.5 * Math.min(1, n / s * ((a2 - 1) / e - 1)))), e -= s, e <= 0 && (e = 0.5 * (e + s)), Math.abs(s) < t * e)
  12179. break;
  12180. }
  12181. return e;
  12182. }
  12183. function um(i, a2, e, t) {
  12184. let r = 0;
  12185. for (let n = 0; n <= i; n++)
  12186. r += xa(n, a2, e, t);
  12187. return r;
  12188. }
  12189. function xa(i, a2, e, t) {
  12190. return a2 - i > t - e ? 0 : zt(e, i) * zt(t - e, a2 - i) / zt(t, a2);
  12191. }
  12192. function Uo(i, a2, e) {
  12193. return i < 0 ? 0 : 0.5 + 0.5 * Zt((Math.log(i) - a2) / Math.sqrt(2 * e * e));
  12194. }
  12195. function cm(i, a2, e) {
  12196. return i <= 0 ? 0 : Math.exp(-Math.log(i) - 0.5 * Math.log(2 * Math.PI) - Math.log(e) - (Math.log(i) - a2) ** 2 / (2 * e * e));
  12197. }
  12198. function lm(i, a2, e) {
  12199. return Math.exp(Wn(i, a2, e));
  12200. }
  12201. function fm(i, a2, e) {
  12202. if (i < 0)
  12203. return 0;
  12204. let t = 0;
  12205. for (let r = 0; r <= i; r++)
  12206. t += ja(r, a2, e);
  12207. return t;
  12208. }
  12209. function ja(i, a2, e) {
  12210. return i < 0 ? 0 : zt(i + a2 - 1, a2 - 1) * e ** a2 * (1 - e) ** i;
  12211. }
  12212. function kr(i, a2, e) {
  12213. return 0.5 * (1 + Zt((i - a2) / Math.sqrt(2 * e * e)));
  12214. }
  12215. function vo(i, a2, e) {
  12216. return Math.exp(-0.5 * Math.log(2 * Math.PI) - Math.log(e) - (i - a2) ** 2 / (2 * e * e));
  12217. }
  12218. function Wn(i, a2, e) {
  12219. return -1.4142135623730951 * e * Hh(2 * i) + a2;
  12220. }
  12221. function hm(i, a2) {
  12222. let e = 0;
  12223. for (let t = 0; t <= i; t++)
  12224. e += To(t, a2);
  12225. return e;
  12226. }
  12227. function To(i, a2) {
  12228. return Math.exp(-a2) * a2 ** i / cr(i);
  12229. }
  12230. function $r(i, a2) {
  12231. const e = 0.5 * Qn(a2 / (i ** 2 + a2), a2 / 2, 0.5);
  12232. return i < 0 ? e : 1 - e;
  12233. }
  12234. function mm(i, a2) {
  12235. const e = (1 + i ** 2 / a2) ** (-(a2 + 1) / 2);
  12236. return 1 / (Math.sqrt(a2) * Ma(0.5, a2 / 2)) * e;
  12237. }
  12238. function qn(i, a2) {
  12239. let e = Oa(2 * Math.min(i, 1 - i), 0.5 * a2, 0.5);
  12240. return e = Math.sqrt(a2 * (1 - e) / e), i > 0.5 ? e : -e;
  12241. }
  12242. function Je(i, a2, e, t, r) {
  12243. const n = [], s = [];
  12244. let o = true;
  12245. for (let u = 0; u < e; u++) {
  12246. const c = Math.floor(u / t), l2 = u % t, f2 = Math.floor(u / r), h = u % r, d2 = i.isArray() ? i.get(c, l2) : i, _ = a2.isArray() ? a2.get(f2, h) : a2;
  12247. if (d2.isError())
  12248. return {
  12249. isError: true,
  12250. errorObject: d2,
  12251. array1Values: n,
  12252. array2Values: s,
  12253. noCalculate: o
  12254. };
  12255. if (_.isError())
  12256. return {
  12257. isError: true,
  12258. errorObject: _,
  12259. array1Values: n,
  12260. array2Values: s,
  12261. noCalculate: o
  12262. };
  12263. if (d2.isNull() || _.isNull() || d2.isBoolean() || _.isBoolean())
  12264. continue;
  12265. const C = d2.getValue(), E2 = _.getValue();
  12266. !DC(C) || !DC(E2) || (n.push(+C), s.push(+E2), o = false);
  12267. }
  12268. return {
  12269. isError: false,
  12270. errorObject: null,
  12271. array1Values: n,
  12272. array2Values: s,
  12273. noCalculate: o
  12274. };
  12275. }
  12276. function Kn(i, a2, e) {
  12277. const t = i.isArray() ? i.getRowCount() : 1, r = i.isArray() ? i.getColumnCount() : 1;
  12278. let n = t, s = r;
  12279. if (a2 && !a2.isNull() && (n = a2.isArray() ? a2.getRowCount() : 1, s = a2.isArray() ? a2.getColumnCount() : 1, t === 1 && s !== r || r === 1 && n !== t || t !== 1 && r !== 1 && (n !== t || s !== r)))
  12280. return {
  12281. isError: true,
  12282. errorObject: g2.create(m2.REF)
  12283. };
  12284. if (e && !e.isNull()) {
  12285. const o = e.isArray() ? e.getRowCount() : 1, u = e.isArray() ? e.getColumnCount() : 1;
  12286. if (t === 1 && n > 1 && o !== n || r === 1 && s > 1 && u !== s)
  12287. return {
  12288. isError: true,
  12289. errorObject: g2.create(m2.REF)
  12290. };
  12291. }
  12292. return {
  12293. isError: false,
  12294. errorObject: null
  12295. };
  12296. }
  12297. function dt(i) {
  12298. const a2 = i.isArray() ? i.getRowCount() : 1, e = i.isArray() ? i.getColumnCount() : 1, t = [];
  12299. for (let r = 0; r < a2; r++) {
  12300. t[r] = [];
  12301. for (let n = 0; n < e; n++) {
  12302. const s = i.isArray() ? i.get(r, n) : i;
  12303. if (s.isError() || s.isNull() || s.isBoolean() || s.isString())
  12304. return g2.create(m2.VALUE);
  12305. t[r].push(+s.getValue());
  12306. }
  12307. }
  12308. return t;
  12309. }
  12310. function Xn(i, a2) {
  12311. const e = [];
  12312. let t = 1;
  12313. for (let r = 0; r < i; r++) {
  12314. e[r] = [];
  12315. for (let n = 0; n < a2; n++)
  12316. e[r].push(t++);
  12317. }
  12318. return e;
  12319. }
  12320. function Zn(i, a2, e, t) {
  12321. let r = a2;
  12322. t && (r = a2.map((o) => Math.log(o)));
  12323. let n, s;
  12324. return e ? { slope: n, intercept: s } = gm(i, r) : { slope: n, intercept: s } = dm(i, r), t && (n = Math.exp(n), s = Math.exp(s)), Number.isNaN(n) && !e && (n = 0), { slope: n, intercept: s, Y: r };
  12325. }
  12326. function gm(i, a2) {
  12327. const e = a2.length;
  12328. let t = 0, r = 0, n = 0, s = 0;
  12329. for (let l2 = 0; l2 < e; l2++)
  12330. t += i[l2], r += a2[l2], n += i[l2] * i[l2], s += i[l2] * a2[l2];
  12331. const u = (e * s - t * r) / (e * n - t * t), c = 1 / e * r - u * (1 / e) * t;
  12332. return {
  12333. slope: u,
  12334. intercept: c
  12335. };
  12336. }
  12337. function dm(i, a2) {
  12338. const e = [[...i]], t = [...a2];
  12339. let r = e.length, n = e[0].length, s = Math.min(r, n);
  12340. const o = new Array(s).fill(0);
  12341. for (let c = 0; c < s; c++) {
  12342. const l2 = e[c];
  12343. let f2 = 0;
  12344. for (let d2 = 0; d2 < n; d2++)
  12345. f2 += l2[d2] ** 2;
  12346. const h = l2[c] < 0 ? Math.sqrt(f2) : -Math.sqrt(f2);
  12347. if (o[c] = h, h !== 0) {
  12348. l2[c] -= h;
  12349. for (let d2 = c + 1; d2 < r; d2++) {
  12350. let _ = 0;
  12351. for (let C = c; C < n; C++)
  12352. _ -= e[d2][C] * l2[C];
  12353. _ /= h * l2[c];
  12354. for (let C = c; C < n; C++)
  12355. e[d2][C] -= _ * l2[C];
  12356. }
  12357. }
  12358. }
  12359. r = e.length, n = e[0].length, s = Math.min(r, n);
  12360. const u = new Array(r).fill(0);
  12361. for (let c = 0; c < s; c++) {
  12362. const l2 = e[c];
  12363. let f2 = 0;
  12364. for (let h = 0; h < n; h++)
  12365. f2 += t[h] * l2[h];
  12366. f2 /= o[c] * l2[c];
  12367. for (let h = 0; h < n; h++)
  12368. t[h] += f2 * l2[h];
  12369. }
  12370. for (let c = o.length - 1; c >= 0; c--) {
  12371. t[c] /= o[c];
  12372. const l2 = t[c], f2 = e[c];
  12373. u[c] = l2;
  12374. for (let h = 0; h < c; h++)
  12375. t[h] -= l2 * f2[h];
  12376. }
  12377. return {
  12378. slope: u[0],
  12379. intercept: 0
  12380. };
  12381. }
  12382. function zn(i, a2, e, t, r) {
  12383. const n = i.length === 1 && i[0].length > 1;
  12384. let s = i;
  12385. r && (s = i.map((C) => C.map((E2) => Math.log(E2))));
  12386. let o = a2, u = e;
  12387. n && (s = mt(s), o = mt(o), u = mt(u)), t && (o = o.map((C) => [...C, 1]));
  12388. const c = mt(o), l2 = lr(c, o), f2 = lr(c, s);
  12389. let h = Wh(l2);
  12390. if (!h && (h = Xh(l2), !h))
  12391. return g2.create(m2.NA);
  12392. let d2 = lr(h, f2);
  12393. t || d2.push([0]), d2 = mt(d2);
  12394. const _ = d2[0].pop();
  12395. if (d2[0].reverse(), d2[0].push(_), r)
  12396. for (let C = 0; C < d2[0].length; C++)
  12397. d2[0][C] = Math.exp(d2[0][C]);
  12398. return {
  12399. coefficients: d2,
  12400. Y: s,
  12401. X: o,
  12402. newX: u,
  12403. XTXInverse: h
  12404. };
  12405. }
  12406. var Bo = class extends V {
  12407. constructor() {
  12408. super(...arguments);
  12409. A(this, "minParams", 3);
  12410. A(this, "maxParams", 5);
  12411. }
  12412. calculate(e, t, r, n, s) {
  12413. let o = n != null ? n : y2.create(0), u = s != null ? s : y2.create(1);
  12414. o.isNull() && (o = y2.create(0)), u.isNull() && (u = y2.create(1));
  12415. const c = Math.max(
  12416. e.isArray() ? e.getRowCount() : 1,
  12417. t.isArray() ? t.getRowCount() : 1,
  12418. r.isArray() ? r.getRowCount() : 1,
  12419. o.isArray() ? o.getRowCount() : 1,
  12420. u.isArray() ? u.getRowCount() : 1
  12421. ), l2 = Math.max(
  12422. e.isArray() ? e.getColumnCount() : 1,
  12423. t.isArray() ? t.getColumnCount() : 1,
  12424. r.isArray() ? r.getColumnCount() : 1,
  12425. o.isArray() ? o.getColumnCount() : 1,
  12426. u.isArray() ? u.getColumnCount() : 1
  12427. ), f2 = O(c, l2, e, g2.create(m2.NA)), h = O(c, l2, t, g2.create(m2.NA)), d2 = O(c, l2, r, g2.create(m2.NA)), _ = O(c, l2, o, g2.create(m2.NA)), C = O(c, l2, u, g2.create(m2.NA)), E2 = f2.mapValue((b, R, p2) => {
  12428. const N2 = h.get(R, p2), M2 = d2.get(R, p2), w = _.get(R, p2), D2 = C.get(R, p2);
  12429. return this._handleSignleObject(b, N2, M2, w, D2);
  12430. });
  12431. return c === 1 && l2 === 1 ? E2.get(0, 0) : E2;
  12432. }
  12433. _handleSignleObject(e, t, r, n, s) {
  12434. if (e.isError())
  12435. return e;
  12436. if (t.isError())
  12437. return t;
  12438. if (r.isError())
  12439. return r;
  12440. if (n.isError())
  12441. return n;
  12442. if (s.isError())
  12443. return s;
  12444. const { isError: o, errorObject: u, variants: c } = I2(e, t, r, n, s);
  12445. if (o)
  12446. return u;
  12447. const [l2, f2, h, d2, _] = c, C = +l2.getValue(), E2 = +f2.getValue(), b = +h.getValue(), R = +d2.getValue(), p2 = +_.getValue();
  12448. if (E2 <= 0 || b <= 0 || C <= 0 || C >= 1 || R >= p2)
  12449. return g2.create(m2.NUM);
  12450. const N2 = Oa(C, E2, b) * (p2 - R) + R;
  12451. return y2.create(N2);
  12452. }
  12453. };
  12454. var Io = class extends V {
  12455. constructor() {
  12456. super(...arguments);
  12457. A(this, "minParams", 4);
  12458. A(this, "maxParams", 4);
  12459. }
  12460. calculate(e, t, r, n) {
  12461. const s = Math.max(
  12462. e.isArray() ? e.getRowCount() : 1,
  12463. t.isArray() ? t.getRowCount() : 1,
  12464. r.isArray() ? r.getRowCount() : 1,
  12465. n.isArray() ? n.getRowCount() : 1
  12466. ), o = Math.max(
  12467. e.isArray() ? e.getColumnCount() : 1,
  12468. t.isArray() ? t.getColumnCount() : 1,
  12469. r.isArray() ? r.getColumnCount() : 1,
  12470. n.isArray() ? n.getColumnCount() : 1
  12471. ), u = O(s, o, e, g2.create(m2.NA)), c = O(s, o, t, g2.create(m2.NA)), l2 = O(s, o, r, g2.create(m2.NA)), f2 = O(s, o, n, g2.create(m2.NA)), h = u.mapValue((d2, _, C) => {
  12472. const E2 = c.get(_, C), b = l2.get(_, C), R = f2.get(_, C);
  12473. return d2.isError() ? d2 : E2.isError() ? E2 : b.isError() ? b : R.isError() ? R : this._handleSignleObject(d2, E2, b, R);
  12474. });
  12475. return s === 1 && o === 1 ? h.get(0, 0) : h;
  12476. }
  12477. _handleSignleObject(e, t, r, n) {
  12478. const { isError: s, errorObject: o, variants: u } = I2(e, t, r, n);
  12479. if (s)
  12480. return o;
  12481. const [c, l2, f2, h] = u, d2 = Math.floor(+c.getValue()), _ = Math.floor(+l2.getValue()), C = +f2.getValue(), E2 = +h.getValue();
  12482. if (d2 < 0 || d2 > _ || C < 0 || C > 1)
  12483. return g2.create(m2.NUM);
  12484. let b;
  12485. return E2 ? b = So(d2, _, C) : b = Da(d2, _, C), y2.create(b);
  12486. }
  12487. };
  12488. var Fo = class extends V {
  12489. constructor() {
  12490. super(...arguments);
  12491. A(this, "minParams", 3);
  12492. A(this, "maxParams", 3);
  12493. }
  12494. calculate(e, t, r) {
  12495. const n = Math.max(
  12496. e.isArray() ? e.getRowCount() : 1,
  12497. t.isArray() ? t.getRowCount() : 1,
  12498. r.isArray() ? r.getRowCount() : 1
  12499. ), s = Math.max(
  12500. e.isArray() ? e.getColumnCount() : 1,
  12501. t.isArray() ? t.getColumnCount() : 1,
  12502. r.isArray() ? r.getColumnCount() : 1
  12503. ), o = O(n, s, e, g2.create(m2.NA)), u = O(n, s, t, g2.create(m2.NA)), c = O(n, s, r, g2.create(m2.NA)), l2 = o.mapValue((f2, h, d2) => {
  12504. const _ = u.get(h, d2), C = c.get(h, d2);
  12505. return f2.isError() ? f2 : _.isError() ? _ : C.isError() ? C : this._handleSignleObject(f2, _, C);
  12506. });
  12507. return n === 1 && s === 1 ? l2.get(0, 0) : l2;
  12508. }
  12509. _handleSignleObject(e, t, r) {
  12510. const { isError: n, errorObject: s, variants: o } = I2(e, t, r);
  12511. if (n)
  12512. return s;
  12513. const [u, c, l2] = o, f2 = Math.floor(+u.getValue()), h = +c.getValue(), d2 = +l2.getValue();
  12514. if (f2 < 0 || h <= 0 || h >= 1 || d2 <= 0 || d2 >= 1)
  12515. return g2.create(m2.NUM);
  12516. let _ = 0;
  12517. for (; _ <= f2 && !(So(_, f2, h) >= d2); )
  12518. _++;
  12519. return y2.create(_);
  12520. }
  12521. };
  12522. var ko = class extends V {
  12523. constructor() {
  12524. super(...arguments);
  12525. A(this, "minParams", 2);
  12526. A(this, "maxParams", 2);
  12527. }
  12528. calculate(e, t) {
  12529. const r = Math.max(
  12530. e.isArray() ? e.getRowCount() : 1,
  12531. t.isArray() ? t.getRowCount() : 1
  12532. ), n = Math.max(
  12533. e.isArray() ? e.getColumnCount() : 1,
  12534. t.isArray() ? t.getColumnCount() : 1
  12535. ), s = O(r, n, e, g2.create(m2.NA)), o = O(r, n, t, g2.create(m2.NA)), u = s.mapValue((c, l2, f2) => {
  12536. const h = o.get(l2, f2);
  12537. return c.isError() ? c : h.isError() ? h : this._handleSignleObject(c, h);
  12538. });
  12539. return r === 1 && n === 1 ? u.get(0, 0) : u;
  12540. }
  12541. _handleSignleObject(e, t) {
  12542. const { isError: r, errorObject: n, variants: s } = I2(e, t);
  12543. if (r)
  12544. return n;
  12545. const [o, u] = s, c = +o.getValue(), l2 = Math.floor(+u.getValue());
  12546. if (c < 0 || l2 < 1 || l2 > 10 ** 10)
  12547. return g2.create(m2.NUM);
  12548. const f2 = 1 - Sa(c, l2);
  12549. return y2.create(f2);
  12550. }
  12551. };
  12552. var $o = class extends V {
  12553. constructor() {
  12554. super(...arguments);
  12555. A(this, "minParams", 2);
  12556. A(this, "maxParams", 2);
  12557. }
  12558. calculate(e, t) {
  12559. const r = Math.max(
  12560. e.isArray() ? e.getRowCount() : 1,
  12561. t.isArray() ? t.getRowCount() : 1
  12562. ), n = Math.max(
  12563. e.isArray() ? e.getColumnCount() : 1,
  12564. t.isArray() ? t.getColumnCount() : 1
  12565. ), s = O(r, n, e, g2.create(m2.NA)), o = O(r, n, t, g2.create(m2.NA)), u = s.mapValue((c, l2, f2) => {
  12566. const h = o.get(l2, f2);
  12567. return c.isError() ? c : h.isError() ? h : this._handleSignleObject(c, h);
  12568. });
  12569. return r === 1 && n === 1 ? u.get(0, 0) : u;
  12570. }
  12571. _handleSignleObject(e, t) {
  12572. const { isError: r, errorObject: n, variants: s } = I2(e, t);
  12573. if (r)
  12574. return n;
  12575. const [o, u] = s, c = +o.getValue(), l2 = Math.floor(+u.getValue());
  12576. if (c < 0 || c > 1 || l2 < 1 || l2 > 10 ** 10)
  12577. return g2.create(m2.NUM);
  12578. const f2 = Po(1 - c, l2);
  12579. return Number.isNaN(f2) || !Number.isFinite(f2) ? g2.create(m2.NUM) : y2.create(f2);
  12580. }
  12581. };
  12582. var Yo = class extends V {
  12583. constructor() {
  12584. super(...arguments);
  12585. A(this, "minParams", 2);
  12586. A(this, "maxParams", 2);
  12587. }
  12588. calculate(e, t) {
  12589. const r = e.isArray() ? e.getRowCount() : 1, n = e.isArray() ? e.getColumnCount() : 1, s = t.isArray() ? t.getRowCount() : 1, o = t.isArray() ? t.getColumnCount() : 1;
  12590. let u = e;
  12591. if (e.isArray() && r === 1 && n === 1 && (u = e.get(0, 0)), u.isError())
  12592. return u;
  12593. let c = t;
  12594. if (t.isArray() && s === 1 && o === 1 && (c = t.get(0, 0)), c.isError())
  12595. return c;
  12596. if (r * n === 1 || s * o === 1)
  12597. return u.isNull() || c.isNull() ? g2.create(m2.VALUE) : g2.create(m2.NA);
  12598. if (r * n !== s * o)
  12599. return g2.create(m2.NA);
  12600. const {
  12601. isError: l2,
  12602. errorObject: f2,
  12603. array1Values: h,
  12604. array2Values: d2,
  12605. noCalculate: _
  12606. } = Je(
  12607. e,
  12608. t,
  12609. r * n,
  12610. n,
  12611. o
  12612. );
  12613. return l2 ? f2 : _ ? g2.create(m2.DIV_BY_ZERO) : this._getResult(h, d2, r, n);
  12614. }
  12615. _getResult(e, t, r, n) {
  12616. let s = 0;
  12617. for (let c = 0; c < e.length; c++) {
  12618. if (t[c] === 0)
  12619. return g2.create(m2.DIV_BY_ZERO);
  12620. s += (e[c] - t[c]) ** 2 / t[c];
  12621. }
  12622. let o = (r - 1) * (n - 1);
  12623. r === 1 ? o = n - 1 : n === 1 && (o = r - 1);
  12624. const u = 1 - Sa(s, o);
  12625. return y2.create(u);
  12626. }
  12627. };
  12628. var Ho = class extends V {
  12629. constructor() {
  12630. super(...arguments);
  12631. A(this, "minParams", 3);
  12632. A(this, "maxParams", 3);
  12633. }
  12634. calculate(e, t, r) {
  12635. const n = Math.max(
  12636. e.isArray() ? e.getRowCount() : 1,
  12637. t.isArray() ? t.getRowCount() : 1,
  12638. r.isArray() ? r.getRowCount() : 1
  12639. ), s = Math.max(
  12640. e.isArray() ? e.getColumnCount() : 1,
  12641. t.isArray() ? t.getColumnCount() : 1,
  12642. r.isArray() ? r.getColumnCount() : 1
  12643. ), o = O(n, s, e, g2.create(m2.NA)), u = O(n, s, t, g2.create(m2.NA)), c = O(n, s, r, g2.create(m2.NA)), l2 = o.mapValue((f2, h, d2) => {
  12644. const _ = u.get(h, d2), C = c.get(h, d2);
  12645. if (f2.isError())
  12646. return f2;
  12647. if (_.isError())
  12648. return _;
  12649. if (C.isError())
  12650. return C;
  12651. const { isError: E2, errorObject: b, variants: R } = I2(f2, _, C);
  12652. if (E2)
  12653. return b;
  12654. const [p2, N2, M2] = R, w = +p2.getValue(), D2 = +N2.getValue(), S2 = Math.floor(+M2.getValue());
  12655. if (w <= 0 || w >= 1 || D2 <= 0 || S2 < 1)
  12656. return g2.create(m2.NUM);
  12657. const P = Math.abs(Wn(w / 2, 0, 1) * D2 / Math.sqrt(S2));
  12658. return y2.create(P);
  12659. });
  12660. return n === 1 && s === 1 ? l2.get(0, 0) : l2;
  12661. }
  12662. };
  12663. var Go = class extends V {
  12664. constructor() {
  12665. super(...arguments);
  12666. A(this, "minParams", 2);
  12667. A(this, "maxParams", 2);
  12668. }
  12669. calculate(e, t) {
  12670. const r = e.isArray() ? e.getRowCount() : 1, n = e.isArray() ? e.getColumnCount() : 1, s = t.isArray() ? t.getRowCount() : 1, o = t.isArray() ? t.getColumnCount() : 1;
  12671. let u = e;
  12672. if (e.isArray() && r === 1 && n === 1 && (u = e.get(0, 0)), u.isError())
  12673. return u;
  12674. let c = t;
  12675. if (t.isArray() && s === 1 && o === 1 && (c = t.get(0, 0)), c.isError())
  12676. return c;
  12677. if ((r * n === 1 || s * o === 1) && (u.isNull() || c.isNull()))
  12678. return g2.create(m2.VALUE);
  12679. if (r * n !== s * o)
  12680. return g2.create(m2.NA);
  12681. const {
  12682. isError: l2,
  12683. errorObject: f2,
  12684. array1Values: h,
  12685. array2Values: d2,
  12686. noCalculate: _
  12687. } = Je(
  12688. e,
  12689. t,
  12690. r * n,
  12691. n,
  12692. o
  12693. );
  12694. return l2 ? f2 : _ ? g2.create(m2.DIV_BY_ZERO) : this._getResult(h, d2);
  12695. }
  12696. _getResult(e, t) {
  12697. if (e.length === 0)
  12698. return g2.create(m2.DIV_BY_ZERO);
  12699. const r = e.length;
  12700. let n = 0, s = 0;
  12701. for (let l2 = 0; l2 < r; l2++)
  12702. n += e[l2], s += t[l2];
  12703. const o = n / r, u = s / r;
  12704. let c = 0;
  12705. for (let l2 = 0; l2 < r; l2++) {
  12706. const f2 = e[l2] - o, h = t[l2] - u;
  12707. c += f2 * h;
  12708. }
  12709. return y2.create(c / r);
  12710. }
  12711. };
  12712. var Qo = class extends V {
  12713. constructor() {
  12714. super(...arguments);
  12715. A(this, "minParams", 3);
  12716. A(this, "maxParams", 3);
  12717. }
  12718. calculate(e, t, r) {
  12719. const n = Math.max(
  12720. e.isArray() ? e.getRowCount() : 1,
  12721. t.isArray() ? t.getRowCount() : 1,
  12722. r.isArray() ? r.getRowCount() : 1
  12723. ), s = Math.max(
  12724. e.isArray() ? e.getColumnCount() : 1,
  12725. t.isArray() ? t.getColumnCount() : 1,
  12726. r.isArray() ? r.getColumnCount() : 1
  12727. ), o = O(n, s, e, g2.create(m2.NA)), u = O(n, s, t, g2.create(m2.NA)), c = O(n, s, r, g2.create(m2.NA)), l2 = o.mapValue((f2, h, d2) => {
  12728. const _ = u.get(h, d2), C = c.get(h, d2);
  12729. return f2.isError() ? f2 : _.isError() ? _ : C.isError() ? C : this._handleSignleObject(f2, _, C);
  12730. });
  12731. return n === 1 && s === 1 ? l2.get(0, 0) : l2;
  12732. }
  12733. _handleSignleObject(e, t, r) {
  12734. const { isError: n, errorObject: s, variants: o } = I2(e, t, r);
  12735. if (n)
  12736. return s;
  12737. const [u, c, l2] = o, f2 = +u.getValue(), h = +c.getValue(), d2 = +l2.getValue();
  12738. if (f2 < 0 || h <= 0)
  12739. return g2.create(m2.NUM);
  12740. let _;
  12741. return d2 ? _ = nm(f2, h) : _ = sm(f2, h), y2.create(_);
  12742. }
  12743. };
  12744. var Wo = class extends V {
  12745. constructor() {
  12746. super(...arguments);
  12747. A(this, "minParams", 3);
  12748. A(this, "maxParams", 3);
  12749. }
  12750. calculate(e, t, r) {
  12751. const n = Math.max(
  12752. e.isArray() ? e.getRowCount() : 1,
  12753. t.isArray() ? t.getRowCount() : 1,
  12754. r.isArray() ? r.getRowCount() : 1
  12755. ), s = Math.max(
  12756. e.isArray() ? e.getColumnCount() : 1,
  12757. t.isArray() ? t.getColumnCount() : 1,
  12758. r.isArray() ? r.getColumnCount() : 1
  12759. ), o = O(n, s, e, g2.create(m2.NA)), u = O(n, s, t, g2.create(m2.NA)), c = O(n, s, r, g2.create(m2.NA)), l2 = o.mapValue((f2, h, d2) => {
  12760. const _ = u.get(h, d2), C = c.get(h, d2);
  12761. return f2.isError() ? f2 : _.isError() ? _ : C.isError() ? C : this._handleSignleObject(f2, _, C);
  12762. });
  12763. return n === 1 && s === 1 ? l2.get(0, 0) : l2;
  12764. }
  12765. _handleSignleObject(e, t, r) {
  12766. const { isError: n, errorObject: s, variants: o } = I2(e, t, r);
  12767. if (n)
  12768. return s;
  12769. const [u, c, l2] = o, f2 = +u.getValue(), h = Math.floor(+c.getValue()), d2 = Math.floor(+l2.getValue());
  12770. if (f2 < 0 || h < 1 || h > 10 ** 10 || d2 < 1 || d2 > 10 ** 10)
  12771. return g2.create(m2.NUM);
  12772. const _ = 1 - Pa(f2, h, d2);
  12773. return y2.create(_);
  12774. }
  12775. };
  12776. var qo = class extends V {
  12777. constructor() {
  12778. super(...arguments);
  12779. A(this, "minParams", 3);
  12780. A(this, "maxParams", 3);
  12781. }
  12782. calculate(e, t, r) {
  12783. const n = Math.max(
  12784. e.isArray() ? e.getRowCount() : 1,
  12785. t.isArray() ? t.getRowCount() : 1,
  12786. r.isArray() ? r.getRowCount() : 1
  12787. ), s = Math.max(
  12788. e.isArray() ? e.getColumnCount() : 1,
  12789. t.isArray() ? t.getColumnCount() : 1,
  12790. r.isArray() ? r.getColumnCount() : 1
  12791. ), o = O(n, s, e, g2.create(m2.NA)), u = O(n, s, t, g2.create(m2.NA)), c = O(n, s, r, g2.create(m2.NA)), l2 = o.mapValue((f2, h, d2) => {
  12792. const _ = u.get(h, d2), C = c.get(h, d2);
  12793. return f2.isError() ? f2 : _.isError() ? _ : C.isError() ? C : this._handleSignleObject(f2, _, C);
  12794. });
  12795. return n === 1 && s === 1 ? l2.get(0, 0) : l2;
  12796. }
  12797. _handleSignleObject(e, t, r) {
  12798. const { isError: n, errorObject: s, variants: o } = I2(e, t, r);
  12799. if (n)
  12800. return s;
  12801. const [u, c, l2] = o, f2 = +u.getValue(), h = Math.floor(+c.getValue()), d2 = Math.floor(+l2.getValue());
  12802. if (f2 < 0 || f2 > 1 || h < 1 || h > 10 ** 10 || d2 < 1 || d2 > 10 ** 10)
  12803. return g2.create(m2.NUM);
  12804. const _ = Lo(1 - f2, h, d2);
  12805. return Number.isNaN(_) || !Number.isFinite(_) ? g2.create(m2.NUM) : y2.create(_);
  12806. }
  12807. };
  12808. var Ko = class extends V {
  12809. constructor() {
  12810. super(...arguments);
  12811. A(this, "minParams", 2);
  12812. A(this, "maxParams", 2);
  12813. }
  12814. calculate(e, t) {
  12815. const {
  12816. isError: r,
  12817. errorObject: n,
  12818. variance: s,
  12819. ns1: o
  12820. } = this._getValues(e);
  12821. if (r)
  12822. return n;
  12823. const {
  12824. isError: u,
  12825. errorObject: c,
  12826. variance: l2,
  12827. ns1: f2
  12828. } = this._getValues(t);
  12829. if (u)
  12830. return c;
  12831. let h = 2 * (1 - Pa(s / l2, o, f2));
  12832. return h > 1 && (h = 2 - h), y2.create(h);
  12833. }
  12834. // eslint-disable-next-line
  12835. _getValues(e) {
  12836. let t = 0, r = 0;
  12837. const n = e.isArray() ? e.getRowCount() : 1, s = e.isArray() ? e.getColumnCount() : 1;
  12838. if (n === 1 && s === 1) {
  12839. const f2 = e.isArray() ? e.get(0, 0) : e;
  12840. return f2.isError() ? {
  12841. isError: true,
  12842. errorObject: f2,
  12843. variance: t,
  12844. ns1: r
  12845. } : f2.isNull() ? {
  12846. isError: true,
  12847. errorObject: g2.create(m2.VALUE),
  12848. variance: t,
  12849. ns1: r
  12850. } : {
  12851. isError: true,
  12852. errorObject: g2.create(m2.DIV_BY_ZERO),
  12853. variance: t,
  12854. ns1: r
  12855. };
  12856. }
  12857. const o = [];
  12858. let u = 0;
  12859. for (let f2 = 0; f2 < n; f2++)
  12860. for (let h = 0; h < s; h++) {
  12861. const d2 = e.isArray() ? e.get(f2, h) : e;
  12862. if (d2.isError())
  12863. return {
  12864. isError: true,
  12865. errorObject: d2,
  12866. variance: t,
  12867. ns1: r
  12868. };
  12869. if (d2.isNull() || d2.isBoolean())
  12870. continue;
  12871. const _ = d2.getValue();
  12872. DC(_) && (o.push(+_), u += +_);
  12873. }
  12874. if (o.length <= 1)
  12875. return {
  12876. isError: true,
  12877. errorObject: g2.create(m2.DIV_BY_ZERO),
  12878. variance: t,
  12879. ns1: r
  12880. };
  12881. const c = u / o.length;
  12882. let l2 = 0;
  12883. for (let f2 = 0; f2 < o.length; f2++)
  12884. l2 += (o[f2] - c) ** 2;
  12885. return r = o.length - 1, t = l2 / r, t === 0 ? {
  12886. isError: true,
  12887. errorObject: g2.create(m2.DIV_BY_ZERO),
  12888. variance: t,
  12889. ns1: r
  12890. } : {
  12891. isError: false,
  12892. errorObject: null,
  12893. variance: t,
  12894. ns1: r
  12895. };
  12896. }
  12897. };
  12898. var Xo = class extends V {
  12899. constructor() {
  12900. super(...arguments);
  12901. A(this, "minParams", 4);
  12902. A(this, "maxParams", 4);
  12903. }
  12904. calculate(e, t, r, n) {
  12905. const s = Math.max(
  12906. e.isArray() ? e.getRowCount() : 1,
  12907. t.isArray() ? t.getRowCount() : 1,
  12908. r.isArray() ? r.getRowCount() : 1,
  12909. n.isArray() ? n.getRowCount() : 1
  12910. ), o = Math.max(
  12911. e.isArray() ? e.getColumnCount() : 1,
  12912. t.isArray() ? t.getColumnCount() : 1,
  12913. r.isArray() ? r.getColumnCount() : 1,
  12914. n.isArray() ? n.getColumnCount() : 1
  12915. ), u = O(s, o, e, g2.create(m2.NA)), c = O(s, o, t, g2.create(m2.NA)), l2 = O(s, o, r, g2.create(m2.NA)), f2 = O(s, o, n, g2.create(m2.NA)), h = u.mapValue((d2, _, C) => {
  12916. const E2 = c.get(_, C), b = l2.get(_, C), R = f2.get(_, C);
  12917. return d2.isError() ? d2 : E2.isError() ? E2 : b.isError() ? b : R.isError() ? R : this._handleSignleObject(d2, E2, b, R);
  12918. });
  12919. return s === 1 && o === 1 ? h.get(0, 0) : h;
  12920. }
  12921. _handleSignleObject(e, t, r, n) {
  12922. const { isError: s, errorObject: o, variants: u } = I2(e, t, r, n);
  12923. if (s)
  12924. return o;
  12925. const [c, l2, f2, h] = u, d2 = +c.getValue(), _ = +l2.getValue(), C = +f2.getValue(), E2 = +h.getValue();
  12926. if (d2 < 0 || _ <= 0 || C <= 0)
  12927. return g2.create(m2.NUM);
  12928. let b;
  12929. return E2 ? b = am(d2, _, C) : b = im(d2, _, C), y2.create(b);
  12930. }
  12931. };
  12932. var Zo = class extends V {
  12933. constructor() {
  12934. super(...arguments);
  12935. A(this, "minParams", 3);
  12936. A(this, "maxParams", 3);
  12937. }
  12938. calculate(e, t, r) {
  12939. const n = Math.max(
  12940. e.isArray() ? e.getRowCount() : 1,
  12941. t.isArray() ? t.getRowCount() : 1,
  12942. r.isArray() ? r.getRowCount() : 1
  12943. ), s = Math.max(
  12944. e.isArray() ? e.getColumnCount() : 1,
  12945. t.isArray() ? t.getColumnCount() : 1,
  12946. r.isArray() ? r.getColumnCount() : 1
  12947. ), o = O(n, s, e, g2.create(m2.NA)), u = O(n, s, t, g2.create(m2.NA)), c = O(n, s, r, g2.create(m2.NA)), l2 = o.mapValue((f2, h, d2) => {
  12948. const _ = u.get(h, d2), C = c.get(h, d2);
  12949. return f2.isError() ? f2 : _.isError() ? _ : C.isError() ? C : this._handleSignleObject(f2, _, C);
  12950. });
  12951. return n === 1 && s === 1 ? l2.get(0, 0) : l2;
  12952. }
  12953. _handleSignleObject(e, t, r) {
  12954. const { isError: n, errorObject: s, variants: o } = I2(e, t, r);
  12955. if (n)
  12956. return s;
  12957. const [u, c, l2] = o, f2 = +u.getValue(), h = +c.getValue(), d2 = +l2.getValue();
  12958. if (f2 < 0 || f2 > 1 || h <= 0 || d2 <= 0)
  12959. return g2.create(m2.NUM);
  12960. const _ = om(f2, h, d2);
  12961. return Number.isNaN(_) || !Number.isFinite(_) ? g2.create(m2.NUM) : y2.create(_);
  12962. }
  12963. };
  12964. var zo = class extends V {
  12965. constructor() {
  12966. super(...arguments);
  12967. A(this, "minParams", 3);
  12968. A(this, "maxParams", 3);
  12969. }
  12970. calculate(e, t, r) {
  12971. const n = Math.max(
  12972. e.isArray() ? e.getRowCount() : 1,
  12973. t.isArray() ? t.getRowCount() : 1,
  12974. r.isArray() ? r.getRowCount() : 1
  12975. ), s = Math.max(
  12976. e.isArray() ? e.getColumnCount() : 1,
  12977. t.isArray() ? t.getColumnCount() : 1,
  12978. r.isArray() ? r.getColumnCount() : 1
  12979. ), o = O(n, s, e, g2.create(m2.NA)), u = O(n, s, t, g2.create(m2.NA)), c = O(n, s, r, g2.create(m2.NA)), l2 = o.mapValue((f2, h, d2) => {
  12980. const _ = u.get(h, d2), C = c.get(h, d2);
  12981. return f2.isError() ? f2 : _.isError() ? _ : C.isError() ? C : this._handleSignleObject(f2, _, C);
  12982. });
  12983. return n === 1 && s === 1 ? l2.get(0, 0) : l2;
  12984. }
  12985. _handleSignleObject(e, t, r) {
  12986. const { isError: n, errorObject: s, variants: o } = I2(e, t, r);
  12987. if (n)
  12988. return s;
  12989. const [u, c, l2] = o, f2 = +u.getValue(), h = +c.getValue(), d2 = +l2.getValue();
  12990. if (f2 <= 0 || f2 >= 1 || d2 <= 0)
  12991. return g2.create(m2.NUM);
  12992. const _ = lm(f2, h, d2);
  12993. return Number.isNaN(_) || !Number.isFinite(_) ? g2.create(m2.NUM) : y2.create(_);
  12994. }
  12995. };
  12996. var Jo = class extends V {
  12997. constructor() {
  12998. super(...arguments);
  12999. A(this, "minParams", 1);
  13000. A(this, "maxParams", 255);
  13001. }
  13002. calculate(...e) {
  13003. const t = {};
  13004. let r = 0, n = 1;
  13005. for (let s = 0; s < e.length; s++) {
  13006. const o = e[s];
  13007. if (o.isError())
  13008. return o;
  13009. if (o.isString()) {
  13010. const l2 = o.convertToNumberObjectValue();
  13011. if (l2.isError())
  13012. return l2;
  13013. }
  13014. const u = o.isArray() ? o.getRowCount() : 1, c = o.isArray() ? o.getColumnCount() : 1;
  13015. for (let l2 = 0; l2 < u; l2++)
  13016. for (let f2 = 0; f2 < c; f2++) {
  13017. const h = o.isArray() ? o.get(l2, f2) : o;
  13018. if (h.isError())
  13019. return h;
  13020. if (h.isNull() || h.isBoolean() || h.isString())
  13021. continue;
  13022. const d2 = h.getValue();
  13023. DC(d2) && (t[+d2] ? (t[+d2].count++, t[+d2].count > n && (n = t[+d2].count)) : t[+d2] = { count: 1, order: r++ });
  13024. }
  13025. }
  13026. return r === 0 || n === 1 ? new g2(m2.NA) : this._getResult(t, n);
  13027. }
  13028. _getResult(e, t) {
  13029. const r = Object.entries(e).filter(([n, { count: s }]) => s === t).sort((n, s) => n[1].order - s[1].order).map(([n]) => +n);
  13030. return y2.create(r[0]);
  13031. }
  13032. };
  13033. var eu = class extends V {
  13034. constructor() {
  13035. super(...arguments);
  13036. A(this, "minParams", 4);
  13037. A(this, "maxParams", 4);
  13038. }
  13039. calculate(e, t, r, n) {
  13040. const s = Math.max(
  13041. e.isArray() ? e.getRowCount() : 1,
  13042. t.isArray() ? t.getRowCount() : 1,
  13043. r.isArray() ? r.getRowCount() : 1,
  13044. n.isArray() ? n.getRowCount() : 1
  13045. ), o = Math.max(
  13046. e.isArray() ? e.getColumnCount() : 1,
  13047. t.isArray() ? t.getColumnCount() : 1,
  13048. r.isArray() ? r.getColumnCount() : 1,
  13049. n.isArray() ? n.getColumnCount() : 1
  13050. ), u = O(s, o, e, g2.create(m2.NA)), c = O(s, o, t, g2.create(m2.NA)), l2 = O(s, o, r, g2.create(m2.NA)), f2 = O(s, o, n, g2.create(m2.NA)), h = u.mapValue((d2, _, C) => {
  13051. const E2 = c.get(_, C), b = l2.get(_, C), R = f2.get(_, C);
  13052. return d2.isError() ? d2 : E2.isError() ? E2 : b.isError() ? b : R.isError() ? R : this._handleSignleObject(d2, E2, b, R);
  13053. });
  13054. return s === 1 && o === 1 ? h.get(0, 0) : h;
  13055. }
  13056. _handleSignleObject(e, t, r, n) {
  13057. const { isError: s, errorObject: o, variants: u } = I2(e, t, r, n);
  13058. if (s)
  13059. return o;
  13060. const [c, l2, f2, h] = u, d2 = +c.getValue(), _ = +l2.getValue(), C = +f2.getValue(), E2 = +h.getValue();
  13061. if (C <= 0)
  13062. return g2.create(m2.NUM);
  13063. let b;
  13064. return E2 ? b = kr(d2, _, C) : b = vo(d2, _, C), y2.create(b);
  13065. }
  13066. };
  13067. var tu = class extends V {
  13068. constructor() {
  13069. super(...arguments);
  13070. A(this, "minParams", 3);
  13071. A(this, "maxParams", 3);
  13072. }
  13073. calculate(e, t, r) {
  13074. const n = Math.max(
  13075. e.isArray() ? e.getRowCount() : 1,
  13076. t.isArray() ? t.getRowCount() : 1,
  13077. r.isArray() ? r.getRowCount() : 1
  13078. ), s = Math.max(
  13079. e.isArray() ? e.getColumnCount() : 1,
  13080. t.isArray() ? t.getColumnCount() : 1,
  13081. r.isArray() ? r.getColumnCount() : 1
  13082. ), o = O(n, s, e, g2.create(m2.NA)), u = O(n, s, t, g2.create(m2.NA)), c = O(n, s, r, g2.create(m2.NA)), l2 = o.mapValue((f2, h, d2) => {
  13083. const _ = u.get(h, d2), C = c.get(h, d2);
  13084. return f2.isError() ? f2 : _.isError() ? _ : C.isError() ? C : this._handleSignleObject(f2, _, C);
  13085. });
  13086. return n === 1 && s === 1 ? l2.get(0, 0) : l2;
  13087. }
  13088. _handleSignleObject(e, t, r) {
  13089. const { isError: n, errorObject: s, variants: o } = I2(e, t, r);
  13090. if (n)
  13091. return s;
  13092. const [u, c, l2] = o, f2 = +u.getValue(), h = +c.getValue(), d2 = +l2.getValue();
  13093. if (f2 <= 0 || f2 >= 1 || d2 <= 0)
  13094. return g2.create(m2.NUM);
  13095. const _ = Wn(f2, h, d2);
  13096. return y2.create(_);
  13097. }
  13098. };
  13099. var ru = class extends V {
  13100. constructor() {
  13101. super(...arguments);
  13102. A(this, "minParams", 1);
  13103. A(this, "maxParams", 1);
  13104. }
  13105. calculate(e) {
  13106. if (e.isArray()) {
  13107. const t = e.mapValue((r) => this._handleSignleObject(r));
  13108. return e.getRowCount() === 1 && e.getColumnCount() === 1 ? t.get(0, 0) : t;
  13109. }
  13110. return this._handleSignleObject(e);
  13111. }
  13112. _handleSignleObject(e) {
  13113. const { isError: t, errorObject: r, variants: n } = I2(e);
  13114. if (t)
  13115. return r;
  13116. const [s] = n, o = +s.getValue();
  13117. if (o <= 0 || o >= 1)
  13118. return g2.create(m2.NUM);
  13119. const u = Wn(o, 0, 1);
  13120. return y2.create(u);
  13121. }
  13122. };
  13123. var nu2 = class extends V {
  13124. constructor() {
  13125. super(...arguments);
  13126. A(this, "minParams", 2);
  13127. A(this, "maxParams", 2);
  13128. }
  13129. calculate(e, t) {
  13130. const r = this._getValues(e);
  13131. if (t.isArray()) {
  13132. const n = t.mapValue((s) => this._handleSingleObject(r, s));
  13133. return n.getRowCount() === 1 && n.getColumnCount() === 1 ? n.get(0, 0) : n;
  13134. }
  13135. return this._handleSingleObject(r, t);
  13136. }
  13137. _handleSingleObject(e, t) {
  13138. if (e instanceof g2)
  13139. return e;
  13140. const { isError: r, errorObject: n, variants: s } = I2(t);
  13141. if (r)
  13142. return n;
  13143. const [o] = s, u = +o.getValue(), c = e.length;
  13144. if (u < 0 || u > 1)
  13145. return g2.create(m2.NUM);
  13146. const l2 = u * (c - 1), f2 = Math.floor(l2), h = l2 - f2;
  13147. if (h === 0)
  13148. return y2.create(e[f2]);
  13149. const d2 = e[f2] + h * (e[f2 + 1] - e[f2]);
  13150. return y2.create(d2);
  13151. }
  13152. _getValues(e) {
  13153. const t = e.isArray() ? e.getRowCount() : 1, r = e.isArray() ? e.getColumnCount() : 1, n = [];
  13154. for (let s = 0; s < t; s++)
  13155. for (let o = 0; o < r; o++) {
  13156. const u = e.isArray() ? e.get(s, o) : e;
  13157. if (u.isError())
  13158. return u;
  13159. if (u.isNull() || u.isBoolean() || u.isString())
  13160. continue;
  13161. const c = u.getValue();
  13162. DC(c) && n.push(+c);
  13163. }
  13164. return n.length === 0 ? g2.create(m2.NUM) : n.sort((s, o) => s - o);
  13165. }
  13166. };
  13167. var su = class extends V {
  13168. constructor() {
  13169. super(...arguments);
  13170. A(this, "minParams", 2);
  13171. A(this, "maxParams", 3);
  13172. }
  13173. calculate(e, t, r) {
  13174. const n = this._getValues(e);
  13175. let s = r != null ? r : y2.create(3);
  13176. s.isNull() && (s = y2.create(3));
  13177. const o = Math.max(
  13178. t.isArray() ? t.getRowCount() : 1,
  13179. s.isArray() ? s.getRowCount() : 1
  13180. ), u = Math.max(
  13181. t.isArray() ? t.getColumnCount() : 1,
  13182. s.isArray() ? s.getColumnCount() : 1
  13183. ), c = O(o, u, t, g2.create(m2.NA)), l2 = O(o, u, s, g2.create(m2.NA)), f2 = c.mapValue((h, d2, _) => {
  13184. const C = l2.get(d2, _);
  13185. return h.isError() ? h : C.isError() ? C : this._handleSingleObject(n, h, C);
  13186. });
  13187. return o === 1 && u === 1 ? f2.get(0, 0) : f2;
  13188. }
  13189. _handleSingleObject(e, t, r) {
  13190. if (e instanceof g2)
  13191. return e;
  13192. const { isError: n, errorObject: s, variants: o } = I2(t, r);
  13193. if (n)
  13194. return s;
  13195. const [u, c] = o, l2 = +u.getValue(), f2 = Math.floor(+c.getValue()), h = e.length;
  13196. if (h === 0 || l2 < e[0] || l2 > e[h - 1])
  13197. return g2.create(m2.NA);
  13198. if (h === 1)
  13199. return l2 === e[0] ? y2.create(1) : g2.create(m2.NA);
  13200. let d2 = 0, _ = false, C = 0;
  13201. for (; !_ && C < h; )
  13202. l2 === e[C] ? (d2 = C / (h - 1), _ = true) : l2 > e[C] && C + 1 < h && l2 < e[C + 1] && (d2 = (C + (l2 - e[C]) / (e[C + 1] - e[C])) / (h - 1), _ = true), C++;
  13203. return _ ? f2 < 1 ? g2.create(m2.NUM) : (d2 = We(d2, f2), y2.create(d2)) : g2.create(m2.NA);
  13204. }
  13205. _getValues(e) {
  13206. const t = e.isArray() ? e.getRowCount() : 1, r = e.isArray() ? e.getColumnCount() : 1, n = [];
  13207. for (let s = 0; s < t; s++)
  13208. for (let o = 0; o < r; o++) {
  13209. const u = e.isArray() ? e.get(s, o) : e;
  13210. if (u.isError())
  13211. return u;
  13212. if (u.isNull() || u.isBoolean())
  13213. continue;
  13214. const c = u.getValue();
  13215. DC(c) && n.push(+c);
  13216. }
  13217. return n.sort((s, o) => s - o);
  13218. }
  13219. };
  13220. var au = class extends V {
  13221. constructor() {
  13222. super(...arguments);
  13223. A(this, "minParams", 3);
  13224. A(this, "maxParams", 3);
  13225. }
  13226. calculate(e, t, r) {
  13227. const n = Math.max(
  13228. e.isArray() ? e.getRowCount() : 1,
  13229. t.isArray() ? t.getRowCount() : 1,
  13230. r.isArray() ? r.getRowCount() : 1
  13231. ), s = Math.max(
  13232. e.isArray() ? e.getColumnCount() : 1,
  13233. t.isArray() ? t.getColumnCount() : 1,
  13234. r.isArray() ? r.getColumnCount() : 1
  13235. ), o = O(n, s, e, g2.create(m2.NA)), u = O(n, s, t, g2.create(m2.NA)), c = O(n, s, r, g2.create(m2.NA)), l2 = o.mapValue((f2, h, d2) => {
  13236. const _ = u.get(h, d2), C = c.get(h, d2);
  13237. return f2.isError() ? f2 : _.isError() ? _ : C.isError() ? C : this._handleSignleObject(f2, _, C);
  13238. });
  13239. return n === 1 && s === 1 ? l2.get(0, 0) : l2;
  13240. }
  13241. _handleSignleObject(e, t, r) {
  13242. const { isError: n, errorObject: s, variants: o } = I2(e, t, r);
  13243. if (n)
  13244. return s;
  13245. const [u, c, l2] = o, f2 = Math.floor(+u.getValue()), h = +c.getValue(), d2 = +l2.getValue();
  13246. if (f2 < 0 || h < 0)
  13247. return g2.create(m2.NUM);
  13248. let _;
  13249. return d2 ? _ = hm(f2, h) : _ = To(f2, h), y2.create(_);
  13250. }
  13251. };
  13252. var iu = class extends V {
  13253. constructor() {
  13254. super(...arguments);
  13255. A(this, "minParams", 2);
  13256. A(this, "maxParams", 2);
  13257. }
  13258. calculate(e, t) {
  13259. const r = this._getValues(e);
  13260. if (t.isArray()) {
  13261. const n = t.mapValue((s) => this._handleSingleObject(r, s));
  13262. return n.getRowCount() === 1 && n.getColumnCount() === 1 ? n.get(0, 0) : n;
  13263. }
  13264. return this._handleSingleObject(r, t);
  13265. }
  13266. _handleSingleObject(e, t) {
  13267. if (e instanceof g2)
  13268. return e;
  13269. const { isError: r, errorObject: n, variants: s } = I2(t);
  13270. if (r)
  13271. return n;
  13272. const [o] = s, u = Math.floor(+o.getValue());
  13273. if (u < 0 || u > 4)
  13274. return g2.create(m2.NUM);
  13275. const c = u / 4, l2 = e.length, f2 = c * (l2 - 1), h = Math.floor(f2), d2 = f2 - h;
  13276. if (d2 === 0)
  13277. return y2.create(e[h]);
  13278. const _ = e[h] + d2 * (e[h + 1] - e[h]);
  13279. return y2.create(_);
  13280. }
  13281. _getValues(e) {
  13282. const t = e.isArray() ? e.getRowCount() : 1, r = e.isArray() ? e.getColumnCount() : 1, n = [];
  13283. for (let s = 0; s < t; s++)
  13284. for (let o = 0; o < r; o++) {
  13285. const u = e.isArray() ? e.get(s, o) : e;
  13286. if (u.isError())
  13287. return u;
  13288. if (u.isNull() || u.isBoolean())
  13289. continue;
  13290. const c = u.getValue();
  13291. DC(c) && n.push(+c);
  13292. }
  13293. return n.length === 0 ? g2.create(m2.NUM) : n.sort((s, o) => s - o);
  13294. }
  13295. };
  13296. var ou = class extends V {
  13297. constructor() {
  13298. super(...arguments);
  13299. A(this, "minParams", 1);
  13300. A(this, "maxParams", 255);
  13301. }
  13302. calculate(...e) {
  13303. const t = this.flattenArray(e);
  13304. return t.isError() ? t : t.std();
  13305. }
  13306. };
  13307. var uu = class extends V {
  13308. constructor() {
  13309. super(...arguments);
  13310. A(this, "minParams", 1);
  13311. A(this, "maxParams", 255);
  13312. }
  13313. calculate(...e) {
  13314. const t = this.flattenArray(e);
  13315. return t.isError() ? t : t.std(1);
  13316. }
  13317. };
  13318. var cu = class extends V {
  13319. constructor() {
  13320. super(...arguments);
  13321. A(this, "minParams", 2);
  13322. A(this, "maxParams", 2);
  13323. }
  13324. calculate(e, t) {
  13325. const r = Math.max(
  13326. e.isArray() ? e.getRowCount() : 1,
  13327. t.isArray() ? t.getRowCount() : 1
  13328. ), n = Math.max(
  13329. e.isArray() ? e.getColumnCount() : 1,
  13330. t.isArray() ? t.getColumnCount() : 1
  13331. ), s = O(r, n, e, g2.create(m2.NA)), o = O(r, n, t, g2.create(m2.NA)), u = s.mapValue((c, l2, f2) => {
  13332. const h = o.get(l2, f2);
  13333. return c.isError() ? c : h.isError() ? h : this._handleSignleObject(c, h);
  13334. });
  13335. return r === 1 && n === 1 ? u.get(0, 0) : u;
  13336. }
  13337. _handleSignleObject(e, t) {
  13338. const { isError: r, errorObject: n, variants: s } = I2(e, t);
  13339. if (r)
  13340. return n;
  13341. const [o, u] = s, c = +o.getValue(), l2 = Math.floor(+u.getValue());
  13342. if (c <= 0 || c > 1 || l2 < 1 || l2 > 10 ** 10)
  13343. return g2.create(m2.NUM);
  13344. const f2 = Math.abs(qn(c / 2, l2));
  13345. return Number.isNaN(f2) || !Number.isFinite(f2) ? g2.create(m2.NUM) : y2.create(f2);
  13346. }
  13347. };
  13348. var lu = class extends V {
  13349. constructor() {
  13350. super(...arguments);
  13351. A(this, "minParams", 4);
  13352. A(this, "maxParams", 4);
  13353. }
  13354. // eslint-disable-next-line
  13355. calculate(e, t, r, n) {
  13356. const { isError: s, errorObject: o, array1Values: u, array2Values: c } = this._handleArray1AndArray2(e, t), l2 = this._getArrayValues(e), f2 = this._getArrayValues(t), h = Math.max(
  13357. r.isArray() ? r.getRowCount() : 1,
  13358. n.isArray() ? n.getRowCount() : 1
  13359. ), d2 = Math.max(
  13360. r.isArray() ? r.getColumnCount() : 1,
  13361. n.isArray() ? n.getColumnCount() : 1
  13362. ), _ = O(h, d2, r, g2.create(m2.NA)), C = O(h, d2, n, g2.create(m2.NA)), E2 = _.mapValue((b, R, p2) => {
  13363. const N2 = C.get(R, p2);
  13364. if (e.isError())
  13365. return e;
  13366. if (t.isError())
  13367. return t;
  13368. if (b.isError())
  13369. return b;
  13370. if (N2.isError())
  13371. return N2;
  13372. const { isError: M2, errorObject: w, variants: D2 } = I2(b, N2);
  13373. if (M2)
  13374. return w;
  13375. const [S2, P] = D2, U2 = Math.floor(+S2.getValue()), x2 = Math.floor(+P.getValue());
  13376. return ![1, 2].includes(U2) || ![1, 2, 3].includes(x2) ? g2.create(m2.NUM) : x2 === 1 && s ? o : x2 !== 1 && l2 instanceof g2 ? l2 : x2 !== 1 && f2 instanceof g2 ? f2 : this._handleSignleObject(
  13377. x2 === 1 ? u : l2,
  13378. x2 === 1 ? c : f2,
  13379. U2,
  13380. x2
  13381. );
  13382. });
  13383. return h === 1 && d2 === 1 ? E2.get(0, 0) : E2;
  13384. }
  13385. _handleSignleObject(e, t, r, n) {
  13386. if (e.length < 2 || t.length < 2)
  13387. return g2.create(m2.DIV_BY_ZERO);
  13388. const { isError: s, errorObject: o, x: u, degFreedom: c } = this._getTDistParamByArrayValues(e, t, n);
  13389. if (s)
  13390. return o;
  13391. let l2 = $r(-u, c);
  13392. return r === 2 && (l2 *= 2), Number.isNaN(l2) || !Number.isFinite(l2) ? g2.create(m2.NUM) : y2.create(l2);
  13393. }
  13394. _getArrayValues(e) {
  13395. const t = e.isArray() ? e.getRowCount() : 1, r = e.isArray() ? e.getColumnCount() : 1, n = [];
  13396. for (let s = 0; s < t; s++)
  13397. for (let o = 0; o < r; o++) {
  13398. const u = e.isArray() ? e.get(s, o) : e;
  13399. if (u.isError())
  13400. return u;
  13401. if (u.isNull()) {
  13402. if (t * r === 1)
  13403. return g2.create(m2.VALUE);
  13404. continue;
  13405. }
  13406. u.isBoolean() || u.isString() || n.push(+u.getValue());
  13407. }
  13408. return n;
  13409. }
  13410. // eslint-disable-next-line
  13411. _handleArray1AndArray2(e, t) {
  13412. const r = e.isArray() ? e.getRowCount() : 1, n = e.isArray() ? e.getColumnCount() : 1, s = t.isArray() ? t.getRowCount() : 1, o = t.isArray() ? t.getColumnCount() : 1;
  13413. let u = e;
  13414. if (e.isArray() && r === 1 && n === 1 && (u = e.get(0, 0)), u.isError())
  13415. return {
  13416. isError: true,
  13417. errorObject: u,
  13418. array1Values: [],
  13419. array2Values: []
  13420. };
  13421. let c = t;
  13422. if (t.isArray() && s === 1 && o === 1 && (c = t.get(0, 0)), c.isError())
  13423. return {
  13424. isError: true,
  13425. errorObject: c,
  13426. array1Values: [],
  13427. array2Values: []
  13428. };
  13429. if ((r * n === 1 || s * o === 1) && (u.isNull() || c.isNull()))
  13430. return {
  13431. isError: true,
  13432. errorObject: g2.create(m2.VALUE),
  13433. array1Values: [],
  13434. array2Values: []
  13435. };
  13436. if (r * n !== s * o)
  13437. return {
  13438. isError: true,
  13439. errorObject: g2.create(m2.NA),
  13440. array1Values: [],
  13441. array2Values: []
  13442. };
  13443. const {
  13444. isError: l2,
  13445. errorObject: f2,
  13446. array1Values: h,
  13447. array2Values: d2,
  13448. noCalculate: _
  13449. } = Je(
  13450. e,
  13451. t,
  13452. r * n,
  13453. n,
  13454. o
  13455. );
  13456. return l2 ? {
  13457. isError: true,
  13458. errorObject: f2,
  13459. array1Values: [],
  13460. array2Values: []
  13461. } : _ || h.length < 2 ? {
  13462. isError: true,
  13463. errorObject: g2.create(m2.DIV_BY_ZERO),
  13464. array1Values: [],
  13465. array2Values: []
  13466. } : {
  13467. isError: false,
  13468. errorObject: null,
  13469. array1Values: h,
  13470. array2Values: d2
  13471. };
  13472. }
  13473. _getTDistParamByArrayValues(e, t, r) {
  13474. return r === 1 ? this._getTDistParamByType1(e, t) : r === 2 ? this._getTDistParamByType2(e, t) : this._getTDistParamByType3(e, t);
  13475. }
  13476. _getTDistParamByType1(e, t) {
  13477. const r = e.length;
  13478. let n = 0, s = 0, o = 0;
  13479. for (let h = 0; h < r; h++)
  13480. n += e[h], s += t[h], o += (e[h] - t[h]) ** 2;
  13481. const u = n - s, c = r * o - u ** 2, l2 = r - 1;
  13482. return c === 0 ? {
  13483. isError: true,
  13484. errorObject: g2.create(m2.DIV_BY_ZERO),
  13485. x: 0,
  13486. degFreedom: l2
  13487. } : {
  13488. isError: false,
  13489. errorObject: null,
  13490. x: Math.abs(u) * Math.sqrt(l2 / c),
  13491. degFreedom: l2
  13492. };
  13493. }
  13494. _getTDistParamByType2(e, t) {
  13495. const r = e.length, n = t.length;
  13496. let s = 0, o = 0;
  13497. for (let E2 = 0; E2 < r; E2++)
  13498. s += e[E2], o += e[E2] ** 2;
  13499. let u = 0, c = 0;
  13500. for (let E2 = 0; E2 < n; E2++)
  13501. u += t[E2], c += t[E2] ** 2;
  13502. const l2 = o - s ** 2 / r, f2 = c - u ** 2 / n, h = Math.sqrt(l2 + f2);
  13503. if (h === 0)
  13504. return {
  13505. isError: true,
  13506. errorObject: g2.create(m2.DIV_BY_ZERO),
  13507. x: 0,
  13508. degFreedom: 0
  13509. };
  13510. const d2 = r - 1 + n - 1, _ = Math.sqrt(r * n * d2 / (r + n));
  13511. return {
  13512. isError: false,
  13513. errorObject: null,
  13514. x: Math.abs(s / r - u / n) / h * _,
  13515. degFreedom: d2
  13516. };
  13517. }
  13518. _getTDistParamByType3(e, t) {
  13519. const r = e.length, n = t.length;
  13520. let s = 0, o = 0;
  13521. for (let C = 0; C < r; C++)
  13522. s += e[C], o += e[C] ** 2;
  13523. let u = 0, c = 0;
  13524. for (let C = 0; C < n; C++)
  13525. u += t[C], c += t[C] ** 2;
  13526. const l2 = (o - s ** 2 / r) / (r * (r - 1)), f2 = (c - u ** 2 / n) / (n * (n - 1));
  13527. if (l2 + f2 === 0)
  13528. return {
  13529. isError: true,
  13530. errorObject: g2.create(m2.DIV_BY_ZERO),
  13531. x: 0,
  13532. degFreedom: 0
  13533. };
  13534. const h = l2 / (l2 + f2), d2 = Math.abs(s / r - u / n) / Math.sqrt(l2 + f2), _ = 1 / (h ** 2 / (r - 1) + (1 - h) ** 2 / (n - 1));
  13535. return {
  13536. isError: false,
  13537. errorObject: null,
  13538. x: d2,
  13539. degFreedom: _
  13540. };
  13541. }
  13542. };
  13543. var fu = class extends V {
  13544. constructor() {
  13545. super(...arguments);
  13546. A(this, "minParams", 1);
  13547. A(this, "maxParams", 255);
  13548. }
  13549. calculate(...e) {
  13550. const t = this.flattenArray(e);
  13551. return t.isError() ? t : t.var();
  13552. }
  13553. };
  13554. var hu = class extends V {
  13555. constructor() {
  13556. super(...arguments);
  13557. A(this, "minParams", 1);
  13558. A(this, "maxParams", 255);
  13559. }
  13560. calculate(...e) {
  13561. const t = this.flattenArray(e);
  13562. return t.isError() ? t : t.var(1);
  13563. }
  13564. };
  13565. var mu = class extends V {
  13566. constructor() {
  13567. super(...arguments);
  13568. A(this, "minParams", 4);
  13569. A(this, "maxParams", 4);
  13570. }
  13571. calculate(e, t, r, n) {
  13572. const s = Math.max(
  13573. e.isArray() ? e.getRowCount() : 1,
  13574. t.isArray() ? t.getRowCount() : 1,
  13575. r.isArray() ? r.getRowCount() : 1,
  13576. n.isArray() ? n.getRowCount() : 1
  13577. ), o = Math.max(
  13578. e.isArray() ? e.getColumnCount() : 1,
  13579. t.isArray() ? t.getColumnCount() : 1,
  13580. r.isArray() ? r.getColumnCount() : 1,
  13581. n.isArray() ? n.getColumnCount() : 1
  13582. ), u = O(s, o, e, g2.create(m2.NA)), c = O(s, o, t, g2.create(m2.NA)), l2 = O(s, o, r, g2.create(m2.NA)), f2 = O(s, o, n, g2.create(m2.NA)), h = u.mapValue((d2, _, C) => {
  13583. const E2 = c.get(_, C), b = l2.get(_, C), R = f2.get(_, C);
  13584. return d2.isError() ? d2 : E2.isError() ? E2 : b.isError() ? b : R.isError() ? R : this._handleSignleObject(d2, E2, b, R);
  13585. });
  13586. return s === 1 && o === 1 ? h.get(0, 0) : h;
  13587. }
  13588. _handleSignleObject(e, t, r, n) {
  13589. const { isError: s, errorObject: o, variants: u } = I2(e, t, r, n);
  13590. if (s)
  13591. return o;
  13592. const [c, l2, f2, h] = u, d2 = +c.getValue(), _ = +l2.getValue(), C = +f2.getValue(), E2 = +h.getValue();
  13593. if (d2 < 0 || _ <= 0 || C <= 0)
  13594. return g2.create(m2.NUM);
  13595. const b = Math.exp(-((d2 / C) ** _));
  13596. let R;
  13597. return E2 ? R = 1 - b : R = _ / C ** _ * d2 ** (_ - 1) * b, Number.isNaN(R) || !Number.isFinite(R) ? g2.create(m2.NUM) : y2.create(R);
  13598. }
  13599. };
  13600. var gu = class extends V {
  13601. constructor() {
  13602. super(...arguments);
  13603. A(this, "minParams", 2);
  13604. A(this, "maxParams", 3);
  13605. }
  13606. calculate(e, t, r) {
  13607. const n = this._getArrayValues(e), s = Math.max(
  13608. t.isArray() ? t.getRowCount() : 1,
  13609. r != null && r.isArray() ? r.getRowCount() : 1
  13610. ), o = Math.max(
  13611. t.isArray() ? t.getColumnCount() : 1,
  13612. r != null && r.isArray() ? r.getColumnCount() : 1
  13613. ), u = O(s, o, t, g2.create(m2.NA)), c = r ? O(s, o, r, g2.create(m2.NA)) : void 0, l2 = u.mapValue((f2, h, d2) => {
  13614. if (n instanceof g2)
  13615. return n;
  13616. if (f2.isError())
  13617. return f2;
  13618. const _ = r ? c.get(h, d2) : void 0;
  13619. return _ != null && _.isError() ? _ : n.length === 0 ? g2.create(m2.NA) : n.length === 1 ? g2.create(m2.DIV_BY_ZERO) : this._handleSignleObject(n, f2, _);
  13620. });
  13621. return s === 1 && o === 1 ? l2.get(0, 0) : l2;
  13622. }
  13623. _handleSignleObject(e, t, r) {
  13624. const { isError: n, errorObject: s, variants: o } = I2(t);
  13625. if (n)
  13626. return s;
  13627. const [u] = o, c = +u.getValue(), l2 = e.length;
  13628. let f2 = 0, h = 0;
  13629. for (let E2 = 0; E2 < l2; E2++)
  13630. f2 += e[E2], h += e[E2] ** 2;
  13631. let d2 = 0;
  13632. if (r !== void 0) {
  13633. const { isError: E2, errorObject: b, variants: R } = I2(r);
  13634. if (E2)
  13635. return b;
  13636. const [p2] = R;
  13637. d2 = +p2.getValue();
  13638. } else {
  13639. const E2 = f2 / l2;
  13640. d2 = Math.sqrt((h - 2 * E2 * f2 + l2 * E2 ** 2) / (l2 - 1));
  13641. }
  13642. if (d2 <= 0)
  13643. return g2.create(m2.NUM);
  13644. const _ = (f2 / l2 - c) / (d2 / Math.sqrt(l2)), C = 1 - kr(_, 0, 1);
  13645. return Number.isNaN(C) || !Number.isFinite(C) ? g2.create(m2.NUM) : y2.create(C);
  13646. }
  13647. _getArrayValues(e) {
  13648. const t = [], r = e.isArray() ? e.getRowCount() : 1, n = e.isArray() ? e.getColumnCount() : 1;
  13649. for (let s = 0; s < r; s++)
  13650. for (let o = 0; o < n; o++) {
  13651. const u = e.isArray() ? e.get(s, o) : e;
  13652. if (u.isError())
  13653. return u;
  13654. if (u.isNull() || u.isBoolean() || u.isString())
  13655. continue;
  13656. const c = u.getValue();
  13657. DC(c) && t.push(+c);
  13658. }
  13659. return t;
  13660. }
  13661. };
  13662. var Cm = class extends V {
  13663. constructor() {
  13664. super(...arguments);
  13665. A(this, "minParams", 3);
  13666. A(this, "maxParams", 5);
  13667. }
  13668. calculate(e, t, r, n, s) {
  13669. let o = n != null ? n : y2.create(0), u = s != null ? s : y2.create(1);
  13670. o.isNull() && (o = y2.create(0)), u.isNull() && (u = y2.create(1));
  13671. const c = Math.max(
  13672. e.isArray() ? e.getRowCount() : 1,
  13673. t.isArray() ? t.getRowCount() : 1,
  13674. r.isArray() ? r.getRowCount() : 1,
  13675. o.isArray() ? o.getRowCount() : 1,
  13676. u.isArray() ? u.getRowCount() : 1
  13677. ), l2 = Math.max(
  13678. e.isArray() ? e.getColumnCount() : 1,
  13679. t.isArray() ? t.getColumnCount() : 1,
  13680. r.isArray() ? r.getColumnCount() : 1,
  13681. o.isArray() ? o.getColumnCount() : 1,
  13682. u.isArray() ? u.getColumnCount() : 1
  13683. ), f2 = O(c, l2, e, g2.create(m2.NA)), h = O(c, l2, t, g2.create(m2.NA)), d2 = O(c, l2, r, g2.create(m2.NA)), _ = O(c, l2, o, g2.create(m2.NA)), C = O(c, l2, u, g2.create(m2.NA)), E2 = f2.mapValue((b, R, p2) => {
  13684. const N2 = h.get(R, p2), M2 = d2.get(R, p2), w = _.get(R, p2), D2 = C.get(R, p2);
  13685. return this._handleSignleObject(b, N2, M2, w, D2);
  13686. });
  13687. return c === 1 && l2 === 1 ? E2.get(0, 0) : E2;
  13688. }
  13689. _handleSignleObject(e, t, r, n, s) {
  13690. if (e.isError())
  13691. return e;
  13692. if (t.isError())
  13693. return t;
  13694. if (r.isError())
  13695. return r;
  13696. if (n.isError())
  13697. return n;
  13698. if (s.isError())
  13699. return s;
  13700. const { isError: o, errorObject: u, variants: c } = I2(e, t, r, n, s);
  13701. if (o)
  13702. return u;
  13703. const [l2, f2, h, d2, _] = c, C = +l2.getValue(), E2 = +f2.getValue(), b = +h.getValue(), R = +d2.getValue(), p2 = +_.getValue();
  13704. if (E2 <= 0 || b <= 0 || C < R || C > p2 || R === p2)
  13705. return g2.create(m2.NUM);
  13706. const N2 = Do((C - R) / (p2 - R), E2, b);
  13707. return y2.create(N2);
  13708. }
  13709. };
  13710. var le2 = ((i) => (i.BETADIST = "BETADIST", i.BETAINV = "BETAINV", i.BINOMDIST = "BINOMDIST", i.CHIDIST = "CHIDIST", i.CHIINV = "CHIINV", i.CHITEST = "CHITEST", i.CONFIDENCE = "CONFIDENCE", i.COVAR = "COVAR", i.CRITBINOM = "CRITBINOM", i.EXPONDIST = "EXPONDIST", i.FDIST = "FDIST", i.FINV = "FINV", i.FTEST = "FTEST", i.GAMMADIST = "GAMMADIST", i.GAMMAINV = "GAMMAINV", i.HYPGEOMDIST = "HYPGEOMDIST", i.LOGINV = "LOGINV", i.LOGNORMDIST = "LOGNORMDIST", i.MODE = "MODE", i.NEGBINOMDIST = "NEGBINOMDIST", i.NORMDIST = "NORMDIST", i.NORMINV = "NORMINV", i.NORMSDIST = "NORMSDIST", i.NORMSINV = "NORMSINV", i.PERCENTILE = "PERCENTILE", i.PERCENTRANK = "PERCENTRANK", i.POISSON = "POISSON", i.QUARTILE = "QUARTILE", i.RANK = "RANK", i.STDEV = "STDEV", i.STDEVP = "STDEVP", i.TDIST = "TDIST", i.TINV = "TINV", i.TTEST = "TTEST", i.VAR = "VAR", i.VARP = "VARP", i.WEIBULL = "WEIBULL", i.ZTEST = "ZTEST", i))(le2 || {});
  13711. var _m = class extends V {
  13712. constructor() {
  13713. super(...arguments);
  13714. A(this, "minParams", 4);
  13715. A(this, "maxParams", 4);
  13716. }
  13717. calculate(e, t, r, n) {
  13718. const s = Math.max(
  13719. e.isArray() ? e.getRowCount() : 1,
  13720. t.isArray() ? t.getRowCount() : 1,
  13721. r.isArray() ? r.getRowCount() : 1,
  13722. n.isArray() ? n.getRowCount() : 1
  13723. ), o = Math.max(
  13724. e.isArray() ? e.getColumnCount() : 1,
  13725. t.isArray() ? t.getColumnCount() : 1,
  13726. r.isArray() ? r.getColumnCount() : 1,
  13727. n.isArray() ? n.getColumnCount() : 1
  13728. ), u = O(s, o, e, g2.create(m2.NA)), c = O(s, o, t, g2.create(m2.NA)), l2 = O(s, o, r, g2.create(m2.NA)), f2 = O(s, o, n, g2.create(m2.NA)), h = u.mapValue((d2, _, C) => {
  13729. const E2 = c.get(_, C), b = l2.get(_, C), R = f2.get(_, C);
  13730. return d2.isError() ? d2 : E2.isError() ? E2 : b.isError() ? b : R.isError() ? R : this._handleSignleObject(d2, E2, b, R);
  13731. });
  13732. return s === 1 && o === 1 ? h.get(0, 0) : h;
  13733. }
  13734. _handleSignleObject(e, t, r, n) {
  13735. const { isError: s, errorObject: o, variants: u } = I2(e, t, r, n);
  13736. if (s)
  13737. return o;
  13738. const [c, l2, f2, h] = u, d2 = Math.floor(+c.getValue()), _ = Math.floor(+l2.getValue()), C = Math.floor(+f2.getValue()), E2 = Math.floor(+h.getValue());
  13739. if (d2 < 0 || d2 > _ || d2 > C || d2 < _ - E2 + C || _ <= 0 || _ > E2 || C <= 0 || C > E2 || E2 <= 0)
  13740. return g2.create(m2.NUM);
  13741. let b = xa(d2, _, C, E2);
  13742. return Number.isNaN(b) && (b = 0), y2.create(b);
  13743. }
  13744. };
  13745. var Am = class extends V {
  13746. constructor() {
  13747. super(...arguments);
  13748. A(this, "minParams", 3);
  13749. A(this, "maxParams", 3);
  13750. }
  13751. calculate(e, t, r) {
  13752. const n = Math.max(
  13753. e.isArray() ? e.getRowCount() : 1,
  13754. t.isArray() ? t.getRowCount() : 1,
  13755. r.isArray() ? r.getRowCount() : 1
  13756. ), s = Math.max(
  13757. e.isArray() ? e.getColumnCount() : 1,
  13758. t.isArray() ? t.getColumnCount() : 1,
  13759. r.isArray() ? r.getColumnCount() : 1
  13760. ), o = O(n, s, e, g2.create(m2.NA)), u = O(n, s, t, g2.create(m2.NA)), c = O(n, s, r, g2.create(m2.NA)), l2 = o.mapValue((f2, h, d2) => {
  13761. const _ = u.get(h, d2), C = c.get(h, d2);
  13762. return f2.isError() ? f2 : _.isError() ? _ : C.isError() ? C : this._handleSignleObject(f2, _, C);
  13763. });
  13764. return n === 1 && s === 1 ? l2.get(0, 0) : l2;
  13765. }
  13766. _handleSignleObject(e, t, r) {
  13767. const { isError: n, errorObject: s, variants: o } = I2(e, t, r);
  13768. if (n)
  13769. return s;
  13770. const [u, c, l2] = o, f2 = +u.getValue(), h = +c.getValue(), d2 = +l2.getValue();
  13771. if (f2 <= 0 || d2 <= 0)
  13772. return g2.create(m2.NUM);
  13773. const _ = Uo(f2, h, d2);
  13774. return y2.create(_);
  13775. }
  13776. };
  13777. var Em = class extends V {
  13778. constructor() {
  13779. super(...arguments);
  13780. A(this, "minParams", 3);
  13781. A(this, "maxParams", 3);
  13782. }
  13783. calculate(e, t, r) {
  13784. const n = Math.max(
  13785. e.isArray() ? e.getRowCount() : 1,
  13786. t.isArray() ? t.getRowCount() : 1,
  13787. r.isArray() ? r.getRowCount() : 1
  13788. ), s = Math.max(
  13789. e.isArray() ? e.getColumnCount() : 1,
  13790. t.isArray() ? t.getColumnCount() : 1,
  13791. r.isArray() ? r.getColumnCount() : 1
  13792. ), o = O(n, s, e, g2.create(m2.NA)), u = O(n, s, t, g2.create(m2.NA)), c = O(n, s, r, g2.create(m2.NA)), l2 = o.mapValue((f2, h, d2) => {
  13793. const _ = u.get(h, d2), C = c.get(h, d2);
  13794. return f2.isError() ? f2 : _.isError() ? _ : C.isError() ? C : this._handleSignleObject(f2, _, C);
  13795. });
  13796. return n === 1 && s === 1 ? l2.get(0, 0) : l2;
  13797. }
  13798. _handleSignleObject(e, t, r) {
  13799. const { isError: n, errorObject: s, variants: o } = I2(e, t, r);
  13800. if (n)
  13801. return s;
  13802. const [u, c, l2] = o, f2 = Math.floor(+u.getValue()), h = Math.floor(+c.getValue()), d2 = +l2.getValue();
  13803. if (f2 < 0 || h < 1 || d2 <= 0 || d2 >= 1)
  13804. return g2.create(m2.NUM);
  13805. const _ = ja(f2, h, d2);
  13806. return y2.create(_);
  13807. }
  13808. };
  13809. var bm = class extends V {
  13810. constructor() {
  13811. super(...arguments);
  13812. A(this, "minParams", 1);
  13813. A(this, "maxParams", 1);
  13814. }
  13815. calculate(e) {
  13816. if (e.isArray()) {
  13817. const t = e.mapValue((r) => this._handleSignleObject(r));
  13818. return e.getRowCount() === 1 && e.getColumnCount() === 1 ? t.get(0, 0) : t;
  13819. }
  13820. return this._handleSignleObject(e);
  13821. }
  13822. _handleSignleObject(e) {
  13823. const { isError: t, errorObject: r, variants: n } = I2(e);
  13824. if (t)
  13825. return r;
  13826. const [s] = n, o = +s.getValue(), u = kr(o, 0, 1);
  13827. return y2.create(u);
  13828. }
  13829. };
  13830. var ym = class extends V {
  13831. constructor() {
  13832. super(...arguments);
  13833. A(this, "minParams", 2);
  13834. A(this, "maxParams", 3);
  13835. A(this, "needsReferenceObject", true);
  13836. }
  13837. calculate(e, t, r) {
  13838. let n = e;
  13839. n.isReferenceObject() && (n = n.toArrayValueObject());
  13840. const { refHasError: s, refErrorObject: o, refNumbers: u } = this._checkRefReferenceObject(t);
  13841. let c = r != null ? r : y2.create(0);
  13842. c.isReferenceObject() && (c = c.toArrayValueObject());
  13843. const l2 = Math.max(
  13844. n.isArray() ? n.getRowCount() : 1,
  13845. c.isArray() ? c.getRowCount() : 1
  13846. ), f2 = Math.max(
  13847. n.isArray() ? n.getColumnCount() : 1,
  13848. c.isArray() ? c.getColumnCount() : 1
  13849. ), h = O(l2, f2, n, g2.create(m2.NA)), d2 = O(l2, f2, c, g2.create(m2.NA)), _ = h.map((C, E2, b) => {
  13850. const R = d2.get(E2, b);
  13851. if (!e.isReferenceObject() && e.isNull())
  13852. return g2.create(m2.NA);
  13853. if (s)
  13854. return o;
  13855. if (R.isError())
  13856. return R;
  13857. const p2 = +C.getValue(), N2 = +R.getValue();
  13858. if (Number.isNaN(p2) || Number.isNaN(N2))
  13859. return g2.create(m2.VALUE);
  13860. const w = u.sort((D2, S2) => N2 ? D2 - S2 : S2 - D2).indexOf(p2);
  13861. return w === -1 ? g2.create(m2.NA) : y2.create(w + 1);
  13862. });
  13863. return l2 === 1 && f2 === 1 ? _.get(0, 0) : _;
  13864. }
  13865. _checkRefReferenceObject(e) {
  13866. let t = false, r = g2.create(m2.NA);
  13867. const n = [];
  13868. return e.isReferenceObject() ? (e.toArrayValueObject().iterator((o) => {
  13869. const u = o;
  13870. if (u.isError())
  13871. return t = true, r = u, false;
  13872. if (u.isNull() || u.isBoolean())
  13873. return true;
  13874. const c = +u.getValue();
  13875. if (Number.isNaN(c))
  13876. return true;
  13877. n.push(c);
  13878. }), {
  13879. refHasError: t,
  13880. refErrorObject: r,
  13881. refNumbers: n
  13882. }) : {
  13883. refHasError: true,
  13884. refErrorObject: r,
  13885. refNumbers: n
  13886. };
  13887. }
  13888. };
  13889. var Rm = class extends V {
  13890. constructor() {
  13891. super(...arguments);
  13892. A(this, "minParams", 3);
  13893. A(this, "maxParams", 3);
  13894. }
  13895. calculate(e, t, r) {
  13896. const n = Math.max(
  13897. e.isArray() ? e.getRowCount() : 1,
  13898. t.isArray() ? t.getRowCount() : 1,
  13899. r.isArray() ? r.getRowCount() : 1
  13900. ), s = Math.max(
  13901. e.isArray() ? e.getColumnCount() : 1,
  13902. t.isArray() ? t.getColumnCount() : 1,
  13903. r.isArray() ? r.getColumnCount() : 1
  13904. ), o = O(n, s, e, g2.create(m2.NA)), u = O(n, s, t, g2.create(m2.NA)), c = O(n, s, r, g2.create(m2.NA)), l2 = o.mapValue((f2, h, d2) => {
  13905. const _ = u.get(h, d2), C = c.get(h, d2);
  13906. return f2.isError() ? f2 : _.isError() ? _ : C.isError() ? C : this._handleSignleObject(f2, _, C);
  13907. });
  13908. return n === 1 && s === 1 ? l2.get(0, 0) : l2;
  13909. }
  13910. _handleSignleObject(e, t, r) {
  13911. const { isError: n, errorObject: s, variants: o } = I2(e, t, r);
  13912. if (n)
  13913. return s;
  13914. const [u, c, l2] = o, f2 = +u.getValue(), h = Math.floor(+c.getValue()), d2 = Math.floor(+l2.getValue());
  13915. if (f2 < 0 || h < 1 || h > 10 ** 10 || d2 < 1 || d2 > 2)
  13916. return g2.create(m2.NUM);
  13917. let _ = $r(-f2, h);
  13918. return d2 === 2 && (_ *= 2), Number.isNaN(_) || !Number.isFinite(_) ? g2.create(m2.NUM) : y2.create(_);
  13919. }
  13920. };
  13921. var pm = [
  13922. [Cm, le2.BETADIST],
  13923. [Bo, le2.BETAINV],
  13924. [Io, le2.BINOMDIST],
  13925. [ko, le2.CHIDIST],
  13926. [$o, le2.CHIINV],
  13927. [Yo, le2.CHITEST],
  13928. [Ho, le2.CONFIDENCE],
  13929. [Go, le2.COVAR],
  13930. [Fo, le2.CRITBINOM],
  13931. [Qo, le2.EXPONDIST],
  13932. [Wo, le2.FDIST],
  13933. [qo, le2.FINV],
  13934. [Ko, le2.FTEST],
  13935. [Xo, le2.GAMMADIST],
  13936. [Zo, le2.GAMMAINV],
  13937. [_m, le2.HYPGEOMDIST],
  13938. [Am, le2.LOGNORMDIST],
  13939. [zo, le2.LOGINV],
  13940. [Jo, le2.MODE],
  13941. [Em, le2.NEGBINOMDIST],
  13942. [eu, le2.NORMDIST],
  13943. [tu, le2.NORMINV],
  13944. [bm, le2.NORMSDIST],
  13945. [ru, le2.NORMSINV],
  13946. [nu2, le2.PERCENTILE],
  13947. [su, le2.PERCENTRANK],
  13948. [au, le2.POISSON],
  13949. [iu, le2.QUARTILE],
  13950. [ym, le2.RANK],
  13951. [uu, le2.STDEV],
  13952. [ou, le2.STDEVP],
  13953. [Rm, le2.TDIST],
  13954. [cu, le2.TINV],
  13955. [lu, le2.TTEST],
  13956. [hu, le2.VAR],
  13957. [fu, le2.VARP],
  13958. [mu, le2.WEIBULL],
  13959. [gu, le2.ZTEST]
  13960. ];
  13961. var Vm = [];
  13962. var Nm = ((i) => (i.CUBEKPIMEMBER = "CUBEKPIMEMBER", i.CUBEMEMBER = "CUBEMEMBER", i.CUBEMEMBERPROPERTY = "CUBEMEMBERPROPERTY", i.CUBERANKEDMEMBER = "CUBERANKEDMEMBER", i.CUBESET = "CUBESET", i.CUBESETCOUNT = "CUBESETCOUNT", i.CUBEVALUE = "CUBEVALUE", i))(Nm || {});
  13963. var Om = class extends V {
  13964. isCustom() {
  13965. return true;
  13966. }
  13967. };
  13968. var Qb = class extends Om {
  13969. isAsync() {
  13970. return true;
  13971. }
  13972. };
  13973. function et(i) {
  13974. const a2 = [];
  13975. if (i.isError())
  13976. return {
  13977. isError: true,
  13978. errorObject: i,
  13979. databaseValues: a2
  13980. };
  13981. const e = i.isArray() ? i.getRowCount() : 1, t = i.isArray() ? i.getColumnCount() : 1;
  13982. if (e < 2)
  13983. return {
  13984. isError: true,
  13985. errorObject: g2.create(m2.VALUE),
  13986. databaseValues: a2
  13987. };
  13988. for (let r = 0; r < e; r++) {
  13989. const n = [];
  13990. for (let s = 0; s < t; s++) {
  13991. const o = i.get(r, s);
  13992. if (o.isNull()) {
  13993. n.push(null);
  13994. continue;
  13995. }
  13996. let u = `${o.getValue()}`;
  13997. if (o.isBoolean() && (u = u.toLocaleUpperCase()), o.isNumber() || DC(u)) {
  13998. n.push(+u);
  13999. continue;
  14000. }
  14001. n.push(u);
  14002. }
  14003. a2.push(n);
  14004. }
  14005. return {
  14006. isError: false,
  14007. errorObject: null,
  14008. databaseValues: a2
  14009. };
  14010. }
  14011. function tt2(i, a2) {
  14012. let e = -1;
  14013. if (i.isError())
  14014. return {
  14015. isError: true,
  14016. errorObject: i,
  14017. fieldIndex: e
  14018. };
  14019. const t = i.isArray() ? i.getRowCount() : 1, r = i.isArray() ? i.getColumnCount() : 1;
  14020. if (t > 1 || r > 1)
  14021. return {
  14022. isError: true,
  14023. errorObject: g2.create(m2.VALUE),
  14024. fieldIndex: e
  14025. };
  14026. const n = i.isArray() ? i.get(0, 0) : i;
  14027. let s = `${n.getValue()}`;
  14028. if (n.isNull() ? s = 0 : n.isBoolean() ? s = n.getValue() ? 1 : 0 : (n.isNumber() || DC(s)) && (s = Math.floor(+s)), typeof s == "number") {
  14029. if (s < 1 || s > a2[0].length)
  14030. return {
  14031. isError: true,
  14032. errorObject: g2.create(m2.VALUE),
  14033. fieldIndex: e
  14034. };
  14035. e = s - 1;
  14036. } else if (e = a2[0].findIndex((o) => o === null ? false : `${o}`.toLocaleLowerCase() === s.toLocaleLowerCase()), e === -1)
  14037. return {
  14038. isError: true,
  14039. errorObject: g2.create(m2.VALUE),
  14040. fieldIndex: e
  14041. };
  14042. return {
  14043. isError: false,
  14044. errorObject: null,
  14045. fieldIndex: e
  14046. };
  14047. }
  14048. function rt(i) {
  14049. const a2 = [];
  14050. if (i.isError())
  14051. return {
  14052. isError: true,
  14053. errorObject: i,
  14054. criteriaValues: a2
  14055. };
  14056. const e = i.isArray() ? i.getRowCount() : 1, t = i.isArray() ? i.getColumnCount() : 1;
  14057. if (e < 2)
  14058. return {
  14059. isError: true,
  14060. errorObject: g2.create(m2.VALUE),
  14061. criteriaValues: a2
  14062. };
  14063. for (let r = 0; r < e; r++) {
  14064. const n = [];
  14065. for (let s = 0; s < t; s++) {
  14066. const o = i.get(r, s);
  14067. if (o.isNull()) {
  14068. n.push(null);
  14069. continue;
  14070. }
  14071. const u = `${o.getValue()}`;
  14072. if (o.isBoolean()) {
  14073. n.push(o.getValue() ? 1 : 0);
  14074. continue;
  14075. }
  14076. if (o.isNumber() || DC(u)) {
  14077. n.push(+u);
  14078. continue;
  14079. }
  14080. n.push(u);
  14081. }
  14082. a2.push(n);
  14083. }
  14084. return {
  14085. isError: false,
  14086. errorObject: null,
  14087. criteriaValues: a2
  14088. };
  14089. }
  14090. function nt2(i, a2, e) {
  14091. const t = i.length, r = i[0].length, n = {};
  14092. let s = false;
  14093. for (let o = 1; o < t; o++) {
  14094. let u = true;
  14095. for (let c = 0; c < r; c++) {
  14096. const l2 = i[o][c];
  14097. if (l2 === null)
  14098. continue;
  14099. let f2 = n[c];
  14100. if (f2 === void 0) {
  14101. const h = i[0][c];
  14102. f2 = a2[0].findIndex((d2) => d2 === null || h === null ? false : `${d2}`.toLocaleLowerCase() === `${h}`.toLocaleLowerCase()), n[c] = f2;
  14103. }
  14104. if (f2 === -1 && (typeof l2 == "string" || l2 === 0)) {
  14105. u = false;
  14106. break;
  14107. } else if (f2 > -1) {
  14108. const h = a2[e][f2];
  14109. if (h === null) {
  14110. u = false;
  14111. break;
  14112. }
  14113. const [d2, _] = Aa(`${l2}`);
  14114. if (!pt.create(`${h}`).compare(_, d2).getValue()) {
  14115. u = false;
  14116. break;
  14117. }
  14118. }
  14119. }
  14120. if (u) {
  14121. s = true;
  14122. break;
  14123. }
  14124. }
  14125. return s;
  14126. }
  14127. var Mm = class extends V {
  14128. constructor() {
  14129. super(...arguments);
  14130. A(this, "minParams", 3);
  14131. A(this, "maxParams", 3);
  14132. }
  14133. calculate(e, t, r) {
  14134. const { isError: n, errorObject: s, databaseValues: o } = et(e);
  14135. if (n)
  14136. return s;
  14137. const { isError: u, errorObject: c, fieldIndex: l2 } = tt2(t, o);
  14138. if (u)
  14139. return c;
  14140. const { isError: f2, errorObject: h, criteriaValues: d2 } = rt(r);
  14141. if (f2)
  14142. return h;
  14143. let _ = 0, C = 0;
  14144. for (let E2 = 1; E2 < o.length; E2++) {
  14145. const b = o[E2][l2];
  14146. typeof b == "number" && nt2(d2, o, E2) && (_ += b, C++);
  14147. }
  14148. return C === 0 ? g2.create(m2.DIV_BY_ZERO) : y2.create(_ / C);
  14149. }
  14150. };
  14151. var wm = class extends V {
  14152. constructor() {
  14153. super(...arguments);
  14154. A(this, "minParams", 3);
  14155. A(this, "maxParams", 3);
  14156. }
  14157. calculate(e, t, r) {
  14158. const { isError: n, errorObject: s, databaseValues: o } = et(e);
  14159. if (n)
  14160. return s;
  14161. const { isError: u, errorObject: c, fieldIndex: l2 } = tt2(t, o);
  14162. if (u)
  14163. return c;
  14164. const { isError: f2, errorObject: h, criteriaValues: d2 } = rt(r);
  14165. if (f2)
  14166. return h;
  14167. let _ = 0;
  14168. for (let C = 1; C < o.length; C++)
  14169. typeof o[C][l2] == "number" && nt2(d2, o, C) && _++;
  14170. return y2.create(_);
  14171. }
  14172. };
  14173. var Dm = class extends V {
  14174. constructor() {
  14175. super(...arguments);
  14176. A(this, "minParams", 3);
  14177. A(this, "maxParams", 3);
  14178. }
  14179. calculate(e, t, r) {
  14180. const { isError: n, errorObject: s, databaseValues: o } = et(e);
  14181. if (n)
  14182. return s;
  14183. const { isError: u, errorObject: c, fieldIndex: l2 } = tt2(t, o);
  14184. if (u)
  14185. return c;
  14186. const { isError: f2, errorObject: h, criteriaValues: d2 } = rt(r);
  14187. if (f2)
  14188. return h;
  14189. let _ = 0;
  14190. for (let C = 1; C < o.length; C++) {
  14191. const E2 = o[C][l2];
  14192. E2 != null && nt2(d2, o, C) && _++;
  14193. }
  14194. return y2.create(_);
  14195. }
  14196. };
  14197. var Sm = class extends V {
  14198. constructor() {
  14199. super(...arguments);
  14200. A(this, "minParams", 3);
  14201. A(this, "maxParams", 3);
  14202. }
  14203. calculate(e, t, r) {
  14204. const { isError: n, errorObject: s, databaseValues: o } = et(e);
  14205. if (n)
  14206. return s;
  14207. const { isError: u, errorObject: c, fieldIndex: l2 } = tt2(t, o);
  14208. if (u)
  14209. return c;
  14210. const { isError: f2, errorObject: h, criteriaValues: d2 } = rt(r);
  14211. if (f2)
  14212. return h;
  14213. let _ = 0, C = 0;
  14214. for (let E2 = 1; E2 < o.length; E2++) {
  14215. const b = o[E2][l2];
  14216. b != null && nt2(d2, o, E2) && (_++, C = E2);
  14217. }
  14218. return _ === 0 ? g2.create(m2.VALUE) : _ > 1 ? g2.create(m2.NUM) : e.get(C, l2);
  14219. }
  14220. };
  14221. var Pm = class extends V {
  14222. constructor() {
  14223. super(...arguments);
  14224. A(this, "minParams", 3);
  14225. A(this, "maxParams", 3);
  14226. }
  14227. calculate(e, t, r) {
  14228. const { isError: n, errorObject: s, databaseValues: o } = et(e);
  14229. if (n)
  14230. return s;
  14231. const { isError: u, errorObject: c, fieldIndex: l2 } = tt2(t, o);
  14232. if (u)
  14233. return c;
  14234. const { isError: f2, errorObject: h, criteriaValues: d2 } = rt(r);
  14235. if (f2)
  14236. return h;
  14237. let _ = -1 / 0, C = 0;
  14238. for (let E2 = 1; E2 < o.length; E2++) {
  14239. const b = o[E2][l2];
  14240. typeof b == "number" && nt2(d2, o, E2) && (_ = Math.max(_, b), C++);
  14241. }
  14242. return C === 0 ? y2.create(0) : y2.create(_);
  14243. }
  14244. };
  14245. var Lm = class extends V {
  14246. constructor() {
  14247. super(...arguments);
  14248. A(this, "minParams", 3);
  14249. A(this, "maxParams", 3);
  14250. }
  14251. calculate(e, t, r) {
  14252. const { isError: n, errorObject: s, databaseValues: o } = et(e);
  14253. if (n)
  14254. return s;
  14255. const { isError: u, errorObject: c, fieldIndex: l2 } = tt2(t, o);
  14256. if (u)
  14257. return c;
  14258. const { isError: f2, errorObject: h, criteriaValues: d2 } = rt(r);
  14259. if (f2)
  14260. return h;
  14261. let _ = 1 / 0, C = 0;
  14262. for (let E2 = 1; E2 < o.length; E2++) {
  14263. const b = o[E2][l2];
  14264. typeof b == "number" && nt2(d2, o, E2) && (_ = Math.min(_, b), C++);
  14265. }
  14266. return C === 0 ? y2.create(0) : y2.create(_);
  14267. }
  14268. };
  14269. var xm = class extends V {
  14270. constructor() {
  14271. super(...arguments);
  14272. A(this, "minParams", 3);
  14273. A(this, "maxParams", 3);
  14274. }
  14275. calculate(e, t, r) {
  14276. const { isError: n, errorObject: s, databaseValues: o } = et(e);
  14277. if (n)
  14278. return s;
  14279. const { isError: u, errorObject: c, fieldIndex: l2 } = tt2(t, o);
  14280. if (u)
  14281. return c;
  14282. const { isError: f2, errorObject: h, criteriaValues: d2 } = rt(r);
  14283. if (f2)
  14284. return h;
  14285. let _ = 1, C = 0;
  14286. for (let E2 = 1; E2 < o.length; E2++) {
  14287. const b = o[E2][l2];
  14288. typeof b == "number" && nt2(d2, o, E2) && (_ *= b, C++);
  14289. }
  14290. return C === 0 ? y2.create(0) : y2.create(_);
  14291. }
  14292. };
  14293. var jm = class extends V {
  14294. constructor() {
  14295. super(...arguments);
  14296. A(this, "minParams", 3);
  14297. A(this, "maxParams", 3);
  14298. }
  14299. calculate(e, t, r) {
  14300. const { isError: n, errorObject: s, databaseValues: o } = et(e);
  14301. if (n)
  14302. return s;
  14303. const { isError: u, errorObject: c, fieldIndex: l2 } = tt2(t, o);
  14304. if (u)
  14305. return c;
  14306. const { isError: f2, errorObject: h, criteriaValues: d2 } = rt(r);
  14307. if (f2)
  14308. return h;
  14309. const _ = [];
  14310. let C = 0, E2 = 0;
  14311. for (let N2 = 1; N2 < o.length; N2++) {
  14312. const M2 = o[N2][l2];
  14313. typeof M2 == "number" && nt2(d2, o, N2) && (_.push(M2), C += M2, E2++);
  14314. }
  14315. if (E2 <= 1)
  14316. return g2.create(m2.DIV_BY_ZERO);
  14317. const b = C / E2;
  14318. let R = 0;
  14319. for (let N2 = 0; N2 < E2; N2++)
  14320. R += (_[N2] - b) ** 2;
  14321. const p2 = Math.sqrt(R / (E2 - 1));
  14322. return y2.create(p2);
  14323. }
  14324. };
  14325. var Um = class extends V {
  14326. constructor() {
  14327. super(...arguments);
  14328. A(this, "minParams", 3);
  14329. A(this, "maxParams", 3);
  14330. }
  14331. calculate(e, t, r) {
  14332. const { isError: n, errorObject: s, databaseValues: o } = et(e);
  14333. if (n)
  14334. return s;
  14335. const { isError: u, errorObject: c, fieldIndex: l2 } = tt2(t, o);
  14336. if (u)
  14337. return c;
  14338. const { isError: f2, errorObject: h, criteriaValues: d2 } = rt(r);
  14339. if (f2)
  14340. return h;
  14341. const _ = [];
  14342. let C = 0, E2 = 0;
  14343. for (let N2 = 1; N2 < o.length; N2++) {
  14344. const M2 = o[N2][l2];
  14345. typeof M2 == "number" && nt2(d2, o, N2) && (_.push(M2), C += M2, E2++);
  14346. }
  14347. if (E2 === 0)
  14348. return g2.create(m2.DIV_BY_ZERO);
  14349. const b = C / E2;
  14350. let R = 0;
  14351. for (let N2 = 0; N2 < E2; N2++)
  14352. R += (_[N2] - b) ** 2;
  14353. const p2 = Math.sqrt(R / E2);
  14354. return y2.create(p2);
  14355. }
  14356. };
  14357. var vm = class extends V {
  14358. constructor() {
  14359. super(...arguments);
  14360. A(this, "minParams", 3);
  14361. A(this, "maxParams", 3);
  14362. }
  14363. calculate(e, t, r) {
  14364. const { isError: n, errorObject: s, databaseValues: o } = et(e);
  14365. if (n)
  14366. return s;
  14367. const { isError: u, errorObject: c, fieldIndex: l2 } = tt2(t, o);
  14368. if (u)
  14369. return c;
  14370. const { isError: f2, errorObject: h, criteriaValues: d2 } = rt(r);
  14371. if (f2)
  14372. return h;
  14373. let _ = 0;
  14374. for (let C = 1; C < o.length; C++) {
  14375. const E2 = o[C][l2];
  14376. typeof E2 == "number" && nt2(d2, o, C) && (_ += E2);
  14377. }
  14378. return y2.create(_);
  14379. }
  14380. };
  14381. var Tm = class extends V {
  14382. constructor() {
  14383. super(...arguments);
  14384. A(this, "minParams", 3);
  14385. A(this, "maxParams", 3);
  14386. }
  14387. calculate(e, t, r) {
  14388. const { isError: n, errorObject: s, databaseValues: o } = et(e);
  14389. if (n)
  14390. return s;
  14391. const { isError: u, errorObject: c, fieldIndex: l2 } = tt2(t, o);
  14392. if (u)
  14393. return c;
  14394. const { isError: f2, errorObject: h, criteriaValues: d2 } = rt(r);
  14395. if (f2)
  14396. return h;
  14397. const _ = [];
  14398. let C = 0, E2 = 0;
  14399. for (let N2 = 1; N2 < o.length; N2++) {
  14400. const M2 = o[N2][l2];
  14401. typeof M2 == "number" && nt2(d2, o, N2) && (_.push(M2), C += M2, E2++);
  14402. }
  14403. if (E2 <= 1)
  14404. return g2.create(m2.DIV_BY_ZERO);
  14405. const b = C / E2;
  14406. let R = 0;
  14407. for (let N2 = 0; N2 < E2; N2++)
  14408. R += (_[N2] - b) ** 2;
  14409. const p2 = R / (E2 - 1);
  14410. return y2.create(p2);
  14411. }
  14412. };
  14413. var Bm = class extends V {
  14414. constructor() {
  14415. super(...arguments);
  14416. A(this, "minParams", 3);
  14417. A(this, "maxParams", 3);
  14418. }
  14419. calculate(e, t, r) {
  14420. const { isError: n, errorObject: s, databaseValues: o } = et(e);
  14421. if (n)
  14422. return s;
  14423. const { isError: u, errorObject: c, fieldIndex: l2 } = tt2(t, o);
  14424. if (u)
  14425. return c;
  14426. const { isError: f2, errorObject: h, criteriaValues: d2 } = rt(r);
  14427. if (f2)
  14428. return h;
  14429. const _ = [];
  14430. let C = 0, E2 = 0;
  14431. for (let N2 = 1; N2 < o.length; N2++) {
  14432. const M2 = o[N2][l2];
  14433. typeof M2 == "number" && nt2(d2, o, N2) && (_.push(M2), C += M2, E2++);
  14434. }
  14435. if (E2 === 0)
  14436. return g2.create(m2.DIV_BY_ZERO);
  14437. const b = C / E2;
  14438. let R = 0;
  14439. for (let N2 = 0; N2 < E2; N2++)
  14440. R += (_[N2] - b) ** 2;
  14441. const p2 = R / E2;
  14442. return y2.create(p2);
  14443. }
  14444. };
  14445. var Qe = ((i) => (i.DAVERAGE = "DAVERAGE", i.DCOUNT = "DCOUNT", i.DCOUNTA = "DCOUNTA", i.DGET = "DGET", i.DMAX = "DMAX", i.DMIN = "DMIN", i.DPRODUCT = "DPRODUCT", i.DSTDEV = "DSTDEV", i.DSTDEVP = "DSTDEVP", i.DSUM = "DSUM", i.DVAR = "DVAR", i.DVARP = "DVARP", i))(Qe || {});
  14446. var Im = [
  14447. [Mm, Qe.DAVERAGE],
  14448. [wm, Qe.DCOUNT],
  14449. [Dm, Qe.DCOUNTA],
  14450. [Sm, Qe.DGET],
  14451. [Pm, Qe.DMAX],
  14452. [Lm, Qe.DMIN],
  14453. [xm, Qe.DPRODUCT],
  14454. [jm, Qe.DSTDEV],
  14455. [Um, Qe.DSTDEVP],
  14456. [vm, Qe.DSUM],
  14457. [Tm, Qe.DVAR],
  14458. [Bm, Qe.DVARP]
  14459. ];
  14460. var Ua = "yyyy/mm/dd;@";
  14461. var Fm = "yyyy/mm/dd hh:mm";
  14462. var km = "h:mm A/P";
  14463. function ye2(i) {
  14464. const a2 = new Date(Date.UTC(1900, 0, 1)), e = new Date(Date.UTC(1900, 1, 28)), t = Date.UTC(i.getFullYear(), i.getMonth(), i.getDate());
  14465. let r = (t - a2.getTime()) / (1e3 * 3600 * 24);
  14466. return t > e.getTime() && (r += 1), Math.floor(r) + 1;
  14467. }
  14468. function Yr(i) {
  14469. const a2 = new Date(Date.UTC(1900, 0, 1, 0, 0, 0)), e = new Date(Date.UTC(1900, 1, 28, 0, 0, 0));
  14470. let r = (i.getTime() - a2.getTime()) / (1e3 * 3600 * 24);
  14471. return i > e && (r += 1), r + 1;
  14472. }
  14473. function re2(i) {
  14474. const a2 = new Date(Date.UTC(1900, 0, 1)), e = new Date(Date.UTC(1900, 1, 28));
  14475. let t = Math.floor(i) - 1;
  14476. return t > (e.getTime() - a2.getTime()) / (1e3 * 3600 * 24) && (t -= 1), new Date(a2.getTime() + t * (1e3 * 3600 * 24));
  14477. }
  14478. function va(i) {
  14479. const a2 = new Date(Date.UTC(1900, 0, 1, 0, 0, 0)), e = new Date(Date.UTC(1900, 1, 28, 0, 0, 0));
  14480. let t = i - 1;
  14481. return t > (e.getTime() - a2.getTime()) / (1e3 * 3600 * 24) && (t -= 1), t < 0 && (t = i), new Date(a2.getTime() + t * (1e3 * 3600 * 24));
  14482. }
  14483. function Ta(i) {
  14484. if (!/^\d{4}[-/](0?[1-9]|1[012])[-/](0?[1-9]|[12][0-9]|3[01])$/.test(i))
  14485. return false;
  14486. const e = i.replace(/-/g, "/").replace(/T.+/, ""), t = /* @__PURE__ */ new Date(`${e}`);
  14487. if (Number.isNaN(t.getTime()))
  14488. return false;
  14489. const r = t.getFullYear(), n = (t.getMonth() + 1).toString().padStart(2, "0"), s = t.getDate().toString().padStart(2, "0"), o = `${r}-${n}-${s}`;
  14490. return i.replace(/\//g, "-").split("-").map((c) => c.padStart(2, "0")).join("-") === o;
  14491. }
  14492. function Xs(i) {
  14493. return Op.parseDate(i);
  14494. }
  14495. function du(i) {
  14496. return Op.parseValue(i);
  14497. }
  14498. function Zs(i) {
  14499. return Op.parseTime(i);
  14500. }
  14501. function Ba(i) {
  14502. return Op.isDate(i);
  14503. }
  14504. var Cu = {
  14505. 1: [6, 0],
  14506. // Saturday, Sunday
  14507. 2: [0, 1],
  14508. // Sunday, Monday
  14509. 3: [1, 2],
  14510. // Monday, Tuesday
  14511. 4: [2, 3],
  14512. // Tuesday, Wednesday
  14513. 5: [3, 4],
  14514. // Wednesday, Thursday
  14515. 6: [4, 5],
  14516. // Thursday, Friday
  14517. 7: [5, 6],
  14518. // Friday, Saturday
  14519. 11: [0],
  14520. // Sunday only
  14521. 12: [1],
  14522. // Monday only
  14523. 13: [2],
  14524. // Tuesday only
  14525. 14: [3],
  14526. // Wednesday only
  14527. 15: [4],
  14528. // Thursday only
  14529. 16: [5],
  14530. // Friday only
  14531. 17: [6]
  14532. // Saturday only
  14533. };
  14534. function Ur(i) {
  14535. return !!(typeof i == "string" && /^[0|1]{7}/.test(i) || Cu[Number(i)]);
  14536. }
  14537. function _u(i) {
  14538. if (!Ur(i))
  14539. return [];
  14540. if (typeof i == "string" && /^[0|1]{7}/.test(i)) {
  14541. const a2 = [];
  14542. for (let e = 1; e <= i.length; e++)
  14543. `${i[e - 1]}` == "1" && (e === i.length ? a2.push(0) : a2.push(e));
  14544. return a2;
  14545. }
  14546. return Cu[Number(i)] || [];
  14547. }
  14548. function On(i, a2, e = 1, t) {
  14549. const r = _u(e), n = Math.floor(i), s = Math.floor(a2), o = s > n ? n : s;
  14550. let u = 0;
  14551. const c = Math.abs(Math.floor(a2) - Math.floor(i)) + 1;
  14552. for (let l2 = 0; l2 < c; l2++) {
  14553. const f2 = o + l2;
  14554. if (t && t.length > 0 && t.some((d2) => Math.floor(d2) === f2))
  14555. continue;
  14556. const h = rr(f2);
  14557. r.includes(h) || u++;
  14558. }
  14559. return s >= n ? u : -u;
  14560. }
  14561. function Mn(i, a2, e = 1, t) {
  14562. const r = _u(e), n = Math.floor(i);
  14563. let s = n, o = Math.abs(a2);
  14564. for (let u = 1; u <= o; u++) {
  14565. const c = a2 < 0 ? n - u : n + u;
  14566. if (c < 0)
  14567. return g2.create(m2.NUM);
  14568. if (t && t.length > 0 && t.some((f2) => Math.floor(f2) === c)) {
  14569. o++;
  14570. continue;
  14571. }
  14572. const l2 = rr(c);
  14573. if (r.includes(l2)) {
  14574. o++;
  14575. continue;
  14576. }
  14577. s = c;
  14578. }
  14579. return s;
  14580. }
  14581. function k(i) {
  14582. if (i.isError())
  14583. return i;
  14584. const a2 = i.getValue();
  14585. if (i.isString()) {
  14586. let e;
  14587. if (Xs(`${a2}`))
  14588. e = Xs(`${a2}`).v;
  14589. else if (Zs(`${a2}`))
  14590. e = Zs(`${a2}`).v;
  14591. else if (DC(a2))
  14592. e = +a2;
  14593. else
  14594. return g2.create(m2.VALUE);
  14595. return e instanceof Date && (e = Yr(e)), +e < 0 || +e > 2958465 ? g2.create(m2.NUM) : +e;
  14596. } else {
  14597. const e = +i.getValue();
  14598. return e < 0 || e > 2958465 ? g2.create(m2.NUM) : e;
  14599. }
  14600. }
  14601. function rr(i) {
  14602. const a2 = Math.floor(i) === 60;
  14603. let e = re2(i);
  14604. const t = new Date(Date.UTC(e.getFullYear(), e.getMonth(), e.getDate())).getTime(), r = new Date(Date.UTC(1900, 1, 28)).getTime();
  14605. return !a2 && t <= r && (e = new Date(t - 24 * 3600 * 1e3)), new Date(Date.UTC(e.getFullYear(), e.getMonth(), e.getDate())).getUTCDay();
  14606. }
  14607. function _e2(i, a2, e) {
  14608. switch (e) {
  14609. case 0:
  14610. return $m(i, a2);
  14611. case 1:
  14612. return Ym(i, a2);
  14613. case 2:
  14614. return {
  14615. days: Math.abs(a2 - i),
  14616. yearDays: 360
  14617. };
  14618. case 3:
  14619. return {
  14620. days: Math.abs(a2 - i),
  14621. yearDays: 365
  14622. };
  14623. case 4:
  14624. return Hm(i, a2);
  14625. default:
  14626. return {
  14627. days: Math.abs(a2 - i),
  14628. yearDays: 365
  14629. };
  14630. }
  14631. }
  14632. function $m(i, a2) {
  14633. const e = re2(i), t = i > 0 ? e.getUTCFullYear() : 1900, r = i > 0 ? e.getUTCMonth() + 1 : 1;
  14634. let n = i > 0 ? e.getUTCDate() : 0, s = re2(a2), o = a2 > 0 ? s.getUTCFullYear() : 1900, u = a2 > 0 ? s.getUTCMonth() + 1 : 1, c = a2 > 0 ? s.getUTCDate() : 0;
  14635. r === 2 ? re2(i + 1).getUTCMonth() + 1 === 3 && (n = 30) : n === 31 && (n = 30), c === 31 && (n < 30 ? (s = re2(a2 + 1), o = s.getUTCFullYear(), u = s.getUTCMonth() + 1, c = s.getUTCDate()) : c = 30);
  14636. const l2 = (o - t) * 360, f2 = a2 >= i ? 30 - n : -n, h = a2 >= i ? c : c - 30, d2 = (a2 >= i ? u - r - 1 : u - r + 1) * 30;
  14637. return {
  14638. days: Math.abs(l2 + f2 + h + d2),
  14639. yearDays: 360
  14640. };
  14641. }
  14642. function Ym(i, a2) {
  14643. const e = re2(i), t = i > 0 ? e.getUTCFullYear() : 1900, r = re2(a2), n = a2 > 0 ? r.getUTCFullYear() : 1900, s = Math.abs(a2 - i), o = Math.abs(n - t) + 1;
  14644. let u, c;
  14645. if (n < t) {
  14646. const l2 = new Date(Date.UTC(n, 0, 1)), f2 = new Date(Date.UTC(t, 11, 31));
  14647. u = ye2(l2), c = ye2(f2), n === 1900 && (u += 1);
  14648. } else {
  14649. const l2 = new Date(Date.UTC(t, 0, 1)), f2 = new Date(Date.UTC(n, 11, 31));
  14650. u = ye2(l2), c = ye2(f2), t === 1900 && (u += 1);
  14651. }
  14652. return {
  14653. days: s,
  14654. yearDays: (c - u + 1) / o
  14655. };
  14656. }
  14657. function Hm(i, a2) {
  14658. const e = re2(i), t = i > 0 ? e.getUTCFullYear() : 1900, r = i > 0 ? e.getUTCMonth() + 1 : 1;
  14659. let n = i > 0 ? e.getUTCDate() : 0;
  14660. const s = re2(a2), o = a2 > 0 ? s.getUTCFullYear() : 1900, u = a2 > 0 ? s.getUTCMonth() + 1 : 1;
  14661. let c = a2 > 0 ? s.getUTCDate() : 0;
  14662. n === 31 && (n = 30), c === 31 && (c = 30);
  14663. const l2 = (o - t) * 360, f2 = a2 >= i ? 30 - n : -n, h = a2 >= i ? c : c - 30, d2 = (a2 >= i ? u - r - 1 : u - r + 1) * 30;
  14664. return {
  14665. days: Math.abs(l2 + f2 + h + d2),
  14666. yearDays: 360
  14667. };
  14668. }
  14669. function Gm(i) {
  14670. return i % 4 === 0 && i % 100 !== 0 || i % 400 === 0;
  14671. }
  14672. function Qm(i) {
  14673. return i % 4 === 0 && i % 100 !== 0 || i % 400 === 0 || i === 1900;
  14674. }
  14675. var Wm = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
  14676. var qm = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
  14677. function Hr(i, a2) {
  14678. return Gm(i) ? Wm[a2] : qm[a2];
  14679. }
  14680. function Jn(i) {
  14681. return Qm(i) ? 366 : 365;
  14682. }
  14683. function Au(i, a2) {
  14684. switch (a2) {
  14685. case 0:
  14686. case 2:
  14687. case 4:
  14688. return 360;
  14689. case 1:
  14690. return Jn(re2(i).getUTCFullYear());
  14691. case 3:
  14692. return 365;
  14693. default:
  14694. return -1;
  14695. }
  14696. }
  14697. function Ar(i, a2, e) {
  14698. return Hr(i, a2) === e;
  14699. }
  14700. function Er(i, a2) {
  14701. let e = i.getUTCFullYear(), t = i.getUTCMonth();
  14702. const r = i.getUTCDate();
  14703. return Ar(e, t, r) ? (i.setUTCDate(1), i.setUTCMonth(i.getUTCMonth() + a2), e = i.getUTCFullYear(), t = i.getUTCMonth(), i.setUTCDate(Hr(e, t))) : i.setUTCMonth(i.getUTCMonth() + a2), i;
  14704. }
  14705. var Km = class extends V {
  14706. constructor() {
  14707. super(...arguments);
  14708. A(this, "minParams", 3);
  14709. A(this, "maxParams", 3);
  14710. }
  14711. calculate(e, t, r) {
  14712. if (e.isError())
  14713. return e;
  14714. if (t.isError())
  14715. return t;
  14716. if (r.isError())
  14717. return r;
  14718. const n = Math.max(
  14719. e.isArray() ? e.getRowCount() : 1,
  14720. t.isArray() ? t.getRowCount() : 1,
  14721. r.isArray() ? r.getRowCount() : 1
  14722. ), s = Math.max(
  14723. e.isArray() ? e.getColumnCount() : 1,
  14724. t.isArray() ? t.getColumnCount() : 1,
  14725. r.isArray() ? r.getColumnCount() : 1
  14726. ), o = O(n, s, e), u = O(n, s, t), c = O(n, s, r);
  14727. return o.map((l2, f2, h) => {
  14728. const d2 = u.get(f2, h) || ie.create(), _ = c.get(f2, h) || ie.create();
  14729. if (l2.isError())
  14730. return l2;
  14731. if (d2.isError())
  14732. return d2;
  14733. if (_.isError())
  14734. return _;
  14735. if (l2.isString() || d2.isString() || _.isString())
  14736. return g2.create(m2.VALUE);
  14737. let C = +l2.getValue();
  14738. const E2 = Math.floor(+d2.getValue()), b = +_.getValue();
  14739. if (C < 0 || C > 9999)
  14740. return g2.create(m2.NUM);
  14741. C >= 0 && C < 1899 && (C += 1900);
  14742. const R = new Date(C, E2 - 1, b), p2 = ye2(R);
  14743. return p2 < 0 ? g2.create(m2.NUM) : y2.create(p2, Ua);
  14744. });
  14745. }
  14746. };
  14747. var Xm = class extends V {
  14748. constructor() {
  14749. super(...arguments);
  14750. A(this, "minParams", 3);
  14751. A(this, "maxParams", 3);
  14752. }
  14753. calculate(e, t, r) {
  14754. let n = e, s = t, o = r;
  14755. if (n.isArray() && (n = n.get(0, 0)), s.isArray() && (s = s.get(0, 0)), o.isArray() && (o = o.get(0, 0)), n.isError())
  14756. return n;
  14757. if (s.isError())
  14758. return s;
  14759. if (o.isError())
  14760. return o;
  14761. const u = k(n);
  14762. if (typeof u != "number")
  14763. return u;
  14764. const c = k(s);
  14765. return typeof c != "number" ? c : c < u || !o.isString() ? g2.create(m2.NUM) : this._getResultByUnit(u, c, o);
  14766. }
  14767. _getResultByUnit(e, t, r) {
  14768. const n = re2(e), s = n.getUTCFullYear(), o = n.getUTCMonth() + 1, u = n.getUTCDate(), c = re2(t), l2 = c.getUTCFullYear(), f2 = c.getUTCMonth() + 1, h = c.getUTCDate(), d2 = `${r.getValue()}`.toLocaleUpperCase();
  14769. let _ = 0, C;
  14770. switch (d2) {
  14771. case "Y":
  14772. _ = l2 - s, (f2 < o || f2 === o && h < u) && (_ -= 1);
  14773. break;
  14774. case "M":
  14775. _ = (l2 - s) * 12 + f2 - o, h < u && (_ -= 1);
  14776. break;
  14777. case "D":
  14778. _ = Math.floor(t) - Math.floor(e);
  14779. break;
  14780. case "MD":
  14781. _ = h - u, h < u && (C = new Date(Date.UTC(l2, f2 - 1, 0)), _ += Hr(C.getUTCFullYear(), C.getUTCMonth()));
  14782. break;
  14783. case "YM":
  14784. _ = f2 - o, (f2 < o || f2 === o && h < u) && (_ += 12), h < u && (_ -= 1);
  14785. break;
  14786. case "YD":
  14787. C = new Date(Date.UTC(s, f2 - 1, h)), (f2 < o || f2 === o && h < u) && (C = new Date(Date.UTC(s + 1, f2 - 1, h))), _ = Math.floor(ye2(C)) - Math.floor(e);
  14788. break;
  14789. default:
  14790. return g2.create(m2.NUM);
  14791. }
  14792. return y2.create(_);
  14793. }
  14794. };
  14795. var Zm = class extends V {
  14796. constructor() {
  14797. super(...arguments);
  14798. A(this, "minParams", 1);
  14799. A(this, "maxParams", 1);
  14800. }
  14801. calculate(e) {
  14802. return e.isError() ? e : e.isArray() ? e.map((t) => this._handleSingleObject(t)) : this._handleSingleObject(e);
  14803. }
  14804. _handleSingleObject(e) {
  14805. if (e.isString()) {
  14806. const t = `${e.getValue()}`, r = du(t);
  14807. if (r) {
  14808. let { v: n, z: s } = r;
  14809. if (s && Ba(s))
  14810. return n instanceof Date && (n = Yr(n)), y2.create(Math.trunc(+n));
  14811. }
  14812. }
  14813. return g2.create(m2.VALUE);
  14814. }
  14815. };
  14816. var zm = class extends V {
  14817. constructor() {
  14818. super(...arguments);
  14819. A(this, "minParams", 1);
  14820. A(this, "maxParams", 1);
  14821. }
  14822. calculate(e) {
  14823. return e.isError() ? e : e.isArray() ? e.map((t) => this._handleSingleObject(t)) : this._handleSingleObject(e);
  14824. }
  14825. _handleSingleObject(e) {
  14826. let t;
  14827. const r = e.getValue();
  14828. if (e.isString()) {
  14829. if (!Ta(`${r}`))
  14830. return g2.create(m2.VALUE);
  14831. t = /* @__PURE__ */ new Date(`${r}`);
  14832. } else {
  14833. const o = +e.getValue();
  14834. if (o < 0)
  14835. return g2.create(m2.NUM);
  14836. if (o === 0)
  14837. return y2.create(0);
  14838. t = re2(o);
  14839. }
  14840. const n = t.getDate();
  14841. return y2.create(n);
  14842. }
  14843. };
  14844. var Jm = class extends V {
  14845. constructor() {
  14846. super(...arguments);
  14847. A(this, "minParams", 2);
  14848. A(this, "maxParams", 2);
  14849. }
  14850. calculate(e, t) {
  14851. if (e.isError())
  14852. return e;
  14853. if (t.isError())
  14854. return t;
  14855. const r = Math.max(
  14856. e.isArray() ? e.getRowCount() : 1,
  14857. t.isArray() ? t.getRowCount() : 1
  14858. ), n = Math.max(
  14859. e.isArray() ? e.getColumnCount() : 1,
  14860. t.isArray() ? t.getColumnCount() : 1
  14861. ), s = O(r, n, e), o = O(r, n, t), u = s.map((c, l2, f2) => {
  14862. const h = o.get(l2, f2);
  14863. if (c.isError())
  14864. return c;
  14865. if (h.isError())
  14866. return h;
  14867. const d2 = k(c);
  14868. if (typeof d2 != "number")
  14869. return d2;
  14870. const _ = k(h);
  14871. if (typeof _ != "number")
  14872. return _;
  14873. const C = Math.floor(d2) - Math.floor(_);
  14874. return y2.create(C);
  14875. });
  14876. return r === 1 && n === 1 ? u.get(0, 0) : u;
  14877. }
  14878. };
  14879. var eg = class extends V {
  14880. constructor() {
  14881. super(...arguments);
  14882. A(this, "minParams", 2);
  14883. A(this, "maxParams", 3);
  14884. }
  14885. calculate(e, t, r) {
  14886. const n = r != null ? r : T2.create(false);
  14887. if (e.isError())
  14888. return e;
  14889. if (t.isError())
  14890. return t;
  14891. if (n.isError())
  14892. return n;
  14893. const s = Math.max(
  14894. e.isArray() ? e.getRowCount() : 1,
  14895. t.isArray() ? t.getRowCount() : 1,
  14896. n.isArray() ? n.getRowCount() : 1
  14897. ), o = Math.max(
  14898. e.isArray() ? e.getColumnCount() : 1,
  14899. t.isArray() ? t.getColumnCount() : 1,
  14900. n.isArray() ? n.getColumnCount() : 1
  14901. ), u = O(s, o, e, g2.create(m2.NA)), c = O(s, o, t, g2.create(m2.NA)), l2 = O(s, o, n, g2.create(m2.NA)), f2 = u.map((h, d2, _) => {
  14902. const C = c.get(d2, _);
  14903. let E2 = l2.get(d2, _);
  14904. if (h.isError())
  14905. return h;
  14906. const b = k(h);
  14907. if (typeof b != "number")
  14908. return b;
  14909. if (C.isError())
  14910. return C;
  14911. const R = k(C);
  14912. if (typeof R != "number")
  14913. return R;
  14914. if (E2.isString() && (E2 = E2.convertToNumberObjectValue()), E2.isError())
  14915. return E2;
  14916. const p2 = +E2.getValue(), { days: N2 } = _e2(b, R, p2 ? 4 : 0), M2 = R >= b ? N2 : -N2;
  14917. return y2.create(M2);
  14918. });
  14919. return s === 1 && o === 1 ? f2.get(0, 0) : f2;
  14920. }
  14921. };
  14922. var tg = class extends V {
  14923. constructor() {
  14924. super(...arguments);
  14925. A(this, "minParams", 2);
  14926. A(this, "maxParams", 2);
  14927. }
  14928. calculate(e, t) {
  14929. if (e.isError())
  14930. return e;
  14931. if (t.isError())
  14932. return t;
  14933. const r = Math.max(
  14934. e.isArray() ? e.getRowCount() : 1,
  14935. t.isArray() ? t.getRowCount() : 1
  14936. ), n = Math.max(
  14937. e.isArray() ? e.getColumnCount() : 1,
  14938. t.isArray() ? t.getColumnCount() : 1
  14939. ), s = O(r, n, e), o = O(r, n, t);
  14940. return s.map((u, c, l2) => {
  14941. const f2 = o.get(c, l2) || ie.create();
  14942. if (u.isError())
  14943. return u;
  14944. if (f2.isError())
  14945. return f2;
  14946. if (u.isString() || u.isBoolean() || f2.isString() || f2.isBoolean())
  14947. return g2.create(m2.VALUE);
  14948. const h = +u.getValue();
  14949. if (h < 0)
  14950. return g2.create(m2.NUM);
  14951. const d2 = Math.floor(+f2.getValue()), _ = re2(h), C = _.getUTCFullYear(), E2 = _.getUTCMonth() + d2, b = _.getUTCDate(), R = new Date(Date.UTC(C, E2, b)), p2 = ye2(R);
  14952. return y2.create(p2, Ua);
  14953. });
  14954. }
  14955. };
  14956. var rg = class extends V {
  14957. constructor() {
  14958. super(...arguments);
  14959. A(this, "minParams", 2);
  14960. A(this, "maxParams", 2);
  14961. }
  14962. calculate(e, t) {
  14963. let r = e, n = t;
  14964. if (r.isArray()) {
  14965. const d2 = r.getRowCount(), _ = r.getColumnCount();
  14966. if (d2 > 1 || _ > 1)
  14967. return g2.create(m2.VALUE);
  14968. r = r.get(0, 0);
  14969. }
  14970. if (n.isArray()) {
  14971. const d2 = n.getRowCount(), _ = n.getColumnCount();
  14972. if (d2 > 1 || _ > 1)
  14973. return g2.create(m2.VALUE);
  14974. n = n.get(0, 0);
  14975. }
  14976. if (r.isError())
  14977. return r;
  14978. if (n.isError())
  14979. return n;
  14980. const s = k(r);
  14981. if (typeof s != "number")
  14982. return s;
  14983. if (n.isBoolean())
  14984. return g2.create(m2.VALUE);
  14985. const o = re2(s), u = s > 0 ? o.getUTCFullYear() : 1900, c = s > 0 ? o.getUTCMonth() : 0, l2 = Math.floor(+n.getValue());
  14986. if (Number.isNaN(l2))
  14987. return g2.create(m2.VALUE);
  14988. const f2 = new Date(Date.UTC(u, c + l2 + 1, 0)), h = ye2(f2);
  14989. return y2.create(h);
  14990. }
  14991. };
  14992. var ng = class extends V {
  14993. constructor() {
  14994. super(...arguments);
  14995. A(this, "minParams", 1);
  14996. A(this, "maxParams", 2);
  14997. A(this, "needsReferenceObject", true);
  14998. }
  14999. calculate(e, t) {
  15000. const r = t != null ? t : y2.create(1), { isError: n, errorObject: s, timestampIsReferenceObject: o, timestampObject: u, unitObject: c } = this._checkVariants(e, r);
  15001. if (n)
  15002. return s;
  15003. if (u.isNull() || u.isBoolean() || u.isString() || !o && u.isNumber() && u.getPattern() !== "")
  15004. return g2.create(m2.VALUE);
  15005. let l2 = +u.getValue();
  15006. const { isError: f2, errorObject: h, variants: d2 } = I2(c);
  15007. if (f2)
  15008. return h;
  15009. const [_] = d2, C = Math.floor(+_.getValue());
  15010. if (l2 < 0 || C < 1 || C > 3)
  15011. return g2.create(m2.NUM);
  15012. C === 1 && (l2 = l2 * 1e3), C === 3 && (l2 = l2 / 1e3);
  15013. const E2 = new Date(Date.UTC(1970, 0, 1, 0, 0, 0, 0) + l2);
  15014. if (Number.isNaN(E2.getTime())) {
  15015. const b = 25569 + l2 / 864e5;
  15016. return y2.create(b);
  15017. } else {
  15018. const b = Yr(E2);
  15019. return y2.create(b, "yyyy-MM-dd AM/PM hh:mm:ss");
  15020. }
  15021. }
  15022. _checkVariants(e, t) {
  15023. const r = e.isReferenceObject(), n = t.isReferenceObject();
  15024. let s = e;
  15025. if (r && (s = e.toArrayValueObject()), s.isArray()) {
  15026. const u = s.getRowCount(), c = s.getColumnCount();
  15027. if (u > 1 || c > 1)
  15028. return {
  15029. isError: true,
  15030. errorObject: g2.create(m2.VALUE)
  15031. };
  15032. s = s.get(0, 0);
  15033. }
  15034. if (s.isError())
  15035. return {
  15036. isError: true,
  15037. errorObject: s
  15038. };
  15039. let o = t;
  15040. if (n && (o = t.toArrayValueObject()), o.isArray()) {
  15041. const u = o.getRowCount(), c = o.getColumnCount();
  15042. if (u > 1 || c > 1)
  15043. return {
  15044. isError: true,
  15045. errorObject: g2.create(m2.VALUE)
  15046. };
  15047. o = o.get(0, 0);
  15048. }
  15049. return o.isError() ? {
  15050. isError: true,
  15051. errorObject: o
  15052. } : {
  15053. isError: false,
  15054. errorObject: null,
  15055. timestampIsReferenceObject: r,
  15056. timestampObject: s,
  15057. unitIsReferenceObject: n,
  15058. unitObject: o
  15059. };
  15060. }
  15061. };
  15062. var be2 = ((i) => (i.DATE = "DATE", i.DATEDIF = "DATEDIF", i.DATEVALUE = "DATEVALUE", i.DAY = "DAY", i.DAYS = "DAYS", i.DAYS360 = "DAYS360", i.EDATE = "EDATE", i.EOMONTH = "EOMONTH", i.EPOCHTODATE = "EPOCHTODATE", i.HOUR = "HOUR", i.ISOWEEKNUM = "ISOWEEKNUM", i.MINUTE = "MINUTE", i.MONTH = "MONTH", i.NETWORKDAYS = "NETWORKDAYS", i.NETWORKDAYS_INTL = "NETWORKDAYS.INTL", i.NOW = "NOW", i.SECOND = "SECOND", i.TIME = "TIME", i.TIMEVALUE = "TIMEVALUE", i.TO_DATE = "TO_DATE", i.TODAY = "TODAY", i.WEEKDAY = "WEEKDAY", i.WEEKNUM = "WEEKNUM", i.WORKDAY = "WORKDAY", i.WORKDAY_INTL = "WORKDAY.INTL", i.YEAR = "YEAR", i.YEARFRAC = "YEARFRAC", i))(be2 || {});
  15063. var sg = class extends V {
  15064. constructor() {
  15065. super(...arguments);
  15066. A(this, "minParams", 1);
  15067. A(this, "maxParams", 1);
  15068. }
  15069. calculate(e) {
  15070. return e.isError() ? e : e.isArray() ? e.map((t) => t.isError() ? t : this._handleSingleObject(t)) : this._handleSingleObject(e);
  15071. }
  15072. _handleSingleObject(e) {
  15073. const t = k(e);
  15074. if (typeof t != "number")
  15075. return t;
  15076. if (t === 0)
  15077. return y2.create(0);
  15078. const n = va(t).getUTCHours();
  15079. return y2.create(n);
  15080. }
  15081. };
  15082. var ag = class extends V {
  15083. constructor() {
  15084. super(...arguments);
  15085. A(this, "minParams", 1);
  15086. A(this, "maxParams", 1);
  15087. }
  15088. calculate(e) {
  15089. return e.isError() ? e : e.isArray() ? e.map((t) => t.isError() ? t : this._handleSingleObject(t)) : this._handleSingleObject(e);
  15090. }
  15091. _handleSingleObject(e) {
  15092. const t = k(e);
  15093. if (typeof t != "number")
  15094. return t;
  15095. const r = re2(t), n = t > 0 ? r.getUTCFullYear() : 1900;
  15096. let s = new Date(Date.UTC(n, 0, 1)), o = ye2(s), u = rr(o), c;
  15097. u < 1 ? c = o + 1 : u <= 4 ? c = o - (u - 1) : c = o + (11 - u), t < c && (s = new Date(Date.UTC(n - 1, 0, 1)), o = ye2(s), u = rr(o), u < 1 ? c = o + 1 : u <= 4 ? c = o - (u - 1) : c = o + (11 - u));
  15098. const l2 = Math.ceil((t - c + 1) / 7);
  15099. return y2.create(l2);
  15100. }
  15101. };
  15102. var ig = class extends V {
  15103. constructor() {
  15104. super(...arguments);
  15105. A(this, "minParams", 1);
  15106. A(this, "maxParams", 1);
  15107. }
  15108. calculate(e) {
  15109. return e.isError() ? e : e.isArray() ? e.map((t) => t.isError() ? t : this._handleSingleObject(t)) : this._handleSingleObject(e);
  15110. }
  15111. _handleSingleObject(e) {
  15112. const t = k(e);
  15113. if (typeof t != "number")
  15114. return t;
  15115. if (t === 0)
  15116. return y2.create(0);
  15117. const n = va(t).getUTCMinutes();
  15118. return y2.create(n);
  15119. }
  15120. };
  15121. var og = class extends V {
  15122. constructor() {
  15123. super(...arguments);
  15124. A(this, "minParams", 1);
  15125. A(this, "maxParams", 1);
  15126. }
  15127. calculate(e) {
  15128. return e.isArray() ? e.map((t) => this._handleSingleObject(t)) : this._handleSingleObject(e);
  15129. }
  15130. _handleSingleObject(e) {
  15131. if (e.isError())
  15132. return e;
  15133. let t;
  15134. const r = e.getValue();
  15135. if (e.isString()) {
  15136. if (!Ta(`${r}`))
  15137. return g2.create(m2.VALUE);
  15138. t = /* @__PURE__ */ new Date(`${r}`);
  15139. } else {
  15140. const o = +e.getValue();
  15141. if (o < 0)
  15142. return g2.create(m2.NUM);
  15143. if (o === 0)
  15144. return y2.create(1);
  15145. t = re2(o);
  15146. }
  15147. const n = t.getUTCMonth() + 1;
  15148. return y2.create(n);
  15149. }
  15150. };
  15151. var ug = class extends V {
  15152. constructor() {
  15153. super(...arguments);
  15154. A(this, "minParams", 2);
  15155. A(this, "maxParams", 3);
  15156. }
  15157. calculate(e, t, r) {
  15158. let n = e, s = t;
  15159. if (n.isArray()) {
  15160. const l2 = n.getRowCount(), f2 = n.getColumnCount();
  15161. if (l2 > 1 || f2 > 1)
  15162. return g2.create(m2.VALUE);
  15163. n = n.get(0, 0);
  15164. }
  15165. if (n.isError())
  15166. return n;
  15167. if (s.isArray()) {
  15168. const l2 = s.getRowCount(), f2 = s.getColumnCount();
  15169. if (l2 > 1 || f2 > 1)
  15170. return g2.create(m2.VALUE);
  15171. s = s.get(0, 0);
  15172. }
  15173. if (s.isError())
  15174. return s;
  15175. if (r != null && r.isError())
  15176. return r;
  15177. if (n.isBoolean() || s.isBoolean())
  15178. return g2.create(m2.VALUE);
  15179. const o = k(n);
  15180. if (typeof o != "number")
  15181. return o;
  15182. const u = k(s);
  15183. if (typeof u != "number")
  15184. return u;
  15185. if (r)
  15186. return this._getResultByHolidays(o, u, r);
  15187. const c = On(o, u);
  15188. return y2.create(c);
  15189. }
  15190. _getResultByHolidays(e, t, r) {
  15191. const n = [];
  15192. if (r != null && r.isArray()) {
  15193. const o = r.getRowCount(), u = r.getColumnCount();
  15194. for (let c = 0; c < o; c++)
  15195. for (let l2 = 0; l2 < u; l2++) {
  15196. const f2 = r.get(c, l2);
  15197. if (f2.isBoolean())
  15198. return g2.create(m2.VALUE);
  15199. const h = k(f2);
  15200. if (typeof h != "number")
  15201. return h;
  15202. n.push(h);
  15203. }
  15204. } else {
  15205. if (r.isBoolean())
  15206. return g2.create(m2.VALUE);
  15207. const o = k(r);
  15208. if (typeof o != "number")
  15209. return o;
  15210. n.push(o);
  15211. }
  15212. const s = On(e, t, 1, n);
  15213. return y2.create(s);
  15214. }
  15215. };
  15216. var cg = class extends V {
  15217. constructor() {
  15218. super(...arguments);
  15219. A(this, "minParams", 2);
  15220. A(this, "maxParams", 4);
  15221. }
  15222. calculate(e, t, r, n) {
  15223. return e.isError() ? e : t.isError() ? t : r != null && r.isError() ? r : n != null && n.isError() ? n : r != null && r.isArray() ? r.map((s) => this._handleSingleObject(e, t, s, n)) : this._handleSingleObject(e, t, r, n);
  15224. }
  15225. _handleSingleObject(e, t, r, n) {
  15226. let s = e, o = t;
  15227. if (s.isArray()) {
  15228. const h = s.getRowCount(), d2 = s.getColumnCount();
  15229. if (h > 1 || d2 > 1)
  15230. return g2.create(m2.VALUE);
  15231. s = s.get(0, 0);
  15232. }
  15233. if (s.isError())
  15234. return s;
  15235. if (o.isArray()) {
  15236. const h = o.getRowCount(), d2 = o.getColumnCount();
  15237. if (h > 1 || d2 > 1)
  15238. return g2.create(m2.VALUE);
  15239. o = o.get(0, 0);
  15240. }
  15241. if (o.isError())
  15242. return o;
  15243. let u = 1;
  15244. if (r) {
  15245. if (u = r.getValue(), r.isBoolean() && (u = +u), r.isString() && !Ur(u))
  15246. return g2.create(m2.VALUE);
  15247. if (!Ur(u))
  15248. return g2.create(m2.NUM);
  15249. }
  15250. if (s.isBoolean() || o.isBoolean())
  15251. return g2.create(m2.VALUE);
  15252. const c = k(s);
  15253. if (typeof c != "number")
  15254. return c;
  15255. const l2 = k(o);
  15256. if (typeof l2 != "number")
  15257. return l2;
  15258. if (n)
  15259. return this._getResultByHolidays(c, l2, u, n);
  15260. const f2 = On(c, l2, u);
  15261. return y2.create(f2);
  15262. }
  15263. _getResultByHolidays(e, t, r, n) {
  15264. const s = [];
  15265. if (n != null && n.isArray()) {
  15266. const u = n.getRowCount(), c = n.getColumnCount();
  15267. for (let l2 = 0; l2 < u; l2++)
  15268. for (let f2 = 0; f2 < c; f2++) {
  15269. const h = n.get(l2, f2);
  15270. if (h.isBoolean())
  15271. return g2.create(m2.VALUE);
  15272. const d2 = k(h);
  15273. if (typeof d2 != "number")
  15274. return d2;
  15275. s.push(d2);
  15276. }
  15277. } else {
  15278. if (n.isBoolean())
  15279. return g2.create(m2.VALUE);
  15280. const u = k(n);
  15281. if (typeof u != "number")
  15282. return u;
  15283. s.push(u);
  15284. }
  15285. const o = On(e, t, r, s);
  15286. return y2.create(o);
  15287. }
  15288. };
  15289. var lg = class extends V {
  15290. constructor() {
  15291. super(...arguments);
  15292. A(this, "minParams", 0);
  15293. A(this, "maxParams", 0);
  15294. }
  15295. calculate() {
  15296. const e = /* @__PURE__ */ new Date(), t = new Date(Date.UTC(e.getFullYear(), e.getMonth(), e.getDate(), e.getHours(), e.getMinutes(), e.getSeconds())), r = Yr(t);
  15297. return y2.create(r, Fm);
  15298. }
  15299. };
  15300. var fg = class extends V {
  15301. constructor() {
  15302. super(...arguments);
  15303. A(this, "minParams", 1);
  15304. A(this, "maxParams", 1);
  15305. }
  15306. calculate(e) {
  15307. return e.isError() ? e : e.isArray() ? e.map((t) => t.isError() ? t : this._handleSingleObject(t)) : this._handleSingleObject(e);
  15308. }
  15309. _handleSingleObject(e) {
  15310. const t = k(e);
  15311. if (typeof t != "number")
  15312. return t;
  15313. if (t === 0)
  15314. return y2.create(0);
  15315. const n = va(t).getUTCSeconds();
  15316. return y2.create(n);
  15317. }
  15318. };
  15319. var hg = class extends V {
  15320. constructor() {
  15321. super(...arguments);
  15322. A(this, "minParams", 3);
  15323. A(this, "maxParams", 3);
  15324. }
  15325. calculate(e, t, r) {
  15326. if (e.isError())
  15327. return e;
  15328. if (t.isError())
  15329. return t;
  15330. if (r.isError())
  15331. return r;
  15332. const n = Math.max(
  15333. e.isArray() ? e.getRowCount() : 1,
  15334. t.isArray() ? t.getRowCount() : 1,
  15335. r.isArray() ? r.getRowCount() : 1
  15336. ), s = Math.max(
  15337. e.isArray() ? e.getColumnCount() : 1,
  15338. t.isArray() ? t.getColumnCount() : 1,
  15339. r.isArray() ? r.getColumnCount() : 1
  15340. ), o = O(n, s, e), u = O(n, s, t), c = O(n, s, r);
  15341. return o.map((l2, f2, h) => this._calculateTime(l2, u, c, f2, h));
  15342. }
  15343. _calculateTime(e, t, r, n, s) {
  15344. let o = e, u = t.get(n, s) || ie.create(), c = r.get(n, s) || ie.create();
  15345. if ((o.isString() || o.isBoolean()) && (o = o.convertToNumberObjectValue()), (u.isString() || u.isBoolean()) && (u = u.convertToNumberObjectValue()), (c.isString() || c.isBoolean()) && (c = c.convertToNumberObjectValue()), o.isError())
  15346. return o;
  15347. if (u.isError())
  15348. return u;
  15349. if (c.isError())
  15350. return c;
  15351. let l2 = Math.floor(+o.getValue()), f2 = Math.floor(+u.getValue()), h = Math.floor(+c.getValue());
  15352. if (l2 < 0 || f2 < 0 || h < 0 || l2 > 32767 || f2 > 32767 || h > 32767)
  15353. return g2.create(m2.NUM);
  15354. f2 += Math.floor(h / 60), h %= 60, l2 += Math.floor(f2 / 60), f2 %= 60, l2 %= 24;
  15355. const _ = (l2 * 3600 + f2 * 60 + h) / 86400;
  15356. return y2.create(_, km);
  15357. }
  15358. };
  15359. var mg = class extends V {
  15360. constructor() {
  15361. super(...arguments);
  15362. A(this, "minParams", 1);
  15363. A(this, "maxParams", 1);
  15364. }
  15365. calculate(e) {
  15366. return e.isError() ? e : e.isArray() ? e.map((t) => this._handleSingleObject(t)) : this._handleSingleObject(e);
  15367. }
  15368. _handleSingleObject(e) {
  15369. if (e.isString()) {
  15370. const t = `${e.getValue()}`, r = du(t);
  15371. if (r) {
  15372. let { v: n, z: s } = r;
  15373. if (s && Ba(s))
  15374. return n instanceof Date && (n = Yr(n)), y2.create(Af(+n));
  15375. }
  15376. }
  15377. return g2.create(m2.VALUE);
  15378. }
  15379. };
  15380. var gg = class extends V {
  15381. constructor() {
  15382. super(...arguments);
  15383. A(this, "minParams", 1);
  15384. A(this, "maxParams", 1);
  15385. A(this, "needsReferenceObject", true);
  15386. }
  15387. calculate(e) {
  15388. const t = e.isReferenceObject();
  15389. let r = e;
  15390. if (t && (r = e.toArrayValueObject()), r.isArray()) {
  15391. const s = r.getRowCount(), o = r.getColumnCount();
  15392. if (s > 1 || o > 1)
  15393. return g2.create(m2.VALUE);
  15394. r = r.get(0, 0);
  15395. }
  15396. if (r.isError() || r.isNull() || r.isBoolean() || r.isString() || !t && r.isNumber() && r.getPattern() !== "")
  15397. return r;
  15398. const n = +r.getValue();
  15399. return y2.create(n, "yyyy-MM-dd hh:mm:ss AM/PM");
  15400. }
  15401. };
  15402. var dg = class extends V {
  15403. constructor() {
  15404. super(...arguments);
  15405. A(this, "minParams", 0);
  15406. A(this, "maxParams", 0);
  15407. }
  15408. calculate() {
  15409. const e = ye2(/* @__PURE__ */ new Date());
  15410. return y2.create(e, Ua);
  15411. }
  15412. };
  15413. var Cg = class extends V {
  15414. constructor() {
  15415. super(...arguments);
  15416. A(this, "minParams", 1);
  15417. A(this, "maxParams", 2);
  15418. A(this, "_returnTypeMap", {
  15419. 1: [1, 2, 3, 4, 5, 6, 7],
  15420. // Sunday = 1 ~ Saturday = 7
  15421. 2: [7, 1, 2, 3, 4, 5, 6],
  15422. // Monday = 1 ~ Sunday = 7
  15423. 3: [6, 0, 1, 2, 3, 4, 5],
  15424. // Monday = 0 ~ Sunday = 6
  15425. 11: [7, 1, 2, 3, 4, 5, 6],
  15426. // Monday = 1 ~ Sunday = 7
  15427. 12: [6, 7, 1, 2, 3, 4, 5],
  15428. // Tuesday = 1 ~ Monday = 7
  15429. 13: [5, 6, 7, 1, 2, 3, 4],
  15430. // Wednesday = 1 ~ Tuesday = 7
  15431. 14: [4, 5, 6, 7, 1, 2, 3],
  15432. // Thursday = 1 ~ Wednesday = 7
  15433. 15: [3, 4, 5, 6, 7, 1, 2],
  15434. // Friday = 1 ~ Thursday = 7
  15435. 16: [2, 3, 4, 5, 6, 7, 1],
  15436. // Saturday = 1 ~ Friday = 7
  15437. 17: [1, 2, 3, 4, 5, 6, 7]
  15438. // Sunday = 1 ~ Saturday = 7
  15439. });
  15440. }
  15441. calculate(e, t) {
  15442. const r = t != null ? t : y2.create(1);
  15443. if (e.isError())
  15444. return e;
  15445. if (r.isError())
  15446. return r;
  15447. const n = Math.max(
  15448. e.isArray() ? e.getRowCount() : 1,
  15449. r.isArray() ? r.getRowCount() : 1
  15450. ), s = Math.max(
  15451. e.isArray() ? e.getColumnCount() : 1,
  15452. r.isArray() ? r.getColumnCount() : 1
  15453. ), o = O(n, s, e, g2.create(m2.NA)), u = O(n, s, r, g2.create(m2.NA)), c = o.map((l2, f2, h) => {
  15454. const d2 = u.get(f2, h);
  15455. return this._handleSingleObject(l2, d2);
  15456. });
  15457. return n === 1 && s === 1 ? c.get(0, 0) : c;
  15458. }
  15459. _handleSingleObject(e, t) {
  15460. let r = t;
  15461. if (e.isError())
  15462. return e;
  15463. if (r.isError())
  15464. return r;
  15465. const n = k(e);
  15466. if (typeof n != "number")
  15467. return n;
  15468. if (r.isString() && (r = r.convertToNumberObjectValue(), r.isError()))
  15469. return r;
  15470. const s = Math.floor(+r.getValue());
  15471. if (!this._returnTypeMap[s])
  15472. return g2.create(m2.NUM);
  15473. const o = rr(n), u = this._returnTypeMap[s][o];
  15474. return y2.create(u);
  15475. }
  15476. };
  15477. var _g = class extends V {
  15478. constructor() {
  15479. super(...arguments);
  15480. A(this, "minParams", 1);
  15481. A(this, "maxParams", 2);
  15482. A(this, "_returnTypeMap", {
  15483. 1: 0,
  15484. 2: 1,
  15485. 11: 1,
  15486. 12: 2,
  15487. 13: 3,
  15488. 14: 4,
  15489. 15: 5,
  15490. 16: 6,
  15491. 17: 0,
  15492. 21: 4
  15493. });
  15494. }
  15495. calculate(e, t) {
  15496. let r = e, n = t != null ? t : y2.create(1);
  15497. if (r.isArray()) {
  15498. const u = r.getRowCount(), c = r.getColumnCount();
  15499. if (u > 1 || c > 1)
  15500. return g2.create(m2.VALUE);
  15501. r = r.get(0, 0);
  15502. }
  15503. if (r.isError())
  15504. return r;
  15505. if (n.isArray()) {
  15506. const u = n.getRowCount(), c = n.getColumnCount();
  15507. if (u > 1 || c > 1)
  15508. return g2.create(m2.VALUE);
  15509. n = n.get(0, 0);
  15510. }
  15511. if (n.isError())
  15512. return n;
  15513. if (r.isBoolean())
  15514. return g2.create(m2.VALUE);
  15515. const s = k(r);
  15516. if (typeof s != "number")
  15517. return s;
  15518. if (n.isBoolean())
  15519. return g2.create(m2.VALUE);
  15520. const o = Math.floor(+n.getValue());
  15521. return Number.isNaN(o) ? g2.create(m2.VALUE) : o in this._returnTypeMap ? this._getResult(s, o) : g2.create(m2.NUM);
  15522. }
  15523. _getResult(e, t) {
  15524. const r = re2(e), n = e > 0 ? r.getUTCFullYear() : 1900;
  15525. let s = new Date(Date.UTC(n, 0, 1)), o = ye2(s), u = rr(o), c;
  15526. if (t === 21)
  15527. u < 1 ? c = o + 1 : u <= 4 ? c = o - (u - 1) : c = o + (11 - u), e < c && (s = new Date(Date.UTC(n - 1, 0, 1)), o = ye2(s), u = rr(o), u < 1 ? c = o + 1 : u <= 4 ? c = o - (u - 1) : c = o + (11 - u));
  15528. else {
  15529. const f2 = this._returnTypeMap[t];
  15530. u < f2 ? c = o - (u + 7 - f2) : c = o - (u - f2);
  15531. }
  15532. const l2 = Math.ceil((e - c + 1) / 7);
  15533. return y2.create(l2);
  15534. }
  15535. };
  15536. var Ag = class extends V {
  15537. constructor() {
  15538. super(...arguments);
  15539. A(this, "minParams", 2);
  15540. A(this, "maxParams", 3);
  15541. }
  15542. calculate(e, t, r) {
  15543. let n = e, s = t;
  15544. if (n.isArray()) {
  15545. const l2 = n.getRowCount(), f2 = n.getColumnCount();
  15546. if (l2 > 1 || f2 > 1)
  15547. return g2.create(m2.VALUE);
  15548. n = n.get(0, 0);
  15549. }
  15550. if (n.isError())
  15551. return n;
  15552. if (s.isArray()) {
  15553. const l2 = s.getRowCount(), f2 = s.getColumnCount();
  15554. if (l2 > 1 || f2 > 1)
  15555. return g2.create(m2.VALUE);
  15556. s = s.get(0, 0);
  15557. }
  15558. if (s.isError())
  15559. return s;
  15560. if (r != null && r.isError())
  15561. return r;
  15562. if (n.isBoolean() || s.isBoolean())
  15563. return g2.create(m2.VALUE);
  15564. const o = k(n);
  15565. if (typeof o != "number")
  15566. return o;
  15567. const u = +s.getValue();
  15568. if (Number.isNaN(u))
  15569. return g2.create(m2.VALUE);
  15570. if (r)
  15571. return this._getResultByHolidays(o, u, r);
  15572. const c = Mn(o, u);
  15573. return typeof c != "number" ? c : y2.create(c);
  15574. }
  15575. _getResultByHolidays(e, t, r) {
  15576. const n = [];
  15577. if (r != null && r.isArray()) {
  15578. const o = r.getRowCount(), u = r.getColumnCount();
  15579. for (let c = 0; c < o; c++)
  15580. for (let l2 = 0; l2 < u; l2++) {
  15581. const f2 = r.get(c, l2);
  15582. if (f2.isBoolean())
  15583. return g2.create(m2.VALUE);
  15584. const h = k(f2);
  15585. if (typeof h != "number")
  15586. return h;
  15587. n.push(h);
  15588. }
  15589. } else {
  15590. if (r.isBoolean())
  15591. return g2.create(m2.VALUE);
  15592. const o = k(r);
  15593. if (typeof o != "number")
  15594. return o;
  15595. n.push(o);
  15596. }
  15597. const s = Mn(e, t, 1, n);
  15598. return typeof s != "number" ? s : y2.create(s);
  15599. }
  15600. };
  15601. var Eg = class extends V {
  15602. constructor() {
  15603. super(...arguments);
  15604. A(this, "minParams", 2);
  15605. A(this, "maxParams", 4);
  15606. }
  15607. calculate(e, t, r, n) {
  15608. return e.isError() ? e : t.isError() ? t : r != null && r.isError() ? r : n != null && n.isError() ? n : r != null && r.isArray() ? r.map((s) => this._handleSingleObject(e, t, s, n)) : this._handleSingleObject(e, t, r, n);
  15609. }
  15610. _handleSingleObject(e, t, r, n) {
  15611. const s = r != null ? r : y2.create(1), o = this._checkArrayError(e);
  15612. if (o.isError())
  15613. return o;
  15614. const u = this._checkArrayError(t);
  15615. if (u.isError())
  15616. return u;
  15617. if (o.isBoolean() || u.isBoolean())
  15618. return g2.create(m2.VALUE);
  15619. const c = k(e);
  15620. if (typeof c != "number")
  15621. return c;
  15622. const l2 = +t.getValue();
  15623. if (Number.isNaN(l2))
  15624. return g2.create(m2.VALUE);
  15625. let f2 = s.getValue();
  15626. if (s.isBoolean() && (f2 = +f2), s.isString() && (!Ur(f2) || f2 === "1111111"))
  15627. return g2.create(m2.VALUE);
  15628. if (!Ur(f2))
  15629. return g2.create(m2.NUM);
  15630. if (n)
  15631. return this._getResultByHolidays(c, l2, f2, n);
  15632. const h = Mn(c, l2, f2);
  15633. return typeof h != "number" ? h : y2.create(h);
  15634. }
  15635. _checkArrayError(e) {
  15636. let t = e;
  15637. if (t.isArray()) {
  15638. const r = t.getRowCount(), n = t.getColumnCount();
  15639. if (r > 1 || n > 1)
  15640. return g2.create(m2.VALUE);
  15641. t = t.get(0, 0);
  15642. }
  15643. return t.isError(), t;
  15644. }
  15645. _getResultByHolidays(e, t, r, n) {
  15646. const s = [];
  15647. if (n != null && n.isArray()) {
  15648. const u = n.getRowCount(), c = n.getColumnCount();
  15649. for (let l2 = 0; l2 < u; l2++)
  15650. for (let f2 = 0; f2 < c; f2++) {
  15651. const h = n.get(l2, f2);
  15652. if (h.isBoolean())
  15653. return g2.create(m2.VALUE);
  15654. const d2 = k(h);
  15655. if (typeof d2 != "number")
  15656. return d2;
  15657. s.push(d2);
  15658. }
  15659. } else {
  15660. if (n.isBoolean())
  15661. return g2.create(m2.VALUE);
  15662. const u = k(n);
  15663. if (typeof u != "number")
  15664. return u;
  15665. s.push(u);
  15666. }
  15667. const o = Mn(e, t, r, s);
  15668. return typeof o != "number" ? o : y2.create(o);
  15669. }
  15670. };
  15671. var bg = class extends V {
  15672. constructor() {
  15673. super(...arguments);
  15674. A(this, "minParams", 1);
  15675. A(this, "maxParams", 1);
  15676. }
  15677. calculate(e) {
  15678. return e.isArray() ? e.map((t) => this._handleSingleObject(t)) : this._handleSingleObject(e);
  15679. }
  15680. _handleSingleObject(e) {
  15681. if (e.isError())
  15682. return e;
  15683. let t;
  15684. const r = e.getValue();
  15685. if (e.isString()) {
  15686. if (!Ta(`${r}`))
  15687. return g2.create(m2.VALUE);
  15688. t = /* @__PURE__ */ new Date(`${r}`);
  15689. } else {
  15690. const o = +r;
  15691. if (o < 0)
  15692. return g2.create(m2.NUM);
  15693. if (o === 0)
  15694. return y2.create(1900);
  15695. t = re2(o);
  15696. }
  15697. const n = t.getUTCFullYear();
  15698. return y2.create(n);
  15699. }
  15700. };
  15701. var yg = class extends V {
  15702. constructor() {
  15703. super(...arguments);
  15704. A(this, "minParams", 2);
  15705. A(this, "maxParams", 3);
  15706. }
  15707. calculate(e, t, r) {
  15708. let n = r != null ? r : y2.create(0);
  15709. const s = Xt(e);
  15710. if (s.isError())
  15711. return s;
  15712. const o = Xt(t);
  15713. if (o.isError())
  15714. return o;
  15715. if (n = Xt(n), n.isError())
  15716. return n;
  15717. if (s.isBoolean() || o.isBoolean() || n.isBoolean())
  15718. return g2.create(m2.VALUE);
  15719. const u = k(s);
  15720. if (typeof u != "number")
  15721. return u;
  15722. const c = k(o);
  15723. if (typeof c != "number")
  15724. return c;
  15725. const l2 = Math.floor(+n.getValue());
  15726. if (Number.isNaN(l2))
  15727. return g2.create(m2.VALUE);
  15728. if (l2 < 0 || l2 > 4)
  15729. return g2.create(m2.NUM);
  15730. const { days: f2, yearDays: h } = _e2(u, c, l2), d2 = f2 / h;
  15731. return y2.create(d2);
  15732. }
  15733. };
  15734. var Rg = [
  15735. [Km, be2.DATE],
  15736. [Xm, be2.DATEDIF],
  15737. [Zm, be2.DATEVALUE],
  15738. [zm, be2.DAY],
  15739. [Jm, be2.DAYS],
  15740. [eg, be2.DAYS360],
  15741. [tg, be2.EDATE],
  15742. [rg, be2.EOMONTH],
  15743. [ng, be2.EPOCHTODATE],
  15744. [sg, be2.HOUR],
  15745. [ag, be2.ISOWEEKNUM],
  15746. [ig, be2.MINUTE],
  15747. [og, be2.MONTH],
  15748. [ug, be2.NETWORKDAYS],
  15749. [cg, be2.NETWORKDAYS_INTL],
  15750. [lg, be2.NOW],
  15751. [fg, be2.SECOND],
  15752. [hg, be2.TIME],
  15753. [mg, be2.TIMEVALUE],
  15754. [gg, be2.TO_DATE],
  15755. [dg, be2.TODAY],
  15756. [Cg, be2.WEEKDAY],
  15757. [_g, be2.WEEKNUM],
  15758. [Ag, be2.WORKDAY],
  15759. [Eg, be2.WORKDAY_INTL],
  15760. [bg, be2.YEAR],
  15761. [yg, be2.YEARFRAC]
  15762. ];
  15763. var pg = class extends V {
  15764. constructor() {
  15765. super(...arguments);
  15766. A(this, "minParams", 2);
  15767. A(this, "maxParams", 2);
  15768. }
  15769. calculate(e, t) {
  15770. if (e.isNull() || t.isNull())
  15771. return g2.create(m2.NA);
  15772. const { isError: r, errorObject: n, variants: s } = H(e, t);
  15773. if (r)
  15774. return n;
  15775. const [o, u] = s, c = +o.getValue(), l2 = Math.floor(+u.getValue());
  15776. if (Number.isNaN(c) || Number.isNaN(l2))
  15777. return g2.create(m2.VALUE);
  15778. if (l2 < 0)
  15779. return g2.create(m2.NUM);
  15780. const f2 = _r.besseli(c, l2);
  15781. return Number.isNaN(f2) || !Number.isFinite(f2) ? g2.create(m2.NUM) : y2.create(f2);
  15782. }
  15783. };
  15784. var Vg = class extends V {
  15785. constructor() {
  15786. super(...arguments);
  15787. A(this, "minParams", 2);
  15788. A(this, "maxParams", 2);
  15789. }
  15790. calculate(e, t) {
  15791. if (e.isNull() || t.isNull())
  15792. return g2.create(m2.NA);
  15793. const { isError: r, errorObject: n, variants: s } = H(e, t);
  15794. if (r)
  15795. return n;
  15796. const [o, u] = s, c = +o.getValue(), l2 = Math.floor(+u.getValue());
  15797. if (Number.isNaN(c) || Number.isNaN(l2))
  15798. return g2.create(m2.VALUE);
  15799. if (l2 < 0)
  15800. return g2.create(m2.NUM);
  15801. const f2 = _r.besselj(c, l2);
  15802. return Number.isNaN(f2) || !Number.isFinite(f2) ? g2.create(m2.NUM) : y2.create(f2);
  15803. }
  15804. };
  15805. var Ng = class extends V {
  15806. constructor() {
  15807. super(...arguments);
  15808. A(this, "minParams", 2);
  15809. A(this, "maxParams", 2);
  15810. }
  15811. calculate(e, t) {
  15812. if (e.isNull() || t.isNull())
  15813. return g2.create(m2.NA);
  15814. const { isError: r, errorObject: n, variants: s } = H(e, t);
  15815. if (r)
  15816. return n;
  15817. const [o, u] = s, c = +o.getValue(), l2 = Math.floor(+u.getValue());
  15818. if (Number.isNaN(c) || Number.isNaN(l2))
  15819. return g2.create(m2.VALUE);
  15820. if (l2 < 0)
  15821. return g2.create(m2.NUM);
  15822. const f2 = _r.besselk(c, l2);
  15823. return Number.isNaN(f2) || !Number.isFinite(f2) ? g2.create(m2.NUM) : y2.create(f2);
  15824. }
  15825. };
  15826. var Og = class extends V {
  15827. constructor() {
  15828. super(...arguments);
  15829. A(this, "minParams", 2);
  15830. A(this, "maxParams", 2);
  15831. }
  15832. calculate(e, t) {
  15833. if (e.isNull() || t.isNull())
  15834. return g2.create(m2.NA);
  15835. const { isError: r, errorObject: n, variants: s } = H(e, t);
  15836. if (r)
  15837. return n;
  15838. const [o, u] = s, c = +o.getValue(), l2 = Math.floor(+u.getValue());
  15839. if (Number.isNaN(c) || Number.isNaN(l2))
  15840. return g2.create(m2.VALUE);
  15841. if (l2 < 0)
  15842. return g2.create(m2.NUM);
  15843. const f2 = _r.bessely(c, l2);
  15844. return Number.isNaN(f2) || !Number.isFinite(f2) ? g2.create(m2.NUM) : y2.create(f2);
  15845. }
  15846. };
  15847. var Mg = class extends V {
  15848. constructor() {
  15849. super(...arguments);
  15850. A(this, "minParams", 1);
  15851. A(this, "maxParams", 1);
  15852. }
  15853. calculate(e) {
  15854. const { isError: t, errorObject: r, variants: n } = H(e);
  15855. if (t)
  15856. return r;
  15857. const [s] = n, o = `${s.getValue()}`;
  15858. if (!Ra2(o))
  15859. return g2.create(m2.NUM);
  15860. let u;
  15861. return o.length === 10 && o.substring(0, 1) === "1" ? u = Number.parseInt(o.substring(1), 2) - 512 : u = Number.parseInt(o, 2), y2.create(u);
  15862. }
  15863. };
  15864. var wg = class extends V {
  15865. constructor() {
  15866. super(...arguments);
  15867. A(this, "minParams", 1);
  15868. A(this, "maxParams", 2);
  15869. }
  15870. calculate(e, t) {
  15871. if (e.isNull())
  15872. return g2.create(m2.NA);
  15873. let r = 0;
  15874. if (t) {
  15875. const { isError: f2, errorObject: h, variants: d2 } = H(t);
  15876. if (f2)
  15877. return h;
  15878. const [_] = d2;
  15879. if (r = Math.floor(+_.getValue()), Number.isNaN(r))
  15880. return g2.create(m2.VALUE);
  15881. if (r < 0 || r > 10)
  15882. return g2.create(m2.NUM);
  15883. }
  15884. const { isError: n, errorObject: s, variants: o } = H(e);
  15885. if (n)
  15886. return s;
  15887. const [u] = o, c = `${u.getValue()}`;
  15888. if (!Ra2(c))
  15889. return g2.create(m2.NUM);
  15890. let l2;
  15891. if (c.length === 10 && c.substring(0, 1) === "1")
  15892. l2 = (1099511627264 + Number.parseInt(c.substring(1), 2)).toString(16);
  15893. else if (l2 = Number.parseInt(c, 2).toString(16), t) {
  15894. if (r < l2.length)
  15895. return g2.create(m2.NUM);
  15896. l2 = "0".repeat(r - l2.length) + l2;
  15897. }
  15898. return j.create(l2.toLocaleUpperCase());
  15899. }
  15900. };
  15901. var Dg = class extends V {
  15902. constructor() {
  15903. super(...arguments);
  15904. A(this, "minParams", 1);
  15905. A(this, "maxParams", 2);
  15906. }
  15907. calculate(e, t) {
  15908. if (e.isNull())
  15909. return g2.create(m2.NA);
  15910. let r = 0;
  15911. if (t) {
  15912. const { isError: f2, errorObject: h, variants: d2 } = H(t);
  15913. if (f2)
  15914. return h;
  15915. const [_] = d2;
  15916. if (r = Math.floor(+_.getValue()), Number.isNaN(r))
  15917. return g2.create(m2.VALUE);
  15918. if (r < 0 || r > 10)
  15919. return g2.create(m2.NUM);
  15920. }
  15921. const { isError: n, errorObject: s, variants: o } = H(e);
  15922. if (n)
  15923. return s;
  15924. const [u] = o, c = `${u.getValue()}`;
  15925. if (!Ra2(c))
  15926. return g2.create(m2.NUM);
  15927. let l2;
  15928. if (c.length === 10 && c.substring(0, 1) === "1")
  15929. l2 = (1073741312 + Number.parseInt(c.substring(1), 2)).toString(8);
  15930. else if (l2 = Number.parseInt(c, 2).toString(8), t) {
  15931. if (r < l2.length)
  15932. return g2.create(m2.NUM);
  15933. l2 = "0".repeat(r - l2.length) + l2;
  15934. }
  15935. return j.create(l2);
  15936. }
  15937. };
  15938. var Sg = class extends V {
  15939. constructor() {
  15940. super(...arguments);
  15941. A(this, "minParams", 2);
  15942. A(this, "maxParams", 2);
  15943. }
  15944. calculate(e, t) {
  15945. if (e.isError())
  15946. return e;
  15947. if (t.isError())
  15948. return t;
  15949. const r = Math.max(
  15950. e.isArray() ? e.getRowCount() : 1,
  15951. t.isArray() ? t.getRowCount() : 1
  15952. ), n = Math.max(
  15953. e.isArray() ? e.getColumnCount() : 1,
  15954. t.isArray() ? t.getColumnCount() : 1
  15955. ), s = O(r, n, e, g2.create(m2.NA)), o = O(r, n, t, g2.create(m2.NA)), u = s.map((c, l2, f2) => {
  15956. let h = c;
  15957. if (h.isString() && (h = h.convertToNumberObjectValue()), h.isError())
  15958. return h;
  15959. let d2 = o.get(l2, f2);
  15960. if (d2.isString() && (d2 = d2.convertToNumberObjectValue()), d2.isError())
  15961. return d2;
  15962. const _ = +h.getValue(), C = +d2.getValue();
  15963. if (_ < 0 || C < 0 || Math.floor(_) !== _ || Math.floor(C) !== C || _ > 281474976710655 || C > 281474976710655)
  15964. return g2.create(m2.NUM);
  15965. const E2 = _ & C;
  15966. return y2.create(E2);
  15967. });
  15968. return r === 1 && n === 1 ? u.get(0, 0) : u;
  15969. }
  15970. };
  15971. var Pg = class extends V {
  15972. constructor() {
  15973. super(...arguments);
  15974. A(this, "minParams", 2);
  15975. A(this, "maxParams", 2);
  15976. }
  15977. calculate(e, t) {
  15978. if (e.isError())
  15979. return e;
  15980. if (t.isError())
  15981. return t;
  15982. const r = Math.max(
  15983. e.isArray() ? e.getRowCount() : 1,
  15984. t.isArray() ? t.getRowCount() : 1
  15985. ), n = Math.max(
  15986. e.isArray() ? e.getColumnCount() : 1,
  15987. t.isArray() ? t.getColumnCount() : 1
  15988. ), s = O(r, n, e, g2.create(m2.NA)), o = O(r, n, t, g2.create(m2.NA)), u = s.map((c, l2, f2) => {
  15989. let h = c;
  15990. if (h.isString() && (h = h.convertToNumberObjectValue()), h.isError())
  15991. return h;
  15992. let d2 = o.get(l2, f2);
  15993. if (d2.isString() && (d2 = d2.convertToNumberObjectValue()), d2.isError())
  15994. return d2;
  15995. const _ = +h.getValue();
  15996. let C = +d2.getValue();
  15997. if (_ < 0 || Math.floor(_) !== _ || _ > 281474976710655 || Math.abs(C) > 53)
  15998. return g2.create(m2.NUM);
  15999. C = Math.trunc(C);
  16000. const E2 = Number(C >= 0 ? BigInt(_) << BigInt(C) : BigInt(_) >> BigInt(-C));
  16001. return E2 > 281474976710655 ? g2.create(m2.NUM) : y2.create(E2);
  16002. });
  16003. return r === 1 && n === 1 ? u.get(0, 0) : u;
  16004. }
  16005. };
  16006. var Lg = class extends V {
  16007. constructor() {
  16008. super(...arguments);
  16009. A(this, "minParams", 2);
  16010. A(this, "maxParams", 2);
  16011. }
  16012. calculate(e, t) {
  16013. if (e.isError())
  16014. return e;
  16015. if (t.isError())
  16016. return t;
  16017. const r = Math.max(
  16018. e.isArray() ? e.getRowCount() : 1,
  16019. t.isArray() ? t.getRowCount() : 1
  16020. ), n = Math.max(
  16021. e.isArray() ? e.getColumnCount() : 1,
  16022. t.isArray() ? t.getColumnCount() : 1
  16023. ), s = O(r, n, e, g2.create(m2.NA)), o = O(r, n, t, g2.create(m2.NA)), u = s.map((c, l2, f2) => {
  16024. let h = c;
  16025. if (h.isString() && (h = h.convertToNumberObjectValue()), h.isError())
  16026. return h;
  16027. let d2 = o.get(l2, f2);
  16028. if (d2.isString() && (d2 = d2.convertToNumberObjectValue()), d2.isError())
  16029. return d2;
  16030. const _ = +h.getValue(), C = +d2.getValue();
  16031. if (_ < 0 || C < 0 || Math.floor(_) !== _ || Math.floor(C) !== C || _ > 281474976710655 || C > 281474976710655)
  16032. return g2.create(m2.NUM);
  16033. const E2 = Number(BigInt(_) | BigInt(C));
  16034. return y2.create(E2);
  16035. });
  16036. return r === 1 && n === 1 ? u.get(0, 0) : u;
  16037. }
  16038. };
  16039. var xg = class extends V {
  16040. constructor() {
  16041. super(...arguments);
  16042. A(this, "minParams", 2);
  16043. A(this, "maxParams", 2);
  16044. }
  16045. calculate(e, t) {
  16046. if (e.isError())
  16047. return e;
  16048. if (t.isError())
  16049. return t;
  16050. const r = Math.max(
  16051. e.isArray() ? e.getRowCount() : 1,
  16052. t.isArray() ? t.getRowCount() : 1
  16053. ), n = Math.max(
  16054. e.isArray() ? e.getColumnCount() : 1,
  16055. t.isArray() ? t.getColumnCount() : 1
  16056. ), s = O(r, n, e, g2.create(m2.NA)), o = O(r, n, t, g2.create(m2.NA)), u = s.map((c, l2, f2) => {
  16057. let h = c;
  16058. if (h.isString() && (h = h.convertToNumberObjectValue()), h.isError())
  16059. return h;
  16060. let d2 = o.get(l2, f2);
  16061. if (d2.isString() && (d2 = d2.convertToNumberObjectValue()), d2.isError())
  16062. return d2;
  16063. const _ = +h.getValue();
  16064. let C = +d2.getValue();
  16065. if (_ < 0 || Math.floor(_) !== _ || _ > 281474976710655 || Math.abs(C) > 53)
  16066. return g2.create(m2.NUM);
  16067. C = Math.trunc(C);
  16068. const E2 = Number(C >= 0 ? BigInt(_) >> BigInt(C) : BigInt(_) << BigInt(-C));
  16069. return E2 > 281474976710655 ? g2.create(m2.NUM) : y2.create(E2);
  16070. });
  16071. return r === 1 && n === 1 ? u.get(0, 0) : u;
  16072. }
  16073. };
  16074. var jg = class extends V {
  16075. constructor() {
  16076. super(...arguments);
  16077. A(this, "minParams", 2);
  16078. A(this, "maxParams", 2);
  16079. }
  16080. calculate(e, t) {
  16081. if (e.isError())
  16082. return e;
  16083. if (t.isError())
  16084. return t;
  16085. const r = Math.max(
  16086. e.isArray() ? e.getRowCount() : 1,
  16087. t.isArray() ? t.getRowCount() : 1
  16088. ), n = Math.max(
  16089. e.isArray() ? e.getColumnCount() : 1,
  16090. t.isArray() ? t.getColumnCount() : 1
  16091. ), s = O(r, n, e, g2.create(m2.NA)), o = O(r, n, t, g2.create(m2.NA)), u = s.map((c, l2, f2) => {
  16092. let h = c;
  16093. if (h.isString() && (h = h.convertToNumberObjectValue()), h.isError())
  16094. return h;
  16095. let d2 = o.get(l2, f2);
  16096. if (d2.isString() && (d2 = d2.convertToNumberObjectValue()), d2.isError())
  16097. return d2;
  16098. const _ = +h.getValue(), C = +d2.getValue();
  16099. if (_ < 0 || C < 0 || Math.floor(_) !== _ || Math.floor(C) !== C || _ > 281474976710655 || C > 281474976710655)
  16100. return g2.create(m2.NUM);
  16101. const E2 = _ ^ C;
  16102. return y2.create(E2);
  16103. });
  16104. return r === 1 && n === 1 ? u.get(0, 0) : u;
  16105. }
  16106. };
  16107. L2.prototype.cos = function() {
  16108. const i = this.toNumber();
  16109. return new L2(Math.cos(i));
  16110. };
  16111. var fe2 = class ce {
  16112. constructor(a2) {
  16113. A(this, "_inumber", "");
  16114. A(this, "_realNum", 0);
  16115. A(this, "_iNum", 0);
  16116. A(this, "_suffix", "");
  16117. A(this, "_isError", false);
  16118. if (`${a2}`.trim() === "") {
  16119. this._isError = true;
  16120. return;
  16121. }
  16122. this._inumber = a2, this._getImReal(), this._getImAginary(), this._getImSuffix();
  16123. }
  16124. static getComplex(a2, e, t) {
  16125. const r = new L2(a2).toSignificantDigits(15).toNumber(), n = new L2(e).toSignificantDigits(15).toNumber(), s = t === "" ? "i" : t;
  16126. let o;
  16127. if (r === 0 && n === 0)
  16128. o = 0;
  16129. else if (r === 0)
  16130. o = n === 1 ? s : `${n}${s}`;
  16131. else if (n === 0)
  16132. o = r;
  16133. else {
  16134. const u = n > 0 ? "+" : "", c = n === 1 ? s : `${n}${s}`;
  16135. o = `${r}${u}${c}`;
  16136. }
  16137. return o;
  16138. }
  16139. static createByComplexStr(a2, e, t) {
  16140. const r = ce.getComplex(a2, e, t);
  16141. return new ce(r);
  16142. }
  16143. _getImReal() {
  16144. if (this._inumber === 0 || this._inumber === "0") {
  16145. this._realNum = 0;
  16146. return;
  16147. }
  16148. const a2 = `${this._inumber}`;
  16149. if (["i", "+i", "1i", "+1i", "-i", "-1i", "j", "+j", "1j", "+1j", "-j", "-1j"].indexOf(a2) >= 0) {
  16150. this._realNum = 0;
  16151. return;
  16152. }
  16153. let e = a2.indexOf("+"), t = a2.indexOf("-");
  16154. e === 0 && (e = a2.indexOf("+", 1)), t === 0 && (t = a2.indexOf("-", 1));
  16155. const r = a2.substring(a2.length - 1, a2.length), n = r === "i" || r === "j";
  16156. if (e >= 0 || t >= 0) {
  16157. if (!n) {
  16158. this._isError = true;
  16159. return;
  16160. }
  16161. e >= 0 ? Number.isNaN(+a2.substring(0, e)) || Number.isNaN(+a2.substring(e + 1, a2.length - 1)) ? this._isError = true : this._realNum = +a2.substring(0, e) : Number.isNaN(+a2.substring(0, t)) || Number.isNaN(+a2.substring(t + 1, a2.length - 1)) ? this._isError = true : this._realNum = +a2.substring(0, t);
  16162. } else
  16163. n ? Number.isNaN(+a2.substring(0, a2.length - 1)) ? this._isError = true : this._realNum = 0 : Number.isNaN(+a2) ? this._isError = true : this._realNum = +a2;
  16164. }
  16165. _getImAginary() {
  16166. if (this._isError)
  16167. return;
  16168. if (this._inumber === 0 || this._inumber === "0") {
  16169. this._iNum = 0;
  16170. return;
  16171. }
  16172. let a2 = `${this._inumber}`;
  16173. if (["i", "j"].indexOf(a2) >= 0) {
  16174. this._iNum = 1;
  16175. return;
  16176. }
  16177. a2 = a2.replace("+i", "+1i").replace("-i", "-1i").replace("+j", "+1j").replace("-j", "-1j");
  16178. let e = a2.indexOf("+"), t = a2.indexOf("-");
  16179. e === 0 && (e = a2.indexOf("+", 1)), t === 0 && (t = a2.indexOf("-", 1));
  16180. const r = a2.substring(a2.length - 1, a2.length), n = r === "i" || r === "j";
  16181. if (e >= 0 || t >= 0) {
  16182. if (!n) {
  16183. this._isError = true;
  16184. return;
  16185. }
  16186. e >= 0 ? Number.isNaN(+a2.substring(0, e)) || Number.isNaN(+a2.substring(e + 1, a2.length - 1)) ? this._isError = true : this._iNum = +a2.substring(e + 1, a2.length - 1) : Number.isNaN(+a2.substring(0, t)) || Number.isNaN(+a2.substring(t + 1, a2.length - 1)) ? this._isError = true : this._iNum = -+a2.substring(t + 1, a2.length - 1);
  16187. } else
  16188. n ? Number.isNaN(+a2.substring(0, a2.length - 1)) ? this._isError = true : this._iNum = +a2.substring(0, a2.length - 1) : Number.isNaN(+a2) ? this._isError = true : this._iNum = 0;
  16189. }
  16190. _getImSuffix() {
  16191. const a2 = `${this._inumber}`, e = a2.substring(a2.length - 1);
  16192. this._suffix = e === "i" || e === "j" ? e : "";
  16193. }
  16194. getRealNum() {
  16195. return this._realNum;
  16196. }
  16197. getINum() {
  16198. return this._iNum;
  16199. }
  16200. getSuffix() {
  16201. return this._suffix;
  16202. }
  16203. isError() {
  16204. return this._isError;
  16205. }
  16206. toString() {
  16207. return ce.getComplex(this._realNum, this._iNum, this._suffix);
  16208. }
  16209. isDifferentSuffixes(a2) {
  16210. const e = a2.getSuffix();
  16211. return this._suffix === "" || e === "" ? false : this._suffix !== e;
  16212. }
  16213. Abs() {
  16214. return L2.sqrt(L2.pow(this._realNum, 2).add(L2.pow(this._iNum, 2))).toSignificantDigits(16).toNumber();
  16215. }
  16216. Argument() {
  16217. const a2 = L2.sqrt(L2.pow(this._realNum, 2).add(L2.pow(this._iNum, 2)));
  16218. let e = L2.acos(new L2(this._realNum).div(a2)).toSignificantDigits(16).toNumber();
  16219. return this._iNum < 0 && (e = -e), e;
  16220. }
  16221. Conjugate() {
  16222. return ce.getComplex(this._realNum, -this._iNum, this._suffix);
  16223. }
  16224. Cos() {
  16225. if (this._iNum) {
  16226. const a2 = L2.cos(this._realNum).mul(L2.cosh(this._iNum)).toNumber(), e = L2.sin(this._realNum).mul(L2.sinh(this._iNum)).negated().toNumber();
  16227. return ce.getComplex(a2, e, this._suffix);
  16228. } else {
  16229. const a2 = L2.cos(this._realNum).toNumber();
  16230. return ce.getComplex(a2, this._iNum, this._suffix);
  16231. }
  16232. }
  16233. Cosh() {
  16234. if (!Number.isFinite(Math.sinh(this._realNum)) || !Number.isFinite(Math.cosh(this._realNum)))
  16235. return this._isError = true, "";
  16236. if (this._iNum) {
  16237. const a2 = L2.cosh(this._realNum).mul(L2.cos(this._iNum)).toNumber(), e = L2.sinh(this._realNum).mul(L2.sin(this._iNum)).toNumber();
  16238. return ce.getComplex(a2, e, this._suffix);
  16239. } else {
  16240. const a2 = L2.cosh(this._realNum).toNumber();
  16241. return ce.getComplex(a2, this._iNum, this._suffix);
  16242. }
  16243. }
  16244. Cot() {
  16245. if (this._iNum) {
  16246. const a2 = L2.cosh(this._iNum * 2).sub(L2.cos(this._realNum * 2)), e = L2.sin(this._realNum * 2).div(a2).toNumber(), t = L2.sinh(this._iNum * 2).div(a2).negated().toNumber();
  16247. return ce.getComplex(e, t, this._suffix);
  16248. } else {
  16249. const a2 = new L2(1).div(L2.tan(this._realNum)).toNumber();
  16250. return ce.getComplex(a2, this._iNum, this._suffix);
  16251. }
  16252. }
  16253. Coth() {
  16254. if (!Number.isFinite(Math.sinh(this._realNum)) || !Number.isFinite(Math.cosh(this._realNum)))
  16255. return this._isError = true, "";
  16256. if (this._iNum) {
  16257. const a2 = L2.cosh(this._realNum * 2).sub(L2.cos(this._iNum * 2)), e = L2.sinh(this._realNum * 2).div(a2).toNumber(), t = L2.sin(this._iNum * 2).div(a2).negated().toNumber();
  16258. return ce.getComplex(e, t, this._suffix);
  16259. } else {
  16260. const a2 = new L2(1).div(L2.tanh(this._realNum)).toNumber();
  16261. return ce.getComplex(a2, this._iNum, this._suffix);
  16262. }
  16263. }
  16264. Csc() {
  16265. if (this._iNum) {
  16266. const a2 = L2.cosh(this._iNum * 2).sub(L2.cos(this._realNum * 2)), e = L2.sin(this._realNum).mul(L2.cosh(this._iNum)).mul(2).div(a2).toNumber(), t = L2.cos(this._realNum).mul(L2.sinh(this._iNum)).mul(-2).div(a2).toNumber();
  16267. return ce.getComplex(e, t, this._suffix);
  16268. } else {
  16269. const a2 = new L2(1).div(L2.sin(this._realNum)).toNumber();
  16270. return ce.getComplex(a2, this._iNum, this._suffix);
  16271. }
  16272. }
  16273. Csch() {
  16274. if (!Number.isFinite(Math.sinh(this._realNum)) || !Number.isFinite(Math.cosh(this._realNum)))
  16275. return ce.getComplex(0, 0, this._suffix);
  16276. if (this._iNum) {
  16277. const a2 = L2.cosh(this._realNum * 2).sub(L2.cos(this._iNum * 2)), e = L2.sinh(this._realNum).mul(L2.cos(this._iNum)).mul(2).div(a2).toNumber(), t = L2.cosh(this._realNum).mul(L2.sin(this._iNum)).mul(-2).div(a2).toNumber();
  16278. return ce.getComplex(e, t, this._suffix);
  16279. } else {
  16280. const a2 = new L2(1).div(L2.sinh(this._realNum)).toNumber();
  16281. return ce.getComplex(a2, this._iNum, this._suffix);
  16282. }
  16283. }
  16284. Div(a2) {
  16285. const e = new L2(this._realNum), t = new L2(this._iNum), r = new L2(a2.getRealNum()), n = new L2(a2.getINum()), s = r.mul(r).add(n.mul(n)), o = e.mul(r).add(t.mul(n)).div(s).toNumber(), u = t.mul(r).sub(e.mul(n)).div(s).toNumber(), c = this._suffix === "" ? a2.getSuffix() : this._suffix;
  16286. return ce.getComplex(o, u, c);
  16287. }
  16288. Exp() {
  16289. if (!Number.isFinite(Math.exp(this._realNum)))
  16290. return this._isError = true, "";
  16291. const a2 = L2.exp(this._realNum).mul(L2.cos(this._iNum)).toNumber(), e = L2.exp(this._realNum).mul(L2.sin(this._iNum)).toNumber();
  16292. return ce.getComplex(a2, e, this._suffix);
  16293. }
  16294. Ln() {
  16295. const a2 = L2.sqrt(L2.pow(this._realNum, 2).add(L2.pow(this._iNum, 2))), e = L2.ln(a2).toNumber(), t = L2.acos(new L2(this._realNum).div(a2)).toNumber();
  16296. return ce.getComplex(e, t, this._suffix);
  16297. }
  16298. Log(a2) {
  16299. const e = L2.sqrt(L2.pow(this._realNum, 2).add(L2.pow(this._iNum, 2))), t = L2.ln(e);
  16300. let r = L2.acos(new L2(this._realNum).div(e));
  16301. this._iNum < 0 && (r = r.negated());
  16302. const n = L2.ln(a2), s = new L2(0), o = n.mul(n).add(s.mul(s));
  16303. if (o.eq(0))
  16304. return this._isError = true, "";
  16305. const u = t.mul(n).add(r.mul(s)).div(o).toNumber(), c = r.mul(n).sub(t.mul(s)).div(o).toNumber();
  16306. return ce.getComplex(u, c, this._suffix);
  16307. }
  16308. Power(a2) {
  16309. if (this._realNum === 0 && this._iNum === 0)
  16310. return a2 > 0 ? ce.getComplex(this._realNum, this._iNum, this._suffix) : (this._isError = true, "");
  16311. let e = L2.sqrt(L2.pow(this._realNum, 2).add(L2.pow(this._iNum, 2))), t = L2.acos(new L2(this._realNum).div(e));
  16312. this._iNum < 0 && (t = t.negated()), e = L2.pow(e, a2), t = t.mul(a2);
  16313. const r = L2.cos(t).mul(e).toNumber(), n = L2.sin(t).mul(e).toNumber();
  16314. return !Number.isFinite(r) || !Number.isFinite(n) ? (this._isError = true, "") : ce.getComplex(r, n, this._suffix);
  16315. }
  16316. Product(a2) {
  16317. const e = new L2(this._realNum), t = new L2(this._iNum), r = new L2(a2.getRealNum()), n = new L2(a2.getINum()), s = e.mul(r).sub(t.mul(n)).toNumber(), o = e.mul(n).add(t.mul(r)).toNumber(), u = this._suffix === "" ? a2.getSuffix() : this._suffix;
  16318. return ce.getComplex(s, o, u);
  16319. }
  16320. Sec() {
  16321. if (this._iNum) {
  16322. const a2 = L2.cosh(this._iNum * 2).add(L2.cos(this._realNum * 2)), e = L2.cos(this._realNum).mul(L2.cosh(this._iNum)).mul(2).div(a2).toNumber(), t = L2.sin(this._realNum).mul(L2.sinh(this._iNum)).mul(2).div(a2).toNumber();
  16323. return ce.getComplex(e, t, this._suffix);
  16324. } else {
  16325. const a2 = new L2(1).div(L2.cos(this._realNum)).toNumber();
  16326. return ce.getComplex(a2, this._iNum, this._suffix);
  16327. }
  16328. }
  16329. Sech() {
  16330. if (!Number.isFinite(Math.sinh(this._realNum * 2)) || !Number.isFinite(Math.cosh(this._realNum * 2)))
  16331. return ce.getComplex(0, 0, this._suffix);
  16332. if (this._iNum) {
  16333. const a2 = L2.cosh(this._realNum * 2).add(L2.cos(this._iNum * 2)), e = L2.cosh(this._realNum).mul(L2.cos(this._iNum)).mul(2).div(a2).toNumber(), t = L2.sinh(this._realNum).mul(L2.sin(this._iNum)).mul(-2).div(a2).toNumber();
  16334. return ce.getComplex(e, t, this._suffix);
  16335. } else {
  16336. const a2 = new L2(1).div(L2.cosh(this._realNum)).toNumber();
  16337. return ce.getComplex(a2, this._iNum, this._suffix);
  16338. }
  16339. }
  16340. Sin() {
  16341. if (this._iNum) {
  16342. const a2 = L2.sin(this._realNum).mul(L2.cosh(this._iNum)).toNumber(), e = L2.cos(this._realNum).mul(L2.sinh(this._iNum)).toNumber();
  16343. return ce.getComplex(a2, e, this._suffix);
  16344. } else {
  16345. const a2 = L2.sin(this._realNum).toNumber();
  16346. return ce.getComplex(a2, this._iNum, this._suffix);
  16347. }
  16348. }
  16349. Sinh() {
  16350. if (!Number.isFinite(Math.sinh(this._realNum)) || !Number.isFinite(Math.cosh(this._realNum)))
  16351. return this._isError = true, "";
  16352. if (this._iNum) {
  16353. const a2 = L2.sinh(this._realNum).mul(L2.cos(this._iNum)).toNumber(), e = L2.cosh(this._realNum).mul(L2.sin(this._iNum)).toNumber();
  16354. return ce.getComplex(a2, e, this._suffix);
  16355. } else {
  16356. const a2 = L2.sinh(this._realNum).toNumber();
  16357. return ce.getComplex(a2, this._iNum, this._suffix);
  16358. }
  16359. }
  16360. Sqrt() {
  16361. const a2 = L2.sqrt(L2.pow(this._realNum, 2).add(L2.pow(this._iNum, 2))), e = L2.sqrt(a2);
  16362. let t = L2.acos(new L2(this._realNum).div(a2));
  16363. this._iNum < 0 && (t = t.negated());
  16364. const r = e.mul(L2.cos(t.div(2).toNumber())).toNumber(), n = e.mul(L2.sin(t.div(2))).toNumber();
  16365. return ce.getComplex(r, n, this._suffix);
  16366. }
  16367. Sub(a2) {
  16368. const e = new L2(this._realNum), t = new L2(this._iNum), r = new L2(a2.getRealNum()), n = new L2(a2.getINum()), s = e.sub(r).toNumber(), o = t.sub(n).toNumber(), u = this._suffix === "" ? a2.getSuffix() : this._suffix;
  16369. return ce.getComplex(s, o, u);
  16370. }
  16371. Sum(a2) {
  16372. const e = new L2(this._realNum), t = new L2(this._iNum), r = new L2(a2.getRealNum()), n = new L2(a2.getINum()), s = e.add(r).toNumber(), o = t.add(n).toNumber(), u = this._suffix === "" ? a2.getSuffix() : this._suffix;
  16373. return ce.getComplex(s, o, u);
  16374. }
  16375. Tan() {
  16376. if (this._iNum) {
  16377. const a2 = L2.cos(this._realNum * 2).add(L2.cosh(this._iNum * 2)), e = L2.sin(this._realNum * 2).div(a2).toNumber(), t = L2.sinh(this._iNum * 2).div(a2).toNumber();
  16378. return ce.getComplex(e, t, this._suffix);
  16379. } else {
  16380. const a2 = L2.tan(this._realNum).toNumber();
  16381. return ce.getComplex(a2, this._iNum, this._suffix);
  16382. }
  16383. }
  16384. Tanh() {
  16385. if (!Number.isFinite(Math.sinh(this._realNum)) || !Number.isFinite(Math.cosh(this._realNum)))
  16386. return this._isError = true, "";
  16387. if (this._iNum) {
  16388. const a2 = L2.cosh(this._realNum * 2).add(L2.cos(this._iNum * 2)), e = L2.sinh(this._realNum * 2).div(a2).toNumber(), t = L2.sin(this._iNum * 2).div(a2).toNumber();
  16389. return ce.getComplex(e, t, this._suffix);
  16390. } else {
  16391. const a2 = L2.tanh(this._realNum).toNumber();
  16392. return ce.getComplex(a2, this._iNum, this._suffix);
  16393. }
  16394. }
  16395. };
  16396. var Ug = class extends V {
  16397. constructor() {
  16398. super(...arguments);
  16399. A(this, "minParams", 2);
  16400. A(this, "maxParams", 3);
  16401. }
  16402. calculate(e, t, r) {
  16403. const n = r != null ? r : j.create("i"), { isError: s, errorObject: o, variants: u } = H(e, t, n);
  16404. if (s)
  16405. return o;
  16406. const [c, l2, f2] = u, h = +c.getValue(), d2 = +l2.getValue(), _ = `${f2.getValue()}`;
  16407. if (Number.isNaN(h) || Number.isNaN(d2) || _ !== "i" && _ !== "j")
  16408. return g2.create(m2.VALUE);
  16409. const C = fe2.getComplex(h, d2, _);
  16410. return typeof C == "number" ? y2.create(C) : j.create(C);
  16411. }
  16412. };
  16413. var vg = class extends V {
  16414. constructor() {
  16415. super(...arguments);
  16416. A(this, "minParams", 3);
  16417. A(this, "maxParams", 3);
  16418. A(this, "_units", [
  16419. ["a.u. of action", "?", null, "action", false, false, 105457168181818e-48],
  16420. ["a.u. of charge", "e", null, "electric_charge", false, false, 160217653141414e-33],
  16421. ["a.u. of energy", "Eh", null, "energy", false, false, 435974417757576e-32],
  16422. ["a.u. of length", "a?", null, "length", false, false, 529177210818182e-25],
  16423. ["a.u. of mass", "m?", null, "mass", false, false, 910938261616162e-45],
  16424. ["a.u. of time", "?/Eh", null, "time", false, false, 241888432650516e-31],
  16425. ["admiralty knot", "admkn", null, "speed", false, true, 0.514773333],
  16426. ["ampere", "A", null, "electric_current", true, false, 1],
  16427. ["ampere per meter", "A/m", null, "magnetic_field_intensity", true, false, 1],
  16428. ["ångström", "Å", ["ang"], "length", false, true, 1e-10],
  16429. ["are", "ar", null, "area", false, true, 100],
  16430. ["astronomical unit", "ua", null, "length", false, false, 149597870691667e-25],
  16431. ["bar", "bar", null, "pressure", false, false, 1e5],
  16432. ["barn", "b", null, "area", false, false, 1e-28],
  16433. ["becquerel", "Bq", null, "radioactivity", true, false, 1],
  16434. ["bit", "bit", ["b"], "information", false, true, 1],
  16435. ["btu", "BTU", ["btu"], "energy", false, true, 1055.05585262],
  16436. ["byte", "byte", null, "information", false, true, 8],
  16437. ["candela", "cd", null, "luminous_intensity", true, false, 1],
  16438. ["candela per square metre", "cd/m?", null, "luminance", true, false, 1],
  16439. ["centigrade", "C", ["cel"], "temperature", true, false, 1],
  16440. ["cubic ångström", "ang3", ["ang^3"], "volume", false, true, 1e-30],
  16441. ["cubic foot", "ft3", ["ft^3"], "volume", false, true, 0.028316846592],
  16442. ["cubic inch", "in3", ["in^3"], "volume", false, true, 16387064e-12],
  16443. ["cubic light-year", "ly3", ["ly^3"], "volume", false, true, 846786664623715e-61],
  16444. ["cubic metre", "m3", ["m^3"], "volume", true, true, 1],
  16445. ["cubic mile", "mi3", ["mi^3"], "volume", false, true, 416818182544058e-5],
  16446. ["cubic nautical mile", "Nmi3", ["Nmi^3"], "volume", false, true, 6352182208],
  16447. ["cubic Pica", "Pica3", ["Picapt3", "Pica^3", "Picapt^3"], "volume", false, true, 758660370370369e-22],
  16448. ["cubic yard", "yd3", ["yd^3"], "volume", false, true, 0.764554857984],
  16449. ["cup", "cup", null, "volume", false, true, 2365882365e-13],
  16450. ["dalton", "Da", ["u"], "mass", false, false, 166053886282828e-41],
  16451. ["day", "d", ["day"], "time", false, true, 86400],
  16452. ["degree", "°", null, "angle", false, false, 0.0174532925199433],
  16453. ["dyne", "dyn", ["dy"], "force", false, true, 1e-5],
  16454. ["electronvolt", "eV", ["ev"], "energy", false, true, 1.60217656514141],
  16455. ["ell", "ell", null, "length", false, true, 1.143],
  16456. ["erg", "erg", ["e"], "energy", false, true, 1e-7],
  16457. ["fahrenheit", "F", ["fah"], "temperature", true, false, 1],
  16458. ["fluid ounce", "oz", null, "volume", false, true, 295735295625e-16],
  16459. ["foot", "ft", null, "length", false, true, 0.3048],
  16460. ["foot-pound", "flb", null, "energy", false, true, 1.3558179483314],
  16461. ["gal", "Gal", null, "acceleration", false, false, 0.01],
  16462. ["gallon", "gal", null, "volume", false, true, 0.003785411784],
  16463. ["gauss", "G", ["ga"], "magnetic_flux_density", false, true, 1],
  16464. ["grain", "grain", null, "mass", false, true, 647989e-10],
  16465. ["gram", "g", null, "mass", false, true, 1e-3],
  16466. ["gray", "Gy", null, "absorbed_dose", true, false, 1],
  16467. ["gross registered ton", "GRT", ["regton"], "volume", false, true, 2.8316846592],
  16468. ["hectare", "ha", null, "area", false, true, 1e4],
  16469. ["henry", "H", null, "inductance", true, false, 1],
  16470. ["hertz", "Hz", null, "frequency", true, false, 1],
  16471. ["horsepower", "HP", ["h"], "power", false, true, 745.69987158227],
  16472. ["horsepower-hour", "HPh", ["hh", "hph"], "energy", false, true, 2684519538e-3],
  16473. ["hour", "h", ["hr"], "time", false, true, 3600],
  16474. ["imperial gallon (U.K.)", "uk_gal", null, "volume", false, true, 454609e-8],
  16475. ["imperial hundredweight", "lcwt", ["uk_cwt", "hweight"], "mass", false, true, 50.802345],
  16476. ["imperial quart (U.K)", "uk_qt", null, "volume", false, true, 0.0011365225],
  16477. ["imperial ton", "brton", ["uk_ton", "LTON"], "mass", false, true, 1016.046909],
  16478. ["inch", "in", null, "length", false, true, 0.0254],
  16479. ["international acre", "uk_acre", null, "area", false, true, 4046.8564224],
  16480. ["IT calorie", "cal", null, "energy", false, true, 4.1868],
  16481. ["joule", "J", null, "energy", true, true, 1],
  16482. ["katal", "kat", null, "catalytic_activity", true, false, 1],
  16483. ["kelvin", "K", ["kel"], "temperature", true, true, 1],
  16484. ["kilogram", "kg", null, "mass", true, true, 1],
  16485. ["knot", "kn", null, "speed", false, true, 0.514444444444444],
  16486. ["light-year", "ly", null, "length", false, true, 9460730472580800],
  16487. ["litre", "L", ["l", "lt"], "volume", false, true, 1e-3],
  16488. ["lumen", "lm", null, "luminous_flux", true, false, 1],
  16489. ["lux", "lx", null, "illuminance", true, false, 1],
  16490. ["maxwell", "Mx", null, "magnetic_flux", false, false, 1e-18],
  16491. ["measurement ton", "MTON", null, "volume", false, true, 1.13267386368],
  16492. ["meter per hour", "m/h", ["m/hr"], "speed", false, true, 27777777777778e-17],
  16493. ["meter per second", "m/s", ["m/sec"], "speed", true, true, 1],
  16494. ["meter per second squared", "m?s??", null, "acceleration", true, false, 1],
  16495. ["parsec", "pc", ["parsec"], "length", false, true, 30856775814671900],
  16496. ["meter squared per second", "m?/s", null, "kinematic_viscosity", true, false, 1],
  16497. ["metre", "m", null, "length", true, true, 1],
  16498. ["miles per hour", "mph", null, "speed", false, true, 0.44704],
  16499. ["millimetre of mercury", "mmHg", null, "pressure", false, false, 133.322],
  16500. ["minute", "?", null, "angle", false, false, 290888208665722e-18],
  16501. ["minute", "min", ["mn"], "time", false, true, 60],
  16502. ["modern teaspoon", "tspm", null, "volume", false, true, 5e-6],
  16503. ["mole", "mol", null, "amount_of_substance", true, false, 1],
  16504. ["morgen", "Morgen", null, "area", false, true, 2500],
  16505. ["n.u. of action", "?", null, "action", false, false, 105457168181818e-48],
  16506. ["n.u. of mass", "m?", null, "mass", false, false, 910938261616162e-45],
  16507. ["n.u. of speed", "c?", null, "speed", false, false, 299792458],
  16508. ["n.u. of time", "?/(me?c??)", null, "time", false, false, 128808866778687e-35],
  16509. ["nautical mile", "M", ["Nmi"], "length", false, true, 1852],
  16510. ["newton", "N", null, "force", true, true, 1],
  16511. ["œrsted", "Oe ", null, "magnetic_field_intensity", false, false, 79.5774715459477],
  16512. ["ohm", "Ω", null, "electric_resistance", true, false, 1],
  16513. ["ounce mass", "ozm", null, "mass", false, true, 0.028349523125],
  16514. ["pascal", "Pa", null, "pressure", true, false, 1],
  16515. ["pascal second", "Pa?s", null, "dynamic_viscosity", true, false, 1],
  16516. ["pferdestärke", "PS", null, "power", false, true, 735.49875],
  16517. ["phot", "ph", null, "illuminance", false, false, 1e-4],
  16518. ["pica (1/6 inch)", "pica", null, "length", false, true, 35277777777778e-17],
  16519. ["pica (1/72 inch)", "Pica", ["Picapt"], "length", false, true, 0.00423333333333333],
  16520. ["poise", "P", null, "dynamic_viscosity", false, false, 0.1],
  16521. ["pond", "pond", null, "force", false, true, 980665e-8],
  16522. ["pound force", "lbf", null, "force", false, true, 4.4482216152605],
  16523. ["pound mass", "lbm", null, "mass", false, true, 0.45359237],
  16524. ["quart", "qt", null, "volume", false, true, 946352946e-12],
  16525. ["radian", "rad", null, "angle", true, false, 1],
  16526. ["rankine", "Rank", null, "temperature", false, true, 1],
  16527. ["reaumur", "Reau", null, "temperature", false, true, 1],
  16528. ["second", "?", null, "angle", false, false, 484813681109536e-20],
  16529. ["second", "s", ["sec"], "time", true, true, 1],
  16530. ["short hundredweight", "cwt", ["shweight"], "mass", false, true, 45.359237],
  16531. ["siemens", "S", null, "electrical_conductance", true, false, 1],
  16532. ["sievert", "Sv", null, "equivalent_dose", true, false, 1],
  16533. ["slug", "sg", null, "mass", false, true, 14.59390294],
  16534. ["square ångström", "ang2", ["ang^2"], "area", false, true, 1e-20],
  16535. ["square foot", "ft2", ["ft^2"], "area", false, true, 0.09290304],
  16536. ["square inch", "in2", ["in^2"], "area", false, true, 64516e-8],
  16537. ["square light-year", "ly2", ["ly^2"], "area", false, true, 895054210748189e17],
  16538. ["square meter", "m?", null, "area", true, true, 1],
  16539. ["square mile", "mi2", ["mi^2"], "area", false, true, 2589988110336e-6],
  16540. ["square nautical mile", "Nmi2", ["Nmi^2"], "area", false, true, 3429904],
  16541. ["square Pica", "Pica2", ["Picapt2", "Pica^2", "Picapt^2"], "area", false, true, 1792111111111e-17],
  16542. ["square yard", "yd2", ["yd^2"], "area", false, true, 0.83612736],
  16543. ["statute mile", "mi", null, "length", false, true, 1609.344],
  16544. ["steradian", "sr", null, "solid_angle", true, false, 1],
  16545. ["stilb", "sb", null, "luminance", false, false, 1e-4],
  16546. ["stokes", "St", null, "kinematic_viscosity", false, false, 1e-4],
  16547. ["stone", "stone", null, "mass", false, true, 6.35029318],
  16548. ["tablespoon", "tbs", null, "volume", false, true, 147868e-10],
  16549. ["teaspoon", "tsp", null, "volume", false, true, 492892e-11],
  16550. ["tesla", "T", null, "magnetic_flux_density", true, true, 1],
  16551. ["thermodynamic calorie", "c", null, "energy", false, true, 4.184],
  16552. ["ton", "ton", null, "mass", false, true, 907.18474],
  16553. ["tonne", "t", null, "mass", false, false, 1e3],
  16554. ["U.K. pint", "uk_pt", null, "volume", false, true, 56826125e-11],
  16555. ["U.S. bushel", "bushel", null, "volume", false, true, 0.03523907],
  16556. ["U.S. oil barrel", "barrel", null, "volume", false, true, 0.158987295],
  16557. ["U.S. pint", "pt", ["us_pt"], "volume", false, true, 473176473e-12],
  16558. ["U.S. survey mile", "survey_mi", null, "length", false, true, 1609.347219],
  16559. ["U.S. survey/statute acre", "us_acre", null, "area", false, true, 4046.87261],
  16560. ["volt", "V", null, "voltage", true, false, 1],
  16561. ["watt", "W", null, "power", true, true, 1],
  16562. ["watt-hour", "Wh", ["wh"], "energy", false, true, 3600],
  16563. ["weber", "Wb", null, "magnetic_flux", true, false, 1],
  16564. ["yard", "yd", null, "length", false, true, 0.9144],
  16565. ["year", "yr", null, "time", false, true, 31557600]
  16566. ]);
  16567. A(this, "_binaryPrefixes", {
  16568. Yi: ["yobi", 80, 12089258196146292e8, "Yi", "yotta"],
  16569. Zi: ["zebi", 70, 11805916207174113e5, "Zi", "zetta"],
  16570. Ei: ["exbi", 60, 1152921504606847e3, "Ei", "exa"],
  16571. Pi: ["pebi", 50, 1125899906842624, "Pi", "peta"],
  16572. Ti: ["tebi", 40, 1099511627776, "Ti", "tera"],
  16573. Gi: ["gibi", 30, 1073741824, "Gi", "giga"],
  16574. Mi: ["mebi", 20, 1048576, "Mi", "mega"],
  16575. ki: ["kibi", 10, 1024, "ki", "kilo"]
  16576. });
  16577. A(this, "_unitPrefixes", {
  16578. Y: ["yotta", 1e24, "Y"],
  16579. Z: ["zetta", 1e21, "Z"],
  16580. E: ["exa", 1e18, "E"],
  16581. P: ["peta", 1e15, "P"],
  16582. T: ["tera", 1e12, "T"],
  16583. G: ["giga", 1e9, "G"],
  16584. M: ["mega", 1e6, "M"],
  16585. k: ["kilo", 1e3, "k"],
  16586. h: ["hecto", 100, "h"],
  16587. e: ["dekao", 10, "e"],
  16588. d: ["deci", 0.1, "d"],
  16589. c: ["centi", 0.01, "c"],
  16590. m: ["milli", 1e-3, "m"],
  16591. u: ["micro", 1e-6, "u"],
  16592. n: ["nano", 1e-9, "n"],
  16593. p: ["pico", 1e-12, "p"],
  16594. f: ["femto", 1e-15, "f"],
  16595. a: ["atto", 1e-18, "a"],
  16596. z: ["zepto", 1e-21, "z"],
  16597. y: ["yocto", 1e-24, "y"]
  16598. });
  16599. }
  16600. calculate(e, t, r) {
  16601. const { isError: n, errorObject: s, variants: o } = H(e, t, r);
  16602. if (n)
  16603. return s;
  16604. const [u, c, l2] = o, f2 = +u.getValue(), h = `${c.getValue()}`, d2 = `${l2.getValue()}`;
  16605. if (Number.isNaN(f2))
  16606. return g2.create(m2.VALUE);
  16607. let _, C = 1, E2, b = 1;
  16608. const { _from: R, _to: p2 } = this._lookupFromAndToUnits(h, d2);
  16609. if (_ = R, E2 = p2, _ === null) {
  16610. const { _from: M2, _fromMultiplier: w } = this._lookupFromPrefix(h);
  16611. _ = M2, C = w;
  16612. }
  16613. if (E2 === null) {
  16614. const { _to: M2, _toMultiplier: w } = this._lookupToPrefix(d2);
  16615. E2 = M2, b = w;
  16616. }
  16617. if (_ === null || E2 === null || _[3] !== E2[3])
  16618. return g2.create(m2.NA);
  16619. let N2;
  16620. return _[3] === "temperature" ? (N2 = this._getTemperatureConversion(f2, _[1], E2[1]), N2 = +N2.toFixed(2)) : N2 = f2 * _[6] * C / (E2[6] * b), y2.create(N2);
  16621. }
  16622. _lookupFromAndToUnits(e, t) {
  16623. let r = null, n = null, s;
  16624. for (let o = 0; o < this._units.length; o++)
  16625. s = this._units[o][2] === null ? [] : this._units[o][2], (this._units[o][1] === e || s.indexOf(e) >= 0) && (r = this._units[o]), (this._units[o][1] === t || s.indexOf(t) >= 0) && (n = this._units[o]);
  16626. return {
  16627. _from: r,
  16628. _to: n
  16629. };
  16630. }
  16631. _lookupFromPrefix(e) {
  16632. let t = null, r = 1, n = e, s;
  16633. const o = this._binaryPrefixes[e.substring(0, 2)];
  16634. let u = this._unitPrefixes[e.substring(0, 1)];
  16635. e.substring(0, 2) === "da" && (u = ["dekao", 10, "da"]), o ? (r = o[2], n = e.substring(2)) : u && (r = u[1], n = e.substring(u[2].length));
  16636. for (let c = 0; c < this._units.length; c++)
  16637. s = this._units[c][2] === null ? [] : this._units[c][2], (this._units[c][1] === n || s.indexOf(n) >= 0) && (t = this._units[c]);
  16638. return {
  16639. _from: t,
  16640. _fromMultiplier: r
  16641. };
  16642. }
  16643. _lookupToPrefix(e) {
  16644. let t = null, r = 1, n = e, s;
  16645. const o = this._binaryPrefixes[e.substring(0, 2)];
  16646. let u = this._unitPrefixes[e.substring(0, 1)];
  16647. e.substring(0, 2) === "da" && (u = ["dekao", 10, "da"]), o ? (r = o[2], n = e.substring(2)) : u && (r = u[1], n = e.substring(u[2].length));
  16648. for (let c = 0; c < this._units.length; c++)
  16649. s = this._units[c][2] === null ? [] : this._units[c][2], (this._units[c][1] === n || s.indexOf(n) >= 0) && (t = this._units[c]);
  16650. return {
  16651. _to: t,
  16652. _toMultiplier: r
  16653. };
  16654. }
  16655. _getTemperatureConversion(e, t, r) {
  16656. switch (t) {
  16657. case "C":
  16658. return this._centigradeConversion(e, r);
  16659. case "F":
  16660. return this._fahrenheitConversion(e, r);
  16661. case "K":
  16662. return this._kelvinConversion(e, r);
  16663. case "Rank":
  16664. return this._rankineConversion(e, r);
  16665. case "Reau":
  16666. return this._reaumurConversion(e, r);
  16667. default:
  16668. return e;
  16669. }
  16670. }
  16671. _centigradeConversion(e, t) {
  16672. switch (t) {
  16673. case "F":
  16674. return e * 9 / 5 + 32;
  16675. case "K":
  16676. return e + 273.15;
  16677. case "Rank":
  16678. return (e + 273.15) * 9 / 5;
  16679. case "Reau":
  16680. return e * 4 / 5;
  16681. default:
  16682. return e;
  16683. }
  16684. }
  16685. _fahrenheitConversion(e, t) {
  16686. switch (t) {
  16687. case "C":
  16688. return (e - 32) * 5 / 9;
  16689. case "K":
  16690. return (e - 32) * 5 / 9 + 273.15;
  16691. case "Rank":
  16692. return e + 459.67;
  16693. case "Reau":
  16694. return (e - 32) * 4 / 9;
  16695. default:
  16696. return e;
  16697. }
  16698. }
  16699. _kelvinConversion(e, t) {
  16700. switch (t) {
  16701. case "C":
  16702. return e - 273.15;
  16703. case "F":
  16704. return (e - 273.15) * 9 / 5 + 32;
  16705. case "Rank":
  16706. return e * 9 / 5;
  16707. case "Reau":
  16708. return (e - 273.15) * 4 / 5;
  16709. default:
  16710. return e;
  16711. }
  16712. }
  16713. _rankineConversion(e, t) {
  16714. switch (t) {
  16715. case "C":
  16716. return (e - 491.67) * 5 / 9;
  16717. case "F":
  16718. return e - 459.67;
  16719. case "K":
  16720. return e * 5 / 9;
  16721. case "Reau":
  16722. return (e - 491.67) * 4 / 9;
  16723. default:
  16724. return e;
  16725. }
  16726. }
  16727. _reaumurConversion(e, t) {
  16728. switch (t) {
  16729. case "C":
  16730. return e * 5 / 4;
  16731. case "F":
  16732. return e * 9 / 4 + 32;
  16733. case "K":
  16734. return e * 5 / 4 + 273.15;
  16735. case "Rank":
  16736. return e * 9 / 4 + 491.67;
  16737. default:
  16738. return e;
  16739. }
  16740. }
  16741. };
  16742. var Tg = class extends V {
  16743. constructor() {
  16744. super(...arguments);
  16745. A(this, "minParams", 1);
  16746. A(this, "maxParams", 2);
  16747. }
  16748. calculate(e, t) {
  16749. if (e.isNull())
  16750. return g2.create(m2.NA);
  16751. let r = 0;
  16752. if (t) {
  16753. const { isError: f2, errorObject: h, variants: d2 } = H(t);
  16754. if (f2)
  16755. return h;
  16756. const [_] = d2;
  16757. if (r = Math.floor(+_.getValue()), Number.isNaN(r))
  16758. return g2.create(m2.VALUE);
  16759. if (r < 0 || r > 10)
  16760. return g2.create(m2.NUM);
  16761. }
  16762. const { isError: n, errorObject: s, variants: o } = H(e);
  16763. if (n)
  16764. return s;
  16765. const [u] = o, c = Math.trunc(+u.getValue());
  16766. if (Number.isNaN(c))
  16767. return g2.create(m2.VALUE);
  16768. if (!/^-?[0-9]{1,3}$/.test(`${c}`) || c < -512 || c > 511)
  16769. return g2.create(m2.NUM);
  16770. let l2;
  16771. if (c < 0) {
  16772. const f2 = (512 + c).toString(2);
  16773. l2 = `1${"0".repeat(9 - f2.length)}${f2}`;
  16774. } else if (l2 = Number.parseInt(`${c}`, 10).toString(2), t) {
  16775. if (r < l2.length)
  16776. return g2.create(m2.NUM);
  16777. l2 = "0".repeat(r - l2.length) + l2;
  16778. }
  16779. return j.create(l2);
  16780. }
  16781. };
  16782. var Bg = class extends V {
  16783. constructor() {
  16784. super(...arguments);
  16785. A(this, "minParams", 1);
  16786. A(this, "maxParams", 2);
  16787. }
  16788. calculate(e, t) {
  16789. if (e.isNull())
  16790. return g2.create(m2.NA);
  16791. let r = 0;
  16792. if (t) {
  16793. const { isError: f2, errorObject: h, variants: d2 } = H(t);
  16794. if (f2)
  16795. return h;
  16796. const [_] = d2;
  16797. if (r = Math.floor(+_.getValue()), Number.isNaN(r))
  16798. return g2.create(m2.VALUE);
  16799. if (r < 0 || r > 10)
  16800. return g2.create(m2.NUM);
  16801. }
  16802. const { isError: n, errorObject: s, variants: o } = H(e);
  16803. if (n)
  16804. return s;
  16805. const [u] = o, c = Math.trunc(+u.getValue());
  16806. if (Number.isNaN(c))
  16807. return g2.create(m2.VALUE);
  16808. if (!/^-?[0-9]{1,12}$/.test(`${c}`) || c < -549755813888 || c > 549755813887)
  16809. return g2.create(m2.NUM);
  16810. let l2;
  16811. if (c < 0)
  16812. l2 = (1099511627776 + c).toString(16);
  16813. else if (l2 = Number.parseInt(`${c}`, 10).toString(16), t) {
  16814. if (r < l2.length)
  16815. return g2.create(m2.NUM);
  16816. l2 = "0".repeat(r - l2.length) + l2;
  16817. }
  16818. return j.create(l2.toLocaleUpperCase());
  16819. }
  16820. };
  16821. var Ig = class extends V {
  16822. constructor() {
  16823. super(...arguments);
  16824. A(this, "minParams", 1);
  16825. A(this, "maxParams", 2);
  16826. }
  16827. calculate(e, t) {
  16828. if (e.isNull())
  16829. return g2.create(m2.NA);
  16830. let r = 0;
  16831. if (t) {
  16832. const { isError: f2, errorObject: h, variants: d2 } = H(t);
  16833. if (f2)
  16834. return h;
  16835. const [_] = d2;
  16836. if (r = Math.floor(+_.getValue()), Number.isNaN(r))
  16837. return g2.create(m2.VALUE);
  16838. if (r < 0 || r > 10)
  16839. return g2.create(m2.NUM);
  16840. }
  16841. const { isError: n, errorObject: s, variants: o } = H(e);
  16842. if (n)
  16843. return s;
  16844. const [u] = o, c = Math.trunc(+u.getValue());
  16845. if (Number.isNaN(c))
  16846. return g2.create(m2.VALUE);
  16847. if (!/^-?[0-9]{1,9}$/.test(`${c}`) || c < -536870912 || c > 536870911)
  16848. return g2.create(m2.NUM);
  16849. let l2;
  16850. if (c < 0)
  16851. l2 = (1073741824 + c).toString(8);
  16852. else if (l2 = Number.parseInt(`${c}`, 10).toString(8), t) {
  16853. if (r < l2.length)
  16854. return g2.create(m2.NUM);
  16855. l2 = "0".repeat(r - l2.length) + l2;
  16856. }
  16857. return j.create(l2);
  16858. }
  16859. };
  16860. var Fg = class extends V {
  16861. constructor() {
  16862. super(...arguments);
  16863. A(this, "minParams", 1);
  16864. A(this, "maxParams", 2);
  16865. }
  16866. calculate(e, t) {
  16867. const r = t != null ? t : y2.create(0), { isError: n, errorObject: s, variants: o } = H(e, r);
  16868. if (n)
  16869. return s;
  16870. const [u, c] = o, l2 = +u.getValue(), f2 = +c.getValue();
  16871. if (Number.isNaN(l2) || Number.isNaN(f2))
  16872. return g2.create(m2.VALUE);
  16873. const h = l2 === f2 ? 1 : 0;
  16874. return y2.create(h);
  16875. }
  16876. };
  16877. var kg = class extends V {
  16878. constructor() {
  16879. super(...arguments);
  16880. A(this, "minParams", 1);
  16881. A(this, "maxParams", 2);
  16882. }
  16883. calculate(e, t) {
  16884. let r;
  16885. if (t) {
  16886. const { isError: n, errorObject: s, variants: o } = H(e, t);
  16887. if (n)
  16888. return s;
  16889. const [u, c] = o, l2 = +u.getValue(), f2 = +c.getValue();
  16890. if (Number.isNaN(l2) || Number.isNaN(f2))
  16891. return g2.create(m2.VALUE);
  16892. r = Zt(f2) - Zt(l2);
  16893. } else {
  16894. const { isError: n, errorObject: s, variants: o } = H(e);
  16895. if (n)
  16896. return s;
  16897. const [u] = o, c = +u.getValue();
  16898. if (Number.isNaN(c))
  16899. return g2.create(m2.VALUE);
  16900. r = Zt(c);
  16901. }
  16902. return y2.create(r);
  16903. }
  16904. };
  16905. var $g = class extends V {
  16906. constructor() {
  16907. super(...arguments);
  16908. A(this, "minParams", 1);
  16909. A(this, "maxParams", 1);
  16910. }
  16911. calculate(e) {
  16912. const { isError: t, errorObject: r, variants: n } = H(e);
  16913. if (t)
  16914. return r;
  16915. const [s] = n, o = +s.getValue();
  16916. if (Number.isNaN(o))
  16917. return g2.create(m2.VALUE);
  16918. const u = Zt(o);
  16919. return y2.create(u);
  16920. }
  16921. };
  16922. var Yg = class extends V {
  16923. constructor() {
  16924. super(...arguments);
  16925. A(this, "minParams", 1);
  16926. A(this, "maxParams", 1);
  16927. }
  16928. calculate(e) {
  16929. const { isError: t, errorObject: r, variants: n } = H(e);
  16930. if (t)
  16931. return r;
  16932. const [s] = n, o = +s.getValue();
  16933. if (Number.isNaN(o))
  16934. return g2.create(m2.VALUE);
  16935. const u = Na(o);
  16936. return y2.create(u);
  16937. }
  16938. };
  16939. var Hg = class extends V {
  16940. constructor() {
  16941. super(...arguments);
  16942. A(this, "minParams", 1);
  16943. A(this, "maxParams", 1);
  16944. }
  16945. calculate(e) {
  16946. const { isError: t, errorObject: r, variants: n } = H(e);
  16947. if (t)
  16948. return r;
  16949. const [s] = n, o = +s.getValue();
  16950. if (Number.isNaN(o))
  16951. return g2.create(m2.VALUE);
  16952. const u = Na(o);
  16953. return y2.create(u);
  16954. }
  16955. };
  16956. var Z2 = ((i) => (i.BESSELI = "BESSELI", i.BESSELJ = "BESSELJ", i.BESSELK = "BESSELK", i.BESSELY = "BESSELY", i.BIN2DEC = "BIN2DEC", i.BIN2HEX = "BIN2HEX", i.BIN2OCT = "BIN2OCT", i.BITAND = "BITAND", i.BITLSHIFT = "BITLSHIFT", i.BITOR = "BITOR", i.BITRSHIFT = "BITRSHIFT", i.BITXOR = "BITXOR", i.COMPLEX = "COMPLEX", i.CONVERT = "CONVERT", i.DEC2BIN = "DEC2BIN", i.DEC2HEX = "DEC2HEX", i.DEC2OCT = "DEC2OCT", i.DELTA = "DELTA", i.ERF = "ERF", i.ERF_PRECISE = "ERF.PRECISE", i.ERFC = "ERFC", i.ERFC_PRECISE = "ERFC.PRECISE", i.GESTEP = "GESTEP", i.HEX2BIN = "HEX2BIN", i.HEX2DEC = "HEX2DEC", i.HEX2OCT = "HEX2OCT", i.IMABS = "IMABS", i.IMAGINARY = "IMAGINARY", i.IMARGUMENT = "IMARGUMENT", i.IMCONJUGATE = "IMCONJUGATE", i.IMCOS = "IMCOS", i.IMCOSH = "IMCOSH", i.IMCOT = "IMCOT", i.IMCOTH = "IMCOTH", i.IMCSC = "IMCSC", i.IMCSCH = "IMCSCH", i.IMDIV = "IMDIV", i.IMEXP = "IMEXP", i.IMLN = "IMLN", i.IMLOG = "IMLOG", i.IMLOG10 = "IMLOG10", i.IMLOG2 = "IMLOG2", i.IMPOWER = "IMPOWER", i.IMPRODUCT = "IMPRODUCT", i.IMREAL = "IMREAL", i.IMSEC = "IMSEC", i.IMSECH = "IMSECH", i.IMSIN = "IMSIN", i.IMSINH = "IMSINH", i.IMSQRT = "IMSQRT", i.IMSUB = "IMSUB", i.IMSUM = "IMSUM", i.IMTAN = "IMTAN", i.IMTANH = "IMTANH", i.OCT2BIN = "OCT2BIN", i.OCT2DEC = "OCT2DEC", i.OCT2HEX = "OCT2HEX", i))(Z2 || {});
  16957. var Gg = class extends V {
  16958. constructor() {
  16959. super(...arguments);
  16960. A(this, "minParams", 1);
  16961. A(this, "maxParams", 2);
  16962. }
  16963. calculate(e, t) {
  16964. if (e.isNull())
  16965. return g2.create(m2.NA);
  16966. const r = t != null ? t : y2.create(0), { isError: n, errorObject: s, variants: o } = H(e, r);
  16967. if (n)
  16968. return s;
  16969. const [u, c] = o, l2 = +u.getValue(), f2 = +c.getValue();
  16970. if (Number.isNaN(l2) || Number.isNaN(f2))
  16971. return g2.create(m2.VALUE);
  16972. const h = l2 >= f2 ? 1 : 0;
  16973. return y2.create(h);
  16974. }
  16975. };
  16976. var Qg = class extends V {
  16977. constructor() {
  16978. super(...arguments);
  16979. A(this, "minParams", 1);
  16980. A(this, "maxParams", 2);
  16981. }
  16982. calculate(e, t) {
  16983. if (e.isNull())
  16984. return g2.create(m2.NA);
  16985. let r = 0;
  16986. if (t) {
  16987. const { isError: d2, errorObject: _, variants: C } = H(t);
  16988. if (d2)
  16989. return _;
  16990. const [E2] = C;
  16991. if (r = Math.floor(+E2.getValue()), Number.isNaN(r))
  16992. return g2.create(m2.VALUE);
  16993. if (r < 0 || r > 10)
  16994. return g2.create(m2.NUM);
  16995. }
  16996. const { isError: n, errorObject: s, variants: o } = H(e);
  16997. if (n)
  16998. return s;
  16999. const [u] = o, c = `${u.getValue()}`;
  17000. if (!Va(c))
  17001. return g2.create(m2.NUM);
  17002. const l2 = c.length === 10 && c.substring(0, 1).toLocaleUpperCase() === "F", f2 = l2 ? Number.parseInt(c, 16) - 1099511627776 : Number.parseInt(c, 16);
  17003. if (f2 < -512 || f2 > 511)
  17004. return g2.create(m2.NUM);
  17005. let h;
  17006. if (l2) {
  17007. const d2 = (512 + f2).toString(2);
  17008. h = `1${"0".repeat(9 - d2.length)}${d2}`;
  17009. } else if (h = f2.toString(2), t) {
  17010. if (r < h.length)
  17011. return g2.create(m2.NUM);
  17012. h = "0".repeat(r - h.length) + h;
  17013. }
  17014. return j.create(h);
  17015. }
  17016. };
  17017. var Wg = class extends V {
  17018. constructor() {
  17019. super(...arguments);
  17020. A(this, "minParams", 1);
  17021. A(this, "maxParams", 1);
  17022. }
  17023. calculate(e) {
  17024. const { isError: t, errorObject: r, variants: n } = H(e);
  17025. if (t)
  17026. return r;
  17027. const [s] = n, o = `${s.getValue()}`;
  17028. if (!Va(o))
  17029. return g2.create(m2.NUM);
  17030. let u = Number.parseInt(o, 16);
  17031. return u >= 549755813888 && (u -= 1099511627776), y2.create(u);
  17032. }
  17033. };
  17034. var qg = class extends V {
  17035. constructor() {
  17036. super(...arguments);
  17037. A(this, "minParams", 1);
  17038. A(this, "maxParams", 2);
  17039. }
  17040. calculate(e, t) {
  17041. if (e.isNull())
  17042. return g2.create(m2.NA);
  17043. let r = 0;
  17044. if (t) {
  17045. const { isError: h, errorObject: d2, variants: _ } = H(t);
  17046. if (h)
  17047. return d2;
  17048. const [C] = _;
  17049. if (r = Math.floor(+C.getValue()), Number.isNaN(r))
  17050. return g2.create(m2.VALUE);
  17051. if (r < 0 || r > 10)
  17052. return g2.create(m2.NUM);
  17053. }
  17054. const { isError: n, errorObject: s, variants: o } = H(e);
  17055. if (n)
  17056. return s;
  17057. const [u] = o, c = `${u.getValue()}`;
  17058. if (!Va(c))
  17059. return g2.create(m2.NUM);
  17060. const l2 = Number.parseInt(c, 16);
  17061. if (l2 > 536870911 && l2 < 1098974756864)
  17062. return g2.create(m2.NUM);
  17063. let f2;
  17064. if (l2 >= 1098974756864)
  17065. f2 = (l2 - 1098437885952).toString(8);
  17066. else if (f2 = l2.toString(8), t) {
  17067. if (r < f2.length)
  17068. return g2.create(m2.NUM);
  17069. f2 = "0".repeat(r - f2.length) + f2;
  17070. }
  17071. return j.create(f2);
  17072. }
  17073. };
  17074. var Kg = class extends V {
  17075. constructor() {
  17076. super(...arguments);
  17077. A(this, "minParams", 1);
  17078. A(this, "maxParams", 1);
  17079. }
  17080. calculate(e) {
  17081. const { isError: t, errorObject: r, variants: n } = H(e);
  17082. if (t)
  17083. return r;
  17084. const [s] = n, o = `${s.getValue()}`, u = new fe2(o);
  17085. if (u.isError())
  17086. return g2.create(m2.NUM);
  17087. const c = u.Abs();
  17088. return y2.create(c);
  17089. }
  17090. };
  17091. var Xg = class extends V {
  17092. constructor() {
  17093. super(...arguments);
  17094. A(this, "minParams", 1);
  17095. A(this, "maxParams", 1);
  17096. }
  17097. calculate(e) {
  17098. const { isError: t, errorObject: r, variants: n } = H(e);
  17099. if (t)
  17100. return r;
  17101. const [s] = n, o = `${s.getValue()}`, u = new fe2(o);
  17102. if (u.isError())
  17103. return g2.create(m2.NUM);
  17104. const c = u.getINum();
  17105. return y2.create(c);
  17106. }
  17107. };
  17108. var Zg = class extends V {
  17109. constructor() {
  17110. super(...arguments);
  17111. A(this, "minParams", 1);
  17112. A(this, "maxParams", 1);
  17113. }
  17114. calculate(e) {
  17115. const { isError: t, errorObject: r, variants: n } = H(e);
  17116. if (t)
  17117. return r;
  17118. const [s] = n, o = `${s.getValue()}`, u = new fe2(o);
  17119. if (u.isError())
  17120. return g2.create(m2.NUM);
  17121. if (u.getRealNum() === 0 && u.getINum() === 0)
  17122. return g2.create(m2.DIV_BY_ZERO);
  17123. const c = u.Argument();
  17124. return y2.create(c);
  17125. }
  17126. };
  17127. var zg = class extends V {
  17128. constructor() {
  17129. super(...arguments);
  17130. A(this, "minParams", 1);
  17131. A(this, "maxParams", 1);
  17132. }
  17133. calculate(e) {
  17134. const { isError: t, errorObject: r, variants: n } = H(e);
  17135. if (t)
  17136. return r;
  17137. const [s] = n, o = `${s.getValue()}`, u = new fe2(o);
  17138. if (u.isError())
  17139. return g2.create(m2.NUM);
  17140. const c = u.Conjugate();
  17141. return typeof c == "number" || DC(c) ? y2.create(+c) : j.create(c);
  17142. }
  17143. };
  17144. var Jg = class extends V {
  17145. constructor() {
  17146. super(...arguments);
  17147. A(this, "minParams", 1);
  17148. A(this, "maxParams", 1);
  17149. }
  17150. calculate(e) {
  17151. const { isError: t, errorObject: r, variants: n } = H(e);
  17152. if (t)
  17153. return r;
  17154. const [s] = n, o = `${s.getValue()}`, u = new fe2(o);
  17155. if (u.isError())
  17156. return g2.create(m2.NUM);
  17157. const c = u.Cos();
  17158. return typeof c == "number" || DC(c) ? y2.create(+c) : j.create(c);
  17159. }
  17160. };
  17161. var e1 = class extends V {
  17162. constructor() {
  17163. super(...arguments);
  17164. A(this, "minParams", 1);
  17165. A(this, "maxParams", 1);
  17166. }
  17167. calculate(e) {
  17168. const { isError: t, errorObject: r, variants: n } = H(e);
  17169. if (t)
  17170. return r;
  17171. const [s] = n, o = `${s.getValue()}`, u = new fe2(o);
  17172. if (u.isError())
  17173. return g2.create(m2.NUM);
  17174. const c = u.Cosh();
  17175. return u.isError() ? g2.create(m2.NUM) : typeof c == "number" || DC(c) ? y2.create(+c) : j.create(c);
  17176. }
  17177. };
  17178. var t1 = class extends V {
  17179. constructor() {
  17180. super(...arguments);
  17181. A(this, "minParams", 1);
  17182. A(this, "maxParams", 1);
  17183. }
  17184. calculate(e) {
  17185. const { isError: t, errorObject: r, variants: n } = H(e);
  17186. if (t)
  17187. return r;
  17188. const [s] = n, o = `${s.getValue()}`, u = new fe2(o);
  17189. if (u.isError() || u.getRealNum() === 0 && u.getINum() === 0)
  17190. return g2.create(m2.NUM);
  17191. const c = u.Cot();
  17192. return typeof c == "number" || DC(c) ? y2.create(+c) : j.create(c);
  17193. }
  17194. };
  17195. var r1 = class extends V {
  17196. constructor() {
  17197. super(...arguments);
  17198. A(this, "minParams", 1);
  17199. A(this, "maxParams", 1);
  17200. }
  17201. calculate(e) {
  17202. const { isError: t, errorObject: r, variants: n } = H(e);
  17203. if (t)
  17204. return r;
  17205. const [s] = n, o = `${s.getValue()}`, u = new fe2(o);
  17206. if (u.isError() || u.getRealNum() === 0 && u.getINum() === 0)
  17207. return g2.create(m2.NUM);
  17208. const c = u.Coth();
  17209. return u.isError() ? g2.create(m2.NUM) : typeof c == "number" || DC(c) ? y2.create(+c) : j.create(c);
  17210. }
  17211. };
  17212. var n1 = class extends V {
  17213. constructor() {
  17214. super(...arguments);
  17215. A(this, "minParams", 1);
  17216. A(this, "maxParams", 1);
  17217. }
  17218. calculate(e) {
  17219. const { isError: t, errorObject: r, variants: n } = H(e);
  17220. if (t)
  17221. return r;
  17222. const [s] = n, o = `${s.getValue()}`, u = new fe2(o);
  17223. if (u.isError() || u.getRealNum() === 0 && u.getINum() === 0)
  17224. return g2.create(m2.NUM);
  17225. const c = u.Csc();
  17226. return typeof c == "number" || DC(c) ? y2.create(+c) : j.create(c);
  17227. }
  17228. };
  17229. var s1 = class extends V {
  17230. constructor() {
  17231. super(...arguments);
  17232. A(this, "minParams", 1);
  17233. A(this, "maxParams", 1);
  17234. }
  17235. calculate(e) {
  17236. const { isError: t, errorObject: r, variants: n } = H(e);
  17237. if (t)
  17238. return r;
  17239. const [s] = n, o = `${s.getValue()}`, u = new fe2(o);
  17240. if (u.isError() || u.getRealNum() === 0 && u.getINum() === 0)
  17241. return g2.create(m2.NUM);
  17242. const c = u.Csch();
  17243. return typeof c == "number" || DC(c) ? y2.create(+c) : j.create(c);
  17244. }
  17245. };
  17246. var a1 = class extends V {
  17247. constructor() {
  17248. super(...arguments);
  17249. A(this, "minParams", 2);
  17250. A(this, "maxParams", 2);
  17251. }
  17252. calculate(e, t) {
  17253. if (e.isNull() || t.isNull())
  17254. return g2.create(m2.NA);
  17255. const { isError: r, errorObject: n, variants: s } = H(e, t);
  17256. if (r)
  17257. return n;
  17258. const [o, u] = s, c = `${o.getValue()}`, l2 = `${u.getValue()}`, f2 = new fe2(c), h = new fe2(l2);
  17259. if (f2.isError() || h.isError() || f2.isDifferentSuffixes(h) || h.getRealNum() === 0 && h.getINum() === 0)
  17260. return g2.create(m2.NUM);
  17261. const d2 = f2.Div(h);
  17262. return typeof d2 == "number" || DC(d2) ? y2.create(+d2) : j.create(d2);
  17263. }
  17264. };
  17265. var i1 = class extends V {
  17266. constructor() {
  17267. super(...arguments);
  17268. A(this, "minParams", 1);
  17269. A(this, "maxParams", 1);
  17270. }
  17271. calculate(e) {
  17272. const { isError: t, errorObject: r, variants: n } = H(e);
  17273. if (t)
  17274. return r;
  17275. const [s] = n, o = `${s.getValue()}`, u = new fe2(o);
  17276. if (u.isError())
  17277. return g2.create(m2.NUM);
  17278. const c = u.Exp();
  17279. return u.isError() ? g2.create(m2.NUM) : typeof c == "number" || DC(c) ? y2.create(+c) : j.create(c);
  17280. }
  17281. };
  17282. var o1 = class extends V {
  17283. constructor() {
  17284. super(...arguments);
  17285. A(this, "minParams", 1);
  17286. A(this, "maxParams", 1);
  17287. }
  17288. calculate(e) {
  17289. const { isError: t, errorObject: r, variants: n } = H(e);
  17290. if (t)
  17291. return r;
  17292. const [s] = n, o = `${s.getValue()}`, u = new fe2(o);
  17293. if (u.isError() || u.getRealNum() === 0 && u.getINum() === 0)
  17294. return g2.create(m2.NUM);
  17295. const c = u.Ln();
  17296. return typeof c == "number" || DC(c) ? y2.create(+c) : j.create(c);
  17297. }
  17298. };
  17299. var u1 = class extends V {
  17300. constructor() {
  17301. super(...arguments);
  17302. A(this, "minParams", 1);
  17303. A(this, "maxParams", 2);
  17304. }
  17305. calculate(e, t) {
  17306. const { isError: r, errorObject: n, variants: s } = H(e);
  17307. if (r)
  17308. return n;
  17309. const [o] = s;
  17310. let u = t != null ? t : y2.create(10);
  17311. if (u.isArray()) {
  17312. const b = u.getRowCount(), R = u.getColumnCount();
  17313. if (b > 1 || R > 1)
  17314. return g2.create(m2.VALUE);
  17315. u = u.get(0, 0);
  17316. }
  17317. const { isError: c, errorObject: l2, variants: f2 } = I2(u);
  17318. if (c)
  17319. return l2;
  17320. const [h] = f2, d2 = `${o.getValue()}`, _ = +h.getValue(), C = new fe2(d2);
  17321. if (C.isError() || C.getRealNum() === 0 && C.getINum() === 0 || _ <= 0)
  17322. return g2.create(m2.NUM);
  17323. const E2 = C.Log(_);
  17324. return C.isError() ? g2.create(m2.NUM) : typeof E2 == "number" || DC(E2) ? y2.create(+E2) : j.create(E2);
  17325. }
  17326. };
  17327. var c1 = class extends V {
  17328. constructor() {
  17329. super(...arguments);
  17330. A(this, "minParams", 1);
  17331. A(this, "maxParams", 1);
  17332. }
  17333. calculate(e) {
  17334. const { isError: t, errorObject: r, variants: n } = H(e);
  17335. if (t)
  17336. return r;
  17337. const [s] = n, o = `${s.getValue()}`, u = new fe2(o);
  17338. if (u.isError() || u.getRealNum() === 0 && u.getINum() === 0)
  17339. return g2.create(m2.NUM);
  17340. const c = u.Log(2);
  17341. return typeof c == "number" || DC(c) ? y2.create(+c) : j.create(c);
  17342. }
  17343. };
  17344. var l1 = class extends V {
  17345. constructor() {
  17346. super(...arguments);
  17347. A(this, "minParams", 1);
  17348. A(this, "maxParams", 1);
  17349. }
  17350. calculate(e) {
  17351. const { isError: t, errorObject: r, variants: n } = H(e);
  17352. if (t)
  17353. return r;
  17354. const [s] = n, o = `${s.getValue()}`, u = new fe2(o);
  17355. if (u.isError() || u.getRealNum() === 0 && u.getINum() === 0)
  17356. return g2.create(m2.NUM);
  17357. const c = u.Log(10);
  17358. return typeof c == "number" || DC(c) ? y2.create(+c) : j.create(c);
  17359. }
  17360. };
  17361. var f1 = class extends V {
  17362. constructor() {
  17363. super(...arguments);
  17364. A(this, "minParams", 2);
  17365. A(this, "maxParams", 2);
  17366. }
  17367. calculate(e, t) {
  17368. if (e.isNull() || t.isNull())
  17369. return g2.create(m2.NA);
  17370. const { isError: r, errorObject: n, variants: s } = H(e, t);
  17371. if (r)
  17372. return n;
  17373. const [o, u] = s, c = `${o.getValue()}`, l2 = new fe2(c);
  17374. if (l2.isError())
  17375. return g2.create(m2.NUM);
  17376. const f2 = +u.getValue();
  17377. if (Number.isNaN(f2))
  17378. return g2.create(m2.VALUE);
  17379. const h = l2.Power(f2);
  17380. return l2.isError() ? g2.create(m2.NUM) : typeof h == "number" || DC(h) ? y2.create(+h) : j.create(h);
  17381. }
  17382. };
  17383. var h1 = class extends V {
  17384. constructor() {
  17385. super(...arguments);
  17386. A(this, "minParams", 1);
  17387. A(this, "maxParams", 255);
  17388. }
  17389. calculate(...e) {
  17390. let t = "";
  17391. for (let r = 0; r < e.length; r++) {
  17392. if (t instanceof g2)
  17393. return t;
  17394. const n = e[r];
  17395. if (n.isArray()) {
  17396. let s = false, o;
  17397. if (n.iterator((u) => {
  17398. if (t = this._handleSingleObject(u, t), t instanceof g2)
  17399. return s = true, o = t, false;
  17400. }), s)
  17401. return o;
  17402. } else
  17403. t = this._handleSingleObject(n, t);
  17404. }
  17405. return t instanceof g2 ? t : typeof t == "number" || DC(t) ? y2.create(+t) : j.create(t);
  17406. }
  17407. _handleSingleObject(e, t) {
  17408. let r = t;
  17409. if (e.isError())
  17410. return e;
  17411. if (e.isBoolean())
  17412. return g2.create(m2.VALUE);
  17413. const n = `${e.getValue()}`;
  17414. if (typeof t != "number" && !t) {
  17415. const s = new fe2(n);
  17416. if (s.isError())
  17417. return g2.create(m2.NUM);
  17418. r = s.toString();
  17419. } else {
  17420. const s = new fe2(t), o = new fe2(n);
  17421. if (s.isError() || o.isError())
  17422. return g2.create(m2.NUM);
  17423. if (s.isDifferentSuffixes(o))
  17424. return g2.create(m2.VALUE);
  17425. r = s.Product(o);
  17426. }
  17427. return r;
  17428. }
  17429. };
  17430. var m1 = class extends V {
  17431. constructor() {
  17432. super(...arguments);
  17433. A(this, "minParams", 1);
  17434. A(this, "maxParams", 1);
  17435. }
  17436. calculate(e) {
  17437. const { isError: t, errorObject: r, variants: n } = H(e);
  17438. if (t)
  17439. return r;
  17440. const [s] = n, o = `${s.getValue()}`, u = new fe2(o);
  17441. if (u.isError())
  17442. return g2.create(m2.NUM);
  17443. const c = u.getRealNum();
  17444. return y2.create(c);
  17445. }
  17446. };
  17447. var g1 = class extends V {
  17448. constructor() {
  17449. super(...arguments);
  17450. A(this, "minParams", 1);
  17451. A(this, "maxParams", 1);
  17452. }
  17453. calculate(e) {
  17454. const { isError: t, errorObject: r, variants: n } = H(e);
  17455. if (t)
  17456. return r;
  17457. const [s] = n, o = `${s.getValue()}`, u = new fe2(o);
  17458. if (u.isError())
  17459. return g2.create(m2.NUM);
  17460. const c = u.Sec();
  17461. return typeof c == "number" || DC(c) ? y2.create(+c) : j.create(c);
  17462. }
  17463. };
  17464. var d1 = class extends V {
  17465. constructor() {
  17466. super(...arguments);
  17467. A(this, "minParams", 1);
  17468. A(this, "maxParams", 1);
  17469. }
  17470. calculate(e) {
  17471. const { isError: t, errorObject: r, variants: n } = H(e);
  17472. if (t)
  17473. return r;
  17474. const [s] = n, o = `${s.getValue()}`, u = new fe2(o);
  17475. if (u.isError())
  17476. return g2.create(m2.NUM);
  17477. const c = u.Sech();
  17478. return typeof c == "number" || DC(c) ? y2.create(+c) : j.create(c);
  17479. }
  17480. };
  17481. var C1 = class extends V {
  17482. constructor() {
  17483. super(...arguments);
  17484. A(this, "minParams", 1);
  17485. A(this, "maxParams", 1);
  17486. }
  17487. calculate(e) {
  17488. const { isError: t, errorObject: r, variants: n } = H(e);
  17489. if (t)
  17490. return r;
  17491. const [s] = n, o = `${s.getValue()}`, u = new fe2(o);
  17492. if (u.isError())
  17493. return g2.create(m2.NUM);
  17494. const c = u.Sin();
  17495. return typeof c == "number" || DC(c) ? y2.create(+c) : j.create(c);
  17496. }
  17497. };
  17498. var _1 = class extends V {
  17499. constructor() {
  17500. super(...arguments);
  17501. A(this, "minParams", 1);
  17502. A(this, "maxParams", 1);
  17503. }
  17504. calculate(e) {
  17505. const { isError: t, errorObject: r, variants: n } = H(e);
  17506. if (t)
  17507. return r;
  17508. const [s] = n, o = `${s.getValue()}`, u = new fe2(o);
  17509. if (u.isError())
  17510. return g2.create(m2.NUM);
  17511. const c = u.Sinh();
  17512. return u.isError() ? g2.create(m2.NUM) : typeof c == "number" || DC(c) ? y2.create(+c) : j.create(c);
  17513. }
  17514. };
  17515. var A1 = class extends V {
  17516. constructor() {
  17517. super(...arguments);
  17518. A(this, "minParams", 1);
  17519. A(this, "maxParams", 1);
  17520. }
  17521. calculate(e) {
  17522. const { isError: t, errorObject: r, variants: n } = H(e);
  17523. if (t)
  17524. return r;
  17525. const [s] = n, o = `${s.getValue()}`, u = new fe2(o);
  17526. if (u.isError())
  17527. return g2.create(m2.NUM);
  17528. if (u.getRealNum() === 0 && u.getINum() === 0)
  17529. return y2.create(0);
  17530. const c = u.Sqrt();
  17531. return typeof c == "number" || DC(c) ? y2.create(+c) : j.create(c);
  17532. }
  17533. };
  17534. var E1 = class extends V {
  17535. constructor() {
  17536. super(...arguments);
  17537. A(this, "minParams", 2);
  17538. A(this, "maxParams", 2);
  17539. }
  17540. calculate(e, t) {
  17541. if (e.isNull() || t.isNull())
  17542. return g2.create(m2.NA);
  17543. const { isError: r, errorObject: n, variants: s } = H(e, t);
  17544. if (r)
  17545. return n;
  17546. const [o, u] = s, c = `${o.getValue()}`, l2 = `${u.getValue()}`, f2 = new fe2(c), h = new fe2(l2);
  17547. if (f2.isError() || h.isError() || f2.isDifferentSuffixes(h))
  17548. return g2.create(m2.NUM);
  17549. const d2 = f2.Sub(h);
  17550. return typeof d2 == "number" || DC(d2) ? y2.create(+d2) : j.create(d2);
  17551. }
  17552. };
  17553. var b1 = class extends V {
  17554. constructor() {
  17555. super(...arguments);
  17556. A(this, "minParams", 1);
  17557. A(this, "maxParams", 255);
  17558. }
  17559. calculate(...e) {
  17560. let t = "";
  17561. for (let r = 0; r < e.length; r++) {
  17562. if (t instanceof g2)
  17563. return t;
  17564. const n = e[r];
  17565. if (n.isArray()) {
  17566. let s = false, o;
  17567. if (n.iterator((u) => {
  17568. if (t = this._handleSingleObject(u, t), t instanceof g2)
  17569. return s = true, o = t, false;
  17570. }), s)
  17571. return o;
  17572. } else
  17573. t = this._handleSingleObject(n, t);
  17574. }
  17575. return t instanceof g2 ? t : typeof t == "number" || DC(t) ? y2.create(+t) : j.create(t);
  17576. }
  17577. _handleSingleObject(e, t) {
  17578. let r = t;
  17579. if (e.isError())
  17580. return e;
  17581. if (e.isBoolean())
  17582. return g2.create(m2.VALUE);
  17583. const n = `${e.getValue()}`;
  17584. if (typeof t != "number" && !t) {
  17585. const s = new fe2(n);
  17586. if (s.isError())
  17587. return g2.create(m2.NUM);
  17588. r = s.toString();
  17589. } else {
  17590. const s = new fe2(t), o = new fe2(n);
  17591. if (s.isError() || o.isError())
  17592. return g2.create(m2.NUM);
  17593. if (s.isDifferentSuffixes(o))
  17594. return g2.create(m2.VALUE);
  17595. r = s.Sum(o);
  17596. }
  17597. return r;
  17598. }
  17599. };
  17600. var y1 = class extends V {
  17601. constructor() {
  17602. super(...arguments);
  17603. A(this, "minParams", 1);
  17604. A(this, "maxParams", 1);
  17605. }
  17606. calculate(e) {
  17607. const { isError: t, errorObject: r, variants: n } = H(e);
  17608. if (t)
  17609. return r;
  17610. const [s] = n, o = `${s.getValue()}`, u = new fe2(o);
  17611. if (u.isError())
  17612. return g2.create(m2.NUM);
  17613. const c = u.Tan();
  17614. return typeof c == "number" || DC(c) ? y2.create(+c) : j.create(c);
  17615. }
  17616. };
  17617. var R1 = class extends V {
  17618. constructor() {
  17619. super(...arguments);
  17620. A(this, "minParams", 1);
  17621. A(this, "maxParams", 1);
  17622. }
  17623. calculate(e) {
  17624. const { isError: t, errorObject: r, variants: n } = H(e);
  17625. if (t)
  17626. return r;
  17627. const [s] = n, o = `${s.getValue()}`, u = new fe2(o);
  17628. if (u.isError())
  17629. return g2.create(m2.NUM);
  17630. const c = u.Tanh();
  17631. return u.isError() ? g2.create(m2.NUM) : typeof c == "number" || DC(c) ? y2.create(+c) : j.create(c);
  17632. }
  17633. };
  17634. var p1 = class extends V {
  17635. constructor() {
  17636. super(...arguments);
  17637. A(this, "minParams", 1);
  17638. A(this, "maxParams", 2);
  17639. }
  17640. calculate(e, t) {
  17641. if (e.isNull())
  17642. return g2.create(m2.NA);
  17643. let r = 0;
  17644. if (t) {
  17645. const { isError: d2, errorObject: _, variants: C } = H(t);
  17646. if (d2)
  17647. return _;
  17648. const [E2] = C;
  17649. if (r = Math.floor(+E2.getValue()), Number.isNaN(r))
  17650. return g2.create(m2.VALUE);
  17651. if (r < 0 || r > 10)
  17652. return g2.create(m2.NUM);
  17653. }
  17654. const { isError: n, errorObject: s, variants: o } = H(e);
  17655. if (n)
  17656. return s;
  17657. const [u] = o, c = `${u.getValue()}`;
  17658. if (!pa(c))
  17659. return g2.create(m2.NUM);
  17660. const l2 = c.length === 10 && c.substring(0, 1) === "7", f2 = l2 ? Number.parseInt(c, 8) - 1073741824 : Number.parseInt(c, 8);
  17661. if (f2 < -512 || f2 > 511)
  17662. return g2.create(m2.NUM);
  17663. let h;
  17664. if (l2) {
  17665. const d2 = (512 + f2).toString(2);
  17666. h = `1${"0".repeat(9 - d2.length)}${d2}`;
  17667. } else if (h = f2.toString(2), t) {
  17668. if (r < h.length)
  17669. return g2.create(m2.NUM);
  17670. h = "0".repeat(r - h.length) + h;
  17671. }
  17672. return j.create(h);
  17673. }
  17674. };
  17675. var V1 = class extends V {
  17676. constructor() {
  17677. super(...arguments);
  17678. A(this, "minParams", 1);
  17679. A(this, "maxParams", 1);
  17680. }
  17681. calculate(e) {
  17682. const { isError: t, errorObject: r, variants: n } = H(e);
  17683. if (t)
  17684. return r;
  17685. const [s] = n, o = `${s.getValue()}`;
  17686. if (!pa(o))
  17687. return g2.create(m2.NUM);
  17688. let u = Number.parseInt(o, 8);
  17689. return u >= 536870912 && (u -= 1073741824), y2.create(u);
  17690. }
  17691. };
  17692. var N1 = class extends V {
  17693. constructor() {
  17694. super(...arguments);
  17695. A(this, "minParams", 1);
  17696. A(this, "maxParams", 2);
  17697. }
  17698. calculate(e, t) {
  17699. if (e.isNull())
  17700. return g2.create(m2.NA);
  17701. let r = 0;
  17702. if (t) {
  17703. const { isError: h, errorObject: d2, variants: _ } = H(t);
  17704. if (h)
  17705. return d2;
  17706. const [C] = _;
  17707. if (r = Math.floor(+C.getValue()), Number.isNaN(r))
  17708. return g2.create(m2.VALUE);
  17709. if (r < 0 || r > 10)
  17710. return g2.create(m2.NUM);
  17711. }
  17712. const { isError: n, errorObject: s, variants: o } = H(e);
  17713. if (n)
  17714. return s;
  17715. const [u] = o, c = `${u.getValue()}`;
  17716. if (!pa(c))
  17717. return g2.create(m2.NUM);
  17718. const l2 = Number.parseInt(c, 8);
  17719. let f2;
  17720. if (l2 >= 536870912)
  17721. f2 = `ff${(l2 + 3221225472).toString(16)}`;
  17722. else if (f2 = l2.toString(16), t) {
  17723. if (r < f2.length)
  17724. return g2.create(m2.NUM);
  17725. f2 = "0".repeat(r - f2.length) + f2;
  17726. }
  17727. return j.create(f2.toLocaleUpperCase());
  17728. }
  17729. };
  17730. var O1 = [
  17731. [pg, Z2.BESSELI],
  17732. [Vg, Z2.BESSELJ],
  17733. [Ng, Z2.BESSELK],
  17734. [Og, Z2.BESSELY],
  17735. [Mg, Z2.BIN2DEC],
  17736. [wg, Z2.BIN2HEX],
  17737. [Dg, Z2.BIN2OCT],
  17738. [Sg, Z2.BITAND],
  17739. [Pg, Z2.BITLSHIFT],
  17740. [Lg, Z2.BITOR],
  17741. [xg, Z2.BITRSHIFT],
  17742. [jg, Z2.BITXOR],
  17743. [Ug, Z2.COMPLEX],
  17744. [vg, Z2.CONVERT],
  17745. [Tg, Z2.DEC2BIN],
  17746. [Bg, Z2.DEC2HEX],
  17747. [Ig, Z2.DEC2OCT],
  17748. [Fg, Z2.DELTA],
  17749. [kg, Z2.ERF],
  17750. [$g, Z2.ERF_PRECISE],
  17751. [Yg, Z2.ERFC],
  17752. [Hg, Z2.ERFC_PRECISE],
  17753. [Gg, Z2.GESTEP],
  17754. [Qg, Z2.HEX2BIN],
  17755. [Wg, Z2.HEX2DEC],
  17756. [qg, Z2.HEX2OCT],
  17757. [Kg, Z2.IMABS],
  17758. [Xg, Z2.IMAGINARY],
  17759. [Zg, Z2.IMARGUMENT],
  17760. [zg, Z2.IMCONJUGATE],
  17761. [Jg, Z2.IMCOS],
  17762. [e1, Z2.IMCOSH],
  17763. [t1, Z2.IMCOT],
  17764. [r1, Z2.IMCOTH],
  17765. [n1, Z2.IMCSC],
  17766. [s1, Z2.IMCSCH],
  17767. [a1, Z2.IMDIV],
  17768. [i1, Z2.IMEXP],
  17769. [o1, Z2.IMLN],
  17770. [u1, Z2.IMLOG],
  17771. [l1, Z2.IMLOG10],
  17772. [c1, Z2.IMLOG2],
  17773. [f1, Z2.IMPOWER],
  17774. [h1, Z2.IMPRODUCT],
  17775. [m1, Z2.IMREAL],
  17776. [g1, Z2.IMSEC],
  17777. [d1, Z2.IMSECH],
  17778. [C1, Z2.IMSIN],
  17779. [_1, Z2.IMSINH],
  17780. [A1, Z2.IMSQRT],
  17781. [E1, Z2.IMSUB],
  17782. [b1, Z2.IMSUM],
  17783. [y1, Z2.IMTAN],
  17784. [R1, Z2.IMTANH],
  17785. [p1, Z2.OCT2BIN],
  17786. [V1, Z2.OCT2DEC],
  17787. [N1, Z2.OCT2HEX]
  17788. ];
  17789. var ee = ((i) => (i.ACCRINT = "ACCRINT", i.ACCRINTM = "ACCRINTM", i.AMORDEGRC = "AMORDEGRC", i.AMORLINC = "AMORLINC", i.COUPDAYBS = "COUPDAYBS", i.COUPDAYS = "COUPDAYS", i.COUPDAYSNC = "COUPDAYSNC", i.COUPNCD = "COUPNCD", i.COUPNUM = "COUPNUM", i.COUPPCD = "COUPPCD", i.CUMIPMT = "CUMIPMT", i.CUMPRINC = "CUMPRINC", i.DB = "DB", i.DDB = "DDB", i.DISC = "DISC", i.DOLLARDE = "DOLLARDE", i.DOLLARFR = "DOLLARFR", i.DURATION = "DURATION", i.EFFECT = "EFFECT", i.FV = "FV", i.FVSCHEDULE = "FVSCHEDULE", i.INTRATE = "INTRATE", i.IPMT = "IPMT", i.IRR = "IRR", i.ISPMT = "ISPMT", i.MDURATION = "MDURATION", i.MIRR = "MIRR", i.NOMINAL = "NOMINAL", i.NPER = "NPER", i.NPV = "NPV", i.ODDFPRICE = "ODDFPRICE", i.ODDFYIELD = "ODDFYIELD", i.ODDLPRICE = "ODDLPRICE", i.ODDLYIELD = "ODDLYIELD", i.PDURATION = "PDURATION", i.PMT = "PMT", i.PPMT = "PPMT", i.PRICE = "PRICE", i.PRICEDISC = "PRICEDISC", i.PRICEMAT = "PRICEMAT", i.PV = "PV", i.RATE = "RATE", i.RECEIVED = "RECEIVED", i.RRI = "RRI", i.SLN = "SLN", i.SYD = "SYD", i.TBILLEQ = "TBILLEQ", i.TBILLPRICE = "TBILLPRICE", i.TBILLYIELD = "TBILLYIELD", i.VDB = "VDB", i.XIRR = "XIRR", i.XNPV = "XNPV", i.YIELD = "YIELD", i.YIELDDISC = "YIELDDISC", i.YIELDMAT = "YIELDMAT", i))(ee || {});
  17790. function es(i, a2, e, t) {
  17791. const r = It(i, a2, e), { days: n } = _e2(r, i, t);
  17792. return n;
  17793. }
  17794. function qe(i, a2, e, t) {
  17795. let r;
  17796. if (t === 1) {
  17797. const n = It(i, a2, e);
  17798. let s = re2(n);
  17799. s = Er(s, 12 / e);
  17800. const o = ye2(s);
  17801. n < 0 && e === 1 ? r = 365 : r = o - n;
  17802. } else
  17803. t === 3 ? r = 365 / e : r = 360 / e;
  17804. return r;
  17805. }
  17806. function Eu(i, a2, e) {
  17807. const t = re2(i);
  17808. let r = re2(a2);
  17809. for (r.setUTCFullYear(t.getUTCFullYear()), r < t && r.setUTCFullYear(r.getUTCFullYear() + 1); r > t; )
  17810. r = Er(r, -12 / e);
  17811. return r = Er(r, 12 / e), ye2(r);
  17812. }
  17813. function nr(i, a2, e) {
  17814. let t = 0;
  17815. const r = re2(i);
  17816. let n = re2(a2);
  17817. for (; n > r; )
  17818. n = Er(n, -12 / e), t++;
  17819. return t;
  17820. }
  17821. function It(i, a2, e) {
  17822. const t = re2(i);
  17823. let r = re2(a2);
  17824. for (r.setUTCFullYear(t.getUTCFullYear()), r < t && r.setUTCFullYear(r.getUTCFullYear() + 1); r > t; )
  17825. r = Er(r, -12 / e);
  17826. return ye2(r);
  17827. }
  17828. function bu(i, a2, e, t, r, n) {
  17829. const s = es(i, a2, r, n), o = qe(i, a2, r, n), u = nr(i, a2, r), c = (o - s) / o - 1, l2 = t / r + 1, f2 = e * 100 / r;
  17830. let h = 0, d2 = 0;
  17831. for (let E2 = 1; E2 <= u; E2++) {
  17832. const b = E2 + c, R = f2 / l2 ** b;
  17833. h += b * R, d2 += R;
  17834. }
  17835. const _ = u + c, C = 100 / l2 ** _;
  17836. return h += _ * C, d2 += C, h / d2 / r;
  17837. }
  17838. function Gr(i, a2, e, t, r) {
  17839. let n;
  17840. if (i === 0)
  17841. n = (e + t) / a2;
  17842. else {
  17843. const s = (1 + i) ** a2;
  17844. n = r === 1 ? (t * i / (s - 1) + e * i / (1 - 1 / s)) / (1 + i) : t * i / (s - 1) + e * i / (1 - 1 / s);
  17845. }
  17846. return -n;
  17847. }
  17848. function sr(i, a2, e, t, r) {
  17849. let n;
  17850. if (i === 0)
  17851. n = t + e * a2;
  17852. else {
  17853. if (i === -1 && a2 === 0)
  17854. return Number.NaN;
  17855. const s = (1 + i) ** a2;
  17856. n = r === 1 ? t * s + e * (1 + i) * (s - 1) / i : t * s + e * (s - 1) / i;
  17857. }
  17858. return -n;
  17859. }
  17860. function yu(i, a2, e, t, r, n) {
  17861. const s = Gr(i, e, t, r, n);
  17862. return (a2 === 1 ? n === 1 ? 0 : -t : n === 1 ? sr(i, a2 - 2, s, t, 1) - s : sr(i, a2 - 1, s, t, 0)) * i;
  17863. }
  17864. function Ru(i, a2) {
  17865. let e = 0;
  17866. for (let t = 1; t <= a2.length; t++)
  17867. e += a2[t - 1] / (1 + i) ** t;
  17868. return e;
  17869. }
  17870. function pu(i, a2, e, t, r, n, s, o, u) {
  17871. const c = Kt(e, t, u), l2 = qe(i, t, o, u);
  17872. return c < l2 ? M1(
  17873. i,
  17874. a2,
  17875. e,
  17876. t,
  17877. r,
  17878. n,
  17879. s,
  17880. o,
  17881. u,
  17882. c,
  17883. l2
  17884. ) : w1(
  17885. i,
  17886. a2,
  17887. e,
  17888. t,
  17889. r,
  17890. n,
  17891. s,
  17892. o,
  17893. u,
  17894. l2
  17895. );
  17896. }
  17897. function M1(i, a2, e, t, r, n, s, o, u, c, l2) {
  17898. let f2 = 0;
  17899. const h = nr(i, a2, o), d2 = Kt(i, t, u);
  17900. f2 += s / (1 + n / o) ** (h - 1 + d2 / l2), f2 += 100 * r / o * c / l2 / (1 + n / o) ** (d2 / l2);
  17901. for (let C = 2; C <= h; C++)
  17902. f2 += 100 * r / o / (1 + n / o) ** (C - 1 + d2 / l2);
  17903. const _ = Kt(e, i, u);
  17904. return f2 -= 100 * r / o * _ / l2, f2;
  17905. }
  17906. function w1(i, a2, e, t, r, n, s, o, u, c) {
  17907. let l2 = 0;
  17908. const f2 = nr(t, a2, o), h = D1(t, i, 12 / o);
  17909. let d2;
  17910. if (u === 2 || u === 3) {
  17911. const R = Eu(i, t, o);
  17912. d2 = Kt(i, R, u);
  17913. } else {
  17914. const R = It(i, t, o), { days: p2 } = _e2(R, i, u);
  17915. d2 = c - p2;
  17916. }
  17917. l2 += s / (1 + n / o) ** (f2 + h + d2 / c);
  17918. const _ = nr(e, t, o);
  17919. let C = t, E2 = 0, b = 0;
  17920. for (let R = _; R >= 1; R--) {
  17921. const p2 = Jt(C, -12 / o, false), N2 = u === 1 ? Kt(p2, C, u) : c, M2 = R > 1 ? N2 : Kt(e, C, u);
  17922. E2 += M2 / N2;
  17923. const w = e > p2 ? e : p2, D2 = i < C ? i : C, S2 = Kt(w, D2, u);
  17924. b += S2 / N2, C = p2;
  17925. }
  17926. l2 += 100 * r / o * E2 / (1 + n / o) ** (h + d2 / c);
  17927. for (let R = 1; R <= f2; R++)
  17928. l2 += 100 * r / o / (1 + n / o) ** (R + h + d2 / c);
  17929. return l2 -= 100 * r / o * b, l2;
  17930. }
  17931. function Kt(i, a2, e) {
  17932. const { days: t } = _e2(i, a2, e);
  17933. return i < a2 ? t : 0;
  17934. }
  17935. function Vu(i, a2, e) {
  17936. const t = re2(i), r = t.getUTCFullYear(), n = t.getUTCMonth(), s = t.getUTCDate(), o = Ar(r, n, s), u = re2(a2), c = u.getUTCFullYear(), l2 = u.getUTCMonth(), f2 = u.getUTCDate(), h = Ar(c, l2, f2);
  17937. return !(s !== f2 && !(o && h) || Math.abs((c - r) * 12 + (l2 - n)) % (12 / e) !== 0);
  17938. }
  17939. function Or(i, a2, e) {
  17940. return It(i, a2, e) >= 0;
  17941. }
  17942. function Jt(i, a2, e) {
  17943. let t = re2(i);
  17944. if (t = Er(t, a2), e) {
  17945. const r = t.getUTCFullYear(), n = t.getUTCMonth(), s = Hr(r, n);
  17946. t.setUTCDate(s);
  17947. }
  17948. return ye2(t);
  17949. }
  17950. function D1(i, a2, e, t) {
  17951. const r = re2(i), n = re2(a2), s = r.getUTCFullYear(), o = r.getUTCMonth(), u = r.getUTCDate(), c = n.getUTCFullYear(), l2 = n.getUTCMonth(), f2 = n.getUTCDate(), h = Ar(s, o, u), d2 = !h && o !== 1 && u > 28 && u < Hr(s, o) ? Ar(c, l2, f2) : h, _ = Jt(a2, 0, d2);
  17952. let C = 1 + +(a2 < _), E2 = Jt(_, e, d2);
  17953. for (; !(e > 0 ? E2 >= a2 : E2 <= a2); )
  17954. E2 = Jt(E2, e, d2), C++;
  17955. return C;
  17956. }
  17957. function Ia(i, a2) {
  17958. let n = 1, s = 0, o = i, u;
  17959. for (; n > 1e-7 && s < 500; ) {
  17960. const c = (a2(o + 1e-7) - a2(o - 1e-7)) / 2e-7;
  17961. u = o - a2(o) / c, s++, n = Math.abs(u - o), o = u;
  17962. }
  17963. return Number.isNaN(o) || Math.abs(o) === 1 / 0 || s === 500 ? S1(i, a2) : o;
  17964. }
  17965. function S1(i, a2) {
  17966. const r = Number.MAX_VALUE, n = -1, s = 1.6;
  17967. let o = i - 0.01 <= n ? n + 1e-7 : i - 0.01, u = i + 0.01 >= r ? r - 1e-7 : i + 0.01, c, l2, f2 = 0;
  17968. if (i <= n || i >= r)
  17969. return g2.create(m2.NUM);
  17970. for (let E2 = 0; E2 < 60; E2++) {
  17971. c = o <= n ? n + 1e-7 : o, l2 = u >= r ? r - 1e-7 : u;
  17972. const b = a2(c), R = a2(l2);
  17973. if (b * R <= 0)
  17974. break;
  17975. if (b * R > 0)
  17976. o = c + s * (c - l2), u = l2 + s * (l2 - c);
  17977. else
  17978. return g2.create(m2.NUM);
  17979. if (E2 === 59)
  17980. return g2.create(m2.NUM);
  17981. }
  17982. c = c, l2 = l2;
  17983. let h = a2(c);
  17984. const d2 = a2(l2);
  17985. let _, C;
  17986. if (Math.abs(h) < 1e-7 || Math.abs(d2) < 1e-7)
  17987. return g2.create(m2.NUM);
  17988. do
  17989. C = c + (l2 - c) / 2, _ = a2(C), h * _ < 0 ? l2 = C : c = C, h = a2(c), f2++;
  17990. while (Math.abs(_) > 1e-7 && f2 < 60);
  17991. return C;
  17992. }
  17993. function un(i, a2, e, t, r, n, s) {
  17994. const o = nr(i, a2, n), u = qe(i, a2, n, s), c = es(i, a2, n, s);
  17995. if (o === 1) {
  17996. const h = u - c, d2 = 100 * e / n + r, _ = t / n * h / u + 1, C = 100 * e / n * c / u;
  17997. return d2 / _ - C;
  17998. }
  17999. const l2 = u - c;
  18000. let f2 = r / (1 + t / n) ** (o - 1 + l2 / u);
  18001. for (let h = 1; h <= o; h++)
  18002. f2 += 100 * e / n / (1 + t / n) ** (h - 1 + l2 / u);
  18003. return f2 -= 100 * e / n * c / u, f2;
  18004. }
  18005. function zs(i, a2, e, t, r) {
  18006. let n = 0, s = r / e;
  18007. s >= 1 ? (s = 1, n = t === 1 ? i : 0) : n = i * (1 - s) ** (t - 1);
  18008. const o = i * (1 - s) ** t;
  18009. let u = 0;
  18010. return o < a2 ? u = n - a2 : u = n - o, u < 0 && (u = 0), u;
  18011. }
  18012. var P1 = class extends V {
  18013. constructor() {
  18014. super(...arguments);
  18015. A(this, "minParams", 6);
  18016. A(this, "maxParams", 8);
  18017. }
  18018. calculate(e, t, r, n, s, o, u, c) {
  18019. const l2 = u != null ? u : y2.create(0), f2 = c != null ? c : T2.create(true), { isError: h, errorObject: d2, variants: _ } = H(e, t, r, n, s, o, l2);
  18020. if (h)
  18021. return d2;
  18022. const [C, E2, b, R, p2, N2, M2] = _, w = k(C);
  18023. if (typeof w != "number")
  18024. return w;
  18025. const D2 = k(E2);
  18026. if (typeof D2 != "number")
  18027. return D2;
  18028. const S2 = k(b);
  18029. if (typeof S2 != "number")
  18030. return S2;
  18031. const P = +R.getValue(), U2 = +p2.getValue(), x2 = Math.floor(+N2.getValue()), F = Math.floor(+M2.getValue()), W2 = +f2.getValue();
  18032. return Number.isNaN(P) || Number.isNaN(U2) || Number.isNaN(x2) || Number.isNaN(F) || Number.isNaN(W2) ? g2.create(m2.VALUE) : P <= 0 || U2 <= 0 || ![1, 2, 4].includes(x2) || F < 0 || F > 4 || Math.floor(w) >= Math.floor(S2) ? g2.create(m2.NUM) : this._getResult(w, D2, S2, P, U2, x2, F, W2);
  18033. }
  18034. _getResult(e, t, r, n, s, o, u, c) {
  18035. let l2 = It(e, t, o);
  18036. if (l2 <= 0)
  18037. return y2.create(0);
  18038. l2 = It(r, t, o);
  18039. const f2 = 12 / o, h = re2(t), d2 = h.getUTCFullYear(), _ = h.getUTCMonth(), C = h.getUTCDate(), E2 = Ar(d2, _, C);
  18040. let b = Jt(t, -f2, E2);
  18041. if (r > t && c)
  18042. for (b = t; b < r; )
  18043. b = Jt(b, f2, E2);
  18044. let R = e > b ? e : b, { days: p2 } = _e2(R, r, u);
  18045. if (l2 >= e) {
  18046. const { days: P } = _e2(R, r, u ? 4 : 0);
  18047. p2 = P;
  18048. }
  18049. r < R && (p2 = -p2);
  18050. let N2 = qe(b, t, o, u), M2 = p2 / N2, w = b, D2 = e;
  18051. for (; w > e; ) {
  18052. D2 = w, w = Jt(w, -f2, E2), R = e > w ? e : w;
  18053. const { days: P } = _e2(R, D2, u);
  18054. if (u === 0)
  18055. D2 >= R || e <= w ? p2 = P : p2 = -P, N2 = qe(w, D2, o, u);
  18056. else if (p2 = D2 < R ? -P : P, u === 3)
  18057. N2 = 365 / o;
  18058. else {
  18059. const { days: U2 } = _e2(w, D2, u);
  18060. N2 = D2 < w ? -U2 : U2;
  18061. }
  18062. M2 += e <= w ? c ? 1 : 0 : p2 / N2;
  18063. }
  18064. const S2 = s * n / o * M2;
  18065. return y2.create(S2);
  18066. }
  18067. };
  18068. var L1 = class extends V {
  18069. constructor() {
  18070. super(...arguments);
  18071. A(this, "minParams", 4);
  18072. A(this, "maxParams", 5);
  18073. }
  18074. calculate(e, t, r, n, s) {
  18075. const o = s != null ? s : y2.create(0), { isError: u, errorObject: c, variants: l2 } = H(e, t, r, n, o);
  18076. if (u)
  18077. return c;
  18078. const [f2, h, d2, _, C] = l2, E2 = k(f2);
  18079. if (typeof E2 != "number")
  18080. return E2;
  18081. const b = k(h);
  18082. if (typeof b != "number")
  18083. return b;
  18084. const R = +d2.getValue(), p2 = +_.getValue(), N2 = Math.floor(+C.getValue());
  18085. if (Number.isNaN(R) || Number.isNaN(p2) || Number.isNaN(N2))
  18086. return g2.create(m2.VALUE);
  18087. if (R <= 0 || p2 <= 0 || N2 < 0 || N2 > 4 || Math.floor(E2) > Math.floor(b))
  18088. return g2.create(m2.NUM);
  18089. if (Math.floor(E2) === Math.floor(b))
  18090. return y2.create(0);
  18091. const { days: M2, yearDays: w } = _e2(E2, b, N2), D2 = p2 * R * M2 / w;
  18092. return y2.create(D2);
  18093. }
  18094. };
  18095. var x1 = class extends V {
  18096. constructor() {
  18097. super(...arguments);
  18098. A(this, "minParams", 6);
  18099. A(this, "maxParams", 7);
  18100. }
  18101. calculate(e, t, r, n, s, o, u) {
  18102. const c = u != null ? u : y2.create(0), { isError: l2, errorObject: f2, variants: h } = H(e, t, r, n, s, o, c);
  18103. if (l2)
  18104. return f2;
  18105. const [d2, _, C, E2, b, R, p2] = h, N2 = k(_);
  18106. if (typeof N2 != "number")
  18107. return N2;
  18108. const M2 = k(C);
  18109. if (typeof M2 != "number")
  18110. return M2;
  18111. const w = +d2.getValue(), D2 = +E2.getValue();
  18112. let S2 = +b.getValue();
  18113. const P = +R.getValue(), U2 = Math.floor(+p2.getValue());
  18114. return Number.isNaN(w) || Number.isNaN(D2) || Number.isNaN(S2) || Number.isNaN(P) || Number.isNaN(U2) ? g2.create(m2.VALUE) : w <= 0 || D2 < 0 || w < D2 || Math.floor(N2) > Math.floor(M2) || S2 < 0 || P <= 0 || ![0, 1, 3, 4].includes(U2) ? g2.create(m2.NUM) : (S2 > 1 ? S2 = Math.floor(S2) : S2 = Math.ceil(S2), this._getResult(w, N2, M2, D2, S2, P, U2));
  18115. }
  18116. _getResult(e, t, r, n, s, o, u) {
  18117. const c = e - n, l2 = e * o, { days: f2, yearDays: h } = _e2(t, r, u), d2 = f2 / h, _ = Math.ceil(c / l2 - d2);
  18118. if (_ < 0)
  18119. return y2.create(0);
  18120. let C = l2;
  18121. return s === 0 ? C = l2 * d2 : s === _ ? C = c - l2 * (d2 + s - 1) : s > _ && (C = 0), y2.create(C);
  18122. }
  18123. };
  18124. var j1 = class extends V {
  18125. constructor() {
  18126. super(...arguments);
  18127. A(this, "minParams", 3);
  18128. A(this, "maxParams", 4);
  18129. }
  18130. calculate(e, t, r, n) {
  18131. const s = n != null ? n : y2.create(0), { isError: o, errorObject: u, variants: c } = H(e, t, r, s);
  18132. if (o)
  18133. return u;
  18134. const [l2, f2, h, d2] = c, _ = k(l2);
  18135. if (typeof _ != "number")
  18136. return _;
  18137. const C = k(f2);
  18138. if (typeof C != "number")
  18139. return C;
  18140. const E2 = Math.floor(+h.getValue()), b = Math.floor(+d2.getValue());
  18141. if (Number.isNaN(E2) || Number.isNaN(b))
  18142. return g2.create(m2.VALUE);
  18143. if (![1, 2, 4].includes(E2) || b < 0 || b > 4 || Math.floor(_) >= Math.floor(C))
  18144. return g2.create(m2.NUM);
  18145. const R = es(_, C, E2, b);
  18146. return y2.create(R);
  18147. }
  18148. };
  18149. var U1 = class extends V {
  18150. constructor() {
  18151. super(...arguments);
  18152. A(this, "minParams", 3);
  18153. A(this, "maxParams", 4);
  18154. }
  18155. calculate(e, t, r, n) {
  18156. const s = n != null ? n : y2.create(0), { isError: o, errorObject: u, variants: c } = H(e, t, r, s);
  18157. if (o)
  18158. return u;
  18159. const [l2, f2, h, d2] = c, _ = k(l2);
  18160. if (typeof _ != "number")
  18161. return _;
  18162. const C = k(f2);
  18163. if (typeof C != "number")
  18164. return C;
  18165. const E2 = Math.floor(+h.getValue()), b = Math.floor(+d2.getValue());
  18166. if (Number.isNaN(E2) || Number.isNaN(b))
  18167. return g2.create(m2.VALUE);
  18168. if (![1, 2, 4].includes(E2) || b < 0 || b > 4 || Math.floor(_) >= Math.floor(C))
  18169. return g2.create(m2.NUM);
  18170. const R = qe(_, C, E2, b);
  18171. return y2.create(R);
  18172. }
  18173. };
  18174. var v1 = class extends V {
  18175. constructor() {
  18176. super(...arguments);
  18177. A(this, "minParams", 3);
  18178. A(this, "maxParams", 4);
  18179. }
  18180. calculate(e, t, r, n) {
  18181. const s = n != null ? n : y2.create(0), { isError: o, errorObject: u, variants: c } = H(e, t, r, s);
  18182. if (o)
  18183. return u;
  18184. const [l2, f2, h, d2] = c, _ = k(l2);
  18185. if (typeof _ != "number")
  18186. return _;
  18187. const C = k(f2);
  18188. if (typeof C != "number")
  18189. return C;
  18190. const E2 = Math.floor(+h.getValue()), b = Math.floor(+d2.getValue());
  18191. if (Number.isNaN(E2) || Number.isNaN(b))
  18192. return g2.create(m2.VALUE);
  18193. if (![1, 2, 4].includes(E2) || b < 0 || b > 4 || Math.floor(_) >= Math.floor(C))
  18194. return g2.create(m2.NUM);
  18195. const R = re2(_), p2 = re2(C);
  18196. for (p2.setUTCFullYear(R.getUTCFullYear()), p2 < R && p2.setUTCFullYear(p2.getUTCFullYear() + 1); p2 > R; )
  18197. p2.setUTCMonth(p2.getUTCMonth() - 12 / E2);
  18198. p2.setUTCMonth(p2.getUTCMonth() + 12 / E2);
  18199. const N2 = ye2(p2), { days: M2 } = _e2(_, N2, b);
  18200. return y2.create(M2);
  18201. }
  18202. };
  18203. var T1 = class extends V {
  18204. constructor() {
  18205. super(...arguments);
  18206. A(this, "minParams", 3);
  18207. A(this, "maxParams", 4);
  18208. }
  18209. calculate(e, t, r, n) {
  18210. const s = n != null ? n : y2.create(0), { isError: o, errorObject: u, variants: c } = H(e, t, r, s);
  18211. if (o)
  18212. return u;
  18213. const [l2, f2, h, d2] = c, _ = k(l2);
  18214. if (typeof _ != "number")
  18215. return _;
  18216. const C = k(f2);
  18217. if (typeof C != "number")
  18218. return C;
  18219. const E2 = Math.floor(+h.getValue()), b = Math.floor(+d2.getValue());
  18220. if (Number.isNaN(E2) || Number.isNaN(b))
  18221. return g2.create(m2.VALUE);
  18222. if (![1, 2, 4].includes(E2) || b < 0 || b > 4 || Math.floor(_) >= Math.floor(C))
  18223. return g2.create(m2.NUM);
  18224. const R = Eu(_, C, E2);
  18225. return y2.create(R);
  18226. }
  18227. };
  18228. var B1 = class extends V {
  18229. constructor() {
  18230. super(...arguments);
  18231. A(this, "minParams", 3);
  18232. A(this, "maxParams", 4);
  18233. }
  18234. calculate(e, t, r, n) {
  18235. const s = n != null ? n : y2.create(0), { isError: o, errorObject: u, variants: c } = H(e, t, r, s);
  18236. if (o)
  18237. return u;
  18238. const [l2, f2, h, d2] = c, _ = k(l2);
  18239. if (typeof _ != "number")
  18240. return _;
  18241. const C = k(f2);
  18242. if (typeof C != "number")
  18243. return C;
  18244. const E2 = Math.floor(+h.getValue()), b = Math.floor(+d2.getValue());
  18245. if (Number.isNaN(E2) || Number.isNaN(b))
  18246. return g2.create(m2.VALUE);
  18247. if (![1, 2, 4].includes(E2) || b < 0 || b > 4 || Math.floor(_) >= Math.floor(C) || It(_, C, E2) < 0)
  18248. return g2.create(m2.NUM);
  18249. const p2 = nr(_, C, E2);
  18250. return y2.create(p2);
  18251. }
  18252. };
  18253. var I1 = class extends V {
  18254. constructor() {
  18255. super(...arguments);
  18256. A(this, "minParams", 3);
  18257. A(this, "maxParams", 4);
  18258. }
  18259. calculate(e, t, r, n) {
  18260. const s = n != null ? n : y2.create(0), { isError: o, errorObject: u, variants: c } = H(e, t, r, s);
  18261. if (o)
  18262. return u;
  18263. const [l2, f2, h, d2] = c, _ = k(l2);
  18264. if (typeof _ != "number")
  18265. return _;
  18266. const C = k(f2);
  18267. if (typeof C != "number")
  18268. return C;
  18269. const E2 = Math.floor(+h.getValue()), b = Math.floor(+d2.getValue());
  18270. if (Number.isNaN(E2) || Number.isNaN(b))
  18271. return g2.create(m2.VALUE);
  18272. if (![1, 2, 4].includes(E2) || b < 0 || b > 4 || Math.floor(_) >= Math.floor(C))
  18273. return g2.create(m2.NUM);
  18274. let R = It(_, C, E2);
  18275. return R < 0 && (R = 0), y2.create(R);
  18276. }
  18277. };
  18278. var F1 = class extends V {
  18279. constructor() {
  18280. super(...arguments);
  18281. A(this, "minParams", 6);
  18282. A(this, "maxParams", 6);
  18283. }
  18284. calculate(e, t, r, n, s, o) {
  18285. const { isError: u, errorObject: c, variants: l2 } = H(e, t, r, n, s, o);
  18286. if (u)
  18287. return c;
  18288. const [f2, h, d2, _, C, E2] = l2, b = +f2.getValue(), R = +h.getValue(), p2 = +d2.getValue(), N2 = +_.getValue(), M2 = +C.getValue(), w = +E2.getValue();
  18289. return Number.isNaN(b) || Number.isNaN(R) || Number.isNaN(p2) || Number.isNaN(N2) || Number.isNaN(M2) || Number.isNaN(w) ? g2.create(m2.VALUE) : b <= 0 || R <= 0 || p2 <= 0 || N2 < 1 || M2 < 1 || N2 > M2 || N2 > R || M2 > R || ![0, 1].includes(w) ? g2.create(m2.NUM) : Math.trunc(N2) !== N2 && Math.trunc(M2) !== M2 && Math.trunc(N2) === Math.trunc(M2) ? y2.create(0) : this._getResult(b, R, p2, N2, M2, w);
  18290. }
  18291. _getResult(e, t, r, n, s, o) {
  18292. const u = Gr(e, t, r, 0, o);
  18293. let c = 0, l2 = Math.ceil(n);
  18294. l2 === 1 && (o === 0 && (c = -r), l2++);
  18295. let f2 = false;
  18296. for (let h = l2; h <= s; h++) {
  18297. const d2 = o === 1 ? sr(e, h - 2, u, r, 1) : sr(e, h - 1, u, r, 0);
  18298. if (d2 === 0) {
  18299. f2 = true;
  18300. break;
  18301. }
  18302. c += o === 1 ? d2 - u : d2;
  18303. }
  18304. return c *= e, (c < u * (s - n + 1) || f2) && (c = u * (s - n + 1)), y2.create(c);
  18305. }
  18306. };
  18307. var k1 = class extends V {
  18308. constructor() {
  18309. super(...arguments);
  18310. A(this, "minParams", 6);
  18311. A(this, "maxParams", 6);
  18312. }
  18313. calculate(e, t, r, n, s, o) {
  18314. const { isError: u, errorObject: c, variants: l2 } = H(e, t, r, n, s, o);
  18315. if (u)
  18316. return c;
  18317. const [f2, h, d2, _, C, E2] = l2, b = +f2.getValue(), R = +h.getValue(), p2 = +d2.getValue(), N2 = +_.getValue(), M2 = +C.getValue(), w = +E2.getValue();
  18318. return Number.isNaN(b) || Number.isNaN(R) || Number.isNaN(p2) || Number.isNaN(N2) || Number.isNaN(M2) || Number.isNaN(w) ? g2.create(m2.VALUE) : b <= 0 || R <= 0 || p2 <= 0 || N2 < 1 || M2 < 1 || N2 > M2 || ![0, 1].includes(w) ? g2.create(m2.NUM) : Math.trunc(N2) !== N2 && Math.trunc(M2) !== M2 && Math.trunc(N2) === Math.trunc(M2) ? y2.create(0) : this._getResult(b, R, p2, N2, M2, w);
  18319. }
  18320. _getResult(e, t, r, n, s, o) {
  18321. const u = Gr(e, t, r, 0, o);
  18322. let c = 0, l2 = Math.ceil(n);
  18323. l2 === 1 && (c = o === 0 ? u + r * e : u, l2++);
  18324. for (let f2 = l2; f2 <= s; f2++)
  18325. c += o === 1 ? u - (sr(e, f2 - 2, u, r, 1) - u) * e : u - sr(e, f2 - 1, u, r, 0) * e;
  18326. return y2.create(c);
  18327. }
  18328. };
  18329. var $1 = class extends V {
  18330. constructor() {
  18331. super(...arguments);
  18332. A(this, "minParams", 4);
  18333. A(this, "maxParams", 5);
  18334. A(this, "needsLocale", true);
  18335. }
  18336. calculate(e, t, r, n, s) {
  18337. let o = s != null ? s : y2.create(12);
  18338. o.isNull() && (o = y2.create(12));
  18339. const u = Math.max(
  18340. e.isArray() ? e.getRowCount() : 1,
  18341. t.isArray() ? t.getRowCount() : 1,
  18342. r.isArray() ? r.getRowCount() : 1,
  18343. n.isArray() ? n.getRowCount() : 1,
  18344. o.isArray() ? o.getRowCount() : 1
  18345. ), c = Math.max(
  18346. e.isArray() ? e.getColumnCount() : 1,
  18347. t.isArray() ? t.getColumnCount() : 1,
  18348. r.isArray() ? r.getColumnCount() : 1,
  18349. n.isArray() ? n.getColumnCount() : 1,
  18350. o.isArray() ? o.getColumnCount() : 1
  18351. ), l2 = O(u, c, e, g2.create(m2.NA)), f2 = O(u, c, t, g2.create(m2.NA)), h = O(u, c, r, g2.create(m2.NA)), d2 = O(u, c, n, g2.create(m2.NA)), _ = O(u, c, o, g2.create(m2.NA)), C = l2.map((E2, b, R) => {
  18352. const p2 = f2.get(b, R), N2 = h.get(b, R), M2 = d2.get(b, R), w = _.get(b, R), { isError: D2, errorObject: S2, variants: P } = I2(E2, p2, N2, M2, w);
  18353. if (D2)
  18354. return S2;
  18355. const [U2, x2, F, W2, ne] = P, z = +U2.getValue(), G2 = +x2.getValue(), ge2 = +F.getValue();
  18356. let de2 = +W2.getValue();
  18357. const Ee = Math.floor(+ne.getValue());
  18358. return z < 0 || G2 < 0 || ge2 <= 0 || de2 <= 0 || Math.floor(de2) > Math.floor(ge2) || Ee < 1 || Ee > 12 ? g2.create(m2.NUM) : (de2 < 1 && (de2 = 1), de2 = Math.floor(de2), this._getResult(z, G2, ge2, de2, Ee, b, R));
  18359. });
  18360. return u === 1 && c === 1 ? C.get(0, 0) : C;
  18361. }
  18362. _getResult(e, t, r, n, s, o, u) {
  18363. const c = +(1 - (t / e) ** (1 / r)).toFixed(3), l2 = e * c * s / 12;
  18364. let f2 = l2, h = 0;
  18365. const d2 = n === r ? r - 1 : n;
  18366. for (let C = 2; C <= d2; C++)
  18367. h = (e - f2) * c, f2 += h;
  18368. let _;
  18369. return n === 1 ? _ = l2 : n === r ? _ = (e - f2) * c : _ = h, Number.isNaN(_) || !Number.isFinite(_) ? g2.create(m2.NUM) : o === 0 && u === 0 ? y2.create(_, Ke(this.getLocale())) : y2.create(_);
  18370. }
  18371. };
  18372. var Y1 = class extends V {
  18373. constructor() {
  18374. super(...arguments);
  18375. A(this, "minParams", 4);
  18376. A(this, "maxParams", 5);
  18377. A(this, "needsLocale", true);
  18378. }
  18379. calculate(e, t, r, n, s) {
  18380. let o = s != null ? s : y2.create(2);
  18381. o.isNull() && (o = y2.create(2));
  18382. const u = Math.max(
  18383. e.isArray() ? e.getRowCount() : 1,
  18384. t.isArray() ? t.getRowCount() : 1,
  18385. r.isArray() ? r.getRowCount() : 1,
  18386. n.isArray() ? n.getRowCount() : 1,
  18387. o.isArray() ? o.getRowCount() : 1
  18388. ), c = Math.max(
  18389. e.isArray() ? e.getColumnCount() : 1,
  18390. t.isArray() ? t.getColumnCount() : 1,
  18391. r.isArray() ? r.getColumnCount() : 1,
  18392. n.isArray() ? n.getColumnCount() : 1,
  18393. o.isArray() ? o.getColumnCount() : 1
  18394. ), l2 = O(u, c, e, g2.create(m2.NA)), f2 = O(u, c, t, g2.create(m2.NA)), h = O(u, c, r, g2.create(m2.NA)), d2 = O(u, c, n, g2.create(m2.NA)), _ = O(u, c, o, g2.create(m2.NA)), C = l2.map((E2, b, R) => {
  18395. const p2 = f2.get(b, R), N2 = h.get(b, R), M2 = d2.get(b, R), w = _.get(b, R), { isError: D2, errorObject: S2, variants: P } = I2(E2, p2, N2, M2, w);
  18396. if (D2)
  18397. return S2;
  18398. const [U2, x2, F, W2, ne] = P, z = +U2.getValue(), G2 = +x2.getValue(), ge2 = +F.getValue(), de2 = +W2.getValue(), Ee = +ne.getValue();
  18399. if (z < 0 || G2 < 0 || ge2 <= 0 || de2 <= 0 || de2 > ge2 || Ee <= 0)
  18400. return g2.create(m2.NUM);
  18401. const Re2 = zs(z, G2, ge2, de2, Ee);
  18402. return Number.isNaN(Re2) || !Number.isFinite(Re2) ? g2.create(m2.NUM) : b === 0 && R === 0 ? y2.create(Re2, Ke(this.getLocale())) : y2.create(Re2);
  18403. });
  18404. return u === 1 && c === 1 ? C.get(0, 0) : C;
  18405. }
  18406. };
  18407. var H1 = class extends V {
  18408. constructor() {
  18409. super(...arguments);
  18410. A(this, "minParams", 4);
  18411. A(this, "maxParams", 5);
  18412. }
  18413. calculate(e, t, r, n, s) {
  18414. const o = s != null ? s : y2.create(0), { isError: u, errorObject: c, variants: l2 } = H(e, t, r, n, o);
  18415. if (u)
  18416. return c;
  18417. const [f2, h, d2, _, C] = l2, E2 = k(f2);
  18418. if (typeof E2 != "number")
  18419. return E2;
  18420. const b = k(h);
  18421. if (typeof b != "number")
  18422. return b;
  18423. const R = +d2.getValue(), p2 = +_.getValue(), N2 = Math.floor(+C.getValue());
  18424. if (Number.isNaN(R) || Number.isNaN(p2) || Number.isNaN(N2))
  18425. return g2.create(m2.VALUE);
  18426. if (R <= 0 || p2 <= 0 || N2 < 0 || N2 > 4 || Math.floor(E2) >= Math.floor(b))
  18427. return g2.create(m2.NUM);
  18428. const { days: M2, yearDays: w } = _e2(E2, b, N2), D2 = (p2 - R) / p2 * (w / M2);
  18429. return y2.create(D2);
  18430. }
  18431. };
  18432. var G1 = class extends V {
  18433. constructor() {
  18434. super(...arguments);
  18435. A(this, "minParams", 2);
  18436. A(this, "maxParams", 2);
  18437. }
  18438. calculate(e, t) {
  18439. const { isError: r, errorObject: n, variants: s } = H(e, t);
  18440. if (r)
  18441. return n;
  18442. const [o, u] = s, c = +o.getValue();
  18443. let l2 = Math.floor(+u.getValue());
  18444. if (Number.isNaN(c) || Number.isNaN(l2))
  18445. return g2.create(m2.VALUE);
  18446. if (l2 < 0)
  18447. return g2.create(m2.NUM);
  18448. if (l2 >= 0 && l2 < 1)
  18449. return g2.create(m2.DIV_BY_ZERO);
  18450. l2 = Number.parseInt(`${l2}`, 10);
  18451. let f2 = Number.parseInt(`${c}`, 10);
  18452. f2 += c % 1 * 10 ** Math.ceil(Math.log(l2) / Math.LN10) / l2;
  18453. const h = 10 ** (Math.ceil(Math.log(l2) / Math.LN2) + 1);
  18454. return f2 = Math.round(f2 * h) / h, y2.create(f2);
  18455. }
  18456. };
  18457. var Q1 = class extends V {
  18458. constructor() {
  18459. super(...arguments);
  18460. A(this, "minParams", 2);
  18461. A(this, "maxParams", 2);
  18462. }
  18463. calculate(e, t) {
  18464. const { isError: r, errorObject: n, variants: s } = H(e, t);
  18465. if (r)
  18466. return n;
  18467. const [o, u] = s, c = +o.getValue();
  18468. let l2 = Math.floor(+u.getValue());
  18469. if (Number.isNaN(c) || Number.isNaN(l2))
  18470. return g2.create(m2.VALUE);
  18471. if (l2 < 0)
  18472. return g2.create(m2.NUM);
  18473. if (l2 >= 0 && l2 < 1)
  18474. return g2.create(m2.DIV_BY_ZERO);
  18475. l2 = Number.parseInt(`${l2}`, 10);
  18476. let f2 = Number.parseInt(`${c}`, 10);
  18477. return f2 += c % 1 * 10 ** -Math.ceil(Math.log(l2) / Math.LN10) * l2, y2.create(f2);
  18478. }
  18479. };
  18480. var W1 = class extends V {
  18481. constructor() {
  18482. super(...arguments);
  18483. A(this, "minParams", 5);
  18484. A(this, "maxParams", 6);
  18485. }
  18486. calculate(e, t, r, n, s, o) {
  18487. let u = o != null ? o : y2.create(0);
  18488. u.isNull() && (u = y2.create(0));
  18489. const { isError: c, errorObject: l2, variants: f2 } = Fe2(e, t, r, n, s, u);
  18490. if (c)
  18491. return l2;
  18492. const [h, d2, _, C, E2, b] = f2, R = k(h);
  18493. if (typeof R != "number")
  18494. return R;
  18495. const p2 = k(d2);
  18496. if (typeof p2 != "number")
  18497. return p2;
  18498. const N2 = +_.getValue(), M2 = +C.getValue(), w = Math.floor(+E2.getValue()), D2 = Math.floor(+b.getValue());
  18499. if (Number.isNaN(N2) || Number.isNaN(M2) || Number.isNaN(w) || Number.isNaN(D2))
  18500. return g2.create(m2.VALUE);
  18501. if (N2 < 0 || M2 < 0 || ![1, 2, 4].includes(w) || D2 < 0 || D2 > 4 || Math.floor(R) >= Math.floor(p2) || R <= 0 || p2 <= 366)
  18502. return g2.create(m2.NUM);
  18503. const S2 = bu(R, p2, N2, M2, w, D2);
  18504. return y2.create(S2);
  18505. }
  18506. };
  18507. var q1 = class extends V {
  18508. constructor() {
  18509. super(...arguments);
  18510. A(this, "minParams", 2);
  18511. A(this, "maxParams", 2);
  18512. }
  18513. calculate(e, t) {
  18514. const { isError: r, errorObject: n, variants: s } = H(e, t);
  18515. if (r)
  18516. return n;
  18517. const [o, u] = s, c = +o.getValue();
  18518. let l2 = Math.floor(+u.getValue());
  18519. if (Number.isNaN(c) || Number.isNaN(l2))
  18520. return g2.create(m2.VALUE);
  18521. if (c <= 0 || l2 < 1)
  18522. return g2.create(m2.NUM);
  18523. l2 = Number.parseInt(`${l2}`, 10);
  18524. const f2 = (1 + c / l2) ** l2 - 1;
  18525. return y2.create(f2);
  18526. }
  18527. };
  18528. var K1 = class extends V {
  18529. constructor() {
  18530. super(...arguments);
  18531. A(this, "minParams", 3);
  18532. A(this, "maxParams", 5);
  18533. A(this, "needsLocale", true);
  18534. }
  18535. calculate(e, t, r, n, s) {
  18536. const o = n != null ? n : y2.create(0), u = s != null ? s : y2.create(0), c = Math.max(
  18537. e.isArray() ? e.getRowCount() : 1,
  18538. t.isArray() ? t.getRowCount() : 1,
  18539. r.isArray() ? r.getRowCount() : 1,
  18540. o.isArray() ? o.getRowCount() : 1,
  18541. u.isArray() ? u.getRowCount() : 1
  18542. ), l2 = Math.max(
  18543. e.isArray() ? e.getColumnCount() : 1,
  18544. t.isArray() ? t.getColumnCount() : 1,
  18545. r.isArray() ? r.getColumnCount() : 1,
  18546. o.isArray() ? o.getColumnCount() : 1,
  18547. u.isArray() ? u.getColumnCount() : 1
  18548. ), f2 = O(c, l2, e, g2.create(m2.NA)), h = O(c, l2, t, g2.create(m2.NA)), d2 = O(c, l2, r, g2.create(m2.NA)), _ = O(c, l2, o, g2.create(m2.NA)), C = O(c, l2, u, g2.create(m2.NA)), E2 = f2.map((b, R, p2) => {
  18549. const N2 = h.get(R, p2), M2 = d2.get(R, p2), w = _.get(R, p2), D2 = C.get(R, p2), { isError: S2, errorObject: P, variants: U2 } = I2(b, N2, M2, w, D2);
  18550. if (S2)
  18551. return P;
  18552. const [x2, F, W2, ne, z] = U2, G2 = +x2.getValue(), ge2 = +F.getValue(), de2 = +W2.getValue(), Ee = +ne.getValue(), Re2 = +z.getValue(), he2 = sr(G2, ge2, de2, Ee, Re2 ? 1 : 0);
  18553. return Number.isNaN(he2) || !Number.isFinite(he2) ? g2.create(m2.NUM) : R === 0 && p2 === 0 ? y2.create(he2, Ke(this.getLocale())) : y2.create(he2);
  18554. });
  18555. return c === 1 && l2 === 1 ? E2.get(0, 0) : E2;
  18556. }
  18557. };
  18558. var X1 = class extends V {
  18559. constructor() {
  18560. super(...arguments);
  18561. A(this, "minParams", 2);
  18562. A(this, "maxParams", 2);
  18563. }
  18564. calculate(e, t) {
  18565. const { isError: r, errorObject: n, variants: s } = H(e);
  18566. if (r)
  18567. return n;
  18568. const [o] = s, u = +o.getValue();
  18569. if (Number.isNaN(u))
  18570. return g2.create(m2.VALUE);
  18571. let c = u;
  18572. if (t.isArray()) {
  18573. const l2 = t.getArrayValue().flat();
  18574. for (let f2 = 0; f2 < l2.length; f2++) {
  18575. const h = l2[f2];
  18576. if (h.isBoolean())
  18577. return g2.create(m2.VALUE);
  18578. const d2 = +h.getValue();
  18579. if (Number.isNaN(d2))
  18580. return g2.create(m2.VALUE);
  18581. c *= 1 + d2;
  18582. }
  18583. } else {
  18584. if (t.isBoolean())
  18585. return g2.create(m2.VALUE);
  18586. const l2 = +t.getValue();
  18587. if (Number.isNaN(l2))
  18588. return g2.create(m2.VALUE);
  18589. c *= 1 + l2;
  18590. }
  18591. return y2.create(c);
  18592. }
  18593. };
  18594. var Z1 = class extends V {
  18595. constructor() {
  18596. super(...arguments);
  18597. A(this, "minParams", 4);
  18598. A(this, "maxParams", 5);
  18599. }
  18600. calculate(e, t, r, n, s) {
  18601. const o = s != null ? s : y2.create(0), { isError: u, errorObject: c, variants: l2 } = H(e, t, r, n, o);
  18602. if (u)
  18603. return c;
  18604. const [f2, h, d2, _, C] = l2, E2 = k(f2);
  18605. if (typeof E2 != "number")
  18606. return E2;
  18607. const b = k(h);
  18608. if (typeof b != "number")
  18609. return b;
  18610. const R = +d2.getValue(), p2 = +_.getValue(), N2 = Math.floor(+C.getValue());
  18611. if (Number.isNaN(R) || Number.isNaN(p2) || Number.isNaN(N2))
  18612. return g2.create(m2.VALUE);
  18613. if (R <= 0 || p2 <= 0 || N2 < 0 || N2 > 4 || Math.floor(E2) >= Math.floor(b))
  18614. return g2.create(m2.NUM);
  18615. const { days: M2, yearDays: w } = _e2(E2, b, N2), D2 = (p2 - R) / R * (w / M2);
  18616. return y2.create(D2);
  18617. }
  18618. };
  18619. var z1 = class extends V {
  18620. constructor() {
  18621. super(...arguments);
  18622. A(this, "minParams", 4);
  18623. A(this, "maxParams", 6);
  18624. A(this, "needsLocale", true);
  18625. }
  18626. calculate(e, t, r, n, s, o) {
  18627. const u = s != null ? s : y2.create(0), c = o != null ? o : y2.create(0), l2 = Math.max(
  18628. e.isArray() ? e.getRowCount() : 1,
  18629. t.isArray() ? t.getRowCount() : 1,
  18630. r.isArray() ? r.getRowCount() : 1,
  18631. n.isArray() ? n.getRowCount() : 1,
  18632. u.isArray() ? u.getRowCount() : 1,
  18633. c.isArray() ? c.getRowCount() : 1
  18634. ), f2 = Math.max(
  18635. e.isArray() ? e.getColumnCount() : 1,
  18636. t.isArray() ? t.getColumnCount() : 1,
  18637. r.isArray() ? r.getColumnCount() : 1,
  18638. n.isArray() ? n.getColumnCount() : 1,
  18639. u.isArray() ? u.getColumnCount() : 1,
  18640. c.isArray() ? c.getColumnCount() : 1
  18641. ), h = O(l2, f2, e, g2.create(m2.NA)), d2 = O(l2, f2, t, g2.create(m2.NA)), _ = O(l2, f2, r, g2.create(m2.NA)), C = O(l2, f2, n, g2.create(m2.NA)), E2 = O(l2, f2, u, g2.create(m2.NA)), b = O(l2, f2, c, g2.create(m2.NA)), R = h.map((p2, N2, M2) => {
  18642. const w = d2.get(N2, M2), D2 = _.get(N2, M2), S2 = C.get(N2, M2), P = E2.get(N2, M2), U2 = b.get(N2, M2), { isError: x2, errorObject: F, variants: W2 } = I2(p2, w, D2, S2, P, U2);
  18643. if (x2)
  18644. return F;
  18645. const [ne, z, G2, ge2, de2, Ee] = W2, Re2 = +ne.getValue(), he2 = +z.getValue(), ke = +G2.getValue(), Ot2 = +ge2.getValue(), ar2 = +de2.getValue(), Mt2 = +Ee.getValue();
  18646. if (he2 < 1 || Math.floor(he2) > Math.ceil(ke))
  18647. return g2.create(m2.NUM);
  18648. const st2 = yu(Re2, he2, ke, Ot2, ar2, Mt2 ? 1 : 0);
  18649. return Number.isNaN(st2) || !Number.isFinite(st2) ? g2.create(m2.NUM) : N2 === 0 && M2 === 0 ? y2.create(st2, Ke(this.getLocale())) : y2.create(st2);
  18650. });
  18651. return l2 === 1 && f2 === 1 ? R.get(0, 0) : R;
  18652. }
  18653. };
  18654. var J1 = class extends V {
  18655. constructor() {
  18656. super(...arguments);
  18657. A(this, "minParams", 1);
  18658. A(this, "maxParams", 2);
  18659. }
  18660. calculate(e, t) {
  18661. let r = t != null ? t : y2.create(0.1);
  18662. return r.isNull() && (r = y2.create(0.1)), r.isArray() ? r.map((n, s, o) => this._handleSingleObject(e, n, s, o)) : this._handleSingleObject(e, r);
  18663. }
  18664. _handleSingleObject(e, t, r = 0, n = 0) {
  18665. if (e.isError())
  18666. return e;
  18667. if (t.isError())
  18668. return t;
  18669. if (e.isNull())
  18670. return g2.create(m2.VALUE);
  18671. if (!e.isArray())
  18672. return g2.create(m2.NUM);
  18673. const { _values: s, valuesHasError: o } = this._getValues(e);
  18674. if (o)
  18675. return g2.create(m2.VALUE);
  18676. let u = t;
  18677. if (u.isString() && (u = u.convertToNumberObjectValue(), u.isError()))
  18678. return u;
  18679. const c = +u.getValue(), { positive: l2, negative: f2 } = this._checkValues(s);
  18680. if (!l2 || !f2)
  18681. return g2.create(m2.NUM);
  18682. const h = Ia(c, (d2) => Ru(d2, s));
  18683. return typeof h != "number" ? h : r === 0 && n === 0 ? y2.create(h, "0%") : y2.create(h);
  18684. }
  18685. _getValues(e) {
  18686. const t = [];
  18687. let r = false;
  18688. return e.iterator((n) => {
  18689. const s = n;
  18690. if (s.isError())
  18691. return r = true, false;
  18692. if (s.isNull() || s.isBoolean())
  18693. return true;
  18694. const o = +s.getValue();
  18695. if (Number.isNaN(o))
  18696. return true;
  18697. t.push(o);
  18698. }), {
  18699. _values: t,
  18700. valuesHasError: r
  18701. };
  18702. }
  18703. _checkValues(e) {
  18704. let t = false, r = false;
  18705. for (let n = 0; n < e.length; n++)
  18706. e[n] > 0 && (t = true), e[n] < 0 && (r = true);
  18707. return {
  18708. positive: t,
  18709. negative: r
  18710. };
  18711. }
  18712. };
  18713. var e0 = class extends V {
  18714. constructor() {
  18715. super(...arguments);
  18716. A(this, "minParams", 4);
  18717. A(this, "maxParams", 4);
  18718. }
  18719. calculate(e, t, r, n) {
  18720. const s = Math.max(
  18721. e.isArray() ? e.getRowCount() : 1,
  18722. t.isArray() ? t.getRowCount() : 1,
  18723. r.isArray() ? r.getRowCount() : 1,
  18724. n.isArray() ? n.getRowCount() : 1
  18725. ), o = Math.max(
  18726. e.isArray() ? e.getColumnCount() : 1,
  18727. t.isArray() ? t.getColumnCount() : 1,
  18728. r.isArray() ? r.getColumnCount() : 1,
  18729. n.isArray() ? n.getColumnCount() : 1
  18730. ), u = O(s, o, e, g2.create(m2.NA)), c = O(s, o, t, g2.create(m2.NA)), l2 = O(s, o, r, g2.create(m2.NA)), f2 = O(s, o, n, g2.create(m2.NA)), h = u.map((d2, _, C) => {
  18731. const E2 = c.get(_, C), b = l2.get(_, C), R = f2.get(_, C), { isError: p2, errorObject: N2, variants: M2 } = I2(d2, E2, b, R);
  18732. if (p2)
  18733. return N2;
  18734. const [w, D2, S2, P] = M2, U2 = +w.getValue(), x2 = +D2.getValue(), F = +S2.getValue(), W2 = +P.getValue();
  18735. if (F === 0)
  18736. return g2.create(m2.DIV_BY_ZERO);
  18737. const ne = W2 * U2 * (x2 / F - 1);
  18738. return y2.create(ne);
  18739. });
  18740. return s === 1 && o === 1 ? h.get(0, 0) : h;
  18741. }
  18742. };
  18743. var t0 = class extends V {
  18744. constructor() {
  18745. super(...arguments);
  18746. A(this, "minParams", 5);
  18747. A(this, "maxParams", 6);
  18748. }
  18749. calculate(e, t, r, n, s, o) {
  18750. let u = o != null ? o : y2.create(0);
  18751. u.isNull() && (u = y2.create(0));
  18752. const { isError: c, errorObject: l2, variants: f2 } = Fe2(e, t, r, n, s, u);
  18753. if (c)
  18754. return l2;
  18755. const [h, d2, _, C, E2, b] = f2, R = k(h);
  18756. if (typeof R != "number")
  18757. return R;
  18758. const p2 = k(d2);
  18759. if (typeof p2 != "number")
  18760. return p2;
  18761. const N2 = +_.getValue(), M2 = +C.getValue(), w = Math.floor(+E2.getValue()), D2 = Math.floor(+b.getValue());
  18762. if (Number.isNaN(N2) || Number.isNaN(M2) || Number.isNaN(w) || Number.isNaN(D2))
  18763. return g2.create(m2.VALUE);
  18764. if (N2 < 0 || M2 < 0 || ![1, 2, 4].includes(w) || D2 < 0 || D2 > 4 || Math.floor(R) >= Math.floor(p2))
  18765. return g2.create(m2.NUM);
  18766. let S2 = bu(R, p2, N2, M2, w, D2);
  18767. return S2 /= 1 + M2 / w, y2.create(S2);
  18768. }
  18769. };
  18770. var r0 = class extends V {
  18771. constructor() {
  18772. super(...arguments);
  18773. A(this, "minParams", 3);
  18774. A(this, "maxParams", 3);
  18775. }
  18776. calculate(e, t, r) {
  18777. const { _values: n, numberValues: s, positive: o, negative: u } = this._getValues(e), c = Math.max(
  18778. t.isArray() ? t.getRowCount() : 1,
  18779. r.isArray() ? r.getRowCount() : 1
  18780. ), l2 = Math.max(
  18781. t.isArray() ? t.getColumnCount() : 1,
  18782. r.isArray() ? r.getColumnCount() : 1
  18783. ), f2 = O(c, l2, t, g2.create(m2.NA)), h = O(c, l2, r, g2.create(m2.NA)), d2 = f2.map((_, C, E2) => {
  18784. const b = h.get(C, E2);
  18785. if (e.isError())
  18786. return e;
  18787. if (b.isError())
  18788. return b;
  18789. if (n.isError())
  18790. return n;
  18791. if (!o || !u)
  18792. return g2.create(m2.DIV_BY_ZERO);
  18793. const R = +_.getValue(), p2 = +b.getValue();
  18794. if (Number.isNaN(R) || Number.isNaN(p2))
  18795. return g2.create(m2.VALUE);
  18796. if (p2 === -1)
  18797. return g2.create(m2.DIV_BY_ZERO);
  18798. const N2 = this._getResult(s, R, p2);
  18799. return C === 0 && E2 === 0 ? y2.create(N2, "0%") : y2.create(N2);
  18800. });
  18801. return c === 1 && l2 === 1 ? d2.get(0, 0) : d2;
  18802. }
  18803. _getValues(e) {
  18804. let t = e, r = [], n = false, s = false;
  18805. if (!e.isError())
  18806. if (e.isNull())
  18807. t = g2.create(m2.VALUE);
  18808. else if (!e.isArray())
  18809. t = g2.create(m2.DIV_BY_ZERO);
  18810. else {
  18811. const { numberValues: o, valuesHasError: u, errorObject: c, positive: l2, negative: f2 } = this._checkValues(e);
  18812. u && (t = c), r = o, n = l2, s = f2;
  18813. }
  18814. return {
  18815. _values: t,
  18816. numberValues: r,
  18817. positive: n,
  18818. negative: s
  18819. };
  18820. }
  18821. _checkValues(e) {
  18822. const t = [];
  18823. let r = false, n = g2.create(m2.VALUE), s = false, o = false;
  18824. return e.iterator((u) => {
  18825. const c = u;
  18826. if (c.isError())
  18827. return r = true, n = c, false;
  18828. if (c.isNull() || c.isBoolean())
  18829. return true;
  18830. const l2 = +c.getValue();
  18831. if (Number.isNaN(l2))
  18832. return true;
  18833. l2 > 0 && (s = true), l2 < 0 && (o = true), t.push(l2);
  18834. }), {
  18835. numberValues: t,
  18836. valuesHasError: r,
  18837. errorObject: n,
  18838. positive: s,
  18839. negative: o
  18840. };
  18841. }
  18842. _getResult(e, t, r) {
  18843. const n = e.length, s = [], o = [];
  18844. for (let d2 = 0; d2 < n; d2++)
  18845. e[d2] > 0 ? o.push(e[d2]) : e[d2] < 0 && s.push(e[d2]);
  18846. const u = this._npv(r, e, "positive"), c = this._npv(t, e, "negative"), l2 = -u * (1 + r) ** n, f2 = c * (1 + t);
  18847. return (l2 / f2) ** (1 / (n - 1)) - 1;
  18848. }
  18849. _npv(e, t, r) {
  18850. let n = 0;
  18851. for (let s = 1; s <= t.length; s++) {
  18852. const o = t[s - 1];
  18853. (r === "positive" && o > 0 || r === "negative" && o < 0) && (n += o / (1 + e) ** s);
  18854. }
  18855. return n;
  18856. }
  18857. };
  18858. var n0 = class extends V {
  18859. constructor() {
  18860. super(...arguments);
  18861. A(this, "minParams", 2);
  18862. A(this, "maxParams", 2);
  18863. }
  18864. calculate(e, t) {
  18865. const { isError: r, errorObject: n, variants: s } = H(e, t);
  18866. if (r)
  18867. return n;
  18868. const [o, u] = s, c = +o.getValue();
  18869. let l2 = Math.floor(+u.getValue());
  18870. if (Number.isNaN(c) || Number.isNaN(l2))
  18871. return g2.create(m2.VALUE);
  18872. if (c <= 0 || l2 < 1)
  18873. return g2.create(m2.NUM);
  18874. l2 = Number.parseInt(`${l2}`, 10);
  18875. const f2 = ((c + 1) ** (1 / l2) - 1) * l2;
  18876. return y2.create(f2);
  18877. }
  18878. };
  18879. var s0 = class extends V {
  18880. constructor() {
  18881. super(...arguments);
  18882. A(this, "minParams", 3);
  18883. A(this, "maxParams", 5);
  18884. }
  18885. calculate(e, t, r, n, s) {
  18886. const o = n != null ? n : y2.create(0), u = s != null ? s : y2.create(0), c = Math.max(
  18887. e.isArray() ? e.getRowCount() : 1,
  18888. t.isArray() ? t.getRowCount() : 1,
  18889. r.isArray() ? r.getRowCount() : 1,
  18890. o.isArray() ? o.getRowCount() : 1,
  18891. u.isArray() ? u.getRowCount() : 1
  18892. ), l2 = Math.max(
  18893. e.isArray() ? e.getColumnCount() : 1,
  18894. t.isArray() ? t.getColumnCount() : 1,
  18895. r.isArray() ? r.getColumnCount() : 1,
  18896. o.isArray() ? o.getColumnCount() : 1,
  18897. u.isArray() ? u.getColumnCount() : 1
  18898. ), f2 = O(c, l2, e, g2.create(m2.NA)), h = O(c, l2, t, g2.create(m2.NA)), d2 = O(c, l2, r, g2.create(m2.NA)), _ = O(c, l2, o, g2.create(m2.NA)), C = O(c, l2, u, g2.create(m2.NA)), E2 = f2.map((b, R, p2) => {
  18899. const N2 = h.get(R, p2), M2 = d2.get(R, p2), w = _.get(R, p2), D2 = C.get(R, p2), { isError: S2, errorObject: P, variants: U2 } = I2(b, N2, M2, w, D2);
  18900. if (S2)
  18901. return P;
  18902. const [x2, F, W2, ne, z] = U2, G2 = +x2.getValue(), ge2 = +F.getValue(), de2 = +W2.getValue(), Ee = +ne.getValue();
  18903. let Re2 = +z.getValue();
  18904. if (Re2 = Re2 ? 1 : 0, G2 === 0 && ge2 === 0)
  18905. return g2.create(m2.DIV_BY_ZERO);
  18906. let he2;
  18907. if (G2 === 0)
  18908. he2 = -(de2 + Ee) / ge2;
  18909. else {
  18910. const ke = ge2 * (1 + G2 * Re2) - Ee * G2, Ot2 = de2 * G2 + ge2 * (1 + G2 * Re2);
  18911. he2 = Math.log(ke / Ot2) / Math.log(1 + G2);
  18912. }
  18913. return Number.isNaN(he2) || !Number.isFinite(he2) ? g2.create(m2.NUM) : y2.create(he2);
  18914. });
  18915. return c === 1 && l2 === 1 ? E2.get(0, 0) : E2;
  18916. }
  18917. };
  18918. var a0 = class extends V {
  18919. constructor() {
  18920. super(...arguments);
  18921. A(this, "minParams", 2);
  18922. A(this, "maxParams", 255);
  18923. A(this, "needsLocale", true);
  18924. }
  18925. calculate(e, ...t) {
  18926. if (e.isError())
  18927. return e;
  18928. const { isError: r, errorObject: n, values: s } = this._getValues(t);
  18929. return e.isArray() ? e.map((o, u, c) => this._handleSingleObject(o, r, n, s, u, c)) : this._handleSingleObject(e, r, n, s);
  18930. }
  18931. _handleSingleObject(e, t, r, n, s = 0, o = 0) {
  18932. let u = e;
  18933. if (u.isString() && (u = u.convertToNumberObjectValue()), u.isError())
  18934. return u;
  18935. if (t)
  18936. return r;
  18937. const c = +e.getValue(), l2 = Ru(c, n);
  18938. return Number.isNaN(l2) || Math.abs(l2) === 1 / 0 ? g2.create(m2.DIV_BY_ZERO) : s === 0 && o === 0 ? y2.create(l2, Ke(this.getLocale())) : y2.create(l2);
  18939. }
  18940. _getValues(e) {
  18941. const t = [];
  18942. for (let r = 0; r < e.length; r++) {
  18943. const n = e[r];
  18944. if (n.isError())
  18945. return {
  18946. isError: true,
  18947. errorObject: n
  18948. };
  18949. if (n.isArray()) {
  18950. let s = false, o = g2.create(m2.VALUE);
  18951. if (n.iterator((u) => {
  18952. const c = u;
  18953. if (c.isError())
  18954. return s = true, o = c, false;
  18955. if (c.isNull() || c.isBoolean())
  18956. return true;
  18957. const l2 = +c.getValue();
  18958. if (Number.isNaN(l2))
  18959. return true;
  18960. t.push(l2);
  18961. }), s)
  18962. return {
  18963. isError: s,
  18964. errorObject: o
  18965. };
  18966. } else {
  18967. const s = +n.getValue();
  18968. if (Number.isNaN(s))
  18969. return {
  18970. isError: true,
  18971. errorObject: g2.create(m2.VALUE)
  18972. };
  18973. t.push(s);
  18974. }
  18975. }
  18976. return {
  18977. isError: false,
  18978. values: t
  18979. };
  18980. }
  18981. };
  18982. var i0 = class extends V {
  18983. constructor() {
  18984. super(...arguments);
  18985. A(this, "minParams", 8);
  18986. A(this, "maxParams", 9);
  18987. }
  18988. calculate(e, t, r, n, s, o, u, c, l2) {
  18989. let f2 = l2 != null ? l2 : y2.create(0);
  18990. f2.isNull() && (f2 = y2.create(0));
  18991. const { isError: h, errorObject: d2, variants: _ } = Fe2(e, t, r, n, s, o, u, c, f2);
  18992. if (h)
  18993. return d2;
  18994. const [C, E2, b, R, p2, N2, M2, w, D2] = _, S2 = k(C);
  18995. if (typeof S2 != "number")
  18996. return S2;
  18997. const P = k(E2);
  18998. if (typeof P != "number")
  18999. return P;
  19000. const U2 = k(b);
  19001. if (typeof U2 != "number")
  19002. return U2;
  19003. const x2 = k(R);
  19004. if (typeof x2 != "number")
  19005. return x2;
  19006. const F = +p2.getValue(), W2 = +N2.getValue(), ne = +M2.getValue(), z = Math.floor(+w.getValue()), G2 = Math.floor(+D2.getValue());
  19007. if (Number.isNaN(F) || Number.isNaN(W2) || Number.isNaN(ne) || Number.isNaN(z) || Number.isNaN(G2))
  19008. return g2.create(m2.VALUE);
  19009. if (F < 0 || W2 < 0 || ne <= 0 || ![1, 2, 4].includes(z) || G2 < 0 || G2 > 4 || !this._validDate(P, x2, S2, U2, z))
  19010. return g2.create(m2.NUM);
  19011. const ge2 = pu(S2, P, U2, x2, F, W2, ne, z, G2);
  19012. return y2.create(ge2);
  19013. }
  19014. _validDate(e, t, r, n, s) {
  19015. return this._getDateCorrectOrder(e, t, r, n) && Vu(e, t, s) && Or(n, e, s);
  19016. }
  19017. _getDateCorrectOrder(e, t, r, n) {
  19018. return Math.floor(e) > Math.floor(t) && Math.floor(t) > Math.floor(r) && Math.floor(r) > Math.floor(n);
  19019. }
  19020. };
  19021. var o0 = class extends V {
  19022. constructor() {
  19023. super(...arguments);
  19024. A(this, "minParams", 8);
  19025. A(this, "maxParams", 9);
  19026. }
  19027. calculate(e, t, r, n, s, o, u, c, l2) {
  19028. let f2 = l2 != null ? l2 : y2.create(0);
  19029. f2.isNull() && (f2 = y2.create(0));
  19030. const { isError: h, errorObject: d2, variants: _ } = Fe2(e, t, r, n, s, o, u, c, f2);
  19031. if (h)
  19032. return d2;
  19033. const [C, E2, b, R, p2, N2, M2, w, D2] = _, S2 = k(C);
  19034. if (typeof S2 != "number")
  19035. return S2;
  19036. const P = k(E2);
  19037. if (typeof P != "number")
  19038. return P;
  19039. const U2 = k(b);
  19040. if (typeof U2 != "number")
  19041. return U2;
  19042. const x2 = k(R);
  19043. if (typeof x2 != "number")
  19044. return x2;
  19045. const F = +p2.getValue(), W2 = +N2.getValue(), ne = +M2.getValue(), z = Math.floor(+w.getValue()), G2 = Math.floor(+D2.getValue());
  19046. return Number.isNaN(F) || Number.isNaN(W2) || Number.isNaN(ne) || Number.isNaN(z) || Number.isNaN(G2) ? g2.create(m2.VALUE) : F < 0 || W2 <= 0 || ne <= 0 || ![1, 2, 4].includes(z) || G2 < 0 || G2 > 4 || !this._validDate(P, x2, S2, U2, z) ? g2.create(m2.NUM) : this._getResult(S2, P, U2, x2, F, W2, ne, z, G2);
  19047. }
  19048. _validDate(e, t, r, n, s) {
  19049. return this._getDateCorrectOrder(e, t, r, n) && Vu(e, t, s) && Or(n, e, s);
  19050. }
  19051. _getDateCorrectOrder(e, t, r, n) {
  19052. return Math.floor(e) > Math.floor(t) && Math.floor(t) > Math.floor(r) && Math.floor(r) > Math.floor(n);
  19053. }
  19054. _getResult(e, t, r, n, s, o, u, c, l2) {
  19055. const { days: f2 } = _e2(e, t, l2), h = (s * f2 * 100 - (o - 100)) / ((o - 100) * 0.25 * (1 + 2 * f2) + f2 * 100);
  19056. function d2(C) {
  19057. return o - pu(e, t, r, n, s, C, u, c, l2);
  19058. }
  19059. const _ = Ia(h, (C) => d2(C));
  19060. return typeof _ != "number" ? _ : y2.create(_);
  19061. }
  19062. };
  19063. var u0 = class extends V {
  19064. constructor() {
  19065. super(...arguments);
  19066. A(this, "minParams", 7);
  19067. A(this, "maxParams", 8);
  19068. }
  19069. calculate(e, t, r, n, s, o, u, c) {
  19070. let l2 = c != null ? c : y2.create(0);
  19071. l2.isNull() && (l2 = y2.create(0));
  19072. const { isError: f2, errorObject: h, variants: d2 } = Fe2(e, t, r, n, s, o, u, l2);
  19073. if (f2)
  19074. return h;
  19075. const [_, C, E2, b, R, p2, N2, M2] = d2, w = k(_);
  19076. if (typeof w != "number")
  19077. return w;
  19078. const D2 = k(C);
  19079. if (typeof D2 != "number")
  19080. return D2;
  19081. const S2 = k(E2);
  19082. if (typeof S2 != "number")
  19083. return S2;
  19084. const P = +b.getValue(), U2 = +R.getValue(), x2 = +p2.getValue(), F = Math.floor(+N2.getValue()), W2 = Math.floor(+M2.getValue());
  19085. if (Number.isNaN(P) || Number.isNaN(U2) || Number.isNaN(x2) || Number.isNaN(F) || Number.isNaN(W2))
  19086. return g2.create(m2.VALUE);
  19087. if (P < 0 || U2 < 0 || x2 <= 0 || ![1, 2, 4].includes(F) || W2 < 0 || W2 > 4 || !this._validDate(D2, w, S2, F))
  19088. return g2.create(m2.NUM);
  19089. const ne = this._getResult(w, D2, S2, P, U2, x2, F, W2);
  19090. return y2.create(ne);
  19091. }
  19092. _validDate(e, t, r, n) {
  19093. return Math.floor(e) > Math.floor(t) && Math.floor(t) > Math.floor(r) && Or(r, e, n);
  19094. }
  19095. _getResult(e, t, r, n, s, o, u, c) {
  19096. const l2 = this._getCoupDate(t, r, u), f2 = this._getFrac(r, e, l2, u, c), h = this._getFrac(r, t, l2, u, c), d2 = this._getFrac(e, t, l2, u, c);
  19097. return (o * u + 100 * n * (h - f2 * (1 + s * d2 / u))) / (s * d2 + u);
  19098. }
  19099. _getCoupDate(e, t, r) {
  19100. const n = re2(e), s = re2(t);
  19101. for (s.setUTCFullYear(n.getUTCFullYear()), s > n && s.setUTCFullYear(s.getUTCFullYear() - 1); s < n; )
  19102. s.setUTCMonth(s.getUTCMonth() + 12 / r);
  19103. return ye2(s);
  19104. }
  19105. _getFrac(e, t, r, n, s) {
  19106. const o = re2(e), u = re2(t), c = re2(r);
  19107. for (c.setUTCFullYear(o.getUTCFullYear()), c < o && c.setUTCFullYear(c.getUTCFullYear() + 1); c > o; )
  19108. c.setUTCMonth(c.getUTCMonth() - 12 / n);
  19109. let l2 = ye2(c);
  19110. c.setUTCMonth(c.getUTCMonth() + 12 / n);
  19111. let f2 = ye2(c);
  19112. if (f2 >= t) {
  19113. const { days: p2 } = _e2(e, t, s), N2 = qe(l2, f2, n, s);
  19114. return p2 / N2;
  19115. }
  19116. const { days: h } = _e2(e, f2, s), d2 = qe(l2, f2, n, s);
  19117. let _ = h / d2;
  19118. const C = re2(f2), E2 = re2(f2);
  19119. for (E2.setUTCMonth(E2.getUTCMonth() + 12 / n); E2 < u; )
  19120. C.setUTCMonth(C.getUTCMonth() + 12 / n), E2.setUTCMonth(E2.getUTCMonth() + 12 / n), _ += 1;
  19121. l2 = ye2(C), f2 = ye2(E2);
  19122. const { days: b } = _e2(l2, t, s), R = qe(l2, f2, n, s);
  19123. return _ += b / R, _;
  19124. }
  19125. };
  19126. var c0 = class extends V {
  19127. constructor() {
  19128. super(...arguments);
  19129. A(this, "minParams", 8);
  19130. A(this, "maxParams", 9);
  19131. }
  19132. calculate(e, t, r, n, s, o, u, c) {
  19133. let l2 = c != null ? c : y2.create(0);
  19134. l2.isNull() && (l2 = y2.create(0));
  19135. const { isError: f2, errorObject: h, variants: d2 } = Fe2(e, t, r, n, s, o, u, l2);
  19136. if (f2)
  19137. return h;
  19138. const [_, C, E2, b, R, p2, N2, M2] = d2, w = k(_);
  19139. if (typeof w != "number")
  19140. return w;
  19141. const D2 = k(C);
  19142. if (typeof D2 != "number")
  19143. return D2;
  19144. const S2 = k(E2);
  19145. if (typeof S2 != "number")
  19146. return S2;
  19147. const P = +b.getValue(), U2 = +R.getValue(), x2 = +p2.getValue(), F = Math.floor(+N2.getValue()), W2 = Math.floor(+M2.getValue());
  19148. if (Number.isNaN(P) || Number.isNaN(U2) || Number.isNaN(x2) || Number.isNaN(F) || Number.isNaN(W2))
  19149. return g2.create(m2.VALUE);
  19150. if (P < 0 || U2 <= 0 || x2 <= 0 || ![1, 2, 4].includes(F) || W2 < 0 || W2 > 4 || !this._validDate(D2, w, S2, F))
  19151. return g2.create(m2.NUM);
  19152. const ne = this._getResult(w, D2, S2, P, U2, x2, F, W2);
  19153. return y2.create(ne);
  19154. }
  19155. _validDate(e, t, r, n) {
  19156. return Math.floor(e) > Math.floor(t) && Math.floor(t) > Math.floor(r) && Or(r, e, n);
  19157. }
  19158. _getResult(e, t, r, n, s, o, u, c) {
  19159. const l2 = this._getCoupDate(t, r, u), f2 = this._getFrac(r, e, l2, u, c), h = this._getFrac(r, t, l2, u, c), d2 = this._getFrac(e, t, l2, u, c);
  19160. return (u * (o - s) + 100 * n * (h - f2)) / (d2 * s + 100 * n * f2 * d2 / u);
  19161. }
  19162. _getCoupDate(e, t, r) {
  19163. const n = re2(e), s = re2(t);
  19164. for (s.setUTCFullYear(n.getUTCFullYear()), s > n && s.setUTCFullYear(s.getUTCFullYear() - 1); s < n; )
  19165. s.setUTCMonth(s.getUTCMonth() + 12 / r);
  19166. return ye2(s);
  19167. }
  19168. _getFrac(e, t, r, n, s) {
  19169. const o = re2(e), u = re2(t), c = re2(r);
  19170. for (c.setUTCFullYear(o.getUTCFullYear()), c < o && c.setUTCFullYear(c.getUTCFullYear() + 1); c > o; )
  19171. c.setUTCMonth(c.getUTCMonth() - 12 / n);
  19172. let l2 = ye2(c);
  19173. c.setUTCMonth(c.getUTCMonth() + 12 / n);
  19174. let f2 = ye2(c);
  19175. if (f2 >= t) {
  19176. const { days: p2 } = _e2(e, t, s), N2 = qe(l2, f2, n, s);
  19177. return p2 / N2;
  19178. }
  19179. const { days: h } = _e2(e, f2, s), d2 = qe(l2, f2, n, s);
  19180. let _ = h / d2;
  19181. const C = re2(f2), E2 = re2(f2);
  19182. for (E2.setUTCMonth(E2.getUTCMonth() + 12 / n); E2 < u; )
  19183. C.setUTCMonth(C.getUTCMonth() + 12 / n), E2.setUTCMonth(E2.getUTCMonth() + 12 / n), _ += 1;
  19184. l2 = ye2(C), f2 = ye2(E2);
  19185. const { days: b } = _e2(l2, t, s), R = qe(l2, f2, n, s);
  19186. return _ += b / R, _;
  19187. }
  19188. };
  19189. var l0 = class extends V {
  19190. constructor() {
  19191. super(...arguments);
  19192. A(this, "minParams", 3);
  19193. A(this, "maxParams", 3);
  19194. }
  19195. calculate(e, t, r) {
  19196. const n = Math.max(
  19197. e.isArray() ? e.getRowCount() : 1,
  19198. t.isArray() ? t.getRowCount() : 1,
  19199. r.isArray() ? r.getRowCount() : 1
  19200. ), s = Math.max(
  19201. e.isArray() ? e.getColumnCount() : 1,
  19202. t.isArray() ? t.getColumnCount() : 1,
  19203. r.isArray() ? r.getColumnCount() : 1
  19204. ), o = O(n, s, e, g2.create(m2.NA)), u = O(n, s, t, g2.create(m2.NA)), c = O(n, s, r, g2.create(m2.NA)), l2 = o.map((f2, h, d2) => {
  19205. const _ = u.get(h, d2), C = c.get(h, d2), { isError: E2, errorObject: b, variants: R } = I2(f2, _, C);
  19206. if (E2)
  19207. return b;
  19208. const [p2, N2, M2] = R, w = +p2.getValue(), D2 = +N2.getValue(), S2 = +M2.getValue();
  19209. if (w <= -1)
  19210. return g2.create(m2.NUM);
  19211. const P = (Math.log(S2) - Math.log(D2)) / Math.log(1 + w);
  19212. return Number.isNaN(P) || !Number.isFinite(P) ? g2.create(m2.NUM) : y2.create(P);
  19213. });
  19214. return n === 1 && s === 1 ? l2.get(0, 0) : l2;
  19215. }
  19216. };
  19217. var f0 = class extends V {
  19218. constructor() {
  19219. super(...arguments);
  19220. A(this, "minParams", 3);
  19221. A(this, "maxParams", 5);
  19222. A(this, "needsLocale", true);
  19223. }
  19224. calculate(e, t, r, n, s) {
  19225. const o = n != null ? n : y2.create(0), u = s != null ? s : y2.create(0), c = Math.max(
  19226. e.isArray() ? e.getRowCount() : 1,
  19227. t.isArray() ? t.getRowCount() : 1,
  19228. r.isArray() ? r.getRowCount() : 1,
  19229. o.isArray() ? o.getRowCount() : 1,
  19230. u.isArray() ? u.getRowCount() : 1
  19231. ), l2 = Math.max(
  19232. e.isArray() ? e.getColumnCount() : 1,
  19233. t.isArray() ? t.getColumnCount() : 1,
  19234. r.isArray() ? r.getColumnCount() : 1,
  19235. o.isArray() ? o.getColumnCount() : 1,
  19236. u.isArray() ? u.getColumnCount() : 1
  19237. ), f2 = O(c, l2, e, g2.create(m2.NA)), h = O(c, l2, t, g2.create(m2.NA)), d2 = O(c, l2, r, g2.create(m2.NA)), _ = O(c, l2, o, g2.create(m2.NA)), C = O(c, l2, u, g2.create(m2.NA)), E2 = f2.map((b, R, p2) => {
  19238. const N2 = h.get(R, p2), M2 = d2.get(R, p2), w = _.get(R, p2), D2 = C.get(R, p2), { isError: S2, errorObject: P, variants: U2 } = I2(b, N2, M2, w, D2);
  19239. if (S2)
  19240. return P;
  19241. const [x2, F, W2, ne, z] = U2, G2 = +x2.getValue(), ge2 = +F.getValue(), de2 = +W2.getValue(), Ee = +ne.getValue(), Re2 = +z.getValue();
  19242. if (G2 <= -1)
  19243. return g2.create(m2.NUM);
  19244. const he2 = Gr(G2, ge2, de2, Ee, Re2 ? 1 : 0);
  19245. return Number.isNaN(he2) || !Number.isFinite(he2) ? g2.create(m2.NUM) : R === 0 && p2 === 0 ? y2.create(he2, Ke(this.getLocale())) : y2.create(he2);
  19246. });
  19247. return c === 1 && l2 === 1 ? E2.get(0, 0) : E2;
  19248. }
  19249. };
  19250. var h0 = class extends V {
  19251. constructor() {
  19252. super(...arguments);
  19253. A(this, "minParams", 4);
  19254. A(this, "maxParams", 6);
  19255. A(this, "needsLocale", true);
  19256. }
  19257. calculate(e, t, r, n, s, o) {
  19258. const u = s != null ? s : y2.create(0), c = o != null ? o : y2.create(0), l2 = Math.max(
  19259. e.isArray() ? e.getRowCount() : 1,
  19260. t.isArray() ? t.getRowCount() : 1,
  19261. r.isArray() ? r.getRowCount() : 1,
  19262. n.isArray() ? n.getRowCount() : 1,
  19263. u.isArray() ? u.getRowCount() : 1,
  19264. c.isArray() ? c.getRowCount() : 1
  19265. ), f2 = Math.max(
  19266. e.isArray() ? e.getColumnCount() : 1,
  19267. t.isArray() ? t.getColumnCount() : 1,
  19268. r.isArray() ? r.getColumnCount() : 1,
  19269. n.isArray() ? n.getColumnCount() : 1,
  19270. u.isArray() ? u.getColumnCount() : 1,
  19271. c.isArray() ? c.getColumnCount() : 1
  19272. ), h = O(l2, f2, e, g2.create(m2.NA)), d2 = O(l2, f2, t, g2.create(m2.NA)), _ = O(l2, f2, r, g2.create(m2.NA)), C = O(l2, f2, n, g2.create(m2.NA)), E2 = O(l2, f2, u, g2.create(m2.NA)), b = O(l2, f2, c, g2.create(m2.NA)), R = h.map((p2, N2, M2) => {
  19273. const w = d2.get(N2, M2), D2 = _.get(N2, M2), S2 = C.get(N2, M2), P = E2.get(N2, M2), U2 = b.get(N2, M2), { isError: x2, errorObject: F, variants: W2 } = I2(p2, w, D2, S2, P, U2);
  19274. if (x2)
  19275. return F;
  19276. const [ne, z, G2, ge2, de2, Ee] = W2, Re2 = +ne.getValue(), he2 = +z.getValue(), ke = +G2.getValue(), Ot2 = +ge2.getValue(), ar2 = +de2.getValue(), Mt2 = +Ee.getValue();
  19277. if (he2 < 1 || Math.floor(he2) > Math.ceil(ke) || he2 - ke >= 1)
  19278. return g2.create(m2.NUM);
  19279. const st2 = Gr(Re2, ke, Ot2, ar2, Mt2 ? 1 : 0) - yu(Re2, he2, ke, Ot2, ar2, Mt2 ? 1 : 0);
  19280. return Number.isNaN(st2) || !Number.isFinite(st2) ? g2.create(m2.NUM) : N2 === 0 && M2 === 0 ? y2.create(st2, Ke(this.getLocale())) : y2.create(st2);
  19281. });
  19282. return l2 === 1 && f2 === 1 ? R.get(0, 0) : R;
  19283. }
  19284. };
  19285. var m0 = class extends V {
  19286. constructor() {
  19287. super(...arguments);
  19288. A(this, "minParams", 6);
  19289. A(this, "maxParams", 7);
  19290. }
  19291. calculate(e, t, r, n, s, o, u) {
  19292. let c = u != null ? u : y2.create(0);
  19293. c.isNull() && (c = y2.create(0));
  19294. const { isError: l2, errorObject: f2, variants: h } = Fe2(e, t, r, n, s, o, c);
  19295. if (l2)
  19296. return f2;
  19297. const [d2, _, C, E2, b, R, p2] = h, N2 = k(d2);
  19298. if (typeof N2 != "number")
  19299. return N2;
  19300. const M2 = k(_);
  19301. if (typeof M2 != "number")
  19302. return M2;
  19303. const w = +C.getValue(), D2 = +E2.getValue(), S2 = +b.getValue(), P = Math.floor(+R.getValue()), U2 = Math.floor(+p2.getValue());
  19304. if (Number.isNaN(w) || Number.isNaN(D2) || Number.isNaN(S2) || Number.isNaN(P) || Number.isNaN(U2))
  19305. return g2.create(m2.VALUE);
  19306. if (w < 0 || D2 < 0 || S2 <= 0 || ![1, 2, 4].includes(P) || U2 < 0 || U2 > 4 || N2 >= M2 || !Or(N2, M2, P))
  19307. return g2.create(m2.NUM);
  19308. const x2 = un(N2, M2, w, D2, S2, P, U2);
  19309. return y2.create(x2);
  19310. }
  19311. };
  19312. var g0 = class extends V {
  19313. constructor() {
  19314. super(...arguments);
  19315. A(this, "minParams", 4);
  19316. A(this, "maxParams", 5);
  19317. }
  19318. calculate(e, t, r, n, s) {
  19319. let o = s != null ? s : y2.create(0);
  19320. o.isNull() && (o = y2.create(0));
  19321. const { isError: u, errorObject: c, variants: l2 } = Fe2(e, t, r, n, o);
  19322. if (u)
  19323. return c;
  19324. const [f2, h, d2, _, C] = l2, E2 = k(f2);
  19325. if (typeof E2 != "number")
  19326. return E2;
  19327. const b = k(h);
  19328. if (typeof b != "number")
  19329. return b;
  19330. const R = +d2.getValue(), p2 = +_.getValue(), N2 = Math.floor(+C.getValue());
  19331. if (Number.isNaN(R) || Number.isNaN(p2) || Number.isNaN(N2))
  19332. return g2.create(m2.VALUE);
  19333. if (R <= 0 || p2 <= 0 || N2 < 0 || N2 > 4 || E2 >= b)
  19334. return g2.create(m2.NUM);
  19335. const { days: M2, yearDays: w } = _e2(E2, b, N2), D2 = p2 - R * p2 * M2 / w;
  19336. return y2.create(D2);
  19337. }
  19338. };
  19339. var d0 = class extends V {
  19340. constructor() {
  19341. super(...arguments);
  19342. A(this, "minParams", 5);
  19343. A(this, "maxParams", 6);
  19344. }
  19345. calculate(e, t, r, n, s, o) {
  19346. let u = o != null ? o : y2.create(0);
  19347. u.isNull() && (u = y2.create(0));
  19348. const { isError: c, errorObject: l2, variants: f2 } = Fe2(e, t, r, n, s, u);
  19349. if (c)
  19350. return l2;
  19351. const [h, d2, _, C, E2, b] = f2, R = k(h);
  19352. if (typeof R != "number")
  19353. return R;
  19354. const p2 = k(d2);
  19355. if (typeof p2 != "number")
  19356. return p2;
  19357. const N2 = k(_);
  19358. if (typeof N2 != "number")
  19359. return N2;
  19360. const M2 = +C.getValue(), w = +E2.getValue(), D2 = Math.floor(+b.getValue());
  19361. if (Number.isNaN(M2) || Number.isNaN(w) || Number.isNaN(D2))
  19362. return g2.create(m2.VALUE);
  19363. const S2 = this._getDateCorrectOrder(p2, R, N2);
  19364. if (M2 < 0 || w < 0 || D2 < 0 || D2 > 4 || !S2)
  19365. return g2.create(m2.NUM);
  19366. const P = Au(R, D2), { days: U2 } = _e2(R, p2, D2), { days: x2 } = _e2(N2, p2, D2), { days: F } = _e2(N2, R, D2), W2 = (100 + x2 / P * M2 * 100) / (1 + U2 / P * w) - F / P * M2 * 100;
  19367. return y2.create(W2);
  19368. }
  19369. _getDateCorrectOrder(e, t, r) {
  19370. return Math.floor(e) > Math.floor(t) && Math.floor(t) > Math.floor(r);
  19371. }
  19372. };
  19373. var C0 = class extends V {
  19374. constructor() {
  19375. super(...arguments);
  19376. A(this, "minParams", 3);
  19377. A(this, "maxParams", 5);
  19378. A(this, "needsLocale", true);
  19379. }
  19380. calculate(e, t, r, n, s) {
  19381. const o = n != null ? n : y2.create(0), u = s != null ? s : y2.create(0), c = Math.max(
  19382. e.isArray() ? e.getRowCount() : 1,
  19383. t.isArray() ? t.getRowCount() : 1,
  19384. r.isArray() ? r.getRowCount() : 1,
  19385. o.isArray() ? o.getRowCount() : 1,
  19386. u.isArray() ? u.getRowCount() : 1
  19387. ), l2 = Math.max(
  19388. e.isArray() ? e.getColumnCount() : 1,
  19389. t.isArray() ? t.getColumnCount() : 1,
  19390. r.isArray() ? r.getColumnCount() : 1,
  19391. o.isArray() ? o.getColumnCount() : 1,
  19392. u.isArray() ? u.getColumnCount() : 1
  19393. ), f2 = O(c, l2, e, g2.create(m2.NA)), h = O(c, l2, t, g2.create(m2.NA)), d2 = O(c, l2, r, g2.create(m2.NA)), _ = O(c, l2, o, g2.create(m2.NA)), C = O(c, l2, u, g2.create(m2.NA)), E2 = f2.map((b, R, p2) => {
  19394. const N2 = h.get(R, p2), M2 = d2.get(R, p2), w = _.get(R, p2), D2 = C.get(R, p2), { isError: S2, errorObject: P, variants: U2 } = I2(b, N2, M2, w, D2);
  19395. if (S2)
  19396. return P;
  19397. const [x2, F, W2, ne, z] = U2, G2 = +x2.getValue(), ge2 = +F.getValue(), de2 = +W2.getValue(), Ee = +ne.getValue();
  19398. let Re2 = +z.getValue();
  19399. Re2 = Re2 ? 1 : 0;
  19400. const he2 = G2 === 0 ? -de2 * ge2 - Ee : ((1 - (1 + G2) ** ge2) / G2 * de2 * (1 + G2 * Re2) - Ee) / (1 + G2) ** ge2;
  19401. return Number.isNaN(he2) || !Number.isFinite(he2) ? g2.create(m2.NUM) : R === 0 && p2 === 0 ? y2.create(he2, Ke(this.getLocale())) : y2.create(he2);
  19402. });
  19403. return c === 1 && l2 === 1 ? E2.get(0, 0) : E2;
  19404. }
  19405. };
  19406. var _0 = class extends V {
  19407. constructor() {
  19408. super(...arguments);
  19409. A(this, "minParams", 3);
  19410. A(this, "maxParams", 6);
  19411. }
  19412. calculate(e, t, r, n, s, o) {
  19413. const u = n != null ? n : y2.create(0), c = s != null ? s : y2.create(0), l2 = o != null ? o : y2.create(0.1), f2 = Math.max(
  19414. e.isArray() ? e.getRowCount() : 1,
  19415. t.isArray() ? t.getRowCount() : 1,
  19416. r.isArray() ? r.getRowCount() : 1,
  19417. u.isArray() ? u.getRowCount() : 1,
  19418. c.isArray() ? c.getRowCount() : 1,
  19419. l2.isArray() ? l2.getRowCount() : 1
  19420. ), h = Math.max(
  19421. e.isArray() ? e.getColumnCount() : 1,
  19422. t.isArray() ? t.getColumnCount() : 1,
  19423. r.isArray() ? r.getColumnCount() : 1,
  19424. u.isArray() ? u.getColumnCount() : 1,
  19425. c.isArray() ? c.getColumnCount() : 1,
  19426. l2.isArray() ? l2.getColumnCount() : 1
  19427. ), d2 = O(f2, h, e, g2.create(m2.NA)), _ = O(f2, h, t, g2.create(m2.NA)), C = O(f2, h, r, g2.create(m2.NA)), E2 = O(f2, h, u, g2.create(m2.NA)), b = O(f2, h, c, g2.create(m2.NA)), R = O(f2, h, l2, g2.create(m2.NA)), p2 = d2.map((N2, M2, w) => {
  19428. const D2 = _.get(M2, w), S2 = C.get(M2, w), P = E2.get(M2, w), U2 = b.get(M2, w), x2 = R.get(M2, w), { isError: F, errorObject: W2, variants: ne } = I2(N2, D2, S2, P, U2, x2);
  19429. if (F)
  19430. return W2;
  19431. const [z, G2, ge2, de2, Ee, Re2] = ne, he2 = +z.getValue(), ke = +G2.getValue(), Ot2 = +ge2.getValue(), ar2 = +de2.getValue();
  19432. let Mt2 = +Ee.getValue();
  19433. const st2 = +Re2.getValue();
  19434. return Mt2 = Mt2 ? 1 : 0, he2 <= 0 || ke >= 0 ? g2.create(m2.NUM) : this._getResult(he2, ke, Ot2, ar2, Mt2, st2, M2, w);
  19435. });
  19436. return f2 === 1 && h === 1 ? p2.get(0, 0) : p2;
  19437. }
  19438. _getResult(e, t, r, n, s, o, u, c) {
  19439. let h = o;
  19440. for (let d2 = 0; d2 < 20; d2++) {
  19441. if (h <= -1)
  19442. return g2.create(m2.NUM);
  19443. let _, C;
  19444. if (Math.abs(h) < 1e-10 ? _ = r * (1 + e * h) + t * (1 + h * s) * e + n : (C = (1 + h) ** e, _ = r * C + t * (1 / h + s) * (C - 1) + n), Math.abs(_) < 1e-10)
  19445. break;
  19446. let E2;
  19447. if (Math.abs(h) < 1e-10)
  19448. E2 = r * e + t * s * e;
  19449. else {
  19450. C = (1 + h) ** e;
  19451. const b = e * (1 + h) ** (e - 1);
  19452. E2 = r * b + t * (1 / h + s) * b + t * (-1 / (h * h)) * (C - 1);
  19453. }
  19454. h -= _ / E2;
  19455. }
  19456. return u === 0 && c === 0 ? y2.create(h, "0%") : y2.create(h);
  19457. }
  19458. };
  19459. var A0 = class extends V {
  19460. constructor() {
  19461. super(...arguments);
  19462. A(this, "minParams", 4);
  19463. A(this, "maxParams", 5);
  19464. }
  19465. calculate(e, t, r, n, s) {
  19466. let o = s != null ? s : y2.create(0);
  19467. o.isNull() && (o = y2.create(0));
  19468. const { isError: u, errorObject: c, variants: l2 } = Fe2(e, t, r, n, o);
  19469. if (u)
  19470. return c;
  19471. const [f2, h, d2, _, C] = l2, E2 = k(f2);
  19472. if (typeof E2 != "number")
  19473. return E2;
  19474. const b = k(h);
  19475. if (typeof b != "number")
  19476. return b;
  19477. const R = +d2.getValue(), p2 = +_.getValue(), N2 = Math.floor(+C.getValue());
  19478. if (Number.isNaN(R) || Number.isNaN(p2) || Number.isNaN(N2))
  19479. return g2.create(m2.VALUE);
  19480. if (R <= 0 || p2 <= 0 || N2 < 0 || N2 > 4 || E2 >= b)
  19481. return g2.create(m2.NUM);
  19482. const { days: M2, yearDays: w } = _e2(E2, b, N2), D2 = R / (1 - p2 * M2 / w);
  19483. return D2 < 0 ? g2.create(m2.NUM) : y2.create(D2);
  19484. }
  19485. };
  19486. var E0 = class extends V {
  19487. constructor() {
  19488. super(...arguments);
  19489. A(this, "minParams", 3);
  19490. A(this, "maxParams", 6);
  19491. }
  19492. calculate(e, t, r) {
  19493. const n = Math.max(
  19494. e.isArray() ? e.getRowCount() : 1,
  19495. t.isArray() ? t.getRowCount() : 1,
  19496. r.isArray() ? r.getRowCount() : 1
  19497. ), s = Math.max(
  19498. e.isArray() ? e.getColumnCount() : 1,
  19499. t.isArray() ? t.getColumnCount() : 1,
  19500. r.isArray() ? r.getColumnCount() : 1
  19501. ), o = O(n, s, e, g2.create(m2.NA)), u = O(n, s, t, g2.create(m2.NA)), c = O(n, s, r, g2.create(m2.NA)), l2 = o.map((f2, h, d2) => {
  19502. const _ = u.get(h, d2), C = c.get(h, d2), { isError: E2, errorObject: b, variants: R } = I2(f2, _, C);
  19503. if (E2)
  19504. return b;
  19505. const [p2, N2, M2] = R, w = +p2.getValue(), D2 = +N2.getValue(), S2 = +M2.getValue();
  19506. if (w <= 0)
  19507. return g2.create(m2.NUM);
  19508. if (D2 === 0 && S2 === 0)
  19509. return y2.create(0);
  19510. const P = (S2 / D2) ** (1 / w) - 1;
  19511. return Number.isNaN(P) || !Number.isFinite(P) || S2 / D2 < 0 ? g2.create(m2.NUM) : y2.create(P);
  19512. });
  19513. return n === 1 && s === 1 ? l2.get(0, 0) : l2;
  19514. }
  19515. };
  19516. var b0 = class extends V {
  19517. constructor() {
  19518. super(...arguments);
  19519. A(this, "minParams", 3);
  19520. A(this, "maxParams", 3);
  19521. A(this, "needsLocale", true);
  19522. }
  19523. calculate(e, t, r) {
  19524. const n = Math.max(
  19525. e.isArray() ? e.getRowCount() : 1,
  19526. t.isArray() ? t.getRowCount() : 1,
  19527. r.isArray() ? r.getRowCount() : 1
  19528. ), s = Math.max(
  19529. e.isArray() ? e.getColumnCount() : 1,
  19530. t.isArray() ? t.getColumnCount() : 1,
  19531. r.isArray() ? r.getColumnCount() : 1
  19532. ), o = O(n, s, e, g2.create(m2.NA)), u = O(n, s, t, g2.create(m2.NA)), c = O(n, s, r, g2.create(m2.NA)), l2 = o.map((f2, h, d2) => {
  19533. const _ = u.get(h, d2), C = c.get(h, d2);
  19534. if (_.isError())
  19535. return _;
  19536. if (C.isError())
  19537. return C;
  19538. const E2 = +f2.getValue(), b = +_.getValue(), R = +C.getValue();
  19539. if (Number.isNaN(E2) || Number.isNaN(b) || Number.isNaN(R))
  19540. return g2.create(m2.VALUE);
  19541. if (R === 0)
  19542. return g2.create(m2.DIV_BY_ZERO);
  19543. const p2 = (E2 - b) / R;
  19544. return h === 0 && d2 === 0 ? y2.create(p2, Ke(this.getLocale())) : y2.create(p2);
  19545. });
  19546. return n === 1 && s === 1 ? l2.get(0, 0) : l2;
  19547. }
  19548. };
  19549. var y0 = class extends V {
  19550. constructor() {
  19551. super(...arguments);
  19552. A(this, "minParams", 4);
  19553. A(this, "maxParams", 4);
  19554. A(this, "needsLocale", true);
  19555. }
  19556. calculate(e, t, r, n) {
  19557. const s = Math.max(
  19558. e.isArray() ? e.getRowCount() : 1,
  19559. t.isArray() ? t.getRowCount() : 1,
  19560. r.isArray() ? r.getRowCount() : 1,
  19561. n.isArray() ? n.getRowCount() : 1
  19562. ), o = Math.max(
  19563. e.isArray() ? e.getColumnCount() : 1,
  19564. t.isArray() ? t.getColumnCount() : 1,
  19565. r.isArray() ? r.getColumnCount() : 1,
  19566. n.isArray() ? n.getColumnCount() : 1
  19567. ), u = O(s, o, e, g2.create(m2.NA)), c = O(s, o, t, g2.create(m2.NA)), l2 = O(s, o, r, g2.create(m2.NA)), f2 = O(s, o, n, g2.create(m2.NA)), h = u.map((d2, _, C) => {
  19568. const E2 = c.get(_, C), b = l2.get(_, C), R = f2.get(_, C);
  19569. if (E2.isError())
  19570. return E2;
  19571. if (b.isError())
  19572. return b;
  19573. if (R.isError())
  19574. return R;
  19575. const p2 = +d2.getValue(), N2 = +E2.getValue(), M2 = +b.getValue(), w = +R.getValue();
  19576. if (Number.isNaN(p2) || Number.isNaN(N2) || Number.isNaN(M2) || Number.isNaN(w))
  19577. return g2.create(m2.VALUE);
  19578. if (N2 < 0 || M2 <= 0 || w > M2)
  19579. return g2.create(m2.NUM);
  19580. const D2 = (p2 - N2) * (M2 - w + 1) * 2 / (M2 * (M2 + 1));
  19581. return _ === 0 && C === 0 ? y2.create(D2, Ke(this.getLocale())) : y2.create(D2);
  19582. });
  19583. return s === 1 && o === 1 ? h.get(0, 0) : h;
  19584. }
  19585. };
  19586. var R0 = class extends V {
  19587. constructor() {
  19588. super(...arguments);
  19589. A(this, "minParams", 3);
  19590. A(this, "maxParams", 3);
  19591. }
  19592. calculate(e, t, r) {
  19593. const { isError: n, errorObject: s, variants: o } = Fe2(e, t, r);
  19594. if (n)
  19595. return s;
  19596. const [u, c, l2] = o, f2 = k(u);
  19597. if (typeof f2 != "number")
  19598. return f2;
  19599. const h = k(c);
  19600. if (typeof h != "number")
  19601. return h;
  19602. const d2 = +l2.getValue();
  19603. if (Number.isNaN(d2))
  19604. return g2.create(m2.VALUE);
  19605. if (d2 <= 0 || f2 >= h)
  19606. return g2.create(m2.NUM);
  19607. const _ = Math.floor(h) - Math.floor(f2), E2 = re2(f2).getUTCFullYear(), b = Jn(E2);
  19608. if (_ > b)
  19609. return g2.create(m2.NUM);
  19610. let R = 365 * d2 / (360 - d2 * _);
  19611. if (_ > 182) {
  19612. const p2 = 100 * (1 - d2 * _ / 360), N2 = _ / 365;
  19613. if (R = (-N2 + Math.sqrt(N2 * N2 - (N2 * 2 - 1) * (1 - 100 / p2))) / (N2 - 0.5), Number.isNaN(R))
  19614. return g2.create(m2.NUM);
  19615. }
  19616. return R < 0 ? g2.create(m2.NUM) : y2.create(R);
  19617. }
  19618. };
  19619. var p0 = class extends V {
  19620. constructor() {
  19621. super(...arguments);
  19622. A(this, "minParams", 3);
  19623. A(this, "maxParams", 3);
  19624. A(this, "needsLocale", true);
  19625. }
  19626. calculate(e, t, r) {
  19627. const { isError: n, errorObject: s, variants: o } = Fe2(e, t, r);
  19628. if (n)
  19629. return s;
  19630. const [u, c, l2] = o, f2 = k(u);
  19631. if (typeof f2 != "number")
  19632. return f2;
  19633. const h = k(c);
  19634. if (typeof h != "number")
  19635. return h;
  19636. const d2 = +l2.getValue();
  19637. if (Number.isNaN(d2))
  19638. return g2.create(m2.VALUE);
  19639. if (d2 <= 0 || f2 >= h)
  19640. return g2.create(m2.NUM);
  19641. const _ = Math.floor(h) - Math.floor(f2), E2 = re2(f2).getUTCFullYear(), b = Jn(E2);
  19642. if (_ > b)
  19643. return g2.create(m2.NUM);
  19644. const R = 100 * (1 - d2 * _ / 360);
  19645. return R < 0 ? g2.create(m2.NUM) : y2.create(R, Ke(this.getLocale()));
  19646. }
  19647. };
  19648. var V0 = class extends V {
  19649. constructor() {
  19650. super(...arguments);
  19651. A(this, "minParams", 3);
  19652. A(this, "maxParams", 3);
  19653. }
  19654. calculate(e, t, r) {
  19655. const { isError: n, errorObject: s, variants: o } = Fe2(e, t, r);
  19656. if (n)
  19657. return s;
  19658. const [u, c, l2] = o, f2 = k(u);
  19659. if (typeof f2 != "number")
  19660. return f2;
  19661. const h = k(c);
  19662. if (typeof h != "number")
  19663. return h;
  19664. const d2 = +l2.getValue();
  19665. if (Number.isNaN(d2))
  19666. return g2.create(m2.VALUE);
  19667. if (d2 <= 0 || f2 >= h)
  19668. return g2.create(m2.NUM);
  19669. const _ = Math.floor(h) - Math.floor(f2), E2 = re2(f2).getUTCFullYear(), b = Jn(E2);
  19670. if (_ > b)
  19671. return g2.create(m2.NUM);
  19672. const R = (100 - d2) / d2 * 360 / _;
  19673. return y2.create(R);
  19674. }
  19675. };
  19676. var N0 = class extends V {
  19677. constructor() {
  19678. super(...arguments);
  19679. A(this, "minParams", 5);
  19680. A(this, "maxParams", 7);
  19681. A(this, "needsLocale", true);
  19682. }
  19683. calculate(e, t, r, n, s, o, u) {
  19684. let c = o != null ? o : y2.create(2);
  19685. c.isNull() && (c = y2.create(2));
  19686. let l2 = u != null ? u : T2.create(false);
  19687. l2.isNull() && (l2 = T2.create(false));
  19688. const f2 = Math.max(
  19689. e.isArray() ? e.getRowCount() : 1,
  19690. t.isArray() ? t.getRowCount() : 1,
  19691. r.isArray() ? r.getRowCount() : 1,
  19692. n.isArray() ? n.getRowCount() : 1,
  19693. s.isArray() ? s.getRowCount() : 1,
  19694. c.isArray() ? c.getRowCount() : 1,
  19695. l2.isArray() ? l2.getRowCount() : 1
  19696. ), h = Math.max(
  19697. e.isArray() ? e.getColumnCount() : 1,
  19698. t.isArray() ? t.getColumnCount() : 1,
  19699. r.isArray() ? r.getColumnCount() : 1,
  19700. n.isArray() ? n.getColumnCount() : 1,
  19701. s.isArray() ? s.getColumnCount() : 1,
  19702. c.isArray() ? c.getColumnCount() : 1,
  19703. l2.isArray() ? l2.getColumnCount() : 1
  19704. ), d2 = O(f2, h, e, g2.create(m2.NA)), _ = O(f2, h, t, g2.create(m2.NA)), C = O(f2, h, r, g2.create(m2.NA)), E2 = O(f2, h, n, g2.create(m2.NA)), b = O(f2, h, s, g2.create(m2.NA)), R = O(f2, h, c, g2.create(m2.NA)), p2 = O(f2, h, l2, g2.create(m2.NA));
  19705. return this._getResultArray(
  19706. d2,
  19707. _,
  19708. C,
  19709. E2,
  19710. b,
  19711. R,
  19712. p2,
  19713. f2,
  19714. h
  19715. );
  19716. }
  19717. _getResultArray(e, t, r, n, s, o, u, c, l2) {
  19718. const f2 = e.map((h, d2, _) => {
  19719. const C = t.get(d2, _), E2 = r.get(d2, _), b = n.get(d2, _), R = s.get(d2, _), p2 = o.get(d2, _), N2 = u.get(d2, _), { isError: M2, errorObject: w, variants: D2 } = I2(h, C, E2, b, R, p2, N2);
  19720. if (M2)
  19721. return w;
  19722. const [S2, P, U2, x2, F, W2, ne] = D2, z = +S2.getValue(), G2 = +P.getValue(), ge2 = +U2.getValue(), de2 = +x2.getValue(), Ee = +F.getValue(), Re2 = +W2.getValue(), he2 = +ne.getValue();
  19723. if (z < 0 || G2 < 0 || ge2 < 0 || de2 < 0 || Ee < 0 || Ee > ge2 || de2 > Ee || Re2 < 0)
  19724. return g2.create(m2.NUM);
  19725. if (ge2 === 0 && de2 === 0 && Ee === 0)
  19726. return g2.create(m2.DIV_BY_ZERO);
  19727. const ke = this._getResult(z, G2, ge2, de2, Ee, Re2, he2);
  19728. return d2 === 0 && _ === 0 ? y2.create(ke, Ke(this.getLocale())) : y2.create(ke);
  19729. });
  19730. return c === 1 && l2 === 1 ? f2.get(0, 0) : f2;
  19731. }
  19732. _getResult(e, t, r, n, s, o, u) {
  19733. const c = Math.floor(n), l2 = Math.ceil(s);
  19734. let f2 = 0;
  19735. if (e < t) {
  19736. if (n >= 1 || u)
  19737. return f2;
  19738. const h = Math.abs(e - t);
  19739. return f2 = h * (s - n) > h ? h : h * (s - n), -f2;
  19740. }
  19741. if (u)
  19742. for (let h = c + 1; h <= l2; h++) {
  19743. let d2 = zs(e, t, r, h, o);
  19744. h === c + 1 ? d2 *= Math.min(s, c + 1) - n : h === l2 && (d2 *= s + 1 - l2), f2 += d2;
  19745. }
  19746. else {
  19747. const h = e - this._getVdb(e, t, r, r, n, o);
  19748. f2 = this._getVdb(h, t, r, r - n, s - n, o);
  19749. }
  19750. return f2;
  19751. }
  19752. _getVdb(e, t, r, n, s, o) {
  19753. const u = Math.ceil(s);
  19754. let c = 0, l2 = e - t, f2 = 0, h = 0, d2 = false;
  19755. for (let _ = 1; _ <= u; _++) {
  19756. if (d2)
  19757. h = f2;
  19758. else {
  19759. const C = zs(e, t, r, _, o);
  19760. f2 = l2 / (n - (_ - 1)), f2 > C ? (h = f2, d2 = true) : (h = C, l2 -= C);
  19761. }
  19762. _ === u && (h *= s + 1 - u), c += h;
  19763. }
  19764. return c;
  19765. }
  19766. };
  19767. var O0 = class extends V {
  19768. constructor() {
  19769. super(...arguments);
  19770. A(this, "minParams", 2);
  19771. A(this, "maxParams", 3);
  19772. }
  19773. calculate(e, t, r) {
  19774. if (e.isNull() || t.isNull())
  19775. return g2.create(m2.NA);
  19776. const { isError: n, errorObejct: s, _values: o, _dates: u } = this._checkErrors(e, t);
  19777. if (n)
  19778. return s;
  19779. let c = r != null ? r : y2.create(0.1);
  19780. c.isNull() && (c = y2.create(0.1));
  19781. const { isError: l2, errorObject: f2, variants: h } = H(c);
  19782. if (l2)
  19783. return f2;
  19784. const [d2] = h, _ = +d2.getValue();
  19785. if (Number.isNaN(_))
  19786. return g2.create(m2.VALUE);
  19787. const { positive: C, negative: E2 } = this._checkValues(o);
  19788. if (!C || !E2 || (o == null ? void 0 : o.length) !== (u == null ? void 0 : u.length) || _ < 0)
  19789. return g2.create(m2.NUM);
  19790. const b = Ia(_, (R) => this._iterF(o, u, R));
  19791. return typeof b != "number" ? b : y2.create(b);
  19792. }
  19793. _checkErrors(e, t) {
  19794. if (e.isError())
  19795. return {
  19796. isError: true,
  19797. errorObejct: e
  19798. };
  19799. if (t.isError())
  19800. return {
  19801. isError: true,
  19802. errorObejct: t
  19803. };
  19804. const { isError: r, errorObejct: n, _values: s } = this._checkErrorValues(e);
  19805. if (r)
  19806. return {
  19807. isError: r,
  19808. errorObejct: n
  19809. };
  19810. const { isError: o, errorObejct: u, _dates: c } = this._checkErrorDates(t);
  19811. return o ? {
  19812. isError: o,
  19813. errorObejct: u
  19814. } : {
  19815. isError: false,
  19816. _values: s,
  19817. _dates: c
  19818. };
  19819. }
  19820. _checkErrorValues(e) {
  19821. const t = [];
  19822. if (e.isArray()) {
  19823. let r = false, n = g2.create(m2.VALUE);
  19824. return e.iterator((s) => {
  19825. const o = s;
  19826. if (o.isError())
  19827. return r = true, n = o, false;
  19828. if (o.isBoolean())
  19829. return r = true, n = g2.create(m2.VALUE), false;
  19830. const u = +o.getValue();
  19831. if (Number.isNaN(u))
  19832. return r = true, n = g2.create(m2.VALUE), false;
  19833. t.push(u);
  19834. }), r ? {
  19835. isError: r,
  19836. errorObejct: n
  19837. } : t.length <= 1 ? {
  19838. isError: true,
  19839. errorObejct: g2.create(m2.NA)
  19840. } : {
  19841. isError: r,
  19842. _values: t
  19843. };
  19844. } else {
  19845. const r = e.getValue();
  19846. return e.isBoolean() || e.isString() && !DC(r) ? {
  19847. isError: true,
  19848. errorObejct: g2.create(m2.VALUE)
  19849. } : {
  19850. isError: true,
  19851. errorObejct: g2.create(m2.NA)
  19852. };
  19853. }
  19854. }
  19855. _checkErrorDates(e) {
  19856. const t = [];
  19857. if (e.isArray()) {
  19858. let r = false, n = g2.create(m2.VALUE);
  19859. return e.iterator((s) => {
  19860. if (s != null && s.isError())
  19861. return r = true, n = s, false;
  19862. if (s != null && s.isBoolean())
  19863. return r = true, n = g2.create(m2.VALUE), false;
  19864. const o = +s.getValue();
  19865. if (Number.isNaN(o))
  19866. return r = true, n = g2.create(m2.VALUE), false;
  19867. if (o < 0)
  19868. return r = true, n = g2.create(m2.NUM), false;
  19869. t.push(Math.floor(o));
  19870. }), r ? {
  19871. isError: r,
  19872. errorObejct: n
  19873. } : t.length <= 1 ? {
  19874. isError: true,
  19875. errorObejct: g2.create(m2.NA)
  19876. } : {
  19877. isError: r,
  19878. _dates: t
  19879. };
  19880. } else {
  19881. const r = e.getValue();
  19882. return e.isBoolean() || e.isString() && !DC(r) ? {
  19883. isError: true,
  19884. errorObejct: g2.create(m2.VALUE)
  19885. } : +r < 0 ? {
  19886. isError: true,
  19887. errorObejct: g2.create(m2.NUM)
  19888. } : {
  19889. isError: true,
  19890. errorObejct: g2.create(m2.NA)
  19891. };
  19892. }
  19893. }
  19894. _checkValues(e) {
  19895. let t = false, r = false;
  19896. for (let n = 0; n < e.length; n++)
  19897. e[n] > 0 && (t = true), e[n] < 0 && (r = true);
  19898. return {
  19899. positive: t,
  19900. negative: r
  19901. };
  19902. }
  19903. _iterF(e, t, r) {
  19904. return e.reduce((n, s, o) => n + s / (1 + r) ** ((t[o] - t[0]) / 365), 0);
  19905. }
  19906. };
  19907. var M0 = class extends V {
  19908. constructor() {
  19909. super(...arguments);
  19910. A(this, "minParams", 3);
  19911. A(this, "maxParams", 3);
  19912. }
  19913. calculate(e, t, r) {
  19914. if (e.isNull() || t.isNull() || r.isNull())
  19915. return g2.create(m2.NA);
  19916. const { isError: n, errorObject: s, variants: o } = H(e);
  19917. if (n)
  19918. return s;
  19919. const [u] = o, c = +u.getValue();
  19920. if (Number.isNaN(c))
  19921. return g2.create(m2.VALUE);
  19922. let { isError: l2, errorObejct: f2, _values: h, _dates: d2 } = this._checkErrors(t, r);
  19923. if (l2)
  19924. return f2;
  19925. if (h = h, d2 = d2, c < 0 || h.length !== d2.length)
  19926. return g2.create(m2.NUM);
  19927. let _ = 0;
  19928. const C = d2[0];
  19929. for (let E2 = 0; E2 < d2.length; E2++) {
  19930. const b = d2[E2], R = h[E2];
  19931. _ += R / (1 + c) ** ((b - C) / 365);
  19932. }
  19933. return y2.create(_);
  19934. }
  19935. _checkErrors(e, t) {
  19936. if (e.isError())
  19937. return {
  19938. isError: true,
  19939. errorObejct: e
  19940. };
  19941. if (t.isError())
  19942. return {
  19943. isError: true,
  19944. errorObejct: t
  19945. };
  19946. const { isError: r, errorObejct: n, _values: s } = this._checkErrorValues(e);
  19947. if (r)
  19948. return {
  19949. isError: r,
  19950. errorObejct: n
  19951. };
  19952. const { isError: o, errorObejct: u, _dates: c } = this._checkErrorDates(t);
  19953. return o ? {
  19954. isError: o,
  19955. errorObejct: u
  19956. } : {
  19957. isError: false,
  19958. _values: s,
  19959. _dates: c
  19960. };
  19961. }
  19962. _checkErrorValues(e) {
  19963. const t = [];
  19964. if (e.isArray()) {
  19965. let r = false, n = g2.create(m2.VALUE);
  19966. return e.iterator((s) => {
  19967. const o = s;
  19968. if (o.isError())
  19969. return r = true, n = o, false;
  19970. if (o.isNull() || o.isBoolean())
  19971. return r = true, n = g2.create(m2.VALUE), false;
  19972. const u = +o.getValue();
  19973. if (Number.isNaN(u))
  19974. return r = true, n = g2.create(m2.VALUE), false;
  19975. t.push(u);
  19976. }), r ? {
  19977. isError: r,
  19978. errorObejct: n
  19979. } : t.length <= 1 ? {
  19980. isError: true,
  19981. errorObejct: g2.create(m2.NA)
  19982. } : {
  19983. isError: r,
  19984. _values: t
  19985. };
  19986. } else {
  19987. const r = e.getValue();
  19988. return e.isNull() || e.isBoolean() || e.isString() && !DC(r) ? {
  19989. isError: true,
  19990. errorObejct: g2.create(m2.VALUE)
  19991. } : {
  19992. isError: true,
  19993. errorObejct: g2.create(m2.NA)
  19994. };
  19995. }
  19996. }
  19997. _checkErrorDates(e) {
  19998. const t = [];
  19999. if (e.isArray()) {
  20000. let r = false, n = g2.create(m2.VALUE);
  20001. return e.iterator((s) => {
  20002. const o = s;
  20003. if (o.isError())
  20004. return r = true, n = o, false;
  20005. if (o.isNull() || o.isBoolean())
  20006. return r = true, n = g2.create(m2.VALUE), false;
  20007. const u = +o.getValue();
  20008. if (Number.isNaN(u))
  20009. return r = true, n = g2.create(m2.VALUE), false;
  20010. if (u < 0)
  20011. return r = true, n = g2.create(m2.NUM), false;
  20012. t.push(Math.floor(u));
  20013. }), r ? {
  20014. isError: r,
  20015. errorObejct: n
  20016. } : t.length <= 1 ? {
  20017. isError: true,
  20018. errorObejct: g2.create(m2.NA)
  20019. } : {
  20020. isError: r,
  20021. _dates: t
  20022. };
  20023. } else {
  20024. const r = e.getValue();
  20025. return e.isNull() || e.isBoolean() || e.isString() && !DC(r) ? {
  20026. isError: true,
  20027. errorObejct: g2.create(m2.VALUE)
  20028. } : +r < 0 ? {
  20029. isError: true,
  20030. errorObejct: g2.create(m2.NUM)
  20031. } : {
  20032. isError: true,
  20033. errorObejct: g2.create(m2.NA)
  20034. };
  20035. }
  20036. }
  20037. };
  20038. var w0 = class extends V {
  20039. constructor() {
  20040. super(...arguments);
  20041. A(this, "minParams", 6);
  20042. A(this, "maxParams", 7);
  20043. }
  20044. calculate(e, t, r, n, s, o, u) {
  20045. let c = u != null ? u : y2.create(0);
  20046. c.isNull() && (c = y2.create(0));
  20047. const { isError: l2, errorObject: f2, variants: h } = Fe2(e, t, r, n, s, o, c);
  20048. if (l2)
  20049. return f2;
  20050. const [d2, _, C, E2, b, R, p2] = h, N2 = k(d2);
  20051. if (typeof N2 != "number")
  20052. return N2;
  20053. const M2 = k(_);
  20054. if (typeof M2 != "number")
  20055. return M2;
  20056. const w = +C.getValue(), D2 = +E2.getValue(), S2 = +b.getValue(), P = Math.floor(+R.getValue()), U2 = Math.floor(+p2.getValue());
  20057. if (Number.isNaN(w) || Number.isNaN(D2) || Number.isNaN(S2) || Number.isNaN(P) || Number.isNaN(U2))
  20058. return g2.create(m2.VALUE);
  20059. if (w < 0 || D2 <= 0 || S2 <= 0 || ![1, 2, 4].includes(P) || U2 < 0 || U2 > 4 || N2 >= M2 || !Or(N2, M2, P))
  20060. return g2.create(m2.NUM);
  20061. const x2 = this._getResult(N2, M2, w, D2, S2, P, U2);
  20062. return y2.create(x2);
  20063. }
  20064. _getResult(e, t, r, n, s, o, u) {
  20065. if (nr(e, t, o) > 1) {
  20066. let E2 = r || 0.01, b = un(e, t, r, E2, s, o, u), R = b - n;
  20067. for (let p2 = 0; p2 < 100 && Math.abs(R) > 1e-7; p2++)
  20068. b = un(e, t, r, 1.01 * E2, s, o, u), E2 += -R / (b - n - R) * E2 * 0.01, R = un(e, t, r, E2, s, o, u) - n;
  20069. return E2;
  20070. }
  20071. const l2 = es(e, t, o, u), f2 = qe(e, t, o, u), { days: h } = _e2(e, t, u), d2 = n / 100 + l2 / f2 * r / o;
  20072. return (s / 100 + r / o - d2) / d2 * o * f2 / h;
  20073. }
  20074. };
  20075. var D0 = class extends V {
  20076. constructor() {
  20077. super(...arguments);
  20078. A(this, "minParams", 4);
  20079. A(this, "maxParams", 5);
  20080. }
  20081. calculate(e, t, r, n, s) {
  20082. let o = s != null ? s : y2.create(0);
  20083. o.isNull() && (o = y2.create(0));
  20084. const { isError: u, errorObject: c, variants: l2 } = Fe2(e, t, r, n, o);
  20085. if (u)
  20086. return c;
  20087. const [f2, h, d2, _, C] = l2, E2 = k(f2);
  20088. if (typeof E2 != "number")
  20089. return E2;
  20090. const b = k(h);
  20091. if (typeof b != "number")
  20092. return b;
  20093. const R = +d2.getValue(), p2 = +_.getValue(), N2 = Math.floor(+C.getValue());
  20094. if (Number.isNaN(R) || Number.isNaN(p2) || Number.isNaN(N2))
  20095. return g2.create(m2.VALUE);
  20096. if (R <= 0 || p2 <= 0 || N2 < 0 || N2 > 4 || E2 >= b)
  20097. return g2.create(m2.NUM);
  20098. const { days: M2, yearDays: w } = _e2(E2, b, N2), D2 = (p2 / R - 1) / (M2 / w);
  20099. return y2.create(D2);
  20100. }
  20101. };
  20102. var S0 = class extends V {
  20103. constructor() {
  20104. super(...arguments);
  20105. A(this, "minParams", 5);
  20106. A(this, "maxParams", 6);
  20107. }
  20108. calculate(e, t, r, n, s, o) {
  20109. let u = o != null ? o : y2.create(0);
  20110. u.isNull() && (u = y2.create(0));
  20111. const { isError: c, errorObject: l2, variants: f2 } = Fe2(e, t, r, n, s, u);
  20112. if (c)
  20113. return l2;
  20114. const [h, d2, _, C, E2, b] = f2, R = k(h);
  20115. if (typeof R != "number")
  20116. return R;
  20117. const p2 = k(d2);
  20118. if (typeof p2 != "number")
  20119. return p2;
  20120. const N2 = k(_);
  20121. if (typeof N2 != "number")
  20122. return N2;
  20123. const M2 = +C.getValue(), w = +E2.getValue(), D2 = Math.floor(+b.getValue());
  20124. if (Number.isNaN(M2) || Number.isNaN(w) || Number.isNaN(D2))
  20125. return g2.create(m2.VALUE);
  20126. const S2 = this._getDateCorrectOrder(p2, R, N2);
  20127. if (M2 < 0 || w <= 0 || D2 < 0 || D2 > 4 || !S2)
  20128. return g2.create(m2.NUM);
  20129. const P = Au(R, D2), { days: U2 } = _e2(R, p2, D2), { days: x2 } = _e2(N2, p2, D2), { days: F } = _e2(N2, R, D2), W2 = ((1 + x2 / P * M2) / (w / 100 + F / P * M2) - 1) / (U2 / P);
  20130. return y2.create(W2);
  20131. }
  20132. _getDateCorrectOrder(e, t, r) {
  20133. return Math.floor(e) > Math.floor(t) && Math.floor(t) > Math.floor(r);
  20134. }
  20135. };
  20136. var P0 = [
  20137. [P1, ee.ACCRINT],
  20138. [L1, ee.ACCRINTM],
  20139. [x1, ee.AMORLINC],
  20140. [j1, ee.COUPDAYBS],
  20141. [U1, ee.COUPDAYS],
  20142. [v1, ee.COUPDAYSNC],
  20143. [T1, ee.COUPNCD],
  20144. [B1, ee.COUPNUM],
  20145. [I1, ee.COUPPCD],
  20146. [F1, ee.CUMIPMT],
  20147. [k1, ee.CUMPRINC],
  20148. [$1, ee.DB],
  20149. [Y1, ee.DDB],
  20150. [H1, ee.DISC],
  20151. [G1, ee.DOLLARDE],
  20152. [Q1, ee.DOLLARFR],
  20153. [W1, ee.DURATION],
  20154. [q1, ee.EFFECT],
  20155. [K1, ee.FV],
  20156. [X1, ee.FVSCHEDULE],
  20157. [Z1, ee.INTRATE],
  20158. [z1, ee.IPMT],
  20159. [J1, ee.IRR],
  20160. [e0, ee.ISPMT],
  20161. [t0, ee.MDURATION],
  20162. [r0, ee.MIRR],
  20163. [n0, ee.NOMINAL],
  20164. [s0, ee.NPER],
  20165. [a0, ee.NPV],
  20166. [i0, ee.ODDFPRICE],
  20167. [o0, ee.ODDFYIELD],
  20168. [u0, ee.ODDLPRICE],
  20169. [c0, ee.ODDLYIELD],
  20170. [l0, ee.PDURATION],
  20171. [f0, ee.PMT],
  20172. [h0, ee.PPMT],
  20173. [m0, ee.PRICE],
  20174. [g0, ee.PRICEDISC],
  20175. [d0, ee.PRICEMAT],
  20176. [C0, ee.PV],
  20177. [_0, ee.RATE],
  20178. [A0, ee.RECEIVED],
  20179. [E0, ee.RRI],
  20180. [b0, ee.SLN],
  20181. [y0, ee.SYD],
  20182. [R0, ee.TBILLEQ],
  20183. [p0, ee.TBILLPRICE],
  20184. [V0, ee.TBILLYIELD],
  20185. [N0, ee.VDB],
  20186. [O0, ee.XIRR],
  20187. [M0, ee.XNPV],
  20188. [w0, ee.YIELD],
  20189. [D0, ee.YIELDDISC],
  20190. [S0, ee.YIELDMAT]
  20191. ];
  20192. var L0 = class extends V {
  20193. constructor() {
  20194. super(...arguments);
  20195. A(this, "needsReferenceObject", true);
  20196. A(this, "minParams", 2);
  20197. A(this, "maxParams", 2);
  20198. }
  20199. calculate(e, t) {
  20200. let r = e;
  20201. if (r.isError())
  20202. return r;
  20203. if (r.isReferenceObject() && (r = r.toArrayValueObject()), r.isArray()) {
  20204. const n = r.getRowCount(), s = r.getColumnCount();
  20205. if (n === 1 && s === 1) {
  20206. const o = r.get(0, 0);
  20207. return this._handleSingleObject(o, t);
  20208. }
  20209. return r.map((o) => o.isError() ? o : this._handleSingleObject(o, t, true));
  20210. }
  20211. return this._handleSingleObject(r, t);
  20212. }
  20213. _handleSingleObject(e, t, r = false) {
  20214. let n = t;
  20215. if (n.isError())
  20216. return n;
  20217. if (!n.isReferenceObject())
  20218. return g2.create(m2.NA);
  20219. const s = n.getCurrentActiveSheetData(), { columnData: o, defaultColumnWidth: u } = s;
  20220. n = n.toArrayValueObject();
  20221. const c = n.getCurrentRow(), l2 = n.getCurrentColumn();
  20222. n = n.getFirstCell();
  20223. const f2 = `${e.getValue()}`;
  20224. let h;
  20225. switch (f2.toLocaleLowerCase()) {
  20226. case "address":
  20227. return j.create(`$${re.chatAtABC(l2)}$${c + 1}`);
  20228. case "col":
  20229. return y2.create(l2 + 1);
  20230. case "color":
  20231. return y2.create(0);
  20232. case "contents":
  20233. return n;
  20234. case "filename":
  20235. return g2.create(m2.VALUE);
  20236. case "format":
  20237. return j.create("G");
  20238. case "parentheses":
  20239. return y2.create(0);
  20240. case "prefix":
  20241. return j.create("");
  20242. case "protect":
  20243. return y2.create(1);
  20244. case "row":
  20245. return y2.create(c + 1);
  20246. case "type":
  20247. return h = "v", n.isNull() && (h = "b"), n.isString() && (h = "l"), j.create(h);
  20248. case "width":
  20249. return this._getWidthResult(o, u, l2, r);
  20250. default:
  20251. return g2.create(m2.VALUE);
  20252. }
  20253. }
  20254. _getWidthResult(e, t, r, n) {
  20255. var u;
  20256. let s = (u = e[r]) == null ? void 0 : u.w;
  20257. if (!s && s !== 0 && (s = t), n)
  20258. return y2.create(s);
  20259. const o = [[s, s === t]];
  20260. return q2.createByArray(o);
  20261. }
  20262. };
  20263. var x0 = class extends V {
  20264. constructor() {
  20265. super(...arguments);
  20266. A(this, "minParams", 1);
  20267. A(this, "maxParams", 1);
  20268. A(this, "_errorTypeValueMap", /* @__PURE__ */ new Map([
  20269. [m2.NULL, 1],
  20270. [m2.DIV_BY_ZERO, 2],
  20271. [m2.VALUE, 3],
  20272. [m2.REF, 4],
  20273. [m2.NAME, 5],
  20274. [m2.NUM, 6],
  20275. [m2.NA, 7],
  20276. [m2.CONNECT, 8],
  20277. [m2.CALC, 14]
  20278. ]));
  20279. }
  20280. calculate(e) {
  20281. return e.isArray() ? e.mapValue((t) => this._handleSingleObject(t)) : this._handleSingleObject(e);
  20282. }
  20283. _handleSingleObject(e) {
  20284. const t = e.getValue(), r = this._errorTypeValueMap.get(t);
  20285. return r ? y2.create(r) : g2.create(m2.NA);
  20286. }
  20287. };
  20288. var Ne = ((i) => (i.CELL = "CELL", i.ERROR_TYPE = "ERROR.TYPE", i.INFO = "INFO", i.ISBETWEEN = "ISBETWEEN", i.ISBLANK = "ISBLANK", i.ISDATE = "ISDATE", i.ISEMAIL = "ISEMAIL", i.ISERR = "ISERR", i.ISERROR = "ISERROR", i.ISEVEN = "ISEVEN", i.ISFORMULA = "ISFORMULA", i.ISLOGICAL = "ISLOGICAL", i.ISNA = "ISNA", i.ISNONTEXT = "ISNONTEXT", i.ISNUMBER = "ISNUMBER", i.ISODD = "ISODD", i.ISOMITTED = "ISOMITTED", i.ISREF = "ISREF", i.ISTEXT = "ISTEXT", i.ISURL = "ISURL", i.N = "N", i.NA = "NA", i.SHEET = "SHEET", i.SHEETS = "SHEETS", i.TYPE = "TYPE", i))(Ne || {});
  20289. var j0 = class extends V {
  20290. constructor() {
  20291. super(...arguments);
  20292. A(this, "minParams", 3);
  20293. A(this, "maxParams", 5);
  20294. }
  20295. calculate(e, t, r, n, s) {
  20296. const o = n != null ? n : T2.create(true), u = s != null ? s : T2.create(true), { isError: c, errorObject: l2, variants: f2 } = Fr(e, t, r, o, u);
  20297. if (c)
  20298. return l2;
  20299. const [h, d2, _, C, E2] = f2;
  20300. if (C.isString() || E2.isString())
  20301. return g2.create(m2.VALUE);
  20302. if (d2.compare(_, ">").getValue() === true)
  20303. return g2.create(m2.NUM);
  20304. const R = +C.getValue(), p2 = +E2.getValue(), N2 = R ? ">=" : ">", M2 = p2 ? "<=" : "<";
  20305. return h.compare(d2, N2).getValue() === false || h.compare(_, M2).getValue() === false ? T2.create(false) : T2.create(true);
  20306. }
  20307. };
  20308. var U0 = class extends V {
  20309. constructor() {
  20310. super(...arguments);
  20311. A(this, "minParams", 1);
  20312. A(this, "maxParams", 1);
  20313. }
  20314. calculate(e) {
  20315. return e.isNull() ? T2.create(true) : e.isArray() ? e.mapValue((t) => t.isNull() ? T2.create(true) : T2.create(false)) : T2.create(false);
  20316. }
  20317. };
  20318. var v0 = class extends V {
  20319. constructor() {
  20320. super(...arguments);
  20321. A(this, "minParams", 1);
  20322. A(this, "maxParams", 1);
  20323. }
  20324. calculate(e) {
  20325. let t = e;
  20326. if (t.isArray()) {
  20327. const r = t.getRowCount(), n = t.getColumnCount();
  20328. if (r > 1 || n > 1)
  20329. return g2.create(m2.VALUE);
  20330. t = t.get(0, 0);
  20331. }
  20332. return t.isError() ? t : t.isNumber() && t.getPattern() !== "" ? T2.create(Ba(t.getPattern())) : t.isString() && (Xs(`${t.getValue()}`) || Zs(`${t.getValue()}`)) ? T2.create(true) : T2.create(false);
  20333. }
  20334. };
  20335. var T0 = class extends V {
  20336. constructor() {
  20337. super(...arguments);
  20338. A(this, "minParams", 1);
  20339. A(this, "maxParams", 1);
  20340. }
  20341. calculate(e) {
  20342. let t = e;
  20343. if (t.isArray()) {
  20344. const o = t.getRowCount(), u = t.getColumnCount();
  20345. if (o > 1 || u > 1)
  20346. return g2.create(m2.VALUE);
  20347. t = t.get(0, 0);
  20348. }
  20349. if (t.isError())
  20350. return t;
  20351. if (t.isNull() || t.isBoolean() || t.isNumber())
  20352. return T2.create(false);
  20353. const r = `${t.getValue()}`;
  20354. if (r.length > 254)
  20355. return T2.create(false);
  20356. const n = re.topLevelDomainCombiningString(), s = new RegExp(
  20357. `^(?:[\\w+-]+\\.)*[\\w+-]+@[a-z0-9_-]+(?:\\.[a-z0-9_-]+)*\\.(?:${n})$`,
  20358. "i"
  20359. );
  20360. return T2.create(s.test(r));
  20361. }
  20362. };
  20363. var B0 = class extends V {
  20364. constructor() {
  20365. super(...arguments);
  20366. A(this, "minParams", 1);
  20367. A(this, "maxParams", 1);
  20368. }
  20369. calculate(e) {
  20370. return e.getValue() === m2.NA ? T2.create(false) : e.isError() ? T2.create(true) : e.isArray() ? e.mapValue((t) => t.getValue() === m2.NA ? T2.create(false) : t.isError() ? T2.create(true) : T2.create(false)) : T2.create(false);
  20371. }
  20372. };
  20373. var I0 = class extends V {
  20374. constructor() {
  20375. super(...arguments);
  20376. A(this, "minParams", 1);
  20377. A(this, "maxParams", 1);
  20378. }
  20379. calculate(e) {
  20380. return e.isError() ? T2.create(true) : e.isArray() ? e.mapValue((t) => t.isError() ? T2.create(true) : T2.create(false)) : T2.create(false);
  20381. }
  20382. };
  20383. var F0 = class extends V {
  20384. constructor() {
  20385. super(...arguments);
  20386. A(this, "minParams", 1);
  20387. A(this, "maxParams", 1);
  20388. }
  20389. calculate(e) {
  20390. let t = e;
  20391. if (t.isArray()) {
  20392. const s = t.getRowCount(), o = t.getColumnCount();
  20393. if (s > 1 || o > 1)
  20394. return g2.create(m2.VALUE);
  20395. t = t.get(0, 0);
  20396. }
  20397. if (t.isError())
  20398. return t;
  20399. if (t.isBoolean())
  20400. return g2.create(m2.VALUE);
  20401. const r = Math.trunc(+t.getValue());
  20402. if (Number.isNaN(r))
  20403. return g2.create(m2.VALUE);
  20404. const n = r % 2 === 0;
  20405. return T2.create(n);
  20406. }
  20407. };
  20408. var k0 = class extends V {
  20409. constructor() {
  20410. super(...arguments);
  20411. A(this, "minParams", 1);
  20412. A(this, "maxParams", 1);
  20413. A(this, "needsReferenceObject", true);
  20414. }
  20415. calculate(e) {
  20416. var u;
  20417. if (e.isError())
  20418. return e;
  20419. if (!e.isReferenceObject())
  20420. return g2.create(m2.NA);
  20421. const t = (u = e.getCurrentActiveSheetData()) == null ? void 0 : u.cellData.getMatrix(), { startRow: r, startColumn: n } = e.getRangePosition(), s = e.toArrayValueObject(), o = s.mapValue((c, l2, f2) => {
  20422. var d2;
  20423. const h = (d2 = t == null ? void 0 : t[r + l2]) == null ? void 0 : d2[n + f2];
  20424. return h != null && h.f || h != null && h.si ? T2.create(true) : T2.create(false);
  20425. });
  20426. return s.getRowCount() === 1 && s.getColumnCount() === 1 ? o.get(0, 0) : o;
  20427. }
  20428. };
  20429. var $0 = class extends V {
  20430. constructor() {
  20431. super(...arguments);
  20432. A(this, "minParams", 1);
  20433. A(this, "maxParams", 1);
  20434. }
  20435. calculate(e) {
  20436. return e.isBoolean() ? T2.create(true) : e.isArray() ? e.mapValue((t) => t.isBoolean() ? T2.create(true) : T2.create(false)) : T2.create(false);
  20437. }
  20438. };
  20439. var Y0 = class extends V {
  20440. constructor() {
  20441. super(...arguments);
  20442. A(this, "minParams", 1);
  20443. A(this, "maxParams", 1);
  20444. }
  20445. calculate(e) {
  20446. return e.getValue() === m2.NA ? T2.create(true) : e.isArray() ? e.mapValue((t) => t.getValue() === m2.NA ? T2.create(true) : T2.create(false)) : T2.create(false);
  20447. }
  20448. };
  20449. var H0 = class extends V {
  20450. constructor() {
  20451. super(...arguments);
  20452. A(this, "minParams", 1);
  20453. A(this, "maxParams", 1);
  20454. }
  20455. calculate(e) {
  20456. return !e.isArray() && !e.isString() ? T2.create(true) : e.isArray() ? e.mapValue((t) => t.isString() ? T2.create(false) : T2.create(true)) : T2.create(false);
  20457. }
  20458. };
  20459. var G0 = class extends V {
  20460. constructor() {
  20461. super(...arguments);
  20462. A(this, "minParams", 1);
  20463. A(this, "maxParams", 1);
  20464. }
  20465. calculate(e) {
  20466. return e.isNumber() ? T2.create(true) : e.isArray() ? e.mapValue((t) => t.isNumber() ? T2.create(true) : T2.create(false)) : T2.create(false);
  20467. }
  20468. };
  20469. var Q0 = class extends V {
  20470. constructor() {
  20471. super(...arguments);
  20472. A(this, "minParams", 1);
  20473. A(this, "maxParams", 1);
  20474. }
  20475. calculate(e) {
  20476. let t = e;
  20477. if (t.isArray()) {
  20478. const s = t.getRowCount(), o = t.getColumnCount();
  20479. if (s > 1 || o > 1)
  20480. return g2.create(m2.VALUE);
  20481. t = t.get(0, 0);
  20482. }
  20483. if (t.isError())
  20484. return t;
  20485. if (t.isBoolean())
  20486. return g2.create(m2.VALUE);
  20487. const r = Math.trunc(+t.getValue());
  20488. if (Number.isNaN(r))
  20489. return g2.create(m2.VALUE);
  20490. const n = r % 2 !== 0;
  20491. return T2.create(n);
  20492. }
  20493. };
  20494. var W0 = class extends V {
  20495. constructor() {
  20496. super(...arguments);
  20497. A(this, "minParams", 1);
  20498. A(this, "maxParams", 1);
  20499. A(this, "needsReferenceObject", true);
  20500. }
  20501. calculate(e) {
  20502. return e.isReferenceObject() ? T2.create(true) : T2.create(false);
  20503. }
  20504. };
  20505. var q0 = class extends V {
  20506. constructor() {
  20507. super(...arguments);
  20508. A(this, "minParams", 1);
  20509. A(this, "maxParams", 1);
  20510. }
  20511. calculate(e) {
  20512. return e.isString() ? T2.create(true) : e.isArray() ? e.mapValue((t) => t.isString() ? T2.create(true) : T2.create(false)) : T2.create(false);
  20513. }
  20514. };
  20515. var K0 = class extends V {
  20516. constructor() {
  20517. super(...arguments);
  20518. A(this, "minParams", 1);
  20519. A(this, "maxParams", 1);
  20520. }
  20521. calculate(e) {
  20522. let t = e;
  20523. if (t.isArray()) {
  20524. const o = t.getRowCount(), u = t.getColumnCount();
  20525. if (o > 1 || u > 1)
  20526. return g2.create(m2.VALUE);
  20527. t = t.get(0, 0);
  20528. }
  20529. if (t.isError())
  20530. return t;
  20531. if (t.isNull() || t.isBoolean() || t.isNumber())
  20532. return T2.create(false);
  20533. const r = `${t.getValue()}`.replace(/^\s+|\s+$/g, "");
  20534. if (r.length > 1e3)
  20535. return T2.create(false);
  20536. const n = re.topLevelDomainCombiningString(), s = new RegExp(
  20537. `^(?:(?:https?|s?ftp|ftps|nfs|ssh)://+[a-z0-9_-]+(?:\\.[a-z0-9_-]+)*(?::[0-9]+)?(?:/(?:[A-Za-z0-9\\-._~!$&'()*+,;=:@]|%[A-Fa-f0-9]{2})*)*/?(?:[?#]\\S*)?|[a-z0-9_-]+(?:\\.[a-z0-9_-]+)*\\.(?:${n})(?::[0-9]+)?(?:/(?:[A-Za-z0-9\\-._~!$&'()*+,;=:@]|%[A-Fa-f0-9]{2})*)*/?(?:[?#]\\S*)?|mailto:(?:[\\w+-]+\\.)*[\\w+-]+@[a-z0-9_-]+(?:\\.[a-z0-9_-]+)*\\.(?:${n})|(?:news|aim):[%a-z0-9$_\\.+!*(),;/?#:@&~=-]+)$`,
  20538. "i"
  20539. );
  20540. return T2.create(s.test(r));
  20541. }
  20542. };
  20543. var X0 = class extends V {
  20544. constructor() {
  20545. super(...arguments);
  20546. A(this, "minParams", 1);
  20547. A(this, "maxParams", 1);
  20548. }
  20549. calculate(e) {
  20550. let t = e;
  20551. if (e.isArray() && (t = e.get(0, 0)), t.isError())
  20552. return t;
  20553. if (t.isString())
  20554. return y2.create(0);
  20555. const r = +t.getValue();
  20556. return y2.create(r);
  20557. }
  20558. };
  20559. var Z0 = class extends V {
  20560. constructor() {
  20561. super(...arguments);
  20562. A(this, "minParams", 0);
  20563. A(this, "maxParams", 0);
  20564. }
  20565. calculate() {
  20566. return g2.create(m2.NA);
  20567. }
  20568. };
  20569. var z0 = class extends V {
  20570. constructor() {
  20571. super(...arguments);
  20572. A(this, "minParams", 0);
  20573. A(this, "maxParams", 1);
  20574. A(this, "needsReferenceObject", true);
  20575. A(this, "needsSheetsInfo", true);
  20576. }
  20577. calculate(e) {
  20578. var u;
  20579. if (e != null && e.isError())
  20580. return e;
  20581. const { sheetOrder: t, sheetNameMap: r } = this.getSheetsInfo();
  20582. if (!e) {
  20583. const c = t.findIndex((l2) => l2 === this.subUnitId);
  20584. return y2.create(c + 1);
  20585. }
  20586. if (e.isReferenceObject()) {
  20587. const c = e.getForcedSheetId(), l2 = e.getDefaultSheetId(), f2 = t.findIndex((h) => c ? h === c : h === l2);
  20588. return y2.create(f2 + 1);
  20589. }
  20590. if (e.isArray())
  20591. return g2.create(m2.NA);
  20592. const n = `${e.getValue()}`.toLocaleLowerCase(), s = (u = Object.entries(r).find(([c, l2]) => l2.toLocaleLowerCase() === n)) == null ? void 0 : u[0];
  20593. if (!s)
  20594. return g2.create(m2.NA);
  20595. const o = t.findIndex((c) => c === s);
  20596. return y2.create(o + 1);
  20597. }
  20598. };
  20599. var J02 = class extends V {
  20600. constructor() {
  20601. super(...arguments);
  20602. A(this, "minParams", 0);
  20603. A(this, "maxParams", 0);
  20604. A(this, "needsSheetsInfo", true);
  20605. }
  20606. calculate() {
  20607. const { sheetOrder: e } = this.getSheetsInfo();
  20608. return y2.create(e.length);
  20609. }
  20610. };
  20611. var ed = class extends V {
  20612. constructor() {
  20613. super(...arguments);
  20614. A(this, "needsReferenceObject", true);
  20615. A(this, "minParams", 1);
  20616. A(this, "maxParams", 1);
  20617. }
  20618. calculate(e) {
  20619. if (e.isReferenceObject()) {
  20620. const t = e.getRowCount(), r = e.getColumnCount();
  20621. if (t === 1 && r === 1) {
  20622. const n = e.getFirstCell();
  20623. if (n.isError())
  20624. return y2.create(16);
  20625. if (n.isBoolean())
  20626. return y2.create(4);
  20627. if (n.isString())
  20628. return y2.create(2);
  20629. if (n.isNumber() || n.isNull())
  20630. return y2.create(1);
  20631. } else
  20632. return y2.create(64);
  20633. } else {
  20634. if (e.isArray())
  20635. return y2.create(64);
  20636. if (e.isError())
  20637. return y2.create(16);
  20638. if (e.isBoolean())
  20639. return y2.create(4);
  20640. if (e.isString())
  20641. return y2.create(2);
  20642. if (e.isNumber() || e.isNull())
  20643. return y2.create(1);
  20644. }
  20645. return y2.create(128);
  20646. }
  20647. };
  20648. var td = [
  20649. [L0, Ne.CELL],
  20650. [x0, Ne.ERROR_TYPE],
  20651. [j0, Ne.ISBETWEEN],
  20652. [U0, Ne.ISBLANK],
  20653. [v0, Ne.ISDATE],
  20654. [T0, Ne.ISEMAIL],
  20655. [B0, Ne.ISERR],
  20656. [I0, Ne.ISERROR],
  20657. [F0, Ne.ISEVEN],
  20658. [k0, Ne.ISFORMULA],
  20659. [$0, Ne.ISLOGICAL],
  20660. [Y0, Ne.ISNA],
  20661. [H0, Ne.ISNONTEXT],
  20662. [G0, Ne.ISNUMBER],
  20663. [Q0, Ne.ISODD],
  20664. [W0, Ne.ISREF],
  20665. [q0, Ne.ISTEXT],
  20666. [K0, Ne.ISURL],
  20667. [X0, Ne.N],
  20668. [Z0, Ne.NA],
  20669. [z0, Ne.SHEET],
  20670. [J02, Ne.SHEETS],
  20671. [ed, Ne.TYPE]
  20672. ];
  20673. var rd = class extends V {
  20674. constructor() {
  20675. super(...arguments);
  20676. A(this, "minParams", 1);
  20677. A(this, "maxParams", 255);
  20678. }
  20679. calculate(...e) {
  20680. let t = true, r = true, n = null;
  20681. for (const s of e) {
  20682. if (s.isError())
  20683. return s;
  20684. if (s.isArray()) {
  20685. if (s.iterator((o) => {
  20686. if (o != null && o.isError())
  20687. return n = o, false;
  20688. (o != null && o.isBoolean() || o != null && o.isNumber()) && (t = t && !!o.getValue(), r = false);
  20689. }), n)
  20690. return n;
  20691. } else
  20692. (s.isBoolean() || s.isNumber()) && (t = t && !!s.getValue(), r = false);
  20693. }
  20694. return r ? g2.create(m2.VALUE) : T2.create(t);
  20695. }
  20696. };
  20697. var nd = class extends V {
  20698. constructor() {
  20699. super(...arguments);
  20700. A(this, "minParams", 2);
  20701. A(this, "maxParams", 2);
  20702. A(this, "needsReferenceObject", true);
  20703. }
  20704. // eslint-disable-next-line
  20705. calculate(e, t) {
  20706. let r = e, n = null;
  20707. if (e.isReferenceObject() && (r = e.toArrayValueObject(), n = e), r.isError())
  20708. return r;
  20709. if (t.isError())
  20710. return t;
  20711. if (!(t.isValueObject() && t.isLambda() && t.getLambdaPrivacyVarKeys().length === 1))
  20712. return g2.create(m2.VALUE);
  20713. const s = t, o = r.isArray() ? r.getRowCount() : 1, u = r.isArray() ? r.getColumnCount() : 1;
  20714. r = O(o, u, r);
  20715. const c = [[]];
  20716. for (let l2 = 0; l2 < u; l2++) {
  20717. const f2 = [];
  20718. for (let _ = 0; _ < o; _++) {
  20719. const C = r.get(_, l2);
  20720. f2.push([C]);
  20721. }
  20722. let h = q2.create({
  20723. calculateValueList: f2,
  20724. rowCount: o,
  20725. columnCount: 1,
  20726. unitId: "",
  20727. sheetId: "",
  20728. row: 0,
  20729. column: 0
  20730. });
  20731. if (n) {
  20732. const { startRow: _, startColumn: C } = n.getRangePosition(), E2 = {
  20733. startRow: _,
  20734. startColumn: C + l2,
  20735. endRow: _ + o - 1,
  20736. endColumn: C + l2
  20737. };
  20738. h = this.createReferenceObject(n, E2);
  20739. }
  20740. let d2 = s.execute(h);
  20741. if (d2.isArray()) {
  20742. const _ = d2.getRowCount(), C = d2.getColumnCount();
  20743. if (_ > 1 || C > 1)
  20744. return g2.create(m2.CALC);
  20745. d2 = d2.get(0, 0);
  20746. }
  20747. d2.isNull() && (d2 = y2.create(0)), c[0].push(d2);
  20748. }
  20749. return u === 1 ? c[0][0] : q2.create({
  20750. calculateValueList: c,
  20751. rowCount: 1,
  20752. columnCount: u,
  20753. unitId: this.unitId,
  20754. sheetId: this.subUnitId,
  20755. row: this.row,
  20756. column: this.column
  20757. });
  20758. }
  20759. };
  20760. var sd = class extends V {
  20761. constructor() {
  20762. super(...arguments);
  20763. A(this, "minParams", 2);
  20764. A(this, "maxParams", 2);
  20765. A(this, "needsReferenceObject", true);
  20766. }
  20767. // eslint-disable-next-line
  20768. calculate(e, t) {
  20769. let r = e, n = null;
  20770. if (e.isReferenceObject() && (r = e.toArrayValueObject(), n = e), r.isError())
  20771. return r;
  20772. if (t.isError())
  20773. return t;
  20774. if (!(t.isValueObject() && t.isLambda() && t.getLambdaPrivacyVarKeys().length === 1))
  20775. return g2.create(m2.VALUE);
  20776. const s = t, o = r.isArray() ? r.getRowCount() : 1, u = r.isArray() ? r.getColumnCount() : 1;
  20777. r = O(o, u, r);
  20778. const c = [];
  20779. for (let l2 = 0; l2 < o; l2++) {
  20780. const f2 = [[]];
  20781. for (let _ = 0; _ < u; _++) {
  20782. const C = r.get(l2, _);
  20783. f2[0].push(C);
  20784. }
  20785. let h = q2.create({
  20786. calculateValueList: f2,
  20787. rowCount: 1,
  20788. columnCount: u,
  20789. unitId: "",
  20790. sheetId: "",
  20791. row: 0,
  20792. column: 0
  20793. });
  20794. if (n) {
  20795. const { startRow: _, startColumn: C } = n.getRangePosition(), E2 = {
  20796. startRow: _ + l2,
  20797. startColumn: C,
  20798. endRow: _ + l2,
  20799. endColumn: C + u - 1
  20800. };
  20801. h = this.createReferenceObject(n, E2);
  20802. }
  20803. let d2 = s.execute(h);
  20804. if (d2.isArray()) {
  20805. const _ = d2.getRowCount(), C = d2.getColumnCount();
  20806. if (_ > 1 || C > 1)
  20807. return g2.create(m2.CALC);
  20808. d2 = d2.get(0, 0);
  20809. }
  20810. d2.isNull() && (d2 = y2.create(0)), c.push([d2]);
  20811. }
  20812. return o === 1 ? c[0][0] : q2.create({
  20813. calculateValueList: c,
  20814. rowCount: o,
  20815. columnCount: 1,
  20816. unitId: this.unitId,
  20817. sheetId: this.subUnitId,
  20818. row: this.row,
  20819. column: this.column
  20820. });
  20821. }
  20822. };
  20823. var ad = class extends V {
  20824. constructor() {
  20825. super(...arguments);
  20826. A(this, "minParams", 0);
  20827. A(this, "maxParams", 0);
  20828. }
  20829. calculate() {
  20830. return T2.create(false);
  20831. }
  20832. };
  20833. var Se2 = ((i) => (i.AND = "AND", i.BYCOL = "BYCOL", i.BYROW = "BYROW", i.FALSE = "FALSE", i.IF = "IF", i.IFERROR = "IFERROR", i.IFNA = "IFNA", i.IFS = "IFS", i.LAMBDA = "LAMBDA", i.LET = "LET", i.MAKEARRAY = "MAKEARRAY", i.MAP = "MAP", i.NOT = "NOT", i.OR = "OR", i.REDUCE = "REDUCE", i.SCAN = "SCAN", i.SWITCH = "SWITCH", i.TRUE = "TRUE", i.XOR = "XOR", i))(Se2 || {});
  20834. var id = class extends V {
  20835. constructor() {
  20836. super(...arguments);
  20837. A(this, "minParams", 2);
  20838. A(this, "maxParams", 3);
  20839. }
  20840. calculate(e, t, r = T2.create(false)) {
  20841. const n = this._getSingleValueObject(e);
  20842. if (n.isError())
  20843. return n;
  20844. if (!n.isArray())
  20845. return n.getValue() ? t : r;
  20846. const s = Math.max(
  20847. n.isArray() ? n.getRowCount() : 1,
  20848. t.isArray() ? t.getRowCount() : 1,
  20849. r.isArray() ? r.getRowCount() : 1
  20850. ), o = Math.max(
  20851. n.isArray() ? n.getColumnCount() : 1,
  20852. t.isArray() ? t.getColumnCount() : 1,
  20853. r.isArray() ? r.getColumnCount() : 1
  20854. ), u = O(s, o, n), c = O(s, o, t, g2.create(m2.NA)), l2 = O(s, o, r, g2.create(m2.NA));
  20855. return u.map((f2, h, d2) => {
  20856. if (f2.isNull())
  20857. return g2.create(m2.NA);
  20858. {
  20859. const _ = c.get(h, d2) || ie.create(), C = l2.get(h, d2) || ie.create();
  20860. return this._calculateSingleCell(f2, _, C);
  20861. }
  20862. });
  20863. }
  20864. _getSingleValueObject(e) {
  20865. return e.isArray() && e.getRowCount() === 1 && e.getColumnCount() === 1 ? e.getFirstCell() : e;
  20866. }
  20867. _calculateSingleCell(e, t, r) {
  20868. return e.isNull() ? g2.create(m2.NA) : e.getValue() ? t.isNull() ? g2.create(m2.NA) : t : r.isNull() ? g2.create(m2.NA) : r;
  20869. }
  20870. };
  20871. var od = class extends V {
  20872. constructor() {
  20873. super(...arguments);
  20874. A(this, "minParams", 2);
  20875. A(this, "maxParams", 2);
  20876. }
  20877. calculate(e, t) {
  20878. if (!e.isArray())
  20879. return e.isError() ? t : e;
  20880. const r = Math.max(
  20881. e.isArray() ? e.getRowCount() : 1,
  20882. t.isArray() ? t.getRowCount() : 1
  20883. ), n = Math.max(
  20884. e.isArray() ? e.getColumnCount() : 1,
  20885. t.isArray() ? t.getColumnCount() : 1
  20886. ), s = O(r, n, e), o = O(r, n, t);
  20887. return s.iterator((u, c, l2) => {
  20888. u != null && u.isError() && s.set(c, l2, o.get(c, l2));
  20889. }), s;
  20890. }
  20891. };
  20892. var ud = class extends V {
  20893. constructor() {
  20894. super(...arguments);
  20895. A(this, "minParams", 2);
  20896. A(this, "maxParams", 2);
  20897. }
  20898. calculate(e, t) {
  20899. if (e.isError() && e.getErrorType() !== m2.NA)
  20900. return e;
  20901. if (t.isError())
  20902. return t;
  20903. if (!e.isArray())
  20904. return e.isError() && e.getErrorType() === m2.NA ? t : e;
  20905. const r = Math.max(
  20906. e.isArray() ? e.getRowCount() : 1,
  20907. t.isArray() ? t.getRowCount() : 1
  20908. ), n = Math.max(
  20909. e.isArray() ? e.getColumnCount() : 1,
  20910. t.isArray() ? t.getColumnCount() : 1
  20911. ), s = O(r, n, e), o = O(r, n, t);
  20912. return s.iterator((u, c, l2) => {
  20913. u != null && u.isError() && u.getErrorType() === m2.NA && s.set(c, l2, o.get(c, l2));
  20914. }), s;
  20915. }
  20916. };
  20917. var cd = class extends V {
  20918. constructor() {
  20919. super(...arguments);
  20920. A(this, "minParams", 2);
  20921. A(this, "maxParams", 255);
  20922. }
  20923. calculate(...e) {
  20924. if (e.length % 2 !== 0)
  20925. return g2.create(m2.NA);
  20926. for (let o = 0; o < e.length; o++)
  20927. if (e[o].isError())
  20928. return e[o];
  20929. const t = Math.max(
  20930. ...e.map((o) => o.isArray() ? o.getRowCount() : 1)
  20931. ), r = Math.max(
  20932. ...e.map((o) => o.isArray() ? o.getColumnCount() : 1)
  20933. ), n = e.map(
  20934. (o) => O(t, r, o, g2.create(m2.NA))
  20935. ), s = n[0].map((o, u, c) => {
  20936. for (let l2 = 0; l2 < n.length; l2 += 2) {
  20937. const f2 = n[l2].get(u, c) || ie.create(), h = n[l2 + 1].get(u, c) || ie.create();
  20938. if (f2.isNull())
  20939. continue;
  20940. if (f2.isError())
  20941. return f2;
  20942. const d2 = f2.getValue();
  20943. if (f2.isString()) {
  20944. if (`${d2}`.toLocaleUpperCase() === "TRUE")
  20945. return h;
  20946. if (`${d2}`.toLocaleUpperCase() === "FALSE")
  20947. continue;
  20948. return g2.create(m2.VALUE);
  20949. }
  20950. if (+d2)
  20951. return h.isNull() ? g2.create(m2.NA) : h;
  20952. }
  20953. return g2.create(m2.NA);
  20954. });
  20955. return t === 1 && r === 1 ? s.get(0, 0) : s;
  20956. }
  20957. };
  20958. var ld = class extends V {
  20959. constructor() {
  20960. super(...arguments);
  20961. A(this, "minParams", 1);
  20962. A(this, "maxParams", 255);
  20963. }
  20964. calculate(...e) {
  20965. return g2.create(m2.VALUE);
  20966. }
  20967. };
  20968. var fd = class extends V {
  20969. constructor() {
  20970. super(...arguments);
  20971. A(this, "minParams", 3);
  20972. A(this, "maxParams", 255);
  20973. }
  20974. calculate(...e) {
  20975. return g2.create(m2.VALUE);
  20976. }
  20977. };
  20978. var hd = class extends V {
  20979. constructor() {
  20980. super(...arguments);
  20981. A(this, "minParams", 3);
  20982. A(this, "maxParams", 3);
  20983. }
  20984. calculate(...e) {
  20985. const t = this.getIndexNumValue(e[0]);
  20986. if (typeof t != "number")
  20987. return t;
  20988. const r = this.getIndexNumValue(e[1]);
  20989. if (typeof r != "number")
  20990. return r;
  20991. if (!(e[2].isValueObject() && e[2].isLambda()))
  20992. return g2.create(m2.VALUE);
  20993. const n = e[2], s = [];
  20994. for (let o = 0; o < t; o++) {
  20995. s[o] == null && (s[o] = []);
  20996. for (let u = 0; u < r; u++) {
  20997. let c = n.execute(y2.create(o + 1), y2.create(u + 1));
  20998. c.isArray() && (c = c.get(0, 0)), s[o][u] = c;
  20999. }
  21000. }
  21001. return new Of(s);
  21002. }
  21003. isAsync() {
  21004. return true;
  21005. }
  21006. };
  21007. var md = class extends V {
  21008. constructor() {
  21009. super(...arguments);
  21010. A(this, "minParams", 2);
  21011. A(this, "maxParams", 255);
  21012. A(this, "needsReferenceObject", true);
  21013. }
  21014. calculate(...e) {
  21015. const t = [];
  21016. let r = null, n = 0, s = 0;
  21017. for (let u = 0; u < e.length; u++) {
  21018. const c = e[u];
  21019. let l2 = c;
  21020. if (l2.isReferenceObject() && (l2 = c.toArrayValueObject()), l2.isError())
  21021. return l2;
  21022. if (u === e.length - 1) {
  21023. if (!(c.isValueObject() && c.isLambda()))
  21024. return g2.create(m2.VALUE);
  21025. r = c;
  21026. } else
  21027. t.push(c), n = Math.max(n, l2.isArray() ? l2.getRowCount() : 1), s = Math.max(s, l2.isArray() ? l2.getColumnCount() : 1);
  21028. }
  21029. const o = this._getResultArray(t, r, n, s);
  21030. return o instanceof g2 ? o : n === 1 && s === 1 ? o[0][0] : q2.create({
  21031. calculateValueList: o,
  21032. rowCount: n,
  21033. columnCount: s,
  21034. unitId: this.unitId,
  21035. sheetId: this.subUnitId,
  21036. row: this.row,
  21037. column: this.column
  21038. });
  21039. }
  21040. // eslint-disable-next-line
  21041. _getResultArray(e, t, r, n) {
  21042. const s = [];
  21043. for (let o = 0; o < r; o++) {
  21044. const u = [];
  21045. for (let c = 0; c < n; c++) {
  21046. const l2 = [];
  21047. let f2 = false;
  21048. for (let d2 = 0; d2 < e.length; d2++) {
  21049. let _ = e[d2], C = null;
  21050. if (_.isReferenceObject() && (C = _, _ = _.toArrayValueObject()), !_.isArray())
  21051. if (o === 0 && c === 0) {
  21052. l2.push(C || _);
  21053. continue;
  21054. } else {
  21055. u.push(g2.create(m2.NA)), f2 = true;
  21056. break;
  21057. }
  21058. let E2 = _.get(o, c);
  21059. if (!E2) {
  21060. u.push(g2.create(m2.NA)), f2 = true;
  21061. break;
  21062. }
  21063. if (C) {
  21064. const { startRow: b, startColumn: R } = C.getRangePosition(), p2 = {
  21065. startRow: b + o,
  21066. startColumn: R + c,
  21067. endRow: b + o,
  21068. endColumn: R + c
  21069. };
  21070. E2 = this.createReferenceObject(C, p2);
  21071. }
  21072. l2.push(E2);
  21073. }
  21074. if (f2 || l2.length === 0)
  21075. continue;
  21076. let h = t.execute(...l2);
  21077. if (h.isArray()) {
  21078. const d2 = h.getRowCount(), _ = h.getColumnCount();
  21079. if (d2 > 1 || _ > 1)
  21080. return g2.create(m2.CALC);
  21081. h = h.get(0, 0);
  21082. }
  21083. h.isNull() && (h = y2.create(0)), u.push(h);
  21084. }
  21085. s.push(u);
  21086. }
  21087. return s;
  21088. }
  21089. };
  21090. var gd = class extends V {
  21091. constructor() {
  21092. super(...arguments);
  21093. A(this, "minParams", 1);
  21094. A(this, "maxParams", 1);
  21095. }
  21096. calculate(e) {
  21097. return e.isArray() ? e.map((t) => this._handleSingleObject(t)) : this._handleSingleObject(e);
  21098. }
  21099. _handleSingleObject(e) {
  21100. if (e.isError())
  21101. return e;
  21102. const t = +e.getValue();
  21103. return Number.isNaN(t) ? g2.create(m2.VALUE) : T2.create(!t);
  21104. }
  21105. };
  21106. var dd = class extends V {
  21107. constructor() {
  21108. super(...arguments);
  21109. A(this, "minParams", 1);
  21110. A(this, "maxParams", 255);
  21111. }
  21112. calculate(...e) {
  21113. let t = false, r = true, n = null;
  21114. for (const s of e) {
  21115. if (s.isError())
  21116. return s;
  21117. if (s.isArray()) {
  21118. if (s.iterator((o) => {
  21119. if (o != null && o.isError())
  21120. return n = o, false;
  21121. (o != null && o.isBoolean() || o != null && o.isNumber()) && (t = t || !!o.getValue(), r = false);
  21122. }), n)
  21123. return n;
  21124. } else
  21125. (s.isBoolean() || s.isNumber()) && (t = t || !!s.getValue(), r = false);
  21126. }
  21127. return r ? new g2(m2.VALUE) : new T2(t);
  21128. }
  21129. };
  21130. var Cd = class extends V {
  21131. constructor() {
  21132. super(...arguments);
  21133. A(this, "minParams", 3);
  21134. A(this, "maxParams", 3);
  21135. A(this, "needsReferenceObject", true);
  21136. }
  21137. calculate(e, t, r) {
  21138. let n, s;
  21139. e.isReferenceObject() ? (n = e.toArrayValueObject(), s = e) : (n = e, s = null);
  21140. let o, u;
  21141. return t.isReferenceObject() ? (o = t.toArrayValueObject(), u = t) : (o = t, u = null), n.isArray() ? n.mapValue((c) => this._handleSingleValueObject(c, o, r, s, u)) : this._handleSingleValueObject(n, o, r, s, u);
  21142. }
  21143. _handleSingleValueObject(e, t, r, n, s) {
  21144. if (e.isError())
  21145. return e;
  21146. if (t.isError())
  21147. return t;
  21148. if (r.isError())
  21149. return r;
  21150. if (!(r.isValueObject() && r.isLambda() && r.getLambdaPrivacyVarKeys().length === 2))
  21151. return g2.create(m2.VALUE);
  21152. const o = r, u = t.isArray() ? t.getRowCount() : 1, c = t.isArray() ? t.getColumnCount() : 1;
  21153. let l2 = e;
  21154. n && (l2 = n);
  21155. for (let f2 = 0; f2 < u; f2++)
  21156. for (let h = 0; h < c; h++) {
  21157. let d2 = t.isArray() ? t.get(f2, h) : t;
  21158. if (d2.isError())
  21159. return d2;
  21160. if (s) {
  21161. const { startRow: C, startColumn: E2 } = s.getRangePosition(), b = {
  21162. startRow: C + f2,
  21163. startColumn: E2 + h,
  21164. endRow: C + f2,
  21165. endColumn: E2 + h
  21166. };
  21167. d2 = this.createReferenceObject(s, b);
  21168. }
  21169. let _ = o.execute(l2, d2);
  21170. if (_.isError())
  21171. return _;
  21172. _.isNull() && (_ = y2.create(0)), l2 = _;
  21173. }
  21174. return l2.isReferenceObject() ? l2.toArrayValueObject() : l2;
  21175. }
  21176. };
  21177. var _d = class extends V {
  21178. constructor() {
  21179. super(...arguments);
  21180. A(this, "minParams", 3);
  21181. A(this, "maxParams", 3);
  21182. A(this, "needsReferenceObject", true);
  21183. }
  21184. calculate(e, t, r) {
  21185. let n = e, s = null;
  21186. e.isReferenceObject() && (n = e.toArrayValueObject(), s = e), n = n;
  21187. let o = t, u = null;
  21188. if (t.isReferenceObject() && (o = t.toArrayValueObject(), u = t), o = o, n.isError())
  21189. return n;
  21190. if (o.isError())
  21191. return o;
  21192. if (r.isError())
  21193. return r;
  21194. if (!(r.isValueObject() && r.isLambda() && r.getLambdaPrivacyVarKeys().length === 2))
  21195. return g2.create(m2.VALUE);
  21196. if (n.isArray()) {
  21197. const c = n.getRowCount(), l2 = n.getColumnCount();
  21198. if (c > 1 || l2 > 1)
  21199. return g2.create(m2.CALC);
  21200. n = n.get(0, 0);
  21201. }
  21202. return this._getResult(n, o, r, s, u);
  21203. }
  21204. // eslint-disable-next-line
  21205. _getResult(e, t, r, n, s) {
  21206. const o = [], u = t.isArray() ? t.getRowCount() : 1, c = t.isArray() ? t.getColumnCount() : 1;
  21207. let l2 = e;
  21208. n && (l2 = n);
  21209. for (let f2 = 0; f2 < u; f2++) {
  21210. const h = [];
  21211. for (let d2 = 0; d2 < c; d2++) {
  21212. if (l2.isError()) {
  21213. h.push(l2);
  21214. continue;
  21215. }
  21216. let _ = t.isArray() ? t.get(f2, d2) : t;
  21217. if (_.isError()) {
  21218. l2 = _, h.push(_);
  21219. continue;
  21220. }
  21221. if (s) {
  21222. const { startRow: E2, startColumn: b } = s.getRangePosition(), R = {
  21223. startRow: E2 + f2,
  21224. startColumn: b + d2,
  21225. endRow: E2 + f2,
  21226. endColumn: b + d2
  21227. };
  21228. _ = this.createReferenceObject(s, R);
  21229. }
  21230. let C = r.execute(l2, _);
  21231. if (C.isArray()) {
  21232. const E2 = C.getRowCount(), b = C.getColumnCount();
  21233. if (E2 > 1 || b > 1)
  21234. return g2.create(m2.CALC);
  21235. C = C.get(0, 0);
  21236. }
  21237. C.isNull() && (C = y2.create(0)), l2 = C, h.push(C);
  21238. }
  21239. o.push(h);
  21240. }
  21241. return u === 1 && c === 1 ? o[0][0] : q2.create({
  21242. calculateValueList: o,
  21243. rowCount: u,
  21244. columnCount: c,
  21245. unitId: this.unitId,
  21246. sheetId: this.subUnitId,
  21247. row: this.row,
  21248. column: this.column
  21249. });
  21250. }
  21251. };
  21252. var Ad = class extends V {
  21253. constructor() {
  21254. super(...arguments);
  21255. A(this, "minParams", 3);
  21256. }
  21257. calculate(e, ...t) {
  21258. if (e.isError())
  21259. return e;
  21260. const r = t.length % 2 !== 0, n = r ? t[t.length - 1] : ie.create();
  21261. return !e.isArray() && !t.some((s) => s.isArray()) ? this._handleNonArrayInputs(e, t, n, r) : this._handleArrayInputs(e, t, n, r);
  21262. }
  21263. _handleNonArrayInputs(e, t, r, n) {
  21264. for (let s = 0; s < t.length - (n ? 1 : 0); s += 2) {
  21265. const o = t[s], u = t[s + 1];
  21266. if (!o.isNull()) {
  21267. if (o.isError())
  21268. return o;
  21269. if (`${e.getValue()}`.toLocaleLowerCase() === `${o.getValue()}`.toLocaleLowerCase())
  21270. return u.isNull() ? g2.create(m2.NA) : u;
  21271. }
  21272. }
  21273. return r.isNull() ? g2.create(m2.NA) : r;
  21274. }
  21275. _handleArrayInputs(e, t, r, n) {
  21276. const s = Math.max(
  21277. e.isArray() ? e.getRowCount() : 1,
  21278. ...t.map((f2) => f2.isArray() ? f2.getRowCount() : 1),
  21279. r.isArray() ? r.getRowCount() : 1
  21280. ), o = Math.max(
  21281. e.isArray() ? e.getColumnCount() : 1,
  21282. ...t.map((f2) => f2.isArray() ? f2.getColumnCount() : 1),
  21283. r.isArray() ? r.getColumnCount() : 1
  21284. ), u = O(s, o, e), c = t.map(
  21285. (f2) => O(s, o, f2, g2.create(m2.NA))
  21286. ), l2 = O(s, o, r, g2.create(m2.NA));
  21287. return u.map((f2, h, d2) => {
  21288. for (let C = 0; C < c.length - (n ? 1 : 0); C += 2) {
  21289. const E2 = c[C].get(h, d2) || ie.create(), b = c[C + 1].get(h, d2) || ie.create();
  21290. if (!E2.isNull()) {
  21291. if (E2.isError() || f2.isError())
  21292. return E2.isError() ? E2 : f2;
  21293. if (`${f2.getValue()}`.toLocaleLowerCase() === `${E2.getValue()}`.toLocaleLowerCase())
  21294. return b.isNull() ? g2.create(m2.NA) : b;
  21295. }
  21296. }
  21297. const _ = l2.get(h, d2) || ie.create();
  21298. return _.isNull() ? g2.create(m2.NA) : _;
  21299. });
  21300. }
  21301. };
  21302. var Ed = class extends V {
  21303. constructor() {
  21304. super(...arguments);
  21305. A(this, "minParams", 0);
  21306. A(this, "maxParams", 0);
  21307. }
  21308. calculate() {
  21309. return T2.create(true);
  21310. }
  21311. };
  21312. var bd = class extends V {
  21313. constructor() {
  21314. super(...arguments);
  21315. A(this, "minParams", 1);
  21316. A(this, "maxParams", 255);
  21317. }
  21318. calculate(...e) {
  21319. let t = 0, r = true, n = null;
  21320. for (const s of e) {
  21321. if (s.isError())
  21322. return s;
  21323. if (s.isArray()) {
  21324. if (s.iterator((o) => {
  21325. if (o != null && o.isError())
  21326. return n = o, false;
  21327. (o != null && o.isBoolean() || o != null && o.isNumber()) && (o.getValue() && t++, r = false);
  21328. }), n)
  21329. return n;
  21330. } else
  21331. (s.isBoolean() || s.isNumber()) && (s.getValue() && t++, r = false);
  21332. }
  21333. return r ? g2.create(m2.VALUE) : T2.create(t % 2 === 1);
  21334. }
  21335. };
  21336. var yd = [
  21337. [rd, Se2.AND],
  21338. [nd, Se2.BYCOL],
  21339. [sd, Se2.BYROW],
  21340. [ad, Se2.FALSE],
  21341. [id, Se2.IF],
  21342. [od, Se2.IFERROR],
  21343. [ud, Se2.IFNA],
  21344. [cd, Se2.IFS],
  21345. [ld, Se2.LAMBDA],
  21346. [fd, Se2.LET],
  21347. [hd, Se2.MAKEARRAY],
  21348. [md, Se2.MAP],
  21349. [gd, Se2.NOT],
  21350. [dd, Se2.OR],
  21351. [Cd, Se2.REDUCE],
  21352. [_d, Se2.SCAN],
  21353. [Ad, Se2.SWITCH],
  21354. [Ed, Se2.TRUE],
  21355. [bd, Se2.XOR]
  21356. ];
  21357. var Rd = class extends V {
  21358. constructor() {
  21359. super(...arguments);
  21360. A(this, "minParams", 2);
  21361. A(this, "maxParams", 5);
  21362. }
  21363. // eslint-disable-next-line max-lines-per-function
  21364. calculate(e, t, r, n, s) {
  21365. if (e.isError())
  21366. return e;
  21367. if (t.isError())
  21368. return t;
  21369. if (r != null && r.isError())
  21370. return r;
  21371. if (n != null && n.isError())
  21372. return n;
  21373. if (s != null && s.isError())
  21374. return s;
  21375. const o = r != null ? r : y2.create(1), u = n != null ? n : T2.create(true), c = s != null ? s : j.create(""), l2 = Math.max(
  21376. e.isArray() ? e.getRowCount() : 1,
  21377. t.isArray() ? t.getRowCount() : 1,
  21378. o.isArray() ? o.getRowCount() : 1,
  21379. u.isArray() ? u.getRowCount() : 1,
  21380. c.isArray() ? c.getRowCount() : 1
  21381. ), f2 = Math.max(
  21382. e.isArray() ? e.getColumnCount() : 1,
  21383. t.isArray() ? t.getColumnCount() : 1,
  21384. o.isArray() ? o.getColumnCount() : 1,
  21385. u.isArray() ? u.getColumnCount() : 1,
  21386. c.isArray() ? c.getColumnCount() : 1
  21387. ), h = O(l2, f2, e, g2.create(m2.NA)), d2 = O(l2, f2, t, g2.create(m2.NA)), _ = O(l2, f2, o, g2.create(m2.NA)), C = O(l2, f2, u, g2.create(m2.NA)), E2 = O(l2, f2, c, g2.create(m2.NA));
  21388. return h.map((b, R, p2) => {
  21389. const N2 = d2.get(R, p2) || g2.create(m2.NA), M2 = _.get(R, p2) || g2.create(m2.NA), w = C.get(R, p2) || g2.create(m2.NA), D2 = E2.get(R, p2) || g2.create(m2.NA);
  21390. return b.isError() ? b : N2.isError() ? N2 : M2.isError() ? M2 : w.isError() ? w : D2.isError() ? D2 : this._calculateSingleCell(b, N2, M2, w, D2);
  21391. });
  21392. }
  21393. _calculateSingleCell(e, t, r, n, s) {
  21394. const o = Number.parseInt(`${Number(e.getValue()) - 1}`), u = Number.parseInt(`${Number(t.getValue()) - 1}`), c = Number.parseInt(`${Number(r.getValue())}`);
  21395. if (Number.isNaN(o) || Number.isNaN(u) || Number.isNaN(c) || c < 1 || c > 4)
  21396. return g2.create(m2.VALUE);
  21397. const l2 = pd(c), f2 = this.getZeroOrOneByOneDefault(n), h = `${s.getValue()}`, d2 = Ki(h), _ = {
  21398. startRow: o,
  21399. startColumn: u,
  21400. endRow: o,
  21401. endColumn: u,
  21402. startAbsoluteRefType: l2,
  21403. endAbsoluteRefType: l2
  21404. }, C = n && !f2 ? Fh(_) : fr(_);
  21405. return j.create(d2 !== "" ? `${d2}!${C}` : C);
  21406. }
  21407. };
  21408. function pd(i) {
  21409. switch (i) {
  21410. case 1:
  21411. return tt.ALL;
  21412. case 2:
  21413. return tt.ROW;
  21414. case 3:
  21415. return tt.COLUMN;
  21416. case 4:
  21417. return tt.NONE;
  21418. default:
  21419. return tt.ALL;
  21420. }
  21421. }
  21422. var Vd = class extends V {
  21423. constructor() {
  21424. super(...arguments);
  21425. A(this, "minParams", 1);
  21426. A(this, "maxParams", 1);
  21427. A(this, "needsReferenceObject", true);
  21428. }
  21429. calculate(e) {
  21430. return e.isReferenceObject() ? y2.create(1) : g2.create(m2.VALUE);
  21431. }
  21432. };
  21433. var Nd = class extends V {
  21434. constructor() {
  21435. super(...arguments);
  21436. A(this, "minParams", 2);
  21437. A(this, "maxParams", 255);
  21438. A(this, "needsReferenceObject", true);
  21439. }
  21440. calculate(e, ...t) {
  21441. let r = e;
  21442. if (r.isError())
  21443. return r;
  21444. if (r.isReferenceObject() && (r = r.toArrayValueObject()), !r.isArray()) {
  21445. const c = r.convertToNumberObjectValue();
  21446. return c.isError() ? c : t[Math.trunc(+c.getValue()) - 1] || g2.create(m2.VALUE);
  21447. }
  21448. let n = r.isArray() ? r.getRowCount() : 1, s = r.isArray() ? r.getColumnCount() : 1;
  21449. t.forEach((c, l2) => {
  21450. if (c.isArray()) {
  21451. const f2 = c;
  21452. n = Math.max(n, f2.getRowCount()), s = Math.max(s, f2.getColumnCount());
  21453. } else
  21454. n = Math.max(n, 1), s = Math.max(s, 1);
  21455. });
  21456. const o = O(n, s, r, g2.create(m2.NA)), u = t.map((c) => {
  21457. let l2 = c;
  21458. return l2.isReferenceObject() && (l2 = l2.toArrayValueObject()), O(n, s, l2, g2.create(m2.NA));
  21459. });
  21460. return o.map((c, l2, f2) => {
  21461. if (c.isError())
  21462. return c;
  21463. const h = c.convertToNumberObjectValue();
  21464. if (h.isError())
  21465. return h;
  21466. const d2 = u[Math.trunc(+h.getValue()) - 1];
  21467. let _ = (d2 == null ? void 0 : d2.get(l2, f2)) || g2.create(m2.VALUE);
  21468. return _ != null && _.isNull() && (_ = y2.create(0)), _;
  21469. });
  21470. }
  21471. };
  21472. var Od = class extends V {
  21473. constructor() {
  21474. super(...arguments);
  21475. A(this, "minParams", 2);
  21476. A(this, "maxParams", 255);
  21477. }
  21478. calculate(e, ...t) {
  21479. if (e.isError())
  21480. return e;
  21481. const r = e.isArray() ? e.getRowCount() : 1, n = e.isArray() ? e.getColumnCount() : 1, s = [];
  21482. for (let o = 0; o < t.length; o++) {
  21483. let u = t[o];
  21484. if (u.isArray()) {
  21485. const f2 = u.getRowCount(), h = u.getColumnCount();
  21486. if (f2 > 1 || h > 1)
  21487. return g2.create(m2.VALUE);
  21488. u = u.get(0, 0);
  21489. }
  21490. if (u.isString() && (u = u.convertToNumberObjectValue()), u.isError())
  21491. return u;
  21492. const c = Math.trunc(+u.getValue());
  21493. if (c === 0 || Math.abs(c) > n)
  21494. return g2.create(m2.VALUE);
  21495. let l2 = e;
  21496. n > 1 && (c < 0 ? l2 = e.slice(void 0, [c + n, c + 1 + n]) : l2 = e.slice(void 0, [c - 1, c]));
  21497. for (let f2 = 0; f2 < r; f2++)
  21498. s[f2] || (s[f2] = []), e.isArray() ? s[f2].push(l2.get(f2, 0)) : s[f2].push(e);
  21499. }
  21500. return q2.create({
  21501. calculateValueList: s,
  21502. rowCount: s.length,
  21503. columnCount: s[0].length || 0,
  21504. unitId: this.unitId,
  21505. sheetId: this.subUnitId,
  21506. row: this.row,
  21507. column: this.column
  21508. });
  21509. }
  21510. };
  21511. var Md = class extends V {
  21512. constructor() {
  21513. super(...arguments);
  21514. A(this, "minParams", 2);
  21515. A(this, "maxParams", 255);
  21516. }
  21517. calculate(e, ...t) {
  21518. if (e.isError())
  21519. return e;
  21520. const r = e.isArray() ? e.getRowCount() : 1, n = [];
  21521. for (let s = 0; s < t.length; s++) {
  21522. let o = t[s];
  21523. if (o.isArray()) {
  21524. const l2 = o.getRowCount(), f2 = o.getColumnCount();
  21525. if (l2 > 1 || f2 > 1)
  21526. return g2.create(m2.VALUE);
  21527. o = o.get(0, 0);
  21528. }
  21529. if (o.isString() && (o = o.convertToNumberObjectValue()), o.isError())
  21530. return o;
  21531. const u = Math.trunc(+o.getValue());
  21532. if (u === 0 || Math.abs(u) > r)
  21533. return g2.create(m2.VALUE);
  21534. let c = e;
  21535. r > 1 && (u < 0 ? c = e.slice([u + r, u + 1 + r]) : c = e.slice([u - 1, u])), e.isArray() ? n.push(c.getArrayValue()[0]) : n.push([e]);
  21536. }
  21537. return q2.create({
  21538. calculateValueList: n,
  21539. rowCount: n.length,
  21540. columnCount: n[0].length || 0,
  21541. unitId: this.unitId,
  21542. sheetId: this.subUnitId,
  21543. row: this.row,
  21544. column: this.column
  21545. });
  21546. }
  21547. };
  21548. var wd = class extends V {
  21549. constructor() {
  21550. super(...arguments);
  21551. A(this, "minParams", 0);
  21552. A(this, "maxParams", 1);
  21553. }
  21554. calculate(e) {
  21555. if (e == null)
  21556. return y2.create(this.column + 1);
  21557. if (e.isError())
  21558. return e;
  21559. if (!e.isArray())
  21560. return g2.create(m2.NA);
  21561. const t = e.getCurrentColumn(), r = e.getColumnCount(), n = [];
  21562. for (let o = 0; o < r; o++)
  21563. n.push(y2.create(t + o + 1));
  21564. const s = {
  21565. calculateValueList: [n],
  21566. rowCount: 1,
  21567. columnCount: r,
  21568. unitId: this.unitId || "",
  21569. sheetId: this.subUnitId || "",
  21570. row: this.row,
  21571. column: this.column
  21572. };
  21573. return q2.create(s);
  21574. }
  21575. };
  21576. var Dd = class extends V {
  21577. constructor() {
  21578. super(...arguments);
  21579. A(this, "minParams", 1);
  21580. A(this, "maxParams", 1);
  21581. }
  21582. calculate(e) {
  21583. if (e.isError())
  21584. return e;
  21585. if (e.isString() || e.isNumber() || e.isBoolean())
  21586. return y2.create(1);
  21587. if (!e.isArray())
  21588. return g2.create(m2.NA);
  21589. const t = e.getColumnCount();
  21590. return y2.create(t);
  21591. }
  21592. };
  21593. var Sd = class extends V {
  21594. constructor() {
  21595. super(...arguments);
  21596. A(this, "minParams", 2);
  21597. A(this, "maxParams", 3);
  21598. }
  21599. calculate(e, t, r) {
  21600. const n = r != null ? r : y2.create(0), s = e.isArray() ? e.getRowCount() : 1, o = e.isArray() ? e.getColumnCount() : 1, u = Math.max(
  21601. t.isArray() ? t.getRowCount() : 1,
  21602. n.isArray() ? n.getRowCount() : 1
  21603. ), c = Math.max(
  21604. t.isArray() ? t.getColumnCount() : 1,
  21605. n.isArray() ? n.getColumnCount() : 1
  21606. ), l2 = O(u, c, t, g2.create(m2.NA)), f2 = O(u, c, n, g2.create(m2.NA));
  21607. if (u > 1 || c > 1)
  21608. return l2.mapValue((R, p2, N2) => {
  21609. const M2 = f2.get(p2, N2);
  21610. if (e.isError())
  21611. return e;
  21612. if (e.isNull())
  21613. return g2.create(m2.VALUE);
  21614. const { isError: w, errorObject: D2 } = this._checkRowsColumns(R, M2, s, o);
  21615. return w ? D2 : e.isArray() ? g2.create(m2.VALUE) : e;
  21616. });
  21617. if (e.isError())
  21618. return e;
  21619. if (e.isNull())
  21620. return g2.create(m2.VALUE);
  21621. const h = t.isArray() ? t.get(0, 0) : t, d2 = n.isArray() ? n.get(0, 0) : n, { isError: _, errorObject: C, rowsValue: E2, columnsValue: b } = this._checkRowsColumns(h, d2, s, o);
  21622. return _ ? C : this._getResultArray(e, E2, b, s, o);
  21623. }
  21624. _checkRowsColumns(e, t, r, n) {
  21625. if (e.isError())
  21626. return {
  21627. isError: true,
  21628. errorObject: e
  21629. };
  21630. if (t.isError())
  21631. return {
  21632. isError: true,
  21633. errorObject: t
  21634. };
  21635. const s = Math.trunc(+e.getValue()), o = Math.trunc(+t.getValue());
  21636. return Number.isNaN(s) || Number.isNaN(o) ? {
  21637. isError: true,
  21638. errorObject: g2.create(m2.VALUE)
  21639. } : Math.abs(s) >= r || Math.abs(o) >= n ? {
  21640. isError: true,
  21641. errorObject: g2.create(m2.CALC)
  21642. } : {
  21643. isError: false,
  21644. rowsValue: s,
  21645. columnsValue: o
  21646. };
  21647. }
  21648. _getResultArray(e, t, r, n, s) {
  21649. const o = t >= 0 ? [t, n] : [0, n + t], u = r >= 0 ? [r, s] : [0, s + r];
  21650. let c;
  21651. return t === 0 && r === 0 ? c = e : t === 0 ? c = e.slice(void 0, u) : r === 0 ? c = e.slice(o, void 0) : c = e.slice(o, u), c = c.map((l2) => l2.isNull() ? y2.create(0) : l2), n - t === 1 && s - r === 1 ? c.get(0, 0) : c;
  21652. }
  21653. };
  21654. var Pd = class extends V {
  21655. constructor() {
  21656. super(...arguments);
  21657. A(this, "minParams", 2);
  21658. A(this, "maxParams", 4);
  21659. }
  21660. calculate(e, t, r, n) {
  21661. const s = e.isArray() ? e.getRowCount() : 1, o = e.isArray() ? e.getColumnCount() : 1;
  21662. let u = t, c = r != null ? r : y2.create(o);
  21663. const l2 = n != null ? n : g2.create(m2.NA);
  21664. t.isNull() && (u = y2.create(s)), c.isNull() && (c = y2.create(o));
  21665. const f2 = Math.max(
  21666. u.isArray() ? u.getRowCount() : 1,
  21667. c.isArray() ? c.getRowCount() : 1
  21668. ), h = Math.max(
  21669. u.isArray() ? u.getColumnCount() : 1,
  21670. c.isArray() ? c.getColumnCount() : 1
  21671. ), d2 = O(f2, h, u, g2.create(m2.NA)), _ = O(f2, h, c, g2.create(m2.NA));
  21672. if (f2 > 1 || h > 1)
  21673. return d2.mapValue((w, D2, S2) => {
  21674. const P = _.get(D2, S2);
  21675. if (e.isError())
  21676. return e;
  21677. if (e.isNull())
  21678. return g2.create(m2.VALUE);
  21679. const { isError: U2, errorObject: x2 } = this._checkRowsColumnsPadWith(w, P, l2, s, o);
  21680. return U2 ? x2 : e.isArray() ? e.get(0, 0) : e;
  21681. });
  21682. if (e.isError())
  21683. return e;
  21684. if (e.isNull())
  21685. return g2.create(m2.VALUE);
  21686. const C = u.isArray() ? u.get(0, 0) : u, E2 = c.isArray() ? c.get(0, 0) : c, { isError: b, errorObject: R, rowsValue: p2, columnsValue: N2, padWithObject: M2 } = this._checkRowsColumnsPadWith(C, E2, l2, s, o);
  21687. return b ? R : this._getResultArray(e, p2, N2, M2, s, o);
  21688. }
  21689. _checkRowsColumnsPadWith(e, t, r, n, s) {
  21690. if (e.isError())
  21691. return {
  21692. isError: true,
  21693. errorObject: e
  21694. };
  21695. if (t.isError())
  21696. return {
  21697. isError: true,
  21698. errorObject: t
  21699. };
  21700. const o = Math.trunc(+e.getValue()), u = Math.trunc(+t.getValue());
  21701. if (Number.isNaN(o) || Number.isNaN(u))
  21702. return {
  21703. isError: true,
  21704. errorObject: g2.create(m2.VALUE)
  21705. };
  21706. if (Math.abs(o) < n || Math.abs(u) < s)
  21707. return {
  21708. isError: true,
  21709. errorObject: g2.create(m2.VALUE)
  21710. };
  21711. let c = r;
  21712. if (r.isArray()) {
  21713. const l2 = r.getRowCount(), f2 = r.getColumnCount();
  21714. if (l2 > 1 || f2 > 1)
  21715. return {
  21716. isError: true,
  21717. errorObject: g2.create(m2.VALUE)
  21718. };
  21719. c = r.get(0, 0);
  21720. }
  21721. return {
  21722. isError: false,
  21723. rowsValue: o,
  21724. columnsValue: u,
  21725. padWithObject: c
  21726. };
  21727. }
  21728. _getResultArray(e, t, r, n, s, o) {
  21729. let u = [];
  21730. e.isArray() ? u = e.map((f2) => f2.isNull() ? y2.create(0) : f2).getArrayValue() : u = [[e]];
  21731. const c = Math.max(0, t - s), l2 = Math.max(0, r - o);
  21732. for (let f2 = 0; f2 < c; f2++)
  21733. u.push(new Array(o).fill(n));
  21734. for (let f2 = 0; f2 < l2; f2++)
  21735. u.forEach((h) => {
  21736. h.push(n);
  21737. });
  21738. return t === 1 && r === 1 ? u[0][0] : q2.create({
  21739. calculateValueList: u,
  21740. rowCount: u.length,
  21741. columnCount: u[0].length,
  21742. unitId: this.unitId,
  21743. sheetId: this.subUnitId,
  21744. row: this.row,
  21745. column: this.column
  21746. });
  21747. }
  21748. };
  21749. var Ld = class extends V {
  21750. constructor() {
  21751. super(...arguments);
  21752. A(this, "minParams", 2);
  21753. A(this, "maxParams", 3);
  21754. }
  21755. calculate(e, t, r) {
  21756. const n = r != null ? r : g2.create(m2.CALC);
  21757. if (e.isError())
  21758. return e;
  21759. if (t.isError())
  21760. return t;
  21761. const s = e.isArray() ? e.getRowCount() : 1, o = e.isArray() ? e.getColumnCount() : 1, u = t.isArray() ? t.getRowCount() : 1, c = t.isArray() ? t.getColumnCount() : 1;
  21762. return u > 1 && c > 1 || u === 1 && c !== o || c === 1 && u !== s ? g2.create(m2.VALUE) : s === 1 && o === 1 ? this._getResultArrayByR1C1(e, t, n) : u === 1 ? c !== o ? g2.create(m2.VALUE) : this._getResultArrayByR1(s, o, e, t, n) : c === 1 ? u !== s ? g2.create(m2.VALUE) : this._getResultArrayByC1(s, o, e, t, n) : n;
  21763. }
  21764. _getResultArrayByR1C1(e, t, r) {
  21765. let n = e, s = t;
  21766. return n.isArray() && (n = n.get(0, 0)), s.isArray() && (s = s.get(0, 0)), s.isString() && (s = s.convertToNumberObjectValue()), s.isError() ? s : +s.getValue() ? n : r;
  21767. }
  21768. _getResultArrayByR1(e, t, r, n, s) {
  21769. const o = [];
  21770. for (let u = 0; u < t; u++) {
  21771. let c = n.get(0, u);
  21772. if (c.isString() && (c = c.convertToNumberObjectValue()), c.isError())
  21773. return c;
  21774. if (+c.getValue())
  21775. for (let f2 = 0; f2 < e; f2++) {
  21776. o[f2] || (o[f2] = []);
  21777. const h = r.get(f2, u);
  21778. o[f2].push(h);
  21779. }
  21780. }
  21781. return o.length === 0 ? s : q2.create({
  21782. calculateValueList: o,
  21783. rowCount: o.length,
  21784. columnCount: o[0].length || 0,
  21785. unitId: this.unitId,
  21786. sheetId: this.subUnitId,
  21787. row: this.row,
  21788. column: this.column
  21789. });
  21790. }
  21791. _getResultArrayByC1(e, t, r, n, s) {
  21792. const o = [];
  21793. for (let u = 0; u < e; u++) {
  21794. let c = n.get(u, 0);
  21795. if (c.isString() && (c = c.convertToNumberObjectValue()), c.isError())
  21796. return c;
  21797. if (!+c.getValue())
  21798. continue;
  21799. const f2 = [];
  21800. for (let h = 0; h < t; h++) {
  21801. const d2 = r.get(u, h);
  21802. f2.push(d2);
  21803. }
  21804. o.push(f2);
  21805. }
  21806. return o.length === 0 ? s : q2.create({
  21807. calculateValueList: o,
  21808. rowCount: o.length,
  21809. columnCount: o[0].length || 0,
  21810. unitId: this.unitId,
  21811. sheetId: this.subUnitId,
  21812. row: this.row,
  21813. column: this.column
  21814. });
  21815. }
  21816. };
  21817. var xd = class extends V {
  21818. constructor() {
  21819. super(...arguments);
  21820. A(this, "minParams", 1);
  21821. A(this, "maxParams", 1);
  21822. A(this, "needsReferenceObject", true);
  21823. A(this, "needsFormulaDataModel", true);
  21824. }
  21825. calculate(e) {
  21826. var f2, h;
  21827. if (!e.isReferenceObject())
  21828. return g2.create(m2.NA);
  21829. const t = e.getUnitId(), r = e.getSheetId(), s = (h = (f2 = e.getUnitData()[t]) == null ? void 0 : f2[r]) == null ? void 0 : h.cellData, { startRow: o, startColumn: u } = e.getRangePosition(), l2 = e.toArrayValueObject().mapValue((d2, _, C) => {
  21830. const E2 = s.getValue(o + _, u + C);
  21831. if (E2 != null && E2.f || E2 != null && E2.si) {
  21832. const b = this._formulaDataModel.getFormulaStringByCell(o + _, u + C, r, t);
  21833. return j.create(b);
  21834. }
  21835. return g2.create(m2.NA);
  21836. });
  21837. return l2.getRowCount() === 1 && l2.getColumnCount() === 1 ? l2.get(0, 0) : l2;
  21838. }
  21839. };
  21840. var me2 = ((i) => (i.ADDRESS = "ADDRESS", i.AREAS = "AREAS", i.CHOOSE = "CHOOSE", i.CHOOSECOLS = "CHOOSECOLS", i.CHOOSEROWS = "CHOOSEROWS", i.COLUMN = "COLUMN", i.COLUMNS = "COLUMNS", i.DROP = "DROP", i.EXPAND = "EXPAND", i.FILTER = "FILTER", i.FORMULATEXT = "FORMULATEXT", i.GETPIVOTDATA = "GETPIVOTDATA", i.HLOOKUP = "HLOOKUP", i.HSTACK = "HSTACK", i.HYPERLINK = "HYPERLINK", i.IMAGE = "IMAGE", i.INDEX = "INDEX", i.INDIRECT = "INDIRECT", i.LOOKUP = "LOOKUP", i.MATCH = "MATCH", i.OFFSET = "OFFSET", i.ROW = "ROW", i.ROWS = "ROWS", i.RTD = "RTD", i.SORT = "SORT", i.SORTBY = "SORTBY", i.TAKE = "TAKE", i.TOCOL = "TOCOL", i.TOROW = "TOROW", i.TRANSPOSE = "TRANSPOSE", i.UNIQUE = "UNIQUE", i.VLOOKUP = "VLOOKUP", i.VSTACK = "VSTACK", i.WRAPCOLS = "WRAPCOLS", i.WRAPROWS = "WRAPROWS", i.XLOOKUP = "XLOOKUP", i.XMATCH = "XMATCH", i))(me2 || {});
  21841. var jd = class extends V {
  21842. constructor() {
  21843. super(...arguments);
  21844. A(this, "minParams", 3);
  21845. A(this, "maxParams", 4);
  21846. }
  21847. calculate(e, t, r, n) {
  21848. if (e.isError())
  21849. return e;
  21850. if (t.isError())
  21851. return g2.create(m2.REF);
  21852. if (!t.isArray() || r.isError() || n != null && n.isError())
  21853. return g2.create(m2.NA);
  21854. const s = this.getZeroOrOneByOneDefault(n);
  21855. if (s == null)
  21856. return g2.create(m2.VALUE);
  21857. const o = this.getIndexNumValue(r);
  21858. if (o instanceof g2)
  21859. return o;
  21860. const u = t.slice([0, 1]), c = t.slice([o - 1, o]);
  21861. return u == null || c == null ? g2.create(m2.REF) : e.isArray() ? e.map((l2) => this._handleSingleObject(l2, u, c, s)) : this._handleSingleObject(e, u, c, s);
  21862. }
  21863. _handleSingleObject(e, t, r, n) {
  21864. return n === 0 ? this.equalSearch(e, t, r) : this.binarySearch(e, t, r);
  21865. }
  21866. };
  21867. var Ud = class extends V {
  21868. constructor() {
  21869. super(...arguments);
  21870. A(this, "minParams", 1);
  21871. A(this, "maxParams", 255);
  21872. }
  21873. calculate(...e) {
  21874. const t = Math.max(
  21875. ...e.map((n) => n.isArray() ? n.getRowCount() : 1)
  21876. ), r = [];
  21877. for (let n = 0; n < e.length; n++) {
  21878. const s = e[n];
  21879. if (s.isError())
  21880. return s;
  21881. const o = s.isArray() ? s.getRowCount() : 1, u = s.isArray() ? s.getColumnCount() : 1;
  21882. for (let c = 0; c < t; c++) {
  21883. r[c] || (r[c] = []);
  21884. for (let l2 = 0; l2 < u; l2++) {
  21885. let f2 = s;
  21886. s.isArray() && (f2 = s.get(c, l2)), c > o - 1 || !f2 ? r[c].push(g2.create(m2.NA)) : r[c].push(f2);
  21887. }
  21888. }
  21889. }
  21890. return q2.create({
  21891. calculateValueList: r,
  21892. rowCount: r.length,
  21893. columnCount: r[0].length || 0,
  21894. unitId: this.unitId,
  21895. sheetId: this.subUnitId,
  21896. row: this.row,
  21897. column: this.column
  21898. });
  21899. }
  21900. };
  21901. var vd = class extends V {
  21902. constructor() {
  21903. super(...arguments);
  21904. A(this, "minParams", 1);
  21905. A(this, "maxParams", 4);
  21906. A(this, "needsReferenceObject", true);
  21907. }
  21908. // eslint-disable-next-line max-lines-per-function, complexity
  21909. calculate(e, t, r, n) {
  21910. if (e.isError())
  21911. return e;
  21912. if (t != null && t.isError())
  21913. return t;
  21914. if (r != null && r.isError())
  21915. return r;
  21916. if (n != null && n.isError())
  21917. return n;
  21918. let s = 0, o = 0;
  21919. if (e.isValueObject())
  21920. s = 1, o = 1;
  21921. else if (e.isReferenceObject()) {
  21922. const { startRow: d2, endRow: _, startColumn: C, endColumn: E2 } = e.getRangePosition();
  21923. s = _ - d2 + 1, o = E2 - C + 1;
  21924. } else
  21925. return g2.create(m2.VALUE);
  21926. let u, c;
  21927. s === 1 && o > 1 && r == null ? (c = t != null ? t : y2.create(0), u = y2.create(0)) : (u = t != null ? t : y2.create(0), c = r != null ? r : y2.create(0));
  21928. let l2 = n != null ? n : y2.create(1);
  21929. u.isReferenceObject() && (u = u.toArrayValueObject()), c.isReferenceObject() && (c = c.toArrayValueObject()), l2.isReferenceObject() && (l2 = l2.toArrayValueObject());
  21930. const f2 = Math.max(
  21931. u.isArray() ? u.getRowCount() : 1,
  21932. c.isArray() ? c.getRowCount() : 1,
  21933. l2.isArray() ? l2.getRowCount() : 1
  21934. ), h = Math.max(
  21935. u.isArray() ? u.getColumnCount() : 1,
  21936. c.isArray() ? c.getColumnCount() : 1,
  21937. l2.isArray() ? l2.getColumnCount() : 1
  21938. );
  21939. if (u = u, c = c, l2 = l2, f2 === 1 && h === 1)
  21940. return this._calculateSingleCell(e, u, c, l2);
  21941. {
  21942. const d2 = O(f2, h, u, g2.create(m2.NA)), _ = O(f2, h, c, g2.create(m2.NA)), C = O(f2, h, l2, g2.create(m2.NA));
  21943. return d2.map((E2, b, R) => {
  21944. const p2 = _.get(b, R) || ie.create(), N2 = C.get(b, R) || ie.create(), M2 = this._calculateSingleCell(e, E2, p2, N2);
  21945. return M2.isReferenceObject() ? M2.toArrayValueObject().getFirstCell() : M2;
  21946. });
  21947. }
  21948. }
  21949. _calculateSingleCell(e, t, r, n) {
  21950. if (t.isError())
  21951. return t;
  21952. const s = this._getNumberValue(t);
  21953. if (s === void 0 || s < 0)
  21954. return g2.create(m2.VALUE);
  21955. if (r.isError())
  21956. return r;
  21957. const o = this._getNumberValue(r);
  21958. if (o === void 0 || o < 0)
  21959. return g2.create(m2.VALUE);
  21960. if (n.isError())
  21961. return n;
  21962. const u = this._getAreaNumberValue(n);
  21963. return u === void 0 || u < 1 ? g2.create(m2.VALUE) : e.isReferenceObject() ? this._getReferenceObject(e, s, o, u) : e.isValueObject() && s === 1 && o === 1 ? e : g2.create(m2.REF);
  21964. }
  21965. _getNumberValue(e) {
  21966. if (e == null)
  21967. return 0;
  21968. let t = 0;
  21969. if (e.isBoolean())
  21970. e.getValue() === true && (t = 1);
  21971. else {
  21972. if (e.isString())
  21973. return;
  21974. e.isNumber() ? t = Math.floor(e.getValue()) : e.isNull() && (t = 0);
  21975. }
  21976. return t;
  21977. }
  21978. _getAreaNumberValue(e) {
  21979. if (e == null)
  21980. return 1;
  21981. let t = 0;
  21982. if (e.isBoolean())
  21983. e.getValue() === true && (t = 1);
  21984. else {
  21985. if (e.isString())
  21986. return;
  21987. e.isNumber() ? t = Math.floor(e.getValue()) : e.isNull() && (t = 0);
  21988. }
  21989. return t;
  21990. }
  21991. _getReferenceObject(e, t, r, n) {
  21992. const { startRow: s, endRow: o, startColumn: u, endColumn: c } = e.getRangePosition();
  21993. let l2 = 0, f2 = 0, h = 0, d2 = 0;
  21994. if (t === 0 ? (l2 = s, f2 = o) : l2 = f2 = s + t - 1, r === 0 ? (h = u, d2 = c) : h = d2 = u + r - 1, l2 > o || h > c)
  21995. return g2.create(m2.REF);
  21996. const _ = {
  21997. startRow: l2,
  21998. startColumn: h,
  21999. endRow: f2,
  22000. endColumn: d2
  22001. };
  22002. return this.createReferenceObject(e, _);
  22003. }
  22004. };
  22005. var Td = class extends V {
  22006. constructor() {
  22007. super(...arguments);
  22008. A(this, "minParams", 1);
  22009. A(this, "maxParams", 2);
  22010. }
  22011. isAddress() {
  22012. return true;
  22013. }
  22014. calculate(e, t) {
  22015. if (e.isError())
  22016. return e;
  22017. if (t != null && t.isError())
  22018. return t;
  22019. let r = this.getZeroOrOneByOneDefault(t);
  22020. r == null && (r = 1);
  22021. let n = e;
  22022. if (e.isArray()) {
  22023. const s = e.getRowCount(), o = e.getColumnCount();
  22024. if (s > 1 || o > 1)
  22025. return e.map(() => g2.create(m2.VALUE));
  22026. n = e.getFirstCell();
  22027. }
  22028. return this._handleSingleObject(n, r);
  22029. }
  22030. _handleSingleObject(e, t) {
  22031. const r = `${e.getValue()}`;
  22032. if (r.trim() === "")
  22033. return g2.create(m2.REF);
  22034. const n = this._convertToDefinedName(r);
  22035. if (t === 0) {
  22036. const f2 = Ih(n), { range: h, sheetName: d2, unitId: _ } = f2, C = new Cn(h);
  22037. return C.setForcedUnitIdDirect(_), C.setForcedSheetName(d2), this._setDefault(C);
  22038. }
  22039. if (vr(n))
  22040. return this._setDefault(new da(n));
  22041. if (Hi(n))
  22042. return this._setDefault(new _a(n));
  22043. if (Gi(n))
  22044. return this._setDefault(new Ca(n));
  22045. const s = mr(n), { range: o, sheetName: u, unitId: c } = s;
  22046. if (Number.isNaN(o.startRow) || o.endRow + 1 > 1048576 || Number.isNaN(o.startColumn) || o.endColumn + 1 > 16384)
  22047. return g2.create(m2.REF);
  22048. const l2 = new Cn(o);
  22049. return l2.setForcedUnitIdDirect(c), l2.setForcedSheetName(u), this._setDefault(l2);
  22050. }
  22051. _setDefault(e) {
  22052. return this.unitId == null || this.subUnitId == null ? g2.create(m2.REF) : (e.setDefaultUnitId(this.unitId), e.setDefaultSheetId(this.subUnitId), e);
  22053. }
  22054. /**
  22055. * In Excel, to inject a defined name into a function that has positioning capabilities,
  22056. * such as using the INDIRECT function to reference a named range,
  22057. * you can write it as follows:
  22058. * =INDIRECT("DefinedName1")
  22059. */
  22060. _convertToDefinedName(e) {
  22061. const t = this.getDefinedName(e);
  22062. if (t == null)
  22063. return e;
  22064. const r = t.formulaOrRefString;
  22065. return r == null ? e : r.startsWith(X2.EQUALS) ? r.slice(1) : r;
  22066. }
  22067. };
  22068. var Bd = class extends V {
  22069. constructor() {
  22070. super(...arguments);
  22071. A(this, "minParams", 2);
  22072. A(this, "maxParams", 3);
  22073. A(this, "needsExpandParams", true);
  22074. }
  22075. calculate(e, t, r) {
  22076. return e.isError() ? e : t.isError() ? g2.create(m2.REF) : t.isArray() ? r != null && r.isError() ? r : t.getColumnCount() === 1 || t.getRowCount() === 1 ? r != null && !r.isArray() ? g2.create(m2.REF) : this._handleVector(e, t, r) : this._handleArray(e, t) : g2.create(m2.VALUE);
  22077. }
  22078. _handleVector(e, t, r) {
  22079. let n = r;
  22080. if (n == null)
  22081. n = t;
  22082. else if (n.getRowCount() !== t.getRowCount() || n.getColumnCount() !== t.getColumnCount())
  22083. return g2.create(m2.REF);
  22084. return e.isArray() ? e.map((s) => this.binarySearch(s, t, n)) : this.binarySearch(e, t, n);
  22085. }
  22086. _handleArray(e, t) {
  22087. const r = t.getRowCount(), n = t.getColumnCount();
  22088. let s, o;
  22089. return n > r ? (s = t.slice([0, 1]), o = t.slice([r - 1, r])) : (s = t.slice(void 0, [0, 1]), o = t.slice(void 0, [n - 1, n])), s == null || o == null ? g2.create(m2.VALUE) : e.isArray() ? e.map((u) => this.binarySearch(u, s, o)) : this.binarySearch(e, s, o);
  22090. }
  22091. };
  22092. var Id = class extends V {
  22093. constructor() {
  22094. super(...arguments);
  22095. A(this, "minParams", 2);
  22096. A(this, "maxParams", 3);
  22097. }
  22098. calculate(e, t, r) {
  22099. if (e.isError())
  22100. return e;
  22101. if (t.isError())
  22102. return g2.create(m2.REF);
  22103. if (!t.isArray())
  22104. return g2.create(m2.VALUE);
  22105. const n = t.getRowCount(), s = t.getColumnCount();
  22106. if (n !== 1 && s !== 1 || r != null && r.isError())
  22107. return g2.create(m2.NA);
  22108. const o = this.getMatchTypeValue(r);
  22109. return o == null ? g2.create(m2.VALUE) : e.isArray() ? e.map((u) => this._handleSingleObject(
  22110. u,
  22111. t,
  22112. o
  22113. )) : this._handleSingleObject(
  22114. e,
  22115. t,
  22116. o
  22117. );
  22118. }
  22119. _handleSingleObject(e, t, r) {
  22120. const n = this._getSearchModeValue(r), s = t.orderSearch(e, n);
  22121. if (s == null)
  22122. return g2.create(m2.NA);
  22123. if (s instanceof g2)
  22124. return s;
  22125. const o = t.getRowCount() === 1 ? s.column + 1 : s.row + 1;
  22126. return y2.create(o);
  22127. }
  22128. _getSearchModeValue(e) {
  22129. switch (e) {
  22130. case 1:
  22131. return Pe.MIN;
  22132. case 0:
  22133. return Pe.NORMAL;
  22134. case -1:
  22135. return Pe.MAX;
  22136. }
  22137. }
  22138. };
  22139. var Fd = class extends V {
  22140. constructor() {
  22141. super(...arguments);
  22142. A(this, "minParams", 3);
  22143. A(this, "maxParams", 5);
  22144. A(this, "needsReferenceObject", true);
  22145. }
  22146. isAddress() {
  22147. return true;
  22148. }
  22149. // eslint-disable-next-line max-lines-per-function, complexity
  22150. calculate(e, t, r, n, s) {
  22151. if (e.isError())
  22152. return e;
  22153. if (t.isError())
  22154. return t;
  22155. if (r.isError())
  22156. return r;
  22157. if (n != null && n.isError())
  22158. return n;
  22159. if (s != null && s.isError())
  22160. return s;
  22161. if (!e.isReferenceObject())
  22162. return g2.create(m2.VALUE);
  22163. const o = e.getRowCount(), u = e.getColumnCount();
  22164. let c = t;
  22165. c.isReferenceObject() && (c = c.toArrayValueObject());
  22166. let l2 = r;
  22167. l2.isReferenceObject() && (l2 = l2.toArrayValueObject());
  22168. let f2 = n != null ? n : y2.create(o);
  22169. f2.isReferenceObject() && (f2 = f2.toArrayValueObject()), f2.isNull() && (f2 = y2.create(o));
  22170. let h = s != null ? s : y2.create(u);
  22171. h.isReferenceObject() && (h = h.toArrayValueObject()), h.isNull() && (h = y2.create(u));
  22172. const d2 = Math.max(
  22173. c.isArray() ? c.getRowCount() : 1,
  22174. l2.isArray() ? l2.getRowCount() : 1,
  22175. f2.isArray() ? f2.getRowCount() : 1,
  22176. h.isArray() ? h.getRowCount() : 1
  22177. ), _ = Math.max(
  22178. c.isArray() ? c.getColumnCount() : 1,
  22179. l2.isArray() ? l2.getColumnCount() : 1,
  22180. f2.isArray() ? f2.getColumnCount() : 1,
  22181. h.isArray() ? h.getColumnCount() : 1
  22182. );
  22183. if (c = c, l2 = l2, f2 = f2, h = h, d2 === 1 && _ === 1)
  22184. return c = c.isArray() ? c.get(0, 0) : c, l2 = l2.isArray() ? l2.get(0, 0) : l2, f2 = f2.isArray() ? f2.get(0, 0) : f2, h = h.isArray() ? h.get(0, 0) : h, this._handleSingleObject(e, c, l2, f2, h);
  22185. const C = O(d2, _, c, g2.create(m2.NA)), E2 = O(d2, _, l2, g2.create(m2.NA)), b = O(d2, _, f2, g2.create(m2.NA)), R = O(d2, _, h, g2.create(m2.NA));
  22186. return C.mapValue((p2, N2, M2) => {
  22187. const w = E2.get(N2, M2), D2 = b.get(N2, M2), S2 = R.get(N2, M2);
  22188. return p2.isError() ? p2 : w.isError() ? w : D2.isError() ? D2 : S2.isError() ? S2 : this._handleSingleObject(e, p2, w, D2, S2, true);
  22189. });
  22190. }
  22191. // eslint-disable-next-line
  22192. _handleSingleObject(e, t, r, n, s, o = false) {
  22193. const { startRow: u, startColumn: c } = e.getRangePosition();
  22194. let l2 = t;
  22195. if (l2.isString() && (l2 = l2.convertToNumberObjectValue()), l2.isError())
  22196. return l2;
  22197. let f2 = r;
  22198. if (f2.isString() && (f2 = f2.convertToNumberObjectValue()), f2.isError())
  22199. return f2;
  22200. const h = +l2.getValue(), d2 = +f2.getValue();
  22201. if (typeof h != "number" || typeof d2 != "number")
  22202. return g2.create(m2.VALUE);
  22203. const _ = u + h, C = c + d2;
  22204. if (_ < 0 || C < 0)
  22205. return g2.create(m2.REF);
  22206. const E2 = this.getIndexNumValue(n), b = this.getIndexNumValue(s);
  22207. if (typeof E2 != "number" || typeof b != "number")
  22208. return g2.create(m2.VALUE);
  22209. if (E2 === 0 || b === 0)
  22210. return g2.create(m2.REF);
  22211. const R = E2 > 0 ? _ + E2 - 1 : _ + E2 + 1, p2 = b > 0 ? C + b - 1 : C + b + 1;
  22212. if (R < 0 || p2 < 0)
  22213. return g2.create(m2.REF);
  22214. if (o)
  22215. return g2.create(m2.VALUE);
  22216. const N2 = _ < R ? _ : R, M2 = C < p2 ? C : p2, w = _ > R ? _ : R, D2 = C > p2 ? C : p2, S2 = {
  22217. startRow: N2,
  22218. startColumn: M2,
  22219. endRow: w,
  22220. endColumn: D2
  22221. };
  22222. return this.createReferenceObject(e, S2);
  22223. }
  22224. };
  22225. var kd = class extends V {
  22226. constructor() {
  22227. super(...arguments);
  22228. A(this, "minParams", 0);
  22229. A(this, "maxParams", 1);
  22230. }
  22231. calculate(e) {
  22232. if (e == null)
  22233. return y2.create(this.row + 1);
  22234. if (e.isError())
  22235. return e;
  22236. if (!e.isArray())
  22237. return g2.create(m2.NA);
  22238. const t = e.getCurrentRow(), r = e.getRowCount(), n = [];
  22239. for (let o = 0; o < r; o++)
  22240. n.push([y2.create(t + o + 1)]);
  22241. const s = {
  22242. calculateValueList: n,
  22243. rowCount: r,
  22244. columnCount: 1,
  22245. unitId: this.unitId || "",
  22246. sheetId: this.subUnitId || "",
  22247. row: this.row,
  22248. column: this.column
  22249. };
  22250. return q2.create(s);
  22251. }
  22252. };
  22253. var $d = class extends V {
  22254. constructor() {
  22255. super(...arguments);
  22256. A(this, "minParams", 1);
  22257. A(this, "maxParams", 1);
  22258. }
  22259. calculate(e) {
  22260. if (e.isError())
  22261. return e;
  22262. if (e.isString() || e.isNumber() || e.isBoolean())
  22263. return y2.create(1);
  22264. if (!e.isArray())
  22265. return g2.create(m2.NA);
  22266. const t = e.getRowCount();
  22267. return y2.create(t);
  22268. }
  22269. };
  22270. var Yd = class extends V {
  22271. constructor() {
  22272. super(...arguments);
  22273. A(this, "minParams", 1);
  22274. A(this, "maxParams", 4);
  22275. }
  22276. calculate(e, t, r, n) {
  22277. const s = t != null ? t : y2.create(1), o = r != null ? r : y2.create(1), u = n != null ? n : T2.create(false);
  22278. if (u.isArray()) {
  22279. const c = u.getRowCount(), l2 = u.getColumnCount();
  22280. if (c === 1 && l2 === 1) {
  22281. const f2 = u.get(0, 0);
  22282. return this._handleSingleObject(e, s, o, f2);
  22283. }
  22284. return u.map((f2) => {
  22285. const h = this._handleSingleObject(e, s, o, f2);
  22286. return h.isArray() ? h.get(0, 0) : h;
  22287. });
  22288. }
  22289. return this._handleSingleObject(e, s, o, u);
  22290. }
  22291. _handleSingleObject(e, t, r, n) {
  22292. if (e.isError())
  22293. return e;
  22294. const s = e.isArray() ? e.getRowCount() : 1, o = e.isArray() ? e.getColumnCount() : 1, u = this._checkArrayError(t);
  22295. if (u.isError())
  22296. return u;
  22297. const c = Math.floor(+u.getValue());
  22298. if (c < 1)
  22299. return g2.create(m2.VALUE);
  22300. const l2 = this._checkArrayError(r);
  22301. if (l2.isError())
  22302. return l2;
  22303. const f2 = Math.floor(+l2.getValue());
  22304. if (f2 !== -1 && f2 !== 1)
  22305. return g2.create(m2.VALUE);
  22306. let h = n;
  22307. if (h.isString() && (h = h.convertToNumberObjectValue()), h.isError())
  22308. return h;
  22309. if (!e.isArray() || s === 1 && o === 1)
  22310. return e;
  22311. const d2 = +h.getValue();
  22312. return this._getResult(e, c, f2, d2, s, o);
  22313. }
  22314. _checkArrayError(e) {
  22315. let t = e;
  22316. if (t.isArray()) {
  22317. const r = t.getRowCount(), n = t.getColumnCount();
  22318. if (r > 1 || n > 1)
  22319. return g2.create(m2.VALUE);
  22320. t = t.get(0, 0);
  22321. }
  22322. return t.isString() && (t = t.convertToNumberObjectValue()), t;
  22323. }
  22324. _getResult(e, t, r, n, s, o) {
  22325. if (n) {
  22326. if (t > s)
  22327. return g2.create(m2.VALUE);
  22328. const u = e.transpose().getArrayValue();
  22329. return u.sort(this._sort(t - 1, r)), q2.create({
  22330. calculateValueList: u,
  22331. rowCount: u.length,
  22332. columnCount: u[0].length || 0,
  22333. unitId: this.unitId,
  22334. sheetId: this.subUnitId,
  22335. row: this.row,
  22336. column: this.column
  22337. }).transpose();
  22338. } else {
  22339. if (t > o)
  22340. return g2.create(m2.VALUE);
  22341. const u = e.getArrayValue();
  22342. return u.sort(this._sort(t - 1, r)), q2.create({
  22343. calculateValueList: u,
  22344. rowCount: u.length,
  22345. columnCount: u[0].length || 0,
  22346. unitId: this.unitId,
  22347. sheetId: this.subUnitId,
  22348. row: this.row,
  22349. column: this.column
  22350. });
  22351. }
  22352. }
  22353. _sort(e, t = 1) {
  22354. const r = hn();
  22355. return t === 1 ? this._sortAsc(e, r) : this._sortDesc(e, r);
  22356. }
  22357. _sortAsc(e, t) {
  22358. return (r, n) => {
  22359. const s = r[e], o = n[e];
  22360. if (s == null || s.isNull())
  22361. return 1;
  22362. if (o == null || o.isNull())
  22363. return -1;
  22364. if (s.isError() && o.isError())
  22365. return 0;
  22366. if (s.isError())
  22367. return 1;
  22368. if (o.isError())
  22369. return -1;
  22370. const u = s.getValue(), c = o.getValue();
  22371. return s.isBoolean() && u === true ? 1 : o.isBoolean() && c === true ? -1 : s.isBoolean() && u === false ? 1 : o.isBoolean() && c === false ? -1 : s.isNumber() && o.isNumber() ? +u - +c : t(
  22372. u,
  22373. c
  22374. );
  22375. };
  22376. }
  22377. _sortDesc(e, t) {
  22378. return (r, n) => {
  22379. const s = r[e], o = n[e];
  22380. if (s == null || s.isNull())
  22381. return 1;
  22382. if (o == null || o.isNull())
  22383. return -1;
  22384. if (s.isError() && o.isError())
  22385. return 0;
  22386. if (s.isError())
  22387. return -1;
  22388. if (o.isError())
  22389. return 1;
  22390. const u = s.getValue(), c = o.getValue();
  22391. return s.isBoolean() && u === true ? -1 : o.isBoolean() && c === true ? 1 : s.isBoolean() && u === false ? -1 : o.isBoolean() && c === false ? 1 : s.isNumber() && o.isNumber() ? +c - +u : t(
  22392. c,
  22393. u
  22394. );
  22395. };
  22396. }
  22397. };
  22398. var Hd = class extends V {
  22399. constructor() {
  22400. super(...arguments);
  22401. A(this, "minParams", 2);
  22402. A(this, "maxParams", 255);
  22403. }
  22404. calculate(e, ...t) {
  22405. t.length === 1 && t.push(y2.create(1));
  22406. const r = this._getVariantsError(e, ...t), { maxRowLength: n, maxColumnLength: s } = Nr(t);
  22407. if (r.isError()) {
  22408. const c = O(n, s, r);
  22409. return n === 1 && s === 1 ? c.get(0, 0) : c;
  22410. }
  22411. const o = t.map((c, l2) => l2 % 2 === 0 ? c : O(n, s, c, g2.create(m2.NA))), u = this._getResultArray(e, o, n, s);
  22412. return n === 1 && s === 1 ? u[0][0] : q2.create({
  22413. calculateValueList: u,
  22414. rowCount: u.length,
  22415. columnCount: u[0].length || 0,
  22416. unitId: this.unitId,
  22417. sheetId: this.subUnitId,
  22418. row: this.row,
  22419. column: this.column
  22420. });
  22421. }
  22422. // eslint-disable-next-line complexity
  22423. _getVariantsError(e, ...t) {
  22424. if (e.isError())
  22425. return e;
  22426. for (let u = 0; u < t.length; u++) {
  22427. const c = t[u];
  22428. if (c.isError())
  22429. return c;
  22430. }
  22431. if (t.length < 2 || t.length % 2 !== 0)
  22432. return g2.create(m2.VALUE);
  22433. const r = e.isArray() ? e.getRowCount() : 1, n = e.isArray() ? e.getColumnCount() : 1, s = t[0].isArray() ? t[0].getRowCount() : 1, o = t[0].isArray() ? t[0].getColumnCount() : 1;
  22434. if ((s > 1 || o > 1) && (s > 1 && o > 1 || s === 1 && o !== n || o === 1 && s !== r))
  22435. return g2.create(m2.VALUE);
  22436. for (let u = 2; u < t.length; u++) {
  22437. if (u % 2 === 1)
  22438. continue;
  22439. const c = t[u].isArray() ? t[u].getRowCount() : 1, l2 = t[u].isArray() ? t[u].getColumnCount() : 1;
  22440. if (c !== s || l2 !== o)
  22441. return g2.create(m2.VALUE);
  22442. }
  22443. return T2.create(true);
  22444. }
  22445. _getResultArray(e, t, r, n) {
  22446. const s = e.isArray() ? e.getRowCount() : 1, o = e.isArray() ? e.getColumnCount() : 1, u = t[0].isArray() ? t[0].getRowCount() : 1, c = t[0].isArray() ? t[0].getColumnCount() : 1, l2 = [];
  22447. for (let f2 = 0; f2 < r; f2++) {
  22448. l2[f2] = [];
  22449. for (let h = 0; h < n; h++) {
  22450. const { isError: d2, errorObject: _, byArrays: C, sortOrders: E2 } = this._getByArraysAndSortOrders(t, f2, h, c);
  22451. if (d2) {
  22452. l2[f2].push(_);
  22453. continue;
  22454. }
  22455. if (!e.isArray() || s === 1 && o === 1) {
  22456. l2[f2].push(e);
  22457. continue;
  22458. }
  22459. let b = e.getArrayValue();
  22460. u === 1 && c === 1 || (u === 1 ? (b = b.concat(C), b = this._transposeArray(b), b.sort(this._sort(s, E2)), b = this._transposeArray(b).slice(0, s)) : c === 1 && (b = this._transposeArray(b), b = b.concat(C), b = this._transposeArray(b), b.sort(this._sort(o, E2)), b = b.map((p2) => p2.slice(0, o))));
  22461. const R = q2.create({
  22462. calculateValueList: b,
  22463. rowCount: b.length,
  22464. columnCount: b[0].length || 0,
  22465. unitId: this.unitId,
  22466. sheetId: this.subUnitId,
  22467. row: this.row,
  22468. column: this.column
  22469. });
  22470. if (r > 1 || n > 1) {
  22471. l2[f2].push(R.get(0, 0));
  22472. continue;
  22473. }
  22474. l2[f2].push(R);
  22475. }
  22476. }
  22477. return l2;
  22478. }
  22479. _getByArraysAndSortOrders(e, t, r, n) {
  22480. const s = [], o = [];
  22481. let u = false, c = null;
  22482. for (let l2 = 0; l2 < e.length; l2++) {
  22483. if (l2 % 2 === 1)
  22484. continue;
  22485. const f2 = e[l2];
  22486. let h = e[l2 + 1].get(t, r);
  22487. if (h.isString() && (h = h.convertToNumberObjectValue()), h.isError()) {
  22488. u = true, c = h;
  22489. break;
  22490. }
  22491. const d2 = Math.floor(+h.getValue());
  22492. if (d2 !== -1 && d2 !== 1) {
  22493. u = true, c = g2.create(m2.VALUE);
  22494. break;
  22495. }
  22496. if (o.push(d2), f2.isArray()) {
  22497. let _ = f2.getArrayValue();
  22498. n === 1 && (_ = this._transposeArray(_)), s.push(_[0]);
  22499. } else
  22500. s.push([f2]);
  22501. }
  22502. return {
  22503. isError: u,
  22504. errorObject: c,
  22505. byArrays: s,
  22506. sortOrders: o
  22507. };
  22508. }
  22509. _transposeArray(e) {
  22510. const t = e.length, r = e[0].length, n = [];
  22511. for (let s = 0; s < r; s++) {
  22512. n[s] = [];
  22513. for (let o = 0; o < t; o++)
  22514. n[s][o] = e[o][s];
  22515. }
  22516. return n;
  22517. }
  22518. _sort(e, t) {
  22519. const r = hn();
  22520. return (n, s) => {
  22521. let o = n[e], u = s[e], c = this._compare(o, u, t[0], r);
  22522. if (c === 0 && t.length > 1) {
  22523. for (let l2 = 1; l2 < t.length; l2++)
  22524. if (o = n[e + l2], u = s[e + l2], c = this._compare(o, u, t[l2], r), c !== 0)
  22525. return c;
  22526. }
  22527. return c;
  22528. };
  22529. }
  22530. _compare(e, t, r, n) {
  22531. return r === 1 ? this._asc(e, t, n) : this._desc(e, t, n);
  22532. }
  22533. _asc(e, t, r) {
  22534. if (e == null || e.isNull())
  22535. return 1;
  22536. if (t == null || t.isNull())
  22537. return -1;
  22538. if (e.isError() && t.isError())
  22539. return 0;
  22540. if (e.isError())
  22541. return 1;
  22542. if (t.isError())
  22543. return -1;
  22544. const n = e.getValue(), s = t.getValue();
  22545. return e.isBoolean() && n === true ? 1 : t.isBoolean() && s === true ? -1 : e.isBoolean() && n === false ? 1 : t.isBoolean() && s === false ? -1 : e.isNumber() && t.isNumber() ? +n - +s : r(
  22546. n,
  22547. s
  22548. );
  22549. }
  22550. _desc(e, t, r) {
  22551. if (e == null || e.isNull())
  22552. return 1;
  22553. if (t == null || t.isNull())
  22554. return -1;
  22555. if (e.isError() && t.isError())
  22556. return 0;
  22557. if (e.isError())
  22558. return -1;
  22559. if (t.isError())
  22560. return 1;
  22561. const n = e.getValue(), s = t.getValue();
  22562. return e.isBoolean() && n === true ? -1 : t.isBoolean() && s === true ? 1 : e.isBoolean() && n === false ? -1 : t.isBoolean() && s === false ? 1 : e.isNumber() && t.isNumber() ? +s - +n : r(
  22563. s,
  22564. n
  22565. );
  22566. }
  22567. };
  22568. var Gd = class extends V {
  22569. constructor() {
  22570. super(...arguments);
  22571. A(this, "minParams", 2);
  22572. A(this, "maxParams", 3);
  22573. }
  22574. calculate(e, t, r) {
  22575. const n = e.isArray() ? e.getRowCount() : 1, s = e.isArray() ? e.getColumnCount() : 1;
  22576. let o = t, u = r != null ? r : y2.create(s);
  22577. t.isNull() && (o = y2.create(n)), u.isNull() && (u = y2.create(s));
  22578. const c = Math.max(
  22579. o.isArray() ? o.getRowCount() : 1,
  22580. u.isArray() ? u.getRowCount() : 1
  22581. ), l2 = Math.max(
  22582. o.isArray() ? o.getColumnCount() : 1,
  22583. u.isArray() ? u.getColumnCount() : 1
  22584. ), f2 = O(c, l2, o, g2.create(m2.NA)), h = O(c, l2, u, g2.create(m2.NA));
  22585. if (c > 1 || l2 > 1)
  22586. return f2.mapValue((p2, N2, M2) => {
  22587. const w = h.get(N2, M2);
  22588. if (e.isError())
  22589. return e;
  22590. if (e.isNull())
  22591. return g2.create(m2.VALUE);
  22592. const { isError: D2, errorObject: S2 } = this._checkRowsColumns(p2, w, n, s);
  22593. return D2 ? S2 : e.isArray() ? g2.create(m2.VALUE) : e;
  22594. });
  22595. if (e.isError())
  22596. return e;
  22597. if (e.isNull())
  22598. return g2.create(m2.VALUE);
  22599. const d2 = o.isArray() ? o.get(0, 0) : o, _ = u.isArray() ? u.get(0, 0) : u, { isError: C, errorObject: E2, rowsValue: b, columnsValue: R } = this._checkRowsColumns(d2, _, n, s);
  22600. return C ? E2 : this._getResultArray(e, b, R, n, s);
  22601. }
  22602. _checkRowsColumns(e, t, r, n) {
  22603. if (e.isError())
  22604. return {
  22605. isError: true,
  22606. errorObject: e
  22607. };
  22608. if (t.isError())
  22609. return {
  22610. isError: true,
  22611. errorObject: t
  22612. };
  22613. let s = Math.trunc(+e.getValue()), o = Math.trunc(+t.getValue());
  22614. return Number.isNaN(s) || Number.isNaN(o) ? {
  22615. isError: true,
  22616. errorObject: g2.create(m2.VALUE)
  22617. } : Math.abs(s) === 0 || Math.abs(o) === 0 ? {
  22618. isError: true,
  22619. errorObject: g2.create(m2.CALC)
  22620. } : (s > r && (s = r), o > n && (o = n), {
  22621. isError: false,
  22622. rowsValue: s,
  22623. columnsValue: o
  22624. });
  22625. }
  22626. _getResultArray(e, t, r, n, s) {
  22627. if (!e.isArray())
  22628. return e;
  22629. const o = t >= 0 ? [0, t] : [n + t, n], u = r >= 0 ? [0, r] : [s + r, s];
  22630. let c;
  22631. return t === n && r === s ? c = e : t === n ? c = e.slice(void 0, u) : r === s ? c = e.slice(o, void 0) : c = e.slice(o, u), c = c.map((l2) => l2.isNull() ? y2.create(0) : l2), t === 1 && r === 1 ? c.get(0, 0) : c;
  22632. }
  22633. };
  22634. var Qd = class extends V {
  22635. constructor() {
  22636. super(...arguments);
  22637. A(this, "minParams", 1);
  22638. A(this, "maxParams", 3);
  22639. }
  22640. calculate(e, t, r) {
  22641. const n = t != null ? t : y2.create(0), s = r != null ? r : T2.create(false), o = Math.max(
  22642. n.isArray() ? n.getRowCount() : 1,
  22643. s.isArray() ? s.getRowCount() : 1
  22644. ), u = Math.max(
  22645. n.isArray() ? n.getColumnCount() : 1,
  22646. s.isArray() ? s.getColumnCount() : 1
  22647. ), c = O(o, u, n, g2.create(m2.NA)), l2 = O(o, u, s, g2.create(m2.NA)), f2 = c.mapValue((h, d2, _) => {
  22648. const C = l2.get(d2, _);
  22649. if (e.isError())
  22650. return e;
  22651. if (e.isNull())
  22652. return g2.create(m2.VALUE);
  22653. if (h.isError())
  22654. return h;
  22655. if (C.isError())
  22656. return C;
  22657. const E2 = Math.trunc(+h.getValue()), b = +C.getValue();
  22658. if (Number.isNaN(E2) || E2 < 0 || E2 > 3 || Number.isNaN(b))
  22659. return g2.create(m2.VALUE);
  22660. if (!e.isArray())
  22661. return e;
  22662. let R = [];
  22663. return b ? R = this._getArrayValueByColumn(e, E2) : R = this._getArrayValueByRow(e, E2), R.length === 0 ? g2.create(m2.CALC) : o > 1 || u > 1 || R.length === 1 ? R[0] : q2.create({
  22664. calculateValueList: R.map((p2) => [p2]),
  22665. rowCount: R.length,
  22666. columnCount: 1,
  22667. unitId: this.unitId,
  22668. sheetId: this.subUnitId,
  22669. row: this.row,
  22670. column: this.column
  22671. });
  22672. });
  22673. return o === 1 && u === 1 ? f2.get(0, 0) : f2;
  22674. }
  22675. _getArrayValueByColumn(e, t) {
  22676. const r = e, n = r.getRowCount(), s = r.getColumnCount(), o = [];
  22677. for (let u = 0; u < s; u++)
  22678. for (let c = 0; c < n; c++) {
  22679. const l2 = r.get(c, u);
  22680. this._isIgnore(l2, t) || o.push(l2.isNull() ? y2.create(0) : l2);
  22681. }
  22682. return o;
  22683. }
  22684. _getArrayValueByRow(e, t) {
  22685. const r = e, n = r.getRowCount(), s = r.getColumnCount(), o = [];
  22686. for (let u = 0; u < n; u++)
  22687. for (let c = 0; c < s; c++) {
  22688. const l2 = r.get(u, c);
  22689. this._isIgnore(l2, t) || o.push(l2.isNull() ? y2.create(0) : l2);
  22690. }
  22691. return o;
  22692. }
  22693. _isIgnore(e, t) {
  22694. switch (t) {
  22695. case 0:
  22696. return false;
  22697. case 1:
  22698. return e.isNull();
  22699. case 2:
  22700. return e.isError();
  22701. case 3:
  22702. return e.isNull() || e.isError();
  22703. default:
  22704. return false;
  22705. }
  22706. }
  22707. };
  22708. var Wd = class extends V {
  22709. constructor() {
  22710. super(...arguments);
  22711. A(this, "minParams", 1);
  22712. A(this, "maxParams", 3);
  22713. }
  22714. calculate(e, t, r) {
  22715. const n = t != null ? t : y2.create(0), s = r != null ? r : T2.create(false), o = Math.max(
  22716. n.isArray() ? n.getRowCount() : 1,
  22717. s.isArray() ? s.getRowCount() : 1
  22718. ), u = Math.max(
  22719. n.isArray() ? n.getColumnCount() : 1,
  22720. s.isArray() ? s.getColumnCount() : 1
  22721. ), c = O(o, u, n, g2.create(m2.NA)), l2 = O(o, u, s, g2.create(m2.NA)), f2 = c.mapValue((h, d2, _) => {
  22722. const C = l2.get(d2, _);
  22723. if (e.isError())
  22724. return e;
  22725. if (h.isError())
  22726. return h;
  22727. if (C.isError())
  22728. return C;
  22729. const E2 = Math.trunc(+h.getValue()), b = +C.getValue();
  22730. if (Number.isNaN(E2) || E2 < 0 || E2 > 3 || Number.isNaN(b) || e.isNull())
  22731. return g2.create(m2.VALUE);
  22732. if (!e.isArray())
  22733. return e;
  22734. let R = [];
  22735. return b ? R = this._getArrayValueByColumn(e, E2) : R = this._getArrayValueByRow(e, E2), R.length === 0 ? g2.create(m2.CALC) : o > 1 || u > 1 || R.length === 1 ? R[0] : q2.create({
  22736. calculateValueList: [R],
  22737. rowCount: 1,
  22738. columnCount: R.length,
  22739. unitId: this.unitId,
  22740. sheetId: this.subUnitId,
  22741. row: this.row,
  22742. column: this.column
  22743. });
  22744. });
  22745. return o === 1 && u === 1 ? f2.get(0, 0) : f2;
  22746. }
  22747. _getArrayValueByColumn(e, t) {
  22748. const r = e, n = r.getRowCount(), s = r.getColumnCount(), o = [];
  22749. for (let u = 0; u < s; u++)
  22750. for (let c = 0; c < n; c++) {
  22751. const l2 = r.get(c, u);
  22752. this._isIgnore(l2, t) || o.push(l2.isNull() ? y2.create(0) : l2);
  22753. }
  22754. return o;
  22755. }
  22756. _getArrayValueByRow(e, t) {
  22757. const r = e, n = r.getRowCount(), s = r.getColumnCount(), o = [];
  22758. for (let u = 0; u < n; u++)
  22759. for (let c = 0; c < s; c++) {
  22760. const l2 = r.get(u, c);
  22761. this._isIgnore(l2, t) || o.push(l2.isNull() ? y2.create(0) : l2);
  22762. }
  22763. return o;
  22764. }
  22765. _isIgnore(e, t) {
  22766. switch (t) {
  22767. case 0:
  22768. return false;
  22769. case 1:
  22770. return e.isNull();
  22771. case 2:
  22772. return e.isError();
  22773. case 3:
  22774. return e.isNull() || e.isError();
  22775. default:
  22776. return false;
  22777. }
  22778. }
  22779. };
  22780. var qd = class extends V {
  22781. constructor() {
  22782. super(...arguments);
  22783. A(this, "minParams", 1);
  22784. A(this, "maxParams", 1);
  22785. }
  22786. calculate(e) {
  22787. if (e.isError())
  22788. return e;
  22789. if (e.isArray()) {
  22790. const t = e.getRowCount(), r = e.getColumnCount();
  22791. return t === 1 && r === 1 ? e.get(0, 0) : e.transpose();
  22792. }
  22793. return e;
  22794. }
  22795. };
  22796. var Kd = class extends V {
  22797. constructor() {
  22798. super(...arguments);
  22799. A(this, "minParams", 1);
  22800. A(this, "maxParams", 3);
  22801. }
  22802. calculate(e, t, r) {
  22803. const n = t != null ? t : T2.create(false), s = r != null ? r : T2.create(false), o = e.isArray() ? e.getRowCount() : 1, u = e.isArray() ? e.getColumnCount() : 1, c = Math.max(
  22804. n.isArray() ? n.getRowCount() : 1,
  22805. s.isArray() ? s.getRowCount() : 1
  22806. ), l2 = Math.max(
  22807. n.isArray() ? n.getColumnCount() : 1,
  22808. s.isArray() ? s.getColumnCount() : 1
  22809. ), f2 = O(c, l2, n, g2.create(m2.NA)), h = O(c, l2, s, g2.create(m2.NA)), d2 = f2.map((_, C, E2) => {
  22810. let b = _, R = h.get(C, E2);
  22811. if (e.isError())
  22812. return e;
  22813. if (b.isString() && (b = b.convertToNumberObjectValue()), b.isError())
  22814. return b;
  22815. if (R.isString() && (R = R.convertToNumberObjectValue()), R.isError())
  22816. return R;
  22817. const p2 = +b.getValue(), N2 = +R.getValue();
  22818. let M2;
  22819. return !p2 && o === 1 || p2 && u === 1 ? M2 = e : M2 = this._getResult(e, p2, N2), (c > 1 || l2 > 1) && (M2 != null && M2.isArray()) ? M2.get(0, 0) : M2;
  22820. });
  22821. return c === 1 && l2 === 1 ? d2.get(0, 0) : d2;
  22822. }
  22823. _getResult(e, t, r) {
  22824. const n = e.isArray() ? e.getRowCount() : 1, s = e.isArray() ? e.getColumnCount() : 1;
  22825. let o = e.getArrayValue(), u = n, c = s;
  22826. t && (o = this._transposeArray(o), u = s, c = n);
  22827. const l2 = this._getRepeatRows(o, u, c);
  22828. if (l2.length > 0) {
  22829. const f2 = [];
  22830. l2.forEach((h) => {
  22831. h.forEach((d2, _) => {
  22832. (_ !== 0 || r) && f2.push(d2);
  22833. });
  22834. }), o = o.filter((h, d2) => !f2.includes(d2));
  22835. }
  22836. return o.length === 0 ? g2.create(m2.CALC) : (t && (o = this._transposeArray(o)), q2.create({
  22837. calculateValueList: o,
  22838. rowCount: o.length,
  22839. columnCount: o[0].length || 0,
  22840. unitId: this.unitId,
  22841. sheetId: this.subUnitId,
  22842. row: this.row,
  22843. column: this.column
  22844. }));
  22845. }
  22846. _getRepeatRows(e, t, r) {
  22847. let n = [];
  22848. for (let s = 0; s < r; s++)
  22849. if (s === 0) {
  22850. const o = new Array(t).fill(null).map((u, c) => ({
  22851. r: c,
  22852. valueObject: e[c][s]
  22853. }));
  22854. n = this._getRepeatRowsByObjects(o);
  22855. } else {
  22856. if (n.length === 0)
  22857. break;
  22858. let o = [];
  22859. n.forEach((u) => {
  22860. const c = u.map((f2) => ({
  22861. r: f2,
  22862. valueObject: e[f2][s]
  22863. })), l2 = this._getRepeatRowsByObjects(c);
  22864. o = o.concat(l2);
  22865. }), n = o;
  22866. }
  22867. return n;
  22868. }
  22869. _getRepeatRowsByObjects(e) {
  22870. const t = /* @__PURE__ */ new Map();
  22871. return e.forEach((r) => {
  22872. const n = r.r, s = r.valueObject;
  22873. let o = s.getValue();
  22874. if (s.isNull() ? o = null : s.isString() && DC(o) && (o = +o), !t.has(o))
  22875. t.set(o, [n]);
  22876. else {
  22877. const u = t.get(o);
  22878. u.push(n), t.set(o, u);
  22879. }
  22880. }), Array.from(t.values()).filter((r) => r.length > 1);
  22881. }
  22882. _transposeArray(e) {
  22883. const t = e.length, r = e[0].length, n = [];
  22884. for (let s = 0; s < r; s++) {
  22885. n[s] = [];
  22886. for (let o = 0; o < t; o++)
  22887. n[s][o] = e[o][s];
  22888. }
  22889. return n;
  22890. }
  22891. };
  22892. var Xd = class extends V {
  22893. constructor() {
  22894. super(...arguments);
  22895. A(this, "minParams", 3);
  22896. A(this, "maxParams", 4);
  22897. }
  22898. calculate(e, t, r, n) {
  22899. if (e.isError())
  22900. return e;
  22901. if (t.isError())
  22902. return t;
  22903. if (!t.isArray())
  22904. return g2.create(m2.VALUE);
  22905. if (r.isError())
  22906. return r;
  22907. if (n != null && n.isError())
  22908. return n;
  22909. const s = n != null ? n : T2.create(true);
  22910. return Ai(e) && Ai(s) && r.isArray() ? this._handleArrayColIndexNum(e, t, r, s) : this._handleNonArrayColIndexNum(e, t, r, s);
  22911. }
  22912. _handleArrayColIndexNum(e, t, r, n) {
  22913. const s = e.isArray() ? e.getFirstCell() : e, o = this.getZeroOrOneByOneDefault(n);
  22914. if (o == null)
  22915. return g2.create(m2.VALUE);
  22916. let u;
  22917. const c = [];
  22918. return r.iterator((l2, f2, h) => {
  22919. if (l2 == null)
  22920. return u = g2.create(m2.VALUE), false;
  22921. const d2 = this._handleTableArray(s, t, l2, o);
  22922. if (d2.isError())
  22923. return u = d2, false;
  22924. c[f2] === void 0 && (c[f2] = []), c[f2][h] = d2;
  22925. }), u || tr(c, c.length, c[0].length, this.unitId || "", this.subUnitId || "");
  22926. }
  22927. _handleNonArrayColIndexNum(e, t, r, n) {
  22928. const s = Math.max(
  22929. e.isArray() ? e.getRowCount() : 1,
  22930. n.isArray() ? n.getRowCount() : 1
  22931. ), o = Math.max(
  22932. e.isArray() ? e.getColumnCount() : 1,
  22933. n.isArray() ? n.getColumnCount() : 1
  22934. ), u = O(s, o, e), c = O(s, o, n);
  22935. return u.map((l2, f2, h) => {
  22936. if (l2.isError())
  22937. return l2;
  22938. const d2 = c.get(f2, h);
  22939. if (d2 == null)
  22940. return g2.create(m2.VALUE);
  22941. if (d2.isError())
  22942. return d2;
  22943. const _ = this.getZeroOrOneByOneDefault(d2);
  22944. return _ == null ? g2.create(m2.VALUE) : this._handleTableArray(l2, t, r, _);
  22945. });
  22946. }
  22947. _handleTableArray(e, t, r, n) {
  22948. let s = this.getIndexNumValue(r);
  22949. if (s instanceof g2)
  22950. return s;
  22951. if (s = Math.floor(s), s < 1)
  22952. return g2.create(m2.VALUE);
  22953. const o = t.slice(void 0, [0, 1]);
  22954. if (o == null)
  22955. return g2.create(m2.VALUE);
  22956. const u = t.slice(void 0, [s - 1, s]);
  22957. return u == null ? g2.create(m2.REF) : this._handleSingleObject(e, o, u, n);
  22958. }
  22959. _handleSingleObject(e, t, r, n) {
  22960. return n === 0 ? this.equalSearch(e, t, r) : this.binarySearch(e, t, r);
  22961. }
  22962. };
  22963. var Zd = class extends V {
  22964. constructor() {
  22965. super(...arguments);
  22966. A(this, "minParams", 1);
  22967. A(this, "maxParams", 255);
  22968. }
  22969. calculate(...e) {
  22970. const t = Math.max(
  22971. ...e.map((n) => n.isArray() ? n.getColumnCount() : 1)
  22972. ), r = [];
  22973. for (let n = 0; n < e.length; n++) {
  22974. const s = e[n];
  22975. if (s.isError())
  22976. return s;
  22977. const o = s.isArray() ? s.getRowCount() : 1, u = s.isArray() ? s.getColumnCount() : 1;
  22978. for (let c = 0; c < o; c++) {
  22979. const l2 = [];
  22980. for (let f2 = 0; f2 < t; f2++) {
  22981. let h = s;
  22982. s.isArray() && (h = s.get(c, f2)), f2 > u - 1 || !h ? l2.push(g2.create(m2.NA)) : l2.push(h);
  22983. }
  22984. r.push(l2);
  22985. }
  22986. }
  22987. return q2.create({
  22988. calculateValueList: r,
  22989. rowCount: r.length,
  22990. columnCount: r[0].length || 0,
  22991. unitId: this.unitId,
  22992. sheetId: this.subUnitId,
  22993. row: this.row,
  22994. column: this.column
  22995. });
  22996. }
  22997. };
  22998. var zd = class extends V {
  22999. constructor() {
  23000. super(...arguments);
  23001. A(this, "minParams", 2);
  23002. A(this, "maxParams", 3);
  23003. }
  23004. calculate(e, t, r) {
  23005. let n = r != null ? r : g2.create(m2.NA);
  23006. n.isNull() && (n = g2.create(m2.NA));
  23007. const s = e.isArray() ? e.getRowCount() : 1, o = e.isArray() ? e.getColumnCount() : 1, u = Math.max(
  23008. t.isArray() ? t.getRowCount() : 1,
  23009. n.isArray() ? n.getRowCount() : 1
  23010. ), c = Math.max(
  23011. t.isArray() ? t.getColumnCount() : 1,
  23012. n.isArray() ? n.getColumnCount() : 1
  23013. ), l2 = O(u, c, t, g2.create(m2.NA)), f2 = O(u, c, n, g2.create(m2.NA)), h = l2.mapValue((d2, _, C) => {
  23014. const E2 = f2.get(_, C);
  23015. if (e.isError())
  23016. return e;
  23017. if (e.isNull())
  23018. return g2.create(m2.VALUE);
  23019. if (d2.isError())
  23020. return d2;
  23021. const b = Math.trunc(+d2.getValue());
  23022. if (s > 1 && o > 1 || Number.isNaN(b))
  23023. return g2.create(m2.VALUE);
  23024. if (b < 1)
  23025. return g2.create(m2.NUM);
  23026. const R = e.isArray() ? e.getArrayValue().flat() : [e], p2 = this._getWrapArray(R, b, E2);
  23027. return u > 1 || c > 1 || p2.length === 1 && p2[0].length === 1 ? p2[0][0] : q2.create({
  23028. calculateValueList: p2,
  23029. rowCount: p2.length,
  23030. columnCount: p2[0].length,
  23031. unitId: this.unitId,
  23032. sheetId: this.subUnitId,
  23033. row: this.row,
  23034. column: this.column
  23035. });
  23036. });
  23037. return u === 1 && c === 1 ? h.get(0, 0) : h;
  23038. }
  23039. _getWrapArray(e, t, r) {
  23040. const n = Math.ceil(e.length / t), s = n > 1 ? t : e.length, o = [];
  23041. for (let u = 0; u < n; u++)
  23042. for (let c = 0; c < s; c++) {
  23043. o[c] || (o[c] = []);
  23044. const l2 = u * s + c;
  23045. l2 < e.length ? o[c].push(e[l2].isNull() ? y2.create(0) : e[l2]) : o[c].push(r);
  23046. }
  23047. return o;
  23048. }
  23049. };
  23050. var Jd = class extends V {
  23051. constructor() {
  23052. super(...arguments);
  23053. A(this, "minParams", 2);
  23054. A(this, "maxParams", 3);
  23055. }
  23056. calculate(e, t, r) {
  23057. let n = r != null ? r : g2.create(m2.NA);
  23058. n.isNull() && (n = g2.create(m2.NA));
  23059. const s = e.isArray() ? e.getRowCount() : 1, o = e.isArray() ? e.getColumnCount() : 1, u = Math.max(
  23060. t.isArray() ? t.getRowCount() : 1,
  23061. n.isArray() ? n.getRowCount() : 1
  23062. ), c = Math.max(
  23063. t.isArray() ? t.getColumnCount() : 1,
  23064. n.isArray() ? n.getColumnCount() : 1
  23065. ), l2 = O(u, c, t, g2.create(m2.NA)), f2 = O(u, c, n, g2.create(m2.NA)), h = l2.mapValue((d2, _, C) => {
  23066. const E2 = f2.get(_, C);
  23067. if (e.isError())
  23068. return e;
  23069. if (e.isNull())
  23070. return g2.create(m2.VALUE);
  23071. if (d2.isError())
  23072. return d2;
  23073. const b = Math.trunc(+d2.getValue());
  23074. if (s > 1 && o > 1 || Number.isNaN(b))
  23075. return g2.create(m2.VALUE);
  23076. if (b < 1)
  23077. return g2.create(m2.NUM);
  23078. const R = e.isArray() ? e.getArrayValue().flat() : [e], p2 = this._getWrapArray(R, b, E2);
  23079. return u > 1 || c > 1 || p2.length === 1 && p2[0].length === 1 ? p2[0][0] : q2.create({
  23080. calculateValueList: p2,
  23081. rowCount: p2.length,
  23082. columnCount: p2[0].length,
  23083. unitId: this.unitId,
  23084. sheetId: this.subUnitId,
  23085. row: this.row,
  23086. column: this.column
  23087. });
  23088. });
  23089. return u === 1 && c === 1 ? h.get(0, 0) : h;
  23090. }
  23091. _getWrapArray(e, t, r) {
  23092. const n = Math.ceil(e.length / t), s = n > 1 ? t : e.length, o = [];
  23093. for (let u = 0; u < n; u++) {
  23094. const c = [];
  23095. for (let l2 = 0; l2 < s; l2++) {
  23096. const f2 = u * s + l2;
  23097. f2 < e.length ? c.push(e[f2].isNull() ? y2.create(0) : e[f2]) : c.push(r);
  23098. }
  23099. o.push(c);
  23100. }
  23101. return o;
  23102. }
  23103. };
  23104. var eC = class extends V {
  23105. constructor() {
  23106. super(...arguments);
  23107. A(this, "minParams", 3);
  23108. A(this, "maxParams", 6);
  23109. }
  23110. // eslint-disable-next-line
  23111. calculate(e, t, r, n, s, o) {
  23112. let u = n != null ? n : g2.create(m2.NA);
  23113. n != null && n.isNull() && (u = g2.create(m2.NA));
  23114. let c = s != null ? s : y2.create(0);
  23115. s != null && s.isNull() && (c = y2.create(0));
  23116. let l2 = o != null ? o : y2.create(1);
  23117. if (o != null && o.isNull() && (l2 = y2.create(1)), e.isError())
  23118. return e;
  23119. if (t.isError() || r.isError())
  23120. return g2.create(m2.REF);
  23121. if (!t.isArray() || !r.isArray())
  23122. return g2.create(m2.VALUE);
  23123. const f2 = t.getRowCount(), h = t.getColumnCount(), d2 = r.getRowCount(), _ = r.getColumnCount();
  23124. if (f2 !== 1 && h !== 1 || f2 === 1 && h > 1 && h !== _ || h === 1 && f2 > 1 && f2 !== d2)
  23125. return g2.create(m2.VALUE);
  23126. if (c.isError())
  23127. return c;
  23128. if (l2.isError())
  23129. return l2;
  23130. const C = this.getIndexNumValue(c);
  23131. if (C instanceof g2)
  23132. return C;
  23133. const E2 = this.getIndexNumValue(l2);
  23134. return E2 instanceof g2 ? E2 : this._getResult(
  23135. e,
  23136. t,
  23137. r,
  23138. u,
  23139. C,
  23140. E2,
  23141. f2,
  23142. h,
  23143. d2,
  23144. _
  23145. );
  23146. }
  23147. _getResult(e, t, r, n, s, o, u, c, l2, f2) {
  23148. const h = e.isArray() ? e.getRowCount() : 1, d2 = e.isArray() ? e.getColumnCount() : 1;
  23149. if (h > 1 || d2 > 1) {
  23150. let b;
  23151. return u === 1 ? b = r.slice([0, 1]) : b = r.slice(void 0, [0, 1]), b == null ? g2.create(m2.NA) : e.map((R) => {
  23152. const p2 = this._checkErrorCombination(s, o);
  23153. if (p2)
  23154. return p2;
  23155. const N2 = this._handleSingleObject(R, t, b, s, o);
  23156. return N2.isError() ? n : N2;
  23157. });
  23158. }
  23159. const _ = e.isArray() ? e.get(0, 0) : e;
  23160. if (c === f2 && u === l2) {
  23161. const b = this._checkErrorCombination(s, o);
  23162. if (b)
  23163. return b;
  23164. const R = this._handleSingleObject(_, t, r, s, o);
  23165. return R.isError() ? n : R;
  23166. }
  23167. let C = 0;
  23168. c === f2 && (C = 1);
  23169. const E2 = this._handleExpandObject(_, t, r, s, o, C);
  23170. return E2 == null ? g2.create(m2.NA) : E2;
  23171. }
  23172. _handleExpandObject(e, t, r, n, s, o = 0) {
  23173. if ((s === 2 || s === -2) && n !== 2) {
  23174. const u = Ps(s), c = Ss(n);
  23175. return this.binarySearchExpand(
  23176. e,
  23177. t,
  23178. r,
  23179. o,
  23180. u,
  23181. c
  23182. );
  23183. }
  23184. return n === 2 ? this.fuzzySearchExpand(e, t, r, s !== -1, o) : n === -1 || n === 1 ? this.orderSearchExpand(
  23185. e,
  23186. t,
  23187. r,
  23188. n === 1 ? Pe.MAX : Pe.MIN,
  23189. s === -1,
  23190. o
  23191. ) : this.equalSearchExpand(e, t, r, s !== -1, o);
  23192. }
  23193. _handleSingleObject(e, t, r, n, s) {
  23194. if ((s === 2 || s === -2) && n !== 2) {
  23195. const o = Ps(s), u = Ss(n);
  23196. return this.binarySearch(e, t, r, o, u);
  23197. }
  23198. return n === 2 ? this.fuzzySearch(e, t, r, s !== -1) : n === -1 || n === 1 ? this.orderSearch(
  23199. e,
  23200. t,
  23201. r,
  23202. n === 1 ? Pe.MAX : Pe.MIN,
  23203. s === -1
  23204. ) : this.equalSearch(e, t, r, s !== -1);
  23205. }
  23206. /**
  23207. * Wildcard matching and binary search cannot appear at the same time
  23208. * @param matchModeValue
  23209. * @param searchModeValue
  23210. * @returns
  23211. */
  23212. _checkErrorCombination(e, t) {
  23213. return e === 2 && (t === -2 || t === 2) ? g2.create(m2.VALUE) : null;
  23214. }
  23215. };
  23216. var tC = class extends V {
  23217. constructor() {
  23218. super(...arguments);
  23219. A(this, "minParams", 2);
  23220. A(this, "maxParams", 4);
  23221. }
  23222. calculate(e, t, r, n) {
  23223. if (e.isError())
  23224. return e;
  23225. if (t.isError())
  23226. return g2.create(m2.REF);
  23227. if (!t.isArray())
  23228. return g2.create(m2.VALUE);
  23229. const s = t.getRowCount(), o = t.getColumnCount();
  23230. if (s !== 1 && o !== 1)
  23231. return g2.create(m2.VALUE);
  23232. if (r != null && r.isError() || n != null && n.isError())
  23233. return g2.create(m2.NA);
  23234. const u = this.getIndexNumValue(r || y2.create(0));
  23235. if (u instanceof g2)
  23236. return u;
  23237. const c = this.getIndexNumValue(n || y2.create(1));
  23238. return c instanceof g2 ? c : e.isArray() ? e.map((l2) => this._handleSingleObject(
  23239. l2,
  23240. t,
  23241. u,
  23242. c
  23243. )) : this._handleSingleObject(
  23244. e,
  23245. t,
  23246. u,
  23247. c
  23248. );
  23249. }
  23250. _handleSingleObject(e, t, r, n) {
  23251. let s;
  23252. if ((n === 2 || n === -2) && r !== 2) {
  23253. const o = Ps(n), u = Ss(r);
  23254. s = t.binarySearch(e, o, u);
  23255. } else if (r === 2) {
  23256. const o = t.compare(e, $.EQUALS);
  23257. let u;
  23258. if (n !== -1 ? u = o.getFirstTruePosition() : u = o.getLastTruePosition(), u == null)
  23259. return g2.create(m2.NA);
  23260. s = t.getRowCount() === 1 ? u.column : u.row;
  23261. } else if (r === -1 || r === 1) {
  23262. const o = t.orderSearch(e, r === 1 ? Pe.MAX : Pe.MIN, n === -1);
  23263. if (o == null)
  23264. return g2.create(m2.NA);
  23265. if (o instanceof g2)
  23266. return o;
  23267. s = t.getRowCount() === 1 ? o.column : o.row;
  23268. } else {
  23269. const o = t.isEqual(e);
  23270. let u;
  23271. if (n !== -1 ? u = o.getFirstTruePosition() : u = o.getLastTruePosition(), u == null)
  23272. return g2.create(m2.NA);
  23273. s = t.getRowCount() === 1 ? u.column : u.row;
  23274. }
  23275. return s == null ? g2.create(m2.NA) : y2.create(s + 1);
  23276. }
  23277. };
  23278. var rC = [
  23279. [Rd, me2.ADDRESS],
  23280. [Vd, me2.AREAS],
  23281. [Nd, me2.CHOOSE],
  23282. [Od, me2.CHOOSECOLS],
  23283. [Md, me2.CHOOSEROWS],
  23284. [wd, me2.COLUMN],
  23285. [Dd, me2.COLUMNS],
  23286. [Sd, me2.DROP],
  23287. [Pd, me2.EXPAND],
  23288. [Ld, me2.FILTER],
  23289. [xd, me2.FORMULATEXT],
  23290. [jd, me2.HLOOKUP],
  23291. [Ud, me2.HSTACK],
  23292. [vd, me2.INDEX],
  23293. [Td, me2.INDIRECT],
  23294. [Bd, me2.LOOKUP],
  23295. [Id, me2.MATCH],
  23296. [Fd, me2.OFFSET],
  23297. [kd, me2.ROW],
  23298. [$d, me2.ROWS],
  23299. [Yd, me2.SORT],
  23300. [Hd, me2.SORTBY],
  23301. [Gd, me2.TAKE],
  23302. [Qd, me2.TOCOL],
  23303. [Wd, me2.TOROW],
  23304. [qd, me2.TRANSPOSE],
  23305. [Kd, me2.UNIQUE],
  23306. [Xd, me2.VLOOKUP],
  23307. [Zd, me2.VSTACK],
  23308. [zd, me2.WRAPCOLS],
  23309. [Jd, me2.WRAPROWS],
  23310. [eC, me2.XLOOKUP],
  23311. [tC, me2.XMATCH]
  23312. ];
  23313. var nC = class extends V {
  23314. constructor() {
  23315. super(...arguments);
  23316. A(this, "minParams", 1);
  23317. A(this, "maxParams", 1);
  23318. }
  23319. calculate(e) {
  23320. let t = e;
  23321. return t.isString() && (t = t.convertToNumberObjectValue()), t.isError() ? t : t.abs();
  23322. }
  23323. };
  23324. var sC = class extends V {
  23325. constructor() {
  23326. super(...arguments);
  23327. A(this, "minParams", 1);
  23328. A(this, "maxParams", 1);
  23329. }
  23330. calculate(e) {
  23331. let t = e;
  23332. return t.isString() && (t = t.convertToNumberObjectValue()), t.isError() ? t : t.acos();
  23333. }
  23334. };
  23335. var aC = class extends V {
  23336. constructor() {
  23337. super(...arguments);
  23338. A(this, "minParams", 1);
  23339. A(this, "maxParams", 1);
  23340. }
  23341. calculate(e) {
  23342. let t = e;
  23343. return t.isString() && (t = t.convertToNumberObjectValue()), t.isError() ? t : t.acosh();
  23344. }
  23345. };
  23346. var iC = class extends V {
  23347. constructor() {
  23348. super(...arguments);
  23349. A(this, "minParams", 1);
  23350. A(this, "maxParams", 1);
  23351. }
  23352. calculate(e) {
  23353. let t = e;
  23354. return t.isString() && (t = t.convertToNumberObjectValue()), t.isError() ? t : t.isArray() ? t.map((r) => r.isError() ? r : Si(r)) : Si(t);
  23355. }
  23356. };
  23357. function Si(i) {
  23358. let a2 = i.getValue();
  23359. if (i.isBoolean() && (a2 = a2 ? 1 : 0), !Number.isFinite(a2))
  23360. return g2.create(m2.VALUE);
  23361. a2 = Number(a2);
  23362. let e = Math.atan(1 / a2);
  23363. return a2 < 0 && (e += Math.PI), Number.isNaN(e) ? g2.create(m2.VALUE) : y2.create(e);
  23364. }
  23365. var oC = class extends V {
  23366. constructor() {
  23367. super(...arguments);
  23368. A(this, "minParams", 1);
  23369. A(this, "maxParams", 1);
  23370. }
  23371. calculate(e) {
  23372. let t = e;
  23373. return t.isString() && (t = t.convertToNumberObjectValue()), t.isError() ? t : t.isArray() ? t.map((r) => r.isError() ? r : Pi(r)) : Pi(t);
  23374. }
  23375. };
  23376. function Pi(i) {
  23377. let a2 = i.getValue();
  23378. if (i.isBoolean() && (a2 = a2 ? 1 : 0), !Number.isFinite(a2))
  23379. return g2.create(m2.VALUE);
  23380. if (a2 = Number(a2), Math.abs(a2) <= 1)
  23381. return g2.create(m2.NUM);
  23382. const e = 1 / 2 * Math.log((a2 + 1) / (a2 - 1));
  23383. return Number.isNaN(e) ? g2.create(m2.VALUE) : y2.create(e);
  23384. }
  23385. var uC = class extends V {
  23386. constructor() {
  23387. super(...arguments);
  23388. A(this, "minParams", 1);
  23389. A(this, "maxParams", 1);
  23390. }
  23391. calculate(e) {
  23392. if (e.isArray()) {
  23393. const t = e.mapValue((r) => this._handleSingleObject(r));
  23394. return t.getRowCount() === 1 && t.getColumnCount() === 1 ? t.get(0, 0) : t;
  23395. }
  23396. return this._handleSingleObject(e);
  23397. }
  23398. // eslint-disable-next-line
  23399. _handleSingleObject(e) {
  23400. if (e.isError())
  23401. return e;
  23402. if (e.isNull())
  23403. return y2.create(0);
  23404. if (e.isBoolean() || e.isNumber())
  23405. return g2.create(m2.VALUE);
  23406. let t = e.getValue().toLocaleString().toLocaleUpperCase();
  23407. if (t.length > 255)
  23408. return g2.create(m2.VALUE);
  23409. const r = t.startsWith("-");
  23410. r && (t = t.slice(1));
  23411. let n = 0;
  23412. for (let s = 0; s < t.length; s++) {
  23413. const o = Xr.get(t[s]) || 0, u = Xr.get(t[s + 1]) || 0, c = Xr.get(t[s + 2]) || 0, l2 = Xr.get(t[s + 3]) || 0;
  23414. if (!o || c >= u && c > o || o === u && o === c && o === l2 || o === u / 2)
  23415. return g2.create(m2.VALUE);
  23416. o < u ? n -= o : n += o;
  23417. }
  23418. return y2.create(r ? -n : n);
  23419. }
  23420. };
  23421. var cC = class extends V {
  23422. constructor() {
  23423. super(...arguments);
  23424. A(this, "minParams", 1);
  23425. A(this, "maxParams", 1);
  23426. }
  23427. calculate(e) {
  23428. let t = e;
  23429. return t.isString() && (t = t.convertToNumberObjectValue()), t.isError() ? t : t.asin();
  23430. }
  23431. };
  23432. var lC = class extends V {
  23433. constructor() {
  23434. super(...arguments);
  23435. A(this, "minParams", 1);
  23436. A(this, "maxParams", 1);
  23437. }
  23438. calculate(e) {
  23439. let t = e;
  23440. return t.isString() && (t = t.convertToNumberObjectValue()), t.isError() ? t : t.asinh();
  23441. }
  23442. };
  23443. var fC = class extends V {
  23444. constructor() {
  23445. super(...arguments);
  23446. A(this, "minParams", 1);
  23447. A(this, "maxParams", 1);
  23448. }
  23449. calculate(e) {
  23450. let t = e;
  23451. return t.isString() && (t = t.convertToNumberObjectValue()), t.isError() ? t : t.atan();
  23452. }
  23453. };
  23454. var hC = class extends V {
  23455. constructor() {
  23456. super(...arguments);
  23457. A(this, "minParams", 2);
  23458. A(this, "maxParams", 2);
  23459. }
  23460. calculate(e, t) {
  23461. let r = e, n = t;
  23462. return r.isString() && (r = r.convertToNumberObjectValue()), r.isError() ? r : (n.isString() && (n = n.convertToNumberObjectValue()), n.isError() ? n : n.atan2(r));
  23463. }
  23464. };
  23465. var mC = class extends V {
  23466. constructor() {
  23467. super(...arguments);
  23468. A(this, "minParams", 1);
  23469. A(this, "maxParams", 1);
  23470. }
  23471. calculate(e) {
  23472. let t = e;
  23473. return t.isString() && (t = t.convertToNumberObjectValue()), t.isError() ? t : t.atanh();
  23474. }
  23475. };
  23476. var gC = class extends V {
  23477. constructor() {
  23478. super(...arguments);
  23479. A(this, "minParams", 2);
  23480. A(this, "maxParams", 3);
  23481. }
  23482. calculate(e, t, r) {
  23483. const n = r != null ? r : y2.create(0);
  23484. if (e.isError())
  23485. return e;
  23486. if (t.isError())
  23487. return t;
  23488. if (n.isError())
  23489. return n;
  23490. const s = Math.max(
  23491. e.isArray() ? e.getRowCount() : 1,
  23492. t.isArray() ? t.getRowCount() : 1,
  23493. n.isArray() ? n.getRowCount() : 1
  23494. ), o = Math.max(
  23495. e.isArray() ? e.getColumnCount() : 1,
  23496. t.isArray() ? t.getColumnCount() : 1,
  23497. n.isArray() ? n.getColumnCount() : 1
  23498. ), u = O(s, o, e, g2.create(m2.NA)), c = O(s, o, t, g2.create(m2.NA)), l2 = O(s, o, n, g2.create(m2.NA)), f2 = u.map((h, d2, _) => {
  23499. const C = c.get(d2, _), E2 = l2.get(d2, _);
  23500. return this._handleSingleObject(h, C, E2);
  23501. });
  23502. return f2.getRowCount() === 1 && f2.getColumnCount() === 1 ? f2.getArrayValue()[0][0] : f2;
  23503. }
  23504. _handleSingleObject(e, t, r) {
  23505. let n = e;
  23506. if (n.isString() && (n = n.convertToNumberObjectValue()), n.isError())
  23507. return n;
  23508. let s = t;
  23509. if (s.isString() && (s = s.convertToNumberObjectValue()), s.isError())
  23510. return s;
  23511. let o = r;
  23512. if (o.isString() && (o = o.convertToNumberObjectValue()), o.isError())
  23513. return o;
  23514. const u = Math.floor(+n.getValue()), c = Math.floor(+s.getValue()), l2 = Math.floor(+o.getValue());
  23515. if (u < 0 || u >= 2 ** 53 || c < 2 || c > 36 || l2 < 0)
  23516. return g2.create(m2.NUM);
  23517. let f2 = u.toString(c);
  23518. return f2.length < l2 && (f2 = new Array(l2 - f2.length + 1).join("0") + f2), j.create(f2.toLocaleUpperCase());
  23519. }
  23520. };
  23521. var dC = class extends V {
  23522. constructor() {
  23523. super(...arguments);
  23524. A(this, "minParams", 2);
  23525. A(this, "maxParams", 2);
  23526. }
  23527. calculate(e, t) {
  23528. if (e.isError())
  23529. return e;
  23530. if (t.isError())
  23531. return t;
  23532. const r = Math.max(
  23533. e.isArray() ? e.getRowCount() : 1,
  23534. t.isArray() ? t.getRowCount() : 1
  23535. ), n = Math.max(
  23536. e.isArray() ? e.getColumnCount() : 1,
  23537. t.isArray() ? t.getColumnCount() : 1
  23538. ), s = O(r, n, e, g2.create(m2.NA)), o = O(r, n, t, g2.create(m2.NA)), u = s.map((c, l2, f2) => {
  23539. let h = c, d2 = o.get(l2, f2);
  23540. if (h.isString() && (h = h.convertToNumberObjectValue()), h.isError())
  23541. return h;
  23542. if (d2.isString() && (d2 = d2.convertToNumberObjectValue()), d2.isError())
  23543. return d2;
  23544. const _ = +h.getValue(), C = +d2.getValue();
  23545. if (_ > 0 && C < 0)
  23546. return g2.create(m2.NUM);
  23547. if (_ === 0 || C === 0)
  23548. return y2.create(0);
  23549. const E2 = Ye(_ / C, 0) * C;
  23550. return y2.create(E2);
  23551. });
  23552. return u.getRowCount() === 1 && u.getColumnCount() === 1 ? u.getArrayValue()[0][0] : u;
  23553. }
  23554. };
  23555. var CC = class extends V {
  23556. constructor() {
  23557. super(...arguments);
  23558. A(this, "minParams", 1);
  23559. A(this, "maxParams", 3);
  23560. }
  23561. calculate(e, t, r) {
  23562. const n = t != null ? t : y2.create(1), s = r != null ? r : y2.create(0);
  23563. if (e.isError())
  23564. return e;
  23565. if (n.isError())
  23566. return n;
  23567. if (s.isError())
  23568. return s;
  23569. const o = Math.max(
  23570. e.isArray() ? e.getRowCount() : 1,
  23571. n.isArray() ? n.getRowCount() : 1,
  23572. s.isArray() ? s.getRowCount() : 1
  23573. ), u = Math.max(
  23574. e.isArray() ? e.getColumnCount() : 1,
  23575. n.isArray() ? n.getColumnCount() : 1,
  23576. s.isArray() ? s.getColumnCount() : 1
  23577. ), c = O(o, u, e, g2.create(m2.NA)), l2 = O(o, u, n, g2.create(m2.NA)), f2 = O(o, u, s, g2.create(m2.NA)), h = c.map((d2, _, C) => {
  23578. let E2 = d2, b = l2.get(_, C), R = f2.get(_, C);
  23579. if (E2.isString() && (E2 = E2.convertToNumberObjectValue()), E2.isError())
  23580. return E2;
  23581. if (b.isString() && (b = b.convertToNumberObjectValue()), b.isError())
  23582. return b;
  23583. if (R.isString() && (R = R.convertToNumberObjectValue()), R.isError())
  23584. return R;
  23585. const p2 = +E2.getValue(), N2 = +b.getValue(), M2 = +R.getValue();
  23586. return p2 === 0 || N2 === 0 ? y2.create(0) : this._getResult(p2, N2, M2);
  23587. });
  23588. return o === 1 && u === 1 ? h.get(0, 0) : h;
  23589. }
  23590. _getResult(e, t, r) {
  23591. let n;
  23592. return e < 0 && r !== 0 ? n = (t < 0 ? Ye(Math.abs(e) / Math.abs(t), 0) : -Ye(Math.abs(e) / t, 0)) * t : n = (t < 0 ? -Ye(e / Math.abs(t), 0) : Ye(e / t, 0)) * t, y2.create(n);
  23593. }
  23594. };
  23595. var _C = class extends V {
  23596. constructor() {
  23597. super(...arguments);
  23598. A(this, "minParams", 1);
  23599. A(this, "maxParams", 2);
  23600. }
  23601. calculate(e, t) {
  23602. const r = t != null ? t : y2.create(1);
  23603. if (e.isError())
  23604. return e;
  23605. if (r.isError())
  23606. return r;
  23607. const n = Math.max(
  23608. e.isArray() ? e.getRowCount() : 1,
  23609. r.isArray() ? r.getRowCount() : 1
  23610. ), s = Math.max(
  23611. e.isArray() ? e.getColumnCount() : 1,
  23612. r.isArray() ? r.getColumnCount() : 1
  23613. ), o = O(n, s, e, g2.create(m2.NA)), u = O(n, s, r, g2.create(m2.NA)), c = o.map((l2, f2, h) => {
  23614. let d2 = u.get(f2, h), _ = l2;
  23615. if (_.isString() && (_ = _.convertToNumberObjectValue()), _.isError())
  23616. return _;
  23617. if (d2.isString() && (d2 = d2.convertToNumberObjectValue()), d2.isError())
  23618. return d2;
  23619. const C = +_.getValue(), E2 = +d2.getValue();
  23620. if (C === 0 || E2 === 0)
  23621. return y2.create(0);
  23622. const b = (E2 < 0 ? -Ye(C / Math.abs(E2), 0) : Ye(C / E2, 0)) * E2;
  23623. return y2.create(b);
  23624. });
  23625. return n === 1 && s === 1 ? c.get(0, 0) : c;
  23626. }
  23627. };
  23628. var AC2 = class extends V {
  23629. constructor() {
  23630. super(...arguments);
  23631. A(this, "minParams", 2);
  23632. A(this, "maxParams", 2);
  23633. }
  23634. calculate(e, t) {
  23635. const r = Math.max(
  23636. e.isArray() ? e.getRowCount() : 1,
  23637. t.isArray() ? t.getRowCount() : 1
  23638. ), n = Math.max(
  23639. e.isArray() ? e.getColumnCount() : 1,
  23640. t.isArray() ? t.getColumnCount() : 1
  23641. ), s = O(r, n, e, g2.create(m2.NA)), o = O(r, n, t, g2.create(m2.NA)), u = s.mapValue((c, l2, f2) => {
  23642. let h = c, d2 = o.get(l2, f2);
  23643. if (h.isString() && (h = h.convertToNumberObjectValue()), d2.isString() && (d2 = d2.convertToNumberObjectValue()), h.isError())
  23644. return h;
  23645. if (d2.isError())
  23646. return d2;
  23647. const _ = Math.floor(+h.getValue()), C = Math.floor(+d2.getValue());
  23648. if (_ < 0 || C < 0 || _ < C)
  23649. return g2.create(m2.NUM);
  23650. const E2 = zt(_, C);
  23651. return Number.isNaN(E2) || !Number.isFinite(E2) ? g2.create(m2.NUM) : y2.create(E2);
  23652. });
  23653. return r === 1 && n === 1 ? u.get(0, 0) : u;
  23654. }
  23655. };
  23656. var EC = class extends V {
  23657. constructor() {
  23658. super(...arguments);
  23659. A(this, "minParams", 2);
  23660. A(this, "maxParams", 2);
  23661. }
  23662. calculate(e, t) {
  23663. const r = Math.max(
  23664. e.isArray() ? e.getRowCount() : 1,
  23665. t.isArray() ? t.getRowCount() : 1
  23666. ), n = Math.max(
  23667. e.isArray() ? e.getColumnCount() : 1,
  23668. t.isArray() ? t.getColumnCount() : 1
  23669. ), s = O(r, n, e, g2.create(m2.NA)), o = O(r, n, t, g2.create(m2.NA)), u = s.mapValue((c, l2, f2) => {
  23670. let h = c, d2 = o.get(l2, f2);
  23671. if (h.isString() && (h = h.convertToNumberObjectValue()), d2.isString() && (d2 = d2.convertToNumberObjectValue()), h.isError())
  23672. return h;
  23673. if (d2.isError())
  23674. return d2;
  23675. const _ = Math.floor(+h.getValue()), C = Math.floor(+d2.getValue());
  23676. if (_ < 0 || C < 0 || _ === 0 && _ < C)
  23677. return g2.create(m2.NUM);
  23678. const E2 = zt(_ + C - 1, _ - 1);
  23679. return Number.isNaN(E2) || !Number.isFinite(E2) ? g2.create(m2.NUM) : y2.create(E2);
  23680. });
  23681. return r === 1 && n === 1 ? u.get(0, 0) : u;
  23682. }
  23683. };
  23684. var bC = class extends V {
  23685. constructor() {
  23686. super(...arguments);
  23687. A(this, "minParams", 1);
  23688. A(this, "maxParams", 1);
  23689. }
  23690. calculate(e) {
  23691. let t = e;
  23692. return t.isString() && (t = t.convertToNumberObjectValue()), t.isError() ? t : t.cos();
  23693. }
  23694. };
  23695. var yC2 = class extends V {
  23696. constructor() {
  23697. super(...arguments);
  23698. A(this, "minParams", 1);
  23699. A(this, "maxParams", 1);
  23700. }
  23701. calculate(e) {
  23702. let t = e;
  23703. return t.isString() && (t = t.convertToNumberObjectValue()), t.isError() ? t : t.cosh();
  23704. }
  23705. };
  23706. var RC = class extends V {
  23707. constructor() {
  23708. super(...arguments);
  23709. A(this, "minParams", 1);
  23710. A(this, "maxParams", 1);
  23711. }
  23712. calculate(e) {
  23713. return e.isArray() ? e.map((t) => this._handleSingleObject(t)) : this._handleSingleObject(e);
  23714. }
  23715. _handleSingleObject(e) {
  23716. let t = e;
  23717. if (t.isString() && (t = t.convertToNumberObjectValue()), t.isError())
  23718. return t;
  23719. const r = +t.getValue();
  23720. return Math.abs(r) >= 2 ** 27 ? g2.create(m2.NUM) : r === 0 ? g2.create(m2.DIV_BY_ZERO) : t.tan().getReciprocal();
  23721. }
  23722. };
  23723. var pC = class extends V {
  23724. constructor() {
  23725. super(...arguments);
  23726. A(this, "minParams", 1);
  23727. A(this, "maxParams", 1);
  23728. }
  23729. calculate(e) {
  23730. return e.isArray() ? e.map((t) => this._handleSingleObject(t)) : this._handleSingleObject(e);
  23731. }
  23732. _handleSingleObject(e) {
  23733. let t = e;
  23734. return t.isString() && (t = t.convertToNumberObjectValue()), t.isError() ? t : +t.getValue() === 0 ? g2.create(m2.DIV_BY_ZERO) : t.tanh().getReciprocal();
  23735. }
  23736. };
  23737. var VC = class extends V {
  23738. constructor() {
  23739. super(...arguments);
  23740. A(this, "minParams", 1);
  23741. A(this, "maxParams", 1);
  23742. }
  23743. calculate(e) {
  23744. return e.isArray() ? e.map((t) => this._handleSingleObject(t)) : this._handleSingleObject(e);
  23745. }
  23746. _handleSingleObject(e) {
  23747. let t = e;
  23748. if (t.isString() && (t = t.convertToNumberObjectValue()), t.isError())
  23749. return t;
  23750. const r = +t.getValue();
  23751. return Math.abs(r) >= 2 ** 27 ? g2.create(m2.NUM) : r === 0 ? g2.create(m2.DIV_BY_ZERO) : t.sin().getReciprocal();
  23752. }
  23753. };
  23754. var NC = class extends V {
  23755. constructor() {
  23756. super(...arguments);
  23757. A(this, "minParams", 1);
  23758. A(this, "maxParams", 1);
  23759. }
  23760. calculate(e) {
  23761. return e.isArray() ? e.map((t) => this._handleSingleObject(t)) : this._handleSingleObject(e);
  23762. }
  23763. _handleSingleObject(e) {
  23764. let t = e;
  23765. if (t.isString() && (t = t.convertToNumberObjectValue()), t.isError())
  23766. return t;
  23767. const r = +t.getValue();
  23768. return r === 0 ? g2.create(m2.DIV_BY_ZERO) : !Number.isNaN(r) && !Number.isFinite(Math.sinh(r)) ? y2.create(0) : t.sinh().getReciprocal();
  23769. }
  23770. };
  23771. var OC = class extends V {
  23772. constructor() {
  23773. super(...arguments);
  23774. A(this, "minParams", 2);
  23775. A(this, "maxParams", 2);
  23776. }
  23777. calculate(e, t) {
  23778. if (e.isError())
  23779. return e;
  23780. if (t.isError())
  23781. return t;
  23782. const r = Math.max(
  23783. e.isArray() ? e.getRowCount() : 1,
  23784. t.isArray() ? t.getRowCount() : 1
  23785. ), n = Math.max(
  23786. e.isArray() ? e.getColumnCount() : 1,
  23787. t.isArray() ? t.getColumnCount() : 1
  23788. ), s = O(r, n, e, g2.create(m2.NA)), o = O(r, n, t, g2.create(m2.NA)), u = s.map((c, l2, f2) => {
  23789. if (c.isError())
  23790. return c;
  23791. let h = o.get(l2, f2);
  23792. if (h.isString() && (h = h.convertToNumberObjectValue()), h.isError())
  23793. return h;
  23794. const d2 = `${c.getValue()}`, _ = Math.floor(+h.getValue());
  23795. if (DC(d2) && (+d2 < 0 || +d2 >= 2 ** 53 || !Number.isInteger(+d2)) || d2.toLocaleLowerCase() === "true" || d2.toLocaleLowerCase() === "false" || _ < 2 || _ > 36)
  23796. return g2.create(m2.NUM);
  23797. if (d2.replace(/\s/g, "") === "")
  23798. return y2.create(0);
  23799. if (!this._isValidCharForRadix(d2, _))
  23800. return g2.create(m2.NUM);
  23801. const C = Number.parseInt(d2, _);
  23802. return Number.isNaN(C) ? g2.create(m2.NUM) : y2.create(C);
  23803. });
  23804. return r === 1 && n === 1 ? u.get(0, 0) : u;
  23805. }
  23806. _isValidCharForRadix(e, t) {
  23807. for (const r of e) {
  23808. const n = r.toUpperCase().charCodeAt(0);
  23809. if (t <= 10 && !(n >= 48 && n < 48 + t) || t > 10 && !(n >= 48 && n < 58 || n >= 65 && n < 65 + t - 10))
  23810. return false;
  23811. }
  23812. return true;
  23813. }
  23814. };
  23815. var MC = class extends V {
  23816. constructor() {
  23817. super(...arguments);
  23818. A(this, "minParams", 1);
  23819. A(this, "maxParams", 1);
  23820. }
  23821. calculate(e) {
  23822. return e.isArray() ? e.map((t) => this._handleSingleObject(t)) : this._handleSingleObject(e);
  23823. }
  23824. _handleSingleObject(e) {
  23825. let t = e;
  23826. if (t.isString() && (t = t.convertToNumberObjectValue()), t.isError())
  23827. return t;
  23828. const r = +t.getValue();
  23829. if (!Number.isFinite(r))
  23830. return g2.create(m2.VALUE);
  23831. const n = r * (180 / Math.PI);
  23832. return Number.isNaN(n) ? g2.create(m2.VALUE) : y2.create(n);
  23833. }
  23834. };
  23835. var wC = class extends V {
  23836. constructor() {
  23837. super(...arguments);
  23838. A(this, "minParams", 1);
  23839. A(this, "maxParams", 1);
  23840. }
  23841. calculate(e) {
  23842. return e.isArray() ? e.map((t) => this._handleSingleObject(t)) : this._handleSingleObject(e);
  23843. }
  23844. _handleSingleObject(e) {
  23845. let t = e;
  23846. if (t.isString() && (t = t.convertToNumberObjectValue()), t.isError())
  23847. return t;
  23848. const r = +t.getValue();
  23849. if (!Number.isFinite(r))
  23850. return g2.create(m2.VALUE);
  23851. const n = (r < 0 ? -Ye(Math.abs(r) / 2, 0) : Ye(r / 2, 0)) * 2;
  23852. return Number.isNaN(n) ? g2.create(m2.VALUE) : n === 0 ? y2.create(0) : y2.create(n);
  23853. }
  23854. };
  23855. var DC2 = class extends V {
  23856. constructor() {
  23857. super(...arguments);
  23858. A(this, "minParams", 1);
  23859. A(this, "maxParams", 1);
  23860. }
  23861. calculate(e) {
  23862. let t = e;
  23863. return t.isString() && (t = t.convertToNumberObjectValue()), t.isError() ? t : t.exp();
  23864. }
  23865. };
  23866. var SC2 = class extends V {
  23867. constructor() {
  23868. super(...arguments);
  23869. A(this, "minParams", 1);
  23870. A(this, "maxParams", 1);
  23871. }
  23872. calculate(e) {
  23873. return e.isArray() ? e.mapValue((t) => this._handleSingleObject(t)) : this._handleSingleObject(e);
  23874. }
  23875. _handleSingleObject(e) {
  23876. let t = e;
  23877. if (t.isString() && (t = t.convertToNumberObjectValue()), t.isError())
  23878. return t;
  23879. const r = Math.floor(+t.getValue()), n = cr(r);
  23880. return Number.isNaN(n) || !Number.isFinite(n) ? g2.create(m2.NUM) : y2.create(n);
  23881. }
  23882. };
  23883. var PC = class extends V {
  23884. constructor() {
  23885. super(...arguments);
  23886. A(this, "minParams", 1);
  23887. A(this, "maxParams", 1);
  23888. }
  23889. calculate(e) {
  23890. let t = e;
  23891. if (e.isArray()) {
  23892. const r = e.getRowCount(), n = e.getColumnCount();
  23893. if (r > 1 || n > 1)
  23894. return g2.create(m2.VALUE);
  23895. t = e.get(0, 0);
  23896. }
  23897. return this._handleSingleObject(t);
  23898. }
  23899. _handleSingleObject(e) {
  23900. let t = e;
  23901. if (t.isString() && (t = t.convertToNumberObjectValue()), t.isError())
  23902. return t;
  23903. const r = Math.floor(+t.getValue()), n = cr(r, 2);
  23904. return Number.isNaN(n) || !Number.isFinite(n) ? g2.create(m2.NUM) : y2.create(n);
  23905. }
  23906. };
  23907. var LC = class extends V {
  23908. constructor() {
  23909. super(...arguments);
  23910. A(this, "minParams", 2);
  23911. A(this, "maxParams", 2);
  23912. }
  23913. calculate(e, t) {
  23914. if (e.isError())
  23915. return e;
  23916. if (t.isError())
  23917. return t;
  23918. const r = Math.max(
  23919. e.isArray() ? e.getRowCount() : 1,
  23920. t.isArray() ? t.getRowCount() : 1
  23921. ), n = Math.max(
  23922. e.isArray() ? e.getColumnCount() : 1,
  23923. t.isArray() ? t.getColumnCount() : 1
  23924. ), s = O(r, n, e, g2.create(m2.NA)), o = O(r, n, t, g2.create(m2.NA)), u = s.map((c, l2, f2) => {
  23925. let h = o.get(l2, f2), d2 = c;
  23926. if (d2.isString() && (d2 = d2.convertToNumberObjectValue()), d2.isError())
  23927. return d2;
  23928. if (h.isString() && (h = h.convertToNumberObjectValue()), h.isError())
  23929. return h;
  23930. const _ = +d2.getValue(), C = +h.getValue();
  23931. if (_ > 0 && C < 0)
  23932. return g2.create(m2.NUM);
  23933. if (_ === 0)
  23934. return y2.create(0);
  23935. if (C === 0)
  23936. return g2.create(m2.DIV_BY_ZERO);
  23937. const E2 = We(_ / C, 0) * C;
  23938. return y2.create(E2);
  23939. });
  23940. return r === 1 && n === 1 ? u.get(0, 0) : u;
  23941. }
  23942. };
  23943. var xC2 = class extends V {
  23944. constructor() {
  23945. super(...arguments);
  23946. A(this, "minParams", 1);
  23947. A(this, "maxParams", 3);
  23948. }
  23949. calculate(e, t, r) {
  23950. const n = t != null ? t : y2.create(1), s = r != null ? r : y2.create(0), o = Math.max(
  23951. e.isArray() ? e.getRowCount() : 1,
  23952. n.isArray() ? n.getRowCount() : 1,
  23953. s.isArray() ? s.getRowCount() : 1
  23954. ), u = Math.max(
  23955. e.isArray() ? e.getColumnCount() : 1,
  23956. n.isArray() ? n.getColumnCount() : 1,
  23957. s.isArray() ? s.getColumnCount() : 1
  23958. ), c = O(o, u, e, g2.create(m2.NA)), l2 = O(o, u, n, g2.create(m2.NA)), f2 = O(o, u, s, g2.create(m2.NA)), h = c.map((d2, _, C) => {
  23959. let E2 = d2, b = l2.get(_, C), R = f2.get(_, C);
  23960. if (E2.isString() && (E2 = E2.convertToNumberObjectValue()), E2.isError())
  23961. return E2;
  23962. if (b.isString() && (b = b.convertToNumberObjectValue()), b.isError())
  23963. return b;
  23964. if (R.isString() && (R = R.convertToNumberObjectValue()), R.isError())
  23965. return R;
  23966. const p2 = +E2.getValue(), N2 = +b.getValue(), M2 = +R.getValue();
  23967. if (p2 === 0 || N2 === 0)
  23968. return y2.create(0);
  23969. let w;
  23970. return p2 < 0 && M2 !== 0 ? w = (N2 < 0 ? We(Math.abs(p2) / Math.abs(N2), 0) : -We(Math.abs(p2) / N2, 0)) * N2 : w = (N2 < 0 ? -We(p2 / Math.abs(N2), 0) : We(p2 / N2, 0)) * N2, y2.create(w);
  23971. });
  23972. return o === 1 && u === 1 ? h.get(0, 0) : h;
  23973. }
  23974. };
  23975. var jC2 = class extends V {
  23976. constructor() {
  23977. super(...arguments);
  23978. A(this, "minParams", 1);
  23979. A(this, "maxParams", 2);
  23980. }
  23981. calculate(e, t) {
  23982. const r = t != null ? t : y2.create(1);
  23983. if (e.isError())
  23984. return e;
  23985. if (r.isError())
  23986. return r;
  23987. const n = Math.max(
  23988. e.isArray() ? e.getRowCount() : 1,
  23989. r.isArray() ? r.getRowCount() : 1
  23990. ), s = Math.max(
  23991. e.isArray() ? e.getColumnCount() : 1,
  23992. r.isArray() ? r.getColumnCount() : 1
  23993. ), o = O(n, s, e, g2.create(m2.NA)), u = O(n, s, r, g2.create(m2.NA)), c = o.map((l2, f2, h) => {
  23994. let d2 = u.get(f2, h), _ = l2;
  23995. if (_.isString() && (_ = _.convertToNumberObjectValue()), _.isError())
  23996. return _;
  23997. if (d2.isString() && (d2 = d2.convertToNumberObjectValue()), d2.isError())
  23998. return d2;
  23999. const C = +_.getValue(), E2 = +d2.getValue();
  24000. if (C === 0 || E2 === 0)
  24001. return y2.create(0);
  24002. const b = (E2 < 0 ? -We(C / Math.abs(E2), 0) : We(C / E2, 0)) * E2;
  24003. return y2.create(b);
  24004. });
  24005. return n === 1 && s === 1 ? c.get(0, 0) : c;
  24006. }
  24007. };
  24008. var UC = class extends V {
  24009. constructor() {
  24010. super(...arguments);
  24011. A(this, "minParams", 1);
  24012. A(this, "maxParams", 255);
  24013. }
  24014. calculate(...e) {
  24015. let t = 0;
  24016. for (let r = 0; r < e.length; r++) {
  24017. const n = e[r];
  24018. if (!n.isNull())
  24019. if (n.isArray()) {
  24020. let s = false, o = g2.create(m2.VALUE);
  24021. if (n.iterator((u) => {
  24022. if (u != null && u.isNull())
  24023. return true;
  24024. const { isError: c, errorObject: l2, number: f2 } = this._handleSingleObject(u);
  24025. if (c)
  24026. return s = true, o = l2, false;
  24027. t = qs(t, f2);
  24028. }), s)
  24029. return o;
  24030. } else {
  24031. const { isError: s, errorObject: o, number: u } = this._handleSingleObject(n);
  24032. if (s)
  24033. return o;
  24034. t = qs(t, u);
  24035. }
  24036. }
  24037. return y2.create(t);
  24038. }
  24039. _handleSingleObject(e) {
  24040. if (e.isBoolean())
  24041. return {
  24042. isError: true,
  24043. errorObject: g2.create(m2.VALUE),
  24044. number: null
  24045. };
  24046. let t = e;
  24047. if (e.isString() && (t = t.convertToNumberObjectValue()), t.isError())
  24048. return {
  24049. isError: true,
  24050. errorObject: t,
  24051. number: null
  24052. };
  24053. const r = Math.floor(+t.getValue());
  24054. return r < 0 || r >= 2 ** 53 ? {
  24055. isError: true,
  24056. errorObject: g2.create(m2.NUM),
  24057. number: null
  24058. } : {
  24059. isError: false,
  24060. errorObject: null,
  24061. number: r
  24062. };
  24063. }
  24064. };
  24065. var vC2 = class extends V {
  24066. constructor() {
  24067. super(...arguments);
  24068. A(this, "minParams", 1);
  24069. A(this, "maxParams", 1);
  24070. }
  24071. calculate(e) {
  24072. return e.isArray() ? e.mapValue((t) => this._handleSingleObject(t)) : this._handleSingleObject(e);
  24073. }
  24074. _handleSingleObject(e) {
  24075. let t = e;
  24076. if (t.isString() && (t = t.convertToNumberObjectValue()), t.isError())
  24077. return t;
  24078. const r = Math.floor(+t.getValue());
  24079. return y2.create(r);
  24080. }
  24081. };
  24082. var TC = class extends V {
  24083. constructor() {
  24084. super(...arguments);
  24085. A(this, "minParams", 1);
  24086. A(this, "maxParams", 255);
  24087. }
  24088. calculate(...e) {
  24089. let t = 1, r = true;
  24090. for (let n = 0; n < e.length; n++) {
  24091. const s = e[n];
  24092. if (!s.isNull())
  24093. if (s.isArray()) {
  24094. let o = false, u = g2.create(m2.VALUE);
  24095. if (s.iterator((c) => {
  24096. if (c != null && c.isNull())
  24097. return true;
  24098. const { isError: l2, errorObject: f2, number: h } = this._handleSingleObject(c);
  24099. if (l2)
  24100. return o = true, u = f2, false;
  24101. t = Mi(t, h), r = false;
  24102. }), o)
  24103. return u;
  24104. } else {
  24105. const { isError: o, errorObject: u, number: c } = this._handleSingleObject(s);
  24106. if (o)
  24107. return u;
  24108. t = Mi(t, c), r = false;
  24109. }
  24110. }
  24111. return r ? y2.create(0) : Number.isNaN(t) || !Number.isFinite(t) || t >= 2 ** 53 ? g2.create(m2.VALUE) : y2.create(t);
  24112. }
  24113. _handleSingleObject(e) {
  24114. if (e.isBoolean())
  24115. return {
  24116. isError: true,
  24117. errorObject: g2.create(m2.VALUE),
  24118. number: null
  24119. };
  24120. let t = e;
  24121. if (e.isString() && (t = t.convertToNumberObjectValue()), t.isError())
  24122. return {
  24123. isError: true,
  24124. errorObject: t,
  24125. number: null
  24126. };
  24127. const r = Math.floor(+t.getValue());
  24128. return r < 0 ? {
  24129. isError: true,
  24130. errorObject: g2.create(m2.NUM),
  24131. number: null
  24132. } : {
  24133. isError: false,
  24134. errorObject: null,
  24135. number: r
  24136. };
  24137. }
  24138. };
  24139. var BC = class extends V {
  24140. constructor() {
  24141. super(...arguments);
  24142. A(this, "minParams", 1);
  24143. A(this, "maxParams", 1);
  24144. }
  24145. calculate(e) {
  24146. let t = e;
  24147. return t.isString() && (t = t.convertToNumberObjectValue()), t.isError() ? t : t.log();
  24148. }
  24149. };
  24150. var IC = class extends V {
  24151. constructor() {
  24152. super(...arguments);
  24153. A(this, "minParams", 1);
  24154. A(this, "maxParams", 2);
  24155. }
  24156. calculate(e, t) {
  24157. const r = t != null ? t : y2.create(10);
  24158. if (e.isError())
  24159. return e;
  24160. if (r.isError())
  24161. return r;
  24162. const n = Math.max(
  24163. e.isArray() ? e.getRowCount() : 1,
  24164. r.isArray() ? r.getRowCount() : 1
  24165. ), s = Math.max(
  24166. e.isArray() ? e.getColumnCount() : 1,
  24167. r.isArray() ? r.getColumnCount() : 1
  24168. ), o = O(n, s, e, g2.create(m2.NA)), u = O(n, s, r, g2.create(m2.NA)), c = o.map((l2, f2, h) => {
  24169. let d2 = u.get(f2, h), _ = l2;
  24170. if (_.isString() && (_ = _.convertToNumberObjectValue()), _.isError())
  24171. return _;
  24172. if (d2.isString() && (d2 = d2.convertToNumberObjectValue()), d2.isError())
  24173. return d2;
  24174. const C = +_.getValue(), E2 = +d2.getValue();
  24175. if (C <= 0 || E2 <= 0)
  24176. return g2.create(m2.NUM);
  24177. const b = Math.log(E2);
  24178. if (b === 0)
  24179. return g2.create(m2.DIV_BY_ZERO);
  24180. const R = Math.log(C) / b;
  24181. return y2.create(R);
  24182. });
  24183. return n === 1 && s === 1 ? c.get(0, 0) : c;
  24184. }
  24185. };
  24186. var FC = class extends V {
  24187. constructor() {
  24188. super(...arguments);
  24189. A(this, "minParams", 1);
  24190. A(this, "maxParams", 1);
  24191. }
  24192. calculate(e) {
  24193. let t = e;
  24194. return t.isString() && (t = t.convertToNumberObjectValue()), t.isError() ? t : t.log10();
  24195. }
  24196. };
  24197. var kC = class extends V {
  24198. constructor() {
  24199. super(...arguments);
  24200. A(this, "minParams", 1);
  24201. A(this, "maxParams", 1);
  24202. }
  24203. calculate(e) {
  24204. const t = e.isArray() ? e.getRowCount() : 1, r = e.isArray() ? e.getColumnCount() : 1, n = [];
  24205. for (let o = 0; o < t; o++) {
  24206. const u = [];
  24207. for (let c = 0; c < r; c++) {
  24208. let l2 = e.isArray() ? e.get(o, c) : e;
  24209. if (l2.isError())
  24210. return l2;
  24211. if (l2.isNull() || l2.isBoolean())
  24212. return g2.create(m2.VALUE);
  24213. if (l2.isString() && (l2 = l2.convertToNumberObjectValue()), l2.isError())
  24214. return l2;
  24215. const f2 = +l2.getValue();
  24216. u.push(f2);
  24217. }
  24218. n.push(u);
  24219. }
  24220. if (t !== r)
  24221. return g2.create(m2.VALUE);
  24222. const s = Gn(n);
  24223. return y2.create(s);
  24224. }
  24225. };
  24226. var $C = class extends V {
  24227. constructor() {
  24228. super(...arguments);
  24229. A(this, "minParams", 1);
  24230. A(this, "maxParams", 1);
  24231. }
  24232. calculate(e) {
  24233. const t = e.isArray() ? e.getRowCount() : 1, r = e.isArray() ? e.getColumnCount() : 1, n = [];
  24234. for (let o = 0; o < t; o++) {
  24235. const u = [];
  24236. for (let c = 0; c < r; c++) {
  24237. let l2 = e.isArray() ? e.get(o, c) : e;
  24238. if (l2.isError())
  24239. return l2;
  24240. if (l2.isNull() || l2.isBoolean())
  24241. return g2.create(m2.VALUE);
  24242. if (l2.isString() && (l2 = l2.convertToNumberObjectValue()), l2.isError())
  24243. return l2;
  24244. const f2 = +l2.getValue();
  24245. u.push(f2);
  24246. }
  24247. n.push(u);
  24248. }
  24249. if (t !== r)
  24250. return g2.create(m2.VALUE);
  24251. const s = Gh(n);
  24252. return s === null ? g2.create(m2.NUM) : q2.createByArray(s);
  24253. }
  24254. };
  24255. var YC = class extends V {
  24256. constructor() {
  24257. super(...arguments);
  24258. A(this, "minParams", 2);
  24259. A(this, "maxParams", 2);
  24260. }
  24261. calculate(e, t) {
  24262. const r = e.isArray() ? e.getRowCount() : 1, n = e.isArray() ? e.getColumnCount() : 1, s = t.isArray() ? t.getRowCount() : 1, o = t.isArray() ? t.getColumnCount() : 1;
  24263. if (n !== s)
  24264. return g2.create(m2.VALUE);
  24265. const u = this._getMatrix(e, r, n), c = this._getMatrix(t, s, o);
  24266. if (u instanceof g2)
  24267. return u;
  24268. if (c instanceof g2)
  24269. return c;
  24270. const l2 = lr(u, c);
  24271. return q2.createByArray(l2);
  24272. }
  24273. _getMatrix(e, t, r) {
  24274. const n = [];
  24275. for (let s = 0; s < t; s++) {
  24276. const o = [];
  24277. for (let u = 0; u < r; u++) {
  24278. let c = e.isArray() ? e.get(s, u) : e;
  24279. if (c.isError())
  24280. return c;
  24281. if (c.isNull() || c.isBoolean())
  24282. return g2.create(m2.VALUE);
  24283. if (c.isString() && (c = c.convertToNumberObjectValue()), c.isError())
  24284. return c;
  24285. const l2 = +c.getValue();
  24286. o.push(l2);
  24287. }
  24288. n.push(o);
  24289. }
  24290. return n;
  24291. }
  24292. };
  24293. var HC = class extends V {
  24294. constructor() {
  24295. super(...arguments);
  24296. A(this, "minParams", 2);
  24297. A(this, "maxParams", 2);
  24298. }
  24299. calculate(e, t) {
  24300. let r = e;
  24301. if (r.isString() && (r = r.convertToNumberObjectValue()), r.isError())
  24302. return r;
  24303. let n = t;
  24304. return n.isString() && (n = n.convertToNumberObjectValue()), n.isError() ? n : r.mod(n);
  24305. }
  24306. };
  24307. var GC = class extends V {
  24308. constructor() {
  24309. super(...arguments);
  24310. A(this, "minParams", 2);
  24311. A(this, "maxParams", 2);
  24312. }
  24313. calculate(e, t) {
  24314. let r = e;
  24315. if (r.isArray()) {
  24316. const c = r.getRowCount(), l2 = r.getColumnCount();
  24317. if (c > 1 || l2 > 1)
  24318. return g2.create(m2.VALUE);
  24319. r = r.get(0, 0);
  24320. }
  24321. if (r.isError())
  24322. return r;
  24323. let n = t;
  24324. if (n.isArray()) {
  24325. const c = n.getRowCount(), l2 = n.getColumnCount();
  24326. if (c > 1 || l2 > 1)
  24327. return g2.create(m2.VALUE);
  24328. n = n.get(0, 0);
  24329. }
  24330. if (n.isError())
  24331. return n;
  24332. if (r.isBoolean() || n.isBoolean())
  24333. return g2.create(m2.VALUE);
  24334. const s = +r.getValue(), o = +n.getValue();
  24335. if (Number.isNaN(s) || Number.isNaN(o))
  24336. return g2.create(m2.VALUE);
  24337. if (o === 0)
  24338. return y2.create(0);
  24339. if (s > 0 && o < 0 || s < 0 && o > 0)
  24340. return g2.create(m2.NUM);
  24341. const u = vt(s / o, 0) * o;
  24342. return y2.create(u);
  24343. }
  24344. };
  24345. var QC = class extends V {
  24346. constructor() {
  24347. super(...arguments);
  24348. A(this, "minParams", 1);
  24349. A(this, "maxParams", 255);
  24350. }
  24351. calculate(...e) {
  24352. let t = 0, r = 1;
  24353. for (let s = 0; s < e.length; s++) {
  24354. const o = e[s];
  24355. if (!o.isNull())
  24356. if (o.isArray()) {
  24357. let u = false, c = g2.create(m2.VALUE);
  24358. if (o.iterator((l2) => {
  24359. if (l2 != null && l2.isNull())
  24360. return true;
  24361. const { isError: f2, errorObject: h, number: d2 } = this._handleSingleObject(l2);
  24362. if (f2)
  24363. return u = true, c = h, false;
  24364. if (t += d2, t > 170)
  24365. return u = true, c = g2.create(m2.NUM), false;
  24366. r *= cr(d2);
  24367. }), u)
  24368. return c;
  24369. } else {
  24370. const { isError: u, errorObject: c, number: l2 } = this._handleSingleObject(o);
  24371. if (u)
  24372. return c;
  24373. if (t += l2, t > 170)
  24374. return g2.create(m2.NUM);
  24375. r *= cr(l2);
  24376. }
  24377. }
  24378. const n = cr(t) / r;
  24379. return y2.create(n);
  24380. }
  24381. _handleSingleObject(e) {
  24382. if (e.isBoolean())
  24383. return {
  24384. isError: true,
  24385. errorObject: g2.create(m2.VALUE),
  24386. number: null
  24387. };
  24388. let t = e;
  24389. if (e.isString() && (t = t.convertToNumberObjectValue()), t.isError())
  24390. return {
  24391. isError: true,
  24392. errorObject: t,
  24393. number: null
  24394. };
  24395. const r = Math.floor(+t.getValue());
  24396. return r < 0 ? {
  24397. isError: true,
  24398. errorObject: g2.create(m2.NUM),
  24399. number: null
  24400. } : {
  24401. isError: false,
  24402. errorObject: null,
  24403. number: r
  24404. };
  24405. }
  24406. };
  24407. var WC = class extends V {
  24408. constructor() {
  24409. super(...arguments);
  24410. A(this, "minParams", 1);
  24411. A(this, "maxParams", 1);
  24412. }
  24413. calculate(e) {
  24414. if (e.isArray()) {
  24415. const t = e.getRowCount(), r = e.getColumnCount(), n = e.mapValue((s) => {
  24416. const o = this._handleSingleObject(s);
  24417. return o.isError() ? o : t > 1 || r > 1 ? o.get(0, 0) : o;
  24418. });
  24419. return t === 1 && r === 1 ? n.get(0, 0) : n;
  24420. }
  24421. return this._handleSingleObject(e);
  24422. }
  24423. _handleSingleObject(e) {
  24424. let t = e;
  24425. if (t.isString() && (t = t.convertToNumberObjectValue()), t.isError())
  24426. return t;
  24427. const r = Math.floor(+t.getValue());
  24428. if (r <= 0)
  24429. return g2.create(m2.VALUE);
  24430. const n = [];
  24431. for (let s = 0; s < r; s++) {
  24432. n[s] = [];
  24433. for (let o = 0; o < r; o++)
  24434. n[s][o] = s === o ? 1 : 0;
  24435. }
  24436. return q2.createByArray(n);
  24437. }
  24438. };
  24439. var qC = class extends V {
  24440. constructor() {
  24441. super(...arguments);
  24442. A(this, "minParams", 1);
  24443. A(this, "maxParams", 1);
  24444. }
  24445. calculate(e) {
  24446. return e.isArray() ? e.map((t) => this._handleSingleObject(t)) : this._handleSingleObject(e);
  24447. }
  24448. _handleSingleObject(e) {
  24449. let t = e;
  24450. if (t.isString() && (t = t.convertToNumberObjectValue()), t.isError())
  24451. return t;
  24452. const r = +t.getValue();
  24453. if (!Number.isFinite(r))
  24454. return g2.create(m2.VALUE);
  24455. let n = r < 0 ? -Ye(Math.abs(r), 0) : Ye(r, 0);
  24456. return Number.isNaN(n) ? g2.create(m2.VALUE) : (Math.abs(n) % 2 === 0 && (r < 0 ? n-- : n++), y2.create(n));
  24457. }
  24458. };
  24459. var KC2 = class extends V {
  24460. constructor() {
  24461. super(...arguments);
  24462. A(this, "minParams", 0);
  24463. A(this, "maxParams", 0);
  24464. }
  24465. calculate() {
  24466. return y2.create(Math.PI);
  24467. }
  24468. };
  24469. var XC = class extends V {
  24470. constructor() {
  24471. super(...arguments);
  24472. A(this, "minParams", 2);
  24473. A(this, "maxParams", 2);
  24474. }
  24475. calculate(e, t) {
  24476. let r = e;
  24477. if (r.isString() && (r = r.convertToNumberObjectValue()), r.isError())
  24478. return r;
  24479. let n = t;
  24480. return n.isString() && (n = n.convertToNumberObjectValue()), n.isError() ? n : r.pow(n);
  24481. }
  24482. };
  24483. var ZC = class extends V {
  24484. constructor() {
  24485. super(...arguments);
  24486. A(this, "minParams", 1);
  24487. A(this, "maxParams", 255);
  24488. }
  24489. calculate(...e) {
  24490. let t = y2.create(1), r = true;
  24491. for (let n = 0; n < e.length; n++) {
  24492. let s = e[n];
  24493. if (s.isError())
  24494. return s;
  24495. if (s.isArray()) {
  24496. let o = false, u = null;
  24497. if (s.iterator((c) => {
  24498. if (c != null && c.isError())
  24499. return o = true, u = c, false;
  24500. if (!c || c.isNull() || c.isString() || c.isBoolean())
  24501. return true;
  24502. t = t.multiply(c), r = false;
  24503. }), o)
  24504. return u;
  24505. } else {
  24506. if (s.isNull())
  24507. continue;
  24508. if (s.isString() && (s = s.convertToNumberObjectValue()), s.isError())
  24509. return s;
  24510. t = t.multiply(s), r = false;
  24511. }
  24512. if (t.isError())
  24513. return t;
  24514. }
  24515. return r ? y2.create(0) : t;
  24516. }
  24517. };
  24518. var zC = class extends V {
  24519. constructor() {
  24520. super(...arguments);
  24521. A(this, "minParams", 2);
  24522. A(this, "maxParams", 2);
  24523. }
  24524. calculate(e, t) {
  24525. const { isError: r, errorObject: n, variants: s } = H(e, t);
  24526. if (r)
  24527. return n;
  24528. const [o, u] = s, c = +o.getValue(), l2 = +u.getValue();
  24529. if (Number.isNaN(c) || Number.isNaN(l2))
  24530. return g2.create(m2.VALUE);
  24531. if (l2 === 0)
  24532. return g2.create(m2.DIV_BY_ZERO);
  24533. const f2 = Math.trunc(c / l2);
  24534. return y2.create(f2);
  24535. }
  24536. };
  24537. var JC = class extends V {
  24538. constructor() {
  24539. super(...arguments);
  24540. A(this, "minParams", 1);
  24541. A(this, "maxParams", 1);
  24542. }
  24543. calculate(e) {
  24544. return e.isArray() ? e.map((t) => this._handleSingleObject(t)) : this._handleSingleObject(e);
  24545. }
  24546. _handleSingleObject(e) {
  24547. let t = e;
  24548. if (t.isString() && (t = t.convertToNumberObjectValue()), t.isError())
  24549. return t;
  24550. const r = +t.getValue();
  24551. if (!Number.isFinite(r))
  24552. return g2.create(m2.VALUE);
  24553. const n = r * (Math.PI / 180);
  24554. return Number.isNaN(n) ? g2.create(m2.VALUE) : y2.create(n);
  24555. }
  24556. };
  24557. var e_ = class extends V {
  24558. constructor() {
  24559. super(...arguments);
  24560. A(this, "minParams", 0);
  24561. A(this, "maxParams", 0);
  24562. }
  24563. calculate() {
  24564. return y2.create(Math.random());
  24565. }
  24566. };
  24567. var t_ = class extends V {
  24568. constructor() {
  24569. super(...arguments);
  24570. A(this, "minParams", 0);
  24571. A(this, "maxParams", 5);
  24572. A(this, "needsSheetRowColumnCount", true);
  24573. }
  24574. calculate(e, t, r, n, s) {
  24575. if (e != null && e.isError())
  24576. return e;
  24577. if (t != null && t.isError())
  24578. return t;
  24579. if (r != null && r.isError())
  24580. return r;
  24581. if (n != null && n.isError())
  24582. return n;
  24583. if (s != null && s.isError())
  24584. return s;
  24585. const o = e != null ? e : y2.create(1), u = t != null ? t : y2.create(1), c = r != null ? r : y2.create(0), l2 = n != null ? n : y2.create(1), f2 = s != null ? s : y2.create(0);
  24586. return this._calculateResult(o, u, c, l2, f2);
  24587. }
  24588. _calculateResult(e, t, r, n, s) {
  24589. const o = Math.max(
  24590. e.isArray() ? e.getRowCount() : 1,
  24591. t.isArray() ? t.getRowCount() : 1,
  24592. r.isArray() ? r.getRowCount() : 1,
  24593. n.isArray() ? n.getRowCount() : 1,
  24594. s.isArray() ? s.getRowCount() : 1
  24595. ), u = Math.max(
  24596. e.isArray() ? e.getColumnCount() : 1,
  24597. t.isArray() ? t.getColumnCount() : 1,
  24598. r.isArray() ? r.getColumnCount() : 1,
  24599. n.isArray() ? n.getColumnCount() : 1,
  24600. s.isArray() ? s.getColumnCount() : 1
  24601. );
  24602. if (o === 1 && u === 1)
  24603. return this._calculateSingleCell(e, t, r, n, s);
  24604. const c = O(o, u, e, g2.create(m2.NA)), l2 = O(o, u, t, g2.create(m2.NA)), f2 = O(o, u, r, g2.create(m2.NA)), h = O(o, u, n, g2.create(m2.NA)), d2 = O(o, u, s, g2.create(m2.NA));
  24605. return c.map((_, C, E2) => {
  24606. const b = l2.get(C, E2), R = f2.get(C, E2), p2 = h.get(C, E2), N2 = d2.get(C, E2), M2 = this._handleError(_, b, R, p2, N2);
  24607. if (M2.errorObject)
  24608. return M2.errorObject;
  24609. let { minValue: w, maxValue: D2, wholeNumberValue: S2 } = M2, P;
  24610. return S2 ? (w = Math.ceil(w), D2 = Math.floor(D2), P = Math.floor(Math.random() * (D2 - w + 1)) + w) : P = Math.random() * (D2 - w) + w, P < w || P > D2 ? g2.create(m2.VALUE) : y2.create(P);
  24611. });
  24612. }
  24613. _calculateSingleCell(e, t, r, n, s) {
  24614. let o = e;
  24615. o.isArray() && (o = o.get(0, 0));
  24616. let u = t;
  24617. u.isArray() && (u = u.get(0, 0));
  24618. let c = r;
  24619. c.isArray() && (c = c.get(0, 0));
  24620. let l2 = n;
  24621. l2.isArray() && (l2 = l2.get(0, 0));
  24622. let f2 = s;
  24623. f2.isArray() && (f2 = f2.get(0, 0));
  24624. const h = this._handleError(o, u, c, l2, f2);
  24625. if (h.errorObject)
  24626. return h.errorObject;
  24627. let { rowsValue: d2, columnsValue: _, minValue: C, maxValue: E2, wholeNumberValue: b } = h;
  24628. if (b && (C = Math.ceil(C), E2 = Math.floor(E2), C > E2))
  24629. return g2.create(m2.VALUE);
  24630. const R = [];
  24631. for (let p2 = 0; p2 < d2; p2++) {
  24632. const N2 = [];
  24633. for (let M2 = 0; M2 < _; M2++)
  24634. b ? N2.push(Math.floor(Math.random() * (E2 - C + 1)) + C) : N2.push(Math.random() * (E2 - C) + C);
  24635. R.push(N2);
  24636. }
  24637. return d2 === 1 && _ === 1 ? y2.create(R[0][0]) : q2.createByArray(R);
  24638. }
  24639. _handleError(e, t, r, n, s) {
  24640. let o = e;
  24641. if (o.isString() && (o = o.convertToNumberObjectValue()), o.isError())
  24642. return {
  24643. errorObject: o
  24644. };
  24645. let u = t;
  24646. if (u.isString() && (u = u.convertToNumberObjectValue()), u.isError())
  24647. return {
  24648. errorObject: u
  24649. };
  24650. let c = r;
  24651. if (c.isString() && (c = c.convertToNumberObjectValue()), c.isError())
  24652. return {
  24653. errorObject: c
  24654. };
  24655. let l2 = n;
  24656. if (l2.isString() && (l2 = l2.convertToNumberObjectValue()), l2.isError())
  24657. return {
  24658. errorObject: l2
  24659. };
  24660. let f2 = s;
  24661. return f2.isString() && (f2 = f2.convertToNumberObjectValue()), f2.isError() ? {
  24662. errorObject: f2
  24663. } : this._getValue(o, u, c, l2, f2);
  24664. }
  24665. _getValue(e, t, r, n, s) {
  24666. const o = Math.floor(+e.getValue()), u = Math.floor(+t.getValue());
  24667. if (o === 0 || u === 0)
  24668. return {
  24669. errorObject: g2.create(m2.CALC)
  24670. };
  24671. const c = this._rowCount - this.row, l2 = this._columnCount - this.column;
  24672. if (o < 0 || u < 0 || o * u > 10 ** 7)
  24673. return {
  24674. errorObject: g2.create(m2.VALUE)
  24675. };
  24676. if (o > c || u > l2)
  24677. return {
  24678. errorObject: g2.create(m2.REF)
  24679. };
  24680. const f2 = +r.getValue(), h = +n.getValue(), d2 = +s.getValue();
  24681. return f2 > h ? {
  24682. errorObject: g2.create(m2.VALUE)
  24683. } : d2 && (!Number.isInteger(f2) || !Number.isInteger(h)) ? {
  24684. errorObject: g2.create(m2.VALUE)
  24685. } : {
  24686. rowsValue: o,
  24687. columnsValue: u,
  24688. minValue: f2,
  24689. maxValue: h,
  24690. wholeNumberValue: d2
  24691. };
  24692. }
  24693. };
  24694. var r_ = class extends V {
  24695. constructor() {
  24696. super(...arguments);
  24697. A(this, "minParams", 2);
  24698. A(this, "maxParams", 2);
  24699. }
  24700. calculate(e, t) {
  24701. let r = e;
  24702. if (r.isArray()) {
  24703. const c = r.getRowCount(), l2 = r.getColumnCount();
  24704. if (c > 1 || l2 > 1)
  24705. return g2.create(m2.VALUE);
  24706. r = r.get(0, 0);
  24707. }
  24708. if (r.isError())
  24709. return r;
  24710. let n = t;
  24711. if (n.isArray()) {
  24712. const c = n.getRowCount(), l2 = n.getColumnCount();
  24713. if (c > 1 || l2 > 1)
  24714. return g2.create(m2.VALUE);
  24715. n = n.get(0, 0);
  24716. }
  24717. if (n.isError())
  24718. return n;
  24719. if (r.isBoolean() || n.isBoolean())
  24720. return g2.create(m2.VALUE);
  24721. let s = +r.getValue(), o = +n.getValue();
  24722. if (Number.isNaN(s) || Number.isNaN(o))
  24723. return g2.create(m2.VALUE);
  24724. if (s > o)
  24725. return g2.create(m2.NUM);
  24726. s = Math.ceil(s), o = Math.floor(o);
  24727. const u = Math.floor(Math.random() * (o - s + 1)) + s;
  24728. return y2.create(u);
  24729. }
  24730. };
  24731. var n_ = class extends V {
  24732. constructor() {
  24733. super(...arguments);
  24734. A(this, "minParams", 1);
  24735. A(this, "maxParams", 2);
  24736. }
  24737. calculate(e, t) {
  24738. const r = t != null ? t : y2.create(0), n = Math.max(
  24739. e.isArray() ? e.getRowCount() : 1,
  24740. r.isArray() ? r.getRowCount() : 1
  24741. ), s = Math.max(
  24742. e.isArray() ? e.getColumnCount() : 1,
  24743. r.isArray() ? r.getColumnCount() : 1
  24744. ), o = O(n, s, e, g2.create(m2.NA)), u = O(n, s, r, g2.create(m2.NA)), c = o.mapValue((l2, f2, h) => {
  24745. const d2 = u.get(f2, h);
  24746. return l2.isError() ? l2 : d2.isError() ? d2 : this._handleSingleObject(l2, d2);
  24747. });
  24748. return n === 1 && s === 1 ? c.get(0, 0) : c;
  24749. }
  24750. _handleSingleObject(e, t) {
  24751. const { isError: r, errorObject: n, variants: s } = I2(e);
  24752. if (r)
  24753. return n;
  24754. const [o] = s;
  24755. let u = Math.floor(+o.getValue()), c = t;
  24756. if (c.isString() && (c = c.convertToNumberObjectValue(), c.isError()))
  24757. return c;
  24758. let l2 = Math.floor(+c.getValue());
  24759. if (c.isBoolean() && (l2 = c.getValue() ? 0 : 4), u < 0 || u > 3999 || l2 < 0 || l2 > 4)
  24760. return g2.create(m2.VALUE);
  24761. const f2 = Jh[l2];
  24762. let h = f2.length - 1, d2 = "";
  24763. for (; u > 0; ) {
  24764. h = this._binarySearch(u, 0, h, f2);
  24765. const _ = f2[h];
  24766. u -= _, d2 += zh.get(_);
  24767. }
  24768. return j.create(d2);
  24769. }
  24770. _binarySearch(e, t, r, n) {
  24771. let s = t, o = r;
  24772. for (; o - s > 1; ) {
  24773. const u = Math.floor((s + o) / 2), c = n[u];
  24774. if (c === e)
  24775. return u;
  24776. c > e ? o = u : s = u;
  24777. }
  24778. return s !== o && n[o] <= e ? o : s;
  24779. }
  24780. };
  24781. var s_ = class extends V {
  24782. constructor() {
  24783. super(...arguments);
  24784. A(this, "minParams", 2);
  24785. A(this, "maxParams", 2);
  24786. }
  24787. calculate(e, t) {
  24788. let r = e;
  24789. if (r.isString() && (r = r.convertToNumberObjectValue()), r.isError())
  24790. return r;
  24791. let n = t;
  24792. return n.isString() && (n = n.convertToNumberObjectValue()), n.isError() ? n : r.round(n);
  24793. }
  24794. };
  24795. var a_ = class extends V {
  24796. constructor() {
  24797. super(...arguments);
  24798. A(this, "minParams", 2);
  24799. A(this, "maxParams", 2);
  24800. }
  24801. calculate(e, t) {
  24802. const r = Math.max(
  24803. e.isArray() ? e.getRowCount() : 1,
  24804. t.isArray() ? t.getRowCount() : 1
  24805. ), n = Math.max(
  24806. e.isArray() ? e.getColumnCount() : 1,
  24807. t.isArray() ? t.getColumnCount() : 1
  24808. ), s = O(r, n, e, g2.create(m2.NA)), o = O(r, n, t, g2.create(m2.NA)), u = s.mapValue((c, l2, f2) => {
  24809. const h = o.get(l2, f2);
  24810. if (c.isError())
  24811. return c;
  24812. if (h.isError())
  24813. return h;
  24814. const { isError: d2, errorObject: _, variants: C } = I2(c, h);
  24815. if (d2)
  24816. return _;
  24817. const [E2, b] = C, R = +E2.getValue(), p2 = Math.trunc(+b.getValue()), N2 = this._roundBank(R, p2);
  24818. return y2.create(N2);
  24819. });
  24820. return r === 1 && n === 1 ? u.get(0, 0) : u;
  24821. }
  24822. _roundBank(e, t) {
  24823. if (t > 16)
  24824. return e;
  24825. if (t < -16)
  24826. return 0;
  24827. const r = 1e-8, n = 10 ** t, s = +(e * n).toFixed(8), o = Math.floor(s), u = s - o;
  24828. let c = Math.round(s);
  24829. return u > 0.5 - r && u < 0.5 + r && (c = o % 2 === 0 ? o : o + 1), t ? c / n : c;
  24830. }
  24831. };
  24832. var i_ = class extends V {
  24833. constructor() {
  24834. super(...arguments);
  24835. A(this, "minParams", 2);
  24836. A(this, "maxParams", 2);
  24837. }
  24838. calculate(e, t) {
  24839. let r = e;
  24840. if (r.isString() && (r = r.convertToNumberObjectValue()), r.isError())
  24841. return r;
  24842. let n = t;
  24843. return n.isString() && (n = n.convertToNumberObjectValue()), n.isError() ? n : r.floor(n);
  24844. }
  24845. };
  24846. var o_ = class extends V {
  24847. constructor() {
  24848. super(...arguments);
  24849. A(this, "minParams", 2);
  24850. A(this, "maxParams", 2);
  24851. }
  24852. calculate(e, t) {
  24853. let r = e;
  24854. if (r.isString() && (r = r.convertToNumberObjectValue()), r.isError())
  24855. return r;
  24856. let n = t;
  24857. return n.isString() && (n = n.convertToNumberObjectValue()), n.isError() ? n : r.ceil(n);
  24858. }
  24859. };
  24860. var u_ = class extends V {
  24861. constructor() {
  24862. super(...arguments);
  24863. A(this, "minParams", 1);
  24864. A(this, "maxParams", 1);
  24865. }
  24866. calculate(e) {
  24867. return e.isArray() ? e.map((t) => this._handleSingleObject(t)) : this._handleSingleObject(e);
  24868. }
  24869. _handleSingleObject(e) {
  24870. let t = e;
  24871. if (t.isString() && (t = t.convertToNumberObjectValue()), t.isError())
  24872. return t;
  24873. const r = +t.getValue();
  24874. return Math.abs(r) >= 2 ** 27 ? g2.create(m2.NUM) : t.cos().getReciprocal();
  24875. }
  24876. };
  24877. var c_ = class extends V {
  24878. constructor() {
  24879. super(...arguments);
  24880. A(this, "minParams", 1);
  24881. A(this, "maxParams", 1);
  24882. }
  24883. calculate(e) {
  24884. return e.isArray() ? e.map((t) => this._handleSingleObject(t)) : this._handleSingleObject(e);
  24885. }
  24886. _handleSingleObject(e) {
  24887. let t = e;
  24888. if (t.isString() && (t = t.convertToNumberObjectValue()), t.isError())
  24889. return t;
  24890. const r = +t.getValue();
  24891. return Number.isFinite(Math.cosh(r)) ? Math.abs(r) >= 2 ** 27 ? g2.create(m2.NUM) : t.cosh().getReciprocal() : y2.create(0);
  24892. }
  24893. };
  24894. var l_ = class extends V {
  24895. constructor() {
  24896. super(...arguments);
  24897. A(this, "minParams", 1);
  24898. A(this, "maxParams", 4);
  24899. A(this, "needsSheetRowColumnCount", true);
  24900. }
  24901. calculate(e, t, r, n) {
  24902. let s = e, o = t != null ? t : y2.create(1), u = r != null ? r : y2.create(1), c = n != null ? n : y2.create(1);
  24903. s.isNull() && (s = y2.create(1)), o.isNull() && (o = y2.create(1)), u.isNull() && (u = y2.create(1)), c.isNull() && (c = y2.create(1));
  24904. const l2 = Math.max(
  24905. s.isArray() ? s.getRowCount() : 1,
  24906. o.isArray() ? o.getRowCount() : 1,
  24907. u.isArray() ? u.getRowCount() : 1,
  24908. c.isArray() ? c.getRowCount() : 1
  24909. ), f2 = Math.max(
  24910. s.isArray() ? s.getColumnCount() : 1,
  24911. o.isArray() ? o.getColumnCount() : 1,
  24912. u.isArray() ? u.getColumnCount() : 1,
  24913. c.isArray() ? c.getColumnCount() : 1
  24914. ), h = O(l2, f2, s, g2.create(m2.NA)), d2 = O(l2, f2, o, g2.create(m2.NA)), _ = O(l2, f2, u, g2.create(m2.NA)), C = O(l2, f2, c, g2.create(m2.NA)), E2 = h.mapValue((b, R, p2) => {
  24915. const N2 = d2.get(R, p2), M2 = _.get(R, p2), w = C.get(R, p2);
  24916. return b.isError() ? b : N2.isError() ? N2 : M2.isError() ? M2 : w.isError() ? w : this._getResult(b, N2, M2, w, l2, f2);
  24917. });
  24918. return l2 === 1 && f2 === 1 ? E2.get(0, 0) : E2;
  24919. }
  24920. _getResult(e, t, r, n, s, o) {
  24921. const { isError: u, errorObject: c, variants: l2 } = I2(e, t, r, n);
  24922. if (u)
  24923. return c;
  24924. const [f2, h, d2, _] = l2, C = Math.floor(+f2.getValue()), E2 = Math.floor(+h.getValue()), b = +d2.getValue(), R = +_.getValue();
  24925. if (C < 0 || E2 < 0 || C * E2 > 10 ** 7)
  24926. return g2.create(m2.VALUE);
  24927. if (C === 0 || E2 === 0)
  24928. return g2.create(m2.CALC);
  24929. const p2 = this._rowCount - this.row, N2 = this._columnCount - this.column;
  24930. if (C > p2 || E2 > N2)
  24931. return g2.create(m2.REF);
  24932. const M2 = [];
  24933. for (let w = 0; w < C; w++) {
  24934. M2[w] = [];
  24935. for (let D2 = 0; D2 < E2; D2++)
  24936. M2[w][D2] = b + (w * E2 + D2) * R;
  24937. }
  24938. return s > 1 || o > 1 ? y2.create(M2[0][0]) : q2.createByArray(M2);
  24939. }
  24940. };
  24941. var f_ = class extends V {
  24942. constructor() {
  24943. super(...arguments);
  24944. A(this, "minParams", 4);
  24945. A(this, "maxParams", 4);
  24946. }
  24947. calculate(e, t, r, n) {
  24948. if (e.isNull() || t.isNull() || r.isNull() || n.isNull())
  24949. return g2.create(m2.NA);
  24950. const { isError: s, errorObject: o, variants: u } = H(e, t, r);
  24951. if (s)
  24952. return o;
  24953. const { isError: c, errorObject: l2, variants: f2 } = I2(...u);
  24954. if (c)
  24955. return l2;
  24956. const [h, d2, _] = f2, C = +h.getValue(), E2 = +d2.getValue(), b = +_.getValue(), R = [];
  24957. if (n.isArray()) {
  24958. let N2 = false, M2 = g2.create(m2.VALUE);
  24959. if (n.iterator((w) => {
  24960. const { isError: D2, errorObject: S2, coefficientsObject: P } = this._handleSingleObject(w);
  24961. if (D2)
  24962. return N2 = true, M2 = S2, false;
  24963. const U2 = +P.getValue();
  24964. R.push(U2);
  24965. }), N2)
  24966. return M2;
  24967. } else {
  24968. const { isError: N2, errorObject: M2, coefficientsObject: w } = this._handleSingleObject(n);
  24969. if (N2)
  24970. return M2;
  24971. const D2 = +w.getValue();
  24972. R.push(D2);
  24973. }
  24974. let p2 = 0;
  24975. for (let N2 = 0; N2 < R.length; N2++)
  24976. p2 += R[N2] * C ** (E2 + N2 * b);
  24977. return Number.isNaN(p2) || !Number.isFinite(p2) ? g2.create(m2.NUM) : y2.create(p2);
  24978. }
  24979. _handleSingleObject(e) {
  24980. if (e.isError())
  24981. return {
  24982. isError: true,
  24983. errorObject: e,
  24984. coefficientsObject: null
  24985. };
  24986. if (e != null && e.isBoolean())
  24987. return {
  24988. isError: true,
  24989. errorObject: g2.create(m2.VALUE),
  24990. coefficientsObject: null
  24991. };
  24992. let t = e;
  24993. return t.isString() && (t = t.convertToNumberObjectValue()), t.isError() ? {
  24994. isError: true,
  24995. errorObject: t,
  24996. coefficientsObject: null
  24997. } : {
  24998. isError: false,
  24999. errorObject: null,
  25000. coefficientsObject: t
  25001. };
  25002. }
  25003. };
  25004. var h_ = class extends V {
  25005. constructor() {
  25006. super(...arguments);
  25007. A(this, "minParams", 1);
  25008. A(this, "maxParams", 1);
  25009. }
  25010. calculate(e) {
  25011. if (e.isArray()) {
  25012. const t = e.mapValue((r) => this._handleSingleObject(r));
  25013. return t.getRowCount() === 1 && t.getColumnCount() === 1 ? t.get(0, 0) : t;
  25014. }
  25015. return this._handleSingleObject(e);
  25016. }
  25017. _handleSingleObject(e) {
  25018. if (e.isError())
  25019. return e;
  25020. const { isError: t, errorObject: r, variants: n } = I2(e);
  25021. if (t)
  25022. return r;
  25023. const [s] = n, o = +s.getValue();
  25024. return o > 0 ? y2.create(1) : o < 0 ? y2.create(-1) : y2.create(0);
  25025. }
  25026. };
  25027. var m_ = class extends V {
  25028. constructor() {
  25029. super(...arguments);
  25030. A(this, "minParams", 1);
  25031. A(this, "maxParams", 1);
  25032. }
  25033. calculate(e) {
  25034. let t = e;
  25035. return t.isString() && (t = t.convertToNumberObjectValue()), t.isError() ? t : t.sin();
  25036. }
  25037. };
  25038. var g_ = class extends V {
  25039. constructor() {
  25040. super(...arguments);
  25041. A(this, "minParams", 1);
  25042. A(this, "maxParams", 1);
  25043. }
  25044. calculate(e) {
  25045. let t = e;
  25046. return t.isString() && (t = t.convertToNumberObjectValue()), t.isError() ? t : t.sinh();
  25047. }
  25048. };
  25049. var d_ = class extends V {
  25050. constructor() {
  25051. super(...arguments);
  25052. A(this, "minParams", 1);
  25053. A(this, "maxParams", 1);
  25054. }
  25055. calculate(e) {
  25056. let t = e;
  25057. return t.isString() && (t = t.convertToNumberObjectValue()), t.isError() ? t : t.sqrt();
  25058. }
  25059. };
  25060. var C_ = class extends V {
  25061. constructor() {
  25062. super(...arguments);
  25063. A(this, "minParams", 1);
  25064. A(this, "maxParams", 1);
  25065. }
  25066. calculate(e) {
  25067. let t = e;
  25068. if (t.isArray()) {
  25069. const s = t.getRowCount(), o = t.getColumnCount();
  25070. if (s > 1 || o > 1)
  25071. return g2.create(m2.VALUE);
  25072. t = t.get(0, 0);
  25073. }
  25074. if (t.isString() && (t = t.convertToNumberObjectValue()), t.isError())
  25075. return t;
  25076. const r = +t.getValue();
  25077. if (r < 0)
  25078. return g2.create(m2.NUM);
  25079. const n = Math.sqrt(r * Math.PI);
  25080. return y2.create(n);
  25081. }
  25082. };
  25083. var __ = class extends V {
  25084. constructor() {
  25085. super(...arguments);
  25086. A(this, "minParams", 2);
  25087. A(this, "maxParams", 255);
  25088. A(this, "needsReferenceObject", true);
  25089. }
  25090. calculate(e, ...t) {
  25091. if (e.isError())
  25092. return e;
  25093. if (e.isReferenceObject()) {
  25094. const r = [];
  25095. return e.iterator((n, s, o) => {
  25096. r[s] == null && (r[s] = []), r[s][o] = this._handleSingleObject(
  25097. n,
  25098. ...t
  25099. );
  25100. }), tr(r, r.length, r[0].length);
  25101. }
  25102. return this._handleSingleObject(e, ...t);
  25103. }
  25104. // eslint-disable-next-line max-lines-per-function, complexity
  25105. _handleSingleObject(e, ...t) {
  25106. const r = this._getIndexNumValue(e);
  25107. let n;
  25108. if (r instanceof g2)
  25109. return r;
  25110. switch (r) {
  25111. case 1:
  25112. n = this._average(false, ...t);
  25113. break;
  25114. case 2:
  25115. n = this._count(false, ...t);
  25116. break;
  25117. case 3:
  25118. n = this._counta(false, ...t);
  25119. break;
  25120. case 4:
  25121. n = this._max(false, ...t);
  25122. break;
  25123. case 5:
  25124. n = this._min(false, ...t);
  25125. break;
  25126. case 6:
  25127. n = this._product(false, ...t);
  25128. break;
  25129. case 7:
  25130. n = this._stdev(false, ...t);
  25131. break;
  25132. case 8:
  25133. n = this._stdevp(false, ...t);
  25134. break;
  25135. case 9:
  25136. n = this._sum(false, ...t);
  25137. break;
  25138. case 10:
  25139. n = this._var(false, ...t);
  25140. break;
  25141. case 11:
  25142. n = this._varp(false, ...t);
  25143. break;
  25144. case 101:
  25145. n = this._average(true, ...t);
  25146. break;
  25147. case 102:
  25148. n = this._count(true, ...t);
  25149. break;
  25150. case 103:
  25151. n = this._counta(true, ...t);
  25152. break;
  25153. case 104:
  25154. n = this._max(true, ...t);
  25155. break;
  25156. case 105:
  25157. n = this._min(true, ...t);
  25158. break;
  25159. case 106:
  25160. n = this._product(true, ...t);
  25161. break;
  25162. case 107:
  25163. n = this._stdev(true, ...t);
  25164. break;
  25165. case 108:
  25166. n = this._stdevp(true, ...t);
  25167. break;
  25168. case 109:
  25169. n = this._sum(true, ...t);
  25170. break;
  25171. case 110:
  25172. n = this._var(true, ...t);
  25173. break;
  25174. case 111:
  25175. n = this._varp(true, ...t);
  25176. break;
  25177. default:
  25178. n = g2.create(m2.VALUE);
  25179. }
  25180. return n;
  25181. }
  25182. _getIndexNumValue(e) {
  25183. const t = e ? Number(e.getValue()) : 0;
  25184. if (Number.isNaN(t))
  25185. return g2.create(m2.VALUE);
  25186. const r = Math.floor(t);
  25187. return r >= 1 && r <= 11 || r >= 101 && r <= 111 ? r : g2.create(m2.VALUE);
  25188. }
  25189. _average(e, ...t) {
  25190. const r = this._flattenRefArray(e, ...t);
  25191. return r.isError() ? r : r.mean();
  25192. }
  25193. _count(e, ...t) {
  25194. let r = y2.create(0);
  25195. for (let n = 0; n < t.length; n++) {
  25196. const s = t[n];
  25197. if (!s.isReferenceObject())
  25198. return g2.create(m2.VALUE);
  25199. const o = s.getRowData();
  25200. s.iterator((u, c) => {
  25201. if (e && this._isRowHidden(o, c))
  25202. return true;
  25203. u != null && u.isNumber() && (r = r.plusBy(1));
  25204. });
  25205. }
  25206. return r;
  25207. }
  25208. _counta(e, ...t) {
  25209. let r = y2.create(0);
  25210. for (let n = 0; n < t.length; n++) {
  25211. const s = t[n];
  25212. if (!s.isReferenceObject())
  25213. return g2.create(m2.VALUE);
  25214. const o = s.getRowData();
  25215. s.iterator((u, c) => {
  25216. if (e && this._isRowHidden(o, c) || u == null || u.isNull())
  25217. return true;
  25218. r = r.plusBy(1);
  25219. });
  25220. }
  25221. return r;
  25222. }
  25223. _max(e, ...t) {
  25224. const r = this._flattenRefArray(e, ...t);
  25225. return r.isError() ? r : this._isBlankArrayObject(r) ? y2.create(0) : r.max();
  25226. }
  25227. _min(e, ...t) {
  25228. const r = this._flattenRefArray(e, ...t);
  25229. return r.isError() ? r : this._isBlankArrayObject(r) ? y2.create(0) : r.min();
  25230. }
  25231. _product(e, ...t) {
  25232. const r = this._flattenRefArray(e, ...t);
  25233. if (r.isError())
  25234. return r;
  25235. if (this._isBlankArrayObject(r))
  25236. return y2.create(0);
  25237. let n = y2.create(1);
  25238. return r.iterator((s) => {
  25239. n = n.multiply(
  25240. s
  25241. );
  25242. }), n;
  25243. }
  25244. _stdev(e, ...t) {
  25245. const r = this._flattenRefArray(e, ...t);
  25246. return r.isError() ? r : this._isBlankArrayObject(r) ? g2.create(m2.DIV_BY_ZERO) : r.std(1);
  25247. }
  25248. _stdevp(e, ...t) {
  25249. const r = this._flattenRefArray(e, ...t);
  25250. return r.isError() ? r : this._isBlankArrayObject(r) ? g2.create(m2.DIV_BY_ZERO) : r.std();
  25251. }
  25252. _sum(e, ...t) {
  25253. const r = this._flattenRefArray(e, ...t);
  25254. return r.isError() ? r : r.sum();
  25255. }
  25256. _var(e, ...t) {
  25257. const r = this._flattenRefArray(e, ...t);
  25258. return r.isError() ? r : this._isBlankArrayObject(r) ? g2.create(m2.DIV_BY_ZERO) : r.var(1);
  25259. }
  25260. _varp(e, ...t) {
  25261. const r = this._flattenRefArray(e, ...t);
  25262. return r.isError() ? r : this._isBlankArrayObject(r) ? g2.create(m2.DIV_BY_ZERO) : r.var();
  25263. }
  25264. _flattenRefArray(e, ...t) {
  25265. const r = [];
  25266. r[0] = [];
  25267. for (let n = 0; n < t.length; n++) {
  25268. const s = t[n];
  25269. if (s.isError())
  25270. return s;
  25271. if (!s.isReferenceObject())
  25272. return g2.create(m2.VALUE);
  25273. const o = s.getRowData();
  25274. let u;
  25275. if (s.iterator((c, l2) => {
  25276. if (e && this._isRowHidden(o, l2) || c == null || c.isNull() || c.isString() || c.isBoolean())
  25277. return true;
  25278. if (c.isError())
  25279. return u = c, false;
  25280. r[0].push(c);
  25281. }), u != null && u.isError())
  25282. return u;
  25283. }
  25284. return tr(r, 1, r[0].length);
  25285. }
  25286. _isRowHidden(e, t) {
  25287. const r = e[t];
  25288. return r ? r.hd === we.TRUE : false;
  25289. }
  25290. _isBlankArrayObject(e) {
  25291. return e.getArrayValue()[0].length === 0;
  25292. }
  25293. };
  25294. var A_ = class extends V {
  25295. constructor() {
  25296. super(...arguments);
  25297. A(this, "minParams", 1);
  25298. A(this, "maxParams", 255);
  25299. }
  25300. calculate(...e) {
  25301. let t = y2.create(0);
  25302. for (let r = 0; r < e.length; r++) {
  25303. let n = e[r];
  25304. if (n.isString() && (n = n.convertToNumberObjectValue()), n.isError() || (n.isArray() && (n = n.sum()), n.isError()))
  25305. return n;
  25306. if (t = t.plus(n), t.isError())
  25307. return t;
  25308. }
  25309. return t;
  25310. }
  25311. };
  25312. var E_ = class extends V {
  25313. constructor() {
  25314. super(...arguments);
  25315. A(this, "minParams", 2);
  25316. A(this, "maxParams", 3);
  25317. A(this, "needsReferenceObject", true);
  25318. }
  25319. calculate(e, t, r) {
  25320. let n = t;
  25321. if (t.isReferenceObject() && (n = t.toArrayValueObject()), n.isArray()) {
  25322. const s = n.mapValue((o) => this._handleSingleObject(e, o, r));
  25323. return s.getRowCount() === 1 && s.getColumnCount() === 1 ? s.get(0, 0) : s;
  25324. }
  25325. return this._handleSingleObject(e, n, r);
  25326. }
  25327. _handleSingleObject(e, t, r) {
  25328. if (e.isError())
  25329. return e;
  25330. if (t.isError())
  25331. return t;
  25332. if (r != null && r.isError())
  25333. return r;
  25334. if (!e.isReferenceObject() || r && !r.isReferenceObject())
  25335. return g2.create(m2.VALUE);
  25336. const n = e.toArrayValueObject();
  25337. let s = $n(n, t);
  25338. s = Yn(s, n, t);
  25339. const o = n.getRowCount(), u = n.getColumnCount();
  25340. let c = n;
  25341. if (r) {
  25342. c = r.toArrayValueObject();
  25343. const l2 = c.getRowCount(), f2 = c.getColumnCount();
  25344. if (o !== l2 || u !== f2) {
  25345. const h = r.getRangeData();
  25346. h.endRow = h.startRow + o - 1, h.endColumn = h.startColumn + u - 1, r.setRangeData(h), c = r.toArrayValueObject();
  25347. }
  25348. }
  25349. return c.pick(s).sum();
  25350. }
  25351. };
  25352. var b_ = class extends V {
  25353. constructor() {
  25354. super(...arguments);
  25355. A(this, "minParams", 3);
  25356. A(this, "maxParams", 255);
  25357. }
  25358. calculate(e, ...t) {
  25359. if (e.isError())
  25360. return e;
  25361. if (!e.isArray() || t.length < 2 || t.length % 2 !== 0 || t.some((u, c) => c % 2 === 0 && !u.isArray()))
  25362. return g2.create(m2.VALUE);
  25363. const { maxRowLength: r, maxColumnLength: n } = Nr(t), s = Br(t, e, r, n);
  25364. if (s)
  25365. return s;
  25366. const o = Ir(t, r, n, true);
  25367. return this._aggregateResults(e, o);
  25368. }
  25369. _aggregateResults(e, t) {
  25370. const r = t.map((s) => s.map((o) => e.pick(o).sum())), n = {
  25371. calculateValueList: r,
  25372. rowCount: r.length,
  25373. columnCount: r[0].length,
  25374. unitId: this.unitId || "",
  25375. sheetId: this.subUnitId || "",
  25376. row: this.row,
  25377. column: this.column
  25378. };
  25379. return q2.create(n);
  25380. }
  25381. };
  25382. var y_ = class extends V {
  25383. constructor() {
  25384. super(...arguments);
  25385. A(this, "minParams", 1);
  25386. A(this, "maxParams", 255);
  25387. }
  25388. calculate(e, ...t) {
  25389. if (e.isError())
  25390. return e;
  25391. const r = this._initArray1(e);
  25392. if (t.length > 0) {
  25393. const n = r.getRowCount(), s = r.getColumnCount();
  25394. let o = this._getResultArrayByArray1(n, s, r);
  25395. if (o instanceof g2)
  25396. return o;
  25397. o = o;
  25398. for (let c = 0; c < t.length; c++) {
  25399. if (t[c].isError())
  25400. return t[c];
  25401. let l2 = 1, f2 = 1;
  25402. if (t[c].isArray() && (l2 = t[c].getRowCount(), f2 = t[c].getColumnCount()), l2 !== n || f2 !== s)
  25403. return g2.create(m2.VALUE);
  25404. for (let h = 0; h < n; h++) {
  25405. const d2 = [];
  25406. for (let _ = 0; _ < s; _++) {
  25407. let C = t[c];
  25408. if (t[c].isArray() && (C = t[c].get(h, _)), C.isError())
  25409. return C;
  25410. const E2 = C.getValue();
  25411. !E2 || !DC(E2) ? d2.push(0) : d2.push(+E2 * o[h][_]);
  25412. }
  25413. o[h] = d2;
  25414. }
  25415. }
  25416. const u = o.reduce((c, l2) => c.concat(l2)).reduce((c, l2) => c + l2, 0);
  25417. return y2.create(u);
  25418. } else
  25419. return r.sum();
  25420. }
  25421. _initArray1(e) {
  25422. let t = e;
  25423. return t.isArray() || (t = q2.create({
  25424. calculateValueList: [[t]],
  25425. rowCount: 1,
  25426. columnCount: 1,
  25427. unitId: "",
  25428. sheetId: "",
  25429. row: 0,
  25430. column: 0
  25431. })), t;
  25432. }
  25433. _getResultArrayByArray1(e, t, r) {
  25434. const n = [];
  25435. for (let s = 0; s < e; s++) {
  25436. const o = [];
  25437. for (let u = 0; u < t; u++) {
  25438. const c = r.get(s, u);
  25439. if (c.isError())
  25440. return c;
  25441. const l2 = c.getValue();
  25442. !l2 || !DC(l2) ? o.push(0) : o.push(+l2);
  25443. }
  25444. n.push(o);
  25445. }
  25446. return n;
  25447. }
  25448. };
  25449. var R_ = class extends V {
  25450. constructor() {
  25451. super(...arguments);
  25452. A(this, "minParams", 1);
  25453. A(this, "maxParams", 255);
  25454. }
  25455. calculate(...e) {
  25456. let t = y2.create(0);
  25457. const r = y2.create(2);
  25458. for (let n = 0; n < e.length; n++) {
  25459. let s = e[n];
  25460. if (s.isString() && (s = s.convertToNumberObjectValue()), s.isError())
  25461. return s;
  25462. if (s.isArray() ? s.iterator((o) => {
  25463. if (o == null || o.isString() || o.isBoolean() || o.isNull())
  25464. return true;
  25465. if (o.isError())
  25466. return t = o, false;
  25467. t = t.plus(
  25468. o.pow(r)
  25469. );
  25470. }) : t = t.plus(s.pow(r)), t.isError())
  25471. return t;
  25472. }
  25473. return t;
  25474. }
  25475. };
  25476. var p_ = class extends V {
  25477. constructor() {
  25478. super(...arguments);
  25479. A(this, "minParams", 2);
  25480. A(this, "maxParams", 2);
  25481. }
  25482. calculate(e, t) {
  25483. if (e.isError())
  25484. return e;
  25485. if (t.isError())
  25486. return t;
  25487. const r = e.isArray() ? e.getRowCount() : 1, n = e.isArray() ? e.getColumnCount() : 1, s = r * n, o = t.isArray() ? t.getRowCount() : 1, u = t.isArray() ? t.getColumnCount() : 1, c = o * u;
  25488. if (s !== c)
  25489. return g2.create(m2.NA);
  25490. if (s === 1)
  25491. return this._calculateSingleCell(e, t);
  25492. {
  25493. const l2 = e.flatten(), f2 = t.flatten();
  25494. let h = ie.create();
  25495. const d2 = [], _ = [];
  25496. let C = 0;
  25497. return l2.iterator((E2, b, R) => {
  25498. const p2 = f2.get(b, R);
  25499. if (E2 == null || E2.isString() || E2.isBoolean() || E2.isNull())
  25500. return true;
  25501. if (E2 != null && E2.isError())
  25502. return h = E2, false;
  25503. if (p2 == null || p2.isString() || p2.isBoolean() || p2.isNull())
  25504. return true;
  25505. if (p2 != null && p2.isError())
  25506. return h = p2, false;
  25507. const N2 = +E2.getValue(), M2 = +p2.getValue();
  25508. d2.push(N2), _.push(M2), C += N2 ** 2 - M2 ** 2;
  25509. }), h.isError() ? h : d2.length === 0 || _.length === 0 ? g2.create(m2.DIV_BY_ZERO) : y2.create(C);
  25510. }
  25511. }
  25512. _calculateSingleCell(e, t) {
  25513. let r = e;
  25514. if (r.isArray() && (r = r.get(0, 0)), r.isError())
  25515. return r;
  25516. let n = t;
  25517. if (n.isArray() && (n = n.get(0, 0)), n.isError())
  25518. return n;
  25519. if (r.isNull() || n.isNull())
  25520. return g2.create(m2.VALUE);
  25521. const s = +r.getValue(), o = +n.getValue();
  25522. if (r.isString() && !DC(s) || r.isBoolean() || n.isString() && !DC(o) || n.isBoolean())
  25523. return g2.create(m2.DIV_BY_ZERO);
  25524. const u = s ** 2 - o ** 2;
  25525. return y2.create(u);
  25526. }
  25527. };
  25528. var V_ = class extends V {
  25529. constructor() {
  25530. super(...arguments);
  25531. A(this, "minParams", 2);
  25532. A(this, "maxParams", 2);
  25533. }
  25534. calculate(e, t) {
  25535. if (e.isError())
  25536. return e;
  25537. if (t.isError())
  25538. return t;
  25539. const r = e.isArray() ? e.getRowCount() : 1, n = e.isArray() ? e.getColumnCount() : 1, s = r * n, o = t.isArray() ? t.getRowCount() : 1, u = t.isArray() ? t.getColumnCount() : 1, c = o * u;
  25540. if (s !== c)
  25541. return g2.create(m2.NA);
  25542. if (s === 1)
  25543. return this._calculateSingleCell(e, t);
  25544. {
  25545. const l2 = e.flatten(), f2 = t.flatten();
  25546. let h = ie.create();
  25547. const d2 = [], _ = [];
  25548. let C = 0;
  25549. return l2.iterator((E2, b, R) => {
  25550. const p2 = f2.get(b, R);
  25551. if (E2 == null || E2.isString() || E2.isBoolean() || E2.isNull())
  25552. return true;
  25553. if (E2 != null && E2.isError())
  25554. return h = E2, false;
  25555. if (p2 == null || p2.isString() || p2.isBoolean() || p2.isNull())
  25556. return true;
  25557. if (p2 != null && p2.isError())
  25558. return h = p2, false;
  25559. const N2 = +E2.getValue(), M2 = +p2.getValue();
  25560. d2.push(N2), _.push(M2), C += N2 ** 2 + M2 ** 2;
  25561. }), h.isError() ? h : d2.length === 0 || _.length === 0 ? g2.create(m2.DIV_BY_ZERO) : y2.create(C);
  25562. }
  25563. }
  25564. _calculateSingleCell(e, t) {
  25565. let r = e;
  25566. if (r.isArray() && (r = r.get(0, 0)), r.isError())
  25567. return r;
  25568. let n = t;
  25569. if (n.isArray() && (n = n.get(0, 0)), n.isError())
  25570. return n;
  25571. if (r.isNull() || n.isNull())
  25572. return g2.create(m2.VALUE);
  25573. const s = +r.getValue(), o = +n.getValue();
  25574. if (r.isString() && !DC(s) || r.isBoolean() || n.isString() && !DC(o) || n.isBoolean())
  25575. return g2.create(m2.DIV_BY_ZERO);
  25576. const u = s ** 2 + o ** 2;
  25577. return y2.create(u);
  25578. }
  25579. };
  25580. var N_ = class extends V {
  25581. constructor() {
  25582. super(...arguments);
  25583. A(this, "minParams", 2);
  25584. A(this, "maxParams", 2);
  25585. }
  25586. calculate(e, t) {
  25587. if (e.isError())
  25588. return e;
  25589. if (t.isError())
  25590. return t;
  25591. const r = e.isArray() ? e.getRowCount() : 1, n = e.isArray() ? e.getColumnCount() : 1, s = r * n, o = t.isArray() ? t.getRowCount() : 1, u = t.isArray() ? t.getColumnCount() : 1, c = o * u;
  25592. if (s !== c)
  25593. return g2.create(m2.NA);
  25594. if (s === 1)
  25595. return this._calculateSingleCell(e, t);
  25596. {
  25597. const l2 = e.flatten(), f2 = t.flatten();
  25598. let h = ie.create();
  25599. const d2 = [], _ = [];
  25600. let C = 0;
  25601. return l2.iterator((E2, b, R) => {
  25602. const p2 = f2.get(b, R);
  25603. if (E2 == null || E2.isString() || E2.isBoolean() || E2.isNull())
  25604. return true;
  25605. if (E2 != null && E2.isError())
  25606. return h = E2, false;
  25607. if (p2 == null || p2.isString() || p2.isBoolean() || p2.isNull())
  25608. return true;
  25609. if (p2 != null && p2.isError())
  25610. return h = p2, false;
  25611. const N2 = +E2.getValue(), M2 = +p2.getValue();
  25612. d2.push(N2), _.push(M2), C += (N2 - M2) ** 2;
  25613. }), h.isError() ? h : d2.length === 0 || _.length === 0 ? g2.create(m2.DIV_BY_ZERO) : y2.create(C);
  25614. }
  25615. }
  25616. _calculateSingleCell(e, t) {
  25617. let r = e;
  25618. if (r.isArray() && (r = r.get(0, 0)), r.isError())
  25619. return r;
  25620. let n = t;
  25621. if (n.isArray() && (n = n.get(0, 0)), n.isError())
  25622. return n;
  25623. if (r.isNull() || n.isNull())
  25624. return g2.create(m2.VALUE);
  25625. const s = +r.getValue(), o = +n.getValue();
  25626. if (r.isString() && !DC(s) || r.isBoolean() || n.isString() && !DC(o) || n.isBoolean())
  25627. return g2.create(m2.DIV_BY_ZERO);
  25628. const u = (s - o) ** 2;
  25629. return y2.create(u);
  25630. }
  25631. };
  25632. var O_ = class extends V {
  25633. constructor() {
  25634. super(...arguments);
  25635. A(this, "minParams", 1);
  25636. A(this, "maxParams", 1);
  25637. }
  25638. calculate(e) {
  25639. let t = e;
  25640. return t.isString() && (t = t.convertToNumberObjectValue()), t.isError() ? t : t.tan();
  25641. }
  25642. };
  25643. var M_ = class extends V {
  25644. constructor() {
  25645. super(...arguments);
  25646. A(this, "minParams", 1);
  25647. A(this, "maxParams", 1);
  25648. }
  25649. calculate(e) {
  25650. let t = e;
  25651. return t.isString() && (t = t.convertToNumberObjectValue()), t.isError() ? t : t.tanh();
  25652. }
  25653. };
  25654. var w_ = class extends V {
  25655. constructor() {
  25656. super(...arguments);
  25657. A(this, "minParams", 1);
  25658. A(this, "maxParams", 2);
  25659. }
  25660. calculate(e, t) {
  25661. const r = t != null ? t : y2.create(0), n = Math.max(
  25662. e.isArray() ? e.getRowCount() : 1,
  25663. r.isArray() ? r.getRowCount() : 1
  25664. ), s = Math.max(
  25665. e.isArray() ? e.getColumnCount() : 1,
  25666. r.isArray() ? r.getColumnCount() : 1
  25667. ), o = O(n, s, e, g2.create(m2.NA)), u = O(n, s, r, g2.create(m2.NA)), c = o.map((l2, f2, h) => {
  25668. let d2 = u.get(f2, h), _ = l2;
  25669. if (_.isString() && (_ = _.convertToNumberObjectValue()), _.isError())
  25670. return _;
  25671. if (d2.isString() && (d2 = d2.convertToNumberObjectValue()), d2.isError())
  25672. return d2;
  25673. const C = +_.getValue(), E2 = +d2.getValue(), b = 10 ** Math.trunc(E2), R = Bn(C, b), p2 = Math.trunc(Vr2(C, b) + R) / b;
  25674. return y2.create(p2);
  25675. });
  25676. return n === 1 && s === 1 ? c.get(0, 0) : c;
  25677. }
  25678. };
  25679. var D_ = [
  25680. [nC, Y2.ABS],
  25681. [sC, Y2.ACOS],
  25682. [aC, Y2.ACOSH],
  25683. [iC, Y2.ACOT],
  25684. [oC, Y2.ACOTH],
  25685. [uC, Y2.ARABIC],
  25686. [cC, Y2.ASIN],
  25687. [lC, Y2.ASINH],
  25688. [fC, Y2.ATAN],
  25689. [hC, Y2.ATAN2],
  25690. [mC, Y2.ATANH],
  25691. [gC, Y2.BASE],
  25692. [dC, Y2.CEILING],
  25693. [CC, Y2.CEILING_MATH],
  25694. [_C, Y2.CEILING_PRECISE],
  25695. [AC2, Y2.COMBIN],
  25696. [EC, Y2.COMBINA],
  25697. [bC, Y2.COS],
  25698. [yC2, Y2.COSH],
  25699. [RC, Y2.COT],
  25700. [pC, Y2.COTH],
  25701. [VC, Y2.CSC],
  25702. [NC, Y2.CSCH],
  25703. [OC, Y2.DECIMAL],
  25704. [MC, Y2.DEGREES],
  25705. [wC, Y2.EVEN],
  25706. [DC2, Y2.EXP],
  25707. [SC2, Y2.FACT],
  25708. [PC, Y2.FACTDOUBLE],
  25709. [LC, Y2.FLOOR],
  25710. [xC2, Y2.FLOOR_MATH],
  25711. [jC2, Y2.FLOOR_PRECISE],
  25712. [UC, Y2.GCD],
  25713. [vC2, Y2.INT],
  25714. [TC, Y2.LCM],
  25715. [BC, Y2.LN],
  25716. [IC, Y2.LOG],
  25717. [FC, Y2.LOG10],
  25718. [kC, Y2.MDETERM],
  25719. [$C, Y2.MINVERSE],
  25720. [YC, Y2.MMULT],
  25721. [HC, Y2.MOD],
  25722. [GC, Y2.MROUND],
  25723. [QC, Y2.MULTINOMIAL],
  25724. [WC, Y2.MUNIT],
  25725. [qC, Y2.ODD],
  25726. [KC2, Y2.PI],
  25727. [XC, Y2.POWER],
  25728. [ZC, Y2.PRODUCT],
  25729. [zC, Y2.QUOTIENT],
  25730. [JC, Y2.RADIANS],
  25731. [e_, Y2.RAND],
  25732. [t_, Y2.RANDARRAY],
  25733. [r_, Y2.RANDBETWEEN],
  25734. [n_, Y2.ROMAN],
  25735. [s_, Y2.ROUND],
  25736. [a_, Y2.ROUNDBANK],
  25737. [i_, Y2.ROUNDDOWN],
  25738. [o_, Y2.ROUNDUP],
  25739. [u_, Y2.SEC],
  25740. [c_, Y2.SECH],
  25741. [f_, Y2.SERIESSUM],
  25742. [l_, Y2.SEQUENCE],
  25743. [h_, Y2.SIGN],
  25744. [m_, Y2.SIN],
  25745. [g_, Y2.SINH],
  25746. [d_, Y2.SQRT],
  25747. [C_, Y2.SQRTPI],
  25748. [__, Y2.SUBTOTAL],
  25749. [A_, Y2.SUM],
  25750. [E_, Y2.SUMIF],
  25751. [b_, Y2.SUMIFS],
  25752. [y_, Y2.SUMPRODUCT],
  25753. [R_, Y2.SUMSQ],
  25754. [p_, Y2.SUMX2MY2],
  25755. [V_, Y2.SUMX2PY2],
  25756. [N_, Y2.SUMXMY2],
  25757. [O_, Y2.TAN],
  25758. [M_, Y2.TANH],
  25759. [w_, Y2.TRUNC]
  25760. ];
  25761. var S_ = class extends V {
  25762. constructor() {
  25763. super(...arguments);
  25764. A(this, "minParams", 2);
  25765. A(this, "maxParams", 2);
  25766. A(this, "_compareType", $.EQUALS);
  25767. }
  25768. setCompareType(e) {
  25769. this._compareType = e;
  25770. }
  25771. calculate(e, t) {
  25772. return e.isError() ? e : t.isError() ? t : e.compare(t, this._compareType);
  25773. }
  25774. };
  25775. var Fa = class _Fa extends kt2 {
  25776. constructor(e) {
  25777. super("");
  25778. A(this, "_values", []);
  25779. this._values = e;
  25780. }
  25781. static create(e) {
  25782. return new _Fa(e);
  25783. }
  25784. isCube() {
  25785. return true;
  25786. }
  25787. dispose() {
  25788. this._values.forEach((e) => {
  25789. e.dispose();
  25790. }), this._values = [];
  25791. }
  25792. sum() {
  25793. const e = y2.create(0);
  25794. return this._values.forEach((t) => {
  25795. e.plus(t.sum());
  25796. }), e;
  25797. }
  25798. max() {
  25799. let e = y2.create(Number.NEGATIVE_INFINITY);
  25800. return this._values.forEach((t) => {
  25801. const r = t.max();
  25802. e.isLessThan(r) && (e = r);
  25803. }), e;
  25804. }
  25805. min() {
  25806. let e = y2.create(Number.POSITIVE_INFINITY);
  25807. return this._values.forEach((t) => {
  25808. const r = t.max();
  25809. e.isGreaterThan(r) && (e = r);
  25810. }), e;
  25811. }
  25812. count() {
  25813. const e = y2.create(0);
  25814. return this._values.forEach((t) => {
  25815. e.plus(t.count());
  25816. }), e;
  25817. }
  25818. countA() {
  25819. const e = y2.create(0);
  25820. return this._values.forEach((t) => {
  25821. e.plus(t.countA());
  25822. }), e;
  25823. }
  25824. countBlank() {
  25825. const e = y2.create(0);
  25826. return this._values.forEach((t) => {
  25827. e.plus(t.countBlank());
  25828. }), e;
  25829. }
  25830. };
  25831. var P_ = class extends V {
  25832. constructor() {
  25833. super(...arguments);
  25834. A(this, "minParams", 1);
  25835. A(this, "maxParams", 255);
  25836. }
  25837. calculate(...e) {
  25838. const t = [];
  25839. for (let r = 0; r < e.length; r++) {
  25840. const n = e[r];
  25841. if (n.isError())
  25842. return n;
  25843. if (!n.isArray())
  25844. return g2.create(m2.VALUE);
  25845. t.push(n);
  25846. }
  25847. return Fa.create(t);
  25848. }
  25849. };
  25850. var L_ = class extends V {
  25851. constructor() {
  25852. super(...arguments);
  25853. A(this, "minParams", 2);
  25854. A(this, "maxParams", 2);
  25855. }
  25856. calculate(e, t) {
  25857. return e.isError() ? e : t.isError() ? t : !t.isArray() && t.getValue() === 0 ? g2.create(m2.DIV_BY_ZERO) : e.divided(t);
  25858. }
  25859. };
  25860. var x_ = class extends V {
  25861. constructor() {
  25862. super(...arguments);
  25863. A(this, "minParams", 2);
  25864. A(this, "maxParams", 2);
  25865. }
  25866. calculate(e, t) {
  25867. return e.isError() ? e : t.isError() ? t : e.minus(t);
  25868. }
  25869. };
  25870. var j_ = class extends V {
  25871. constructor() {
  25872. super(...arguments);
  25873. A(this, "minParams", 2);
  25874. A(this, "maxParams", 2);
  25875. }
  25876. calculate(e, t) {
  25877. return e.isError() ? e : t.isError() ? t : e.multiply(t);
  25878. }
  25879. };
  25880. var U_ = class extends V {
  25881. constructor() {
  25882. super(...arguments);
  25883. A(this, "minParams", 2);
  25884. A(this, "maxParams", 2);
  25885. }
  25886. calculate(e, t) {
  25887. return e.isError() ? e : t.isError() ? t : e.plus(t);
  25888. }
  25889. };
  25890. var v_ = [
  25891. [S_, Te.COMPARE],
  25892. [L_, Te.DIVIDED],
  25893. [x_, Te.MINUS],
  25894. [j_, Te.MULTIPLY],
  25895. [U_, Te.PLUS],
  25896. [P_, Te.CUBE]
  25897. ];
  25898. var T_ = class extends V {
  25899. constructor() {
  25900. super(...arguments);
  25901. A(this, "minParams", 1);
  25902. A(this, "maxParams", 255);
  25903. }
  25904. calculate(...e) {
  25905. let t = y2.create(0), r = y2.create(0);
  25906. for (let o = 0; o < e.length; o++) {
  25907. let u = e[o];
  25908. if (u.isString() && (u = u.convertToNumberObjectValue()), u.isError())
  25909. return u;
  25910. if (u.isArray()) {
  25911. if (u = B_(u), u.isError())
  25912. return u;
  25913. if (e[o] = u, t = t.plus(u.sum()), t.isError())
  25914. return t;
  25915. r = r.plus(u.count());
  25916. } else
  25917. u.isNull() || (t = t.plus(u), r = r.plus(y2.create(1)));
  25918. }
  25919. if (r.getValue() === 0)
  25920. return g2.create(m2.NUM);
  25921. const n = t.divided(r);
  25922. if (n.isError())
  25923. return n;
  25924. let s = y2.create(0);
  25925. for (let o = 0; o < e.length; o++) {
  25926. let u = e[o];
  25927. if (u.isString() && (u = u.convertToNumberObjectValue()), u.isError())
  25928. return u;
  25929. if (u.isArray()) {
  25930. if (s = s.plus(u.minus(n).abs().sum()), s.isError())
  25931. return s;
  25932. } else
  25933. u.isNull() || (s = s.plus(u.minus(n).abs()));
  25934. }
  25935. return s.divided(r);
  25936. }
  25937. };
  25938. function B_(i) {
  25939. const a2 = [];
  25940. a2[0] = [];
  25941. let e = null;
  25942. return i.iterator((t, r, n) => {
  25943. if (t != null && t.isError())
  25944. return e = t, false;
  25945. t != null && t.isNumber() && a2[0].push(t);
  25946. }), e || tr(a2, 1, a2[0].length);
  25947. }
  25948. var I_ = class extends V {
  25949. constructor() {
  25950. super(...arguments);
  25951. A(this, "minParams", 1);
  25952. A(this, "maxParams", 255);
  25953. }
  25954. calculate(...e) {
  25955. let t = y2.create(0), r = y2.create(0);
  25956. for (let n = 0; n < e.length; n++) {
  25957. let s = e[n];
  25958. if ((s.isString() || s.isBoolean()) && (s = s.convertToNumberObjectValue()), s.isError())
  25959. return s;
  25960. if (s.isArray()) {
  25961. if (t = t.plus(s.sum()), t.isError())
  25962. return t;
  25963. r = r.plus(s.count());
  25964. } else
  25965. s.isNull() || (t = t.plus(s), r = r.plus(y2.create(1)));
  25966. }
  25967. return t.divided(r);
  25968. }
  25969. };
  25970. var F_ = class extends V {
  25971. constructor() {
  25972. super(...arguments);
  25973. A(this, "minParams", 2);
  25974. A(this, "maxParams", 254);
  25975. }
  25976. // eslint-disable-next-line
  25977. calculate(...e) {
  25978. let t = false, r;
  25979. e.length % 2 !== 0 && (t = true, r = g2.create(m2.NA));
  25980. const n = [], s = [];
  25981. for (let o = 0; o < e.length; o += 2) {
  25982. const u = e[o], c = u.isArray() ? u.getRowCount() : 1, l2 = u.isArray() ? u.getColumnCount() : 1;
  25983. for (let _ = 0; _ < c; _++)
  25984. for (let C = 0; C < l2; C++) {
  25985. const E2 = u.isArray() ? u.get(_, C) : u;
  25986. if (E2.isError())
  25987. return E2;
  25988. if (t)
  25989. continue;
  25990. const b = E2.isNull() ? "" : E2.getValue();
  25991. n.push(b);
  25992. }
  25993. if (o + 1 >= e.length)
  25994. continue;
  25995. const f2 = e[o + 1], h = f2.isArray() ? f2.getRowCount() : 1, d2 = f2.isArray() ? f2.getColumnCount() : 1;
  25996. (h !== c || d2 !== l2) && (t = true, r = g2.create(m2.VALUE));
  25997. for (let _ = 0; _ < h; _++)
  25998. for (let C = 0; C < d2; C++) {
  25999. const E2 = f2.isArray() ? f2.get(_, C) : f2;
  26000. if (E2.isError())
  26001. return E2;
  26002. if (t)
  26003. continue;
  26004. const b = E2.isNull() ? "" : E2.getValue();
  26005. s.push(b);
  26006. }
  26007. }
  26008. return t ? r : this._getResult(n, s);
  26009. }
  26010. _getResult(e, t) {
  26011. const r = e.length;
  26012. let n = 0, s = 0;
  26013. for (let u = 0; u < r; u++) {
  26014. const c = e[u], l2 = t[u];
  26015. if (!(typeof c != "number" && typeof l2 != "number")) {
  26016. if (typeof c != "number" || typeof l2 != "number" || l2 < 0)
  26017. return g2.create(m2.VALUE);
  26018. n += c * l2, s += l2;
  26019. }
  26020. }
  26021. if (s === 0)
  26022. return g2.create(m2.DIV_BY_ZERO);
  26023. const o = n / s;
  26024. return y2.create(o);
  26025. }
  26026. };
  26027. var k_ = class extends V {
  26028. constructor() {
  26029. super(...arguments);
  26030. A(this, "minParams", 1);
  26031. A(this, "maxParams", 255);
  26032. }
  26033. calculate(...e) {
  26034. let t = y2.create(0), r = y2.create(0);
  26035. for (let n = 0; n < e.length; n++) {
  26036. let s = e[n];
  26037. if ((s.isString() || s.isBoolean()) && (s = s.convertToNumberObjectValue()), s.isError())
  26038. return s;
  26039. if (s.isArray()) {
  26040. if (s.iterator((o) => {
  26041. if (o == null || o.isNull())
  26042. return true;
  26043. let u = o;
  26044. if (u.isString() && (u = u.convertToNumberObjectValue(), u.isError() && (u = y2.create(0))), u.isBoolean() && (u = u.convertToNumberObjectValue()), u.isError())
  26045. return t = u, false;
  26046. t = t.plus(u), r = r.plus(y2.create(1));
  26047. }), t.isError())
  26048. return t;
  26049. } else
  26050. s.isNull() || (t = t.plus(s), r = r.plus(y2.create(1)));
  26051. }
  26052. return t.divided(r);
  26053. }
  26054. };
  26055. var $_ = class extends V {
  26056. constructor() {
  26057. super(...arguments);
  26058. A(this, "minParams", 2);
  26059. A(this, "maxParams", 3);
  26060. A(this, "needsReferenceObject", true);
  26061. }
  26062. calculate(e, t, r) {
  26063. if (e.isError())
  26064. return e;
  26065. if (t.isError())
  26066. return t;
  26067. if (r != null && r.isError())
  26068. return r;
  26069. let n = e;
  26070. n.isReferenceObject() && (n = n.toArrayValueObject()), n.isArray() || (n = tr([[n]], 1, 1));
  26071. let s = t;
  26072. return s.isReferenceObject() && (s = s.toArrayValueObject()), r && !(r != null && r.isReferenceObject()) ? g2.create(m2.NA) : (s = s, s.isArray() ? s.map((o) => this._handleSingleObject(n, o, r)) : this._handleSingleObject(n, s, r));
  26073. }
  26074. _handleSingleObject(e, t, r) {
  26075. let n = $n(e, t);
  26076. n = Yn(n, e, t);
  26077. let s = r ? this._createRangeReferenceObject(r, e) : e;
  26078. if (!s)
  26079. return g2.create(m2.VALUE);
  26080. if (s.isError())
  26081. return s;
  26082. s.isReferenceObject() && (s = s.toArrayValueObject()), s = s;
  26083. const o = s.pick(n), u = o.sum(), c = o.count();
  26084. return u.divided(c);
  26085. }
  26086. /**
  26087. * Create reference object, starting from the first cell in the upper left corner, the height is rowCount and the width is columnCount
  26088. * @param averageRange
  26089. * @param rowCount
  26090. * @param columnCount
  26091. * @returns
  26092. */
  26093. _createRangeReferenceObject(e, t) {
  26094. const r = e.getRowCount(), n = e.getColumnCount(), s = t.isArray() ? t.getRowCount() : 1, o = t.isArray() ? t.getColumnCount() : 1;
  26095. if (r === s && n === o)
  26096. return e;
  26097. const { startRow: u, startColumn: c } = e.getRangePosition(), l2 = {
  26098. startRow: u,
  26099. startColumn: c,
  26100. endRow: u + s - 1,
  26101. endColumn: c + o - 1
  26102. };
  26103. return this.createReferenceObject(e, l2);
  26104. }
  26105. };
  26106. var Y_ = class extends V {
  26107. constructor() {
  26108. super(...arguments);
  26109. A(this, "minParams", 3);
  26110. A(this, "maxParams", 255);
  26111. }
  26112. calculate(e, ...t) {
  26113. if (e.isError())
  26114. return g2.create(m2.NA);
  26115. if (!e.isArray() || t.length % 2 !== 0 || t.some((u, c) => c % 2 === 0 && !u.isArray()))
  26116. return g2.create(m2.VALUE);
  26117. const { maxRowLength: r, maxColumnLength: n } = Nr(t), s = Br(t, e, r, n);
  26118. if (s)
  26119. return s;
  26120. const o = Ir(t, r, n, true);
  26121. return this._aggregateResults(e, o);
  26122. }
  26123. _aggregateResults(e, t) {
  26124. const r = t.map((s) => s.map((o) => {
  26125. const u = e.pick(o), c = u.sum(), l2 = u.count();
  26126. return c.divided(l2);
  26127. })), n = {
  26128. calculateValueList: r,
  26129. rowCount: r.length,
  26130. columnCount: r[0].length,
  26131. unitId: this.unitId || "",
  26132. sheetId: this.subUnitId || "",
  26133. row: this.row,
  26134. column: this.column
  26135. };
  26136. return q2.create(n);
  26137. }
  26138. };
  26139. var H_ = class extends V {
  26140. constructor() {
  26141. super(...arguments);
  26142. A(this, "minParams", 4);
  26143. A(this, "maxParams", 6);
  26144. }
  26145. calculate(e, t, r, n, s, o) {
  26146. let u = s != null ? s : y2.create(0), c = o != null ? o : y2.create(1);
  26147. u.isNull() && (u = y2.create(0)), c.isNull() && (c = y2.create(1));
  26148. const l2 = Math.max(
  26149. e.isArray() ? e.getRowCount() : 1,
  26150. t.isArray() ? t.getRowCount() : 1,
  26151. r.isArray() ? r.getRowCount() : 1,
  26152. n.isArray() ? n.getRowCount() : 1,
  26153. u.isArray() ? u.getRowCount() : 1,
  26154. c.isArray() ? c.getRowCount() : 1
  26155. ), f2 = Math.max(
  26156. e.isArray() ? e.getColumnCount() : 1,
  26157. t.isArray() ? t.getColumnCount() : 1,
  26158. r.isArray() ? r.getColumnCount() : 1,
  26159. n.isArray() ? n.getColumnCount() : 1,
  26160. u.isArray() ? u.getColumnCount() : 1,
  26161. c.isArray() ? c.getColumnCount() : 1
  26162. ), h = O(l2, f2, e, g2.create(m2.NA)), d2 = O(l2, f2, t, g2.create(m2.NA)), _ = O(l2, f2, r, g2.create(m2.NA)), C = O(l2, f2, n, g2.create(m2.NA)), E2 = O(l2, f2, u, g2.create(m2.NA)), b = O(l2, f2, c, g2.create(m2.NA)), R = h.mapValue((p2, N2, M2) => {
  26163. const w = d2.get(N2, M2), D2 = _.get(N2, M2), S2 = C.get(N2, M2), P = E2.get(N2, M2), U2 = b.get(N2, M2);
  26164. return this._handleSignleObject(p2, w, D2, S2, P, U2);
  26165. });
  26166. return l2 === 1 && f2 === 1 ? R.get(0, 0) : R;
  26167. }
  26168. _handleSignleObject(e, t, r, n, s, o) {
  26169. if (e.isError())
  26170. return e;
  26171. if (t.isError())
  26172. return t;
  26173. if (r.isError())
  26174. return r;
  26175. if (n.isError())
  26176. return n;
  26177. if (s.isError())
  26178. return s;
  26179. if (o.isError())
  26180. return o;
  26181. const { isError: u, errorObject: c, variants: l2 } = I2(e, t, r, n, s, o);
  26182. if (u)
  26183. return c;
  26184. const [f2, h, d2, _, C, E2] = l2, b = +f2.getValue(), R = +h.getValue(), p2 = +d2.getValue(), N2 = +_.getValue(), M2 = +C.getValue(), w = +E2.getValue();
  26185. if (R <= 0 || p2 <= 0 || b < M2 || b > w || M2 === w)
  26186. return g2.create(m2.NUM);
  26187. let D2;
  26188. return N2 ? D2 = Do((b - M2) / (w - M2), R, p2) : D2 = em((b - M2) / (w - M2), R, p2) / (w - M2), y2.create(D2);
  26189. }
  26190. };
  26191. var G_ = class extends V {
  26192. constructor() {
  26193. super(...arguments);
  26194. A(this, "minParams", 3);
  26195. A(this, "maxParams", 4);
  26196. }
  26197. calculate(e, t, r, n) {
  26198. let s = n != null ? n : r;
  26199. s.isNull() && (s = r);
  26200. const o = Math.max(
  26201. e.isArray() ? e.getRowCount() : 1,
  26202. t.isArray() ? t.getRowCount() : 1,
  26203. r.isArray() ? r.getRowCount() : 1,
  26204. s.isArray() ? s.getRowCount() : 1
  26205. ), u = Math.max(
  26206. e.isArray() ? e.getColumnCount() : 1,
  26207. t.isArray() ? t.getColumnCount() : 1,
  26208. r.isArray() ? r.getColumnCount() : 1,
  26209. s.isArray() ? s.getColumnCount() : 1
  26210. ), c = O(o, u, e, g2.create(m2.NA)), l2 = O(o, u, t, g2.create(m2.NA)), f2 = O(o, u, r, g2.create(m2.NA)), h = O(o, u, s, g2.create(m2.NA)), d2 = c.mapValue((_, C, E2) => {
  26211. const b = l2.get(C, E2), R = f2.get(C, E2), p2 = h.get(C, E2);
  26212. return _.isError() ? _ : b.isError() ? b : R.isError() ? R : p2.isError() ? p2 : this._handleSignleObject(_, b, R, p2);
  26213. });
  26214. return o === 1 && u === 1 ? d2.get(0, 0) : d2;
  26215. }
  26216. _handleSignleObject(e, t, r, n) {
  26217. const { isError: s, errorObject: o, variants: u } = I2(e, t, r, n);
  26218. if (s)
  26219. return o;
  26220. const [c, l2, f2, h] = u, d2 = Math.floor(+c.getValue()), _ = +l2.getValue(), C = Math.floor(+f2.getValue()), E2 = Math.floor(+h.getValue());
  26221. if (d2 < 0 || _ < 0 || _ > 1 || C < 0 || C > d2 || E2 < 0 || E2 < C || E2 > d2)
  26222. return g2.create(m2.NUM);
  26223. let b = 0;
  26224. for (let R = C; R <= E2; R++)
  26225. b += Da(R, d2, _);
  26226. return y2.create(b);
  26227. }
  26228. };
  26229. var Q_ = class extends V {
  26230. constructor() {
  26231. super(...arguments);
  26232. A(this, "minParams", 3);
  26233. A(this, "maxParams", 3);
  26234. }
  26235. calculate(e, t, r) {
  26236. const n = Math.max(
  26237. e.isArray() ? e.getRowCount() : 1,
  26238. t.isArray() ? t.getRowCount() : 1,
  26239. r.isArray() ? r.getRowCount() : 1
  26240. ), s = Math.max(
  26241. e.isArray() ? e.getColumnCount() : 1,
  26242. t.isArray() ? t.getColumnCount() : 1,
  26243. r.isArray() ? r.getColumnCount() : 1
  26244. ), o = O(n, s, e, g2.create(m2.NA)), u = O(n, s, t, g2.create(m2.NA)), c = O(n, s, r, g2.create(m2.NA)), l2 = o.mapValue((f2, h, d2) => {
  26245. const _ = u.get(h, d2), C = c.get(h, d2);
  26246. return f2.isError() ? f2 : _.isError() ? _ : C.isError() ? C : this._handleSignleObject(f2, _, C);
  26247. });
  26248. return n === 1 && s === 1 ? l2.get(0, 0) : l2;
  26249. }
  26250. _handleSignleObject(e, t, r) {
  26251. const { isError: n, errorObject: s, variants: o } = I2(e, t, r);
  26252. if (n)
  26253. return s;
  26254. const [u, c, l2] = o, f2 = +u.getValue(), h = Math.floor(+c.getValue()), d2 = +l2.getValue();
  26255. if (f2 < 0 || h < 1 || h > 10 ** 10)
  26256. return g2.create(m2.NUM);
  26257. let _;
  26258. return d2 ? _ = Sa(f2, h) : _ = tm(f2, h), y2.create(_);
  26259. }
  26260. };
  26261. var W_ = class extends V {
  26262. constructor() {
  26263. super(...arguments);
  26264. A(this, "minParams", 2);
  26265. A(this, "maxParams", 2);
  26266. }
  26267. calculate(e, t) {
  26268. const r = Math.max(
  26269. e.isArray() ? e.getRowCount() : 1,
  26270. t.isArray() ? t.getRowCount() : 1
  26271. ), n = Math.max(
  26272. e.isArray() ? e.getColumnCount() : 1,
  26273. t.isArray() ? t.getColumnCount() : 1
  26274. ), s = O(r, n, e, g2.create(m2.NA)), o = O(r, n, t, g2.create(m2.NA)), u = s.mapValue((c, l2, f2) => {
  26275. const h = o.get(l2, f2);
  26276. return c.isError() ? c : h.isError() ? h : this._handleSignleObject(c, h);
  26277. });
  26278. return r === 1 && n === 1 ? u.get(0, 0) : u;
  26279. }
  26280. _handleSignleObject(e, t) {
  26281. const { isError: r, errorObject: n, variants: s } = I2(e, t);
  26282. if (r)
  26283. return n;
  26284. const [o, u] = s, c = +o.getValue(), l2 = Math.floor(+u.getValue());
  26285. if (c < 0 || c > 1 || l2 < 1 || l2 > 10 ** 10)
  26286. return g2.create(m2.NUM);
  26287. const f2 = Po(c, l2);
  26288. return Number.isNaN(f2) || !Number.isFinite(f2) ? g2.create(m2.NUM) : y2.create(f2);
  26289. }
  26290. };
  26291. var q_ = class extends V {
  26292. constructor() {
  26293. super(...arguments);
  26294. A(this, "minParams", 3);
  26295. A(this, "maxParams", 3);
  26296. }
  26297. calculate(e, t, r) {
  26298. const n = Math.max(
  26299. e.isArray() ? e.getRowCount() : 1,
  26300. t.isArray() ? t.getRowCount() : 1,
  26301. r.isArray() ? r.getRowCount() : 1
  26302. ), s = Math.max(
  26303. e.isArray() ? e.getColumnCount() : 1,
  26304. t.isArray() ? t.getColumnCount() : 1,
  26305. r.isArray() ? r.getColumnCount() : 1
  26306. ), o = O(n, s, e, g2.create(m2.NA)), u = O(n, s, t, g2.create(m2.NA)), c = O(n, s, r, g2.create(m2.NA)), l2 = o.mapValue((f2, h, d2) => {
  26307. const _ = u.get(h, d2), C = c.get(h, d2);
  26308. if (f2.isError())
  26309. return f2;
  26310. if (_.isError())
  26311. return _;
  26312. if (C.isError())
  26313. return C;
  26314. const { isError: E2, errorObject: b, variants: R } = I2(f2, _, C);
  26315. if (E2)
  26316. return b;
  26317. const [p2, N2, M2] = R, w = +p2.getValue(), D2 = +N2.getValue(), S2 = Math.floor(+M2.getValue());
  26318. if (w <= 0 || w >= 1 || D2 <= 0 || S2 < 1)
  26319. return g2.create(m2.NUM);
  26320. if (S2 === 1)
  26321. return g2.create(m2.DIV_BY_ZERO);
  26322. const P = Math.abs(qn(w / 2, S2 - 1) * D2 / Math.sqrt(S2));
  26323. return y2.create(P);
  26324. });
  26325. return n === 1 && s === 1 ? l2.get(0, 0) : l2;
  26326. }
  26327. };
  26328. var K_ = class extends V {
  26329. constructor() {
  26330. super(...arguments);
  26331. A(this, "minParams", 2);
  26332. A(this, "maxParams", 2);
  26333. }
  26334. calculate(e, t) {
  26335. const r = e.isArray() ? e.getRowCount() : 1, n = e.isArray() ? e.getColumnCount() : 1, s = t.isArray() ? t.getRowCount() : 1, o = t.isArray() ? t.getColumnCount() : 1;
  26336. let u = e;
  26337. if (e.isArray() && r === 1 && n === 1 && (u = e.get(0, 0)), u.isError())
  26338. return u;
  26339. let c = t;
  26340. if (t.isArray() && s === 1 && o === 1 && (c = t.get(0, 0)), c.isError())
  26341. return c;
  26342. if (r * n === 1 || s * o === 1)
  26343. return u.isNull() || c.isNull() ? g2.create(m2.VALUE) : g2.create(m2.DIV_BY_ZERO);
  26344. if (r * n !== s * o)
  26345. return g2.create(m2.NA);
  26346. const {
  26347. isError: l2,
  26348. errorObject: f2,
  26349. array1Values: h,
  26350. array2Values: d2,
  26351. noCalculate: _
  26352. } = Je(
  26353. e,
  26354. t,
  26355. r * n,
  26356. n,
  26357. o
  26358. );
  26359. return l2 ? f2 : _ ? g2.create(m2.DIV_BY_ZERO) : this._getResult(h, d2);
  26360. }
  26361. _getResult(e, t) {
  26362. const r = e.length;
  26363. let n = 0, s = 0;
  26364. for (let d2 = 0; d2 < r; d2++)
  26365. n += e[d2], s += t[d2];
  26366. const o = n / r, u = s / r;
  26367. let c = 0, l2 = 0, f2 = 0;
  26368. for (let d2 = 0; d2 < r; d2++) {
  26369. const _ = e[d2] - o, C = t[d2] - u;
  26370. c += _ * C, l2 += _ ** 2, f2 += C ** 2;
  26371. }
  26372. const h = Math.sqrt(l2 * f2);
  26373. return h === 0 ? g2.create(m2.DIV_BY_ZERO) : y2.create(c / h);
  26374. }
  26375. };
  26376. var X_ = class extends V {
  26377. constructor() {
  26378. super(...arguments);
  26379. A(this, "minParams", 1);
  26380. A(this, "maxParams", 255);
  26381. }
  26382. calculate(...e) {
  26383. let t = y2.create(0);
  26384. for (let r = 0; r < e.length; r++) {
  26385. const n = e[r];
  26386. n.isError() || (n.isArray() ? t = t.plus(n.count()) : n.isString() ? n.convertToNumberObjectValue().isError() || (t = t.plus(y2.create(1))) : n.isNull() || (t = t.plus(y2.create(1))));
  26387. }
  26388. return t;
  26389. }
  26390. };
  26391. var Z_ = class extends V {
  26392. constructor() {
  26393. super(...arguments);
  26394. A(this, "minParams", 1);
  26395. A(this, "maxParams", 255);
  26396. }
  26397. calculate(...e) {
  26398. let t = y2.create(0);
  26399. for (let r = 0; r < e.length; r++) {
  26400. let n = e[r];
  26401. if (n.isError()) {
  26402. t = t.plus(y2.create(1));
  26403. continue;
  26404. }
  26405. n.isArray() ? (n = n.countA(), t = t.plus(n)) : n.isNull() || (t = t.plus(y2.create(1)));
  26406. }
  26407. return t;
  26408. }
  26409. };
  26410. var z_ = class extends V {
  26411. constructor() {
  26412. super(...arguments);
  26413. A(this, "minParams", 1);
  26414. A(this, "maxParams", 1);
  26415. }
  26416. calculate(e) {
  26417. return e.isError() ? e : e.getValue() === "" || e.isNull() ? y2.create(1) : e.isArray() ? e.countBlank() : y2.create(0);
  26418. }
  26419. };
  26420. var J_ = class extends V {
  26421. constructor() {
  26422. super(...arguments);
  26423. A(this, "minParams", 2);
  26424. A(this, "maxParams", 2);
  26425. }
  26426. calculate(e, t) {
  26427. return e.isError() || t.isError() ? g2.create(m2.NA) : e.isArray() ? t.isArray() ? t.mapValue((r) => this._handleSingleObject(e, r)) : this._handleSingleObject(e, t) : g2.create(m2.VALUE);
  26428. }
  26429. _handleSingleObject(e, t) {
  26430. let r = $n(e, t);
  26431. r = Yn(r, e, t);
  26432. const n = e.pick(r);
  26433. return this._countA(n);
  26434. }
  26435. _countA(e) {
  26436. let t = y2.create(0);
  26437. return e.iterator((r) => {
  26438. if (r == null)
  26439. return true;
  26440. t = t.plusBy(1);
  26441. }), t;
  26442. }
  26443. };
  26444. var eA = class extends V {
  26445. constructor() {
  26446. super(...arguments);
  26447. A(this, "minParams", 2);
  26448. A(this, "maxParams", 255);
  26449. }
  26450. calculate(...e) {
  26451. if (e.length % 2 !== 0 || e.some((o, u) => u % 2 === 0 && !o.isArray()))
  26452. return g2.create(m2.VALUE);
  26453. const { maxRowLength: t, maxColumnLength: r } = Nr(e), n = Br(e, e[0], t, r);
  26454. if (n)
  26455. return n;
  26456. const s = Ir(e, t, r, true);
  26457. return this._aggregateResults(s);
  26458. }
  26459. _aggregateResults(e) {
  26460. const t = e.map((n) => n.map((s) => tA(s))), r = {
  26461. calculateValueList: t,
  26462. rowCount: t.length,
  26463. columnCount: t[0].length,
  26464. unitId: this.unitId || "",
  26465. sheetId: this.subUnitId || "",
  26466. row: this.row,
  26467. column: this.column
  26468. };
  26469. return q2.create(r);
  26470. }
  26471. };
  26472. function tA(i) {
  26473. let a2 = 0;
  26474. return i.iterator((e) => {
  26475. e != null && e.isBoolean() && e.getValue() === true && a2++;
  26476. }), y2.create(a2);
  26477. }
  26478. var rA = class extends V {
  26479. constructor() {
  26480. super(...arguments);
  26481. A(this, "minParams", 2);
  26482. A(this, "maxParams", 2);
  26483. }
  26484. calculate(e, t) {
  26485. const r = e.isArray() ? e.getRowCount() : 1, n = e.isArray() ? e.getColumnCount() : 1, s = t.isArray() ? t.getRowCount() : 1, o = t.isArray() ? t.getColumnCount() : 1;
  26486. let u = e;
  26487. if (e.isArray() && r === 1 && n === 1 && (u = e.get(0, 0)), u.isError())
  26488. return u;
  26489. let c = t;
  26490. if (t.isArray() && s === 1 && o === 1 && (c = t.get(0, 0)), c.isError())
  26491. return c;
  26492. if ((r * n === 1 || s * o === 1) && (u.isNull() || c.isNull()))
  26493. return g2.create(m2.VALUE);
  26494. if (r * n !== s * o)
  26495. return g2.create(m2.NA);
  26496. const {
  26497. isError: l2,
  26498. errorObject: f2,
  26499. array1Values: h,
  26500. array2Values: d2,
  26501. noCalculate: _
  26502. } = Je(
  26503. e,
  26504. t,
  26505. r * n,
  26506. n,
  26507. o
  26508. );
  26509. return l2 ? f2 : _ ? g2.create(m2.DIV_BY_ZERO) : this._getResult(h, d2);
  26510. }
  26511. _getResult(e, t) {
  26512. if (e.length <= 1)
  26513. return g2.create(m2.DIV_BY_ZERO);
  26514. const r = e.length;
  26515. let n = 0, s = 0;
  26516. for (let l2 = 0; l2 < r; l2++)
  26517. n += e[l2], s += t[l2];
  26518. const o = n / r, u = s / r;
  26519. let c = 0;
  26520. for (let l2 = 0; l2 < r; l2++) {
  26521. const f2 = e[l2] - o, h = t[l2] - u;
  26522. c += f2 * h;
  26523. }
  26524. return y2.create(c / (r - 1));
  26525. }
  26526. };
  26527. var nA = class extends V {
  26528. constructor() {
  26529. super(...arguments);
  26530. A(this, "minParams", 1);
  26531. A(this, "maxParams", 255);
  26532. }
  26533. calculate(...e) {
  26534. const t = [];
  26535. let r = 0, n = true;
  26536. for (let u = 0; u < e.length; u++) {
  26537. const c = e[u];
  26538. if (c.isArray()) {
  26539. let l2 = false, f2 = g2.create(m2.VALUE);
  26540. if (c.iterator((h) => {
  26541. const d2 = this._handleSingleObject(h);
  26542. if (d2.isError())
  26543. return l2 = true, f2 = d2, false;
  26544. if (d2.isNull())
  26545. return true;
  26546. const _ = d2.getValue();
  26547. t.push(_), r += _, n = false;
  26548. }), l2)
  26549. return f2;
  26550. } else {
  26551. const l2 = this._handleSingleObject(c);
  26552. if (l2.isError())
  26553. return l2;
  26554. if (l2.isNull())
  26555. continue;
  26556. const f2 = l2.getValue();
  26557. t.push(f2), r += f2, n = false;
  26558. }
  26559. }
  26560. if (n)
  26561. return g2.create(m2.NUM);
  26562. const s = r / t.length;
  26563. let o = 0;
  26564. for (let u = 0; u < t.length; u++)
  26565. o += (t[u] - s) ** 2;
  26566. return y2.create(o);
  26567. }
  26568. _handleSingleObject(e) {
  26569. if (e.isError())
  26570. return e;
  26571. if (e.isNull() || e.isBoolean())
  26572. return ie.create();
  26573. const t = e.getValue();
  26574. return DC(t) ? y2.create(+t) : ie.create();
  26575. }
  26576. };
  26577. var sA = class extends V {
  26578. constructor() {
  26579. super(...arguments);
  26580. A(this, "minParams", 4);
  26581. A(this, "maxParams", 4);
  26582. }
  26583. calculate(e, t, r, n) {
  26584. const s = Math.max(
  26585. e.isArray() ? e.getRowCount() : 1,
  26586. t.isArray() ? t.getRowCount() : 1,
  26587. r.isArray() ? r.getRowCount() : 1,
  26588. n.isArray() ? n.getRowCount() : 1
  26589. ), o = Math.max(
  26590. e.isArray() ? e.getColumnCount() : 1,
  26591. t.isArray() ? t.getColumnCount() : 1,
  26592. r.isArray() ? r.getColumnCount() : 1,
  26593. n.isArray() ? n.getColumnCount() : 1
  26594. ), u = O(s, o, e, g2.create(m2.NA)), c = O(s, o, t, g2.create(m2.NA)), l2 = O(s, o, r, g2.create(m2.NA)), f2 = O(s, o, n, g2.create(m2.NA)), h = u.mapValue((d2, _, C) => {
  26595. const E2 = c.get(_, C), b = l2.get(_, C), R = f2.get(_, C);
  26596. return d2.isError() ? d2 : E2.isError() ? E2 : b.isError() ? b : R.isError() ? R : this._handleSignleObject(d2, E2, b, R);
  26597. });
  26598. return s === 1 && o === 1 ? h.get(0, 0) : h;
  26599. }
  26600. _handleSignleObject(e, t, r, n) {
  26601. const { isError: s, errorObject: o, variants: u } = I2(e, t, r, n);
  26602. if (s)
  26603. return o;
  26604. const [c, l2, f2, h] = u, d2 = +c.getValue(), _ = Math.floor(+l2.getValue()), C = Math.floor(+f2.getValue()), E2 = +h.getValue();
  26605. if (d2 < 0 || _ < 1 || _ > 10 ** 10 || C < 1 || C > 10 ** 10)
  26606. return g2.create(m2.NUM);
  26607. let b;
  26608. return E2 ? b = Pa(d2, _, C) : b = rm(d2, _, C), Number.isNaN(b) || !Number.isFinite(b) ? g2.create(m2.NUM) : y2.create(b);
  26609. }
  26610. };
  26611. var aA = class extends V {
  26612. constructor() {
  26613. super(...arguments);
  26614. A(this, "minParams", 3);
  26615. A(this, "maxParams", 3);
  26616. }
  26617. calculate(e, t, r) {
  26618. const n = Math.max(
  26619. e.isArray() ? e.getRowCount() : 1,
  26620. t.isArray() ? t.getRowCount() : 1,
  26621. r.isArray() ? r.getRowCount() : 1
  26622. ), s = Math.max(
  26623. e.isArray() ? e.getColumnCount() : 1,
  26624. t.isArray() ? t.getColumnCount() : 1,
  26625. r.isArray() ? r.getColumnCount() : 1
  26626. ), o = O(n, s, e, g2.create(m2.NA)), u = O(n, s, t, g2.create(m2.NA)), c = O(n, s, r, g2.create(m2.NA)), l2 = o.mapValue((f2, h, d2) => {
  26627. const _ = u.get(h, d2), C = c.get(h, d2);
  26628. return f2.isError() ? f2 : _.isError() ? _ : C.isError() ? C : this._handleSignleObject(f2, _, C);
  26629. });
  26630. return n === 1 && s === 1 ? l2.get(0, 0) : l2;
  26631. }
  26632. _handleSignleObject(e, t, r) {
  26633. const { isError: n, errorObject: s, variants: o } = I2(e, t, r);
  26634. if (n)
  26635. return s;
  26636. const [u, c, l2] = o, f2 = +u.getValue(), h = Math.floor(+c.getValue()), d2 = Math.floor(+l2.getValue());
  26637. if (f2 < 0 || f2 > 1 || h < 1 || h > 10 ** 10 || d2 < 1 || d2 > 10 ** 10)
  26638. return g2.create(m2.NUM);
  26639. const _ = Lo(f2, h, d2);
  26640. return Number.isNaN(_) || !Number.isFinite(_) ? g2.create(m2.NUM) : y2.create(_);
  26641. }
  26642. };
  26643. var iA = class extends V {
  26644. constructor() {
  26645. super(...arguments);
  26646. A(this, "minParams", 1);
  26647. A(this, "maxParams", 1);
  26648. }
  26649. calculate(e) {
  26650. return e.isArray() ? e.mapValue((t) => this._handleSingleObject(t)) : this._handleSingleObject(e);
  26651. }
  26652. _handleSingleObject(e) {
  26653. const { isError: t, errorObject: r, variants: n } = I2(e);
  26654. if (t)
  26655. return r;
  26656. const [s] = n, o = s.getValue();
  26657. if (o <= -1 || o >= 1)
  26658. return g2.create(m2.NUM);
  26659. const u = Math.log((1 + o) / (1 - o)) / 2;
  26660. return y2.create(u);
  26661. }
  26662. };
  26663. var oA = class extends V {
  26664. constructor() {
  26665. super(...arguments);
  26666. A(this, "minParams", 1);
  26667. A(this, "maxParams", 1);
  26668. }
  26669. calculate(e) {
  26670. return e.isArray() ? e.mapValue((t) => this._handleSingleObject(t)) : this._handleSingleObject(e);
  26671. }
  26672. _handleSingleObject(e) {
  26673. const { isError: t, errorObject: r, variants: n } = I2(e);
  26674. if (t)
  26675. return r;
  26676. const [s] = n, o = +s.getValue(), u = Math.exp(2 * o) - 1, c = Math.exp(2 * o) + 1;
  26677. return !Number.isFinite(u) && u > 0 && !Number.isFinite(c) && c > 0 ? y2.create(1) : y2.create(u / c);
  26678. }
  26679. };
  26680. var Li = class extends V {
  26681. constructor() {
  26682. super(...arguments);
  26683. A(this, "minParams", 3);
  26684. A(this, "maxParams", 3);
  26685. }
  26686. calculate(e, t, r) {
  26687. const n = t.isArray() ? t.getRowCount() : 1, s = t.isArray() ? t.getColumnCount() : 1, o = r.isArray() ? r.getRowCount() : 1, u = r.isArray() ? r.getColumnCount() : 1;
  26688. let c = t;
  26689. t.isArray() && n === 1 && s === 1 && (c = t.get(0, 0));
  26690. let l2 = r;
  26691. return r.isArray() && o === 1 && u === 1 && (l2 = r.get(0, 0)), e.isArray() ? e.mapValue(
  26692. (f2) => this._handleSignleObject(f2, c, l2, n, s, o, u)
  26693. ) : this._handleSignleObject(e, c, l2, n, s, o, u);
  26694. }
  26695. _handleSignleObject(e, t, r, n, s, o, u) {
  26696. if (e.isError())
  26697. return e;
  26698. if (t.isError())
  26699. return t;
  26700. if (r.isError())
  26701. return r;
  26702. let c = e;
  26703. if (e.isString() && (c = e.convertToNumberObjectValue()), c.isError())
  26704. return c;
  26705. const l2 = +c.getValue();
  26706. if ((n * s === 1 || o * u === 1) && (t.isNull() || r.isNull()))
  26707. return g2.create(m2.VALUE);
  26708. if (n * s !== o * u)
  26709. return g2.create(m2.NA);
  26710. const {
  26711. isError: f2,
  26712. errorObject: h,
  26713. array1Values: d2,
  26714. array2Values: _,
  26715. noCalculate: C
  26716. } = Je(
  26717. t,
  26718. r,
  26719. n * s,
  26720. s,
  26721. u
  26722. );
  26723. if (f2)
  26724. return h;
  26725. if (C)
  26726. return g2.create(m2.DIV_BY_ZERO);
  26727. const E2 = xo(l2, d2, _);
  26728. return Number.isFinite(E2) ? y2.create(E2) : g2.create(m2.DIV_BY_ZERO);
  26729. }
  26730. };
  26731. var uA = class extends V {
  26732. constructor() {
  26733. super(...arguments);
  26734. A(this, "minParams", 2);
  26735. A(this, "maxParams", 2);
  26736. }
  26737. calculate(e, t) {
  26738. const { isError: r, errorObject: n, values: s } = this._getValues(e);
  26739. if (r)
  26740. return n;
  26741. if (e.isNull() || t.isNull())
  26742. return g2.create(m2.VALUE);
  26743. let { values: o } = this._getValues(t, true);
  26744. o.length === 0 && (o = [0]);
  26745. const u = this._getNewBinsArrayValues(o), c = new Array(u.length).fill(0);
  26746. for (let l2 = 0; l2 < s.length; l2++) {
  26747. const f2 = s[l2], h = u.findIndex((d2) => f2 > d2.start && f2 <= d2.end);
  26748. c[h]++;
  26749. }
  26750. return q2.createByArray(c.map((l2) => [l2]));
  26751. }
  26752. _getValues(e, t = false) {
  26753. const r = [], n = e.isArray() ? e.getRowCount() : 1, s = e.isArray() ? e.getColumnCount() : 1;
  26754. for (let o = 0; o < n; o++)
  26755. for (let u = 0; u < s; u++) {
  26756. const c = e.isArray() ? e.get(o, u) : e;
  26757. if (c.isError()) {
  26758. if (!t)
  26759. return {
  26760. isError: true,
  26761. errorObject: c,
  26762. values: r
  26763. };
  26764. continue;
  26765. }
  26766. if (c.isNull() || c.isBoolean())
  26767. continue;
  26768. const l2 = c.getValue();
  26769. DC(l2) && r.push(+l2);
  26770. }
  26771. return {
  26772. isError: false,
  26773. errorObject: null,
  26774. values: r
  26775. };
  26776. }
  26777. _getNewBinsArrayValues(e) {
  26778. const t = e.map((n, s) => ({
  26779. value: n,
  26780. index: s
  26781. })).sort((n, s) => n.value - s.value), r = [];
  26782. for (let n = 0; n < t.length; n++) {
  26783. const s = t[n].index;
  26784. if (n === 0) {
  26785. r[s] = {
  26786. start: -1 / 0,
  26787. end: t[n].value
  26788. };
  26789. continue;
  26790. }
  26791. r[s] = {
  26792. start: t[n - 1].value,
  26793. end: t[n].value
  26794. };
  26795. }
  26796. return r.push({
  26797. start: t[t.length - 1].value,
  26798. end: 1 / 0
  26799. }), r;
  26800. }
  26801. };
  26802. var v = ((i) => (i.AVEDEV = "AVEDEV", i.AVERAGE = "AVERAGE", i.AVERAGE_WEIGHTED = "AVERAGE.WEIGHTED", i.AVERAGEA = "AVERAGEA", i.AVERAGEIF = "AVERAGEIF", i.AVERAGEIFS = "AVERAGEIFS", i.BETA_DIST = "BETA.DIST", i.BETA_INV = "BETA.INV", i.BINOM_DIST = "BINOM.DIST", i.BINOM_DIST_RANGE = "BINOM.DIST.RANGE", i.BINOM_INV = "BINOM.INV", i.CHISQ_DIST = "CHISQ.DIST", i.CHISQ_DIST_RT = "CHISQ.DIST.RT", i.CHISQ_INV = "CHISQ.INV", i.CHISQ_INV_RT = "CHISQ.INV.RT", i.CHISQ_TEST = "CHISQ.TEST", i.CONFIDENCE_NORM = "CONFIDENCE.NORM", i.CONFIDENCE_T = "CONFIDENCE.T", i.CORREL = "CORREL", i.COUNT = "COUNT", i.COUNTA = "COUNTA", i.COUNTBLANK = "COUNTBLANK", i.COUNTIF = "COUNTIF", i.COUNTIFS = "COUNTIFS", i.COVARIANCE_P = "COVARIANCE.P", i.COVARIANCE_S = "COVARIANCE.S", i.DEVSQ = "DEVSQ", i.EXPON_DIST = "EXPON.DIST", i.F_DIST = "F.DIST", i.F_DIST_RT = "F.DIST.RT", i.F_INV = "F.INV", i.F_INV_RT = "F.INV.RT", i.F_TEST = "F.TEST", i.FISHER = "FISHER", i.FISHERINV = "FISHERINV", i.FORECAST = "FORECAST", i.FORECAST_ETS = "FORECAST.ETS", i.FORECAST_ETS_CONFINT = "FORECAST.ETS.CONFINT", i.FORECAST_ETS_SEASONALITY = "FORECAST.ETS.SEASONALITY", i.FORECAST_ETS_STAT = "FORECAST.ETS.STAT", i.FORECAST_LINEAR = "FORECAST.LINEAR", i.FREQUENCY = "FREQUENCY", i.GAMMA = "GAMMA", i.GAMMA_DIST = "GAMMA.DIST", i.GAMMA_INV = "GAMMA.INV", i.GAMMALN = "GAMMALN", i.GAMMALN_PRECISE = "GAMMALN.PRECISE", i.GAUSS = "GAUSS", i.GEOMEAN = "GEOMEAN", i.GROWTH = "GROWTH", i.HARMEAN = "HARMEAN", i.HYPGEOM_DIST = "HYPGEOM.DIST", i.INTERCEPT = "INTERCEPT", i.KURT = "KURT", i.LARGE = "LARGE", i.LINEST = "LINEST", i.LOGEST = "LOGEST", i.LOGNORM_DIST = "LOGNORM.DIST", i.LOGNORM_INV = "LOGNORM.INV", i.MARGINOFERROR = "MARGINOFERROR", i.MAX = "MAX", i.MAXA = "MAXA", i.MAXIFS = "MAXIFS", i.MEDIAN = "MEDIAN", i.MIN = "MIN", i.MINA = "MINA", i.MINIFS = "MINIFS", i.MODE_MULT = "MODE.MULT", i.MODE_SNGL = "MODE.SNGL", i.NEGBINOM_DIST = "NEGBINOM.DIST", i.NORM_DIST = "NORM.DIST", i.NORM_INV = "NORM.INV", i.NORM_S_DIST = "NORM.S.DIST", i.NORM_S_INV = "NORM.S.INV", i.PEARSON = "PEARSON", i.PERCENTILE_EXC = "PERCENTILE.EXC", i.PERCENTILE_INC = "PERCENTILE.INC", i.PERCENTRANK_EXC = "PERCENTRANK.EXC", i.PERCENTRANK_INC = "PERCENTRANK.INC", i.PERMUT = "PERMUT", i.PERMUTATIONA = "PERMUTATIONA", i.PHI = "PHI", i.POISSON_DIST = "POISSON.DIST", i.PROB = "PROB", i.QUARTILE_EXC = "QUARTILE.EXC", i.QUARTILE_INC = "QUARTILE.INC", i.RANK_AVG = "RANK.AVG", i.RANK_EQ = "RANK.EQ", i.RSQ = "RSQ", i.SKEW = "SKEW", i.SKEW_P = "SKEW.P", i.SLOPE = "SLOPE", i.SMALL = "SMALL", i.STANDARDIZE = "STANDARDIZE", i.STDEV_P = "STDEV.P", i.STDEV_S = "STDEV.S", i.STDEVA = "STDEVA", i.STDEVPA = "STDEVPA", i.STEYX = "STEYX", i.T_DIST = "T.DIST", i.T_DIST_2T = "T.DIST.2T", i.T_DIST_RT = "T.DIST.RT", i.T_INV = "T.INV", i.T_INV_2T = "T.INV.2T", i.T_TEST = "T.TEST", i.TREND = "TREND", i.TRIMMEAN = "TRIMMEAN", i.VAR_P = "VAR.P", i.VAR_S = "VAR.S", i.VARA = "VARA", i.VARPA = "VARPA", i.WEIBULL_DIST = "WEIBULL.DIST", i.Z_TEST = "Z.TEST", i))(v || {});
  26803. var cA = class extends V {
  26804. constructor() {
  26805. super(...arguments);
  26806. A(this, "minParams", 1);
  26807. A(this, "maxParams", 1);
  26808. }
  26809. calculate(e) {
  26810. if (e.isArray()) {
  26811. const t = e.mapValue((r) => this._handleSingleObject(r));
  26812. return t.getRowCount() === 1 && t.getColumnCount() === 1 ? t.get(0, 0) : t;
  26813. }
  26814. return this._handleSingleObject(e);
  26815. }
  26816. _handleSingleObject(e) {
  26817. const { isError: t, errorObject: r, variants: n } = I2(e);
  26818. if (t)
  26819. return r;
  26820. const [s] = n, o = +s.getValue();
  26821. if (o === 0 || o < 0 && o % 1 === 0)
  26822. return g2.create(m2.NUM);
  26823. const u = on(o);
  26824. return Number.isNaN(u) || !Number.isFinite(u) ? g2.create(m2.NUM) : y2.create(u);
  26825. }
  26826. };
  26827. var xi = class extends V {
  26828. constructor() {
  26829. super(...arguments);
  26830. A(this, "minParams", 1);
  26831. A(this, "maxParams", 1);
  26832. }
  26833. calculate(e) {
  26834. if (e.isArray()) {
  26835. const t = e.mapValue((r) => this._handleSingleObject(r));
  26836. return t.getRowCount() === 1 && t.getColumnCount() === 1 ? t.get(0, 0) : t;
  26837. }
  26838. return this._handleSingleObject(e);
  26839. }
  26840. _handleSingleObject(e) {
  26841. const { isError: t, errorObject: r, variants: n } = I2(e);
  26842. if (t)
  26843. return r;
  26844. const [s] = n, o = +s.getValue();
  26845. if (o <= 0)
  26846. return g2.create(m2.NUM);
  26847. const u = ct(o);
  26848. return Math.abs(u) < 1e-15 ? y2.create(0) : y2.create(u);
  26849. }
  26850. };
  26851. var lA = class extends V {
  26852. constructor() {
  26853. super(...arguments);
  26854. A(this, "minParams", 1);
  26855. A(this, "maxParams", 1);
  26856. }
  26857. calculate(e) {
  26858. if (e.isArray()) {
  26859. const t = e.mapValue((r) => this._handleSingleObject(r));
  26860. return t.getRowCount() === 1 && t.getColumnCount() === 1 ? t.get(0, 0) : t;
  26861. }
  26862. return this._handleSingleObject(e);
  26863. }
  26864. _handleSingleObject(e) {
  26865. const { isError: t, errorObject: r, variants: n } = I2(e);
  26866. if (t)
  26867. return r;
  26868. const [s] = n, o = +s.getValue(), u = kr(o, 0, 1) - 0.5;
  26869. return y2.create(u);
  26870. }
  26871. };
  26872. var fA = class extends V {
  26873. constructor() {
  26874. super(...arguments);
  26875. A(this, "minParams", 1);
  26876. A(this, "maxParams", 255);
  26877. }
  26878. calculate(...e) {
  26879. let t = 1, r = 0, n = false;
  26880. for (let o = 0; o < e.length; o++) {
  26881. const u = e[o];
  26882. if (u.isArray()) {
  26883. let c = false, l2 = g2.create(m2.VALUE);
  26884. if (u.iterator((f2) => {
  26885. if (f2 != null && f2.isError())
  26886. return c = true, l2 = f2, false;
  26887. if (f2 != null && f2.isNull() || f2 != null && f2.isBoolean())
  26888. return true;
  26889. const h = f2.getValue();
  26890. if (!DC(h))
  26891. return true;
  26892. +h <= 0 && (n = true), t *= +h, r++;
  26893. }), c)
  26894. return l2;
  26895. } else {
  26896. if (u.isError())
  26897. return u;
  26898. if (u.isString()) {
  26899. const l2 = u.convertToNumberObjectValue();
  26900. if (l2.isError())
  26901. return l2;
  26902. }
  26903. if (u.isNull() || u.isBoolean())
  26904. continue;
  26905. const c = u.getValue();
  26906. if (!DC(c))
  26907. continue;
  26908. +c <= 0 && (n = true), t *= +c, r++;
  26909. }
  26910. }
  26911. if (r === 0 || n)
  26912. return g2.create(m2.NUM);
  26913. const s = t ** (1 / r);
  26914. return y2.create(s);
  26915. }
  26916. };
  26917. var hA = class extends V {
  26918. constructor() {
  26919. super(...arguments);
  26920. A(this, "minParams", 1);
  26921. A(this, "maxParams", 4);
  26922. }
  26923. calculate(e, t, r, n) {
  26924. const { isError: s, errorObject: o } = Kn(e, t, r);
  26925. if (s)
  26926. return o;
  26927. const u = dt(e);
  26928. if (u instanceof g2)
  26929. return u;
  26930. const c = this._getKnownXsValues(u, t);
  26931. if (c instanceof g2)
  26932. return c;
  26933. const l2 = this._getNewXsValues(c, r);
  26934. if (l2 instanceof g2)
  26935. return l2;
  26936. let f2 = n != null ? n : T2.create(true);
  26937. if (f2.isArray() && (f2 = f2.get(0, 0)), f2.isString() && (f2 = f2.convertToNumberObjectValue()), f2.isError())
  26938. return f2;
  26939. const h = +f2.getValue();
  26940. return this._getResult(u, c, l2, h);
  26941. }
  26942. _getResult(e, t, r, n) {
  26943. return e.length === 1 && t.length > 1 || e[0].length === 1 && t[0].length > 1 ? e.length === 1 && t.length > 1 && (n ? t.length + 1 : t.length) > e[0].length || e[0].length === 1 && t[0].length > 1 && (n ? t[0].length + 1 : t[0].length) > e.length ? g2.create(m2.NA) : this._getResultByMultipleVariables(e, t, r, n) : this._getResultBySimpleVariables(e, t, r, n);
  26944. }
  26945. _getResultByMultipleVariables(e, t, r, n) {
  26946. const s = e.length === 1 && e[0].length > 1, o = zn(e, t, r, n, true);
  26947. if (o instanceof g2)
  26948. return o;
  26949. const { coefficients: u, newX: c } = o, l2 = u[0].length, f2 = u[0][l2 - 1];
  26950. let h = [];
  26951. for (let d2 = 0; d2 < c.length; d2++) {
  26952. h[d2] = [];
  26953. let _ = f2;
  26954. for (let C = l2 - 2; C >= 0; C--)
  26955. _ *= u[0][l2 - 2 - C] ** c[d2][C];
  26956. h[d2].push(_);
  26957. }
  26958. return s && (h = mt(h)), q2.createByArray(h);
  26959. }
  26960. _getResultBySimpleVariables(e, t, r, n) {
  26961. const s = e.flat(), o = t.flat(), { slope: u, intercept: c } = Zn(o, s, n, true), l2 = r.map((f2) => f2.map((h) => c * u ** h));
  26962. return q2.createByArray(l2);
  26963. }
  26964. _getKnownXsValues(e, t) {
  26965. return !t || t.isNull() ? Xn(e.length, e[0].length) : dt(t);
  26966. }
  26967. _getNewXsValues(e, t) {
  26968. return !t || t.isNull() ? e : dt(t);
  26969. }
  26970. };
  26971. var mA = class extends V {
  26972. constructor() {
  26973. super(...arguments);
  26974. A(this, "minParams", 1);
  26975. A(this, "maxParams", 255);
  26976. }
  26977. calculate(...e) {
  26978. let t = 0, r = 0, n = false;
  26979. for (let o = 0; o < e.length; o++) {
  26980. const u = e[o];
  26981. if (u.isArray()) {
  26982. let c = false, l2 = g2.create(m2.VALUE);
  26983. if (u.iterator((f2) => {
  26984. if (f2 != null && f2.isError())
  26985. return c = true, l2 = f2, false;
  26986. if (f2 != null && f2.isNull() || f2 != null && f2.isBoolean())
  26987. return true;
  26988. const h = f2.getValue();
  26989. if (!DC(h))
  26990. return true;
  26991. +h <= 0 && (n = true), t += 1 / +h, r++;
  26992. }), c)
  26993. return l2;
  26994. } else {
  26995. if (u.isError())
  26996. return u;
  26997. if (u.isString()) {
  26998. const l2 = u.convertToNumberObjectValue();
  26999. if (l2.isError())
  27000. return l2;
  27001. }
  27002. if (u.isNull() || u.isBoolean())
  27003. continue;
  27004. const c = u.getValue();
  27005. if (!DC(c))
  27006. continue;
  27007. +c <= 0 && (n = true), t += 1 / +c, r++;
  27008. }
  27009. }
  27010. if (r === 0)
  27011. return g2.create(m2.NA);
  27012. if (n)
  27013. return g2.create(m2.NUM);
  27014. const s = r / t;
  27015. return y2.create(s);
  27016. }
  27017. };
  27018. var gA = class extends V {
  27019. constructor() {
  27020. super(...arguments);
  27021. A(this, "minParams", 5);
  27022. A(this, "maxParams", 5);
  27023. }
  27024. calculate(e, t, r, n, s) {
  27025. const o = Math.max(
  27026. e.isArray() ? e.getRowCount() : 1,
  27027. t.isArray() ? t.getRowCount() : 1,
  27028. r.isArray() ? r.getRowCount() : 1,
  27029. n.isArray() ? n.getRowCount() : 1,
  27030. s.isArray() ? s.getRowCount() : 1
  27031. ), u = Math.max(
  27032. e.isArray() ? e.getColumnCount() : 1,
  27033. t.isArray() ? t.getColumnCount() : 1,
  27034. r.isArray() ? r.getColumnCount() : 1,
  27035. n.isArray() ? n.getColumnCount() : 1,
  27036. s.isArray() ? s.getColumnCount() : 1
  27037. ), c = O(o, u, e, g2.create(m2.NA)), l2 = O(o, u, t, g2.create(m2.NA)), f2 = O(o, u, r, g2.create(m2.NA)), h = O(o, u, n, g2.create(m2.NA)), d2 = O(o, u, s, g2.create(m2.NA)), _ = c.mapValue((C, E2, b) => {
  27038. const R = l2.get(E2, b), p2 = f2.get(E2, b), N2 = h.get(E2, b), M2 = d2.get(E2, b);
  27039. return C.isError() ? C : R.isError() ? R : p2.isError() ? p2 : N2.isError() ? N2 : M2.isError() ? M2 : this._handleSignleObject(C, R, p2, N2, M2);
  27040. });
  27041. return o === 1 && u === 1 ? _.get(0, 0) : _;
  27042. }
  27043. _handleSignleObject(e, t, r, n, s) {
  27044. const { isError: o, errorObject: u, variants: c } = I2(e, t, r, n, s);
  27045. if (o)
  27046. return u;
  27047. const [l2, f2, h, d2, _] = c, C = Math.floor(+l2.getValue()), E2 = Math.floor(+f2.getValue()), b = Math.floor(+h.getValue()), R = Math.floor(+d2.getValue()), p2 = +_.getValue();
  27048. if (C < 0 || C > E2 || C > b || C < E2 - R + b || E2 <= 0 || E2 > R || b <= 0 || b > R || R <= 0)
  27049. return g2.create(m2.NUM);
  27050. let N2;
  27051. return p2 ? N2 = um(C, E2, b, R) : N2 = xa(C, E2, b, R), Number.isNaN(N2) && (N2 = 0), y2.create(N2);
  27052. }
  27053. };
  27054. var dA = class extends V {
  27055. constructor() {
  27056. super(...arguments);
  27057. A(this, "minParams", 2);
  27058. A(this, "maxParams", 2);
  27059. }
  27060. calculate(e, t) {
  27061. const r = e.isArray() ? e.getRowCount() : 1, n = e.isArray() ? e.getColumnCount() : 1, s = t.isArray() ? t.getRowCount() : 1, o = t.isArray() ? t.getColumnCount() : 1;
  27062. let u = e;
  27063. if (e.isArray() && r === 1 && n === 1 && (u = e.get(0, 0)), u.isError())
  27064. return u;
  27065. let c = t;
  27066. if (t.isArray() && s === 1 && o === 1 && (c = t.get(0, 0)), c.isError())
  27067. return c;
  27068. if (r * n === 1 || s * o === 1)
  27069. return u.isNull() || c.isNull() ? g2.create(m2.VALUE) : g2.create(m2.DIV_BY_ZERO);
  27070. if (r * n !== s * o)
  27071. return g2.create(m2.NA);
  27072. const {
  27073. isError: l2,
  27074. errorObject: f2,
  27075. array1Values: h,
  27076. array2Values: d2,
  27077. noCalculate: _
  27078. } = Je(
  27079. e,
  27080. t,
  27081. r * n,
  27082. n,
  27083. o
  27084. );
  27085. return l2 ? f2 : _ ? g2.create(m2.DIV_BY_ZERO) : this._getResult(h, d2);
  27086. }
  27087. _getResult(e, t) {
  27088. const r = xo(0, e, t);
  27089. return Number.isFinite(r) ? y2.create(r) : g2.create(m2.DIV_BY_ZERO);
  27090. }
  27091. };
  27092. var CA = class extends V {
  27093. constructor() {
  27094. super(...arguments);
  27095. A(this, "minParams", 1);
  27096. A(this, "maxParams", 255);
  27097. }
  27098. calculate(...e) {
  27099. const t = [];
  27100. let r = 0;
  27101. for (let n = 0; n < e.length; n++) {
  27102. const s = e[n];
  27103. if (s.isError())
  27104. return s;
  27105. if (s.isString()) {
  27106. const c = s.convertToNumberObjectValue();
  27107. if (c.isError())
  27108. return c;
  27109. }
  27110. const o = s.isArray() ? s.getRowCount() : 1, u = s.isArray() ? s.getColumnCount() : 1;
  27111. for (let c = 0; c < o; c++)
  27112. for (let l2 = 0; l2 < u; l2++) {
  27113. const f2 = s.isArray() ? s.get(c, l2) : s;
  27114. if (f2.isError())
  27115. return f2;
  27116. if (f2.isNull() || f2.isBoolean())
  27117. continue;
  27118. const h = f2.getValue();
  27119. DC(h) && (t.push(+h), r += +h);
  27120. }
  27121. }
  27122. return t.length <= 3 ? g2.create(m2.DIV_BY_ZERO) : this._getResult(t, r);
  27123. }
  27124. _getResult(e, t) {
  27125. const r = e.length, n = t / r;
  27126. let s = 0;
  27127. for (let l2 = 0; l2 < r; l2++)
  27128. s += (e[l2] - n) ** 2;
  27129. const o = Math.sqrt(s / (r - 1));
  27130. if (o === 0)
  27131. return g2.create(m2.DIV_BY_ZERO);
  27132. let u = 0;
  27133. for (let l2 = 0; l2 < r; l2++)
  27134. u += ((e[l2] - n) / o) ** 4;
  27135. const c = r * (r + 1) / ((r - 1) * (r - 2) * (r - 3)) * u - 3 * (r - 1) ** 2 / ((r - 2) * (r - 3));
  27136. return y2.create(c);
  27137. }
  27138. };
  27139. var _A = class extends V {
  27140. constructor() {
  27141. super(...arguments);
  27142. A(this, "minParams", 2);
  27143. A(this, "maxParams", 2);
  27144. }
  27145. calculate(e, t) {
  27146. const r = this._getValues(e);
  27147. if (t.isArray()) {
  27148. const n = t.mapValue((s) => this._handleSingleObject(r, s));
  27149. return n.getRowCount() === 1 && n.getColumnCount() === 1 ? n.get(0, 0) : n;
  27150. }
  27151. return this._handleSingleObject(r, t);
  27152. }
  27153. _handleSingleObject(e, t) {
  27154. if (e instanceof g2)
  27155. return e;
  27156. const { isError: r, errorObject: n, variants: s } = I2(t);
  27157. if (r)
  27158. return n;
  27159. const [o] = s;
  27160. let u = +o.getValue();
  27161. return u < 1 || u > e.length ? g2.create(m2.NUM) : (u = Math.ceil(u), y2.create(e[u - 1]));
  27162. }
  27163. _getValues(e) {
  27164. const t = e.isArray() ? e.getRowCount() : 1, r = e.isArray() ? e.getColumnCount() : 1, n = [];
  27165. for (let s = 0; s < t; s++)
  27166. for (let o = 0; o < r; o++) {
  27167. const u = e.isArray() ? e.get(s, o) : e;
  27168. if (u.isError())
  27169. return u;
  27170. if (u.isNull() || u.isBoolean() || u.isString())
  27171. continue;
  27172. const c = u.getValue();
  27173. DC(c) && n.push(+c);
  27174. }
  27175. return n.length === 0 ? g2.create(m2.NUM) : n.sort((s, o) => o - s);
  27176. }
  27177. };
  27178. var AA = class extends V {
  27179. constructor() {
  27180. super(...arguments);
  27181. A(this, "minParams", 1);
  27182. A(this, "maxParams", 4);
  27183. }
  27184. calculate(e, t, r, n) {
  27185. const { isError: s, errorObject: o } = Kn(e, t);
  27186. if (s)
  27187. return o;
  27188. const u = dt(e);
  27189. if (u instanceof g2)
  27190. return u;
  27191. const c = this._getKnownXsValues(u, t);
  27192. if (c instanceof g2)
  27193. return c;
  27194. let l2 = r != null ? r : T2.create(true);
  27195. l2.isArray() && (l2 = l2.get(0, 0));
  27196. let f2 = n != null ? n : T2.create(false);
  27197. f2.isArray() && (f2 = f2.get(0, 0));
  27198. const { isError: h, errorObject: d2, variants: _ } = I2(l2, f2);
  27199. if (h)
  27200. return d2;
  27201. const [C, E2] = _;
  27202. return this._getResult(u, c, +C.getValue(), +E2.getValue());
  27203. }
  27204. _getResult(e, t, r, n) {
  27205. return e.length === 1 && t.length > 1 || e[0].length === 1 && t[0].length > 1 ? e.length === 1 && t.length > 1 && (r ? t.length + 1 : t.length) > e[0].length || e[0].length === 1 && t[0].length > 1 && (r ? t[0].length + 1 : t[0].length) > e.length ? g2.create(m2.NA) : this._getResultByMultipleVariables(e, t, r, n) : this._getResultBySimpleVariables(e, t, r, n);
  27206. }
  27207. _getResultByMultipleVariables(e, t, r, n) {
  27208. const s = zn(e, t, t, r, false);
  27209. if (s instanceof g2)
  27210. return s;
  27211. const { coefficients: o, X: u, XTXInverse: c } = s;
  27212. let l2 = [];
  27213. if (n) {
  27214. const f2 = e.flat(), h = f2.length, d2 = r ? f2.reduce((x2, F) => x2 + F, 0) / h : 0, _ = c.length, C = h - _, E2 = o[0].length, b = new Array(E2 - 2).fill(m2.NA), R = o[0][E2 - 1], p2 = [];
  27215. for (let x2 = 0; x2 < u.length; x2++) {
  27216. let F = R;
  27217. for (let W2 = E2 - 2; W2 >= 0; W2--)
  27218. F += o[0][E2 - 2 - W2] * u[x2][W2];
  27219. p2.push(F);
  27220. }
  27221. let N2 = 0, M2 = 0;
  27222. for (let x2 = 0; x2 < h; x2++)
  27223. N2 += (f2[x2] - d2) ** 2, M2 += (f2[x2] - p2[x2]) ** 2;
  27224. const w = N2 - M2, D2 = N2 === 0 ? 0 : w / N2, S2 = [];
  27225. for (let x2 = _ - 1; x2 >= 0; x2--) {
  27226. const F = C > 0 ? Math.sqrt(M2 / C * c[x2][x2]) : 0;
  27227. S2.push(F);
  27228. }
  27229. if (r) {
  27230. const x2 = S2.shift();
  27231. S2.push(x2);
  27232. } else
  27233. S2.push(m2.NA);
  27234. const P = C > 0 ? Math.sqrt(M2 / C) : 0, U2 = C > 0 ? w / (E2 - 1) / (M2 / C) : m2.NUM;
  27235. l2 = [
  27236. o[0],
  27237. // [mn, mn-1, ..., m1, b]
  27238. [...S2],
  27239. // [sen, sen-1, ..., se1, seb]
  27240. [D2, P, ...b],
  27241. // [r2, sey]
  27242. [U2, C, ...b],
  27243. // [F, df]
  27244. [w, M2, ...b]
  27245. // [ssreg, ssresid]
  27246. ];
  27247. } else
  27248. l2 = [
  27249. o[0]
  27250. // [mn, mn-1, ..., m1, b]
  27251. ];
  27252. return q2.createByArray(l2);
  27253. }
  27254. _getResultBySimpleVariables(e, t, r, n) {
  27255. const s = e.flat(), o = t.flat(), { slope: u, intercept: c } = Zn(o, s, r, false);
  27256. if (Number.isNaN(u))
  27257. return g2.create(m2.NA);
  27258. let l2 = [];
  27259. if (n) {
  27260. const f2 = s.length;
  27261. let h = 0, d2 = 0, _ = f2 - 1;
  27262. if (r) {
  27263. let S2 = 0, P = 0;
  27264. for (let U2 = 0; U2 < f2; U2++)
  27265. S2 += s[U2], P += o[U2];
  27266. h = S2 / f2, d2 = P / f2, _ = f2 - 2;
  27267. }
  27268. let C = 0, E2 = 0, b = 0;
  27269. for (let S2 = 0; S2 < f2; S2++)
  27270. C += (s[S2] - h) ** 2, E2 += (s[S2] - (u * o[S2] + c)) ** 2, b += (o[S2] - d2) ** 2;
  27271. const R = C - E2, p2 = R === C ? 1 : R / C;
  27272. let N2 = 0, M2 = 0, w = 0;
  27273. _ > 0 && (b > 0 && (N2 = Math.sqrt(E2 / _ / b), M2 = Math.sqrt(E2 / _ * (1 / f2 + d2 ** 2 / b))), w = Math.sqrt(E2 / _));
  27274. const D2 = _ > 0 ? R / 1 / (E2 / _) : m2.NUM;
  27275. r || (M2 = m2.NA), l2 = [
  27276. [u, c],
  27277. // [m, b]
  27278. [N2, M2],
  27279. // [se, seb]
  27280. [p2, w],
  27281. // [r2, sey]
  27282. [D2, _],
  27283. // [F, df]
  27284. [R, E2]
  27285. // [ssreg, ssresid]
  27286. ];
  27287. } else
  27288. l2 = [
  27289. [u, c]
  27290. // [m, b]
  27291. ];
  27292. return q2.createByArray(l2);
  27293. }
  27294. _getKnownXsValues(e, t) {
  27295. return !t || t.isNull() ? Xn(e.length, e[0].length) : dt(t);
  27296. }
  27297. };
  27298. var EA = class extends V {
  27299. constructor() {
  27300. super(...arguments);
  27301. A(this, "minParams", 1);
  27302. A(this, "maxParams", 4);
  27303. }
  27304. calculate(e, t, r, n) {
  27305. const { isError: s, errorObject: o } = Kn(e, t);
  27306. if (s)
  27307. return o;
  27308. const u = dt(e);
  27309. if (u instanceof g2)
  27310. return u;
  27311. const c = this._getKnownXsValues(u, t);
  27312. if (c instanceof g2)
  27313. return c;
  27314. let l2 = r != null ? r : T2.create(true);
  27315. l2.isArray() && (l2 = l2.get(0, 0));
  27316. let f2 = n != null ? n : T2.create(false);
  27317. f2.isArray() && (f2 = f2.get(0, 0));
  27318. const { isError: h, errorObject: d2, variants: _ } = I2(l2, f2);
  27319. if (h)
  27320. return d2;
  27321. const [C, E2] = _;
  27322. return this._getResult(u, c, +C.getValue(), +E2.getValue());
  27323. }
  27324. _getResult(e, t, r, n) {
  27325. return e.length === 1 && t.length > 1 || e[0].length === 1 && t[0].length > 1 ? e.length === 1 && t.length > 1 && (r ? t.length + 1 : t.length) > e[0].length || e[0].length === 1 && t[0].length > 1 && (r ? t[0].length + 1 : t[0].length) > e.length ? g2.create(m2.NA) : this._getResultByMultipleVariables(e, t, r, n) : this._getResultBySimpleVariables(e, t, r, n);
  27326. }
  27327. // eslint-disable-next-line max-lines-per-function
  27328. _getResultByMultipleVariables(e, t, r, n) {
  27329. const s = zn(e, t, t, r, true);
  27330. if (s instanceof g2)
  27331. return s;
  27332. const { coefficients: o, Y: u, X: c, XTXInverse: l2 } = s;
  27333. let f2 = [];
  27334. if (n) {
  27335. const h = u.flat(), d2 = h.length, _ = r ? h.reduce((F, W2) => F + W2, 0) / d2 : 0, C = l2.length, E2 = d2 - C, b = o[0].length, R = new Array(b - 2).fill(m2.NA), p2 = o[0][b - 1], N2 = [];
  27336. for (let F = 0; F < c.length; F++) {
  27337. let W2 = p2;
  27338. for (let ne = b - 2; ne >= 0; ne--)
  27339. W2 *= o[0][b - 2 - ne] ** c[F][ne];
  27340. N2.push(Math.log(W2));
  27341. }
  27342. let M2 = 0, w = 0;
  27343. for (let F = 0; F < d2; F++)
  27344. M2 += (h[F] - _) ** 2, !(!r && !Number.isFinite(N2[F])) && (w += (h[F] - N2[F]) ** 2);
  27345. Number.isFinite(w) || (w = 0);
  27346. const D2 = M2 - w, S2 = M2 === 0 ? 0 : D2 / M2, P = [];
  27347. for (let F = C - 1; F >= 0; F--) {
  27348. const W2 = E2 > 0 ? Math.sqrt(w / E2 * l2[F][F]) : 0;
  27349. P.push(W2);
  27350. }
  27351. if (r) {
  27352. const F = P.shift();
  27353. P.push(F);
  27354. } else
  27355. P.push(m2.NA);
  27356. const U2 = E2 > 0 ? Math.sqrt(w / E2) : 0, x2 = E2 > 0 ? D2 / (b - 1) / (w / E2) : m2.NUM;
  27357. f2 = [
  27358. o[0],
  27359. // [mn, mn-1, ..., m1, b]
  27360. [...P],
  27361. // [sen, sen-1, ..., se1, seb]
  27362. [S2, U2, ...R],
  27363. // [r2, sey]
  27364. [x2, E2, ...R],
  27365. // [F, df]
  27366. [D2, w, ...R]
  27367. // [ssreg, ssresid]
  27368. ];
  27369. } else
  27370. f2 = [
  27371. o[0]
  27372. // [mn, mn-1, ..., m1, b]
  27373. ];
  27374. return q2.createByArray(f2);
  27375. }
  27376. _getResultBySimpleVariables(e, t, r, n) {
  27377. const s = e.flat(), o = t.flat(), { slope: u, intercept: c, Y: l2 } = Zn(o, s, r, true);
  27378. if (Number.isNaN(u))
  27379. return g2.create(m2.NA);
  27380. let f2 = [];
  27381. if (n) {
  27382. const h = l2.length;
  27383. let d2 = 0, _ = 0, C = h - 1;
  27384. if (r) {
  27385. let P = 0, U2 = 0;
  27386. for (let x2 = 0; x2 < h; x2++)
  27387. P += l2[x2], U2 += o[x2];
  27388. d2 = P / h, _ = U2 / h, C = h - 2;
  27389. }
  27390. let E2 = 0, b = 0, R = 0;
  27391. for (let P = 0; P < h; P++)
  27392. E2 += (l2[P] - d2) ** 2, b += (l2[P] - Math.log(c * u ** o[P])) ** 2, R += (o[P] - _) ** 2;
  27393. const p2 = E2 - b, N2 = E2 === 0 ? 0 : p2 / E2;
  27394. let M2 = 0, w = 0, D2 = 0, S2 = 0;
  27395. C > 0 && (R > 0 && (M2 = Math.sqrt(b / C / R), w = Math.sqrt(b / C * (1 / h + _ ** 2 / R))), D2 = Math.sqrt(b / C), S2 = p2 / 1 / (b / C)), r || (w = m2.NA), f2 = [
  27396. [u, c],
  27397. // [m, b]
  27398. [M2, w],
  27399. // [se, seb]
  27400. [N2, D2],
  27401. // [r2, sey]
  27402. [S2, C],
  27403. // [F, df]
  27404. [p2, b]
  27405. // [ssreg, ssresid]
  27406. ];
  27407. } else
  27408. f2 = [
  27409. [u, c]
  27410. // [m, b]
  27411. ];
  27412. return q2.createByArray(f2);
  27413. }
  27414. _getKnownXsValues(e, t) {
  27415. return !t || t.isNull() ? Xn(e.length, e[0].length) : dt(t);
  27416. }
  27417. };
  27418. var bA = class extends V {
  27419. constructor() {
  27420. super(...arguments);
  27421. A(this, "minParams", 4);
  27422. A(this, "maxParams", 4);
  27423. }
  27424. calculate(e, t, r, n) {
  27425. const s = Math.max(
  27426. e.isArray() ? e.getRowCount() : 1,
  27427. t.isArray() ? t.getRowCount() : 1,
  27428. r.isArray() ? r.getRowCount() : 1,
  27429. n.isArray() ? n.getRowCount() : 1
  27430. ), o = Math.max(
  27431. e.isArray() ? e.getColumnCount() : 1,
  27432. t.isArray() ? t.getColumnCount() : 1,
  27433. r.isArray() ? r.getColumnCount() : 1,
  27434. n.isArray() ? n.getColumnCount() : 1
  27435. ), u = O(s, o, e, g2.create(m2.NA)), c = O(s, o, t, g2.create(m2.NA)), l2 = O(s, o, r, g2.create(m2.NA)), f2 = O(s, o, n, g2.create(m2.NA)), h = u.mapValue((d2, _, C) => {
  27436. const E2 = c.get(_, C), b = l2.get(_, C), R = f2.get(_, C);
  27437. return d2.isError() ? d2 : E2.isError() ? E2 : b.isError() ? b : R.isError() ? R : this._handleSignleObject(d2, E2, b, R);
  27438. });
  27439. return s === 1 && o === 1 ? h.get(0, 0) : h;
  27440. }
  27441. _handleSignleObject(e, t, r, n) {
  27442. const { isError: s, errorObject: o, variants: u } = I2(e, t, r, n);
  27443. if (s)
  27444. return o;
  27445. const [c, l2, f2, h] = u, d2 = +c.getValue(), _ = +l2.getValue(), C = +f2.getValue(), E2 = +h.getValue();
  27446. if (d2 <= 0 || C <= 0)
  27447. return g2.create(m2.NUM);
  27448. let b;
  27449. return E2 ? b = Uo(d2, _, C) : b = cm(d2, _, C), y2.create(b);
  27450. }
  27451. };
  27452. var yA = class extends V {
  27453. constructor() {
  27454. super(...arguments);
  27455. A(this, "minParams", 2);
  27456. A(this, "maxParams", 2);
  27457. }
  27458. calculate(e, t) {
  27459. const r = this._getRangeValues(e);
  27460. if (r instanceof g2)
  27461. return r;
  27462. const n = Xt(t);
  27463. if (n.isError())
  27464. return n;
  27465. const { isError: s, errorObject: o, variants: u } = I2(n);
  27466. if (s)
  27467. return o;
  27468. const [c] = u, l2 = +c.getValue();
  27469. if (l2 <= 0 || l2 >= 1)
  27470. return g2.create(m2.NUM);
  27471. if (r.length < 2)
  27472. return g2.create(m2.DIV_BY_ZERO);
  27473. const f2 = 1 - l2, h = r.length, d2 = r.reduce((b, R) => b + R, 0) / h, _ = r.reduce((b, R) => b + (R - d2) ** 2, 0) / (h - 1), C = Math.sqrt(_);
  27474. if (C <= 0)
  27475. return g2.create(m2.NUM);
  27476. const E2 = Math.abs(qn(f2 / 2, h - 1) * C / Math.sqrt(h));
  27477. return y2.create(E2);
  27478. }
  27479. _getRangeValues(e) {
  27480. const t = [], r = e.isArray() ? e.getRowCount() : 1, n = e.isArray() ? e.getColumnCount() : 1;
  27481. for (let s = 0; s < r; s++)
  27482. for (let o = 0; o < n; o++) {
  27483. const u = e.isArray() ? e.get(s, o) : e;
  27484. if (u.isError())
  27485. return u;
  27486. u.isNull() || u.isBoolean() || u.isString() || t.push(+u.getValue());
  27487. }
  27488. return t;
  27489. }
  27490. };
  27491. var RA = class extends V {
  27492. constructor() {
  27493. super(...arguments);
  27494. A(this, "minParams", 1);
  27495. A(this, "maxParams", 255);
  27496. }
  27497. calculate(...e) {
  27498. let t = y2.create(Number.NEGATIVE_INFINITY);
  27499. for (let r = 0; r < e.length; r++) {
  27500. let n = e[r];
  27501. if (!n.isNull()) {
  27502. if ((n.isString() || n.isBoolean()) && (n = n.convertToNumberObjectValue()), n.isArray() && (n = n.max()), n.isError())
  27503. return n;
  27504. t = this._validator(t, n);
  27505. }
  27506. }
  27507. return t.getValue() === Number.NEGATIVE_INFINITY ? y2.create(0) : t;
  27508. }
  27509. _validator(e, t) {
  27510. const r = e.isLessThan(t);
  27511. let n = e;
  27512. return r.getValue() && (n = t), n;
  27513. }
  27514. };
  27515. var pA = class extends V {
  27516. constructor() {
  27517. super(...arguments);
  27518. A(this, "minParams", 1);
  27519. A(this, "maxParams", 255);
  27520. }
  27521. calculate(...e) {
  27522. let t = y2.create(Number.NEGATIVE_INFINITY);
  27523. for (let r = 0; r < e.length; r++) {
  27524. let n = e[r];
  27525. if (!n.isNull()) {
  27526. if ((n.isString() || n.isBoolean()) && (n = n.convertToNumberObjectValue()), n.isError())
  27527. return n;
  27528. if (n.isArray() && n.iterator((s) => {
  27529. let o = s;
  27530. if ((o == null || o.isNull() || o.isString()) && (o = y2.create(0)), o.isBoolean() && (o = o.convertToNumberObjectValue()), o.isError())
  27531. return t = o, false;
  27532. t = this._validator(t, o);
  27533. }), t.isError())
  27534. return t;
  27535. t = this._validator(t, n);
  27536. }
  27537. }
  27538. return t.getValue() === Number.NEGATIVE_INFINITY ? y2.create(0) : t;
  27539. }
  27540. _validator(e, t) {
  27541. const r = e.isLessThan(t);
  27542. let n = e;
  27543. return r.getValue() && (n = t), n;
  27544. }
  27545. };
  27546. var VA = class extends V {
  27547. constructor() {
  27548. super(...arguments);
  27549. A(this, "minParams", 3);
  27550. A(this, "maxParams", 255);
  27551. }
  27552. calculate(e, ...t) {
  27553. if (e.isError())
  27554. return g2.create(m2.NA);
  27555. if (!e.isArray() || t.length % 2 !== 0 || t.some((u, c) => c % 2 === 0 && !u.isArray()))
  27556. return g2.create(m2.VALUE);
  27557. const { maxRowLength: r, maxColumnLength: n } = Nr(t), s = Br(t, e, r, n);
  27558. if (s)
  27559. return s;
  27560. const o = Ir(t, r, n, true);
  27561. return this._aggregateResults(e, o);
  27562. }
  27563. _aggregateResults(e, t) {
  27564. const r = t.map((s) => s.map((o) => {
  27565. const u = e.pick(o);
  27566. return u.getColumnCount() === 0 ? q2.create("0") : u.max();
  27567. })), n = {
  27568. calculateValueList: r,
  27569. rowCount: r.length,
  27570. columnCount: r[0].length,
  27571. unitId: this.unitId || "",
  27572. sheetId: this.subUnitId || "",
  27573. row: this.row,
  27574. column: this.column
  27575. };
  27576. return q2.create(n);
  27577. }
  27578. };
  27579. var NA = class extends V {
  27580. constructor() {
  27581. super(...arguments);
  27582. A(this, "minParams", 1);
  27583. A(this, "maxParams", 255);
  27584. }
  27585. calculate(...e) {
  27586. const t = [];
  27587. for (let r = 0; r < e.length; r++) {
  27588. const n = e[r];
  27589. if (n.isArray()) {
  27590. let s = false, o = g2.create(m2.VALUE);
  27591. if (n.iterator((u) => {
  27592. if (u != null && u.isError())
  27593. return s = true, o = u, false;
  27594. if (u != null && u.isNull() || u != null && u.isBoolean())
  27595. return true;
  27596. const c = u.getValue();
  27597. if (!DC(c))
  27598. return true;
  27599. t.push(+c);
  27600. }), s)
  27601. return o;
  27602. } else {
  27603. if (n.isError())
  27604. return n;
  27605. if (n.isNull() || n.isBoolean())
  27606. continue;
  27607. if (n.isString()) {
  27608. const o = n.convertToNumberObjectValue();
  27609. if (o.isError())
  27610. return o;
  27611. }
  27612. const s = n.getValue();
  27613. if (!DC(s))
  27614. continue;
  27615. t.push(+s);
  27616. }
  27617. }
  27618. return t.length === 0 ? g2.create(m2.NUM) : this._getResult(t.sort((r, n) => r - n));
  27619. }
  27620. _getResult(e) {
  27621. const t = e.length;
  27622. let r;
  27623. if (t % 2 === 0) {
  27624. const n = t / 2;
  27625. r = (e[n - 1] + e[n]) / 2;
  27626. } else
  27627. r = e[Math.floor(t / 2)];
  27628. return y2.create(r);
  27629. }
  27630. };
  27631. var OA = class extends V {
  27632. constructor() {
  27633. super(...arguments);
  27634. A(this, "minParams", 1);
  27635. A(this, "maxParams", 255);
  27636. }
  27637. calculate(...e) {
  27638. let t = y2.create(Number.POSITIVE_INFINITY);
  27639. for (let r = 0; r < e.length; r++) {
  27640. let n = e[r];
  27641. if (!n.isNull()) {
  27642. if ((n.isString() || n.isBoolean()) && (n = n.convertToNumberObjectValue()), n.isArray() && (n = n.min()), n.isError())
  27643. return n;
  27644. t = this._validator(t, n);
  27645. }
  27646. }
  27647. return t.getValue() === Number.POSITIVE_INFINITY ? y2.create(0) : t;
  27648. }
  27649. _validator(e, t) {
  27650. const r = e.isGreaterThan(t);
  27651. let n = e;
  27652. return r.getValue() && (n = t), n;
  27653. }
  27654. };
  27655. var MA = class extends V {
  27656. constructor() {
  27657. super(...arguments);
  27658. A(this, "minParams", 1);
  27659. A(this, "maxParams", 255);
  27660. }
  27661. calculate(...e) {
  27662. let t = y2.create(Number.POSITIVE_INFINITY);
  27663. for (let r = 0; r < e.length; r++) {
  27664. let n = e[r];
  27665. if (!n.isNull()) {
  27666. if ((n.isString() || n.isBoolean()) && (n = n.convertToNumberObjectValue()), n.isError())
  27667. return n;
  27668. if (n.isArray() && n.iterator((s) => {
  27669. let o = s;
  27670. if ((o == null || o.isNull() || o.isString()) && (o = y2.create(0)), o.isBoolean() && (o = o.convertToNumberObjectValue()), o.isError())
  27671. return t = o, false;
  27672. t = this._validator(t, o);
  27673. }), t.isError())
  27674. return t;
  27675. t = this._validator(t, n);
  27676. }
  27677. }
  27678. return t.getValue() === Number.POSITIVE_INFINITY ? y2.create(0) : t;
  27679. }
  27680. _validator(e, t) {
  27681. const r = e.isGreaterThan(t);
  27682. let n = e;
  27683. return r.getValue() && (n = t), n;
  27684. }
  27685. };
  27686. var wA = class extends V {
  27687. constructor() {
  27688. super(...arguments);
  27689. A(this, "minParams", 3);
  27690. A(this, "maxParams", 255);
  27691. }
  27692. calculate(e, ...t) {
  27693. if (e.isError())
  27694. return g2.create(m2.NA);
  27695. if (!e.isArray() || t.length % 2 !== 0 || t.some((u, c) => c % 2 === 0 && !u.isArray()))
  27696. return g2.create(m2.VALUE);
  27697. const { maxRowLength: r, maxColumnLength: n } = Nr(t), s = Br(t, e, r, n);
  27698. if (s)
  27699. return s;
  27700. const o = Ir(t, r, n, true);
  27701. return this._aggregateResults(e, o);
  27702. }
  27703. _aggregateResults(e, t) {
  27704. const r = t.map((s) => s.map((o) => {
  27705. const u = e.pick(o);
  27706. return u.getColumnCount() === 0 ? q2.create("0") : u.min();
  27707. })), n = {
  27708. calculateValueList: r,
  27709. rowCount: r.length,
  27710. columnCount: r[0].length,
  27711. unitId: this.unitId || "",
  27712. sheetId: this.subUnitId || "",
  27713. row: this.row,
  27714. column: this.column
  27715. };
  27716. return q2.create(n);
  27717. }
  27718. };
  27719. var DA = class extends V {
  27720. constructor() {
  27721. super(...arguments);
  27722. A(this, "minParams", 1);
  27723. A(this, "maxParams", 255);
  27724. }
  27725. calculate(...e) {
  27726. const t = {};
  27727. let r = 0, n = 1;
  27728. for (let s = 0; s < e.length; s++) {
  27729. const o = e[s];
  27730. if (o.isError())
  27731. return o;
  27732. if (o.isString()) {
  27733. const l2 = o.convertToNumberObjectValue();
  27734. if (l2.isError())
  27735. return l2;
  27736. }
  27737. const u = o.isArray() ? o.getRowCount() : 1, c = o.isArray() ? o.getColumnCount() : 1;
  27738. for (let l2 = 0; l2 < u; l2++)
  27739. for (let f2 = 0; f2 < c; f2++) {
  27740. const h = o.isArray() ? o.get(l2, f2) : o;
  27741. if (h.isError())
  27742. return h;
  27743. if (h.isNull() || h.isBoolean() || h.isString())
  27744. continue;
  27745. const d2 = h.getValue();
  27746. DC(d2) && (t[+d2] ? (t[+d2].count++, t[+d2].count > n && (n = t[+d2].count)) : t[+d2] = { count: 1, order: r++ });
  27747. }
  27748. }
  27749. return r === 0 || n === 1 ? new g2(m2.NA) : this._getResult(t, n);
  27750. }
  27751. _getResult(e, t) {
  27752. const r = Object.entries(e).filter(([n, { count: s }]) => s === t).sort((n, s) => n[1].order - s[1].order).map(([n]) => +n);
  27753. return r.length === 1 ? y2.create(r[0]) : q2.createByArray(r.map((n) => [n]));
  27754. }
  27755. };
  27756. var SA = class extends V {
  27757. constructor() {
  27758. super(...arguments);
  27759. A(this, "minParams", 4);
  27760. A(this, "maxParams", 4);
  27761. }
  27762. calculate(e, t, r, n) {
  27763. const s = Math.max(
  27764. e.isArray() ? e.getRowCount() : 1,
  27765. t.isArray() ? t.getRowCount() : 1,
  27766. r.isArray() ? r.getRowCount() : 1,
  27767. n.isArray() ? n.getRowCount() : 1
  27768. ), o = Math.max(
  27769. e.isArray() ? e.getColumnCount() : 1,
  27770. t.isArray() ? t.getColumnCount() : 1,
  27771. r.isArray() ? r.getColumnCount() : 1,
  27772. n.isArray() ? n.getColumnCount() : 1
  27773. ), u = O(s, o, e, g2.create(m2.NA)), c = O(s, o, t, g2.create(m2.NA)), l2 = O(s, o, r, g2.create(m2.NA)), f2 = O(s, o, n, g2.create(m2.NA)), h = u.mapValue((d2, _, C) => {
  27774. const E2 = c.get(_, C), b = l2.get(_, C), R = f2.get(_, C);
  27775. return d2.isError() ? d2 : E2.isError() ? E2 : b.isError() ? b : R.isError() ? R : this._handleSignleObject(d2, E2, b, R);
  27776. });
  27777. return s === 1 && o === 1 ? h.get(0, 0) : h;
  27778. }
  27779. _handleSignleObject(e, t, r, n) {
  27780. const { isError: s, errorObject: o, variants: u } = I2(e, t, r, n);
  27781. if (s)
  27782. return o;
  27783. const [c, l2, f2, h] = u, d2 = Math.floor(+c.getValue()), _ = Math.floor(+l2.getValue()), C = +f2.getValue(), E2 = +h.getValue();
  27784. if (d2 < 0 || _ < 1 || C <= 0 || C >= 1)
  27785. return g2.create(m2.NUM);
  27786. let b;
  27787. return E2 ? b = fm(d2, _, C) : b = ja(d2, _, C), y2.create(b);
  27788. }
  27789. };
  27790. var PA = class extends V {
  27791. constructor() {
  27792. super(...arguments);
  27793. A(this, "minParams", 2);
  27794. A(this, "maxParams", 2);
  27795. }
  27796. calculate(e, t) {
  27797. const r = Math.max(
  27798. e.isArray() ? e.getRowCount() : 1,
  27799. t.isArray() ? t.getRowCount() : 1
  27800. ), n = Math.max(
  27801. e.isArray() ? e.getColumnCount() : 1,
  27802. t.isArray() ? t.getColumnCount() : 1
  27803. ), s = O(r, n, e, g2.create(m2.NA)), o = O(r, n, t, g2.create(m2.NA)), u = s.mapValue((c, l2, f2) => {
  27804. const h = o.get(l2, f2);
  27805. return c.isError() ? c : h.isError() ? h : this._handleSignleObject(c, h);
  27806. });
  27807. return r === 1 && n === 1 ? u.get(0, 0) : u;
  27808. }
  27809. _handleSignleObject(e, t) {
  27810. const { isError: r, errorObject: n, variants: s } = I2(e, t);
  27811. if (r)
  27812. return n;
  27813. const [o, u] = s, c = +o.getValue(), l2 = +u.getValue();
  27814. let f2;
  27815. return l2 ? f2 = kr(c, 0, 1) : f2 = vo(c, 0, 1), y2.create(f2);
  27816. }
  27817. };
  27818. var LA = class extends V {
  27819. constructor() {
  27820. super(...arguments);
  27821. A(this, "minParams", 2);
  27822. A(this, "maxParams", 2);
  27823. }
  27824. calculate(e, t) {
  27825. const r = e.isArray() ? e.getRowCount() : 1, n = e.isArray() ? e.getColumnCount() : 1, s = t.isArray() ? t.getRowCount() : 1, o = t.isArray() ? t.getColumnCount() : 1;
  27826. let u = e;
  27827. if (e.isArray() && r === 1 && n === 1 && (u = e.get(0, 0)), u.isError())
  27828. return u;
  27829. let c = t;
  27830. if (t.isArray() && s === 1 && o === 1 && (c = t.get(0, 0)), c.isError())
  27831. return c;
  27832. if (r * n === 1 || s * o === 1)
  27833. return u.isNull() || c.isNull() ? g2.create(m2.VALUE) : g2.create(m2.DIV_BY_ZERO);
  27834. if (r * n !== s * o)
  27835. return g2.create(m2.NA);
  27836. const {
  27837. isError: l2,
  27838. errorObject: f2,
  27839. array1Values: h,
  27840. array2Values: d2,
  27841. noCalculate: _
  27842. } = Je(
  27843. e,
  27844. t,
  27845. r * n,
  27846. n,
  27847. o
  27848. );
  27849. return l2 ? f2 : _ ? g2.create(m2.DIV_BY_ZERO) : this._getResult(h, d2);
  27850. }
  27851. _getResult(e, t) {
  27852. const r = e.length;
  27853. let n = 0, s = 0;
  27854. for (let d2 = 0; d2 < r; d2++)
  27855. n += e[d2], s += t[d2];
  27856. const o = n / r, u = s / r;
  27857. let c = 0, l2 = 0, f2 = 0;
  27858. for (let d2 = 0; d2 < r; d2++)
  27859. c += (e[d2] - o) * (t[d2] - u), l2 += (e[d2] - o) ** 2, f2 += (t[d2] - u) ** 2;
  27860. if (l2 === 0 || f2 === 0)
  27861. return g2.create(m2.DIV_BY_ZERO);
  27862. const h = c / Math.sqrt(l2 * f2);
  27863. return y2.create(h);
  27864. }
  27865. };
  27866. var xA = class extends V {
  27867. constructor() {
  27868. super(...arguments);
  27869. A(this, "minParams", 2);
  27870. A(this, "maxParams", 2);
  27871. }
  27872. calculate(e, t) {
  27873. const r = this._getValues(e);
  27874. if (t.isArray()) {
  27875. const n = t.mapValue((s) => this._handleSingleObject(r, s));
  27876. return n.getRowCount() === 1 && n.getColumnCount() === 1 ? n.get(0, 0) : n;
  27877. }
  27878. return this._handleSingleObject(r, t);
  27879. }
  27880. _handleSingleObject(e, t) {
  27881. if (e instanceof g2)
  27882. return e;
  27883. const { isError: r, errorObject: n, variants: s } = I2(t);
  27884. if (r)
  27885. return n;
  27886. const [o] = s, u = +o.getValue(), c = e.length;
  27887. if (u < 1 / (c + 1) || u > 1 - 1 / (c + 1))
  27888. return g2.create(m2.NUM);
  27889. const l2 = u * (c + 1) - 1, f2 = Math.floor(l2), h = l2 - f2;
  27890. if (h === 0)
  27891. return y2.create(e[f2]);
  27892. const d2 = e[f2] + h * (e[f2 + 1] - e[f2]);
  27893. return y2.create(d2);
  27894. }
  27895. _getValues(e) {
  27896. const t = e.isArray() ? e.getRowCount() : 1, r = e.isArray() ? e.getColumnCount() : 1, n = [];
  27897. for (let s = 0; s < t; s++)
  27898. for (let o = 0; o < r; o++) {
  27899. const u = e.isArray() ? e.get(s, o) : e;
  27900. if (u.isError())
  27901. return u;
  27902. if (u.isNull() || u.isBoolean() || u.isString())
  27903. continue;
  27904. const c = u.getValue();
  27905. DC(c) && n.push(+c);
  27906. }
  27907. return n.length === 0 ? g2.create(m2.NUM) : n.sort((s, o) => s - o);
  27908. }
  27909. };
  27910. var jA = class extends V {
  27911. constructor() {
  27912. super(...arguments);
  27913. A(this, "minParams", 2);
  27914. A(this, "maxParams", 3);
  27915. }
  27916. calculate(e, t, r) {
  27917. const n = this._getValues(e);
  27918. let s = r != null ? r : y2.create(3);
  27919. s.isNull() && (s = y2.create(3));
  27920. const o = Math.max(
  27921. t.isArray() ? t.getRowCount() : 1,
  27922. s.isArray() ? s.getRowCount() : 1
  27923. ), u = Math.max(
  27924. t.isArray() ? t.getColumnCount() : 1,
  27925. s.isArray() ? s.getColumnCount() : 1
  27926. ), c = O(o, u, t, g2.create(m2.NA)), l2 = O(o, u, s, g2.create(m2.NA)), f2 = c.mapValue((h, d2, _) => {
  27927. const C = l2.get(d2, _);
  27928. return h.isError() ? h : C.isError() ? C : this._handleSingleObject(n, h, C);
  27929. });
  27930. return o === 1 && u === 1 ? f2.get(0, 0) : f2;
  27931. }
  27932. _handleSingleObject(e, t, r) {
  27933. if (e instanceof g2)
  27934. return e;
  27935. const { isError: n, errorObject: s, variants: o } = I2(t, r);
  27936. if (n)
  27937. return s;
  27938. const [u, c] = o, l2 = +u.getValue(), f2 = Math.floor(+c.getValue()), h = e.length;
  27939. if (h === 0 || l2 < e[0] || l2 > e[h - 1])
  27940. return g2.create(m2.NA);
  27941. if (h === 1)
  27942. return l2 === e[0] ? y2.create(1) : g2.create(m2.NA);
  27943. let d2 = 0, _ = false, C = 0;
  27944. for (; !_ && C < h; )
  27945. l2 === e[C] ? (d2 = (C + 1) / (h + 1), _ = true) : l2 > e[C] && C + 1 < h && l2 < e[C + 1] && (d2 = (C + 1 + (l2 - e[C]) / (e[C + 1] - e[C])) / (h + 1), _ = true), C++;
  27946. return _ ? f2 < 1 ? g2.create(m2.NUM) : (d2 = We(d2, f2), y2.create(d2)) : g2.create(m2.NA);
  27947. }
  27948. _getValues(e) {
  27949. const t = e.isArray() ? e.getRowCount() : 1, r = e.isArray() ? e.getColumnCount() : 1, n = [];
  27950. for (let s = 0; s < t; s++)
  27951. for (let o = 0; o < r; o++) {
  27952. const u = e.isArray() ? e.get(s, o) : e;
  27953. if (u.isError())
  27954. return u;
  27955. if (u.isNull() || u.isBoolean())
  27956. continue;
  27957. const c = u.getValue();
  27958. DC(c) && n.push(+c);
  27959. }
  27960. return n.sort((s, o) => s - o);
  27961. }
  27962. };
  27963. var UA = class extends V {
  27964. constructor() {
  27965. super(...arguments);
  27966. A(this, "minParams", 2);
  27967. A(this, "maxParams", 2);
  27968. }
  27969. calculate(e, t) {
  27970. const r = Math.max(
  27971. e.isArray() ? e.getRowCount() : 1,
  27972. t.isArray() ? t.getRowCount() : 1
  27973. ), n = Math.max(
  27974. e.isArray() ? e.getColumnCount() : 1,
  27975. t.isArray() ? t.getColumnCount() : 1
  27976. ), s = O(r, n, e, g2.create(m2.NA)), o = O(r, n, t, g2.create(m2.NA)), u = s.mapValue((c, l2, f2) => {
  27977. const h = o.get(l2, f2);
  27978. if (c.isError())
  27979. return c;
  27980. if (h.isError())
  27981. return h;
  27982. const { isError: d2, errorObject: _, variants: C } = I2(c, h);
  27983. if (d2)
  27984. return _;
  27985. const [E2, b] = C, R = Math.floor(+E2.getValue()), p2 = Math.floor(+b.getValue());
  27986. if (R < 0 || R >= 2147483647 || p2 < 0 || R < p2)
  27987. return g2.create(m2.NUM);
  27988. let N2 = 1;
  27989. for (let M2 = R - p2 + 1; M2 <= R; M2++)
  27990. N2 *= M2;
  27991. return Number.isFinite(N2) ? y2.create(N2) : g2.create(m2.NUM);
  27992. });
  27993. return r === 1 && n === 1 ? u.get(0, 0) : u;
  27994. }
  27995. };
  27996. var vA = class extends V {
  27997. constructor() {
  27998. super(...arguments);
  27999. A(this, "minParams", 2);
  28000. A(this, "maxParams", 2);
  28001. }
  28002. calculate(e, t) {
  28003. const r = Math.max(
  28004. e.isArray() ? e.getRowCount() : 1,
  28005. t.isArray() ? t.getRowCount() : 1
  28006. ), n = Math.max(
  28007. e.isArray() ? e.getColumnCount() : 1,
  28008. t.isArray() ? t.getColumnCount() : 1
  28009. ), s = O(r, n, e, g2.create(m2.NA)), o = O(r, n, t, g2.create(m2.NA)), u = s.mapValue((c, l2, f2) => {
  28010. const h = o.get(l2, f2);
  28011. if (c.isError())
  28012. return c;
  28013. if (h.isError())
  28014. return h;
  28015. const { isError: d2, errorObject: _, variants: C } = I2(c, h);
  28016. if (d2)
  28017. return _;
  28018. const [E2, b] = C, R = Math.floor(+E2.getValue()), p2 = Math.floor(+b.getValue());
  28019. if (R < 0 || R >= 2147483647 || p2 < 0)
  28020. return g2.create(m2.NUM);
  28021. if (R === 0)
  28022. return p2 === 0 ? y2.create(1) : y2.create(0);
  28023. const N2 = R ** p2;
  28024. return Number.isFinite(N2) ? y2.create(N2) : g2.create(m2.NUM);
  28025. });
  28026. return r === 1 && n === 1 ? u.get(0, 0) : u;
  28027. }
  28028. };
  28029. var TA = class extends V {
  28030. constructor() {
  28031. super(...arguments);
  28032. A(this, "minParams", 1);
  28033. A(this, "maxParams", 1);
  28034. }
  28035. calculate(e) {
  28036. if (e.isArray()) {
  28037. const t = e.mapValue((r) => this._handleSingleObject(r));
  28038. return t.getRowCount() === 1 && t.getColumnCount() === 1 ? t.get(0, 0) : t;
  28039. }
  28040. return this._handleSingleObject(e);
  28041. }
  28042. _handleSingleObject(e) {
  28043. const { isError: t, errorObject: r, variants: n } = I2(e);
  28044. if (t)
  28045. return r;
  28046. const [s] = n, o = +s.getValue(), u = Math.exp(-0.5 * o * o) / Math.sqrt(2 * Math.PI);
  28047. return y2.create(u);
  28048. }
  28049. };
  28050. var BA = class extends V {
  28051. constructor() {
  28052. super(...arguments);
  28053. A(this, "minParams", 3);
  28054. A(this, "maxParams", 4);
  28055. }
  28056. calculate(e, t, r, n) {
  28057. const { isError: s, errorObject: o, xRangeValues: u, probRangeValues: c } = this._handleXRangeAndProbRange(e, t);
  28058. let l2 = n != null ? n : r;
  28059. n != null && n.isNull() && (l2 = r);
  28060. const f2 = Math.max(
  28061. r.isArray() ? r.getRowCount() : 1,
  28062. l2.isArray() ? l2.getRowCount() : 1
  28063. ), h = Math.max(
  28064. r.isArray() ? r.getColumnCount() : 1,
  28065. l2.isArray() ? l2.getColumnCount() : 1
  28066. ), d2 = O(f2, h, r, g2.create(m2.NA)), _ = O(f2, h, l2, g2.create(m2.NA)), C = d2.mapValue((E2, b, R) => {
  28067. const p2 = _.get(b, R);
  28068. return e.isError() ? e : t.isError() ? t : E2.isError() ? E2 : p2.isError() ? p2 : s ? o : this._handleSignleObject(u, c, E2, p2);
  28069. });
  28070. return f2 === 1 && h === 1 ? C.get(0, 0) : C;
  28071. }
  28072. _handleSignleObject(e, t, r, n) {
  28073. const { isError: s, errorObject: o, variants: u } = I2(r, n);
  28074. if (s)
  28075. return o;
  28076. const [c, l2] = u, f2 = +c.getValue(), h = +l2.getValue();
  28077. if (t.reduce((_, C) => _ + C, 0) !== 1)
  28078. return g2.create(m2.NUM);
  28079. let d2 = 0;
  28080. for (let _ = 0; _ < e.length; _++)
  28081. e[_] >= f2 && e[_] <= h && (d2 += t[_]);
  28082. return y2.create(d2);
  28083. }
  28084. // eslint-disable-next-line
  28085. _handleXRangeAndProbRange(e, t) {
  28086. const r = e.isArray() ? e.getRowCount() : 1, n = e.isArray() ? e.getColumnCount() : 1, s = t.isArray() ? t.getRowCount() : 1, o = t.isArray() ? t.getColumnCount() : 1;
  28087. let u = e;
  28088. if (e.isArray() && r === 1 && n === 1 && (u = e.get(0, 0)), u.isError())
  28089. return {
  28090. isError: true,
  28091. errorObject: u,
  28092. xRangeValues: [],
  28093. probRangeValues: []
  28094. };
  28095. let c = t;
  28096. if (t.isArray() && s === 1 && o === 1 && (c = t.get(0, 0)), c.isError())
  28097. return {
  28098. isError: true,
  28099. errorObject: c,
  28100. xRangeValues: [],
  28101. probRangeValues: []
  28102. };
  28103. if ((r * n === 1 || s * o === 1) && (u.isNull() || c.isNull()))
  28104. return {
  28105. isError: true,
  28106. errorObject: g2.create(m2.VALUE),
  28107. xRangeValues: [],
  28108. probRangeValues: []
  28109. };
  28110. if (r * n !== s * o)
  28111. return {
  28112. isError: true,
  28113. errorObject: g2.create(m2.NA),
  28114. xRangeValues: [],
  28115. probRangeValues: []
  28116. };
  28117. const {
  28118. isError: l2,
  28119. errorObject: f2,
  28120. array1Values: h,
  28121. array2Values: d2,
  28122. noCalculate: _
  28123. } = Je(
  28124. e,
  28125. t,
  28126. r * n,
  28127. n,
  28128. o
  28129. );
  28130. return l2 ? {
  28131. isError: true,
  28132. errorObject: f2,
  28133. xRangeValues: [],
  28134. probRangeValues: []
  28135. } : _ ? {
  28136. isError: true,
  28137. errorObject: g2.create(m2.DIV_BY_ZERO),
  28138. xRangeValues: [],
  28139. probRangeValues: []
  28140. } : {
  28141. isError: false,
  28142. errorObject: null,
  28143. xRangeValues: h,
  28144. probRangeValues: d2
  28145. };
  28146. }
  28147. };
  28148. var IA = class extends V {
  28149. constructor() {
  28150. super(...arguments);
  28151. A(this, "minParams", 2);
  28152. A(this, "maxParams", 2);
  28153. }
  28154. calculate(e, t) {
  28155. const r = this._getValues(e);
  28156. if (t.isArray()) {
  28157. const n = t.mapValue((s) => this._handleSingleObject(r, s));
  28158. return n.getRowCount() === 1 && n.getColumnCount() === 1 ? n.get(0, 0) : n;
  28159. }
  28160. return this._handleSingleObject(r, t);
  28161. }
  28162. _handleSingleObject(e, t) {
  28163. if (e instanceof g2)
  28164. return e;
  28165. const { isError: r, errorObject: n, variants: s } = I2(t);
  28166. if (r)
  28167. return n;
  28168. const [o] = s, u = Math.floor(+o.getValue());
  28169. if (u <= 0 || u >= 4)
  28170. return g2.create(m2.NUM);
  28171. const c = u / 4, l2 = e.length;
  28172. if (c < 1 / (l2 + 1) || c > 1 - 1 / (l2 + 1))
  28173. return g2.create(m2.NUM);
  28174. const f2 = c * (l2 + 1) - 1, h = Math.floor(f2), d2 = f2 - h;
  28175. if (d2 === 0)
  28176. return y2.create(e[h]);
  28177. const _ = e[h] + d2 * (e[h + 1] - e[h]);
  28178. return y2.create(_);
  28179. }
  28180. _getValues(e) {
  28181. const t = e.isArray() ? e.getRowCount() : 1, r = e.isArray() ? e.getColumnCount() : 1, n = [];
  28182. for (let s = 0; s < t; s++)
  28183. for (let o = 0; o < r; o++) {
  28184. const u = e.isArray() ? e.get(s, o) : e;
  28185. if (u.isError())
  28186. return u;
  28187. if (u.isNull() || u.isBoolean())
  28188. continue;
  28189. const c = u.getValue();
  28190. DC(c) && n.push(+c);
  28191. }
  28192. return n.length === 0 ? g2.create(m2.NUM) : n.sort((s, o) => s - o);
  28193. }
  28194. };
  28195. var FA = class extends V {
  28196. constructor() {
  28197. super(...arguments);
  28198. A(this, "minParams", 2);
  28199. A(this, "maxParams", 3);
  28200. A(this, "needsReferenceObject", true);
  28201. }
  28202. calculate(e, t, r) {
  28203. let n = e;
  28204. n.isReferenceObject() && (n = n.toArrayValueObject());
  28205. const { refHasError: s, refErrorObject: o, refNumbers: u } = this._checkRefReferenceObject(t);
  28206. let c = r != null ? r : y2.create(0);
  28207. c.isReferenceObject() && (c = c.toArrayValueObject());
  28208. const l2 = Math.max(
  28209. n.isArray() ? n.getRowCount() : 1,
  28210. c.isArray() ? c.getRowCount() : 1
  28211. ), f2 = Math.max(
  28212. n.isArray() ? n.getColumnCount() : 1,
  28213. c.isArray() ? c.getColumnCount() : 1
  28214. ), h = O(l2, f2, n, g2.create(m2.NA)), d2 = O(l2, f2, c, g2.create(m2.NA)), _ = h.map((C, E2, b) => {
  28215. const R = d2.get(E2, b);
  28216. if (!e.isReferenceObject() && e.isNull())
  28217. return g2.create(m2.NA);
  28218. if (s)
  28219. return o;
  28220. if (R.isError())
  28221. return R;
  28222. const p2 = +C.getValue(), N2 = +R.getValue();
  28223. return Number.isNaN(p2) || Number.isNaN(N2) ? g2.create(m2.VALUE) : this._getResult(p2, N2, u);
  28224. });
  28225. return l2 === 1 && f2 === 1 ? _.get(0, 0) : _;
  28226. }
  28227. _getResult(e, t, r) {
  28228. const n = r.sort((c, l2) => t ? c - l2 : l2 - c);
  28229. let s = n.indexOf(e);
  28230. const o = [];
  28231. for (; s >= 0; ) {
  28232. const c = s + 1;
  28233. o.push(c), s = n.indexOf(e, c);
  28234. }
  28235. if (o.length === 0)
  28236. return g2.create(m2.NA);
  28237. const u = o.reduce((c, l2) => c + l2, 0) / o.length;
  28238. return y2.create(u);
  28239. }
  28240. _checkRefReferenceObject(e) {
  28241. let t = false, r = g2.create(m2.NA);
  28242. const n = [];
  28243. return e.isReferenceObject() ? (e.toArrayValueObject().iterator((o) => {
  28244. const u = o;
  28245. if (u.isError())
  28246. return t = true, r = u, false;
  28247. if (u.isNull() || u.isBoolean())
  28248. return true;
  28249. const c = +u.getValue();
  28250. if (Number.isNaN(c))
  28251. return true;
  28252. n.push(c);
  28253. }), {
  28254. refHasError: t,
  28255. refErrorObject: r,
  28256. refNumbers: n
  28257. }) : {
  28258. refHasError: true,
  28259. refErrorObject: r,
  28260. refNumbers: n
  28261. };
  28262. }
  28263. };
  28264. var kA = class extends V {
  28265. constructor() {
  28266. super(...arguments);
  28267. A(this, "minParams", 2);
  28268. A(this, "maxParams", 3);
  28269. A(this, "needsReferenceObject", true);
  28270. }
  28271. calculate(e, t, r) {
  28272. let n = e;
  28273. n.isReferenceObject() && (n = n.toArrayValueObject());
  28274. const { refHasError: s, refErrorObject: o, refNumbers: u } = this._checkRefReferenceObject(t);
  28275. let c = r != null ? r : y2.create(0);
  28276. c.isReferenceObject() && (c = c.toArrayValueObject());
  28277. const l2 = Math.max(
  28278. n.isArray() ? n.getRowCount() : 1,
  28279. c.isArray() ? c.getRowCount() : 1
  28280. ), f2 = Math.max(
  28281. n.isArray() ? n.getColumnCount() : 1,
  28282. c.isArray() ? c.getColumnCount() : 1
  28283. ), h = O(l2, f2, n, g2.create(m2.NA)), d2 = O(l2, f2, c, g2.create(m2.NA)), _ = h.map((C, E2, b) => {
  28284. const R = d2.get(E2, b);
  28285. if (!e.isReferenceObject() && e.isNull())
  28286. return g2.create(m2.NA);
  28287. if (s)
  28288. return o;
  28289. if (R.isError())
  28290. return R;
  28291. const p2 = +C.getValue(), N2 = +R.getValue();
  28292. if (Number.isNaN(p2) || Number.isNaN(N2))
  28293. return g2.create(m2.VALUE);
  28294. const w = u.sort((D2, S2) => N2 ? D2 - S2 : S2 - D2).indexOf(p2);
  28295. return w === -1 ? g2.create(m2.NA) : y2.create(w + 1);
  28296. });
  28297. return l2 === 1 && f2 === 1 ? _.get(0, 0) : _;
  28298. }
  28299. _checkRefReferenceObject(e) {
  28300. let t = false, r = g2.create(m2.NA);
  28301. const n = [];
  28302. return e.isReferenceObject() ? (e.toArrayValueObject().iterator((o) => {
  28303. const u = o;
  28304. if (u.isError())
  28305. return t = true, r = u, false;
  28306. if (u.isNull() || u.isBoolean())
  28307. return true;
  28308. const c = +u.getValue();
  28309. if (Number.isNaN(c))
  28310. return true;
  28311. n.push(c);
  28312. }), {
  28313. refHasError: t,
  28314. refErrorObject: r,
  28315. refNumbers: n
  28316. }) : {
  28317. refHasError: true,
  28318. refErrorObject: r,
  28319. refNumbers: n
  28320. };
  28321. }
  28322. };
  28323. var $A = class extends V {
  28324. constructor() {
  28325. super(...arguments);
  28326. A(this, "minParams", 2);
  28327. A(this, "maxParams", 2);
  28328. }
  28329. calculate(e, t) {
  28330. const r = e.isArray() ? e.getRowCount() : 1, n = e.isArray() ? e.getColumnCount() : 1, s = t.isArray() ? t.getRowCount() : 1, o = t.isArray() ? t.getColumnCount() : 1;
  28331. let u = e;
  28332. if (e.isArray() && r === 1 && n === 1 && (u = e.get(0, 0)), u.isError())
  28333. return u;
  28334. let c = t;
  28335. if (t.isArray() && s === 1 && o === 1 && (c = t.get(0, 0)), c.isError())
  28336. return c;
  28337. if ((r * n === 1 || s * o === 1) && (u.isNull() || c.isNull()))
  28338. return g2.create(m2.VALUE);
  28339. if (r * n !== s * o)
  28340. return g2.create(m2.NA);
  28341. const {
  28342. isError: l2,
  28343. errorObject: f2,
  28344. array1Values: h,
  28345. array2Values: d2,
  28346. noCalculate: _
  28347. } = Je(
  28348. e,
  28349. t,
  28350. r * n,
  28351. n,
  28352. o
  28353. );
  28354. return l2 ? f2 : _ ? g2.create(m2.DIV_BY_ZERO) : this._getResult(h, d2);
  28355. }
  28356. _getResult(e, t) {
  28357. if (e.length === 0)
  28358. return g2.create(m2.DIV_BY_ZERO);
  28359. const r = e.length;
  28360. let n = 0, s = 0;
  28361. for (let d2 = 0; d2 < r; d2++)
  28362. n += e[d2], s += t[d2];
  28363. const o = n / r, u = s / r;
  28364. let c = 0, l2 = 0, f2 = 0;
  28365. for (let d2 = 0; d2 < r; d2++)
  28366. c += (e[d2] - o) * (t[d2] - u), l2 += (e[d2] - o) ** 2, f2 += (t[d2] - u) ** 2;
  28367. if (l2 === 0 || f2 === 0)
  28368. return g2.create(m2.DIV_BY_ZERO);
  28369. const h = (c / Math.sqrt(l2 * f2)) ** 2;
  28370. return y2.create(h);
  28371. }
  28372. };
  28373. var YA = class extends V {
  28374. constructor() {
  28375. super(...arguments);
  28376. A(this, "minParams", 1);
  28377. A(this, "maxParams", 255);
  28378. }
  28379. calculate(...e) {
  28380. const t = [];
  28381. let r = 0;
  28382. for (let n = 0; n < e.length; n++) {
  28383. const s = e[n];
  28384. if (s.isError())
  28385. return s;
  28386. if (s.isString()) {
  28387. const c = s.convertToNumberObjectValue();
  28388. if (c.isError())
  28389. return c;
  28390. }
  28391. const o = s.isArray() ? s.getRowCount() : 1, u = s.isArray() ? s.getColumnCount() : 1;
  28392. for (let c = 0; c < o; c++)
  28393. for (let l2 = 0; l2 < u; l2++) {
  28394. const f2 = s.isArray() ? s.get(c, l2) : s;
  28395. if (f2.isError())
  28396. return f2;
  28397. if (f2.isNull() || f2.isBoolean())
  28398. continue;
  28399. const h = f2.getValue();
  28400. DC(h) && (t.push(+h), r += +h);
  28401. }
  28402. }
  28403. return t.length <= 2 ? g2.create(m2.DIV_BY_ZERO) : this._getResult(t, r);
  28404. }
  28405. _getResult(e, t) {
  28406. const r = e.length, n = t / r;
  28407. let s = 0;
  28408. for (let l2 = 0; l2 < r; l2++)
  28409. s += (e[l2] - n) ** 2;
  28410. const o = Math.sqrt(s / (r - 1));
  28411. if (o === 0)
  28412. return g2.create(m2.DIV_BY_ZERO);
  28413. let u = 0;
  28414. for (let l2 = 0; l2 < r; l2++)
  28415. u += ((e[l2] - n) / o) ** 3;
  28416. const c = r / ((r - 1) * (r - 2)) * u;
  28417. return y2.create(c);
  28418. }
  28419. };
  28420. var HA = class extends V {
  28421. constructor() {
  28422. super(...arguments);
  28423. A(this, "minParams", 1);
  28424. A(this, "maxParams", 255);
  28425. }
  28426. calculate(...e) {
  28427. const t = [];
  28428. let r = 0;
  28429. for (let n = 0; n < e.length; n++) {
  28430. const s = e[n];
  28431. if (s.isError())
  28432. return s;
  28433. if (s.isString()) {
  28434. const c = s.convertToNumberObjectValue();
  28435. if (c.isError())
  28436. return c;
  28437. }
  28438. const o = s.isArray() ? s.getRowCount() : 1, u = s.isArray() ? s.getColumnCount() : 1;
  28439. for (let c = 0; c < o; c++)
  28440. for (let l2 = 0; l2 < u; l2++) {
  28441. const f2 = s.isArray() ? s.get(c, l2) : s;
  28442. if (f2.isError())
  28443. return f2;
  28444. if (f2.isNull() || f2.isBoolean())
  28445. continue;
  28446. const h = f2.getValue();
  28447. DC(h) && (t.push(+h), r += +h);
  28448. }
  28449. }
  28450. return t.length <= 2 ? g2.create(m2.DIV_BY_ZERO) : this._getResult(t, r);
  28451. }
  28452. _getResult(e, t) {
  28453. const r = e.length, n = t / r;
  28454. let s = 0;
  28455. for (let l2 = 0; l2 < r; l2++)
  28456. s += (e[l2] - n) ** 2;
  28457. const o = Math.sqrt(s / r);
  28458. if (o === 0)
  28459. return g2.create(m2.DIV_BY_ZERO);
  28460. let u = 0;
  28461. for (let l2 = 0; l2 < r; l2++)
  28462. u += ((e[l2] - n) / o) ** 3;
  28463. const c = u / r;
  28464. return y2.create(c);
  28465. }
  28466. };
  28467. var GA = class extends V {
  28468. constructor() {
  28469. super(...arguments);
  28470. A(this, "minParams", 2);
  28471. A(this, "maxParams", 2);
  28472. }
  28473. calculate(e, t) {
  28474. const r = e.isArray() ? e.getRowCount() : 1, n = e.isArray() ? e.getColumnCount() : 1, s = t.isArray() ? t.getRowCount() : 1, o = t.isArray() ? t.getColumnCount() : 1;
  28475. let u = e;
  28476. if (e.isArray() && r === 1 && n === 1 && (u = e.get(0, 0)), u.isError())
  28477. return u;
  28478. let c = t;
  28479. if (t.isArray() && s === 1 && o === 1 && (c = t.get(0, 0)), c.isError())
  28480. return c;
  28481. if (r * n === 1 || s * o === 1)
  28482. return u.isNull() || c.isNull() ? g2.create(m2.VALUE) : g2.create(m2.DIV_BY_ZERO);
  28483. if (r * n !== s * o)
  28484. return g2.create(m2.NA);
  28485. const {
  28486. isError: l2,
  28487. errorObject: f2,
  28488. array1Values: h,
  28489. array2Values: d2,
  28490. noCalculate: _
  28491. } = Je(
  28492. e,
  28493. t,
  28494. r * n,
  28495. n,
  28496. o
  28497. );
  28498. return l2 ? f2 : _ ? g2.create(m2.DIV_BY_ZERO) : this._getResult(h, d2);
  28499. }
  28500. _getResult(e, t) {
  28501. const r = e.length;
  28502. let n = 0, s = 0;
  28503. for (let h = 0; h < r; h++)
  28504. n += e[h], s += t[h];
  28505. const o = n / r, u = s / r;
  28506. let c = 0, l2 = 0;
  28507. for (let h = 0; h < r; h++)
  28508. c += (e[h] - o) * (t[h] - u), l2 += (t[h] - u) ** 2;
  28509. if (l2 === 0)
  28510. return g2.create(m2.DIV_BY_ZERO);
  28511. const f2 = c / l2;
  28512. return y2.create(f2);
  28513. }
  28514. };
  28515. var QA = class extends V {
  28516. constructor() {
  28517. super(...arguments);
  28518. A(this, "minParams", 2);
  28519. A(this, "maxParams", 2);
  28520. }
  28521. calculate(e, t) {
  28522. const r = this._getValues(e);
  28523. if (t.isArray()) {
  28524. const n = t.mapValue((s) => this._handleSingleObject(r, s));
  28525. return n.getRowCount() === 1 && n.getColumnCount() === 1 ? n.get(0, 0) : n;
  28526. }
  28527. return this._handleSingleObject(r, t);
  28528. }
  28529. _handleSingleObject(e, t) {
  28530. if (e instanceof g2)
  28531. return e;
  28532. const { isError: r, errorObject: n, variants: s } = I2(t);
  28533. if (r)
  28534. return n;
  28535. const [o] = s;
  28536. let u = +o.getValue();
  28537. return u < 1 || u > e.length ? g2.create(m2.NUM) : (u = Math.floor(u), y2.create(e[u - 1]));
  28538. }
  28539. _getValues(e) {
  28540. const t = e.isArray() ? e.getRowCount() : 1, r = e.isArray() ? e.getColumnCount() : 1, n = [];
  28541. for (let s = 0; s < t; s++)
  28542. for (let o = 0; o < r; o++) {
  28543. const u = e.isArray() ? e.get(s, o) : e;
  28544. if (u.isError())
  28545. return u;
  28546. if (u.isNull() || u.isBoolean() || u.isString())
  28547. continue;
  28548. const c = u.getValue();
  28549. DC(c) && n.push(+c);
  28550. }
  28551. return n.length === 0 ? g2.create(m2.NUM) : n.sort((s, o) => s - o);
  28552. }
  28553. };
  28554. var WA = class extends V {
  28555. constructor() {
  28556. super(...arguments);
  28557. A(this, "minParams", 3);
  28558. A(this, "maxParams", 3);
  28559. }
  28560. calculate(e, t, r) {
  28561. const n = Math.max(
  28562. e.isArray() ? e.getRowCount() : 1,
  28563. t.isArray() ? t.getRowCount() : 1,
  28564. r.isArray() ? r.getRowCount() : 1
  28565. ), s = Math.max(
  28566. e.isArray() ? e.getColumnCount() : 1,
  28567. t.isArray() ? t.getColumnCount() : 1,
  28568. r.isArray() ? r.getColumnCount() : 1
  28569. ), o = O(n, s, e, g2.create(m2.NA)), u = O(n, s, t, g2.create(m2.NA)), c = O(n, s, r, g2.create(m2.NA)), l2 = o.mapValue((f2, h, d2) => {
  28570. const _ = u.get(h, d2), C = c.get(h, d2);
  28571. return f2.isError() ? f2 : _.isError() ? _ : C.isError() ? C : this._handleSignleObject(f2, _, C);
  28572. });
  28573. return n === 1 && s === 1 ? l2.get(0, 0) : l2;
  28574. }
  28575. _handleSignleObject(e, t, r) {
  28576. const { isError: n, errorObject: s, variants: o } = I2(e, t, r);
  28577. if (n)
  28578. return s;
  28579. const [u, c, l2] = o, f2 = +u.getValue(), h = +c.getValue(), d2 = +l2.getValue();
  28580. if (d2 <= 0)
  28581. return g2.create(m2.NUM);
  28582. const _ = (f2 - h) / d2;
  28583. return y2.create(_);
  28584. }
  28585. };
  28586. var qA = class extends V {
  28587. constructor() {
  28588. super(...arguments);
  28589. A(this, "minParams", 1);
  28590. A(this, "maxParams", 255);
  28591. }
  28592. calculate(...e) {
  28593. const t = this.flattenArray(e, false);
  28594. return t.isError() ? t : t.std(1);
  28595. }
  28596. };
  28597. var KA = class extends V {
  28598. constructor() {
  28599. super(...arguments);
  28600. A(this, "minParams", 1);
  28601. A(this, "maxParams", 255);
  28602. }
  28603. calculate(...e) {
  28604. const t = this.flattenArray(e, false);
  28605. return t.isError() ? t : t.std();
  28606. }
  28607. };
  28608. var XA = class extends V {
  28609. constructor() {
  28610. super(...arguments);
  28611. A(this, "minParams", 2);
  28612. A(this, "maxParams", 2);
  28613. }
  28614. calculate(e, t) {
  28615. const r = e.isArray() ? e.getRowCount() : 1, n = e.isArray() ? e.getColumnCount() : 1, s = t.isArray() ? t.getRowCount() : 1, o = t.isArray() ? t.getColumnCount() : 1;
  28616. let u = e;
  28617. if (e.isArray() && r === 1 && n === 1 && (u = e.get(0, 0)), u.isError())
  28618. return u;
  28619. let c = t;
  28620. if (t.isArray() && s === 1 && o === 1 && (c = t.get(0, 0)), c.isError())
  28621. return c;
  28622. if ((r * n === 1 || s * o === 1) && (u.isNull() || c.isNull()))
  28623. return g2.create(m2.VALUE);
  28624. if (r * n !== s * o)
  28625. return g2.create(m2.NA);
  28626. const {
  28627. isError: l2,
  28628. errorObject: f2,
  28629. array1Values: h,
  28630. array2Values: d2,
  28631. noCalculate: _
  28632. } = Je(
  28633. e,
  28634. t,
  28635. r * n,
  28636. n,
  28637. o
  28638. );
  28639. return l2 ? f2 : _ ? g2.create(m2.DIV_BY_ZERO) : this._getResult(h, d2);
  28640. }
  28641. _getResult(e, t) {
  28642. const r = e.length;
  28643. if (r <= 2)
  28644. return g2.create(m2.DIV_BY_ZERO);
  28645. let n = 0, s = 0;
  28646. for (let d2 = 0; d2 < r; d2++)
  28647. n += e[d2], s += t[d2];
  28648. const o = n / r, u = s / r;
  28649. let c = 0, l2 = 0, f2 = 0;
  28650. for (let d2 = 0; d2 < r; d2++)
  28651. c += (e[d2] - o) * (t[d2] - u), l2 += (e[d2] - o) ** 2, f2 += (t[d2] - u) ** 2;
  28652. if (f2 === 0)
  28653. return g2.create(m2.DIV_BY_ZERO);
  28654. const h = Math.sqrt((l2 - c ** 2 / f2) / (r - 2));
  28655. return Number.isNaN(h) || !Number.isFinite(h) ? g2.create(m2.NUM) : y2.create(h);
  28656. }
  28657. };
  28658. var ZA = class extends V {
  28659. constructor() {
  28660. super(...arguments);
  28661. A(this, "minParams", 3);
  28662. A(this, "maxParams", 3);
  28663. }
  28664. calculate(e, t, r) {
  28665. const n = Math.max(
  28666. e.isArray() ? e.getRowCount() : 1,
  28667. t.isArray() ? t.getRowCount() : 1,
  28668. r.isArray() ? r.getRowCount() : 1
  28669. ), s = Math.max(
  28670. e.isArray() ? e.getColumnCount() : 1,
  28671. t.isArray() ? t.getColumnCount() : 1,
  28672. r.isArray() ? r.getColumnCount() : 1
  28673. ), o = O(n, s, e, g2.create(m2.NA)), u = O(n, s, t, g2.create(m2.NA)), c = O(n, s, r, g2.create(m2.NA)), l2 = o.mapValue((f2, h, d2) => {
  28674. const _ = u.get(h, d2), C = c.get(h, d2);
  28675. return f2.isError() ? f2 : _.isError() ? _ : C.isError() ? C : this._handleSignleObject(f2, _, C);
  28676. });
  28677. return n === 1 && s === 1 ? l2.get(0, 0) : l2;
  28678. }
  28679. _handleSignleObject(e, t, r) {
  28680. const { isError: n, errorObject: s, variants: o } = I2(e, t, r);
  28681. if (n)
  28682. return s;
  28683. const [u, c, l2] = o, f2 = +u.getValue(), h = Math.floor(+c.getValue()), d2 = +l2.getValue();
  28684. if (h < 1)
  28685. return g2.create(m2.NUM);
  28686. let _;
  28687. return d2 ? _ = $r(f2, h) : _ = mm(f2, h), Number.isNaN(_) || !Number.isFinite(_) ? g2.create(m2.NUM) : y2.create(_);
  28688. }
  28689. };
  28690. var zA = class extends V {
  28691. constructor() {
  28692. super(...arguments);
  28693. A(this, "minParams", 2);
  28694. A(this, "maxParams", 2);
  28695. }
  28696. calculate(e, t) {
  28697. const r = Math.max(
  28698. e.isArray() ? e.getRowCount() : 1,
  28699. t.isArray() ? t.getRowCount() : 1
  28700. ), n = Math.max(
  28701. e.isArray() ? e.getColumnCount() : 1,
  28702. t.isArray() ? t.getColumnCount() : 1
  28703. ), s = O(r, n, e, g2.create(m2.NA)), o = O(r, n, t, g2.create(m2.NA)), u = s.mapValue((c, l2, f2) => {
  28704. const h = o.get(l2, f2);
  28705. return c.isError() ? c : h.isError() ? h : this._handleSignleObject(c, h);
  28706. });
  28707. return r === 1 && n === 1 ? u.get(0, 0) : u;
  28708. }
  28709. _handleSignleObject(e, t) {
  28710. const { isError: r, errorObject: n, variants: s } = I2(e, t);
  28711. if (r)
  28712. return n;
  28713. const [o, u] = s, c = +o.getValue(), l2 = Math.floor(+u.getValue());
  28714. if (c < 0 || l2 < 1 || l2 > 10 ** 10)
  28715. return g2.create(m2.NUM);
  28716. const f2 = $r(-c, l2) * 2;
  28717. return Number.isNaN(f2) || !Number.isFinite(f2) ? g2.create(m2.NUM) : y2.create(f2);
  28718. }
  28719. };
  28720. var JA = class extends V {
  28721. constructor() {
  28722. super(...arguments);
  28723. A(this, "minParams", 2);
  28724. A(this, "maxParams", 2);
  28725. }
  28726. calculate(e, t) {
  28727. const r = Math.max(
  28728. e.isArray() ? e.getRowCount() : 1,
  28729. t.isArray() ? t.getRowCount() : 1
  28730. ), n = Math.max(
  28731. e.isArray() ? e.getColumnCount() : 1,
  28732. t.isArray() ? t.getColumnCount() : 1
  28733. ), s = O(r, n, e, g2.create(m2.NA)), o = O(r, n, t, g2.create(m2.NA)), u = s.mapValue((c, l2, f2) => {
  28734. const h = o.get(l2, f2);
  28735. return c.isError() ? c : h.isError() ? h : this._handleSignleObject(c, h);
  28736. });
  28737. return r === 1 && n === 1 ? u.get(0, 0) : u;
  28738. }
  28739. _handleSignleObject(e, t) {
  28740. const { isError: r, errorObject: n, variants: s } = I2(e, t);
  28741. if (r)
  28742. return n;
  28743. const [o, u] = s, c = +o.getValue(), l2 = Math.floor(+u.getValue());
  28744. if (l2 < 1 || l2 > 10 ** 10)
  28745. return g2.create(m2.NUM);
  28746. const f2 = $r(-c, l2);
  28747. return Number.isNaN(f2) || !Number.isFinite(f2) ? g2.create(m2.NUM) : y2.create(f2);
  28748. }
  28749. };
  28750. var eE = class extends V {
  28751. constructor() {
  28752. super(...arguments);
  28753. A(this, "minParams", 2);
  28754. A(this, "maxParams", 2);
  28755. }
  28756. calculate(e, t) {
  28757. const r = Math.max(
  28758. e.isArray() ? e.getRowCount() : 1,
  28759. t.isArray() ? t.getRowCount() : 1
  28760. ), n = Math.max(
  28761. e.isArray() ? e.getColumnCount() : 1,
  28762. t.isArray() ? t.getColumnCount() : 1
  28763. ), s = O(r, n, e, g2.create(m2.NA)), o = O(r, n, t, g2.create(m2.NA)), u = s.mapValue((c, l2, f2) => {
  28764. const h = o.get(l2, f2);
  28765. return c.isError() ? c : h.isError() ? h : this._handleSignleObject(c, h);
  28766. });
  28767. return r === 1 && n === 1 ? u.get(0, 0) : u;
  28768. }
  28769. _handleSignleObject(e, t) {
  28770. const { isError: r, errorObject: n, variants: s } = I2(e, t);
  28771. if (r)
  28772. return n;
  28773. const [o, u] = s, c = +o.getValue(), l2 = Math.floor(+u.getValue());
  28774. if (c <= 0 || c > 1 || l2 < 1 || l2 > 10 ** 10)
  28775. return g2.create(m2.NUM);
  28776. const f2 = qn(c, l2);
  28777. return Number.isNaN(f2) || !Number.isFinite(f2) ? g2.create(m2.NUM) : y2.create(f2);
  28778. }
  28779. };
  28780. var tE = class extends V {
  28781. constructor() {
  28782. super(...arguments);
  28783. A(this, "minParams", 1);
  28784. A(this, "maxParams", 4);
  28785. }
  28786. calculate(e, t, r, n) {
  28787. const { isError: s, errorObject: o } = Kn(e, t, r);
  28788. if (s)
  28789. return o;
  28790. const u = dt(e);
  28791. if (u instanceof g2)
  28792. return u;
  28793. const c = this._getKnownXsValues(u, t);
  28794. if (c instanceof g2)
  28795. return c;
  28796. const l2 = this._getNewXsValues(c, r);
  28797. if (l2 instanceof g2)
  28798. return l2;
  28799. let f2 = n != null ? n : T2.create(true);
  28800. if (f2.isArray() && (f2 = f2.get(0, 0)), f2.isString() && (f2 = f2.convertToNumberObjectValue()), f2.isError())
  28801. return f2;
  28802. const h = +f2.getValue();
  28803. return this._getResult(u, c, l2, h);
  28804. }
  28805. _getResult(e, t, r, n) {
  28806. return e.length === 1 && t.length > 1 || e[0].length === 1 && t[0].length > 1 ? e.length === 1 && t.length > 1 && (n ? t.length + 1 : t.length) > e[0].length || e[0].length === 1 && t[0].length > 1 && (n ? t[0].length + 1 : t[0].length) > e.length ? g2.create(m2.NA) : this._getResultByMultipleVariables(e, t, r, n) : this._getResultBySimpleVariables(e, t, r, n);
  28807. }
  28808. _getResultByMultipleVariables(e, t, r, n) {
  28809. const s = e.length === 1 && e[0].length > 1, o = zn(e, t, r, n, false);
  28810. if (o instanceof g2)
  28811. return o;
  28812. const { coefficients: u, newX: c } = o, l2 = u[0].length, f2 = u[0][l2 - 1];
  28813. let h = [];
  28814. for (let d2 = 0; d2 < c.length; d2++) {
  28815. h[d2] = [];
  28816. let _ = f2;
  28817. for (let C = l2 - 2; C >= 0; C--)
  28818. _ += u[0][l2 - 2 - C] * c[d2][C];
  28819. h[d2].push(_);
  28820. }
  28821. return s && (h = mt(h)), q2.createByArray(h);
  28822. }
  28823. _getResultBySimpleVariables(e, t, r, n) {
  28824. const s = e.flat(), o = t.flat(), { slope: u, intercept: c } = Zn(o, s, n, false);
  28825. if (Number.isNaN(u))
  28826. return g2.create(m2.NA);
  28827. const l2 = r.map((f2) => f2.map((h) => u * h + c));
  28828. return q2.createByArray(l2);
  28829. }
  28830. _getKnownXsValues(e, t) {
  28831. return !t || t.isNull() ? Xn(e.length, e[0].length) : dt(t);
  28832. }
  28833. _getNewXsValues(e, t) {
  28834. return !t || t.isNull() ? e : dt(t);
  28835. }
  28836. };
  28837. var rE = class extends V {
  28838. constructor() {
  28839. super(...arguments);
  28840. A(this, "minParams", 2);
  28841. A(this, "maxParams", 2);
  28842. }
  28843. calculate(e, t) {
  28844. const r = this._getValues(e);
  28845. if (t.isArray()) {
  28846. const n = t.mapValue((s) => this._handleSingleObject(r, s));
  28847. return n.getRowCount() === 1 && n.getColumnCount() === 1 ? n.get(0, 0) : n;
  28848. }
  28849. return this._handleSingleObject(r, t);
  28850. }
  28851. _handleSingleObject(e, t) {
  28852. if (e instanceof g2)
  28853. return e;
  28854. const { isError: r, errorObject: n, variants: s } = I2(t);
  28855. if (r)
  28856. return n;
  28857. const [o] = s, u = +o.getValue();
  28858. if (u < 0 || u >= 1)
  28859. return g2.create(m2.NUM);
  28860. const c = We(e.length * u / 2, 0) * 2, l2 = e.slice(c / 2, e.length - c / 2), f2 = l2.reduce((h, d2) => h + d2, 0) / l2.length;
  28861. return y2.create(f2);
  28862. }
  28863. _getValues(e) {
  28864. const t = e.isArray() ? e.getRowCount() : 1, r = e.isArray() ? e.getColumnCount() : 1, n = [];
  28865. for (let s = 0; s < t; s++)
  28866. for (let o = 0; o < r; o++) {
  28867. const u = e.isArray() ? e.get(s, o) : e;
  28868. if (u.isError())
  28869. return u;
  28870. if (u.isNull() || u.isBoolean())
  28871. continue;
  28872. const c = u.getValue();
  28873. DC(c) && n.push(+c);
  28874. }
  28875. return n.length === 0 ? g2.create(m2.NUM) : n.sort((s, o) => s - o);
  28876. }
  28877. };
  28878. var nE = class extends V {
  28879. constructor() {
  28880. super(...arguments);
  28881. A(this, "minParams", 1);
  28882. A(this, "maxParams", 255);
  28883. }
  28884. calculate(...e) {
  28885. const t = this.flattenArray(e, false);
  28886. return t.isError() ? t : t.var(1);
  28887. }
  28888. };
  28889. var sE = class extends V {
  28890. constructor() {
  28891. super(...arguments);
  28892. A(this, "minParams", 1);
  28893. A(this, "maxParams", 255);
  28894. }
  28895. calculate(...e) {
  28896. const t = this.flattenArray(e, false);
  28897. return t.isError() ? t : t.var();
  28898. }
  28899. };
  28900. var aE = [
  28901. [T_, v.AVEDEV],
  28902. [I_, v.AVERAGE],
  28903. [F_, v.AVERAGE_WEIGHTED],
  28904. [k_, v.AVERAGEA],
  28905. [$_, v.AVERAGEIF],
  28906. [Y_, v.AVERAGEIFS],
  28907. [H_, v.BETA_DIST],
  28908. [Bo, v.BETA_INV],
  28909. [Io, v.BINOM_DIST],
  28910. [G_, v.BINOM_DIST_RANGE],
  28911. [Fo, v.BINOM_INV],
  28912. [Q_, v.CHISQ_DIST],
  28913. [ko, v.CHISQ_DIST_RT],
  28914. [W_, v.CHISQ_INV],
  28915. [$o, v.CHISQ_INV_RT],
  28916. [Yo, v.CHISQ_TEST],
  28917. [Ho, v.CONFIDENCE_NORM],
  28918. [q_, v.CONFIDENCE_T],
  28919. [K_, v.CORREL],
  28920. [X_, v.COUNT],
  28921. [Z_, v.COUNTA],
  28922. [z_, v.COUNTBLANK],
  28923. [J_, v.COUNTIF],
  28924. [eA, v.COUNTIFS],
  28925. [Go, v.COVARIANCE_P],
  28926. [rA, v.COVARIANCE_S],
  28927. [nA, v.DEVSQ],
  28928. [Qo, v.EXPON_DIST],
  28929. [sA, v.F_DIST],
  28930. [Wo, v.F_DIST_RT],
  28931. [aA, v.F_INV],
  28932. [qo, v.F_INV_RT],
  28933. [Ko, v.F_TEST],
  28934. [iA, v.FISHER],
  28935. [oA, v.FISHERINV],
  28936. [Li, v.FORECAST],
  28937. [Li, v.FORECAST_LINEAR],
  28938. [uA, v.FREQUENCY],
  28939. [cA, v.GAMMA],
  28940. [Xo, v.GAMMA_DIST],
  28941. [Zo, v.GAMMA_INV],
  28942. [xi, v.GAMMALN],
  28943. [xi, v.GAMMALN_PRECISE],
  28944. [lA, v.GAUSS],
  28945. [fA, v.GEOMEAN],
  28946. [hA, v.GROWTH],
  28947. [mA, v.HARMEAN],
  28948. [gA, v.HYPGEOM_DIST],
  28949. [dA, v.INTERCEPT],
  28950. [CA, v.KURT],
  28951. [_A, v.LARGE],
  28952. [AA, v.LINEST],
  28953. [EA, v.LOGEST],
  28954. [bA, v.LOGNORM_DIST],
  28955. [zo, v.LOGNORM_INV],
  28956. [yA, v.MARGINOFERROR],
  28957. [RA, v.MAX],
  28958. [pA, v.MAXA],
  28959. [VA, v.MAXIFS],
  28960. [NA, v.MEDIAN],
  28961. [OA, v.MIN],
  28962. [MA, v.MINA],
  28963. [wA, v.MINIFS],
  28964. [DA, v.MODE_MULT],
  28965. [Jo, v.MODE_SNGL],
  28966. [SA, v.NEGBINOM_DIST],
  28967. [eu, v.NORM_DIST],
  28968. [tu, v.NORM_INV],
  28969. [PA, v.NORM_S_DIST],
  28970. [ru, v.NORM_S_INV],
  28971. [LA, v.PEARSON],
  28972. [xA, v.PERCENTILE_EXC],
  28973. [nu2, v.PERCENTILE_INC],
  28974. [jA, v.PERCENTRANK_EXC],
  28975. [su, v.PERCENTRANK_INC],
  28976. [UA, v.PERMUT],
  28977. [vA, v.PERMUTATIONA],
  28978. [TA, v.PHI],
  28979. [au, v.POISSON_DIST],
  28980. [BA, v.PROB],
  28981. [IA, v.QUARTILE_EXC],
  28982. [iu, v.QUARTILE_INC],
  28983. [FA, v.RANK_AVG],
  28984. [kA, v.RANK_EQ],
  28985. [$A, v.RSQ],
  28986. [YA, v.SKEW],
  28987. [HA, v.SKEW_P],
  28988. [GA, v.SLOPE],
  28989. [QA, v.SMALL],
  28990. [WA, v.STANDARDIZE],
  28991. [ou, v.STDEV_P],
  28992. [uu, v.STDEV_S],
  28993. [qA, v.STDEVA],
  28994. [KA, v.STDEVPA],
  28995. [XA, v.STEYX],
  28996. [ZA, v.T_DIST],
  28997. [zA, v.T_DIST_2T],
  28998. [JA, v.T_DIST_RT],
  28999. [eE, v.T_INV],
  29000. [cu, v.T_INV_2T],
  29001. [lu, v.T_TEST],
  29002. [tE, v.TREND],
  29003. [rE, v.TRIMMEAN],
  29004. [fu, v.VAR_P],
  29005. [hu, v.VAR_S],
  29006. [nE, v.VARA],
  29007. [sE, v.VARPA],
  29008. [mu, v.WEIBULL_DIST],
  29009. [gu, v.Z_TEST]
  29010. ];
  29011. var iE = class extends V {
  29012. constructor() {
  29013. super(...arguments);
  29014. A(this, "minParams", 1);
  29015. A(this, "maxParams", 2);
  29016. }
  29017. calculate(e, t) {
  29018. let r = t != null ? t : y2.create(0);
  29019. if (t != null && t.isNull() && (r = y2.create(0)), r.isArray()) {
  29020. const n = r.mapValue((s) => this._handleSingleObject(e, s));
  29021. return n.getRowCount() === 1 && n.getColumnCount() === 1 ? n.get(0, 0) : n;
  29022. }
  29023. return this._handleSingleObject(e, r);
  29024. }
  29025. _handleSingleObject(e, t) {
  29026. const r = this._checkArray(e);
  29027. if (r.isError())
  29028. return r;
  29029. const { isError: n, errorObject: s, variants: o } = I2(t);
  29030. if (n)
  29031. return s;
  29032. const [u] = o, c = +u.getValue(), l2 = e.isArray() ? e.getRowCount() : 1, f2 = e.isArray() ? e.getColumnCount() : 1;
  29033. let h = "";
  29034. for (let d2 = 0; d2 < l2; d2++)
  29035. for (let _ = 0; _ < f2; _++) {
  29036. const C = e.isArray() ? e.get(d2, _) : e;
  29037. let E2 = `${C.getValue()}`;
  29038. C.isNull() && (E2 = ""), C.isBoolean() && (E2 = E2.toLocaleUpperCase()), C.isString() && c ? h += `"${E2}"` : h += E2, d2 === l2 - 1 && _ === f2 - 1 || (c ? _ === f2 - 1 ? h += ";" : h += "," : h += ", ");
  29039. }
  29040. return c && (h = `{${h}}`), h.length > 32767 ? g2.create(m2.CALC) : j.create(h);
  29041. }
  29042. _checkArray(e) {
  29043. if (e.isArray()) {
  29044. const t = e.getRowCount(), r = e.getColumnCount();
  29045. return t > 1 || r > 1 ? e : e.get(0, 0);
  29046. }
  29047. return e;
  29048. }
  29049. };
  29050. var oE = class extends V {
  29051. constructor() {
  29052. super(...arguments);
  29053. A(this, "minParams", 1);
  29054. A(this, "maxParams", 1);
  29055. }
  29056. calculate(e) {
  29057. if (e.isArray()) {
  29058. const t = e.mapValue((r) => this._handleSingleObject(r));
  29059. return t.getRowCount() === 1 && t.getColumnCount() === 1 ? t.get(0, 0) : t;
  29060. }
  29061. return this._handleSingleObject(e);
  29062. }
  29063. _handleSingleObject(e) {
  29064. if (e.isError() || e.isNull() || e.isBoolean() || e.isNumber())
  29065. return e;
  29066. const t = e.getValue().toLocaleString();
  29067. let r = "";
  29068. for (let n = 0; n < t.length; n++) {
  29069. let s = t.charCodeAt(n);
  29070. s === 12288 ? s = 32 : s >= 65281 && s <= 65374 && (s -= 65248), r += String.fromCharCode(s);
  29071. }
  29072. return j.create(r);
  29073. }
  29074. };
  29075. var uE = class extends V {
  29076. constructor() {
  29077. super(...arguments);
  29078. A(this, "minParams", 1);
  29079. A(this, "maxParams", 1);
  29080. }
  29081. calculate(e) {
  29082. if (e.isArray()) {
  29083. const t = e.mapValue((r) => this._handleSingleObject(r));
  29084. return t.getRowCount() === 1 && t.getColumnCount() === 1 ? t.get(0, 0) : t;
  29085. }
  29086. return this._handleSingleObject(e);
  29087. }
  29088. _handleSingleObject(e) {
  29089. const { isError: t, errorObject: r, variants: n } = I2(e);
  29090. if (t)
  29091. return r;
  29092. const [s] = n, o = +s.getValue(), u = Math.abs(Number.parseInt(o.toString(), 10)), c = Number.parseFloat((Math.abs(o) - u).toFixed(2));
  29093. let l2 = "";
  29094. return u === 0 ? c !== 0 ? l2 = `${o < 0 ? "ลบ" : ""}${this._convertNumberToThaiText(c * 100)}สตางค์` : l2 = "ศูนย์บาทถ้วน" : c === 0 ? l2 = `${o < 0 ? "ลบ" : ""}${this._convertNumberToThaiText(u)}บาทถ้วน` : l2 = `${o < 0 ? "ลบ" : ""}${this._convertNumberToThaiText(u)}บาท${this._convertNumberToThaiText(c * 100)}สตางค์`, j.create(l2);
  29095. }
  29096. _convertNumberToThaiText(e) {
  29097. const t = ["ล้าน", "สิบ", "ร้อย", "พัน", "หมื่น", "แสน", ""], r = ["ศูนย์", "หนึ่ง", "สอง", "สาม", "สี่", "ห้า", "หก", "เจ็ด", "แปด", "เก้า"], n = ["ลบ", "บาท", "ถ้วน", "สตางค์", "ยี่", "เอ็ด", ",", " ", "฿"], s = e.toString(), o = s.length;
  29098. let u = "";
  29099. for (let c = o; c > 0; c--) {
  29100. const l2 = Number.parseInt(s.charAt(o - c), 10);
  29101. let f2 = r[l2];
  29102. const h = c > 1 ? (c - 1) % 6 : 6;
  29103. if (h === 1 && l2 === 2 && (f2 = n[4]), l2 === 1)
  29104. switch (h) {
  29105. case 0:
  29106. case 6:
  29107. u += c < o ? n[5] : f2;
  29108. break;
  29109. case 1:
  29110. break;
  29111. default:
  29112. u += f2;
  29113. break;
  29114. }
  29115. else if (l2 === 0) {
  29116. h === 0 && (u += t[h]);
  29117. continue;
  29118. } else
  29119. u += f2;
  29120. u += t[h];
  29121. }
  29122. return u;
  29123. }
  29124. };
  29125. var cE = Object.values(ln).filter((i) => [
  29126. ln.TABLE_START,
  29127. ln.TABLE_ROW_START,
  29128. ln.TABLE_CELL_START,
  29129. ln.TABLE_CELL_END,
  29130. ln.TABLE_ROW_END,
  29131. ln.TABLE_END,
  29132. ln.CUSTOM_BLOCK
  29133. ].includes(i));
  29134. var lE = class extends V {
  29135. constructor() {
  29136. super(...arguments);
  29137. A(this, "minParams", 1);
  29138. A(this, "maxParams", 1);
  29139. }
  29140. calculate(e) {
  29141. if (e.isArray()) {
  29142. const t = e.mapValue((r) => this._handleSingleObject(r));
  29143. return t.getRowCount() === 1 && t.getColumnCount() === 1 ? t.get(0, 0) : t;
  29144. }
  29145. return this._handleSingleObject(e);
  29146. }
  29147. _handleSingleObject(e) {
  29148. const { isError: t, errorObject: r, variants: n } = I2(e);
  29149. if (t)
  29150. return r;
  29151. const [s] = n, o = Math.floor(+s.getValue());
  29152. if (o <= 0)
  29153. return g2.create(m2.VALUE);
  29154. let u = String.fromCharCode(o);
  29155. return cE.some((c) => c === u) && (u = ""), j.create(u);
  29156. }
  29157. };
  29158. var fE = class extends V {
  29159. constructor() {
  29160. super(...arguments);
  29161. A(this, "minParams", 1);
  29162. A(this, "maxParams", 1);
  29163. }
  29164. calculate(e) {
  29165. if (e.isArray()) {
  29166. const t = e.mapValue((r) => this._handleSingleObject(r));
  29167. return t.getRowCount() === 1 && t.getColumnCount() === 1 ? t.get(0, 0) : t;
  29168. }
  29169. return this._handleSingleObject(e);
  29170. }
  29171. _handleSingleObject(e) {
  29172. if (e.isError() || e.isBoolean() || e.isNumber())
  29173. return e;
  29174. if (e.isNull())
  29175. return j.create("");
  29176. const r = `${e.getValue()}`.replace(/[\0-\x1F]/g, "");
  29177. return j.create(r);
  29178. }
  29179. };
  29180. var hE = class extends V {
  29181. constructor() {
  29182. super(...arguments);
  29183. A(this, "minParams", 1);
  29184. A(this, "maxParams", 1);
  29185. }
  29186. calculate(e) {
  29187. if (e.isArray()) {
  29188. const t = e.mapValue((r) => this._handleSingleObject(r));
  29189. return t.getRowCount() === 1 && t.getColumnCount() === 1 ? t.get(0, 0) : t;
  29190. }
  29191. return this._handleSingleObject(e);
  29192. }
  29193. _handleSingleObject(e) {
  29194. if (e.isError())
  29195. return e;
  29196. if (e.isNull())
  29197. return g2.create(m2.VALUE);
  29198. let t = e.getValue().toLocaleString();
  29199. if (e.isBoolean() && (t = t.toLocaleUpperCase()), t === "")
  29200. return g2.create(m2.VALUE);
  29201. const r = t.charCodeAt(0);
  29202. return y2.create(r);
  29203. }
  29204. };
  29205. var mE = class extends V {
  29206. constructor() {
  29207. super(...arguments);
  29208. A(this, "minParams", 1);
  29209. A(this, "maxParams", 255);
  29210. }
  29211. calculate(...e) {
  29212. let t = "", r = null;
  29213. for (const n of e)
  29214. if (n.isArray()) {
  29215. if (n.iterator((s) => {
  29216. if (s == null || s.isNull())
  29217. return true;
  29218. if (s.isError())
  29219. return r = s, false;
  29220. s.isBoolean() ? t += `${s.getValue()}`.toLocaleUpperCase() : (s.isString() || s.isNumber()) && (t += s.getValue());
  29221. }), r)
  29222. return r;
  29223. } else
  29224. !n.isError() && !n.isNull() && (t += n.getValue());
  29225. return j.create(t);
  29226. }
  29227. };
  29228. var gE = class extends V {
  29229. constructor() {
  29230. super(...arguments);
  29231. A(this, "minParams", 1);
  29232. A(this, "maxParams", 255);
  29233. }
  29234. calculate(...e) {
  29235. let t = 0, r = 0;
  29236. e.forEach((s) => {
  29237. if (s.isArray()) {
  29238. const o = s;
  29239. t = Math.max(t, o.getRowCount()), r = Math.max(r, o.getColumnCount());
  29240. } else
  29241. t = Math.max(t, 1), r = Math.max(r, 1);
  29242. });
  29243. let n = null;
  29244. for (const s of e)
  29245. n = O(t, r, s, g2.create(m2.NA)).mapValue((u, c, l2) => {
  29246. const f2 = n && n.get(c, l2);
  29247. if (f2 != null && f2.isError())
  29248. return f2;
  29249. if (u.isError())
  29250. return u;
  29251. let h = f2 == null ? void 0 : f2.getValue(), d2 = u == null ? void 0 : u.getValue();
  29252. f2 != null && f2.isBoolean() && (h = `${h}`.toLocaleUpperCase()), u != null && u.isBoolean() && (d2 = `${d2}`.toLocaleUpperCase());
  29253. const _ = f2 != null && f2.isNull() ? "" : h != null ? h : "", C = u != null && u.isNull() ? "" : d2 != null ? d2 : "";
  29254. return j.create(`${_}${C}`);
  29255. });
  29256. return n || g2.create(m2.VALUE);
  29257. }
  29258. };
  29259. var dE = class extends V {
  29260. constructor() {
  29261. super(...arguments);
  29262. A(this, "minParams", 1);
  29263. A(this, "maxParams", 1);
  29264. }
  29265. calculate(e) {
  29266. if (e.isArray()) {
  29267. const t = e.mapValue((r) => this._handleSingleObject(r));
  29268. return t.getRowCount() === 1 && t.getColumnCount() === 1 ? t.get(0, 0) : t;
  29269. }
  29270. return this._handleSingleObject(e);
  29271. }
  29272. _handleSingleObject(e) {
  29273. if (e.isError())
  29274. return e;
  29275. if (e.isNull())
  29276. return j.create("");
  29277. let t = `${e.getValue()}`;
  29278. e.isBoolean() && (t = t.toLocaleUpperCase());
  29279. let r = "";
  29280. for (let n = 0; n < t.length; n++) {
  29281. const s = t.charCodeAt(n);
  29282. s >= 33 && s <= 126 ? r += String.fromCharCode(s + 65248) : s === 32 ? r += " " : r += t.charAt(n);
  29283. }
  29284. return j.create(r);
  29285. }
  29286. };
  29287. var CE = class extends V {
  29288. constructor() {
  29289. super(...arguments);
  29290. A(this, "minParams", 1);
  29291. A(this, "maxParams", 2);
  29292. A(this, "needsLocale", true);
  29293. }
  29294. calculate(e, t) {
  29295. let r = t != null ? t : y2.create(2);
  29296. r.isNull() && (r = y2.create(2));
  29297. const n = Math.max(
  29298. e.isArray() ? e.getRowCount() : 1,
  29299. r.isArray() ? r.getRowCount() : 1
  29300. ), s = Math.max(
  29301. e.isArray() ? e.getColumnCount() : 1,
  29302. r.isArray() ? r.getColumnCount() : 1
  29303. ), o = O(n, s, e, g2.create(m2.NA)), u = O(n, s, r, g2.create(m2.NA)), c = o.mapValue((l2, f2, h) => {
  29304. const d2 = u.get(f2, h);
  29305. return l2.isError() ? l2 : d2.isError() ? d2 : this._handleSingleObject(l2, d2);
  29306. });
  29307. return n === 1 && s === 1 ? c.get(0, 0) : c;
  29308. }
  29309. _handleSingleObject(e, t) {
  29310. const { isError: r, errorObject: n, variants: s } = I2(e, t);
  29311. if (r)
  29312. return n;
  29313. const [o, u] = s;
  29314. let c = +o.getValue(), l2 = Math.trunc(+u.getValue());
  29315. if (l2 > 127)
  29316. return g2.create(m2.VALUE);
  29317. l2 < 0 && (`${c}`.length < Math.abs(l2) ? c = 0 : c = c < 0 ? -vt(Math.abs(c), l2) : vt(c, l2), l2 = 0);
  29318. const f2 = al(this.getLocale(), c, l2);
  29319. return j.create(f2);
  29320. }
  29321. };
  29322. var _E = class extends V {
  29323. constructor() {
  29324. super(...arguments);
  29325. A(this, "minParams", 2);
  29326. A(this, "maxParams", 2);
  29327. }
  29328. calculate(e, t) {
  29329. const r = Math.max(
  29330. e.isArray() ? e.getRowCount() : 1,
  29331. t.isArray() ? t.getRowCount() : 1
  29332. ), n = Math.max(
  29333. e.isArray() ? e.getColumnCount() : 1,
  29334. t.isArray() ? t.getColumnCount() : 1
  29335. ), s = O(r, n, e, ie.create()), o = O(r, n, t, ie.create()), u = s.mapValue((c, l2, f2) => {
  29336. const h = o.get(l2, f2);
  29337. return c.isError() ? c : h.isError() ? h : this._handleSingleObject(c, h);
  29338. });
  29339. return r === 1 && n === 1 ? u.get(0, 0) : u;
  29340. }
  29341. _handleSingleObject(e, t) {
  29342. if (e.isNull() || t.isNull()) {
  29343. const o = e.isNull() && t.isNull();
  29344. return T2.create(o);
  29345. }
  29346. let r = `${e.getValue()}`;
  29347. e.isBoolean() && (r = r.toLocaleUpperCase());
  29348. let n = `${t.getValue()}`;
  29349. t.isBoolean() && (n = n.toLocaleUpperCase());
  29350. const s = r === n;
  29351. return T2.create(s);
  29352. }
  29353. };
  29354. var ka = (i, a2) => Op.format(i, a2, { throws: false });
  29355. var De2 = (i) => {
  29356. let a2 = `${i.getValue()}`;
  29357. return i.isNull() && (a2 = ""), i.isBoolean() && (a2 = a2.toLocaleUpperCase()), i.isNumber() && (i.getPattern() !== "" ? a2 = ka(i.getPattern(), +i.getValue()) : a2 = `${_f(+i.getValue())}`), a2;
  29358. };
  29359. var AE = class extends V {
  29360. constructor() {
  29361. super(...arguments);
  29362. A(this, "minParams", 2);
  29363. A(this, "maxParams", 3);
  29364. }
  29365. calculate(e, t, r) {
  29366. const n = r != null ? r : y2.create(1), s = Math.max(
  29367. e.isArray() ? e.getRowCount() : 1,
  29368. t.isArray() ? t.getRowCount() : 1,
  29369. n.isArray() ? n.getRowCount() : 1
  29370. ), o = Math.max(
  29371. e.isArray() ? e.getColumnCount() : 1,
  29372. t.isArray() ? t.getColumnCount() : 1,
  29373. n.isArray() ? n.getColumnCount() : 1
  29374. ), u = O(s, o, e, g2.create(m2.NA)), c = O(s, o, t, g2.create(m2.NA)), l2 = O(s, o, n, g2.create(m2.NA)), f2 = u.mapValue((h, d2, _) => {
  29375. const C = c.get(d2, _), E2 = l2.get(d2, _);
  29376. return h.isError() ? h : C.isError() ? C : E2.isError() ? E2 : this._handleSingleObject(h, C, E2);
  29377. });
  29378. return s === 1 && o === 1 ? f2.get(0, 0) : f2;
  29379. }
  29380. _handleSingleObject(e, t, r) {
  29381. const n = De2(e), s = De2(t), { isError: o, errorObject: u, variants: c } = I2(r);
  29382. if (o)
  29383. return u;
  29384. const [l2] = c, f2 = Math.floor(+l2.getValue());
  29385. if (t.isNull() || f2 <= 0 || f2 > s.length)
  29386. return g2.create(m2.VALUE);
  29387. if (e.isNull() || n.length === 0)
  29388. return y2.create(f2);
  29389. const h = s.indexOf(n, f2 - 1);
  29390. return h === -1 ? g2.create(m2.VALUE) : y2.create(h + 1);
  29391. }
  29392. };
  29393. function $a(i) {
  29394. let a2 = 0;
  29395. for (let e = 0; e < i.length; e++)
  29396. a2 += Qr2(i, e);
  29397. return a2;
  29398. }
  29399. function Qr2(i, a2, e = "ltr") {
  29400. return EE(i, a2, e) > 255 ? 2 : 1;
  29401. }
  29402. function ji(i) {
  29403. return i >= 55296 && i <= 56319;
  29404. }
  29405. function Ui(i) {
  29406. return i >= 56320 && i <= 57343;
  29407. }
  29408. function vi(i, a2) {
  29409. const e = (i & 1023) << 10, t = a2 & 1023;
  29410. return e + t + 65536;
  29411. }
  29412. function EE(i, a2, e = "ltr") {
  29413. const t = i.charCodeAt(a2);
  29414. if (e === "ltr" && ji(t) && a2 + 1 < i.length) {
  29415. const r = i.charCodeAt(a2 + 1);
  29416. if (Ui(r))
  29417. return vi(t, r);
  29418. }
  29419. if (e === "rtl" && Ui(t) && a2 - 1 >= 0) {
  29420. const r = i.charCodeAt(a2 - 1);
  29421. if (ji(r))
  29422. return vi(r, t);
  29423. }
  29424. return t;
  29425. }
  29426. var bE = class extends V {
  29427. constructor() {
  29428. super(...arguments);
  29429. A(this, "minParams", 2);
  29430. A(this, "maxParams", 3);
  29431. }
  29432. calculate(e, t, r) {
  29433. const n = r != null ? r : y2.create(1), s = Math.max(
  29434. e.isArray() ? e.getRowCount() : 1,
  29435. t.isArray() ? t.getRowCount() : 1,
  29436. n.isArray() ? n.getRowCount() : 1
  29437. ), o = Math.max(
  29438. e.isArray() ? e.getColumnCount() : 1,
  29439. t.isArray() ? t.getColumnCount() : 1,
  29440. n.isArray() ? n.getColumnCount() : 1
  29441. ), u = O(s, o, e, g2.create(m2.NA)), c = O(s, o, t, g2.create(m2.NA)), l2 = O(s, o, n, g2.create(m2.NA)), f2 = u.mapValue((h, d2, _) => {
  29442. const C = c.get(d2, _), E2 = l2.get(d2, _);
  29443. return h.isError() ? h : C.isError() ? C : E2.isError() ? E2 : this._handleSingleObject(h, C, E2);
  29444. });
  29445. return s === 1 && o === 1 ? f2.get(0, 0) : f2;
  29446. }
  29447. _handleSingleObject(e, t, r) {
  29448. const n = De2(e), s = De2(t), { isError: o, errorObject: u, variants: c } = I2(r);
  29449. if (o)
  29450. return u;
  29451. const [l2] = c, f2 = Math.floor(+l2.getValue());
  29452. if (t.isNull() || f2 <= 0 || f2 > s.length)
  29453. return g2.create(m2.VALUE);
  29454. if (e.isNull() || n.length === 0)
  29455. return y2.create(f2);
  29456. const h = s.indexOf(n, f2 - 1);
  29457. if (h === -1)
  29458. return g2.create(m2.VALUE);
  29459. const d2 = $a(s.substring(0, h)) + 1;
  29460. return y2.create(d2);
  29461. }
  29462. };
  29463. var yE = class extends V {
  29464. constructor() {
  29465. super(...arguments);
  29466. A(this, "minParams", 1);
  29467. A(this, "maxParams", 3);
  29468. }
  29469. calculate(e, t, r) {
  29470. let n = t != null ? t : y2.create(2);
  29471. n.isNull() && (n = y2.create(2));
  29472. let s = r != null ? r : T2.create(false);
  29473. s.isNull() && (s = T2.create(false));
  29474. const o = Math.max(
  29475. e.isArray() ? e.getRowCount() : 1,
  29476. n.isArray() ? n.getRowCount() : 1,
  29477. s.isArray() ? s.getRowCount() : 1
  29478. ), u = Math.max(
  29479. e.isArray() ? e.getColumnCount() : 1,
  29480. n.isArray() ? n.getColumnCount() : 1,
  29481. s.isArray() ? s.getColumnCount() : 1
  29482. ), c = O(o, u, e, g2.create(m2.NA)), l2 = O(o, u, n, g2.create(m2.NA)), f2 = O(o, u, s, g2.create(m2.NA)), h = c.mapValue((d2, _, C) => {
  29483. const E2 = l2.get(_, C), b = f2.get(_, C);
  29484. return d2.isError() ? d2 : E2.isError() ? E2 : b.isError() ? b : this._handleSingleObject(d2, E2, b);
  29485. });
  29486. return o === 1 && u === 1 ? h.get(0, 0) : h;
  29487. }
  29488. _handleSingleObject(e, t, r) {
  29489. const { isError: n, errorObject: s, variants: o } = I2(e, t, r);
  29490. if (n)
  29491. return s;
  29492. const [u, c, l2] = o;
  29493. let f2 = +u.getValue(), h = Math.trunc(+c.getValue());
  29494. const d2 = +l2.getValue();
  29495. if (h > 127)
  29496. return g2.create(m2.VALUE);
  29497. h < 0 && (`${f2}`.length < Math.abs(h) ? f2 = 0 : f2 = f2 < 0 ? -vt(Math.abs(f2), h) : vt(f2, h), h = 0);
  29498. let _ = d2 ? "###0" : "#,##0";
  29499. h > 0 && (_ += `.${"0".repeat(h)}`);
  29500. const C = ka(_, f2);
  29501. return j.create(C);
  29502. }
  29503. };
  29504. var RE = class extends V {
  29505. constructor() {
  29506. super(...arguments);
  29507. A(this, "minParams", 1);
  29508. A(this, "maxParams", 2);
  29509. }
  29510. calculate(e, t) {
  29511. const r = t != null ? t : y2.create(1), n = Math.max(
  29512. e.isArray() ? e.getRowCount() : 1,
  29513. r.isArray() ? r.getRowCount() : 1
  29514. ), s = Math.max(
  29515. e.isArray() ? e.getColumnCount() : 1,
  29516. r.isArray() ? r.getColumnCount() : 1
  29517. ), o = O(n, s, e, g2.create(m2.NA)), u = O(n, s, r, g2.create(m2.NA)), c = o.mapValue((l2, f2, h) => {
  29518. const d2 = u.get(f2, h);
  29519. return l2.isError() ? l2 : d2.isError() ? d2 : this._handleSingleObject(l2, d2);
  29520. });
  29521. return n === 1 && s === 1 ? c.get(0, 0) : c;
  29522. }
  29523. _handleSingleObject(e, t) {
  29524. const r = De2(e), { isError: n, errorObject: s, variants: o } = I2(t);
  29525. if (n)
  29526. return s;
  29527. const [u] = o, c = Math.floor(+u.getValue());
  29528. if (c < 0)
  29529. return g2.create(m2.VALUE);
  29530. if (e.isNull() || c === 0)
  29531. return j.create("");
  29532. if (c >= r.length)
  29533. return j.create(r);
  29534. const l2 = r.substring(0, c);
  29535. return j.create(l2);
  29536. }
  29537. };
  29538. var pE = class extends V {
  29539. constructor() {
  29540. super(...arguments);
  29541. A(this, "minParams", 1);
  29542. A(this, "maxParams", 2);
  29543. }
  29544. calculate(e, t) {
  29545. const r = t != null ? t : y2.create(1), n = Math.max(
  29546. e.isArray() ? e.getRowCount() : 1,
  29547. r.isArray() ? r.getRowCount() : 1
  29548. ), s = Math.max(
  29549. e.isArray() ? e.getColumnCount() : 1,
  29550. r.isArray() ? r.getColumnCount() : 1
  29551. ), o = O(n, s, e, ie.create()), u = O(n, s, r, ie.create()), c = o.mapValue((l2, f2, h) => {
  29552. const d2 = u.get(f2, h);
  29553. return l2.isError() ? l2 : d2.isError() ? d2 : this._handleSingleObject(l2, d2);
  29554. });
  29555. return n === 1 && s === 1 ? c.get(0, 0) : c;
  29556. }
  29557. _handleSingleObject(e, t) {
  29558. const r = De2(e), { isError: n, errorObject: s, variants: o } = I2(t);
  29559. if (n)
  29560. return s;
  29561. const [u] = o, c = Math.floor(+u.getValue());
  29562. if (c < 0)
  29563. return g2.create(m2.VALUE);
  29564. if (e.isNull() || c === 0)
  29565. return j.create("");
  29566. let l2 = 0, f2 = 0, h = "";
  29567. for (; f2 < c && l2 < r.length; )
  29568. f2 += Qr2(r, l2), h += r.charAt(l2), l2++;
  29569. return j.create(h);
  29570. }
  29571. };
  29572. var VE = class extends V {
  29573. constructor() {
  29574. super(...arguments);
  29575. A(this, "minParams", 1);
  29576. A(this, "maxParams", 1);
  29577. }
  29578. calculate(e) {
  29579. if (e.isArray()) {
  29580. const t = e.mapValue((r) => this._handleSingleText(r));
  29581. return t.getRowCount() === 1 && t.getColumnCount() === 1 ? t.get(0, 0) : t;
  29582. }
  29583. return this._handleSingleText(e);
  29584. }
  29585. _handleSingleText(e) {
  29586. if (e.isError())
  29587. return e;
  29588. const t = De2(e);
  29589. return y2.create(t.length);
  29590. }
  29591. };
  29592. var NE = class extends V {
  29593. constructor() {
  29594. super(...arguments);
  29595. A(this, "minParams", 1);
  29596. A(this, "maxParams", 1);
  29597. }
  29598. calculate(e) {
  29599. if (e.isArray()) {
  29600. const t = e.mapValue((r) => this._handleSingleText(r));
  29601. return t.getRowCount() === 1 && t.getColumnCount() === 1 ? t.get(0, 0) : t;
  29602. }
  29603. return this._handleSingleText(e);
  29604. }
  29605. _handleSingleText(e) {
  29606. if (e.isError())
  29607. return e;
  29608. const t = De2(e), r = $a(t);
  29609. return y2.create(r);
  29610. }
  29611. };
  29612. var OE = class extends V {
  29613. constructor() {
  29614. super(...arguments);
  29615. A(this, "minParams", 1);
  29616. A(this, "maxParams", 1);
  29617. }
  29618. calculate(e) {
  29619. if (e.isArray()) {
  29620. const t = e.mapValue((r) => this._handleSingleObject(r));
  29621. return t.getRowCount() === 1 && t.getColumnCount() === 1 ? t.get(0, 0) : t;
  29622. }
  29623. return this._handleSingleObject(e);
  29624. }
  29625. _handleSingleObject(e) {
  29626. if (e.isError())
  29627. return e;
  29628. if (e.isNull())
  29629. return j.create("");
  29630. const t = `${e.getValue()}`.toLocaleLowerCase();
  29631. return j.create(t);
  29632. }
  29633. };
  29634. var ME = class extends V {
  29635. constructor() {
  29636. super(...arguments);
  29637. A(this, "minParams", 3);
  29638. A(this, "maxParams", 3);
  29639. }
  29640. calculate(e, t, r) {
  29641. const n = Math.max(
  29642. e.isArray() ? e.getRowCount() : 1,
  29643. t.isArray() ? t.getRowCount() : 1,
  29644. r.isArray() ? r.getRowCount() : 1
  29645. ), s = Math.max(
  29646. e.isArray() ? e.getColumnCount() : 1,
  29647. t.isArray() ? t.getColumnCount() : 1,
  29648. r.isArray() ? r.getColumnCount() : 1
  29649. ), o = O(n, s, e, g2.create(m2.NA)), u = O(n, s, t, g2.create(m2.NA)), c = O(n, s, r, g2.create(m2.NA)), l2 = o.mapValue((f2, h, d2) => {
  29650. const _ = u.get(h, d2), C = c.get(h, d2);
  29651. return f2.isError() ? f2 : _.isError() ? _ : C.isError() ? C : this._handleSingleObject(f2, _, C);
  29652. });
  29653. return n === 1 && s === 1 ? l2.get(0, 0) : l2;
  29654. }
  29655. _handleSingleObject(e, t, r) {
  29656. const n = De2(e), { isError: s, errorObject: o, variants: u } = I2(t, r);
  29657. if (s)
  29658. return o;
  29659. const [c, l2] = u, f2 = Math.floor(+c.getValue()), h = Math.floor(+l2.getValue());
  29660. if (f2 <= 0 || h < 0)
  29661. return g2.create(m2.VALUE);
  29662. if (e.isNull() || f2 > n.length || h === 0)
  29663. return j.create("");
  29664. const d2 = n.substring(f2 - 1, f2 - 1 + h);
  29665. return j.create(d2);
  29666. }
  29667. };
  29668. var wE = class extends V {
  29669. constructor() {
  29670. super(...arguments);
  29671. A(this, "minParams", 3);
  29672. A(this, "maxParams", 3);
  29673. }
  29674. calculate(e, t, r) {
  29675. const n = Math.max(
  29676. e.isArray() ? e.getRowCount() : 1,
  29677. t.isArray() ? t.getRowCount() : 1,
  29678. r.isArray() ? r.getRowCount() : 1
  29679. ), s = Math.max(
  29680. e.isArray() ? e.getColumnCount() : 1,
  29681. t.isArray() ? t.getColumnCount() : 1,
  29682. r.isArray() ? r.getColumnCount() : 1
  29683. ), o = O(n, s, e, g2.create(m2.NA)), u = O(n, s, t, g2.create(m2.NA)), c = O(n, s, r, g2.create(m2.NA)), l2 = o.mapValue((f2, h, d2) => {
  29684. const _ = u.get(h, d2), C = c.get(h, d2);
  29685. return f2.isError() ? f2 : _.isError() ? _ : C.isError() ? C : this._handleSingleObject(f2, _, C);
  29686. });
  29687. return n === 1 && s === 1 ? l2.get(0, 0) : l2;
  29688. }
  29689. _handleSingleObject(e, t, r) {
  29690. let n = De2(e);
  29691. const { isError: s, errorObject: o, variants: u } = I2(t, r);
  29692. if (s)
  29693. return o;
  29694. const [c, l2] = u, f2 = Math.floor(+c.getValue()), h = Math.floor(+l2.getValue());
  29695. if (f2 <= 0 || h < 0)
  29696. return g2.create(m2.VALUE);
  29697. if (e.isNull() || f2 > n.length || h === 0)
  29698. return j.create("");
  29699. n = n.substring(f2 - 1);
  29700. let d2 = 0, _ = 0, C = "";
  29701. for (; _ < h && d2 < n.length; )
  29702. _ += Qr2(n, d2), C += n.charAt(d2), d2++;
  29703. return j.create(C);
  29704. }
  29705. };
  29706. var DE = class extends V {
  29707. constructor() {
  29708. super(...arguments);
  29709. A(this, "minParams", 1);
  29710. A(this, "maxParams", 3);
  29711. }
  29712. calculate(e, t, r) {
  29713. const n = t != null ? t : j.create("."), s = Math.max(
  29714. e.isArray() ? e.getRowCount() : 1,
  29715. n.isArray() ? n.getRowCount() : 1,
  29716. r != null && r.isArray() ? r.getRowCount() : 1
  29717. ), o = Math.max(
  29718. e.isArray() ? e.getColumnCount() : 1,
  29719. n.isArray() ? n.getColumnCount() : 1,
  29720. r != null && r.isArray() ? r.getColumnCount() : 1
  29721. ), u = O(s, o, e, g2.create(m2.NA)), c = O(s, o, n, g2.create(m2.NA)), l2 = r ? O(s, o, r, g2.create(m2.NA)) : void 0, f2 = u.mapValue((h, d2, _) => {
  29722. const C = c.get(d2, _), E2 = r ? l2.get(d2, _) : void 0;
  29723. return h.isError() ? h : C.isError() ? C : E2 != null && E2.isError() ? E2 : C.isNull() || E2 != null && E2.isNull() ? g2.create(m2.VALUE) : h.isNull() ? y2.create(0) : this._handleSingleObject(h, C, E2);
  29724. });
  29725. return s === 1 && o === 1 ? f2.get(0, 0) : f2;
  29726. }
  29727. // eslint-disable-next-line
  29728. _handleSingleObject(e, t, r) {
  29729. let n = `${e.getValue()}`;
  29730. n = n.replace(/\s+/g, "");
  29731. let s = `${t.getValue()}`;
  29732. t.isBoolean() && (s = s.toLocaleUpperCase()), s = s.charAt(0);
  29733. let o;
  29734. if (r && (o = `${r.getValue()}`, r.isBoolean() && (o = o.toLocaleUpperCase()), o = o.charAt(0), s === o))
  29735. return g2.create(m2.VALUE);
  29736. if (n.trim() === "")
  29737. return y2.create(0);
  29738. if (!n.match(/^\s*[+-]?\s*(?:(?:\d+(?:\.\d*)?)|(?:\.\d+))(?:[eE][+-]?\d+)?[ \t]*/))
  29739. return g2.create(m2.VALUE);
  29740. const u = n.split(s);
  29741. if (u.length > 2)
  29742. return g2.create(m2.VALUE);
  29743. let c = u[0].replace(/,/g, "");
  29744. r && (c = c.split(o).join(""));
  29745. let l2 = 0;
  29746. if (u.length === 1) {
  29747. s === "," && (c = c.replace(/\./g, ""));
  29748. let f2 = 0;
  29749. for (; c.endsWith("%"); )
  29750. c = c.slice(0, -1), f2++;
  29751. f2 > 0 ? l2 = +c / 100 ** f2 : l2 = +c;
  29752. } else {
  29753. if (!DC(c))
  29754. return g2.create(m2.VALUE);
  29755. let f2 = u[1], h = 0;
  29756. for (; f2.endsWith("%"); )
  29757. f2 = f2.slice(0, -1), h++;
  29758. const d2 = `${c}.${f2}`;
  29759. if (!DC(d2))
  29760. return g2.create(m2.VALUE);
  29761. h > 0 ? l2 = +d2 / 100 ** h : l2 = +d2;
  29762. }
  29763. return Number.isNaN(l2) ? g2.create(m2.VALUE) : y2.create(l2);
  29764. }
  29765. };
  29766. var SE2 = class extends V {
  29767. constructor() {
  29768. super(...arguments);
  29769. A(this, "minParams", 1);
  29770. A(this, "maxParams", 1);
  29771. }
  29772. calculate(e) {
  29773. if (e.isArray()) {
  29774. const t = e.mapValue((r) => this._handleSingleObject(r));
  29775. return t.getRowCount() === 1 && t.getColumnCount() === 1 ? t.get(0, 0) : t;
  29776. }
  29777. return this._handleSingleObject(e);
  29778. }
  29779. _handleSingleObject(e) {
  29780. if (e.isError() || e.isNull() || e.isBoolean() || e.isNumber())
  29781. return e;
  29782. const r = e.getValue().toLocaleString().toLocaleLowerCase().replace(/(^|\b|\W|\d|_)[a-z]/g, (n) => n.toLocaleUpperCase());
  29783. return j.create(r);
  29784. }
  29785. };
  29786. var Nu = () => [
  29787. {
  29788. type: 4,
  29789. from: 48,
  29790. to: 57
  29791. }
  29792. ];
  29793. var Ou = () => [
  29794. {
  29795. type: 7,
  29796. value: 95
  29797. },
  29798. {
  29799. type: 4,
  29800. from: 97,
  29801. to: 122
  29802. },
  29803. {
  29804. type: 4,
  29805. from: 65,
  29806. to: 90
  29807. },
  29808. {
  29809. type: 4,
  29810. from: 48,
  29811. to: 57
  29812. }
  29813. ];
  29814. var Mu = () => [
  29815. {
  29816. type: 7,
  29817. value: 9
  29818. },
  29819. {
  29820. type: 7,
  29821. value: 10
  29822. },
  29823. {
  29824. type: 7,
  29825. value: 11
  29826. },
  29827. {
  29828. type: 7,
  29829. value: 12
  29830. },
  29831. {
  29832. type: 7,
  29833. value: 13
  29834. },
  29835. {
  29836. type: 7,
  29837. value: 32
  29838. },
  29839. {
  29840. type: 7,
  29841. value: 160
  29842. },
  29843. {
  29844. type: 7,
  29845. value: 5760
  29846. },
  29847. {
  29848. type: 4,
  29849. from: 8192,
  29850. to: 8202
  29851. },
  29852. {
  29853. type: 7,
  29854. value: 8232
  29855. },
  29856. {
  29857. type: 7,
  29858. value: 8233
  29859. },
  29860. {
  29861. type: 7,
  29862. value: 8239
  29863. },
  29864. {
  29865. type: 7,
  29866. value: 8287
  29867. },
  29868. {
  29869. type: 7,
  29870. value: 12288
  29871. },
  29872. {
  29873. type: 7,
  29874. value: 65279
  29875. }
  29876. ];
  29877. var wu = () => ({
  29878. type: 3,
  29879. set: Ou(),
  29880. not: false
  29881. });
  29882. var Du = () => ({
  29883. type: 3,
  29884. set: Ou(),
  29885. not: true
  29886. });
  29887. var Su = () => ({
  29888. type: 3,
  29889. set: Nu(),
  29890. not: false
  29891. });
  29892. var Pu = () => ({
  29893. type: 3,
  29894. set: Nu(),
  29895. not: true
  29896. });
  29897. var Lu = () => ({
  29898. type: 3,
  29899. set: Mu(),
  29900. not: false
  29901. });
  29902. var xu = () => ({
  29903. type: 3,
  29904. set: Mu(),
  29905. not: true
  29906. });
  29907. var PE = () => ({
  29908. type: 3,
  29909. set: [
  29910. {
  29911. type: 7,
  29912. value: 10
  29913. },
  29914. {
  29915. type: 7,
  29916. value: 13
  29917. },
  29918. {
  29919. type: 7,
  29920. value: 8232
  29921. },
  29922. {
  29923. type: 7,
  29924. value: 8233
  29925. }
  29926. ],
  29927. not: true
  29928. });
  29929. function LE(i) {
  29930. const a2 = {
  29931. type: 0,
  29932. stack: []
  29933. };
  29934. let e = a2, t = a2.stack;
  29935. const r = [], n = [];
  29936. let s = 0;
  29937. const o = (f2) => {
  29938. throw new SyntaxError(`Invalid regular expression: /${i}/: Nothing to repeat at column ${f2 - 1}`);
  29939. }, u = jE(i);
  29940. let c = 0, l2;
  29941. for (; c < u.length; )
  29942. switch (l2 = u[c++], l2) {
  29943. case "\\":
  29944. if (c === u.length)
  29945. throw new SyntaxError(`Invalid regular expression: /${i}/: \\ at end of pattern`);
  29946. switch (l2 = u[c++], l2) {
  29947. case "b":
  29948. t.push({
  29949. type: 2,
  29950. value: "b"
  29951. });
  29952. break;
  29953. case "B":
  29954. t.push({
  29955. type: 2,
  29956. value: "B"
  29957. });
  29958. break;
  29959. case "w":
  29960. t.push(wu());
  29961. break;
  29962. case "W":
  29963. t.push(Du());
  29964. break;
  29965. case "d":
  29966. t.push(Su());
  29967. break;
  29968. case "D":
  29969. t.push(Pu());
  29970. break;
  29971. case "s":
  29972. t.push(Lu());
  29973. break;
  29974. case "S":
  29975. t.push(xu());
  29976. break;
  29977. default:
  29978. if (/\d/.test(l2)) {
  29979. for (; /\d/.test(u[c]) && c < u.length; )
  29980. l2 += u[c++];
  29981. const f2 = Number.parseInt(l2, 10);
  29982. t.push({
  29983. type: 6,
  29984. value: f2
  29985. }), n.push({
  29986. reference: {
  29987. type: 6,
  29988. value: f2
  29989. },
  29990. stack: t,
  29991. index: t.length - 1
  29992. });
  29993. } else
  29994. t.push({
  29995. type: 7,
  29996. value: l2.charCodeAt(0)
  29997. });
  29998. }
  29999. break;
  30000. case "^":
  30001. t.push({
  30002. type: 2,
  30003. value: "^"
  30004. });
  30005. break;
  30006. case "$":
  30007. t.push({
  30008. type: 2,
  30009. value: "$"
  30010. });
  30011. break;
  30012. case "[": {
  30013. const f2 = u[c] === "^";
  30014. f2 && c++;
  30015. const h = xE(u.slice(c), i);
  30016. c += h[1], t.push({
  30017. type: 3,
  30018. set: h[0],
  30019. not: f2
  30020. });
  30021. break;
  30022. }
  30023. case ".":
  30024. t.push(PE());
  30025. break;
  30026. case "(": {
  30027. const f2 = {
  30028. type: 1,
  30029. stack: [],
  30030. remember: true
  30031. // 默认情况下,捕获组是需要记住(捕获)的
  30032. };
  30033. if (u[c] === "?") {
  30034. const h = u[c + 1];
  30035. if (c += 2, h === "=")
  30036. f2.followedBy = true;
  30037. else if (h === "!")
  30038. f2.notFollowedBy = true;
  30039. else if (h !== ":")
  30040. throw new SyntaxError(`Invalid regular expression: /${i}/: Invalid group, character '${h}' after '?' at column ${c - 1}`);
  30041. f2.remember = false;
  30042. } else
  30043. s += 1;
  30044. t.push(f2), r.push(e), e = f2, t = f2.stack;
  30045. break;
  30046. }
  30047. case ")":
  30048. if (r.length === 0)
  30049. throw new SyntaxError(`Invalid regular expression: /${i}/: Unmatched ) at column ${c - 1}`);
  30050. e = r.pop(), t = e.options ? e.options[e.options.length - 1] : e.stack;
  30051. break;
  30052. case "|": {
  30053. e.options || (e.options = [e.stack], delete e.stack);
  30054. const f2 = [];
  30055. e.options.push(f2), t = f2;
  30056. break;
  30057. }
  30058. case "{": {
  30059. const f2 = /^(\d+)(,(\d+)?)?\}/.exec(u.slice(c));
  30060. if (f2) {
  30061. t.length === 0 && o(c);
  30062. const h = Number.parseInt(f2[1], 10), d2 = f2[2] ? f2[3] ? Number.parseInt(f2[3], 10) : 1 / 0 : h;
  30063. c += f2[0].length, t.push({
  30064. type: 5,
  30065. min: h,
  30066. max: d2,
  30067. value: t.pop()
  30068. });
  30069. } else
  30070. t.push({
  30071. // Assuming 123 is the character code for '{'
  30072. type: 7,
  30073. value: 123
  30074. });
  30075. break;
  30076. }
  30077. case "?":
  30078. t.length === 0 && o(c), t.push({
  30079. type: 5,
  30080. min: 0,
  30081. max: 1,
  30082. value: t.pop()
  30083. });
  30084. break;
  30085. case "+":
  30086. t.length === 0 && o(c), t.push({
  30087. type: 5,
  30088. min: 1,
  30089. max: 1 / 0,
  30090. value: t.pop()
  30091. });
  30092. break;
  30093. case "*":
  30094. t.length === 0 && o(c), t.push({
  30095. type: 5,
  30096. min: 0,
  30097. max: 1 / 0,
  30098. value: t.pop()
  30099. });
  30100. break;
  30101. default:
  30102. t.push({
  30103. type: 7,
  30104. value: l2.charCodeAt(0)
  30105. });
  30106. }
  30107. if (r.length > 0)
  30108. throw new SyntaxError(`Invalid regular expression: /${i}/: Unterminated group`);
  30109. return UE(n, s), a2;
  30110. }
  30111. function xE(i, a2) {
  30112. let e;
  30113. const t = [], r = /\\(?:(w)|(d)|(s)|(W)|(D)|(S))|((?:(?:\\)(.)|([^\]\\]))-(((?:\\)])|(((?:\\)?([^\]])))))|(\])|(?:\\)?([^])/g;
  30114. for (; (e = r.exec(i)) !== null; ) {
  30115. let n = null;
  30116. const [, s, o, u, c, l2, f2, h, d2, _, C] = e;
  30117. if (s || o || u || c || l2 || f2 ? n = (() => {
  30118. let E2 = {
  30119. type: 3,
  30120. set: [],
  30121. not: false
  30122. };
  30123. return s ? E2 = wu() : o ? E2 = Su() : u ? E2 = Lu() : c ? E2 = Du() : l2 ? E2 = Pu() : f2 && (E2 = xu()), E2;
  30124. })() : h && C ? n = {
  30125. type: 4,
  30126. from: (d2 || _).charCodeAt(0),
  30127. to: C.charCodeAt(C.length - 1)
  30128. } : e[16] && (n = {
  30129. type: 7,
  30130. value: e[16].charCodeAt(0)
  30131. }), !n)
  30132. return [t, r.lastIndex];
  30133. t.push(n);
  30134. }
  30135. throw new SyntaxError(`Invalid regular expression: /${a2}/: Unterminated character class`);
  30136. }
  30137. function jE(i) {
  30138. return i.replace(
  30139. /(\[\\b\])|(\\)?\\(?:u([A-F0-9]{4})|x([A-F0-9]{2})|c([@A-Z[\\\]^?])|([0tnvfr]))/g,
  30140. (a2, e, t, r, n, s, o) => {
  30141. if (t)
  30142. return a2;
  30143. let u;
  30144. e ? u = 8 : r ? u = Number.parseInt(r, 16) : n ? u = Number.parseInt(n, 16) : s ? u = "@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^ ?".indexOf(s) : u = {
  30145. 0: 0,
  30146. t: 9,
  30147. n: 10,
  30148. v: 11,
  30149. f: 12,
  30150. r: 13
  30151. }[o];
  30152. const c = String.fromCharCode(u);
  30153. return /[[\]{}^$.|?*+()]/.test(c) ? `\\${c}` : c;
  30154. }
  30155. );
  30156. }
  30157. function UE(i, a2) {
  30158. for (const e of i.reverse()) {
  30159. const t = e.reference.value;
  30160. if (a2 < t) {
  30161. e.reference.type = 7;
  30162. const r = t.toString();
  30163. if (e.reference.value = Number.parseInt(r, 8), !/^[0-7]+$/.test(r)) {
  30164. let n = 0;
  30165. for (; r[n] !== "8" && r[n] !== "9" && n < r.length; )
  30166. n += 1;
  30167. if (n === 0 ? (e.reference.value = r.charCodeAt(0), n += 1) : e.reference.value = Number.parseInt(r.slice(0, n), 8), r.length > n) {
  30168. const s = e.stack.splice(e.index + 1);
  30169. for (const o of r.slice(n))
  30170. e.stack.push({
  30171. type: 7,
  30172. value: o.charCodeAt(0)
  30173. });
  30174. e.stack.push(...s);
  30175. }
  30176. }
  30177. }
  30178. }
  30179. }
  30180. function Ya(i, a2) {
  30181. if (!vE(i))
  30182. return {
  30183. isError: true,
  30184. regExp: null
  30185. };
  30186. try {
  30187. const e = new RegExp(i, a2 ? "ug" : "u");
  30188. return TE(e) ? {
  30189. isError: false,
  30190. regExp: e
  30191. } : {
  30192. isError: true,
  30193. regExp: null
  30194. };
  30195. } catch {
  30196. return {
  30197. isError: true,
  30198. regExp: null
  30199. };
  30200. }
  30201. }
  30202. function vE(i) {
  30203. return !(/\(\?<=.*?\)/g.test(i) && !/\[.*?(\?<=.*?)\]/g.test(i) || /\(\?<!.*?\)/g.test(i) && !/\[.*?(\?<!.*?)\]/g.test(i));
  30204. }
  30205. function TE(i, a2) {
  30206. let t;
  30207. Object.prototype.toString.call(i) === "[object RegExp]" ? t = i.source : i && typeof i != "string" && (t = `${i}`);
  30208. let r;
  30209. try {
  30210. r = LE(t);
  30211. } catch {
  30212. return false;
  30213. }
  30214. let n = 0;
  30215. const s = (o, u) => {
  30216. let c = u;
  30217. if (o.type === 5 && (c++, n++, c > 1 || n > 25))
  30218. return false;
  30219. if (o.options) {
  30220. for (const f2 of o.options)
  30221. if (!s({ stack: f2 }, c))
  30222. return false;
  30223. }
  30224. const l2 = o.stack || o.value && o.value.stack;
  30225. if (!l2)
  30226. return true;
  30227. for (const f2 of l2)
  30228. if (!s(f2, c))
  30229. return false;
  30230. return true;
  30231. };
  30232. return s(r, 0);
  30233. }
  30234. var BE = class extends V {
  30235. constructor() {
  30236. super(...arguments);
  30237. A(this, "minParams", 2);
  30238. A(this, "maxParams", 2);
  30239. }
  30240. calculate(e, t) {
  30241. const { isError: r, errorObject: n, variants: s } = Fr(e, t);
  30242. if (r)
  30243. return n;
  30244. const [o, u] = s;
  30245. let c = o.getValue();
  30246. o.isNull() && (c = ""), o.isBoolean() && (c = c ? "TRUE" : "FALSE"), c = `${c}`;
  30247. let l2 = u.getValue();
  30248. u.isNull() && (l2 = ""), u.isBoolean() && (l2 = l2 ? "TRUE" : "FALSE"), l2 = `${l2}`;
  30249. const { isError: f2, regExp: h } = Ya(l2, false);
  30250. if (f2)
  30251. return g2.create(m2.REF);
  30252. const d2 = c.match(h);
  30253. if (d2 === null)
  30254. return g2.create(m2.NA);
  30255. if (d2.length > 1) {
  30256. const _ = d2.slice(1).map((C) => j.create(C));
  30257. return _.length > 1 ? q2.create({
  30258. calculateValueList: [_],
  30259. rowCount: 1,
  30260. columnCount: _.length,
  30261. unitId: this.unitId,
  30262. sheetId: this.subUnitId,
  30263. row: this.row,
  30264. column: this.column
  30265. }) : _[0];
  30266. }
  30267. return j.create(d2[0]);
  30268. }
  30269. };
  30270. var IE = class extends V {
  30271. constructor() {
  30272. super(...arguments);
  30273. A(this, "minParams", 2);
  30274. A(this, "maxParams", 2);
  30275. }
  30276. calculate(e, t) {
  30277. const { isError: r, errorObject: n, variants: s } = Fr(e, t);
  30278. if (r)
  30279. return n;
  30280. const [o, u] = s;
  30281. let c = o.getValue();
  30282. o.isNull() && (c = ""), o.isBoolean() && (c = c ? "TRUE" : "FALSE"), c = `${c}`;
  30283. let l2 = u.getValue();
  30284. u.isNull() && (l2 = ""), u.isBoolean() && (l2 = l2 ? "TRUE" : "FALSE"), l2 = `${l2}`;
  30285. const { isError: f2, regExp: h } = Ya(l2, false);
  30286. return f2 ? g2.create(m2.REF) : c.match(h) === null ? T2.create(false) : T2.create(true);
  30287. }
  30288. };
  30289. var FE = class extends V {
  30290. constructor() {
  30291. super(...arguments);
  30292. A(this, "minParams", 3);
  30293. A(this, "maxParams", 3);
  30294. }
  30295. calculate(e, t, r) {
  30296. const { isError: n, errorObject: s, variants: o } = Fr(e, t, r);
  30297. if (n)
  30298. return s;
  30299. const [u, c, l2] = o;
  30300. let f2 = u.getValue();
  30301. u.isNull() && (f2 = ""), u.isBoolean() && (f2 = f2 ? "TRUE" : "FALSE"), f2 = `${f2}`;
  30302. let h = c.getValue();
  30303. c.isNull() && (h = ""), c.isBoolean() && (h = h ? "TRUE" : "FALSE"), h = `${h}`;
  30304. let d2 = l2.getValue();
  30305. l2.isNull() && (d2 = ""), l2.isBoolean() && (d2 = d2 ? "TRUE" : "FALSE"), d2 = `${d2}`;
  30306. const { isError: _, regExp: C } = Ya(h, true);
  30307. if (_)
  30308. return g2.create(m2.REF);
  30309. const E2 = f2.replace(C, d2);
  30310. return j.create(E2);
  30311. }
  30312. };
  30313. var kE = class extends V {
  30314. constructor() {
  30315. super(...arguments);
  30316. A(this, "minParams", 4);
  30317. A(this, "maxParams", 4);
  30318. }
  30319. calculate(e, t, r, n) {
  30320. const s = Math.max(
  30321. e.isArray() ? e.getRowCount() : 1,
  30322. t.isArray() ? t.getRowCount() : 1,
  30323. r.isArray() ? r.getRowCount() : 1,
  30324. n.isArray() ? n.getRowCount() : 1
  30325. ), o = Math.max(
  30326. e.isArray() ? e.getColumnCount() : 1,
  30327. t.isArray() ? t.getColumnCount() : 1,
  30328. r.isArray() ? r.getColumnCount() : 1,
  30329. n.isArray() ? n.getColumnCount() : 1
  30330. ), u = O(s, o, e, g2.create(m2.NA)), c = O(s, o, t, g2.create(m2.NA)), l2 = O(s, o, r, g2.create(m2.NA)), f2 = O(s, o, n, g2.create(m2.NA)), h = u.mapValue((d2, _, C) => {
  30331. const E2 = c.get(_, C), b = l2.get(_, C), R = f2.get(_, C);
  30332. return d2.isError() ? d2 : E2.isError() ? E2 : b.isError() ? b : R.isError() ? R : this._handleSingleObject(d2, E2, b, R);
  30333. });
  30334. return s === 1 && o === 1 ? h.get(0, 0) : h;
  30335. }
  30336. _handleSingleObject(e, t, r, n) {
  30337. const { isError: s, errorObject: o, variants: u } = I2(t, r);
  30338. if (s)
  30339. return o;
  30340. const [c, l2] = u, f2 = Math.floor(+c.getValue()), h = Math.floor(+l2.getValue());
  30341. if (f2 <= 0 || h < 0)
  30342. return g2.create(m2.VALUE);
  30343. const d2 = De2(e), _ = De2(n), C = d2.substring(0, f2 - 1) + _ + d2.substring(f2 - 1 + h);
  30344. return j.create(C);
  30345. }
  30346. };
  30347. var $E = class extends V {
  30348. constructor() {
  30349. super(...arguments);
  30350. A(this, "minParams", 4);
  30351. A(this, "maxParams", 4);
  30352. }
  30353. calculate(e, t, r, n) {
  30354. const s = Math.max(
  30355. e.isArray() ? e.getRowCount() : 1,
  30356. t.isArray() ? t.getRowCount() : 1,
  30357. r.isArray() ? r.getRowCount() : 1,
  30358. n.isArray() ? n.getRowCount() : 1
  30359. ), o = Math.max(
  30360. e.isArray() ? e.getColumnCount() : 1,
  30361. t.isArray() ? t.getColumnCount() : 1,
  30362. r.isArray() ? r.getColumnCount() : 1,
  30363. n.isArray() ? n.getColumnCount() : 1
  30364. ), u = O(s, o, e, g2.create(m2.NA)), c = O(s, o, t, g2.create(m2.NA)), l2 = O(s, o, r, g2.create(m2.NA)), f2 = O(s, o, n, g2.create(m2.NA)), h = u.mapValue((d2, _, C) => {
  30365. const E2 = c.get(_, C), b = l2.get(_, C), R = f2.get(_, C);
  30366. return d2.isError() ? d2 : E2.isError() ? E2 : b.isError() ? b : R.isError() ? R : this._handleSingleObject(d2, E2, b, R);
  30367. });
  30368. return s === 1 && o === 1 ? h.get(0, 0) : h;
  30369. }
  30370. _handleSingleObject(e, t, r, n) {
  30371. const { isError: s, errorObject: o, variants: u } = I2(t, r);
  30372. if (s)
  30373. return o;
  30374. const [c, l2] = u, f2 = Math.floor(+c.getValue()), h = Math.floor(+l2.getValue());
  30375. if (f2 <= 0 || h < 0)
  30376. return g2.create(m2.VALUE);
  30377. let d2 = De2(e);
  30378. const _ = De2(n);
  30379. let C = d2.substring(0, f2 - 1);
  30380. d2 = d2.substring(f2 - 1);
  30381. let E2 = 0, b = 0;
  30382. for (; b < h && E2 < d2.length; )
  30383. b += Qr2(d2, E2), E2++;
  30384. return C += _ + d2.substring(E2), j.create(C);
  30385. }
  30386. };
  30387. var YE = class extends V {
  30388. constructor() {
  30389. super(...arguments);
  30390. A(this, "minParams", 2);
  30391. A(this, "maxParams", 2);
  30392. }
  30393. calculate(e, t) {
  30394. if (e.isError())
  30395. return e;
  30396. if (t.isError())
  30397. return t;
  30398. const r = Math.max(
  30399. e.isArray() ? e.getRowCount() : 1,
  30400. t.isArray() ? t.getRowCount() : 1
  30401. ), n = Math.max(
  30402. e.isArray() ? e.getColumnCount() : 1,
  30403. t.isArray() ? t.getColumnCount() : 1
  30404. ), s = O(r, n, e, g2.create(m2.NA)), o = O(r, n, t, g2.create(m2.NA)), u = s.map((c, l2, f2) => {
  30405. let h = o.get(l2, f2);
  30406. if (c.isError())
  30407. return c;
  30408. let d2 = c.getValue();
  30409. if (c.isNull() && (d2 = ""), c.isBoolean() && (d2 = d2 ? "TRUE" : "FALSE"), d2 += "", h.isString() && (h = h.convertToNumberObjectValue()), h.isError())
  30410. return h;
  30411. const _ = 32767, C = Math.floor(+h.getValue());
  30412. if (C < 0 || C > _ / d2.length)
  30413. return g2.create(m2.VALUE);
  30414. const E2 = d2.repeat(C);
  30415. return j.create(E2);
  30416. });
  30417. return r === 1 && n === 1 ? u.get(0, 0) : u;
  30418. }
  30419. };
  30420. var HE = class extends V {
  30421. constructor() {
  30422. super(...arguments);
  30423. A(this, "minParams", 1);
  30424. A(this, "maxParams", 2);
  30425. }
  30426. calculate(e, t) {
  30427. const r = t != null ? t : y2.create(1), n = Math.max(
  30428. e.isArray() ? e.getRowCount() : 1,
  30429. r.isArray() ? r.getRowCount() : 1
  30430. ), s = Math.max(
  30431. e.isArray() ? e.getColumnCount() : 1,
  30432. r.isArray() ? r.getColumnCount() : 1
  30433. ), o = O(n, s, e, g2.create(m2.NA)), u = O(n, s, r, g2.create(m2.NA)), c = o.mapValue((l2, f2, h) => {
  30434. const d2 = u.get(f2, h);
  30435. return l2.isError() ? l2 : d2.isError() ? d2 : this._handleSingleObject(l2, d2);
  30436. });
  30437. return n === 1 && s === 1 ? c.get(0, 0) : c;
  30438. }
  30439. _handleSingleObject(e, t) {
  30440. const r = De2(e), { isError: n, errorObject: s, variants: o } = I2(t);
  30441. if (n)
  30442. return s;
  30443. const [u] = o, c = Math.floor(+u.getValue());
  30444. if (c < 0)
  30445. return g2.create(m2.VALUE);
  30446. if (e.isNull() || c === 0)
  30447. return j.create("");
  30448. if (c >= r.length)
  30449. return j.create(r);
  30450. const l2 = r.substring(r.length - c);
  30451. return j.create(l2);
  30452. }
  30453. };
  30454. var GE = class extends V {
  30455. constructor() {
  30456. super(...arguments);
  30457. A(this, "minParams", 1);
  30458. A(this, "maxParams", 2);
  30459. }
  30460. calculate(e, t) {
  30461. const r = t != null ? t : y2.create(1), n = Math.max(
  30462. e.isArray() ? e.getRowCount() : 1,
  30463. r.isArray() ? r.getRowCount() : 1
  30464. ), s = Math.max(
  30465. e.isArray() ? e.getColumnCount() : 1,
  30466. r.isArray() ? r.getColumnCount() : 1
  30467. ), o = O(n, s, e, g2.create(m2.NA)), u = O(n, s, r, g2.create(m2.NA)), c = o.mapValue((l2, f2, h) => {
  30468. const d2 = u.get(f2, h);
  30469. return l2.isError() ? l2 : d2.isError() ? d2 : this._handleSingleObject(l2, d2);
  30470. });
  30471. return n === 1 && s === 1 ? c.get(0, 0) : c;
  30472. }
  30473. _handleSingleObject(e, t) {
  30474. const r = De2(e), { isError: n, errorObject: s, variants: o } = I2(t);
  30475. if (n)
  30476. return s;
  30477. const [u] = o, c = Math.floor(+u.getValue());
  30478. if (c < 0)
  30479. return g2.create(m2.VALUE);
  30480. if (e.isNull() || c === 0)
  30481. return j.create("");
  30482. let l2 = r.length - 1, f2 = 0, h = "";
  30483. for (; f2 < c && l2 >= 0; )
  30484. f2 += Qr2(r, l2, "rtl"), h = r.charAt(l2) + h, l2--;
  30485. return j.create(h);
  30486. }
  30487. };
  30488. var QE = class extends V {
  30489. constructor() {
  30490. super(...arguments);
  30491. A(this, "minParams", 2);
  30492. A(this, "maxParams", 3);
  30493. }
  30494. calculate(e, t, r) {
  30495. const n = r != null ? r : y2.create(1), s = Math.max(
  30496. e.isArray() ? e.getRowCount() : 1,
  30497. t.isArray() ? t.getRowCount() : 1,
  30498. n.isArray() ? n.getRowCount() : 1
  30499. ), o = Math.max(
  30500. e.isArray() ? e.getColumnCount() : 1,
  30501. t.isArray() ? t.getColumnCount() : 1,
  30502. n.isArray() ? n.getColumnCount() : 1
  30503. ), u = O(s, o, e, g2.create(m2.NA)), c = O(s, o, t, g2.create(m2.NA)), l2 = O(s, o, n, g2.create(m2.NA)), f2 = u.mapValue((h, d2, _) => {
  30504. const C = c.get(d2, _), E2 = l2.get(d2, _);
  30505. return h.isError() ? h : C.isError() ? C : E2.isError() ? E2 : this._handleSingleObject(h, C, E2);
  30506. });
  30507. return s === 1 && o === 1 ? f2.get(0, 0) : f2;
  30508. }
  30509. _handleSingleObject(e, t, r) {
  30510. const n = De2(e).toLocaleUpperCase(), s = De2(t).toLocaleUpperCase(), { isError: o, errorObject: u, variants: c } = I2(r);
  30511. if (o)
  30512. return u;
  30513. const [l2] = c, f2 = Math.floor(+l2.getValue());
  30514. if (t.isNull() || f2 <= 0 || f2 > s.length)
  30515. return g2.create(m2.VALUE);
  30516. if (e.isNull() || n.length === 0)
  30517. return y2.create(f2);
  30518. const h = s.indexOf(n, f2 - 1);
  30519. return h === -1 ? g2.create(m2.VALUE) : y2.create(h + 1);
  30520. }
  30521. };
  30522. var WE = class extends V {
  30523. constructor() {
  30524. super(...arguments);
  30525. A(this, "minParams", 2);
  30526. A(this, "maxParams", 3);
  30527. }
  30528. calculate(e, t, r) {
  30529. const n = r != null ? r : y2.create(1), s = Math.max(
  30530. e.isArray() ? e.getRowCount() : 1,
  30531. t.isArray() ? t.getRowCount() : 1,
  30532. n.isArray() ? n.getRowCount() : 1
  30533. ), o = Math.max(
  30534. e.isArray() ? e.getColumnCount() : 1,
  30535. t.isArray() ? t.getColumnCount() : 1,
  30536. n.isArray() ? n.getColumnCount() : 1
  30537. ), u = O(s, o, e, g2.create(m2.NA)), c = O(s, o, t, g2.create(m2.NA)), l2 = O(s, o, n, g2.create(m2.NA)), f2 = u.mapValue((h, d2, _) => {
  30538. const C = c.get(d2, _), E2 = l2.get(d2, _);
  30539. return h.isError() ? h : C.isError() ? C : E2.isError() ? E2 : this._handleSingleObject(h, C, E2);
  30540. });
  30541. return s === 1 && o === 1 ? f2.get(0, 0) : f2;
  30542. }
  30543. _handleSingleObject(e, t, r) {
  30544. const n = De2(e).toLocaleUpperCase(), s = De2(t).toLocaleUpperCase(), { isError: o, errorObject: u, variants: c } = I2(r);
  30545. if (o)
  30546. return u;
  30547. const [l2] = c, f2 = Math.floor(+l2.getValue());
  30548. if (t.isNull() || f2 <= 0 || f2 > s.length)
  30549. return g2.create(m2.VALUE);
  30550. if (e.isNull() || n.length === 0)
  30551. return y2.create(f2);
  30552. const h = s.indexOf(n, f2 - 1);
  30553. if (h === -1)
  30554. return g2.create(m2.VALUE);
  30555. const d2 = $a(s.substring(0, h)) + 1;
  30556. return y2.create(d2);
  30557. }
  30558. };
  30559. var qE = class extends V {
  30560. constructor() {
  30561. super(...arguments);
  30562. A(this, "minParams", 3);
  30563. A(this, "maxParams", 4);
  30564. }
  30565. calculate(e, t, r, n) {
  30566. const s = Math.max(
  30567. e.isArray() ? e.getRowCount() : 1,
  30568. t.isArray() ? t.getRowCount() : 1,
  30569. r.isArray() ? r.getRowCount() : 1,
  30570. n != null && n.isArray() ? n.getRowCount() : 1
  30571. ), o = Math.max(
  30572. e.isArray() ? e.getColumnCount() : 1,
  30573. t.isArray() ? t.getColumnCount() : 1,
  30574. r.isArray() ? r.getColumnCount() : 1,
  30575. n != null && n.isArray() ? n.getColumnCount() : 1
  30576. ), u = O(s, o, e, g2.create(m2.NA)), c = O(s, o, t, g2.create(m2.NA)), l2 = O(s, o, r, g2.create(m2.NA)), f2 = n ? O(s, o, n, g2.create(m2.NA)) : void 0, h = u.mapValue((d2, _, C) => {
  30577. const E2 = c.get(_, C), b = l2.get(_, C);
  30578. let R = n ? f2.get(_, C) : void 0;
  30579. return d2.isError() ? d2 : E2.isError() ? E2 : b.isError() ? b : R != null && R.isError() ? R : R != null && R.isNull() || R != null && R.isBoolean() ? g2.create(m2.VALUE) : (R != null && R.isString() && (R = R.convertToNumberObjectValue()), R != null && R.isError() ? R : this._handleSingleObject(d2, E2, b, R));
  30580. });
  30581. return s === 1 && o === 1 ? h.get(0, 0) : h;
  30582. }
  30583. _handleSingleObject(e, t, r, n) {
  30584. const s = this._getObjectString(e), o = this._getObjectString(t), u = this._getObjectString(r), c = n ? Math.floor(+n.getValue()) : void 0;
  30585. if (n && c <= 0)
  30586. return g2.create(m2.VALUE);
  30587. if (o === "")
  30588. return j.create(s);
  30589. let l2 = "", f2 = 0;
  30590. for (let h = 0; h < s.length; h++) {
  30591. const d2 = s.substr(h, o.length);
  30592. if (d2 === o || d2.length === o.length && d2.trim() === o.trim()) {
  30593. if (f2++, f2 === c) {
  30594. l2 = s.substr(0, h) + u + s.substr(h + o.length);
  30595. break;
  30596. }
  30597. c === void 0 && (l2 += u), h += o.length - 1;
  30598. } else
  30599. c === void 0 && (l2 += s[h]);
  30600. }
  30601. return c && f2 < c && (l2 = s), j.create(l2);
  30602. }
  30603. _getObjectString(e) {
  30604. let t = `${e.getValue()}`;
  30605. return e.isNull() && (t = ""), e.isBoolean() && (t = t.toLocaleUpperCase()), t;
  30606. }
  30607. };
  30608. var KE = class extends V {
  30609. constructor() {
  30610. super(...arguments);
  30611. A(this, "minParams", 1);
  30612. A(this, "maxParams", 1);
  30613. }
  30614. calculate(e) {
  30615. let t = e;
  30616. return e.isArray() && (t = e.get(0, 0)), t.isError() ? t : t.isNull() || t.isBoolean() || t.isNumber() ? j.create("") : t;
  30617. }
  30618. };
  30619. var XE = class extends V {
  30620. constructor() {
  30621. super(...arguments);
  30622. A(this, "minParams", 2);
  30623. A(this, "maxParams", 2);
  30624. }
  30625. calculate(e, t) {
  30626. if (e.isError())
  30627. return e;
  30628. if (t.isError())
  30629. return t;
  30630. const r = Math.max(
  30631. e.isArray() ? e.getRowCount() : 1,
  30632. t.isArray() ? t.getRowCount() : 1
  30633. ), n = Math.max(
  30634. e.isArray() ? e.getColumnCount() : 1,
  30635. t.isArray() ? t.getColumnCount() : 1
  30636. ), s = O(r, n, e), o = O(r, n, t);
  30637. return s.map((u, c, l2) => {
  30638. if (u.isError())
  30639. return u;
  30640. let f2 = o.get(c, l2) || j.create(" ");
  30641. if (f2.isError())
  30642. return f2;
  30643. if (f2.isBoolean())
  30644. return g2.create(m2.VALUE);
  30645. if (u.isBoolean())
  30646. return u;
  30647. let h = u.getValue();
  30648. if (u.isNull() && (h = 0), u.isString()) {
  30649. if (!DC(h))
  30650. return u;
  30651. h = Number(h);
  30652. }
  30653. f2.isNull() && (f2 = j.create(" "));
  30654. const d2 = `${f2.getValue()}`, _ = ka(d2, h);
  30655. return j.create(d2 === " " ? _.trimEnd() : _);
  30656. });
  30657. }
  30658. };
  30659. var ZE = class extends V {
  30660. constructor() {
  30661. super(...arguments);
  30662. A(this, "minParams", 2);
  30663. A(this, "maxParams", 6);
  30664. }
  30665. calculate(e, t, r, n, s, o) {
  30666. let u = false, c = r != null ? r : y2.create(1);
  30667. c.isNull() && (u = true, c = y2.create(1));
  30668. const l2 = !n, f2 = n != null ? n : y2.create(0), h = s != null ? s : y2.create(0), d2 = o != null ? o : g2.create(m2.NA), _ = Math.max(
  30669. e.isArray() ? e.getRowCount() : 1,
  30670. c.isArray() ? c.getRowCount() : 1,
  30671. f2.isArray() ? f2.getRowCount() : 1,
  30672. h.isArray() ? h.getRowCount() : 1,
  30673. d2.isArray() ? d2.getRowCount() : 1
  30674. ), C = Math.max(
  30675. e.isArray() ? e.getColumnCount() : 1,
  30676. c.isArray() ? c.getColumnCount() : 1,
  30677. f2.isArray() ? f2.getColumnCount() : 1,
  30678. h.isArray() ? h.getColumnCount() : 1,
  30679. d2.isArray() ? d2.getColumnCount() : 1
  30680. ), E2 = O(_, C, e, g2.create(m2.NA)), b = O(_, C, c, g2.create(m2.NA)), R = O(_, C, f2, g2.create(m2.NA)), p2 = O(_, C, h, g2.create(m2.NA)), N2 = O(_, C, d2, g2.create(m2.NA)), M2 = this._getResultArray(E2, t, b, R, p2, N2, u, l2);
  30681. return _ === 1 && C === 1 ? M2.get(0, 0) : M2;
  30682. }
  30683. _getResultArray(e, t, r, n, s, o, u, c) {
  30684. return e.map((f2, h, d2) => {
  30685. const _ = r.get(h, d2), C = n.get(h, d2), E2 = s.get(h, d2), b = o.get(h, d2), R = this._checkVariantsError(f2, _, C, E2);
  30686. if (R.isError())
  30687. return R;
  30688. const p2 = this._getStringValue(f2), N2 = this._getDelimiterValue(t);
  30689. if (N2 instanceof g2)
  30690. return N2;
  30691. const M2 = this._getVariantsNumberFloorValue(_, C, E2);
  30692. if (M2 instanceof g2)
  30693. return M2;
  30694. const [w, D2, S2] = M2;
  30695. return w === 0 || D2 < 0 || D2 > 1 || S2 < 0 || S2 > 1 ? g2.create(m2.VALUE) : N2.includes("") ? w > 0 ? j.create(p2) : j.create("") : !u && Math.abs(w) > p2.length ? g2.create(m2.VALUE) : N2.every((P) => P.length > p2.length) ? g2.create(m2.NA) : this._getResult(p2, N2, w, D2, S2, b, c);
  30696. });
  30697. }
  30698. _checkVariantsError(...e) {
  30699. for (let t = 0; t < e.length; t++) {
  30700. const r = e[t];
  30701. if (r.isError())
  30702. return r;
  30703. }
  30704. return T2.create(true);
  30705. }
  30706. _getStringValue(e) {
  30707. let t = `${e.getValue()}`;
  30708. return e.isNull() && (t = ""), e.isBoolean() && (t = t.toLocaleUpperCase()), t;
  30709. }
  30710. _getDelimiterValue(e) {
  30711. const t = [];
  30712. if (e.isArray()) {
  30713. let r = false, n = g2.create(m2.VALUE);
  30714. if (e.iterator((s) => {
  30715. const o = s;
  30716. if (o.isError())
  30717. return r = true, n = o, false;
  30718. t.push(this._getStringValue(o));
  30719. }), r)
  30720. return n;
  30721. } else {
  30722. if (e.isError())
  30723. return e;
  30724. t.push(this._getStringValue(e));
  30725. }
  30726. return t;
  30727. }
  30728. _getVariantsNumberFloorValue(...e) {
  30729. const t = [];
  30730. for (let r = 0; r < e.length; r++) {
  30731. let n = e[r];
  30732. if (n.isString() && (n = n.convertToNumberObjectValue()), n.isError())
  30733. return n;
  30734. const s = Math.floor(+n.getValue());
  30735. t.push(s);
  30736. }
  30737. return t;
  30738. }
  30739. _getResult(e, t, r, n, s, o, u) {
  30740. let c = n ? e.toLocaleLowerCase() : e;
  30741. const l2 = n ? t.map((C) => C.toLocaleLowerCase()) : t;
  30742. let f2 = 0, h = 0, d2 = 0;
  30743. for (let C = 0; C < Math.abs(r); C++)
  30744. if (r < 0) {
  30745. const E2 = l2.map((b) => ({
  30746. index: c.lastIndexOf(b),
  30747. length: b.length
  30748. })).filter((b) => b.index !== -1).sort((b, R) => R.index - b.index)[0];
  30749. if (!E2)
  30750. break;
  30751. f2 = E2.index, c = c.substr(0, E2.index), d2 = E2.length, h++;
  30752. } else {
  30753. const E2 = l2.map((b) => ({
  30754. index: c.indexOf(b),
  30755. length: b.length
  30756. })).filter((b) => b.index !== -1).sort((b, R) => b.index - R.index)[0];
  30757. if (!E2)
  30758. break;
  30759. f2 += E2.index + d2, c = c.substr(E2.index + E2.length), d2 = E2.length, h++;
  30760. }
  30761. if (h && h < Math.abs(r) && u)
  30762. return g2.create(m2.NA);
  30763. if (!h || h < Math.abs(r))
  30764. return s ? r > 0 ? j.create("") : j.create(e) : o;
  30765. const _ = e.substr(f2 + d2);
  30766. return j.create(_);
  30767. }
  30768. };
  30769. var zE = class extends V {
  30770. constructor() {
  30771. super(...arguments);
  30772. A(this, "minParams", 2);
  30773. A(this, "maxParams", 6);
  30774. }
  30775. calculate(e, t, r, n, s, o) {
  30776. let u = false, c = r != null ? r : y2.create(1);
  30777. c.isNull() && (u = true, c = y2.create(1));
  30778. const l2 = !n, f2 = n != null ? n : y2.create(0), h = s != null ? s : y2.create(0), d2 = o != null ? o : g2.create(m2.NA), _ = Math.max(
  30779. e.isArray() ? e.getRowCount() : 1,
  30780. c.isArray() ? c.getRowCount() : 1,
  30781. f2.isArray() ? f2.getRowCount() : 1,
  30782. h.isArray() ? h.getRowCount() : 1,
  30783. d2.isArray() ? d2.getRowCount() : 1
  30784. ), C = Math.max(
  30785. e.isArray() ? e.getColumnCount() : 1,
  30786. c.isArray() ? c.getColumnCount() : 1,
  30787. f2.isArray() ? f2.getColumnCount() : 1,
  30788. h.isArray() ? h.getColumnCount() : 1,
  30789. d2.isArray() ? d2.getColumnCount() : 1
  30790. ), E2 = O(_, C, e, g2.create(m2.NA)), b = O(_, C, c, g2.create(m2.NA)), R = O(_, C, f2, g2.create(m2.NA)), p2 = O(_, C, h, g2.create(m2.NA)), N2 = O(_, C, d2, g2.create(m2.NA)), M2 = this._getResultArray(E2, t, b, R, p2, N2, u, l2);
  30791. return _ === 1 && C === 1 ? M2.get(0, 0) : M2;
  30792. }
  30793. _getResultArray(e, t, r, n, s, o, u, c) {
  30794. return e.map((f2, h, d2) => {
  30795. const _ = r.get(h, d2), C = n.get(h, d2), E2 = s.get(h, d2), b = o.get(h, d2), R = this._checkVariantsError(f2, _, C, E2);
  30796. if (R.isError())
  30797. return R;
  30798. const p2 = this._getStringValue(f2), N2 = this._getDelimiterValue(t);
  30799. if (N2 instanceof g2)
  30800. return N2;
  30801. const M2 = this._getVariantsNumberFloorValue(_, C, E2);
  30802. if (M2 instanceof g2)
  30803. return M2;
  30804. const [w, D2, S2] = M2;
  30805. return w === 0 || D2 < 0 || D2 > 1 || S2 < 0 || S2 > 1 ? g2.create(m2.VALUE) : N2.includes("") ? w > 0 ? j.create("") : j.create(p2) : !u && Math.abs(w) > p2.length ? g2.create(m2.VALUE) : N2.every((P) => P.length > p2.length) ? g2.create(m2.NA) : this._getResult(p2, N2, w, D2, S2, b, c);
  30806. });
  30807. }
  30808. _checkVariantsError(...e) {
  30809. for (let t = 0; t < e.length; t++) {
  30810. const r = e[t];
  30811. if (r.isError())
  30812. return r;
  30813. }
  30814. return T2.create(true);
  30815. }
  30816. _getStringValue(e) {
  30817. let t = `${e.getValue()}`;
  30818. return e.isNull() && (t = ""), e.isBoolean() && (t = t.toLocaleUpperCase()), t;
  30819. }
  30820. _getDelimiterValue(e) {
  30821. const t = [];
  30822. if (e.isArray()) {
  30823. let r = false, n = g2.create(m2.VALUE);
  30824. if (e.iterator((s) => {
  30825. const o = s;
  30826. if (o.isError())
  30827. return r = true, n = o, false;
  30828. t.push(this._getStringValue(o));
  30829. }), r)
  30830. return n;
  30831. } else {
  30832. if (e.isError())
  30833. return e;
  30834. t.push(this._getStringValue(e));
  30835. }
  30836. return t;
  30837. }
  30838. _getVariantsNumberFloorValue(...e) {
  30839. const t = [];
  30840. for (let r = 0; r < e.length; r++) {
  30841. let n = e[r];
  30842. if (n.isString() && (n = n.convertToNumberObjectValue()), n.isError())
  30843. return n;
  30844. const s = Math.floor(+n.getValue());
  30845. t.push(s);
  30846. }
  30847. return t;
  30848. }
  30849. _getResult(e, t, r, n, s, o, u) {
  30850. let c = n ? e.toLocaleLowerCase() : e;
  30851. const l2 = n ? t.map((C) => C.toLocaleLowerCase()) : t;
  30852. let f2 = 0, h = 0, d2 = 0;
  30853. for (let C = 0; C < Math.abs(r); C++)
  30854. if (r < 0) {
  30855. const E2 = l2.map((b) => ({
  30856. index: c.lastIndexOf(b),
  30857. length: b.length
  30858. })).filter((b) => b.index !== -1).sort((b, R) => R.index - b.index)[0];
  30859. if (!E2)
  30860. break;
  30861. f2 = E2.index, c = c.substr(0, E2.index), h++;
  30862. } else {
  30863. const E2 = l2.map((b) => ({
  30864. index: c.indexOf(b),
  30865. length: b.length
  30866. })).filter((b) => b.index !== -1).sort((b, R) => b.index - R.index)[0];
  30867. if (!E2)
  30868. break;
  30869. f2 += E2.index + d2, c = c.substr(E2.index + E2.length), d2 = E2.length, h++;
  30870. }
  30871. if (h && h < Math.abs(r) && u)
  30872. return g2.create(m2.NA);
  30873. if (!h || h < Math.abs(r))
  30874. return s ? r > 0 ? j.create(e) : j.create("") : o;
  30875. const _ = e.substr(0, f2);
  30876. return j.create(_);
  30877. }
  30878. };
  30879. var JE = class extends V {
  30880. constructor() {
  30881. super(...arguments);
  30882. A(this, "minParams", 3);
  30883. A(this, "maxParams", 255);
  30884. }
  30885. calculate(e, t, ...r) {
  30886. const n = this._getDelimiterValues(e), s = this._getTextValues(r);
  30887. if (t.isArray()) {
  30888. const u = t.mapValue((c) => this._handleSingleObject(n, c, s));
  30889. return u.getRowCount() === 1 && u.getColumnCount() === 1 ? u.get(0, 0) : u;
  30890. }
  30891. const o = t;
  30892. if (o.isString()) {
  30893. const u = `${o.getValue()}`.toLocaleUpperCase();
  30894. if (u === "TRUE")
  30895. return this._handleSingleObject(n, T2.create(true), s);
  30896. if (u === "FALSE")
  30897. return this._handleSingleObject(n, T2.create(false), s);
  30898. }
  30899. return this._handleSingleObject(n, t, s);
  30900. }
  30901. _handleSingleObject(e, t, r) {
  30902. if (e instanceof g2)
  30903. return e;
  30904. const { isError: n, errorObject: s, variants: o } = I2(t);
  30905. if (n)
  30906. return s;
  30907. if (r instanceof g2)
  30908. return r;
  30909. const [u] = o, c = +u.getValue();
  30910. let l2 = r;
  30911. c && (l2 = r.filter((h) => h !== null));
  30912. let f2 = "";
  30913. for (let h = 0; h < l2.length; h++)
  30914. l2[h] !== null && (f2 += l2[h]), h < l2.length - 1 && (f2 += e[h % e.length]);
  30915. return j.create(f2);
  30916. }
  30917. _getDelimiterValues(e) {
  30918. const t = [], r = e.isArray() ? e.getRowCount() : 1, n = e.isArray() ? e.getColumnCount() : 1;
  30919. for (let s = 0; s < r; s++)
  30920. for (let o = 0; o < n; o++) {
  30921. const u = e.isArray() ? e.get(s, o) : e;
  30922. if (u.isError())
  30923. return u;
  30924. let c = `${u.getValue()}`;
  30925. u.isNull() && (c = ""), u.isBoolean() && (c = c.toLocaleUpperCase()), t.push(c);
  30926. }
  30927. return t;
  30928. }
  30929. _getTextValues(e) {
  30930. const t = [];
  30931. for (const r of e) {
  30932. const n = r.isArray() ? r.getRowCount() : 1, s = r.isArray() ? r.getColumnCount() : 1;
  30933. for (let o = 0; o < n; o++)
  30934. for (let u = 0; u < s; u++) {
  30935. const c = r.isArray() ? r.get(o, u) : r;
  30936. if (c.isError())
  30937. return c;
  30938. if (c.isNull()) {
  30939. t.push(null);
  30940. continue;
  30941. }
  30942. let l2 = `${c.getValue()}`;
  30943. c.isBoolean() && (l2 = l2.toLocaleUpperCase()), t.push(l2);
  30944. }
  30945. }
  30946. return t;
  30947. }
  30948. };
  30949. var eb = class extends V {
  30950. constructor() {
  30951. super(...arguments);
  30952. A(this, "minParams", 2);
  30953. A(this, "maxParams", 6);
  30954. }
  30955. calculate(e, t, r, n, s, o) {
  30956. let u = r != null ? r : j.create("\\s");
  30957. const c = n != null ? n : y2.create(0), l2 = s != null ? s : y2.create(0), f2 = o != null ? o : j.create(m2.NA), { _variant: h, values: d2 } = this._getStringValues(t), { _variant: _, values: C } = this._getStringValues(u, false);
  30958. u = _;
  30959. const E2 = Math.max(
  30960. e.isArray() ? e.getRowCount() : 1,
  30961. c.isArray() ? c.getRowCount() : 1,
  30962. l2.isArray() ? l2.getRowCount() : 1
  30963. ), b = Math.max(
  30964. e.isArray() ? e.getColumnCount() : 1,
  30965. c.isArray() ? c.getColumnCount() : 1,
  30966. l2.isArray() ? l2.getColumnCount() : 1
  30967. ), R = O(E2, b, e, g2.create(m2.NA)), p2 = O(E2, b, c, g2.create(m2.NA)), N2 = O(E2, b, l2, g2.create(m2.NA)), M2 = this._getResultArray(
  30968. R,
  30969. h,
  30970. u,
  30971. p2,
  30972. N2,
  30973. f2,
  30974. d2,
  30975. C
  30976. );
  30977. return E2 === 1 && b === 1 ? M2.get(0, 0) : M2.map((w) => w.get(0, 0));
  30978. }
  30979. _getStringValues(e, t = true) {
  30980. let r = e;
  30981. const n = [];
  30982. if (r.isArray())
  30983. r.iterator((s) => {
  30984. if (s != null && s.isError())
  30985. return r = s, false;
  30986. if (s != null && s.isNull() && t)
  30987. return r = g2.create(m2.VALUE), false;
  30988. const o = this._getRegExpStringValue(s);
  30989. if (o === "")
  30990. return r = g2.create(m2.VALUE), false;
  30991. n.push(o);
  30992. });
  30993. else {
  30994. r.isNull() && t && (r = g2.create(m2.VALUE));
  30995. const s = this._getRegExpStringValue(r);
  30996. s === "" && (r = g2.create(m2.VALUE)), n.push(s);
  30997. }
  30998. return {
  30999. _variant: r,
  31000. values: n
  31001. };
  31002. }
  31003. _getResultArray(e, t, r, n, s, o, u, c) {
  31004. return e.map((f2, h, d2) => {
  31005. let _ = n.get(h, d2), C = s.get(h, d2);
  31006. const E2 = this._checkVariantsError(f2, t, r, _, C);
  31007. if (E2.isError())
  31008. return E2;
  31009. if (f2.isNull())
  31010. return g2.create(m2.VALUE);
  31011. let b = o;
  31012. if (b.isArray()) {
  31013. const w = b.getRowCount(), D2 = b.getColumnCount();
  31014. if (w > 1 || D2 > 1)
  31015. return g2.create(m2.VALUE);
  31016. b = b.get(0, 0);
  31017. }
  31018. let R = `${f2.getValue()}`;
  31019. if (f2.isBoolean() && (R = R.toLocaleUpperCase()), _.isString() && (_ = _.convertToNumberObjectValue(), _.isError()))
  31020. return _;
  31021. const p2 = Math.floor(+_.getValue());
  31022. if (C.isString() && (C = C.convertToNumberObjectValue(), C.isError()))
  31023. return C;
  31024. const N2 = Math.floor(+C.getValue());
  31025. if (N2 < 0 || N2 > 1)
  31026. return g2.create(m2.VALUE);
  31027. let M2 = `${b.getValue()}`;
  31028. return b.isBoolean() && (M2 = M2.toLocaleUpperCase()), this._getResult(R, u, c, p2, N2, M2);
  31029. });
  31030. }
  31031. _getResult(e, t, r, n, s, o) {
  31032. const u = new RegExp(r.join("|"), `g${s ? "i" : ""}`), c = new RegExp(t.join("|"), `g${s ? "i" : ""}`), l2 = e.split(u);
  31033. let f2 = 1, h = l2.map((d2) => {
  31034. let _ = d2.split(c);
  31035. return n && (_ = _.filter((C) => C !== "")), f2 = Math.max(f2, _.length), _;
  31036. });
  31037. return h = h.map((d2) => {
  31038. let _ = d2;
  31039. return _.length < f2 && (_ = _.concat(new Array(f2 - _.length).fill(o))), _;
  31040. }), q2.createByArray(h);
  31041. }
  31042. _checkVariantsError(...e) {
  31043. for (let t = 0; t < e.length; t++) {
  31044. const r = e[t];
  31045. if (r.isError())
  31046. return r;
  31047. }
  31048. return T2.create(true);
  31049. }
  31050. _getRegExpStringValue(e) {
  31051. let t = e.getValue();
  31052. return e.isNull() && (t = "\\s"), e.isBoolean() && (t = t ? "TRUE" : "FALSE"), t += "", this._escapeRegExp(t);
  31053. }
  31054. _escapeRegExp(e) {
  31055. return e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
  31056. }
  31057. };
  31058. var tb = class extends V {
  31059. constructor() {
  31060. super(...arguments);
  31061. A(this, "minParams", 1);
  31062. A(this, "maxParams", 1);
  31063. }
  31064. calculate(e) {
  31065. if (e.isArray()) {
  31066. const t = e.mapValue((r) => this._handleSingleObject(r));
  31067. return t.getRowCount() === 1 && t.getColumnCount() === 1 ? t.get(0, 0) : t;
  31068. }
  31069. return this._handleSingleObject(e);
  31070. }
  31071. _handleSingleObject(e) {
  31072. if (e.isError())
  31073. return e;
  31074. if (e.isNull())
  31075. return j.create("");
  31076. let t = `${e.getValue()}`;
  31077. return e.isBoolean() && (t = t.toLocaleUpperCase()), t = t.trim().replace(/\s+/g, " "), j.create(t);
  31078. }
  31079. };
  31080. var rb = Object.values(ln).filter((i) => [
  31081. ln.TABLE_START,
  31082. ln.TABLE_ROW_START,
  31083. ln.TABLE_CELL_START,
  31084. ln.TABLE_CELL_END,
  31085. ln.TABLE_ROW_END,
  31086. ln.TABLE_END,
  31087. ln.CUSTOM_BLOCK
  31088. ].includes(i));
  31089. var nb = class extends V {
  31090. constructor() {
  31091. super(...arguments);
  31092. A(this, "minParams", 1);
  31093. A(this, "maxParams", 1);
  31094. }
  31095. calculate(e) {
  31096. if (e.isArray()) {
  31097. const t = e.mapValue((r) => this._handleSingleObject(r));
  31098. return t.getRowCount() === 1 && t.getColumnCount() === 1 ? t.get(0, 0) : t;
  31099. }
  31100. return this._handleSingleObject(e);
  31101. }
  31102. _handleSingleObject(e) {
  31103. const { isError: t, errorObject: r, variants: n } = I2(e);
  31104. if (t)
  31105. return r;
  31106. const [s] = n, o = Math.floor(+s.getValue());
  31107. if (o < 1 || o > 1114111)
  31108. return g2.create(m2.VALUE);
  31109. if (o === 1114111 || o === 1114110)
  31110. return g2.create(m2.NA);
  31111. let u = String.fromCharCode(o);
  31112. return rb.some((c) => c === u) && (u = ""), j.create(u);
  31113. }
  31114. };
  31115. var sb = class extends V {
  31116. constructor() {
  31117. super(...arguments);
  31118. A(this, "minParams", 1);
  31119. A(this, "maxParams", 1);
  31120. }
  31121. calculate(e) {
  31122. if (e.isArray()) {
  31123. const t = e.mapValue((r) => this._handleSingleObject(r));
  31124. return t.getRowCount() === 1 && t.getColumnCount() === 1 ? t.get(0, 0) : t;
  31125. }
  31126. return this._handleSingleObject(e);
  31127. }
  31128. _handleSingleObject(e) {
  31129. if (e.isError())
  31130. return e;
  31131. if (e.isNull())
  31132. return g2.create(m2.VALUE);
  31133. let t = e.getValue().toLocaleString();
  31134. e.isBoolean() && (t = t.toLocaleUpperCase());
  31135. const r = t.charCodeAt(0);
  31136. return y2.create(r);
  31137. }
  31138. };
  31139. var ab = class extends V {
  31140. constructor() {
  31141. super(...arguments);
  31142. A(this, "minParams", 1);
  31143. A(this, "maxParams", 1);
  31144. }
  31145. calculate(e) {
  31146. if (e.isArray()) {
  31147. const t = e.mapValue((r) => this._handleSingleObject(r));
  31148. return t.getRowCount() === 1 && t.getColumnCount() === 1 ? t.get(0, 0) : t;
  31149. }
  31150. return this._handleSingleObject(e);
  31151. }
  31152. _handleSingleObject(e) {
  31153. if (e.isError())
  31154. return e;
  31155. if (e.isNull())
  31156. return j.create("");
  31157. const t = `${e.getValue()}`.toLocaleUpperCase();
  31158. return j.create(t);
  31159. }
  31160. };
  31161. var ib = class extends V {
  31162. constructor() {
  31163. super(...arguments);
  31164. A(this, "minParams", 1);
  31165. A(this, "maxParams", 1);
  31166. }
  31167. calculate(e) {
  31168. if (e.isArray()) {
  31169. const t = e.mapValue((r) => this._handleSingleObject(r));
  31170. return t.getRowCount() === 1 && t.getColumnCount() === 1 ? t.get(0, 0) : t;
  31171. }
  31172. return this._handleSingleObject(e);
  31173. }
  31174. _handleSingleObject(e) {
  31175. if (e.isError())
  31176. return e;
  31177. if (e.isBoolean())
  31178. return g2.create(m2.VALUE);
  31179. let t = e;
  31180. if (e.isString() && (t = t.convertToNumberObjectValue(), t.isError()))
  31181. return t;
  31182. const r = +t.getValue();
  31183. return y2.create(r);
  31184. }
  31185. };
  31186. var ob = class extends V {
  31187. constructor() {
  31188. super(...arguments);
  31189. A(this, "minParams", 1);
  31190. A(this, "maxParams", 2);
  31191. }
  31192. calculate(e, t) {
  31193. const r = t != null ? t : y2.create(0), n = Math.max(
  31194. e.isArray() ? e.getRowCount() : 1,
  31195. r.isArray() ? r.getRowCount() : 1
  31196. ), s = Math.max(
  31197. e.isArray() ? e.getColumnCount() : 1,
  31198. r.isArray() ? r.getColumnCount() : 1
  31199. ), o = O(n, s, e, g2.create(m2.NA)), u = O(n, s, r, g2.create(m2.NA)), c = o.mapValue((l2, f2, h) => {
  31200. const d2 = u.get(f2, h);
  31201. return l2.isError() ? l2 : d2.isError() ? d2 : this._handleSingleObject(l2, d2);
  31202. });
  31203. return n === 1 && s === 1 ? c.get(0, 0) : c;
  31204. }
  31205. _handleSingleObject(e, t) {
  31206. const { isError: r, errorObject: n, variants: s } = I2(t);
  31207. if (r)
  31208. return n;
  31209. const [o] = s, u = Math.floor(+o.getValue());
  31210. if (u < 0 || u > 1)
  31211. return g2.create(m2.VALUE);
  31212. if (e.isNull())
  31213. return j.create("");
  31214. if (e.isBoolean())
  31215. return e;
  31216. if (e.isNumber())
  31217. return y2.create(e.getValue());
  31218. const c = u ? `"${e.getValue()}"` : `${e.getValue()}`;
  31219. return j.create(c);
  31220. }
  31221. };
  31222. var ub = [
  31223. [oE, se.ASC],
  31224. [iE, se.ARRAYTOTEXT],
  31225. [uE, se.BAHTTEXT],
  31226. [lE, se.CHAR],
  31227. [fE, se.CLEAN],
  31228. [hE, se.CODE],
  31229. [mE, se.CONCAT],
  31230. [gE, se.CONCATENATE],
  31231. [dE, se.DBCS],
  31232. [CE, se.DOLLAR],
  31233. [_E, se.EXACT],
  31234. [AE, se.FIND],
  31235. [bE, se.FINDB],
  31236. [yE, se.FIXED],
  31237. [RE, se.LEFT],
  31238. [pE, se.LEFTB],
  31239. [VE, se.LEN],
  31240. [NE, se.LENB],
  31241. [OE, se.LOWER],
  31242. [ME, se.MID],
  31243. [wE, se.MIDB],
  31244. [DE, se.NUMBERVALUE],
  31245. [BE, se.REGEXEXTRACT],
  31246. [IE, se.REGEXMATCH],
  31247. [FE, se.REGEXREPLACE],
  31248. [SE2, se.PROPER],
  31249. [kE, se.REPLACE],
  31250. [$E, se.REPLACEB],
  31251. [YE, se.REPT],
  31252. [HE, se.RIGHT],
  31253. [GE, se.RIGHTB],
  31254. [QE, se.SEARCH],
  31255. [WE, se.SEARCHB],
  31256. [qE, se.SUBSTITUTE],
  31257. [KE, se.T],
  31258. [XE, se.TEXT],
  31259. [ZE, se.TEXTAFTER],
  31260. [zE, se.TEXTBEFORE],
  31261. [JE, se.TEXTJOIN],
  31262. [eb, se.TEXTSPLIT],
  31263. [tb, se.TRIM],
  31264. [nb, se.UNICHAR],
  31265. [sb, se.UNICODE],
  31266. [ab, se.UPPER],
  31267. [ib, se.VALUE],
  31268. [ob, se.VALUETOTEXT]
  31269. ];
  31270. var cb = [];
  31271. var lb = ((i) => i)(lb || {});
  31272. var fb = class extends V {
  31273. constructor() {
  31274. super(...arguments);
  31275. A(this, "minParams", 1);
  31276. A(this, "maxParams", 1);
  31277. }
  31278. calculate(e) {
  31279. if (e.isArray()) {
  31280. const t = e.mapValue((r) => this._handleSingleObject(r));
  31281. return t.getRowCount() === 1 && t.getColumnCount() === 1 ? t.get(0, 0) : t;
  31282. }
  31283. return this._handleSingleObject(e);
  31284. }
  31285. _handleSingleObject(e) {
  31286. if (e.isError())
  31287. return e;
  31288. const t = De2(e), r = encodeURIComponent(t).replace(/[!~'()*]/g, (n) => `%${n.charCodeAt(0).toString(16).toLocaleUpperCase()}`);
  31289. return j.create(r);
  31290. }
  31291. };
  31292. var ju = ((i) => (i.ENCODEURL = "ENCODEURL", i.FILTERXML = "FILTERXML", i.WEBSERVICE = "WEBSERVICE", i))(ju || {});
  31293. var hb = [
  31294. [fb, ju.ENCODEURL]
  31295. ];
  31296. var mb = Object.defineProperty;
  31297. var gb = Object.getOwnPropertyDescriptor;
  31298. var db = (i, a2, e, t) => {
  31299. for (var r = t > 1 ? void 0 : t ? gb(a2, e) : a2, n = i.length - 1, s; n >= 0; n--)
  31300. (s = i[n]) && (r = (t ? s(a2, e, r) : s(r)) || r);
  31301. return t && r && mb(a2, e, r), r;
  31302. };
  31303. var Zr = (i, a2) => (e, t) => a2(e, t, i);
  31304. var wn = class extends nt {
  31305. constructor(i, a2, e, t) {
  31306. super(), this._commandService = i, this._functionService = a2, this._configService = e, this._dataSyncPrimaryController = t, this._initialize();
  31307. }
  31308. _initialize() {
  31309. this._registerCommands(), this._registerFunctions();
  31310. }
  31311. _registerCommands() {
  31312. [
  31313. eo,
  31314. bs,
  31315. Zi,
  31316. zi,
  31317. Ns,
  31318. Ji,
  31319. sa,
  31320. Xi,
  31321. aa,
  31322. ia,
  31323. oa,
  31324. ua,
  31325. jc,
  31326. Uc,
  31327. to,
  31328. bc
  31329. ].forEach((i) => {
  31330. var a2;
  31331. this._commandService.registerCommand(i), (a2 = this._dataSyncPrimaryController) == null || a2.registerSyncingMutations(i);
  31332. });
  31333. }
  31334. _registerFunctions() {
  31335. var e;
  31336. const i = this._configService.getConfig(fa), a2 = [
  31337. ...Yh,
  31338. ...pm,
  31339. ...Vm,
  31340. ...Im,
  31341. ...Rg,
  31342. ...O1,
  31343. ...P0,
  31344. ...td,
  31345. ...yd,
  31346. ...rC,
  31347. ...D_,
  31348. ...v_,
  31349. ...aE,
  31350. ...ub,
  31351. ...cb,
  31352. ...hb
  31353. ].concat((e = i == null ? void 0 : i.function) != null ? e : []).map((t) => {
  31354. const r = t[0], n = t[1];
  31355. return new r(n);
  31356. });
  31357. this._functionService.registerExecutors(...a2);
  31358. }
  31359. };
  31360. wn = db([
  31361. Zr(0, Pt),
  31362. Zr(1, Yt),
  31363. Zr(2, SE),
  31364. Zr(3, nf(g))
  31365. ], wn);
  31366. var Cb = Object.defineProperty;
  31367. var _b = Object.getOwnPropertyDescriptor;
  31368. var Ab = (i, a2, e, t) => {
  31369. for (var r = t > 1 ? void 0 : t ? _b(a2, e) : a2, n = i.length - 1, s; n >= 0; n--)
  31370. (s = i[n]) && (r = (t ? s(a2, e, r) : s(r)) || r);
  31371. return t && r && Cb(a2, e, r), r;
  31372. };
  31373. var zr = (i, a2) => (e, t) => a2(e, t, i);
  31374. var Dn = class extends nt {
  31375. constructor(i, a2, e) {
  31376. super(), this._commandService = i, this._dependencyManagerService = a2, this._featureCalculationManagerService = e, this._initialize();
  31377. }
  31378. _initialize() {
  31379. this._commandExecutedListener(), this._featureCalculationManagerServiceListener();
  31380. }
  31381. _featureCalculationManagerServiceListener() {
  31382. this.disposeWithMe(
  31383. this._featureCalculationManagerService.onChanged$.subscribe((i) => {
  31384. const { unitId: a2, subUnitId: e, featureIds: t } = i;
  31385. this._dependencyManagerService.removeFeatureFormulaDependency(a2, e, t);
  31386. })
  31387. );
  31388. }
  31389. _commandExecutedListener() {
  31390. this.disposeWithMe(
  31391. this._commandService.onCommandExecuted((i) => {
  31392. if (i.id === ia.id) {
  31393. const a2 = i.params;
  31394. if (a2 == null)
  31395. return;
  31396. const { featureIds: e, unitId: t, subUnitId: r } = a2;
  31397. this._dependencyManagerService.removeFeatureFormulaDependency(t, r, e);
  31398. } else if (i.id === aa.id) {
  31399. const a2 = i.params;
  31400. if (a2 == null)
  31401. return;
  31402. const { featureId: e, calculationParam: t } = a2, { unitId: r, subUnitId: n } = t;
  31403. this._dependencyManagerService.removeFeatureFormulaDependency(r, n, [e]);
  31404. } else if (i.id === ua.id) {
  31405. const a2 = i.params;
  31406. if (a2 == null)
  31407. return;
  31408. this._dependencyManagerService.removeOtherFormulaDependency(a2.unitId, a2.subUnitId, a2.formulaIdList);
  31409. } else if (i.id === oa.id) {
  31410. const a2 = i.params;
  31411. if (a2 == null)
  31412. return;
  31413. const e = a2.formulaMap, t = [];
  31414. Object.keys(e).forEach((r) => {
  31415. t.push(r);
  31416. }), this._dependencyManagerService.removeOtherFormulaDependency(a2.unitId, a2.subUnitId, t);
  31417. } else if (i.id === eo.id) {
  31418. const a2 = i.params.formulaData;
  31419. Object.keys(a2).forEach((e) => {
  31420. const t = a2[e];
  31421. if (t !== void 0) {
  31422. if (t === null) {
  31423. this._dependencyManagerService.clearFormulaDependency(e);
  31424. return;
  31425. }
  31426. Object.keys(t).forEach((r) => {
  31427. const n = t[r];
  31428. if (n !== void 0) {
  31429. if (n === null)
  31430. return this._dependencyManagerService.clearFormulaDependency(e, r), true;
  31431. new kt(n).forValue((s, o) => {
  31432. this._dependencyManagerService.removeFormulaDependency(e, r, s, o);
  31433. });
  31434. }
  31435. });
  31436. }
  31437. });
  31438. } else
  31439. i.id === sa.id && this._handleSetDefinedName(i);
  31440. })
  31441. );
  31442. }
  31443. _handleSetDefinedName(i) {
  31444. const a2 = i.params;
  31445. if (a2 == null)
  31446. return;
  31447. const { unitId: e, name: t } = a2;
  31448. this._dependencyManagerService.removeFormulaDependencyByDefinedName(e, t);
  31449. }
  31450. };
  31451. Dn = Ab([
  31452. zr(0, Pt),
  31453. zr(1, jr),
  31454. zr(1, Hn),
  31455. zr(2, jr)
  31456. ], Dn);
  31457. var Eb = Object.defineProperty;
  31458. var bb = Object.getOwnPropertyDescriptor;
  31459. var yb = (i, a2, e, t) => {
  31460. for (var r = t > 1 ? void 0 : t ? bb(a2, e) : a2, n = i.length - 1, s; n >= 0; n--)
  31461. (s = i[n]) && (r = (t ? s(a2, e, r) : s(r)) || r);
  31462. return t && r && Eb(a2, e, r), r;
  31463. };
  31464. var Ti = (i, a2) => (e, t) => a2(e, t, i);
  31465. var Sn = class extends nt {
  31466. constructor(i, a2) {
  31467. super(), this._commandService = i, this._featureCalculationManagerService = a2, this._initialize();
  31468. }
  31469. _initialize() {
  31470. this._commandExecutedListener();
  31471. }
  31472. _commandExecutedListener() {
  31473. this.disposeWithMe(
  31474. this._commandService.onCommandExecuted((i) => {
  31475. if (i.id === aa.id) {
  31476. const a2 = i.params;
  31477. if (a2 == null)
  31478. return;
  31479. const { featureId: e, calculationParam: t } = a2, { unitId: r, subUnitId: n } = t;
  31480. this._featureCalculationManagerService.register(r, n, e, t);
  31481. } else if (i.id === ia.id) {
  31482. const a2 = i.params;
  31483. if (a2 == null)
  31484. return;
  31485. const { featureIds: e, unitId: t, subUnitId: r } = a2;
  31486. this._featureCalculationManagerService.remove(t, r, e);
  31487. }
  31488. })
  31489. );
  31490. }
  31491. };
  31492. Sn = yb([
  31493. Ti(0, Pt),
  31494. Ti(1, jr)
  31495. ], Sn);
  31496. var Rb = Object.defineProperty;
  31497. var pb = Object.getOwnPropertyDescriptor;
  31498. var Vb = (i, a2, e, t) => {
  31499. for (var r = t > 1 ? void 0 : t ? pb(a2, e) : a2, n = i.length - 1, s; n >= 0; n--)
  31500. (s = i[n]) && (r = (t ? s(a2, e, r) : s(r)) || r);
  31501. return t && r && Rb(a2, e, r), r;
  31502. };
  31503. var Cs = (i, a2) => (e, t) => a2(e, t, i);
  31504. var Pn = class extends nt {
  31505. constructor(i, a2, e) {
  31506. super(), this._commandService = i, this._otherFormulaManagerService = a2, this._dependencyManagerService = e, this._initialize();
  31507. }
  31508. _initialize() {
  31509. this._commandExecutedListener();
  31510. }
  31511. _commandExecutedListener() {
  31512. this.disposeWithMe(
  31513. this._commandService.onCommandExecuted((i) => {
  31514. if (i.id === oa.id) {
  31515. const a2 = i.params;
  31516. if (a2 == null)
  31517. return;
  31518. const e = { [a2.unitId]: { [a2.subUnitId]: a2.formulaMap } };
  31519. this._otherFormulaManagerService.batchRegister(e);
  31520. } else if (i.id === ua.id) {
  31521. const a2 = i.params;
  31522. if (a2 == null)
  31523. return;
  31524. const e = {};
  31525. a2.formulaIdList.forEach((r) => e[r] = true);
  31526. const t = { [a2.unitId]: { [a2.subUnitId]: e } };
  31527. this._otherFormulaManagerService.batchRemove(t);
  31528. }
  31529. })
  31530. );
  31531. }
  31532. };
  31533. Pn = Vb([
  31534. Cs(0, Pt),
  31535. Cs(1, ya),
  31536. Cs(2, Hn)
  31537. ], Pn);
  31538. var Nb = class extends nt {
  31539. constructor() {
  31540. super(...arguments);
  31541. A(this, "_tableMap", /* @__PURE__ */ new Map());
  31542. A(this, "_tableOptionMap", /* @__PURE__ */ new Map());
  31543. }
  31544. dispose() {
  31545. this._tableMap.clear(), this._tableOptionMap.clear();
  31546. }
  31547. remove(e, t) {
  31548. var r;
  31549. (r = this._tableMap.get(e)) == null || r.delete(t);
  31550. }
  31551. getTableMap(e) {
  31552. return this._tableMap.get(e);
  31553. }
  31554. getTableOptionMap() {
  31555. return this._tableOptionMap;
  31556. }
  31557. registerTable(e, t, r) {
  31558. var n;
  31559. this._tableMap.get(e) == null && this._tableMap.set(e, /* @__PURE__ */ new Map()), (n = this._tableMap.get(e)) == null || n.set(t, r);
  31560. }
  31561. registerTableOptionMap(e, t) {
  31562. this._tableOptionMap.set(e, t);
  31563. }
  31564. };
  31565. var Uu = Ct("univer.formula.super-table.service");
  31566. var Ob = Object.defineProperty;
  31567. var Mb = Object.getOwnPropertyDescriptor;
  31568. var wb = (i, a2, e, t) => {
  31569. for (var r = t > 1 ? void 0 : t ? Mb(a2, e) : a2, n = i.length - 1, s; n >= 0; n--)
  31570. (s = i[n]) && (r = (t ? s(a2, e, r) : s(r)) || r);
  31571. return t && r && Ob(a2, e, r), r;
  31572. };
  31573. var Bi = (i, a2) => (e, t) => a2(e, t, i);
  31574. var Ln = class extends nt {
  31575. constructor(i, a2) {
  31576. super(), this._commandService = i, this._superTableService = a2, this._initialize();
  31577. }
  31578. _initialize() {
  31579. this._commandExecutedListener();
  31580. }
  31581. _commandExecutedListener() {
  31582. this.disposeWithMe(
  31583. this._commandService.onCommandExecuted((i) => {
  31584. if (i.id === sa.id) {
  31585. const a2 = i.params;
  31586. if (a2 == null)
  31587. return;
  31588. const { unitId: e, tableName: t, reference: r } = a2;
  31589. this._superTableService.registerTable(e, t, r);
  31590. } else if (i.id === Xi.id) {
  31591. const a2 = i.params;
  31592. if (a2 == null)
  31593. return;
  31594. const { unitId: e, tableName: t } = a2;
  31595. this._superTableService.remove(e, t);
  31596. } else if (i.id === to.id) {
  31597. const a2 = i.params;
  31598. if (a2 == null)
  31599. return;
  31600. const { tableOption: e, tableOptionType: t } = a2;
  31601. this._superTableService.registerTableOptionMap(e, t);
  31602. }
  31603. })
  31604. );
  31605. }
  31606. };
  31607. Ln = wb([
  31608. Bi(0, Pt),
  31609. Bi(1, Uu)
  31610. ], Ln);
  31611. var Db = class extends nt {
  31612. constructor() {
  31613. super(...arguments);
  31614. A(this, "_dirtyConversionMap", /* @__PURE__ */ new Map());
  31615. }
  31616. dispose() {
  31617. this._dirtyConversionMap.clear();
  31618. }
  31619. remove(e) {
  31620. this._dirtyConversionMap.delete(e);
  31621. }
  31622. get(e) {
  31623. return this._dirtyConversionMap.get(e);
  31624. }
  31625. has(e) {
  31626. return this._dirtyConversionMap.has(e);
  31627. }
  31628. register(e, t) {
  31629. this._dirtyConversionMap.set(e, t);
  31630. }
  31631. getDirtyConversionMap() {
  31632. return this._dirtyConversionMap;
  31633. }
  31634. };
  31635. var Sb = Ct(
  31636. "univer.formula.active-dirty-manager.service"
  31637. );
  31638. var Pb = Object.defineProperty;
  31639. var Lb = Object.getOwnPropertyDescriptor;
  31640. var xb = (i, a2, e, t) => {
  31641. for (var r = t > 1 ? void 0 : t ? Lb(a2, e) : a2, n = i.length - 1, s; n >= 0; n--)
  31642. (s = i[n]) && (r = (t ? s(a2, e, r) : s(r)) || r);
  31643. return t && r && Pb(a2, e, r), r;
  31644. };
  31645. var Ii = (i, a2) => (e, t) => a2(e, t, i);
  31646. var jb = "UNIVER_ENGINE_FORMULA_PLUGIN";
  31647. var _s;
  31648. var Fi = (_s = class extends Ra {
  31649. constructor(i = ai, a2, e) {
  31650. super(), this._config = i, this._injector = a2, this._configService = e;
  31651. const { ...t } = nu(
  31652. {},
  31653. ai,
  31654. this._config
  31655. );
  31656. this._configService.setConfig(fa, t);
  31657. }
  31658. onStarting() {
  31659. this._initialize(), this._initializeWithOverride();
  31660. }
  31661. onReady() {
  31662. var i;
  31663. Mf(this._injector, [
  31664. [wn],
  31665. [Ln]
  31666. ]), (i = this._config) != null && i.notExecuteFormula || Mf(this._injector, [
  31667. [Pn],
  31668. [Sn],
  31669. [Dn],
  31670. [Nn]
  31671. ]);
  31672. }
  31673. onRendered() {
  31674. var i;
  31675. (i = this._config) != null && i.notExecuteFormula || Mf(this._injector, [
  31676. [Gs],
  31677. [Ys]
  31678. ]);
  31679. }
  31680. _initialize() {
  31681. var a2;
  31682. const i = [
  31683. // Services
  31684. [Yt, { useClass: vf }],
  31685. [pr, { useClass: Vs }],
  31686. [Sb, { useClass: Db }],
  31687. [Uu, { useClass: Nb }],
  31688. // Models
  31689. [Pr],
  31690. // Engine
  31691. [ca],
  31692. //Controllers
  31693. [wn],
  31694. [Ln]
  31695. ];
  31696. (a2 = this._config) != null && a2.notExecuteFormula || i.push(
  31697. // Services
  31698. [ya, { useClass: Oh }],
  31699. [Nt, { useClass: Is }],
  31700. [Ft, { useClass: ws }],
  31701. [jr, { useClass: Nh }],
  31702. //Controller
  31703. [Nn],
  31704. [Pn],
  31705. [Dn],
  31706. [Sn],
  31707. // Calculation engine
  31708. [Cr],
  31709. [xr],
  31710. [gr],
  31711. // AstNode factory
  31712. [Eo],
  31713. [En],
  31714. [bn],
  31715. [Vo],
  31716. [yn],
  31717. [An],
  31718. [Rn],
  31719. [pn],
  31720. [Vn],
  31721. [No]
  31722. ), i.forEach((e) => this._injector.add(e));
  31723. }
  31724. _initializeWithOverride() {
  31725. var i;
  31726. (i = this._config) != null && i.notExecuteFormula || [
  31727. [Gs, { useClass: Qs }],
  31728. [Hn, { useClass: Vh }],
  31729. [Ys, { useClass: Hs }]
  31730. ].forEach((e) => this._injector.add(e));
  31731. }
  31732. }, A(_s, "pluginName", jb), _s);
  31733. Fi = xb([
  31734. Ii(1, ot(Ot)),
  31735. Ii(2, SE)
  31736. ], Fi);
  31737. export {
  31738. Y,
  31739. B,
  31740. I,
  31741. g,
  31742. er,
  31743. zu,
  31744. m2 as m,
  31745. yr,
  31746. Ju,
  31747. X2 as X,
  31748. $,
  31749. K2 as K,
  31750. en2 as en,
  31751. rc,
  31752. Ib,
  31753. Fb,
  31754. oc,
  31755. Ec,
  31756. bc,
  31757. bs,
  31758. tn,
  31759. kb,
  31760. fr,
  31761. pc,
  31762. Vc,
  31763. ys,
  31764. ns,
  31765. na,
  31766. fn,
  31767. rn,
  31768. $b,
  31769. Oc,
  31770. Vs,
  31771. pr,
  31772. Yb,
  31773. sa,
  31774. Xi,
  31775. aa,
  31776. ia,
  31777. Zi,
  31778. zi,
  31779. Ns,
  31780. Ji,
  31781. eo,
  31782. oa,
  31783. ua,
  31784. jc,
  31785. Uc,
  31786. to,
  31787. mr,
  31788. $e,
  31789. ri,
  31790. ae,
  31791. ca,
  31792. Pr,
  31793. si,
  31794. fa,
  31795. Hb,
  31796. ws,
  31797. Ft,
  31798. gr,
  31799. Gb,
  31800. kt2 as kt,
  31801. g2,
  31802. Ci,
  31803. _f,
  31804. ie,
  31805. T2 as T,
  31806. y2 as y,
  31807. j,
  31808. q2 as q,
  31809. pt,
  31810. kn,
  31811. Nf,
  31812. Of,
  31813. Cn,
  31814. ft,
  31815. wr,
  31816. Is,
  31817. Nt,
  31818. Eo,
  31819. Yt,
  31820. vf,
  31821. An,
  31822. En,
  31823. Cr,
  31824. ba,
  31825. bn,
  31826. Vo,
  31827. Y2,
  31828. se,
  31829. yn,
  31830. Rn,
  31831. pn,
  31832. Vn,
  31833. No,
  31834. xr,
  31835. ph,
  31836. Vh,
  31837. Hn,
  31838. Nh,
  31839. jr,
  31840. Oh,
  31841. ya,
  31842. pi,
  31843. $s,
  31844. Vi,
  31845. hs,
  31846. or,
  31847. Ys,
  31848. Hs,
  31849. Uh,
  31850. Gs,
  31851. Qs,
  31852. Nn,
  31853. Ih,
  31854. V,
  31855. Ws,
  31856. Yh,
  31857. le2 as le,
  31858. pm,
  31859. Vm,
  31860. Nm,
  31861. Om,
  31862. Qb,
  31863. Qe,
  31864. Im,
  31865. be2 as be,
  31866. Rg,
  31867. Z2 as Z,
  31868. O1,
  31869. ee,
  31870. P0,
  31871. Ne,
  31872. td,
  31873. Se2 as Se,
  31874. yd,
  31875. me2 as me,
  31876. rC,
  31877. D_,
  31878. v_,
  31879. v,
  31880. aE,
  31881. ub,
  31882. cb,
  31883. lb,
  31884. ju,
  31885. hb,
  31886. Nb,
  31887. Uu,
  31888. Db,
  31889. Sb,
  31890. Fi
  31891. };
  31892. /*! Bundled license information:
  31893. @univerjs/engine-formula/lib/es/index.js:
  31894. (*!
  31895. * decimal.js v10.4.3
  31896. * An arbitrary-precision Decimal type for JavaScript.
  31897. * https://github.com/MikeMcl/decimal.js
  31898. * Copyright (c) 2022 Michael Mclaughlin <M8ch88l@gmail.com>
  31899. * MIT Licence
  31900. *)
  31901. */
  31902. //# sourceMappingURL=chunk-QRYBFJ3R.js.map