| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066 |
- var vu = Object.defineProperty;
- var Tu = (i, a, e) => a in i ? vu(i, a, { enumerable: !0, configurable: !0, writable: !0, value: e }) : i[a] = e;
- var A = (i, a, e) => Tu(i, typeof a != "symbol" ? a + "" : a, e);
- import { ObjectMatrix as Ce, CommandType as Ie, Tools as Xe, AbsoluteRefType as we, RANGE_TYPE as Ze, createIdentifier as lt, Disposable as Me, IUniverInstanceService as Js, LRUMap as Bu, hashAlgorithm as Iu, moveRangeByOffset as ea, isValidRange as Fu, isFormulaString as bt, isFormulaId as Lt, Rectangle as Ha, cellToRange as ku, Inject as Ve, UniverInstanceType as Dr, LocaleService as $u, LocaleType as Mr, numfmt as gt, BuildTextUtils as Yu, isRealNum as Q, CellValueType as yt, toDisposable as Hu, Injector as ki, sortRules as Gu, RTree as As, requestImmediateMacroTask as Qu, IConfigService as ta, ICommandService as br, BooleanNumber as Wu, DataStreamTreeTokenType as ve, Optional as qu, Plugin as Ku, merge as Xu, touchDependencies as ts } from "@univerjs/core";
- import { Subject as ur } from "rxjs";
- import { DataSyncPrimaryController as Zu } from "@univerjs/rpc";
- var er = /* @__PURE__ */ ((i) => (i.FALSE = "FALSE", i.TRUE = "TRUE", i))(er || {}), xt = /* @__PURE__ */ ((i) => (i[i.SUCCESS = 0] = "SUCCESS", i[i.ERROR = 1] = "ERROR", i))(xt || {}), it = /* @__PURE__ */ ((i) => (i[i.FRONT = 0] = "FRONT", i[i.BACK = 1] = "BACK", i))(it || {});
- function zu(i, a, e, t, r) {
- for (let n = 0, s = i.length; n < s; n++) {
- const o = i[n];
- if (a !== o.unitId || e !== o.sheetId)
- continue;
- const { startRow: u, startColumn: c, endRow: l, endColumn: f } = o.range;
- if (t >= u && t <= l && r >= c && r <= f)
- return !0;
- }
- return !1;
- }
- var m = /* @__PURE__ */ ((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))(m || {});
- const yr = new Set(Object.values(m)), Ga = [...new Set(Object.values(m).map((i) => i.length))];
- var Ju = /* @__PURE__ */ ((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 || {}), X = /* @__PURE__ */ ((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))(X || {}), $ = /* @__PURE__ */ ((i) => (i.EQUALS = "=", i.NOT_EQUAL = "<>", i.GREATER_THAN = ">", i.GREATER_THAN_OR_EQUAL = ">=", i.LESS_THAN = "<", i.LESS_THAN_OR_EQUAL = "<=", i))($ || {});
- const Jr = /* @__PURE__ */ new Map([
- ["<>", 4],
- ["<", 4],
- [">=", 4],
- ["=", 4],
- [">", 4],
- ["<=", 4],
- ["&", 3],
- ["+", 2],
- ["-", 2],
- ["/", 1],
- ["*", 1],
- ["^", 0]
- ]), Dt = new Set(Jr.keys()), ec = /* @__PURE__ */ new Set([
- "=",
- "<>",
- ">",
- ">=",
- "<",
- "<="
- /* LESS_THAN_OR_EQUAL */
- ]);
- var K = /* @__PURE__ */ ((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))(K || {}), ze = /* @__PURE__ */ ((i) => (i.PERCENTAGE = "%", i.POUND = "#", i))(ze || {});
- const rs = /* @__PURE__ */ new Set([
- "%",
- "#"
- /* POUND */
- ]);
- var Oe = /* @__PURE__ */ ((i) => (i.AT = "@", i.MINUS = "-", i.PLUS = "+", i))(Oe || {});
- const tc = " ", $i = [
- ...Object.values($),
- ...Object.values(X),
- ...Object.values(K),
- ...Object.values(ze),
- ...Object.values(Oe)
- ];
- function en(i) {
- return $i.includes(i);
- }
- function rc(i) {
- for (const a of $i)
- if (i.indexOf(a) > -1)
- return !0;
- return !1;
- }
- function Ib(i) {
- return i[0] === "'" && i[i.length - 1] === "'" ? i.substring(1, i.length - 1) : i;
- }
- function Fb(i) {
- return en(i) && i !== K.CLOSE_BRACES && i !== K.CLOSE_BRACKET && i !== K.SINGLE_QUOTATION && i !== K.DOUBLE_QUOTATION || i === " ";
- }
- const nc = /* @__PURE__ */ new Set([
- X.PLUS,
- X.MINUS,
- X.MULTIPLY,
- X.DIVIDED,
- X.CONCATENATE,
- X.POWER,
- X.EQUALS,
- X.NOT_EQUAL,
- X.GREATER_THAN,
- X.GREATER_THAN_OR_EQUAL,
- X.LESS_THAN,
- X.LESS_THAN_OR_EQUAL,
- K.OPEN_BRACKET,
- K.COMMA,
- K.COLON,
- K.OPEN_BRACES,
- K.OPEN_SQUARE_BRACKET
- ]);
- function sc(i) {
- return nc.has(i);
- }
- const ac = /* @__PURE__ */ new Set([
- X.PLUS,
- X.MINUS,
- X.MULTIPLY,
- X.DIVIDED,
- X.CONCATENATE,
- X.POWER,
- X.EQUALS,
- X.NOT_EQUAL,
- X.GREATER_THAN,
- X.GREATER_THAN_OR_EQUAL,
- X.LESS_THAN,
- X.LESS_THAN_OR_EQUAL,
- K.OPEN_BRACKET,
- K.COMMA,
- K.COLON,
- K.OPEN_BRACES,
- K.OPEN_SQUARE_BRACKET,
- ze.PERCENTAGE,
- ze.POUND
- ]);
- function ic(i) {
- return ac.has(i);
- }
- function oc(i) {
- const a = {};
- return Object.keys(i).forEach((e) => {
- const t = i[e];
- if (t == null)
- return !0;
- a[e] == null && (a[e] = {}), Object.keys(t).forEach((r) => {
- const n = t[r];
- a[e][r] = new Ce(n);
- });
- }), a;
- }
- function uc(i) {
- const a = {};
- for (const e in i) {
- const t = i[e];
- if (t != null) {
- a[e] == null && (a[e] = {});
- for (const r in t) {
- const n = t[r], s = {};
- n.forValue((o, u, c) => {
- s[o] === void 0 && (s[o] = {}), s[o][u] = c;
- }), a[e][r] = s;
- }
- }
- }
- return a;
- }
- const Yi = '\\[([^\\[\\]\\/?:"<>|*\\\\]+)\\]', Qa = new RegExp(Yi), cc = "((?![\\[\\]\\/?*\\\\]).)*!", Tt = "$", ra = "\\s*?:\\s*?", cn = "[A-Za-z]+", ln = "[1-9][0-9]*", Rr = `'?(${Yi})?(${cc})?'?`, Es = `\\${Tt}?${cn}\\${Tt}?${ln}`, lc = `^(${Oe.AT})?${Rr}${Es}${ra}${Es}$`, Wa = new RegExp(lc), fc = `^${Rr}\\s*?${Es}(${ze.POUND})?$`, qa = new RegExp(fc), hc = `^${Rr}\\${Tt}?${ln}${ra}\\${Tt}?${ln}$`, Ka = new RegExp(hc), mc = `^${Rr}\\${Tt}?${cn}${ra}\\${Tt}?${cn}$`, Xa = new RegExp(mc), gc = `^${Rr}\\s*?\\${Tt}?${ln}$`, Za = new RegExp(gc), dc = `^${Rr}\\s*?\\${Tt}?${cn}$`, za = new RegExp(dc), Cc = "{.*?}", Ja = new RegExp(Cc, "g");
- function vr(i) {
- return qa.lastIndex = 0, qa.test(i);
- }
- function _c(i) {
- return Wa.lastIndex = 0, Wa.test(i);
- }
- function Hi(i) {
- return Ka.lastIndex = 0, Ka.test(i);
- }
- function Gi(i) {
- return Xa.lastIndex = 0, Xa.test(i);
- }
- function Qi(i) {
- return Za.lastIndex = 0, Za.test(i);
- }
- function Wi(i) {
- return za.lastIndex = 0, za.test(i);
- }
- function Ac(i) {
- return Ja.lastIndex = 0, Ja.test(i);
- }
- function Ec(i) {
- return vr(i) || _c(i) || Hi(i) || Gi(i);
- }
- const bc = {
- id: "formula.mutation.register-function",
- type: Ie.MUTATION,
- handler: () => !0
- }, bs = {
- id: "formula.mutation.set-array-formula-data",
- type: Ie.MUTATION,
- handler: (i, a) => !0
- }, yc = /[^0-9]/g, Rc = /[^A-Za-z]/g;
- function tn(i) {
- let a = i[0] === "$";
- const e = i.substring(1);
- let t = e.indexOf("$") > -1;
- return Xe.isStringNumber(e) && a && !t && (a = !1, t = !0), a && t ? we.ALL : a ? we.COLUMN : t ? we.ROW : we.NONE;
- }
- function kb(i) {
- const a = i.split("!");
- a.length > 1 && (i = a[a.length - 1]);
- const e = i.split(":");
- return e.length > 1 ? {
- startAbsoluteRefType: tn(e[0]),
- endAbsoluteRefType: tn(e[1])
- } : { startAbsoluteRefType: tn(e[0]) };
- }
- function ei(i = we.NONE) {
- let a = "", e = "";
- return i === we.ROW ? a = "$" : i === we.COLUMN ? e = "$" : i === we.ALL && (a = "$", e = "$"), {
- rowAbsoluteString: a,
- columnAbsoluteString: e
- };
- }
- function fr(i) {
- const {
- startColumn: a,
- startRow: e,
- endColumn: t,
- endRow: r,
- startAbsoluteRefType: n,
- endAbsoluteRefType: s,
- rangeType: o = Ze.NORMAL
- } = i, u = ei(n), c = ei(s);
- if (o === Ze.ROW || o === Ze.ALL) {
- const h = `${u.rowAbsoluteString}${e + 1}`, d = `${c.rowAbsoluteString}${r + 1}`;
- return `${h}:${d}`;
- }
- if (o === Ze.COLUMN) {
- const h = `${u.columnAbsoluteString}${Xe.chatAtABC(a)}`, d = `${c.columnAbsoluteString}${Xe.chatAtABC(t)}`;
- return `${h}:${d}`;
- }
- const l = `${u.columnAbsoluteString}${Xe.chatAtABC(a)}${u.rowAbsoluteString}${e + 1}`, f = `${c.columnAbsoluteString}${Xe.chatAtABC(t)}${c.rowAbsoluteString}${r + 1}`;
- return l === f ? l : `${l}:${f}`;
- }
- function pc(i, a) {
- return `${Ki(i)}!${fr(a)}`;
- }
- function Vc(i, a, e) {
- return Rs(i) || Rs(a) ? `'[${ps(i)}]${ps(a)}'!${fr(e)}` : `[${i}]${a}!${fr(e)}`;
- }
- function ys(i) {
- const { unitId: a, sheetName: e, range: t } = i;
- return a != null && a.length > 0 && e != null && e.length > 0 ? Vc(a, e, t) : e != null && e.length > 0 ? pc(e, t) : fr(t);
- }
- function ns(i) {
- const a = Number.parseInt(i.replace(yc, "")) - 1, e = Xe.ABCatNum(i.replace(Rc, "")), t = tn(i);
- return {
- row: a,
- column: e,
- absoluteRefType: t
- };
- }
- function na(i) {
- const a = Qa.exec(i);
- let e = "";
- a != null && (e = a[0].trim(), e = ti(e.slice(1, e.length - 1)), i = i.replace(Qa, ""));
- const t = i.indexOf("!");
- let r = "", n = "";
- 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, {
- refBody: n,
- sheetName: r,
- unitId: e
- };
- }
- function fn(i) {
- const { refBody: a, sheetName: e, unitId: t } = na(i), r = a.indexOf(":");
- if (r === -1) {
- const _ = ns(a), C = _.row, E = _.column, b = _.absoluteRefType;
- return {
- unitId: t,
- sheetName: e,
- range: {
- startRow: C,
- startColumn: E,
- endRow: C,
- endColumn: E,
- startAbsoluteRefType: b,
- endAbsoluteRefType: b
- }
- };
- }
- const n = a.substring(0, r), s = a.substring(r + 1), o = ns(n), u = ns(s), c = o.row > u.row ? u.row : o.row, l = o.column > u.column ? u.column : o.column, f = o.row > u.row ? o.row : u.row, h = o.column > u.column ? o.column : u.column;
- let d = Ze.NORMAL;
- return Number.isNaN(c) && Number.isNaN(f) ? d = Ze.COLUMN : Number.isNaN(l) && Number.isNaN(h) && (d = Ze.ROW), {
- unitId: t,
- sheetName: e,
- range: {
- startRow: c,
- startColumn: l,
- endRow: f,
- endColumn: h,
- startAbsoluteRefType: o.absoluteRefType,
- endAbsoluteRefType: u.absoluteRefType,
- rangeType: d
- }
- };
- }
- const Nc = ["LOG10"];
- function rn(i) {
- const a = qi(i);
- if (!Ec(a) || Nc.includes(a.toUpperCase().trim()))
- return !1;
- const { range: e } = fn(a);
- return !(e.endColumn >= 16384);
- }
- function qi(i) {
- const a = [];
- let e = !1;
- for (let t = 0, r = i.length; t < r; t++) {
- const n = i[t];
- if (n === tc && !e)
- a.push(n);
- else {
- if (!e && (n === Oe.AT || n === Oe.MINUS || n === Oe.PLUS))
- continue;
- a.push(n), e = !0;
- }
- }
- return a.join("");
- }
- function $b(i, a) {
- const e = (i == null ? void 0 : i.split(",")) || [];
- return i === "" || e.length === 0 ? [] : Oc(i) ? e.map((n) => {
- const s = fn(n);
- return {
- unitId: s.unitId,
- sheetId: a(s.sheetName),
- range: s.range,
- sheetName: s.sheetName
- };
- }) : [];
- }
- function Oc(i) {
- return ((i == null ? void 0 : i.split(",")) || []).every((e) => rn(e.trim()));
- }
- function Rs(i) {
- return i.length === 0 ? !1 : !!(rc(i) || Mc(i) || wc(i) || Dc(i) || /[\s!$%^&*()+\-=\[\]{};':"\\|,.<>\/?()]/.test(i));
- }
- function Ki(i) {
- return Rs(i) ? `'${ps(i)}'` : i;
- }
- function ps(i) {
- return i.replace(/'/g, "''");
- }
- function ti(i) {
- return i.replace(/''/g, "'");
- }
- function Mc(i) {
- const a = i.match(/[1-9][0-9]{0,6}/);
- return /^[A-Z]+[1-9][0-9]{0,6}$/.test(i) && a !== null;
- }
- function wc(i) {
- return /^(R(-?[0-9]+)?C(-?[0-9]+)?|C(-?[0-9]+)?|R(-?[0-9]+)?)$/.test(i);
- }
- function Dc(i) {
- return !new RegExp("^\\p{Letter}", "u").test(i.charAt(0));
- }
- var Sc = Object.defineProperty, Pc = Object.getOwnPropertyDescriptor, Lc = (i, a, e, t) => {
- for (var r = t > 1 ? void 0 : t ? Pc(a, e) : a, n = i.length - 1, s; n >= 0; n--)
- (s = i[n]) && (r = (t ? s(a, e, r) : s(r)) || r);
- return t && r && Sc(a, e, r), r;
- }, xc = (i, a) => (e, t) => a(e, t, i);
- let Vs = class extends Me {
- constructor(a) {
- super();
- // 18.2.6 definedNames (Defined Names)
- A(this, "_definedNameMap", {});
- A(this, "_update$", new ur());
- A(this, "update$", this._update$.asObservable());
- A(this, "_currentRange", {
- unitId: "",
- sheetId: "",
- range: {
- startRow: 0,
- endRow: 0,
- startColumn: 0,
- endColumn: 0
- }
- });
- A(this, "_currentRange$", new ur());
- A(this, "currentRange$", this._currentRange$.asObservable());
- A(this, "_focusRange$", new ur());
- A(this, "focusRange$", this._focusRange$.asObservable());
- this._univerInstanceService = a;
- }
- dispose() {
- this._definedNameMap = {};
- }
- getWorksheetByRef(a, e) {
- var r;
- const { sheetName: t } = na(e);
- return (r = this._univerInstanceService.getUnit(a)) == null ? void 0 : r.getSheetBySheetName(t);
- }
- focusRange(a, e) {
- const t = this.getValueById(a, e);
- t != null && this._focusRange$.next({ ...t, unitId: a });
- }
- setCurrentRange(a) {
- this._currentRange = a, this._currentRange$.next(a);
- }
- getCurrentRange() {
- return this._currentRange;
- }
- getCurrentRangeForString() {
- return fr(this._currentRange.range);
- }
- registerDefinedNames(a, e) {
- this._definedNameMap[a] = e, this._update();
- }
- registerDefinedName(a, e) {
- this._definedNameMap[a] == null && (this._definedNameMap[a] = {}), this._definedNameMap[a][e.id] = e, this._update();
- }
- removeDefinedName(a, e) {
- var t;
- (t = this._definedNameMap[a]) == null || delete t[e], this._update();
- }
- removeUnitDefinedName(a) {
- delete this._definedNameMap[a], this._update();
- }
- getDefinedNameMap(a) {
- return this._definedNameMap[a];
- }
- getValueByName(a, e) {
- var r;
- const t = this._definedNameMap[a];
- return t == null ? null : (r = Array.from(Object.values(t)).filter((n) => n.name === e)) == null ? void 0 : r[0];
- }
- getValueById(a, e) {
- var t;
- return (t = this._definedNameMap[a]) == null ? void 0 : t[e];
- }
- hasDefinedName(a) {
- return this._definedNameMap[a] == null ? !1 : (Array.from(Object.values(this._definedNameMap[a])).length || 0) !== 0;
- }
- _update() {
- this._update$.next(null);
- }
- };
- Vs = Lc([
- xc(0, Js)
- ], Vs);
- const pr = lt("univer.formula.defined-names.service"), Yb = (i, a) => {
- const { unitId: e, id: t } = a;
- return {
- ...i.get(pr).getValueById(e, t),
- unitId: e
- };
- }, sa = {
- id: "formula.mutation.set-defined-name",
- type: Ie.MUTATION,
- handler: (i, a) => {
- if (a == null)
- return !1;
- const e = i.get(pr), { id: t, unitId: r, name: n, formulaOrRefString: s, comment: o, hidden: u, localSheetId: c } = a;
- return e.registerDefinedName(r, {
- id: t,
- name: n.trim(),
- formulaOrRefString: s.trim(),
- comment: o == null ? void 0 : o.trim(),
- hidden: u,
- localSheetId: c
- }), !0;
- }
- }, Xi = {
- id: "formula.mutation.remove-defined-name",
- type: Ie.MUTATION,
- handler: (i, a) => {
- if (a == null)
- return !1;
- const e = i.get(pr), { unitId: t, id: r } = a;
- return e.removeDefinedName(t, r), !0;
- }
- }, aa = {
- id: "formula.mutation.set-feature-calculation",
- type: Ie.MUTATION,
- handler: () => !0
- }, ia = {
- id: "formula.mutation.remove-feature-calculation",
- type: Ie.MUTATION,
- handler: () => !0
- }, Zi = {
- id: "formula.mutation.set-formula-calculation-start",
- type: Ie.MUTATION,
- handler: () => !0
- }, zi = {
- id: "formula.mutation.set-formula-calculation-stop",
- type: Ie.MUTATION,
- handler: () => !0
- }, Ns = {
- id: "formula.mutation.set-formula-calculation-notification",
- type: Ie.MUTATION,
- handler: () => !0
- }, Ji = {
- id: "formula.mutation.set-formula-calculation-result",
- type: Ie.MUTATION,
- handler: () => !0
- }, eo = {
- id: "formula.mutation.set-formula-data",
- type: Ie.MUTATION,
- handler: (i, a) => !0
- }, oa = {
- id: "formula.mutation.set-other-formula",
- type: Ie.MUTATION,
- handler: () => !0
- }, ua = {
- id: "formula.mutation.remove-other-formula",
- type: Ie.MUTATION,
- handler: () => !0
- }, jc = {
- id: "formula.mutation.set-super-table",
- type: Ie.MUTATION,
- handler: () => !0
- }, Uc = {
- id: "formula.mutation.remove-super-table",
- type: Ie.MUTATION,
- handler: () => !0
- }, to = {
- id: "formula.mutation.set-super-table-option",
- type: Ie.MUTATION,
- handler: () => !0
- };
- class Vt {
- constructor(a) {
- A(this, "_cache");
- this._cache = new Bu(a);
- }
- set(a, e) {
- const t = this._hash(a);
- this._cache.set(t, e);
- }
- get(a) {
- const e = this._hash(a);
- return this._cache.get(e);
- }
- clear() {
- this._cache.clear();
- }
- _hash(a) {
- return a.length <= 64 ? a : Iu(a).toString();
- }
- }
- const ht = "P_1", Ut = "R_1", hr = "L_1", Tr = "LR_1", ro = "LO_1", vc = "LET", Sr = "LAMBDA", Tc = "CUBE", Bc = /* @__PURE__ */ new Set(["RAND", "RANDBETWEEN", "NOW", "TODAY"]), Os = new Vt(1e5);
- function mr(i) {
- const a = Os.get(i);
- if (a)
- return a;
- const e = fn(i);
- return Os.set(i, e), fn(i);
- }
- function Ic() {
- Os.clear();
- }
- var $e = /* @__PURE__ */ ((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 || {});
- function ri(i) {
- let a = "";
- for (const e of i)
- typeof e == "string" ? a += e : a += e.token;
- return a;
- }
- class ae {
- constructor() {
- A(this, "_parent");
- A(this, "_token", Ut);
- A(this, "_children", []);
- A(this, "_lambdaId");
- A(this, "_functionDefinitionPrivacyVar");
- A(this, "_lambdaParameter", "");
- A(this, "_startIndex", -1);
- A(this, "_endIndex", -1);
- A(this, "_definedNames", []);
- }
- dispose() {
- var a;
- this._children.forEach((e) => {
- typeof e != "string" && e.dispose();
- }), (a = this._functionDefinitionPrivacyVar) == null || a.clear(), this._functionDefinitionPrivacyVar = null, this._children = [], this._parent = null, this._definedNames = [];
- }
- getDefinedNames() {
- return this._definedNames;
- }
- getStartIndex() {
- return this._startIndex;
- }
- getLambdaId() {
- return this._lambdaId;
- }
- setLambdaId(a) {
- this._lambdaId = a;
- }
- getFunctionDefinitionPrivacyVar() {
- return this._functionDefinitionPrivacyVar;
- }
- setLambdaPrivacyVar(a) {
- this._functionDefinitionPrivacyVar = a;
- }
- getLambdaParameter() {
- return this._lambdaParameter;
- }
- setLambdaParameter(a) {
- this._lambdaParameter = a;
- }
- getParent() {
- return this._parent;
- }
- setParent(a) {
- this._parent = a;
- }
- getChildren() {
- return this._children;
- }
- setChildren(a) {
- this._children = a;
- }
- addChildren(a) {
- this._children.push(a);
- }
- addChildrenFirst(a) {
- this._children.unshift(a);
- }
- getToken() {
- return this._token;
- }
- setToken(a) {
- this._token = a;
- }
- setIndex(a, e) {
- this._startIndex = a, this._endIndex = e;
- }
- setDefinedNames(a) {
- this._definedNames = a;
- }
- hasDefinedNames() {
- return this._definedNames.length > 0;
- }
- replaceChild(a, e) {
- const t = this._getIndexInParent(a);
- t != null && (this.getChildren().splice(t, 1, e), e.setParent(this));
- }
- changeToParent(a) {
- const e = this.getParent();
- e && e.removeChild(this), this.setParent(a), a.getChildren().push(this);
- }
- removeChild(a) {
- const e = this._getIndexInParent(a);
- e != null && this.getChildren().splice(e, 1);
- }
- serialize() {
- const a = this.getToken(), e = this.getChildren(), t = [], r = e.length;
- for (let n = 0; n < r; n++) {
- const s = e[n];
- s instanceof ae ? t.push(s.serialize()) : t.push(s);
- }
- return {
- token: a,
- st: this._startIndex,
- ed: this._endIndex,
- children: t
- };
- }
- _getIndexInParent(a) {
- const e = this.getChildren(), t = e.length;
- for (let r = 0; r < t; r++)
- if (e[r] === a)
- return r;
- }
- }
- const no = 2e3, ss = new Vt(no), as = new Vt(no);
- class ca extends Me {
- constructor() {
- super(...arguments);
- A(this, "_currentLexerNode", new ae());
- A(this, "_upLevel", 0);
- A(this, "_segment", "");
- A(this, "_bracketState", []);
- // ()
- A(this, "_squareBracketState", 0);
- A(this, "_bracesState", 0);
- // {}
- A(this, "_singleQuotationState", 0);
- // ''
- A(this, "_doubleQuotationState", 0);
- // ""
- A(this, "_lambdaState", !1);
- // Lambda
- A(this, "_colonState", !1);
- // :
- A(this, "_formulaErrorCount", 0);
- A(this, "_tableBracketState", !1);
- }
- // Table3[[#All],[Column1]:[Column2]]
- dispose() {
- this._resetTemp(), this._currentLexerNode.dispose(), ss.clear(), as.clear();
- }
- getUpLevel() {
- return this._upLevel;
- }
- isColonClose() {
- return this._colonState === !1;
- }
- isColonOpen() {
- return this._colonState === !0;
- }
- isDoubleQuotationClose() {
- return this._doubleQuotationState === 0;
- }
- isLambdaOpen() {
- return this._lambdaState === !0;
- }
- isLambdaClose() {
- return this._lambdaState === !1;
- }
- isSingleQuotationClose() {
- return this._singleQuotationState === 0;
- }
- isBracesClose() {
- return this._bracesState === 0;
- }
- isBracketClose() {
- return this._bracketState.length === 0;
- }
- isSquareBracketClose() {
- return this._squareBracketState === 0;
- }
- getCurrentLexerNode() {
- return this._currentLexerNode;
- }
- getFunctionAndParameter(e, t) {
- const r = this._getCurrentParamIndex(e, t);
- if (r == null || r === m.VALUE)
- return;
- const n = r[0];
- if (typeof n == "string")
- return;
- let s = n.getParent(), o = n;
- for (; s; ) {
- const u = s.getToken();
- if (u !== ht && !en(u) && s.getStartIndex() !== -1) {
- const c = s.getChildren().indexOf(o);
- return {
- functionName: u,
- paramIndex: c
- };
- }
- o = s, s = s.getParent();
- }
- }
- /**
- * Estimate the number of right brackets that need to be automatically added to the end of the formula.
- * @param formulaString
- */
- checkIfAddBracket(e) {
- let t = 0, r = e.length - 1, n = e[r];
- for (; (n === K.CLOSE_BRACKET || n === " ") && r >= 0; )
- n === K.CLOSE_BRACKET && t++, n = e[--r];
- const s = this._getCurrentParamIndex(e, e.length - 2);
- if (s == null || s === m.VALUE)
- return 0;
- const o = s[0];
- if (typeof o == "string")
- return 0;
- let u = o.getParent(), c = 0;
- for (s[1] === K.OPEN_BRACKET && c++; u; ) {
- const l = u.getToken();
- l !== ht && l !== K.COLON && u.getStartIndex() !== -1 && l.toUpperCase() !== Sr && (t === 0 ? c += 1 : t--), u = u.getParent();
- }
- return c;
- }
- sequenceNodesBuilder(e) {
- const t = as.get(e);
- if (t)
- return [...t];
- const r = this._getSequenceArray(e);
- if (r.length === 0)
- return;
- const n = this.getSequenceNode(r);
- return as.set(e, [...n]), n;
- }
- convertRefersToAbsolute(e, t, r, n = "") {
- const s = this.sequenceNodesBuilder(e);
- if (s == null)
- return e;
- let o = "";
- e.substring(0, 1) === X.EQUALS && (o = X.EQUALS);
- for (let u = 0, c = s.length; u < c; u++) {
- const l = s[u];
- if (typeof l != "string" && l.nodeType === $e.REFERENCE) {
- const { token: f, endIndex: h } = l, d = mr(f);
- if (d == null)
- continue;
- const { range: _, sheetName: C, unitId: E } = d, b = {
- ..._,
- startAbsoluteRefType: t,
- endAbsoluteRefType: r
- }, R = ys({
- range: b,
- unitId: E,
- sheetName: C || n
- }), p = R.length - f.length;
- s[u] = {
- ...l,
- token: R,
- endIndex: h + p
- };
- for (let N = u + 1; N < c; N++) {
- const M = s[N];
- typeof M != "string" && (M.startIndex += p, M.endIndex += p);
- }
- }
- }
- return `${o}${ri(s)}`;
- }
- moveFormulaRefOffset(e, t, r, n = !1) {
- const s = this.sequenceNodesBuilder(e);
- if (s == null)
- return e;
- const o = [];
- for (let u = 0, c = s.length; u < c; u++) {
- const l = s[u];
- if (typeof l == "string" || l.nodeType !== $e.REFERENCE) {
- o.push(l);
- continue;
- }
- const { token: f } = l, h = mr(f), { sheetName: d, unitId: _ } = h;
- let C = h.range;
- if (!n && C.startAbsoluteRefType === we.ALL && C.endAbsoluteRefType === we.ALL) {
- o.push(l);
- continue;
- } else
- C = ea(C, t, r, n);
- let E = "";
- Fu(C) ? E = ys({
- range: C,
- unitId: _,
- sheetName: d
- }) : E = m.REF, o.push({
- ...l,
- token: E
- });
- }
- return `=${ri(o)}`;
- }
- /**
- * univer-pro/issues/1684
- * =sum({}{})
- */
- _formulaSpellCheck() {
- if (this._currentLexerNode.getChildren().length === 0)
- return !0;
- const e = this._currentLexerNode.getChildren()[0];
- return !!(e instanceof ae || Dt.has(e) || rs.has(e) || e === Oe.AT || e === K.COMMA || e === K.COLON || e === K.OPEN_BRACKET);
- }
- // eslint-disable-next-line complexity
- getSequenceNode(e) {
- const t = [];
- let r = !1;
- for (let n = 0, s = e.length; n < s; n++) {
- const o = e[n], u = e[n - 1], { segment: c, currentString: l } = o;
- if (l === K.DOUBLE_QUOTATION && (r = !0), (c !== "" || n === 0) && n !== s - 1) {
- t.push(l);
- continue;
- }
- let f = (u == null ? void 0 : u.segment) || "";
- const h = n - f.length;
- let d = n - 1;
- const _ = n - 1;
- if (n === s - 1 && this._isLastMergeString(l) && (f += l, d += 1), f === "" || Jr.has(f)) {
- t.push(l);
- continue;
- }
- const C = f.trim(), E = qi(C);
- r === !0 && C[C.length - 1] === K.DOUBLE_QUOTATION && C[0] !== K.OPEN_BRACES ? (r = !1, this._processPushSequenceNode(t, $e.STRING, f, h, d, _)) : vr(E) && rn(E) ? this._processPushSequenceNode(t, $e.REFERENCE, f, h, d, _) : Xe.isStringNumber(C) ? this._processPushSequenceNode(t, $e.NUMBER, f, h, d, _) : C.length > 0 && this._processPushSequenceNode(t, $e.FUNCTION, f, h, d, _), (n !== s - 1 || !this._isLastMergeString(l)) && t.push(l);
- }
- return this._mergeSequenceNodeReference(t);
- }
- _processPushSequenceNode(e, t, r, n, s, o) {
- this._pushSequenceNode(
- e,
- {
- nodeType: t,
- token: r,
- startIndex: n,
- endIndex: s
- },
- o
- );
- }
- _getCurrentParamIndex(e, t) {
- return this._nodeMaker(e, void 0, t);
- }
- _isLastMergeString(e) {
- return e === K.DOUBLE_QUOTATION || Xe.isStringNumber(e) || !en(e);
- }
- /**
- * Merge array and handle ref operations
- *
- */
- _mergeSequenceNodeReference(e) {
- const t = [], r = e.length;
- let n = 0;
- for (; n < r; ) {
- const s = e[n];
- if (typeof s == "string") {
- const o = e[n - 1];
- if (s.trim() === K.CLOSE_BRACES && o != null && typeof o != "string" && o.nodeType === $e.FUNCTION && o.token.trim().substring(0, 1) === K.OPEN_BRACES) {
- o.nodeType = $e.ARRAY, o.token += s, o.endIndex += s.length, n++;
- continue;
- }
- t.push(s);
- } else {
- const o = e[n + 1], u = e[n + 2];
- o === K.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);
- }
- n++;
- }
- return this._minusSplitSequenceNode(t);
- }
- /**
- * =-A1 Separate the negative sign from the ref string.
- */
- _minusSplitSequenceNode(e) {
- const t = [];
- for (const r of e) {
- if (typeof r != "string") {
- const s = r.token.match(/^(\s*([-@+]\s*)+)(.*)$/);
- if (s) {
- const o = s[1], u = s[3];
- if (rn(u.trim())) {
- const c = o.length, l = r.startIndex, f = r.startIndex + c - 1, h = {
- nodeType: $e.NORMAL,
- // Use appropriate nodeType for operators
- token: o,
- startIndex: l,
- endIndex: f
- }, d = {
- nodeType: $e.REFERENCE,
- token: u,
- startIndex: f + 1,
- endIndex: r.endIndex
- };
- t.push(h), t.push(d);
- continue;
- }
- }
- }
- t.push(r);
- }
- return t;
- }
- _pushSequenceNode(e, t, r) {
- const n = r - t.startIndex + 1;
- e.splice(e.length - n, n, t);
- }
- nodeMakerTest(e) {
- return this._nodeMaker(e);
- }
- treeBuilder(e, t = !0, r, n) {
- if (t === !0) {
- const h = ss.get(e), d = n == null ? void 0 : n(e);
- if (h && !d)
- return h;
- }
- this._resetCurrentLexerNode(), this._currentLexerNode.setToken(Ut);
- const s = [];
- let o = this._nodeMaker(e, s);
- if (o === m.VALUE || s.length === 0)
- return o;
- let u = !1, c = "", l = [];
- if (r) {
- const { hasDefinedName: h, sequenceString: d, definedNames: _ } = r(s);
- u = h, c = d, l = _;
- }
- if (u && (this._resetCurrentLexerNode(), this._currentLexerNode.setToken(Ut), o = this._nodeMaker(`=${c}`), o === m.VALUE))
- return o;
- const f = this._getTopNode(this._currentLexerNode);
- if (f && (this._currentLexerNode = f), t) {
- if (!this._suffixExpressionHandler(this._currentLexerNode))
- return m.VALUE;
- ss.set(e, this._currentLexerNode);
- }
- return u && this._currentLexerNode.setDefinedNames(l), this._currentLexerNode;
- }
- // eslint-disable-next-line complexity
- _suffixExpressionHandler(e) {
- var u;
- const t = e.getChildren();
- if (!t)
- return !1;
- const r = t.length, n = [], s = [];
- let o = !0;
- for (let c = 0; c < r; c++) {
- const l = t[c];
- if (l instanceof ae)
- o = this._suffixExpressionHandler(l), n.push(l);
- else {
- const f = l.trim();
- if (f === "")
- continue;
- if (Dt.has(f)) {
- if (f === X.PLUS && this._deletePlusForPreNode(t[c - 1]))
- continue;
- if (f !== X.PLUS && f !== X.MINUS && this._deletePlusForPreNode(t[c - 1]))
- return !1;
- for (; s.length > 0; ) {
- const h = (u = s[s.length - 1]) == null ? void 0 : u.trim();
- if (!h || h === K.OPEN_BRACKET)
- break;
- const d = Jr.get(h), _ = Jr.get(f);
- if (!d || !_)
- break;
- if (_ >= d)
- n.push(s.pop());
- else
- break;
- }
- s.push(l);
- } else if (f === K.OPEN_BRACKET)
- s.push(l);
- else if (f === K.CLOSE_BRACKET)
- this._processSuffixExpressionCloseBracket(n, s, t, c);
- else {
- if (this._checkCloseBracket(t[c - 1]))
- return !1;
- n.push(l);
- }
- }
- }
- return o ? this._processSuffixExpressionRemain(n, s, e) : !1;
- }
- _processSuffixExpressionRemain(e, t, r) {
- const n = e.length, s = e[n - 1];
- for (; t.length > 0; ) {
- const o = t.pop();
- if (!(s instanceof ae) && (o === K.OPEN_BRACKET || o === K.CLOSE_BRACKET))
- return !1;
- e.push(o);
- }
- return r.setChildren(e), !0;
- }
- _processSuffixExpressionCloseBracket(e, t, r, n) {
- var s;
- if (this._checkOpenBracket(r[n - 1]) || this._checkOperator(r[n - 1]))
- return !1;
- for (; t.length > 0; ) {
- const o = (s = t[t.length - 1]) == null ? void 0 : s.trim();
- if (!o)
- break;
- if (o === K.OPEN_BRACKET) {
- t.pop();
- break;
- }
- e.push(t.pop());
- }
- }
- _checkCloseBracket(e) {
- return e === K.CLOSE_BRACKET || e instanceof ae;
- }
- _checkOpenBracket(e) {
- return e === K.OPEN_BRACKET;
- }
- _checkOperator(e) {
- return e == null || e instanceof ae ? !1 : Dt.has(e);
- }
- _deletePlusForPreNode(e) {
- if (e == null)
- return !0;
- if (!(e instanceof ae)) {
- const t = e.trim();
- if (Dt.has(t) || t === K.OPEN_BRACKET)
- return !0;
- }
- return !1;
- }
- _resetCurrentLexerNode() {
- this._currentLexerNode = new ae();
- }
- _resetSegment() {
- this._segment = "";
- }
- _openBracket(e = 0) {
- this._bracketState.push(e);
- }
- _closeBracket() {
- this._bracketState.pop();
- }
- _openSquareBracket() {
- this._squareBracketState += 1;
- }
- _closeSquareBracket() {
- this._squareBracketState -= 1;
- }
- _getCurrentBracket() {
- const e = this._bracketState;
- return e[e.length - 1];
- }
- _changeCurrentBracket(e) {
- const t = this._bracketState;
- t[t.length - 1] = e;
- }
- _openBraces() {
- this._bracesState += 1;
- }
- _closeBraces() {
- this._bracesState -= 1;
- }
- _openSingleQuotation() {
- this._singleQuotationState += 1;
- }
- _closeSingleQuotation() {
- this._singleQuotationState -= 1;
- }
- _openDoubleQuotation() {
- this._doubleQuotationState += 1;
- }
- _closeDoubleQuotation() {
- this._doubleQuotationState -= 1;
- }
- _openLambda() {
- this._lambdaState = !0;
- }
- _closeLambda() {
- this._lambdaState = !1;
- }
- _openColon(e) {
- this._upLevel = e, this._colonState = !0;
- }
- _closeColon() {
- this._upLevel = 0, this._colonState = !1;
- }
- _isTableBracket() {
- return this._tableBracketState;
- }
- _openTableBracket() {
- this._tableBracketState = !0;
- }
- _closeTableBracket() {
- this._tableBracketState = !1;
- }
- _formalErrorOccurred() {
- this._formulaErrorCount += 1;
- }
- _hasFormalError() {
- return this._formulaErrorCount > 0;
- }
- _getLastChildCurrentLexerNode() {
- const e = this._currentLexerNode.getChildren();
- if (e && e.length > 0) {
- const t = e[e.length - 1];
- if (t instanceof ae)
- return t;
- }
- return !1;
- }
- _getLastChildCurrent() {
- const e = this._currentLexerNode.getChildren();
- return e && e.length > 0 ? e[e.length - 1] : !1;
- }
- _setParentCurrentLexerNode() {
- const e = this._currentLexerNode.getParent();
- return e ? (this._currentLexerNode = e, !0) : !1;
- }
- _setAncestorCurrentLexerNode() {
- var r, n, s, o, u, c;
- const e = (r = this._currentLexerNode) == null ? void 0 : r.getParent();
- let t = !1;
- if (e && e.getToken() === hr) {
- if ((n = e == null ? void 0 : e.getParent()) != null && n.getParent()) {
- const l = (o = (s = this._currentLexerNode.getParent()) == null ? void 0 : s.getParent()) == null ? void 0 : o.getParent();
- l && (this._currentLexerNode = l), t = !0;
- }
- } else if (e != null && e.getParent()) {
- const l = (u = this._currentLexerNode.getParent()) == null ? void 0 : u.getParent();
- l && (this._currentLexerNode = l), t = !0;
- }
- for (let l = 0; l < this._upLevel; l++) {
- const f = (c = this._currentLexerNode) == null ? void 0 : c.getParent();
- f && (this._currentLexerNode = f), this._currentLexerNode ? t = !0 : t = !1;
- }
- return t;
- }
- _segmentCount() {
- return this._segment.trim().length;
- }
- _pushSegment(e) {
- this._segment += e;
- }
- _pushNodeToChildren(e, t = !1) {
- let r = e;
- if (r !== "") {
- const n = this._currentLexerNode.getChildren();
- if (!(r instanceof ae) && this.isColonOpen()) {
- const s = new ae();
- s.setToken(r), s.setParent(this._currentLexerNode), r = s;
- }
- t ? n.unshift(r) : n.push(r);
- }
- this.isColonOpen() && (this._setAncestorCurrentLexerNode(), this._closeColon());
- }
- _setCurrentLexerNode(e, t = !1) {
- this._pushNodeToChildren(e, t), e.setParent(this._currentLexerNode), this._currentLexerNode = e;
- }
- _newAndPushCurrentLexerNode(e, t, r = !1) {
- const n = new ae();
- n.setToken(e), n.setIndex(t - e.length, t - 1), this._setCurrentLexerNode(n, r);
- }
- _getTopNode(e) {
- let t = e;
- for (; t != null && t.getParent(); )
- t = t.getParent();
- return t;
- }
- _removeLastChild() {
- this._currentLexerNode.getChildren().splice(-1);
- }
- /**
- * fix univer-pro/issues/2447
- * =1/3+
- * =+
- * =sum(A1+)
- */
- _formulaErrorLastTokenCheck(e, t) {
- const r = this._findPreviousToken(e, t) || "", n = e.length - 1 === t;
- if (!n && this._isOperatorToken(r) || n && sc(r))
- return !0;
- if (rs.has(r)) {
- const s = this._findSecondLastNonSpaceToken(e, t);
- if (s == null || ic(s))
- return !0;
- }
- return !1;
- }
- _findPreviousToken(e, t) {
- let r = t;
- for (; r >= 0; ) {
- const n = e[r];
- if (n !== " ")
- return n;
- r--;
- }
- }
- _findSecondLastNonSpaceToken(e, t) {
- let r = t, n = 0;
- for (; r >= 0; ) {
- const s = e[r];
- if (s !== " " && (n++, n === 2))
- return s;
- r--;
- }
- return null;
- }
- _findNextToken(e, t) {
- let r = t;
- for (; r >= 0; ) {
- const n = e[r];
- if (n !== " ")
- return n;
- r++;
- }
- }
- _unexpectedEndingTokenExcludeOperator(e) {
- return (
- // OPERATOR_TOKEN_SET.has(prevString) ||
- e === K.OPEN_BRACKET || e === K.COMMA || e === X.EQUALS || e === ""
- );
- }
- _unexpectedEndingToken(e) {
- return !!(this._isOperatorToken(e) || this._unexpectedEndingTokenExcludeOperator(e));
- }
- _isOperatorToken(e) {
- return !!Dt.has(e);
- }
- _getSequenceArray(e) {
- const t = [];
- return this._nodeMaker(e, t), t;
- }
- _resetTemp() {
- this._currentLexerNode = new ae(), this._upLevel = 0, this._segment = "", this._bracketState = [], this._bracesState = 0, this._singleQuotationState = 0, this._doubleQuotationState = 0, this._lambdaState = !1, this._colonState = !1, this._formulaErrorCount = 0;
- }
- _checkErrorState() {
- return !!(this._bracketState.length > 0 || this._bracesState > 0 || this._singleQuotationState > 0 || this._doubleQuotationState > 0 || this._hasFormalError());
- }
- _checkSimilarErrorToken(e, t, r) {
- let n = t;
- if (e !== ze.POUND)
- return !0;
- let s = r[++n];
- for (; s === " "; )
- s = r[++n];
- return !!en(s);
- }
- _checkIfErrorObject(e, t) {
- return !!this._findErrorObject(e, t);
- }
- _findErrorObject(e, t) {
- for (let r = 0; r < Ga.length; r++) {
- const n = Ga[r], s = t.slice(e, e + n).join("").toUpperCase();
- if (yr.has(s))
- return s;
- }
- }
- // eslint-disable-next-line max-lines-per-function, complexity
- _nodeMaker(e, t, r) {
- let n = e.replace(/\r\n$/, "").replace(/\r/g, " ").replace(/\n/g, " ");
- n.substring(0, 1) === X.EQUALS && (n = n.substring(1));
- const s = n.split(""), o = s.length;
- let u = 0;
- for (this._resetTemp(), this._formulaErrorLastTokenCheck(s, o - 1) && this._formalErrorOccurred(); u < o; ) {
- const c = s[u];
- if (r === u)
- return [this._currentLexerNode, c];
- if (c === ze.POUND && this.isSingleQuotationClose() && this.isDoubleQuotationClose() && this.isBracesClose() && this.isSquareBracketClose() && this._checkIfErrorObject(u, s)) {
- const l = this._findErrorObject(u, s);
- if (l == null)
- return m.VALUE;
- this._pushNodeToChildren(l);
- for (let f = 0; f < l.length; f++) {
- const h = s[u];
- this._pushSegment(h), this._addSequenceArray(t, h, u), u++;
- }
- this._resetSegment();
- continue;
- } else if (c === K.OPEN_BRACKET && this.isSingleQuotationClose() && this.isDoubleQuotationClose())
- if (this._segmentCount() > 0 || this.isLambdaOpen()) {
- this.isLambdaClose() && (this._newAndPushCurrentLexerNode(this._segment, u), this._resetSegment()), this._openBracket(
- 1
- /* FUNCTION */
- ), this._closeLambda();
- const l = s[u + 1];
- if (l && l === K.CLOSE_BRACKET) {
- if (!this._setParentCurrentLexerNode() && u !== o - 1)
- return m.VALUE;
- this._addSequenceArray(t, c, u), u++, this._addSequenceArray(t, l, u), u++, this._closeBracket();
- continue;
- } else l && this._newAndPushCurrentLexerNode(ht, u);
- } else
- this._pushNodeToChildren(c), this._openBracket(
- 0
- /* NORMAL */
- ), this._resetSegment();
- else if (c === K.CLOSE_BRACKET && this.isSingleQuotationClose() && this.isDoubleQuotationClose()) {
- this._formulaErrorLastTokenCheck(s, u - 1) && this._formalErrorOccurred(), this._pushNodeToChildren(this._segment), this._resetSegment();
- const l = this._getCurrentBracket();
- if (l === 0)
- this._pushNodeToChildren(c);
- else if (l === 1) {
- const f = s[u + 1];
- if (f && f === K.OPEN_BRACKET) {
- if (!this._setParentCurrentLexerNode() && u !== o - 1)
- return m.VALUE;
- this._newAndPushCurrentLexerNode(hr, u, !0), this._openLambda();
- } else if (!this._setAncestorCurrentLexerNode() && u !== o - 1)
- return m.VALUE;
- } else
- return m.VALUE;
- this._closeBracket();
- } else if (c === K.OPEN_BRACES && this.isSingleQuotationClose() && this.isDoubleQuotationClose()) {
- if (this._pushSegment(c), this._openBraces(), !this._formulaSpellCheck())
- return m.VALUE;
- } else if (c === K.CLOSE_BRACES && this.isSingleQuotationClose() && this.isDoubleQuotationClose())
- this._pushSegment(c), this._pushNodeToChildren(this._segment), this._resetSegment(), this._closeBraces();
- else if (c === K.OPEN_SQUARE_BRACKET && this.isSingleQuotationClose() && this.isDoubleQuotationClose())
- this._segment.length > 0 && this._openTableBracket(), this._pushSegment(c), this._openSquareBracket();
- else if (c === K.CLOSE_SQUARE_BRACKET && this.isSingleQuotationClose() && this.isDoubleQuotationClose())
- this._closeSquareBracket(), this.isSquareBracketClose() ? (this._pushSegment(c), this._isTableBracket() && (this._pushNodeToChildren(this._segment), this._resetSegment()), this._closeTableBracket()) : this._pushSegment(c);
- else if (c === K.DOUBLE_QUOTATION && this.isSingleQuotationClose() && this.isSquareBracketClose()) {
- if (this.isDoubleQuotationClose())
- this._openDoubleQuotation();
- else {
- const l = s[u + 1];
- l && l === K.DOUBLE_QUOTATION ? u++ : this._closeDoubleQuotation();
- }
- this._pushSegment(c);
- } else if (c === K.SINGLE_QUOTATION && this.isDoubleQuotationClose()) {
- if (this.isSingleQuotationClose())
- this._openSingleQuotation(), this._segmentCount() === 0 && this._resetSegment();
- else {
- const l = s[u + 1];
- if (l && l === K.SINGLE_QUOTATION) {
- this._pushSegment(c), this._addSequenceArray(t, c, u), u++, this._pushSegment(l), this._addSequenceArray(t, l, u), u++;
- continue;
- } else
- this._closeSingleQuotation();
- }
- this._pushSegment(c);
- } else if (c === K.COMMA && this.isSingleQuotationClose() && this.isDoubleQuotationClose() && this.isBracesClose() && this.isSquareBracketClose()) {
- this._formulaErrorLastTokenCheck(s, u - 1) && this._formalErrorOccurred();
- const l = this._getCurrentBracket();
- if (l === 1 || l == null) {
- if (this._pushNodeToChildren(this._segment), this._resetSegment(), !this._setParentCurrentLexerNode() && u !== o - 1 && l != null)
- return m.VALUE;
- this._newAndPushCurrentLexerNode(ht, u);
- } else {
- const f = new ae();
- f.setToken(Tc);
- const h = new ae();
- h.setToken(ht), h.changeToParent(f);
- const d = this._currentLexerNode.getParent();
- if (d && d.getToken() === K.COLON) {
- const _ = d.getParent();
- if (!_)
- return m.VALUE;
- d.changeToParent(h), _.setChildren([]), f.changeToParent(_);
- } else
- return m.VALUE;
- this._changeCurrentBracket(
- 1
- /* FUNCTION */
- ), this._pushNodeToChildren(this._segment), this._resetSegment(), this._currentLexerNode = f, this._newAndPushCurrentLexerNode(ht, u);
- }
- } else if (c === K.COLON && this.isSingleQuotationClose() && this.isDoubleQuotationClose() && this.isBracesClose() && this.isSquareBracketClose()) {
- const l = new ae();
- l.setToken(c);
- const f = new ae();
- f.setToken(ht), f.setParent(l);
- const h = new ae();
- h.setToken(ht), h.setParent(l), l.getChildren().push(f, h);
- let d = l, _ = 0;
- if (this._segmentCount() > 0) {
- let C, E, b = 0;
- const R = this._segment.trim(), p = R[0], N = R[1];
- if (p === Oe.MINUS && (C = new ae(), C.setToken(Oe.MINUS), b++), (p === Oe.AT || N === Oe.AT) && (E = new ae(), E.setToken(Oe.AT), C && (C.addChildren(E), E.setParent(C)), b++), b > 0 && (this._segment = R.slice(b)), _ = b, E)
- if (E.addChildren(l), l.setParent(E), E.getParent()) {
- const w = E.getParent();
- w && (d = w);
- } else
- d = E;
- else C && (d = C, C.addChildren(l), l.setParent(C));
- const M = new ae();
- M.setToken(this._segment), M.setParent(f), f.getChildren().push(M), this._resetSegment();
- } else {
- const C = this._getLastChildCurrentLexerNode();
- C && C.changeToParent(f);
- }
- this._setCurrentLexerNode(d), this._currentLexerNode = h, this._openColon(_);
- } else if (rs.has(c) && this._checkSimilarErrorToken(c, u, s) && this.isSingleQuotationClose() && this.isDoubleQuotationClose() && this.isSquareBracketClose() && this.isBracesClose()) {
- this._pushNodeToChildren(this._segment);
- const l = new ae();
- l.setToken(c);
- const f = this._getLastChildCurrent();
- f instanceof ae ? f.changeToParent(l) : f !== !1 && (l.getChildren().push(f), this._removeLastChild()), this._pushNodeToChildren(l), l.setParent(this._currentLexerNode), this._resetSegment();
- } else if (Dt.has(c) && this.isSingleQuotationClose() && this.isDoubleQuotationClose() && this.isSquareBracketClose() && this.isBracesClose()) {
- let l = this._segment.trim();
- if (c === X.MINUS && l === "") {
- const f = this._findPreviousToken(s, u - 1) || "", h = this._findNextToken(s, u + 1) || "";
- if (this._unexpectedEndingTokenExcludeOperator(f) && this._isOperatorToken(h)) {
- this._pushNodeToChildren("0"), this._pushNodeToChildren(X.MINUS), this._addSequenceArray(t, c, u), this._resetSegment(), u++;
- continue;
- } else if (this._unexpectedEndingToken(f))
- if (h === X.PLUS) {
- this._pushSegment(X.MINUS), this._addSequenceArray(t, c, u), this._addSequenceArray(t, X.PLUS, u + 1), u += 2;
- continue;
- } else {
- this._pushSegment(X.MINUS), this._addSequenceArray(t, c, u), u++;
- continue;
- }
- } else if (this._segment.length > 0 && this._isScientificNotation(s, u, c)) {
- this._pushSegment(c), this._addSequenceArray(t, c, u), u++;
- continue;
- } else this._segment.length > 0 && l === "" ? l = this._segment : (this._pushNodeToChildren(this._segment), l = "");
- if (c === X.LESS_THAN || c === X.GREATER_THAN) {
- const f = s[u + 1];
- if (f && Dt.has(c + f)) {
- this._pushNodeToChildren(l + c + f), this._resetSegment(), this._addSequenceArray(t, c, u), u++, this._addSequenceArray(t, f, u), u++;
- continue;
- } else
- this._pushNodeToChildren(l + c);
- } else
- this._pushNodeToChildren(l + c);
- this._resetSegment();
- } else
- this._pushSegment(c);
- this._addSequenceArray(t, c, u), u++;
- }
- if (this._pushNodeToChildren(this._segment), this._checkErrorState())
- return m.VALUE;
- }
- _isScientificNotation(e, t, r) {
- const n = e[t - 2];
- if (n && Number.isNaN(Number(n)) || !(r === X.MINUS || r === X.PLUS))
- return !1;
- const s = e[t + 1];
- if (s && Number.isNaN(Number(s)))
- return !1;
- const o = e[t - 1];
- return o && o.toUpperCase() === "E";
- }
- _addSequenceArray(e, t, r) {
- e == null || e.push({
- segment: this._segment,
- currentString: t,
- cur: r,
- currentLexerNode: this._currentLexerNode
- });
- }
- }
- function Fc(i, a, e, t, r, n, s) {
- const o = (s == null ? void 0 : s.f) || "", u = (s == null ? void 0 : s.si) || "", c = bt(o), l = Lt(u), f = i.getValue(r, n), h = (f == null ? void 0 : f.f) || "", d = (f == null ? void 0 : f.si) || "";
- function _() {
- var C;
- if (bt(h) && Lt(d)) {
- const E = (C = e == null ? void 0 : e[d]) == null ? void 0 : C.f;
- E ? t.set(d, E) : t.set(d, h);
- }
- }
- c && l ? (d !== u && _(), i.setValue(r, n, {
- f: o,
- si: u
- }), e[u] = { f: o, r, c: n }, a.setValue(r, n, {
- f: o,
- si: u
- })) : c && !l ? (h !== o && _(), i.setValue(r, n, {
- f: o
- }), a.setValue(r, n, {
- f: o
- })) : !c && l ? (d !== u && _(), i.setValue(r, n, {
- f: "",
- si: u
- })) : !c && !l && i.getValue(r, n) && (_(), i.realDeleteValue(r, n), a.setValue(r, n, null));
- }
- function kc(i, a, e, t) {
- const r = i == null ? void 0 : i.getValue(e, t);
- if (r == null)
- return !0;
- const n = [];
- i.forValue((l, f, h) => {
- l === e && f === t || Ha.intersects(h, r) && n.push(h);
- });
- const { startRow: s, startColumn: o, endRow: u, endColumn: c } = r;
- for (let l = s; l <= u; l++)
- for (let f = o; f <= c; f++) {
- let h = !1;
- const d = ku(l, f);
- n.some((_) => Ha.contains(_, d) ? (h = !0, !0) : !1), h || a.realDeleteValue(l, f);
- }
- }
- var $c = Object.defineProperty, Yc = Object.getOwnPropertyDescriptor, Hc = (i, a, e, t) => {
- for (var r = t > 1 ? void 0 : t ? Yc(a, e) : a, n = i.length - 1, s; n >= 0; n--)
- (s = i[n]) && (r = (t ? s(a, e, r) : s(r)) || r);
- return t && r && $c(a, e, r), r;
- }, ni = (i, a) => (e, t) => a(e, t, i);
- let Pr = class extends Me {
- constructor(a, e) {
- super();
- A(this, "_arrayFormulaRange", {});
- A(this, "_arrayFormulaCellData", {});
- this._univerInstanceService = a, this._lexerTreeBuilder = e;
- }
- dispose() {
- super.dispose(), this._arrayFormulaRange = {}, this._arrayFormulaCellData = {};
- }
- clearPreviousArrayFormulaCellData(a) {
- Object.keys(a).forEach((e) => {
- const t = a[e];
- if (t == null)
- return !0;
- Object.keys(t).forEach((r) => {
- var c, l, f, h;
- const n = t[r], s = (l = (c = this._arrayFormulaRange) == null ? void 0 : c[e]) == null ? void 0 : l[r];
- if (s == null)
- return !0;
- const o = new Ce(s);
- let u = new Ce();
- ((f = this._arrayFormulaCellData[e]) == null ? void 0 : f[r]) != null && (u = new Ce(
- (h = this._arrayFormulaCellData[e]) == null ? void 0 : h[r]
- )), n.forValue((d, _) => {
- const C = o.getValue(d, _);
- if (C == null)
- return !0;
- const { startRow: E, startColumn: b, endRow: R, endColumn: p } = C;
- for (let N = E; N <= R; N++)
- for (let M = b; M <= p; M++)
- u.setValue(N, M, null);
- o.realDeleteValue(d, _);
- }), this._arrayFormulaCellData[e] && (this._arrayFormulaCellData[e][r] = u.getData());
- });
- });
- }
- mergeArrayFormulaCellData(a) {
- Object.keys(a).forEach((e) => {
- const t = a[e];
- if (t == null)
- return !0;
- this._arrayFormulaRange[e] == null && (this._arrayFormulaRange[e] = {}), this._arrayFormulaCellData[e] == null && (this._arrayFormulaCellData[e] = {}), Object.keys(t).forEach((r) => {
- var u, c;
- const n = t[r], s = new Ce((u = this._arrayFormulaRange[e]) == null ? void 0 : u[r]), o = new Ce((c = this._arrayFormulaCellData[e]) == null ? void 0 : c[r]);
- n.forValue((l, f) => {
- const h = s == null ? void 0 : s.getValue(l, f);
- if (h == null)
- return !0;
- const { startRow: d, startColumn: _, endRow: C, endColumn: E } = h;
- for (let b = d; b <= C; b++)
- for (let R = _; R <= E; R++)
- o.setValue(b, R, null);
- }), n.forValue((l, f, h) => {
- o.setValue(l, f, h);
- }), this._arrayFormulaCellData[e] && (this._arrayFormulaCellData[e][r] = o.getData());
- });
- });
- }
- getFormulaData() {
- const a = {}, e = this._univerInstanceService.getAllUnitsForType(Dr.UNIVER_SHEET);
- return e.length === 0 || e.forEach((t) => {
- const r = t.getUnitId();
- a[r] = {}, t.getSheets().forEach((s) => {
- const o = s.getCellMatrix(), u = s.getSheetId();
- si(a, r, u, o);
- });
- }), a;
- }
- getSheetFormulaData(a, e) {
- const t = {}, r = this._univerInstanceService.getUnit(a);
- if (r == null)
- return {};
- t[a] = {};
- const n = r.getSheetBySheetId(e);
- if (n == null)
- return {};
- const s = n.getCellMatrix();
- return si(t, a, e, s), t[a][e];
- }
- getArrayFormulaRange() {
- return this._arrayFormulaRange;
- }
- setArrayFormulaRange(a) {
- this._arrayFormulaRange = a;
- }
- getArrayFormulaCellData() {
- return this._arrayFormulaCellData;
- }
- setArrayFormulaCellData(a) {
- this._arrayFormulaCellData = a;
- }
- mergeArrayFormulaRange(a) {
- Object.keys(a).forEach((e) => {
- const t = a[e];
- if (t == null)
- return !0;
- this._arrayFormulaRange[e] || (this._arrayFormulaRange[e] = {}), Object.keys(t).forEach((r) => {
- var o;
- const n = new Ce(t[r]), s = new Ce((o = this._arrayFormulaRange[e]) == null ? void 0 : o[r]);
- n.forValue((u, c, l) => {
- s.setValue(u, c, l);
- }), this._arrayFormulaRange[e] && (this._arrayFormulaRange[e][r] = s.getData());
- });
- });
- }
- deleteArrayFormulaRange(a, e, t, r) {
- var o;
- const n = (o = this._arrayFormulaRange[a]) == null ? void 0 : o[e];
- if (n == null)
- return;
- const s = new Ce(n);
- s.getValue(t, r) && (s.realDeleteValue(t, r), this._arrayFormulaRange[a] && (this._arrayFormulaRange[a][e] = s.getData()));
- }
- getCalculateData() {
- const a = this._univerInstanceService.getAllUnitsForType(Dr.UNIVER_SHEET), e = {}, t = {};
- for (const r of a) {
- const n = r.getUnitId(), s = r.getSheets(), o = {}, u = {};
- for (const c of s) {
- const l = c.getSheetId(), f = c.getConfig();
- o[l] = {
- cellData: new Ce(f.cellData),
- rowCount: f.rowCount,
- columnCount: f.columnCount,
- rowData: f.rowData,
- columnData: f.columnData,
- defaultRowHeight: f.defaultRowHeight,
- defaultColumnWidth: f.defaultColumnWidth
- }, u[c.getName()] = c.getSheetId();
- }
- e[n] = o, t[n] = u;
- }
- return {
- allUnitData: e,
- unitSheetNameMap: t
- };
- }
- updateFormulaData(a, e, t) {
- const r = new Ce(t), n = this._getSheetFormulaIdMap(a, e), s = /* @__PURE__ */ new Map(), o = this.getFormulaData();
- o[a] == null && (o[a] = {});
- const u = o[a];
- u[e] == null && (u[e] = {});
- const c = new Ce(u[e] || {}), l = new Ce();
- return r.forValue((f, h, d) => {
- Fc(c, l, n, s, f, h, d);
- }), c.forValue((f, h, d) => {
- const _ = (d == null ? void 0 : d.f) || "", C = (d == null ? void 0 : d.si) || "";
- if (Lt(C)) {
- const E = n == null ? void 0 : n[C], b = s.get(C);
- if (E && !bt(_)) {
- const R = E.f, p = h - E.c, N = f - E.r;
- c.setValue(f, h, { f: R, si: C, x: p, y: N }), l.setValue(f, h, { f: R, si: C, x: p, y: N });
- } else if (typeof b == "string") {
- const R = (d == null ? void 0 : d.x) || 0, p = (d == null ? void 0 : d.y) || 0, N = this._lexerTreeBuilder.moveFormulaRefOffset(b, R, p);
- s.set(C, { r: f, c: h, f: N }), c.setValue(f, h, { f: N, si: C }), l.setValue(f, h, { f: N, si: C });
- } else if (typeof b == "object") {
- const R = h - b.c, p = f - b.r;
- c.setValue(f, h, { f: b.f, si: C, x: R, y: p }), l.setValue(f, h, { f: b.f, si: C, x: R, y: p });
- }
- }
- }), l.getMatrix();
- }
- updateArrayFormulaRange(a, e, t) {
- var o;
- const r = (o = this._arrayFormulaRange[a]) == null ? void 0 : o[e];
- if (!r) return;
- const n = new Ce(r);
- new Ce(t).forValue((u, c, l) => {
- n.realDeleteValue(u, c);
- });
- }
- updateArrayFormulaCellData(a, e, t) {
- var c, l;
- const r = (c = this._arrayFormulaRange[a]) == null ? void 0 : c[e];
- if (!r) return;
- const n = new Ce(r), s = (l = this._arrayFormulaCellData[a]) == null ? void 0 : l[e];
- if (!s) return;
- const o = new Ce(s);
- new Ce(t).forValue((f, h, d) => {
- kc(n, o, f, h);
- });
- }
- getFormulaStringByCell(a, e, t, r) {
- const n = this._univerInstanceService.getUnit(r);
- if (n == null)
- return null;
- const s = n.getSheetBySheetId(t);
- if (s == null)
- return null;
- const o = s.getCellMatrix(), u = o.getValue(a, e);
- if (u == null)
- return null;
- const { f: c, si: l } = u;
- if (bt(c))
- return c;
- if (Lt(l)) {
- let f = null;
- return o.forValue((h, d, _) => {
- if (_ == null)
- return !0;
- const { f: C, si: E } = _;
- if (bt(C) && l === E)
- return f = this._lexerTreeBuilder.moveFormulaRefOffset(
- C,
- e - d,
- a - h
- ), !1;
- }), f;
- }
- return null;
- }
- /**
- * Function to get all formula ranges
- * @returns
- */
- getFormulaDirtyRanges() {
- const a = this.getFormulaData(), e = [];
- for (const t in a) {
- const r = a[t];
- if (!r) continue;
- const n = this._univerInstanceService.getUnit(t);
- if (n)
- for (const s in r) {
- const o = r[s];
- if (!o) continue;
- const u = n.getSheetBySheetId(s);
- if (!u) continue;
- const c = {};
- for (const l of Object.keys(o)) {
- const f = Number(l);
- for (const h in o[f]) {
- const d = Number(h), _ = u.getCellRaw(f, d), C = bt(_ == null ? void 0 : _.f) || Lt(_ == null ? void 0 : _.si), E = (_ == null ? void 0 : _.v) === void 0;
- if (!(C && E)) continue;
- c[d] || (c[d] = []);
- const b = c[d].slice(-1)[0];
- b && b.endRow === f - 1 ? b.endRow = f : c[d].push({ startRow: f, endRow: f });
- }
- }
- for (const l in c) {
- const f = c[l];
- for (let h = 0; h < f.length; h++) {
- const d = f[h];
- e.push({
- unitId: t,
- sheetId: s,
- range: {
- rangeType: Ze.NORMAL,
- startRow: d.startRow,
- endRow: d.endRow,
- // Use endRow as the inclusive end row
- startColumn: Number(l),
- endColumn: Number(l)
- }
- });
- }
- }
- }
- }
- return e;
- }
- _getSheetFormulaIdMap(a, e) {
- const t = {}, r = this._univerInstanceService.getUnit(a);
- if (r == null)
- return t;
- const n = r.getSheetBySheetId(e);
- return n == null || n.getCellMatrix().forValue((o, u, c) => {
- if (c == null)
- return !0;
- const { f: l, si: f } = c;
- bt(l) && Lt(f) && (t[f] = { f: l, r: o, c: u });
- }), t;
- }
- };
- Pr = Hc([
- ni(0, Js),
- ni(1, Ve(ca))
- ], Pr);
- function si(i, a, e, t) {
- i[a] || (i[a] = {}), i[a][e] || (i[a][e] = {});
- const r = /* @__PURE__ */ new Map(), n = new Ce(i[a][e]);
- t.forValue((o, u, c) => {
- const l = (c == null ? void 0 : c.f) || "", f = (c == null ? void 0 : c.si) || "", h = bt(l), d = Lt(f);
- h && d ? (n.setValue(o, u, {
- f: l,
- si: f
- }), r.set(f, { f: l, r: o, c: u })) : h && !d ? n.setValue(o, u, {
- f: l
- }) : !h && d && n.setValue(o, u, {
- f: "",
- si: f
- });
- }), n.forValue((o, u, c) => {
- const l = (c == null ? void 0 : c.f) || "", f = (c == null ? void 0 : c.si) || "";
- if (Lt(f) && !bt(l)) {
- const h = r.get(f);
- if (h) {
- const d = h.f, _ = u - h.c, C = o - h.r;
- n.setValue(o, u, { f: d, si: f, x: _, y: C });
- } else
- n.realDeleteValue(o, u);
- }
- });
- const s = n.getMatrix();
- return {
- [a]: {
- [e]: s
- }
- };
- }
- const Gc = class Ms {
- /**
- * Accept two comparable values and creates new instance of interval
- * Predicate Interval.comparable_less(low, high) supposed to return true on these values
- * @param low
- * @param high
- */
- constructor(a, e) {
- this.low = a, this.high = e;
- }
- /**
- * Clone interval
- * @returns {Interval}
- */
- clone() {
- return new Ms(this.low, this.high);
- }
- /**
- * Propery max returns clone of this interval
- * @returns {Interval}
- */
- get max() {
- return this.clone();
- }
- /**
- * Predicate returns true is this interval less than other interval
- * @param other_interval
- * @returns {boolean}
- */
- less_than(a) {
- return this.low < a.low || this.low === a.low && this.high < a.high;
- }
- /**
- * Predicate returns true is this interval equals to other interval
- * @param other_interval
- * @returns {boolean}
- */
- equal_to(a) {
- return this.low === a.low && this.high === a.high;
- }
- /**
- * Predicate returns true if this interval intersects other interval
- * @param other_interval
- * @returns {boolean}
- */
- intersect(a) {
- return !this.not_intersect(a);
- }
- /**
- * Predicate returns true if this interval does not intersect other interval
- * @param other_interval
- * @returns {boolean}
- */
- not_intersect(a) {
- return this.high < a.low || a.high < this.low;
- }
- /**
- * Returns new interval merged with other interval
- * @param {Interval} other_interval - Other interval to merge with
- * @returns {Interval}
- */
- merge(a) {
- return new Ms(
- this.low === void 0 ? a.low : this.low < a.low ? this.low : a.low,
- this.high === void 0 ? a.high : this.high > a.high ? this.high : a.high
- );
- }
- /**
- * Returns how key should return
- */
- output() {
- return [this.low, this.high];
- }
- /**
- * Function returns maximum between two comparable values
- * @param interval1
- * @param interval2
- * @returns {Interval}
- */
- static comparable_max(a, e) {
- return a.merge(e);
- }
- /**
- * Predicate returns true if first value less than second value
- * @param val1
- * @param val2
- * @returns {boolean}
- */
- static comparable_less_than(a, e) {
- return a < e;
- }
- }, je = 0, Ae = 1;
- class Ht {
- constructor(a = void 0, e = void 0, t = null, r = null, n = null, s = Ae) {
- if (this.left = t, this.right = r, this.parent = n, this.color = s, this.item = { key: a, value: e }, a && a instanceof Array && a.length === 2 && !Number.isNaN(a[0]) && !Number.isNaN(a[1])) {
- let [o, u] = a;
- o > u && ([o, u] = [u, o]), this.item.key = new Gc(o, u);
- }
- this.max = this.item.key ? this.item.key.max : void 0;
- }
- isNil() {
- return this.item.key === void 0 && this.item.value === void 0 && this.left === null && this.right === null && this.color === Ae;
- }
- _value_less_than(a) {
- return this.item.value && a.item.value && this.item.value.less_than ? this.item.value.less_than(a.item.value) : this.item.value < a.item.value;
- }
- less_than(a) {
- return this.item.value === this.item.key && a.item.value === a.item.key ? this.item.key.less_than(a.item.key) : this.item.key.less_than(a.item.key) || this.item.key.equal_to(a.item.key) && this._value_less_than(a);
- }
- _value_equal(a) {
- return this.item.value && a.item.value && this.item.value.equal_to ? this.item.value.equal_to(a.item.value) : this.item.value === a.item.value;
- }
- equal_to(a) {
- return this.item.value === this.item.key && a.item.value === a.item.key ? this.item.key.equal_to(a.item.key) : this.item.key.equal_to(a.item.key) && this._value_equal(a);
- }
- intersect(a) {
- return this.item.key.intersect(a.item.key);
- }
- copy_data(a) {
- this.item.key = a.item.key, this.item.value = a.item.value;
- }
- update_max() {
- if (this.max = this.item.key ? this.item.key.max : void 0, this.right && this.right.max) {
- const a = this.item.key.constructor.comparable_max;
- this.max = a(this.max, this.right.max);
- }
- if (this.left && this.left.max) {
- const a = this.item.key.constructor.comparable_max;
- this.max = a(this.max, this.left.max);
- }
- }
- // Other_node does not intersect any node of left subtree, if this.left.max < other_node.item.key.low
- not_intersect_left_subtree(a) {
- const e = this.item.key.constructor.comparable_less_than;
- let t = this.left.max.high !== void 0 ? this.left.max.high : this.left.max;
- return e(t, a.item.key.low);
- }
- // Other_node does not intersect right subtree if other_node.item.key.high < this.right.key.low
- not_intersect_right_subtree(a) {
- const e = this.item.key.constructor.comparable_less_than;
- let t = this.right.max.low !== void 0 ? this.right.max.low : this.right.item.key.low;
- return e(a.item.key.high, t);
- }
- }
- class la {
- /**
- * Construct new empty instance of IntervalTree
- */
- constructor() {
- this.root = null, this.nil_node = new Ht();
- }
- /**
- * Returns number of items stored in the interval tree
- * @returns {number}
- */
- get size() {
- let a = 0;
- return this.tree_walk(this.root, () => a++), a;
- }
- /**
- * Returns array of sorted keys in the ascending order
- * @returns {Array}
- */
- get keys() {
- let a = [];
- return this.tree_walk(this.root, (e) => a.push(
- e.item.key.output ? e.item.key.output() : e.item.key
- )), a;
- }
- /**
- * Return array of values in the ascending keys order
- * @returns {Array}
- */
- get values() {
- let a = [];
- return this.tree_walk(this.root, (e) => a.push(e.item.value)), a;
- }
- /**
- * Returns array of items (<key,value> pairs) in the ascended keys order
- * @returns {Array}
- */
- get items() {
- let a = [];
- return this.tree_walk(this.root, (e) => a.push({
- key: e.item.key.output ? e.item.key.output() : e.item.key,
- value: e.item.value
- })), a;
- }
- /**
- * Returns true if tree is empty
- * @returns {boolean}
- */
- isEmpty() {
- return this.root == null || this.root === this.nil_node;
- }
- /**
- * Clear tree
- */
- clear() {
- this.root = null;
- }
- /**
- * Insert new item into interval tree
- * @param {Interval} key - interval object or array of two numbers [low, high]
- * @param {any} value - value representing any object (optional)
- * @returns {Node} returns reference to inserted node as an object {key:interval, value: value}
- */
- insert(a, e = a) {
- if (a === void 0) return;
- let t = new Ht(a, e, this.nil_node, this.nil_node, null, je);
- return this.tree_insert(t), this.recalc_max(t), t;
- }
- /**
- * Returns true if item {key,value} exist in the tree
- * @param {Interval} key - interval correspondent to keys stored in the tree
- * @param {any} value - value object to be checked
- * @returns {boolean} true if item {key, value} exist in the tree, false otherwise
- */
- exist(a, e = a) {
- let t = new Ht(a, e);
- return !!this.tree_search(this.root, t);
- }
- /**
- * Remove entry {key, value} from the tree
- * @param {Interval} key - interval correspondent to keys stored in the tree
- * @param {any} value - value object
- * @returns {boolean} true if item {key, value} deleted, false if not found
- */
- remove(a, e = a) {
- let t = new Ht(a, e), r = this.tree_search(this.root, t);
- return r && this.tree_delete(r), r;
- }
- /**
- * Returns array of entry values which keys intersect with given interval <br/>
- * If no values stored in the tree, returns array of keys which intersect given interval
- * @param {Interval} interval - search interval, or tuple [low, high]
- * @param outputMapperFn(value,key) - optional function that maps (value, key) to custom output
- * @returns {Array}
- */
- search(a, e = (t, r) => t === r ? r.output() : t) {
- let t = new Ht(a), r = [];
- return this.tree_search_interval(this.root, t, r), r.map((n) => e(n.item.value, n.item.key));
- }
- /**
- * Returns true if intersection between given and any interval stored in the tree found
- * @param {Interval} interval - search interval or tuple [low, high]
- * @returns {boolean}
- */
- intersect_any(a) {
- let e = new Ht(a);
- return this.tree_find_any_interval(this.root, e);
- }
- /**
- * Tree visitor. For each node implement a callback function. <br/>
- * Method calls a callback function with two parameters (key, value)
- * @param visitor(key,value) - function to be called for each tree item
- */
- forEach(a) {
- this.tree_walk(this.root, (e) => a(e.item.key, e.item.value));
- }
- /**
- * Value Mapper. Walk through every node and map node value to another value
- * @param callback(value,key) - function to be called for each tree item
- */
- map(a) {
- const e = new la();
- return this.tree_walk(this.root, (t) => e.insert(t.item.key, a(t.item.value, t.item.key))), e;
- }
- /**
- * @param {Interval} interval - optional if the iterator is intended to start from the beginning
- * @param outputMapperFn(value,key) - optional function that maps (value, key) to custom output
- * @returns {Iterator}
- */
- *iterate(a, e = (t, r) => t === r ? r.output() : t) {
- let t;
- for (a ? t = this.tree_search_nearest_forward(this.root, new Ht(a)) : this.root && (t = this.local_minimum(this.root)); t; )
- yield e(t.item.value, t.item.key), t = this.tree_successor(t);
- }
- recalc_max(a) {
- let e = a;
- for (; e.parent != null; )
- e.parent.update_max(), e = e.parent;
- }
- tree_insert(a) {
- let e = this.root, t = null;
- if (this.root == null || this.root === this.nil_node)
- this.root = a;
- else {
- for (; e !== this.nil_node; )
- t = e, a.less_than(e) ? e = e.left : e = e.right;
- a.parent = t, a.less_than(t) ? t.left = a : t.right = a;
- }
- this.insert_fixup(a);
- }
- // After insertion insert_node may have red-colored parent, and this is a single possible violation
- // Go upwords to the root and re-color until violation will be resolved
- insert_fixup(a) {
- let e, t;
- for (e = a; e !== this.root && e.parent.color === je; )
- 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)));
- this.root.color = Ae;
- }
- tree_delete(a) {
- let e, t;
- a.left === this.nil_node || a.right === this.nil_node ? e = a : e = this.tree_successor(a), 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 !== a && (a.copy_data(e), a.update_max(), this.recalc_max(a)), /*fix_node != this.nil_node && */
- e.color === Ae && this.delete_fixup(t);
- }
- delete_fixup(a) {
- let e = a, t;
- for (; e !== this.root && e.parent != null && e.color === Ae; )
- 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));
- e.color = Ae;
- }
- tree_search(a, e) {
- if (!(a == null || a === this.nil_node))
- return e.equal_to(a) ? a : e.less_than(a) ? this.tree_search(a.left, e) : this.tree_search(a.right, e);
- }
- tree_search_nearest_forward(a, e) {
- let t, r = a;
- for (; r && r !== this.nil_node; )
- 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);
- return t || null;
- }
- // Original search_interval method; container res support push() insertion
- // Search all intervals intersecting given one
- tree_search_interval(a, e, t) {
- a != null && a !== this.nil_node && (a.left !== this.nil_node && !a.not_intersect_left_subtree(e) && this.tree_search_interval(a.left, e, t), a.intersect(e) && t.push(a), a.right !== this.nil_node && !a.not_intersect_right_subtree(e) && this.tree_search_interval(a.right, e, t));
- }
- tree_find_any_interval(a, e) {
- let t = !1;
- return a != null && a !== this.nil_node && (a.left !== this.nil_node && !a.not_intersect_left_subtree(e) && (t = this.tree_find_any_interval(a.left, e)), t || (t = a.intersect(e)), !t && a.right !== this.nil_node && !a.not_intersect_right_subtree(e) && (t = this.tree_find_any_interval(a.right, e))), t;
- }
- local_minimum(a) {
- let e = a;
- for (; e.left != null && e.left !== this.nil_node; )
- e = e.left;
- return e;
- }
- // not in use
- local_maximum(a) {
- let e = a;
- for (; e.right != null && e.right !== this.nil_node; )
- e = e.right;
- return e;
- }
- tree_successor(a) {
- let e, t, r;
- if (a.right !== this.nil_node)
- e = this.local_minimum(a.right);
- else {
- for (t = a, r = a.parent; r != null && r.right === t; )
- t = r, r = r.parent;
- e = r;
- }
- return e;
- }
- // | right-rotate(T,y) |
- // y ---------------. x
- // / \ / \
- // x c left-rotate(T,x) a y
- // / \ <--------------- / \
- // a b b c
- rotate_left(a) {
- let e = a.right;
- a.right = e.left, e.left !== this.nil_node && (e.left.parent = a), e.parent = a.parent, a === this.root ? this.root = e : a === a.parent.left ? a.parent.left = e : a.parent.right = e, e.left = a, a.parent = e, a != null && a !== this.nil_node && a.update_max(), e = a.parent, e != null && e !== this.nil_node && e.update_max();
- }
- rotate_right(a) {
- let e = a.left;
- a.left = e.right, e.right !== this.nil_node && (e.right.parent = a), e.parent = a.parent, a === this.root ? this.root = e : a === a.parent.left ? a.parent.left = e : a.parent.right = e, e.right = a, a.parent = e, a !== null && a !== this.nil_node && a.update_max(), e = a.parent, e != null && e !== this.nil_node && e.update_max();
- }
- tree_walk(a, e) {
- a != null && a !== this.nil_node && (this.tree_walk(a.left, e), e(a), this.tree_walk(a.right, e));
- }
- /* Return true if all red nodes have exactly two black child nodes */
- testRedBlackProperty() {
- let a = !0;
- return this.tree_walk(this.root, function(e) {
- e.color === je && (e.left.color === Ae && e.right.color === Ae || (a = !1));
- }), a;
- }
- /* Throw error if not every path from root to bottom has same black height */
- testBlackHeightProperty(a) {
- let e = 0, t = 0, r = 0;
- if (a.color === Ae && e++, a.left !== this.nil_node ? t = this.testBlackHeightProperty(a.left) : t = 1, a.right !== this.nil_node ? r = this.testBlackHeightProperty(a.right) : r = 1, t !== r)
- throw new Error("Red-black height property violated");
- return e += t, e;
- }
- }
- class Qc {
- constructor() {
- /**
- * {
- * unitId:{
- * sheetId:{
- * 'columnIndex': {
- * 10:[1,3,4,5],
- * 5:[2,6,11,22]
- * }
- * }
- * }
- * }
- */
- A(this, "_cache", /* @__PURE__ */ new Map());
- A(this, "_continueBuildingCache", /* @__PURE__ */ new Map());
- }
- set(a, e, t, r, n) {
- if (!this.shouldContinueBuildingCache(a, e, t, n))
- return;
- let s = this._cache.get(a);
- s == null && (s = /* @__PURE__ */ new Map(), this._cache.set(a, s));
- let o = s.get(e);
- o == null && (o = /* @__PURE__ */ new Map(), s.set(e, o));
- let u = o.get(t);
- u == null && (u = /* @__PURE__ */ new Map(), o.set(t, u));
- let c = u.get(r);
- c == null && (c = /* @__PURE__ */ new Set(), u.set(r, c)), c.add(n);
- }
- getCellValuePositions(a, e, t) {
- var r, n;
- return (n = (r = this._cache.get(a)) == null ? void 0 : r.get(e)) == null ? void 0 : n.get(t);
- }
- getCellPositions(a, e, t, r, n) {
- var o, u, c;
- const s = (c = (u = (o = this._cache.get(a)) == null ? void 0 : o.get(e)) == null ? void 0 : u.get(t)) == null ? void 0 : c.get(r);
- return s && [...s].filter((l) => n.some(([f, h]) => l >= f && l <= h));
- }
- setContinueBuildingCache(a, e, t, r, n) {
- if (t === -1 || r === -1 || n === -1)
- return;
- let s = this._continueBuildingCache.get(a);
- s == null && (s = /* @__PURE__ */ new Map(), this._continueBuildingCache.set(a, s));
- let o = s.get(e);
- o == null && (o = /* @__PURE__ */ new Map(), s.set(e, o));
- let u = o.get(t);
- if (u == null) {
- u = new la(), u.insert([r, n]), o.set(t, u);
- return;
- }
- this._handleNewInterval(u, r, n);
- }
- shouldContinueBuildingCache(a, e, t, r) {
- var o, u;
- if (t === -1 || r === -1)
- return !1;
- const n = (u = (o = this._continueBuildingCache.get(a)) == null ? void 0 : o.get(e)) == null ? void 0 : u.get(t);
- return n ? n.search([r, r]).length === 0 : !0;
- }
- canUseCache(a, e, t, r, n) {
- var f, h;
- const s = (h = (f = this._continueBuildingCache.get(a)) == null ? void 0 : f.get(e)) == null ? void 0 : h.get(t);
- if (t === -1 || r === -1 || n === -1 || !s)
- return {
- rowsInCache: [],
- rowsNotInCache: []
- };
- const o = s.search([r, n]);
- if (o.length === 0)
- return {
- rowsInCache: [],
- rowsNotInCache: []
- };
- o.sort((d, _) => d[0] - _[0]);
- const u = [], c = [];
- let l = r;
- for (let d = 0; d < o.length; d++) {
- const [_, C] = o[d];
- if (l >= _) {
- if (n <= C) {
- u.push([l, n]);
- break;
- }
- u.push([l, C]), l = C + 1, d === o.length - 1 && l <= n && c.push([l, n]);
- } else {
- if (n > C) {
- u.push([_, C]), c.push([l, _ - 1]), l = C + 1, d === o.length - 1 && l <= n && c.push([l, n]);
- continue;
- }
- u.push([_, n]), c.push([l, _ - 1]);
- }
- }
- return {
- rowsInCache: u,
- rowsNotInCache: c
- };
- }
- clear() {
- this._cache.clear(), this._continueBuildingCache.clear();
- }
- _handleNewInterval(a, e, t) {
- let r = a.search([e, t]);
- if (r.length === 0) {
- const o = [e - 1 < 0 ? 0 : e - 1, t + 1];
- if (r = a.search(o), r.length === 0) {
- a.insert([e, t]);
- return;
- }
- }
- let n = e, s = t;
- for (const o of r)
- n = Math.min(n, o[0]), s = Math.max(s, o[1]), a.remove(o);
- a.insert([n, s]);
- }
- }
- const St = new Qc(), fa = "engine-formula.config", so = 1, Hb = "CYCLE_REFERENCE_COUNT", ai = {};
- var Wc = Object.defineProperty, qc = Object.getOwnPropertyDescriptor, Kc = (i, a, e, t) => {
- for (var r = t > 1 ? void 0 : t ? qc(a, e) : a, n = i.length - 1, s; n >= 0; n--)
- (s = i[n]) && (r = (t ? s(a, e, r) : s(r)) || r);
- return t && r && Wc(a, e, r), r;
- }, ii = (i, a) => (e, t) => a(e, t, i);
- let ws = class extends Me {
- constructor(a, e) {
- super();
- A(this, "_unitData", {});
- A(this, "_unitStylesData", {});
- A(this, "_arrayFormulaCellData", {});
- A(this, "_arrayFormulaRange", {});
- A(this, "_formulaData", {});
- A(this, "_sheetNameMap", {});
- A(this, "_forceCalculate", !1);
- A(this, "_clearDependencyTreeCache", {});
- A(this, "_dirtyRanges", []);
- A(this, "_dirtyNameMap", {});
- A(this, "_dirtyDefinedNameMap", {});
- A(this, "_dirtyUnitFeatureMap", {});
- A(this, "_dirtyUnitOtherFormulaMap", {});
- A(this, "_excludedCell");
- A(this, "_sheetIdToNameMap", {});
- A(this, "_executeUnitId", "");
- A(this, "_executeSubUnitId", "");
- this._univerInstanceService = a, this._localeService = e;
- }
- dispose() {
- 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 = {};
- }
- getExecuteUnitId() {
- return this._executeUnitId;
- }
- getExecuteSubUnitId() {
- return this._executeSubUnitId;
- }
- setExecuteUnitId(a) {
- this._executeUnitId = a;
- }
- setExecuteSubUnitId(a) {
- this._executeSubUnitId = a;
- }
- getExcludedRange() {
- return this._excludedCell;
- }
- getUnitData() {
- return this._unitData;
- }
- getUnitStylesData() {
- return this._unitStylesData;
- }
- getFormulaData() {
- return this._formulaData;
- }
- getArrayFormulaCellData() {
- return this._arrayFormulaCellData;
- }
- getArrayFormulaRange() {
- return this._arrayFormulaRange;
- }
- getSheetNameMap() {
- return this._sheetNameMap;
- }
- isForceCalculate() {
- return this._forceCalculate;
- }
- getDirtyRanges() {
- return this._dirtyRanges;
- }
- getDirtyNameMap() {
- return this._dirtyNameMap;
- }
- getDirtyDefinedNameMap() {
- return this._dirtyDefinedNameMap;
- }
- getDirtyUnitFeatureMap() {
- return this._dirtyUnitFeatureMap;
- }
- getDirtyUnitOtherFormulaMap() {
- return this._dirtyUnitOtherFormulaMap;
- }
- getSheetName(a, e) {
- return this._sheetIdToNameMap[a] == null ? "" : this._sheetIdToNameMap[a][e] || "";
- }
- getClearDependencyTreeCache() {
- return this._clearDependencyTreeCache;
- }
- getLocale() {
- return this._localeService.getCurrentLocale();
- }
- getSheetsInfo() {
- const a = this._univerInstanceService.getCurrentUnitForType(Dr.UNIVER_SHEET), { id: e, sheetOrder: t } = a.getSnapshot();
- return {
- sheetOrder: t,
- sheetNameMap: this._sheetIdToNameMap[e]
- };
- }
- getSheetRowColumnCount(a, e) {
- const t = this._univerInstanceService.getUnit(a), r = t == null ? void 0 : t.getSheetBySheetId(e), n = r == null ? void 0 : r.getSnapshot();
- if (!n)
- return { rowCount: 0, columnCount: 0 };
- const { rowCount: s, columnCount: o } = n;
- return { rowCount: s, columnCount: o };
- }
- load(a) {
- if (a.allUnitData && a.unitSheetNameMap && a.unitStylesData)
- this._unitData = a.allUnitData, this._unitStylesData = a.unitStylesData, this._sheetNameMap = a.unitSheetNameMap;
- else {
- const { allUnitData: e, unitSheetNameMap: t, unitStylesData: r } = this._loadSheetData();
- this._unitData = e, this._unitStylesData = r, this._sheetNameMap = t;
- }
- this._formulaData = a.formulaData, this._arrayFormulaCellData = oc(a.arrayFormulaCellData), this._arrayFormulaRange = a.arrayFormulaRange, this._forceCalculate = a.forceCalculate, this._clearDependencyTreeCache = a.clearDependencyTreeCache || {}, this._dirtyRanges = a.dirtyRanges, this._dirtyNameMap = a.dirtyNameMap, this._dirtyDefinedNameMap = a.dirtyDefinedNameMap, this._dirtyUnitFeatureMap = a.dirtyUnitFeatureMap, this._dirtyUnitOtherFormulaMap = a.dirtyUnitOtherFormulaMap, this._excludedCell = a.excludedCell, this._mergeNameMap(this._sheetNameMap, this._dirtyNameMap);
- }
- getDirtyData() {
- return {
- forceCalculation: this._forceCalculate,
- dirtyRanges: this._dirtyRanges,
- dirtyNameMap: this._dirtyNameMap,
- dirtyDefinedNameMap: this._dirtyDefinedNameMap,
- dirtyUnitFeatureMap: this._dirtyUnitFeatureMap,
- dirtyUnitOtherFormulaMap: this._dirtyUnitOtherFormulaMap,
- clearDependencyTreeCache: this._clearDependencyTreeCache
- };
- }
- loadDirtyRangesAndExcludedCell(a, e) {
- this._dirtyRanges = a, this._excludedCell = e, this._dirtyNameMap = {};
- }
- registerUnitData(a) {
- this._unitData = a;
- }
- registerFormulaData(a) {
- this._formulaData = a;
- }
- registerSheetNameMap(a) {
- this._sheetNameMap = a;
- }
- // private _loadOtherFormulaData() {
- // const unitAllDoc = this._univerInstanceService.getAllUniverDocsInstance();
- // const unitAllSlide = this._univerInstanceService.getAllUniverSlidesInstance();
- // const otherFormulaData: IOtherFormulaData = {};
- // for (const documentDataModel of unitAllDoc) {
- // const unitId = documentDataModel.getUnitId();
- // if (otherFormulaData[unitId] == null) {
- // otherFormulaData[unitId] = {};
- // }
- // if (otherFormulaData[unitId][DEFAULT_DOCUMENT_SUB_COMPONENT_ID] == null) {
- // otherFormulaData[unitId][DEFAULT_DOCUMENT_SUB_COMPONENT_ID] = {};
- // }
- // const subComponent = otherFormulaData[unitId][DEFAULT_DOCUMENT_SUB_COMPONENT_ID];
- // const customRanges = documentDataModel.getBody()?.customRanges;
- // if (customRanges == null) {
- // continue;
- // }
- // for (const customRange of customRanges) {
- // subComponent[customRange.rangeId] = {
- // f: customRange.endIndex.toString(),
- // };
- // }
- // }
- // for (const slide of unitAllSlide) {
- // const unitId = slide.getUnitId();
- // if (otherFormulaData[unitId] == null) {
- // otherFormulaData[unitId] = {};
- // }
- // if (otherFormulaData[unitId][DEFAULT_DOCUMENT_SUB_COMPONENT_ID] == null) {
- // otherFormulaData[unitId][DEFAULT_DOCUMENT_SUB_COMPONENT_ID] = {};
- // }
- // const pages = slide.getPages();
- // if (pages == null) {
- // continue;
- // }
- // const pageIds = Object.keys(pages);
- // for (const pageId of pageIds) {
- // const page = pages[pageId];
- // const subComponent = otherFormulaData[unitId][pageId];
- // const pageElements = page.pageElements;
- // if (pageElements == null) {
- // continue;
- // }
- // const pageElementIds = Object.keys(pageElements);
- // for (const pageElementId of pageElementIds) {
- // const pageElement = pageElements[pageElementId];
- // subComponent[pageElementId] = {
- // f: pageElement.title,
- // };
- // }
- // }
- // }
- // return otherFormulaData;
- // }
- _mergeNameMap(a, e) {
- Object.keys(e).forEach((t) => {
- e[t] && Object.keys(e[t]).forEach((r) => {
- a[t] == null && (a[t] = {}), a[t][e[t][r]] = r;
- });
- }), this._sheetIdToNameMap = {}, Object.keys(a).forEach((t) => {
- Object.keys(a[t]).forEach((r) => {
- this._sheetIdToNameMap[t] == null && (this._sheetIdToNameMap[t] = {}), this._sheetIdToNameMap[t][a[t][r]] = r;
- });
- });
- }
- _loadSheetData() {
- const a = this._univerInstanceService.getAllUnitsForType(Dr.UNIVER_SHEET), e = this._univerInstanceService.getCurrentUnitForType(Dr.UNIVER_SHEET), t = e == null ? void 0 : e.getActiveSheet();
- this._executeUnitId = e == null ? void 0 : e.getUnitId(), this._executeSubUnitId = t == null ? void 0 : t.getSheetId();
- const r = {}, n = {}, s = {};
- for (const o of a) {
- const u = o.getUnitId(), c = o.getSheets(), l = {}, f = {};
- for (const h of c) {
- const d = h.getSheetId(), _ = h.getConfig();
- l[d] = {
- cellData: new Ce(_.cellData),
- rowCount: _.rowCount,
- columnCount: _.columnCount,
- rowData: _.rowData,
- columnData: _.columnData,
- defaultRowHeight: _.defaultRowHeight,
- defaultColumnWidth: _.defaultColumnWidth
- }, f[h.getName()] = h.getSheetId();
- }
- r[u] = l, n[u] = o.getStyles(), s[u] = f;
- }
- return {
- allUnitData: r,
- unitStylesData: n,
- unitSheetNameMap: s
- };
- }
- };
- ws = Kc([
- ii(0, Js),
- ii(1, Ve($u))
- ], ws);
- const Ft = lt(
- "univer.formula.current-data.service"
- );
- var Xc = Object.defineProperty, Zc = Object.getOwnPropertyDescriptor, zc = (i, a, e, t) => {
- for (var r = t > 1 ? void 0 : t ? Zc(a, e) : a, n = i.length - 1, s; n >= 0; n--)
- (s = i[n]) && (r = (t ? s(a, e, r) : s(r)) || r);
- return t && r && Xc(a, e, r), r;
- }, is = (i, a) => (e, t) => a(e, t, i);
- let gr = class extends Me {
- constructor(i, a, e) {
- super(), this._definedNamesService = i, this._lexerTreeBuilder = a, this._formulaCurrentConfigService = e;
- }
- treeBuilder(i, a = !0) {
- return this._lexerTreeBuilder.treeBuilder(i, a, this._injectDefinedName.bind(this), this._simpleCheckDefinedName.bind(this));
- }
- _simpleCheckDefinedName(i) {
- const a = this._formulaCurrentConfigService.getDirtyDefinedNameMap(), e = this._formulaCurrentConfigService.getExecuteUnitId();
- if (e != null && a[e] != null) {
- const t = Object.keys(a[e]);
- for (let r = 0, n = t.length; r < n; r++) {
- const s = t[r];
- if (i.indexOf(s) > -1)
- return !0;
- }
- }
- return !1;
- }
- _checkDefinedNameDirty(i) {
- const a = this._formulaCurrentConfigService.getDirtyDefinedNameMap(), e = this._formulaCurrentConfigService.getExecuteUnitId();
- if (e != null && a[e] != null) {
- const t = Object.keys(a[e]);
- for (let r = 0, n = t.length; r < n; r++)
- if (t[r] === i)
- return !0;
- }
- return !1;
- }
- _injectDefinedName(i) {
- const a = this._formulaCurrentConfigService.getExecuteUnitId();
- if (a == null)
- return {
- sequenceString: "",
- hasDefinedName: !1,
- definedNames: []
- };
- const e = this._lexerTreeBuilder.getSequenceNode(i);
- let t = "", r = !1;
- const n = [];
- for (let s = 0, o = e.length; s < o; s++) {
- const u = e[s];
- if (typeof u == "string") {
- t += u;
- continue;
- }
- const { nodeType: c, token: l } = u;
- if (c === $e.REFERENCE || c === $e.FUNCTION) {
- const f = this._definedNamesService.getValueByName(a, l);
- if (f) {
- let h = f.formulaOrRefString;
- h.substring(0, 1) === X.EQUALS && (h = h.substring(1)), t += h, n.push(f.name), r = !0;
- } else this._checkDefinedNameDirty(l) ? (t += m.NAME, r = !0, n.push(l)) : t += l;
- } else
- t += l;
- }
- return {
- sequenceString: t,
- hasDefinedName: r,
- definedNames: n
- };
- }
- };
- gr = zc([
- is(0, pr),
- is(1, Ve(ca)),
- is(2, Ft)
- ], gr);
- function nn(i) {
- if (i == null)
- return !0;
- const { v: a, f: e, si: t, p: r } = i;
- return !(!(a == null || typeof a == "string" && a.length === 0) || e != null && e.length > 0 || t != null && t.length > 0 || r != null);
- }
- function ao(i, a, e, t, r) {
- var s;
- const n = Object.keys(r);
- for (const o of n) {
- const u = r[o], c = (s = u == null ? void 0 : u[t]) == null ? void 0 : s[e];
- if (c == null)
- continue;
- const l = c.getValue(i, a);
- if (l != null)
- return l;
- }
- }
- const Jc = [
- "$",
- "£",
- "¥",
- "¤",
- "֏",
- "؋",
- "৳",
- "฿",
- "៛",
- "₡",
- "₦",
- "₩",
- "₪",
- "₫",
- "€",
- "₭",
- "₮",
- "₱",
- "₲",
- "₴",
- "₸",
- "₹",
- "₺",
- "₼",
- "₽",
- "₾",
- "₿"
- ], el = {
- currency: 2,
- date: 4,
- datetime: 5,
- error: 11,
- fraction: 7,
- general: 0,
- grouped: 11,
- number: 1,
- percent: 6,
- scientific: 8,
- text: 9,
- time: 5,
- unknown: 11
- /* Custom */
- };
- function Gb(i, a, e) {
- var u, c;
- if (i == null || a == null)
- return a;
- const t = (e == null ? void 0 : e.getStyleByCell(i)) || i.s, r = (e == null ? void 0 : e.getStyleByCell(a)) || a.s;
- if (t == null || r == null || typeof t != "object" || typeof r != "object")
- return a;
- 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;
- if (n == null || s == null)
- return a;
- const o = n || s;
- return r.n.pattern = o, a;
- }
- const Ds = new Vt(1e5);
- function oi(i) {
- const a = Ds.get(i);
- if (a !== void 0)
- return a;
- const e = rl(i);
- return Ds.set(i, e), e;
- }
- function tl() {
- Ds.clear();
- }
- function rl(i) {
- if (nl(i))
- return 3;
- const a = gt.getInfo(i).type || "unknown";
- return el[a];
- }
- function nl(i) {
- return !!Jc.find((a) => i.includes(a)) && i.startsWith("_(");
- }
- function Wr(i, a, e) {
- if (i === "")
- return a;
- if (a === "")
- return i;
- const t = oi(i), r = oi(a);
- return e === X.PLUS || e === X.MINUS ? t === 4 && r === 4 || t === 11 && r === 11 ? "" : a : e === X.MULTIPLY || e === X.DIVIDED ? t === 6 && r === 6 || t === 7 && r === 7 || t === 8 && r === 8 || t === 9 && r === 9 ? a : "" : i || a;
- }
- const sl = /* @__PURE__ */ new Map([
- [Mr.EN_US, "$"],
- // [LocaleType.JA_JP, '¥'],
- [Mr.RU_RU, "₽"],
- [Mr.VI_VN, "₫"],
- [Mr.ZH_CN, "¥"],
- [Mr.ZH_TW, "NT$"]
- ]);
- function ui(i) {
- return sl.get(i) || "$";
- }
- function Ke(i, a = 2) {
- let e = a;
- a > 127 && (e = 127);
- let t = "";
- return e > 0 && (t = `.${"0".repeat(e)}`), `"${ui(i)}"#,##0${t}_);[Red]("${ui(i)}"#,##0${t})`;
- }
- function al(i, a, e = 2) {
- return gt.format(Ke(i, e), a);
- }
- const ha = new Vt(1e5);
- function il(i) {
- let a = i;
- a.startsWith('"') && a.endsWith('"') && (a = a.slice(1, -1));
- const e = ha.get(a);
- if (e)
- return {
- isNumberPattern: !0,
- value: e.value,
- pattern: e.pattern
- };
- const t = gt.parseNumber(a);
- if (t && t.z)
- return os(a, t.v, t.z);
- const r = gt.parseDate(a);
- if (r && r.z)
- return os(a, r.v, r.z);
- const n = gt.parseTime(a);
- return n && n.z ? os(a, n.v, n.z) : {
- isNumberPattern: !1
- };
- }
- function os(i, a, e) {
- return ha.set(i, {
- value: a,
- pattern: e
- }), {
- isNumberPattern: !0,
- value: a,
- pattern: e
- };
- }
- function ol() {
- ha.clear();
- }
- class jn {
- constructor() {
- A(this, "pattern", "");
- }
- dispose() {
- }
- getPattern() {
- return this.pattern;
- }
- /**
- * Only used in NumberValueObject
- * @param pattern
- */
- setPattern(a) {
- this.pattern = a;
- }
- isError() {
- return !1;
- }
- isAsyncObject() {
- return !1;
- }
- isAsyncArrayObject() {
- return !1;
- }
- isReferenceObject() {
- return !1;
- }
- isArray() {
- return !1;
- }
- isValueObject() {
- return !1;
- }
- isEqualType(a) {
- return !1;
- }
- }
- class kt extends jn {
- constructor(a) {
- super(), this._rawValue = a;
- }
- isValueObject() {
- return !0;
- }
- toUnitRange() {
- return {
- range: {
- startColumn: -1,
- startRow: -1,
- endRow: -1,
- endColumn: -1
- },
- sheetId: "",
- unitId: ""
- };
- }
- getValue() {
- return 0;
- }
- getArrayValue() {
- return [];
- }
- setValue(a) {
- }
- setArrayValue(a) {
- }
- isCube() {
- return !1;
- }
- isString() {
- return !1;
- }
- isNumber() {
- return !1;
- }
- isBoolean() {
- return !1;
- }
- isLambda() {
- return !1;
- }
- isError() {
- return !1;
- }
- isNull() {
- return !1;
- }
- sum() {
- return g.create(m.VALUE);
- }
- max() {
- return g.create(m.VALUE);
- }
- min() {
- return g.create(m.VALUE);
- }
- count() {
- return g.create(m.VALUE);
- }
- countA() {
- return g.create(m.VALUE);
- }
- countBlank() {
- return g.create(m.VALUE);
- }
- getNegative() {
- return g.create(m.VALUE);
- }
- getReciprocal() {
- return g.create(m.VALUE);
- }
- plus(a) {
- return g.create(m.VALUE);
- }
- minus(a) {
- return g.create(m.VALUE);
- }
- multiply(a) {
- return g.create(m.VALUE);
- }
- divided(a) {
- return g.create(m.VALUE);
- }
- mod(a) {
- return g.create(m.VALUE);
- }
- /**
- * return every value in the array after the callback function, excluding the error value
- * @param callbackFn
- * @returns
- */
- map(a) {
- return g.create(m.NAME);
- }
- /**
- * return every value in the array after the callback function
- * @param callbackFn
- * @returns
- */
- mapValue(a) {
- return g.create(m.NAME);
- }
- compare(a, e, t = !1) {
- return g.create(m.NAME);
- }
- isEqual(a) {
- return this.compare(a, $.EQUALS);
- }
- isNotEqual(a) {
- return this.compare(a, $.NOT_EQUAL);
- }
- isGreaterThanOrEqual(a) {
- return this.compare(a, $.GREATER_THAN_OR_EQUAL);
- }
- isLessThanOrEqual(a) {
- return this.compare(a, $.LESS_THAN_OR_EQUAL);
- }
- isLessThan(a) {
- return this.compare(a, $.LESS_THAN);
- }
- isGreaterThan(a) {
- return this.compare(a, $.GREATER_THAN);
- }
- concatenateFront(a) {
- return g.create(m.NAME);
- }
- concatenateBack(a) {
- return g.create(m.NAME);
- }
- plusBy(a) {
- return g.create(m.VALUE);
- }
- minusBy(a) {
- return g.create(m.VALUE);
- }
- multiplyBy(a) {
- return g.create(m.VALUE);
- }
- dividedBy(a) {
- return g.create(m.VALUE);
- }
- modInverse(a) {
- return g.create(m.VALUE);
- }
- compareBy(a, e) {
- return g.create(m.NAME);
- }
- concatenate(a, e = it.FRONT) {
- let t = this.getValue().toString();
- if (typeof a == "string")
- e === it.FRONT ? t = a + t : t += a;
- else if (typeof a == "number")
- e === it.FRONT ? t = a.toString() + t : t += a.toString();
- else if (typeof a == "boolean") {
- const r = a ? "TRUE" : "FALSE";
- e === it.FRONT ? t = r + t : t += r;
- }
- return t;
- }
- pow(a) {
- return g.create(m.VALUE);
- }
- powInverse(a) {
- return g.create(m.VALUE);
- }
- sqrt() {
- return g.create(m.VALUE);
- }
- cbrt() {
- return g.create(m.VALUE);
- }
- cos() {
- return g.create(m.VALUE);
- }
- cosh() {
- return g.create(m.VALUE);
- }
- acos() {
- return g.create(m.VALUE);
- }
- acosh() {
- return g.create(m.VALUE);
- }
- sin() {
- return g.create(m.VALUE);
- }
- sinh() {
- return g.create(m.VALUE);
- }
- asin() {
- return g.create(m.VALUE);
- }
- asinh() {
- return g.create(m.VALUE);
- }
- tan() {
- return g.create(m.VALUE);
- }
- tanh() {
- return g.create(m.VALUE);
- }
- atan() {
- return g.create(m.VALUE);
- }
- atan2(a) {
- return g.create(m.VALUE);
- }
- atan2Inverse(a) {
- return g.create(m.VALUE);
- }
- atanh() {
- return g.create(m.VALUE);
- }
- /**
- * Calculate the mean of the entire array.
- *
- * reference https://numpy.org/doc/stable/reference/generated/numpy.mean.html#numpy.mean
- *
- */
- mean() {
- return this;
- }
- /**
- * Calculate the median of the entire array.
- *
- * reference https://numpy.org/doc/stable/reference/generated/numpy.median.html
- *
- */
- median() {
- return this;
- }
- /**
- * Calculate the variance of the entire array.
- *
- * reference https://numpy.org/doc/stable/reference/generated/numpy.var.html
- */
- var() {
- return this;
- }
- /**
- * Calculate the standard deviation of the entire array.
- *
- * reference https://numpy.org/doc/stable/reference/generated/numpy.std.html
- */
- std() {
- return this;
- }
- log() {
- return g.create(m.VALUE);
- }
- log10() {
- return g.create(m.VALUE);
- }
- exp() {
- return g.create(m.VALUE);
- }
- abs() {
- return g.create(m.VALUE);
- }
- round(a) {
- return g.create(m.VALUE);
- }
- roundInverse(a) {
- return g.create(m.VALUE);
- }
- floor(a) {
- return g.create(m.VALUE);
- }
- floorInverse(a) {
- return g.create(m.VALUE);
- }
- ceil(a) {
- return g.create(m.VALUE);
- }
- ceilInverse(a) {
- return g.create(m.VALUE);
- }
- convertToNumberObjectValue() {
- return g.create(m.VALUE);
- }
- convertToBooleanObjectValue() {
- return g.create(m.VALUE);
- }
- }
- const ul = 1e3, ci = new Vt(ul);
- class g extends kt {
- constructor(a, e = "") {
- super(a), this._errorType = a, this._errorContent = e;
- }
- static create(a, e = "") {
- const t = `${a}-${e}`, r = ci.get(t);
- if (r)
- return r;
- const n = new g(a, e);
- return ci.set(t, n), n;
- }
- getValue() {
- return this._errorType;
- }
- getErrorType() {
- return this._errorType;
- }
- getErrorContent() {
- return this._errorContent;
- }
- isEqualType(a) {
- return a.getErrorType() === this.getErrorType();
- }
- isError() {
- return !0;
- }
- }
- function cl(i) {
- if (i === null)
- return 0;
- if (i != null && i.p) {
- const a = i == null ? void 0 : i.p.body;
- if (a == null)
- return 0;
- const e = a.dataStream;
- return Yu.transform.getPlainText(e);
- }
- return (i == null ? void 0 : i.v) || 0;
- }
- var Wt = /* @__PURE__ */ ((i) => (i[i.MIN = 0] = "MIN", i[i.MAX = 1] = "MAX", i))(Wt || {}), Pe = /* @__PURE__ */ ((i) => (i[i.NORMAL = 0] = "NORMAL", i[i.MIN = 1] = "MIN", i[i.MAX = 2] = "MAX", i))(Pe || {});
- function hn() {
- return Intl && Intl.Collator ? new Intl.Collator(void 0, { numeric: !1 }).compare : (i, a) => i.localeCompare(a);
- }
- function ll(i) {
- return i.indexOf("*") > -1 || i.indexOf("?") > -1;
- }
- function us(i, a) {
- const e = hl(a).replace(/~?[*?]/g, (r) => r.startsWith("~") ? `\\${r.substring(1)}` : r === "*" ? ".*" : r === "?" ? "." : r);
- return new RegExp(`^${e}$`).test(i);
- }
- function li(i) {
- return i.replace(/~?[*?]/g, (a) => a.startsWith("~") ? a.substring(1) : " ");
- }
- function fl(i, a, e) {
- let t = !1;
- switch (e) {
- case $.EQUALS:
- t = us(i, a);
- break;
- case $.NOT_EQUAL:
- t = !us(i, a);
- break;
- case $.GREATER_THAN:
- case $.GREATER_THAN_OR_EQUAL:
- t = us(i, a) || i > li(a);
- break;
- case $.LESS_THAN:
- case $.LESS_THAN_OR_EQUAL:
- t = i < li(a);
- break;
- }
- return t;
- }
- function hl(i) {
- return i.replace(/[.+^${}()|[\]\\]/g, "\\$&");
- }
- function Ss(i) {
- switch (i) {
- case 1:
- return 2;
- case 0:
- return 0;
- case -1:
- return 1;
- default:
- return 0;
- }
- }
- function Ps(i) {
- return i === -2 ? 1 : 0;
- }
- function ma(i) {
- let a;
- switch (i) {
- case $.EQUALS:
- a = $.EQUALS;
- break;
- case $.GREATER_THAN:
- a = $.LESS_THAN;
- break;
- case $.GREATER_THAN_OR_EQUAL:
- a = $.LESS_THAN_OR_EQUAL;
- break;
- case $.LESS_THAN:
- a = $.GREATER_THAN;
- break;
- case $.LESS_THAN_OR_EQUAL:
- a = $.GREATER_THAN_OR_EQUAL;
- break;
- case $.NOT_EQUAL:
- a = $.NOT_EQUAL;
- break;
- }
- return a;
- }
- /*!
- * decimal.js v10.4.3
- * An arbitrary-precision Decimal type for JavaScript.
- * https://github.com/MikeMcl/decimal.js
- * Copyright (c) 2022 Michael Mclaughlin <M8ch88l@gmail.com>
- * MIT Licence
- */
- var Ls = 9e15, $t = 1e9, xs = "0123456789abcdef", mn = "2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058", gn = "3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789", js = {
- // These values must be integers within the stated ranges (inclusive).
- // Most of these values can be changed at run-time using the `Decimal.config` method.
- // The maximum number of significant digits of the result of a calculation or base conversion.
- // E.g. `Decimal.config({ precision: 20 });`
- precision: 20,
- // 1 to MAX_DIGITS
- // The rounding mode used when rounding to `precision`.
- //
- // ROUND_UP 0 Away from zero.
- // ROUND_DOWN 1 Towards zero.
- // ROUND_CEIL 2 Towards +Infinity.
- // ROUND_FLOOR 3 Towards -Infinity.
- // ROUND_HALF_UP 4 Towards nearest neighbour. If equidistant, up.
- // ROUND_HALF_DOWN 5 Towards nearest neighbour. If equidistant, down.
- // ROUND_HALF_EVEN 6 Towards nearest neighbour. If equidistant, towards even neighbour.
- // ROUND_HALF_CEIL 7 Towards nearest neighbour. If equidistant, towards +Infinity.
- // ROUND_HALF_FLOOR 8 Towards nearest neighbour. If equidistant, towards -Infinity.
- //
- // E.g.
- // `Decimal.rounding = 4;`
- // `Decimal.rounding = Decimal.ROUND_HALF_UP;`
- rounding: 4,
- // 0 to 8
- // The modulo mode used when calculating the modulus: a mod n.
- // The quotient (q = a / n) is calculated according to the corresponding rounding mode.
- // The remainder (r) is calculated as: r = a - n * q.
- //
- // UP 0 The remainder is positive if the dividend is negative, else is negative.
- // DOWN 1 The remainder has the same sign as the dividend (JavaScript %).
- // FLOOR 3 The remainder has the same sign as the divisor (Python %).
- // HALF_EVEN 6 The IEEE 754 remainder function.
- // EUCLID 9 Euclidian division. q = sign(n) * floor(a / abs(n)). Always positive.
- //
- // Truncated division (1), floored division (3), the IEEE 754 remainder (6), and Euclidian
- // division (9) are commonly used for the modulus operation. The other rounding modes can also
- // be used, but they may not give useful results.
- modulo: 1,
- // 0 to 9
- // The exponent value at and beneath which `toString` returns exponential notation.
- // JavaScript numbers: -7
- toExpNeg: -7,
- // 0 to -EXP_LIMIT
- // The exponent value at and above which `toString` returns exponential notation.
- // JavaScript numbers: 21
- toExpPos: 21,
- // 0 to EXP_LIMIT
- // The minimum exponent value, beneath which underflow to zero occurs.
- // JavaScript numbers: -324 (5e-324)
- minE: -9e15,
- // -1 to -EXP_LIMIT
- // The maximum exponent value, above which overflow to Infinity occurs.
- // JavaScript numbers: 308 (1.7976931348623157e+308)
- maxE: Ls,
- // 1 to EXP_LIMIT
- // Whether to use cryptographically-secure random number generation, if available.
- crypto: !1
- // true/false
- }, io, Rt, ue = !0, Un = "[DecimalError] ", Bt = Un + "Invalid argument: ", oo = Un + "Precision limit exceeded", uo = Un + "crypto unavailable", co = "[object Decimal]", Be = Math.floor, Le = Math.pow, ml = /^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i, gl = /^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i, dl = /^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i, lo = /^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i, ut = 1e7, te = 7, Cl = 9007199254740991, _l = mn.length - 1, Us = gn.length - 1, B = { toStringTag: co };
- B.absoluteValue = B.abs = function() {
- var i = new this.constructor(this);
- return i.s < 0 && (i.s = 1), J(i);
- };
- B.ceil = function() {
- return J(new this.constructor(this), this.e + 1, 2);
- };
- B.clampedTo = B.clamp = function(i, a) {
- var e, t = this, r = t.constructor;
- if (i = new r(i), a = new r(a), !i.s || !a.s) return new r(NaN);
- if (i.gt(a)) throw Error(Bt + a);
- return e = t.cmp(i), e < 0 ? i : t.cmp(a) > 0 ? a : new r(t);
- };
- B.comparedTo = B.cmp = function(i) {
- var a, e, t, r, n = this, s = n.d, o = (i = new n.constructor(i)).d, u = n.s, c = i.s;
- if (!s || !o)
- return !u || !c ? NaN : u !== c ? u : s === o ? 0 : !s ^ u < 0 ? 1 : -1;
- if (!s[0] || !o[0]) return s[0] ? u : o[0] ? -c : 0;
- if (u !== c) return u;
- if (n.e !== i.e) return n.e > i.e ^ u < 0 ? 1 : -1;
- for (t = s.length, r = o.length, a = 0, e = t < r ? t : r; a < e; ++a)
- if (s[a] !== o[a]) return s[a] > o[a] ^ u < 0 ? 1 : -1;
- return t === r ? 0 : t > r ^ u < 0 ? 1 : -1;
- };
- B.cosine = B.cos = function() {
- var i, a, e = this, t = e.constructor;
- return e.d ? e.d[0] ? (i = t.precision, a = 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 = a, J(Rt == 2 || Rt == 3 ? e.neg() : e, i, a, !0)) : new t(1) : new t(NaN);
- };
- B.cubeRoot = B.cbrt = function() {
- var i, a, e, t, r, n, s, o, u, c, l = this, f = l.constructor;
- if (!l.isFinite() || l.isZero()) return new f(l);
- for (ue = !1, n = l.s * Le(l.s * l, 1 / 3), !n || Math.abs(n) == 1 / 0 ? (e = Ue(l.d), i = l.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 f(e), t.s = l.s) : t = new f(n.toString()), s = (i = f.precision) + 3; ; )
- if (o = t, u = o.times(o).times(o), c = u.plus(l), t = pe(c.plus(l).times(o), c.plus(u), s + 2, 1), Ue(o.d).slice(0, s) === (e = Ue(t.d)).slice(0, s))
- if (e = e.slice(s - 3, s + 1), e == "9999" || !r && e == "4999") {
- if (!r && (J(o, i + 1, 0), o.times(o).times(o).eq(l))) {
- t = o;
- break;
- }
- s += 4, r = 1;
- } else {
- (!+e || !+e.slice(1) && e.charAt(0) == "5") && (J(t, i + 1, 1), a = !t.times(t).times(t).eq(l));
- break;
- }
- return ue = !0, J(t, i, f.rounding, a);
- };
- B.decimalPlaces = B.dp = function() {
- var i, a = this.d, e = NaN;
- if (a) {
- if (i = a.length - 1, e = (i - Be(this.e / te)) * te, i = a[i], i) for (; i % 10 == 0; i /= 10) e--;
- e < 0 && (e = 0);
- }
- return e;
- };
- B.dividedBy = B.div = function(i) {
- return pe(this, new this.constructor(i));
- };
- B.dividedToIntegerBy = B.divToInt = function(i) {
- var a = this, e = a.constructor;
- return J(pe(a, new e(i), 0, 1, 1), e.precision, e.rounding);
- };
- B.equals = B.eq = function(i) {
- return this.cmp(i) === 0;
- };
- B.floor = function() {
- return J(new this.constructor(this), this.e + 1, 3);
- };
- B.greaterThan = B.gt = function(i) {
- return this.cmp(i) > 0;
- };
- B.greaterThanOrEqualTo = B.gte = function(i) {
- var a = this.cmp(i);
- return a == 1 || a === 0;
- };
- B.hyperbolicCosine = B.cosh = function() {
- var i, a, e, t, r, n = this, s = n.constructor, o = new s(1);
- if (!n.isFinite()) return new s(n.s ? 1 / 0 : NaN);
- if (n.isZero()) return o;
- 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), a = (1 / Tn(4, i)).toString()) : (i = 16, a = "2.3283064365386962890625e-10"), n = dr(s, 1, n.times(a), new s(1), !0);
- for (var u, c = i, l = new s(8); c--; )
- u = n.times(n), n = o.minus(u.times(l.minus(u.times(l))));
- return J(n, s.precision = e, s.rounding = t, !0);
- };
- B.hyperbolicSine = B.sinh = function() {
- var i, a, e, t, r = this, n = r.constructor;
- if (!r.isFinite() || r.isZero()) return new n(r);
- if (a = n.precision, e = n.rounding, n.precision = a + Math.max(r.e, r.sd()) + 4, n.rounding = 1, t = r.d.length, t < 3)
- r = dr(n, 2, r, r, !0);
- else {
- 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, !0);
- for (var s, o = new n(5), u = new n(16), c = new n(20); i--; )
- s = r.times(r), r = r.times(o.plus(s.times(u.times(s).plus(c))));
- }
- return n.precision = a, n.rounding = e, J(r, a, e, !0);
- };
- B.hyperbolicTangent = B.tanh = function() {
- var i, a, e = this, t = e.constructor;
- return e.isFinite() ? e.isZero() ? new t(e) : (i = t.precision, a = t.rounding, t.precision = i + 7, t.rounding = 1, pe(e.sinh(), e.cosh(), t.precision = i, t.rounding = a)) : new t(e.s);
- };
- B.inverseCosine = B.acos = function() {
- var i, a = this, e = a.constructor, t = a.abs().cmp(1), r = e.precision, n = e.rounding;
- return t !== -1 ? t === 0 ? a.isNeg() ? ot(e, r, n) : new e(0) : new e(NaN) : a.isZero() ? ot(e, r + 4, n).times(0.5) : (e.precision = r + 6, e.rounding = 1, a = a.asin(), i = ot(e, r + 4, n).times(0.5), e.precision = r, e.rounding = n, i.minus(a));
- };
- B.inverseHyperbolicCosine = B.acosh = function() {
- var i, a, e = this, t = e.constructor;
- return e.lte(1) ? new t(e.eq(1) ? 0 : NaN) : e.isFinite() ? (i = t.precision, a = t.rounding, t.precision = i + Math.max(Math.abs(e.e), e.sd()) + 4, t.rounding = 1, ue = !1, e = e.times(e).minus(1).sqrt().plus(e), ue = !0, t.precision = i, t.rounding = a, e.ln()) : new t(e);
- };
- B.inverseHyperbolicSine = B.asinh = function() {
- var i, a, e = this, t = e.constructor;
- return !e.isFinite() || e.isZero() ? new t(e) : (i = t.precision, a = t.rounding, t.precision = i + 2 * Math.max(Math.abs(e.e), e.sd()) + 6, t.rounding = 1, ue = !1, e = e.times(e).plus(1).sqrt().plus(e), ue = !0, t.precision = i, t.rounding = a, e.ln());
- };
- B.inverseHyperbolicTangent = B.atanh = function() {
- var i, a, e, t, r = this, n = r.constructor;
- return r.isFinite() ? r.e >= 0 ? new n(r.abs().eq(1) ? r.s / 0 : r.isZero() ? r : NaN) : (i = n.precision, a = n.rounding, t = r.sd(), Math.max(t, i) < 2 * -r.e - 1 ? J(new n(r), i, a, !0) : (n.precision = e = t - r.e, r = pe(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 = a, r.times(0.5))) : new n(NaN);
- };
- B.inverseSine = B.asin = function() {
- var i, a, e, t, r = this, n = r.constructor;
- return r.isZero() ? new n(r) : (a = r.abs().cmp(1), e = n.precision, t = n.rounding, a !== -1 ? a === 0 ? (i = ot(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)));
- };
- B.inverseTangent = B.atan = function() {
- var i, a, e, t, r, n, s, o, u, c = this, l = c.constructor, f = l.precision, h = l.rounding;
- if (c.isFinite()) {
- if (c.isZero())
- return new l(c);
- if (c.abs().eq(1) && f + 4 <= Us)
- return s = ot(l, f + 4, h).times(0.25), s.s = c.s, s;
- } else {
- if (!c.s) return new l(NaN);
- if (f + 4 <= Us)
- return s = ot(l, f + 4, h).times(0.5), s.s = c.s, s;
- }
- for (l.precision = o = f + 10, l.rounding = 1, e = Math.min(28, o / te + 2 | 0), i = e; i; --i) c = c.div(c.times(c).plus(1).sqrt().plus(1));
- for (ue = !1, a = Math.ceil(o / te), t = 1, u = c.times(c), s = new l(c), r = c; i !== -1; )
- 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[a] !== void 0) for (i = a; s.d[i] === n.d[i] && i--; ) ;
- return e && (s = s.times(2 << e - 1)), ue = !0, J(s, l.precision = f, l.rounding = h, !0);
- };
- B.isFinite = function() {
- return !!this.d;
- };
- B.isInteger = B.isInt = function() {
- return !!this.d && Be(this.e / te) > this.d.length - 2;
- };
- B.isNaN = function() {
- return !this.s;
- };
- B.isNegative = B.isNeg = function() {
- return this.s < 0;
- };
- B.isPositive = B.isPos = function() {
- return this.s > 0;
- };
- B.isZero = function() {
- return !!this.d && this.d[0] === 0;
- };
- B.lessThan = B.lt = function(i) {
- return this.cmp(i) < 0;
- };
- B.lessThanOrEqualTo = B.lte = function(i) {
- return this.cmp(i) < 1;
- };
- B.logarithm = B.log = function(i) {
- var a, e, t, r, n, s, o, u, c = this, l = c.constructor, f = l.precision, h = l.rounding, d = 5;
- if (i == null)
- i = new l(10), a = !0;
- else {
- if (i = new l(i), e = i.d, i.s < 0 || !e || !e[0] || i.eq(1)) return new l(NaN);
- a = i.eq(10);
- }
- if (e = c.d, c.s < 0 || !e || !e[0] || c.eq(1))
- return new l(e && !e[0] ? -1 / 0 : c.s != 1 ? NaN : e ? 0 : 1 / 0);
- if (a)
- if (e.length > 1)
- n = !0;
- else {
- for (r = e[0]; r % 10 === 0; ) r /= 10;
- n = r !== 1;
- }
- if (ue = !1, o = f + d, s = jt(c, o), t = a ? dn(l, o + 10) : jt(i, o), u = pe(s, t, o, 1), Lr(u.d, r = f, h))
- do
- if (o += 10, s = jt(c, o), t = a ? dn(l, o + 10) : jt(i, o), u = pe(s, t, o, 1), !n) {
- +Ue(u.d).slice(r + 1, r + 15) + 1 == 1e14 && (u = J(u, f + 1, 0));
- break;
- }
- while (Lr(u.d, r += 10, h));
- return ue = !0, J(u, f, h);
- };
- B.minus = B.sub = function(i) {
- var a, e, t, r, n, s, o, u, c, l, f, h, d = this, _ = d.constructor;
- if (i = new _(i), !d.d || !i.d)
- return !d.s || !i.s ? i = new _(NaN) : d.d ? i.s = -i.s : i = new _(i.d || d.s !== i.s ? d : NaN), i;
- if (d.s != i.s)
- return i.s = -i.s, d.plus(i);
- if (c = d.d, h = i.d, o = _.precision, u = _.rounding, !c[0] || !h[0]) {
- if (h[0]) i.s = -i.s;
- else if (c[0]) i = new _(d);
- else return new _(u === 3 ? -0 : 0);
- return ue ? J(i, o, u) : i;
- }
- if (e = Be(i.e / te), l = Be(d.e / te), c = c.slice(), n = l - e, n) {
- for (f = n < 0, f ? (a = c, n = -n, s = h.length) : (a = h, e = l, s = c.length), t = Math.max(Math.ceil(o / te), s) + 2, n > t && (n = t, a.length = 1), a.reverse(), t = n; t--; ) a.push(0);
- a.reverse();
- } else {
- for (t = c.length, s = h.length, f = t < s, f && (s = t), t = 0; t < s; t++)
- if (c[t] != h[t]) {
- f = c[t] < h[t];
- break;
- }
- n = 0;
- }
- for (f && (a = c, c = h, h = a, i.s = -i.s), s = c.length, t = h.length - s; t > 0; --t) c[s++] = 0;
- for (t = h.length; t > n; ) {
- if (c[--t] < h[t]) {
- for (r = t; r && c[--r] === 0; ) c[r] = ut - 1;
- --c[r], c[t] += ut;
- }
- c[t] -= h[t];
- }
- for (; c[--s] === 0; ) c.pop();
- for (; c[0] === 0; c.shift()) --e;
- return c[0] ? (i.d = c, i.e = vn(c, e), ue ? J(i, o, u) : i) : new _(u === 3 ? -0 : 0);
- };
- B.modulo = B.mod = function(i) {
- var a, e = this, t = e.constructor;
- return i = new t(i), !e.d || !i.s || i.d && !i.d[0] ? new t(NaN) : !i.d || e.d && !e.d[0] ? J(new t(e), t.precision, t.rounding) : (ue = !1, t.modulo == 9 ? (a = pe(e, i.abs(), 0, 3, 1), a.s *= i.s) : a = pe(e, i, 0, t.modulo, 1), a = a.times(i), ue = !0, e.minus(a));
- };
- B.naturalExponential = B.exp = function() {
- return vs(this);
- };
- B.naturalLogarithm = B.ln = function() {
- return jt(this);
- };
- B.negated = B.neg = function() {
- var i = new this.constructor(this);
- return i.s = -i.s, J(i);
- };
- B.plus = B.add = function(i) {
- var a, e, t, r, n, s, o, u, c, l, f = this, h = f.constructor;
- if (i = new h(i), !f.d || !i.d)
- return !f.s || !i.s ? i = new h(NaN) : f.d || (i = new h(i.d || f.s === i.s ? f : NaN)), i;
- if (f.s != i.s)
- return i.s = -i.s, f.minus(i);
- if (c = f.d, l = i.d, o = h.precision, u = h.rounding, !c[0] || !l[0])
- return l[0] || (i = new h(f)), ue ? J(i, o, u) : i;
- if (n = Be(f.e / te), t = Be(i.e / te), c = c.slice(), r = n - t, r) {
- for (r < 0 ? (e = c, r = -r, s = l.length) : (e = l, 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--; ) e.push(0);
- e.reverse();
- }
- for (s = c.length, r = l.length, s - r < 0 && (r = s, e = l, l = c, c = e), a = 0; r; )
- a = (c[--r] = c[r] + l[r] + a) / ut | 0, c[r] %= ut;
- for (a && (c.unshift(a), ++t), s = c.length; c[--s] == 0; ) c.pop();
- return i.d = c, i.e = vn(c, t), ue ? J(i, o, u) : i;
- };
- B.precision = B.sd = function(i) {
- var a, e = this;
- if (i !== void 0 && i !== !!i && i !== 1 && i !== 0) throw Error(Bt + i);
- return e.d ? (a = fo(e.d), i && e.e + 1 > a && (a = e.e + 1)) : a = NaN, a;
- };
- B.round = function() {
- var i = this, a = i.constructor;
- return J(new a(i), i.e + 1, a.rounding);
- };
- B.sine = B.sin = function() {
- var i, a, e = this, t = e.constructor;
- return e.isFinite() ? e.isZero() ? new t(e) : (i = t.precision, a = 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 = a, J(Rt > 2 ? e.neg() : e, i, a, !0)) : new t(NaN);
- };
- B.squareRoot = B.sqrt = function() {
- var i, a, e, t, r, n, s = this, o = s.d, u = s.e, c = s.s, l = s.constructor;
- if (c !== 1 || !o || !o[0])
- return new l(!c || c < 0 && (!o || o[0]) ? NaN : o ? s : 1 / 0);
- for (ue = !1, c = Math.sqrt(+s), c == 0 || c == 1 / 0 ? (a = Ue(o), (a.length + u) % 2 == 0 && (a += "0"), c = Math.sqrt(a), u = Be((u + 1) / 2) - (u < 0 || u % 2), c == 1 / 0 ? a = "5e" + u : (a = c.toExponential(), a = a.slice(0, a.indexOf("e") + 1) + u), t = new l(a)) : t = new l(c.toString()), e = (u = l.precision) + 3; ; )
- if (n = t, t = n.plus(pe(s, n, e + 2, 1)).times(0.5), Ue(n.d).slice(0, e) === (a = Ue(t.d)).slice(0, e))
- if (a = a.slice(e - 3, e + 1), a == "9999" || !r && a == "4999") {
- if (!r && (J(n, u + 1, 0), n.times(n).eq(s))) {
- t = n;
- break;
- }
- e += 4, r = 1;
- } else {
- (!+a || !+a.slice(1) && a.charAt(0) == "5") && (J(t, u + 1, 1), i = !t.times(t).eq(s));
- break;
- }
- return ue = !0, J(t, u, l.rounding, i);
- };
- B.tangent = B.tan = function() {
- var i, a, e = this, t = e.constructor;
- return e.isFinite() ? e.isZero() ? new t(e) : (i = t.precision, a = t.rounding, t.precision = i + 10, t.rounding = 1, e = e.sin(), e.s = 1, e = pe(e, new t(1).minus(e.times(e)).sqrt(), i + 10, 0), t.precision = i, t.rounding = a, J(Rt == 2 || Rt == 4 ? e.neg() : e, i, a, !0)) : new t(NaN);
- };
- B.times = B.mul = function(i) {
- var a, e, t, r, n, s, o, u, c, l = this, f = l.constructor, h = l.d, d = (i = new f(i)).d;
- if (i.s *= l.s, !h || !h[0] || !d || !d[0])
- return new f(!i.s || h && !h[0] && !d || d && !d[0] && !h ? NaN : !h || !d ? i.s / 0 : i.s * 0);
- for (e = Be(l.e / te) + Be(i.e / te), u = h.length, c = d.length, u < c && (n = h, h = d, d = n, s = u, u = c, c = s), n = [], s = u + c, t = s; t--; ) n.push(0);
- for (t = c; --t >= 0; ) {
- for (a = 0, r = u + t; r > t; )
- o = n[r] + d[t] * h[r - t - 1] + a, n[r--] = o % ut | 0, a = o / ut | 0;
- n[r] = (n[r] + a) % ut | 0;
- }
- for (; !n[--s]; ) n.pop();
- return a ? ++e : n.shift(), i.d = n, i.e = vn(n, e), ue ? J(i, f.precision, f.rounding) : i;
- };
- B.toBinary = function(i, a) {
- return ga(this, 2, i, a);
- };
- B.toDecimalPlaces = B.toDP = function(i, a) {
- var e = this, t = e.constructor;
- return e = new t(e), i === void 0 ? e : (He(i, 0, $t), a === void 0 ? a = t.rounding : He(a, 0, 8), J(e, i + e.e + 1, a));
- };
- B.toExponential = function(i, a) {
- var e, t = this, r = t.constructor;
- return i === void 0 ? e = Ct(t, !0) : (He(i, 0, $t), a === void 0 ? a = r.rounding : He(a, 0, 8), t = J(new r(t), i + 1, a), e = Ct(t, !0, i + 1)), t.isNeg() && !t.isZero() ? "-" + e : e;
- };
- B.toFixed = function(i, a) {
- var e, t, r = this, n = r.constructor;
- return i === void 0 ? e = Ct(r) : (He(i, 0, $t), a === void 0 ? a = n.rounding : He(a, 0, 8), t = J(new n(r), i + r.e + 1, a), e = Ct(t, !1, i + t.e + 1)), r.isNeg() && !r.isZero() ? "-" + e : e;
- };
- B.toFraction = function(i) {
- var a, e, t, r, n, s, o, u, c, l, f, h, d = this, _ = d.d, C = d.constructor;
- if (!_) return new C(d);
- if (c = e = new C(1), t = u = new C(0), a = new C(t), n = a.e = fo(_) - d.e - 1, s = n % te, a.d[0] = Le(10, s < 0 ? te + s : s), i == null)
- i = n > 0 ? a : c;
- else {
- if (o = new C(i), !o.isInt() || o.lt(c)) throw Error(Bt + o);
- i = o.gt(a) ? n > 0 ? a : c : o;
- }
- for (ue = !1, o = new C(Ue(_)), l = C.precision, C.precision = n = _.length * te * 2; f = pe(o, a, 0, 1, 1), r = e.plus(f.times(t)), r.cmp(i) != 1; )
- e = t, t = r, r = c, c = u.plus(f.times(r)), u = r, r = a, a = o.minus(f.times(r)), o = r;
- return r = pe(i.minus(e), t, 0, 1, 1), u = u.plus(r.times(c)), e = e.plus(r.times(t)), u.s = c.s = d.s, h = pe(c, t, n, 1).minus(d).abs().cmp(pe(u, e, n, 1).minus(d).abs()) < 1 ? [c, t] : [u, e], C.precision = l, ue = !0, h;
- };
- B.toHexadecimal = B.toHex = function(i, a) {
- return ga(this, 16, i, a);
- };
- B.toNearest = function(i, a) {
- var e = this, t = e.constructor;
- if (e = new t(e), i == null) {
- if (!e.d) return e;
- i = new t(1), a = t.rounding;
- } else {
- if (i = new t(i), a === void 0 ? a = t.rounding : He(a, 0, 8), !e.d) return i.s ? e : i;
- if (!i.d)
- return i.s && (i.s = e.s), i;
- }
- return i.d[0] ? (ue = !1, e = pe(e, i, 0, a, 1).times(i), ue = !0, J(e)) : (i.s = e.s, e = i), e;
- };
- B.toNumber = function() {
- return +this;
- };
- B.toOctal = function(i, a) {
- return ga(this, 8, i, a);
- };
- B.toPower = B.pow = function(i) {
- var a, e, t, r, n, s, o = this, u = o.constructor, c = +(i = new u(i));
- if (!o.d || !i.d || !o.d[0] || !i.d[0]) return new u(Le(+o, c));
- if (o = new u(o), o.eq(1)) return o;
- if (t = u.precision, n = u.rounding, i.eq(1)) return J(o, t, n);
- if (a = Be(i.e / te), a >= i.d.length - 1 && (e = c < 0 ? -c : c) <= Cl)
- return r = ho(u, o, e, t), i.s < 0 ? new u(1).div(r) : J(r, t, n);
- if (s = o.s, s < 0) {
- if (a < i.d.length - 1) return new u(NaN);
- if (i.d[a] & 1 || (s = 1), o.e == 0 && o.d[0] == 1 && o.d.length == 1)
- return o.s = s, o;
- }
- return e = Le(+o, c), a = e == 0 || !isFinite(e) ? Be(c * (Math.log("0." + Ue(o.d)) / Math.LN10 + o.e + 1)) : new u(e + "").e, a > u.maxE + 1 || a < u.minE - 1 ? new u(a > 0 ? s / 0 : 0) : (ue = !1, u.rounding = o.s = 1, e = Math.min(12, (a + "").length), r = vs(i.times(jt(o, t + e)), t), r.d && (r = J(r, t + 5, 1), Lr(r.d, t, n) && (a = t + 10, r = J(vs(i.times(jt(o, a + e)), a), a + 5, 1), +Ue(r.d).slice(t + 1, t + 15) + 1 == 1e14 && (r = J(r, t + 1, 0)))), r.s = s, ue = !0, u.rounding = n, J(r, t, n));
- };
- B.toPrecision = function(i, a) {
- var e, t = this, r = t.constructor;
- return i === void 0 ? e = Ct(t, t.e <= r.toExpNeg || t.e >= r.toExpPos) : (He(i, 1, $t), a === void 0 ? a = r.rounding : He(a, 0, 8), t = J(new r(t), i, a), e = Ct(t, i <= t.e || t.e <= r.toExpNeg, i)), t.isNeg() && !t.isZero() ? "-" + e : e;
- };
- B.toSignificantDigits = B.toSD = function(i, a) {
- var e = this, t = e.constructor;
- return i === void 0 ? (i = t.precision, a = t.rounding) : (He(i, 1, $t), a === void 0 ? a = t.rounding : He(a, 0, 8)), J(new t(e), i, a);
- };
- B.toString = function() {
- var i = this, a = i.constructor, e = Ct(i, i.e <= a.toExpNeg || i.e >= a.toExpPos);
- return i.isNeg() && !i.isZero() ? "-" + e : e;
- };
- B.truncated = B.trunc = function() {
- return J(new this.constructor(this), this.e + 1, 1);
- };
- B.valueOf = B.toJSON = function() {
- var i = this, a = i.constructor, e = Ct(i, i.e <= a.toExpNeg || i.e >= a.toExpPos);
- return i.isNeg() ? "-" + e : e;
- };
- function Ue(i) {
- var a, e, t, r = i.length - 1, n = "", s = i[0];
- if (r > 0) {
- for (n += s, a = 1; a < r; a++)
- t = i[a] + "", e = te - t.length, e && (n += Pt(e)), n += t;
- s = i[a], t = s + "", e = te - t.length, e && (n += Pt(e));
- } else if (s === 0)
- return "0";
- for (; s % 10 === 0; ) s /= 10;
- return n + s;
- }
- function He(i, a, e) {
- if (i !== ~~i || i < a || i > e)
- throw Error(Bt + i);
- }
- function Lr(i, a, e, t) {
- var r, n, s, o;
- for (n = i[0]; n >= 10; n /= 10) --a;
- return --a < 0 ? (a += te, r = 0) : (r = Math.ceil((a + 1) / te), a %= te), n = Le(10, te - a), o = i[r] % n | 0, t == null ? a < 3 ? (a == 0 ? o = o / 100 | 0 : a == 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, a - 2) - 1 || (o == n / 2 || o == 0) && (i[r + 1] / n / 100 | 0) == 0 : a < 4 ? (a == 0 ? o = o / 1e3 | 0 : a == 1 ? o = o / 100 | 0 : a == 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, a - 3) - 1, s;
- }
- function sn(i, a, e) {
- for (var t, r = [0], n, s = 0, o = i.length; s < o; ) {
- for (n = r.length; n--; ) r[n] *= a;
- for (r[0] += xs.indexOf(i.charAt(s++)), t = 0; t < r.length; t++)
- r[t] > e - 1 && (r[t + 1] === void 0 && (r[t + 1] = 0), r[t + 1] += r[t] / e | 0, r[t] %= e);
- }
- return r.reverse();
- }
- function Al(i, a) {
- var e, t, r;
- if (a.isZero()) return a;
- t = a.d.length, t < 32 ? (e = Math.ceil(t / 3), r = (1 / Tn(4, e)).toString()) : (e = 16, r = "2.3283064365386962890625e-10"), i.precision += e, a = dr(i, 1, a.times(r), new i(1));
- for (var n = e; n--; ) {
- var s = a.times(a);
- a = s.times(s).minus(s).times(8).plus(1);
- }
- return i.precision -= e, a;
- }
- var pe = /* @__PURE__ */ function() {
- function i(t, r, n) {
- var s, o = 0, u = t.length;
- for (t = t.slice(); u--; )
- s = t[u] * r + o, t[u] = s % n | 0, o = s / n | 0;
- return o && t.unshift(o), t;
- }
- function a(t, r, n, s) {
- var o, u;
- if (n != s)
- u = n > s ? 1 : -1;
- else
- for (o = u = 0; o < n; o++)
- if (t[o] != r[o]) {
- u = t[o] > r[o] ? 1 : -1;
- break;
- }
- return u;
- }
- function e(t, r, n, s) {
- for (var o = 0; n--; )
- t[n] -= o, o = t[n] < r[n] ? 1 : 0, t[n] = o * s + t[n] - r[n];
- for (; !t[0] && t.length > 1; ) t.shift();
- }
- return function(t, r, n, s, o, u) {
- var c, l, f, h, d, _, C, E, b, R, p, N, M, w, D, S, P, U, x, F, W = t.constructor, ne = t.s == r.s ? 1 : -1, z = t.d, G = r.d;
- if (!z || !z[0] || !G || !G[0])
- return new W(
- // Return NaN if either NaN, or both Infinity or 0.
- !t.s || !r.s || (z ? G && z[0] == G[0] : !G) ? NaN : (
- // Return ±0 if x is 0 or y is ±Infinity, or return ±Infinity as y is 0.
- z && z[0] == 0 || !G ? ne * 0 : ne / 0
- )
- );
- for (u ? (d = 1, l = t.e - r.e) : (u = ut, d = te, l = Be(t.e / d) - Be(r.e / d)), x = G.length, P = z.length, b = new W(ne), R = b.d = [], f = 0; G[f] == (z[f] || 0); f++) ;
- if (G[f] > (z[f] || 0) && l--, n == null ? (w = n = W.precision, s = W.rounding) : o ? w = n + (t.e - r.e) + 1 : w = n, w < 0)
- R.push(1), _ = !0;
- else {
- if (w = w / d + 2 | 0, f = 0, x == 1) {
- for (h = 0, G = G[0], w++; (f < P || h) && w--; f++)
- D = h * u + (z[f] || 0), R[f] = D / G | 0, h = D % G | 0;
- _ = h || f < P;
- } else {
- for (h = u / (G[0] + 1) | 0, h > 1 && (G = i(G, h, u), z = i(z, h, u), x = G.length, P = z.length), S = x, p = z.slice(0, x), N = p.length; N < x; ) p[N++] = 0;
- F = G.slice(), F.unshift(0), U = G[0], G[1] >= u / 2 && ++U;
- do
- h = 0, c = a(G, p, x, N), c < 0 ? (M = p[0], x != N && (M = M * u + (p[1] || 0)), h = M / U | 0, h > 1 ? (h >= u && (h = u - 1), C = i(G, h, u), E = C.length, N = p.length, c = a(C, p, E, N), c == 1 && (h--, e(C, x < E ? F : G, E, u))) : (h == 0 && (c = h = 1), C = G.slice()), E = C.length, E < N && C.unshift(0), e(p, C, N, u), c == -1 && (N = p.length, c = a(G, p, x, N), c < 1 && (h++, e(p, x < N ? F : G, N, u))), N = p.length) : c === 0 && (h++, p = [0]), R[f++] = h, c && p[0] ? p[N++] = z[S] || 0 : (p = [z[S]], N = 1);
- while ((S++ < P || p[0] !== void 0) && w--);
- _ = p[0] !== void 0;
- }
- R[0] || R.shift();
- }
- if (d == 1)
- b.e = l, io = _;
- else {
- for (f = 1, h = R[0]; h >= 10; h /= 10) f++;
- b.e = f + l * d - 1, J(b, o ? n + b.e + 1 : n, s, _);
- }
- return b;
- };
- }();
- function J(i, a, e, t) {
- var r, n, s, o, u, c, l, f, h, d = i.constructor;
- e: if (a != null) {
- if (f = i.d, !f) return i;
- for (r = 1, o = f[0]; o >= 10; o /= 10) r++;
- if (n = a - r, n < 0)
- n += te, s = a, l = f[h = 0], u = l / Le(10, r - s - 1) % 10 | 0;
- else if (h = Math.ceil((n + 1) / te), o = f.length, h >= o)
- if (t) {
- for (; o++ <= h; ) f.push(0);
- l = u = 0, r = 1, n %= te, s = n - te + 1;
- } else
- break e;
- else {
- for (l = o = f[h], r = 1; o >= 10; o /= 10) r++;
- n %= te, s = n - te + r, u = s < 0 ? 0 : l / Le(10, r - s - 1) % 10 | 0;
- }
- if (t = t || a < 0 || f[h + 1] !== void 0 || (s < 0 ? l : l % 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.
- (n > 0 ? s > 0 ? l / Le(10, r - s) : 0 : f[h - 1]) % 10 & 1 || e == (i.s < 0 ? 8 : 7)), a < 1 || !f[0])
- return f.length = 0, c ? (a -= i.e + 1, f[0] = Le(10, (te - a % te) % te), i.e = -a || 0) : f[0] = i.e = 0, i;
- if (n == 0 ? (f.length = h, o = 1, h--) : (f.length = h + 1, o = Le(10, te - n), f[h] = s > 0 ? (l / Le(10, r - s) % Le(10, s) | 0) * o : 0), c)
- for (; ; )
- if (h == 0) {
- for (n = 1, s = f[0]; s >= 10; s /= 10) n++;
- for (s = f[0] += o, o = 1; s >= 10; s /= 10) o++;
- n != o && (i.e++, f[0] == ut && (f[0] = 1));
- break;
- } else {
- if (f[h] += o, f[h] != ut) break;
- f[h--] = 0, o = 1;
- }
- for (n = f.length; f[--n] === 0; ) f.pop();
- }
- return ue && (i.e > d.maxE ? (i.d = null, i.e = NaN) : i.e < d.minE && (i.e = 0, i.d = [0])), i;
- }
- function Ct(i, a, e) {
- if (!i.isFinite()) return go(i);
- var t, r = i.e, n = Ue(i.d), s = n.length;
- return a ? (e && (t = e - s) > 0 ? n = n.charAt(0) + "." + n.slice(1) + Pt(t) : s > 1 && (n = n.charAt(0) + "." + n.slice(1)), n = n + (i.e < 0 ? "e" : "e+") + i.e) : r < 0 ? (n = "0." + Pt(-r - 1) + n, e && (t = e - s) > 0 && (n += Pt(t))) : r >= s ? (n += Pt(r + 1 - s), e && (t = e - r - 1) > 0 && (n = n + "." + Pt(t))) : ((t = r + 1) < s && (n = n.slice(0, t) + "." + n.slice(t)), e && (t = e - s) > 0 && (r + 1 === s && (n += "."), n += Pt(t))), n;
- }
- function vn(i, a) {
- var e = i[0];
- for (a *= te; e >= 10; e /= 10) a++;
- return a;
- }
- function dn(i, a, e) {
- if (a > _l)
- throw ue = !0, e && (i.precision = e), Error(oo);
- return J(new i(mn), a, 1, !0);
- }
- function ot(i, a, e) {
- if (a > Us) throw Error(oo);
- return J(new i(gn), a, e, !0);
- }
- function fo(i) {
- var a = i.length - 1, e = a * te + 1;
- if (a = i[a], a) {
- for (; a % 10 == 0; a /= 10) e--;
- for (a = i[0]; a >= 10; a /= 10) e++;
- }
- return e;
- }
- function Pt(i) {
- for (var a = ""; i--; ) a += "0";
- return a;
- }
- function ho(i, a, e, t) {
- var r, n = new i(1), s = Math.ceil(t / te + 4);
- for (ue = !1; ; ) {
- if (e % 2 && (n = n.times(a), hi(n.d, s) && (r = !0)), e = Be(e / 2), e === 0) {
- e = n.d.length - 1, r && n.d[e] === 0 && ++n.d[e];
- break;
- }
- a = a.times(a), hi(a.d, s);
- }
- return ue = !0, n;
- }
- function fi(i) {
- return i.d[i.d.length - 1] & 1;
- }
- function mo(i, a, e) {
- for (var t, r = new i(a[0]), n = 0; ++n < a.length; )
- if (t = new i(a[n]), t.s)
- r[e](t) && (r = t);
- else {
- r = t;
- break;
- }
- return r;
- }
- function vs(i, a) {
- var e, t, r, n, s, o, u, c = 0, l = 0, f = 0, h = i.constructor, d = h.rounding, _ = h.precision;
- if (!i.d || !i.d[0] || i.e > 17)
- return new h(i.d ? i.d[0] ? i.s < 0 ? 0 : 1 / 0 : 1 : i.s ? i.s < 0 ? 0 : i : NaN);
- for (a == null ? (ue = !1, u = _) : u = a, o = new h(0.03125); i.e > -2; )
- i = i.times(o), f += 5;
- for (t = Math.log(Le(2, f)) / Math.LN10 * 2 + 5 | 0, u += t, e = n = s = new h(1), h.precision = u; ; ) {
- if (n = J(n.times(i), u, 1), e = e.times(++l), o = s.plus(pe(n, e, u, 1)), Ue(o.d).slice(0, u) === Ue(s.d).slice(0, u)) {
- for (r = f; r--; ) s = J(s.times(s), u, 1);
- if (a == null)
- if (c < 3 && Lr(s.d, u - t, d, c))
- h.precision = u += 10, e = n = o = new h(1), l = 0, c++;
- else
- return J(s, h.precision = _, d, ue = !0);
- else
- return h.precision = _, s;
- }
- s = o;
- }
- }
- function jt(i, a) {
- var e, t, r, n, s, o, u, c, l, f, h, d = 1, _ = 10, C = i, E = C.d, b = C.constructor, R = b.rounding, p = b.precision;
- if (C.s < 0 || !E || !E[0] || !C.e && E[0] == 1 && E.length == 1)
- return new b(E && !E[0] ? -1 / 0 : C.s != 1 ? NaN : E ? 0 : C);
- if (a == null ? (ue = !1, l = p) : l = a, b.precision = l += _, e = Ue(E), t = e.charAt(0), Math.abs(n = C.e) < 15e14) {
- for (; t < 7 && t != 1 || t == 1 && e.charAt(1) > 3; )
- C = C.times(i), e = Ue(C.d), t = e.charAt(0), d++;
- n = C.e, t > 1 ? (C = new b("0." + e), n++) : C = new b(t + "." + e.slice(1));
- } else
- return c = dn(b, l + 2, p).times(n + ""), C = jt(new b(t + "." + e.slice(1)), l - _).plus(c), b.precision = p, a == null ? J(C, p, R, ue = !0) : C;
- for (f = C, u = s = C = pe(C.minus(1), C.plus(1), l, 1), h = J(C.times(C), l, 1), r = 3; ; ) {
- if (s = J(s.times(h), l, 1), c = u.plus(pe(s, new b(r), l, 1)), Ue(c.d).slice(0, l) === Ue(u.d).slice(0, l))
- if (u = u.times(2), n !== 0 && (u = u.plus(dn(b, l + 2, p).times(n + ""))), u = pe(u, new b(d), l, 1), a == null)
- if (Lr(u.d, l - _, R, o))
- b.precision = l += _, c = s = C = pe(f.minus(1), f.plus(1), l, 1), h = J(C.times(C), l, 1), r = o = 1;
- else
- return J(u, b.precision = p, R, ue = !0);
- else
- return b.precision = p, u;
- u = c, r += 2;
- }
- }
- function go(i) {
- return String(i.s * i.s / 0);
- }
- function Ts(i, a) {
- var e, t, r;
- for ((e = a.indexOf(".")) > -1 && (a = a.replace(".", "")), (t = a.search(/e/i)) > 0 ? (e < 0 && (e = t), e += +a.slice(t + 1), a = a.substring(0, t)) : e < 0 && (e = a.length), t = 0; a.charCodeAt(t) === 48; t++) ;
- for (r = a.length; a.charCodeAt(r - 1) === 48; --r) ;
- if (a = a.slice(t, r), a) {
- if (r -= t, i.e = e = e - t - 1, i.d = [], t = (e + 1) % te, e < 0 && (t += te), t < r) {
- for (t && i.d.push(+a.slice(0, t)), r -= te; t < r; ) i.d.push(+a.slice(t, t += te));
- a = a.slice(t), t = te - a.length;
- } else
- t -= r;
- for (; t--; ) a += "0";
- i.d.push(+a), ue && (i.e > i.constructor.maxE ? (i.d = null, i.e = NaN) : i.e < i.constructor.minE && (i.e = 0, i.d = [0]));
- } else
- i.e = 0, i.d = [0];
- return i;
- }
- function El(i, a) {
- var e, t, r, n, s, o, u, c, l;
- if (a.indexOf("_") > -1) {
- if (a = a.replace(/(\d)_(?=\d)/g, "$1"), lo.test(a)) return Ts(i, a);
- } else if (a === "Infinity" || a === "NaN")
- return +a || (i.s = NaN), i.e = NaN, i.d = null, i;
- if (gl.test(a))
- e = 16, a = a.toLowerCase();
- else if (ml.test(a))
- e = 2;
- else if (dl.test(a))
- e = 8;
- else
- throw Error(Bt + a);
- for (n = a.search(/p/i), n > 0 ? (u = +a.slice(n + 1), a = a.substring(2, n)) : a = a.slice(2), n = a.indexOf("."), s = n >= 0, t = i.constructor, s && (a = a.replace(".", ""), o = a.length, n = o - n, r = ho(t, new t(e), n, n * 2)), c = sn(a, e, ut), l = c.length - 1, n = l; c[n] === 0; --n) c.pop();
- return n < 0 ? new t(i.s * 0) : (i.e = vn(c, l), i.d = c, ue = !1, s && (i = pe(i, r, o * 4)), u && (i = i.times(Math.abs(u) < 54 ? Le(2, u) : L.pow(2, u))), ue = !0, i);
- }
- function bl(i, a) {
- var e, t = a.d.length;
- if (t < 3)
- return a.isZero() ? a : dr(i, 2, a, a);
- e = 1.4 * Math.sqrt(t), e = e > 16 ? 16 : e | 0, a = a.times(1 / Tn(5, e)), a = dr(i, 2, a, a);
- for (var r, n = new i(5), s = new i(16), o = new i(20); e--; )
- r = a.times(a), a = a.times(n.plus(r.times(s.times(r).minus(o))));
- return a;
- }
- function dr(i, a, e, t, r) {
- var n, s, o, u, c = i.precision, l = Math.ceil(c / te);
- for (ue = !1, u = e.times(e), o = new i(t); ; ) {
- if (s = pe(o.times(u), new i(a++ * a++), c, 1), o = r ? t.plus(s) : t.minus(s), t = pe(s.times(u), new i(a++ * a++), c, 1), s = o.plus(t), s.d[l] !== void 0) {
- for (n = l; s.d[n] === o.d[n] && n--; ) ;
- if (n == -1) break;
- }
- n = o, o = t, t = s, s = n;
- }
- return ue = !0, s.d.length = l + 1, s;
- }
- function Tn(i, a) {
- for (var e = i; --a; ) e *= i;
- return e;
- }
- function Co(i, a) {
- var e, t = a.s < 0, r = ot(i, i.precision, 1), n = r.times(0.5);
- if (a = a.abs(), a.lte(n))
- return Rt = t ? 4 : 1, a;
- if (e = a.divToInt(r), e.isZero())
- Rt = t ? 3 : 2;
- else {
- if (a = a.minus(e.times(r)), a.lte(n))
- return Rt = fi(e) ? t ? 2 : 3 : t ? 4 : 1, a;
- Rt = fi(e) ? t ? 1 : 4 : t ? 3 : 2;
- }
- return a.minus(r).abs();
- }
- function ga(i, a, e, t) {
- var r, n, s, o, u, c, l, f, h, d = i.constructor, _ = e !== void 0;
- if (_ ? (He(e, 1, $t), t === void 0 ? t = d.rounding : He(t, 0, 8)) : (e = d.precision, t = d.rounding), !i.isFinite())
- l = go(i);
- else {
- for (l = Ct(i), s = l.indexOf("."), _ ? (r = 2, a == 16 ? e = e * 4 - 3 : a == 8 && (e = e * 3 - 2)) : r = a, s >= 0 && (l = l.replace(".", ""), h = new d(1), h.e = l.length - s, h.d = sn(Ct(h), 10, r), h.e = h.d.length), f = sn(l, 10, r), n = u = f.length; f[--u] == 0; ) f.pop();
- if (!f[0])
- l = _ ? "0p+0" : "0";
- else {
- if (s < 0 ? n-- : (i = new d(i), i.d = f, i.e = n, i = pe(i, h, e, t, 0, r), f = i.d, n = i.e, c = io), s = f[e], o = r / 2, c = c || f[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 && f[e - 1] & 1 || t === (i.s < 0 ? 8 : 7)), f.length = e, c)
- for (; ++f[--e] > r - 1; )
- f[e] = 0, e || (++n, f.unshift(1));
- for (u = f.length; !f[u - 1]; --u) ;
- for (s = 0, l = ""; s < u; s++) l += xs.charAt(f[s]);
- if (_) {
- if (u > 1)
- if (a == 16 || a == 8) {
- for (s = a == 16 ? 4 : 3, --u; u % s; u++) l += "0";
- for (f = sn(l, r, a), u = f.length; !f[u - 1]; --u) ;
- for (s = 1, l = "1."; s < u; s++) l += xs.charAt(f[s]);
- } else
- l = l.charAt(0) + "." + l.slice(1);
- l = l + (n < 0 ? "p" : "p+") + n;
- } else if (n < 0) {
- for (; ++n; ) l = "0" + l;
- l = "0." + l;
- } else if (++n > u) for (n -= u; n--; ) l += "0";
- else n < u && (l = l.slice(0, n) + "." + l.slice(n));
- }
- l = (a == 16 ? "0x" : a == 2 ? "0b" : a == 8 ? "0o" : "") + l;
- }
- return i.s < 0 ? "-" + l : l;
- }
- function hi(i, a) {
- if (i.length > a)
- return i.length = a, !0;
- }
- function yl(i) {
- return new this(i).abs();
- }
- function Rl(i) {
- return new this(i).acos();
- }
- function pl(i) {
- return new this(i).acosh();
- }
- function Vl(i, a) {
- return new this(i).plus(a);
- }
- function Nl(i) {
- return new this(i).asin();
- }
- function Ol(i) {
- return new this(i).asinh();
- }
- function Ml(i) {
- return new this(i).atan();
- }
- function wl(i) {
- return new this(i).atanh();
- }
- function Dl(i, a) {
- i = new this(i), a = new this(a);
- var e, t = this.precision, r = this.rounding, n = t + 4;
- return !i.s || !a.s ? e = new this(NaN) : !i.d && !a.d ? (e = ot(this, n, 1).times(a.s > 0 ? 0.25 : 0.75), e.s = i.s) : !a.d || i.isZero() ? (e = a.s < 0 ? ot(this, t, r) : new this(0), e.s = i.s) : !i.d || a.isZero() ? (e = ot(this, n, 1).times(0.5), e.s = i.s) : a.s < 0 ? (this.precision = n, this.rounding = 1, e = this.atan(pe(i, a, n, 1)), a = ot(this, n, 1), this.precision = t, this.rounding = r, e = i.s < 0 ? e.minus(a) : e.plus(a)) : e = this.atan(pe(i, a, n, 1)), e;
- }
- function Sl(i) {
- return new this(i).cbrt();
- }
- function Pl(i) {
- return J(i = new this(i), i.e + 1, 2);
- }
- function Ll(i, a, e) {
- return new this(i).clamp(a, e);
- }
- function xl(i) {
- if (!i || typeof i != "object") throw Error(Un + "Object expected");
- var a, e, t, r = i.defaults === !0, n = [
- "precision",
- 1,
- $t,
- "rounding",
- 0,
- 8,
- "toExpNeg",
- -9e15,
- 0,
- "toExpPos",
- 0,
- Ls,
- "maxE",
- 0,
- Ls,
- "minE",
- -9e15,
- 0,
- "modulo",
- 0,
- 9
- ];
- for (a = 0; a < n.length; a += 3)
- if (e = n[a], r && (this[e] = js[e]), (t = i[e]) !== void 0)
- if (Be(t) === t && t >= n[a + 1] && t <= n[a + 2]) this[e] = t;
- else throw Error(Bt + e + ": " + t);
- if (e = "crypto", r && (this[e] = js[e]), (t = i[e]) !== void 0)
- if (t === !0 || t === !1 || t === 0 || t === 1)
- if (t)
- if (typeof crypto < "u" && crypto && (crypto.getRandomValues || crypto.randomBytes))
- this[e] = !0;
- else
- throw Error(uo);
- else
- this[e] = !1;
- else
- throw Error(Bt + e + ": " + t);
- return this;
- }
- function jl(i) {
- return new this(i).cos();
- }
- function Ul(i) {
- return new this(i).cosh();
- }
- function _o(i) {
- var a, e, t;
- function r(n) {
- var s, o, u, c = this;
- if (!(c instanceof r)) return new r(n);
- if (c.constructor = r, mi(n)) {
- c.s = n.s, ue ? !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);
- return;
- }
- if (u = typeof n, u === "number") {
- if (n === 0) {
- c.s = 1 / n < 0 ? -1 : 1, c.e = 0, c.d = [0];
- return;
- }
- if (n < 0 ? (n = -n, c.s = -1) : c.s = 1, n === ~~n && n < 1e7) {
- for (s = 0, o = n; o >= 10; o /= 10) s++;
- ue ? 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]);
- return;
- } else if (n * 0 !== 0) {
- n || (c.s = NaN), c.e = NaN, c.d = null;
- return;
- }
- return Ts(c, n.toString());
- } else if (u !== "string")
- throw Error(Bt + n);
- 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);
- }
- if (r.prototype = B, 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 = nf, r.tanh = sf, r.trunc = af, i === void 0 && (i = {}), i && i.defaults !== !0)
- for (t = ["precision", "rounding", "toExpNeg", "toExpPos", "maxE", "minE", "modulo", "crypto"], a = 0; a < t.length; ) i.hasOwnProperty(e = t[a++]) || (i[e] = this[e]);
- return r.config(i), r;
- }
- function vl(i, a) {
- return new this(i).div(a);
- }
- function Tl(i) {
- return new this(i).exp();
- }
- function Bl(i) {
- return J(i = new this(i), i.e + 1, 3);
- }
- function Il() {
- var i, a, e = new this(0);
- for (ue = !1, i = 0; i < arguments.length; )
- if (a = new this(arguments[i++]), a.d)
- e.d && (e = e.plus(a.times(a)));
- else {
- if (a.s)
- return ue = !0, new this(1 / 0);
- e = a;
- }
- return ue = !0, e.sqrt();
- }
- function mi(i) {
- return i instanceof L || i && i.toStringTag === co || !1;
- }
- function Fl(i) {
- return new this(i).ln();
- }
- function kl(i, a) {
- return new this(i).log(a);
- }
- function $l(i) {
- return new this(i).log(2);
- }
- function Yl(i) {
- return new this(i).log(10);
- }
- function Hl() {
- return mo(this, arguments, "lt");
- }
- function Gl() {
- return mo(this, arguments, "gt");
- }
- function Ql(i, a) {
- return new this(i).mod(a);
- }
- function Wl(i, a) {
- return new this(i).mul(a);
- }
- function ql(i, a) {
- return new this(i).pow(a);
- }
- function Kl(i) {
- var a, e, t, r, n = 0, s = new this(1), o = [];
- if (i === void 0 ? i = this.precision : He(i, 1, $t), t = Math.ceil(i / te), this.crypto)
- if (crypto.getRandomValues)
- for (a = crypto.getRandomValues(new Uint32Array(t)); n < t; )
- r = a[n], r >= 429e7 ? a[n] = crypto.getRandomValues(new Uint32Array(1))[0] : o[n++] = r % 1e7;
- else if (crypto.randomBytes) {
- for (a = crypto.randomBytes(t *= 4); n < t; )
- r = a[n] + (a[n + 1] << 8) + (a[n + 2] << 16) + ((a[n + 3] & 127) << 24), r >= 214e7 ? crypto.randomBytes(4).copy(a, n) : (o.push(r % 1e7), n += 4);
- n = t / 4;
- } else
- throw Error(uo);
- else for (; n < t; ) o[n++] = Math.random() * 1e7 | 0;
- for (t = o[--n], i %= te, t && i && (r = Le(10, te - i), o[n] = (t / r | 0) * r); o[n] === 0; n--) o.pop();
- if (n < 0)
- e = 0, o = [0];
- else {
- for (e = -1; o[0] === 0; e -= te) o.shift();
- for (t = 1, r = o[0]; r >= 10; r /= 10) t++;
- t < te && (e -= te - t);
- }
- return s.e = e, s.d = o, s;
- }
- function Xl(i) {
- return J(i = new this(i), i.e + 1, this.rounding);
- }
- function Zl(i) {
- return i = new this(i), i.d ? i.d[0] ? i.s : 0 * i.s : i.s || NaN;
- }
- function zl(i) {
- return new this(i).sin();
- }
- function Jl(i) {
- return new this(i).sinh();
- }
- function ef(i) {
- return new this(i).sqrt();
- }
- function tf(i, a) {
- return new this(i).sub(a);
- }
- function rf() {
- var i = 0, a = arguments, e = new this(a[i]);
- for (ue = !1; e.s && ++i < a.length; ) e = e.plus(a[i]);
- return ue = !0, J(e, this.precision, this.rounding);
- }
- function nf(i) {
- return new this(i).tan();
- }
- function sf(i) {
- return new this(i).tanh();
- }
- function af(i) {
- return J(i = new this(i), i.e + 1, 1);
- }
- B[Symbol.for("nodejs.util.inspect.custom")] = B.toString;
- B[Symbol.toStringTag] = "Decimal";
- var L = B.constructor = _o(js);
- mn = new L(mn);
- gn = new L(gn);
- function of(i, a) {
- const e = i + a;
- return Number.isSafeInteger(e) ? e : new L(i).add(a).toNumber();
- }
- function uf(i, a) {
- const e = i - a;
- return Number.isSafeInteger(e) ? e : new L(i).sub(a).toNumber();
- }
- function Vr(i, a) {
- const e = i * a;
- return Number.isSafeInteger(e) ? e : new L(i).mul(a).toNumber();
- }
- function cf(i, a) {
- const e = i / a;
- return Number.isSafeInteger(e) ? e : new L(i).div(a).toNumber();
- }
- function vt(i, a) {
- const e = 10 ** Math.trunc(a), t = Bn(i, e);
- return Math.round(Vr(i, e) + t) / e;
- }
- function We(i, a) {
- const e = 10 ** Math.trunc(a), t = Bn(i, e);
- return Math.floor(Vr(i, e) + t) / e;
- }
- function Ye(i, a) {
- const e = 10 ** Math.trunc(a), t = Bn(i, e);
- return Math.ceil(Vr(i, e) - t) / e;
- }
- function Bn(i, a) {
- return Number.EPSILON * Math.max(1, Math.abs(Vr(i, a)));
- }
- function gi(i, a) {
- return i - a * Math.floor(i / a);
- }
- function lf(i, a) {
- return i ** a;
- }
- function ff(i) {
- return Math.sqrt(i);
- }
- function di(i, a) {
- return i === a;
- }
- function hf(i, a) {
- return i > a;
- }
- function mf(i, a) {
- return i >= a;
- }
- function gf(i, a) {
- return i < a;
- }
- function df(i, a) {
- return i <= a;
- }
- function Ci(i, a = 15) {
- return Number.parseFloat(i.toPrecision(a));
- }
- function Cf(i, a, e = Number.EPSILON) {
- return Math.abs(i - a) < e;
- }
- function _f(i, a = 12, e = 1e-10) {
- const t = Ci(i, a);
- return Cf(i, t, e) ? t : Ci(i);
- }
- function Af(i) {
- return i - Math.trunc(i);
- }
- const xn = class xn extends kt {
- static create() {
- return this._instance = this._instance || new xn(0), this._instance;
- }
- isNull() {
- return !0;
- }
- plus(a) {
- return y.create(0).plus(a);
- }
- minus(a) {
- return y.create(0).minus(a);
- }
- multiply(a) {
- return y.create(0).multiply(a);
- }
- divided(a) {
- return y.create(0).divided(a);
- }
- mod(a) {
- return y.create(0).mod(a);
- }
- compare(a, e) {
- return a.isString() ? j.create("").compare(a, e) : a.isBoolean() ? T.create(!1).compare(a, e) : y.create(0).compare(a, e);
- }
- concatenateFront(a) {
- return a.isArray() ? a.concatenateBack(j.create("")) : j.create(this.concatenate(a.getValue(), it.FRONT));
- }
- concatenateBack(a) {
- return a.isArray() ? a.concatenateFront(j.create("")) : j.create(this.concatenate(a.getValue(), it.BACK));
- }
- plusBy(a) {
- return y.create(0).plusBy(a);
- }
- minusBy(a) {
- return y.create(0).minusBy(a);
- }
- multiplyBy(a) {
- return y.create(0).multiplyBy(a);
- }
- dividedBy(a) {
- return y.create(0).dividedBy(a);
- }
- compareBy(a, e) {
- return typeof a == "string" ? j.create("").compareBy(a, e) : typeof a == "boolean" ? T.create(!1).compareBy(a, e) : y.create(0).compareBy(a, e);
- }
- pow(a) {
- return y.create(0).pow(a);
- }
- sqrt() {
- return y.create(0).sqrt();
- }
- cbrt() {
- return y.create(0).cbrt();
- }
- cos() {
- return y.create(0).cos();
- }
- cosh() {
- return y.create(0).cosh();
- }
- acos() {
- return y.create(0).acos();
- }
- acosh() {
- return y.create(0).acosh();
- }
- sin() {
- return y.create(0).sin();
- }
- sinh() {
- return y.create(0).sinh();
- }
- asin() {
- return y.create(0).asin();
- }
- asinh() {
- return y.create(0).asinh();
- }
- tan() {
- return y.create(0).tan();
- }
- tanh() {
- return y.create(0).tanh();
- }
- atan() {
- return y.create(0).atan();
- }
- atan2(a) {
- return y.create(0).atan2(a);
- }
- atanh() {
- return y.create(0).atanh();
- }
- log() {
- return g.create(m.NUM);
- }
- log10() {
- return g.create(m.NUM);
- }
- exp() {
- return y.create(0).exp();
- }
- abs() {
- return y.create(0).abs();
- }
- round(a) {
- return y.create(0).round(a);
- }
- floor(a) {
- return y.create(0).floor(a);
- }
- ceil(a) {
- return y.create(0).ceil(a);
- }
- convertToNumberObjectValue() {
- return y.create(0);
- }
- convertToBooleanObjectValue() {
- return T.create(!1);
- }
- };
- A(xn, "_instance");
- let ie = xn;
- const qt = class qt extends kt {
- constructor(e) {
- super(e);
- A(this, "_value", !1);
- this._value = e;
- }
- static create(e) {
- return e ? (this._instanceTrue = this._instanceTrue || new qt(!0), this._instanceTrue) : (this._instanceFalse = this._instanceFalse || new qt(!1), this._instanceFalse);
- }
- getValue() {
- return this._value;
- }
- isBoolean() {
- return !0;
- }
- getNegative() {
- const e = this.getValue();
- let t = 0;
- return e && (t = 1), y.create(-t);
- }
- getReciprocal() {
- return this.getValue() ? y.create(1) : g.create(m.DIV_BY_ZERO);
- }
- plus(e) {
- return this._convertToNumber().plus(e);
- }
- minus(e) {
- return this._convertToNumber().minus(e);
- }
- multiply(e) {
- return this._convertToNumber().multiply(e);
- }
- divided(e) {
- return this._convertToNumber().divided(e);
- }
- mod(e) {
- return this._convertToNumber().mod(e);
- }
- compare(e, t) {
- return e.isArray() ? e.compare(this, ma(t)) : e.isNull() ? this._convertToNumber().compare(e, t) : this.compareBy(e.getValue(), t);
- }
- compareBy(e, t) {
- let r = !1;
- if (typeof e == "string" || typeof e == "number")
- r = this._compareString(t);
- else if (typeof e == "boolean") {
- const n = y.create(e ? 1 : 0);
- return this._convertToNumber().compare(n, t);
- }
- return qt.create(r);
- }
- _compareString(e) {
- switch (e) {
- case $.GREATER_THAN:
- case $.GREATER_THAN_OR_EQUAL:
- return !0;
- case $.EQUALS:
- case $.LESS_THAN:
- case $.LESS_THAN_OR_EQUAL:
- case $.NOT_EQUAL:
- return !1;
- }
- }
- concatenateFront(e) {
- return this._convertToNumber().concatenateFront(e);
- }
- concatenateBack(e) {
- return this._convertToNumber().concatenateBack(e);
- }
- _convertToNumber() {
- const e = this.getValue();
- let t = 0;
- return e && (t = 1), y.create(t);
- }
- pow(e) {
- return this._convertToNumber().pow(e);
- }
- sqrt() {
- return this._convertToNumber().sqrt();
- }
- cbrt() {
- return this._convertToNumber().cbrt();
- }
- cos() {
- return this._convertToNumber().cos();
- }
- cosh() {
- return this._convertToNumber().cosh();
- }
- acos() {
- return this._convertToNumber().acos();
- }
- acosh() {
- return this._convertToNumber().acosh();
- }
- sin() {
- return this._convertToNumber().sin();
- }
- sinh() {
- return this._convertToNumber().sinh();
- }
- asin() {
- return this._convertToNumber().asin();
- }
- asinh() {
- return this._convertToNumber().asinh();
- }
- tan() {
- return this._convertToNumber().tan();
- }
- tanh() {
- return this._convertToNumber().tanh();
- }
- atan() {
- return this._convertToNumber().atan();
- }
- atan2(e) {
- return this._convertToNumber().atan2(e);
- }
- atanh() {
- return this._convertToNumber().atanh();
- }
- log() {
- return this._convertToNumber().log();
- }
- log10() {
- return this._convertToNumber().log10();
- }
- exp() {
- return this._convertToNumber().exp();
- }
- abs() {
- return this._convertToNumber().abs();
- }
- round(e) {
- return this._convertToNumber().round(e);
- }
- floor(e) {
- return this._convertToNumber().floor(e);
- }
- ceil(e) {
- return this._convertToNumber().ceil(e);
- }
- convertToNumberObjectValue() {
- return Fn(this.getValue());
- }
- convertToBooleanObjectValue() {
- return this;
- }
- };
- A(qt, "_instanceTrue"), A(qt, "_instanceFalse");
- let T = qt;
- class y extends kt {
- constructor(e) {
- super(e);
- A(this, "_value", 0);
- this._value = Number(e);
- }
- static create(e, t = "") {
- const r = new y(e);
- return t && r.setPattern(t), r;
- }
- getValue() {
- return this._value;
- }
- setValue(e) {
- this._value = e;
- }
- isNumber() {
- return !0;
- }
- getNegative() {
- return y.create(0).minus(this);
- }
- getReciprocal() {
- return y.create(1).divided(this);
- }
- plus(e) {
- if (e.isArray())
- return e.plus(this);
- let t = this.plusBy(e.getValue());
- if (t.isError())
- return t;
- const r = Wr(this.getPattern(), e.getPattern(), X.PLUS);
- return t = y.create(Number(t.getValue()), r), t;
- }
- equalZero() {
- return this._value === 0;
- }
- minus(e) {
- if (e.isArray()) {
- const n = e.getNegative();
- return n.isError() ? n : n.plus(this);
- }
- let t = this.minusBy(e.getValue());
- if (t.isError())
- return t;
- const r = Wr(this.getPattern(), e.getPattern(), X.MINUS);
- return t = y.create(Number(t.getValue()), r), t;
- }
- multiply(e) {
- if (e.isArray())
- return e.multiply(this);
- let t = this.multiplyBy(e.getValue());
- if (t.isError())
- return t;
- const r = Wr(this.getPattern(), e.getPattern(), X.MULTIPLY);
- return t = y.create(Number(t.getValue()), r), t;
- }
- divided(e) {
- if (e.isArray()) {
- const n = e.getReciprocal();
- return n.isError() ? n : n.multiply(this);
- }
- let t = this.dividedBy(e.getValue());
- if (t.isError())
- return t;
- const r = Wr(this.getPattern(), e.getPattern(), X.DIVIDED);
- return t = y.create(Number(t.getValue()), r), t;
- }
- mod(e) {
- if (e.isArray())
- return e.modInverse(this);
- const t = this.getValue(), r = e.getValue();
- if (e.isNull())
- return g.create(m.DIV_BY_ZERO);
- if (typeof r == "string")
- return g.create(m.VALUE);
- if (typeof r == "number") {
- if (r === 0)
- return g.create(m.DIV_BY_ZERO);
- if (!Number.isFinite(t) || !Number.isFinite(r) || Math.abs(r) * 11259e8 <= Math.abs(t))
- return g.create(m.NUM);
- const n = gi(t, r);
- return Number.isFinite(n) ? y.create(n) : g.create(m.NUM);
- }
- if (typeof r == "boolean") {
- const n = r ? 1 : 0;
- return n === 0 ? g.create(m.DIV_BY_ZERO) : y.create(gi(t, n));
- }
- return this;
- }
- concatenateFront(e) {
- return e.isArray() ? e.concatenateBack(this) : j.create(this.concatenate(e.getValue(), it.FRONT));
- }
- concatenateBack(e) {
- return e.isArray() ? e.concatenateFront(this) : j.create(this.concatenate(e.getValue(), it.BACK));
- }
- compare(e, t) {
- return e.isArray() ? e.compare(this, ma(t)) : this.compareBy(e.getValue(), t);
- }
- plusBy(e) {
- const t = +this.getValue(), r = +e;
- if (Number.isNaN(t) || Number.isNaN(r))
- return g.create(m.VALUE);
- if (!Number.isFinite(t) || !Number.isFinite(r))
- return g.create(m.NUM);
- const n = of(t, r);
- return Number.isFinite(n) ? y.create(n) : g.create(m.NUM);
- }
- minusBy(e) {
- const t = +this.getValue(), r = +e;
- if (Number.isNaN(t) || Number.isNaN(r))
- return g.create(m.VALUE);
- if (!Number.isFinite(t) || !Number.isFinite(r))
- return g.create(m.NUM);
- const n = uf(t, r);
- return Number.isFinite(n) ? y.create(n) : g.create(m.NUM);
- }
- multiplyBy(e) {
- const t = +this.getValue(), r = +e;
- if (Number.isNaN(t) || Number.isNaN(r))
- return g.create(m.VALUE);
- if (!Number.isFinite(t) || !Number.isFinite(r))
- return g.create(m.NUM);
- const n = Vr(t, r);
- return Number.isFinite(n) ? y.create(n) : g.create(m.NUM);
- }
- dividedBy(e) {
- const t = +this.getValue(), r = +e;
- if (Number.isNaN(t) || Number.isNaN(r))
- return g.create(m.VALUE);
- if (!Number.isFinite(t) || !Number.isFinite(r))
- return g.create(m.NUM);
- if (r === 0)
- return g.create(m.DIV_BY_ZERO);
- const n = cf(t, r);
- return Number.isFinite(n) ? y.create(n) : g.create(m.NUM);
- }
- compareBy(e, t) {
- const r = this.getValue();
- let n = !1;
- return typeof e == "string" ? n = this._compareString(t) : typeof e == "number" ? n = this._compareNumber(r, e, t) : typeof e == "boolean" && (n = this._compareBoolean(t)), T.create(n);
- }
- _compareString(e) {
- switch (e) {
- case $.EQUALS:
- case $.GREATER_THAN:
- case $.GREATER_THAN_OR_EQUAL:
- return !1;
- case $.LESS_THAN:
- case $.LESS_THAN_OR_EQUAL:
- case $.NOT_EQUAL:
- return !0;
- }
- }
- _compareNumber(e, t, r) {
- return !Number.isFinite(e) || !Number.isFinite(t) ? this._compareInfinity(e, t, r) : this._compareFiniteNumber(e, t, r);
- }
- _compareFiniteNumber(e, t, r) {
- switch (r) {
- case $.EQUALS:
- return di(e, t);
- case $.GREATER_THAN:
- return hf(e, t);
- case $.GREATER_THAN_OR_EQUAL:
- return mf(e, t);
- case $.LESS_THAN:
- return gf(e, t);
- case $.LESS_THAN_OR_EQUAL:
- return df(e, t);
- case $.NOT_EQUAL:
- return !di(e, t);
- }
- }
- _compareBoolean(e) {
- switch (e) {
- case $.EQUALS:
- case $.GREATER_THAN:
- case $.GREATER_THAN_OR_EQUAL:
- return !1;
- case $.LESS_THAN:
- case $.LESS_THAN_OR_EQUAL:
- case $.NOT_EQUAL:
- return !0;
- }
- }
- pow(e) {
- if (e.isArray())
- return e.powInverse(this);
- if (this.isError())
- return this;
- const t = this.getValue();
- let r = e;
- if (e.isString() && (r = e.convertToNumberObjectValue()), r.isError())
- return r;
- const n = +r.getValue();
- if (Number.isNaN(n))
- return g.create(m.VALUE);
- if (!Number.isFinite(t) || !Number.isFinite(n))
- return g.create(m.NUM);
- if (t === 0)
- return n < 0 ? g.create(m.DIV_BY_ZERO) : n === 0 ? g.create(m.NUM) : y.create(0);
- const s = lf(t, n);
- return Number.isFinite(s) ? y.create(s) : g.create(m.NUM);
- }
- sqrt() {
- const e = this.getValue();
- if (!Number.isFinite(e))
- return g.create(m.NUM);
- const t = ff(e);
- return Number.isFinite(t) ? y.create(t) : g.create(m.NUM);
- }
- cbrt() {
- const e = this.getValue();
- if (!Number.isFinite(e))
- return g.create(m.NUM);
- const t = Math.cbrt(e);
- return Number.isFinite(t) ? y.create(t) : g.create(m.NUM);
- }
- cos() {
- const e = this.getValue();
- if (!Number.isFinite(e))
- return g.create(m.NUM);
- const t = Math.cos(e);
- return Number.isFinite(t) ? y.create(t) : g.create(m.NUM);
- }
- cosh() {
- const e = this.getValue();
- if (!Number.isFinite(e))
- return g.create(m.NUM);
- const t = Math.cosh(e);
- return Number.isFinite(t) ? y.create(t) : g.create(m.NUM);
- }
- acos() {
- const e = this.getValue();
- if (!Number.isFinite(e))
- return g.create(m.NUM);
- const t = Math.acos(e);
- return Number.isNaN(t) ? g.create(m.NUM) : y.create(t);
- }
- acosh() {
- const e = this.getValue();
- if (!Number.isFinite(e))
- return g.create(m.NUM);
- const t = Math.acosh(e);
- return Number.isNaN(t) ? g.create(m.NUM) : y.create(t);
- }
- sin() {
- const e = this.getValue();
- if (!Number.isFinite(e))
- return g.create(m.NUM);
- const t = Math.sin(e);
- return Number.isFinite(t) ? y.create(t) : g.create(m.NUM);
- }
- sinh() {
- const e = this.getValue();
- if (!Number.isFinite(e))
- return g.create(m.NUM);
- const t = Math.sinh(e);
- return Number.isFinite(t) ? y.create(t) : g.create(m.NUM);
- }
- asin() {
- const e = this.getValue();
- if (!Number.isFinite(e))
- return g.create(m.NUM);
- const t = Math.asin(e);
- return Number.isNaN(t) ? g.create(m.NUM) : y.create(t);
- }
- asinh() {
- const e = this.getValue();
- if (!Number.isFinite(e))
- return g.create(m.NUM);
- const t = Math.asinh(e);
- return Number.isNaN(t) ? g.create(m.NUM) : y.create(t);
- }
- tan() {
- const e = this.getValue();
- if (!Number.isFinite(e))
- return g.create(m.NUM);
- const t = Math.tan(e);
- return Number.isFinite(t) ? y.create(t) : g.create(m.NUM);
- }
- tanh() {
- const e = this.getValue();
- if (!Number.isFinite(e))
- return g.create(m.NUM);
- const t = Math.tanh(e);
- return Number.isFinite(t) ? y.create(t) : g.create(m.NUM);
- }
- atan() {
- const e = this.getValue();
- if (!Number.isFinite(e))
- return g.create(m.NUM);
- const t = Math.atan(e);
- return Number.isFinite(t) ? y.create(t) : g.create(m.NUM);
- }
- atan2(e) {
- if (e.isArray())
- return e.atan2Inverse(this);
- const t = this.getValue(), r = e.getValue();
- if (typeof r == "string")
- return g.create(m.VALUE);
- if (typeof r == "number") {
- if (!Number.isFinite(t) || !Number.isFinite(r))
- return g.create(m.NUM);
- if (t === 0 && r === 0)
- return g.create(m.DIV_BY_ZERO);
- const n = Math.atan2(t, r);
- return Number.isFinite(n) ? y.create(n) : g.create(m.NUM);
- }
- return typeof r == "boolean" ? y.create(Math.atan2(t, r ? 1 : 0)) : this;
- }
- atanh() {
- const e = this.getValue();
- if (!Number.isFinite(e))
- return g.create(m.NUM);
- const t = Math.atanh(e);
- return Number.isFinite(t) ? y.create(t) : g.create(m.NUM);
- }
- log() {
- const e = this.getValue();
- if (typeof e == "number" && e <= 0 || !Number.isFinite(e))
- return g.create(m.NUM);
- const t = Math.log(e);
- return Number.isFinite(t) ? y.create(t) : g.create(m.NUM);
- }
- log10() {
- const e = this.getValue();
- if (typeof e == "number" && e <= 0 || !Number.isFinite(e))
- return g.create(m.NUM);
- const t = Math.log10(e);
- return Number.isFinite(t) ? y.create(t) : g.create(m.NUM);
- }
- exp() {
- const e = this.getValue();
- if (!Number.isFinite(e))
- return g.create(m.NUM);
- const t = Math.exp(e);
- return Number.isFinite(t) ? y.create(t) : g.create(m.NUM);
- }
- abs() {
- const e = this.getValue();
- if (!Number.isFinite(e))
- return g.create(m.NUM);
- const t = Math.abs(e);
- return Number.isFinite(t) ? y.create(t) : g.create(m.NUM);
- }
- round(e) {
- if (e.isArray())
- return e.roundInverse(this);
- const t = this.getValue(), r = e.getValue();
- if (typeof r == "string")
- return g.create(m.VALUE);
- if (typeof r == "number") {
- if (!Number.isFinite(t) || !Number.isFinite(r))
- return g.create(m.NUM);
- const n = t < 0 ? -vt(Math.abs(t), r) : vt(t, r);
- return Number.isFinite(n) ? y.create(n) : g.create(m.NUM);
- }
- return typeof r == "boolean" ? y.create(vt(t, r ? 1 : 0)) : this;
- }
- floor(e) {
- if (e.isArray())
- return e.floorInverse(this);
- const t = this.getValue(), r = e.getValue();
- if (typeof r == "string")
- return g.create(m.VALUE);
- if (typeof r == "number") {
- if (!Number.isFinite(t) || !Number.isFinite(r))
- return g.create(m.NUM);
- const n = t < 0 ? -We(Math.abs(t), r) : We(t, r);
- return Number.isFinite(n) ? y.create(n) : g.create(m.NUM);
- }
- return typeof r == "boolean" ? y.create(We(t, r ? 1 : 0)) : this;
- }
- ceil(e) {
- if (e.isArray())
- return e.ceilInverse(this);
- const t = this.getValue(), r = e.getValue();
- if (typeof r == "string")
- return g.create(m.VALUE);
- if (typeof r == "number") {
- if (!Number.isFinite(t) || !Number.isFinite(r))
- return g.create(m.NUM);
- const n = t < 0 ? -Ye(Math.abs(t), r) : Ye(t, r);
- return Number.isFinite(n) ? y.create(n) : g.create(m.NUM);
- }
- return typeof r == "boolean" ? y.create(Ye(t, r ? 1 : 0)) : this;
- }
- convertToNumberObjectValue() {
- return this;
- }
- convertToBooleanObjectValue() {
- return In(!0);
- }
- _compareInfinity(e, t, r) {
- let n = !1;
- switch (r) {
- case $.EQUALS:
- n = e === t;
- break;
- case $.GREATER_THAN:
- n = e > t;
- break;
- case $.GREATER_THAN_OR_EQUAL:
- n = e >= t;
- break;
- case $.LESS_THAN:
- n = e < t;
- break;
- case $.LESS_THAN_OR_EQUAL:
- n = e <= t;
- break;
- case $.NOT_EQUAL:
- n = e !== t;
- break;
- }
- return n;
- }
- }
- const Ef = 1e5, _i = new Vt(Ef);
- class j extends kt {
- constructor(e) {
- super(e);
- A(this, "_value");
- this._value = e;
- }
- static create(e) {
- const t = _i.get(e);
- if (t)
- return t;
- const r = new j(e);
- return _i.set(e, r), r;
- }
- getValue() {
- return this._value;
- }
- isString() {
- return !0;
- }
- concatenateFront(e) {
- return e.isArray() ? e.concatenateBack(this) : j.create(this.concatenate(e.getValue(), it.FRONT));
- }
- concatenateBack(e) {
- return e.isArray() ? e.concatenateFront(this) : j.create(this.concatenate(e.getValue(), it.BACK));
- }
- plus(e) {
- return this.convertToNumberObjectValue().plus(e);
- }
- minus(e) {
- return this.convertToNumberObjectValue().minus(e);
- }
- multiply(e) {
- return this.convertToNumberObjectValue().multiply(e);
- }
- divided(e) {
- return this.convertToNumberObjectValue().divided(e);
- }
- compare(e, t, r) {
- return e.isArray() ? e.compare(this, ma(t), r) : this.compareBy(e.getValue(), t, r);
- }
- compareBy(e, t, r = !1) {
- let n = this.getValue(), s = !1;
- if (typeof e == "string") {
- let o = e;
- if (r || (n = n.toLocaleLowerCase(), o = o.toLocaleLowerCase()), ll(o))
- return this._checkWildcard(o, t);
- s = this._compareString(n, o, t);
- } else typeof e == "number" ? s = this._compareNumber(t) : typeof e == "boolean" && (s = this._compareBoolean(t));
- return T.create(s);
- }
- _compareString(e, t, r) {
- switch (r) {
- case $.EQUALS:
- return e === t;
- case $.GREATER_THAN:
- return e > t;
- case $.GREATER_THAN_OR_EQUAL:
- return e >= t;
- case $.LESS_THAN:
- return e < t;
- case $.LESS_THAN_OR_EQUAL:
- return e <= t;
- case $.NOT_EQUAL:
- return e !== t;
- }
- }
- _compareNumber(e) {
- switch (e) {
- case $.NOT_EQUAL:
- case $.GREATER_THAN:
- case $.GREATER_THAN_OR_EQUAL:
- return !0;
- case $.EQUALS:
- case $.LESS_THAN:
- case $.LESS_THAN_OR_EQUAL:
- return !1;
- }
- }
- _compareBoolean(e) {
- switch (e) {
- case $.EQUALS:
- case $.GREATER_THAN:
- case $.GREATER_THAN_OR_EQUAL:
- return !1;
- case $.LESS_THAN:
- case $.LESS_THAN_OR_EQUAL:
- case $.NOT_EQUAL:
- return !0;
- }
- }
- convertToNumberObjectValue() {
- return Fn(this.getValue());
- }
- convertToBooleanObjectValue() {
- return T.create(!0);
- }
- _checkWildcard(e, t) {
- const r = this.getValue().toLocaleLowerCase(), n = fl(r, e, t);
- return T.create(n);
- }
- }
- function In(i) {
- if (typeof i == "boolean")
- return T.create(i);
- let a = !1;
- if (typeof i == "string") {
- const e = i.toLocaleUpperCase();
- e === er.TRUE ? a = !0 : e === er.FALSE && (a = !1);
- } else
- i === 1 ? a = !0 : a = !1;
- return T.create(a);
- }
- function bf(i) {
- let a = i.toString();
- return a.charAt(0) === '"' && a.charAt(a.length - 1) === '"' && (a = a.slice(1, -1), a = a.replace(/""/g, '"')), j.create(a);
- }
- function Fn(i, a = "") {
- if (typeof i == "boolean") {
- let e = 0;
- return i && (e = 1), y.create(e, a);
- } else {
- if (typeof i == "number")
- return Number.isFinite(i) ? y.create(i, a) : g.create(m.NUM);
- if (Q(i))
- return y.create(Number(i), a);
- }
- return g.create(m.VALUE);
- }
- function yf(i) {
- return "";
- }
- function Ao(i = []) {
- const a = [];
- for (let e = 0; e < i.length; e++) {
- const t = i[e];
- a[e] == null && (a[e] = []);
- for (let r = 0; r < t.length; r++) {
- const n = t[r];
- a[e][r] = pt.create(n);
- }
- }
- return a;
- }
- function Rf(i = []) {
- const a = [];
- for (let e = 0; e < i.length; e++) {
- const t = i[e];
- a[e] == null && (a[e] = []);
- for (let r = 0; r < t.length; r++) {
- const n = t[r];
- n == null ? a[e][r] = null : n.isError() ? a[e][r] = n.getErrorType() : a[e][r] = n.getValue();
- }
- }
- return a;
- }
- class q extends kt {
- constructor(e) {
- super(typeof e == "string" ? e : yf());
- A(this, "_values", []);
- A(this, "_rowCount", -1);
- A(this, "_columnCount", -1);
- A(this, "_unitId", "");
- A(this, "_sheetId", "");
- A(this, "_currentRow", -1);
- A(this, "_currentColumn", -1);
- A(this, "_sliceCache", /* @__PURE__ */ new Map());
- A(this, "_flattenCache");
- /**
- * The default value of the array, null values in comparison results support setting to false
- */
- A(this, "_defaultValue", null);
- A(this, "_flattenPosition");
- this._values = this._formatValue(e);
- }
- /**
- * Create an array value object based on the string or IArrayValueObject data.
- * @param rawValue
- * @returns
- */
- static create(e) {
- return new q(e);
- }
- /**
- * Create an array value object based on the array data.
- * @param array
- * @returns
- */
- static createByArray(e) {
- const r = {
- calculateValueList: Ao(e),
- rowCount: e.length,
- columnCount: e[0].length || 0,
- unitId: "",
- sheetId: "",
- row: -1,
- column: -1
- };
- return new q(r);
- }
- dispose() {
- this._values = [], this._defaultValue = null, this._flattenPosition = null, this._clearCache();
- }
- clone() {
- return this.map((e) => e);
- }
- getRowCount() {
- return this._rowCount;
- }
- setRowCount(e) {
- this._rowCount = e;
- }
- getColumnCount() {
- return this._columnCount;
- }
- setColumnCount(e) {
- this._columnCount = e;
- }
- setCurrent(e, t) {
- this._currentRow = e, this._currentColumn = t;
- }
- setUnitId(e) {
- this._unitId = e;
- }
- getUnitId() {
- return this._unitId;
- }
- setSheetId(e) {
- this._sheetId = e;
- }
- getSheetId() {
- return this._sheetId;
- }
- getCurrentRow() {
- return this._currentRow;
- }
- getCurrentColumn() {
- return this._currentColumn;
- }
- getArrayValue() {
- return this._values;
- }
- setArrayValue(e) {
- this._clearCache(), this._values = e;
- }
- isArray() {
- return !0;
- }
- setDefaultValue(e) {
- this._defaultValue = e;
- }
- get(e, t) {
- var r;
- return ((r = this._values[e]) == null ? void 0 : r[t]) || this._defaultValue;
- }
- getRealValue(e, t) {
- const r = this._values[e];
- if (r == null)
- return null;
- const n = r[t];
- return n == null ? null : n;
- }
- getValueOrDefault(e, t) {
- return this.get(e, t) || this._defaultValue;
- }
- set(e, t, r) {
- if (e >= this._rowCount || t >= this._columnCount)
- throw new Error("Exceeding array bounds.");
- this._clearCache(), this._values[e][t] = r;
- }
- getRangePosition() {
- const t = this.getRowCount(), r = 0, n = this.getColumnCount();
- return {
- startRow: 0,
- endRow: t - 1,
- startColumn: r,
- endColumn: n - 1
- };
- }
- iterator(e) {
- var u;
- const { startRow: t, endRow: r, startColumn: n, endColumn: s } = this.getRangePosition(), o = this.getArrayValue();
- for (let c = t; c <= r; c++)
- for (let l = n; l <= s; l++)
- if (e(((u = o[c]) == null ? void 0 : u[l]) || this._defaultValue, c, l) === !1)
- return;
- }
- iteratorReverse(e) {
- var u;
- const { startRow: t, endRow: r, startColumn: n, endColumn: s } = this.getRangePosition(), o = this.getArrayValue();
- for (let c = r; c >= t; c--)
- for (let l = s; l >= n; l--)
- if (e(((u = o[c]) == null ? void 0 : u[l]) || this._defaultValue, c, l) === !1)
- return;
- }
- getLastTruePosition() {
- let e;
- return this.iteratorReverse((t, r, n) => {
- if (t != null && t.isBoolean() && t.getValue() === !0)
- return e = {
- row: r,
- column: n
- }, !1;
- }), e;
- }
- getFirstTruePosition() {
- let e;
- return this.iterator((t, r, n) => {
- if (t != null && t.isBoolean() && t.getValue() === !0)
- return e = {
- row: r,
- column: n
- }, !1;
- }), e;
- }
- getFirstCell() {
- const { startRow: e, startColumn: t } = this.getRangePosition();
- return this.get(e, t) || this._defaultValue || ie.create();
- }
- getLastCell() {
- const { endRow: e, endColumn: t } = this.getRangePosition();
- return this.get(e, t) || this._defaultValue || ie.create();
- }
- /**
- * Referring to matrix calculations,
- * extract the matching values from a true/false matrix based on parameters and store them in a two-dimensional array.
- * implement x[x<10]
- * https://numpy.org/doc/stable/user/basics.indexing.html
- * @param takeArray
- */
- pick(e) {
- const t = this.pickRaw(e);
- return this._createNewArray(t, 1, t[0].length);
- }
- pickRaw(e) {
- const t = e.getRowCount(), r = e.getColumnCount();
- if (t !== this._rowCount || r !== this._columnCount)
- return [[ie.create()]];
- const n = [];
- n[0] = [];
- for (let s = 0; s < t; s++)
- for (let o = 0; o < r; o++) {
- const u = e.get(s, o);
- if (!(u == null || u.isError()) && u.getValue() === !0) {
- const c = this.get(s, o);
- n[0].push(c);
- }
- }
- return n;
- }
- /**
- * Flatten a 2D array.
- * https://numpy.org/doc/stable/reference/generated/numpy.chararray.flatten.html#numpy.chararray.flatten
- */
- flatten() {
- if (this._flattenCache != null)
- return this._flattenCache;
- const e = [];
- e[0] = [];
- for (let r = 0; r < this._rowCount; r++)
- for (let n = 0; n < this._columnCount; n++) {
- const s = this.get(r, n);
- e[0].push(s);
- }
- const t = this._createNewArray(e, 1, e[0].length);
- return t.setDefaultValue(this._defaultValue), this._flattenCache = t, t;
- }
- /**
- * Flatten a 2D array.
- * In Excel, errors and blank cells are ignored, which results in a binary search that cannot strictly adhere to the number of cells.
- */
- flattenPosition() {
- if (this._flattenPosition != null)
- return this._flattenPosition;
- const e = [], t = [], r = [], n = [];
- let s = 0;
- for (let u = 0; u < this._rowCount; u++)
- for (let c = 0; c < this._columnCount; c++) {
- const l = this.get(u, c);
- if (l == null || l.isError() || l.isNull()) {
- s++;
- continue;
- }
- l.isString() ? (e.push(l), r.push(s++)) : (t.push(l), n.push(s++));
- }
- const o = {
- stringArray: e,
- numberArray: t,
- stringPosition: r,
- numberPosition: n
- };
- return this._flattenPosition = o, o;
- }
- /**
- * I'm looking to perform slicing operations on 2D arrays, similar to the functionality provided by NumPy.
- * https://numpy.org/doc/stable/user/basics.indexing.html
- * @rowParam start:stop:step
- * @columnParam start:stop:step
- * @param takeArray
- */
- slice(e, t) {
- let r = 0, n = this._rowCount, s = 1, o = 0, u = this._columnCount, c = 1;
- 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)
- return;
- const l = `${r}_${n}_${s}_${o}_${u}_${c}`, f = this._sliceCache.get(l);
- if (f != null)
- return f;
- const h = [], d = this._values;
- let _ = 0, C = 0;
- for (let p = r; p < n; p += s) {
- C = 0, h[_] == null && (h[_] = []);
- for (let N = o; N < u; N += c) {
- if (!d[p])
- return;
- let M = d[p][N] || this._defaultValue;
- M == null && (M = ie.create()), h[_][C] = M, C++;
- }
- _++;
- }
- if (h.length === 0 || h[0].length === 0)
- return;
- const E = s > 1 ? -1 : r + this._currentRow, b = c > 1 ? -1 : o + this._currentColumn, R = this._createNewArray(h, h.length, h[0].length, E, b);
- return R.setDefaultValue(this._defaultValue), this._sliceCache.set(l, R), R;
- }
- sortByRow(e) {
- const t = this._transposeArray(this._values);
- t.sort(this._sort(e)), this._clearCache(), this._values = this._transposeArray(t);
- }
- sortByColumn(e) {
- this._clearCache(), this._values.sort(this._sort(e));
- }
- transpose() {
- const e = this._transposeArray(this._values), t = this._rowCount, r = this._columnCount, n = this._createNewArray(e, r, t);
- return n.setDefaultValue(this._defaultValue), n;
- }
- /**
- * Due to the inability to effectively utilize the cache,
- * the sequential matching approach is only used for special matches in XLOOKUP and XMATCH.
- * For example, when match_mode is set to 1 and -1 for an exact match. If not found, it returns the next smaller item.
- */
- orderSearch(e, t = Pe.MIN, r = !1, n = !1) {
- let s, o, u, c;
- const l = (f, h, d) => {
- if (f == null)
- return !0;
- let _;
- if (n === !0 ? _ = f.compare(e, $.EQUALS) : _ = f.isEqual(e), (_ == null ? void 0 : _.getValue()) === !0)
- return s = f, u = { row: h, column: d }, !1;
- t === Pe.MAX ? f.isGreaterThan(e).getValue() === !0 && (o == null || f.minus(e).abs().isLessThanOrEqual(o.minus(e).abs()).getValue() === !0) && (o = f, c = { row: h, column: d }) : t === Pe.MIN && f.isLessThan(e).getValue() === !0 && (o == null || f.minus(e).abs().isLessThanOrEqual(o.minus(e).abs()).getValue() === !0) && (o = f, c = { row: h, column: d });
- };
- if (r ? this.iteratorReverse((f, h, d) => l(f, h, d)) : this.iterator((f, h, d) => l(f, h, d)), s != null)
- return u;
- if (o != null)
- return c;
- }
- binarySearch(e, t = Wt.MIN, r = Pe.MIN) {
- if (e.isError())
- return;
- const { stringArray: n, stringPosition: s, numberArray: o, numberPosition: u } = this.flattenPosition();
- return e.isString() ? this._binarySearch(e, n, s, t, r) : this._binarySearch(e, o, u, t, r);
- }
- /**
- * searchType defaults to ascending order
- *
- * matchType defaults to the maximum value less than the search value, which is used for the default matching mode of VLOOKUP/LOOKUP/HLOOKUP.
- * @param valueObject
- * @param searchArray
- * @param positionArray
- * @param searchType
- * @param matchType
- * @returns
- */
- _binarySearch(e, t, r, n = Wt.MIN, s = Pe.MIN) {
- const o = hn(), u = Number(e.getValue()), c = !Number.isNaN(u);
- let l = 0, f = t.length - 1, h = -1, d = -1, _ = -1;
- for (; l <= f; ) {
- const C = Math.floor((l + f) / 2), E = t[C];
- let b;
- if (E.isNull())
- b = n === Wt.MIN ? 1 : -1;
- else {
- const R = E.getValue();
- if (c) {
- const p = Number(R);
- b = Number.isNaN(p) ? 1 : Math.sign(p - u);
- } else
- b = o(R.toString().toLocaleLowerCase(), e.getValue().toString().toLocaleLowerCase());
- }
- if (n === Wt.MAX && (b = -b), b === 0) {
- h = C;
- break;
- }
- b < 0 ? (d = C, l = C + 1) : (_ = C, f = C - 1);
- }
- if (s === Pe.NORMAL)
- return h !== -1 ? r[h] : void 0;
- if (s === Pe.MIN)
- return h !== -1 ? r[h] : n === Wt.MIN ? r[d] : r[_];
- if (s === Pe.MAX)
- return h !== -1 ? r[h] : n === Wt.MIN ? r[_] : r[d];
- }
- sum() {
- let e = y.create(0);
- return this.iterator((t) => {
- if (t == null || t.isString() || t.isBoolean() || t.isNull())
- return !0;
- if (t.isError())
- return e = t, !1;
- e = e.plus(
- t
- );
- }), e;
- }
- max() {
- let e = y.create(Number.NEGATIVE_INFINITY);
- return this.iterator((t) => {
- if (t == null)
- return !0;
- if (t.isError())
- return e = t, !1;
- if (t.isString() || t.isNull() || t.isBoolean())
- return !0;
- e.isLessThan(t).getValue() && (e = t);
- }), e;
- }
- min() {
- let e = y.create(Number.POSITIVE_INFINITY);
- return this.iterator((t) => {
- if (t == null)
- return !0;
- if (t.isError())
- return e = t, !1;
- if (t.isString() || t.isNull() || t.isBoolean())
- return !0;
- e.isGreaterThan(t).getValue() && (e = t);
- }), e;
- }
- count() {
- let e = y.create(0);
- return this.iterator((t) => {
- if (t == null || t.isError() || t.isString() || t.isNull() || t.isBoolean())
- return !0;
- e = e.plusBy(1);
- }), e;
- }
- countA() {
- let e = y.create(0);
- return this.iterator((t) => {
- if (t == null || t.isNull())
- return !0;
- e = e.plusBy(1);
- }), e;
- }
- countBlank() {
- let e = y.create(0);
- return this.iterator((t) => {
- (t == null || t.isNull() || t.getValue() === "") && (e = e.plusBy(1));
- }), e;
- }
- getNegative() {
- return q.create("{0}").minus(this);
- }
- getReciprocal() {
- return q.create("{1}").divided(this);
- }
- plus(e) {
- return this._batchOperator(
- e,
- 1
- /* PLUS */
- );
- }
- minus(e) {
- return this._batchOperator(
- e,
- 0
- /* MINUS */
- );
- }
- multiply(e) {
- return this._batchOperator(
- e,
- 2
- /* MULTIPLY */
- );
- }
- divided(e) {
- return this._batchOperator(
- e,
- 3
- /* DIVIDED */
- );
- }
- mod(e) {
- return this._batchOperator(
- e,
- 4
- /* MOD */
- );
- }
- modInverse(e) {
- return this.map((t) => t.isError() ? t : e.mod(t));
- }
- compare(e, t, r) {
- return this._batchOperator(e, 5, t, r);
- }
- concatenateFront(e) {
- return this._batchOperator(
- e,
- 6
- /* CONCATENATE_FRONT */
- );
- }
- concatenateBack(e) {
- return this._batchOperator(
- e,
- 7
- /* CONCATENATE_BACK */
- );
- }
- map(e) {
- const t = (r, n, s) => r == null ? ie.create() : r.isError() ? r : e(r, n, s);
- return this.mapValue(t);
- }
- mapValue(e) {
- var s;
- const t = this._rowCount, r = this._columnCount, n = [];
- for (let o = 0; o < t; o++) {
- const u = [];
- for (let c = 0; c < r; c++) {
- const l = (s = this._values) == null ? void 0 : s[o];
- if (l == null)
- u[c] = g.create(m.VALUE);
- else {
- const f = l[c] || this._defaultValue;
- f ? u[c] = e(f, o, c) : u[c] = ie.create();
- }
- }
- n.push(u);
- }
- return this._createNewArray(n, t, r);
- }
- pow(e) {
- return this._batchOperator(
- e,
- 8
- /* POW */
- );
- }
- /**
- *
- * @param valueObject In the case of an inverse, it is certainly not an array.
- * @returns
- */
- powInverse(e) {
- return this.map((t) => t.isError() ? t : e.pow(t));
- }
- sqrt() {
- return this.map((e) => e.isError() ? e : e.sqrt());
- }
- cbrt() {
- return this.map((e) => e.isError() ? e : e.cbrt());
- }
- cos() {
- return this.map((e) => e.isError() ? e : e.cos());
- }
- cosh() {
- return this.map((e) => e.isError() ? e : e.cosh());
- }
- acos() {
- return this.map((e) => e.isError() ? e : e.acos());
- }
- acosh() {
- return this.map((e) => e.isError() ? e : e.acosh());
- }
- sin() {
- return this.map((e) => e.isError() ? e : e.sin());
- }
- sinh() {
- return this.map((e) => e.isError() ? e : e.sinh());
- }
- asin() {
- return this.map((e) => e.isError() ? e : e.asin());
- }
- asinh() {
- return this.map((e) => e.isError() ? e : e.asinh());
- }
- tan() {
- return this.map((e) => e.isError() ? e : e.tan());
- }
- tanh() {
- return this.map((e) => e.isError() ? e : e.tanh());
- }
- atan() {
- return this.map((e) => e.isError() ? e : e.atan());
- }
- atanh() {
- return this.map((e) => e.isError() ? e : e.atanh());
- }
- atan2(e) {
- return this._batchOperator(
- e,
- 12
- /* ATAN2 */
- );
- }
- atan2Inverse(e) {
- return this.map((t) => t.isError() ? t : e.atan2(t));
- }
- mean(e = 0) {
- const t = this.sum(), r = this.count();
- return t.divided(e === 0 ? r : r.minusBy(1));
- }
- median() {
- const e = this.flattenPosition().numberArray, t = this._createNewArray([e], 1, e.length), r = t.getColumnCount();
- if (r <= 1)
- return t.get(0, 0) || ie.create();
- if (t.sortByRow(0), r % 2 === 0) {
- const n = t.get(0, r / 2) || ie.create(), s = t.get(0, r / 2 - 1) || ie.create();
- return n.plus(s).divided(y.create(2));
- }
- return t.get(0, (r - 1) / 2) || ie.create();
- }
- /**
- * ┌──────────────┬────────────────────────────────┬───────────────────┐
- * │ Function │ Ignore logical values and text │ Type │
- * ├──────────────┼────────────────────────────────┼───────────────────┤
- * │ VAR.S (VAR) │ TRUE │ sample │
- * │ VAR.P (VARP) │ TRUE │ entire population │
- * │ VARA │ FALSE │ sample │
- * │ VARPA │ FALSE │ entire population │
- * └──────────────┴────────────────────────────────┴───────────────────┘
- *
- * for VARPA and VARA, strings and FALSE are counted as 0, TRUE is counted as 1
- * for VAR.S/VAR, or VAR.P/VARP, strings,TRUE and FALSE are ignored
- * Since sum ignores strings and booleans, they are ignored here too, and VAR.S and VAR.P are used more
- *
- * VAR.S assumes that its arguments are a sample of the population, like numpy.var(data, ddof=1)
- * VAR.P assumes that its arguments are the entire population, like numpy.var(data, ddof=0)
- * numpy.var uses ddof=0 (Delta Degrees of Freedom) by default, so we use ddof=0 here
- *
- */
- var(e = 0) {
- const t = this.mean(), r = [[]];
- this.iterator((l) => {
- if (l == null || l.isError() || l.isString() || l.isBoolean() || l.isNull())
- return;
- const f = l.minus(t).pow(y.create(2));
- f.isError() || r[0].push(f);
- });
- const { _unitId: n, _sheetId: s, _currentRow: o, _currentColumn: u } = this;
- return q.create({
- calculateValueList: r,
- rowCount: 1,
- columnCount: r[0].length,
- unitId: n,
- sheetId: s,
- row: o,
- column: u
- }).mean(e);
- }
- /**
- * STDEV.P (STDEVP): ddof=0, ignore strings and booleans
- * STDEV.S (STDEV): ddof=1, ignore strings and booleans
- *
- * STDEVPA: ddof=0,
- * STDEVA: ddof=1,
- * @returns
- */
- std(e = 0) {
- const t = this.var(e);
- return t.isError() ? t : t.sqrt();
- }
- log() {
- return this.map((e) => e.isError() ? e : e.log());
- }
- log10() {
- return this.map((e) => e.isError() ? e : e.log10());
- }
- exp() {
- return this.map((e) => e.isError() ? e : e.exp());
- }
- abs() {
- return this.map((e) => e.isError() ? e : e.abs());
- }
- round(e) {
- return this._batchOperator(
- e,
- 9
- /* ROUND */
- );
- }
- roundInverse(e) {
- return this.map((t) => t.isError() ? t : e.round(t));
- }
- floor(e) {
- return this._batchOperator(
- e,
- 10
- /* FLOOR */
- );
- }
- floorInverse(e) {
- return this.map((t) => t.isError() ? t : e.floor(t));
- }
- ceil(e) {
- return this._batchOperator(
- e,
- 11
- /* CEIL */
- );
- }
- ceilInverse(e) {
- return this.map((t) => t.isError() ? t : e.ceil(t));
- }
- toValue() {
- return Rf(this._values);
- }
- _clearCache() {
- this._flattenCache = null, this._sliceCache.clear();
- }
- _sort(e) {
- const t = hn();
- return (r, n) => {
- const s = r[e], o = n[e];
- return s == null ? 1 : o == null ? -1 : s.isError() && s.isError() ? 0 : s.isError() ? 1 : o.isError() ? -1 : t(
- s.getValue(),
- o.getValue()
- );
- };
- }
- _transposeArray(e) {
- const t = e.length, r = e[0].length, n = [];
- for (let s = 0; s < r; s++) {
- n[s] = [];
- for (let o = 0; o < t; o++)
- n[s][o] = e[o][s];
- }
- return n;
- }
- _batchOperator(e, t, r, n) {
- const s = [];
- let o = this._rowCount, u = this._columnCount;
- if (e.isArray()) {
- const f = e.getRowCount(), h = e.getColumnCount();
- if (o = Math.max(f, o), u = Math.max(h, u), f === 1 && h === 1) {
- const d = e.getFirstCell();
- for (let _ = 0; _ < u; _++)
- s.push(d);
- } else if (f === 1 && this._columnCount > 1) {
- const d = e.getArrayValue();
- for (let _ = 0; _ < u; _++)
- s.push(d[0][_]);
- } else
- return this._batchOperatorArray(e, t, r, n);
- } else
- for (let f = 0; f < u; f++)
- s.push(e);
- const c = [];
- for (let f = 0; f < u; f++) {
- const h = s[f];
- this._batchOperatorValue(h, f, c, t, r, n);
- }
- const l = this._createNewArray(c, o, u);
- return l.setDefaultValue(T.create(!1)), l;
- }
- // eslint-disable-next-line max-lines-per-function
- _batchOperatorValue(e, t, r, n, s, o) {
- const u = this._rowCount, c = this.getUnitId(), l = this.getSheetId(), f = this.getCurrentRow(), h = this.getCurrentColumn();
- if (n === 5) {
- const { rowsInCache: d, rowsNotInCache: _ } = St.canUseCache(
- c,
- l,
- t + h,
- f,
- f + u - 1
- );
- if (d.length > 0) {
- if (s === $.EQUALS) {
- const C = St.getCellPositions(
- c,
- l,
- t + h,
- e.getValue(),
- d
- );
- C != null && C.forEach((E) => {
- if (E < f || E > f + u - 1)
- return;
- const b = E - f;
- r[b] == null && (r[b] = []), r[b][t] = T.create(!0);
- });
- } else {
- const C = St.getCellValuePositions(
- c,
- l,
- t + h
- );
- C != null && C.forEach((E, b) => {
- let R = ie.create();
- yr.has(b) ? R = g.create(b) : typeof b == "string" ? R = j.create(b) : typeof b == "number" ? R = y.create(b) : typeof b == "boolean" && (R = T.create(b));
- let p;
- R.isError() ? p = R : e.isError() ? p = e : p = R.compare(e, s, o), (p.isError() || p.getValue() === !0) && E.forEach((N) => {
- N >= f && N <= f + u - 1 && (r[N - f] == null && (r[N - f] = []), r[N - f][t] = p);
- });
- });
- }
- if (_.length > 0)
- for (const C of _) {
- const [E, b] = C;
- for (let R = E; R <= b; R++)
- this.__batchOperatorRowValue(
- e,
- t,
- r,
- n,
- R - f,
- c,
- l,
- f,
- h,
- s,
- o
- );
- St.setContinueBuildingCache(
- c,
- l,
- t + h,
- E,
- b
- );
- }
- return;
- }
- }
- for (let d = 0; d < u; d++)
- this.__batchOperatorRowValue(
- e,
- t,
- r,
- n,
- d,
- c,
- l,
- f,
- h,
- s,
- o
- );
- St.setContinueBuildingCache(
- c,
- l,
- t + h,
- f,
- f + u - 1
- );
- }
- // eslint-disable-next-line
- __batchOperatorRowValue(e, t, r, n, s, o, u, c, l, f, h) {
- const d = this.getValueOrDefault(s, t);
- if (r[s] == null && (r[s] = []), d && e)
- if (d.isError())
- r[s][t] = d;
- else if (e.isError())
- r[s][t] = e;
- else
- switch (n) {
- case 1:
- r[s][t] = d.plus(e);
- break;
- case 0:
- r[s][t] = d.minus(e);
- break;
- case 2:
- r[s][t] = d.multiply(e);
- break;
- case 3:
- r[s][t] = d.divided(e);
- break;
- case 4:
- r[s][t] = d.mod(e);
- break;
- case 5:
- f ? r[s][t] = d.compare(e, f, h) : r[s][t] = g.create(m.VALUE);
- break;
- case 6:
- r[s][t] = d.concatenateFront(e);
- break;
- case 7:
- r[s][t] = d.concatenateBack(e);
- break;
- case 8:
- r[s][t] = d.pow(e);
- break;
- case 9:
- r[s][t] = d.round(e);
- break;
- case 10:
- r[s][t] = d.floor(e);
- break;
- case 12:
- r[s][t] = d.atan2(e);
- break;
- case 11:
- r[s][t] = d.ceil(e);
- break;
- }
- else
- r[s][t] = g.create(m.NA);
- d != null && (d.isError() ? St.set(
- o,
- u,
- t + l,
- d.getErrorType(),
- s + c
- ) : St.set(
- o,
- u,
- t + l,
- d.getValue(),
- s + c
- ));
- }
- // eslint-disable-next-line max-lines-per-function, complexity
- _batchOperatorArray(e, t, r, n) {
- let s = e.getRowCount(), o = e.getColumnCount();
- s < this._rowCount && (s = this._rowCount), o < this._columnCount && (o = this._columnCount);
- const u = [], c = this._checkArrayCalculateType(this), l = this._checkArrayCalculateType(e);
- for (let f = 0; f < s; f++) {
- const h = [];
- for (let d = 0; d < o; d++) {
- let _;
- c === 3 ? _ = this.getValueOrDefault(0, 0) : c === 1 ? _ = this.getValueOrDefault(0, d) : c === 2 ? _ = this.getValueOrDefault(f, 0) : _ = this.getValueOrDefault(f, d);
- let C;
- if (l === 3 ? C = e.getValueOrDefault(0, 0) : l === 1 ? C = e.getValueOrDefault(0, d) : l === 2 ? C = e.getValueOrDefault(f, 0) : C = e.getValueOrDefault(f, d), _ && C)
- if (_.isError())
- h[d] = _;
- else if (C.isError())
- h[d] = C;
- else
- switch (t) {
- case 1:
- h[d] = _.plus(C);
- break;
- case 0:
- h[d] = _.minus(C);
- break;
- case 2:
- h[d] = _.multiply(C);
- break;
- case 3:
- h[d] = _.divided(C);
- break;
- case 4:
- h[d] = _.mod(C);
- break;
- case 5:
- r ? h[d] = _.compare(C, r, n) : h[d] = g.create(m.VALUE);
- break;
- case 6:
- h[d] = _.concatenateFront(C);
- break;
- case 7:
- h[d] = _.concatenateBack(C);
- break;
- case 8:
- h[d] = _.pow(C);
- break;
- case 9:
- h[d] = _.round(C);
- break;
- case 12:
- h[d] = _.atan2(C);
- break;
- case 10:
- h[d] = _.floor(C);
- break;
- case 11:
- h[d] = _.ceil(C);
- break;
- }
- else
- h[d] = g.create(m.NA);
- }
- u.push(h);
- }
- return this._createNewArray(u, s, o);
- }
- _checkArrayCalculateType(e) {
- return e.getRowCount() === 1 && e.getColumnCount() === 1 ? 3 : e.getRowCount() === 1 ? 1 : e.getColumnCount() === 1 ? 2 : 0;
- }
- _formatValue(e) {
- if (typeof e != "string")
- 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;
- e = e.slice(1, -1);
- const t = e.split(";"), r = t.length, n = [];
- let s = 0;
- for (let o = 0; o < r; o++) {
- const c = t[o].split(","), l = c.length;
- s < l && (s = l);
- const f = [];
- for (let h = 0; h < l; h++) {
- const d = c[h].trim();
- f.push(pt.create(d));
- }
- n.push(f);
- }
- return this._rowCount = r, this._columnCount = s, n;
- }
- _createNewArray(e, t, r, n = -1, s = -1) {
- (this._currentColumn === -1 || this._currentRow === -1) && (n = -1, s = -1);
- const o = {
- calculateValueList: e,
- rowCount: t,
- columnCount: r,
- unitId: this.getUnitId(),
- sheetId: this.getSheetId(),
- row: n,
- column: s
- };
- return q.create(o);
- }
- }
- class pt {
- static create(a) {
- if (a == null)
- return ie.create();
- if (typeof a == "boolean")
- return T.create(a);
- if (typeof a == "string") {
- const e = a.toLocaleUpperCase().trim();
- if (yr.has(e))
- return g.create(e);
- if (e === er.TRUE || e === er.FALSE)
- return In(a);
- if (Q(a))
- return y.create(Number(a));
- const { isNumberPattern: t, value: r, pattern: n } = il(a);
- if (t)
- return y.create(r, n);
- const s = a.replace(/\n/g, "").replace(/\r/g, "");
- return !pf(s) && Ac(s) ? q.create(s) : bf(a);
- }
- return typeof a == "number" ? Fn(a) : g.create(m.VALUE);
- }
- }
- function pf(i) {
- const a = i.trim();
- return a.startsWith('"') && a.endsWith('"');
- }
- const Vf = 1e4, Bs = new Vt(Vf);
- class kn extends jn {
- constructor(e) {
- super();
- A(this, "_forcedSheetId", "");
- A(this, "_forcedSheetName", "");
- A(this, "_defaultSheetId", "");
- A(this, "_rangeData", {
- startColumn: -1,
- startRow: -1,
- endRow: -1,
- endColumn: -1
- });
- A(this, "_unitData", {});
- A(this, "_unitStylesData", {});
- A(this, "_defaultUnitId", "");
- A(this, "_forcedUnitId", "");
- A(this, "_runtimeData", {});
- A(this, "_arrayFormulaCellData", {});
- A(this, "_runtimeArrayFormulaCellData", {});
- A(this, "_runtimeFeatureCellData", {});
- A(this, "_refOffsetX", 0);
- A(this, "_refOffsetY", 0);
- this._token = e;
- }
- dispose() {
- this._unitData = {}, this._unitStylesData = {}, this._runtimeData = {};
- }
- getToken() {
- return this._token;
- }
- setToken(e) {
- this._token = e;
- }
- isExceedRange() {
- const { startRow: e, endRow: t, startColumn: r, endColumn: n } = this.getRangePosition();
- return e < 0 || r < 0 || t >= this.getActiveSheetRowCount() || n >= this.getActiveSheetColumnCount();
- }
- setRefOffset(e = 0, t = 0) {
- this._refOffsetX = e, this._refOffsetY = t;
- }
- getRefOffset() {
- return {
- x: this._refOffsetX,
- y: this._refOffsetY
- };
- }
- getRangePosition() {
- let { startRow: e, startColumn: t, endRow: r, endColumn: n } = ea(this._rangeData, this._refOffsetX, this._refOffsetY);
- 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), {
- ...this._rangeData,
- startRow: e,
- endRow: r,
- startColumn: t,
- endColumn: n
- };
- }
- isReferenceObject() {
- return !0;
- }
- iterator(e) {
- const { startRow: t, endRow: r, startColumn: n, endColumn: s } = this.getRangePosition();
- if (this._checkIfWorksheetMiss())
- return e(g.create(m.VALUE), t, n);
- const o = this._forcedUnitId || this._defaultUnitId, u = this._forcedSheetId || this._defaultSheetId;
- for (let c = t; c <= r; c++)
- for (let l = n; l <= s; l++) {
- if (c < 0 || l < 0)
- return e(g.create(m.REF), c, l);
- const f = this.getCellData(c, l);
- let h = !1;
- if (nn(f)) {
- h = e(null, c, l);
- continue;
- }
- let d = this.getCellValueObject(f);
- if (c === t && l === n) {
- const _ = this.getCellPattern(o, u, c, l);
- if (_ && d.isNumber()) {
- const C = Number(d.getValue());
- d = y.create(C, _);
- }
- }
- if (h = e(d, c, l), h === !1)
- return;
- }
- }
- getFirstCell() {
- const { startRow: e, startColumn: t } = this.getRangePosition(), r = this.getCellData(e, t);
- if (!r)
- return y.create(0);
- let n = this.getCellValueObject(r);
- const s = this._forcedUnitId || this._defaultUnitId, o = this._forcedSheetId || this._defaultSheetId, u = this.getCellPattern(s, o, e, t);
- if (u && n.isNumber()) {
- const c = Number(n.getValue());
- n = y.create(c, u);
- }
- return n;
- }
- getRangeData() {
- return this._rangeData;
- }
- setRangeData(e) {
- this._rangeData = e;
- }
- getUnitId() {
- return this._forcedUnitId && this._forcedUnitId.length > 0 ? this._forcedUnitId : this._defaultUnitId;
- }
- getSheetId() {
- return this._forcedSheetId && this._forcedSheetId.length > 0 ? this._forcedSheetId : this._defaultSheetId;
- }
- setForcedUnitIdDirect(e) {
- e.length > 0 && (this._forcedUnitId = e);
- }
- getForcedUnitId() {
- return this._forcedUnitId;
- }
- setForcedSheetId(e) {
- var t;
- this._forcedSheetId = (t = e[this.getUnitId()]) == null ? void 0 : t[this._forcedSheetName];
- }
- setForcedSheetIdDirect(e) {
- this._forcedSheetId = e;
- }
- getForcedSheetId() {
- return this._forcedSheetId;
- }
- setForcedSheetName(e) {
- e.length > 0 && (this._forcedSheetName = e);
- }
- getForcedSheetName() {
- return this._forcedSheetName;
- }
- setDefaultSheetId(e) {
- this._defaultSheetId = e;
- }
- getDefaultSheetId() {
- return this._defaultSheetId;
- }
- setDefaultUnitId(e) {
- this._defaultUnitId = e;
- }
- getDefaultUnitId() {
- return this._defaultUnitId;
- }
- getUnitData() {
- return this._unitData;
- }
- setUnitData(e) {
- this._unitData = e;
- }
- getUnitStylesData() {
- return this._unitStylesData;
- }
- setUnitStylesData(e) {
- this._unitStylesData = e;
- }
- getRuntimeData() {
- return this._runtimeData;
- }
- setRuntimeData(e) {
- this._runtimeData = e;
- }
- getArrayFormulaCellData() {
- return this._arrayFormulaCellData;
- }
- setArrayFormulaCellData(e) {
- this._arrayFormulaCellData = e;
- }
- getRuntimeArrayFormulaCellData() {
- return this._runtimeArrayFormulaCellData;
- }
- setRuntimeArrayFormulaCellData(e) {
- this._runtimeArrayFormulaCellData = e;
- }
- getRuntimeFeatureCellData() {
- return this._runtimeFeatureCellData;
- }
- setRuntimeFeatureCellData(e) {
- this._runtimeFeatureCellData = e;
- }
- getActiveSheetRowCount() {
- var e;
- return ((e = this.getCurrentActiveSheetData()) == null ? void 0 : e.rowCount) || 0;
- }
- getActiveSheetColumnCount() {
- var e;
- return ((e = this.getCurrentActiveSheetData()) == null ? void 0 : e.columnCount) || 0;
- }
- getRowCount() {
- return this._rangeData.endRow - this._rangeData.startRow + 1;
- }
- getColumnCount() {
- return this._rangeData.endColumn - this._rangeData.startColumn + 1;
- }
- getRowData() {
- var e;
- return ((e = this.getCurrentActiveSheetData()) == null ? void 0 : e.rowData) || {};
- }
- getColumnData() {
- var e;
- return ((e = this.getCurrentActiveSheetData()) == null ? void 0 : e.columnData) || {};
- }
- isCell() {
- return !1;
- }
- isColumn() {
- return !1;
- }
- isRow() {
- return !1;
- }
- isRange() {
- return !1;
- }
- isTable() {
- return !1;
- }
- unionBy(e) {
- return g.create(m.REF);
- }
- unionRange(e, t) {
- return {
- startRow: -1,
- startColumn: -1,
- endRow: -1,
- endColumn: -1
- };
- }
- getCellValueObject(e) {
- const t = cl(e);
- if (yr.has(t))
- return g.create(t);
- if (e.t === yt.NUMBER) {
- const r = this._getPatternByCell(e);
- return Fn(t, r);
- }
- return e.t === yt.STRING || e.t === yt.FORCE_STRING ? j.create(t.toString()) : e.t === yt.BOOLEAN ? In(t) : pt.create(t);
- }
- _getPatternByCell(e) {
- var n;
- const t = this._unitStylesData[this.getUnitId()];
- if (!t) return "";
- const r = t.getStyleByCell(e);
- return ((n = r == null ? void 0 : r.n) == null ? void 0 : n.pattern) || "";
- }
- getCellByRow(e) {
- return this.getCellByPosition(e);
- }
- getCellByColumn(e) {
- return this.getCellByPosition(void 0, e);
- }
- getCurrentActiveSheetData() {
- var e;
- return (e = this._unitData[this.getUnitId()]) == null ? void 0 : e[this.getSheetId()];
- }
- getCurrentStylesData() {
- return this._unitStylesData[this.getUnitId()];
- }
- getCurrentRuntimeSheetData() {
- var e, t;
- return (t = (e = this._runtimeData) == null ? void 0 : e[this.getUnitId()]) == null ? void 0 : t[this.getSheetId()];
- }
- getCurrentActiveArrayFormulaCellData() {
- var e, t;
- return (t = (e = this._arrayFormulaCellData) == null ? void 0 : e[this.getUnitId()]) == null ? void 0 : t[this.getSheetId()];
- }
- getCurrentRuntimeActiveArrayFormulaCellData() {
- var e, t;
- return (t = (e = this._runtimeArrayFormulaCellData) == null ? void 0 : e[this.getUnitId()]) == null ? void 0 : t[this.getSheetId()];
- }
- getCellData(e, t) {
- const r = this.getCurrentActiveSheetData(), n = this.getCurrentRuntimeSheetData(), s = this.getCurrentActiveArrayFormulaCellData(), o = this.getCurrentRuntimeActiveArrayFormulaCellData();
- 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));
- }
- getRuntimeFeatureCellValue(e, t) {
- return ao(e, t, this.getSheetId(), this.getUnitId(), this._runtimeFeatureCellData);
- }
- getCellByPosition(e, t) {
- let r = e, n = t;
- r || (r = this._rangeData.startRow), n || (n = this._rangeData.startColumn);
- const s = this.getCellData(r, n);
- return s ? this.getCellValueObject(s) : g.create(m.VALUE);
- }
- /**
- * Get the pattern of the cell
- * @param unitId
- * @param sheetId
- * @param row
- * @param column
- * @returns
- */
- getCellPattern(e, t, r, n) {
- var c, l, f, h;
- const s = this._unitStylesData[e];
- if (!s)
- return "";
- const o = (f = (l = (c = this._unitData[e]) == null ? void 0 : c[t]) == null ? void 0 : l.cellData) == null ? void 0 : f.getValue(r, n);
- if (!o)
- return "";
- const u = s.getStyleByCell(o);
- return ((h = u == null ? void 0 : u.n) == null ? void 0 : h.pattern) || "";
- }
- toArrayValueObject(e = !0) {
- var _;
- const { startRow: t, endRow: r, startColumn: n, endColumn: s } = this.getRangePosition(), o = `${this.getUnitId()}_${this.getSheetId()}_${t}_${r}_${n}_${s}`, u = Bs.get(o);
- if (u && e)
- return u;
- const c = r - t + 1, l = s - n + 1;
- if (c < 0 || l < 0)
- return this._getBlankArrayValueObject();
- const f = new Array(c);
- this.iterator((C, E, b) => {
- const R = E - t, p = b - n;
- f[R] || (f[R] = new Array(l)), C == null && (C = ie.create()), f[R][p] = C;
- });
- const h = {
- calculateValueList: f,
- rowCount: f.length,
- columnCount: ((_ = f[0]) == null ? void 0 : _.length) || 0,
- unitId: this.getUnitId(),
- sheetId: this.getSheetId(),
- row: t,
- column: n
- }, d = q.create(h);
- return e && Bs.set(o, d), d;
- }
- toUnitRange() {
- return {
- range: this.getRangePosition(),
- sheetId: this.getSheetId(),
- unitId: this.getUnitId()
- };
- }
- _checkIfWorksheetMiss() {
- return (this._forcedSheetId == null || this._forcedSheetId.length === 0) && this._forcedSheetName.length > 0;
- }
- _getBlankArrayValueObject() {
- const e = {
- calculateValueList: [],
- rowCount: 0,
- columnCount: 0,
- unitId: this.getUnitId(),
- sheetId: this.getSheetId(),
- row: 0,
- column: 0
- };
- return q.create(e);
- }
- }
- class Nf extends jn {
- constructor(a) {
- super(), this._promise = a;
- }
- isAsyncObject() {
- return !0;
- }
- async getValue() {
- return this._promise;
- }
- }
- class Of extends jn {
- constructor(a) {
- super(), this._promiseList = a;
- }
- isAsyncArrayObject() {
- return !0;
- }
- async getValue() {
- var t;
- const a = [];
- for (let r = 0; r < this._promiseList.length; r++) {
- const n = this._promiseList[r];
- a[r] == null && (a[r] = []);
- for (let s = 0; s < n.length; s++) {
- const o = n[s];
- o.isAsyncObject() ? a[r][s] = await o.getValue() : a[r][s] = o;
- }
- }
- const e = {
- calculateValueList: a,
- rowCount: a.length,
- columnCount: ((t = a[0]) == null ? void 0 : t.length) || 0,
- unitId: "",
- sheetId: "",
- row: 0,
- column: 0
- };
- return q.create(e);
- }
- }
- class Cn extends kn {
- constructor(a, e, t) {
- super(""), this.setRangeData(a), e && this.setForcedSheetIdDirect(e), t && this.setForcedUnitIdDirect(t);
- }
- isRange() {
- return !0;
- }
- }
- class da extends kn {
- constructor(a) {
- super(a);
- const e = mr(a);
- this.setForcedUnitIdDirect(e.unitId), this.setForcedSheetName(e.sheetName), this.setRangeData(e.range);
- }
- isCell() {
- return !0;
- }
- unionBy(a) {
- if (!a.isCell())
- return g.create(m.REF);
- const e = a, t = this.unionRange(this.getRangeData(), e.getRangeData());
- return this._createRange(t);
- }
- unionRange(a, e) {
- const t = a.startRow, r = a.startColumn, n = e.startRow, s = e.startColumn, o = {
- startRow: -1,
- startColumn: -1,
- endRow: -1,
- endColumn: -1
- };
- 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), a.startAbsoluteRefType && (o.startAbsoluteRefType = a.startAbsoluteRefType), e.startAbsoluteRefType && (o.endAbsoluteRefType = e.startAbsoluteRefType), o;
- }
- _createRange(a) {
- const e = new Cn(
- a,
- this.getForcedSheetId(),
- this.getForcedUnitId()
- );
- 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());
- const { x: t, y: r } = this.getRefOffset();
- e.setRefOffset(t, r);
- const n = this.getForcedSheetId();
- e.setForcedSheetName(this.getForcedSheetName()), n != null && e.setForcedSheetIdDirect(n);
- const s = this.getForcedUnitId();
- return s && e.setForcedUnitIdDirect(s), e;
- }
- }
- class Ca extends kn {
- constructor(a) {
- super(a);
- const e = mr(a);
- this.setForcedUnitIdDirect(e.unitId), this.setForcedSheetName(e.sheetName);
- const t = {
- ...e.range,
- startColumn: e.range.startColumn,
- startRow: Number.NaN,
- endColumn: e.range.endColumn,
- endRow: Number.NaN,
- rangeType: Ze.COLUMN
- };
- this.setRangeData(t);
- }
- isColumn() {
- return !0;
- }
- unionBy(a) {
- if (!a.isColumn())
- return g.create(m.REF);
- const e = a;
- if (e.getForcedSheetName() !== void 0 && e.getForcedSheetName() !== "")
- return g.create(m.REF);
- const t = this.getRangeData(), r = e.getRangeData(), n = r.startColumn;
- if (n >= t.startColumn && n <= t.endColumn)
- return this;
- const s = t.startColumn;
- return n > s ? t.endColumn = n : (t.startColumn = n, t.endColumn = s), r.startAbsoluteRefType && (t.endAbsoluteRefType = r.startAbsoluteRefType), t.rangeType = Ze.COLUMN, this.setToken(`${this.getToken()}${K.COLON}${e.getToken()}`), this;
- }
- }
- class _a extends kn {
- constructor(a) {
- super(a);
- const e = mr(a);
- this.setForcedUnitIdDirect(e.unitId), this.setForcedSheetName(e.sheetName);
- const t = {
- ...e.range,
- startColumn: Number.NaN,
- startRow: e.range.startRow,
- endColumn: Number.NaN,
- endRow: e.range.endRow,
- rangeType: Ze.ROW
- };
- this.setRangeData(t);
- }
- isRow() {
- return !0;
- }
- unionBy(a) {
- if (!a.isRow())
- return g.create(m.REF);
- const e = a;
- if (e.getForcedSheetName() !== void 0 && e.getForcedSheetName() !== "")
- return g.create(m.REF);
- const t = this.getRangeData(), r = e.getRangeData(), n = r.startRow;
- if (n >= t.startRow && n <= t.endRow)
- return this;
- const s = t.startRow;
- return n > s ? t.endRow = n : (t.startRow = n, t.endRow = s), r.startAbsoluteRefType && (t.endAbsoluteRefType = r.startAbsoluteRefType), t.rangeType = Ze.ROW, this.setToken(`${this.getToken()}${K.COLON}${e.getToken()}`), this;
- }
- }
- function O(i, a, e, t) {
- const r = e.isArray() ? e.getRowCount() : 1, n = e.isArray() ? e.getColumnCount() : 1, s = [];
- for (let o = 0; o < i; o++) {
- const u = [];
- for (let c = 0; c < a; c++) {
- if (r === 1 && n === 1) {
- const f = e.isArray() ? e.get(0, 0) : e;
- u.push(f);
- continue;
- }
- if (r === 1 && c < n) {
- const f = e.get(0, c);
- u.push(f);
- continue;
- }
- if (n === 1 && o < r) {
- const f = e.get(o, 0);
- u.push(f);
- continue;
- }
- if (o >= r || c >= n) {
- u.push(t != null ? t : ie.create());
- continue;
- }
- const l = e.get(o, c);
- u.push(l);
- }
- s.push(u);
- }
- return tr(s, i, a);
- }
- function tr(i, a, e, t = "", r = "") {
- const n = {
- calculateValueList: i,
- rowCount: a,
- columnCount: e,
- unitId: t,
- sheetId: r,
- row: -1,
- column: -1
- };
- return q.create(n);
- }
- function Aa(i) {
- const a = [
- $.EQUALS,
- $.NOT_EQUAL,
- $.GREATER_THAN_OR_EQUAL,
- $.GREATER_THAN,
- $.LESS_THAN_OR_EQUAL,
- $.LESS_THAN
- ];
- for (const e of a)
- if (i.startsWith(e)) {
- const t = i.substring(e.length);
- return [e, pt.create(t)];
- }
- return [$.EQUALS, pt.create(i)];
- }
- function $n(i, a, e, t) {
- if (!e)
- if (a.isString()) {
- const r = `${a.getValue()}`, [n, s] = Aa(r);
- e = n, a = s;
- } else
- e = $.EQUALS;
- return i.compare(a, e, t);
- }
- function Mf(i, a) {
- const e = Math.max(i.isArray() ? i.getRowCount() : 1, a.isArray() ? a.getRowCount() : 1), t = Math.max(i.isArray() ? i.getColumnCount() : 1, a.isArray() ? a.getColumnCount() : 1), r = O(e, t, i), n = O(e, t, a);
- return r.mapValue((s, o, u) => {
- const c = n.get(o, u);
- return s != null && s.isError() ? s : c != null && c.isError() ? c : s != null && s.isBoolean() && (c != null && c.isBoolean()) ? In(s.getValue() && c.getValue()) : T.create(!1);
- });
- }
- function wf(i) {
- const a = i.getValue();
- let e = 0;
- return a && (e = 1), y.create(e);
- }
- function Ai(i) {
- return i.isArray() && i.getRowCount() === 1 && i.getColumnCount() === 1 ? !0 : i.isReferenceObject() ? !!(i.isCell() || i.getRowCount() === 1 && i.getColumnCount() === 1) : (i = i, !!(i.isString() || i.isNumber() || i.isBoolean() || i.isError() || i.isNull()));
- }
- function Gt(i) {
- const a = i == null ? void 0 : i.getPattern();
- let e = {};
- if (a && (e = {
- s: {
- n: {
- pattern: a
- }
- }
- }), i == null)
- return {
- v: null,
- ...e
- };
- if (i.isError())
- return {
- v: i.getErrorType(),
- t: yt.STRING,
- ...e
- };
- if (i.isValueObject()) {
- const t = i, r = t.getValue();
- return t.isNumber() ? {
- v: r,
- t: yt.NUMBER,
- ...e
- } : t.isBoolean() ? {
- v: r ? 1 : 0,
- t: yt.BOOLEAN,
- ...e
- } : t.isString() ? {
- v: r,
- t: yt.STRING,
- ...e
- } : t.isNull() ? {
- v: null,
- ...e
- } : {
- v: r,
- t: yt.STRING,
- ...e
- };
- }
- }
- function Nr(i) {
- let a = 0, e = 0;
- return i.forEach((t, r) => {
- if (r % 2 === 1)
- if (t.isArray()) {
- const n = t;
- a = Math.max(a, n.getRowCount()), e = Math.max(e, n.getColumnCount());
- } else
- a = Math.max(a, 1), e = Math.max(e, 1);
- }), { maxRowLength: a, maxColumnLength: e };
- }
- function Br(i, a, e, t) {
- const r = a.getRowCount(), n = a.getColumnCount();
- for (let s = 0; s < i.length; s++) {
- if (s % 2 === 1) continue;
- const o = i[s], u = o.getRowCount(), c = o.getColumnCount();
- if (u !== r || c !== n)
- return O(e, t, g.create(m.VALUE));
- }
- return null;
- }
- function Ir(i, a, e, t = !1) {
- const r = [];
- for (let n = 0; n < i.length; n++) {
- if (n % 2 === 1) continue;
- const s = i[n], o = i[n + 1];
- O(a, e, o, g.create(m.NA)).iterator((c, l, f) => {
- if (!c)
- return;
- let h = $n(s, c);
- if (t && (h = Yn(h, s, c)), r[l] === void 0 && (r[l] = []), r[l][f] === void 0) {
- r[l][f] = h;
- return;
- }
- r[l][f] = Mf(r[l][f], h);
- });
- }
- return r;
- }
- function Yn(i, a, e) {
- const [t, r] = Aa(`${e.getValue()}`);
- return i.mapValue((n, s, o) => {
- const u = a.get(s, o);
- if (u && Df(u, r))
- return n;
- if (u != null && u.isNumber()) {
- if (r.isString()) {
- const c = r.convertToNumberObjectValue();
- if (c.isNumber())
- return u.compare(c, t);
- }
- return T.create(!1);
- } else if (r.isNumber()) {
- if (u != null && u.isString()) {
- const c = u.convertToNumberObjectValue();
- if (c.isNumber())
- return c.compare(r, t);
- }
- return T.create(!1);
- } else return u != null && u.isError() && r.isError() && u.getValue() === r.getValue() ? T.create(!0) : T.create(!1);
- });
- }
- function Df(i, a) {
- if (i.isNumber() && a.isNumber() || i.isBoolean() && a.isBoolean())
- return !0;
- const e = i.isString() && i.getValue() === "", t = a.isString() && a.getValue() === "";
- return !!((e || i.isNull()) && (t || a.isNull()) || i.isString() && !e && a.isString() && !t);
- }
- var an = /* @__PURE__ */ ((i) => (i[i.CELL = 0] = "CELL", i[i.COLUMN = 1] = "COLUMN", i[i.ROW = 2] = "ROW", i))(an || {});
- function Sf(i, a) {
- let e;
- switch (a) {
- case 0:
- e = new da(i);
- break;
- case 1:
- e = new Ca(i);
- break;
- case 2:
- e = new _a(i);
- break;
- default:
- throw new Error("Unknown reference object type");
- }
- return e;
- }
- function Pf(i, a) {
- let e = g.create(m.NAME);
- return (i.isCell() && a.isCell() || i.isRow() && a.isRow() || i.isColumn() && a.isColumn()) && (e = i.unionBy(a)), e;
- }
- var Lf = Object.defineProperty, xf = Object.getOwnPropertyDescriptor, jf = (i, a, e, t) => {
- for (var r = t > 1 ? void 0 : t ? xf(a, e) : a, n = i.length - 1, s; n >= 0; n--)
- (s = i[n]) && (r = (t ? s(a, e, r) : s(r)) || r);
- return t && r && Lf(a, e, r), r;
- }, Uf = (i, a) => (e, t) => a(e, t, i), ft = /* @__PURE__ */ ((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 || {}), wr = /* @__PURE__ */ ((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 || {});
- let Is = class extends Me {
- constructor(a) {
- super();
- A(this, "_formulaExecuteStage", 0);
- A(this, "_stopState", !1);
- A(this, "_currentRow", -1);
- A(this, "_currentColumn", -1);
- A(this, "_currentRowCount", Number.NEGATIVE_INFINITY);
- A(this, "_currentColumnCount", Number.NEGATIVE_INFINITY);
- A(this, "_currentSubUnitId", "");
- A(this, "_currentUnitId", "");
- A(this, "_runtimeData", {});
- A(this, "_runtimeOtherData", {});
- // Data returned by other businesses through formula calculation, excluding the sheet.
- A(this, "_unitArrayFormulaRange", {});
- A(this, "_runtimeArrayFormulaCellData", {});
- A(this, "_runtimeClearArrayFormulaCellData", {});
- A(this, "_runtimeFeatureRange", {});
- A(this, "_runtimeFeatureCellData", {});
- A(this, "_functionsExecutedState", 0);
- // lambdaId: { key: BaseAstNode }
- A(this, "_functionDefinitionPrivacyVar", /* @__PURE__ */ new Map());
- A(this, "_totalFormulasToCalculate", 0);
- A(this, "_completedFormulasCount", 0);
- A(this, "_totalArrayFormulasToCalculate", 0);
- A(this, "_completedArrayFormulasCount", 0);
- A(this, "_formulaCycleIndex", 0);
- A(this, "_isCycleDependency", !1);
- this._currentConfigService = a;
- }
- get currentRow() {
- return this._currentRow;
- }
- get currentColumn() {
- return this._currentColumn;
- }
- get currentRowCount() {
- return this._currentRowCount;
- }
- get currentColumnCount() {
- return this._currentColumnCount;
- }
- get currentSubUnitId() {
- return this._currentSubUnitId;
- }
- get currentUnitId() {
- return this._currentUnitId;
- }
- dispose() {
- this.reset(), this._runtimeFeatureCellData = {}, this._runtimeFeatureRange = {}, this.clearReferenceAndNumberformatCache();
- }
- enableCycleDependency() {
- this._isCycleDependency = !0;
- }
- disableCycleDependency() {
- this._isCycleDependency = !1;
- }
- isCycleDependency() {
- return this._isCycleDependency;
- }
- setFormulaCycleIndex(a) {
- this._formulaCycleIndex = a;
- }
- getFormulaCycleIndex() {
- return this._formulaCycleIndex;
- }
- setTotalArrayFormulasToCalculate(a) {
- this._totalArrayFormulasToCalculate = a;
- }
- getTotalArrayFormulasToCalculate() {
- return this._totalArrayFormulasToCalculate;
- }
- setCompletedArrayFormulasCount(a) {
- this._completedArrayFormulasCount = a;
- }
- getCompletedArrayFormulasCount() {
- return this._completedArrayFormulasCount;
- }
- setTotalFormulasToCalculate(a) {
- this._totalFormulasToCalculate = a;
- }
- getTotalFormulasToCalculate() {
- return this._totalFormulasToCalculate;
- }
- setCompletedFormulasCount(a) {
- this._completedFormulasCount = a;
- }
- getCompletedFormulasCount() {
- return this._completedFormulasCount;
- }
- markedAsSuccessfullyExecuted() {
- this._functionsExecutedState = 3;
- }
- markedAsNoFunctionsExecuted() {
- this._functionsExecutedState = 2;
- }
- markedAsStopFunctionsExecuted() {
- this._functionsExecutedState = 1;
- }
- markedAsInitialFunctionsExecuted() {
- this._functionsExecutedState = 0;
- }
- stopExecution() {
- this._stopState = !0, this.setFormulaExecuteStage(
- 0
- /* IDLE */
- );
- }
- isStopExecution() {
- return this._stopState;
- }
- setFormulaExecuteStage(a) {
- this._formulaExecuteStage = a;
- }
- getFormulaExecuteStage() {
- return this._formulaExecuteStage;
- }
- reset() {
- this._formulaExecuteStage = 0, this._runtimeData = {}, this._runtimeOtherData = {}, this._unitArrayFormulaRange = {}, this._runtimeArrayFormulaCellData = {}, this._runtimeClearArrayFormulaCellData = {}, this._functionDefinitionPrivacyVar.clear(), this.markedAsInitialFunctionsExecuted(), this._stopState = !1, this._isCycleDependency = !1, this._totalFormulasToCalculate = 0, this._completedFormulasCount = 0, this.clearReferenceAndNumberformatCache();
- }
- clearReferenceAndNumberformatCache() {
- tl(), ol(), Ic();
- }
- setCurrent(a, e, t, r, n, s) {
- this._currentRow = a, this._currentColumn = e, this._currentRowCount = t, this._currentColumnCount = r, this._currentSubUnitId = n, this._currentUnitId = s;
- }
- clearFunctionDefinitionPrivacyVar() {
- this._functionDefinitionPrivacyVar.clear();
- }
- registerFunctionDefinitionPrivacyVar(a, e) {
- this._functionDefinitionPrivacyVar.set(a, e);
- }
- getFunctionDefinitionPrivacyVar(a) {
- return this._functionDefinitionPrivacyVar.get(a);
- }
- setRuntimeOtherData(a, e, t, r) {
- const n = this._currentSubUnitId, s = this._currentUnitId;
- this._runtimeOtherData[s] === void 0 && (this._runtimeOtherData[s] = {});
- const o = this._runtimeOtherData[s];
- (o[n] === void 0 || o[n] === null) && (o[n] = {});
- const u = o[n];
- let c = [];
- if (r.isReferenceObject() || r.isValueObject() && r.isArray()) {
- const l = r, { startRow: f, startColumn: h } = l.getRangePosition();
- l.iterator((d, _, C) => {
- const E = Gt(d), b = _ - f, R = C - h;
- c[b] == null && (c[b] = []), c[b][R] = E;
- });
- } else
- c = [[Gt(r)]];
- (u[a] === void 0 || u[a] === null) && (u[a] = {}), (u[a][t] === void 0 || u[a][t] === null) && (u[a][t] = {}), u[a][t][e] = c;
- }
- // eslint-disable-next-line max-lines-per-function
- setRuntimeData(a) {
- const e = this._currentRow, t = this._currentColumn, r = this._currentRowCount, n = this.currentColumnCount, s = this._currentSubUnitId, o = this._currentUnitId;
- this._runtimeData[o] == null && (this._runtimeData[o] = {});
- const u = this._runtimeData[o];
- u[s] == null && (u[s] = new Ce()), this._unitArrayFormulaRange[o] == null && (this._unitArrayFormulaRange[o] = {});
- const c = this._unitArrayFormulaRange[o];
- (c[s] === null || c[s] === void 0) && (c[s] = {});
- const l = new Ce(c[s]);
- this._runtimeArrayFormulaCellData[o] === void 0 && (this._runtimeArrayFormulaCellData[o] = {});
- const f = this._runtimeArrayFormulaCellData[o];
- f[s] == null && (f[s] = new Ce()), this._runtimeClearArrayFormulaCellData[o] === void 0 && (this._runtimeClearArrayFormulaCellData[o] = {});
- const h = this._runtimeClearArrayFormulaCellData[o];
- h[s] == null && (h[s] = new Ce());
- const d = u[s], _ = f[s], C = h[s];
- if (a.isReferenceObject() || a.isValueObject() && a.isArray()) {
- const E = a, { startRow: b, startColumn: R, endRow: p, endColumn: N } = E.getRangePosition();
- if (b === p && R === N) {
- const w = E.getFirstCell(), D = Gt(w);
- d.setValue(e, t, D), C.setValue(e, t, D);
- return;
- }
- const M = {
- startRow: e,
- startColumn: t,
- endRow: p - b + e,
- endColumn: N - R + t
- };
- if (l.setValue(e, t, M), this._checkIfArrayFormulaRangeHasData(o, s, e, t, M) || this._checkIfArrayFormulaExceeded(r, n, M)) {
- const w = Gt(g.create(m.SPILL));
- d.setValue(e, t, w), C.setValue(e, t, w);
- const D = this._currentConfigService.getUnitData();
- E.iterator((S, P, U) => {
- var ne, z;
- const x = P - b + e, F = U - R + t, W = (z = (ne = D[o]) == null ? void 0 : ne[s]) == null ? void 0 : z.cellData.getValue(x, F);
- if (P === b && U === R)
- _.setValue(e, t, w);
- else if (W != null)
- W.v == null && (W.v = ""), _.setValue(x, F, W);
- else {
- if (this._isInOtherArrayFormulaRange(o, s, e, t, x, F))
- return !0;
- _.setValue(x, F, { v: "" });
- }
- });
- } else {
- const w = g.create(m.SPILL);
- E.iterator((D, S, P) => {
- const U = Gt(D);
- if (S === b && P === R) {
- if (D != null && D.isError() && D.isEqualType(w))
- return C.setValue(e, t, {}), d.setValue(e, t, { ...Gt(w) }), !1;
- d.setValue(e, t, { ...U });
- }
- const x = S - b + e, F = P - R + t;
- _.setValue(x, F, U);
- });
- }
- } else {
- const E = Gt(a);
- d.setValue(e, t, E), C.setValue(e, t, E);
- }
- }
- getUnitData() {
- return this._runtimeData;
- }
- getUnitArrayFormula() {
- return this._unitArrayFormulaRange;
- }
- getRuntimeOtherData() {
- return this._runtimeOtherData;
- }
- getRuntimeArrayFormulaCellData() {
- return this._runtimeArrayFormulaCellData;
- }
- getRuntimeClearArrayFormulaCellData() {
- return this._runtimeClearArrayFormulaCellData;
- }
- getRuntimeFeatureRange() {
- return this._runtimeFeatureRange;
- }
- setRuntimeFeatureRange(a, e) {
- this._runtimeFeatureRange[a] = e;
- }
- getRuntimeFeatureCellData() {
- return this._runtimeFeatureCellData;
- }
- setRuntimeFeatureCellData(a, e) {
- this._runtimeFeatureCellData[a] = e;
- }
- getAllRuntimeData() {
- return {
- unitData: this.getUnitData(),
- arrayFormulaRange: this.getUnitArrayFormula(),
- unitOtherData: this.getRuntimeOtherData(),
- functionsExecutedState: this._functionsExecutedState,
- arrayFormulaCellData: this.getRuntimeArrayFormulaCellData(),
- clearArrayFormulaCellData: this.getRuntimeClearArrayFormulaCellData(),
- runtimeFeatureRange: this.getRuntimeFeatureRange(),
- runtimeFeatureCellData: this.getRuntimeFeatureCellData()
- };
- }
- getRuntimeState() {
- return {
- totalFormulasToCalculate: this.getTotalFormulasToCalculate(),
- completedFormulasCount: this.getCompletedFormulasCount(),
- totalArrayFormulasToCalculate: this.getTotalArrayFormulasToCalculate(),
- completedArrayFormulasCount: this.getCompletedArrayFormulasCount(),
- stage: this.getFormulaExecuteStage(),
- formulaCycleIndex: this.getFormulaCycleIndex()
- };
- }
- // eslint-disable-next-line complexity
- _checkIfArrayFormulaRangeHasData(a, e, t, r, n) {
- var h, d, _, C, E, b, R, p, N, M, w;
- const { startRow: s, startColumn: o, endRow: u, endColumn: c } = n, l = this._currentConfigService.getUnitData(), f = this._currentConfigService.getArrayFormulaCellData();
- (_ = (d = (h = this._unitArrayFormulaRange[a]) == null ? void 0 : h[e]) == null ? void 0 : d[t]) == null || _[r];
- for (let D = s; D <= u; D++)
- for (let S = o; S <= c; S++) {
- if (D === t && r === S)
- continue;
- const P = (b = (E = (C = this._runtimeData) == null ? void 0 : C[a]) == null ? void 0 : E[e]) == null ? void 0 : b.getValue(D, S);
- (p = (R = f == null ? void 0 : f[a]) == null ? void 0 : R[e]) == null || p.getValue(
- D,
- S
- );
- const U = (w = (M = (N = l == null ? void 0 : l[a]) == null ? void 0 : N[e]) == null ? void 0 : M.cellData) == null ? void 0 : w.getValue(D, S), x = this._getRuntimeFeatureCellValue(D, S, e, a);
- if (!nn(P) || this._isInOtherArrayFormulaRange(a, e, t, r, D, S) || !nn(U) || !nn(x))
- return !0;
- }
- return !1;
- }
- _getRuntimeFeatureCellValue(a, e, t, r) {
- return ao(a, e, t, r, this._runtimeFeatureCellData);
- }
- _arrayCellHasData(a) {
- return a == null ? !1 : a.v !== void 0;
- }
- /**
- * 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
- * @param formulaUnitId
- * @param formulaSheetId
- * @param formulaRow
- * @param formulaColumn
- * @param r
- * @param c
- * @returns
- */
- _isInOtherArrayFormulaRange(a, e, t, r, n, s) {
- var l;
- const o = (l = this._currentConfigService.getArrayFormulaRange()[a]) == null ? void 0 : l[e];
- if (o == null)
- return !1;
- let u = !1;
- return new Ce(o).forValue((f, h, d) => {
- var E, b;
- if (f === t && h === r)
- return;
- const _ = this._isInArrayFormulaRange(d, n, s), C = (b = (E = this._runtimeData[a]) == null ? void 0 : E[e]) == null ? void 0 : b.getValue(f, h);
- _ && (C == null ? void 0 : C.v) !== m.SPILL && (u = !0);
- }), u;
- }
- _isInArrayFormulaRange(a, e, t) {
- if (a == null)
- return !1;
- const { startRow: r, startColumn: n, endRow: s, endColumn: o } = a;
- return e >= r && e <= s && t >= n && t <= o;
- }
- _checkIfArrayFormulaExceeded(a, e, t) {
- return t.endRow >= a || t.endColumn >= e;
- }
- _isInDirtyRange(a, e, t, r) {
- const n = this._currentConfigService.getDirtyRanges();
- return n.length === 0 ? !0 : zu(n, a, e, t, r);
- }
- };
- Is = jf([
- Uf(0, Ft)
- ], Is);
- const Nt = lt("univer.formula.runtime.service");
- var oe = /* @__PURE__ */ ((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 || {});
- const _t = /* @__PURE__ */ new Map([
- [1, 7],
- [2, 9],
- [3, 8],
- [4, 6],
- [5, 1],
- [6, 2],
- [9, 10],
- [10, 3],
- [11, 4],
- [12, 5]
- ]);
- class Ge {
- constructor(a) {
- A(this, "_children", []);
- A(this, "_definedNames");
- A(this, "_parent");
- A(this, "_valueObject");
- A(this, "_calculateState", !1);
- A(this, "_async", !1);
- A(this, "_address", !1);
- A(this, "_isForcedCalculateFunction", !1);
- this._token = a;
- }
- dispose() {
- var a;
- this._children.forEach((e) => {
- e.dispose();
- }), (a = this._valueObject) == null || a.dispose(), this._valueObject = null, this._children = [], this._definedNames = null, this._parent = null;
- }
- get nodeType() {
- return oe.BASE;
- }
- isAsync() {
- return this._async;
- }
- isAddress() {
- return this._address;
- }
- isForcedCalculateFunction() {
- return this._isForcedCalculateFunction;
- }
- setAsync() {
- this._async = !0;
- }
- setAddress() {
- this._address = !0;
- }
- getParent() {
- return this._parent;
- }
- setParent(a) {
- this._parent = a, a.addChildren(this);
- }
- setForcedCalculateFunction() {
- this._isForcedCalculateFunction = !0;
- }
- getChildren() {
- return this._children;
- }
- addChildren(...a) {
- this._children.push(...a);
- }
- getToken() {
- return this._token;
- }
- setValue(a) {
- this._valueObject = a;
- }
- getValue() {
- return this._valueObject;
- }
- isCalculated() {
- return this._calculateState;
- }
- setCalculated() {
- this._calculateState = !0;
- }
- execute() {
- }
- setNotEmpty(a = !0) {
- }
- async executeAsync() {
- return Promise.resolve(xt.SUCCESS);
- }
- serialize() {
- const a = this.getToken(), e = this.getChildren(), t = [], r = e.length;
- for (let s = 0; s < r; s++) {
- const o = e[s];
- t.push(o.serialize());
- }
- const n = {
- token: a,
- nodeType: this.nodeType
- };
- return r > 0 && (n.children = t), n;
- }
- hasDefinedName(a) {
- var e;
- return ((e = this._definedNames) == null ? void 0 : e.includes(a)) || !1;
- }
- setDefinedNames(a) {
- this._definedNames = a;
- }
- getDefinedNames() {
- return this._definedNames;
- }
- }
- class xe extends Ge {
- constructor(e) {
- super(e);
- A(this, "_errorValueObject");
- this._errorValueObject = g.create(e);
- }
- get nodeType() {
- return oe.ERROR;
- }
- static create(e) {
- return new xe(e);
- }
- getValue() {
- return this._errorValueObject;
- }
- }
- const At = 100;
- class Et {
- get zIndex() {
- return 0;
- }
- dispose() {
- }
- create(a, e, t) {
- let r;
- return a instanceof ae ? r = a.getToken() : r = a, new Ge(r);
- }
- }
- class Fs extends Ge {
- get nodeType() {
- return oe.ROOT;
- }
- execute() {
- const a = this.getChildren();
- if (a.length > 1) {
- this.setValue(g.create(m.VALUE));
- return;
- }
- const e = a[0];
- e == null ? this.setValue(g.create(m.VALUE)) : this.setValue(e.getValue());
- }
- }
- class Eo extends Et {
- get zIndex() {
- return _t.get(oe.ROOT) || At;
- }
- checkAndCreateNodeType(a) {
- if (!(a instanceof ae))
- return;
- if (a.getToken() === Ut)
- return new Fs(Ut);
- }
- }
- const Yt = lt("univer.formula-function.service");
- class vf extends Me {
- constructor() {
- super(...arguments);
- A(this, "_functionExecutors", /* @__PURE__ */ new Map());
- A(this, "_functionDescriptions", /* @__PURE__ */ new Map());
- }
- dispose() {
- this._functionExecutors.clear(), this._functionDescriptions.clear();
- }
- registerExecutors(...e) {
- for (let t = 0; t < e.length; t++) {
- const r = e[t];
- this._functionExecutors.set(r.name, r);
- }
- }
- getExecutors() {
- return this._functionExecutors;
- }
- getExecutor(e) {
- return this._functionExecutors.get(e);
- }
- hasExecutor(e) {
- return this._functionExecutors.has(e);
- }
- unregisterExecutors(...e) {
- for (let t = 0; t < e.length; t++) {
- const r = e[t];
- this._functionExecutors.delete(r);
- }
- }
- registerDescriptions(...e) {
- for (let t = 0; t < e.length; t++) {
- const r = e[t];
- this._functionDescriptions.set(r.functionName, r);
- }
- return Hu(() => {
- for (let t = 0; t < e.length; t++) {
- const r = e[t];
- this._functionDescriptions.delete(r.functionName);
- }
- });
- }
- getDescriptions() {
- return this._functionDescriptions;
- }
- getDescription(e) {
- return this._functionDescriptions.get(e);
- }
- hasDescription(e) {
- return this._functionDescriptions.has(e);
- }
- unregisterDescriptions(...e) {
- for (let t = 0; t < e.length; t++) {
- const r = e[t];
- this._functionDescriptions.delete(r);
- }
- }
- }
- var Te = /* @__PURE__ */ ((i) => (i.COMPARE = "COMPARE", i.DIVIDED = "DIVIDED", i.MINUS = "MINUS", i.MULTIPLY = "MULTIPLY", i.PLUS = "PLUS", i.UNION = "UNION", i.CUBE = "CUBE", i))(Te || {}), Tf = Object.defineProperty, Bf = Object.getOwnPropertyDescriptor, If = (i, a, e, t) => {
- for (var r = t > 1 ? void 0 : t ? Bf(a, e) : a, n = i.length - 1, s; n >= 0; n--)
- (s = i[n]) && (r = (t ? s(a, e, r) : s(r)) || r);
- return t && r && Tf(a, e, r), r;
- }, Ei = (i, a) => (e, t) => a(e, t, i);
- class _n extends Ge {
- constructor(a, e, t) {
- super(e), this._runtimeService = a, this._operatorString = e, this._functionExecutor = t;
- }
- get nodeType() {
- return oe.PREFIX;
- }
- execute() {
- let e = this.getChildren()[0].getValue(), t;
- if (e == null)
- throw new Error("object is null");
- this._operatorString === Oe.MINUS ? (e.isReferenceObject() && (e = e.toArrayValueObject()), t = this._functionExecutor.calculate(
- y.create(0),
- e
- )) : this._operatorString === Oe.AT ? t = this._handlerAT(e) : t = g.create(m.VALUE), this.setValue(t);
- }
- _handlerAT(a) {
- if (!a.isReferenceObject())
- return g.create(m.VALUE);
- const e = a;
- if (e.isCell())
- return g.create(m.VALUE);
- const t = this._runtimeService, r = t.currentRow || 0, n = t.currentColumn || 0, s = e.getRangePosition(), { startRow: o, startColumn: u, endRow: c, endColumn: l } = s;
- return l !== u && c !== o || o === c && u === l ? g.create(m.VALUE) : c === o && n >= u && n <= l ? e.getCellByColumn(n) : u === l && r >= o && r <= c ? e.getCellByRow(r) : e.isTable() ? e.getCellByPosition(r) : g.create(m.VALUE);
- }
- }
- let An = class extends Et {
- constructor(i, a) {
- super(), this._functionService = i, this._runtimeService = a;
- }
- get zIndex() {
- return _t.get(oe.PREFIX) || At;
- }
- checkAndCreateNodeType(i) {
- if (!(i instanceof ae))
- return;
- const a = i.getToken(), e = a.trim();
- if (e.charAt(0) === '"' && e.charAt(e.length - 1) === '"')
- return;
- let t = "";
- if (e === Oe.MINUS)
- t = Te.MINUS;
- else return e === Oe.AT ? new _n(this._runtimeService, e) : void 0;
- const r = this._functionService.getExecutor(t);
- return r ? new _n(this._runtimeService, e, r) : (console.error(`No function ${a}`), xe.create(m.NAME));
- }
- };
- An = If([
- Ei(0, Yt),
- Ei(1, Nt)
- ], An);
- new RegExp(Oe.MINUS, "g");
- new RegExp(Oe.AT, "g");
- function bo(i, a, e) {
- let t, r, n = i;
- const s = n.slice(0, 2);
- let o = 0;
- if (s[0] === Oe.MINUS) {
- const u = a.getExecutor(Te.MINUS);
- t = new _n(e, Oe.MINUS, u), o++;
- }
- return s[0] === Oe.AT && (r = new _n(e, Oe.AT), t && r.setParent(t), o++), o > 0 && (n = n.slice(o)), { tokenTrim: n, minusPrefixNode: t, atPrefixNode: r };
- }
- var Ff = Object.defineProperty, kf = Object.getOwnPropertyDescriptor, $f = (i, a, e, t) => {
- for (var r = t > 1 ? void 0 : t ? kf(a, e) : a, n = i.length - 1, s; n >= 0; n--)
- (s = i[n]) && (r = (t ? s(a, e, r) : s(r)) || r);
- return t && r && Ff(a, e, r), r;
- }, ir = (i, a) => (e, t) => a(e, t, i);
- class Yf extends Ge {
- constructor(a, e, t, r, n, s) {
- super(a), 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);
- }
- get nodeType() {
- return oe.FUNCTION;
- }
- async executeAsync() {
- const a = [], e = this.getChildren(), t = e.length;
- this._compatibility();
- for (let s = 0; s < t; s++) {
- const u = e[s].getValue();
- u != null && (u.isReferenceObject() && !this._functionExecutor.needsReferenceObject ? a.push(u.toArrayValueObject()) : a.push(u));
- }
- const r = await this._calculateAsync(a);
- let n;
- return r.isAsyncObject() || r.isAsyncArrayObject() ? n = await r.getValue() : n = r, this._setRefData(n), this.setValue(n), Promise.resolve(xt.SUCCESS);
- }
- execute() {
- const a = [], e = this.getChildren(), t = e.length;
- this._compatibility();
- for (let n = 0; n < t; n++) {
- const o = e[n].getValue();
- o != null && (o.isReferenceObject() && !this._functionExecutor.needsReferenceObject ? a.push(o.toArrayValueObject()) : a.push(o));
- }
- const r = this._calculate(a);
- this._setRefData(r), this.setValue(r);
- }
- /**
- * Compatibility handling for special functions.
- */
- _compatibility() {
- this._lookupCompatibility();
- }
- /**
- * The LOOKUP function follows the following rules when dealing with vectors of different sizes:
- * If the lookup_vector is larger than the result_vector,
- * 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.
- * If the lookup_vector is smaller than the result_vector,
- * 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.
- */
- _lookupCompatibility() {
- const a = this.getChildren(), e = a.length;
- if (!this._functionExecutor.needsExpandParams || e !== 3)
- return;
- const t = a[1].getValue(), r = a[2].getValue();
- if (!(t != null && t.isReferenceObject()) && !(r != null && r.isReferenceObject()))
- return;
- let n, s;
- if (t != null && t.isReferenceObject()) {
- const _ = t.getRangeData(), { startRow: C, startColumn: E, endRow: b, endColumn: R } = _;
- n = b - C + 1, s = R - E + 1;
- } else
- n = t != null && t.isArray() ? t.getRowCount() : 1, s = t != null && t.isArray() ? t.getColumnCount() : 1;
- const o = r.getRangeData(), { startRow: u, startColumn: c, endRow: l, endColumn: f } = o, h = l - u + 1, d = f - c + 1;
- n !== h && (o.endRow += n - h), s !== d && (o.endColumn += s - d);
- }
- /**
- * Transform the result of a custom function to a NodeValueType.
- */
- _handleCustomResult(a) {
- var t;
- if (typeof a != "object" || a == null)
- return pt.create(a);
- const e = Ao(a);
- return q.create({
- calculateValueList: e,
- rowCount: e.length,
- columnCount: ((t = e[0]) == null ? void 0 : t.length) || 0,
- unitId: "",
- sheetId: "",
- row: -1,
- column: -1
- });
- }
- _handleAddressFunction() {
- this._functionExecutor.isAddress() && this._setDefinedNamesForFunction();
- }
- _mapVariantsToValues(a) {
- return a.map((e) => e.isArray() ? e.toValue() : e.isLambda() ? e : e.getValue());
- }
- _calculate(a) {
- const { minParams: e, maxParams: t } = this._functionExecutor;
- if (e !== -1 && t !== -1 && (a.length < e || a.length > t))
- return g.create(m.NA);
- let r;
- if (this._setRefInfo(), this._functionExecutor.isCustom()) {
- const n = this._functionExecutor.calculateCustom(
- ...this._mapVariantsToValues(a)
- );
- r = this._handleCustomResult(n);
- } else
- this._handleAddressFunction(), r = this._functionExecutor.calculate(...a);
- return r;
- }
- async _calculateAsync(a) {
- const { minParams: e, maxParams: t } = this._functionExecutor;
- if (e !== -1 && t !== -1 && (a.length < e || a.length > t))
- return g.create(m.NA);
- let r;
- if (this._setRefInfo(), this._functionExecutor.isCustom()) {
- const n = await this._functionExecutor.calculateCustom(
- ...this._mapVariantsToValues(a)
- );
- r = this._handleCustomResult(n);
- } else
- this._handleAddressFunction(), r = this._functionExecutor.calculate(...a);
- return r;
- }
- _setDefinedNamesForFunction() {
- const a = this._currentConfigService.getExecuteUnitId();
- if (a == null)
- return;
- const e = this._definedNamesService.getDefinedNameMap(a);
- e != null && this._functionExecutor.setDefinedNames(e);
- }
- _setRefInfo() {
- const { currentUnitId: a, currentSubUnitId: e, currentRow: t, currentColumn: r } = this._runtimeService;
- if (this._functionExecutor.setRefInfo(a, e, t, r), this._functionExecutor.needsSheetRowColumnCount) {
- const { rowCount: n, columnCount: s } = this._currentConfigService.getSheetRowColumnCount(a, e);
- this._functionExecutor.setSheetRowColumnCount(n, s);
- }
- }
- _setRefData(a) {
- if (!a.isReferenceObject())
- return;
- const e = a;
- 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());
- }
- _setLocale() {
- this._functionExecutor.setLocale(this._currentConfigService.getLocale());
- }
- _setSheetsInfo() {
- this._functionExecutor.setSheetsInfo(this._currentConfigService.getSheetsInfo());
- }
- }
- class Hf extends Ge {
- constructor(a = "Error") {
- super(a);
- }
- get nodeType() {
- return oe.FUNCTION;
- }
- async executeAsync() {
- return this.setValue(g.create(m.NAME)), Promise.resolve(xt.SUCCESS);
- }
- execute() {
- this.setValue(g.create(m.NAME));
- }
- }
- let En = class extends Et {
- constructor(i, a, e, t, r, n) {
- super(), this._functionService = i, this._currentConfigService = a, this._runtimeService = e, this._definedNamesService = t, this._injector = r, this._formulaDataModel = n;
- }
- get zIndex() {
- return _t.get(oe.FUNCTION) || At;
- }
- create(i) {
- const a = this._functionService.getExecutor(i);
- return a ? new Yf(
- i,
- a,
- this._currentConfigService,
- this._runtimeService,
- this._definedNamesService,
- this._formulaDataModel
- ) : (console.error(`No function ${i}`), xe.create(m.NAME));
- }
- checkAndCreateNodeType(i) {
- if (typeof i == "string")
- return;
- const a = i.getToken(), { tokenTrim: e, minusPrefixNode: t, atPrefixNode: r } = bo(a.trim(), this._functionService, this._runtimeService);
- if (!Number.isNaN(Number(e)) && !this._isParentUnionNode(i))
- return xe.create(m.VALUE);
- const n = e.toUpperCase();
- if (this._functionService.hasExecutor(n)) {
- const s = this.create(n);
- return r ? s.setParent(r) : t && s.setParent(t), s;
- }
- }
- _isParentUnionNode(i) {
- var a, e;
- return ((e = (a = i.getParent()) == null ? void 0 : a.getParent()) == null ? void 0 : e.getToken()) === K.COLON;
- }
- };
- En = $f([
- ir(0, Yt),
- ir(1, Ft),
- ir(2, Nt),
- ir(3, pr),
- ir(4, Ve(ki)),
- ir(5, Ve(Pr))
- ], En);
- var Gf = Object.defineProperty, Qf = Object.getOwnPropertyDescriptor, Wf = (i, a, e, t) => {
- for (var r = t > 1 ? void 0 : t ? Qf(a, e) : a, n = i.length - 1, s; n >= 0; n--)
- (s = i[n]) && (r = (t ? s(a, e, r) : s(r)) || r);
- return t && r && Gf(a, e, r), r;
- }, qf = (i, a) => (e, t) => a(e, t, i);
- let Cr = class extends Me {
- constructor(i) {
- super(), this._runtimeService = i;
- }
- async executeAsync(i) {
- if (!i || !i.node)
- return Promise.resolve(g.create(m.VALUE));
- const a = i.node, e = i.refOffsetX, t = i.refOffsetY;
- await this._executeAsync(a, e, t);
- const r = a.getValue();
- return r == null ? Promise.resolve(g.create(m.VALUE)) : Promise.resolve(r);
- }
- execute(i) {
- if (!i || !i.node)
- return g.create(m.VALUE);
- const a = i.node, e = i.refOffsetX, t = i.refOffsetY;
- this._execute(a, e, t);
- const r = a.getValue();
- return r == null ? g.create(m.VALUE) : r;
- }
- executePreCalculateNode(i) {
- return i.execute(), i.getValue();
- }
- checkAsyncNode(i) {
- if (i == null)
- return !1;
- const a = [];
- this._checkAsyncNode(i, a);
- for (let e = 0, t = a.length; e < t; e++)
- if (a[e] === !0)
- return !0;
- return !1;
- }
- _checkAsyncNode(i, a) {
- const e = i.getChildren(), t = e.length;
- for (let r = 0; r < t; r++) {
- const n = e[r];
- a.push(n.isAsync()), this._checkAsyncNode(n, a);
- }
- }
- async _executeAsync(i, a = 0, e = 0) {
- if (this._runtimeService.isStopExecution())
- return Promise.resolve(xt.ERROR);
- const t = i.getChildren(), r = t.length;
- for (let n = 0; n < r; n++) {
- const s = t[n];
- if (s.getToken().toUpperCase() === Sr && s.isEmptyParamFunction()) {
- s.execute();
- continue;
- }
- await this._executeAsync(s, a, e);
- }
- return i.nodeType === oe.REFERENCE && i.setRefOffset(a, e), i.nodeType === oe.FUNCTION && i.isAsync() ? await i.executeAsync() : i.execute(), Promise.resolve(xt.SUCCESS);
- }
- _execute(i, a = 0, e = 0) {
- if (this._runtimeService.isStopExecution())
- return xt.ERROR;
- const t = i.getChildren(), r = t.length;
- for (let n = 0; n < r; n++) {
- const s = t[n];
- if (s.getToken().toUpperCase() === Sr && s.isEmptyParamFunction()) {
- s.execute();
- continue;
- }
- this._execute(s, a, e);
- }
- return i.nodeType === oe.REFERENCE && i.setRefOffset(a, e), i.execute(), xt.SUCCESS;
- }
- };
- Cr = Wf([
- qf(0, Nt)
- ], Cr);
- function yo(i) {
- return i instanceof ae ? i.getToken() === hr : !1;
- }
- function Kf(i) {
- return i instanceof ae ? i.getToken() === ro : !1;
- }
- function Ea(i, a, e) {
- const t = i.getChildren(), r = t.length, n = t[0];
- for (let s = 0; s < r; s++) {
- const o = t[s];
- if (!(yo(n) && s !== 0))
- if (o instanceof ae)
- Ea(o, a, e);
- else {
- const u = o.trim();
- if (e.has(u)) {
- const c = new ae();
- c.setToken(Tr), c.setLambdaId(a), c.setLambdaPrivacyVar(e), c.setLambdaParameter(u), t[s] = c;
- }
- }
- }
- }
- function Xf(i) {
- let a = i;
- for (; a != null && a.getParent(); )
- a = a.getParent();
- return a;
- }
- function bi(i, a = 0, e = 0) {
- return {
- node: i,
- refOffsetX: a,
- refOffsetY: e
- };
- }
- function Ro(i) {
- if (!i)
- return;
- if (i.getToken() !== Tr)
- return i;
- const a = i, e = a.getCurrentLambdaPrivacyVar(), t = a.getLambdaParameter();
- if (!e)
- return;
- const r = e.get(t);
- return r == null && i.getValue() ? i : Ro(r);
- }
- class ba extends kt {
- constructor(e, t, r) {
- super(0);
- A(this, "_lambdaPrivacyValueMap", /* @__PURE__ */ new Map());
- this._lambdaNode = e, this._interpreter = t, this._lambdaPrivacyVarKeys = r, this._lambdaPrivacyValueMap.clear();
- }
- static create(e, t, r) {
- return new ba(e, t, r);
- }
- dispose() {
- this._lambdaPrivacyValueMap.clear(), this._lambdaPrivacyValueMap = /* @__PURE__ */ new Map(), this._lambdaNode = null, this._interpreter = null, this._lambdaPrivacyVarKeys = [];
- }
- isLambda() {
- return !0;
- }
- execute(...e) {
- const t = this._lambdaPrivacyVarKeys.length;
- if (e.length !== t || !this._interpreter || !this._lambdaNode)
- return g.create(m.VALUE);
- this._setLambdaPrivacyValueMap(e), this._setLambdaNodeValue(this._lambdaNode), this._lambdaNode.setNotEmpty(!1);
- let r;
- if (this._interpreter.checkAsyncNode(this._lambdaNode))
- r = new Nf(this._interpreter.executeAsync(bi(this._lambdaNode)));
- else {
- const n = this._interpreter.execute(bi(this._lambdaNode));
- n.isReferenceObject() ? r = n.toArrayValueObject() : r = n;
- }
- return this._lambdaNode.setNotEmpty(!0), r;
- }
- /**
- * Execute custom lambda function, handle basic types
- * @param variants
- */
- executeCustom(...e) {
- const t = e.map((r) => pt.create(r));
- return this.execute(...t);
- }
- _setLambdaNodeValue(e) {
- if (!e)
- return;
- const t = e.getChildren(), r = t.length;
- for (let n = 0; n < r; n++) {
- const s = t[n];
- if (s.getToken() === Tr) {
- const u = s.getLambdaParameter(), c = this._lambdaPrivacyValueMap.get(u);
- if (c)
- s.setValue(c);
- else {
- const l = s.getCurrentLambdaPrivacyVar(), f = Ro(l.get(u));
- f != null && s.setValue(f.getValue());
- }
- continue;
- }
- this._setLambdaNodeValue(s);
- }
- }
- _setLambdaPrivacyValueMap(e) {
- for (let t = 0; t < e.length; t++) {
- const r = e[t], n = this._lambdaPrivacyVarKeys[t];
- this._lambdaPrivacyValueMap.set(n, r);
- }
- }
- getLambdaPrivacyVarKeys() {
- return this._lambdaPrivacyVarKeys;
- }
- }
- var Zf = Object.defineProperty, zf = Object.getOwnPropertyDescriptor, Jf = (i, a, e, t) => {
- for (var r = t > 1 ? void 0 : t ? zf(a, e) : a, n = i.length - 1, s; n >= 0; n--)
- (s = i[n]) && (r = (t ? s(a, e, r) : s(r)) || r);
- return t && r && Zf(a, e, r), r;
- }, yi = (i, a) => (e, t) => a(e, t, i);
- class eh extends Ge {
- constructor(e, t, r, n) {
- super(e);
- A(this, "_isNotEmpty", !0);
- this._lambdaId = t, this._interpreter = r, this._lambdaPrivacyVarKeys = n;
- }
- get nodeType() {
- return oe.LAMBDA;
- }
- setNotEmpty(e = !1) {
- this._isNotEmpty = e;
- }
- isEmptyParamFunction() {
- return this.getChildren().length < 2 && this._isNotEmpty;
- }
- isFunctionParameter() {
- return this._lambdaId === null;
- }
- getLambdaId() {
- return this._lambdaId;
- }
- execute() {
- if (this.isEmptyParamFunction())
- this.setValue(ba.create(this, this._interpreter, this._lambdaPrivacyVarKeys));
- else {
- const e = this.getChildren(), t = e.length;
- this.setValue(e[t - 1].getValue());
- }
- }
- // override async executeAsync() {
- // if (this.isEmptyParamFunction()) {
- // await this.setValue(LambdaValueObjectObject.create(this, this._interpreter, this._lambdaPrivacyVarKeys));
- // } else {
- // const children = this.getChildren();
- // const childrenCount = children.length;
- // await this.setValue(children[childrenCount - 1].getValue());
- // }
- // return Promise.resolve(AstNodePromiseType.SUCCESS);
- // }
- }
- let bn = class extends Et {
- constructor(i, a) {
- super(), this._runtimeService = i, this._interpreter = a;
- }
- get zIndex() {
- return _t.get(oe.LAMBDA) || At;
- }
- create(i) {
- const a = i.getChildren(), e = a[0];
- let t = a.slice(1, -1);
- const r = a[a.length - 1];
- if (!(e instanceof ae && r instanceof ae))
- return xe.create(m.NAME);
- if (e.getToken() === hr) {
- const o = e.getChildren();
- if (t.length !== o.length)
- return xe.create(m.VALUE);
- } else
- t = a.slice(0, -1);
- const n = Xe.generateRandomId(8), s = /* @__PURE__ */ new Map();
- for (let o = 0; o < t.length; o++) {
- const u = t[o];
- if (u instanceof ae) {
- const c = u.getChildren()[0];
- u.setToken(ro), s.set(c.trim(), void 0);
- } else
- return xe.create(m.VALUE);
- }
- return this._runtimeService.registerFunctionDefinitionPrivacyVar(n, s), this._updateLambdaStatement(r, n, s), new eh(i.getToken(), n, this._interpreter, [...s.keys()]);
- }
- checkAndCreateNodeType(i) {
- if (!(!(i instanceof ae) || i.getToken().trim().toUpperCase() !== Sr))
- return this.create(i);
- }
- _updateLambdaStatement(i, a, e) {
- Ea(i, a, e);
- }
- };
- bn = Jf([
- yi(0, Nt),
- yi(1, Ve(Cr))
- ], bn);
- function po(i) {
- if (!i)
- return;
- if (i.getToken() !== Tr)
- return i;
- const a = i, e = a.getCurrentLambdaPrivacyVar(), t = a.getLambdaParameter();
- if (e)
- return po(e.get(t));
- }
- class th extends Ge {
- constructor(a, e, t) {
- super(a), this._lambdaParameter = e, this._currentLambdaPrivacyVar = t;
- }
- getLambdaParameter() {
- return this._lambdaParameter;
- }
- getCurrentLambdaPrivacyVar() {
- return this._currentLambdaPrivacyVar;
- }
- get nodeType() {
- return oe.LAMBDA_PARAMETER;
- }
- execute() {
- const a = po(this._currentLambdaPrivacyVar.get(this._lambdaParameter));
- if (a)
- this.setValue(a.getValue());
- else {
- const e = this.getValue();
- (e == null || e.isError()) && this.setValue(g.create(m.NAME));
- }
- }
- }
- class Vo extends Et {
- get zIndex() {
- return _t.get(oe.LAMBDA_PARAMETER) || At;
- }
- create(a) {
- const e = a.getFunctionDefinitionPrivacyVar(), t = a.getLambdaParameter();
- return e ? new th(a.getToken(), t, e) : new xe(m.NAME);
- }
- checkAndCreateNodeType(a) {
- if (!(!(a instanceof ae) || a.getToken().trim() !== Tr))
- return this.create(a);
- }
- }
- class rh extends Ge {
- constructor(a) {
- super(a), this._operatorString = a;
- }
- get nodeType() {
- return oe.NULL;
- }
- execute() {
- this.setValue(ie.create());
- }
- }
- var Y = /* @__PURE__ */ ((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))(Y || {}), se = /* @__PURE__ */ ((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 || {}), nh = Object.defineProperty, sh = Object.getOwnPropertyDescriptor, ah = (i, a, e, t) => {
- for (var r = t > 1 ? void 0 : t ? sh(a, e) : a, n = i.length - 1, s; n >= 0; n--)
- (s = i[n]) && (r = (t ? s(a, e, r) : s(r)) || r);
- return t && r && nh(a, e, r), r;
- }, ih = (i, a) => (e, t) => a(e, t, i);
- class oh extends Ge {
- constructor(a, e) {
- super(a), this._functionExecutor = e;
- }
- get nodeType() {
- return oe.OPERATOR;
- }
- execute() {
- const a = this.getChildren();
- this._functionExecutor.name === Te.COMPARE && this._functionExecutor.setCompareType(this.getToken());
- const e = a[0], t = a[1];
- let r = e == null ? void 0 : e.getValue(), n = t == null ? void 0 : t.getValue();
- const s = this.getToken();
- if ((r == null || n == null) && s !== X.MINUS && s !== X.PLUS) {
- this.setValue(g.create(m.VALUE));
- return;
- }
- r == null && (r = ie.create()), n == null && (n = ie.create()), r.isReferenceObject() && (r = r.toArrayValueObject()), n.isReferenceObject() && (n = n.toArrayValueObject()), this.setValue(
- this._functionExecutor.calculate(
- r,
- n
- )
- );
- }
- }
- let yn = class extends Et {
- constructor(i) {
- super(), this._functionService = i;
- }
- get zIndex() {
- return _t.get(oe.OPERATOR) || At;
- }
- create(i) {
- let a = "";
- const e = i;
- e === X.PLUS ? a = Te.PLUS : e === X.MINUS ? a = Te.MINUS : e === X.MULTIPLY ? a = Te.MULTIPLY : e === X.DIVIDED ? a = Te.DIVIDED : e === X.CONCATENATE ? a = se.CONCATENATE : e === X.POWER ? a = Y.POWER : ec.has(e) && (a = Te.COMPARE);
- const t = this._functionService.getExecutor(a);
- return t ? new oh(e, t) : (console.error(`No function ${i}`), xe.create(m.NAME));
- }
- checkAndCreateNodeType(i) {
- if (i instanceof ae)
- return;
- const a = i.trim();
- if (!(a.charAt(0) === '"' && a.charAt(a.length - 1) === '"') && Dt.has(a))
- return this.create(a);
- }
- };
- yn = ah([
- ih(0, Yt)
- ], yn);
- var uh = Object.defineProperty, ch = Object.getOwnPropertyDescriptor, lh = (i, a, e, t) => {
- for (var r = t > 1 ? void 0 : t ? ch(a, e) : a, n = i.length - 1, s; n >= 0; n--)
- (s = i[n]) && (r = (t ? s(a, e, r) : s(r)) || r);
- return t && r && uh(a, e, r), r;
- }, cs = (i, a) => (e, t) => a(e, t, i);
- class ls extends Ge {
- constructor(e, t, r, n, s = !1) {
- super(r);
- A(this, "_refOffsetX", 0);
- A(this, "_refOffsetY", 0);
- this._currentConfigService = e, this._runtimeService = t, this._referenceObjectType = n, this._isPrepareMerge = s;
- }
- get nodeType() {
- return oe.REFERENCE;
- }
- execute() {
- const e = this._currentConfigService, t = this._runtimeService, r = Sf(this.getToken(), this._referenceObjectType);
- 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());
- const { x: n, y: s } = this.getRefOffset();
- r.setRefOffset(n, s), !this._isPrepareMerge && r.isExceedRange() ? this.setValue(g.create(m.NAME)) : this.setValue(r);
- }
- setRefOffset(e = 0, t = 0) {
- this._refOffsetX = e, this._refOffsetY = t;
- }
- getRefOffset() {
- return {
- x: this._refOffsetX,
- y: this._refOffsetY
- };
- }
- }
- let Rn = class extends Et {
- constructor(i, a, e) {
- super(), this._currentConfigService = i, this._formulaRuntimeService = a, this._functionService = e;
- }
- get zIndex() {
- return _t.get(oe.REFERENCE) || At;
- }
- checkAndCreateNodeType(i) {
- var l, f;
- let a = !1, e, t = !1;
- i instanceof ae ? (a = !0, e = i.getToken().trim(), ((f = (l = i.getParent()) == null ? void 0 : l.getParent()) == null ? void 0 : f.getToken().trim()) === K.COLON && (t = !0)) : e = i.trim();
- const r = this._currentConfigService, n = this._formulaRuntimeService, { tokenTrim: s, minusPrefixNode: o, atPrefixNode: u } = bo(e, this._functionService, n);
- if (!a && s.charAt(0) === '"' && s.charAt(s.length - 1) === '"')
- return;
- let c;
- if (vr(s) ? c = new ls(r, n, s, an.CELL, t) : a && 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)
- return u ? c.setParent(u) : o && c.setParent(o), c;
- }
- _checkParentIsUnionOperator(i) {
- var a, e;
- return ((e = (a = i.getParent()) == null ? void 0 : a.getParent()) == null ? void 0 : e.getToken().trim()) === K.COLON;
- }
- };
- Rn = lh([
- cs(0, Ft),
- cs(1, Nt),
- cs(2, Yt)
- ], Rn);
- var fh = Object.defineProperty, hh = Object.getOwnPropertyDescriptor, mh = (i, a, e, t) => {
- for (var r = t > 1 ? void 0 : t ? hh(a, e) : a, n = i.length - 1, s; n >= 0; n--)
- (s = i[n]) && (r = (t ? s(a, e, r) : s(r)) || r);
- return t && r && fh(a, e, r), r;
- }, fs = (i, a) => (e, t) => a(e, t, i);
- class Ri extends Ge {
- constructor(a, e, t, r) {
- super(t), this._currentConfigService = a, this._lexer = e, this._operatorString = t, this._functionExecutor = r;
- }
- get nodeType() {
- return oe.SUFFIX;
- }
- execute() {
- let e = this.getChildren()[0].getValue(), t;
- if (e == null)
- throw new Error("object is null");
- if (this._operatorString === ze.PERCENTAGE) {
- if (e.isReferenceObject() && (e = e.toArrayValueObject()), t = this._functionExecutor.calculate(
- e,
- y.create(100)
- ), t.isNumber()) {
- const r = Number(t.getValue());
- t = y.create(r, "0.00%");
- }
- } else this._operatorString === ze.POUND ? t = this._handlerPound(e) : t = g.create(m.VALUE);
- this.setValue(t);
- }
- _handlerPound(a) {
- var u, c, l, f;
- if (!a.isReferenceObject() || !a.isCell())
- return g.create(m.VALUE);
- const e = a, t = e.getRangePosition(), r = e.getUnitId(), n = e.getSheetId(), s = this._currentConfigService.getFormulaData(), o = (f = (l = (c = (u = s == null ? void 0 : s[r]) == null ? void 0 : u[n]) == null ? void 0 : c[t.startRow]) == null ? void 0 : l[t.startColumn]) == null ? void 0 : f.f;
- return o && this._lexer.treeBuilder(o), g.create(m.VALUE);
- }
- }
- let pn = class extends Et {
- constructor(i, a, e) {
- super(), this._functionService = i, this._lexer = a, this._currentConfigService = e;
- }
- get zIndex() {
- return _t.get(oe.SUFFIX) || At;
- }
- checkAndCreateNodeType(i) {
- if (!(i instanceof ae))
- return;
- const a = i.getToken().trim();
- if (a.charAt(0) === '"' && a.charAt(a.length - 1) === '"')
- return;
- let e = "";
- if (a === ze.PERCENTAGE)
- e = Te.DIVIDED;
- else return a === ze.POUND ? new Ri(this._currentConfigService, this._lexer, a) : void 0;
- const t = this._functionService.getExecutor(e);
- return t ? new Ri(this._currentConfigService, this._lexer, a, t) : (console.error(`No function ${i}`), xe.create(m.NAME));
- }
- };
- pn = mh([
- fs(0, Yt),
- fs(1, Ve(gr)),
- fs(2, Ft)
- ], pn);
- var gh = Object.defineProperty, dh = Object.getOwnPropertyDescriptor, Ch = (i, a, e, t) => {
- for (var r = t > 1 ? void 0 : t ? dh(a, e) : a, n = i.length - 1, s; n >= 0; n--)
- (s = i[n]) && (r = (t ? s(a, e, r) : s(r)) || r);
- return t && r && gh(a, e, r), r;
- }, _h = (i, a) => (e, t) => a(e, t, i);
- class Ah extends Ge {
- constructor(a) {
- super(a);
- }
- get nodeType() {
- return oe.UNION;
- }
- execute() {
- const a = this.getChildren(), e = a[0], t = a[1], r = e.getValue(), n = t.getValue();
- if (r == null || n == null)
- throw new Error("leftNode and rightNode");
- let s;
- this.getToken() === K.COLON ? s = this._unionFunction(r, n) : s = g.create(m.NAME), this.setValue(s);
- }
- _unionFunction(a, e) {
- return a.isError() || e.isError() || !a.isReferenceObject() || !e.isReferenceObject() ? g.create(m.REF) : (a = a, e = e, Pf(a, e));
- }
- }
- let Vn = class extends Et {
- constructor(i) {
- super(), this._functionService = i;
- }
- get zIndex() {
- return _t.get(oe.UNION) || At;
- }
- create(i) {
- return new Ah(i);
- }
- checkAndCreateNodeType(i) {
- if (!(i instanceof ae))
- return;
- const e = i.getToken().trim();
- if (!(e.charAt(0) === '"' && e.charAt(e.length - 1) === '"') && e === K.COLON)
- return this.create(e);
- }
- };
- Vn = Ch([
- _h(0, Yt)
- ], Vn);
- class Eh extends Ge {
- constructor(a) {
- super(a);
- }
- get nodeType() {
- return oe.VALUE;
- }
- execute() {
- this.setValue(pt.create(this.getToken()));
- }
- }
- class No extends Et {
- get zIndex() {
- return _t.get(oe.VALUE) || At;
- }
- _checkValueNode(a) {
- if (Number.isNaN(Number(a))) {
- const e = a.trim(), t = e.charAt(0), r = e.charAt(e.length - 1);
- if (yr.has(e))
- return this.create(e);
- if (t === '"' && r === '"')
- return this.create(e);
- if (t === "{" && r === "}")
- return this.create(e);
- const n = e.toUpperCase();
- if (n === er.TRUE || n === er.FALSE)
- return this.create(n);
- } else
- return this.create(a);
- }
- create(a) {
- return new Eh(a);
- }
- checkAndCreateNodeType(a) {
- if (!(a instanceof ae))
- return this._checkValueNode(a);
- }
- }
- var bh = Object.defineProperty, yh = Object.getOwnPropertyDescriptor, Rh = (i, a, e, t) => {
- for (var r = t > 1 ? void 0 : t ? yh(a, e) : a, n = i.length - 1, s; n >= 0; n--)
- (s = i[n]) && (r = (t ? s(a, e, r) : s(r)) || r);
- return t && r && bh(a, e, r), r;
- }, at = (i, a) => (e, t) => a(e, t, i);
- let xr = class extends Me {
- constructor(a, e, t, r, n, s, o, u, c, l, f) {
- super();
- A(this, "_astNodeFactoryList", []);
- this._runtimeService = a, 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 = l, this._valueNodeFactory = f, this._initializeAstNode();
- }
- dispose() {
- this._astNodeFactoryList.forEach((a) => {
- a.dispose();
- }), this._astNodeFactoryList = [];
- }
- parse(a) {
- const e = new Fs(Ut), t = this._parse(a, e);
- return a.hasDefinedNames() && (t == null || t.setDefinedNames(a.getDefinedNames())), t;
- }
- _lambdaParameterHandler(a, e) {
- if (e.getLambdaId == null)
- return xe.create(m.VALUE);
- const t = e.getLambdaId(), r = new Fs(Ut), n = this._runtimeService.getFunctionDefinitionPrivacyVar(t);
- if (!n)
- return !1;
- const s = [...n.keys()], o = a.getChildren(), u = o.length;
- for (let c = 0; c < u; c++) {
- const l = o[c];
- if (l instanceof ae) {
- Ea(l, t, n), this._parse(l, r);
- const h = r.getChildren()[c];
- h != null && n.set(s[c], h);
- } else
- return !1;
- }
- return r.setParent(e), e;
- }
- _changeLetToLambda(a) {
- const e = a.getChildren(), t = e.length;
- if (t % 2 !== 1 || t === 0)
- return;
- const r = new ae();
- r.setToken(Sr);
- const n = new ae();
- n.setToken(hr);
- const s = [...e];
- for (let u = 0; u < t; u++) {
- const c = s[u];
- if (!(c instanceof ae))
- return;
- u % 2 === 0 ? c.changeToParent(r) : c.changeToParent(n);
- }
- r.addChildrenFirst(n), n.setParent(r);
- const o = a.getParent();
- return o == null || o.replaceChild(a, r), r;
- }
- // eslint-disable-next-line max-lines-per-function, complexity
- _parse(a, e) {
- var l;
- const t = a.getChildren(), r = t.length, n = [];
- let s = null;
- const o = a.getToken().trim().toUpperCase();
- if (o === vc) {
- const f = this._changeLetToLambda(a);
- return f != null ? this._parse(f, e) : xe.create(m.ERROR);
- }
- if (o === ht) {
- if (s = e, r === 0)
- return new rh(Ut).setParent(e), s;
- } else {
- if (o === hr) {
- let f = this._lambdaParameterHandler(a, e);
- return f === !1 && (f = xe.create(m.ERROR)), f;
- }
- if (s = this._checkAstNode(a), s == null)
- return xe.create(m.NAME);
- }
- const u = t[0];
- for (let f = 0; f < r; f++) {
- const h = t[f];
- if (yo(u)) {
- if (f !== 0 && f !== r - 1)
- continue;
- } else if (Kf(h) && f !== r - 1)
- continue;
- let d = null;
- if (h instanceof ae) {
- if (h.getToken() === ht && h.getChildren().length === 0) {
- const _ = (l = h.getParent()) == null ? void 0 : l.getChildren();
- if (_ && _.length === 1)
- return xe.create(m.NAME);
- }
- if (d = this._parse(h, s), d === s)
- continue;
- } else
- d = this._checkAstNode(h);
- if (d == null)
- return xe.create(m.NAME);
- if (d = Xf(d), d == null || (d == null ? void 0 : d.nodeType) === oe.ERROR)
- return d;
- switch (d.nodeType) {
- // case NodeType.ERROR:
- // return astNode;
- case oe.FUNCTION: {
- const _ = d.getToken().trim().toUpperCase();
- Bc.has(_) && d.setForcedCalculateFunction(), n.push(d);
- break;
- }
- case oe.LAMBDA:
- n.push(d);
- break;
- case oe.LAMBDA_PARAMETER:
- n.push(d);
- break;
- case oe.OPERATOR: {
- const _ = n.pop(), C = n.pop();
- C && C.setParent(d), _ && _.setParent(d), n.push(d);
- break;
- }
- case oe.REFERENCE:
- n.push(d);
- break;
- case oe.ROOT:
- n.push(d);
- break;
- case oe.UNION:
- n.push(d);
- break;
- case oe.VALUE:
- n.push(d);
- break;
- case oe.PREFIX:
- n.push(d);
- break;
- case oe.SUFFIX:
- n.push(d);
- break;
- }
- }
- const c = n.length;
- for (let f = 0; f < c; f++)
- n[f].setParent(s);
- return s;
- }
- // private _setPrefixRefOffset(astNode: BaseAstNode) {
- // const children = astNode.getChildren();
- // const childrenCount = children.length;
- // for (let i = 0; i < childrenCount; i++) {
- // const item = children[i];
- // if (item.nodeType === NodeType.REFERENCE) {
- // item.setRefOffset(this._refOffsetX, this._refOffsetY);
- // }
- // }
- // }
- _checkAstNode(a) {
- let e = null;
- const t = this._astNodeFactoryList.length;
- for (let r = 0; r < t && (e = this._astNodeFactoryList[r].checkAndCreateNodeType(a), e == null); r++)
- ;
- return e == null ? new Hf() : e;
- }
- _initializeAstNode() {
- this._astNodeFactoryList = [
- this._astRootNodeFactory,
- this._functionNodeFactory,
- this._lambdaNodeFactory,
- this._lambdaParameterNodeFactory,
- this._operatorNodeFactory,
- this._prefixNodeFactory,
- this._referenceNodeFactory,
- this._suffixNodeFactory,
- this._unionNodeFactory,
- this._valueNodeFactory
- ].sort(Gu);
- }
- };
- xr = Rh([
- at(0, Nt),
- at(1, Ve(Eo)),
- at(2, Ve(En)),
- at(3, Ve(bn)),
- at(4, Ve(Vo)),
- at(5, Ve(yn)),
- at(6, Ve(An)),
- at(7, Ve(Rn)),
- at(8, Ve(pn)),
- at(9, Ve(Vn)),
- at(10, Ve(No))
- ], xr);
- class ph extends Me {
- constructor() {
- super(...arguments);
- A(this, "_otherFormulaData", /* @__PURE__ */ new Map());
- // [unitId: string]: Nullable<{ [sheetId: string]: { [formulaId: string]: Set<number> } }>;
- A(this, "_featureFormulaData", /* @__PURE__ */ new Map());
- // [unitId: string]: Nullable<{ [sheetId: string]: { [featureId: string]: Nullable<number> } }>;
- A(this, "_formulaData", /* @__PURE__ */ new Map());
- // [unitId: string]: Nullable<{ [sheetId: string]: ObjectMatrix<number> }>;
- A(this, "_definedNameMap", /* @__PURE__ */ new Map());
- // unitId -> definedName -> treeId
- A(this, "_otherFormulaDataMainData", /* @__PURE__ */ new Set());
- A(this, "_dependencyRTreeCache", new As());
- A(this, "_dependencyTreeIdLast", 0);
- }
- buildDependencyTree(e, t) {
- throw new Error("Method not implemented.");
- }
- getTreeById(e) {
- throw new Error("Method not implemented.");
- }
- getAllTree() {
- throw new Error("Method not implemented.");
- }
- reset() {
- throw new Error("Method not implemented.");
- }
- addOtherFormulaDependency(e, t, r, n) {
- throw new Error("Method not implemented.");
- }
- removeOtherFormulaDependency(e, t, r) {
- throw new Error("Method not implemented.");
- }
- clearOtherFormulaDependency(e, t) {
- throw new Error("Method not implemented.");
- }
- addFeatureFormulaDependency(e, t, r, n) {
- throw new Error("Method not implemented.");
- }
- removeFeatureFormulaDependency(e, t, r) {
- throw new Error("Method not implemented.");
- }
- clearFeatureFormulaDependency(e, t) {
- throw new Error("Method not implemented.");
- }
- addFormulaDependency(e, t, r, n, s) {
- throw new Error("Method not implemented.");
- }
- removeFormulaDependency(e, t, r, n) {
- throw new Error("Method not implemented.");
- }
- clearFormulaDependency(e, t) {
- throw new Error("Method not implemented.");
- }
- removeFormulaDependencyByDefinedName(e, t) {
- throw new Error("Method not implemented.");
- }
- searchDependency(e, t) {
- return this._dependencyRTreeCache.bulkSearch(e, t);
- }
- _restDependencyTreeId() {
- this._dependencyTreeIdLast = 0;
- }
- getOtherFormulaDependency(e, t, r) {
- var n, s;
- return (s = (n = this._otherFormulaData.get(e)) == null ? void 0 : n.get(t)) == null ? void 0 : s.get(r);
- }
- addOtherFormulaDependencyMainData(e) {
- this._otherFormulaDataMainData.add(e);
- }
- hasOtherFormulaDataMainData(e) {
- return this._otherFormulaDataMainData.has(e);
- }
- _removeDependencyRTreeCacheById(e, t) {
- this._dependencyRTreeCache.removeById(e, t);
- }
- getFeatureFormulaDependency(e, t, r) {
- var n, s;
- return (s = (n = this._featureFormulaData.get(e)) == null ? void 0 : n.get(t)) == null ? void 0 : s.get(r);
- }
- getFormulaDependency(e, t, r, n) {
- var s, o;
- return (o = (s = this._formulaData.get(e)) == null ? void 0 : s.get(t)) == null ? void 0 : o.getValue(r, n);
- }
- addDependencyRTreeCache(e) {
- const t = [];
- for (let r = 0; r < e.rangeList.length; r++) {
- const n = e.rangeList[r], { unitId: s, sheetId: o, range: u } = n;
- t.push({
- unitId: s,
- sheetId: o,
- range: u,
- id: e.treeId
- });
- }
- this._dependencyRTreeCache.bulkInsert(t), this._addAllTreeMap(e);
- }
- getLastTreeId() {
- const e = this._dependencyTreeIdLast;
- return this._dependencyTreeIdLast++, e;
- }
- _addAllTreeMap(e) {
- throw new Error("Method not implemented.");
- }
- _addDefinedName(e, t, r) {
- this._definedNameMap.has(e) || this._definedNameMap.set(e, /* @__PURE__ */ new Map());
- const n = this._definedNameMap.get(e);
- n.has(t) || n.set(t, /* @__PURE__ */ new Set()), n.get(t).add(r);
- }
- addFormulaDependencyByDefinedName(e, t) {
- const r = e.treeId, n = (t == null ? void 0 : t.getDefinedNames()) || [];
- for (const s of n)
- this._addDefinedName(e.unitId, s, r);
- }
- }
- class Vh extends ph {
- constructor() {
- super(...arguments);
- A(this, "_allTreeMap", /* @__PURE__ */ new Map());
- }
- dispose() {
- this.reset();
- }
- buildDependencyTree(e, t = []) {
- const r = this.getAllTree();
- return e.length === 0 ? (this._buildReverseDependency(r, t), r) : (this._buildDependencyTree(r, e), this._buildReverseDependency(r, e), r);
- }
- /**
- * Build the dependency relationship between the trees.
- * @param allTrees all FormulaDependencyTree
- * @param shouldBeBuildTrees FormulaDependencyTree[] | FormulaDependencyTreeCache
- */
- _buildDependencyTree(e, t) {
- const r = /* @__PURE__ */ new Map();
- for (let n = 0; n < t.length; n++) {
- const s = t[n];
- r.set(s.treeId, s);
- }
- for (let n = 0; n < e.length; n++) {
- const s = e[n], o = s.toRTreeItem(), u = this._dependencyRTreeCache.bulkSearch(o);
- for (const c of u) {
- const l = r.get(c);
- l && s !== l && !l.hasChildren(s.treeId) && l.pushChildren(s);
- }
- }
- r.clear();
- }
- /**
- * Build the reverse dependency relationship between the trees.
- * @param allTrees
- * @param dependencyTrees
- */
- _buildReverseDependency(e, t) {
- const r = /* @__PURE__ */ new Map();
- for (let n = 0; n < e.length; n++) {
- const s = e[n];
- r.set(s.treeId, s);
- }
- for (let n = 0; n < t.length; n++) {
- const s = t[n], o = s.toRTreeItem(), u = this._dependencyRTreeCache.bulkSearch(o);
- for (const c of u) {
- const l = r.get(c);
- l && s !== l && !l.hasChildren(s.treeId) && l.pushChildren(s);
- }
- }
- r.clear();
- }
- /**
- * Get all FormulaDependencyTree from _otherFormulaData, _featureFormulaData, _formulaData
- * return FormulaDependencyTree[]
- */
- getAllTree() {
- const e = [];
- return this._allTreeMap.forEach((t) => {
- t.resetState(), e.push(t);
- }), e;
- }
- getTreeById(e) {
- return this._allTreeMap.get(e);
- }
- reset() {
- this._otherFormulaData.clear(), this._featureFormulaData.clear(), this._formulaData.clear(), this._dependencyRTreeCache.clear(), this._allTreeMap.clear(), this._restDependencyTreeId(), this._otherFormulaDataMainData.clear();
- }
- addOtherFormulaDependency(e, t, r, n) {
- this._otherFormulaData.has(e) || this._otherFormulaData.set(e, /* @__PURE__ */ new Map());
- const s = this._otherFormulaData.get(e);
- s.has(t) || s.set(t, /* @__PURE__ */ new Map());
- const o = s.get(t);
- o.has(r) || o.set(r, new Ce()), o.get(r).setValue(n.refOffsetX, n.refOffsetY, n.treeId), this._addAllTreeMap(n);
- }
- removeOtherFormulaDependency(e, t, r) {
- const n = this._otherFormulaData.get(e);
- if (n && n.has(t)) {
- const s = n.get(t);
- r.forEach((o) => {
- const u = s.get(o);
- u != null && (u.forValue((c, l, f) => {
- this._removeDependencyRTreeCache(f), this.clearDependencyForTree(this._allTreeMap.get(f)), this._removeAllTreeMap(f);
- }), s.delete(o), this._otherFormulaDataMainData.delete(o));
- }), s.size === 0 && n.delete(t), n.size === 0 && this._otherFormulaData.delete(e);
- }
- }
- clearOtherFormulaDependency(e, t) {
- const r = this._otherFormulaData.get(e);
- if (t && r && r.has(t)) {
- const n = r.get(t);
- this._removeDependencyRTreeCacheById(e, t);
- for (const s of n.keys()) {
- const o = n.get(s);
- o != null && (o.forValue((u, c, l) => {
- const f = this._allTreeMap.get(l);
- f && (this.clearDependencyForTree(f), this._removeAllTreeMap(l));
- }), this._otherFormulaDataMainData.delete(s));
- }
- n.clear();
- } else if (r) {
- for (const n of r.keys()) {
- const s = r.get(n);
- this._removeDependencyRTreeCacheById(e, n);
- for (const o of s.keys()) {
- const u = s.get(o);
- u != null && (u.forValue((c, l, f) => {
- const h = this._allTreeMap.get(f);
- h && (this.clearDependencyForTree(h), this._removeAllTreeMap(f));
- }), this._otherFormulaDataMainData.delete(o));
- }
- }
- this._otherFormulaData.delete(e);
- }
- }
- addFeatureFormulaDependency(e, t, r, n) {
- this._featureFormulaData.has(e) || this._featureFormulaData.set(e, /* @__PURE__ */ new Map());
- const s = this._featureFormulaData.get(e);
- s.has(t) || s.set(t, /* @__PURE__ */ new Map()), s.get(t).set(r, n.treeId), this._addAllTreeMap(n);
- }
- removeFeatureFormulaDependency(e, t, r) {
- const n = this._featureFormulaData.get(e);
- if (n && n.has(t)) {
- const s = n.get(t);
- r.forEach((o) => {
- const u = s.get(o);
- u != null && (this._removeDependencyRTreeCache(u), s.delete(o), this.clearDependencyForTree(this._allTreeMap.get(u)), this._removeAllTreeMap(u));
- });
- }
- }
- clearFeatureFormulaDependency(e, t) {
- const r = this._featureFormulaData.get(e);
- if (t && r && r.has(t)) {
- const n = r.get(t);
- this._removeDependencyRTreeCacheById(e, t), n.forEach((s) => {
- s != null && (this.clearDependencyForTree(this._allTreeMap.get(s)), this._removeAllTreeMap(s));
- }), n.clear();
- } else r && (r.forEach((n, s) => {
- this._removeDependencyRTreeCacheById(e, s), n.forEach((o) => {
- o != null && (this.clearDependencyForTree(this._allTreeMap.get(o)), this._removeAllTreeMap(o));
- });
- }), this._featureFormulaData.delete(e));
- }
- addFormulaDependency(e, t, r, n, s) {
- this._formulaData.has(e) || this._formulaData.set(e, /* @__PURE__ */ new Map());
- const o = this._formulaData.get(e);
- o.has(t) || o.set(t, new Ce()), o.get(t).setValue(r, n, s.treeId), this._addAllTreeMap(s);
- }
- removeFormulaDependency(e, t, r, n) {
- const s = this._formulaData.get(e);
- if (s && s.has(t)) {
- const o = s.get(t), u = o.getValue(r, n);
- if (u == null)
- return;
- this._removeDependencyRTreeCache(u), o.realDeleteValue(r, n), this.clearDependencyForTree(this._allTreeMap.get(u)), this._removeAllTreeMap(u);
- }
- }
- clearFormulaDependency(e, t) {
- const r = this._formulaData.get(e);
- if (t && r && r.has(t)) {
- const n = r.get(t);
- this._removeDependencyRTreeCacheById(e, t), n.forValue((s, o, u) => {
- if (u == null)
- return !0;
- this.clearDependencyForTree(this._allTreeMap.get(u)), this._removeAllTreeMap(u);
- }), n.reset();
- } else r && (r.forEach((n, s) => {
- this._removeDependencyRTreeCacheById(e, s), n.forValue((o, u, c) => {
- if (c == null)
- return !0;
- this.clearDependencyForTree(this._allTreeMap.get(c)), this._removeAllTreeMap(c);
- });
- }), this._formulaData.delete(e));
- }
- /**
- * Clear the dependency relationship of the tree.
- * establish the relationship between the parent and the child.
- * @param shouldBeClearTree
- */
- clearDependencyForTree(e) {
- if (e == null)
- return;
- const t = e.parents, r = e.children, n = this._allTreeMap;
- for (const s of t) {
- const o = n.get(s);
- o == null || o.children.delete(e.treeId);
- }
- for (const s of r) {
- const o = n.get(s);
- o == null || o.parents.delete(e.treeId);
- }
- e.dispose();
- }
- _removeDependencyRTreeCache(e) {
- if (e == null)
- return;
- const t = this._allTreeMap.get(e);
- if (t) {
- const r = [];
- for (let n = 0; n < t.rangeList.length; n++) {
- const s = t.rangeList[n], { unitId: o, sheetId: u, range: c } = s;
- r.push({
- unitId: o,
- sheetId: u,
- range: c,
- id: e
- });
- }
- this._dependencyRTreeCache.bulkRemove(r);
- }
- }
- removeFormulaDependencyByDefinedName(e, t) {
- const r = this._definedNameMap.get(e);
- if (r) {
- const n = r.get(t);
- if (n) {
- for (const s of n)
- this._removeDependencyRTreeCache(s), this.clearDependencyForTree(this._allTreeMap.get(s)), this._removeAllTreeMap(s);
- n.clear();
- }
- }
- }
- _removeAllTreeMap(e) {
- e != null && this._allTreeMap.delete(e);
- }
- _addAllTreeMap(e) {
- this._allTreeMap.set(e.treeId, e);
- }
- }
- const Hn = lt(
- "univer.formula.dependency-manager.service"
- );
- class Nh extends Me {
- constructor() {
- super(...arguments);
- A(this, "_referenceExecutorMap", /* @__PURE__ */ new Map());
- // unitId -> subUnitId -> featureId -> IFeatureCalculationManagerParam
- A(this, "_onChanged$", new ur());
- A(this, "onChanged$", this._onChanged$.asObservable());
- }
- dispose() {
- this._referenceExecutorMap.clear();
- }
- remove(e, t, r) {
- r.forEach((n) => {
- var s, o;
- (o = (s = this._referenceExecutorMap.get(e)) == null ? void 0 : s.get(t)) == null || o.delete(n);
- }), this._onChanged$.next({
- unitId: e,
- subUnitId: t,
- featureIds: r
- });
- }
- get(e, t, r) {
- var n, s;
- return (s = (n = this._referenceExecutorMap.get(e)) == null ? void 0 : n.get(t)) == null ? void 0 : s.get(r);
- }
- has(e, t, r) {
- var n, s;
- return !!((s = (n = this._referenceExecutorMap.get(e)) == null ? void 0 : n.get(t)) != null && s.has(r));
- }
- register(e, t, r, n) {
- let s = this._referenceExecutorMap.get(e);
- s || (s = /* @__PURE__ */ new Map(), this._referenceExecutorMap.set(e, s));
- let o = s.get(t);
- o || (o = /* @__PURE__ */ new Map(), s.set(t, o)), this._onChanged$.next({
- unitId: e,
- subUnitId: t,
- featureIds: [r]
- }), o.set(r, n);
- }
- getReferenceExecutorMap() {
- return this._referenceExecutorMap;
- }
- }
- const jr = lt(
- "univer.formula.feature-calculation-manager.service"
- );
- class Oh extends Me {
- constructor() {
- super(...arguments);
- A(this, "_otherFormulaData", {});
- }
- dispose() {
- this._otherFormulaData = {};
- }
- remove(e) {
- var s, o, u;
- const { unitId: t, subUnitId: r, formulaId: n } = e;
- (u = (o = (s = this._otherFormulaData) == null ? void 0 : s[t]) == null ? void 0 : o[r]) == null || delete u[n];
- }
- get(e) {
- var s, o;
- const { unitId: t, subUnitId: r, formulaId: n } = e;
- return (o = (s = this._otherFormulaData[t]) == null ? void 0 : s[r]) == null ? void 0 : o[n];
- }
- has(e) {
- var s, o;
- const { unitId: t, subUnitId: r, formulaId: n } = e;
- return ((o = (s = this._otherFormulaData[t]) == null ? void 0 : s[r]) == null ? void 0 : o[n]) != null;
- }
- register(e) {
- const { unitId: t, subUnitId: r, formulaId: n, item: s } = e;
- this._otherFormulaData[t] || (this._otherFormulaData[t] = {}), this._otherFormulaData[t][r] || (this._otherFormulaData[t][r] = {}), this._otherFormulaData[t][r][n] = s;
- }
- batchRegister(e) {
- Object.keys(e).forEach((t) => {
- const r = e[t];
- if (r == null)
- return !0;
- Object.keys(r).forEach((n) => {
- const s = r[n];
- if (s == null)
- return !0;
- Object.keys(s).forEach((o) => {
- const u = s[o];
- if (u == null)
- return !0;
- this.register({
- unitId: t,
- subUnitId: n,
- formulaId: o,
- item: u
- });
- });
- });
- });
- }
- batchRemove(e) {
- Object.keys(e).forEach((t) => {
- const r = e[t];
- if (r == null)
- return !0;
- Object.keys(r).forEach((n) => {
- const s = r[n];
- if (s == null)
- return !0;
- Object.keys(s).forEach((o) => {
- this.remove({
- unitId: t,
- subUnitId: n,
- formulaId: o
- });
- });
- });
- });
- }
- getOtherFormulaData() {
- return this._otherFormulaData;
- }
- }
- const ya = lt(
- "univer.formula.other-formula-manager.service"
- ), Mh = 5e3, ks = new Vt(Mh);
- function pi(i, a, e, t, r) {
- let n = ks.get(`${i}${a}`);
- if (n && !Oo(n, r))
- return n;
- const s = e.treeBuilder(a);
- if (yr.has(s))
- return xe.create(s);
- if (n = t.parse(s), n == null)
- throw new Error("astNode is null");
- return ks.set(`${i}${a}`, n), n;
- }
- function Oo(i, a) {
- const e = a.getDirtyDefinedNameMap(), t = a.getExecuteUnitId();
- if (t != null && e[t] != null) {
- const r = Object.keys(e[t]);
- for (let n = 0, s = r.length; n < s; n++) {
- const o = r[n];
- if (i.hasDefinedName(o))
- return !0;
- }
- }
- return !1;
- }
- function wh(i, a, e) {
- return !!(a != null && Oo(a, e));
- }
- var $s = /* @__PURE__ */ ((i) => (i[i.NORMAL_FORMULA = 0] = "NORMAL_FORMULA", i[i.OTHER_FORMULA = 1] = "OTHER_FORMULA", i[i.FEATURE_FORMULA = 2] = "FEATURE_FORMULA", i))($s || {});
- class Mo {
- constructor() {
- A(this, "_state", 0);
- A(this, "treeId");
- A(this, "children", /* @__PURE__ */ new Set());
- A(this, "parents", /* @__PURE__ */ new Set());
- }
- resetState() {
- this._state = 0;
- }
- setAdded() {
- this._state = 1;
- }
- isAdded() {
- return this._state === 1;
- }
- setSkip() {
- this._state = 2;
- }
- isSkip() {
- return this._state === 2;
- }
- pushChildren(a) {
- this.children.add(a.treeId), a._pushParent(this);
- }
- hasChildren(a) {
- return this.children.has(a);
- }
- _pushParent(a) {
- this.parents.add(a.treeId);
- }
- }
- class Vi extends Mo {
- constructor() {
- super(...arguments);
- A(this, "refTree");
- A(this, "refOffsetX", -1);
- A(this, "refOffsetY", -1);
- A(this, "isCache", !1);
- A(this, "isDirty", !1);
- A(this, "addressFunctionNodes", []);
- A(this, "getDirtyData");
- A(this, "featureId");
- }
- get isVirtual() {
- return !0;
- }
- get row() {
- return this.refTree == null ? -1 : this.refTree.row + this.refOffsetY;
- }
- get column() {
- return this.refTree == null ? -1 : this.refTree.column + this.refOffsetX;
- }
- get rowCount() {
- return this.refTree == null ? 0 : this.refTree.rowCount;
- }
- get columnCount() {
- return this.refTree == null ? 0 : this.refTree.columnCount;
- }
- get unitId() {
- return this.refTree == null ? "" : this.refTree.unitId;
- }
- get subUnitId() {
- return this.refTree == null ? "" : this.refTree.subUnitId;
- }
- get formula() {
- var e, t;
- return (t = (e = this.refTree) == null ? void 0 : e.formula) != null ? t : "";
- }
- get nodeData() {
- return {
- node: this.node,
- refOffsetX: this.refOffsetX,
- refOffsetY: this.refOffsetY
- };
- }
- get node() {
- var e;
- return (e = this.refTree) == null ? void 0 : e.node;
- }
- dispose() {
- this.refTree = null;
- }
- get rangeList() {
- const e = [];
- if (this.refTree == null)
- return [];
- for (let t = 0; t < this.refTree.rangeList.length; t++) {
- const r = this.refTree.rangeList[t];
- e.push({
- unitId: r.unitId,
- sheetId: r.sheetId,
- range: ea(r.range, this.refOffsetX, this.refOffsetY)
- });
- }
- return e;
- }
- toRTreeItem() {
- const e = this.row, t = this.column;
- return [{
- unitId: this.unitId,
- sheetId: this.subUnitId,
- range: {
- startRow: e,
- startColumn: t,
- endRow: e,
- endColumn: t
- }
- }];
- }
- inRangeData(e) {
- const t = e.startRow, r = e.startColumn, n = e.endRow, s = e.endColumn, o = this.row, u = this.column;
- return !(o < t || o > n || u < r || u > s);
- }
- dependencySheetName(e) {
- return this.refTree == null ? !1 : this.refTree.dependencySheetName(e);
- }
- isExcludeRange(e) {
- var r;
- const t = this.rangeList;
- if (t.length === 0)
- return !1;
- for (let n = 0, s = t.length; n < s; n++) {
- const o = t[n], { unitId: u, sheetId: c, range: l } = o, f = (r = e == null ? void 0 : e[u]) == null ? void 0 : r[c];
- let { startRow: h, endRow: d, startColumn: _, endColumn: C } = l;
- Number.isNaN(h) && (h = 0), Number.isNaN(_) && (_ = 0), Number.isNaN(d) && (d = Number.POSITIVE_INFINITY), Number.isNaN(C) && (C = Number.POSITIVE_INFINITY);
- let E = !1;
- if (f == null || f.forValue((b, R) => {
- if (b >= h && b <= d && R >= _ && R <= C)
- return E = !0, !1;
- }), E)
- return !0;
- }
- return !1;
- }
- get formulaId() {
- return this.refTree == null ? "" : this.refTree.formulaId;
- }
- }
- class hs extends Mo {
- constructor(e) {
- super();
- A(this, "isCache", !1);
- A(this, "featureId");
- A(this, "featureDirtyRanges", []);
- A(this, "refOffsetX", 0);
- A(this, "refOffsetY", 0);
- A(this, "type", 0);
- A(this, "formulaId");
- A(this, "subUnitId", "");
- A(this, "unitId", "");
- A(this, "rangeList", []);
- A(this, "formula", "");
- A(this, "row", -1);
- A(this, "column", -1);
- A(this, "rowCount", Number.NEGATIVE_INFINITY);
- A(this, "columnCount", Number.NEGATIVE_INFINITY);
- A(this, "isDirty", !1);
- A(this, "node");
- A(this, "addressFunctionNodes", []);
- A(this, "getDirtyData");
- this.treeId = e;
- }
- get isVirtual() {
- return !1;
- }
- get nodeData() {
- return {
- node: this.node,
- refOffsetX: 0,
- refOffsetY: 0
- };
- }
- toJson() {
- return {
- formula: this.formula,
- refOffsetX: this.refOffsetX,
- refOffsetY: this.refOffsetY
- };
- }
- dispose() {
- this.featureDirtyRanges = [], this.rangeList = [], this.addressFunctionNodes = [], this.getDirtyData = null;
- }
- inRangeData(e) {
- const t = e.startRow, r = e.startColumn, n = e.endRow, s = e.endColumn, o = this.row, u = this.column;
- return !(o < t || o > n || u < r || u > s);
- }
- dependencySheetName(e) {
- var r;
- const t = this.rangeList;
- if (t.length === 0 || e == null)
- return !1;
- for (let n = 0, s = t.length; n < s; n++) {
- const o = t[n], { unitId: u, sheetId: c } = o;
- if (((r = e[u]) == null ? void 0 : r[c]) != null)
- return !0;
- }
- return !1;
- }
- isExcludeRange(e) {
- var r;
- const t = this.rangeList;
- if (t.length === 0)
- return !1;
- for (let n = 0, s = t.length; n < s; n++) {
- const o = t[n], { unitId: u, sheetId: c, range: l } = o, f = (r = e == null ? void 0 : e[u]) == null ? void 0 : r[c];
- let { startRow: h, endRow: d, startColumn: _, endColumn: C } = l;
- Number.isNaN(h) && (h = 0), Number.isNaN(_) && (_ = 0), Number.isNaN(d) && (d = Number.POSITIVE_INFINITY), Number.isNaN(C) && (C = Number.POSITIVE_INFINITY);
- let E = !1;
- if (f == null || f.forValue((b, R) => {
- if (b >= h && b <= d && R >= _ && R <= C)
- return E = !0, !1;
- }), E)
- return !0;
- }
- return !1;
- }
- // pushChildren(tree: FormulaDependencyTree) {
- // this.children.add(tree.treeId);
- // tree._pushParent(this);
- // }
- /**
- * Add the range corresponding to the current ast node.
- * @param range
- */
- pushRangeList(e) {
- this.rangeList.push(...e);
- }
- shouldBePushRangeList() {
- return this.rangeList.length === 0 && this.type !== 2;
- }
- // hasChildren(treeId: number) {
- // return this.children.has(treeId);
- // }
- toRTreeItem() {
- if (this.featureId != null)
- return this.featureDirtyRanges;
- const e = this.row, t = this.column;
- return [{
- unitId: this.unitId,
- sheetId: this.subUnitId,
- range: {
- startRow: e,
- startColumn: t,
- endRow: e,
- endColumn: t
- }
- }];
- }
- /**
- * Determine whether it is dependent on other trees.
- * @param dependenceTree
- */
- // dependency(dependenceTree: FormulaDependencyTree) {
- // if (this.rangeList.length === 0) {
- // return false;
- // }
- // for (let r = 0, len = this.rangeList.length; r < len; r++) {
- // const unitRange = this.rangeList[r];
- // const unitId = unitRange.unitId;
- // const sheetId = unitRange.sheetId;
- // const range = unitRange.range;
- // if (
- // dependenceTree.unitId === unitId &&
- // dependenceTree.subUnitId === sheetId &&
- // dependenceTree.inRangeData(range)
- // ) {
- // return true;
- // }
- // }
- // return false;
- // }
- // private _pushParent(tree: FormulaDependencyTree) {
- // this.parents.add(tree.treeId);
- // }
- }
- var Dh = Object.defineProperty, Sh = Object.getOwnPropertyDescriptor, Ph = (i, a, e, t) => {
- for (var r = t > 1 ? void 0 : t ? Sh(a, e) : a, n = i.length - 1, s; n >= 0; n--)
- (s = i[n]) && (r = (t ? s(a, e, r) : s(r)) || r);
- return t && r && Dh(a, e, r), r;
- }, wt = (i, a) => (e, t) => a(e, t, i);
- function or(i) {
- return i.getLastTreeId() || 0;
- }
- const Ys = lt("engine-formula.dependency-generator");
- let Hs = class extends Me {
- constructor(a, e, t, r, n, s, o, u) {
- super();
- A(this, "_updateRangeFlattenCache", /* @__PURE__ */ new Map());
- A(this, "_dependencyRTreeCacheForAddressFunction", new As());
- A(this, "_executedAddressFunctionNodeIds", /* @__PURE__ */ new Set());
- this._currentConfigService = a, this._runtimeService = e, this._otherFormulaManagerService = t, this._featureCalculationManagerService = r, this._interpreter = n, this._astTreeBuilder = s, this._lexer = o, this._dependencyManagerService = u;
- }
- dispose() {
- this._updateRangeFlattenCache.clear(), this._dependencyRTreeCacheForAddressFunction.clear(), ks.clear();
- }
- async generate() {
- this._updateRangeFlatten();
- const a = this._currentConfigService.getFormulaData(), e = this._otherFormulaManagerService.getOtherFormulaData(), t = this._currentConfigService.getClearDependencyTreeCache();
- t != null && Object.keys(t).forEach((l) => {
- l != null && Object.keys(t[l]).forEach((f) => {
- f != null && (this._dependencyManagerService.clearOtherFormulaDependency(l, f), this._dependencyManagerService.clearFeatureFormulaDependency(l, f), this._dependencyManagerService.clearFormulaDependency(l, f));
- });
- });
- const r = this._currentConfigService.getUnitData(), n = await this._generateTreeList(a, e, r), s = this._getUpdateTreeListAndMakeDependency(n);
- let o = this._calculateRunList(s);
- return this._dependencyFeatureCalculation(o) && (o.forEach((l) => {
- l.resetState();
- }), o = this._calculateRunList(o)), this._checkIsCycleDependency(o) && this._runtimeService.enableCycleDependency(), this._dependencyRTreeCacheForAddressFunction.clear(), Promise.resolve(o);
- }
- _dependencyFeatureCalculation(a) {
- const e = this._featureCalculationManagerService.getReferenceExecutorMap();
- if (e.size === 0)
- return;
- this._clearFeatureCalculationNode(a);
- let t = !1;
- return e.forEach((r, n) => {
- r.forEach((s, o) => {
- s.forEach((u, c) => {
- const { unitId: l, subUnitId: f, getDirtyData: h } = u, d = h(this._currentConfigService.getDirtyData(), this._runtimeService.getAllRuntimeData()), _ = this._convertDirtyRangesToUnitRange(d.dirtyRanges), C = this._intersectFeatureCalculation(_, a, { unitId: l, subUnitId: f, featureId: c });
- if (C.length > 0) {
- let E = this._getExistTreeList({ unitId: l, subUnitId: f, featureId: c }, a);
- E == null && (E = this._getFeatureFormulaTree(c, or(this._dependencyManagerService), u), a.push(E)), E.parents = /* @__PURE__ */ new Set(), C.forEach((b) => {
- b.hasChildren(E.treeId) || b.pushChildren(E);
- }), t = !0;
- }
- });
- });
- }), t;
- }
- _clearFeatureCalculationNode(a) {
- const e = this._featureCalculationManagerService.getReferenceExecutorMap();
- a.forEach((t) => {
- var s, o, u, c;
- const r = /* @__PURE__ */ new Set();
- for (const l of t.children) {
- const f = this._dependencyManagerService.getTreeById(l);
- f && (f.featureId && (o = (s = e.get(t.unitId)) == null ? void 0 : s.get(t.subUnitId)) != null && o.has(f.featureId) || r.add(l));
- }
- t.children = r;
- const n = /* @__PURE__ */ new Set();
- for (const l of t.parents) {
- const f = this._dependencyManagerService.getTreeById(l);
- f && (f.featureId && (c = (u = e.get(t.unitId)) == null ? void 0 : u.get(t.subUnitId)) != null && c.has(f.featureId) || n.add(l));
- }
- t.parents = n;
- });
- }
- /**
- * TODO @DR-Univer: The next step will be to try changing the incoming dirtyRanges to an array, thus avoiding conversion.
- * @param dirtyRanges
- * @returns
- */
- _convertDirtyRangesToUnitRange(a) {
- const e = [];
- for (const t in a) {
- const r = a[t];
- for (const n in r) {
- const s = r[n];
- for (const o of s)
- e.push({
- unitId: t,
- sheetId: n,
- range: o
- });
- }
- }
- return e;
- }
- _intersectFeatureCalculation(a, e, t) {
- const r = [], n = this._dependencyManagerService.searchDependency(a);
- for (let s = 0, o = e.length; s < o; s++) {
- const u = e[s];
- if (u.unitId === t.unitId && u.subUnitId === t.subUnitId && u.featureId === t.featureId)
- continue;
- n.has(u.treeId) && r.push(u);
- }
- return r;
- }
- _getExistTreeList(a, e) {
- const { unitId: t, subUnitId: r, featureId: n } = a;
- for (let s = 0, o = e.length; s < o; s++) {
- const u = e[s];
- if (u.unitId === t && u.subUnitId === r && u.featureId === n)
- return u;
- }
- }
- _isCyclicUtil(a, e, t) {
- const r = this._dependencyManagerService.getTreeById(a);
- if (r == null)
- return !1;
- if (!e.has(r.treeId)) {
- e.add(r.treeId), t.add(r.treeId);
- for (const n of r.children)
- if (!e.has(n) && this._isCyclicUtil(n, e, t) || t.has(n))
- return !0;
- }
- return t.delete(r.treeId), !1;
- }
- _checkIsCycleDependency(a) {
- const e = /* @__PURE__ */ new Set(), t = /* @__PURE__ */ new Set();
- for (let r = 0, n = a.length; r < n; r++) {
- const s = a[r];
- if (this._isCyclicUtil(s.treeId, e, t) === !0)
- return !0;
- }
- return !1;
- }
- /**
- * Generate nodes for the dependency tree, where each node contains all the reference data ranges included in each formula.
- * @param formulaData
- */
- async _generateTreeList(a, e, t) {
- const r = Object.keys(a), n = Object.keys(e), s = [];
- this._currentConfigService.isForceCalculate() && this._dependencyManagerService.reset(), this._registerFormulas(r, a, t, s), this._registerOtherFormulas(e, n, s), this._registerFeatureFormulas(s);
- for (let u = 0, c = s.length; u < c; u++) {
- const l = s[u], f = this._getTreeNode(l);
- l.isDirty = this._includeTree(l, f);
- const h = this._getAddressFunctionNodeList(f);
- if (h.length > 0 && (l.addressFunctionNodes = h), l.isVirtual)
- continue;
- this._runtimeService.setCurrent(
- l.row,
- l.column,
- l.rowCount,
- l.columnCount,
- l.subUnitId,
- l.unitId
- );
- const d = await this._getRangeListByNode({
- node: f,
- refOffsetX: l.refOffsetX,
- refOffsetY: l.refOffsetY
- });
- l.pushRangeList(d);
- }
- for (let u = 0, c = s.length; u < c; u++) {
- const l = s[u];
- l.isCache || this._dependencyManagerService.addDependencyRTreeCache(l);
- }
- return await this._calculateListByFunctionRefNode(s), s;
- }
- // private _moveRangeList(tree: FormulaDependencyTree, refOffsetX: number, refOffsetY: number) {
- // const rangeList = tree.rangeList;
- // const newRangeList = [];
- // for (let i = 0, len = rangeList.length; i < len; i++) {
- // const unitRange = rangeList[i];
- // const newRange = {
- // unitId: tree.unitId,
- // sheetId: tree.subUnitId,
- // range: moveRangeByOffset(unitRange.range, refOffsetX, refOffsetY),
- // };
- // newRangeList.push(newRange);
- // }
- // return newRangeList;
- // }
- _registerFeatureFormulas(a) {
- this._featureCalculationManagerService.getReferenceExecutorMap().forEach((t, r) => {
- t.forEach((n, s) => {
- n.forEach((o, u) => {
- const c = this._dependencyManagerService.getFeatureFormulaDependency(o.unitId, o.subUnitId, u);
- a.push(this._getFeatureFormulaTree(u, c, o));
- });
- });
- });
- }
- _getFeatureFormulaTree(a, e, t) {
- const { unitId: r, subUnitId: n, dependencyRanges: s, getDirtyData: o } = t, u = e || or(this._dependencyManagerService), c = new hs(u);
- c.unitId = r, c.subUnitId = n, c.rangeList = s, c.getDirtyData = o;
- const l = o(this._currentConfigService.getDirtyData(), this._runtimeService.getAllRuntimeData()), f = this._convertDirtyRangesToUnitRange(l.dirtyRanges);
- return c.featureDirtyRanges = f, c.featureId = a, c.type = $s.FEATURE_FORMULA, this._dependencyManagerService.addFeatureFormulaDependency(r, n, a, c), this._dependencyManagerService.getFeatureFormulaDependency(t.unitId, t.subUnitId, a) && (c.isCache = !0), c;
- }
- _registerOtherFormulas(a, e, t) {
- for (const r of e) {
- const n = a[r];
- if (n == null)
- continue;
- const s = Object.keys(n);
- for (const o of s) {
- const u = n[o];
- if (u == null)
- continue;
- const c = Object.keys(u);
- for (const l of c) {
- const f = this._dependencyManagerService.hasOtherFormulaDataMainData(l), h = u[l], { f: d, ranges: _ } = h;
- let C = !1;
- f && (C = !0);
- const E = pi(r, d, this._lexer, this._astTreeBuilder, this._currentConfigService), { firstRow: b, firstColumn: R } = this._getFirstCellOfRange(_), p = this._dependencyManagerService.getOtherFormulaDependency(r, o, l), N = (p == null ? void 0 : p.getValue(0, 0)) || or(this._dependencyManagerService), M = new hs(N);
- for (let w = 0; w < _.length; w++) {
- const D = _[w], { startRow: S, startColumn: P, endRow: U, endColumn: x } = D;
- for (let F = S; F <= U; F++)
- for (let W = P; W <= x; W++) {
- const ne = W - R, z = F - b;
- if (ne === 0 && z === 0) {
- M.node = E, M.formula = d, M.unitId = r, M.subUnitId = o, M.formulaId = l, M.type = $s.OTHER_FORMULA, M.isCache = C, t.push(M), this._dependencyManagerService.addOtherFormulaDependency(r, o, l, M), this._dependencyManagerService.addFormulaDependencyByDefinedName(M);
- continue;
- }
- const G = new Vi();
- G.treeId = (p == null ? void 0 : p.getValue(ne, z)) || or(this._dependencyManagerService), G.refTree = M, G.refOffsetX = ne, G.refOffsetY = z, G.isCache = C, this._dependencyManagerService.addOtherFormulaDependency(r, o, l, G), this._dependencyManagerService.addFormulaDependencyByDefinedName(G), t.push(G);
- }
- }
- this._dependencyManagerService.addOtherFormulaDependencyMainData(l);
- }
- }
- }
- }
- _getFirstCellOfRange(a) {
- const e = a[0];
- return {
- firstRow: e.startRow,
- firstColumn: e.startColumn
- };
- }
- _registerFormulas(a, e, t, r) {
- for (const n of a) {
- const s = e[n];
- if (s == null)
- continue;
- const o = Object.keys(s);
- for (const u of o) {
- const c = new Ce(s[u] || {}), l = /* @__PURE__ */ new Map();
- c.forValue((f, h, d) => {
- if (d == null)
- return !0;
- const { x: _ = 0, y: C = 0, si: E } = d;
- if (!(_ === 0 && C === 0 && E != null))
- return !0;
- const b = this._createFDtree(n, u, f, h, t, d), R = this._dependencyManagerService.getFormulaDependency(n, u, f, h);
- R != null ? b.treeId = R : (this._dependencyManagerService.addFormulaDependency(n, u, f, h, b), this._dependencyManagerService.addFormulaDependencyByDefinedName(b)), l.set(E, b), r.push(b);
- }), c.forValue((f, h, d) => {
- if (d == null)
- return !0;
- const { x: _ = 0, y: C = 0, si: E } = d;
- if (_ === 0 && C === 0 && E != null)
- return !0;
- let b;
- if (E && l.has(E)) {
- const p = l.get(E);
- b = this._createVirtualFDtree(p, d);
- } else
- b = this._createFDtree(n, u, f, h, t, d);
- const R = this._dependencyManagerService.getFormulaDependency(n, u, f, h);
- R != null ? b.treeId = R : (this._dependencyManagerService.addFormulaDependency(n, u, f, h, b), this._dependencyManagerService.addFormulaDependencyByDefinedName(b)), r.push(b);
- }), l.clear();
- }
- }
- }
- _createFDtree(a, e, t, r, n, s) {
- const { f: o, x: u = 0, y: c = 0 } = s, l = new hs(or(this._dependencyManagerService)), f = n[a][e], h = pi(a, o, this._lexer, this._astTreeBuilder, this._currentConfigService);
- return l.node = h, l.formula = o, l.unitId = a, l.subUnitId = e, l.row = t, l.column = r, l.rowCount = f.rowCount, l.columnCount = f.columnCount, l;
- }
- _createVirtualFDtree(a, e) {
- const { x: t = 0, y: r = 0 } = e, n = new Vi();
- return n.treeId = or(this._dependencyManagerService), n.refTree = a, n.refOffsetX = t, n.refOffsetY = r, n;
- }
- /**
- * Break down the dirty areas into ranges for subsequent matching.
- */
- _updateRangeFlatten() {
- const a = this._currentConfigService.isForceCalculate(), e = this._currentConfigService.getDirtyRanges();
- if (!a) {
- this._updateRangeFlattenCache.clear();
- for (let t = 0; t < e.length; t++) {
- const r = e[t], n = r.range, s = r.sheetId, o = r.unitId;
- this._addFlattenCache(o, s, n);
- }
- }
- }
- _addFlattenCache(a, e, t) {
- let r = this._updateRangeFlattenCache.get(a);
- r == null && (r = /* @__PURE__ */ new Map(), this._updateRangeFlattenCache.set(a, r));
- let n = r.get(e);
- n == null && (n = [], r.set(e, n)), n.push(t);
- }
- _isPreCalculateNode(a) {
- return a.nodeType === oe.UNION || a.nodeType === oe.PREFIX && a.getToken() === Oe.AT || a.nodeType === oe.SUFFIX && a.getToken() === ze.POUND;
- }
- _nodeTraversalRef(a, e) {
- const t = a.getChildren(), r = t.length;
- for (let n = 0; n < r; n++) {
- const s = t[n];
- if (this._isPreCalculateNode(s)) {
- if (e.push(s), s.nodeType === oe.UNION)
- for (const o of s.getChildren())
- o.nodeType === oe.FUNCTION && o.isAddress() && this._nodeTraversalRef(o, e);
- continue;
- } else s.nodeType === oe.REFERENCE && e.push(s);
- this._nodeTraversalRef(s, e);
- }
- }
- _nodeTraversalReferenceFunction(a, e) {
- const t = a.getChildren(), r = t.length;
- for (let n = 0; n < r; n++) {
- const s = t[n];
- if (s.nodeType === oe.FUNCTION && s.isAddress()) {
- e.push(s);
- continue;
- }
- this._nodeTraversalReferenceFunction(s, e);
- }
- }
- async _executeNode(a, e = 0, t = 0) {
- let r;
- const n = {
- node: a,
- refOffsetX: e,
- refOffsetY: t
- };
- return this._interpreter.checkAsyncNode(a) ? r = await this._interpreter.executeAsync(n) : r = this._interpreter.execute(n), r;
- }
- /**
- * Calculate the range required for collection in advance,
- * including references and location functions (such as OFFSET, INDIRECT, INDEX, etc.).
- * @param node
- */
- async _getRangeListByNode(a) {
- const e = [], t = a.refOffsetX, r = a.refOffsetY, n = a.node;
- if (n == null)
- return [];
- this._nodeTraversalRef(n, e);
- const s = [];
- for (let o = 0, u = e.length; o < u; o++) {
- const c = e[o], f = (await this._executeNode(c, t, r)).toUnitRange();
- s.push(f), c.setValue(null);
- }
- return s;
- }
- _getAddressFunctionNodeList(a) {
- const e = [];
- return a == null ? [] : (this._nodeTraversalReferenceFunction(a, e), e);
- }
- _getTreeNode(a) {
- return a.node;
- }
- async _buildDirtyRangesByAddressFunction(a, e) {
- const t = e.addressFunctionNodes;
- if (t.length === 0)
- return;
- const r = e.refOffsetX, n = e.refOffsetY, s = await this._getRangeListByFunctionRefNode(t, r, n);
- e.addressFunctionNodes = [], this._addDependencyTreeByAddressFunction(e, s);
- const o = a.bulkSearch(s), u = this._buildTreeNodeById(o);
- u.length !== 0 && await this._calculateAddressFunctionRuntimeData(a, u);
- }
- async _calculateListByFunctionRefNode(a) {
- const e = new As();
- for (let t = 0, r = a.length; t < r; t++) {
- const n = a[t];
- e.insert({
- unitId: n.unitId,
- sheetId: n.subUnitId,
- range: {
- startRow: n.row,
- startColumn: n.column,
- endRow: n.row,
- endColumn: n.column
- },
- id: n.treeId
- });
- }
- this._executedAddressFunctionNodeIds.clear();
- for (let t = 0, r = a.length; t < r; t++) {
- const n = a[t];
- await this._calculateAddressFunction(e, n);
- }
- }
- async _calculateAddressFunction(a, e) {
- const t = e.addressFunctionNodes;
- if (t.length === 0)
- return;
- const r = e.refOffsetX, n = e.refOffsetY;
- this._runtimeService.setCurrent(
- e.row,
- e.column,
- e.rowCount,
- e.columnCount,
- e.subUnitId,
- e.unitId
- );
- const s = [];
- for (let c = 0, l = t.length; c < l; c++) {
- const f = await this._getRangeListByNode({
- node: t[c],
- refOffsetX: r,
- refOffsetY: n
- });
- s.push(...f);
- }
- const o = /* @__PURE__ */ new Set();
- this._searchDependencyByAddressFunction(a, s, o);
- const u = this._buildTreeNodeById(o);
- if (u.length === 0) {
- await this._buildDirtyRangesByAddressFunction(a, e);
- return;
- }
- await this._calculateAddressFunctionRuntimeData(a, u), await this._buildDirtyRangesByAddressFunction(a, e);
- }
- async _calculateAddressFunctionRuntimeData(a, e) {
- for (; e.length > 0; ) {
- const t = e.pop(), n = {
- node: this._getTreeNode(t),
- refOffsetX: t.refOffsetX,
- refOffsetY: t.refOffsetY
- };
- await this._calculateAddressFunction(a, t), this._runtimeService.setCurrent(
- t.row,
- t.column,
- t.rowCount,
- t.columnCount,
- t.subUnitId,
- t.unitId
- );
- let s;
- 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);
- }
- }
- _buildTreeNodeById(a) {
- const e = [];
- for (const t of a) {
- const r = this._getTreeById(t);
- !r || this._executedAddressFunctionNodeIds.has(t) || (this._executedAddressFunctionNodeIds.add(t), e.push(r));
- }
- return e;
- }
- _searchDependencyByAddressFunction(a, e, t) {
- const r = a.bulkSearch(e), n = this._dependencyRTreeCacheForAddressFunction.bulkSearch(e);
- for (const o of n)
- t.has(o) || t.add(o);
- const s = [];
- for (const o of r) {
- const u = this._getTreeById(o);
- u && !t.has(o) && (s.push(...u.rangeList), t.add(o));
- }
- return s.length > 0 && this._searchDependencyByAddressFunction(a, s, t), t;
- }
- _getTreeById(a) {
- return this._dependencyManagerService.getTreeById(a);
- }
- _addDependencyTreeByAddressFunction(a, e) {
- const t = [];
- for (let r = 0; r < e.length; r++) {
- const n = e[r], { unitId: s, sheetId: o, range: u } = n;
- t.push({
- unitId: s,
- sheetId: o,
- range: u,
- id: a.treeId
- });
- }
- this._dependencyRTreeCacheForAddressFunction.bulkInsert(t);
- }
- /**
- * Calculate the range required for collection in advance,
- * including references and location functions (such as OFFSET, INDIRECT, INDEX, etc.).
- * @param node
- */
- async _getRangeListByFunctionRefNode(a, e, t) {
- const r = [];
- for (let n = 0, s = a.length; n < s; n++) {
- const o = a[n], c = (await this._executeNode(o, e, t)).toUnitRange();
- r.push(c), o.setValue(null);
- }
- return r;
- }
- /**
- * Build a formula dependency tree based on the dependency relationships.
- * @param treeList
- */
- _getUpdateTreeListAndMakeDependency(a) {
- const e = [], t = /* @__PURE__ */ new Set(), r = this._currentConfigService.isForceCalculate(), n = this._currentConfigService.getDirtyRanges(), s = this._dependencyManagerService.searchDependency(n), o = this._dependencyRTreeCacheForAddressFunction.bulkSearch(n);
- for (const c of o)
- s.add(c);
- const u = this._dependencyManagerService.buildDependencyTree(a);
- for (const c of u) {
- const l = c.treeId;
- (r || c.isDirty || c.dependencySheetName(this._currentConfigService.getDirtyNameMap()) || //O(n) n=tree.rangeList.length
- s.has(l) && !c.isExcludeRange(this._currentConfigService.getExcludedRange())) && !t.has(l) && (e.push(c), t.add(l));
- }
- return e;
- }
- _includeTreeFeature(a) {
- var n, s;
- const e = a.unitId, t = a.subUnitId, r = a.featureId;
- if (r != null) {
- const o = this._currentConfigService.getDirtyUnitFeatureMap();
- if (((s = (n = o == null ? void 0 : o[e]) == null ? void 0 : n[t]) == null ? void 0 : s[r]) != null)
- return !0;
- }
- return !1;
- }
- _includeOtherFormula(a) {
- var n, s;
- const e = a.unitId, t = a.subUnitId, r = a.formulaId;
- if (r != null) {
- const o = this._currentConfigService.getDirtyUnitOtherFormulaMap();
- if (((s = (n = o == null ? void 0 : o[e]) == null ? void 0 : n[t]) == null ? void 0 : s[r]) != null)
- return !0;
- }
- return !1;
- }
- _detectForcedRecalculationNode(a, e) {
- return e == null ? !1 : this._detectForcedRecalculationNodeRecursion(e);
- }
- _detectForcedRecalculationNodeRecursion(a) {
- if (a.isForcedCalculateFunction())
- return !0;
- const e = a.getChildren();
- for (let t = 0, r = e.length; t < r; t++) {
- const n = e[t];
- if (this._detectForcedRecalculationNodeRecursion(n))
- return !0;
- }
- return !1;
- }
- /**
- * Determine whether all ranges of the current node exist within the dirty area.
- * If they are within the dirty area, return true, indicating that this node needs to be calculated.
- * @param tree
- */
- _includeTree(a, e) {
- var c, l, f;
- const t = a.unitId, r = a.subUnitId;
- if (this._detectForcedRecalculationNode(a, e) === !0 || this._includeTreeFeature(a) === !0 || this._includeOtherFormula(a) === !0 || wh(a, e, this._currentConfigService) === !0)
- return !0;
- const n = (l = (c = this._currentConfigService.getExcludedRange()) == null ? void 0 : c[t]) == null ? void 0 : l[r];
- if ((n == null ? void 0 : n.getValue(a.row, a.column)) != null)
- return !1;
- if (((f = this._currentConfigService.getDirtyNameMap()[t]) == null ? void 0 : f[r]) != null)
- return !0;
- if (!this._updateRangeFlattenCache.has(t))
- return !1;
- const o = this._updateRangeFlattenCache.get(t);
- if (!o.has(r))
- return !1;
- const u = o.get(r);
- for (const h of u)
- if (a.inRangeData(h))
- return !0;
- return !1;
- }
- /**
- * Generate the final formula calculation order array by traversing the dependency tree established via depth-first search.
- * @param treeList
- */
- _calculateRunList(a) {
- const e = a, t = [], r = [];
- for (; e.length > 0; ) {
- const n = e.pop();
- if (n === void 0 || n.isSkip())
- continue;
- if (n.isAdded()) {
- t.push(n), n.setSkip();
- continue;
- }
- r.length = 0;
- for (const o of n.parents) {
- const u = this._dependencyManagerService.getTreeById(o);
- if (!u)
- throw new Error("ParentDependencyTree object is null");
- u.isAdded() || n.isSkip() || r.push(u);
- }
- const s = this._dependencyRTreeCacheForAddressFunction.bulkSearch(n.toRTreeItem());
- for (const o of s) {
- const u = this._dependencyManagerService.getTreeById(o);
- if (!u)
- throw new Error("ParentDependencyTree object is null");
- u.isAdded() || n.isSkip() || r.push(u);
- }
- r.length === 0 ? (t.push(n), n.setSkip()) : (n.setAdded(), e.push(n, ...r));
- }
- return t;
- }
- };
- Hs = Ph([
- wt(0, Ft),
- wt(1, Nt),
- wt(2, ya),
- wt(3, jr),
- wt(4, Ve(Cr)),
- wt(5, Ve(xr)),
- wt(6, Ve(gr)),
- wt(7, Hn)
- ], Hs);
- var Lh = Object.defineProperty, xh = Object.getOwnPropertyDescriptor, jh = (i, a, e, t) => {
- for (var r = t > 1 ? void 0 : t ? xh(a, e) : a, n = i.length - 1, s; n >= 0; n--)
- (s = i[n]) && (r = (t ? s(a, e, r) : s(r)) || r);
- return t && r && Lh(a, e, r), r;
- }, Qt = (i, a) => (e, t) => a(e, t, i);
- const Uh = 500, Gs = lt("engine-formula.calculate-formula.service");
- let Qs = class extends Me {
- constructor(a, e, t, r, n, s, o) {
- super();
- A(this, "_executionInProgressListener$", new ur());
- A(this, "executionInProgressListener$", this._executionInProgressListener$.asObservable());
- A(this, "_executionCompleteListener$", new ur());
- A(this, "executionCompleteListener$", this._executionCompleteListener$.asObservable());
- this._configService = a, this._lexer = e, this._currentConfigService = t, this._runtimeService = r, this._formulaDependencyGenerator = n, this._interpreter = s, this._astTreeBuilder = o;
- }
- /**
- * Stop the execution of the formula.
- */
- stopFormulaExecution() {
- this._runtimeService.stopExecution();
- }
- /**
- * When the feature is loading,
- * the pre-calculated content needs to be input to the formula engine in advance,
- * so that the formula can read the correct values.
- * @param featureId
- * @param featureData
- */
- setRuntimeFeatureCellData(a, e) {
- this._runtimeService.setRuntimeFeatureCellData(a, e);
- }
- setRuntimeFeatureRange(a, e) {
- this._runtimeService.setRuntimeFeatureRange(a, e);
- }
- async execute(a) {
- this._runtimeService.setFormulaExecuteStage(ft.START), this._executionInProgressListener$.next(this._runtimeService.getRuntimeState()), this._currentConfigService.load(a), this._runtimeService.reset();
- const e = a.maxIteration || so;
- for (let t = 0; t < e && (this._runtimeService.setFormulaCycleIndex(t), await this._execute(), Bs.clear(), !!this._runtimeService.isCycleDependency()); t++)
- ;
- this._runtimeService.setFormulaExecuteStage(ft.CALCULATION_COMPLETED), this._executionInProgressListener$.next(this._runtimeService.getRuntimeState()), this._executionCompleteListener$.next(this._runtimeService.getAllRuntimeData()), St.clear(), this._runtimeService.reset();
- }
- async _execute() {
- const a = await this._apply();
- if (a == null)
- return;
- const { arrayFormulaRange: e, runtimeFeatureRange: t } = a, { dirtyRanges: r, excludedCell: n } = this._getArrayFormulaDirtyRangeAndExcludedRange(
- e,
- t
- );
- return r == null || r.length === 0 || (this._currentConfigService.loadDirtyRangesAndExcludedCell(r, n), await this._apply(!0)), !0;
- }
- _getArrayFormulaDirtyRangeAndExcludedRange(a, e) {
- const t = [], r = {};
- return Object.keys(a).forEach((n) => {
- const s = a[n];
- if (s == null)
- return !0;
- Object.keys(s).forEach((o) => {
- const u = new Ce(s[o]);
- if (u == null)
- return !0;
- const c = new Ce();
- u.forValue((l, f, h) => {
- c.setValue(l, f, !0), t.push({ unitId: n, sheetId: o, range: h });
- }), r[n] == null && (r[n] = {}), r[n][o] = c;
- });
- }), Object.keys(e).forEach((n) => {
- const s = e[n];
- Object.keys(s).forEach((o) => {
- const u = s[o];
- if (u == null)
- return !0;
- Object.keys(u).forEach((c) => {
- const l = u[c];
- if (l == null)
- return !0;
- for (const f of l)
- t.push({ unitId: o, sheetId: c, range: f });
- });
- });
- }), { dirtyRanges: t, excludedCell: r };
- }
- // eslint-disable-next-line max-lines-per-function
- async _apply(a = !1) {
- a ? this._runtimeService.setFormulaExecuteStage(ft.START_DEPENDENCY_ARRAY_FORMULA) : this._runtimeService.setFormulaExecuteStage(ft.START_DEPENDENCY), this._executionInProgressListener$.next(this._runtimeService.getRuntimeState());
- const e = (await this._formulaDependencyGenerator.generate()).reverse(), t = this._interpreter;
- a ? (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());
- let r = [];
- const n = this._configService.getConfig(fa), s = (n == null ? void 0 : n.intervalCount) || Uh, o = e.length;
- for (let u = 0; u < o; u++) {
- const c = e[u], l = c.nodeData, f = c.getDirtyData;
- if (u % s === 0 && (await new Promise((d) => {
- const _ = Qu(d);
- r.push(_);
- }), a ? (this._runtimeService.setFormulaExecuteStage(
- ft.CURRENTLY_CALCULATING_ARRAY_FORMULA
- ), 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() || l == null && f == null)) {
- this._runtimeService.setFormulaExecuteStage(ft.IDLE), this._runtimeService.markedAsStopFunctionsExecuted(), this._executionCompleteListener$.next(this._runtimeService.getAllRuntimeData());
- return;
- }
- this._runtimeService.setCurrent(
- c.row,
- c.column,
- c.rowCount,
- c.columnCount,
- c.subUnitId,
- c.unitId
- );
- let h;
- if (f != null && c.featureId != null) {
- const { runtimeCellData: d, dirtyRanges: _ } = f(this._currentConfigService.getDirtyData(), this._runtimeService.getAllRuntimeData());
- this._runtimeService.setRuntimeFeatureCellData(c.featureId, d), this._runtimeService.setRuntimeFeatureRange(c.featureId, _);
- } else l != null && (t.checkAsyncNode(l.node) ? h = await t.executeAsync(l) : h = t.execute(l), c.formulaId != null ? this._runtimeService.setRuntimeOtherData(c.formulaId, c.refOffsetX, c.refOffsetY, h) : this._runtimeService.setRuntimeData(h));
- }
- return r.forEach((u) => u()), r = [], o > 0 ? this._runtimeService.markedAsSuccessfullyExecuted() : a || this._runtimeService.markedAsNoFunctionsExecuted(), this._runtimeService.getAllRuntimeData();
- }
- calculate(a, e = !0) {
- const t = this._lexer.treeBuilder(a, e);
- if (Object.values(m).includes(t))
- return xe.create(t);
- const r = this._astTreeBuilder.parse(t);
- r == null || r.serialize();
- }
- };
- Qs = jh([
- Qt(0, ta),
- Qt(1, Ve(gr)),
- Qt(2, Ft),
- Qt(3, Nt),
- Qt(4, Ys),
- Qt(5, Ve(Cr)),
- Qt(6, Ve(xr))
- ], Qs);
- var vh = Object.defineProperty, Th = Object.getOwnPropertyDescriptor, Bh = (i, a, e, t) => {
- for (var r = t > 1 ? void 0 : t ? Th(a, e) : a, n = i.length - 1, s; n >= 0; n--)
- (s = i[n]) && (r = (t ? s(a, e, r) : s(r)) || r);
- return t && r && vh(a, e, r), r;
- }, ms = (i, a) => (e, t) => a(e, t, i);
- let Nn = class extends Me {
- constructor(i, a, e) {
- super(), this._commandService = i, this._calculateFormulaService = a, this._formulaDataModel = e, this._initialize();
- }
- _initialize() {
- this._commandExecutedListener(), this._initialExecuteFormulaListener();
- }
- _commandExecutedListener() {
- this.disposeWithMe(
- this._commandService.onCommandExecuted((i) => {
- if (i.id === zi.id)
- this._calculateFormulaService.stopFormulaExecution();
- else if (i.id === Zi.id) {
- const a = i.params;
- this._calculate(a);
- } else if (i.id === bs.id) {
- const a = i.params;
- if (a == null)
- return;
- const { arrayFormulaRange: e, arrayFormulaCellData: t } = a;
- this._formulaDataModel.setArrayFormulaRange(e), this._formulaDataModel.setArrayFormulaCellData(t);
- }
- })
- );
- }
- async _calculate(i) {
- const { forceCalculation: a = !1, dirtyRanges: e = [], dirtyNameMap: t = {}, dirtyDefinedNameMap: r = {}, dirtyUnitFeatureMap: n = {}, dirtyUnitOtherFormulaMap: s = {}, clearDependencyTreeCache: o = {}, maxIteration: u = so } = i, c = this._formulaDataModel.getFormulaData(), l = this._formulaDataModel.getArrayFormulaCellData(), f = this._formulaDataModel.getArrayFormulaRange();
- this._calculateFormulaService.execute({
- formulaData: c,
- arrayFormulaCellData: l,
- arrayFormulaRange: f,
- forceCalculate: a,
- dirtyRanges: e,
- dirtyNameMap: t,
- dirtyDefinedNameMap: r,
- dirtyUnitFeatureMap: n,
- dirtyUnitOtherFormulaMap: s,
- clearDependencyTreeCache: o,
- maxIteration: u
- });
- }
- // Notification
- _initialExecuteFormulaListener() {
- this._calculateFormulaService.executionCompleteListener$.subscribe((i) => {
- const a = i.functionsExecutedState;
- switch (a) {
- case wr.NOT_EXECUTED:
- break;
- case wr.STOP_EXECUTION:
- break;
- case wr.SUCCESS:
- this._applyResult(i);
- break;
- case wr.INITIAL:
- break;
- }
- this._commandService.executeCommand(
- Ns.id,
- {
- functionsExecutedState: a
- },
- {
- onlyLocal: !0
- }
- );
- }), this._calculateFormulaService.executionInProgressListener$.subscribe((i) => {
- this._commandService.executeCommand(
- Ns.id,
- {
- stageInfo: i
- },
- {
- onlyLocal: !0
- }
- );
- });
- }
- async _applyResult(i) {
- const { unitData: a, unitOtherData: e, arrayFormulaRange: t, arrayFormulaCellData: r, clearArrayFormulaCellData: n } = i;
- if (!a) {
- console.error("No sheetData from Formula Engine!");
- return;
- }
- t && (this._formulaDataModel.clearPreviousArrayFormulaCellData(n), this._formulaDataModel.mergeArrayFormulaCellData(r), this._formulaDataModel.mergeArrayFormulaRange(t), this._commandService.executeCommand(
- bs.id,
- {
- arrayFormulaRange: this._formulaDataModel.getArrayFormulaRange(),
- arrayFormulaCellData: this._formulaDataModel.getArrayFormulaCellData()
- },
- {
- onlyLocal: !0
- }
- )), this._commandService.executeCommand(
- Ji.id,
- {
- unitData: uc(a),
- unitOtherData: e
- },
- {
- onlyLocal: !0
- }
- );
- }
- };
- Nn = Bh([
- ms(0, br),
- ms(1, Gs),
- ms(2, Ve(Pr))
- ], Nn);
- const Ni = /[\[\]]/g;
- function Oi(i, a) {
- if (Ni.test(i)) {
- const e = Number(i.replace(Ni, ""));
- return a + e;
- }
- return Number(i) - 1;
- }
- function gs(i, a = 0, e = 0) {
- i = i.toLocaleUpperCase();
- const t = i.split(/[RC]/), r = t[1], n = t[2], s = Oi(r, a), o = Oi(n, e);
- return {
- row: s,
- column: o,
- absoluteRefType: we.NONE
- };
- }
- function Ih(i, a = 0, e = 0) {
- const { refBody: t, sheetName: r, unitId: n } = na(i), s = t.indexOf(":");
- if (s === -1) {
- const C = gs(t, a, e), E = C.row, b = C.column, R = C.absoluteRefType;
- return {
- unitId: n,
- sheetName: r,
- range: {
- startRow: E,
- startColumn: b,
- endRow: E,
- endColumn: b,
- startAbsoluteRefType: R,
- endAbsoluteRefType: R
- }
- };
- }
- const o = t.substring(0, s), u = t.substring(s + 1), c = gs(o, a, e), l = gs(u, a, e), f = c.row, h = c.column, d = l.row, _ = l.column;
- return {
- unitId: n,
- sheetName: r,
- range: {
- startRow: f,
- startColumn: h,
- endRow: d,
- endColumn: _,
- startAbsoluteRefType: c.absoluteRefType,
- endAbsoluteRefType: l.absoluteRefType
- }
- };
- }
- function Fh(i) {
- const a = qr(i.startRow, i.startAbsoluteRefType, !0), e = qr(i.startColumn, i.startAbsoluteRefType, !1), t = qr(i.endRow, i.endAbsoluteRefType, !0), r = qr(i.endColumn, i.endAbsoluteRefType, !1);
- return a === t && e === r ? `R${a}C${e}` : `R${a}C${e}:R${t}C${r}`;
- }
- function qr(i, a = we.ALL, e) {
- switch (i += 1, a) {
- case we.ALL:
- return `${i}`;
- case we.ROW:
- return e ? `${i}` : `[${i}]`;
- case we.COLUMN:
- return e ? `[${i}]` : `${i}`;
- case we.NONE:
- return `[${i}]`;
- }
- }
- function Xt(i) {
- let a = i;
- if (i.isArray()) {
- const e = i.getRowCount(), t = i.getColumnCount();
- if (e > 1 || t > 1)
- return g.create(m.VALUE);
- a = i.get(0, 0);
- }
- return a.isError(), a;
- }
- function Fr(...i) {
- for (let a = 0; a < i.length; a++) {
- const e = Xt(i[a]);
- if (e.isError())
- return {
- isError: !0,
- errorObject: e
- };
- i[a] = e;
- }
- return {
- isError: !1,
- variants: i
- };
- }
- function H(...i) {
- for (let a = 0; a < i.length; a++) {
- const e = Xt(i[a]);
- if (e.isError())
- return {
- isError: !0,
- errorObject: e
- };
- if (e.isBoolean())
- return {
- isError: !0,
- errorObject: g.create(m.VALUE)
- };
- i[a] = e;
- }
- return {
- isError: !1,
- variants: i
- };
- }
- function Fe(...i) {
- for (let a = 0; a < i.length; a++) {
- let e = i[a];
- if (e.isError())
- return {
- isError: !0,
- errorObject: e
- };
- if (e.isNull())
- return {
- isError: !0,
- errorObject: g.create(m.NA)
- };
- if (e = Xt(i[a]), e.isError())
- return {
- isError: !0,
- errorObject: e
- };
- if (e.isBoolean())
- return {
- isError: !0,
- errorObject: g.create(m.VALUE)
- };
- i[a] = e;
- }
- return {
- isError: !1,
- variants: i
- };
- }
- function I(...i) {
- for (let a = 0; a < i.length; a++) {
- let e = i[a];
- if (e.isString() && (e = e.convertToNumberObjectValue()), e.isError())
- return {
- isError: !0,
- errorObject: e
- };
- i[a] = e;
- }
- return {
- isError: !1,
- variants: i
- };
- }
- class V {
- constructor(a) {
- A(this, "_unitId");
- A(this, "_subUnitId");
- A(this, "_row", -1);
- A(this, "_column", -1);
- A(this, "_definedNames");
- A(this, "_locale");
- A(this, "_sheetOrder");
- A(this, "_sheetNameMap");
- A(this, "_formulaDataModel");
- A(this, "_rowCount", -1);
- A(this, "_columnCount", -1);
- /**
- * Whether the function needs to expand the parameters
- */
- A(this, "needsExpandParams", !1);
- /**
- * Whether the function needs to pass in reference object
- */
- A(this, "needsReferenceObject", !1);
- /**
- * Whether the function needs handle locale
- */
- A(this, "needsLocale", !1);
- /**
- * Whether the function needs sheets info
- */
- A(this, "needsSheetsInfo", !1);
- /**
- * Whether the function needs function methods in FormulaDataModel
- */
- A(this, "needsFormulaDataModel", !1);
- /**
- * Whether the function needs the number of rows and columns in the sheet
- */
- A(this, "needsSheetRowColumnCount", !1);
- /**
- * Minimum number of parameters
- */
- A(this, "minParams", -1);
- /**
- * Maximum number of parameters
- */
- A(this, "maxParams", -1);
- this._name = a;
- }
- get name() {
- return this._name;
- }
- get unitId() {
- return this._unitId;
- }
- get subUnitId() {
- return this._subUnitId;
- }
- get row() {
- return this._row;
- }
- get column() {
- return this._column;
- }
- dispose() {
- }
- /**
- * In Excel, to inject a defined name into a function that has positioning capabilities,
- * such as using the INDIRECT function to reference a named range,
- * you can write it as follows:
- * =INDIRECT("DefinedName1")
- */
- getDefinedName(a) {
- var t;
- const e = this._definedNames;
- return e == null ? null : (t = Array.from(Object.values(e)).filter((r) => r.name === a)) == null ? void 0 : t[0];
- }
- setDefinedNames(a) {
- this._definedNames = a;
- }
- getLocale() {
- return this._locale;
- }
- setLocale(a) {
- this._locale = a;
- }
- getSheetsInfo() {
- return {
- sheetOrder: this._sheetOrder,
- sheetNameMap: this._sheetNameMap
- };
- }
- setSheetsInfo({
- sheetOrder: a,
- sheetNameMap: e
- }) {
- this._sheetOrder = a, this._sheetNameMap = e;
- }
- setFormulaDataModel(a) {
- this._formulaDataModel = a;
- }
- setSheetRowColumnCount(a, e) {
- this._rowCount = a, this._columnCount = e;
- }
- isAsync() {
- return !1;
- }
- isAddress() {
- return !1;
- }
- isCustom() {
- return !1;
- }
- setRefInfo(a, e, t, r) {
- this._unitId = a, this._subUnitId = e, this._row = t, this._column = r;
- }
- calculateCustom(...a) {
- return null;
- }
- calculate(...a) {
- return g.create(m.VALUE);
- }
- checkArrayType(a) {
- return a.isReferenceObject() || a.isValueObject() && a.isArray();
- }
- /**
- * Starting with 1
- * For instance, The column number (starting with 1 for the left-most column of table_array) that contains the return value.
- * https://support.microsoft.com/en-us/office/vlookup-function-0bbc8083-26fe-4963-8ab8-93a18ad188a1
- * @param indexNum
- */
- getIndexNumValue(a, e = 1) {
- let t = a;
- if (t.isArray() && (t = t.getFirstCell()), t.isBoolean())
- return t.getValue() === !1 ? g.create(m.VALUE) : e;
- if (t.isString()) {
- const r = Number(t.getValue());
- return Number.isNaN(r) ? g.create(m.REF) : r;
- } else if (t.isNumber())
- return t.getValue();
- return g.create(m.VALUE);
- }
- /**
- * A logical value that specifies 1/TRUE , 0/FALSE, default 1
- * For instance range_lookup, A logical value that specifies whether you want VLOOKUP to find an approximate or an exact match
- * Approximate match - 1/TRUE
- * Exact match - 0/FALSE
- * https://support.microsoft.com/en-us/office/vlookup-function-0bbc8083-26fe-4963-8ab8-93a18ad188a1
- * For instance A1, A logical value that specifies what type of reference is contained in the cell ref_text.
- * If a1 is TRUE or omitted, ref_text is interpreted as an A1-style reference.
- * If a1 is FALSE, ref_text is interpreted as an R1C1-style reference.
- * https://support.microsoft.com/zh-cn/office/indirect-%E5%87%BD%E6%95%B0-474b3a3a-8a26-4f44-b491-92b6306fa261
- * @param logicValueObject
- */
- getZeroOrOneByOneDefault(a) {
- if (a == null)
- return 1;
- let e = 1;
- if (a.isArray() && (a = a.getFirstCell()), a.isBoolean())
- a.getValue() === !1 && (e = 0);
- else {
- if (a.isString())
- return;
- a.isNumber() && a.getValue() === 0 && (e = 0);
- }
- return e;
- }
- /**
- * A logical value that specifies 1/TRUE , 0/FALSE, -1, default 1.
- * The difference from getZeroOrOneByOneDefault is that we need to get -1
- * @param logicValueObject
- */
- getMatchTypeValue(a) {
- if (a == null)
- return 1;
- let e = 1;
- if (a.isArray() && (a = a.getFirstCell()), a.isBoolean())
- a.getValue() === !1 && (e = 0);
- else {
- if (a.isString())
- return;
- if (a.isNumber()) {
- const t = a.getValue();
- t <= 0 && (e = t);
- }
- }
- return e;
- }
- binarySearch(a, e, t, r, n) {
- const s = e.binarySearch(a, r, n);
- if (s == null)
- return g.create(m.NA);
- let o;
- return t.getRowCount() === 1 ? o = t.get(0, s) || ie.create() : o = t.get(s, 0) || ie.create(), o.isNull() ? y.create(0) : o;
- }
- _getOneFirstByRaw(a) {
- return a.length === 0 ? g.create(m.NA) : a[0][0] || g.create(m.NA);
- }
- _getOneLastByRaw(a) {
- return a.length === 0 ? g.create(m.NA) : a[a.length - 1][a[0].length - 1] || g.create(m.NA);
- }
- equalSearch(a, e, t, r = !0) {
- const n = t.pickRaw(e.isEqual(a));
- return r ? this._getOneFirstByRaw(n) : this._getOneLastByRaw(n);
- }
- fuzzySearch(a, e, t, r = !0) {
- const n = t.pickRaw(e.compare(a, $.EQUALS));
- return r ? this._getOneFirstByRaw(n) : this._getOneLastByRaw(n);
- }
- orderSearch(a, e, t, r = Pe.MIN, n = !1) {
- const s = e.orderSearch(a, r, n);
- if (s == null)
- return g.create(m.NA);
- const o = t.get(s.row, s.column) || ie.create();
- return o.isNull() ? g.create(m.NA) : o;
- }
- binarySearchExpand(a, e, t, r = 0, n, s) {
- const o = e.binarySearch(a, n, s);
- return o == null ? g.create(m.NA) : r === 0 ? t.slice([o, o + 1]) : t.slice(void 0, [o, o + 1]);
- }
- equalSearchExpand(a, e, t, r = !0, n = 0) {
- const s = e.isEqual(a);
- let o;
- return r ? o = s.getFirstTruePosition() : o = s.getLastTruePosition(), o == null ? g.create(m.NA) : n === 0 ? t.slice([o.row, o.row + 1]) : t.slice(void 0, [o.column, o.column + 1]);
- }
- fuzzySearchExpand(a, e, t, r = !0, n = 0) {
- const s = e.compare(a, $.EQUALS);
- let o;
- return r ? o = s.getFirstTruePosition() : o = s.getLastTruePosition(), o == null ? g.create(m.NA) : n === 0 ? t.slice([o.row, o.row + 1]) : t.slice(void 0, [o.column, o.column + 1]);
- }
- orderSearchExpand(a, e, t, r = Pe.MIN, n = !1, s = 0) {
- const o = e.orderSearch(a, r, n);
- return o == null ? g.create(m.NA) : s === 0 ? t.slice([o.row, o.row + 1]) : t.slice(void 0, [o.column, o.column + 1]);
- }
- flattenArray(a, e = !0) {
- const t = [];
- t[0] = [];
- for (let r = 0; r < a.length; r++) {
- let n = a[r];
- if ((n.isString() || n.isBoolean() || n.isNull()) && (n = n.convertToNumberObjectValue()), n.isError())
- return n;
- if (n.isArray()) {
- let s;
- if (n.iterator((o) => {
- if (o == null || o.isNull() || e && (o.isString() || o.isBoolean()))
- return !0;
- if (o = this._includingLogicalValuesAndText(o), o.isError())
- return s = o, !1;
- t[0].push(o);
- }), s != null && s.isError())
- return s;
- } else
- t[0].push(n);
- }
- return tr(t, 1, t[0].length);
- }
- _includingLogicalValuesAndText(a) {
- if (a.isBoolean() && (a = wf(a)), a.isString()) {
- const e = Number(a.getValue());
- a = y.create(Number.isNaN(e) ? 0 : e);
- }
- return a;
- }
- createReferenceObject(a, e) {
- const t = a.getForcedUnitId(), r = a.getForcedSheetId() || "", n = a.getForcedSheetName(), o = ys({
- unitId: t,
- sheetName: n,
- range: e
- });
- let u;
- 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(a, u);
- }
- _setReferenceDefault(a, e) {
- return this.unitId == null || this.subUnitId == null ? g.create(m.REF) : (e.setDefaultUnitId(this.unitId), e.setDefaultSheetId(this.subUnitId), e.setUnitData(a.getUnitData()), e.setRuntimeData(a.getRuntimeData()), e.setArrayFormulaCellData(a.getArrayFormulaCellData()), e.setRuntimeArrayFormulaCellData(a.getRuntimeArrayFormulaCellData()), e);
- }
- }
- class kh extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 3);
- A(this, "maxParams", 3);
- }
- calculate(e, t, r) {
- if (e.isError())
- return e;
- const { isError: n, errorObject: s, variants: o } = Fr(t, r);
- if (n)
- return s;
- const { isError: u, errorObject: c, variants: l } = I(...o);
- if (u)
- return c;
- const [f, h] = l, d = Math.floor(+f.getValue()), _ = Math.floor(+h.getValue());
- if (d < 0 || _ < 0)
- return g.create(m.NUM);
- if (d === 0 || _ === 0)
- return g.create(m.REF);
- const C = e.isArray() ? e.getRowCount() : 1, E = e.isArray() ? e.getColumnCount() : 1;
- if (C === 1 && E === 1)
- return e.isArray() ? e.get(0, 0) : e;
- const b = d > C ? C : d, R = _ > E ? E : _;
- return e.slice([0, b], [0, R]);
- }
- }
- class $h extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 255);
- }
- calculate(...e) {
- const t = [];
- for (let r = 0; r < e.length; r++) {
- const n = e[r], s = n.isArray() ? n.getRowCount() : 1, o = n.isArray() ? n.getColumnCount() : 1;
- for (let u = 0; u < s; u++)
- for (let c = 0; c < o; c++) {
- const l = n.isArray() ? n.get(u, c) : n;
- t.push([l]);
- }
- }
- return q.create({
- calculateValueList: t,
- rowCount: t.length,
- columnCount: 1,
- unitId: this.unitId,
- sheetId: this.subUnitId,
- row: this.row,
- column: this.column
- });
- }
- }
- var Ws = /* @__PURE__ */ ((i) => (i.ARRAY_CONSTRAIN = "ARRAY_CONSTRAIN", i.FLATTEN = "FLATTEN", i))(Ws || {});
- const Yh = [
- [kh, Ws.ARRAY_CONSTRAIN],
- [$h, Ws.FLATTEN]
- ];
- var _r;
- ((i) => {
- const a = 0.636619772;
- function e(n, s) {
- let o = 0;
- for (let u = 0; u < n.length; ++u)
- o = s * o + n[u];
- return o;
- }
- function t(n, s, o, u, c) {
- if (s === 0)
- return o;
- if (s === 1)
- return u;
- const l = 2 / n;
- let f = o, h = u, d = u;
- for (let _ = 1; _ < s; ++_)
- d = h * _ * l + c * f, f = h, h = d;
- return d;
- }
- function r(n, s, o, u) {
- return function(l, f) {
- if (o) {
- if (l === 0)
- return o === 1 ? -1 / 0 : 1 / 0;
- if (l < 0)
- return Number.NaN;
- }
- if (f === 0)
- return n(l);
- if (f === 1)
- return s(l);
- if (f < 0)
- return Number.NaN;
- const h = f | 0, d = n(l), _ = s(l);
- return t(l, h, d, _, u);
- };
- }
- i.besselj = /* @__PURE__ */ (() => {
- 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];
- function c(C) {
- let E = 0, b = 0, R = 0, p = C * C;
- if (C < 8)
- b = e(n, p), R = e(s, p), E = b / R;
- else {
- const N = C - 0.785398164;
- p = 64 / p, b = e(o, p), R = e(u, p), E = Math.sqrt(a / C) * (Math.cos(N) * b - Math.sin(N) * R * 8 / C);
- }
- return E;
- }
- const l = [-30.16036606, 15704.4826, -2972611439e-3, 2423968531e-1, -7895059235, 72362614232], f = [1, 376.9991397, 99447.43394, 1858330474e-2, 2300535178, 144725228442], h = [-240337019e-15, 2457520174e-15, -3516396496e-14, 183105e-8, 1], d = [105787412e-15, -88228987e-14, 8449199096e-15, -2002690873e-13, 0.04687499995];
- function _(C) {
- let E = 0, b = 0, R = 0, p = C * C;
- const N = Math.abs(C) - 2.356194491;
- return Math.abs(C) < 8 ? (b = C * e(l, p), R = e(f, p), E = b / R) : (p = 64 / p, b = e(h, p), R = e(d, p), E = Math.sqrt(a / Math.abs(C)) * (Math.cos(N) * b - Math.sin(N) * R * 8 / Math.abs(C)), C < 0 && (E = -E)), E;
- }
- return function C(E, b) {
- const R = Math.round(b);
- if (!Number.isFinite(E))
- return Number.isNaN(E) ? E : 0;
- if (R < 0)
- return (R % 2 ? -1 : 1) * C(E, -R);
- if (E < 0)
- return (R % 2 ? -1 : 1) * C(-E, R);
- if (R === 0)
- return c(E);
- if (R === 1)
- return _(E);
- if (E === 0)
- return 0;
- let p = 0;
- if (E > R)
- p = t(E, R, c(E), _(E), -1);
- else {
- const N = 2 * Math.floor((R + Math.floor(Math.sqrt(40 * R))) / 2);
- let M = !1, w = 0, D = 0, S = 1, P = 0;
- const U = 2 / E;
- for (let x = N; x > 0; x--)
- if (P = x * U * S - w, w = S, S = P, Math.abs(S) > 1e10 && (S *= 1e-10, w *= 1e-10, p *= 1e-10, D *= 1e-10), M && (D += S), M = !M, x === R && (p = w), N - x > 100 && p === 0)
- return Number.NaN;
- D = 2 * D - S, p /= D;
- }
- return p;
- };
- })(), i.bessely = (() => {
- 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];
- function c(C) {
- let E = 0, b = 0, R = 0, p = C * C;
- const N = C - 0.785398164;
- return C < 8 ? (b = e(n, p), R = e(s, p), E = b / R + a * (0, i.besselj)(C, 0) * Math.log(C)) : (p = 64 / p, b = e(o, p), R = e(u, p), E = Math.sqrt(a / C) * (Math.sin(N) * b + Math.cos(N) * R * 8 / C)), E;
- }
- const l = [8511.937935, -4237922726e-3, 7349264551e-1, -51534381390, 127527439e4, -4900604943e3], f = [1, 354.9632885, 102042.605, 2245904002e-2, 3733650367, 424441966400, 249958057e5], h = [-240337019e-15, 2457520174e-15, -3516396496e-14, 183105e-8, 1], d = [105787412e-15, -88228987e-14, 8449199096e-15, -2002690873e-13, 0.04687499995];
- function _(C) {
- let E = 0, b = 0, R = 0, p = C * C;
- const N = C - 2.356194491;
- return C < 8 ? (b = C * e(l, p), R = e(f, p), E = b / R + a * ((0, i.besselj)(C, 1) * Math.log(C) - 1 / C)) : (p = 64 / p, b = e(h, p), R = e(d, p), E = Math.sqrt(a / C) * (Math.sin(N) * b + Math.cos(N) * R * 8 / C)), E;
- }
- return r(c, _, 1, -1);
- })(), i.besseli = /* @__PURE__ */ (() => {
- 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];
- function o(f) {
- return f <= 3.75 ? e(n, f * f / (3.75 * 3.75)) : Math.exp(Math.abs(f)) / Math.sqrt(Math.abs(f)) * e(s, 3.75 / Math.abs(f));
- }
- 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];
- function l(f) {
- return f < 3.75 ? f * e(u, f * f / (3.75 * 3.75)) : (f < 0 ? -1 : 1) * Math.exp(Math.abs(f)) / Math.sqrt(Math.abs(f)) * e(c, 3.75 / Math.abs(f));
- }
- return function f(h, d) {
- const _ = Math.round(d);
- if (_ === 0)
- return o(h);
- if (_ === 1)
- return l(h);
- if (_ < 0)
- return Number.NaN;
- if (Math.abs(h) === 0)
- return 0;
- if (h === 1 / 0)
- return 1 / 0;
- let C = 0, E;
- const b = 2 / Math.abs(h);
- let R = 0, p = 1, N = 0;
- const M = 2 * Math.round((_ + Math.round(Math.sqrt(40 * _))) / 2);
- for (E = M; E > 0; E--)
- if (N = E * b * p + R, R = p, p = N, Math.abs(p) > 1e10 && (p *= 1e-10, R *= 1e-10, C *= 1e-10), E === _ && (C = R), M - E > 100 && C === 0)
- return Number.NaN;
- return C *= f(h, 0) / p, h < 0 && _ % 2 ? -C : C;
- };
- })(), i.besselk = (() => {
- 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];
- function o(f) {
- return f <= 2 ? -Math.log(f / 2) * (0, i.besseli)(f, 0) + e(n, f * f / 4) : Math.exp(-f) / Math.sqrt(f) * e(s, 2 / f);
- }
- 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];
- function l(f) {
- return f <= 2 ? Math.log(f / 2) * (0, i.besseli)(f, 1) + 1 / f * e(u, f * f / 4) : Math.exp(-f) / Math.sqrt(f) * e(c, 2 / f);
- }
- return r(o, l, 2, 1);
- })();
- })(_r || (_r = {}));
- function Ra(i) {
- return /^[01]{1,10}$/.test(i);
- }
- function pa(i) {
- return /^[0-7]{1,10}$/.test(i);
- }
- function Va(i) {
- return /^[0-9A-Fa-f]{1,10}$/.test(i);
- }
- function Zt(i) {
- if (i === 0)
- return 0;
- const a = [
- -1.3026537197817094,
- 0.6419697923564902,
- 0.019476473204185836,
- -0.00956151478680863,
- -946595344482036e-18,
- 366839497852761e-18,
- 42523324806907e-18,
- -20278578112534e-18,
- -1624290004647e-18,
- 130365583558e-17,
- 15626441722e-18,
- -85238095915e-18,
- 6529054439e-18,
- 5059343495e-18,
- -991364156e-18,
- -227365122e-18,
- 96467911e-18,
- 2394038e-18,
- -6886027e-18,
- 894487e-18,
- 313092e-18,
- -112708e-18,
- 381e-18,
- 7106e-18,
- -1523e-18,
- -94e-18,
- 121e-18,
- -28e-18
- ];
- let e = i, t = !1;
- e < 0 && (e = -e, t = !0);
- const r = 2 / (2 + e), n = 4 * r - 2;
- let s = 0, o = 0, u;
- for (let l = a.length - 1; l > 0; l--)
- u = s, s = n * s - o + a[l], o = u;
- const c = r * Math.exp(-e * e + 0.5 * (a[0] + n * s) - o);
- return t ? c - 1 : 1 - c;
- }
- function Na(i) {
- return 1 - Zt(i);
- }
- function Hh(i) {
- if (i >= 2)
- return -100;
- if (i <= 0)
- return 100;
- const a = i < 1 ? i : 2 - i, e = Math.sqrt(-2 * Math.log(a / 2));
- let t = -0.70711 * ((2.30753 + e * 0.27061) / (1 + e * (0.99229 + e * 0.04481)) - e);
- for (let r = 0; r < 2; r++) {
- const n = Na(t) - a;
- t += n / (1.1283791670955126 * Math.exp(-t * t) - t * n);
- }
- return i < 1 ? t : -t;
- }
- function cr(i, a = 1) {
- let e = Math.floor(i);
- if (i < 0)
- return Number.NaN;
- let t = 1;
- for (; e > 1 && Number.isFinite(t); )
- t *= e, e -= a;
- return t;
- }
- function zt(i, a) {
- const e = Math.min(i - a, a);
- let t = 1;
- for (let r = 1; r <= e && Number.isFinite(t); r++)
- t *= i - r + 1, t /= r;
- return t;
- }
- function qs(i, a) {
- let e = Math.floor(i), t = Math.floor(a);
- for (; t !== 0; ) {
- const r = t;
- t = e % t, e = r;
- }
- return e;
- }
- function Mi(i, a) {
- const e = qs(i, a);
- return e === 0 ? 0 : Math.abs(i * a) / e;
- }
- function Gn(i) {
- const a = i.length;
- if (a === 1)
- return i[0][0];
- if (a === 2)
- return i[0][0] * i[1][1] - i[0][1] * i[1][0];
- let e = 0;
- for (let t = 0; t < a; t++)
- e += (t % 2 === 0 ? 1 : -1) * i[0][t] * Gn(wo(i, 0, t));
- return e;
- }
- function Gh(i) {
- const a = Gn(i);
- return a === 0 ? null : i.length === 1 ? [[1 / a]] : Qh(i).map((r) => r.map((n) => n / a));
- }
- function wo(i, a, e) {
- return i.filter((t, r) => r !== a).map((t) => t.filter((r, n) => n !== e));
- }
- function Qh(i) {
- const a = i.length, e = Array.from({ length: a }, () => new Array(a).fill(0));
- for (let t = 0; t < a; t++)
- for (let r = 0; r < a; r++) {
- const n = (t + r) % 2 === 0 ? 1 : -1;
- e[r][t] = n * Gn(wo(i, t, r));
- }
- return e;
- }
- function lr(i, a) {
- return i.map((e) => a[0].map(
- (t, r) => e.reduce((n, s, o) => n + s * a[o][r], 0)
- ));
- }
- function mt(i) {
- return i[0].map((a, e) => i.map((t) => t[e]));
- }
- function Wh(i) {
- const { smallPivotDetected: a, luMatrix: e, permutation: t } = qh(i);
- return a ? null : Kh(e, t);
- }
- function qh(i) {
- const a = mt(i), e = a.length, t = a[0].length;
- let r = !0, n = !1;
- const s = Ks(e, t, 0), o = new Array(t).fill(0).map((u, c) => c);
- for (let u = 0; u < t; u++) {
- for (let h = 0; h < u; h++) {
- let d = a[h][u];
- for (let _ = 0; _ < h; _++)
- d -= s[h][_] * s[_][u];
- s[h][u] = d;
- }
- let c = -1 / 0, l = u;
- for (let h = u; h < e; h++) {
- let d = a[h][u];
- for (let C = 0; C < u; C++)
- d -= s[h][C] * s[C][u];
- s[h][u] = d;
- const _ = Math.abs(d);
- _ > c && (c = _, l = h);
- }
- if (Math.abs(s[l][u]) < 1e-11) {
- n = !0;
- break;
- }
- l !== u && ([s[u], s[l]] = [s[l], s[u]], [a[u], a[l]] = [a[l], a[u]], [o[u], o[l]] = [o[l], o[u]], r = !r);
- const f = s[u][u];
- for (let h = u + 1; h < e; h++)
- s[h][u] /= f;
- }
- return {
- rowSwap: r,
- smallPivotDetected: n,
- luMatrix: s,
- permutation: o
- };
- }
- function Kh(i, a) {
- const e = a.length, t = Ks(e, e, 0);
- for (let n = 0; n < e; n++)
- t[n][n] = 1;
- const r = Ks(e, e, 0);
- for (let n = 0; n < e; n++) {
- const s = a[n];
- for (let o = 0; o < e; o++)
- r[n][o] = t[s][o];
- }
- for (let n = 0; n < e; n++) {
- const s = r[n];
- for (let o = n + 1; o < e; o++) {
- const u = i[o][n];
- for (let c = 0; c < e; c++)
- r[o][c] -= s[c] * u;
- }
- }
- for (let n = e - 1; n >= 0; n--) {
- const s = r[n], o = i[n][n];
- for (let u = 0; u < e; u++)
- s[u] /= o;
- for (let u = 0; u < n; u++) {
- const c = i[u][n];
- for (let l = 0; l < e; l++)
- r[u][l] -= s[l] * c;
- }
- }
- return r;
- }
- function Ks(i, a, e) {
- const t = [];
- for (let r = 0; r < i; r++) {
- t[r] = [];
- for (let n = 0; n < a; n++)
- t[r].push(e);
- }
- return t;
- }
- function Xh(i) {
- const a = Zh(i);
- if (!a)
- return null;
- const { matrixU: e, matrixS: t, matrixV: r } = a, 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];
- for (let u = 0; u < t.length; u++)
- Math.abs(t[u]) > o && (s[u][u] = 1 / t[u]);
- return lr(r, lr(s, n));
- }
- function Zh(i) {
- const a = mt(i), e = a.length, t = a[0].length;
- if (e < t)
- return null;
- const r = new Array(t).fill(0), n = new Array(t).fill(0), s = Array.from({ length: t }, () => new Array(t).fill(0));
- let o = Number.EPSILON, u = 0, c = 0, l = 0;
- for (let C = 0; C < t; C++) {
- if (r[C] = u, c = ds(a, C, e, C, C), c <= 1e-64 / o)
- u = 0;
- else {
- u = Math.sqrt(c), a[C][C] >= 0 && (u = -u);
- const b = a[C][C] * u - c;
- a[C][C] -= u;
- for (let R = C + 1; R < t; R++) {
- c = ds(a, C, e, C, R);
- for (let p = C; p < e; p++)
- a[p][R] += c / b * a[p][C];
- }
- }
- if (n[C] = u, c = wi(a, C + 1, t, C, C), c <= 1e-64 / o)
- u = 0;
- else {
- u = Math.sqrt(c), a[C][C + 1] >= 0 && (u = -u);
- const b = a[C][C + 1] * u - c;
- a[C][C + 1] -= u;
- for (let R = C + 1; R < t; R++)
- r[R] = a[C][R] / b;
- for (let R = C + 1; R < e; R++) {
- c = wi(a, C + 1, t, R, C);
- for (let p = C + 1; p < t; p++)
- a[R][p] += c * r[p];
- }
- }
- const E = Math.abs(n[C]) + Math.abs(r[C]);
- E > l && (l = E);
- }
- let f = 0;
- for (let C = t - 1; C >= 0; C--) {
- if (u !== 0) {
- for (let E = f; E < t; E++)
- s[E][C] = a[C][E] / (u * a[C][C + 1]);
- for (let E = f; E < t; E++) {
- c = 0;
- for (let b = f; b < t; b++)
- c += a[C][b] * s[b][E];
- for (let b = f; b < t; b++)
- s[b][E] += c * s[b][C];
- }
- }
- for (let E = f; E < t; E++)
- s[C][E] = 0, s[E][C] = 0;
- s[C][C] = 1, u = r[C], f = C;
- }
- for (let C = t - 1; C >= 0; C--) {
- u = n[C];
- for (let E = C + 1; E < t; E++)
- a[C][E] = 0;
- if (u !== 0) {
- for (let E = C + 1; E < t; E++) {
- c = ds(a, C + 1, e, C, E);
- for (let b = C; b < e; b++)
- a[b][E] += c / (a[C][C] * u) * a[b][C];
- }
- for (let E = C; E < e; E++)
- a[E][C] /= u;
- } else
- for (let E = C; E < e; E++)
- a[E][C] = 0;
- a[C][C] += 1;
- }
- o *= l;
- let h = 0, d = 0, _ = 0;
- for (let C = t - 1; C >= 0; C--)
- for (let E = 0; E < 50; E++) {
- let b = !1, R = C;
- for (; R >= 0; R--) {
- if (Math.abs(r[R]) <= o) {
- b = !0;
- break;
- }
- if (Math.abs(n[R - 1]) <= o)
- break;
- }
- if (!b) {
- let w = 0, D = 1;
- for (let S = R; S < C + 1 && (h = D * r[S], d = n[S], r[S] *= w, !(Math.abs(h) <= o)); S++) {
- _ = Kr(h, d), n[S] = _, w = d / _, D = -h / _;
- for (let P = 0; P < e; P++) {
- const U = a[P][R - 1], x = a[P][S];
- a[P][R - 1] = U * w + x * D, a[P][S] = -U * D + x * w;
- }
- }
- }
- if (R === C) {
- if (n[C] < 0) {
- n[C] = -n[C];
- for (let w = 0; w < t; w++)
- s[w][C] = -s[w][C];
- }
- break;
- }
- if (E >= 49)
- return null;
- let p = n[R];
- 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 = ((p - n[C]) * (p + n[C]) + r[C] * (n[C - 1] / (h - _) - r[C])) / p : h = ((p - n[C]) * (p + n[C]) + r[C] * (n[C - 1] / (h + _) - r[C])) / p;
- let N = 1, M = 1;
- for (let w = R + 1; w < C + 1; w++) {
- let D = r[w], S = n[w];
- d = M * D, D *= N, _ = Kr(h, d), r[w - 1] = _, N = h / _, M = d / _, h = p * N + D * M, d = S * M, D = -p * M + D * N, S *= N;
- for (let P = 0; P < t; P++) {
- const U = s[P][w - 1], x = s[P][w];
- s[P][w - 1] = U * N + x * M, s[P][w] = -U * M + x * N;
- }
- _ = Kr(h, d), n[w - 1] = _, N = h / _, M = d / _, h = N * D + M * S, p = -M * D + N * S;
- for (let P = 0; P < e; P++) {
- const U = a[P][w - 1], x = a[P][w];
- a[P][w - 1] = U * N + x * M, a[P][w] = -U * M + x * N;
- }
- }
- r[R] = 0, r[C] = h, n[C] = p;
- }
- for (let C = 0; C < n.length; C++)
- n[C] < o && (n[C] = 0);
- for (let C = 0; C < t; C++)
- for (let E = C - 1; E >= 0; E--)
- if (n[E] < n[C]) {
- const b = n[E];
- n[E] = n[C], n[C] = b;
- for (let R = 0; R < a.length; R++) {
- const p = a[R][C];
- a[R][C] = a[R][E], a[R][E] = p;
- }
- for (let R = 0; R < s.length; R++) {
- const p = s[R][C];
- s[R][C] = s[R][E], s[R][E] = p;
- }
- C = E;
- }
- return {
- matrixU: a,
- matrixS: n,
- matrixV: s
- };
- }
- function Kr(i, a) {
- let e = 0;
- return Math.abs(i) > Math.abs(a) ? (e = a / i, Math.abs(i) * Math.sqrt(1 + e * e)) : a !== 0 ? (e = i / a, Math.abs(a) * Math.sqrt(1 + e * e)) : 0;
- }
- function ds(i, a, e, t, r) {
- let n = 0;
- for (let s = a; s < e; s++)
- n += i[s][t] * i[s][r];
- return n;
- }
- function wi(i, a, e, t, r) {
- let n = 0;
- for (let s = a; s < e; s++)
- n += i[t][s] * i[r][s];
- return n;
- }
- const Xr = /* @__PURE__ */ new Map([
- ["I", 1],
- ["V", 5],
- ["X", 10],
- ["L", 50],
- ["C", 100],
- ["D", 500],
- ["M", 1e3]
- ]), zh = /* @__PURE__ */ new Map([
- [1, "I"],
- [4, "IV"],
- [5, "V"],
- [9, "IX"],
- [10, "X"],
- [40, "XL"],
- [45, "VL"],
- [49, "IL"],
- [50, "L"],
- [90, "XC"],
- [95, "VC"],
- [99, "IC"],
- [100, "C"],
- [400, "CD"],
- [450, "LD"],
- [490, "XD"],
- [495, "VD"],
- [499, "ID"],
- [500, "D"],
- [900, "CM"],
- [950, "LM"],
- [990, "XM"],
- [995, "VM"],
- [999, "IM"],
- [1e3, "M"]
- ]), Jh = [
- [1, 4, 5, 9, 10, 40, 50, 90, 100, 400, 500, 900, 1e3, 4e3],
- [1, 4, 5, 9, 10, 40, 45, 50, 90, 95, 100, 400, 450, 500, 900, 950, 1e3, 4e3],
- [1, 4, 5, 9, 10, 40, 45, 49, 50, 90, 95, 99, 100, 400, 450, 490, 500, 900, 950, 990, 1e3, 4e3],
- [1, 4, 5, 9, 10, 40, 45, 49, 50, 90, 95, 99, 100, 400, 450, 490, 495, 500, 900, 950, 990, 995, 1e3, 4e3],
- [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]
- ];
- function Do(i, a, e) {
- return i <= 0 ? 0 : i >= 1 ? 1 : Qn(i, a, e);
- }
- function em(i, a, e) {
- return i <= 0 || i >= 1 ? 0 : a === 1 && e === 1 ? 1 : a < 512 && e < 512 ? i ** (a - 1) * (1 - i) ** (e - 1) / Ma(a, e) : Math.exp((a - 1) * Math.log(i) + (e - 1) * Math.log(1 - i) - wa(a, e));
- }
- function Oa(i, a, e) {
- if (i <= 0)
- return 0;
- if (i >= 1)
- return 1;
- const t = 1e-8;
- let r;
- if (a >= 1 && e >= 1) {
- const c = i < 0.5 ? i : 1 - i, l = Math.sqrt(-2 * Math.log(c));
- r = (2.30753 + l * 0.27061) / (1 + l * (0.99229 + l * 0.04481)) - l, i < 0.5 && (r = -r);
- const f = (r * r - 3) / 6, h = 2 / (1 / (2 * a - 1) + 1 / (2 * e - 1)), d = r * Math.sqrt(f + h) / h - (1 / (2 * e - 1) - 1 / (2 * a - 1)) * (f + 5 / 6 - 2 / (3 * h));
- r = a / (a + e * Math.exp(2 * d));
- } else {
- const c = Math.exp(a * Math.log(a / (a + e))) / a, l = Math.exp(e * Math.log(e / (a + e))) / e, f = c + l;
- i < c / f ? r = (a * f * i) ** (1 / a) : r = 1 - (e * f * (1 - i)) ** (1 / e);
- }
- const n = -wa(a, e);
- let s, o, u;
- for (let c = 0; c < 10; c++) {
- if (r === 0 || r === 1)
- return r;
- if (s = Qn(r, a, e) - i, o = Math.exp((a - 1) * Math.log(r) + (e - 1) * Math.log(1 - r) + n), u = s / o, r -= o = u / (1 - 0.5 * Math.min(1, u * ((a - 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)
- break;
- }
- return r;
- }
- function Qn(i, a, e) {
- const t = i === 0 || i === 1 ? 0 : Math.exp(ct(a + e) - ct(a) - ct(e) + a * Math.log(i) + e * Math.log(1 - i));
- return i < (a + 1) / (a + e + 2) ? t * Di(i, a, e) / a : 1 - t * Di(1 - i, e, a) / e;
- }
- function Di(i, a, e) {
- let n = 1 - (a + e) * i / (a + 1);
- Math.abs(n) < 1e-8 && (n = 1e-8), n = 1 / n;
- let s = 1, o = n;
- for (let u = 1; u <= 100; u++) {
- let c = u * (e - u) * i / ((a - 1 + u * 2) * (a + u * 2));
- 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 = -(a + u) * (a + e + u) * i / ((a + u * 2) * (a + 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)
- break;
- }
- return o;
- }
- function Ma(i, a) {
- return i + a > 170 ? Math.exp(wa(i, a)) : on(i) * on(a) / on(i + a);
- }
- function wa(i, a) {
- return ct(i) + ct(a) - ct(i + a);
- }
- function So(i, a, e) {
- if (i < 0)
- return 0;
- if (i >= a)
- return 1;
- if (e < 0 || e > 1 || a <= 0)
- return Number.NaN;
- let t = 0;
- for (let r = 0; r <= i; r++)
- t += Da(r, a, e);
- return t;
- }
- function Da(i, a, e) {
- return e === 0 || e === 1 ? a * e === i ? 1 : 0 : zt(a, i) * e ** i * (1 - e) ** (a - i);
- }
- function Sa(i, a) {
- return i <= 0 ? 0 : La(a / 2, i / 2);
- }
- function tm(i, a) {
- return i < 0 ? 0 : i === 0 && a === 2 ? 0.5 : Math.exp((a / 2 - 1) * Math.log(i) - i / 2 - a / 2 * Math.log(2) - ct(a / 2));
- }
- function Po(i, a) {
- return i <= 0 ? 0 : i >= 1 ? 1 / 0 : 2 * jo(i, a / 2);
- }
- function Pa(i, a, e) {
- return i < 0 ? 0 : Qn(a * i / (a * i + e), a / 2, e / 2);
- }
- function rm(i, a, e) {
- if (i < 0)
- return 0;
- if (i === 0 && a < 2)
- return 1 / 0;
- if (i === 0 && a === 2)
- return 1;
- let t = 1 / Ma(a / 2, e / 2);
- return t *= (a / e) ** (a / 2), t *= i ** (a / 2 - 1), t *= (1 + a / e * i) ** (-(a + e) / 2), t;
- }
- function Lo(i, a, e) {
- return i <= 0 ? 0 : i >= 1 ? 1 / 0 : e / (a * (1 / Oa(i, a / 2, e / 2) - 1));
- }
- function nm(i, a) {
- return i < 0 ? 0 : 1 - Math.exp(-a * i);
- }
- function sm(i, a) {
- return i < 0 ? 0 : a * Math.exp(-a * i);
- }
- function xo(i, a, e) {
- const t = a.length;
- let r = 0, n = 0;
- for (let h = 0; h < t; h++)
- r += a[h], n += e[h];
- const s = r / t, o = n / t;
- let u = 0, c = 0;
- for (let h = 0; h < t; h++)
- u += (a[h] - s) * (e[h] - o), c += (e[h] - o) ** 2;
- if (c === 0)
- return 1 / 0;
- const l = u / c;
- return s - l * o + l * i;
- }
- function on(i) {
- const a = [
- -1.716185138865495,
- 24.76565080557592,
- -379.80425647094563,
- 629.3311553128184,
- 866.9662027904133,
- -31451.272968848367,
- -36144.413418691176,
- 66456.14382024054
- ], e = [
- -30.8402300119739,
- 315.35062697960416,
- -1015.1563674902192,
- -3107.771671572311,
- 22538.11842098015,
- 4755.846277527881,
- // eslint-disable-line
- -134659.9598649693,
- -115132.2596755535
- ];
- let t = 0, r = i;
- if (i > 171.6243769536076)
- return 1 / 0;
- if (r <= 0) {
- const f = r % 1 + 36e-17;
- if (f)
- t = (r & 1 ? -1 : 1) * Math.PI / Math.sin(Math.PI * f), r = 1 - r;
- else
- return 1 / 0;
- }
- const n = r;
- let s = 0, o;
- r < 1 ? o = r++ : o = (r -= s = (r | 0) - 1) - 1;
- let u = 0, c = 0;
- for (let f = 0; f < 8; ++f)
- u = (u + a[f]) * o, c = c * o + e[f];
- let l = u / c + 1;
- if (n < r)
- l /= n;
- else if (n > r)
- for (let f = 0; f < s; ++f)
- l *= r, r++;
- return t && (l = t / l), l;
- }
- function am(i, a, e) {
- return i <= 0 ? 0 : La(a, i / e);
- }
- function im(i, a, e) {
- return i < 0 ? 0 : i === 0 && a === 1 ? 1 / e : Math.exp((a - 1) * Math.log(i) - i / e - ct(a) - a * Math.log(e));
- }
- function om(i, a, e) {
- return i <= 0 ? 0 : i >= 1 ? 1 / 0 : e * jo(i, a);
- }
- function ct(i) {
- const a = [
- 76.18009172947146,
- -86.50532032941678,
- 24.01409824083091,
- // eslint-disable-line
- -1.231739572450155,
- 0.001208650973866179,
- -5395239384953e-18
- ];
- let e = i, t = i + 5.5;
- t -= (i + 0.5) * Math.log(t);
- let r = 1.000000000190015;
- for (let n = 0; n < 6; n++)
- r += a[n] / ++e;
- return -t + Math.log(2.5066282746310007 * r / i);
- }
- function La(i, a) {
- if (a < 0 || i <= 0)
- return Number.NaN;
- const e = 1e-30, t = -~(Math.log(i >= 1 ? i : 1 / i) * 8.5 + i * 0.4 + 17), r = ct(i), n = Math.exp(-a + i * Math.log(a) - r);
- let s = i, o = 1 / i, u = o;
- if (a < i + 1) {
- if (n === 0)
- return 0;
- for (let d = 1; d <= t && (o += u *= a / ++s, !(Math.abs(u) < Math.abs(o) * e)); d++)
- ;
- return o * n;
- }
- if (n === 0)
- return 1;
- let c = a + 1 - i, l = 1 / e, f = 1 / c, h = f;
- for (let d = 1; d <= t; d++) {
- const _ = -d * (d - i);
- if (c += 2, f = _ * f + c, Math.abs(f) < e && (f = e), l = c + _ / l, Math.abs(l) < e && (l = e), f = 1 / f, h *= f * l, Math.abs(f * l - 1) < e)
- break;
- }
- return 1 - h * n;
- }
- function jo(i, a) {
- if (i <= 0)
- return 0;
- if (i >= 1)
- return Math.max(100, a + 100 * Math.sqrt(a));
- let e;
- if (a > 1) {
- const o = i < 0.5 ? i : 1 - i, u = Math.sqrt(-2 * Math.log(o));
- e = (2.30753 + u * 0.27061) / (1 + u * (0.99229 + u * 0.04481)) - u, i < 0.5 && (e = -e), e = Math.max(1e-3, a * (1 - 1 / (9 * a) - e / (3 * Math.sqrt(a))) ** 3);
- } else {
- const o = 1 - a * (0.253 + a * 0.12);
- i < o ? e = (i / o) ** (1 / a) : e = 1 - Math.log(1 - (i - o) / (1 - o));
- }
- const t = 1e-8, r = ct(a);
- let n, s;
- for (let o = 0; o < 12; o++) {
- if (e <= 0)
- return 0;
- if (n = La(a, e) - i, a > 1 ? s = Math.exp((a - 1) * (Math.log(a - 1) - 1) - r) * Math.exp(-(e - (a - 1)) + (a - 1) * (Math.log(e) - Math.log(a - 1))) : s = Math.exp(-e + (a - 1) * Math.log(e) - r), s !== 0 && (s = n / s / (1 - 0.5 * Math.min(1, n / s * ((a - 1) / e - 1)))), e -= s, e <= 0 && (e = 0.5 * (e + s)), Math.abs(s) < t * e)
- break;
- }
- return e;
- }
- function um(i, a, e, t) {
- let r = 0;
- for (let n = 0; n <= i; n++)
- r += xa(n, a, e, t);
- return r;
- }
- function xa(i, a, e, t) {
- return a - i > t - e ? 0 : zt(e, i) * zt(t - e, a - i) / zt(t, a);
- }
- function Uo(i, a, e) {
- return i < 0 ? 0 : 0.5 + 0.5 * Zt((Math.log(i) - a) / Math.sqrt(2 * e * e));
- }
- function cm(i, a, e) {
- return i <= 0 ? 0 : Math.exp(-Math.log(i) - 0.5 * Math.log(2 * Math.PI) - Math.log(e) - (Math.log(i) - a) ** 2 / (2 * e * e));
- }
- function lm(i, a, e) {
- return Math.exp(Wn(i, a, e));
- }
- function fm(i, a, e) {
- if (i < 0)
- return 0;
- let t = 0;
- for (let r = 0; r <= i; r++)
- t += ja(r, a, e);
- return t;
- }
- function ja(i, a, e) {
- return i < 0 ? 0 : zt(i + a - 1, a - 1) * e ** a * (1 - e) ** i;
- }
- function kr(i, a, e) {
- return 0.5 * (1 + Zt((i - a) / Math.sqrt(2 * e * e)));
- }
- function vo(i, a, e) {
- return Math.exp(-0.5 * Math.log(2 * Math.PI) - Math.log(e) - (i - a) ** 2 / (2 * e * e));
- }
- function Wn(i, a, e) {
- return -1.4142135623730951 * e * Hh(2 * i) + a;
- }
- function hm(i, a) {
- let e = 0;
- for (let t = 0; t <= i; t++)
- e += To(t, a);
- return e;
- }
- function To(i, a) {
- return Math.exp(-a) * a ** i / cr(i);
- }
- function $r(i, a) {
- const e = 0.5 * Qn(a / (i ** 2 + a), a / 2, 0.5);
- return i < 0 ? e : 1 - e;
- }
- function mm(i, a) {
- const e = (1 + i ** 2 / a) ** (-(a + 1) / 2);
- return 1 / (Math.sqrt(a) * Ma(0.5, a / 2)) * e;
- }
- function qn(i, a) {
- let e = Oa(2 * Math.min(i, 1 - i), 0.5 * a, 0.5);
- return e = Math.sqrt(a * (1 - e) / e), i > 0.5 ? e : -e;
- }
- function Je(i, a, e, t, r) {
- const n = [], s = [];
- let o = !0;
- for (let u = 0; u < e; u++) {
- const c = Math.floor(u / t), l = u % t, f = Math.floor(u / r), h = u % r, d = i.isArray() ? i.get(c, l) : i, _ = a.isArray() ? a.get(f, h) : a;
- if (d.isError())
- return {
- isError: !0,
- errorObject: d,
- array1Values: n,
- array2Values: s,
- noCalculate: o
- };
- if (_.isError())
- return {
- isError: !0,
- errorObject: _,
- array1Values: n,
- array2Values: s,
- noCalculate: o
- };
- if (d.isNull() || _.isNull() || d.isBoolean() || _.isBoolean())
- continue;
- const C = d.getValue(), E = _.getValue();
- !Q(C) || !Q(E) || (n.push(+C), s.push(+E), o = !1);
- }
- return {
- isError: !1,
- errorObject: null,
- array1Values: n,
- array2Values: s,
- noCalculate: o
- };
- }
- function Kn(i, a, e) {
- const t = i.isArray() ? i.getRowCount() : 1, r = i.isArray() ? i.getColumnCount() : 1;
- let n = t, s = r;
- if (a && !a.isNull() && (n = a.isArray() ? a.getRowCount() : 1, s = a.isArray() ? a.getColumnCount() : 1, t === 1 && s !== r || r === 1 && n !== t || t !== 1 && r !== 1 && (n !== t || s !== r)))
- return {
- isError: !0,
- errorObject: g.create(m.REF)
- };
- if (e && !e.isNull()) {
- const o = e.isArray() ? e.getRowCount() : 1, u = e.isArray() ? e.getColumnCount() : 1;
- if (t === 1 && n > 1 && o !== n || r === 1 && s > 1 && u !== s)
- return {
- isError: !0,
- errorObject: g.create(m.REF)
- };
- }
- return {
- isError: !1,
- errorObject: null
- };
- }
- function dt(i) {
- const a = i.isArray() ? i.getRowCount() : 1, e = i.isArray() ? i.getColumnCount() : 1, t = [];
- for (let r = 0; r < a; r++) {
- t[r] = [];
- for (let n = 0; n < e; n++) {
- const s = i.isArray() ? i.get(r, n) : i;
- if (s.isError() || s.isNull() || s.isBoolean() || s.isString())
- return g.create(m.VALUE);
- t[r].push(+s.getValue());
- }
- }
- return t;
- }
- function Xn(i, a) {
- const e = [];
- let t = 1;
- for (let r = 0; r < i; r++) {
- e[r] = [];
- for (let n = 0; n < a; n++)
- e[r].push(t++);
- }
- return e;
- }
- function Zn(i, a, e, t) {
- let r = a;
- t && (r = a.map((o) => Math.log(o)));
- let n, s;
- 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 };
- }
- function gm(i, a) {
- const e = a.length;
- let t = 0, r = 0, n = 0, s = 0;
- for (let l = 0; l < e; l++)
- t += i[l], r += a[l], n += i[l] * i[l], s += i[l] * a[l];
- const u = (e * s - t * r) / (e * n - t * t), c = 1 / e * r - u * (1 / e) * t;
- return {
- slope: u,
- intercept: c
- };
- }
- function dm(i, a) {
- const e = [[...i]], t = [...a];
- let r = e.length, n = e[0].length, s = Math.min(r, n);
- const o = new Array(s).fill(0);
- for (let c = 0; c < s; c++) {
- const l = e[c];
- let f = 0;
- for (let d = 0; d < n; d++)
- f += l[d] ** 2;
- const h = l[c] < 0 ? Math.sqrt(f) : -Math.sqrt(f);
- if (o[c] = h, h !== 0) {
- l[c] -= h;
- for (let d = c + 1; d < r; d++) {
- let _ = 0;
- for (let C = c; C < n; C++)
- _ -= e[d][C] * l[C];
- _ /= h * l[c];
- for (let C = c; C < n; C++)
- e[d][C] -= _ * l[C];
- }
- }
- }
- r = e.length, n = e[0].length, s = Math.min(r, n);
- const u = new Array(r).fill(0);
- for (let c = 0; c < s; c++) {
- const l = e[c];
- let f = 0;
- for (let h = 0; h < n; h++)
- f += t[h] * l[h];
- f /= o[c] * l[c];
- for (let h = 0; h < n; h++)
- t[h] += f * l[h];
- }
- for (let c = o.length - 1; c >= 0; c--) {
- t[c] /= o[c];
- const l = t[c], f = e[c];
- u[c] = l;
- for (let h = 0; h < c; h++)
- t[h] -= l * f[h];
- }
- return {
- slope: u[0],
- intercept: 0
- };
- }
- function zn(i, a, e, t, r) {
- const n = i.length === 1 && i[0].length > 1;
- let s = i;
- r && (s = i.map((C) => C.map((E) => Math.log(E))));
- let o = a, u = e;
- n && (s = mt(s), o = mt(o), u = mt(u)), t && (o = o.map((C) => [...C, 1]));
- const c = mt(o), l = lr(c, o), f = lr(c, s);
- let h = Wh(l);
- if (!h && (h = Xh(l), !h))
- return g.create(m.NA);
- let d = lr(h, f);
- t || d.push([0]), d = mt(d);
- const _ = d[0].pop();
- if (d[0].reverse(), d[0].push(_), r)
- for (let C = 0; C < d[0].length; C++)
- d[0][C] = Math.exp(d[0][C]);
- return {
- coefficients: d,
- Y: s,
- X: o,
- newX: u,
- XTXInverse: h
- };
- }
- class Bo extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 3);
- A(this, "maxParams", 5);
- }
- calculate(e, t, r, n, s) {
- let o = n != null ? n : y.create(0), u = s != null ? s : y.create(1);
- o.isNull() && (o = y.create(0)), u.isNull() && (u = y.create(1));
- const c = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1,
- r.isArray() ? r.getRowCount() : 1,
- o.isArray() ? o.getRowCount() : 1,
- u.isArray() ? u.getRowCount() : 1
- ), l = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1,
- r.isArray() ? r.getColumnCount() : 1,
- o.isArray() ? o.getColumnCount() : 1,
- u.isArray() ? u.getColumnCount() : 1
- ), f = O(c, l, e, g.create(m.NA)), h = O(c, l, t, g.create(m.NA)), d = O(c, l, r, g.create(m.NA)), _ = O(c, l, o, g.create(m.NA)), C = O(c, l, u, g.create(m.NA)), E = f.mapValue((b, R, p) => {
- const N = h.get(R, p), M = d.get(R, p), w = _.get(R, p), D = C.get(R, p);
- return this._handleSignleObject(b, N, M, w, D);
- });
- return c === 1 && l === 1 ? E.get(0, 0) : E;
- }
- _handleSignleObject(e, t, r, n, s) {
- if (e.isError())
- return e;
- if (t.isError())
- return t;
- if (r.isError())
- return r;
- if (n.isError())
- return n;
- if (s.isError())
- return s;
- const { isError: o, errorObject: u, variants: c } = I(e, t, r, n, s);
- if (o)
- return u;
- const [l, f, h, d, _] = c, C = +l.getValue(), E = +f.getValue(), b = +h.getValue(), R = +d.getValue(), p = +_.getValue();
- if (E <= 0 || b <= 0 || C <= 0 || C >= 1 || R >= p)
- return g.create(m.NUM);
- const N = Oa(C, E, b) * (p - R) + R;
- return y.create(N);
- }
- }
- class Io extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 4);
- A(this, "maxParams", 4);
- }
- calculate(e, t, r, n) {
- const s = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1,
- r.isArray() ? r.getRowCount() : 1,
- n.isArray() ? n.getRowCount() : 1
- ), o = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1,
- r.isArray() ? r.getColumnCount() : 1,
- n.isArray() ? n.getColumnCount() : 1
- ), u = O(s, o, e, g.create(m.NA)), c = O(s, o, t, g.create(m.NA)), l = O(s, o, r, g.create(m.NA)), f = O(s, o, n, g.create(m.NA)), h = u.mapValue((d, _, C) => {
- const E = c.get(_, C), b = l.get(_, C), R = f.get(_, C);
- return d.isError() ? d : E.isError() ? E : b.isError() ? b : R.isError() ? R : this._handleSignleObject(d, E, b, R);
- });
- return s === 1 && o === 1 ? h.get(0, 0) : h;
- }
- _handleSignleObject(e, t, r, n) {
- const { isError: s, errorObject: o, variants: u } = I(e, t, r, n);
- if (s)
- return o;
- const [c, l, f, h] = u, d = Math.floor(+c.getValue()), _ = Math.floor(+l.getValue()), C = +f.getValue(), E = +h.getValue();
- if (d < 0 || d > _ || C < 0 || C > 1)
- return g.create(m.NUM);
- let b;
- return E ? b = So(d, _, C) : b = Da(d, _, C), y.create(b);
- }
- }
- class Fo extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 3);
- A(this, "maxParams", 3);
- }
- calculate(e, t, r) {
- const n = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1,
- r.isArray() ? r.getRowCount() : 1
- ), s = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1,
- r.isArray() ? r.getColumnCount() : 1
- ), o = O(n, s, e, g.create(m.NA)), u = O(n, s, t, g.create(m.NA)), c = O(n, s, r, g.create(m.NA)), l = o.mapValue((f, h, d) => {
- const _ = u.get(h, d), C = c.get(h, d);
- return f.isError() ? f : _.isError() ? _ : C.isError() ? C : this._handleSignleObject(f, _, C);
- });
- return n === 1 && s === 1 ? l.get(0, 0) : l;
- }
- _handleSignleObject(e, t, r) {
- const { isError: n, errorObject: s, variants: o } = I(e, t, r);
- if (n)
- return s;
- const [u, c, l] = o, f = Math.floor(+u.getValue()), h = +c.getValue(), d = +l.getValue();
- if (f < 0 || h <= 0 || h >= 1 || d <= 0 || d >= 1)
- return g.create(m.NUM);
- let _ = 0;
- for (; _ <= f && !(So(_, f, h) >= d); )
- _++;
- return y.create(_);
- }
- }
- class ko extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- const r = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1
- ), n = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1
- ), s = O(r, n, e, g.create(m.NA)), o = O(r, n, t, g.create(m.NA)), u = s.mapValue((c, l, f) => {
- const h = o.get(l, f);
- return c.isError() ? c : h.isError() ? h : this._handleSignleObject(c, h);
- });
- return r === 1 && n === 1 ? u.get(0, 0) : u;
- }
- _handleSignleObject(e, t) {
- const { isError: r, errorObject: n, variants: s } = I(e, t);
- if (r)
- return n;
- const [o, u] = s, c = +o.getValue(), l = Math.floor(+u.getValue());
- if (c < 0 || l < 1 || l > 10 ** 10)
- return g.create(m.NUM);
- const f = 1 - Sa(c, l);
- return y.create(f);
- }
- }
- class $o extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- const r = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1
- ), n = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1
- ), s = O(r, n, e, g.create(m.NA)), o = O(r, n, t, g.create(m.NA)), u = s.mapValue((c, l, f) => {
- const h = o.get(l, f);
- return c.isError() ? c : h.isError() ? h : this._handleSignleObject(c, h);
- });
- return r === 1 && n === 1 ? u.get(0, 0) : u;
- }
- _handleSignleObject(e, t) {
- const { isError: r, errorObject: n, variants: s } = I(e, t);
- if (r)
- return n;
- const [o, u] = s, c = +o.getValue(), l = Math.floor(+u.getValue());
- if (c < 0 || c > 1 || l < 1 || l > 10 ** 10)
- return g.create(m.NUM);
- const f = Po(1 - c, l);
- return Number.isNaN(f) || !Number.isFinite(f) ? g.create(m.NUM) : y.create(f);
- }
- }
- class Yo extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- 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;
- let u = e;
- if (e.isArray() && r === 1 && n === 1 && (u = e.get(0, 0)), u.isError())
- return u;
- let c = t;
- if (t.isArray() && s === 1 && o === 1 && (c = t.get(0, 0)), c.isError())
- return c;
- if (r * n === 1 || s * o === 1)
- return u.isNull() || c.isNull() ? g.create(m.VALUE) : g.create(m.NA);
- if (r * n !== s * o)
- return g.create(m.NA);
- const {
- isError: l,
- errorObject: f,
- array1Values: h,
- array2Values: d,
- noCalculate: _
- } = Je(
- e,
- t,
- r * n,
- n,
- o
- );
- return l ? f : _ ? g.create(m.DIV_BY_ZERO) : this._getResult(h, d, r, n);
- }
- _getResult(e, t, r, n) {
- let s = 0;
- for (let c = 0; c < e.length; c++) {
- if (t[c] === 0)
- return g.create(m.DIV_BY_ZERO);
- s += (e[c] - t[c]) ** 2 / t[c];
- }
- let o = (r - 1) * (n - 1);
- r === 1 ? o = n - 1 : n === 1 && (o = r - 1);
- const u = 1 - Sa(s, o);
- return y.create(u);
- }
- }
- class Ho extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 3);
- A(this, "maxParams", 3);
- }
- calculate(e, t, r) {
- const n = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1,
- r.isArray() ? r.getRowCount() : 1
- ), s = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1,
- r.isArray() ? r.getColumnCount() : 1
- ), o = O(n, s, e, g.create(m.NA)), u = O(n, s, t, g.create(m.NA)), c = O(n, s, r, g.create(m.NA)), l = o.mapValue((f, h, d) => {
- const _ = u.get(h, d), C = c.get(h, d);
- if (f.isError())
- return f;
- if (_.isError())
- return _;
- if (C.isError())
- return C;
- const { isError: E, errorObject: b, variants: R } = I(f, _, C);
- if (E)
- return b;
- const [p, N, M] = R, w = +p.getValue(), D = +N.getValue(), S = Math.floor(+M.getValue());
- if (w <= 0 || w >= 1 || D <= 0 || S < 1)
- return g.create(m.NUM);
- const P = Math.abs(Wn(w / 2, 0, 1) * D / Math.sqrt(S));
- return y.create(P);
- });
- return n === 1 && s === 1 ? l.get(0, 0) : l;
- }
- }
- class Go extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- 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;
- let u = e;
- if (e.isArray() && r === 1 && n === 1 && (u = e.get(0, 0)), u.isError())
- return u;
- let c = t;
- if (t.isArray() && s === 1 && o === 1 && (c = t.get(0, 0)), c.isError())
- return c;
- if ((r * n === 1 || s * o === 1) && (u.isNull() || c.isNull()))
- return g.create(m.VALUE);
- if (r * n !== s * o)
- return g.create(m.NA);
- const {
- isError: l,
- errorObject: f,
- array1Values: h,
- array2Values: d,
- noCalculate: _
- } = Je(
- e,
- t,
- r * n,
- n,
- o
- );
- return l ? f : _ ? g.create(m.DIV_BY_ZERO) : this._getResult(h, d);
- }
- _getResult(e, t) {
- if (e.length === 0)
- return g.create(m.DIV_BY_ZERO);
- const r = e.length;
- let n = 0, s = 0;
- for (let l = 0; l < r; l++)
- n += e[l], s += t[l];
- const o = n / r, u = s / r;
- let c = 0;
- for (let l = 0; l < r; l++) {
- const f = e[l] - o, h = t[l] - u;
- c += f * h;
- }
- return y.create(c / r);
- }
- }
- class Qo extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 3);
- A(this, "maxParams", 3);
- }
- calculate(e, t, r) {
- const n = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1,
- r.isArray() ? r.getRowCount() : 1
- ), s = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1,
- r.isArray() ? r.getColumnCount() : 1
- ), o = O(n, s, e, g.create(m.NA)), u = O(n, s, t, g.create(m.NA)), c = O(n, s, r, g.create(m.NA)), l = o.mapValue((f, h, d) => {
- const _ = u.get(h, d), C = c.get(h, d);
- return f.isError() ? f : _.isError() ? _ : C.isError() ? C : this._handleSignleObject(f, _, C);
- });
- return n === 1 && s === 1 ? l.get(0, 0) : l;
- }
- _handleSignleObject(e, t, r) {
- const { isError: n, errorObject: s, variants: o } = I(e, t, r);
- if (n)
- return s;
- const [u, c, l] = o, f = +u.getValue(), h = +c.getValue(), d = +l.getValue();
- if (f < 0 || h <= 0)
- return g.create(m.NUM);
- let _;
- return d ? _ = nm(f, h) : _ = sm(f, h), y.create(_);
- }
- }
- class Wo extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 3);
- A(this, "maxParams", 3);
- }
- calculate(e, t, r) {
- const n = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1,
- r.isArray() ? r.getRowCount() : 1
- ), s = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1,
- r.isArray() ? r.getColumnCount() : 1
- ), o = O(n, s, e, g.create(m.NA)), u = O(n, s, t, g.create(m.NA)), c = O(n, s, r, g.create(m.NA)), l = o.mapValue((f, h, d) => {
- const _ = u.get(h, d), C = c.get(h, d);
- return f.isError() ? f : _.isError() ? _ : C.isError() ? C : this._handleSignleObject(f, _, C);
- });
- return n === 1 && s === 1 ? l.get(0, 0) : l;
- }
- _handleSignleObject(e, t, r) {
- const { isError: n, errorObject: s, variants: o } = I(e, t, r);
- if (n)
- return s;
- const [u, c, l] = o, f = +u.getValue(), h = Math.floor(+c.getValue()), d = Math.floor(+l.getValue());
- if (f < 0 || h < 1 || h > 10 ** 10 || d < 1 || d > 10 ** 10)
- return g.create(m.NUM);
- const _ = 1 - Pa(f, h, d);
- return y.create(_);
- }
- }
- class qo extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 3);
- A(this, "maxParams", 3);
- }
- calculate(e, t, r) {
- const n = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1,
- r.isArray() ? r.getRowCount() : 1
- ), s = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1,
- r.isArray() ? r.getColumnCount() : 1
- ), o = O(n, s, e, g.create(m.NA)), u = O(n, s, t, g.create(m.NA)), c = O(n, s, r, g.create(m.NA)), l = o.mapValue((f, h, d) => {
- const _ = u.get(h, d), C = c.get(h, d);
- return f.isError() ? f : _.isError() ? _ : C.isError() ? C : this._handleSignleObject(f, _, C);
- });
- return n === 1 && s === 1 ? l.get(0, 0) : l;
- }
- _handleSignleObject(e, t, r) {
- const { isError: n, errorObject: s, variants: o } = I(e, t, r);
- if (n)
- return s;
- const [u, c, l] = o, f = +u.getValue(), h = Math.floor(+c.getValue()), d = Math.floor(+l.getValue());
- if (f < 0 || f > 1 || h < 1 || h > 10 ** 10 || d < 1 || d > 10 ** 10)
- return g.create(m.NUM);
- const _ = Lo(1 - f, h, d);
- return Number.isNaN(_) || !Number.isFinite(_) ? g.create(m.NUM) : y.create(_);
- }
- }
- class Ko extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- const {
- isError: r,
- errorObject: n,
- variance: s,
- ns1: o
- } = this._getValues(e);
- if (r)
- return n;
- const {
- isError: u,
- errorObject: c,
- variance: l,
- ns1: f
- } = this._getValues(t);
- if (u)
- return c;
- let h = 2 * (1 - Pa(s / l, o, f));
- return h > 1 && (h = 2 - h), y.create(h);
- }
- // eslint-disable-next-line
- _getValues(e) {
- let t = 0, r = 0;
- const n = e.isArray() ? e.getRowCount() : 1, s = e.isArray() ? e.getColumnCount() : 1;
- if (n === 1 && s === 1) {
- const f = e.isArray() ? e.get(0, 0) : e;
- return f.isError() ? {
- isError: !0,
- errorObject: f,
- variance: t,
- ns1: r
- } : f.isNull() ? {
- isError: !0,
- errorObject: g.create(m.VALUE),
- variance: t,
- ns1: r
- } : {
- isError: !0,
- errorObject: g.create(m.DIV_BY_ZERO),
- variance: t,
- ns1: r
- };
- }
- const o = [];
- let u = 0;
- for (let f = 0; f < n; f++)
- for (let h = 0; h < s; h++) {
- const d = e.isArray() ? e.get(f, h) : e;
- if (d.isError())
- return {
- isError: !0,
- errorObject: d,
- variance: t,
- ns1: r
- };
- if (d.isNull() || d.isBoolean())
- continue;
- const _ = d.getValue();
- Q(_) && (o.push(+_), u += +_);
- }
- if (o.length <= 1)
- return {
- isError: !0,
- errorObject: g.create(m.DIV_BY_ZERO),
- variance: t,
- ns1: r
- };
- const c = u / o.length;
- let l = 0;
- for (let f = 0; f < o.length; f++)
- l += (o[f] - c) ** 2;
- return r = o.length - 1, t = l / r, t === 0 ? {
- isError: !0,
- errorObject: g.create(m.DIV_BY_ZERO),
- variance: t,
- ns1: r
- } : {
- isError: !1,
- errorObject: null,
- variance: t,
- ns1: r
- };
- }
- }
- class Xo extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 4);
- A(this, "maxParams", 4);
- }
- calculate(e, t, r, n) {
- const s = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1,
- r.isArray() ? r.getRowCount() : 1,
- n.isArray() ? n.getRowCount() : 1
- ), o = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1,
- r.isArray() ? r.getColumnCount() : 1,
- n.isArray() ? n.getColumnCount() : 1
- ), u = O(s, o, e, g.create(m.NA)), c = O(s, o, t, g.create(m.NA)), l = O(s, o, r, g.create(m.NA)), f = O(s, o, n, g.create(m.NA)), h = u.mapValue((d, _, C) => {
- const E = c.get(_, C), b = l.get(_, C), R = f.get(_, C);
- return d.isError() ? d : E.isError() ? E : b.isError() ? b : R.isError() ? R : this._handleSignleObject(d, E, b, R);
- });
- return s === 1 && o === 1 ? h.get(0, 0) : h;
- }
- _handleSignleObject(e, t, r, n) {
- const { isError: s, errorObject: o, variants: u } = I(e, t, r, n);
- if (s)
- return o;
- const [c, l, f, h] = u, d = +c.getValue(), _ = +l.getValue(), C = +f.getValue(), E = +h.getValue();
- if (d < 0 || _ <= 0 || C <= 0)
- return g.create(m.NUM);
- let b;
- return E ? b = am(d, _, C) : b = im(d, _, C), y.create(b);
- }
- }
- class Zo extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 3);
- A(this, "maxParams", 3);
- }
- calculate(e, t, r) {
- const n = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1,
- r.isArray() ? r.getRowCount() : 1
- ), s = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1,
- r.isArray() ? r.getColumnCount() : 1
- ), o = O(n, s, e, g.create(m.NA)), u = O(n, s, t, g.create(m.NA)), c = O(n, s, r, g.create(m.NA)), l = o.mapValue((f, h, d) => {
- const _ = u.get(h, d), C = c.get(h, d);
- return f.isError() ? f : _.isError() ? _ : C.isError() ? C : this._handleSignleObject(f, _, C);
- });
- return n === 1 && s === 1 ? l.get(0, 0) : l;
- }
- _handleSignleObject(e, t, r) {
- const { isError: n, errorObject: s, variants: o } = I(e, t, r);
- if (n)
- return s;
- const [u, c, l] = o, f = +u.getValue(), h = +c.getValue(), d = +l.getValue();
- if (f < 0 || f > 1 || h <= 0 || d <= 0)
- return g.create(m.NUM);
- const _ = om(f, h, d);
- return Number.isNaN(_) || !Number.isFinite(_) ? g.create(m.NUM) : y.create(_);
- }
- }
- class zo extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 3);
- A(this, "maxParams", 3);
- }
- calculate(e, t, r) {
- const n = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1,
- r.isArray() ? r.getRowCount() : 1
- ), s = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1,
- r.isArray() ? r.getColumnCount() : 1
- ), o = O(n, s, e, g.create(m.NA)), u = O(n, s, t, g.create(m.NA)), c = O(n, s, r, g.create(m.NA)), l = o.mapValue((f, h, d) => {
- const _ = u.get(h, d), C = c.get(h, d);
- return f.isError() ? f : _.isError() ? _ : C.isError() ? C : this._handleSignleObject(f, _, C);
- });
- return n === 1 && s === 1 ? l.get(0, 0) : l;
- }
- _handleSignleObject(e, t, r) {
- const { isError: n, errorObject: s, variants: o } = I(e, t, r);
- if (n)
- return s;
- const [u, c, l] = o, f = +u.getValue(), h = +c.getValue(), d = +l.getValue();
- if (f <= 0 || f >= 1 || d <= 0)
- return g.create(m.NUM);
- const _ = lm(f, h, d);
- return Number.isNaN(_) || !Number.isFinite(_) ? g.create(m.NUM) : y.create(_);
- }
- }
- class Jo extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 255);
- }
- calculate(...e) {
- const t = {};
- let r = 0, n = 1;
- for (let s = 0; s < e.length; s++) {
- const o = e[s];
- if (o.isError())
- return o;
- if (o.isString()) {
- const l = o.convertToNumberObjectValue();
- if (l.isError())
- return l;
- }
- const u = o.isArray() ? o.getRowCount() : 1, c = o.isArray() ? o.getColumnCount() : 1;
- for (let l = 0; l < u; l++)
- for (let f = 0; f < c; f++) {
- const h = o.isArray() ? o.get(l, f) : o;
- if (h.isError())
- return h;
- if (h.isNull() || h.isBoolean() || h.isString())
- continue;
- const d = h.getValue();
- Q(d) && (t[+d] ? (t[+d].count++, t[+d].count > n && (n = t[+d].count)) : t[+d] = { count: 1, order: r++ });
- }
- }
- return r === 0 || n === 1 ? new g(m.NA) : this._getResult(t, n);
- }
- _getResult(e, t) {
- const r = Object.entries(e).filter(([n, { count: s }]) => s === t).sort((n, s) => n[1].order - s[1].order).map(([n]) => +n);
- return y.create(r[0]);
- }
- }
- class eu extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 4);
- A(this, "maxParams", 4);
- }
- calculate(e, t, r, n) {
- const s = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1,
- r.isArray() ? r.getRowCount() : 1,
- n.isArray() ? n.getRowCount() : 1
- ), o = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1,
- r.isArray() ? r.getColumnCount() : 1,
- n.isArray() ? n.getColumnCount() : 1
- ), u = O(s, o, e, g.create(m.NA)), c = O(s, o, t, g.create(m.NA)), l = O(s, o, r, g.create(m.NA)), f = O(s, o, n, g.create(m.NA)), h = u.mapValue((d, _, C) => {
- const E = c.get(_, C), b = l.get(_, C), R = f.get(_, C);
- return d.isError() ? d : E.isError() ? E : b.isError() ? b : R.isError() ? R : this._handleSignleObject(d, E, b, R);
- });
- return s === 1 && o === 1 ? h.get(0, 0) : h;
- }
- _handleSignleObject(e, t, r, n) {
- const { isError: s, errorObject: o, variants: u } = I(e, t, r, n);
- if (s)
- return o;
- const [c, l, f, h] = u, d = +c.getValue(), _ = +l.getValue(), C = +f.getValue(), E = +h.getValue();
- if (C <= 0)
- return g.create(m.NUM);
- let b;
- return E ? b = kr(d, _, C) : b = vo(d, _, C), y.create(b);
- }
- }
- class tu extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 3);
- A(this, "maxParams", 3);
- }
- calculate(e, t, r) {
- const n = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1,
- r.isArray() ? r.getRowCount() : 1
- ), s = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1,
- r.isArray() ? r.getColumnCount() : 1
- ), o = O(n, s, e, g.create(m.NA)), u = O(n, s, t, g.create(m.NA)), c = O(n, s, r, g.create(m.NA)), l = o.mapValue((f, h, d) => {
- const _ = u.get(h, d), C = c.get(h, d);
- return f.isError() ? f : _.isError() ? _ : C.isError() ? C : this._handleSignleObject(f, _, C);
- });
- return n === 1 && s === 1 ? l.get(0, 0) : l;
- }
- _handleSignleObject(e, t, r) {
- const { isError: n, errorObject: s, variants: o } = I(e, t, r);
- if (n)
- return s;
- const [u, c, l] = o, f = +u.getValue(), h = +c.getValue(), d = +l.getValue();
- if (f <= 0 || f >= 1 || d <= 0)
- return g.create(m.NUM);
- const _ = Wn(f, h, d);
- return y.create(_);
- }
- }
- class ru extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- if (e.isArray()) {
- const t = e.mapValue((r) => this._handleSignleObject(r));
- return e.getRowCount() === 1 && e.getColumnCount() === 1 ? t.get(0, 0) : t;
- }
- return this._handleSignleObject(e);
- }
- _handleSignleObject(e) {
- const { isError: t, errorObject: r, variants: n } = I(e);
- if (t)
- return r;
- const [s] = n, o = +s.getValue();
- if (o <= 0 || o >= 1)
- return g.create(m.NUM);
- const u = Wn(o, 0, 1);
- return y.create(u);
- }
- }
- class nu extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- const r = this._getValues(e);
- if (t.isArray()) {
- const n = t.mapValue((s) => this._handleSingleObject(r, s));
- return n.getRowCount() === 1 && n.getColumnCount() === 1 ? n.get(0, 0) : n;
- }
- return this._handleSingleObject(r, t);
- }
- _handleSingleObject(e, t) {
- if (e instanceof g)
- return e;
- const { isError: r, errorObject: n, variants: s } = I(t);
- if (r)
- return n;
- const [o] = s, u = +o.getValue(), c = e.length;
- if (u < 0 || u > 1)
- return g.create(m.NUM);
- const l = u * (c - 1), f = Math.floor(l), h = l - f;
- if (h === 0)
- return y.create(e[f]);
- const d = e[f] + h * (e[f + 1] - e[f]);
- return y.create(d);
- }
- _getValues(e) {
- const t = e.isArray() ? e.getRowCount() : 1, r = e.isArray() ? e.getColumnCount() : 1, n = [];
- for (let s = 0; s < t; s++)
- for (let o = 0; o < r; o++) {
- const u = e.isArray() ? e.get(s, o) : e;
- if (u.isError())
- return u;
- if (u.isNull() || u.isBoolean() || u.isString())
- continue;
- const c = u.getValue();
- Q(c) && n.push(+c);
- }
- return n.length === 0 ? g.create(m.NUM) : n.sort((s, o) => s - o);
- }
- }
- class su extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 3);
- }
- calculate(e, t, r) {
- const n = this._getValues(e);
- let s = r != null ? r : y.create(3);
- s.isNull() && (s = y.create(3));
- const o = Math.max(
- t.isArray() ? t.getRowCount() : 1,
- s.isArray() ? s.getRowCount() : 1
- ), u = Math.max(
- t.isArray() ? t.getColumnCount() : 1,
- s.isArray() ? s.getColumnCount() : 1
- ), c = O(o, u, t, g.create(m.NA)), l = O(o, u, s, g.create(m.NA)), f = c.mapValue((h, d, _) => {
- const C = l.get(d, _);
- return h.isError() ? h : C.isError() ? C : this._handleSingleObject(n, h, C);
- });
- return o === 1 && u === 1 ? f.get(0, 0) : f;
- }
- _handleSingleObject(e, t, r) {
- if (e instanceof g)
- return e;
- const { isError: n, errorObject: s, variants: o } = I(t, r);
- if (n)
- return s;
- const [u, c] = o, l = +u.getValue(), f = Math.floor(+c.getValue()), h = e.length;
- if (h === 0 || l < e[0] || l > e[h - 1])
- return g.create(m.NA);
- if (h === 1)
- return l === e[0] ? y.create(1) : g.create(m.NA);
- let d = 0, _ = !1, C = 0;
- for (; !_ && C < h; )
- l === e[C] ? (d = C / (h - 1), _ = !0) : l > e[C] && C + 1 < h && l < e[C + 1] && (d = (C + (l - e[C]) / (e[C + 1] - e[C])) / (h - 1), _ = !0), C++;
- return _ ? f < 1 ? g.create(m.NUM) : (d = We(d, f), y.create(d)) : g.create(m.NA);
- }
- _getValues(e) {
- const t = e.isArray() ? e.getRowCount() : 1, r = e.isArray() ? e.getColumnCount() : 1, n = [];
- for (let s = 0; s < t; s++)
- for (let o = 0; o < r; o++) {
- const u = e.isArray() ? e.get(s, o) : e;
- if (u.isError())
- return u;
- if (u.isNull() || u.isBoolean())
- continue;
- const c = u.getValue();
- Q(c) && n.push(+c);
- }
- return n.sort((s, o) => s - o);
- }
- }
- class au extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 3);
- A(this, "maxParams", 3);
- }
- calculate(e, t, r) {
- const n = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1,
- r.isArray() ? r.getRowCount() : 1
- ), s = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1,
- r.isArray() ? r.getColumnCount() : 1
- ), o = O(n, s, e, g.create(m.NA)), u = O(n, s, t, g.create(m.NA)), c = O(n, s, r, g.create(m.NA)), l = o.mapValue((f, h, d) => {
- const _ = u.get(h, d), C = c.get(h, d);
- return f.isError() ? f : _.isError() ? _ : C.isError() ? C : this._handleSignleObject(f, _, C);
- });
- return n === 1 && s === 1 ? l.get(0, 0) : l;
- }
- _handleSignleObject(e, t, r) {
- const { isError: n, errorObject: s, variants: o } = I(e, t, r);
- if (n)
- return s;
- const [u, c, l] = o, f = Math.floor(+u.getValue()), h = +c.getValue(), d = +l.getValue();
- if (f < 0 || h < 0)
- return g.create(m.NUM);
- let _;
- return d ? _ = hm(f, h) : _ = To(f, h), y.create(_);
- }
- }
- class iu extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- const r = this._getValues(e);
- if (t.isArray()) {
- const n = t.mapValue((s) => this._handleSingleObject(r, s));
- return n.getRowCount() === 1 && n.getColumnCount() === 1 ? n.get(0, 0) : n;
- }
- return this._handleSingleObject(r, t);
- }
- _handleSingleObject(e, t) {
- if (e instanceof g)
- return e;
- const { isError: r, errorObject: n, variants: s } = I(t);
- if (r)
- return n;
- const [o] = s, u = Math.floor(+o.getValue());
- if (u < 0 || u > 4)
- return g.create(m.NUM);
- const c = u / 4, l = e.length, f = c * (l - 1), h = Math.floor(f), d = f - h;
- if (d === 0)
- return y.create(e[h]);
- const _ = e[h] + d * (e[h + 1] - e[h]);
- return y.create(_);
- }
- _getValues(e) {
- const t = e.isArray() ? e.getRowCount() : 1, r = e.isArray() ? e.getColumnCount() : 1, n = [];
- for (let s = 0; s < t; s++)
- for (let o = 0; o < r; o++) {
- const u = e.isArray() ? e.get(s, o) : e;
- if (u.isError())
- return u;
- if (u.isNull() || u.isBoolean())
- continue;
- const c = u.getValue();
- Q(c) && n.push(+c);
- }
- return n.length === 0 ? g.create(m.NUM) : n.sort((s, o) => s - o);
- }
- }
- class ou extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 255);
- }
- calculate(...e) {
- const t = this.flattenArray(e);
- return t.isError() ? t : t.std();
- }
- }
- class uu extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 255);
- }
- calculate(...e) {
- const t = this.flattenArray(e);
- return t.isError() ? t : t.std(1);
- }
- }
- class cu extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- const r = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1
- ), n = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1
- ), s = O(r, n, e, g.create(m.NA)), o = O(r, n, t, g.create(m.NA)), u = s.mapValue((c, l, f) => {
- const h = o.get(l, f);
- return c.isError() ? c : h.isError() ? h : this._handleSignleObject(c, h);
- });
- return r === 1 && n === 1 ? u.get(0, 0) : u;
- }
- _handleSignleObject(e, t) {
- const { isError: r, errorObject: n, variants: s } = I(e, t);
- if (r)
- return n;
- const [o, u] = s, c = +o.getValue(), l = Math.floor(+u.getValue());
- if (c <= 0 || c > 1 || l < 1 || l > 10 ** 10)
- return g.create(m.NUM);
- const f = Math.abs(qn(c / 2, l));
- return Number.isNaN(f) || !Number.isFinite(f) ? g.create(m.NUM) : y.create(f);
- }
- }
- class lu extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 4);
- A(this, "maxParams", 4);
- }
- // eslint-disable-next-line
- calculate(e, t, r, n) {
- const { isError: s, errorObject: o, array1Values: u, array2Values: c } = this._handleArray1AndArray2(e, t), l = this._getArrayValues(e), f = this._getArrayValues(t), h = Math.max(
- r.isArray() ? r.getRowCount() : 1,
- n.isArray() ? n.getRowCount() : 1
- ), d = Math.max(
- r.isArray() ? r.getColumnCount() : 1,
- n.isArray() ? n.getColumnCount() : 1
- ), _ = O(h, d, r, g.create(m.NA)), C = O(h, d, n, g.create(m.NA)), E = _.mapValue((b, R, p) => {
- const N = C.get(R, p);
- if (e.isError())
- return e;
- if (t.isError())
- return t;
- if (b.isError())
- return b;
- if (N.isError())
- return N;
- const { isError: M, errorObject: w, variants: D } = I(b, N);
- if (M)
- return w;
- const [S, P] = D, U = Math.floor(+S.getValue()), x = Math.floor(+P.getValue());
- return ![1, 2].includes(U) || ![1, 2, 3].includes(x) ? g.create(m.NUM) : x === 1 && s ? o : x !== 1 && l instanceof g ? l : x !== 1 && f instanceof g ? f : this._handleSignleObject(
- x === 1 ? u : l,
- x === 1 ? c : f,
- U,
- x
- );
- });
- return h === 1 && d === 1 ? E.get(0, 0) : E;
- }
- _handleSignleObject(e, t, r, n) {
- if (e.length < 2 || t.length < 2)
- return g.create(m.DIV_BY_ZERO);
- const { isError: s, errorObject: o, x: u, degFreedom: c } = this._getTDistParamByArrayValues(e, t, n);
- if (s)
- return o;
- let l = $r(-u, c);
- return r === 2 && (l *= 2), Number.isNaN(l) || !Number.isFinite(l) ? g.create(m.NUM) : y.create(l);
- }
- _getArrayValues(e) {
- const t = e.isArray() ? e.getRowCount() : 1, r = e.isArray() ? e.getColumnCount() : 1, n = [];
- for (let s = 0; s < t; s++)
- for (let o = 0; o < r; o++) {
- const u = e.isArray() ? e.get(s, o) : e;
- if (u.isError())
- return u;
- if (u.isNull()) {
- if (t * r === 1)
- return g.create(m.VALUE);
- continue;
- }
- u.isBoolean() || u.isString() || n.push(+u.getValue());
- }
- return n;
- }
- // eslint-disable-next-line
- _handleArray1AndArray2(e, t) {
- 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;
- let u = e;
- if (e.isArray() && r === 1 && n === 1 && (u = e.get(0, 0)), u.isError())
- return {
- isError: !0,
- errorObject: u,
- array1Values: [],
- array2Values: []
- };
- let c = t;
- if (t.isArray() && s === 1 && o === 1 && (c = t.get(0, 0)), c.isError())
- return {
- isError: !0,
- errorObject: c,
- array1Values: [],
- array2Values: []
- };
- if ((r * n === 1 || s * o === 1) && (u.isNull() || c.isNull()))
- return {
- isError: !0,
- errorObject: g.create(m.VALUE),
- array1Values: [],
- array2Values: []
- };
- if (r * n !== s * o)
- return {
- isError: !0,
- errorObject: g.create(m.NA),
- array1Values: [],
- array2Values: []
- };
- const {
- isError: l,
- errorObject: f,
- array1Values: h,
- array2Values: d,
- noCalculate: _
- } = Je(
- e,
- t,
- r * n,
- n,
- o
- );
- return l ? {
- isError: !0,
- errorObject: f,
- array1Values: [],
- array2Values: []
- } : _ || h.length < 2 ? {
- isError: !0,
- errorObject: g.create(m.DIV_BY_ZERO),
- array1Values: [],
- array2Values: []
- } : {
- isError: !1,
- errorObject: null,
- array1Values: h,
- array2Values: d
- };
- }
- _getTDistParamByArrayValues(e, t, r) {
- return r === 1 ? this._getTDistParamByType1(e, t) : r === 2 ? this._getTDistParamByType2(e, t) : this._getTDistParamByType3(e, t);
- }
- _getTDistParamByType1(e, t) {
- const r = e.length;
- let n = 0, s = 0, o = 0;
- for (let h = 0; h < r; h++)
- n += e[h], s += t[h], o += (e[h] - t[h]) ** 2;
- const u = n - s, c = r * o - u ** 2, l = r - 1;
- return c === 0 ? {
- isError: !0,
- errorObject: g.create(m.DIV_BY_ZERO),
- x: 0,
- degFreedom: l
- } : {
- isError: !1,
- errorObject: null,
- x: Math.abs(u) * Math.sqrt(l / c),
- degFreedom: l
- };
- }
- _getTDistParamByType2(e, t) {
- const r = e.length, n = t.length;
- let s = 0, o = 0;
- for (let E = 0; E < r; E++)
- s += e[E], o += e[E] ** 2;
- let u = 0, c = 0;
- for (let E = 0; E < n; E++)
- u += t[E], c += t[E] ** 2;
- const l = o - s ** 2 / r, f = c - u ** 2 / n, h = Math.sqrt(l + f);
- if (h === 0)
- return {
- isError: !0,
- errorObject: g.create(m.DIV_BY_ZERO),
- x: 0,
- degFreedom: 0
- };
- const d = r - 1 + n - 1, _ = Math.sqrt(r * n * d / (r + n));
- return {
- isError: !1,
- errorObject: null,
- x: Math.abs(s / r - u / n) / h * _,
- degFreedom: d
- };
- }
- _getTDistParamByType3(e, t) {
- const r = e.length, n = t.length;
- let s = 0, o = 0;
- for (let C = 0; C < r; C++)
- s += e[C], o += e[C] ** 2;
- let u = 0, c = 0;
- for (let C = 0; C < n; C++)
- u += t[C], c += t[C] ** 2;
- const l = (o - s ** 2 / r) / (r * (r - 1)), f = (c - u ** 2 / n) / (n * (n - 1));
- if (l + f === 0)
- return {
- isError: !0,
- errorObject: g.create(m.DIV_BY_ZERO),
- x: 0,
- degFreedom: 0
- };
- const h = l / (l + f), d = Math.abs(s / r - u / n) / Math.sqrt(l + f), _ = 1 / (h ** 2 / (r - 1) + (1 - h) ** 2 / (n - 1));
- return {
- isError: !1,
- errorObject: null,
- x: d,
- degFreedom: _
- };
- }
- }
- class fu extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 255);
- }
- calculate(...e) {
- const t = this.flattenArray(e);
- return t.isError() ? t : t.var();
- }
- }
- class hu extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 255);
- }
- calculate(...e) {
- const t = this.flattenArray(e);
- return t.isError() ? t : t.var(1);
- }
- }
- class mu extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 4);
- A(this, "maxParams", 4);
- }
- calculate(e, t, r, n) {
- const s = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1,
- r.isArray() ? r.getRowCount() : 1,
- n.isArray() ? n.getRowCount() : 1
- ), o = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1,
- r.isArray() ? r.getColumnCount() : 1,
- n.isArray() ? n.getColumnCount() : 1
- ), u = O(s, o, e, g.create(m.NA)), c = O(s, o, t, g.create(m.NA)), l = O(s, o, r, g.create(m.NA)), f = O(s, o, n, g.create(m.NA)), h = u.mapValue((d, _, C) => {
- const E = c.get(_, C), b = l.get(_, C), R = f.get(_, C);
- return d.isError() ? d : E.isError() ? E : b.isError() ? b : R.isError() ? R : this._handleSignleObject(d, E, b, R);
- });
- return s === 1 && o === 1 ? h.get(0, 0) : h;
- }
- _handleSignleObject(e, t, r, n) {
- const { isError: s, errorObject: o, variants: u } = I(e, t, r, n);
- if (s)
- return o;
- const [c, l, f, h] = u, d = +c.getValue(), _ = +l.getValue(), C = +f.getValue(), E = +h.getValue();
- if (d < 0 || _ <= 0 || C <= 0)
- return g.create(m.NUM);
- const b = Math.exp(-((d / C) ** _));
- let R;
- return E ? R = 1 - b : R = _ / C ** _ * d ** (_ - 1) * b, Number.isNaN(R) || !Number.isFinite(R) ? g.create(m.NUM) : y.create(R);
- }
- }
- class gu extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 3);
- }
- calculate(e, t, r) {
- const n = this._getArrayValues(e), s = Math.max(
- t.isArray() ? t.getRowCount() : 1,
- r != null && r.isArray() ? r.getRowCount() : 1
- ), o = Math.max(
- t.isArray() ? t.getColumnCount() : 1,
- r != null && r.isArray() ? r.getColumnCount() : 1
- ), u = O(s, o, t, g.create(m.NA)), c = r ? O(s, o, r, g.create(m.NA)) : void 0, l = u.mapValue((f, h, d) => {
- if (n instanceof g)
- return n;
- if (f.isError())
- return f;
- const _ = r ? c.get(h, d) : void 0;
- return _ != null && _.isError() ? _ : n.length === 0 ? g.create(m.NA) : n.length === 1 ? g.create(m.DIV_BY_ZERO) : this._handleSignleObject(n, f, _);
- });
- return s === 1 && o === 1 ? l.get(0, 0) : l;
- }
- _handleSignleObject(e, t, r) {
- const { isError: n, errorObject: s, variants: o } = I(t);
- if (n)
- return s;
- const [u] = o, c = +u.getValue(), l = e.length;
- let f = 0, h = 0;
- for (let E = 0; E < l; E++)
- f += e[E], h += e[E] ** 2;
- let d = 0;
- if (r !== void 0) {
- const { isError: E, errorObject: b, variants: R } = I(r);
- if (E)
- return b;
- const [p] = R;
- d = +p.getValue();
- } else {
- const E = f / l;
- d = Math.sqrt((h - 2 * E * f + l * E ** 2) / (l - 1));
- }
- if (d <= 0)
- return g.create(m.NUM);
- const _ = (f / l - c) / (d / Math.sqrt(l)), C = 1 - kr(_, 0, 1);
- return Number.isNaN(C) || !Number.isFinite(C) ? g.create(m.NUM) : y.create(C);
- }
- _getArrayValues(e) {
- const t = [], r = e.isArray() ? e.getRowCount() : 1, n = e.isArray() ? e.getColumnCount() : 1;
- for (let s = 0; s < r; s++)
- for (let o = 0; o < n; o++) {
- const u = e.isArray() ? e.get(s, o) : e;
- if (u.isError())
- return u;
- if (u.isNull() || u.isBoolean() || u.isString())
- continue;
- const c = u.getValue();
- Q(c) && t.push(+c);
- }
- return t;
- }
- }
- class Cm extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 3);
- A(this, "maxParams", 5);
- }
- calculate(e, t, r, n, s) {
- let o = n != null ? n : y.create(0), u = s != null ? s : y.create(1);
- o.isNull() && (o = y.create(0)), u.isNull() && (u = y.create(1));
- const c = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1,
- r.isArray() ? r.getRowCount() : 1,
- o.isArray() ? o.getRowCount() : 1,
- u.isArray() ? u.getRowCount() : 1
- ), l = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1,
- r.isArray() ? r.getColumnCount() : 1,
- o.isArray() ? o.getColumnCount() : 1,
- u.isArray() ? u.getColumnCount() : 1
- ), f = O(c, l, e, g.create(m.NA)), h = O(c, l, t, g.create(m.NA)), d = O(c, l, r, g.create(m.NA)), _ = O(c, l, o, g.create(m.NA)), C = O(c, l, u, g.create(m.NA)), E = f.mapValue((b, R, p) => {
- const N = h.get(R, p), M = d.get(R, p), w = _.get(R, p), D = C.get(R, p);
- return this._handleSignleObject(b, N, M, w, D);
- });
- return c === 1 && l === 1 ? E.get(0, 0) : E;
- }
- _handleSignleObject(e, t, r, n, s) {
- if (e.isError())
- return e;
- if (t.isError())
- return t;
- if (r.isError())
- return r;
- if (n.isError())
- return n;
- if (s.isError())
- return s;
- const { isError: o, errorObject: u, variants: c } = I(e, t, r, n, s);
- if (o)
- return u;
- const [l, f, h, d, _] = c, C = +l.getValue(), E = +f.getValue(), b = +h.getValue(), R = +d.getValue(), p = +_.getValue();
- if (E <= 0 || b <= 0 || C < R || C > p || R === p)
- return g.create(m.NUM);
- const N = Do((C - R) / (p - R), E, b);
- return y.create(N);
- }
- }
- var le = /* @__PURE__ */ ((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))(le || {});
- class _m extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 4);
- A(this, "maxParams", 4);
- }
- calculate(e, t, r, n) {
- const s = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1,
- r.isArray() ? r.getRowCount() : 1,
- n.isArray() ? n.getRowCount() : 1
- ), o = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1,
- r.isArray() ? r.getColumnCount() : 1,
- n.isArray() ? n.getColumnCount() : 1
- ), u = O(s, o, e, g.create(m.NA)), c = O(s, o, t, g.create(m.NA)), l = O(s, o, r, g.create(m.NA)), f = O(s, o, n, g.create(m.NA)), h = u.mapValue((d, _, C) => {
- const E = c.get(_, C), b = l.get(_, C), R = f.get(_, C);
- return d.isError() ? d : E.isError() ? E : b.isError() ? b : R.isError() ? R : this._handleSignleObject(d, E, b, R);
- });
- return s === 1 && o === 1 ? h.get(0, 0) : h;
- }
- _handleSignleObject(e, t, r, n) {
- const { isError: s, errorObject: o, variants: u } = I(e, t, r, n);
- if (s)
- return o;
- const [c, l, f, h] = u, d = Math.floor(+c.getValue()), _ = Math.floor(+l.getValue()), C = Math.floor(+f.getValue()), E = Math.floor(+h.getValue());
- if (d < 0 || d > _ || d > C || d < _ - E + C || _ <= 0 || _ > E || C <= 0 || C > E || E <= 0)
- return g.create(m.NUM);
- let b = xa(d, _, C, E);
- return Number.isNaN(b) && (b = 0), y.create(b);
- }
- }
- class Am extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 3);
- A(this, "maxParams", 3);
- }
- calculate(e, t, r) {
- const n = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1,
- r.isArray() ? r.getRowCount() : 1
- ), s = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1,
- r.isArray() ? r.getColumnCount() : 1
- ), o = O(n, s, e, g.create(m.NA)), u = O(n, s, t, g.create(m.NA)), c = O(n, s, r, g.create(m.NA)), l = o.mapValue((f, h, d) => {
- const _ = u.get(h, d), C = c.get(h, d);
- return f.isError() ? f : _.isError() ? _ : C.isError() ? C : this._handleSignleObject(f, _, C);
- });
- return n === 1 && s === 1 ? l.get(0, 0) : l;
- }
- _handleSignleObject(e, t, r) {
- const { isError: n, errorObject: s, variants: o } = I(e, t, r);
- if (n)
- return s;
- const [u, c, l] = o, f = +u.getValue(), h = +c.getValue(), d = +l.getValue();
- if (f <= 0 || d <= 0)
- return g.create(m.NUM);
- const _ = Uo(f, h, d);
- return y.create(_);
- }
- }
- class Em extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 3);
- A(this, "maxParams", 3);
- }
- calculate(e, t, r) {
- const n = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1,
- r.isArray() ? r.getRowCount() : 1
- ), s = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1,
- r.isArray() ? r.getColumnCount() : 1
- ), o = O(n, s, e, g.create(m.NA)), u = O(n, s, t, g.create(m.NA)), c = O(n, s, r, g.create(m.NA)), l = o.mapValue((f, h, d) => {
- const _ = u.get(h, d), C = c.get(h, d);
- return f.isError() ? f : _.isError() ? _ : C.isError() ? C : this._handleSignleObject(f, _, C);
- });
- return n === 1 && s === 1 ? l.get(0, 0) : l;
- }
- _handleSignleObject(e, t, r) {
- const { isError: n, errorObject: s, variants: o } = I(e, t, r);
- if (n)
- return s;
- const [u, c, l] = o, f = Math.floor(+u.getValue()), h = Math.floor(+c.getValue()), d = +l.getValue();
- if (f < 0 || h < 1 || d <= 0 || d >= 1)
- return g.create(m.NUM);
- const _ = ja(f, h, d);
- return y.create(_);
- }
- }
- class bm extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- if (e.isArray()) {
- const t = e.mapValue((r) => this._handleSignleObject(r));
- return e.getRowCount() === 1 && e.getColumnCount() === 1 ? t.get(0, 0) : t;
- }
- return this._handleSignleObject(e);
- }
- _handleSignleObject(e) {
- const { isError: t, errorObject: r, variants: n } = I(e);
- if (t)
- return r;
- const [s] = n, o = +s.getValue(), u = kr(o, 0, 1);
- return y.create(u);
- }
- }
- class ym extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 3);
- A(this, "needsReferenceObject", !0);
- }
- calculate(e, t, r) {
- let n = e;
- n.isReferenceObject() && (n = n.toArrayValueObject());
- const { refHasError: s, refErrorObject: o, refNumbers: u } = this._checkRefReferenceObject(t);
- let c = r != null ? r : y.create(0);
- c.isReferenceObject() && (c = c.toArrayValueObject());
- const l = Math.max(
- n.isArray() ? n.getRowCount() : 1,
- c.isArray() ? c.getRowCount() : 1
- ), f = Math.max(
- n.isArray() ? n.getColumnCount() : 1,
- c.isArray() ? c.getColumnCount() : 1
- ), h = O(l, f, n, g.create(m.NA)), d = O(l, f, c, g.create(m.NA)), _ = h.map((C, E, b) => {
- const R = d.get(E, b);
- if (!e.isReferenceObject() && e.isNull())
- return g.create(m.NA);
- if (s)
- return o;
- if (R.isError())
- return R;
- const p = +C.getValue(), N = +R.getValue();
- if (Number.isNaN(p) || Number.isNaN(N))
- return g.create(m.VALUE);
- const w = u.sort((D, S) => N ? D - S : S - D).indexOf(p);
- return w === -1 ? g.create(m.NA) : y.create(w + 1);
- });
- return l === 1 && f === 1 ? _.get(0, 0) : _;
- }
- _checkRefReferenceObject(e) {
- let t = !1, r = g.create(m.NA);
- const n = [];
- return e.isReferenceObject() ? (e.toArrayValueObject().iterator((o) => {
- const u = o;
- if (u.isError())
- return t = !0, r = u, !1;
- if (u.isNull() || u.isBoolean())
- return !0;
- const c = +u.getValue();
- if (Number.isNaN(c))
- return !0;
- n.push(c);
- }), {
- refHasError: t,
- refErrorObject: r,
- refNumbers: n
- }) : {
- refHasError: !0,
- refErrorObject: r,
- refNumbers: n
- };
- }
- }
- class Rm extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 3);
- A(this, "maxParams", 3);
- }
- calculate(e, t, r) {
- const n = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1,
- r.isArray() ? r.getRowCount() : 1
- ), s = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1,
- r.isArray() ? r.getColumnCount() : 1
- ), o = O(n, s, e, g.create(m.NA)), u = O(n, s, t, g.create(m.NA)), c = O(n, s, r, g.create(m.NA)), l = o.mapValue((f, h, d) => {
- const _ = u.get(h, d), C = c.get(h, d);
- return f.isError() ? f : _.isError() ? _ : C.isError() ? C : this._handleSignleObject(f, _, C);
- });
- return n === 1 && s === 1 ? l.get(0, 0) : l;
- }
- _handleSignleObject(e, t, r) {
- const { isError: n, errorObject: s, variants: o } = I(e, t, r);
- if (n)
- return s;
- const [u, c, l] = o, f = +u.getValue(), h = Math.floor(+c.getValue()), d = Math.floor(+l.getValue());
- if (f < 0 || h < 1 || h > 10 ** 10 || d < 1 || d > 2)
- return g.create(m.NUM);
- let _ = $r(-f, h);
- return d === 2 && (_ *= 2), Number.isNaN(_) || !Number.isFinite(_) ? g.create(m.NUM) : y.create(_);
- }
- }
- const pm = [
- [Cm, le.BETADIST],
- [Bo, le.BETAINV],
- [Io, le.BINOMDIST],
- [ko, le.CHIDIST],
- [$o, le.CHIINV],
- [Yo, le.CHITEST],
- [Ho, le.CONFIDENCE],
- [Go, le.COVAR],
- [Fo, le.CRITBINOM],
- [Qo, le.EXPONDIST],
- [Wo, le.FDIST],
- [qo, le.FINV],
- [Ko, le.FTEST],
- [Xo, le.GAMMADIST],
- [Zo, le.GAMMAINV],
- [_m, le.HYPGEOMDIST],
- [Am, le.LOGNORMDIST],
- [zo, le.LOGINV],
- [Jo, le.MODE],
- [Em, le.NEGBINOMDIST],
- [eu, le.NORMDIST],
- [tu, le.NORMINV],
- [bm, le.NORMSDIST],
- [ru, le.NORMSINV],
- [nu, le.PERCENTILE],
- [su, le.PERCENTRANK],
- [au, le.POISSON],
- [iu, le.QUARTILE],
- [ym, le.RANK],
- [uu, le.STDEV],
- [ou, le.STDEVP],
- [Rm, le.TDIST],
- [cu, le.TINV],
- [lu, le.TTEST],
- [hu, le.VAR],
- [fu, le.VARP],
- [mu, le.WEIBULL],
- [gu, le.ZTEST]
- ], Vm = [];
- var Nm = /* @__PURE__ */ ((i) => (i.CUBEKPIMEMBER = "CUBEKPIMEMBER", i.CUBEMEMBER = "CUBEMEMBER", i.CUBEMEMBERPROPERTY = "CUBEMEMBERPROPERTY", i.CUBERANKEDMEMBER = "CUBERANKEDMEMBER", i.CUBESET = "CUBESET", i.CUBESETCOUNT = "CUBESETCOUNT", i.CUBEVALUE = "CUBEVALUE", i))(Nm || {});
- class Om extends V {
- isCustom() {
- return !0;
- }
- }
- class Qb extends Om {
- isAsync() {
- return !0;
- }
- }
- function et(i) {
- const a = [];
- if (i.isError())
- return {
- isError: !0,
- errorObject: i,
- databaseValues: a
- };
- const e = i.isArray() ? i.getRowCount() : 1, t = i.isArray() ? i.getColumnCount() : 1;
- if (e < 2)
- return {
- isError: !0,
- errorObject: g.create(m.VALUE),
- databaseValues: a
- };
- for (let r = 0; r < e; r++) {
- const n = [];
- for (let s = 0; s < t; s++) {
- const o = i.get(r, s);
- if (o.isNull()) {
- n.push(null);
- continue;
- }
- let u = `${o.getValue()}`;
- if (o.isBoolean() && (u = u.toLocaleUpperCase()), o.isNumber() || Q(u)) {
- n.push(+u);
- continue;
- }
- n.push(u);
- }
- a.push(n);
- }
- return {
- isError: !1,
- errorObject: null,
- databaseValues: a
- };
- }
- function tt(i, a) {
- let e = -1;
- if (i.isError())
- return {
- isError: !0,
- errorObject: i,
- fieldIndex: e
- };
- const t = i.isArray() ? i.getRowCount() : 1, r = i.isArray() ? i.getColumnCount() : 1;
- if (t > 1 || r > 1)
- return {
- isError: !0,
- errorObject: g.create(m.VALUE),
- fieldIndex: e
- };
- const n = i.isArray() ? i.get(0, 0) : i;
- let s = `${n.getValue()}`;
- if (n.isNull() ? s = 0 : n.isBoolean() ? s = n.getValue() ? 1 : 0 : (n.isNumber() || Q(s)) && (s = Math.floor(+s)), typeof s == "number") {
- if (s < 1 || s > a[0].length)
- return {
- isError: !0,
- errorObject: g.create(m.VALUE),
- fieldIndex: e
- };
- e = s - 1;
- } else if (e = a[0].findIndex((o) => o === null ? !1 : `${o}`.toLocaleLowerCase() === s.toLocaleLowerCase()), e === -1)
- return {
- isError: !0,
- errorObject: g.create(m.VALUE),
- fieldIndex: e
- };
- return {
- isError: !1,
- errorObject: null,
- fieldIndex: e
- };
- }
- function rt(i) {
- const a = [];
- if (i.isError())
- return {
- isError: !0,
- errorObject: i,
- criteriaValues: a
- };
- const e = i.isArray() ? i.getRowCount() : 1, t = i.isArray() ? i.getColumnCount() : 1;
- if (e < 2)
- return {
- isError: !0,
- errorObject: g.create(m.VALUE),
- criteriaValues: a
- };
- for (let r = 0; r < e; r++) {
- const n = [];
- for (let s = 0; s < t; s++) {
- const o = i.get(r, s);
- if (o.isNull()) {
- n.push(null);
- continue;
- }
- const u = `${o.getValue()}`;
- if (o.isBoolean()) {
- n.push(o.getValue() ? 1 : 0);
- continue;
- }
- if (o.isNumber() || Q(u)) {
- n.push(+u);
- continue;
- }
- n.push(u);
- }
- a.push(n);
- }
- return {
- isError: !1,
- errorObject: null,
- criteriaValues: a
- };
- }
- function nt(i, a, e) {
- const t = i.length, r = i[0].length, n = {};
- let s = !1;
- for (let o = 1; o < t; o++) {
- let u = !0;
- for (let c = 0; c < r; c++) {
- const l = i[o][c];
- if (l === null)
- continue;
- let f = n[c];
- if (f === void 0) {
- const h = i[0][c];
- f = a[0].findIndex((d) => d === null || h === null ? !1 : `${d}`.toLocaleLowerCase() === `${h}`.toLocaleLowerCase()), n[c] = f;
- }
- if (f === -1 && (typeof l == "string" || l === 0)) {
- u = !1;
- break;
- } else if (f > -1) {
- const h = a[e][f];
- if (h === null) {
- u = !1;
- break;
- }
- const [d, _] = Aa(`${l}`);
- if (!pt.create(`${h}`).compare(_, d).getValue()) {
- u = !1;
- break;
- }
- }
- }
- if (u) {
- s = !0;
- break;
- }
- }
- return s;
- }
- class Mm extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 3);
- A(this, "maxParams", 3);
- }
- calculate(e, t, r) {
- const { isError: n, errorObject: s, databaseValues: o } = et(e);
- if (n)
- return s;
- const { isError: u, errorObject: c, fieldIndex: l } = tt(t, o);
- if (u)
- return c;
- const { isError: f, errorObject: h, criteriaValues: d } = rt(r);
- if (f)
- return h;
- let _ = 0, C = 0;
- for (let E = 1; E < o.length; E++) {
- const b = o[E][l];
- typeof b == "number" && nt(d, o, E) && (_ += b, C++);
- }
- return C === 0 ? g.create(m.DIV_BY_ZERO) : y.create(_ / C);
- }
- }
- class wm extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 3);
- A(this, "maxParams", 3);
- }
- calculate(e, t, r) {
- const { isError: n, errorObject: s, databaseValues: o } = et(e);
- if (n)
- return s;
- const { isError: u, errorObject: c, fieldIndex: l } = tt(t, o);
- if (u)
- return c;
- const { isError: f, errorObject: h, criteriaValues: d } = rt(r);
- if (f)
- return h;
- let _ = 0;
- for (let C = 1; C < o.length; C++)
- typeof o[C][l] == "number" && nt(d, o, C) && _++;
- return y.create(_);
- }
- }
- class Dm extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 3);
- A(this, "maxParams", 3);
- }
- calculate(e, t, r) {
- const { isError: n, errorObject: s, databaseValues: o } = et(e);
- if (n)
- return s;
- const { isError: u, errorObject: c, fieldIndex: l } = tt(t, o);
- if (u)
- return c;
- const { isError: f, errorObject: h, criteriaValues: d } = rt(r);
- if (f)
- return h;
- let _ = 0;
- for (let C = 1; C < o.length; C++) {
- const E = o[C][l];
- E != null && nt(d, o, C) && _++;
- }
- return y.create(_);
- }
- }
- class Sm extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 3);
- A(this, "maxParams", 3);
- }
- calculate(e, t, r) {
- const { isError: n, errorObject: s, databaseValues: o } = et(e);
- if (n)
- return s;
- const { isError: u, errorObject: c, fieldIndex: l } = tt(t, o);
- if (u)
- return c;
- const { isError: f, errorObject: h, criteriaValues: d } = rt(r);
- if (f)
- return h;
- let _ = 0, C = 0;
- for (let E = 1; E < o.length; E++) {
- const b = o[E][l];
- b != null && nt(d, o, E) && (_++, C = E);
- }
- return _ === 0 ? g.create(m.VALUE) : _ > 1 ? g.create(m.NUM) : e.get(C, l);
- }
- }
- class Pm extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 3);
- A(this, "maxParams", 3);
- }
- calculate(e, t, r) {
- const { isError: n, errorObject: s, databaseValues: o } = et(e);
- if (n)
- return s;
- const { isError: u, errorObject: c, fieldIndex: l } = tt(t, o);
- if (u)
- return c;
- const { isError: f, errorObject: h, criteriaValues: d } = rt(r);
- if (f)
- return h;
- let _ = -1 / 0, C = 0;
- for (let E = 1; E < o.length; E++) {
- const b = o[E][l];
- typeof b == "number" && nt(d, o, E) && (_ = Math.max(_, b), C++);
- }
- return C === 0 ? y.create(0) : y.create(_);
- }
- }
- class Lm extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 3);
- A(this, "maxParams", 3);
- }
- calculate(e, t, r) {
- const { isError: n, errorObject: s, databaseValues: o } = et(e);
- if (n)
- return s;
- const { isError: u, errorObject: c, fieldIndex: l } = tt(t, o);
- if (u)
- return c;
- const { isError: f, errorObject: h, criteriaValues: d } = rt(r);
- if (f)
- return h;
- let _ = 1 / 0, C = 0;
- for (let E = 1; E < o.length; E++) {
- const b = o[E][l];
- typeof b == "number" && nt(d, o, E) && (_ = Math.min(_, b), C++);
- }
- return C === 0 ? y.create(0) : y.create(_);
- }
- }
- class xm extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 3);
- A(this, "maxParams", 3);
- }
- calculate(e, t, r) {
- const { isError: n, errorObject: s, databaseValues: o } = et(e);
- if (n)
- return s;
- const { isError: u, errorObject: c, fieldIndex: l } = tt(t, o);
- if (u)
- return c;
- const { isError: f, errorObject: h, criteriaValues: d } = rt(r);
- if (f)
- return h;
- let _ = 1, C = 0;
- for (let E = 1; E < o.length; E++) {
- const b = o[E][l];
- typeof b == "number" && nt(d, o, E) && (_ *= b, C++);
- }
- return C === 0 ? y.create(0) : y.create(_);
- }
- }
- class jm extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 3);
- A(this, "maxParams", 3);
- }
- calculate(e, t, r) {
- const { isError: n, errorObject: s, databaseValues: o } = et(e);
- if (n)
- return s;
- const { isError: u, errorObject: c, fieldIndex: l } = tt(t, o);
- if (u)
- return c;
- const { isError: f, errorObject: h, criteriaValues: d } = rt(r);
- if (f)
- return h;
- const _ = [];
- let C = 0, E = 0;
- for (let N = 1; N < o.length; N++) {
- const M = o[N][l];
- typeof M == "number" && nt(d, o, N) && (_.push(M), C += M, E++);
- }
- if (E <= 1)
- return g.create(m.DIV_BY_ZERO);
- const b = C / E;
- let R = 0;
- for (let N = 0; N < E; N++)
- R += (_[N] - b) ** 2;
- const p = Math.sqrt(R / (E - 1));
- return y.create(p);
- }
- }
- class Um extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 3);
- A(this, "maxParams", 3);
- }
- calculate(e, t, r) {
- const { isError: n, errorObject: s, databaseValues: o } = et(e);
- if (n)
- return s;
- const { isError: u, errorObject: c, fieldIndex: l } = tt(t, o);
- if (u)
- return c;
- const { isError: f, errorObject: h, criteriaValues: d } = rt(r);
- if (f)
- return h;
- const _ = [];
- let C = 0, E = 0;
- for (let N = 1; N < o.length; N++) {
- const M = o[N][l];
- typeof M == "number" && nt(d, o, N) && (_.push(M), C += M, E++);
- }
- if (E === 0)
- return g.create(m.DIV_BY_ZERO);
- const b = C / E;
- let R = 0;
- for (let N = 0; N < E; N++)
- R += (_[N] - b) ** 2;
- const p = Math.sqrt(R / E);
- return y.create(p);
- }
- }
- class vm extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 3);
- A(this, "maxParams", 3);
- }
- calculate(e, t, r) {
- const { isError: n, errorObject: s, databaseValues: o } = et(e);
- if (n)
- return s;
- const { isError: u, errorObject: c, fieldIndex: l } = tt(t, o);
- if (u)
- return c;
- const { isError: f, errorObject: h, criteriaValues: d } = rt(r);
- if (f)
- return h;
- let _ = 0;
- for (let C = 1; C < o.length; C++) {
- const E = o[C][l];
- typeof E == "number" && nt(d, o, C) && (_ += E);
- }
- return y.create(_);
- }
- }
- class Tm extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 3);
- A(this, "maxParams", 3);
- }
- calculate(e, t, r) {
- const { isError: n, errorObject: s, databaseValues: o } = et(e);
- if (n)
- return s;
- const { isError: u, errorObject: c, fieldIndex: l } = tt(t, o);
- if (u)
- return c;
- const { isError: f, errorObject: h, criteriaValues: d } = rt(r);
- if (f)
- return h;
- const _ = [];
- let C = 0, E = 0;
- for (let N = 1; N < o.length; N++) {
- const M = o[N][l];
- typeof M == "number" && nt(d, o, N) && (_.push(M), C += M, E++);
- }
- if (E <= 1)
- return g.create(m.DIV_BY_ZERO);
- const b = C / E;
- let R = 0;
- for (let N = 0; N < E; N++)
- R += (_[N] - b) ** 2;
- const p = R / (E - 1);
- return y.create(p);
- }
- }
- class Bm extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 3);
- A(this, "maxParams", 3);
- }
- calculate(e, t, r) {
- const { isError: n, errorObject: s, databaseValues: o } = et(e);
- if (n)
- return s;
- const { isError: u, errorObject: c, fieldIndex: l } = tt(t, o);
- if (u)
- return c;
- const { isError: f, errorObject: h, criteriaValues: d } = rt(r);
- if (f)
- return h;
- const _ = [];
- let C = 0, E = 0;
- for (let N = 1; N < o.length; N++) {
- const M = o[N][l];
- typeof M == "number" && nt(d, o, N) && (_.push(M), C += M, E++);
- }
- if (E === 0)
- return g.create(m.DIV_BY_ZERO);
- const b = C / E;
- let R = 0;
- for (let N = 0; N < E; N++)
- R += (_[N] - b) ** 2;
- const p = R / E;
- return y.create(p);
- }
- }
- var Qe = /* @__PURE__ */ ((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 || {});
- const Im = [
- [Mm, Qe.DAVERAGE],
- [wm, Qe.DCOUNT],
- [Dm, Qe.DCOUNTA],
- [Sm, Qe.DGET],
- [Pm, Qe.DMAX],
- [Lm, Qe.DMIN],
- [xm, Qe.DPRODUCT],
- [jm, Qe.DSTDEV],
- [Um, Qe.DSTDEVP],
- [vm, Qe.DSUM],
- [Tm, Qe.DVAR],
- [Bm, Qe.DVARP]
- ], Ua = "yyyy/mm/dd;@", Fm = "yyyy/mm/dd hh:mm", km = "h:mm A/P";
- function ye(i) {
- const a = new Date(Date.UTC(1900, 0, 1)), e = new Date(Date.UTC(1900, 1, 28)), t = Date.UTC(i.getFullYear(), i.getMonth(), i.getDate());
- let r = (t - a.getTime()) / (1e3 * 3600 * 24);
- return t > e.getTime() && (r += 1), Math.floor(r) + 1;
- }
- function Yr(i) {
- const a = new Date(Date.UTC(1900, 0, 1, 0, 0, 0)), e = new Date(Date.UTC(1900, 1, 28, 0, 0, 0));
- let r = (i.getTime() - a.getTime()) / (1e3 * 3600 * 24);
- return i > e && (r += 1), r + 1;
- }
- function re(i) {
- const a = new Date(Date.UTC(1900, 0, 1)), e = new Date(Date.UTC(1900, 1, 28));
- let t = Math.floor(i) - 1;
- return t > (e.getTime() - a.getTime()) / (1e3 * 3600 * 24) && (t -= 1), new Date(a.getTime() + t * (1e3 * 3600 * 24));
- }
- function va(i) {
- const a = new Date(Date.UTC(1900, 0, 1, 0, 0, 0)), e = new Date(Date.UTC(1900, 1, 28, 0, 0, 0));
- let t = i - 1;
- return t > (e.getTime() - a.getTime()) / (1e3 * 3600 * 24) && (t -= 1), t < 0 && (t = i), new Date(a.getTime() + t * (1e3 * 3600 * 24));
- }
- function Ta(i) {
- if (!/^\d{4}[-/](0?[1-9]|1[012])[-/](0?[1-9]|[12][0-9]|3[01])$/.test(i))
- return !1;
- const e = i.replace(/-/g, "/").replace(/T.+/, ""), t = /* @__PURE__ */ new Date(`${e}`);
- if (Number.isNaN(t.getTime()))
- return !1;
- const r = t.getFullYear(), n = (t.getMonth() + 1).toString().padStart(2, "0"), s = t.getDate().toString().padStart(2, "0"), o = `${r}-${n}-${s}`;
- return i.replace(/\//g, "-").split("-").map((c) => c.padStart(2, "0")).join("-") === o;
- }
- function Xs(i) {
- return gt.parseDate(i);
- }
- function du(i) {
- return gt.parseValue(i);
- }
- function Zs(i) {
- return gt.parseTime(i);
- }
- function Ba(i) {
- return gt.isDate(i);
- }
- const Cu = {
- 1: [6, 0],
- // Saturday, Sunday
- 2: [0, 1],
- // Sunday, Monday
- 3: [1, 2],
- // Monday, Tuesday
- 4: [2, 3],
- // Tuesday, Wednesday
- 5: [3, 4],
- // Wednesday, Thursday
- 6: [4, 5],
- // Thursday, Friday
- 7: [5, 6],
- // Friday, Saturday
- 11: [0],
- // Sunday only
- 12: [1],
- // Monday only
- 13: [2],
- // Tuesday only
- 14: [3],
- // Wednesday only
- 15: [4],
- // Thursday only
- 16: [5],
- // Friday only
- 17: [6]
- // Saturday only
- };
- function Ur(i) {
- return !!(typeof i == "string" && /^[0|1]{7}/.test(i) || Cu[Number(i)]);
- }
- function _u(i) {
- if (!Ur(i))
- return [];
- if (typeof i == "string" && /^[0|1]{7}/.test(i)) {
- const a = [];
- for (let e = 1; e <= i.length; e++)
- `${i[e - 1]}` == "1" && (e === i.length ? a.push(0) : a.push(e));
- return a;
- }
- return Cu[Number(i)] || [];
- }
- function On(i, a, e = 1, t) {
- const r = _u(e), n = Math.floor(i), s = Math.floor(a), o = s > n ? n : s;
- let u = 0;
- const c = Math.abs(Math.floor(a) - Math.floor(i)) + 1;
- for (let l = 0; l < c; l++) {
- const f = o + l;
- if (t && t.length > 0 && t.some((d) => Math.floor(d) === f))
- continue;
- const h = rr(f);
- r.includes(h) || u++;
- }
- return s >= n ? u : -u;
- }
- function Mn(i, a, e = 1, t) {
- const r = _u(e), n = Math.floor(i);
- let s = n, o = Math.abs(a);
- for (let u = 1; u <= o; u++) {
- const c = a < 0 ? n - u : n + u;
- if (c < 0)
- return g.create(m.NUM);
- if (t && t.length > 0 && t.some((f) => Math.floor(f) === c)) {
- o++;
- continue;
- }
- const l = rr(c);
- if (r.includes(l)) {
- o++;
- continue;
- }
- s = c;
- }
- return s;
- }
- function k(i) {
- if (i.isError())
- return i;
- const a = i.getValue();
- if (i.isString()) {
- let e;
- if (Xs(`${a}`))
- e = Xs(`${a}`).v;
- else if (Zs(`${a}`))
- e = Zs(`${a}`).v;
- else if (Q(a))
- e = +a;
- else
- return g.create(m.VALUE);
- return e instanceof Date && (e = Yr(e)), +e < 0 || +e > 2958465 ? g.create(m.NUM) : +e;
- } else {
- const e = +i.getValue();
- return e < 0 || e > 2958465 ? g.create(m.NUM) : e;
- }
- }
- function rr(i) {
- const a = Math.floor(i) === 60;
- let e = re(i);
- const t = new Date(Date.UTC(e.getFullYear(), e.getMonth(), e.getDate())).getTime(), r = new Date(Date.UTC(1900, 1, 28)).getTime();
- return !a && t <= r && (e = new Date(t - 24 * 3600 * 1e3)), new Date(Date.UTC(e.getFullYear(), e.getMonth(), e.getDate())).getUTCDay();
- }
- function _e(i, a, e) {
- switch (e) {
- case 0:
- return $m(i, a);
- case 1:
- return Ym(i, a);
- case 2:
- return {
- days: Math.abs(a - i),
- yearDays: 360
- };
- case 3:
- return {
- days: Math.abs(a - i),
- yearDays: 365
- };
- case 4:
- return Hm(i, a);
- default:
- return {
- days: Math.abs(a - i),
- yearDays: 365
- };
- }
- }
- function $m(i, a) {
- const e = re(i), t = i > 0 ? e.getUTCFullYear() : 1900, r = i > 0 ? e.getUTCMonth() + 1 : 1;
- let n = i > 0 ? e.getUTCDate() : 0, s = re(a), o = a > 0 ? s.getUTCFullYear() : 1900, u = a > 0 ? s.getUTCMonth() + 1 : 1, c = a > 0 ? s.getUTCDate() : 0;
- r === 2 ? re(i + 1).getUTCMonth() + 1 === 3 && (n = 30) : n === 31 && (n = 30), c === 31 && (n < 30 ? (s = re(a + 1), o = s.getUTCFullYear(), u = s.getUTCMonth() + 1, c = s.getUTCDate()) : c = 30);
- const l = (o - t) * 360, f = a >= i ? 30 - n : -n, h = a >= i ? c : c - 30, d = (a >= i ? u - r - 1 : u - r + 1) * 30;
- return {
- days: Math.abs(l + f + h + d),
- yearDays: 360
- };
- }
- function Ym(i, a) {
- const e = re(i), t = i > 0 ? e.getUTCFullYear() : 1900, r = re(a), n = a > 0 ? r.getUTCFullYear() : 1900, s = Math.abs(a - i), o = Math.abs(n - t) + 1;
- let u, c;
- if (n < t) {
- const l = new Date(Date.UTC(n, 0, 1)), f = new Date(Date.UTC(t, 11, 31));
- u = ye(l), c = ye(f), n === 1900 && (u += 1);
- } else {
- const l = new Date(Date.UTC(t, 0, 1)), f = new Date(Date.UTC(n, 11, 31));
- u = ye(l), c = ye(f), t === 1900 && (u += 1);
- }
- return {
- days: s,
- yearDays: (c - u + 1) / o
- };
- }
- function Hm(i, a) {
- const e = re(i), t = i > 0 ? e.getUTCFullYear() : 1900, r = i > 0 ? e.getUTCMonth() + 1 : 1;
- let n = i > 0 ? e.getUTCDate() : 0;
- const s = re(a), o = a > 0 ? s.getUTCFullYear() : 1900, u = a > 0 ? s.getUTCMonth() + 1 : 1;
- let c = a > 0 ? s.getUTCDate() : 0;
- n === 31 && (n = 30), c === 31 && (c = 30);
- const l = (o - t) * 360, f = a >= i ? 30 - n : -n, h = a >= i ? c : c - 30, d = (a >= i ? u - r - 1 : u - r + 1) * 30;
- return {
- days: Math.abs(l + f + h + d),
- yearDays: 360
- };
- }
- function Gm(i) {
- return i % 4 === 0 && i % 100 !== 0 || i % 400 === 0;
- }
- function Qm(i) {
- return i % 4 === 0 && i % 100 !== 0 || i % 400 === 0 || i === 1900;
- }
- const Wm = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31], qm = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
- function Hr(i, a) {
- return Gm(i) ? Wm[a] : qm[a];
- }
- function Jn(i) {
- return Qm(i) ? 366 : 365;
- }
- function Au(i, a) {
- switch (a) {
- case 0:
- case 2:
- case 4:
- return 360;
- case 1:
- return Jn(re(i).getUTCFullYear());
- case 3:
- return 365;
- default:
- return -1;
- }
- }
- function Ar(i, a, e) {
- return Hr(i, a) === e;
- }
- function Er(i, a) {
- let e = i.getUTCFullYear(), t = i.getUTCMonth();
- const r = i.getUTCDate();
- return Ar(e, t, r) ? (i.setUTCDate(1), i.setUTCMonth(i.getUTCMonth() + a), e = i.getUTCFullYear(), t = i.getUTCMonth(), i.setUTCDate(Hr(e, t))) : i.setUTCMonth(i.getUTCMonth() + a), i;
- }
- class Km extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 3);
- A(this, "maxParams", 3);
- }
- calculate(e, t, r) {
- if (e.isError())
- return e;
- if (t.isError())
- return t;
- if (r.isError())
- return r;
- const n = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1,
- r.isArray() ? r.getRowCount() : 1
- ), s = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1,
- r.isArray() ? r.getColumnCount() : 1
- ), o = O(n, s, e), u = O(n, s, t), c = O(n, s, r);
- return o.map((l, f, h) => {
- const d = u.get(f, h) || ie.create(), _ = c.get(f, h) || ie.create();
- if (l.isError())
- return l;
- if (d.isError())
- return d;
- if (_.isError())
- return _;
- if (l.isString() || d.isString() || _.isString())
- return g.create(m.VALUE);
- let C = +l.getValue();
- const E = Math.floor(+d.getValue()), b = +_.getValue();
- if (C < 0 || C > 9999)
- return g.create(m.NUM);
- C >= 0 && C < 1899 && (C += 1900);
- const R = new Date(C, E - 1, b), p = ye(R);
- return p < 0 ? g.create(m.NUM) : y.create(p, Ua);
- });
- }
- }
- class Xm extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 3);
- A(this, "maxParams", 3);
- }
- calculate(e, t, r) {
- let n = e, s = t, o = r;
- if (n.isArray() && (n = n.get(0, 0)), s.isArray() && (s = s.get(0, 0)), o.isArray() && (o = o.get(0, 0)), n.isError())
- return n;
- if (s.isError())
- return s;
- if (o.isError())
- return o;
- const u = k(n);
- if (typeof u != "number")
- return u;
- const c = k(s);
- return typeof c != "number" ? c : c < u || !o.isString() ? g.create(m.NUM) : this._getResultByUnit(u, c, o);
- }
- _getResultByUnit(e, t, r) {
- const n = re(e), s = n.getUTCFullYear(), o = n.getUTCMonth() + 1, u = n.getUTCDate(), c = re(t), l = c.getUTCFullYear(), f = c.getUTCMonth() + 1, h = c.getUTCDate(), d = `${r.getValue()}`.toLocaleUpperCase();
- let _ = 0, C;
- switch (d) {
- case "Y":
- _ = l - s, (f < o || f === o && h < u) && (_ -= 1);
- break;
- case "M":
- _ = (l - s) * 12 + f - o, h < u && (_ -= 1);
- break;
- case "D":
- _ = Math.floor(t) - Math.floor(e);
- break;
- case "MD":
- _ = h - u, h < u && (C = new Date(Date.UTC(l, f - 1, 0)), _ += Hr(C.getUTCFullYear(), C.getUTCMonth()));
- break;
- case "YM":
- _ = f - o, (f < o || f === o && h < u) && (_ += 12), h < u && (_ -= 1);
- break;
- case "YD":
- C = new Date(Date.UTC(s, f - 1, h)), (f < o || f === o && h < u) && (C = new Date(Date.UTC(s + 1, f - 1, h))), _ = Math.floor(ye(C)) - Math.floor(e);
- break;
- default:
- return g.create(m.NUM);
- }
- return y.create(_);
- }
- }
- class Zm extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- return e.isError() ? e : e.isArray() ? e.map((t) => this._handleSingleObject(t)) : this._handleSingleObject(e);
- }
- _handleSingleObject(e) {
- if (e.isString()) {
- const t = `${e.getValue()}`, r = du(t);
- if (r) {
- let { v: n, z: s } = r;
- if (s && Ba(s))
- return n instanceof Date && (n = Yr(n)), y.create(Math.trunc(+n));
- }
- }
- return g.create(m.VALUE);
- }
- }
- class zm extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- return e.isError() ? e : e.isArray() ? e.map((t) => this._handleSingleObject(t)) : this._handleSingleObject(e);
- }
- _handleSingleObject(e) {
- let t;
- const r = e.getValue();
- if (e.isString()) {
- if (!Ta(`${r}`))
- return g.create(m.VALUE);
- t = /* @__PURE__ */ new Date(`${r}`);
- } else {
- const o = +e.getValue();
- if (o < 0)
- return g.create(m.NUM);
- if (o === 0)
- return y.create(0);
- t = re(o);
- }
- const n = t.getDate();
- return y.create(n);
- }
- }
- class Jm extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- if (e.isError())
- return e;
- if (t.isError())
- return t;
- const r = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1
- ), n = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1
- ), s = O(r, n, e), o = O(r, n, t), u = s.map((c, l, f) => {
- const h = o.get(l, f);
- if (c.isError())
- return c;
- if (h.isError())
- return h;
- const d = k(c);
- if (typeof d != "number")
- return d;
- const _ = k(h);
- if (typeof _ != "number")
- return _;
- const C = Math.floor(d) - Math.floor(_);
- return y.create(C);
- });
- return r === 1 && n === 1 ? u.get(0, 0) : u;
- }
- }
- class eg extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 3);
- }
- calculate(e, t, r) {
- const n = r != null ? r : T.create(!1);
- if (e.isError())
- return e;
- if (t.isError())
- return t;
- if (n.isError())
- return n;
- const s = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1,
- n.isArray() ? n.getRowCount() : 1
- ), o = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1,
- n.isArray() ? n.getColumnCount() : 1
- ), u = O(s, o, e, g.create(m.NA)), c = O(s, o, t, g.create(m.NA)), l = O(s, o, n, g.create(m.NA)), f = u.map((h, d, _) => {
- const C = c.get(d, _);
- let E = l.get(d, _);
- if (h.isError())
- return h;
- const b = k(h);
- if (typeof b != "number")
- return b;
- if (C.isError())
- return C;
- const R = k(C);
- if (typeof R != "number")
- return R;
- if (E.isString() && (E = E.convertToNumberObjectValue()), E.isError())
- return E;
- const p = +E.getValue(), { days: N } = _e(b, R, p ? 4 : 0), M = R >= b ? N : -N;
- return y.create(M);
- });
- return s === 1 && o === 1 ? f.get(0, 0) : f;
- }
- }
- class tg extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- if (e.isError())
- return e;
- if (t.isError())
- return t;
- const r = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1
- ), n = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1
- ), s = O(r, n, e), o = O(r, n, t);
- return s.map((u, c, l) => {
- const f = o.get(c, l) || ie.create();
- if (u.isError())
- return u;
- if (f.isError())
- return f;
- if (u.isString() || u.isBoolean() || f.isString() || f.isBoolean())
- return g.create(m.VALUE);
- const h = +u.getValue();
- if (h < 0)
- return g.create(m.NUM);
- const d = Math.floor(+f.getValue()), _ = re(h), C = _.getUTCFullYear(), E = _.getUTCMonth() + d, b = _.getUTCDate(), R = new Date(Date.UTC(C, E, b)), p = ye(R);
- return y.create(p, Ua);
- });
- }
- }
- class rg extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- let r = e, n = t;
- if (r.isArray()) {
- const d = r.getRowCount(), _ = r.getColumnCount();
- if (d > 1 || _ > 1)
- return g.create(m.VALUE);
- r = r.get(0, 0);
- }
- if (n.isArray()) {
- const d = n.getRowCount(), _ = n.getColumnCount();
- if (d > 1 || _ > 1)
- return g.create(m.VALUE);
- n = n.get(0, 0);
- }
- if (r.isError())
- return r;
- if (n.isError())
- return n;
- const s = k(r);
- if (typeof s != "number")
- return s;
- if (n.isBoolean())
- return g.create(m.VALUE);
- const o = re(s), u = s > 0 ? o.getUTCFullYear() : 1900, c = s > 0 ? o.getUTCMonth() : 0, l = Math.floor(+n.getValue());
- if (Number.isNaN(l))
- return g.create(m.VALUE);
- const f = new Date(Date.UTC(u, c + l + 1, 0)), h = ye(f);
- return y.create(h);
- }
- }
- class ng extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 2);
- A(this, "needsReferenceObject", !0);
- }
- calculate(e, t) {
- const r = t != null ? t : y.create(1), { isError: n, errorObject: s, timestampIsReferenceObject: o, timestampObject: u, unitObject: c } = this._checkVariants(e, r);
- if (n)
- return s;
- if (u.isNull() || u.isBoolean() || u.isString() || !o && u.isNumber() && u.getPattern() !== "")
- return g.create(m.VALUE);
- let l = +u.getValue();
- const { isError: f, errorObject: h, variants: d } = I(c);
- if (f)
- return h;
- const [_] = d, C = Math.floor(+_.getValue());
- if (l < 0 || C < 1 || C > 3)
- return g.create(m.NUM);
- C === 1 && (l = l * 1e3), C === 3 && (l = l / 1e3);
- const E = new Date(Date.UTC(1970, 0, 1, 0, 0, 0, 0) + l);
- if (Number.isNaN(E.getTime())) {
- const b = 25569 + l / 864e5;
- return y.create(b);
- } else {
- const b = Yr(E);
- return y.create(b, "yyyy-MM-dd AM/PM hh:mm:ss");
- }
- }
- _checkVariants(e, t) {
- const r = e.isReferenceObject(), n = t.isReferenceObject();
- let s = e;
- if (r && (s = e.toArrayValueObject()), s.isArray()) {
- const u = s.getRowCount(), c = s.getColumnCount();
- if (u > 1 || c > 1)
- return {
- isError: !0,
- errorObject: g.create(m.VALUE)
- };
- s = s.get(0, 0);
- }
- if (s.isError())
- return {
- isError: !0,
- errorObject: s
- };
- let o = t;
- if (n && (o = t.toArrayValueObject()), o.isArray()) {
- const u = o.getRowCount(), c = o.getColumnCount();
- if (u > 1 || c > 1)
- return {
- isError: !0,
- errorObject: g.create(m.VALUE)
- };
- o = o.get(0, 0);
- }
- return o.isError() ? {
- isError: !0,
- errorObject: o
- } : {
- isError: !1,
- errorObject: null,
- timestampIsReferenceObject: r,
- timestampObject: s,
- unitIsReferenceObject: n,
- unitObject: o
- };
- }
- }
- var be = /* @__PURE__ */ ((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))(be || {});
- class sg extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- return e.isError() ? e : e.isArray() ? e.map((t) => t.isError() ? t : this._handleSingleObject(t)) : this._handleSingleObject(e);
- }
- _handleSingleObject(e) {
- const t = k(e);
- if (typeof t != "number")
- return t;
- if (t === 0)
- return y.create(0);
- const n = va(t).getUTCHours();
- return y.create(n);
- }
- }
- class ag extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- return e.isError() ? e : e.isArray() ? e.map((t) => t.isError() ? t : this._handleSingleObject(t)) : this._handleSingleObject(e);
- }
- _handleSingleObject(e) {
- const t = k(e);
- if (typeof t != "number")
- return t;
- const r = re(t), n = t > 0 ? r.getUTCFullYear() : 1900;
- let s = new Date(Date.UTC(n, 0, 1)), o = ye(s), u = rr(o), c;
- 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 = ye(s), u = rr(o), u < 1 ? c = o + 1 : u <= 4 ? c = o - (u - 1) : c = o + (11 - u));
- const l = Math.ceil((t - c + 1) / 7);
- return y.create(l);
- }
- }
- class ig extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- return e.isError() ? e : e.isArray() ? e.map((t) => t.isError() ? t : this._handleSingleObject(t)) : this._handleSingleObject(e);
- }
- _handleSingleObject(e) {
- const t = k(e);
- if (typeof t != "number")
- return t;
- if (t === 0)
- return y.create(0);
- const n = va(t).getUTCMinutes();
- return y.create(n);
- }
- }
- class og extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- return e.isArray() ? e.map((t) => this._handleSingleObject(t)) : this._handleSingleObject(e);
- }
- _handleSingleObject(e) {
- if (e.isError())
- return e;
- let t;
- const r = e.getValue();
- if (e.isString()) {
- if (!Ta(`${r}`))
- return g.create(m.VALUE);
- t = /* @__PURE__ */ new Date(`${r}`);
- } else {
- const o = +e.getValue();
- if (o < 0)
- return g.create(m.NUM);
- if (o === 0)
- return y.create(1);
- t = re(o);
- }
- const n = t.getUTCMonth() + 1;
- return y.create(n);
- }
- }
- class ug extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 3);
- }
- calculate(e, t, r) {
- let n = e, s = t;
- if (n.isArray()) {
- const l = n.getRowCount(), f = n.getColumnCount();
- if (l > 1 || f > 1)
- return g.create(m.VALUE);
- n = n.get(0, 0);
- }
- if (n.isError())
- return n;
- if (s.isArray()) {
- const l = s.getRowCount(), f = s.getColumnCount();
- if (l > 1 || f > 1)
- return g.create(m.VALUE);
- s = s.get(0, 0);
- }
- if (s.isError())
- return s;
- if (r != null && r.isError())
- return r;
- if (n.isBoolean() || s.isBoolean())
- return g.create(m.VALUE);
- const o = k(n);
- if (typeof o != "number")
- return o;
- const u = k(s);
- if (typeof u != "number")
- return u;
- if (r)
- return this._getResultByHolidays(o, u, r);
- const c = On(o, u);
- return y.create(c);
- }
- _getResultByHolidays(e, t, r) {
- const n = [];
- if (r != null && r.isArray()) {
- const o = r.getRowCount(), u = r.getColumnCount();
- for (let c = 0; c < o; c++)
- for (let l = 0; l < u; l++) {
- const f = r.get(c, l);
- if (f.isBoolean())
- return g.create(m.VALUE);
- const h = k(f);
- if (typeof h != "number")
- return h;
- n.push(h);
- }
- } else {
- if (r.isBoolean())
- return g.create(m.VALUE);
- const o = k(r);
- if (typeof o != "number")
- return o;
- n.push(o);
- }
- const s = On(e, t, 1, n);
- return y.create(s);
- }
- }
- class cg extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 4);
- }
- calculate(e, t, r, n) {
- 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);
- }
- _handleSingleObject(e, t, r, n) {
- let s = e, o = t;
- if (s.isArray()) {
- const h = s.getRowCount(), d = s.getColumnCount();
- if (h > 1 || d > 1)
- return g.create(m.VALUE);
- s = s.get(0, 0);
- }
- if (s.isError())
- return s;
- if (o.isArray()) {
- const h = o.getRowCount(), d = o.getColumnCount();
- if (h > 1 || d > 1)
- return g.create(m.VALUE);
- o = o.get(0, 0);
- }
- if (o.isError())
- return o;
- let u = 1;
- if (r) {
- if (u = r.getValue(), r.isBoolean() && (u = +u), r.isString() && !Ur(u))
- return g.create(m.VALUE);
- if (!Ur(u))
- return g.create(m.NUM);
- }
- if (s.isBoolean() || o.isBoolean())
- return g.create(m.VALUE);
- const c = k(s);
- if (typeof c != "number")
- return c;
- const l = k(o);
- if (typeof l != "number")
- return l;
- if (n)
- return this._getResultByHolidays(c, l, u, n);
- const f = On(c, l, u);
- return y.create(f);
- }
- _getResultByHolidays(e, t, r, n) {
- const s = [];
- if (n != null && n.isArray()) {
- const u = n.getRowCount(), c = n.getColumnCount();
- for (let l = 0; l < u; l++)
- for (let f = 0; f < c; f++) {
- const h = n.get(l, f);
- if (h.isBoolean())
- return g.create(m.VALUE);
- const d = k(h);
- if (typeof d != "number")
- return d;
- s.push(d);
- }
- } else {
- if (n.isBoolean())
- return g.create(m.VALUE);
- const u = k(n);
- if (typeof u != "number")
- return u;
- s.push(u);
- }
- const o = On(e, t, r, s);
- return y.create(o);
- }
- }
- class lg extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 0);
- A(this, "maxParams", 0);
- }
- calculate() {
- 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);
- return y.create(r, Fm);
- }
- }
- class fg extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- return e.isError() ? e : e.isArray() ? e.map((t) => t.isError() ? t : this._handleSingleObject(t)) : this._handleSingleObject(e);
- }
- _handleSingleObject(e) {
- const t = k(e);
- if (typeof t != "number")
- return t;
- if (t === 0)
- return y.create(0);
- const n = va(t).getUTCSeconds();
- return y.create(n);
- }
- }
- class hg extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 3);
- A(this, "maxParams", 3);
- }
- calculate(e, t, r) {
- if (e.isError())
- return e;
- if (t.isError())
- return t;
- if (r.isError())
- return r;
- const n = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1,
- r.isArray() ? r.getRowCount() : 1
- ), s = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1,
- r.isArray() ? r.getColumnCount() : 1
- ), o = O(n, s, e), u = O(n, s, t), c = O(n, s, r);
- return o.map((l, f, h) => this._calculateTime(l, u, c, f, h));
- }
- _calculateTime(e, t, r, n, s) {
- let o = e, u = t.get(n, s) || ie.create(), c = r.get(n, s) || ie.create();
- if ((o.isString() || o.isBoolean()) && (o = o.convertToNumberObjectValue()), (u.isString() || u.isBoolean()) && (u = u.convertToNumberObjectValue()), (c.isString() || c.isBoolean()) && (c = c.convertToNumberObjectValue()), o.isError())
- return o;
- if (u.isError())
- return u;
- if (c.isError())
- return c;
- let l = Math.floor(+o.getValue()), f = Math.floor(+u.getValue()), h = Math.floor(+c.getValue());
- if (l < 0 || f < 0 || h < 0 || l > 32767 || f > 32767 || h > 32767)
- return g.create(m.NUM);
- f += Math.floor(h / 60), h %= 60, l += Math.floor(f / 60), f %= 60, l %= 24;
- const _ = (l * 3600 + f * 60 + h) / 86400;
- return y.create(_, km);
- }
- }
- class mg extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- return e.isError() ? e : e.isArray() ? e.map((t) => this._handleSingleObject(t)) : this._handleSingleObject(e);
- }
- _handleSingleObject(e) {
- if (e.isString()) {
- const t = `${e.getValue()}`, r = du(t);
- if (r) {
- let { v: n, z: s } = r;
- if (s && Ba(s))
- return n instanceof Date && (n = Yr(n)), y.create(Af(+n));
- }
- }
- return g.create(m.VALUE);
- }
- }
- class gg extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- A(this, "needsReferenceObject", !0);
- }
- calculate(e) {
- const t = e.isReferenceObject();
- let r = e;
- if (t && (r = e.toArrayValueObject()), r.isArray()) {
- const s = r.getRowCount(), o = r.getColumnCount();
- if (s > 1 || o > 1)
- return g.create(m.VALUE);
- r = r.get(0, 0);
- }
- if (r.isError() || r.isNull() || r.isBoolean() || r.isString() || !t && r.isNumber() && r.getPattern() !== "")
- return r;
- const n = +r.getValue();
- return y.create(n, "yyyy-MM-dd hh:mm:ss AM/PM");
- }
- }
- class dg extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 0);
- A(this, "maxParams", 0);
- }
- calculate() {
- const e = ye(/* @__PURE__ */ new Date());
- return y.create(e, Ua);
- }
- }
- class Cg extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 2);
- A(this, "_returnTypeMap", {
- 1: [1, 2, 3, 4, 5, 6, 7],
- // Sunday = 1 ~ Saturday = 7
- 2: [7, 1, 2, 3, 4, 5, 6],
- // Monday = 1 ~ Sunday = 7
- 3: [6, 0, 1, 2, 3, 4, 5],
- // Monday = 0 ~ Sunday = 6
- 11: [7, 1, 2, 3, 4, 5, 6],
- // Monday = 1 ~ Sunday = 7
- 12: [6, 7, 1, 2, 3, 4, 5],
- // Tuesday = 1 ~ Monday = 7
- 13: [5, 6, 7, 1, 2, 3, 4],
- // Wednesday = 1 ~ Tuesday = 7
- 14: [4, 5, 6, 7, 1, 2, 3],
- // Thursday = 1 ~ Wednesday = 7
- 15: [3, 4, 5, 6, 7, 1, 2],
- // Friday = 1 ~ Thursday = 7
- 16: [2, 3, 4, 5, 6, 7, 1],
- // Saturday = 1 ~ Friday = 7
- 17: [1, 2, 3, 4, 5, 6, 7]
- // Sunday = 1 ~ Saturday = 7
- });
- }
- calculate(e, t) {
- const r = t != null ? t : y.create(1);
- if (e.isError())
- return e;
- if (r.isError())
- return r;
- const n = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- r.isArray() ? r.getRowCount() : 1
- ), s = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- r.isArray() ? r.getColumnCount() : 1
- ), o = O(n, s, e, g.create(m.NA)), u = O(n, s, r, g.create(m.NA)), c = o.map((l, f, h) => {
- const d = u.get(f, h);
- return this._handleSingleObject(l, d);
- });
- return n === 1 && s === 1 ? c.get(0, 0) : c;
- }
- _handleSingleObject(e, t) {
- let r = t;
- if (e.isError())
- return e;
- if (r.isError())
- return r;
- const n = k(e);
- if (typeof n != "number")
- return n;
- if (r.isString() && (r = r.convertToNumberObjectValue(), r.isError()))
- return r;
- const s = Math.floor(+r.getValue());
- if (!this._returnTypeMap[s])
- return g.create(m.NUM);
- const o = rr(n), u = this._returnTypeMap[s][o];
- return y.create(u);
- }
- }
- class _g extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 2);
- A(this, "_returnTypeMap", {
- 1: 0,
- 2: 1,
- 11: 1,
- 12: 2,
- 13: 3,
- 14: 4,
- 15: 5,
- 16: 6,
- 17: 0,
- 21: 4
- });
- }
- calculate(e, t) {
- let r = e, n = t != null ? t : y.create(1);
- if (r.isArray()) {
- const u = r.getRowCount(), c = r.getColumnCount();
- if (u > 1 || c > 1)
- return g.create(m.VALUE);
- r = r.get(0, 0);
- }
- if (r.isError())
- return r;
- if (n.isArray()) {
- const u = n.getRowCount(), c = n.getColumnCount();
- if (u > 1 || c > 1)
- return g.create(m.VALUE);
- n = n.get(0, 0);
- }
- if (n.isError())
- return n;
- if (r.isBoolean())
- return g.create(m.VALUE);
- const s = k(r);
- if (typeof s != "number")
- return s;
- if (n.isBoolean())
- return g.create(m.VALUE);
- const o = Math.floor(+n.getValue());
- return Number.isNaN(o) ? g.create(m.VALUE) : o in this._returnTypeMap ? this._getResult(s, o) : g.create(m.NUM);
- }
- _getResult(e, t) {
- const r = re(e), n = e > 0 ? r.getUTCFullYear() : 1900;
- let s = new Date(Date.UTC(n, 0, 1)), o = ye(s), u = rr(o), c;
- if (t === 21)
- 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 = ye(s), u = rr(o), u < 1 ? c = o + 1 : u <= 4 ? c = o - (u - 1) : c = o + (11 - u));
- else {
- const f = this._returnTypeMap[t];
- u < f ? c = o - (u + 7 - f) : c = o - (u - f);
- }
- const l = Math.ceil((e - c + 1) / 7);
- return y.create(l);
- }
- }
- class Ag extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 3);
- }
- calculate(e, t, r) {
- let n = e, s = t;
- if (n.isArray()) {
- const l = n.getRowCount(), f = n.getColumnCount();
- if (l > 1 || f > 1)
- return g.create(m.VALUE);
- n = n.get(0, 0);
- }
- if (n.isError())
- return n;
- if (s.isArray()) {
- const l = s.getRowCount(), f = s.getColumnCount();
- if (l > 1 || f > 1)
- return g.create(m.VALUE);
- s = s.get(0, 0);
- }
- if (s.isError())
- return s;
- if (r != null && r.isError())
- return r;
- if (n.isBoolean() || s.isBoolean())
- return g.create(m.VALUE);
- const o = k(n);
- if (typeof o != "number")
- return o;
- const u = +s.getValue();
- if (Number.isNaN(u))
- return g.create(m.VALUE);
- if (r)
- return this._getResultByHolidays(o, u, r);
- const c = Mn(o, u);
- return typeof c != "number" ? c : y.create(c);
- }
- _getResultByHolidays(e, t, r) {
- const n = [];
- if (r != null && r.isArray()) {
- const o = r.getRowCount(), u = r.getColumnCount();
- for (let c = 0; c < o; c++)
- for (let l = 0; l < u; l++) {
- const f = r.get(c, l);
- if (f.isBoolean())
- return g.create(m.VALUE);
- const h = k(f);
- if (typeof h != "number")
- return h;
- n.push(h);
- }
- } else {
- if (r.isBoolean())
- return g.create(m.VALUE);
- const o = k(r);
- if (typeof o != "number")
- return o;
- n.push(o);
- }
- const s = Mn(e, t, 1, n);
- return typeof s != "number" ? s : y.create(s);
- }
- }
- class Eg extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 4);
- }
- calculate(e, t, r, n) {
- 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);
- }
- _handleSingleObject(e, t, r, n) {
- const s = r != null ? r : y.create(1), o = this._checkArrayError(e);
- if (o.isError())
- return o;
- const u = this._checkArrayError(t);
- if (u.isError())
- return u;
- if (o.isBoolean() || u.isBoolean())
- return g.create(m.VALUE);
- const c = k(e);
- if (typeof c != "number")
- return c;
- const l = +t.getValue();
- if (Number.isNaN(l))
- return g.create(m.VALUE);
- let f = s.getValue();
- if (s.isBoolean() && (f = +f), s.isString() && (!Ur(f) || f === "1111111"))
- return g.create(m.VALUE);
- if (!Ur(f))
- return g.create(m.NUM);
- if (n)
- return this._getResultByHolidays(c, l, f, n);
- const h = Mn(c, l, f);
- return typeof h != "number" ? h : y.create(h);
- }
- _checkArrayError(e) {
- let t = e;
- if (t.isArray()) {
- const r = t.getRowCount(), n = t.getColumnCount();
- if (r > 1 || n > 1)
- return g.create(m.VALUE);
- t = t.get(0, 0);
- }
- return t.isError(), t;
- }
- _getResultByHolidays(e, t, r, n) {
- const s = [];
- if (n != null && n.isArray()) {
- const u = n.getRowCount(), c = n.getColumnCount();
- for (let l = 0; l < u; l++)
- for (let f = 0; f < c; f++) {
- const h = n.get(l, f);
- if (h.isBoolean())
- return g.create(m.VALUE);
- const d = k(h);
- if (typeof d != "number")
- return d;
- s.push(d);
- }
- } else {
- if (n.isBoolean())
- return g.create(m.VALUE);
- const u = k(n);
- if (typeof u != "number")
- return u;
- s.push(u);
- }
- const o = Mn(e, t, r, s);
- return typeof o != "number" ? o : y.create(o);
- }
- }
- class bg extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- return e.isArray() ? e.map((t) => this._handleSingleObject(t)) : this._handleSingleObject(e);
- }
- _handleSingleObject(e) {
- if (e.isError())
- return e;
- let t;
- const r = e.getValue();
- if (e.isString()) {
- if (!Ta(`${r}`))
- return g.create(m.VALUE);
- t = /* @__PURE__ */ new Date(`${r}`);
- } else {
- const o = +r;
- if (o < 0)
- return g.create(m.NUM);
- if (o === 0)
- return y.create(1900);
- t = re(o);
- }
- const n = t.getUTCFullYear();
- return y.create(n);
- }
- }
- class yg extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 3);
- }
- calculate(e, t, r) {
- let n = r != null ? r : y.create(0);
- const s = Xt(e);
- if (s.isError())
- return s;
- const o = Xt(t);
- if (o.isError())
- return o;
- if (n = Xt(n), n.isError())
- return n;
- if (s.isBoolean() || o.isBoolean() || n.isBoolean())
- return g.create(m.VALUE);
- const u = k(s);
- if (typeof u != "number")
- return u;
- const c = k(o);
- if (typeof c != "number")
- return c;
- const l = Math.floor(+n.getValue());
- if (Number.isNaN(l))
- return g.create(m.VALUE);
- if (l < 0 || l > 4)
- return g.create(m.NUM);
- const { days: f, yearDays: h } = _e(u, c, l), d = f / h;
- return y.create(d);
- }
- }
- const Rg = [
- [Km, be.DATE],
- [Xm, be.DATEDIF],
- [Zm, be.DATEVALUE],
- [zm, be.DAY],
- [Jm, be.DAYS],
- [eg, be.DAYS360],
- [tg, be.EDATE],
- [rg, be.EOMONTH],
- [ng, be.EPOCHTODATE],
- [sg, be.HOUR],
- [ag, be.ISOWEEKNUM],
- [ig, be.MINUTE],
- [og, be.MONTH],
- [ug, be.NETWORKDAYS],
- [cg, be.NETWORKDAYS_INTL],
- [lg, be.NOW],
- [fg, be.SECOND],
- [hg, be.TIME],
- [mg, be.TIMEVALUE],
- [gg, be.TO_DATE],
- [dg, be.TODAY],
- [Cg, be.WEEKDAY],
- [_g, be.WEEKNUM],
- [Ag, be.WORKDAY],
- [Eg, be.WORKDAY_INTL],
- [bg, be.YEAR],
- [yg, be.YEARFRAC]
- ];
- class pg extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- if (e.isNull() || t.isNull())
- return g.create(m.NA);
- const { isError: r, errorObject: n, variants: s } = H(e, t);
- if (r)
- return n;
- const [o, u] = s, c = +o.getValue(), l = Math.floor(+u.getValue());
- if (Number.isNaN(c) || Number.isNaN(l))
- return g.create(m.VALUE);
- if (l < 0)
- return g.create(m.NUM);
- const f = _r.besseli(c, l);
- return Number.isNaN(f) || !Number.isFinite(f) ? g.create(m.NUM) : y.create(f);
- }
- }
- class Vg extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- if (e.isNull() || t.isNull())
- return g.create(m.NA);
- const { isError: r, errorObject: n, variants: s } = H(e, t);
- if (r)
- return n;
- const [o, u] = s, c = +o.getValue(), l = Math.floor(+u.getValue());
- if (Number.isNaN(c) || Number.isNaN(l))
- return g.create(m.VALUE);
- if (l < 0)
- return g.create(m.NUM);
- const f = _r.besselj(c, l);
- return Number.isNaN(f) || !Number.isFinite(f) ? g.create(m.NUM) : y.create(f);
- }
- }
- class Ng extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- if (e.isNull() || t.isNull())
- return g.create(m.NA);
- const { isError: r, errorObject: n, variants: s } = H(e, t);
- if (r)
- return n;
- const [o, u] = s, c = +o.getValue(), l = Math.floor(+u.getValue());
- if (Number.isNaN(c) || Number.isNaN(l))
- return g.create(m.VALUE);
- if (l < 0)
- return g.create(m.NUM);
- const f = _r.besselk(c, l);
- return Number.isNaN(f) || !Number.isFinite(f) ? g.create(m.NUM) : y.create(f);
- }
- }
- class Og extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- if (e.isNull() || t.isNull())
- return g.create(m.NA);
- const { isError: r, errorObject: n, variants: s } = H(e, t);
- if (r)
- return n;
- const [o, u] = s, c = +o.getValue(), l = Math.floor(+u.getValue());
- if (Number.isNaN(c) || Number.isNaN(l))
- return g.create(m.VALUE);
- if (l < 0)
- return g.create(m.NUM);
- const f = _r.bessely(c, l);
- return Number.isNaN(f) || !Number.isFinite(f) ? g.create(m.NUM) : y.create(f);
- }
- }
- class Mg extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- const { isError: t, errorObject: r, variants: n } = H(e);
- if (t)
- return r;
- const [s] = n, o = `${s.getValue()}`;
- if (!Ra(o))
- return g.create(m.NUM);
- let u;
- return o.length === 10 && o.substring(0, 1) === "1" ? u = Number.parseInt(o.substring(1), 2) - 512 : u = Number.parseInt(o, 2), y.create(u);
- }
- }
- class wg extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- if (e.isNull())
- return g.create(m.NA);
- let r = 0;
- if (t) {
- const { isError: f, errorObject: h, variants: d } = H(t);
- if (f)
- return h;
- const [_] = d;
- if (r = Math.floor(+_.getValue()), Number.isNaN(r))
- return g.create(m.VALUE);
- if (r < 0 || r > 10)
- return g.create(m.NUM);
- }
- const { isError: n, errorObject: s, variants: o } = H(e);
- if (n)
- return s;
- const [u] = o, c = `${u.getValue()}`;
- if (!Ra(c))
- return g.create(m.NUM);
- let l;
- if (c.length === 10 && c.substring(0, 1) === "1")
- l = (1099511627264 + Number.parseInt(c.substring(1), 2)).toString(16);
- else if (l = Number.parseInt(c, 2).toString(16), t) {
- if (r < l.length)
- return g.create(m.NUM);
- l = "0".repeat(r - l.length) + l;
- }
- return j.create(l.toLocaleUpperCase());
- }
- }
- class Dg extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- if (e.isNull())
- return g.create(m.NA);
- let r = 0;
- if (t) {
- const { isError: f, errorObject: h, variants: d } = H(t);
- if (f)
- return h;
- const [_] = d;
- if (r = Math.floor(+_.getValue()), Number.isNaN(r))
- return g.create(m.VALUE);
- if (r < 0 || r > 10)
- return g.create(m.NUM);
- }
- const { isError: n, errorObject: s, variants: o } = H(e);
- if (n)
- return s;
- const [u] = o, c = `${u.getValue()}`;
- if (!Ra(c))
- return g.create(m.NUM);
- let l;
- if (c.length === 10 && c.substring(0, 1) === "1")
- l = (1073741312 + Number.parseInt(c.substring(1), 2)).toString(8);
- else if (l = Number.parseInt(c, 2).toString(8), t) {
- if (r < l.length)
- return g.create(m.NUM);
- l = "0".repeat(r - l.length) + l;
- }
- return j.create(l);
- }
- }
- class Sg extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- if (e.isError())
- return e;
- if (t.isError())
- return t;
- const r = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1
- ), n = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1
- ), s = O(r, n, e, g.create(m.NA)), o = O(r, n, t, g.create(m.NA)), u = s.map((c, l, f) => {
- let h = c;
- if (h.isString() && (h = h.convertToNumberObjectValue()), h.isError())
- return h;
- let d = o.get(l, f);
- if (d.isString() && (d = d.convertToNumberObjectValue()), d.isError())
- return d;
- const _ = +h.getValue(), C = +d.getValue();
- if (_ < 0 || C < 0 || Math.floor(_) !== _ || Math.floor(C) !== C || _ > 281474976710655 || C > 281474976710655)
- return g.create(m.NUM);
- const E = _ & C;
- return y.create(E);
- });
- return r === 1 && n === 1 ? u.get(0, 0) : u;
- }
- }
- class Pg extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- if (e.isError())
- return e;
- if (t.isError())
- return t;
- const r = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1
- ), n = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1
- ), s = O(r, n, e, g.create(m.NA)), o = O(r, n, t, g.create(m.NA)), u = s.map((c, l, f) => {
- let h = c;
- if (h.isString() && (h = h.convertToNumberObjectValue()), h.isError())
- return h;
- let d = o.get(l, f);
- if (d.isString() && (d = d.convertToNumberObjectValue()), d.isError())
- return d;
- const _ = +h.getValue();
- let C = +d.getValue();
- if (_ < 0 || Math.floor(_) !== _ || _ > 281474976710655 || Math.abs(C) > 53)
- return g.create(m.NUM);
- C = Math.trunc(C);
- const E = Number(C >= 0 ? BigInt(_) << BigInt(C) : BigInt(_) >> BigInt(-C));
- return E > 281474976710655 ? g.create(m.NUM) : y.create(E);
- });
- return r === 1 && n === 1 ? u.get(0, 0) : u;
- }
- }
- class Lg extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- if (e.isError())
- return e;
- if (t.isError())
- return t;
- const r = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1
- ), n = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1
- ), s = O(r, n, e, g.create(m.NA)), o = O(r, n, t, g.create(m.NA)), u = s.map((c, l, f) => {
- let h = c;
- if (h.isString() && (h = h.convertToNumberObjectValue()), h.isError())
- return h;
- let d = o.get(l, f);
- if (d.isString() && (d = d.convertToNumberObjectValue()), d.isError())
- return d;
- const _ = +h.getValue(), C = +d.getValue();
- if (_ < 0 || C < 0 || Math.floor(_) !== _ || Math.floor(C) !== C || _ > 281474976710655 || C > 281474976710655)
- return g.create(m.NUM);
- const E = Number(BigInt(_) | BigInt(C));
- return y.create(E);
- });
- return r === 1 && n === 1 ? u.get(0, 0) : u;
- }
- }
- class xg extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- if (e.isError())
- return e;
- if (t.isError())
- return t;
- const r = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1
- ), n = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1
- ), s = O(r, n, e, g.create(m.NA)), o = O(r, n, t, g.create(m.NA)), u = s.map((c, l, f) => {
- let h = c;
- if (h.isString() && (h = h.convertToNumberObjectValue()), h.isError())
- return h;
- let d = o.get(l, f);
- if (d.isString() && (d = d.convertToNumberObjectValue()), d.isError())
- return d;
- const _ = +h.getValue();
- let C = +d.getValue();
- if (_ < 0 || Math.floor(_) !== _ || _ > 281474976710655 || Math.abs(C) > 53)
- return g.create(m.NUM);
- C = Math.trunc(C);
- const E = Number(C >= 0 ? BigInt(_) >> BigInt(C) : BigInt(_) << BigInt(-C));
- return E > 281474976710655 ? g.create(m.NUM) : y.create(E);
- });
- return r === 1 && n === 1 ? u.get(0, 0) : u;
- }
- }
- class jg extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- if (e.isError())
- return e;
- if (t.isError())
- return t;
- const r = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1
- ), n = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1
- ), s = O(r, n, e, g.create(m.NA)), o = O(r, n, t, g.create(m.NA)), u = s.map((c, l, f) => {
- let h = c;
- if (h.isString() && (h = h.convertToNumberObjectValue()), h.isError())
- return h;
- let d = o.get(l, f);
- if (d.isString() && (d = d.convertToNumberObjectValue()), d.isError())
- return d;
- const _ = +h.getValue(), C = +d.getValue();
- if (_ < 0 || C < 0 || Math.floor(_) !== _ || Math.floor(C) !== C || _ > 281474976710655 || C > 281474976710655)
- return g.create(m.NUM);
- const E = _ ^ C;
- return y.create(E);
- });
- return r === 1 && n === 1 ? u.get(0, 0) : u;
- }
- }
- L.prototype.cos = function() {
- const i = this.toNumber();
- return new L(Math.cos(i));
- };
- let fe = class ce {
- constructor(a) {
- A(this, "_inumber", "");
- A(this, "_realNum", 0);
- A(this, "_iNum", 0);
- A(this, "_suffix", "");
- A(this, "_isError", !1);
- if (`${a}`.trim() === "") {
- this._isError = !0;
- return;
- }
- this._inumber = a, this._getImReal(), this._getImAginary(), this._getImSuffix();
- }
- static getComplex(a, e, t) {
- const r = new L(a).toSignificantDigits(15).toNumber(), n = new L(e).toSignificantDigits(15).toNumber(), s = t === "" ? "i" : t;
- let o;
- if (r === 0 && n === 0)
- o = 0;
- else if (r === 0)
- o = n === 1 ? s : `${n}${s}`;
- else if (n === 0)
- o = r;
- else {
- const u = n > 0 ? "+" : "", c = n === 1 ? s : `${n}${s}`;
- o = `${r}${u}${c}`;
- }
- return o;
- }
- static createByComplexStr(a, e, t) {
- const r = ce.getComplex(a, e, t);
- return new ce(r);
- }
- _getImReal() {
- if (this._inumber === 0 || this._inumber === "0") {
- this._realNum = 0;
- return;
- }
- const a = `${this._inumber}`;
- if (["i", "+i", "1i", "+1i", "-i", "-1i", "j", "+j", "1j", "+1j", "-j", "-1j"].indexOf(a) >= 0) {
- this._realNum = 0;
- return;
- }
- let e = a.indexOf("+"), t = a.indexOf("-");
- e === 0 && (e = a.indexOf("+", 1)), t === 0 && (t = a.indexOf("-", 1));
- const r = a.substring(a.length - 1, a.length), n = r === "i" || r === "j";
- if (e >= 0 || t >= 0) {
- if (!n) {
- this._isError = !0;
- return;
- }
- e >= 0 ? Number.isNaN(+a.substring(0, e)) || Number.isNaN(+a.substring(e + 1, a.length - 1)) ? this._isError = !0 : this._realNum = +a.substring(0, e) : Number.isNaN(+a.substring(0, t)) || Number.isNaN(+a.substring(t + 1, a.length - 1)) ? this._isError = !0 : this._realNum = +a.substring(0, t);
- } else
- n ? Number.isNaN(+a.substring(0, a.length - 1)) ? this._isError = !0 : this._realNum = 0 : Number.isNaN(+a) ? this._isError = !0 : this._realNum = +a;
- }
- _getImAginary() {
- if (this._isError)
- return;
- if (this._inumber === 0 || this._inumber === "0") {
- this._iNum = 0;
- return;
- }
- let a = `${this._inumber}`;
- if (["i", "j"].indexOf(a) >= 0) {
- this._iNum = 1;
- return;
- }
- a = a.replace("+i", "+1i").replace("-i", "-1i").replace("+j", "+1j").replace("-j", "-1j");
- let e = a.indexOf("+"), t = a.indexOf("-");
- e === 0 && (e = a.indexOf("+", 1)), t === 0 && (t = a.indexOf("-", 1));
- const r = a.substring(a.length - 1, a.length), n = r === "i" || r === "j";
- if (e >= 0 || t >= 0) {
- if (!n) {
- this._isError = !0;
- return;
- }
- e >= 0 ? Number.isNaN(+a.substring(0, e)) || Number.isNaN(+a.substring(e + 1, a.length - 1)) ? this._isError = !0 : this._iNum = +a.substring(e + 1, a.length - 1) : Number.isNaN(+a.substring(0, t)) || Number.isNaN(+a.substring(t + 1, a.length - 1)) ? this._isError = !0 : this._iNum = -+a.substring(t + 1, a.length - 1);
- } else
- n ? Number.isNaN(+a.substring(0, a.length - 1)) ? this._isError = !0 : this._iNum = +a.substring(0, a.length - 1) : Number.isNaN(+a) ? this._isError = !0 : this._iNum = 0;
- }
- _getImSuffix() {
- const a = `${this._inumber}`, e = a.substring(a.length - 1);
- this._suffix = e === "i" || e === "j" ? e : "";
- }
- getRealNum() {
- return this._realNum;
- }
- getINum() {
- return this._iNum;
- }
- getSuffix() {
- return this._suffix;
- }
- isError() {
- return this._isError;
- }
- toString() {
- return ce.getComplex(this._realNum, this._iNum, this._suffix);
- }
- isDifferentSuffixes(a) {
- const e = a.getSuffix();
- return this._suffix === "" || e === "" ? !1 : this._suffix !== e;
- }
- Abs() {
- return L.sqrt(L.pow(this._realNum, 2).add(L.pow(this._iNum, 2))).toSignificantDigits(16).toNumber();
- }
- Argument() {
- const a = L.sqrt(L.pow(this._realNum, 2).add(L.pow(this._iNum, 2)));
- let e = L.acos(new L(this._realNum).div(a)).toSignificantDigits(16).toNumber();
- return this._iNum < 0 && (e = -e), e;
- }
- Conjugate() {
- return ce.getComplex(this._realNum, -this._iNum, this._suffix);
- }
- Cos() {
- if (this._iNum) {
- const a = L.cos(this._realNum).mul(L.cosh(this._iNum)).toNumber(), e = L.sin(this._realNum).mul(L.sinh(this._iNum)).negated().toNumber();
- return ce.getComplex(a, e, this._suffix);
- } else {
- const a = L.cos(this._realNum).toNumber();
- return ce.getComplex(a, this._iNum, this._suffix);
- }
- }
- Cosh() {
- if (!Number.isFinite(Math.sinh(this._realNum)) || !Number.isFinite(Math.cosh(this._realNum)))
- return this._isError = !0, "";
- if (this._iNum) {
- const a = L.cosh(this._realNum).mul(L.cos(this._iNum)).toNumber(), e = L.sinh(this._realNum).mul(L.sin(this._iNum)).toNumber();
- return ce.getComplex(a, e, this._suffix);
- } else {
- const a = L.cosh(this._realNum).toNumber();
- return ce.getComplex(a, this._iNum, this._suffix);
- }
- }
- Cot() {
- if (this._iNum) {
- const a = L.cosh(this._iNum * 2).sub(L.cos(this._realNum * 2)), e = L.sin(this._realNum * 2).div(a).toNumber(), t = L.sinh(this._iNum * 2).div(a).negated().toNumber();
- return ce.getComplex(e, t, this._suffix);
- } else {
- const a = new L(1).div(L.tan(this._realNum)).toNumber();
- return ce.getComplex(a, this._iNum, this._suffix);
- }
- }
- Coth() {
- if (!Number.isFinite(Math.sinh(this._realNum)) || !Number.isFinite(Math.cosh(this._realNum)))
- return this._isError = !0, "";
- if (this._iNum) {
- const a = L.cosh(this._realNum * 2).sub(L.cos(this._iNum * 2)), e = L.sinh(this._realNum * 2).div(a).toNumber(), t = L.sin(this._iNum * 2).div(a).negated().toNumber();
- return ce.getComplex(e, t, this._suffix);
- } else {
- const a = new L(1).div(L.tanh(this._realNum)).toNumber();
- return ce.getComplex(a, this._iNum, this._suffix);
- }
- }
- Csc() {
- if (this._iNum) {
- const a = L.cosh(this._iNum * 2).sub(L.cos(this._realNum * 2)), e = L.sin(this._realNum).mul(L.cosh(this._iNum)).mul(2).div(a).toNumber(), t = L.cos(this._realNum).mul(L.sinh(this._iNum)).mul(-2).div(a).toNumber();
- return ce.getComplex(e, t, this._suffix);
- } else {
- const a = new L(1).div(L.sin(this._realNum)).toNumber();
- return ce.getComplex(a, this._iNum, this._suffix);
- }
- }
- Csch() {
- if (!Number.isFinite(Math.sinh(this._realNum)) || !Number.isFinite(Math.cosh(this._realNum)))
- return ce.getComplex(0, 0, this._suffix);
- if (this._iNum) {
- const a = L.cosh(this._realNum * 2).sub(L.cos(this._iNum * 2)), e = L.sinh(this._realNum).mul(L.cos(this._iNum)).mul(2).div(a).toNumber(), t = L.cosh(this._realNum).mul(L.sin(this._iNum)).mul(-2).div(a).toNumber();
- return ce.getComplex(e, t, this._suffix);
- } else {
- const a = new L(1).div(L.sinh(this._realNum)).toNumber();
- return ce.getComplex(a, this._iNum, this._suffix);
- }
- }
- Div(a) {
- const e = new L(this._realNum), t = new L(this._iNum), r = new L(a.getRealNum()), n = new L(a.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 === "" ? a.getSuffix() : this._suffix;
- return ce.getComplex(o, u, c);
- }
- Exp() {
- if (!Number.isFinite(Math.exp(this._realNum)))
- return this._isError = !0, "";
- const a = L.exp(this._realNum).mul(L.cos(this._iNum)).toNumber(), e = L.exp(this._realNum).mul(L.sin(this._iNum)).toNumber();
- return ce.getComplex(a, e, this._suffix);
- }
- Ln() {
- const a = L.sqrt(L.pow(this._realNum, 2).add(L.pow(this._iNum, 2))), e = L.ln(a).toNumber(), t = L.acos(new L(this._realNum).div(a)).toNumber();
- return ce.getComplex(e, t, this._suffix);
- }
- Log(a) {
- const e = L.sqrt(L.pow(this._realNum, 2).add(L.pow(this._iNum, 2))), t = L.ln(e);
- let r = L.acos(new L(this._realNum).div(e));
- this._iNum < 0 && (r = r.negated());
- const n = L.ln(a), s = new L(0), o = n.mul(n).add(s.mul(s));
- if (o.eq(0))
- return this._isError = !0, "";
- const u = t.mul(n).add(r.mul(s)).div(o).toNumber(), c = r.mul(n).sub(t.mul(s)).div(o).toNumber();
- return ce.getComplex(u, c, this._suffix);
- }
- Power(a) {
- if (this._realNum === 0 && this._iNum === 0)
- return a > 0 ? ce.getComplex(this._realNum, this._iNum, this._suffix) : (this._isError = !0, "");
- let e = L.sqrt(L.pow(this._realNum, 2).add(L.pow(this._iNum, 2))), t = L.acos(new L(this._realNum).div(e));
- this._iNum < 0 && (t = t.negated()), e = L.pow(e, a), t = t.mul(a);
- const r = L.cos(t).mul(e).toNumber(), n = L.sin(t).mul(e).toNumber();
- return !Number.isFinite(r) || !Number.isFinite(n) ? (this._isError = !0, "") : ce.getComplex(r, n, this._suffix);
- }
- Product(a) {
- const e = new L(this._realNum), t = new L(this._iNum), r = new L(a.getRealNum()), n = new L(a.getINum()), s = e.mul(r).sub(t.mul(n)).toNumber(), o = e.mul(n).add(t.mul(r)).toNumber(), u = this._suffix === "" ? a.getSuffix() : this._suffix;
- return ce.getComplex(s, o, u);
- }
- Sec() {
- if (this._iNum) {
- const a = L.cosh(this._iNum * 2).add(L.cos(this._realNum * 2)), e = L.cos(this._realNum).mul(L.cosh(this._iNum)).mul(2).div(a).toNumber(), t = L.sin(this._realNum).mul(L.sinh(this._iNum)).mul(2).div(a).toNumber();
- return ce.getComplex(e, t, this._suffix);
- } else {
- const a = new L(1).div(L.cos(this._realNum)).toNumber();
- return ce.getComplex(a, this._iNum, this._suffix);
- }
- }
- Sech() {
- if (!Number.isFinite(Math.sinh(this._realNum * 2)) || !Number.isFinite(Math.cosh(this._realNum * 2)))
- return ce.getComplex(0, 0, this._suffix);
- if (this._iNum) {
- const a = L.cosh(this._realNum * 2).add(L.cos(this._iNum * 2)), e = L.cosh(this._realNum).mul(L.cos(this._iNum)).mul(2).div(a).toNumber(), t = L.sinh(this._realNum).mul(L.sin(this._iNum)).mul(-2).div(a).toNumber();
- return ce.getComplex(e, t, this._suffix);
- } else {
- const a = new L(1).div(L.cosh(this._realNum)).toNumber();
- return ce.getComplex(a, this._iNum, this._suffix);
- }
- }
- Sin() {
- if (this._iNum) {
- const a = L.sin(this._realNum).mul(L.cosh(this._iNum)).toNumber(), e = L.cos(this._realNum).mul(L.sinh(this._iNum)).toNumber();
- return ce.getComplex(a, e, this._suffix);
- } else {
- const a = L.sin(this._realNum).toNumber();
- return ce.getComplex(a, this._iNum, this._suffix);
- }
- }
- Sinh() {
- if (!Number.isFinite(Math.sinh(this._realNum)) || !Number.isFinite(Math.cosh(this._realNum)))
- return this._isError = !0, "";
- if (this._iNum) {
- const a = L.sinh(this._realNum).mul(L.cos(this._iNum)).toNumber(), e = L.cosh(this._realNum).mul(L.sin(this._iNum)).toNumber();
- return ce.getComplex(a, e, this._suffix);
- } else {
- const a = L.sinh(this._realNum).toNumber();
- return ce.getComplex(a, this._iNum, this._suffix);
- }
- }
- Sqrt() {
- const a = L.sqrt(L.pow(this._realNum, 2).add(L.pow(this._iNum, 2))), e = L.sqrt(a);
- let t = L.acos(new L(this._realNum).div(a));
- this._iNum < 0 && (t = t.negated());
- const r = e.mul(L.cos(t.div(2).toNumber())).toNumber(), n = e.mul(L.sin(t.div(2))).toNumber();
- return ce.getComplex(r, n, this._suffix);
- }
- Sub(a) {
- const e = new L(this._realNum), t = new L(this._iNum), r = new L(a.getRealNum()), n = new L(a.getINum()), s = e.sub(r).toNumber(), o = t.sub(n).toNumber(), u = this._suffix === "" ? a.getSuffix() : this._suffix;
- return ce.getComplex(s, o, u);
- }
- Sum(a) {
- const e = new L(this._realNum), t = new L(this._iNum), r = new L(a.getRealNum()), n = new L(a.getINum()), s = e.add(r).toNumber(), o = t.add(n).toNumber(), u = this._suffix === "" ? a.getSuffix() : this._suffix;
- return ce.getComplex(s, o, u);
- }
- Tan() {
- if (this._iNum) {
- const a = L.cos(this._realNum * 2).add(L.cosh(this._iNum * 2)), e = L.sin(this._realNum * 2).div(a).toNumber(), t = L.sinh(this._iNum * 2).div(a).toNumber();
- return ce.getComplex(e, t, this._suffix);
- } else {
- const a = L.tan(this._realNum).toNumber();
- return ce.getComplex(a, this._iNum, this._suffix);
- }
- }
- Tanh() {
- if (!Number.isFinite(Math.sinh(this._realNum)) || !Number.isFinite(Math.cosh(this._realNum)))
- return this._isError = !0, "";
- if (this._iNum) {
- const a = L.cosh(this._realNum * 2).add(L.cos(this._iNum * 2)), e = L.sinh(this._realNum * 2).div(a).toNumber(), t = L.sin(this._iNum * 2).div(a).toNumber();
- return ce.getComplex(e, t, this._suffix);
- } else {
- const a = L.tanh(this._realNum).toNumber();
- return ce.getComplex(a, this._iNum, this._suffix);
- }
- }
- };
- class Ug extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 3);
- }
- calculate(e, t, r) {
- const n = r != null ? r : j.create("i"), { isError: s, errorObject: o, variants: u } = H(e, t, n);
- if (s)
- return o;
- const [c, l, f] = u, h = +c.getValue(), d = +l.getValue(), _ = `${f.getValue()}`;
- if (Number.isNaN(h) || Number.isNaN(d) || _ !== "i" && _ !== "j")
- return g.create(m.VALUE);
- const C = fe.getComplex(h, d, _);
- return typeof C == "number" ? y.create(C) : j.create(C);
- }
- }
- class vg extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 3);
- A(this, "maxParams", 3);
- // List of units supported by CONVERT and units defined by the International System of Units
- // [Name, Symbol, Alternate symbols, Quantity, ISU, CONVERT, Conversion ratio]
- A(this, "_units", [
- ["a.u. of action", "?", null, "action", !1, !1, 105457168181818e-48],
- ["a.u. of charge", "e", null, "electric_charge", !1, !1, 160217653141414e-33],
- ["a.u. of energy", "Eh", null, "energy", !1, !1, 435974417757576e-32],
- ["a.u. of length", "a?", null, "length", !1, !1, 529177210818182e-25],
- ["a.u. of mass", "m?", null, "mass", !1, !1, 910938261616162e-45],
- ["a.u. of time", "?/Eh", null, "time", !1, !1, 241888432650516e-31],
- ["admiralty knot", "admkn", null, "speed", !1, !0, 0.514773333],
- ["ampere", "A", null, "electric_current", !0, !1, 1],
- ["ampere per meter", "A/m", null, "magnetic_field_intensity", !0, !1, 1],
- ["ångström", "Å", ["ang"], "length", !1, !0, 1e-10],
- ["are", "ar", null, "area", !1, !0, 100],
- ["astronomical unit", "ua", null, "length", !1, !1, 149597870691667e-25],
- ["bar", "bar", null, "pressure", !1, !1, 1e5],
- ["barn", "b", null, "area", !1, !1, 1e-28],
- ["becquerel", "Bq", null, "radioactivity", !0, !1, 1],
- ["bit", "bit", ["b"], "information", !1, !0, 1],
- ["btu", "BTU", ["btu"], "energy", !1, !0, 1055.05585262],
- ["byte", "byte", null, "information", !1, !0, 8],
- ["candela", "cd", null, "luminous_intensity", !0, !1, 1],
- ["candela per square metre", "cd/m?", null, "luminance", !0, !1, 1],
- ["centigrade", "C", ["cel"], "temperature", !0, !1, 1],
- ["cubic ångström", "ang3", ["ang^3"], "volume", !1, !0, 1e-30],
- ["cubic foot", "ft3", ["ft^3"], "volume", !1, !0, 0.028316846592],
- ["cubic inch", "in3", ["in^3"], "volume", !1, !0, 16387064e-12],
- ["cubic light-year", "ly3", ["ly^3"], "volume", !1, !0, 846786664623715e-61],
- ["cubic metre", "m3", ["m^3"], "volume", !0, !0, 1],
- ["cubic mile", "mi3", ["mi^3"], "volume", !1, !0, 416818182544058e-5],
- ["cubic nautical mile", "Nmi3", ["Nmi^3"], "volume", !1, !0, 6352182208],
- ["cubic Pica", "Pica3", ["Picapt3", "Pica^3", "Picapt^3"], "volume", !1, !0, 758660370370369e-22],
- ["cubic yard", "yd3", ["yd^3"], "volume", !1, !0, 0.764554857984],
- ["cup", "cup", null, "volume", !1, !0, 2365882365e-13],
- ["dalton", "Da", ["u"], "mass", !1, !1, 166053886282828e-41],
- ["day", "d", ["day"], "time", !1, !0, 86400],
- ["degree", "°", null, "angle", !1, !1, 0.0174532925199433],
- ["dyne", "dyn", ["dy"], "force", !1, !0, 1e-5],
- ["electronvolt", "eV", ["ev"], "energy", !1, !0, 1.60217656514141],
- ["ell", "ell", null, "length", !1, !0, 1.143],
- ["erg", "erg", ["e"], "energy", !1, !0, 1e-7],
- ["fahrenheit", "F", ["fah"], "temperature", !0, !1, 1],
- ["fluid ounce", "oz", null, "volume", !1, !0, 295735295625e-16],
- ["foot", "ft", null, "length", !1, !0, 0.3048],
- ["foot-pound", "flb", null, "energy", !1, !0, 1.3558179483314],
- ["gal", "Gal", null, "acceleration", !1, !1, 0.01],
- ["gallon", "gal", null, "volume", !1, !0, 0.003785411784],
- ["gauss", "G", ["ga"], "magnetic_flux_density", !1, !0, 1],
- ["grain", "grain", null, "mass", !1, !0, 647989e-10],
- ["gram", "g", null, "mass", !1, !0, 1e-3],
- ["gray", "Gy", null, "absorbed_dose", !0, !1, 1],
- ["gross registered ton", "GRT", ["regton"], "volume", !1, !0, 2.8316846592],
- ["hectare", "ha", null, "area", !1, !0, 1e4],
- ["henry", "H", null, "inductance", !0, !1, 1],
- ["hertz", "Hz", null, "frequency", !0, !1, 1],
- ["horsepower", "HP", ["h"], "power", !1, !0, 745.69987158227],
- ["horsepower-hour", "HPh", ["hh", "hph"], "energy", !1, !0, 2684519538e-3],
- ["hour", "h", ["hr"], "time", !1, !0, 3600],
- ["imperial gallon (U.K.)", "uk_gal", null, "volume", !1, !0, 454609e-8],
- ["imperial hundredweight", "lcwt", ["uk_cwt", "hweight"], "mass", !1, !0, 50.802345],
- ["imperial quart (U.K)", "uk_qt", null, "volume", !1, !0, 0.0011365225],
- ["imperial ton", "brton", ["uk_ton", "LTON"], "mass", !1, !0, 1016.046909],
- ["inch", "in", null, "length", !1, !0, 0.0254],
- ["international acre", "uk_acre", null, "area", !1, !0, 4046.8564224],
- ["IT calorie", "cal", null, "energy", !1, !0, 4.1868],
- ["joule", "J", null, "energy", !0, !0, 1],
- ["katal", "kat", null, "catalytic_activity", !0, !1, 1],
- ["kelvin", "K", ["kel"], "temperature", !0, !0, 1],
- ["kilogram", "kg", null, "mass", !0, !0, 1],
- ["knot", "kn", null, "speed", !1, !0, 0.514444444444444],
- ["light-year", "ly", null, "length", !1, !0, 9460730472580800],
- ["litre", "L", ["l", "lt"], "volume", !1, !0, 1e-3],
- ["lumen", "lm", null, "luminous_flux", !0, !1, 1],
- ["lux", "lx", null, "illuminance", !0, !1, 1],
- ["maxwell", "Mx", null, "magnetic_flux", !1, !1, 1e-18],
- ["measurement ton", "MTON", null, "volume", !1, !0, 1.13267386368],
- ["meter per hour", "m/h", ["m/hr"], "speed", !1, !0, 27777777777778e-17],
- ["meter per second", "m/s", ["m/sec"], "speed", !0, !0, 1],
- ["meter per second squared", "m?s??", null, "acceleration", !0, !1, 1],
- ["parsec", "pc", ["parsec"], "length", !1, !0, 30856775814671900],
- ["meter squared per second", "m?/s", null, "kinematic_viscosity", !0, !1, 1],
- ["metre", "m", null, "length", !0, !0, 1],
- ["miles per hour", "mph", null, "speed", !1, !0, 0.44704],
- ["millimetre of mercury", "mmHg", null, "pressure", !1, !1, 133.322],
- ["minute", "?", null, "angle", !1, !1, 290888208665722e-18],
- ["minute", "min", ["mn"], "time", !1, !0, 60],
- ["modern teaspoon", "tspm", null, "volume", !1, !0, 5e-6],
- ["mole", "mol", null, "amount_of_substance", !0, !1, 1],
- ["morgen", "Morgen", null, "area", !1, !0, 2500],
- ["n.u. of action", "?", null, "action", !1, !1, 105457168181818e-48],
- ["n.u. of mass", "m?", null, "mass", !1, !1, 910938261616162e-45],
- ["n.u. of speed", "c?", null, "speed", !1, !1, 299792458],
- ["n.u. of time", "?/(me?c??)", null, "time", !1, !1, 128808866778687e-35],
- ["nautical mile", "M", ["Nmi"], "length", !1, !0, 1852],
- ["newton", "N", null, "force", !0, !0, 1],
- ["œrsted", "Oe ", null, "magnetic_field_intensity", !1, !1, 79.5774715459477],
- ["ohm", "Ω", null, "electric_resistance", !0, !1, 1],
- ["ounce mass", "ozm", null, "mass", !1, !0, 0.028349523125],
- ["pascal", "Pa", null, "pressure", !0, !1, 1],
- ["pascal second", "Pa?s", null, "dynamic_viscosity", !0, !1, 1],
- ["pferdestärke", "PS", null, "power", !1, !0, 735.49875],
- ["phot", "ph", null, "illuminance", !1, !1, 1e-4],
- ["pica (1/6 inch)", "pica", null, "length", !1, !0, 35277777777778e-17],
- ["pica (1/72 inch)", "Pica", ["Picapt"], "length", !1, !0, 0.00423333333333333],
- ["poise", "P", null, "dynamic_viscosity", !1, !1, 0.1],
- ["pond", "pond", null, "force", !1, !0, 980665e-8],
- ["pound force", "lbf", null, "force", !1, !0, 4.4482216152605],
- ["pound mass", "lbm", null, "mass", !1, !0, 0.45359237],
- ["quart", "qt", null, "volume", !1, !0, 946352946e-12],
- ["radian", "rad", null, "angle", !0, !1, 1],
- ["rankine", "Rank", null, "temperature", !1, !0, 1],
- ["reaumur", "Reau", null, "temperature", !1, !0, 1],
- ["second", "?", null, "angle", !1, !1, 484813681109536e-20],
- ["second", "s", ["sec"], "time", !0, !0, 1],
- ["short hundredweight", "cwt", ["shweight"], "mass", !1, !0, 45.359237],
- ["siemens", "S", null, "electrical_conductance", !0, !1, 1],
- ["sievert", "Sv", null, "equivalent_dose", !0, !1, 1],
- ["slug", "sg", null, "mass", !1, !0, 14.59390294],
- ["square ångström", "ang2", ["ang^2"], "area", !1, !0, 1e-20],
- ["square foot", "ft2", ["ft^2"], "area", !1, !0, 0.09290304],
- ["square inch", "in2", ["in^2"], "area", !1, !0, 64516e-8],
- ["square light-year", "ly2", ["ly^2"], "area", !1, !0, 895054210748189e17],
- ["square meter", "m?", null, "area", !0, !0, 1],
- ["square mile", "mi2", ["mi^2"], "area", !1, !0, 2589988110336e-6],
- ["square nautical mile", "Nmi2", ["Nmi^2"], "area", !1, !0, 3429904],
- ["square Pica", "Pica2", ["Picapt2", "Pica^2", "Picapt^2"], "area", !1, !0, 1792111111111e-17],
- ["square yard", "yd2", ["yd^2"], "area", !1, !0, 0.83612736],
- ["statute mile", "mi", null, "length", !1, !0, 1609.344],
- ["steradian", "sr", null, "solid_angle", !0, !1, 1],
- ["stilb", "sb", null, "luminance", !1, !1, 1e-4],
- ["stokes", "St", null, "kinematic_viscosity", !1, !1, 1e-4],
- ["stone", "stone", null, "mass", !1, !0, 6.35029318],
- ["tablespoon", "tbs", null, "volume", !1, !0, 147868e-10],
- ["teaspoon", "tsp", null, "volume", !1, !0, 492892e-11],
- ["tesla", "T", null, "magnetic_flux_density", !0, !0, 1],
- ["thermodynamic calorie", "c", null, "energy", !1, !0, 4.184],
- ["ton", "ton", null, "mass", !1, !0, 907.18474],
- ["tonne", "t", null, "mass", !1, !1, 1e3],
- ["U.K. pint", "uk_pt", null, "volume", !1, !0, 56826125e-11],
- ["U.S. bushel", "bushel", null, "volume", !1, !0, 0.03523907],
- ["U.S. oil barrel", "barrel", null, "volume", !1, !0, 0.158987295],
- ["U.S. pint", "pt", ["us_pt"], "volume", !1, !0, 473176473e-12],
- ["U.S. survey mile", "survey_mi", null, "length", !1, !0, 1609.347219],
- ["U.S. survey/statute acre", "us_acre", null, "area", !1, !0, 4046.87261],
- ["volt", "V", null, "voltage", !0, !1, 1],
- ["watt", "W", null, "power", !0, !0, 1],
- ["watt-hour", "Wh", ["wh"], "energy", !1, !0, 3600],
- ["weber", "Wb", null, "magnetic_flux", !0, !1, 1],
- ["yard", "yd", null, "length", !1, !0, 0.9144],
- ["year", "yr", null, "time", !1, !0, 31557600]
- ]);
- // Binary prefixes
- // [Name, Prefix power of 2 value, Previx value, Abbreviation, Derived from]
- A(this, "_binaryPrefixes", {
- Yi: ["yobi", 80, 12089258196146292e8, "Yi", "yotta"],
- Zi: ["zebi", 70, 11805916207174113e5, "Zi", "zetta"],
- Ei: ["exbi", 60, 1152921504606847e3, "Ei", "exa"],
- Pi: ["pebi", 50, 1125899906842624, "Pi", "peta"],
- Ti: ["tebi", 40, 1099511627776, "Ti", "tera"],
- Gi: ["gibi", 30, 1073741824, "Gi", "giga"],
- Mi: ["mebi", 20, 1048576, "Mi", "mega"],
- ki: ["kibi", 10, 1024, "ki", "kilo"]
- });
- // Unit prefixes
- // [Name, Multiplier, Abbreviation]
- A(this, "_unitPrefixes", {
- Y: ["yotta", 1e24, "Y"],
- Z: ["zetta", 1e21, "Z"],
- E: ["exa", 1e18, "E"],
- P: ["peta", 1e15, "P"],
- T: ["tera", 1e12, "T"],
- G: ["giga", 1e9, "G"],
- M: ["mega", 1e6, "M"],
- k: ["kilo", 1e3, "k"],
- h: ["hecto", 100, "h"],
- e: ["dekao", 10, "e"],
- d: ["deci", 0.1, "d"],
- c: ["centi", 0.01, "c"],
- m: ["milli", 1e-3, "m"],
- u: ["micro", 1e-6, "u"],
- n: ["nano", 1e-9, "n"],
- p: ["pico", 1e-12, "p"],
- f: ["femto", 1e-15, "f"],
- a: ["atto", 1e-18, "a"],
- z: ["zepto", 1e-21, "z"],
- y: ["yocto", 1e-24, "y"]
- });
- }
- calculate(e, t, r) {
- const { isError: n, errorObject: s, variants: o } = H(e, t, r);
- if (n)
- return s;
- const [u, c, l] = o, f = +u.getValue(), h = `${c.getValue()}`, d = `${l.getValue()}`;
- if (Number.isNaN(f))
- return g.create(m.VALUE);
- let _, C = 1, E, b = 1;
- const { _from: R, _to: p } = this._lookupFromAndToUnits(h, d);
- if (_ = R, E = p, _ === null) {
- const { _from: M, _fromMultiplier: w } = this._lookupFromPrefix(h);
- _ = M, C = w;
- }
- if (E === null) {
- const { _to: M, _toMultiplier: w } = this._lookupToPrefix(d);
- E = M, b = w;
- }
- if (_ === null || E === null || _[3] !== E[3])
- return g.create(m.NA);
- let N;
- return _[3] === "temperature" ? (N = this._getTemperatureConversion(f, _[1], E[1]), N = +N.toFixed(2)) : N = f * _[6] * C / (E[6] * b), y.create(N);
- }
- _lookupFromAndToUnits(e, t) {
- let r = null, n = null, s;
- for (let o = 0; o < this._units.length; o++)
- 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]);
- return {
- _from: r,
- _to: n
- };
- }
- _lookupFromPrefix(e) {
- let t = null, r = 1, n = e, s;
- const o = this._binaryPrefixes[e.substring(0, 2)];
- let u = this._unitPrefixes[e.substring(0, 1)];
- 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));
- for (let c = 0; c < this._units.length; c++)
- s = this._units[c][2] === null ? [] : this._units[c][2], (this._units[c][1] === n || s.indexOf(n) >= 0) && (t = this._units[c]);
- return {
- _from: t,
- _fromMultiplier: r
- };
- }
- _lookupToPrefix(e) {
- let t = null, r = 1, n = e, s;
- const o = this._binaryPrefixes[e.substring(0, 2)];
- let u = this._unitPrefixes[e.substring(0, 1)];
- 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));
- for (let c = 0; c < this._units.length; c++)
- s = this._units[c][2] === null ? [] : this._units[c][2], (this._units[c][1] === n || s.indexOf(n) >= 0) && (t = this._units[c]);
- return {
- _to: t,
- _toMultiplier: r
- };
- }
- _getTemperatureConversion(e, t, r) {
- switch (t) {
- case "C":
- return this._centigradeConversion(e, r);
- case "F":
- return this._fahrenheitConversion(e, r);
- case "K":
- return this._kelvinConversion(e, r);
- case "Rank":
- return this._rankineConversion(e, r);
- case "Reau":
- return this._reaumurConversion(e, r);
- default:
- return e;
- }
- }
- _centigradeConversion(e, t) {
- switch (t) {
- case "F":
- return e * 9 / 5 + 32;
- case "K":
- return e + 273.15;
- case "Rank":
- return (e + 273.15) * 9 / 5;
- case "Reau":
- return e * 4 / 5;
- default:
- return e;
- }
- }
- _fahrenheitConversion(e, t) {
- switch (t) {
- case "C":
- return (e - 32) * 5 / 9;
- case "K":
- return (e - 32) * 5 / 9 + 273.15;
- case "Rank":
- return e + 459.67;
- case "Reau":
- return (e - 32) * 4 / 9;
- default:
- return e;
- }
- }
- _kelvinConversion(e, t) {
- switch (t) {
- case "C":
- return e - 273.15;
- case "F":
- return (e - 273.15) * 9 / 5 + 32;
- case "Rank":
- return e * 9 / 5;
- case "Reau":
- return (e - 273.15) * 4 / 5;
- default:
- return e;
- }
- }
- _rankineConversion(e, t) {
- switch (t) {
- case "C":
- return (e - 491.67) * 5 / 9;
- case "F":
- return e - 459.67;
- case "K":
- return e * 5 / 9;
- case "Reau":
- return (e - 491.67) * 4 / 9;
- default:
- return e;
- }
- }
- _reaumurConversion(e, t) {
- switch (t) {
- case "C":
- return e * 5 / 4;
- case "F":
- return e * 9 / 4 + 32;
- case "K":
- return e * 5 / 4 + 273.15;
- case "Rank":
- return e * 9 / 4 + 491.67;
- default:
- return e;
- }
- }
- }
- class Tg extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- if (e.isNull())
- return g.create(m.NA);
- let r = 0;
- if (t) {
- const { isError: f, errorObject: h, variants: d } = H(t);
- if (f)
- return h;
- const [_] = d;
- if (r = Math.floor(+_.getValue()), Number.isNaN(r))
- return g.create(m.VALUE);
- if (r < 0 || r > 10)
- return g.create(m.NUM);
- }
- const { isError: n, errorObject: s, variants: o } = H(e);
- if (n)
- return s;
- const [u] = o, c = Math.trunc(+u.getValue());
- if (Number.isNaN(c))
- return g.create(m.VALUE);
- if (!/^-?[0-9]{1,3}$/.test(`${c}`) || c < -512 || c > 511)
- return g.create(m.NUM);
- let l;
- if (c < 0) {
- const f = (512 + c).toString(2);
- l = `1${"0".repeat(9 - f.length)}${f}`;
- } else if (l = Number.parseInt(`${c}`, 10).toString(2), t) {
- if (r < l.length)
- return g.create(m.NUM);
- l = "0".repeat(r - l.length) + l;
- }
- return j.create(l);
- }
- }
- class Bg extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- if (e.isNull())
- return g.create(m.NA);
- let r = 0;
- if (t) {
- const { isError: f, errorObject: h, variants: d } = H(t);
- if (f)
- return h;
- const [_] = d;
- if (r = Math.floor(+_.getValue()), Number.isNaN(r))
- return g.create(m.VALUE);
- if (r < 0 || r > 10)
- return g.create(m.NUM);
- }
- const { isError: n, errorObject: s, variants: o } = H(e);
- if (n)
- return s;
- const [u] = o, c = Math.trunc(+u.getValue());
- if (Number.isNaN(c))
- return g.create(m.VALUE);
- if (!/^-?[0-9]{1,12}$/.test(`${c}`) || c < -549755813888 || c > 549755813887)
- return g.create(m.NUM);
- let l;
- if (c < 0)
- l = (1099511627776 + c).toString(16);
- else if (l = Number.parseInt(`${c}`, 10).toString(16), t) {
- if (r < l.length)
- return g.create(m.NUM);
- l = "0".repeat(r - l.length) + l;
- }
- return j.create(l.toLocaleUpperCase());
- }
- }
- class Ig extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- if (e.isNull())
- return g.create(m.NA);
- let r = 0;
- if (t) {
- const { isError: f, errorObject: h, variants: d } = H(t);
- if (f)
- return h;
- const [_] = d;
- if (r = Math.floor(+_.getValue()), Number.isNaN(r))
- return g.create(m.VALUE);
- if (r < 0 || r > 10)
- return g.create(m.NUM);
- }
- const { isError: n, errorObject: s, variants: o } = H(e);
- if (n)
- return s;
- const [u] = o, c = Math.trunc(+u.getValue());
- if (Number.isNaN(c))
- return g.create(m.VALUE);
- if (!/^-?[0-9]{1,9}$/.test(`${c}`) || c < -536870912 || c > 536870911)
- return g.create(m.NUM);
- let l;
- if (c < 0)
- l = (1073741824 + c).toString(8);
- else if (l = Number.parseInt(`${c}`, 10).toString(8), t) {
- if (r < l.length)
- return g.create(m.NUM);
- l = "0".repeat(r - l.length) + l;
- }
- return j.create(l);
- }
- }
- class Fg extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- const r = t != null ? t : y.create(0), { isError: n, errorObject: s, variants: o } = H(e, r);
- if (n)
- return s;
- const [u, c] = o, l = +u.getValue(), f = +c.getValue();
- if (Number.isNaN(l) || Number.isNaN(f))
- return g.create(m.VALUE);
- const h = l === f ? 1 : 0;
- return y.create(h);
- }
- }
- class kg extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- let r;
- if (t) {
- const { isError: n, errorObject: s, variants: o } = H(e, t);
- if (n)
- return s;
- const [u, c] = o, l = +u.getValue(), f = +c.getValue();
- if (Number.isNaN(l) || Number.isNaN(f))
- return g.create(m.VALUE);
- r = Zt(f) - Zt(l);
- } else {
- const { isError: n, errorObject: s, variants: o } = H(e);
- if (n)
- return s;
- const [u] = o, c = +u.getValue();
- if (Number.isNaN(c))
- return g.create(m.VALUE);
- r = Zt(c);
- }
- return y.create(r);
- }
- }
- class $g extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- const { isError: t, errorObject: r, variants: n } = H(e);
- if (t)
- return r;
- const [s] = n, o = +s.getValue();
- if (Number.isNaN(o))
- return g.create(m.VALUE);
- const u = Zt(o);
- return y.create(u);
- }
- }
- class Yg extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- const { isError: t, errorObject: r, variants: n } = H(e);
- if (t)
- return r;
- const [s] = n, o = +s.getValue();
- if (Number.isNaN(o))
- return g.create(m.VALUE);
- const u = Na(o);
- return y.create(u);
- }
- }
- class Hg extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- const { isError: t, errorObject: r, variants: n } = H(e);
- if (t)
- return r;
- const [s] = n, o = +s.getValue();
- if (Number.isNaN(o))
- return g.create(m.VALUE);
- const u = Na(o);
- return y.create(u);
- }
- }
- var Z = /* @__PURE__ */ ((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))(Z || {});
- class Gg extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- if (e.isNull())
- return g.create(m.NA);
- const r = t != null ? t : y.create(0), { isError: n, errorObject: s, variants: o } = H(e, r);
- if (n)
- return s;
- const [u, c] = o, l = +u.getValue(), f = +c.getValue();
- if (Number.isNaN(l) || Number.isNaN(f))
- return g.create(m.VALUE);
- const h = l >= f ? 1 : 0;
- return y.create(h);
- }
- }
- class Qg extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- if (e.isNull())
- return g.create(m.NA);
- let r = 0;
- if (t) {
- const { isError: d, errorObject: _, variants: C } = H(t);
- if (d)
- return _;
- const [E] = C;
- if (r = Math.floor(+E.getValue()), Number.isNaN(r))
- return g.create(m.VALUE);
- if (r < 0 || r > 10)
- return g.create(m.NUM);
- }
- const { isError: n, errorObject: s, variants: o } = H(e);
- if (n)
- return s;
- const [u] = o, c = `${u.getValue()}`;
- if (!Va(c))
- return g.create(m.NUM);
- const l = c.length === 10 && c.substring(0, 1).toLocaleUpperCase() === "F", f = l ? Number.parseInt(c, 16) - 1099511627776 : Number.parseInt(c, 16);
- if (f < -512 || f > 511)
- return g.create(m.NUM);
- let h;
- if (l) {
- const d = (512 + f).toString(2);
- h = `1${"0".repeat(9 - d.length)}${d}`;
- } else if (h = f.toString(2), t) {
- if (r < h.length)
- return g.create(m.NUM);
- h = "0".repeat(r - h.length) + h;
- }
- return j.create(h);
- }
- }
- class Wg extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- const { isError: t, errorObject: r, variants: n } = H(e);
- if (t)
- return r;
- const [s] = n, o = `${s.getValue()}`;
- if (!Va(o))
- return g.create(m.NUM);
- let u = Number.parseInt(o, 16);
- return u >= 549755813888 && (u -= 1099511627776), y.create(u);
- }
- }
- class qg extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- if (e.isNull())
- return g.create(m.NA);
- let r = 0;
- if (t) {
- const { isError: h, errorObject: d, variants: _ } = H(t);
- if (h)
- return d;
- const [C] = _;
- if (r = Math.floor(+C.getValue()), Number.isNaN(r))
- return g.create(m.VALUE);
- if (r < 0 || r > 10)
- return g.create(m.NUM);
- }
- const { isError: n, errorObject: s, variants: o } = H(e);
- if (n)
- return s;
- const [u] = o, c = `${u.getValue()}`;
- if (!Va(c))
- return g.create(m.NUM);
- const l = Number.parseInt(c, 16);
- if (l > 536870911 && l < 1098974756864)
- return g.create(m.NUM);
- let f;
- if (l >= 1098974756864)
- f = (l - 1098437885952).toString(8);
- else if (f = l.toString(8), t) {
- if (r < f.length)
- return g.create(m.NUM);
- f = "0".repeat(r - f.length) + f;
- }
- return j.create(f);
- }
- }
- class Kg extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- const { isError: t, errorObject: r, variants: n } = H(e);
- if (t)
- return r;
- const [s] = n, o = `${s.getValue()}`, u = new fe(o);
- if (u.isError())
- return g.create(m.NUM);
- const c = u.Abs();
- return y.create(c);
- }
- }
- class Xg extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- const { isError: t, errorObject: r, variants: n } = H(e);
- if (t)
- return r;
- const [s] = n, o = `${s.getValue()}`, u = new fe(o);
- if (u.isError())
- return g.create(m.NUM);
- const c = u.getINum();
- return y.create(c);
- }
- }
- class Zg extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- const { isError: t, errorObject: r, variants: n } = H(e);
- if (t)
- return r;
- const [s] = n, o = `${s.getValue()}`, u = new fe(o);
- if (u.isError())
- return g.create(m.NUM);
- if (u.getRealNum() === 0 && u.getINum() === 0)
- return g.create(m.DIV_BY_ZERO);
- const c = u.Argument();
- return y.create(c);
- }
- }
- class zg extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- const { isError: t, errorObject: r, variants: n } = H(e);
- if (t)
- return r;
- const [s] = n, o = `${s.getValue()}`, u = new fe(o);
- if (u.isError())
- return g.create(m.NUM);
- const c = u.Conjugate();
- return typeof c == "number" || Q(c) ? y.create(+c) : j.create(c);
- }
- }
- class Jg extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- const { isError: t, errorObject: r, variants: n } = H(e);
- if (t)
- return r;
- const [s] = n, o = `${s.getValue()}`, u = new fe(o);
- if (u.isError())
- return g.create(m.NUM);
- const c = u.Cos();
- return typeof c == "number" || Q(c) ? y.create(+c) : j.create(c);
- }
- }
- class e1 extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- const { isError: t, errorObject: r, variants: n } = H(e);
- if (t)
- return r;
- const [s] = n, o = `${s.getValue()}`, u = new fe(o);
- if (u.isError())
- return g.create(m.NUM);
- const c = u.Cosh();
- return u.isError() ? g.create(m.NUM) : typeof c == "number" || Q(c) ? y.create(+c) : j.create(c);
- }
- }
- class t1 extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- const { isError: t, errorObject: r, variants: n } = H(e);
- if (t)
- return r;
- const [s] = n, o = `${s.getValue()}`, u = new fe(o);
- if (u.isError() || u.getRealNum() === 0 && u.getINum() === 0)
- return g.create(m.NUM);
- const c = u.Cot();
- return typeof c == "number" || Q(c) ? y.create(+c) : j.create(c);
- }
- }
- class r1 extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- const { isError: t, errorObject: r, variants: n } = H(e);
- if (t)
- return r;
- const [s] = n, o = `${s.getValue()}`, u = new fe(o);
- if (u.isError() || u.getRealNum() === 0 && u.getINum() === 0)
- return g.create(m.NUM);
- const c = u.Coth();
- return u.isError() ? g.create(m.NUM) : typeof c == "number" || Q(c) ? y.create(+c) : j.create(c);
- }
- }
- class n1 extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- const { isError: t, errorObject: r, variants: n } = H(e);
- if (t)
- return r;
- const [s] = n, o = `${s.getValue()}`, u = new fe(o);
- if (u.isError() || u.getRealNum() === 0 && u.getINum() === 0)
- return g.create(m.NUM);
- const c = u.Csc();
- return typeof c == "number" || Q(c) ? y.create(+c) : j.create(c);
- }
- }
- class s1 extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- const { isError: t, errorObject: r, variants: n } = H(e);
- if (t)
- return r;
- const [s] = n, o = `${s.getValue()}`, u = new fe(o);
- if (u.isError() || u.getRealNum() === 0 && u.getINum() === 0)
- return g.create(m.NUM);
- const c = u.Csch();
- return typeof c == "number" || Q(c) ? y.create(+c) : j.create(c);
- }
- }
- class a1 extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- if (e.isNull() || t.isNull())
- return g.create(m.NA);
- const { isError: r, errorObject: n, variants: s } = H(e, t);
- if (r)
- return n;
- const [o, u] = s, c = `${o.getValue()}`, l = `${u.getValue()}`, f = new fe(c), h = new fe(l);
- if (f.isError() || h.isError() || f.isDifferentSuffixes(h) || h.getRealNum() === 0 && h.getINum() === 0)
- return g.create(m.NUM);
- const d = f.Div(h);
- return typeof d == "number" || Q(d) ? y.create(+d) : j.create(d);
- }
- }
- class i1 extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- const { isError: t, errorObject: r, variants: n } = H(e);
- if (t)
- return r;
- const [s] = n, o = `${s.getValue()}`, u = new fe(o);
- if (u.isError())
- return g.create(m.NUM);
- const c = u.Exp();
- return u.isError() ? g.create(m.NUM) : typeof c == "number" || Q(c) ? y.create(+c) : j.create(c);
- }
- }
- class o1 extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- const { isError: t, errorObject: r, variants: n } = H(e);
- if (t)
- return r;
- const [s] = n, o = `${s.getValue()}`, u = new fe(o);
- if (u.isError() || u.getRealNum() === 0 && u.getINum() === 0)
- return g.create(m.NUM);
- const c = u.Ln();
- return typeof c == "number" || Q(c) ? y.create(+c) : j.create(c);
- }
- }
- class u1 extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- const { isError: r, errorObject: n, variants: s } = H(e);
- if (r)
- return n;
- const [o] = s;
- let u = t != null ? t : y.create(10);
- if (u.isArray()) {
- const b = u.getRowCount(), R = u.getColumnCount();
- if (b > 1 || R > 1)
- return g.create(m.VALUE);
- u = u.get(0, 0);
- }
- const { isError: c, errorObject: l, variants: f } = I(u);
- if (c)
- return l;
- const [h] = f, d = `${o.getValue()}`, _ = +h.getValue(), C = new fe(d);
- if (C.isError() || C.getRealNum() === 0 && C.getINum() === 0 || _ <= 0)
- return g.create(m.NUM);
- const E = C.Log(_);
- return C.isError() ? g.create(m.NUM) : typeof E == "number" || Q(E) ? y.create(+E) : j.create(E);
- }
- }
- class c1 extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- const { isError: t, errorObject: r, variants: n } = H(e);
- if (t)
- return r;
- const [s] = n, o = `${s.getValue()}`, u = new fe(o);
- if (u.isError() || u.getRealNum() === 0 && u.getINum() === 0)
- return g.create(m.NUM);
- const c = u.Log(2);
- return typeof c == "number" || Q(c) ? y.create(+c) : j.create(c);
- }
- }
- class l1 extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- const { isError: t, errorObject: r, variants: n } = H(e);
- if (t)
- return r;
- const [s] = n, o = `${s.getValue()}`, u = new fe(o);
- if (u.isError() || u.getRealNum() === 0 && u.getINum() === 0)
- return g.create(m.NUM);
- const c = u.Log(10);
- return typeof c == "number" || Q(c) ? y.create(+c) : j.create(c);
- }
- }
- class f1 extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- if (e.isNull() || t.isNull())
- return g.create(m.NA);
- const { isError: r, errorObject: n, variants: s } = H(e, t);
- if (r)
- return n;
- const [o, u] = s, c = `${o.getValue()}`, l = new fe(c);
- if (l.isError())
- return g.create(m.NUM);
- const f = +u.getValue();
- if (Number.isNaN(f))
- return g.create(m.VALUE);
- const h = l.Power(f);
- return l.isError() ? g.create(m.NUM) : typeof h == "number" || Q(h) ? y.create(+h) : j.create(h);
- }
- }
- class h1 extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 255);
- }
- calculate(...e) {
- let t = "";
- for (let r = 0; r < e.length; r++) {
- if (t instanceof g)
- return t;
- const n = e[r];
- if (n.isArray()) {
- let s = !1, o;
- if (n.iterator((u) => {
- if (t = this._handleSingleObject(u, t), t instanceof g)
- return s = !0, o = t, !1;
- }), s)
- return o;
- } else
- t = this._handleSingleObject(n, t);
- }
- return t instanceof g ? t : typeof t == "number" || Q(t) ? y.create(+t) : j.create(t);
- }
- _handleSingleObject(e, t) {
- let r = t;
- if (e.isError())
- return e;
- if (e.isBoolean())
- return g.create(m.VALUE);
- const n = `${e.getValue()}`;
- if (typeof t != "number" && !t) {
- const s = new fe(n);
- if (s.isError())
- return g.create(m.NUM);
- r = s.toString();
- } else {
- const s = new fe(t), o = new fe(n);
- if (s.isError() || o.isError())
- return g.create(m.NUM);
- if (s.isDifferentSuffixes(o))
- return g.create(m.VALUE);
- r = s.Product(o);
- }
- return r;
- }
- }
- class m1 extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- const { isError: t, errorObject: r, variants: n } = H(e);
- if (t)
- return r;
- const [s] = n, o = `${s.getValue()}`, u = new fe(o);
- if (u.isError())
- return g.create(m.NUM);
- const c = u.getRealNum();
- return y.create(c);
- }
- }
- class g1 extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- const { isError: t, errorObject: r, variants: n } = H(e);
- if (t)
- return r;
- const [s] = n, o = `${s.getValue()}`, u = new fe(o);
- if (u.isError())
- return g.create(m.NUM);
- const c = u.Sec();
- return typeof c == "number" || Q(c) ? y.create(+c) : j.create(c);
- }
- }
- class d1 extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- const { isError: t, errorObject: r, variants: n } = H(e);
- if (t)
- return r;
- const [s] = n, o = `${s.getValue()}`, u = new fe(o);
- if (u.isError())
- return g.create(m.NUM);
- const c = u.Sech();
- return typeof c == "number" || Q(c) ? y.create(+c) : j.create(c);
- }
- }
- class C1 extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- const { isError: t, errorObject: r, variants: n } = H(e);
- if (t)
- return r;
- const [s] = n, o = `${s.getValue()}`, u = new fe(o);
- if (u.isError())
- return g.create(m.NUM);
- const c = u.Sin();
- return typeof c == "number" || Q(c) ? y.create(+c) : j.create(c);
- }
- }
- class _1 extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- const { isError: t, errorObject: r, variants: n } = H(e);
- if (t)
- return r;
- const [s] = n, o = `${s.getValue()}`, u = new fe(o);
- if (u.isError())
- return g.create(m.NUM);
- const c = u.Sinh();
- return u.isError() ? g.create(m.NUM) : typeof c == "number" || Q(c) ? y.create(+c) : j.create(c);
- }
- }
- class A1 extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- const { isError: t, errorObject: r, variants: n } = H(e);
- if (t)
- return r;
- const [s] = n, o = `${s.getValue()}`, u = new fe(o);
- if (u.isError())
- return g.create(m.NUM);
- if (u.getRealNum() === 0 && u.getINum() === 0)
- return y.create(0);
- const c = u.Sqrt();
- return typeof c == "number" || Q(c) ? y.create(+c) : j.create(c);
- }
- }
- class E1 extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- if (e.isNull() || t.isNull())
- return g.create(m.NA);
- const { isError: r, errorObject: n, variants: s } = H(e, t);
- if (r)
- return n;
- const [o, u] = s, c = `${o.getValue()}`, l = `${u.getValue()}`, f = new fe(c), h = new fe(l);
- if (f.isError() || h.isError() || f.isDifferentSuffixes(h))
- return g.create(m.NUM);
- const d = f.Sub(h);
- return typeof d == "number" || Q(d) ? y.create(+d) : j.create(d);
- }
- }
- class b1 extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 255);
- }
- calculate(...e) {
- let t = "";
- for (let r = 0; r < e.length; r++) {
- if (t instanceof g)
- return t;
- const n = e[r];
- if (n.isArray()) {
- let s = !1, o;
- if (n.iterator((u) => {
- if (t = this._handleSingleObject(u, t), t instanceof g)
- return s = !0, o = t, !1;
- }), s)
- return o;
- } else
- t = this._handleSingleObject(n, t);
- }
- return t instanceof g ? t : typeof t == "number" || Q(t) ? y.create(+t) : j.create(t);
- }
- _handleSingleObject(e, t) {
- let r = t;
- if (e.isError())
- return e;
- if (e.isBoolean())
- return g.create(m.VALUE);
- const n = `${e.getValue()}`;
- if (typeof t != "number" && !t) {
- const s = new fe(n);
- if (s.isError())
- return g.create(m.NUM);
- r = s.toString();
- } else {
- const s = new fe(t), o = new fe(n);
- if (s.isError() || o.isError())
- return g.create(m.NUM);
- if (s.isDifferentSuffixes(o))
- return g.create(m.VALUE);
- r = s.Sum(o);
- }
- return r;
- }
- }
- class y1 extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- const { isError: t, errorObject: r, variants: n } = H(e);
- if (t)
- return r;
- const [s] = n, o = `${s.getValue()}`, u = new fe(o);
- if (u.isError())
- return g.create(m.NUM);
- const c = u.Tan();
- return typeof c == "number" || Q(c) ? y.create(+c) : j.create(c);
- }
- }
- class R1 extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- const { isError: t, errorObject: r, variants: n } = H(e);
- if (t)
- return r;
- const [s] = n, o = `${s.getValue()}`, u = new fe(o);
- if (u.isError())
- return g.create(m.NUM);
- const c = u.Tanh();
- return u.isError() ? g.create(m.NUM) : typeof c == "number" || Q(c) ? y.create(+c) : j.create(c);
- }
- }
- class p1 extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- if (e.isNull())
- return g.create(m.NA);
- let r = 0;
- if (t) {
- const { isError: d, errorObject: _, variants: C } = H(t);
- if (d)
- return _;
- const [E] = C;
- if (r = Math.floor(+E.getValue()), Number.isNaN(r))
- return g.create(m.VALUE);
- if (r < 0 || r > 10)
- return g.create(m.NUM);
- }
- const { isError: n, errorObject: s, variants: o } = H(e);
- if (n)
- return s;
- const [u] = o, c = `${u.getValue()}`;
- if (!pa(c))
- return g.create(m.NUM);
- const l = c.length === 10 && c.substring(0, 1) === "7", f = l ? Number.parseInt(c, 8) - 1073741824 : Number.parseInt(c, 8);
- if (f < -512 || f > 511)
- return g.create(m.NUM);
- let h;
- if (l) {
- const d = (512 + f).toString(2);
- h = `1${"0".repeat(9 - d.length)}${d}`;
- } else if (h = f.toString(2), t) {
- if (r < h.length)
- return g.create(m.NUM);
- h = "0".repeat(r - h.length) + h;
- }
- return j.create(h);
- }
- }
- class V1 extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- const { isError: t, errorObject: r, variants: n } = H(e);
- if (t)
- return r;
- const [s] = n, o = `${s.getValue()}`;
- if (!pa(o))
- return g.create(m.NUM);
- let u = Number.parseInt(o, 8);
- return u >= 536870912 && (u -= 1073741824), y.create(u);
- }
- }
- class N1 extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- if (e.isNull())
- return g.create(m.NA);
- let r = 0;
- if (t) {
- const { isError: h, errorObject: d, variants: _ } = H(t);
- if (h)
- return d;
- const [C] = _;
- if (r = Math.floor(+C.getValue()), Number.isNaN(r))
- return g.create(m.VALUE);
- if (r < 0 || r > 10)
- return g.create(m.NUM);
- }
- const { isError: n, errorObject: s, variants: o } = H(e);
- if (n)
- return s;
- const [u] = o, c = `${u.getValue()}`;
- if (!pa(c))
- return g.create(m.NUM);
- const l = Number.parseInt(c, 8);
- let f;
- if (l >= 536870912)
- f = `ff${(l + 3221225472).toString(16)}`;
- else if (f = l.toString(16), t) {
- if (r < f.length)
- return g.create(m.NUM);
- f = "0".repeat(r - f.length) + f;
- }
- return j.create(f.toLocaleUpperCase());
- }
- }
- const O1 = [
- [pg, Z.BESSELI],
- [Vg, Z.BESSELJ],
- [Ng, Z.BESSELK],
- [Og, Z.BESSELY],
- [Mg, Z.BIN2DEC],
- [wg, Z.BIN2HEX],
- [Dg, Z.BIN2OCT],
- [Sg, Z.BITAND],
- [Pg, Z.BITLSHIFT],
- [Lg, Z.BITOR],
- [xg, Z.BITRSHIFT],
- [jg, Z.BITXOR],
- [Ug, Z.COMPLEX],
- [vg, Z.CONVERT],
- [Tg, Z.DEC2BIN],
- [Bg, Z.DEC2HEX],
- [Ig, Z.DEC2OCT],
- [Fg, Z.DELTA],
- [kg, Z.ERF],
- [$g, Z.ERF_PRECISE],
- [Yg, Z.ERFC],
- [Hg, Z.ERFC_PRECISE],
- [Gg, Z.GESTEP],
- [Qg, Z.HEX2BIN],
- [Wg, Z.HEX2DEC],
- [qg, Z.HEX2OCT],
- [Kg, Z.IMABS],
- [Xg, Z.IMAGINARY],
- [Zg, Z.IMARGUMENT],
- [zg, Z.IMCONJUGATE],
- [Jg, Z.IMCOS],
- [e1, Z.IMCOSH],
- [t1, Z.IMCOT],
- [r1, Z.IMCOTH],
- [n1, Z.IMCSC],
- [s1, Z.IMCSCH],
- [a1, Z.IMDIV],
- [i1, Z.IMEXP],
- [o1, Z.IMLN],
- [u1, Z.IMLOG],
- [l1, Z.IMLOG10],
- [c1, Z.IMLOG2],
- [f1, Z.IMPOWER],
- [h1, Z.IMPRODUCT],
- [m1, Z.IMREAL],
- [g1, Z.IMSEC],
- [d1, Z.IMSECH],
- [C1, Z.IMSIN],
- [_1, Z.IMSINH],
- [A1, Z.IMSQRT],
- [E1, Z.IMSUB],
- [b1, Z.IMSUM],
- [y1, Z.IMTAN],
- [R1, Z.IMTANH],
- [p1, Z.OCT2BIN],
- [V1, Z.OCT2DEC],
- [N1, Z.OCT2HEX]
- ];
- var ee = /* @__PURE__ */ ((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 || {});
- function es(i, a, e, t) {
- const r = It(i, a, e), { days: n } = _e(r, i, t);
- return n;
- }
- function qe(i, a, e, t) {
- let r;
- if (t === 1) {
- const n = It(i, a, e);
- let s = re(n);
- s = Er(s, 12 / e);
- const o = ye(s);
- n < 0 && e === 1 ? r = 365 : r = o - n;
- } else t === 3 ? r = 365 / e : r = 360 / e;
- return r;
- }
- function Eu(i, a, e) {
- const t = re(i);
- let r = re(a);
- for (r.setUTCFullYear(t.getUTCFullYear()), r < t && r.setUTCFullYear(r.getUTCFullYear() + 1); r > t; )
- r = Er(r, -12 / e);
- return r = Er(r, 12 / e), ye(r);
- }
- function nr(i, a, e) {
- let t = 0;
- const r = re(i);
- let n = re(a);
- for (; n > r; )
- n = Er(n, -12 / e), t++;
- return t;
- }
- function It(i, a, e) {
- const t = re(i);
- let r = re(a);
- for (r.setUTCFullYear(t.getUTCFullYear()), r < t && r.setUTCFullYear(r.getUTCFullYear() + 1); r > t; )
- r = Er(r, -12 / e);
- return ye(r);
- }
- function bu(i, a, e, t, r, n) {
- const s = es(i, a, r, n), o = qe(i, a, r, n), u = nr(i, a, r), c = (o - s) / o - 1, l = t / r + 1, f = e * 100 / r;
- let h = 0, d = 0;
- for (let E = 1; E <= u; E++) {
- const b = E + c, R = f / l ** b;
- h += b * R, d += R;
- }
- const _ = u + c, C = 100 / l ** _;
- return h += _ * C, d += C, h / d / r;
- }
- function Gr(i, a, e, t, r) {
- let n;
- if (i === 0)
- n = (e + t) / a;
- else {
- const s = (1 + i) ** a;
- n = r === 1 ? (t * i / (s - 1) + e * i / (1 - 1 / s)) / (1 + i) : t * i / (s - 1) + e * i / (1 - 1 / s);
- }
- return -n;
- }
- function sr(i, a, e, t, r) {
- let n;
- if (i === 0)
- n = t + e * a;
- else {
- if (i === -1 && a === 0)
- return Number.NaN;
- const s = (1 + i) ** a;
- n = r === 1 ? t * s + e * (1 + i) * (s - 1) / i : t * s + e * (s - 1) / i;
- }
- return -n;
- }
- function yu(i, a, e, t, r, n) {
- const s = Gr(i, e, t, r, n);
- return (a === 1 ? n === 1 ? 0 : -t : n === 1 ? sr(i, a - 2, s, t, 1) - s : sr(i, a - 1, s, t, 0)) * i;
- }
- function Ru(i, a) {
- let e = 0;
- for (let t = 1; t <= a.length; t++)
- e += a[t - 1] / (1 + i) ** t;
- return e;
- }
- function pu(i, a, e, t, r, n, s, o, u) {
- const c = Kt(e, t, u), l = qe(i, t, o, u);
- return c < l ? M1(
- i,
- a,
- e,
- t,
- r,
- n,
- s,
- o,
- u,
- c,
- l
- ) : w1(
- i,
- a,
- e,
- t,
- r,
- n,
- s,
- o,
- u,
- l
- );
- }
- function M1(i, a, e, t, r, n, s, o, u, c, l) {
- let f = 0;
- const h = nr(i, a, o), d = Kt(i, t, u);
- f += s / (1 + n / o) ** (h - 1 + d / l), f += 100 * r / o * c / l / (1 + n / o) ** (d / l);
- for (let C = 2; C <= h; C++)
- f += 100 * r / o / (1 + n / o) ** (C - 1 + d / l);
- const _ = Kt(e, i, u);
- return f -= 100 * r / o * _ / l, f;
- }
- function w1(i, a, e, t, r, n, s, o, u, c) {
- let l = 0;
- const f = nr(t, a, o), h = D1(t, i, 12 / o);
- let d;
- if (u === 2 || u === 3) {
- const R = Eu(i, t, o);
- d = Kt(i, R, u);
- } else {
- const R = It(i, t, o), { days: p } = _e(R, i, u);
- d = c - p;
- }
- l += s / (1 + n / o) ** (f + h + d / c);
- const _ = nr(e, t, o);
- let C = t, E = 0, b = 0;
- for (let R = _; R >= 1; R--) {
- const p = Jt(C, -12 / o, !1), N = u === 1 ? Kt(p, C, u) : c, M = R > 1 ? N : Kt(e, C, u);
- E += M / N;
- const w = e > p ? e : p, D = i < C ? i : C, S = Kt(w, D, u);
- b += S / N, C = p;
- }
- l += 100 * r / o * E / (1 + n / o) ** (h + d / c);
- for (let R = 1; R <= f; R++)
- l += 100 * r / o / (1 + n / o) ** (R + h + d / c);
- return l -= 100 * r / o * b, l;
- }
- function Kt(i, a, e) {
- const { days: t } = _e(i, a, e);
- return i < a ? t : 0;
- }
- function Vu(i, a, e) {
- const t = re(i), r = t.getUTCFullYear(), n = t.getUTCMonth(), s = t.getUTCDate(), o = Ar(r, n, s), u = re(a), c = u.getUTCFullYear(), l = u.getUTCMonth(), f = u.getUTCDate(), h = Ar(c, l, f);
- return !(s !== f && !(o && h) || Math.abs((c - r) * 12 + (l - n)) % (12 / e) !== 0);
- }
- function Or(i, a, e) {
- return It(i, a, e) >= 0;
- }
- function Jt(i, a, e) {
- let t = re(i);
- if (t = Er(t, a), e) {
- const r = t.getUTCFullYear(), n = t.getUTCMonth(), s = Hr(r, n);
- t.setUTCDate(s);
- }
- return ye(t);
- }
- function D1(i, a, e, t) {
- const r = re(i), n = re(a), s = r.getUTCFullYear(), o = r.getUTCMonth(), u = r.getUTCDate(), c = n.getUTCFullYear(), l = n.getUTCMonth(), f = n.getUTCDate(), h = Ar(s, o, u), d = !h && o !== 1 && u > 28 && u < Hr(s, o) ? Ar(c, l, f) : h, _ = Jt(a, 0, d);
- let C = 1 + +(a < _), E = Jt(_, e, d);
- for (; !(e > 0 ? E >= a : E <= a); )
- E = Jt(E, e, d), C++;
- return C;
- }
- function Ia(i, a) {
- let n = 1, s = 0, o = i, u;
- for (; n > 1e-7 && s < 500; ) {
- const c = (a(o + 1e-7) - a(o - 1e-7)) / 2e-7;
- u = o - a(o) / c, s++, n = Math.abs(u - o), o = u;
- }
- return Number.isNaN(o) || Math.abs(o) === 1 / 0 || s === 500 ? S1(i, a) : o;
- }
- function S1(i, a) {
- const r = Number.MAX_VALUE, n = -1, s = 1.6;
- let o = i - 0.01 <= n ? n + 1e-7 : i - 0.01, u = i + 0.01 >= r ? r - 1e-7 : i + 0.01, c, l, f = 0;
- if (i <= n || i >= r)
- return g.create(m.NUM);
- for (let E = 0; E < 60; E++) {
- c = o <= n ? n + 1e-7 : o, l = u >= r ? r - 1e-7 : u;
- const b = a(c), R = a(l);
- if (b * R <= 0)
- break;
- if (b * R > 0)
- o = c + s * (c - l), u = l + s * (l - c);
- else
- return g.create(m.NUM);
- if (E === 59)
- return g.create(m.NUM);
- }
- c = c, l = l;
- let h = a(c);
- const d = a(l);
- let _, C;
- if (Math.abs(h) < 1e-7 || Math.abs(d) < 1e-7)
- return g.create(m.NUM);
- do
- C = c + (l - c) / 2, _ = a(C), h * _ < 0 ? l = C : c = C, h = a(c), f++;
- while (Math.abs(_) > 1e-7 && f < 60);
- return C;
- }
- function un(i, a, e, t, r, n, s) {
- const o = nr(i, a, n), u = qe(i, a, n, s), c = es(i, a, n, s);
- if (o === 1) {
- const h = u - c, d = 100 * e / n + r, _ = t / n * h / u + 1, C = 100 * e / n * c / u;
- return d / _ - C;
- }
- const l = u - c;
- let f = r / (1 + t / n) ** (o - 1 + l / u);
- for (let h = 1; h <= o; h++)
- f += 100 * e / n / (1 + t / n) ** (h - 1 + l / u);
- return f -= 100 * e / n * c / u, f;
- }
- function zs(i, a, e, t, r) {
- let n = 0, s = r / e;
- s >= 1 ? (s = 1, n = t === 1 ? i : 0) : n = i * (1 - s) ** (t - 1);
- const o = i * (1 - s) ** t;
- let u = 0;
- return o < a ? u = n - a : u = n - o, u < 0 && (u = 0), u;
- }
- class P1 extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 6);
- A(this, "maxParams", 8);
- }
- calculate(e, t, r, n, s, o, u, c) {
- const l = u != null ? u : y.create(0), f = c != null ? c : T.create(!0), { isError: h, errorObject: d, variants: _ } = H(e, t, r, n, s, o, l);
- if (h)
- return d;
- const [C, E, b, R, p, N, M] = _, w = k(C);
- if (typeof w != "number")
- return w;
- const D = k(E);
- if (typeof D != "number")
- return D;
- const S = k(b);
- if (typeof S != "number")
- return S;
- const P = +R.getValue(), U = +p.getValue(), x = Math.floor(+N.getValue()), F = Math.floor(+M.getValue()), W = +f.getValue();
- return Number.isNaN(P) || Number.isNaN(U) || Number.isNaN(x) || Number.isNaN(F) || Number.isNaN(W) ? g.create(m.VALUE) : P <= 0 || U <= 0 || ![1, 2, 4].includes(x) || F < 0 || F > 4 || Math.floor(w) >= Math.floor(S) ? g.create(m.NUM) : this._getResult(w, D, S, P, U, x, F, W);
- }
- _getResult(e, t, r, n, s, o, u, c) {
- let l = It(e, t, o);
- if (l <= 0)
- return y.create(0);
- l = It(r, t, o);
- const f = 12 / o, h = re(t), d = h.getUTCFullYear(), _ = h.getUTCMonth(), C = h.getUTCDate(), E = Ar(d, _, C);
- let b = Jt(t, -f, E);
- if (r > t && c)
- for (b = t; b < r; )
- b = Jt(b, f, E);
- let R = e > b ? e : b, { days: p } = _e(R, r, u);
- if (l >= e) {
- const { days: P } = _e(R, r, u ? 4 : 0);
- p = P;
- }
- r < R && (p = -p);
- let N = qe(b, t, o, u), M = p / N, w = b, D = e;
- for (; w > e; ) {
- D = w, w = Jt(w, -f, E), R = e > w ? e : w;
- const { days: P } = _e(R, D, u);
- if (u === 0)
- D >= R || e <= w ? p = P : p = -P, N = qe(w, D, o, u);
- else if (p = D < R ? -P : P, u === 3)
- N = 365 / o;
- else {
- const { days: U } = _e(w, D, u);
- N = D < w ? -U : U;
- }
- M += e <= w ? c ? 1 : 0 : p / N;
- }
- const S = s * n / o * M;
- return y.create(S);
- }
- }
- class L1 extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 4);
- A(this, "maxParams", 5);
- }
- calculate(e, t, r, n, s) {
- const o = s != null ? s : y.create(0), { isError: u, errorObject: c, variants: l } = H(e, t, r, n, o);
- if (u)
- return c;
- const [f, h, d, _, C] = l, E = k(f);
- if (typeof E != "number")
- return E;
- const b = k(h);
- if (typeof b != "number")
- return b;
- const R = +d.getValue(), p = +_.getValue(), N = Math.floor(+C.getValue());
- if (Number.isNaN(R) || Number.isNaN(p) || Number.isNaN(N))
- return g.create(m.VALUE);
- if (R <= 0 || p <= 0 || N < 0 || N > 4 || Math.floor(E) > Math.floor(b))
- return g.create(m.NUM);
- if (Math.floor(E) === Math.floor(b))
- return y.create(0);
- const { days: M, yearDays: w } = _e(E, b, N), D = p * R * M / w;
- return y.create(D);
- }
- }
- class x1 extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 6);
- A(this, "maxParams", 7);
- }
- calculate(e, t, r, n, s, o, u) {
- const c = u != null ? u : y.create(0), { isError: l, errorObject: f, variants: h } = H(e, t, r, n, s, o, c);
- if (l)
- return f;
- const [d, _, C, E, b, R, p] = h, N = k(_);
- if (typeof N != "number")
- return N;
- const M = k(C);
- if (typeof M != "number")
- return M;
- const w = +d.getValue(), D = +E.getValue();
- let S = +b.getValue();
- const P = +R.getValue(), U = Math.floor(+p.getValue());
- return Number.isNaN(w) || Number.isNaN(D) || Number.isNaN(S) || Number.isNaN(P) || Number.isNaN(U) ? g.create(m.VALUE) : w <= 0 || D < 0 || w < D || Math.floor(N) > Math.floor(M) || S < 0 || P <= 0 || ![0, 1, 3, 4].includes(U) ? g.create(m.NUM) : (S > 1 ? S = Math.floor(S) : S = Math.ceil(S), this._getResult(w, N, M, D, S, P, U));
- }
- _getResult(e, t, r, n, s, o, u) {
- const c = e - n, l = e * o, { days: f, yearDays: h } = _e(t, r, u), d = f / h, _ = Math.ceil(c / l - d);
- if (_ < 0)
- return y.create(0);
- let C = l;
- return s === 0 ? C = l * d : s === _ ? C = c - l * (d + s - 1) : s > _ && (C = 0), y.create(C);
- }
- }
- class j1 extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 3);
- A(this, "maxParams", 4);
- }
- calculate(e, t, r, n) {
- const s = n != null ? n : y.create(0), { isError: o, errorObject: u, variants: c } = H(e, t, r, s);
- if (o)
- return u;
- const [l, f, h, d] = c, _ = k(l);
- if (typeof _ != "number")
- return _;
- const C = k(f);
- if (typeof C != "number")
- return C;
- const E = Math.floor(+h.getValue()), b = Math.floor(+d.getValue());
- if (Number.isNaN(E) || Number.isNaN(b))
- return g.create(m.VALUE);
- if (![1, 2, 4].includes(E) || b < 0 || b > 4 || Math.floor(_) >= Math.floor(C))
- return g.create(m.NUM);
- const R = es(_, C, E, b);
- return y.create(R);
- }
- }
- class U1 extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 3);
- A(this, "maxParams", 4);
- }
- calculate(e, t, r, n) {
- const s = n != null ? n : y.create(0), { isError: o, errorObject: u, variants: c } = H(e, t, r, s);
- if (o)
- return u;
- const [l, f, h, d] = c, _ = k(l);
- if (typeof _ != "number")
- return _;
- const C = k(f);
- if (typeof C != "number")
- return C;
- const E = Math.floor(+h.getValue()), b = Math.floor(+d.getValue());
- if (Number.isNaN(E) || Number.isNaN(b))
- return g.create(m.VALUE);
- if (![1, 2, 4].includes(E) || b < 0 || b > 4 || Math.floor(_) >= Math.floor(C))
- return g.create(m.NUM);
- const R = qe(_, C, E, b);
- return y.create(R);
- }
- }
- class v1 extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 3);
- A(this, "maxParams", 4);
- }
- calculate(e, t, r, n) {
- const s = n != null ? n : y.create(0), { isError: o, errorObject: u, variants: c } = H(e, t, r, s);
- if (o)
- return u;
- const [l, f, h, d] = c, _ = k(l);
- if (typeof _ != "number")
- return _;
- const C = k(f);
- if (typeof C != "number")
- return C;
- const E = Math.floor(+h.getValue()), b = Math.floor(+d.getValue());
- if (Number.isNaN(E) || Number.isNaN(b))
- return g.create(m.VALUE);
- if (![1, 2, 4].includes(E) || b < 0 || b > 4 || Math.floor(_) >= Math.floor(C))
- return g.create(m.NUM);
- const R = re(_), p = re(C);
- for (p.setUTCFullYear(R.getUTCFullYear()), p < R && p.setUTCFullYear(p.getUTCFullYear() + 1); p > R; )
- p.setUTCMonth(p.getUTCMonth() - 12 / E);
- p.setUTCMonth(p.getUTCMonth() + 12 / E);
- const N = ye(p), { days: M } = _e(_, N, b);
- return y.create(M);
- }
- }
- class T1 extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 3);
- A(this, "maxParams", 4);
- }
- calculate(e, t, r, n) {
- const s = n != null ? n : y.create(0), { isError: o, errorObject: u, variants: c } = H(e, t, r, s);
- if (o)
- return u;
- const [l, f, h, d] = c, _ = k(l);
- if (typeof _ != "number")
- return _;
- const C = k(f);
- if (typeof C != "number")
- return C;
- const E = Math.floor(+h.getValue()), b = Math.floor(+d.getValue());
- if (Number.isNaN(E) || Number.isNaN(b))
- return g.create(m.VALUE);
- if (![1, 2, 4].includes(E) || b < 0 || b > 4 || Math.floor(_) >= Math.floor(C))
- return g.create(m.NUM);
- const R = Eu(_, C, E);
- return y.create(R);
- }
- }
- class B1 extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 3);
- A(this, "maxParams", 4);
- }
- calculate(e, t, r, n) {
- const s = n != null ? n : y.create(0), { isError: o, errorObject: u, variants: c } = H(e, t, r, s);
- if (o)
- return u;
- const [l, f, h, d] = c, _ = k(l);
- if (typeof _ != "number")
- return _;
- const C = k(f);
- if (typeof C != "number")
- return C;
- const E = Math.floor(+h.getValue()), b = Math.floor(+d.getValue());
- if (Number.isNaN(E) || Number.isNaN(b))
- return g.create(m.VALUE);
- if (![1, 2, 4].includes(E) || b < 0 || b > 4 || Math.floor(_) >= Math.floor(C) || It(_, C, E) < 0)
- return g.create(m.NUM);
- const p = nr(_, C, E);
- return y.create(p);
- }
- }
- class I1 extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 3);
- A(this, "maxParams", 4);
- }
- calculate(e, t, r, n) {
- const s = n != null ? n : y.create(0), { isError: o, errorObject: u, variants: c } = H(e, t, r, s);
- if (o)
- return u;
- const [l, f, h, d] = c, _ = k(l);
- if (typeof _ != "number")
- return _;
- const C = k(f);
- if (typeof C != "number")
- return C;
- const E = Math.floor(+h.getValue()), b = Math.floor(+d.getValue());
- if (Number.isNaN(E) || Number.isNaN(b))
- return g.create(m.VALUE);
- if (![1, 2, 4].includes(E) || b < 0 || b > 4 || Math.floor(_) >= Math.floor(C))
- return g.create(m.NUM);
- let R = It(_, C, E);
- return R < 0 && (R = 0), y.create(R);
- }
- }
- class F1 extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 6);
- A(this, "maxParams", 6);
- }
- calculate(e, t, r, n, s, o) {
- const { isError: u, errorObject: c, variants: l } = H(e, t, r, n, s, o);
- if (u)
- return c;
- const [f, h, d, _, C, E] = l, b = +f.getValue(), R = +h.getValue(), p = +d.getValue(), N = +_.getValue(), M = +C.getValue(), w = +E.getValue();
- return Number.isNaN(b) || Number.isNaN(R) || Number.isNaN(p) || Number.isNaN(N) || Number.isNaN(M) || Number.isNaN(w) ? g.create(m.VALUE) : b <= 0 || R <= 0 || p <= 0 || N < 1 || M < 1 || N > M || N > R || M > R || ![0, 1].includes(w) ? g.create(m.NUM) : Math.trunc(N) !== N && Math.trunc(M) !== M && Math.trunc(N) === Math.trunc(M) ? y.create(0) : this._getResult(b, R, p, N, M, w);
- }
- _getResult(e, t, r, n, s, o) {
- const u = Gr(e, t, r, 0, o);
- let c = 0, l = Math.ceil(n);
- l === 1 && (o === 0 && (c = -r), l++);
- let f = !1;
- for (let h = l; h <= s; h++) {
- const d = o === 1 ? sr(e, h - 2, u, r, 1) : sr(e, h - 1, u, r, 0);
- if (d === 0) {
- f = !0;
- break;
- }
- c += o === 1 ? d - u : d;
- }
- return c *= e, (c < u * (s - n + 1) || f) && (c = u * (s - n + 1)), y.create(c);
- }
- }
- class k1 extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 6);
- A(this, "maxParams", 6);
- }
- calculate(e, t, r, n, s, o) {
- const { isError: u, errorObject: c, variants: l } = H(e, t, r, n, s, o);
- if (u)
- return c;
- const [f, h, d, _, C, E] = l, b = +f.getValue(), R = +h.getValue(), p = +d.getValue(), N = +_.getValue(), M = +C.getValue(), w = +E.getValue();
- return Number.isNaN(b) || Number.isNaN(R) || Number.isNaN(p) || Number.isNaN(N) || Number.isNaN(M) || Number.isNaN(w) ? g.create(m.VALUE) : b <= 0 || R <= 0 || p <= 0 || N < 1 || M < 1 || N > M || ![0, 1].includes(w) ? g.create(m.NUM) : Math.trunc(N) !== N && Math.trunc(M) !== M && Math.trunc(N) === Math.trunc(M) ? y.create(0) : this._getResult(b, R, p, N, M, w);
- }
- _getResult(e, t, r, n, s, o) {
- const u = Gr(e, t, r, 0, o);
- let c = 0, l = Math.ceil(n);
- l === 1 && (c = o === 0 ? u + r * e : u, l++);
- for (let f = l; f <= s; f++)
- c += o === 1 ? u - (sr(e, f - 2, u, r, 1) - u) * e : u - sr(e, f - 1, u, r, 0) * e;
- return y.create(c);
- }
- }
- class $1 extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 4);
- A(this, "maxParams", 5);
- A(this, "needsLocale", !0);
- }
- calculate(e, t, r, n, s) {
- let o = s != null ? s : y.create(12);
- o.isNull() && (o = y.create(12));
- const u = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1,
- r.isArray() ? r.getRowCount() : 1,
- n.isArray() ? n.getRowCount() : 1,
- o.isArray() ? o.getRowCount() : 1
- ), c = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1,
- r.isArray() ? r.getColumnCount() : 1,
- n.isArray() ? n.getColumnCount() : 1,
- o.isArray() ? o.getColumnCount() : 1
- ), l = O(u, c, e, g.create(m.NA)), f = O(u, c, t, g.create(m.NA)), h = O(u, c, r, g.create(m.NA)), d = O(u, c, n, g.create(m.NA)), _ = O(u, c, o, g.create(m.NA)), C = l.map((E, b, R) => {
- const p = f.get(b, R), N = h.get(b, R), M = d.get(b, R), w = _.get(b, R), { isError: D, errorObject: S, variants: P } = I(E, p, N, M, w);
- if (D)
- return S;
- const [U, x, F, W, ne] = P, z = +U.getValue(), G = +x.getValue(), ge = +F.getValue();
- let de = +W.getValue();
- const Ee = Math.floor(+ne.getValue());
- return z < 0 || G < 0 || ge <= 0 || de <= 0 || Math.floor(de) > Math.floor(ge) || Ee < 1 || Ee > 12 ? g.create(m.NUM) : (de < 1 && (de = 1), de = Math.floor(de), this._getResult(z, G, ge, de, Ee, b, R));
- });
- return u === 1 && c === 1 ? C.get(0, 0) : C;
- }
- _getResult(e, t, r, n, s, o, u) {
- const c = +(1 - (t / e) ** (1 / r)).toFixed(3), l = e * c * s / 12;
- let f = l, h = 0;
- const d = n === r ? r - 1 : n;
- for (let C = 2; C <= d; C++)
- h = (e - f) * c, f += h;
- let _;
- return n === 1 ? _ = l : n === r ? _ = (e - f) * c : _ = h, Number.isNaN(_) || !Number.isFinite(_) ? g.create(m.NUM) : o === 0 && u === 0 ? y.create(_, Ke(this.getLocale())) : y.create(_);
- }
- }
- class Y1 extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 4);
- A(this, "maxParams", 5);
- A(this, "needsLocale", !0);
- }
- calculate(e, t, r, n, s) {
- let o = s != null ? s : y.create(2);
- o.isNull() && (o = y.create(2));
- const u = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1,
- r.isArray() ? r.getRowCount() : 1,
- n.isArray() ? n.getRowCount() : 1,
- o.isArray() ? o.getRowCount() : 1
- ), c = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1,
- r.isArray() ? r.getColumnCount() : 1,
- n.isArray() ? n.getColumnCount() : 1,
- o.isArray() ? o.getColumnCount() : 1
- ), l = O(u, c, e, g.create(m.NA)), f = O(u, c, t, g.create(m.NA)), h = O(u, c, r, g.create(m.NA)), d = O(u, c, n, g.create(m.NA)), _ = O(u, c, o, g.create(m.NA)), C = l.map((E, b, R) => {
- const p = f.get(b, R), N = h.get(b, R), M = d.get(b, R), w = _.get(b, R), { isError: D, errorObject: S, variants: P } = I(E, p, N, M, w);
- if (D)
- return S;
- const [U, x, F, W, ne] = P, z = +U.getValue(), G = +x.getValue(), ge = +F.getValue(), de = +W.getValue(), Ee = +ne.getValue();
- if (z < 0 || G < 0 || ge <= 0 || de <= 0 || de > ge || Ee <= 0)
- return g.create(m.NUM);
- const Re = zs(z, G, ge, de, Ee);
- return Number.isNaN(Re) || !Number.isFinite(Re) ? g.create(m.NUM) : b === 0 && R === 0 ? y.create(Re, Ke(this.getLocale())) : y.create(Re);
- });
- return u === 1 && c === 1 ? C.get(0, 0) : C;
- }
- }
- class H1 extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 4);
- A(this, "maxParams", 5);
- }
- calculate(e, t, r, n, s) {
- const o = s != null ? s : y.create(0), { isError: u, errorObject: c, variants: l } = H(e, t, r, n, o);
- if (u)
- return c;
- const [f, h, d, _, C] = l, E = k(f);
- if (typeof E != "number")
- return E;
- const b = k(h);
- if (typeof b != "number")
- return b;
- const R = +d.getValue(), p = +_.getValue(), N = Math.floor(+C.getValue());
- if (Number.isNaN(R) || Number.isNaN(p) || Number.isNaN(N))
- return g.create(m.VALUE);
- if (R <= 0 || p <= 0 || N < 0 || N > 4 || Math.floor(E) >= Math.floor(b))
- return g.create(m.NUM);
- const { days: M, yearDays: w } = _e(E, b, N), D = (p - R) / p * (w / M);
- return y.create(D);
- }
- }
- class G1 extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- const { isError: r, errorObject: n, variants: s } = H(e, t);
- if (r)
- return n;
- const [o, u] = s, c = +o.getValue();
- let l = Math.floor(+u.getValue());
- if (Number.isNaN(c) || Number.isNaN(l))
- return g.create(m.VALUE);
- if (l < 0)
- return g.create(m.NUM);
- if (l >= 0 && l < 1)
- return g.create(m.DIV_BY_ZERO);
- l = Number.parseInt(`${l}`, 10);
- let f = Number.parseInt(`${c}`, 10);
- f += c % 1 * 10 ** Math.ceil(Math.log(l) / Math.LN10) / l;
- const h = 10 ** (Math.ceil(Math.log(l) / Math.LN2) + 1);
- return f = Math.round(f * h) / h, y.create(f);
- }
- }
- class Q1 extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- const { isError: r, errorObject: n, variants: s } = H(e, t);
- if (r)
- return n;
- const [o, u] = s, c = +o.getValue();
- let l = Math.floor(+u.getValue());
- if (Number.isNaN(c) || Number.isNaN(l))
- return g.create(m.VALUE);
- if (l < 0)
- return g.create(m.NUM);
- if (l >= 0 && l < 1)
- return g.create(m.DIV_BY_ZERO);
- l = Number.parseInt(`${l}`, 10);
- let f = Number.parseInt(`${c}`, 10);
- return f += c % 1 * 10 ** -Math.ceil(Math.log(l) / Math.LN10) * l, y.create(f);
- }
- }
- class W1 extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 5);
- A(this, "maxParams", 6);
- }
- calculate(e, t, r, n, s, o) {
- let u = o != null ? o : y.create(0);
- u.isNull() && (u = y.create(0));
- const { isError: c, errorObject: l, variants: f } = Fe(e, t, r, n, s, u);
- if (c)
- return l;
- const [h, d, _, C, E, b] = f, R = k(h);
- if (typeof R != "number")
- return R;
- const p = k(d);
- if (typeof p != "number")
- return p;
- const N = +_.getValue(), M = +C.getValue(), w = Math.floor(+E.getValue()), D = Math.floor(+b.getValue());
- if (Number.isNaN(N) || Number.isNaN(M) || Number.isNaN(w) || Number.isNaN(D))
- return g.create(m.VALUE);
- if (N < 0 || M < 0 || ![1, 2, 4].includes(w) || D < 0 || D > 4 || Math.floor(R) >= Math.floor(p) || R <= 0 || p <= 366)
- return g.create(m.NUM);
- const S = bu(R, p, N, M, w, D);
- return y.create(S);
- }
- }
- class q1 extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- const { isError: r, errorObject: n, variants: s } = H(e, t);
- if (r)
- return n;
- const [o, u] = s, c = +o.getValue();
- let l = Math.floor(+u.getValue());
- if (Number.isNaN(c) || Number.isNaN(l))
- return g.create(m.VALUE);
- if (c <= 0 || l < 1)
- return g.create(m.NUM);
- l = Number.parseInt(`${l}`, 10);
- const f = (1 + c / l) ** l - 1;
- return y.create(f);
- }
- }
- class K1 extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 3);
- A(this, "maxParams", 5);
- A(this, "needsLocale", !0);
- }
- calculate(e, t, r, n, s) {
- const o = n != null ? n : y.create(0), u = s != null ? s : y.create(0), c = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1,
- r.isArray() ? r.getRowCount() : 1,
- o.isArray() ? o.getRowCount() : 1,
- u.isArray() ? u.getRowCount() : 1
- ), l = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1,
- r.isArray() ? r.getColumnCount() : 1,
- o.isArray() ? o.getColumnCount() : 1,
- u.isArray() ? u.getColumnCount() : 1
- ), f = O(c, l, e, g.create(m.NA)), h = O(c, l, t, g.create(m.NA)), d = O(c, l, r, g.create(m.NA)), _ = O(c, l, o, g.create(m.NA)), C = O(c, l, u, g.create(m.NA)), E = f.map((b, R, p) => {
- const N = h.get(R, p), M = d.get(R, p), w = _.get(R, p), D = C.get(R, p), { isError: S, errorObject: P, variants: U } = I(b, N, M, w, D);
- if (S)
- return P;
- const [x, F, W, ne, z] = U, G = +x.getValue(), ge = +F.getValue(), de = +W.getValue(), Ee = +ne.getValue(), Re = +z.getValue(), he = sr(G, ge, de, Ee, Re ? 1 : 0);
- return Number.isNaN(he) || !Number.isFinite(he) ? g.create(m.NUM) : R === 0 && p === 0 ? y.create(he, Ke(this.getLocale())) : y.create(he);
- });
- return c === 1 && l === 1 ? E.get(0, 0) : E;
- }
- }
- class X1 extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- const { isError: r, errorObject: n, variants: s } = H(e);
- if (r)
- return n;
- const [o] = s, u = +o.getValue();
- if (Number.isNaN(u))
- return g.create(m.VALUE);
- let c = u;
- if (t.isArray()) {
- const l = t.getArrayValue().flat();
- for (let f = 0; f < l.length; f++) {
- const h = l[f];
- if (h.isBoolean())
- return g.create(m.VALUE);
- const d = +h.getValue();
- if (Number.isNaN(d))
- return g.create(m.VALUE);
- c *= 1 + d;
- }
- } else {
- if (t.isBoolean())
- return g.create(m.VALUE);
- const l = +t.getValue();
- if (Number.isNaN(l))
- return g.create(m.VALUE);
- c *= 1 + l;
- }
- return y.create(c);
- }
- }
- class Z1 extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 4);
- A(this, "maxParams", 5);
- }
- calculate(e, t, r, n, s) {
- const o = s != null ? s : y.create(0), { isError: u, errorObject: c, variants: l } = H(e, t, r, n, o);
- if (u)
- return c;
- const [f, h, d, _, C] = l, E = k(f);
- if (typeof E != "number")
- return E;
- const b = k(h);
- if (typeof b != "number")
- return b;
- const R = +d.getValue(), p = +_.getValue(), N = Math.floor(+C.getValue());
- if (Number.isNaN(R) || Number.isNaN(p) || Number.isNaN(N))
- return g.create(m.VALUE);
- if (R <= 0 || p <= 0 || N < 0 || N > 4 || Math.floor(E) >= Math.floor(b))
- return g.create(m.NUM);
- const { days: M, yearDays: w } = _e(E, b, N), D = (p - R) / R * (w / M);
- return y.create(D);
- }
- }
- class z1 extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 4);
- A(this, "maxParams", 6);
- A(this, "needsLocale", !0);
- }
- calculate(e, t, r, n, s, o) {
- const u = s != null ? s : y.create(0), c = o != null ? o : y.create(0), l = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1,
- r.isArray() ? r.getRowCount() : 1,
- n.isArray() ? n.getRowCount() : 1,
- u.isArray() ? u.getRowCount() : 1,
- c.isArray() ? c.getRowCount() : 1
- ), f = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1,
- r.isArray() ? r.getColumnCount() : 1,
- n.isArray() ? n.getColumnCount() : 1,
- u.isArray() ? u.getColumnCount() : 1,
- c.isArray() ? c.getColumnCount() : 1
- ), h = O(l, f, e, g.create(m.NA)), d = O(l, f, t, g.create(m.NA)), _ = O(l, f, r, g.create(m.NA)), C = O(l, f, n, g.create(m.NA)), E = O(l, f, u, g.create(m.NA)), b = O(l, f, c, g.create(m.NA)), R = h.map((p, N, M) => {
- const w = d.get(N, M), D = _.get(N, M), S = C.get(N, M), P = E.get(N, M), U = b.get(N, M), { isError: x, errorObject: F, variants: W } = I(p, w, D, S, P, U);
- if (x)
- return F;
- const [ne, z, G, ge, de, Ee] = W, Re = +ne.getValue(), he = +z.getValue(), ke = +G.getValue(), Ot = +ge.getValue(), ar = +de.getValue(), Mt = +Ee.getValue();
- if (he < 1 || Math.floor(he) > Math.ceil(ke))
- return g.create(m.NUM);
- const st = yu(Re, he, ke, Ot, ar, Mt ? 1 : 0);
- return Number.isNaN(st) || !Number.isFinite(st) ? g.create(m.NUM) : N === 0 && M === 0 ? y.create(st, Ke(this.getLocale())) : y.create(st);
- });
- return l === 1 && f === 1 ? R.get(0, 0) : R;
- }
- }
- class J1 extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- let r = t != null ? t : y.create(0.1);
- return r.isNull() && (r = y.create(0.1)), r.isArray() ? r.map((n, s, o) => this._handleSingleObject(e, n, s, o)) : this._handleSingleObject(e, r);
- }
- _handleSingleObject(e, t, r = 0, n = 0) {
- if (e.isError())
- return e;
- if (t.isError())
- return t;
- if (e.isNull())
- return g.create(m.VALUE);
- if (!e.isArray())
- return g.create(m.NUM);
- const { _values: s, valuesHasError: o } = this._getValues(e);
- if (o)
- return g.create(m.VALUE);
- let u = t;
- if (u.isString() && (u = u.convertToNumberObjectValue(), u.isError()))
- return u;
- const c = +u.getValue(), { positive: l, negative: f } = this._checkValues(s);
- if (!l || !f)
- return g.create(m.NUM);
- const h = Ia(c, (d) => Ru(d, s));
- return typeof h != "number" ? h : r === 0 && n === 0 ? y.create(h, "0%") : y.create(h);
- }
- _getValues(e) {
- const t = [];
- let r = !1;
- return e.iterator((n) => {
- const s = n;
- if (s.isError())
- return r = !0, !1;
- if (s.isNull() || s.isBoolean())
- return !0;
- const o = +s.getValue();
- if (Number.isNaN(o))
- return !0;
- t.push(o);
- }), {
- _values: t,
- valuesHasError: r
- };
- }
- _checkValues(e) {
- let t = !1, r = !1;
- for (let n = 0; n < e.length; n++)
- e[n] > 0 && (t = !0), e[n] < 0 && (r = !0);
- return {
- positive: t,
- negative: r
- };
- }
- }
- class e0 extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 4);
- A(this, "maxParams", 4);
- }
- calculate(e, t, r, n) {
- const s = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1,
- r.isArray() ? r.getRowCount() : 1,
- n.isArray() ? n.getRowCount() : 1
- ), o = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1,
- r.isArray() ? r.getColumnCount() : 1,
- n.isArray() ? n.getColumnCount() : 1
- ), u = O(s, o, e, g.create(m.NA)), c = O(s, o, t, g.create(m.NA)), l = O(s, o, r, g.create(m.NA)), f = O(s, o, n, g.create(m.NA)), h = u.map((d, _, C) => {
- const E = c.get(_, C), b = l.get(_, C), R = f.get(_, C), { isError: p, errorObject: N, variants: M } = I(d, E, b, R);
- if (p)
- return N;
- const [w, D, S, P] = M, U = +w.getValue(), x = +D.getValue(), F = +S.getValue(), W = +P.getValue();
- if (F === 0)
- return g.create(m.DIV_BY_ZERO);
- const ne = W * U * (x / F - 1);
- return y.create(ne);
- });
- return s === 1 && o === 1 ? h.get(0, 0) : h;
- }
- }
- class t0 extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 5);
- A(this, "maxParams", 6);
- }
- calculate(e, t, r, n, s, o) {
- let u = o != null ? o : y.create(0);
- u.isNull() && (u = y.create(0));
- const { isError: c, errorObject: l, variants: f } = Fe(e, t, r, n, s, u);
- if (c)
- return l;
- const [h, d, _, C, E, b] = f, R = k(h);
- if (typeof R != "number")
- return R;
- const p = k(d);
- if (typeof p != "number")
- return p;
- const N = +_.getValue(), M = +C.getValue(), w = Math.floor(+E.getValue()), D = Math.floor(+b.getValue());
- if (Number.isNaN(N) || Number.isNaN(M) || Number.isNaN(w) || Number.isNaN(D))
- return g.create(m.VALUE);
- if (N < 0 || M < 0 || ![1, 2, 4].includes(w) || D < 0 || D > 4 || Math.floor(R) >= Math.floor(p))
- return g.create(m.NUM);
- let S = bu(R, p, N, M, w, D);
- return S /= 1 + M / w, y.create(S);
- }
- }
- class r0 extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 3);
- A(this, "maxParams", 3);
- }
- calculate(e, t, r) {
- const { _values: n, numberValues: s, positive: o, negative: u } = this._getValues(e), c = Math.max(
- t.isArray() ? t.getRowCount() : 1,
- r.isArray() ? r.getRowCount() : 1
- ), l = Math.max(
- t.isArray() ? t.getColumnCount() : 1,
- r.isArray() ? r.getColumnCount() : 1
- ), f = O(c, l, t, g.create(m.NA)), h = O(c, l, r, g.create(m.NA)), d = f.map((_, C, E) => {
- const b = h.get(C, E);
- if (e.isError())
- return e;
- if (b.isError())
- return b;
- if (n.isError())
- return n;
- if (!o || !u)
- return g.create(m.DIV_BY_ZERO);
- const R = +_.getValue(), p = +b.getValue();
- if (Number.isNaN(R) || Number.isNaN(p))
- return g.create(m.VALUE);
- if (p === -1)
- return g.create(m.DIV_BY_ZERO);
- const N = this._getResult(s, R, p);
- return C === 0 && E === 0 ? y.create(N, "0%") : y.create(N);
- });
- return c === 1 && l === 1 ? d.get(0, 0) : d;
- }
- _getValues(e) {
- let t = e, r = [], n = !1, s = !1;
- if (!e.isError())
- if (e.isNull())
- t = g.create(m.VALUE);
- else if (!e.isArray())
- t = g.create(m.DIV_BY_ZERO);
- else {
- const { numberValues: o, valuesHasError: u, errorObject: c, positive: l, negative: f } = this._checkValues(e);
- u && (t = c), r = o, n = l, s = f;
- }
- return {
- _values: t,
- numberValues: r,
- positive: n,
- negative: s
- };
- }
- _checkValues(e) {
- const t = [];
- let r = !1, n = g.create(m.VALUE), s = !1, o = !1;
- return e.iterator((u) => {
- const c = u;
- if (c.isError())
- return r = !0, n = c, !1;
- if (c.isNull() || c.isBoolean())
- return !0;
- const l = +c.getValue();
- if (Number.isNaN(l))
- return !0;
- l > 0 && (s = !0), l < 0 && (o = !0), t.push(l);
- }), {
- numberValues: t,
- valuesHasError: r,
- errorObject: n,
- positive: s,
- negative: o
- };
- }
- _getResult(e, t, r) {
- const n = e.length, s = [], o = [];
- for (let d = 0; d < n; d++)
- e[d] > 0 ? o.push(e[d]) : e[d] < 0 && s.push(e[d]);
- const u = this._npv(r, e, "positive"), c = this._npv(t, e, "negative"), l = -u * (1 + r) ** n, f = c * (1 + t);
- return (l / f) ** (1 / (n - 1)) - 1;
- }
- _npv(e, t, r) {
- let n = 0;
- for (let s = 1; s <= t.length; s++) {
- const o = t[s - 1];
- (r === "positive" && o > 0 || r === "negative" && o < 0) && (n += o / (1 + e) ** s);
- }
- return n;
- }
- }
- class n0 extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- const { isError: r, errorObject: n, variants: s } = H(e, t);
- if (r)
- return n;
- const [o, u] = s, c = +o.getValue();
- let l = Math.floor(+u.getValue());
- if (Number.isNaN(c) || Number.isNaN(l))
- return g.create(m.VALUE);
- if (c <= 0 || l < 1)
- return g.create(m.NUM);
- l = Number.parseInt(`${l}`, 10);
- const f = ((c + 1) ** (1 / l) - 1) * l;
- return y.create(f);
- }
- }
- class s0 extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 3);
- A(this, "maxParams", 5);
- }
- calculate(e, t, r, n, s) {
- const o = n != null ? n : y.create(0), u = s != null ? s : y.create(0), c = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1,
- r.isArray() ? r.getRowCount() : 1,
- o.isArray() ? o.getRowCount() : 1,
- u.isArray() ? u.getRowCount() : 1
- ), l = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1,
- r.isArray() ? r.getColumnCount() : 1,
- o.isArray() ? o.getColumnCount() : 1,
- u.isArray() ? u.getColumnCount() : 1
- ), f = O(c, l, e, g.create(m.NA)), h = O(c, l, t, g.create(m.NA)), d = O(c, l, r, g.create(m.NA)), _ = O(c, l, o, g.create(m.NA)), C = O(c, l, u, g.create(m.NA)), E = f.map((b, R, p) => {
- const N = h.get(R, p), M = d.get(R, p), w = _.get(R, p), D = C.get(R, p), { isError: S, errorObject: P, variants: U } = I(b, N, M, w, D);
- if (S)
- return P;
- const [x, F, W, ne, z] = U, G = +x.getValue(), ge = +F.getValue(), de = +W.getValue(), Ee = +ne.getValue();
- let Re = +z.getValue();
- if (Re = Re ? 1 : 0, G === 0 && ge === 0)
- return g.create(m.DIV_BY_ZERO);
- let he;
- if (G === 0)
- he = -(de + Ee) / ge;
- else {
- const ke = ge * (1 + G * Re) - Ee * G, Ot = de * G + ge * (1 + G * Re);
- he = Math.log(ke / Ot) / Math.log(1 + G);
- }
- return Number.isNaN(he) || !Number.isFinite(he) ? g.create(m.NUM) : y.create(he);
- });
- return c === 1 && l === 1 ? E.get(0, 0) : E;
- }
- }
- class a0 extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 255);
- A(this, "needsLocale", !0);
- }
- calculate(e, ...t) {
- if (e.isError())
- return e;
- const { isError: r, errorObject: n, values: s } = this._getValues(t);
- return e.isArray() ? e.map((o, u, c) => this._handleSingleObject(o, r, n, s, u, c)) : this._handleSingleObject(e, r, n, s);
- }
- _handleSingleObject(e, t, r, n, s = 0, o = 0) {
- let u = e;
- if (u.isString() && (u = u.convertToNumberObjectValue()), u.isError())
- return u;
- if (t)
- return r;
- const c = +e.getValue(), l = Ru(c, n);
- return Number.isNaN(l) || Math.abs(l) === 1 / 0 ? g.create(m.DIV_BY_ZERO) : s === 0 && o === 0 ? y.create(l, Ke(this.getLocale())) : y.create(l);
- }
- _getValues(e) {
- const t = [];
- for (let r = 0; r < e.length; r++) {
- const n = e[r];
- if (n.isError())
- return {
- isError: !0,
- errorObject: n
- };
- if (n.isArray()) {
- let s = !1, o = g.create(m.VALUE);
- if (n.iterator((u) => {
- const c = u;
- if (c.isError())
- return s = !0, o = c, !1;
- if (c.isNull() || c.isBoolean())
- return !0;
- const l = +c.getValue();
- if (Number.isNaN(l))
- return !0;
- t.push(l);
- }), s)
- return {
- isError: s,
- errorObject: o
- };
- } else {
- const s = +n.getValue();
- if (Number.isNaN(s))
- return {
- isError: !0,
- errorObject: g.create(m.VALUE)
- };
- t.push(s);
- }
- }
- return {
- isError: !1,
- values: t
- };
- }
- }
- class i0 extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 8);
- A(this, "maxParams", 9);
- }
- calculate(e, t, r, n, s, o, u, c, l) {
- let f = l != null ? l : y.create(0);
- f.isNull() && (f = y.create(0));
- const { isError: h, errorObject: d, variants: _ } = Fe(e, t, r, n, s, o, u, c, f);
- if (h)
- return d;
- const [C, E, b, R, p, N, M, w, D] = _, S = k(C);
- if (typeof S != "number")
- return S;
- const P = k(E);
- if (typeof P != "number")
- return P;
- const U = k(b);
- if (typeof U != "number")
- return U;
- const x = k(R);
- if (typeof x != "number")
- return x;
- const F = +p.getValue(), W = +N.getValue(), ne = +M.getValue(), z = Math.floor(+w.getValue()), G = Math.floor(+D.getValue());
- if (Number.isNaN(F) || Number.isNaN(W) || Number.isNaN(ne) || Number.isNaN(z) || Number.isNaN(G))
- return g.create(m.VALUE);
- if (F < 0 || W < 0 || ne <= 0 || ![1, 2, 4].includes(z) || G < 0 || G > 4 || !this._validDate(P, x, S, U, z))
- return g.create(m.NUM);
- const ge = pu(S, P, U, x, F, W, ne, z, G);
- return y.create(ge);
- }
- _validDate(e, t, r, n, s) {
- return this._getDateCorrectOrder(e, t, r, n) && Vu(e, t, s) && Or(n, e, s);
- }
- _getDateCorrectOrder(e, t, r, n) {
- return Math.floor(e) > Math.floor(t) && Math.floor(t) > Math.floor(r) && Math.floor(r) > Math.floor(n);
- }
- }
- class o0 extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 8);
- A(this, "maxParams", 9);
- }
- calculate(e, t, r, n, s, o, u, c, l) {
- let f = l != null ? l : y.create(0);
- f.isNull() && (f = y.create(0));
- const { isError: h, errorObject: d, variants: _ } = Fe(e, t, r, n, s, o, u, c, f);
- if (h)
- return d;
- const [C, E, b, R, p, N, M, w, D] = _, S = k(C);
- if (typeof S != "number")
- return S;
- const P = k(E);
- if (typeof P != "number")
- return P;
- const U = k(b);
- if (typeof U != "number")
- return U;
- const x = k(R);
- if (typeof x != "number")
- return x;
- const F = +p.getValue(), W = +N.getValue(), ne = +M.getValue(), z = Math.floor(+w.getValue()), G = Math.floor(+D.getValue());
- return Number.isNaN(F) || Number.isNaN(W) || Number.isNaN(ne) || Number.isNaN(z) || Number.isNaN(G) ? g.create(m.VALUE) : F < 0 || W <= 0 || ne <= 0 || ![1, 2, 4].includes(z) || G < 0 || G > 4 || !this._validDate(P, x, S, U, z) ? g.create(m.NUM) : this._getResult(S, P, U, x, F, W, ne, z, G);
- }
- _validDate(e, t, r, n, s) {
- return this._getDateCorrectOrder(e, t, r, n) && Vu(e, t, s) && Or(n, e, s);
- }
- _getDateCorrectOrder(e, t, r, n) {
- return Math.floor(e) > Math.floor(t) && Math.floor(t) > Math.floor(r) && Math.floor(r) > Math.floor(n);
- }
- _getResult(e, t, r, n, s, o, u, c, l) {
- const { days: f } = _e(e, t, l), h = (s * f * 100 - (o - 100)) / ((o - 100) * 0.25 * (1 + 2 * f) + f * 100);
- function d(C) {
- return o - pu(e, t, r, n, s, C, u, c, l);
- }
- const _ = Ia(h, (C) => d(C));
- return typeof _ != "number" ? _ : y.create(_);
- }
- }
- class u0 extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 7);
- A(this, "maxParams", 8);
- }
- calculate(e, t, r, n, s, o, u, c) {
- let l = c != null ? c : y.create(0);
- l.isNull() && (l = y.create(0));
- const { isError: f, errorObject: h, variants: d } = Fe(e, t, r, n, s, o, u, l);
- if (f)
- return h;
- const [_, C, E, b, R, p, N, M] = d, w = k(_);
- if (typeof w != "number")
- return w;
- const D = k(C);
- if (typeof D != "number")
- return D;
- const S = k(E);
- if (typeof S != "number")
- return S;
- const P = +b.getValue(), U = +R.getValue(), x = +p.getValue(), F = Math.floor(+N.getValue()), W = Math.floor(+M.getValue());
- if (Number.isNaN(P) || Number.isNaN(U) || Number.isNaN(x) || Number.isNaN(F) || Number.isNaN(W))
- return g.create(m.VALUE);
- if (P < 0 || U < 0 || x <= 0 || ![1, 2, 4].includes(F) || W < 0 || W > 4 || !this._validDate(D, w, S, F))
- return g.create(m.NUM);
- const ne = this._getResult(w, D, S, P, U, x, F, W);
- return y.create(ne);
- }
- _validDate(e, t, r, n) {
- return Math.floor(e) > Math.floor(t) && Math.floor(t) > Math.floor(r) && Or(r, e, n);
- }
- _getResult(e, t, r, n, s, o, u, c) {
- const l = this._getCoupDate(t, r, u), f = this._getFrac(r, e, l, u, c), h = this._getFrac(r, t, l, u, c), d = this._getFrac(e, t, l, u, c);
- return (o * u + 100 * n * (h - f * (1 + s * d / u))) / (s * d + u);
- }
- _getCoupDate(e, t, r) {
- const n = re(e), s = re(t);
- for (s.setUTCFullYear(n.getUTCFullYear()), s > n && s.setUTCFullYear(s.getUTCFullYear() - 1); s < n; )
- s.setUTCMonth(s.getUTCMonth() + 12 / r);
- return ye(s);
- }
- _getFrac(e, t, r, n, s) {
- const o = re(e), u = re(t), c = re(r);
- for (c.setUTCFullYear(o.getUTCFullYear()), c < o && c.setUTCFullYear(c.getUTCFullYear() + 1); c > o; )
- c.setUTCMonth(c.getUTCMonth() - 12 / n);
- let l = ye(c);
- c.setUTCMonth(c.getUTCMonth() + 12 / n);
- let f = ye(c);
- if (f >= t) {
- const { days: p } = _e(e, t, s), N = qe(l, f, n, s);
- return p / N;
- }
- const { days: h } = _e(e, f, s), d = qe(l, f, n, s);
- let _ = h / d;
- const C = re(f), E = re(f);
- for (E.setUTCMonth(E.getUTCMonth() + 12 / n); E < u; )
- C.setUTCMonth(C.getUTCMonth() + 12 / n), E.setUTCMonth(E.getUTCMonth() + 12 / n), _ += 1;
- l = ye(C), f = ye(E);
- const { days: b } = _e(l, t, s), R = qe(l, f, n, s);
- return _ += b / R, _;
- }
- }
- class c0 extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 8);
- A(this, "maxParams", 9);
- }
- calculate(e, t, r, n, s, o, u, c) {
- let l = c != null ? c : y.create(0);
- l.isNull() && (l = y.create(0));
- const { isError: f, errorObject: h, variants: d } = Fe(e, t, r, n, s, o, u, l);
- if (f)
- return h;
- const [_, C, E, b, R, p, N, M] = d, w = k(_);
- if (typeof w != "number")
- return w;
- const D = k(C);
- if (typeof D != "number")
- return D;
- const S = k(E);
- if (typeof S != "number")
- return S;
- const P = +b.getValue(), U = +R.getValue(), x = +p.getValue(), F = Math.floor(+N.getValue()), W = Math.floor(+M.getValue());
- if (Number.isNaN(P) || Number.isNaN(U) || Number.isNaN(x) || Number.isNaN(F) || Number.isNaN(W))
- return g.create(m.VALUE);
- if (P < 0 || U <= 0 || x <= 0 || ![1, 2, 4].includes(F) || W < 0 || W > 4 || !this._validDate(D, w, S, F))
- return g.create(m.NUM);
- const ne = this._getResult(w, D, S, P, U, x, F, W);
- return y.create(ne);
- }
- _validDate(e, t, r, n) {
- return Math.floor(e) > Math.floor(t) && Math.floor(t) > Math.floor(r) && Or(r, e, n);
- }
- _getResult(e, t, r, n, s, o, u, c) {
- const l = this._getCoupDate(t, r, u), f = this._getFrac(r, e, l, u, c), h = this._getFrac(r, t, l, u, c), d = this._getFrac(e, t, l, u, c);
- return (u * (o - s) + 100 * n * (h - f)) / (d * s + 100 * n * f * d / u);
- }
- _getCoupDate(e, t, r) {
- const n = re(e), s = re(t);
- for (s.setUTCFullYear(n.getUTCFullYear()), s > n && s.setUTCFullYear(s.getUTCFullYear() - 1); s < n; )
- s.setUTCMonth(s.getUTCMonth() + 12 / r);
- return ye(s);
- }
- _getFrac(e, t, r, n, s) {
- const o = re(e), u = re(t), c = re(r);
- for (c.setUTCFullYear(o.getUTCFullYear()), c < o && c.setUTCFullYear(c.getUTCFullYear() + 1); c > o; )
- c.setUTCMonth(c.getUTCMonth() - 12 / n);
- let l = ye(c);
- c.setUTCMonth(c.getUTCMonth() + 12 / n);
- let f = ye(c);
- if (f >= t) {
- const { days: p } = _e(e, t, s), N = qe(l, f, n, s);
- return p / N;
- }
- const { days: h } = _e(e, f, s), d = qe(l, f, n, s);
- let _ = h / d;
- const C = re(f), E = re(f);
- for (E.setUTCMonth(E.getUTCMonth() + 12 / n); E < u; )
- C.setUTCMonth(C.getUTCMonth() + 12 / n), E.setUTCMonth(E.getUTCMonth() + 12 / n), _ += 1;
- l = ye(C), f = ye(E);
- const { days: b } = _e(l, t, s), R = qe(l, f, n, s);
- return _ += b / R, _;
- }
- }
- class l0 extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 3);
- A(this, "maxParams", 3);
- }
- calculate(e, t, r) {
- const n = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1,
- r.isArray() ? r.getRowCount() : 1
- ), s = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1,
- r.isArray() ? r.getColumnCount() : 1
- ), o = O(n, s, e, g.create(m.NA)), u = O(n, s, t, g.create(m.NA)), c = O(n, s, r, g.create(m.NA)), l = o.map((f, h, d) => {
- const _ = u.get(h, d), C = c.get(h, d), { isError: E, errorObject: b, variants: R } = I(f, _, C);
- if (E)
- return b;
- const [p, N, M] = R, w = +p.getValue(), D = +N.getValue(), S = +M.getValue();
- if (w <= -1)
- return g.create(m.NUM);
- const P = (Math.log(S) - Math.log(D)) / Math.log(1 + w);
- return Number.isNaN(P) || !Number.isFinite(P) ? g.create(m.NUM) : y.create(P);
- });
- return n === 1 && s === 1 ? l.get(0, 0) : l;
- }
- }
- class f0 extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 3);
- A(this, "maxParams", 5);
- A(this, "needsLocale", !0);
- }
- calculate(e, t, r, n, s) {
- const o = n != null ? n : y.create(0), u = s != null ? s : y.create(0), c = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1,
- r.isArray() ? r.getRowCount() : 1,
- o.isArray() ? o.getRowCount() : 1,
- u.isArray() ? u.getRowCount() : 1
- ), l = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1,
- r.isArray() ? r.getColumnCount() : 1,
- o.isArray() ? o.getColumnCount() : 1,
- u.isArray() ? u.getColumnCount() : 1
- ), f = O(c, l, e, g.create(m.NA)), h = O(c, l, t, g.create(m.NA)), d = O(c, l, r, g.create(m.NA)), _ = O(c, l, o, g.create(m.NA)), C = O(c, l, u, g.create(m.NA)), E = f.map((b, R, p) => {
- const N = h.get(R, p), M = d.get(R, p), w = _.get(R, p), D = C.get(R, p), { isError: S, errorObject: P, variants: U } = I(b, N, M, w, D);
- if (S)
- return P;
- const [x, F, W, ne, z] = U, G = +x.getValue(), ge = +F.getValue(), de = +W.getValue(), Ee = +ne.getValue(), Re = +z.getValue();
- if (G <= -1)
- return g.create(m.NUM);
- const he = Gr(G, ge, de, Ee, Re ? 1 : 0);
- return Number.isNaN(he) || !Number.isFinite(he) ? g.create(m.NUM) : R === 0 && p === 0 ? y.create(he, Ke(this.getLocale())) : y.create(he);
- });
- return c === 1 && l === 1 ? E.get(0, 0) : E;
- }
- }
- class h0 extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 4);
- A(this, "maxParams", 6);
- A(this, "needsLocale", !0);
- }
- calculate(e, t, r, n, s, o) {
- const u = s != null ? s : y.create(0), c = o != null ? o : y.create(0), l = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1,
- r.isArray() ? r.getRowCount() : 1,
- n.isArray() ? n.getRowCount() : 1,
- u.isArray() ? u.getRowCount() : 1,
- c.isArray() ? c.getRowCount() : 1
- ), f = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1,
- r.isArray() ? r.getColumnCount() : 1,
- n.isArray() ? n.getColumnCount() : 1,
- u.isArray() ? u.getColumnCount() : 1,
- c.isArray() ? c.getColumnCount() : 1
- ), h = O(l, f, e, g.create(m.NA)), d = O(l, f, t, g.create(m.NA)), _ = O(l, f, r, g.create(m.NA)), C = O(l, f, n, g.create(m.NA)), E = O(l, f, u, g.create(m.NA)), b = O(l, f, c, g.create(m.NA)), R = h.map((p, N, M) => {
- const w = d.get(N, M), D = _.get(N, M), S = C.get(N, M), P = E.get(N, M), U = b.get(N, M), { isError: x, errorObject: F, variants: W } = I(p, w, D, S, P, U);
- if (x)
- return F;
- const [ne, z, G, ge, de, Ee] = W, Re = +ne.getValue(), he = +z.getValue(), ke = +G.getValue(), Ot = +ge.getValue(), ar = +de.getValue(), Mt = +Ee.getValue();
- if (he < 1 || Math.floor(he) > Math.ceil(ke) || he - ke >= 1)
- return g.create(m.NUM);
- const st = Gr(Re, ke, Ot, ar, Mt ? 1 : 0) - yu(Re, he, ke, Ot, ar, Mt ? 1 : 0);
- return Number.isNaN(st) || !Number.isFinite(st) ? g.create(m.NUM) : N === 0 && M === 0 ? y.create(st, Ke(this.getLocale())) : y.create(st);
- });
- return l === 1 && f === 1 ? R.get(0, 0) : R;
- }
- }
- class m0 extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 6);
- A(this, "maxParams", 7);
- }
- calculate(e, t, r, n, s, o, u) {
- let c = u != null ? u : y.create(0);
- c.isNull() && (c = y.create(0));
- const { isError: l, errorObject: f, variants: h } = Fe(e, t, r, n, s, o, c);
- if (l)
- return f;
- const [d, _, C, E, b, R, p] = h, N = k(d);
- if (typeof N != "number")
- return N;
- const M = k(_);
- if (typeof M != "number")
- return M;
- const w = +C.getValue(), D = +E.getValue(), S = +b.getValue(), P = Math.floor(+R.getValue()), U = Math.floor(+p.getValue());
- if (Number.isNaN(w) || Number.isNaN(D) || Number.isNaN(S) || Number.isNaN(P) || Number.isNaN(U))
- return g.create(m.VALUE);
- if (w < 0 || D < 0 || S <= 0 || ![1, 2, 4].includes(P) || U < 0 || U > 4 || N >= M || !Or(N, M, P))
- return g.create(m.NUM);
- const x = un(N, M, w, D, S, P, U);
- return y.create(x);
- }
- }
- class g0 extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 4);
- A(this, "maxParams", 5);
- }
- calculate(e, t, r, n, s) {
- let o = s != null ? s : y.create(0);
- o.isNull() && (o = y.create(0));
- const { isError: u, errorObject: c, variants: l } = Fe(e, t, r, n, o);
- if (u)
- return c;
- const [f, h, d, _, C] = l, E = k(f);
- if (typeof E != "number")
- return E;
- const b = k(h);
- if (typeof b != "number")
- return b;
- const R = +d.getValue(), p = +_.getValue(), N = Math.floor(+C.getValue());
- if (Number.isNaN(R) || Number.isNaN(p) || Number.isNaN(N))
- return g.create(m.VALUE);
- if (R <= 0 || p <= 0 || N < 0 || N > 4 || E >= b)
- return g.create(m.NUM);
- const { days: M, yearDays: w } = _e(E, b, N), D = p - R * p * M / w;
- return y.create(D);
- }
- }
- class d0 extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 5);
- A(this, "maxParams", 6);
- }
- calculate(e, t, r, n, s, o) {
- let u = o != null ? o : y.create(0);
- u.isNull() && (u = y.create(0));
- const { isError: c, errorObject: l, variants: f } = Fe(e, t, r, n, s, u);
- if (c)
- return l;
- const [h, d, _, C, E, b] = f, R = k(h);
- if (typeof R != "number")
- return R;
- const p = k(d);
- if (typeof p != "number")
- return p;
- const N = k(_);
- if (typeof N != "number")
- return N;
- const M = +C.getValue(), w = +E.getValue(), D = Math.floor(+b.getValue());
- if (Number.isNaN(M) || Number.isNaN(w) || Number.isNaN(D))
- return g.create(m.VALUE);
- const S = this._getDateCorrectOrder(p, R, N);
- if (M < 0 || w < 0 || D < 0 || D > 4 || !S)
- return g.create(m.NUM);
- const P = Au(R, D), { days: U } = _e(R, p, D), { days: x } = _e(N, p, D), { days: F } = _e(N, R, D), W = (100 + x / P * M * 100) / (1 + U / P * w) - F / P * M * 100;
- return y.create(W);
- }
- _getDateCorrectOrder(e, t, r) {
- return Math.floor(e) > Math.floor(t) && Math.floor(t) > Math.floor(r);
- }
- }
- class C0 extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 3);
- A(this, "maxParams", 5);
- A(this, "needsLocale", !0);
- }
- calculate(e, t, r, n, s) {
- const o = n != null ? n : y.create(0), u = s != null ? s : y.create(0), c = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1,
- r.isArray() ? r.getRowCount() : 1,
- o.isArray() ? o.getRowCount() : 1,
- u.isArray() ? u.getRowCount() : 1
- ), l = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1,
- r.isArray() ? r.getColumnCount() : 1,
- o.isArray() ? o.getColumnCount() : 1,
- u.isArray() ? u.getColumnCount() : 1
- ), f = O(c, l, e, g.create(m.NA)), h = O(c, l, t, g.create(m.NA)), d = O(c, l, r, g.create(m.NA)), _ = O(c, l, o, g.create(m.NA)), C = O(c, l, u, g.create(m.NA)), E = f.map((b, R, p) => {
- const N = h.get(R, p), M = d.get(R, p), w = _.get(R, p), D = C.get(R, p), { isError: S, errorObject: P, variants: U } = I(b, N, M, w, D);
- if (S)
- return P;
- const [x, F, W, ne, z] = U, G = +x.getValue(), ge = +F.getValue(), de = +W.getValue(), Ee = +ne.getValue();
- let Re = +z.getValue();
- Re = Re ? 1 : 0;
- const he = G === 0 ? -de * ge - Ee : ((1 - (1 + G) ** ge) / G * de * (1 + G * Re) - Ee) / (1 + G) ** ge;
- return Number.isNaN(he) || !Number.isFinite(he) ? g.create(m.NUM) : R === 0 && p === 0 ? y.create(he, Ke(this.getLocale())) : y.create(he);
- });
- return c === 1 && l === 1 ? E.get(0, 0) : E;
- }
- }
- class _0 extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 3);
- A(this, "maxParams", 6);
- }
- calculate(e, t, r, n, s, o) {
- const u = n != null ? n : y.create(0), c = s != null ? s : y.create(0), l = o != null ? o : y.create(0.1), f = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1,
- r.isArray() ? r.getRowCount() : 1,
- u.isArray() ? u.getRowCount() : 1,
- c.isArray() ? c.getRowCount() : 1,
- l.isArray() ? l.getRowCount() : 1
- ), h = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1,
- r.isArray() ? r.getColumnCount() : 1,
- u.isArray() ? u.getColumnCount() : 1,
- c.isArray() ? c.getColumnCount() : 1,
- l.isArray() ? l.getColumnCount() : 1
- ), d = O(f, h, e, g.create(m.NA)), _ = O(f, h, t, g.create(m.NA)), C = O(f, h, r, g.create(m.NA)), E = O(f, h, u, g.create(m.NA)), b = O(f, h, c, g.create(m.NA)), R = O(f, h, l, g.create(m.NA)), p = d.map((N, M, w) => {
- const D = _.get(M, w), S = C.get(M, w), P = E.get(M, w), U = b.get(M, w), x = R.get(M, w), { isError: F, errorObject: W, variants: ne } = I(N, D, S, P, U, x);
- if (F)
- return W;
- const [z, G, ge, de, Ee, Re] = ne, he = +z.getValue(), ke = +G.getValue(), Ot = +ge.getValue(), ar = +de.getValue();
- let Mt = +Ee.getValue();
- const st = +Re.getValue();
- return Mt = Mt ? 1 : 0, he <= 0 || ke >= 0 ? g.create(m.NUM) : this._getResult(he, ke, Ot, ar, Mt, st, M, w);
- });
- return f === 1 && h === 1 ? p.get(0, 0) : p;
- }
- _getResult(e, t, r, n, s, o, u, c) {
- let h = o;
- for (let d = 0; d < 20; d++) {
- if (h <= -1)
- return g.create(m.NUM);
- let _, C;
- 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)
- break;
- let E;
- if (Math.abs(h) < 1e-10)
- E = r * e + t * s * e;
- else {
- C = (1 + h) ** e;
- const b = e * (1 + h) ** (e - 1);
- E = r * b + t * (1 / h + s) * b + t * (-1 / (h * h)) * (C - 1);
- }
- h -= _ / E;
- }
- return u === 0 && c === 0 ? y.create(h, "0%") : y.create(h);
- }
- }
- class A0 extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 4);
- A(this, "maxParams", 5);
- }
- calculate(e, t, r, n, s) {
- let o = s != null ? s : y.create(0);
- o.isNull() && (o = y.create(0));
- const { isError: u, errorObject: c, variants: l } = Fe(e, t, r, n, o);
- if (u)
- return c;
- const [f, h, d, _, C] = l, E = k(f);
- if (typeof E != "number")
- return E;
- const b = k(h);
- if (typeof b != "number")
- return b;
- const R = +d.getValue(), p = +_.getValue(), N = Math.floor(+C.getValue());
- if (Number.isNaN(R) || Number.isNaN(p) || Number.isNaN(N))
- return g.create(m.VALUE);
- if (R <= 0 || p <= 0 || N < 0 || N > 4 || E >= b)
- return g.create(m.NUM);
- const { days: M, yearDays: w } = _e(E, b, N), D = R / (1 - p * M / w);
- return D < 0 ? g.create(m.NUM) : y.create(D);
- }
- }
- class E0 extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 3);
- A(this, "maxParams", 6);
- }
- calculate(e, t, r) {
- const n = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1,
- r.isArray() ? r.getRowCount() : 1
- ), s = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1,
- r.isArray() ? r.getColumnCount() : 1
- ), o = O(n, s, e, g.create(m.NA)), u = O(n, s, t, g.create(m.NA)), c = O(n, s, r, g.create(m.NA)), l = o.map((f, h, d) => {
- const _ = u.get(h, d), C = c.get(h, d), { isError: E, errorObject: b, variants: R } = I(f, _, C);
- if (E)
- return b;
- const [p, N, M] = R, w = +p.getValue(), D = +N.getValue(), S = +M.getValue();
- if (w <= 0)
- return g.create(m.NUM);
- if (D === 0 && S === 0)
- return y.create(0);
- const P = (S / D) ** (1 / w) - 1;
- return Number.isNaN(P) || !Number.isFinite(P) || S / D < 0 ? g.create(m.NUM) : y.create(P);
- });
- return n === 1 && s === 1 ? l.get(0, 0) : l;
- }
- }
- class b0 extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 3);
- A(this, "maxParams", 3);
- A(this, "needsLocale", !0);
- }
- calculate(e, t, r) {
- const n = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1,
- r.isArray() ? r.getRowCount() : 1
- ), s = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1,
- r.isArray() ? r.getColumnCount() : 1
- ), o = O(n, s, e, g.create(m.NA)), u = O(n, s, t, g.create(m.NA)), c = O(n, s, r, g.create(m.NA)), l = o.map((f, h, d) => {
- const _ = u.get(h, d), C = c.get(h, d);
- if (_.isError())
- return _;
- if (C.isError())
- return C;
- const E = +f.getValue(), b = +_.getValue(), R = +C.getValue();
- if (Number.isNaN(E) || Number.isNaN(b) || Number.isNaN(R))
- return g.create(m.VALUE);
- if (R === 0)
- return g.create(m.DIV_BY_ZERO);
- const p = (E - b) / R;
- return h === 0 && d === 0 ? y.create(p, Ke(this.getLocale())) : y.create(p);
- });
- return n === 1 && s === 1 ? l.get(0, 0) : l;
- }
- }
- class y0 extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 4);
- A(this, "maxParams", 4);
- A(this, "needsLocale", !0);
- }
- calculate(e, t, r, n) {
- const s = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1,
- r.isArray() ? r.getRowCount() : 1,
- n.isArray() ? n.getRowCount() : 1
- ), o = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1,
- r.isArray() ? r.getColumnCount() : 1,
- n.isArray() ? n.getColumnCount() : 1
- ), u = O(s, o, e, g.create(m.NA)), c = O(s, o, t, g.create(m.NA)), l = O(s, o, r, g.create(m.NA)), f = O(s, o, n, g.create(m.NA)), h = u.map((d, _, C) => {
- const E = c.get(_, C), b = l.get(_, C), R = f.get(_, C);
- if (E.isError())
- return E;
- if (b.isError())
- return b;
- if (R.isError())
- return R;
- const p = +d.getValue(), N = +E.getValue(), M = +b.getValue(), w = +R.getValue();
- if (Number.isNaN(p) || Number.isNaN(N) || Number.isNaN(M) || Number.isNaN(w))
- return g.create(m.VALUE);
- if (N < 0 || M <= 0 || w > M)
- return g.create(m.NUM);
- const D = (p - N) * (M - w + 1) * 2 / (M * (M + 1));
- return _ === 0 && C === 0 ? y.create(D, Ke(this.getLocale())) : y.create(D);
- });
- return s === 1 && o === 1 ? h.get(0, 0) : h;
- }
- }
- class R0 extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 3);
- A(this, "maxParams", 3);
- }
- calculate(e, t, r) {
- const { isError: n, errorObject: s, variants: o } = Fe(e, t, r);
- if (n)
- return s;
- const [u, c, l] = o, f = k(u);
- if (typeof f != "number")
- return f;
- const h = k(c);
- if (typeof h != "number")
- return h;
- const d = +l.getValue();
- if (Number.isNaN(d))
- return g.create(m.VALUE);
- if (d <= 0 || f >= h)
- return g.create(m.NUM);
- const _ = Math.floor(h) - Math.floor(f), E = re(f).getUTCFullYear(), b = Jn(E);
- if (_ > b)
- return g.create(m.NUM);
- let R = 365 * d / (360 - d * _);
- if (_ > 182) {
- const p = 100 * (1 - d * _ / 360), N = _ / 365;
- if (R = (-N + Math.sqrt(N * N - (N * 2 - 1) * (1 - 100 / p))) / (N - 0.5), Number.isNaN(R))
- return g.create(m.NUM);
- }
- return R < 0 ? g.create(m.NUM) : y.create(R);
- }
- }
- class p0 extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 3);
- A(this, "maxParams", 3);
- A(this, "needsLocale", !0);
- }
- calculate(e, t, r) {
- const { isError: n, errorObject: s, variants: o } = Fe(e, t, r);
- if (n)
- return s;
- const [u, c, l] = o, f = k(u);
- if (typeof f != "number")
- return f;
- const h = k(c);
- if (typeof h != "number")
- return h;
- const d = +l.getValue();
- if (Number.isNaN(d))
- return g.create(m.VALUE);
- if (d <= 0 || f >= h)
- return g.create(m.NUM);
- const _ = Math.floor(h) - Math.floor(f), E = re(f).getUTCFullYear(), b = Jn(E);
- if (_ > b)
- return g.create(m.NUM);
- const R = 100 * (1 - d * _ / 360);
- return R < 0 ? g.create(m.NUM) : y.create(R, Ke(this.getLocale()));
- }
- }
- class V0 extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 3);
- A(this, "maxParams", 3);
- }
- calculate(e, t, r) {
- const { isError: n, errorObject: s, variants: o } = Fe(e, t, r);
- if (n)
- return s;
- const [u, c, l] = o, f = k(u);
- if (typeof f != "number")
- return f;
- const h = k(c);
- if (typeof h != "number")
- return h;
- const d = +l.getValue();
- if (Number.isNaN(d))
- return g.create(m.VALUE);
- if (d <= 0 || f >= h)
- return g.create(m.NUM);
- const _ = Math.floor(h) - Math.floor(f), E = re(f).getUTCFullYear(), b = Jn(E);
- if (_ > b)
- return g.create(m.NUM);
- const R = (100 - d) / d * 360 / _;
- return y.create(R);
- }
- }
- class N0 extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 5);
- A(this, "maxParams", 7);
- A(this, "needsLocale", !0);
- }
- calculate(e, t, r, n, s, o, u) {
- let c = o != null ? o : y.create(2);
- c.isNull() && (c = y.create(2));
- let l = u != null ? u : T.create(!1);
- l.isNull() && (l = T.create(!1));
- const f = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1,
- r.isArray() ? r.getRowCount() : 1,
- n.isArray() ? n.getRowCount() : 1,
- s.isArray() ? s.getRowCount() : 1,
- c.isArray() ? c.getRowCount() : 1,
- l.isArray() ? l.getRowCount() : 1
- ), h = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1,
- r.isArray() ? r.getColumnCount() : 1,
- n.isArray() ? n.getColumnCount() : 1,
- s.isArray() ? s.getColumnCount() : 1,
- c.isArray() ? c.getColumnCount() : 1,
- l.isArray() ? l.getColumnCount() : 1
- ), d = O(f, h, e, g.create(m.NA)), _ = O(f, h, t, g.create(m.NA)), C = O(f, h, r, g.create(m.NA)), E = O(f, h, n, g.create(m.NA)), b = O(f, h, s, g.create(m.NA)), R = O(f, h, c, g.create(m.NA)), p = O(f, h, l, g.create(m.NA));
- return this._getResultArray(
- d,
- _,
- C,
- E,
- b,
- R,
- p,
- f,
- h
- );
- }
- _getResultArray(e, t, r, n, s, o, u, c, l) {
- const f = e.map((h, d, _) => {
- const C = t.get(d, _), E = r.get(d, _), b = n.get(d, _), R = s.get(d, _), p = o.get(d, _), N = u.get(d, _), { isError: M, errorObject: w, variants: D } = I(h, C, E, b, R, p, N);
- if (M)
- return w;
- const [S, P, U, x, F, W, ne] = D, z = +S.getValue(), G = +P.getValue(), ge = +U.getValue(), de = +x.getValue(), Ee = +F.getValue(), Re = +W.getValue(), he = +ne.getValue();
- if (z < 0 || G < 0 || ge < 0 || de < 0 || Ee < 0 || Ee > ge || de > Ee || Re < 0)
- return g.create(m.NUM);
- if (ge === 0 && de === 0 && Ee === 0)
- return g.create(m.DIV_BY_ZERO);
- const ke = this._getResult(z, G, ge, de, Ee, Re, he);
- return d === 0 && _ === 0 ? y.create(ke, Ke(this.getLocale())) : y.create(ke);
- });
- return c === 1 && l === 1 ? f.get(0, 0) : f;
- }
- _getResult(e, t, r, n, s, o, u) {
- const c = Math.floor(n), l = Math.ceil(s);
- let f = 0;
- if (e < t) {
- if (n >= 1 || u)
- return f;
- const h = Math.abs(e - t);
- return f = h * (s - n) > h ? h : h * (s - n), -f;
- }
- if (u)
- for (let h = c + 1; h <= l; h++) {
- let d = zs(e, t, r, h, o);
- h === c + 1 ? d *= Math.min(s, c + 1) - n : h === l && (d *= s + 1 - l), f += d;
- }
- else {
- const h = e - this._getVdb(e, t, r, r, n, o);
- f = this._getVdb(h, t, r, r - n, s - n, o);
- }
- return f;
- }
- _getVdb(e, t, r, n, s, o) {
- const u = Math.ceil(s);
- let c = 0, l = e - t, f = 0, h = 0, d = !1;
- for (let _ = 1; _ <= u; _++) {
- if (d)
- h = f;
- else {
- const C = zs(e, t, r, _, o);
- f = l / (n - (_ - 1)), f > C ? (h = f, d = !0) : (h = C, l -= C);
- }
- _ === u && (h *= s + 1 - u), c += h;
- }
- return c;
- }
- }
- class O0 extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 3);
- }
- calculate(e, t, r) {
- if (e.isNull() || t.isNull())
- return g.create(m.NA);
- const { isError: n, errorObejct: s, _values: o, _dates: u } = this._checkErrors(e, t);
- if (n)
- return s;
- let c = r != null ? r : y.create(0.1);
- c.isNull() && (c = y.create(0.1));
- const { isError: l, errorObject: f, variants: h } = H(c);
- if (l)
- return f;
- const [d] = h, _ = +d.getValue();
- if (Number.isNaN(_))
- return g.create(m.VALUE);
- const { positive: C, negative: E } = this._checkValues(o);
- if (!C || !E || (o == null ? void 0 : o.length) !== (u == null ? void 0 : u.length) || _ < 0)
- return g.create(m.NUM);
- const b = Ia(_, (R) => this._iterF(o, u, R));
- return typeof b != "number" ? b : y.create(b);
- }
- _checkErrors(e, t) {
- if (e.isError())
- return {
- isError: !0,
- errorObejct: e
- };
- if (t.isError())
- return {
- isError: !0,
- errorObejct: t
- };
- const { isError: r, errorObejct: n, _values: s } = this._checkErrorValues(e);
- if (r)
- return {
- isError: r,
- errorObejct: n
- };
- const { isError: o, errorObejct: u, _dates: c } = this._checkErrorDates(t);
- return o ? {
- isError: o,
- errorObejct: u
- } : {
- isError: !1,
- _values: s,
- _dates: c
- };
- }
- _checkErrorValues(e) {
- const t = [];
- if (e.isArray()) {
- let r = !1, n = g.create(m.VALUE);
- return e.iterator((s) => {
- const o = s;
- if (o.isError())
- return r = !0, n = o, !1;
- if (o.isBoolean())
- return r = !0, n = g.create(m.VALUE), !1;
- const u = +o.getValue();
- if (Number.isNaN(u))
- return r = !0, n = g.create(m.VALUE), !1;
- t.push(u);
- }), r ? {
- isError: r,
- errorObejct: n
- } : t.length <= 1 ? {
- isError: !0,
- errorObejct: g.create(m.NA)
- } : {
- isError: r,
- _values: t
- };
- } else {
- const r = e.getValue();
- return e.isBoolean() || e.isString() && !Q(r) ? {
- isError: !0,
- errorObejct: g.create(m.VALUE)
- } : {
- isError: !0,
- errorObejct: g.create(m.NA)
- };
- }
- }
- _checkErrorDates(e) {
- const t = [];
- if (e.isArray()) {
- let r = !1, n = g.create(m.VALUE);
- return e.iterator((s) => {
- if (s != null && s.isError())
- return r = !0, n = s, !1;
- if (s != null && s.isBoolean())
- return r = !0, n = g.create(m.VALUE), !1;
- const o = +s.getValue();
- if (Number.isNaN(o))
- return r = !0, n = g.create(m.VALUE), !1;
- if (o < 0)
- return r = !0, n = g.create(m.NUM), !1;
- t.push(Math.floor(o));
- }), r ? {
- isError: r,
- errorObejct: n
- } : t.length <= 1 ? {
- isError: !0,
- errorObejct: g.create(m.NA)
- } : {
- isError: r,
- _dates: t
- };
- } else {
- const r = e.getValue();
- return e.isBoolean() || e.isString() && !Q(r) ? {
- isError: !0,
- errorObejct: g.create(m.VALUE)
- } : +r < 0 ? {
- isError: !0,
- errorObejct: g.create(m.NUM)
- } : {
- isError: !0,
- errorObejct: g.create(m.NA)
- };
- }
- }
- _checkValues(e) {
- let t = !1, r = !1;
- for (let n = 0; n < e.length; n++)
- e[n] > 0 && (t = !0), e[n] < 0 && (r = !0);
- return {
- positive: t,
- negative: r
- };
- }
- _iterF(e, t, r) {
- return e.reduce((n, s, o) => n + s / (1 + r) ** ((t[o] - t[0]) / 365), 0);
- }
- }
- class M0 extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 3);
- A(this, "maxParams", 3);
- }
- calculate(e, t, r) {
- if (e.isNull() || t.isNull() || r.isNull())
- return g.create(m.NA);
- const { isError: n, errorObject: s, variants: o } = H(e);
- if (n)
- return s;
- const [u] = o, c = +u.getValue();
- if (Number.isNaN(c))
- return g.create(m.VALUE);
- let { isError: l, errorObejct: f, _values: h, _dates: d } = this._checkErrors(t, r);
- if (l)
- return f;
- if (h = h, d = d, c < 0 || h.length !== d.length)
- return g.create(m.NUM);
- let _ = 0;
- const C = d[0];
- for (let E = 0; E < d.length; E++) {
- const b = d[E], R = h[E];
- _ += R / (1 + c) ** ((b - C) / 365);
- }
- return y.create(_);
- }
- _checkErrors(e, t) {
- if (e.isError())
- return {
- isError: !0,
- errorObejct: e
- };
- if (t.isError())
- return {
- isError: !0,
- errorObejct: t
- };
- const { isError: r, errorObejct: n, _values: s } = this._checkErrorValues(e);
- if (r)
- return {
- isError: r,
- errorObejct: n
- };
- const { isError: o, errorObejct: u, _dates: c } = this._checkErrorDates(t);
- return o ? {
- isError: o,
- errorObejct: u
- } : {
- isError: !1,
- _values: s,
- _dates: c
- };
- }
- _checkErrorValues(e) {
- const t = [];
- if (e.isArray()) {
- let r = !1, n = g.create(m.VALUE);
- return e.iterator((s) => {
- const o = s;
- if (o.isError())
- return r = !0, n = o, !1;
- if (o.isNull() || o.isBoolean())
- return r = !0, n = g.create(m.VALUE), !1;
- const u = +o.getValue();
- if (Number.isNaN(u))
- return r = !0, n = g.create(m.VALUE), !1;
- t.push(u);
- }), r ? {
- isError: r,
- errorObejct: n
- } : t.length <= 1 ? {
- isError: !0,
- errorObejct: g.create(m.NA)
- } : {
- isError: r,
- _values: t
- };
- } else {
- const r = e.getValue();
- return e.isNull() || e.isBoolean() || e.isString() && !Q(r) ? {
- isError: !0,
- errorObejct: g.create(m.VALUE)
- } : {
- isError: !0,
- errorObejct: g.create(m.NA)
- };
- }
- }
- _checkErrorDates(e) {
- const t = [];
- if (e.isArray()) {
- let r = !1, n = g.create(m.VALUE);
- return e.iterator((s) => {
- const o = s;
- if (o.isError())
- return r = !0, n = o, !1;
- if (o.isNull() || o.isBoolean())
- return r = !0, n = g.create(m.VALUE), !1;
- const u = +o.getValue();
- if (Number.isNaN(u))
- return r = !0, n = g.create(m.VALUE), !1;
- if (u < 0)
- return r = !0, n = g.create(m.NUM), !1;
- t.push(Math.floor(u));
- }), r ? {
- isError: r,
- errorObejct: n
- } : t.length <= 1 ? {
- isError: !0,
- errorObejct: g.create(m.NA)
- } : {
- isError: r,
- _dates: t
- };
- } else {
- const r = e.getValue();
- return e.isNull() || e.isBoolean() || e.isString() && !Q(r) ? {
- isError: !0,
- errorObejct: g.create(m.VALUE)
- } : +r < 0 ? {
- isError: !0,
- errorObejct: g.create(m.NUM)
- } : {
- isError: !0,
- errorObejct: g.create(m.NA)
- };
- }
- }
- }
- class w0 extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 6);
- A(this, "maxParams", 7);
- }
- calculate(e, t, r, n, s, o, u) {
- let c = u != null ? u : y.create(0);
- c.isNull() && (c = y.create(0));
- const { isError: l, errorObject: f, variants: h } = Fe(e, t, r, n, s, o, c);
- if (l)
- return f;
- const [d, _, C, E, b, R, p] = h, N = k(d);
- if (typeof N != "number")
- return N;
- const M = k(_);
- if (typeof M != "number")
- return M;
- const w = +C.getValue(), D = +E.getValue(), S = +b.getValue(), P = Math.floor(+R.getValue()), U = Math.floor(+p.getValue());
- if (Number.isNaN(w) || Number.isNaN(D) || Number.isNaN(S) || Number.isNaN(P) || Number.isNaN(U))
- return g.create(m.VALUE);
- if (w < 0 || D <= 0 || S <= 0 || ![1, 2, 4].includes(P) || U < 0 || U > 4 || N >= M || !Or(N, M, P))
- return g.create(m.NUM);
- const x = this._getResult(N, M, w, D, S, P, U);
- return y.create(x);
- }
- _getResult(e, t, r, n, s, o, u) {
- if (nr(e, t, o) > 1) {
- let E = r || 0.01, b = un(e, t, r, E, s, o, u), R = b - n;
- for (let p = 0; p < 100 && Math.abs(R) > 1e-7; p++)
- b = un(e, t, r, 1.01 * E, s, o, u), E += -R / (b - n - R) * E * 0.01, R = un(e, t, r, E, s, o, u) - n;
- return E;
- }
- const l = es(e, t, o, u), f = qe(e, t, o, u), { days: h } = _e(e, t, u), d = n / 100 + l / f * r / o;
- return (s / 100 + r / o - d) / d * o * f / h;
- }
- }
- class D0 extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 4);
- A(this, "maxParams", 5);
- }
- calculate(e, t, r, n, s) {
- let o = s != null ? s : y.create(0);
- o.isNull() && (o = y.create(0));
- const { isError: u, errorObject: c, variants: l } = Fe(e, t, r, n, o);
- if (u)
- return c;
- const [f, h, d, _, C] = l, E = k(f);
- if (typeof E != "number")
- return E;
- const b = k(h);
- if (typeof b != "number")
- return b;
- const R = +d.getValue(), p = +_.getValue(), N = Math.floor(+C.getValue());
- if (Number.isNaN(R) || Number.isNaN(p) || Number.isNaN(N))
- return g.create(m.VALUE);
- if (R <= 0 || p <= 0 || N < 0 || N > 4 || E >= b)
- return g.create(m.NUM);
- const { days: M, yearDays: w } = _e(E, b, N), D = (p / R - 1) / (M / w);
- return y.create(D);
- }
- }
- class S0 extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 5);
- A(this, "maxParams", 6);
- }
- calculate(e, t, r, n, s, o) {
- let u = o != null ? o : y.create(0);
- u.isNull() && (u = y.create(0));
- const { isError: c, errorObject: l, variants: f } = Fe(e, t, r, n, s, u);
- if (c)
- return l;
- const [h, d, _, C, E, b] = f, R = k(h);
- if (typeof R != "number")
- return R;
- const p = k(d);
- if (typeof p != "number")
- return p;
- const N = k(_);
- if (typeof N != "number")
- return N;
- const M = +C.getValue(), w = +E.getValue(), D = Math.floor(+b.getValue());
- if (Number.isNaN(M) || Number.isNaN(w) || Number.isNaN(D))
- return g.create(m.VALUE);
- const S = this._getDateCorrectOrder(p, R, N);
- if (M < 0 || w <= 0 || D < 0 || D > 4 || !S)
- return g.create(m.NUM);
- const P = Au(R, D), { days: U } = _e(R, p, D), { days: x } = _e(N, p, D), { days: F } = _e(N, R, D), W = ((1 + x / P * M) / (w / 100 + F / P * M) - 1) / (U / P);
- return y.create(W);
- }
- _getDateCorrectOrder(e, t, r) {
- return Math.floor(e) > Math.floor(t) && Math.floor(t) > Math.floor(r);
- }
- }
- const P0 = [
- [P1, ee.ACCRINT],
- [L1, ee.ACCRINTM],
- [x1, ee.AMORLINC],
- [j1, ee.COUPDAYBS],
- [U1, ee.COUPDAYS],
- [v1, ee.COUPDAYSNC],
- [T1, ee.COUPNCD],
- [B1, ee.COUPNUM],
- [I1, ee.COUPPCD],
- [F1, ee.CUMIPMT],
- [k1, ee.CUMPRINC],
- [$1, ee.DB],
- [Y1, ee.DDB],
- [H1, ee.DISC],
- [G1, ee.DOLLARDE],
- [Q1, ee.DOLLARFR],
- [W1, ee.DURATION],
- [q1, ee.EFFECT],
- [K1, ee.FV],
- [X1, ee.FVSCHEDULE],
- [Z1, ee.INTRATE],
- [z1, ee.IPMT],
- [J1, ee.IRR],
- [e0, ee.ISPMT],
- [t0, ee.MDURATION],
- [r0, ee.MIRR],
- [n0, ee.NOMINAL],
- [s0, ee.NPER],
- [a0, ee.NPV],
- [i0, ee.ODDFPRICE],
- [o0, ee.ODDFYIELD],
- [u0, ee.ODDLPRICE],
- [c0, ee.ODDLYIELD],
- [l0, ee.PDURATION],
- [f0, ee.PMT],
- [h0, ee.PPMT],
- [m0, ee.PRICE],
- [g0, ee.PRICEDISC],
- [d0, ee.PRICEMAT],
- [C0, ee.PV],
- [_0, ee.RATE],
- [A0, ee.RECEIVED],
- [E0, ee.RRI],
- [b0, ee.SLN],
- [y0, ee.SYD],
- [R0, ee.TBILLEQ],
- [p0, ee.TBILLPRICE],
- [V0, ee.TBILLYIELD],
- [N0, ee.VDB],
- [O0, ee.XIRR],
- [M0, ee.XNPV],
- [w0, ee.YIELD],
- [D0, ee.YIELDDISC],
- [S0, ee.YIELDMAT]
- ];
- class L0 extends V {
- constructor() {
- super(...arguments);
- A(this, "needsReferenceObject", !0);
- A(this, "minParams", 2);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- let r = e;
- if (r.isError())
- return r;
- if (r.isReferenceObject() && (r = r.toArrayValueObject()), r.isArray()) {
- const n = r.getRowCount(), s = r.getColumnCount();
- if (n === 1 && s === 1) {
- const o = r.get(0, 0);
- return this._handleSingleObject(o, t);
- }
- return r.map((o) => o.isError() ? o : this._handleSingleObject(o, t, !0));
- }
- return this._handleSingleObject(r, t);
- }
- _handleSingleObject(e, t, r = !1) {
- let n = t;
- if (n.isError())
- return n;
- if (!n.isReferenceObject())
- return g.create(m.NA);
- const s = n.getCurrentActiveSheetData(), { columnData: o, defaultColumnWidth: u } = s;
- n = n.toArrayValueObject();
- const c = n.getCurrentRow(), l = n.getCurrentColumn();
- n = n.getFirstCell();
- const f = `${e.getValue()}`;
- let h;
- switch (f.toLocaleLowerCase()) {
- case "address":
- return j.create(`$${Xe.chatAtABC(l)}$${c + 1}`);
- case "col":
- return y.create(l + 1);
- case "color":
- return y.create(0);
- case "contents":
- return n;
- case "filename":
- return g.create(m.VALUE);
- case "format":
- return j.create("G");
- case "parentheses":
- return y.create(0);
- case "prefix":
- return j.create("");
- case "protect":
- return y.create(1);
- case "row":
- return y.create(c + 1);
- case "type":
- return h = "v", n.isNull() && (h = "b"), n.isString() && (h = "l"), j.create(h);
- case "width":
- return this._getWidthResult(o, u, l, r);
- default:
- return g.create(m.VALUE);
- }
- }
- _getWidthResult(e, t, r, n) {
- var u;
- let s = (u = e[r]) == null ? void 0 : u.w;
- if (!s && s !== 0 && (s = t), n)
- return y.create(s);
- const o = [[s, s === t]];
- return q.createByArray(o);
- }
- }
- class x0 extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- A(this, "_errorTypeValueMap", /* @__PURE__ */ new Map([
- [m.NULL, 1],
- [m.DIV_BY_ZERO, 2],
- [m.VALUE, 3],
- [m.REF, 4],
- [m.NAME, 5],
- [m.NUM, 6],
- [m.NA, 7],
- [m.CONNECT, 8],
- [m.CALC, 14]
- ]));
- }
- calculate(e) {
- return e.isArray() ? e.mapValue((t) => this._handleSingleObject(t)) : this._handleSingleObject(e);
- }
- _handleSingleObject(e) {
- const t = e.getValue(), r = this._errorTypeValueMap.get(t);
- return r ? y.create(r) : g.create(m.NA);
- }
- }
- var Ne = /* @__PURE__ */ ((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 || {});
- class j0 extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 3);
- A(this, "maxParams", 5);
- }
- calculate(e, t, r, n, s) {
- const o = n != null ? n : T.create(!0), u = s != null ? s : T.create(!0), { isError: c, errorObject: l, variants: f } = Fr(e, t, r, o, u);
- if (c)
- return l;
- const [h, d, _, C, E] = f;
- if (C.isString() || E.isString())
- return g.create(m.VALUE);
- if (d.compare(_, ">").getValue() === !0)
- return g.create(m.NUM);
- const R = +C.getValue(), p = +E.getValue(), N = R ? ">=" : ">", M = p ? "<=" : "<";
- return h.compare(d, N).getValue() === !1 || h.compare(_, M).getValue() === !1 ? T.create(!1) : T.create(!0);
- }
- }
- class U0 extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- return e.isNull() ? T.create(!0) : e.isArray() ? e.mapValue((t) => t.isNull() ? T.create(!0) : T.create(!1)) : T.create(!1);
- }
- }
- class v0 extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- let t = e;
- if (t.isArray()) {
- const r = t.getRowCount(), n = t.getColumnCount();
- if (r > 1 || n > 1)
- return g.create(m.VALUE);
- t = t.get(0, 0);
- }
- return t.isError() ? t : t.isNumber() && t.getPattern() !== "" ? T.create(Ba(t.getPattern())) : t.isString() && (Xs(`${t.getValue()}`) || Zs(`${t.getValue()}`)) ? T.create(!0) : T.create(!1);
- }
- }
- class T0 extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- let t = e;
- if (t.isArray()) {
- const o = t.getRowCount(), u = t.getColumnCount();
- if (o > 1 || u > 1)
- return g.create(m.VALUE);
- t = t.get(0, 0);
- }
- if (t.isError())
- return t;
- if (t.isNull() || t.isBoolean() || t.isNumber())
- return T.create(!1);
- const r = `${t.getValue()}`;
- if (r.length > 254)
- return T.create(!1);
- const n = Xe.topLevelDomainCombiningString(), s = new RegExp(
- `^(?:[\\w+-]+\\.)*[\\w+-]+@[a-z0-9_-]+(?:\\.[a-z0-9_-]+)*\\.(?:${n})$`,
- "i"
- );
- return T.create(s.test(r));
- }
- }
- class B0 extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- return e.getValue() === m.NA ? T.create(!1) : e.isError() ? T.create(!0) : e.isArray() ? e.mapValue((t) => t.getValue() === m.NA ? T.create(!1) : t.isError() ? T.create(!0) : T.create(!1)) : T.create(!1);
- }
- }
- class I0 extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- return e.isError() ? T.create(!0) : e.isArray() ? e.mapValue((t) => t.isError() ? T.create(!0) : T.create(!1)) : T.create(!1);
- }
- }
- class F0 extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- let t = e;
- if (t.isArray()) {
- const s = t.getRowCount(), o = t.getColumnCount();
- if (s > 1 || o > 1)
- return g.create(m.VALUE);
- t = t.get(0, 0);
- }
- if (t.isError())
- return t;
- if (t.isBoolean())
- return g.create(m.VALUE);
- const r = Math.trunc(+t.getValue());
- if (Number.isNaN(r))
- return g.create(m.VALUE);
- const n = r % 2 === 0;
- return T.create(n);
- }
- }
- class k0 extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- A(this, "needsReferenceObject", !0);
- }
- calculate(e) {
- var u;
- if (e.isError())
- return e;
- if (!e.isReferenceObject())
- return g.create(m.NA);
- const t = (u = e.getCurrentActiveSheetData()) == null ? void 0 : u.cellData.getMatrix(), { startRow: r, startColumn: n } = e.getRangePosition(), s = e.toArrayValueObject(), o = s.mapValue((c, l, f) => {
- var d;
- const h = (d = t == null ? void 0 : t[r + l]) == null ? void 0 : d[n + f];
- return h != null && h.f || h != null && h.si ? T.create(!0) : T.create(!1);
- });
- return s.getRowCount() === 1 && s.getColumnCount() === 1 ? o.get(0, 0) : o;
- }
- }
- class $0 extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- return e.isBoolean() ? T.create(!0) : e.isArray() ? e.mapValue((t) => t.isBoolean() ? T.create(!0) : T.create(!1)) : T.create(!1);
- }
- }
- class Y0 extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- return e.getValue() === m.NA ? T.create(!0) : e.isArray() ? e.mapValue((t) => t.getValue() === m.NA ? T.create(!0) : T.create(!1)) : T.create(!1);
- }
- }
- class H0 extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- return !e.isArray() && !e.isString() ? T.create(!0) : e.isArray() ? e.mapValue((t) => t.isString() ? T.create(!1) : T.create(!0)) : T.create(!1);
- }
- }
- class G0 extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- return e.isNumber() ? T.create(!0) : e.isArray() ? e.mapValue((t) => t.isNumber() ? T.create(!0) : T.create(!1)) : T.create(!1);
- }
- }
- class Q0 extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- let t = e;
- if (t.isArray()) {
- const s = t.getRowCount(), o = t.getColumnCount();
- if (s > 1 || o > 1)
- return g.create(m.VALUE);
- t = t.get(0, 0);
- }
- if (t.isError())
- return t;
- if (t.isBoolean())
- return g.create(m.VALUE);
- const r = Math.trunc(+t.getValue());
- if (Number.isNaN(r))
- return g.create(m.VALUE);
- const n = r % 2 !== 0;
- return T.create(n);
- }
- }
- class W0 extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- A(this, "needsReferenceObject", !0);
- }
- calculate(e) {
- return e.isReferenceObject() ? T.create(!0) : T.create(!1);
- }
- }
- class q0 extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- return e.isString() ? T.create(!0) : e.isArray() ? e.mapValue((t) => t.isString() ? T.create(!0) : T.create(!1)) : T.create(!1);
- }
- }
- class K0 extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- let t = e;
- if (t.isArray()) {
- const o = t.getRowCount(), u = t.getColumnCount();
- if (o > 1 || u > 1)
- return g.create(m.VALUE);
- t = t.get(0, 0);
- }
- if (t.isError())
- return t;
- if (t.isNull() || t.isBoolean() || t.isNumber())
- return T.create(!1);
- const r = `${t.getValue()}`.replace(/^\s+|\s+$/g, "");
- if (r.length > 1e3)
- return T.create(!1);
- const n = Xe.topLevelDomainCombiningString(), s = new RegExp(
- `^(?:(?: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$_\\.+!*(),;/?#:@&~=-]+)$`,
- "i"
- );
- return T.create(s.test(r));
- }
- }
- class X0 extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- let t = e;
- if (e.isArray() && (t = e.get(0, 0)), t.isError())
- return t;
- if (t.isString())
- return y.create(0);
- const r = +t.getValue();
- return y.create(r);
- }
- }
- class Z0 extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 0);
- A(this, "maxParams", 0);
- }
- calculate() {
- return g.create(m.NA);
- }
- }
- class z0 extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 0);
- A(this, "maxParams", 1);
- A(this, "needsReferenceObject", !0);
- A(this, "needsSheetsInfo", !0);
- }
- calculate(e) {
- var u;
- if (e != null && e.isError())
- return e;
- const { sheetOrder: t, sheetNameMap: r } = this.getSheetsInfo();
- if (!e) {
- const c = t.findIndex((l) => l === this.subUnitId);
- return y.create(c + 1);
- }
- if (e.isReferenceObject()) {
- const c = e.getForcedSheetId(), l = e.getDefaultSheetId(), f = t.findIndex((h) => c ? h === c : h === l);
- return y.create(f + 1);
- }
- if (e.isArray())
- return g.create(m.NA);
- const n = `${e.getValue()}`.toLocaleLowerCase(), s = (u = Object.entries(r).find(([c, l]) => l.toLocaleLowerCase() === n)) == null ? void 0 : u[0];
- if (!s)
- return g.create(m.NA);
- const o = t.findIndex((c) => c === s);
- return y.create(o + 1);
- }
- }
- class J0 extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 0);
- A(this, "maxParams", 0);
- A(this, "needsSheetsInfo", !0);
- }
- calculate() {
- const { sheetOrder: e } = this.getSheetsInfo();
- return y.create(e.length);
- }
- }
- class ed extends V {
- constructor() {
- super(...arguments);
- A(this, "needsReferenceObject", !0);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- if (e.isReferenceObject()) {
- const t = e.getRowCount(), r = e.getColumnCount();
- if (t === 1 && r === 1) {
- const n = e.getFirstCell();
- if (n.isError())
- return y.create(16);
- if (n.isBoolean())
- return y.create(4);
- if (n.isString())
- return y.create(2);
- if (n.isNumber() || n.isNull())
- return y.create(1);
- } else
- return y.create(64);
- } else {
- if (e.isArray())
- return y.create(64);
- if (e.isError())
- return y.create(16);
- if (e.isBoolean())
- return y.create(4);
- if (e.isString())
- return y.create(2);
- if (e.isNumber() || e.isNull())
- return y.create(1);
- }
- return y.create(128);
- }
- }
- const td = [
- [L0, Ne.CELL],
- [x0, Ne.ERROR_TYPE],
- [j0, Ne.ISBETWEEN],
- [U0, Ne.ISBLANK],
- [v0, Ne.ISDATE],
- [T0, Ne.ISEMAIL],
- [B0, Ne.ISERR],
- [I0, Ne.ISERROR],
- [F0, Ne.ISEVEN],
- [k0, Ne.ISFORMULA],
- [$0, Ne.ISLOGICAL],
- [Y0, Ne.ISNA],
- [H0, Ne.ISNONTEXT],
- [G0, Ne.ISNUMBER],
- [Q0, Ne.ISODD],
- [W0, Ne.ISREF],
- [q0, Ne.ISTEXT],
- [K0, Ne.ISURL],
- [X0, Ne.N],
- [Z0, Ne.NA],
- [z0, Ne.SHEET],
- [J0, Ne.SHEETS],
- [ed, Ne.TYPE]
- ];
- class rd extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 255);
- }
- calculate(...e) {
- let t = !0, r = !0, n = null;
- for (const s of e) {
- if (s.isError())
- return s;
- if (s.isArray()) {
- if (s.iterator((o) => {
- if (o != null && o.isError())
- return n = o, !1;
- (o != null && o.isBoolean() || o != null && o.isNumber()) && (t = t && !!o.getValue(), r = !1);
- }), n)
- return n;
- } else (s.isBoolean() || s.isNumber()) && (t = t && !!s.getValue(), r = !1);
- }
- return r ? g.create(m.VALUE) : T.create(t);
- }
- }
- class nd extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 2);
- A(this, "needsReferenceObject", !0);
- }
- // eslint-disable-next-line
- calculate(e, t) {
- let r = e, n = null;
- if (e.isReferenceObject() && (r = e.toArrayValueObject(), n = e), r.isError())
- return r;
- if (t.isError())
- return t;
- if (!(t.isValueObject() && t.isLambda() && t.getLambdaPrivacyVarKeys().length === 1))
- return g.create(m.VALUE);
- const s = t, o = r.isArray() ? r.getRowCount() : 1, u = r.isArray() ? r.getColumnCount() : 1;
- r = O(o, u, r);
- const c = [[]];
- for (let l = 0; l < u; l++) {
- const f = [];
- for (let _ = 0; _ < o; _++) {
- const C = r.get(_, l);
- f.push([C]);
- }
- let h = q.create({
- calculateValueList: f,
- rowCount: o,
- columnCount: 1,
- unitId: "",
- sheetId: "",
- row: 0,
- column: 0
- });
- if (n) {
- const { startRow: _, startColumn: C } = n.getRangePosition(), E = {
- startRow: _,
- startColumn: C + l,
- endRow: _ + o - 1,
- endColumn: C + l
- };
- h = this.createReferenceObject(n, E);
- }
- let d = s.execute(h);
- if (d.isArray()) {
- const _ = d.getRowCount(), C = d.getColumnCount();
- if (_ > 1 || C > 1)
- return g.create(m.CALC);
- d = d.get(0, 0);
- }
- d.isNull() && (d = y.create(0)), c[0].push(d);
- }
- return u === 1 ? c[0][0] : q.create({
- calculateValueList: c,
- rowCount: 1,
- columnCount: u,
- unitId: this.unitId,
- sheetId: this.subUnitId,
- row: this.row,
- column: this.column
- });
- }
- }
- class sd extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 2);
- A(this, "needsReferenceObject", !0);
- }
- // eslint-disable-next-line
- calculate(e, t) {
- let r = e, n = null;
- if (e.isReferenceObject() && (r = e.toArrayValueObject(), n = e), r.isError())
- return r;
- if (t.isError())
- return t;
- if (!(t.isValueObject() && t.isLambda() && t.getLambdaPrivacyVarKeys().length === 1))
- return g.create(m.VALUE);
- const s = t, o = r.isArray() ? r.getRowCount() : 1, u = r.isArray() ? r.getColumnCount() : 1;
- r = O(o, u, r);
- const c = [];
- for (let l = 0; l < o; l++) {
- const f = [[]];
- for (let _ = 0; _ < u; _++) {
- const C = r.get(l, _);
- f[0].push(C);
- }
- let h = q.create({
- calculateValueList: f,
- rowCount: 1,
- columnCount: u,
- unitId: "",
- sheetId: "",
- row: 0,
- column: 0
- });
- if (n) {
- const { startRow: _, startColumn: C } = n.getRangePosition(), E = {
- startRow: _ + l,
- startColumn: C,
- endRow: _ + l,
- endColumn: C + u - 1
- };
- h = this.createReferenceObject(n, E);
- }
- let d = s.execute(h);
- if (d.isArray()) {
- const _ = d.getRowCount(), C = d.getColumnCount();
- if (_ > 1 || C > 1)
- return g.create(m.CALC);
- d = d.get(0, 0);
- }
- d.isNull() && (d = y.create(0)), c.push([d]);
- }
- return o === 1 ? c[0][0] : q.create({
- calculateValueList: c,
- rowCount: o,
- columnCount: 1,
- unitId: this.unitId,
- sheetId: this.subUnitId,
- row: this.row,
- column: this.column
- });
- }
- }
- class ad extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 0);
- A(this, "maxParams", 0);
- }
- calculate() {
- return T.create(!1);
- }
- }
- var Se = /* @__PURE__ */ ((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))(Se || {});
- class id extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 3);
- }
- calculate(e, t, r = T.create(!1)) {
- const n = this._getSingleValueObject(e);
- if (n.isError())
- return n;
- if (!n.isArray())
- return n.getValue() ? t : r;
- const s = Math.max(
- n.isArray() ? n.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1,
- r.isArray() ? r.getRowCount() : 1
- ), o = Math.max(
- n.isArray() ? n.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1,
- r.isArray() ? r.getColumnCount() : 1
- ), u = O(s, o, n), c = O(s, o, t, g.create(m.NA)), l = O(s, o, r, g.create(m.NA));
- return u.map((f, h, d) => {
- if (f.isNull())
- return g.create(m.NA);
- {
- const _ = c.get(h, d) || ie.create(), C = l.get(h, d) || ie.create();
- return this._calculateSingleCell(f, _, C);
- }
- });
- }
- _getSingleValueObject(e) {
- return e.isArray() && e.getRowCount() === 1 && e.getColumnCount() === 1 ? e.getFirstCell() : e;
- }
- _calculateSingleCell(e, t, r) {
- return e.isNull() ? g.create(m.NA) : e.getValue() ? t.isNull() ? g.create(m.NA) : t : r.isNull() ? g.create(m.NA) : r;
- }
- }
- class od extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- if (!e.isArray())
- return e.isError() ? t : e;
- const r = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1
- ), n = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1
- ), s = O(r, n, e), o = O(r, n, t);
- return s.iterator((u, c, l) => {
- u != null && u.isError() && s.set(c, l, o.get(c, l));
- }), s;
- }
- }
- class ud extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- if (e.isError() && e.getErrorType() !== m.NA)
- return e;
- if (t.isError())
- return t;
- if (!e.isArray())
- return e.isError() && e.getErrorType() === m.NA ? t : e;
- const r = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1
- ), n = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1
- ), s = O(r, n, e), o = O(r, n, t);
- return s.iterator((u, c, l) => {
- u != null && u.isError() && u.getErrorType() === m.NA && s.set(c, l, o.get(c, l));
- }), s;
- }
- }
- class cd extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 255);
- }
- calculate(...e) {
- if (e.length % 2 !== 0)
- return g.create(m.NA);
- for (let o = 0; o < e.length; o++)
- if (e[o].isError())
- return e[o];
- const t = Math.max(
- ...e.map((o) => o.isArray() ? o.getRowCount() : 1)
- ), r = Math.max(
- ...e.map((o) => o.isArray() ? o.getColumnCount() : 1)
- ), n = e.map(
- (o) => O(t, r, o, g.create(m.NA))
- ), s = n[0].map((o, u, c) => {
- for (let l = 0; l < n.length; l += 2) {
- const f = n[l].get(u, c) || ie.create(), h = n[l + 1].get(u, c) || ie.create();
- if (f.isNull())
- continue;
- if (f.isError())
- return f;
- const d = f.getValue();
- if (f.isString()) {
- if (`${d}`.toLocaleUpperCase() === "TRUE")
- return h;
- if (`${d}`.toLocaleUpperCase() === "FALSE")
- continue;
- return g.create(m.VALUE);
- }
- if (+d)
- return h.isNull() ? g.create(m.NA) : h;
- }
- return g.create(m.NA);
- });
- return t === 1 && r === 1 ? s.get(0, 0) : s;
- }
- }
- class ld extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 255);
- }
- calculate(...e) {
- return g.create(m.VALUE);
- }
- }
- class fd extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 3);
- A(this, "maxParams", 255);
- }
- calculate(...e) {
- return g.create(m.VALUE);
- }
- }
- class hd extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 3);
- A(this, "maxParams", 3);
- }
- calculate(...e) {
- const t = this.getIndexNumValue(e[0]);
- if (typeof t != "number")
- return t;
- const r = this.getIndexNumValue(e[1]);
- if (typeof r != "number")
- return r;
- if (!(e[2].isValueObject() && e[2].isLambda()))
- return g.create(m.VALUE);
- const n = e[2], s = [];
- for (let o = 0; o < t; o++) {
- s[o] == null && (s[o] = []);
- for (let u = 0; u < r; u++) {
- let c = n.execute(y.create(o + 1), y.create(u + 1));
- c.isArray() && (c = c.get(0, 0)), s[o][u] = c;
- }
- }
- return new Of(s);
- }
- isAsync() {
- return !0;
- }
- }
- let md = class extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 255);
- A(this, "needsReferenceObject", !0);
- }
- calculate(...e) {
- const t = [];
- let r = null, n = 0, s = 0;
- for (let u = 0; u < e.length; u++) {
- const c = e[u];
- let l = c;
- if (l.isReferenceObject() && (l = c.toArrayValueObject()), l.isError())
- return l;
- if (u === e.length - 1) {
- if (!(c.isValueObject() && c.isLambda()))
- return g.create(m.VALUE);
- r = c;
- } else
- t.push(c), n = Math.max(n, l.isArray() ? l.getRowCount() : 1), s = Math.max(s, l.isArray() ? l.getColumnCount() : 1);
- }
- const o = this._getResultArray(t, r, n, s);
- return o instanceof g ? o : n === 1 && s === 1 ? o[0][0] : q.create({
- calculateValueList: o,
- rowCount: n,
- columnCount: s,
- unitId: this.unitId,
- sheetId: this.subUnitId,
- row: this.row,
- column: this.column
- });
- }
- // eslint-disable-next-line
- _getResultArray(e, t, r, n) {
- const s = [];
- for (let o = 0; o < r; o++) {
- const u = [];
- for (let c = 0; c < n; c++) {
- const l = [];
- let f = !1;
- for (let d = 0; d < e.length; d++) {
- let _ = e[d], C = null;
- if (_.isReferenceObject() && (C = _, _ = _.toArrayValueObject()), !_.isArray())
- if (o === 0 && c === 0) {
- l.push(C || _);
- continue;
- } else {
- u.push(g.create(m.NA)), f = !0;
- break;
- }
- let E = _.get(o, c);
- if (!E) {
- u.push(g.create(m.NA)), f = !0;
- break;
- }
- if (C) {
- const { startRow: b, startColumn: R } = C.getRangePosition(), p = {
- startRow: b + o,
- startColumn: R + c,
- endRow: b + o,
- endColumn: R + c
- };
- E = this.createReferenceObject(C, p);
- }
- l.push(E);
- }
- if (f || l.length === 0)
- continue;
- let h = t.execute(...l);
- if (h.isArray()) {
- const d = h.getRowCount(), _ = h.getColumnCount();
- if (d > 1 || _ > 1)
- return g.create(m.CALC);
- h = h.get(0, 0);
- }
- h.isNull() && (h = y.create(0)), u.push(h);
- }
- s.push(u);
- }
- return s;
- }
- };
- class gd extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- return e.isArray() ? e.map((t) => this._handleSingleObject(t)) : this._handleSingleObject(e);
- }
- _handleSingleObject(e) {
- if (e.isError())
- return e;
- const t = +e.getValue();
- return Number.isNaN(t) ? g.create(m.VALUE) : T.create(!t);
- }
- }
- class dd extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 255);
- }
- calculate(...e) {
- let t = !1, r = !0, n = null;
- for (const s of e) {
- if (s.isError())
- return s;
- if (s.isArray()) {
- if (s.iterator((o) => {
- if (o != null && o.isError())
- return n = o, !1;
- (o != null && o.isBoolean() || o != null && o.isNumber()) && (t = t || !!o.getValue(), r = !1);
- }), n)
- return n;
- } else (s.isBoolean() || s.isNumber()) && (t = t || !!s.getValue(), r = !1);
- }
- return r ? new g(m.VALUE) : new T(t);
- }
- }
- class Cd extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 3);
- A(this, "maxParams", 3);
- A(this, "needsReferenceObject", !0);
- }
- calculate(e, t, r) {
- let n, s;
- e.isReferenceObject() ? (n = e.toArrayValueObject(), s = e) : (n = e, s = null);
- let o, u;
- 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);
- }
- _handleSingleValueObject(e, t, r, n, s) {
- if (e.isError())
- return e;
- if (t.isError())
- return t;
- if (r.isError())
- return r;
- if (!(r.isValueObject() && r.isLambda() && r.getLambdaPrivacyVarKeys().length === 2))
- return g.create(m.VALUE);
- const o = r, u = t.isArray() ? t.getRowCount() : 1, c = t.isArray() ? t.getColumnCount() : 1;
- let l = e;
- n && (l = n);
- for (let f = 0; f < u; f++)
- for (let h = 0; h < c; h++) {
- let d = t.isArray() ? t.get(f, h) : t;
- if (d.isError())
- return d;
- if (s) {
- const { startRow: C, startColumn: E } = s.getRangePosition(), b = {
- startRow: C + f,
- startColumn: E + h,
- endRow: C + f,
- endColumn: E + h
- };
- d = this.createReferenceObject(s, b);
- }
- let _ = o.execute(l, d);
- if (_.isError())
- return _;
- _.isNull() && (_ = y.create(0)), l = _;
- }
- return l.isReferenceObject() ? l.toArrayValueObject() : l;
- }
- }
- class _d extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 3);
- A(this, "maxParams", 3);
- A(this, "needsReferenceObject", !0);
- }
- calculate(e, t, r) {
- let n = e, s = null;
- e.isReferenceObject() && (n = e.toArrayValueObject(), s = e), n = n;
- let o = t, u = null;
- if (t.isReferenceObject() && (o = t.toArrayValueObject(), u = t), o = o, n.isError())
- return n;
- if (o.isError())
- return o;
- if (r.isError())
- return r;
- if (!(r.isValueObject() && r.isLambda() && r.getLambdaPrivacyVarKeys().length === 2))
- return g.create(m.VALUE);
- if (n.isArray()) {
- const c = n.getRowCount(), l = n.getColumnCount();
- if (c > 1 || l > 1)
- return g.create(m.CALC);
- n = n.get(0, 0);
- }
- return this._getResult(n, o, r, s, u);
- }
- // eslint-disable-next-line
- _getResult(e, t, r, n, s) {
- const o = [], u = t.isArray() ? t.getRowCount() : 1, c = t.isArray() ? t.getColumnCount() : 1;
- let l = e;
- n && (l = n);
- for (let f = 0; f < u; f++) {
- const h = [];
- for (let d = 0; d < c; d++) {
- if (l.isError()) {
- h.push(l);
- continue;
- }
- let _ = t.isArray() ? t.get(f, d) : t;
- if (_.isError()) {
- l = _, h.push(_);
- continue;
- }
- if (s) {
- const { startRow: E, startColumn: b } = s.getRangePosition(), R = {
- startRow: E + f,
- startColumn: b + d,
- endRow: E + f,
- endColumn: b + d
- };
- _ = this.createReferenceObject(s, R);
- }
- let C = r.execute(l, _);
- if (C.isArray()) {
- const E = C.getRowCount(), b = C.getColumnCount();
- if (E > 1 || b > 1)
- return g.create(m.CALC);
- C = C.get(0, 0);
- }
- C.isNull() && (C = y.create(0)), l = C, h.push(C);
- }
- o.push(h);
- }
- return u === 1 && c === 1 ? o[0][0] : q.create({
- calculateValueList: o,
- rowCount: u,
- columnCount: c,
- unitId: this.unitId,
- sheetId: this.subUnitId,
- row: this.row,
- column: this.column
- });
- }
- }
- class Ad extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 3);
- }
- calculate(e, ...t) {
- if (e.isError())
- return e;
- const r = t.length % 2 !== 0, n = r ? t[t.length - 1] : ie.create();
- return !e.isArray() && !t.some((s) => s.isArray()) ? this._handleNonArrayInputs(e, t, n, r) : this._handleArrayInputs(e, t, n, r);
- }
- _handleNonArrayInputs(e, t, r, n) {
- for (let s = 0; s < t.length - (n ? 1 : 0); s += 2) {
- const o = t[s], u = t[s + 1];
- if (!o.isNull()) {
- if (o.isError())
- return o;
- if (`${e.getValue()}`.toLocaleLowerCase() === `${o.getValue()}`.toLocaleLowerCase())
- return u.isNull() ? g.create(m.NA) : u;
- }
- }
- return r.isNull() ? g.create(m.NA) : r;
- }
- _handleArrayInputs(e, t, r, n) {
- const s = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- ...t.map((f) => f.isArray() ? f.getRowCount() : 1),
- r.isArray() ? r.getRowCount() : 1
- ), o = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- ...t.map((f) => f.isArray() ? f.getColumnCount() : 1),
- r.isArray() ? r.getColumnCount() : 1
- ), u = O(s, o, e), c = t.map(
- (f) => O(s, o, f, g.create(m.NA))
- ), l = O(s, o, r, g.create(m.NA));
- return u.map((f, h, d) => {
- for (let C = 0; C < c.length - (n ? 1 : 0); C += 2) {
- const E = c[C].get(h, d) || ie.create(), b = c[C + 1].get(h, d) || ie.create();
- if (!E.isNull()) {
- if (E.isError() || f.isError())
- return E.isError() ? E : f;
- if (`${f.getValue()}`.toLocaleLowerCase() === `${E.getValue()}`.toLocaleLowerCase())
- return b.isNull() ? g.create(m.NA) : b;
- }
- }
- const _ = l.get(h, d) || ie.create();
- return _.isNull() ? g.create(m.NA) : _;
- });
- }
- }
- class Ed extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 0);
- A(this, "maxParams", 0);
- }
- calculate() {
- return T.create(!0);
- }
- }
- class bd extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 255);
- }
- calculate(...e) {
- let t = 0, r = !0, n = null;
- for (const s of e) {
- if (s.isError())
- return s;
- if (s.isArray()) {
- if (s.iterator((o) => {
- if (o != null && o.isError())
- return n = o, !1;
- (o != null && o.isBoolean() || o != null && o.isNumber()) && (o.getValue() && t++, r = !1);
- }), n)
- return n;
- } else (s.isBoolean() || s.isNumber()) && (s.getValue() && t++, r = !1);
- }
- return r ? g.create(m.VALUE) : T.create(t % 2 === 1);
- }
- }
- const yd = [
- [rd, Se.AND],
- [nd, Se.BYCOL],
- [sd, Se.BYROW],
- [ad, Se.FALSE],
- [id, Se.IF],
- [od, Se.IFERROR],
- [ud, Se.IFNA],
- [cd, Se.IFS],
- [ld, Se.LAMBDA],
- [fd, Se.LET],
- [hd, Se.MAKEARRAY],
- [md, Se.MAP],
- [gd, Se.NOT],
- [dd, Se.OR],
- [Cd, Se.REDUCE],
- [_d, Se.SCAN],
- [Ad, Se.SWITCH],
- [Ed, Se.TRUE],
- [bd, Se.XOR]
- ];
- class Rd extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 5);
- }
- // eslint-disable-next-line max-lines-per-function
- calculate(e, t, r, n, s) {
- if (e.isError())
- return e;
- if (t.isError())
- return t;
- if (r != null && r.isError())
- return r;
- if (n != null && n.isError())
- return n;
- if (s != null && s.isError())
- return s;
- const o = r != null ? r : y.create(1), u = n != null ? n : T.create(!0), c = s != null ? s : j.create(""), l = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1,
- o.isArray() ? o.getRowCount() : 1,
- u.isArray() ? u.getRowCount() : 1,
- c.isArray() ? c.getRowCount() : 1
- ), f = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1,
- o.isArray() ? o.getColumnCount() : 1,
- u.isArray() ? u.getColumnCount() : 1,
- c.isArray() ? c.getColumnCount() : 1
- ), h = O(l, f, e, g.create(m.NA)), d = O(l, f, t, g.create(m.NA)), _ = O(l, f, o, g.create(m.NA)), C = O(l, f, u, g.create(m.NA)), E = O(l, f, c, g.create(m.NA));
- return h.map((b, R, p) => {
- const N = d.get(R, p) || g.create(m.NA), M = _.get(R, p) || g.create(m.NA), w = C.get(R, p) || g.create(m.NA), D = E.get(R, p) || g.create(m.NA);
- return b.isError() ? b : N.isError() ? N : M.isError() ? M : w.isError() ? w : D.isError() ? D : this._calculateSingleCell(b, N, M, w, D);
- });
- }
- _calculateSingleCell(e, t, r, n, s) {
- const o = Number.parseInt(`${Number(e.getValue()) - 1}`), u = Number.parseInt(`${Number(t.getValue()) - 1}`), c = Number.parseInt(`${Number(r.getValue())}`);
- if (Number.isNaN(o) || Number.isNaN(u) || Number.isNaN(c) || c < 1 || c > 4)
- return g.create(m.VALUE);
- const l = pd(c), f = this.getZeroOrOneByOneDefault(n), h = `${s.getValue()}`, d = Ki(h), _ = {
- startRow: o,
- startColumn: u,
- endRow: o,
- endColumn: u,
- startAbsoluteRefType: l,
- endAbsoluteRefType: l
- }, C = n && !f ? Fh(_) : fr(_);
- return j.create(d !== "" ? `${d}!${C}` : C);
- }
- }
- function pd(i) {
- switch (i) {
- case 1:
- return we.ALL;
- case 2:
- return we.ROW;
- case 3:
- return we.COLUMN;
- case 4:
- return we.NONE;
- default:
- return we.ALL;
- }
- }
- class Vd extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- A(this, "needsReferenceObject", !0);
- }
- calculate(e) {
- return e.isReferenceObject() ? y.create(1) : g.create(m.VALUE);
- }
- }
- class Nd extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 255);
- A(this, "needsReferenceObject", !0);
- }
- calculate(e, ...t) {
- let r = e;
- if (r.isError())
- return r;
- if (r.isReferenceObject() && (r = r.toArrayValueObject()), !r.isArray()) {
- const c = r.convertToNumberObjectValue();
- return c.isError() ? c : t[Math.trunc(+c.getValue()) - 1] || g.create(m.VALUE);
- }
- let n = r.isArray() ? r.getRowCount() : 1, s = r.isArray() ? r.getColumnCount() : 1;
- t.forEach((c, l) => {
- if (c.isArray()) {
- const f = c;
- n = Math.max(n, f.getRowCount()), s = Math.max(s, f.getColumnCount());
- } else
- n = Math.max(n, 1), s = Math.max(s, 1);
- });
- const o = O(n, s, r, g.create(m.NA)), u = t.map((c) => {
- let l = c;
- return l.isReferenceObject() && (l = l.toArrayValueObject()), O(n, s, l, g.create(m.NA));
- });
- return o.map((c, l, f) => {
- if (c.isError())
- return c;
- const h = c.convertToNumberObjectValue();
- if (h.isError())
- return h;
- const d = u[Math.trunc(+h.getValue()) - 1];
- let _ = (d == null ? void 0 : d.get(l, f)) || g.create(m.VALUE);
- return _ != null && _.isNull() && (_ = y.create(0)), _;
- });
- }
- }
- class Od extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 255);
- }
- calculate(e, ...t) {
- if (e.isError())
- return e;
- const r = e.isArray() ? e.getRowCount() : 1, n = e.isArray() ? e.getColumnCount() : 1, s = [];
- for (let o = 0; o < t.length; o++) {
- let u = t[o];
- if (u.isArray()) {
- const f = u.getRowCount(), h = u.getColumnCount();
- if (f > 1 || h > 1)
- return g.create(m.VALUE);
- u = u.get(0, 0);
- }
- if (u.isString() && (u = u.convertToNumberObjectValue()), u.isError())
- return u;
- const c = Math.trunc(+u.getValue());
- if (c === 0 || Math.abs(c) > n)
- return g.create(m.VALUE);
- let l = e;
- n > 1 && (c < 0 ? l = e.slice(void 0, [c + n, c + 1 + n]) : l = e.slice(void 0, [c - 1, c]));
- for (let f = 0; f < r; f++)
- s[f] || (s[f] = []), e.isArray() ? s[f].push(l.get(f, 0)) : s[f].push(e);
- }
- return q.create({
- calculateValueList: s,
- rowCount: s.length,
- columnCount: s[0].length || 0,
- unitId: this.unitId,
- sheetId: this.subUnitId,
- row: this.row,
- column: this.column
- });
- }
- }
- class Md extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 255);
- }
- calculate(e, ...t) {
- if (e.isError())
- return e;
- const r = e.isArray() ? e.getRowCount() : 1, n = [];
- for (let s = 0; s < t.length; s++) {
- let o = t[s];
- if (o.isArray()) {
- const l = o.getRowCount(), f = o.getColumnCount();
- if (l > 1 || f > 1)
- return g.create(m.VALUE);
- o = o.get(0, 0);
- }
- if (o.isString() && (o = o.convertToNumberObjectValue()), o.isError())
- return o;
- const u = Math.trunc(+o.getValue());
- if (u === 0 || Math.abs(u) > r)
- return g.create(m.VALUE);
- let c = e;
- 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]);
- }
- return q.create({
- calculateValueList: n,
- rowCount: n.length,
- columnCount: n[0].length || 0,
- unitId: this.unitId,
- sheetId: this.subUnitId,
- row: this.row,
- column: this.column
- });
- }
- }
- class wd extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 0);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- if (e == null)
- return y.create(this.column + 1);
- if (e.isError())
- return e;
- if (!e.isArray())
- return g.create(m.NA);
- const t = e.getCurrentColumn(), r = e.getColumnCount(), n = [];
- for (let o = 0; o < r; o++)
- n.push(y.create(t + o + 1));
- const s = {
- calculateValueList: [n],
- rowCount: 1,
- columnCount: r,
- unitId: this.unitId || "",
- sheetId: this.subUnitId || "",
- row: this.row,
- column: this.column
- };
- return q.create(s);
- }
- }
- class Dd extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- if (e.isError())
- return e;
- if (e.isString() || e.isNumber() || e.isBoolean())
- return y.create(1);
- if (!e.isArray())
- return g.create(m.NA);
- const t = e.getColumnCount();
- return y.create(t);
- }
- }
- class Sd extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 3);
- }
- calculate(e, t, r) {
- const n = r != null ? r : y.create(0), s = e.isArray() ? e.getRowCount() : 1, o = e.isArray() ? e.getColumnCount() : 1, u = Math.max(
- t.isArray() ? t.getRowCount() : 1,
- n.isArray() ? n.getRowCount() : 1
- ), c = Math.max(
- t.isArray() ? t.getColumnCount() : 1,
- n.isArray() ? n.getColumnCount() : 1
- ), l = O(u, c, t, g.create(m.NA)), f = O(u, c, n, g.create(m.NA));
- if (u > 1 || c > 1)
- return l.mapValue((R, p, N) => {
- const M = f.get(p, N);
- if (e.isError())
- return e;
- if (e.isNull())
- return g.create(m.VALUE);
- const { isError: w, errorObject: D } = this._checkRowsColumns(R, M, s, o);
- return w ? D : e.isArray() ? g.create(m.VALUE) : e;
- });
- if (e.isError())
- return e;
- if (e.isNull())
- return g.create(m.VALUE);
- const h = t.isArray() ? t.get(0, 0) : t, d = n.isArray() ? n.get(0, 0) : n, { isError: _, errorObject: C, rowsValue: E, columnsValue: b } = this._checkRowsColumns(h, d, s, o);
- return _ ? C : this._getResultArray(e, E, b, s, o);
- }
- _checkRowsColumns(e, t, r, n) {
- if (e.isError())
- return {
- isError: !0,
- errorObject: e
- };
- if (t.isError())
- return {
- isError: !0,
- errorObject: t
- };
- const s = Math.trunc(+e.getValue()), o = Math.trunc(+t.getValue());
- return Number.isNaN(s) || Number.isNaN(o) ? {
- isError: !0,
- errorObject: g.create(m.VALUE)
- } : Math.abs(s) >= r || Math.abs(o) >= n ? {
- isError: !0,
- errorObject: g.create(m.CALC)
- } : {
- isError: !1,
- rowsValue: s,
- columnsValue: o
- };
- }
- _getResultArray(e, t, r, n, s) {
- const o = t >= 0 ? [t, n] : [0, n + t], u = r >= 0 ? [r, s] : [0, s + r];
- let c;
- 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((l) => l.isNull() ? y.create(0) : l), n - t === 1 && s - r === 1 ? c.get(0, 0) : c;
- }
- }
- class Pd extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 4);
- }
- calculate(e, t, r, n) {
- const s = e.isArray() ? e.getRowCount() : 1, o = e.isArray() ? e.getColumnCount() : 1;
- let u = t, c = r != null ? r : y.create(o);
- const l = n != null ? n : g.create(m.NA);
- t.isNull() && (u = y.create(s)), c.isNull() && (c = y.create(o));
- const f = Math.max(
- u.isArray() ? u.getRowCount() : 1,
- c.isArray() ? c.getRowCount() : 1
- ), h = Math.max(
- u.isArray() ? u.getColumnCount() : 1,
- c.isArray() ? c.getColumnCount() : 1
- ), d = O(f, h, u, g.create(m.NA)), _ = O(f, h, c, g.create(m.NA));
- if (f > 1 || h > 1)
- return d.mapValue((w, D, S) => {
- const P = _.get(D, S);
- if (e.isError())
- return e;
- if (e.isNull())
- return g.create(m.VALUE);
- const { isError: U, errorObject: x } = this._checkRowsColumnsPadWith(w, P, l, s, o);
- return U ? x : e.isArray() ? e.get(0, 0) : e;
- });
- if (e.isError())
- return e;
- if (e.isNull())
- return g.create(m.VALUE);
- const C = u.isArray() ? u.get(0, 0) : u, E = c.isArray() ? c.get(0, 0) : c, { isError: b, errorObject: R, rowsValue: p, columnsValue: N, padWithObject: M } = this._checkRowsColumnsPadWith(C, E, l, s, o);
- return b ? R : this._getResultArray(e, p, N, M, s, o);
- }
- _checkRowsColumnsPadWith(e, t, r, n, s) {
- if (e.isError())
- return {
- isError: !0,
- errorObject: e
- };
- if (t.isError())
- return {
- isError: !0,
- errorObject: t
- };
- const o = Math.trunc(+e.getValue()), u = Math.trunc(+t.getValue());
- if (Number.isNaN(o) || Number.isNaN(u))
- return {
- isError: !0,
- errorObject: g.create(m.VALUE)
- };
- if (Math.abs(o) < n || Math.abs(u) < s)
- return {
- isError: !0,
- errorObject: g.create(m.VALUE)
- };
- let c = r;
- if (r.isArray()) {
- const l = r.getRowCount(), f = r.getColumnCount();
- if (l > 1 || f > 1)
- return {
- isError: !0,
- errorObject: g.create(m.VALUE)
- };
- c = r.get(0, 0);
- }
- return {
- isError: !1,
- rowsValue: o,
- columnsValue: u,
- padWithObject: c
- };
- }
- _getResultArray(e, t, r, n, s, o) {
- let u = [];
- e.isArray() ? u = e.map((f) => f.isNull() ? y.create(0) : f).getArrayValue() : u = [[e]];
- const c = Math.max(0, t - s), l = Math.max(0, r - o);
- for (let f = 0; f < c; f++)
- u.push(new Array(o).fill(n));
- for (let f = 0; f < l; f++)
- u.forEach((h) => {
- h.push(n);
- });
- return t === 1 && r === 1 ? u[0][0] : q.create({
- calculateValueList: u,
- rowCount: u.length,
- columnCount: u[0].length,
- unitId: this.unitId,
- sheetId: this.subUnitId,
- row: this.row,
- column: this.column
- });
- }
- }
- class Ld extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 3);
- }
- calculate(e, t, r) {
- const n = r != null ? r : g.create(m.CALC);
- if (e.isError())
- return e;
- if (t.isError())
- return t;
- 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;
- return u > 1 && c > 1 || u === 1 && c !== o || c === 1 && u !== s ? g.create(m.VALUE) : s === 1 && o === 1 ? this._getResultArrayByR1C1(e, t, n) : u === 1 ? c !== o ? g.create(m.VALUE) : this._getResultArrayByR1(s, o, e, t, n) : c === 1 ? u !== s ? g.create(m.VALUE) : this._getResultArrayByC1(s, o, e, t, n) : n;
- }
- _getResultArrayByR1C1(e, t, r) {
- let n = e, s = t;
- 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;
- }
- _getResultArrayByR1(e, t, r, n, s) {
- const o = [];
- for (let u = 0; u < t; u++) {
- let c = n.get(0, u);
- if (c.isString() && (c = c.convertToNumberObjectValue()), c.isError())
- return c;
- if (+c.getValue())
- for (let f = 0; f < e; f++) {
- o[f] || (o[f] = []);
- const h = r.get(f, u);
- o[f].push(h);
- }
- }
- return o.length === 0 ? s : q.create({
- calculateValueList: o,
- rowCount: o.length,
- columnCount: o[0].length || 0,
- unitId: this.unitId,
- sheetId: this.subUnitId,
- row: this.row,
- column: this.column
- });
- }
- _getResultArrayByC1(e, t, r, n, s) {
- const o = [];
- for (let u = 0; u < e; u++) {
- let c = n.get(u, 0);
- if (c.isString() && (c = c.convertToNumberObjectValue()), c.isError())
- return c;
- if (!+c.getValue())
- continue;
- const f = [];
- for (let h = 0; h < t; h++) {
- const d = r.get(u, h);
- f.push(d);
- }
- o.push(f);
- }
- return o.length === 0 ? s : q.create({
- calculateValueList: o,
- rowCount: o.length,
- columnCount: o[0].length || 0,
- unitId: this.unitId,
- sheetId: this.subUnitId,
- row: this.row,
- column: this.column
- });
- }
- }
- class xd extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- A(this, "needsReferenceObject", !0);
- A(this, "needsFormulaDataModel", !0);
- }
- calculate(e) {
- var f, h;
- if (!e.isReferenceObject())
- return g.create(m.NA);
- const t = e.getUnitId(), r = e.getSheetId(), s = (h = (f = e.getUnitData()[t]) == null ? void 0 : f[r]) == null ? void 0 : h.cellData, { startRow: o, startColumn: u } = e.getRangePosition(), l = e.toArrayValueObject().mapValue((d, _, C) => {
- const E = s.getValue(o + _, u + C);
- if (E != null && E.f || E != null && E.si) {
- const b = this._formulaDataModel.getFormulaStringByCell(o + _, u + C, r, t);
- return j.create(b);
- }
- return g.create(m.NA);
- });
- return l.getRowCount() === 1 && l.getColumnCount() === 1 ? l.get(0, 0) : l;
- }
- }
- var me = /* @__PURE__ */ ((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))(me || {});
- class jd extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 3);
- A(this, "maxParams", 4);
- }
- calculate(e, t, r, n) {
- if (e.isError())
- return e;
- if (t.isError())
- return g.create(m.REF);
- if (!t.isArray() || r.isError() || n != null && n.isError())
- return g.create(m.NA);
- const s = this.getZeroOrOneByOneDefault(n);
- if (s == null)
- return g.create(m.VALUE);
- const o = this.getIndexNumValue(r);
- if (o instanceof g)
- return o;
- const u = t.slice([0, 1]), c = t.slice([o - 1, o]);
- return u == null || c == null ? g.create(m.REF) : e.isArray() ? e.map((l) => this._handleSingleObject(l, u, c, s)) : this._handleSingleObject(e, u, c, s);
- }
- _handleSingleObject(e, t, r, n) {
- return n === 0 ? this.equalSearch(e, t, r) : this.binarySearch(e, t, r);
- }
- }
- class Ud extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 255);
- }
- calculate(...e) {
- const t = Math.max(
- ...e.map((n) => n.isArray() ? n.getRowCount() : 1)
- ), r = [];
- for (let n = 0; n < e.length; n++) {
- const s = e[n];
- if (s.isError())
- return s;
- const o = s.isArray() ? s.getRowCount() : 1, u = s.isArray() ? s.getColumnCount() : 1;
- for (let c = 0; c < t; c++) {
- r[c] || (r[c] = []);
- for (let l = 0; l < u; l++) {
- let f = s;
- s.isArray() && (f = s.get(c, l)), c > o - 1 || !f ? r[c].push(g.create(m.NA)) : r[c].push(f);
- }
- }
- }
- return q.create({
- calculateValueList: r,
- rowCount: r.length,
- columnCount: r[0].length || 0,
- unitId: this.unitId,
- sheetId: this.subUnitId,
- row: this.row,
- column: this.column
- });
- }
- }
- class vd extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 4);
- A(this, "needsReferenceObject", !0);
- }
- // eslint-disable-next-line max-lines-per-function, complexity
- calculate(e, t, r, n) {
- if (e.isError())
- return e;
- if (t != null && t.isError())
- return t;
- if (r != null && r.isError())
- return r;
- if (n != null && n.isError())
- return n;
- let s = 0, o = 0;
- if (e.isValueObject())
- s = 1, o = 1;
- else if (e.isReferenceObject()) {
- const { startRow: d, endRow: _, startColumn: C, endColumn: E } = e.getRangePosition();
- s = _ - d + 1, o = E - C + 1;
- } else
- return g.create(m.VALUE);
- let u, c;
- s === 1 && o > 1 && r == null ? (c = t != null ? t : y.create(0), u = y.create(0)) : (u = t != null ? t : y.create(0), c = r != null ? r : y.create(0));
- let l = n != null ? n : y.create(1);
- u.isReferenceObject() && (u = u.toArrayValueObject()), c.isReferenceObject() && (c = c.toArrayValueObject()), l.isReferenceObject() && (l = l.toArrayValueObject());
- const f = Math.max(
- u.isArray() ? u.getRowCount() : 1,
- c.isArray() ? c.getRowCount() : 1,
- l.isArray() ? l.getRowCount() : 1
- ), h = Math.max(
- u.isArray() ? u.getColumnCount() : 1,
- c.isArray() ? c.getColumnCount() : 1,
- l.isArray() ? l.getColumnCount() : 1
- );
- if (u = u, c = c, l = l, f === 1 && h === 1)
- return this._calculateSingleCell(e, u, c, l);
- {
- const d = O(f, h, u, g.create(m.NA)), _ = O(f, h, c, g.create(m.NA)), C = O(f, h, l, g.create(m.NA));
- return d.map((E, b, R) => {
- const p = _.get(b, R) || ie.create(), N = C.get(b, R) || ie.create(), M = this._calculateSingleCell(e, E, p, N);
- return M.isReferenceObject() ? M.toArrayValueObject().getFirstCell() : M;
- });
- }
- }
- _calculateSingleCell(e, t, r, n) {
- if (t.isError())
- return t;
- const s = this._getNumberValue(t);
- if (s === void 0 || s < 0)
- return g.create(m.VALUE);
- if (r.isError())
- return r;
- const o = this._getNumberValue(r);
- if (o === void 0 || o < 0)
- return g.create(m.VALUE);
- if (n.isError())
- return n;
- const u = this._getAreaNumberValue(n);
- return u === void 0 || u < 1 ? g.create(m.VALUE) : e.isReferenceObject() ? this._getReferenceObject(e, s, o, u) : e.isValueObject() && s === 1 && o === 1 ? e : g.create(m.REF);
- }
- _getNumberValue(e) {
- if (e == null)
- return 0;
- let t = 0;
- if (e.isBoolean())
- e.getValue() === !0 && (t = 1);
- else {
- if (e.isString())
- return;
- e.isNumber() ? t = Math.floor(e.getValue()) : e.isNull() && (t = 0);
- }
- return t;
- }
- _getAreaNumberValue(e) {
- if (e == null)
- return 1;
- let t = 0;
- if (e.isBoolean())
- e.getValue() === !0 && (t = 1);
- else {
- if (e.isString())
- return;
- e.isNumber() ? t = Math.floor(e.getValue()) : e.isNull() && (t = 0);
- }
- return t;
- }
- _getReferenceObject(e, t, r, n) {
- const { startRow: s, endRow: o, startColumn: u, endColumn: c } = e.getRangePosition();
- let l = 0, f = 0, h = 0, d = 0;
- if (t === 0 ? (l = s, f = o) : l = f = s + t - 1, r === 0 ? (h = u, d = c) : h = d = u + r - 1, l > o || h > c)
- return g.create(m.REF);
- const _ = {
- startRow: l,
- startColumn: h,
- endRow: f,
- endColumn: d
- };
- return this.createReferenceObject(e, _);
- }
- }
- class Td extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 2);
- }
- isAddress() {
- return !0;
- }
- calculate(e, t) {
- if (e.isError())
- return e;
- if (t != null && t.isError())
- return t;
- let r = this.getZeroOrOneByOneDefault(t);
- r == null && (r = 1);
- let n = e;
- if (e.isArray()) {
- const s = e.getRowCount(), o = e.getColumnCount();
- if (s > 1 || o > 1)
- return e.map(() => g.create(m.VALUE));
- n = e.getFirstCell();
- }
- return this._handleSingleObject(n, r);
- }
- _handleSingleObject(e, t) {
- const r = `${e.getValue()}`;
- if (r.trim() === "")
- return g.create(m.REF);
- const n = this._convertToDefinedName(r);
- if (t === 0) {
- const f = Ih(n), { range: h, sheetName: d, unitId: _ } = f, C = new Cn(h);
- return C.setForcedUnitIdDirect(_), C.setForcedSheetName(d), this._setDefault(C);
- }
- if (vr(n))
- return this._setDefault(new da(n));
- if (Hi(n))
- return this._setDefault(new _a(n));
- if (Gi(n))
- return this._setDefault(new Ca(n));
- const s = mr(n), { range: o, sheetName: u, unitId: c } = s;
- if (Number.isNaN(o.startRow) || o.endRow + 1 > 1048576 || Number.isNaN(o.startColumn) || o.endColumn + 1 > 16384)
- return g.create(m.REF);
- const l = new Cn(o);
- return l.setForcedUnitIdDirect(c), l.setForcedSheetName(u), this._setDefault(l);
- }
- _setDefault(e) {
- return this.unitId == null || this.subUnitId == null ? g.create(m.REF) : (e.setDefaultUnitId(this.unitId), e.setDefaultSheetId(this.subUnitId), e);
- }
- /**
- * In Excel, to inject a defined name into a function that has positioning capabilities,
- * such as using the INDIRECT function to reference a named range,
- * you can write it as follows:
- * =INDIRECT("DefinedName1")
- */
- _convertToDefinedName(e) {
- const t = this.getDefinedName(e);
- if (t == null)
- return e;
- const r = t.formulaOrRefString;
- return r == null ? e : r.startsWith(X.EQUALS) ? r.slice(1) : r;
- }
- }
- class Bd extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 3);
- A(this, "needsExpandParams", !0);
- }
- calculate(e, t, r) {
- return e.isError() ? e : t.isError() ? g.create(m.REF) : t.isArray() ? r != null && r.isError() ? r : t.getColumnCount() === 1 || t.getRowCount() === 1 ? r != null && !r.isArray() ? g.create(m.REF) : this._handleVector(e, t, r) : this._handleArray(e, t) : g.create(m.VALUE);
- }
- _handleVector(e, t, r) {
- let n = r;
- if (n == null)
- n = t;
- else if (n.getRowCount() !== t.getRowCount() || n.getColumnCount() !== t.getColumnCount())
- return g.create(m.REF);
- return e.isArray() ? e.map((s) => this.binarySearch(s, t, n)) : this.binarySearch(e, t, n);
- }
- _handleArray(e, t) {
- const r = t.getRowCount(), n = t.getColumnCount();
- let s, o;
- 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 ? g.create(m.VALUE) : e.isArray() ? e.map((u) => this.binarySearch(u, s, o)) : this.binarySearch(e, s, o);
- }
- }
- class Id extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 3);
- }
- calculate(e, t, r) {
- if (e.isError())
- return e;
- if (t.isError())
- return g.create(m.REF);
- if (!t.isArray())
- return g.create(m.VALUE);
- const n = t.getRowCount(), s = t.getColumnCount();
- if (n !== 1 && s !== 1 || r != null && r.isError())
- return g.create(m.NA);
- const o = this.getMatchTypeValue(r);
- return o == null ? g.create(m.VALUE) : e.isArray() ? e.map((u) => this._handleSingleObject(
- u,
- t,
- o
- )) : this._handleSingleObject(
- e,
- t,
- o
- );
- }
- _handleSingleObject(e, t, r) {
- const n = this._getSearchModeValue(r), s = t.orderSearch(e, n);
- if (s == null)
- return g.create(m.NA);
- if (s instanceof g)
- return s;
- const o = t.getRowCount() === 1 ? s.column + 1 : s.row + 1;
- return y.create(o);
- }
- _getSearchModeValue(e) {
- switch (e) {
- case 1:
- return Pe.MIN;
- case 0:
- return Pe.NORMAL;
- case -1:
- return Pe.MAX;
- }
- }
- }
- class Fd extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 3);
- A(this, "maxParams", 5);
- A(this, "needsReferenceObject", !0);
- }
- isAddress() {
- return !0;
- }
- // eslint-disable-next-line max-lines-per-function, complexity
- calculate(e, t, r, n, s) {
- if (e.isError())
- return e;
- if (t.isError())
- return t;
- if (r.isError())
- return r;
- if (n != null && n.isError())
- return n;
- if (s != null && s.isError())
- return s;
- if (!e.isReferenceObject())
- return g.create(m.VALUE);
- const o = e.getRowCount(), u = e.getColumnCount();
- let c = t;
- c.isReferenceObject() && (c = c.toArrayValueObject());
- let l = r;
- l.isReferenceObject() && (l = l.toArrayValueObject());
- let f = n != null ? n : y.create(o);
- f.isReferenceObject() && (f = f.toArrayValueObject()), f.isNull() && (f = y.create(o));
- let h = s != null ? s : y.create(u);
- h.isReferenceObject() && (h = h.toArrayValueObject()), h.isNull() && (h = y.create(u));
- const d = Math.max(
- c.isArray() ? c.getRowCount() : 1,
- l.isArray() ? l.getRowCount() : 1,
- f.isArray() ? f.getRowCount() : 1,
- h.isArray() ? h.getRowCount() : 1
- ), _ = Math.max(
- c.isArray() ? c.getColumnCount() : 1,
- l.isArray() ? l.getColumnCount() : 1,
- f.isArray() ? f.getColumnCount() : 1,
- h.isArray() ? h.getColumnCount() : 1
- );
- if (c = c, l = l, f = f, h = h, d === 1 && _ === 1)
- return c = c.isArray() ? c.get(0, 0) : c, l = l.isArray() ? l.get(0, 0) : l, f = f.isArray() ? f.get(0, 0) : f, h = h.isArray() ? h.get(0, 0) : h, this._handleSingleObject(e, c, l, f, h);
- const C = O(d, _, c, g.create(m.NA)), E = O(d, _, l, g.create(m.NA)), b = O(d, _, f, g.create(m.NA)), R = O(d, _, h, g.create(m.NA));
- return C.mapValue((p, N, M) => {
- const w = E.get(N, M), D = b.get(N, M), S = R.get(N, M);
- return p.isError() ? p : w.isError() ? w : D.isError() ? D : S.isError() ? S : this._handleSingleObject(e, p, w, D, S, !0);
- });
- }
- // eslint-disable-next-line
- _handleSingleObject(e, t, r, n, s, o = !1) {
- const { startRow: u, startColumn: c } = e.getRangePosition();
- let l = t;
- if (l.isString() && (l = l.convertToNumberObjectValue()), l.isError())
- return l;
- let f = r;
- if (f.isString() && (f = f.convertToNumberObjectValue()), f.isError())
- return f;
- const h = +l.getValue(), d = +f.getValue();
- if (typeof h != "number" || typeof d != "number")
- return g.create(m.VALUE);
- const _ = u + h, C = c + d;
- if (_ < 0 || C < 0)
- return g.create(m.REF);
- const E = this.getIndexNumValue(n), b = this.getIndexNumValue(s);
- if (typeof E != "number" || typeof b != "number")
- return g.create(m.VALUE);
- if (E === 0 || b === 0)
- return g.create(m.REF);
- const R = E > 0 ? _ + E - 1 : _ + E + 1, p = b > 0 ? C + b - 1 : C + b + 1;
- if (R < 0 || p < 0)
- return g.create(m.REF);
- if (o)
- return g.create(m.VALUE);
- const N = _ < R ? _ : R, M = C < p ? C : p, w = _ > R ? _ : R, D = C > p ? C : p, S = {
- startRow: N,
- startColumn: M,
- endRow: w,
- endColumn: D
- };
- return this.createReferenceObject(e, S);
- }
- }
- class kd extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 0);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- if (e == null)
- return y.create(this.row + 1);
- if (e.isError())
- return e;
- if (!e.isArray())
- return g.create(m.NA);
- const t = e.getCurrentRow(), r = e.getRowCount(), n = [];
- for (let o = 0; o < r; o++)
- n.push([y.create(t + o + 1)]);
- const s = {
- calculateValueList: n,
- rowCount: r,
- columnCount: 1,
- unitId: this.unitId || "",
- sheetId: this.subUnitId || "",
- row: this.row,
- column: this.column
- };
- return q.create(s);
- }
- }
- class $d extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- if (e.isError())
- return e;
- if (e.isString() || e.isNumber() || e.isBoolean())
- return y.create(1);
- if (!e.isArray())
- return g.create(m.NA);
- const t = e.getRowCount();
- return y.create(t);
- }
- }
- class Yd extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 4);
- }
- calculate(e, t, r, n) {
- const s = t != null ? t : y.create(1), o = r != null ? r : y.create(1), u = n != null ? n : T.create(!1);
- if (u.isArray()) {
- const c = u.getRowCount(), l = u.getColumnCount();
- if (c === 1 && l === 1) {
- const f = u.get(0, 0);
- return this._handleSingleObject(e, s, o, f);
- }
- return u.map((f) => {
- const h = this._handleSingleObject(e, s, o, f);
- return h.isArray() ? h.get(0, 0) : h;
- });
- }
- return this._handleSingleObject(e, s, o, u);
- }
- _handleSingleObject(e, t, r, n) {
- if (e.isError())
- return e;
- const s = e.isArray() ? e.getRowCount() : 1, o = e.isArray() ? e.getColumnCount() : 1, u = this._checkArrayError(t);
- if (u.isError())
- return u;
- const c = Math.floor(+u.getValue());
- if (c < 1)
- return g.create(m.VALUE);
- const l = this._checkArrayError(r);
- if (l.isError())
- return l;
- const f = Math.floor(+l.getValue());
- if (f !== -1 && f !== 1)
- return g.create(m.VALUE);
- let h = n;
- if (h.isString() && (h = h.convertToNumberObjectValue()), h.isError())
- return h;
- if (!e.isArray() || s === 1 && o === 1)
- return e;
- const d = +h.getValue();
- return this._getResult(e, c, f, d, s, o);
- }
- _checkArrayError(e) {
- let t = e;
- if (t.isArray()) {
- const r = t.getRowCount(), n = t.getColumnCount();
- if (r > 1 || n > 1)
- return g.create(m.VALUE);
- t = t.get(0, 0);
- }
- return t.isString() && (t = t.convertToNumberObjectValue()), t;
- }
- _getResult(e, t, r, n, s, o) {
- if (n) {
- if (t > s)
- return g.create(m.VALUE);
- const u = e.transpose().getArrayValue();
- return u.sort(this._sort(t - 1, r)), q.create({
- calculateValueList: u,
- rowCount: u.length,
- columnCount: u[0].length || 0,
- unitId: this.unitId,
- sheetId: this.subUnitId,
- row: this.row,
- column: this.column
- }).transpose();
- } else {
- if (t > o)
- return g.create(m.VALUE);
- const u = e.getArrayValue();
- return u.sort(this._sort(t - 1, r)), q.create({
- calculateValueList: u,
- rowCount: u.length,
- columnCount: u[0].length || 0,
- unitId: this.unitId,
- sheetId: this.subUnitId,
- row: this.row,
- column: this.column
- });
- }
- }
- _sort(e, t = 1) {
- const r = hn();
- return t === 1 ? this._sortAsc(e, r) : this._sortDesc(e, r);
- }
- _sortAsc(e, t) {
- return (r, n) => {
- const s = r[e], o = n[e];
- if (s == null || s.isNull())
- return 1;
- if (o == null || o.isNull())
- return -1;
- if (s.isError() && o.isError())
- return 0;
- if (s.isError())
- return 1;
- if (o.isError())
- return -1;
- const u = s.getValue(), c = o.getValue();
- return s.isBoolean() && u === !0 ? 1 : o.isBoolean() && c === !0 ? -1 : s.isBoolean() && u === !1 ? 1 : o.isBoolean() && c === !1 ? -1 : s.isNumber() && o.isNumber() ? +u - +c : t(
- u,
- c
- );
- };
- }
- _sortDesc(e, t) {
- return (r, n) => {
- const s = r[e], o = n[e];
- if (s == null || s.isNull())
- return 1;
- if (o == null || o.isNull())
- return -1;
- if (s.isError() && o.isError())
- return 0;
- if (s.isError())
- return -1;
- if (o.isError())
- return 1;
- const u = s.getValue(), c = o.getValue();
- return s.isBoolean() && u === !0 ? -1 : o.isBoolean() && c === !0 ? 1 : s.isBoolean() && u === !1 ? -1 : o.isBoolean() && c === !1 ? 1 : s.isNumber() && o.isNumber() ? +c - +u : t(
- c,
- u
- );
- };
- }
- }
- class Hd extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 255);
- }
- calculate(e, ...t) {
- t.length === 1 && t.push(y.create(1));
- const r = this._getVariantsError(e, ...t), { maxRowLength: n, maxColumnLength: s } = Nr(t);
- if (r.isError()) {
- const c = O(n, s, r);
- return n === 1 && s === 1 ? c.get(0, 0) : c;
- }
- const o = t.map((c, l) => l % 2 === 0 ? c : O(n, s, c, g.create(m.NA))), u = this._getResultArray(e, o, n, s);
- return n === 1 && s === 1 ? u[0][0] : q.create({
- calculateValueList: u,
- rowCount: u.length,
- columnCount: u[0].length || 0,
- unitId: this.unitId,
- sheetId: this.subUnitId,
- row: this.row,
- column: this.column
- });
- }
- // eslint-disable-next-line complexity
- _getVariantsError(e, ...t) {
- if (e.isError())
- return e;
- for (let u = 0; u < t.length; u++) {
- const c = t[u];
- if (c.isError())
- return c;
- }
- if (t.length < 2 || t.length % 2 !== 0)
- return g.create(m.VALUE);
- 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;
- if ((s > 1 || o > 1) && (s > 1 && o > 1 || s === 1 && o !== n || o === 1 && s !== r))
- return g.create(m.VALUE);
- for (let u = 2; u < t.length; u++) {
- if (u % 2 === 1)
- continue;
- const c = t[u].isArray() ? t[u].getRowCount() : 1, l = t[u].isArray() ? t[u].getColumnCount() : 1;
- if (c !== s || l !== o)
- return g.create(m.VALUE);
- }
- return T.create(!0);
- }
- _getResultArray(e, t, r, n) {
- 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, l = [];
- for (let f = 0; f < r; f++) {
- l[f] = [];
- for (let h = 0; h < n; h++) {
- const { isError: d, errorObject: _, byArrays: C, sortOrders: E } = this._getByArraysAndSortOrders(t, f, h, c);
- if (d) {
- l[f].push(_);
- continue;
- }
- if (!e.isArray() || s === 1 && o === 1) {
- l[f].push(e);
- continue;
- }
- let b = e.getArrayValue();
- u === 1 && c === 1 || (u === 1 ? (b = b.concat(C), b = this._transposeArray(b), b.sort(this._sort(s, E)), 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, E)), b = b.map((p) => p.slice(0, o))));
- const R = q.create({
- calculateValueList: b,
- rowCount: b.length,
- columnCount: b[0].length || 0,
- unitId: this.unitId,
- sheetId: this.subUnitId,
- row: this.row,
- column: this.column
- });
- if (r > 1 || n > 1) {
- l[f].push(R.get(0, 0));
- continue;
- }
- l[f].push(R);
- }
- }
- return l;
- }
- _getByArraysAndSortOrders(e, t, r, n) {
- const s = [], o = [];
- let u = !1, c = null;
- for (let l = 0; l < e.length; l++) {
- if (l % 2 === 1)
- continue;
- const f = e[l];
- let h = e[l + 1].get(t, r);
- if (h.isString() && (h = h.convertToNumberObjectValue()), h.isError()) {
- u = !0, c = h;
- break;
- }
- const d = Math.floor(+h.getValue());
- if (d !== -1 && d !== 1) {
- u = !0, c = g.create(m.VALUE);
- break;
- }
- if (o.push(d), f.isArray()) {
- let _ = f.getArrayValue();
- n === 1 && (_ = this._transposeArray(_)), s.push(_[0]);
- } else
- s.push([f]);
- }
- return {
- isError: u,
- errorObject: c,
- byArrays: s,
- sortOrders: o
- };
- }
- _transposeArray(e) {
- const t = e.length, r = e[0].length, n = [];
- for (let s = 0; s < r; s++) {
- n[s] = [];
- for (let o = 0; o < t; o++)
- n[s][o] = e[o][s];
- }
- return n;
- }
- _sort(e, t) {
- const r = hn();
- return (n, s) => {
- let o = n[e], u = s[e], c = this._compare(o, u, t[0], r);
- if (c === 0 && t.length > 1) {
- for (let l = 1; l < t.length; l++)
- if (o = n[e + l], u = s[e + l], c = this._compare(o, u, t[l], r), c !== 0)
- return c;
- }
- return c;
- };
- }
- _compare(e, t, r, n) {
- return r === 1 ? this._asc(e, t, n) : this._desc(e, t, n);
- }
- _asc(e, t, r) {
- if (e == null || e.isNull())
- return 1;
- if (t == null || t.isNull())
- return -1;
- if (e.isError() && t.isError())
- return 0;
- if (e.isError())
- return 1;
- if (t.isError())
- return -1;
- const n = e.getValue(), s = t.getValue();
- return e.isBoolean() && n === !0 ? 1 : t.isBoolean() && s === !0 ? -1 : e.isBoolean() && n === !1 ? 1 : t.isBoolean() && s === !1 ? -1 : e.isNumber() && t.isNumber() ? +n - +s : r(
- n,
- s
- );
- }
- _desc(e, t, r) {
- if (e == null || e.isNull())
- return 1;
- if (t == null || t.isNull())
- return -1;
- if (e.isError() && t.isError())
- return 0;
- if (e.isError())
- return -1;
- if (t.isError())
- return 1;
- const n = e.getValue(), s = t.getValue();
- return e.isBoolean() && n === !0 ? -1 : t.isBoolean() && s === !0 ? 1 : e.isBoolean() && n === !1 ? -1 : t.isBoolean() && s === !1 ? 1 : e.isNumber() && t.isNumber() ? +s - +n : r(
- s,
- n
- );
- }
- }
- class Gd extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 3);
- }
- calculate(e, t, r) {
- const n = e.isArray() ? e.getRowCount() : 1, s = e.isArray() ? e.getColumnCount() : 1;
- let o = t, u = r != null ? r : y.create(s);
- t.isNull() && (o = y.create(n)), u.isNull() && (u = y.create(s));
- const c = Math.max(
- o.isArray() ? o.getRowCount() : 1,
- u.isArray() ? u.getRowCount() : 1
- ), l = Math.max(
- o.isArray() ? o.getColumnCount() : 1,
- u.isArray() ? u.getColumnCount() : 1
- ), f = O(c, l, o, g.create(m.NA)), h = O(c, l, u, g.create(m.NA));
- if (c > 1 || l > 1)
- return f.mapValue((p, N, M) => {
- const w = h.get(N, M);
- if (e.isError())
- return e;
- if (e.isNull())
- return g.create(m.VALUE);
- const { isError: D, errorObject: S } = this._checkRowsColumns(p, w, n, s);
- return D ? S : e.isArray() ? g.create(m.VALUE) : e;
- });
- if (e.isError())
- return e;
- if (e.isNull())
- return g.create(m.VALUE);
- const d = o.isArray() ? o.get(0, 0) : o, _ = u.isArray() ? u.get(0, 0) : u, { isError: C, errorObject: E, rowsValue: b, columnsValue: R } = this._checkRowsColumns(d, _, n, s);
- return C ? E : this._getResultArray(e, b, R, n, s);
- }
- _checkRowsColumns(e, t, r, n) {
- if (e.isError())
- return {
- isError: !0,
- errorObject: e
- };
- if (t.isError())
- return {
- isError: !0,
- errorObject: t
- };
- let s = Math.trunc(+e.getValue()), o = Math.trunc(+t.getValue());
- return Number.isNaN(s) || Number.isNaN(o) ? {
- isError: !0,
- errorObject: g.create(m.VALUE)
- } : Math.abs(s) === 0 || Math.abs(o) === 0 ? {
- isError: !0,
- errorObject: g.create(m.CALC)
- } : (s > r && (s = r), o > n && (o = n), {
- isError: !1,
- rowsValue: s,
- columnsValue: o
- });
- }
- _getResultArray(e, t, r, n, s) {
- if (!e.isArray())
- return e;
- const o = t >= 0 ? [0, t] : [n + t, n], u = r >= 0 ? [0, r] : [s + r, s];
- let c;
- 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((l) => l.isNull() ? y.create(0) : l), t === 1 && r === 1 ? c.get(0, 0) : c;
- }
- }
- class Qd extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 3);
- }
- calculate(e, t, r) {
- const n = t != null ? t : y.create(0), s = r != null ? r : T.create(!1), o = Math.max(
- n.isArray() ? n.getRowCount() : 1,
- s.isArray() ? s.getRowCount() : 1
- ), u = Math.max(
- n.isArray() ? n.getColumnCount() : 1,
- s.isArray() ? s.getColumnCount() : 1
- ), c = O(o, u, n, g.create(m.NA)), l = O(o, u, s, g.create(m.NA)), f = c.mapValue((h, d, _) => {
- const C = l.get(d, _);
- if (e.isError())
- return e;
- if (e.isNull())
- return g.create(m.VALUE);
- if (h.isError())
- return h;
- if (C.isError())
- return C;
- const E = Math.trunc(+h.getValue()), b = +C.getValue();
- if (Number.isNaN(E) || E < 0 || E > 3 || Number.isNaN(b))
- return g.create(m.VALUE);
- if (!e.isArray())
- return e;
- let R = [];
- return b ? R = this._getArrayValueByColumn(e, E) : R = this._getArrayValueByRow(e, E), R.length === 0 ? g.create(m.CALC) : o > 1 || u > 1 || R.length === 1 ? R[0] : q.create({
- calculateValueList: R.map((p) => [p]),
- rowCount: R.length,
- columnCount: 1,
- unitId: this.unitId,
- sheetId: this.subUnitId,
- row: this.row,
- column: this.column
- });
- });
- return o === 1 && u === 1 ? f.get(0, 0) : f;
- }
- _getArrayValueByColumn(e, t) {
- const r = e, n = r.getRowCount(), s = r.getColumnCount(), o = [];
- for (let u = 0; u < s; u++)
- for (let c = 0; c < n; c++) {
- const l = r.get(c, u);
- this._isIgnore(l, t) || o.push(l.isNull() ? y.create(0) : l);
- }
- return o;
- }
- _getArrayValueByRow(e, t) {
- const r = e, n = r.getRowCount(), s = r.getColumnCount(), o = [];
- for (let u = 0; u < n; u++)
- for (let c = 0; c < s; c++) {
- const l = r.get(u, c);
- this._isIgnore(l, t) || o.push(l.isNull() ? y.create(0) : l);
- }
- return o;
- }
- _isIgnore(e, t) {
- switch (t) {
- case 0:
- return !1;
- case 1:
- return e.isNull();
- case 2:
- return e.isError();
- case 3:
- return e.isNull() || e.isError();
- default:
- return !1;
- }
- }
- }
- class Wd extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 3);
- }
- calculate(e, t, r) {
- const n = t != null ? t : y.create(0), s = r != null ? r : T.create(!1), o = Math.max(
- n.isArray() ? n.getRowCount() : 1,
- s.isArray() ? s.getRowCount() : 1
- ), u = Math.max(
- n.isArray() ? n.getColumnCount() : 1,
- s.isArray() ? s.getColumnCount() : 1
- ), c = O(o, u, n, g.create(m.NA)), l = O(o, u, s, g.create(m.NA)), f = c.mapValue((h, d, _) => {
- const C = l.get(d, _);
- if (e.isError())
- return e;
- if (h.isError())
- return h;
- if (C.isError())
- return C;
- const E = Math.trunc(+h.getValue()), b = +C.getValue();
- if (Number.isNaN(E) || E < 0 || E > 3 || Number.isNaN(b) || e.isNull())
- return g.create(m.VALUE);
- if (!e.isArray())
- return e;
- let R = [];
- return b ? R = this._getArrayValueByColumn(e, E) : R = this._getArrayValueByRow(e, E), R.length === 0 ? g.create(m.CALC) : o > 1 || u > 1 || R.length === 1 ? R[0] : q.create({
- calculateValueList: [R],
- rowCount: 1,
- columnCount: R.length,
- unitId: this.unitId,
- sheetId: this.subUnitId,
- row: this.row,
- column: this.column
- });
- });
- return o === 1 && u === 1 ? f.get(0, 0) : f;
- }
- _getArrayValueByColumn(e, t) {
- const r = e, n = r.getRowCount(), s = r.getColumnCount(), o = [];
- for (let u = 0; u < s; u++)
- for (let c = 0; c < n; c++) {
- const l = r.get(c, u);
- this._isIgnore(l, t) || o.push(l.isNull() ? y.create(0) : l);
- }
- return o;
- }
- _getArrayValueByRow(e, t) {
- const r = e, n = r.getRowCount(), s = r.getColumnCount(), o = [];
- for (let u = 0; u < n; u++)
- for (let c = 0; c < s; c++) {
- const l = r.get(u, c);
- this._isIgnore(l, t) || o.push(l.isNull() ? y.create(0) : l);
- }
- return o;
- }
- _isIgnore(e, t) {
- switch (t) {
- case 0:
- return !1;
- case 1:
- return e.isNull();
- case 2:
- return e.isError();
- case 3:
- return e.isNull() || e.isError();
- default:
- return !1;
- }
- }
- }
- class qd extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- if (e.isError())
- return e;
- if (e.isArray()) {
- const t = e.getRowCount(), r = e.getColumnCount();
- return t === 1 && r === 1 ? e.get(0, 0) : e.transpose();
- }
- return e;
- }
- }
- class Kd extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 3);
- }
- calculate(e, t, r) {
- const n = t != null ? t : T.create(!1), s = r != null ? r : T.create(!1), o = e.isArray() ? e.getRowCount() : 1, u = e.isArray() ? e.getColumnCount() : 1, c = Math.max(
- n.isArray() ? n.getRowCount() : 1,
- s.isArray() ? s.getRowCount() : 1
- ), l = Math.max(
- n.isArray() ? n.getColumnCount() : 1,
- s.isArray() ? s.getColumnCount() : 1
- ), f = O(c, l, n, g.create(m.NA)), h = O(c, l, s, g.create(m.NA)), d = f.map((_, C, E) => {
- let b = _, R = h.get(C, E);
- if (e.isError())
- return e;
- if (b.isString() && (b = b.convertToNumberObjectValue()), b.isError())
- return b;
- if (R.isString() && (R = R.convertToNumberObjectValue()), R.isError())
- return R;
- const p = +b.getValue(), N = +R.getValue();
- let M;
- return !p && o === 1 || p && u === 1 ? M = e : M = this._getResult(e, p, N), (c > 1 || l > 1) && (M != null && M.isArray()) ? M.get(0, 0) : M;
- });
- return c === 1 && l === 1 ? d.get(0, 0) : d;
- }
- _getResult(e, t, r) {
- const n = e.isArray() ? e.getRowCount() : 1, s = e.isArray() ? e.getColumnCount() : 1;
- let o = e.getArrayValue(), u = n, c = s;
- t && (o = this._transposeArray(o), u = s, c = n);
- const l = this._getRepeatRows(o, u, c);
- if (l.length > 0) {
- const f = [];
- l.forEach((h) => {
- h.forEach((d, _) => {
- (_ !== 0 || r) && f.push(d);
- });
- }), o = o.filter((h, d) => !f.includes(d));
- }
- return o.length === 0 ? g.create(m.CALC) : (t && (o = this._transposeArray(o)), q.create({
- calculateValueList: o,
- rowCount: o.length,
- columnCount: o[0].length || 0,
- unitId: this.unitId,
- sheetId: this.subUnitId,
- row: this.row,
- column: this.column
- }));
- }
- _getRepeatRows(e, t, r) {
- let n = [];
- for (let s = 0; s < r; s++)
- if (s === 0) {
- const o = new Array(t).fill(null).map((u, c) => ({
- r: c,
- valueObject: e[c][s]
- }));
- n = this._getRepeatRowsByObjects(o);
- } else {
- if (n.length === 0)
- break;
- let o = [];
- n.forEach((u) => {
- const c = u.map((f) => ({
- r: f,
- valueObject: e[f][s]
- })), l = this._getRepeatRowsByObjects(c);
- o = o.concat(l);
- }), n = o;
- }
- return n;
- }
- _getRepeatRowsByObjects(e) {
- const t = /* @__PURE__ */ new Map();
- return e.forEach((r) => {
- const n = r.r, s = r.valueObject;
- let o = s.getValue();
- if (s.isNull() ? o = null : s.isString() && Q(o) && (o = +o), !t.has(o))
- t.set(o, [n]);
- else {
- const u = t.get(o);
- u.push(n), t.set(o, u);
- }
- }), Array.from(t.values()).filter((r) => r.length > 1);
- }
- _transposeArray(e) {
- const t = e.length, r = e[0].length, n = [];
- for (let s = 0; s < r; s++) {
- n[s] = [];
- for (let o = 0; o < t; o++)
- n[s][o] = e[o][s];
- }
- return n;
- }
- }
- class Xd extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 3);
- A(this, "maxParams", 4);
- }
- calculate(e, t, r, n) {
- if (e.isError())
- return e;
- if (t.isError())
- return t;
- if (!t.isArray())
- return g.create(m.VALUE);
- if (r.isError())
- return r;
- if (n != null && n.isError())
- return n;
- const s = n != null ? n : T.create(!0);
- return Ai(e) && Ai(s) && r.isArray() ? this._handleArrayColIndexNum(e, t, r, s) : this._handleNonArrayColIndexNum(e, t, r, s);
- }
- _handleArrayColIndexNum(e, t, r, n) {
- const s = e.isArray() ? e.getFirstCell() : e, o = this.getZeroOrOneByOneDefault(n);
- if (o == null)
- return g.create(m.VALUE);
- let u;
- const c = [];
- return r.iterator((l, f, h) => {
- if (l == null)
- return u = g.create(m.VALUE), !1;
- const d = this._handleTableArray(s, t, l, o);
- if (d.isError())
- return u = d, !1;
- c[f] === void 0 && (c[f] = []), c[f][h] = d;
- }), u || tr(c, c.length, c[0].length, this.unitId || "", this.subUnitId || "");
- }
- _handleNonArrayColIndexNum(e, t, r, n) {
- const s = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- n.isArray() ? n.getRowCount() : 1
- ), o = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- n.isArray() ? n.getColumnCount() : 1
- ), u = O(s, o, e), c = O(s, o, n);
- return u.map((l, f, h) => {
- if (l.isError())
- return l;
- const d = c.get(f, h);
- if (d == null)
- return g.create(m.VALUE);
- if (d.isError())
- return d;
- const _ = this.getZeroOrOneByOneDefault(d);
- return _ == null ? g.create(m.VALUE) : this._handleTableArray(l, t, r, _);
- });
- }
- _handleTableArray(e, t, r, n) {
- let s = this.getIndexNumValue(r);
- if (s instanceof g)
- return s;
- if (s = Math.floor(s), s < 1)
- return g.create(m.VALUE);
- const o = t.slice(void 0, [0, 1]);
- if (o == null)
- return g.create(m.VALUE);
- const u = t.slice(void 0, [s - 1, s]);
- return u == null ? g.create(m.REF) : this._handleSingleObject(e, o, u, n);
- }
- _handleSingleObject(e, t, r, n) {
- return n === 0 ? this.equalSearch(e, t, r) : this.binarySearch(e, t, r);
- }
- }
- class Zd extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 255);
- }
- calculate(...e) {
- const t = Math.max(
- ...e.map((n) => n.isArray() ? n.getColumnCount() : 1)
- ), r = [];
- for (let n = 0; n < e.length; n++) {
- const s = e[n];
- if (s.isError())
- return s;
- const o = s.isArray() ? s.getRowCount() : 1, u = s.isArray() ? s.getColumnCount() : 1;
- for (let c = 0; c < o; c++) {
- const l = [];
- for (let f = 0; f < t; f++) {
- let h = s;
- s.isArray() && (h = s.get(c, f)), f > u - 1 || !h ? l.push(g.create(m.NA)) : l.push(h);
- }
- r.push(l);
- }
- }
- return q.create({
- calculateValueList: r,
- rowCount: r.length,
- columnCount: r[0].length || 0,
- unitId: this.unitId,
- sheetId: this.subUnitId,
- row: this.row,
- column: this.column
- });
- }
- }
- class zd extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 3);
- }
- calculate(e, t, r) {
- let n = r != null ? r : g.create(m.NA);
- n.isNull() && (n = g.create(m.NA));
- const s = e.isArray() ? e.getRowCount() : 1, o = e.isArray() ? e.getColumnCount() : 1, u = Math.max(
- t.isArray() ? t.getRowCount() : 1,
- n.isArray() ? n.getRowCount() : 1
- ), c = Math.max(
- t.isArray() ? t.getColumnCount() : 1,
- n.isArray() ? n.getColumnCount() : 1
- ), l = O(u, c, t, g.create(m.NA)), f = O(u, c, n, g.create(m.NA)), h = l.mapValue((d, _, C) => {
- const E = f.get(_, C);
- if (e.isError())
- return e;
- if (e.isNull())
- return g.create(m.VALUE);
- if (d.isError())
- return d;
- const b = Math.trunc(+d.getValue());
- if (s > 1 && o > 1 || Number.isNaN(b))
- return g.create(m.VALUE);
- if (b < 1)
- return g.create(m.NUM);
- const R = e.isArray() ? e.getArrayValue().flat() : [e], p = this._getWrapArray(R, b, E);
- return u > 1 || c > 1 || p.length === 1 && p[0].length === 1 ? p[0][0] : q.create({
- calculateValueList: p,
- rowCount: p.length,
- columnCount: p[0].length,
- unitId: this.unitId,
- sheetId: this.subUnitId,
- row: this.row,
- column: this.column
- });
- });
- return u === 1 && c === 1 ? h.get(0, 0) : h;
- }
- _getWrapArray(e, t, r) {
- const n = Math.ceil(e.length / t), s = n > 1 ? t : e.length, o = [];
- for (let u = 0; u < n; u++)
- for (let c = 0; c < s; c++) {
- o[c] || (o[c] = []);
- const l = u * s + c;
- l < e.length ? o[c].push(e[l].isNull() ? y.create(0) : e[l]) : o[c].push(r);
- }
- return o;
- }
- }
- class Jd extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 3);
- }
- calculate(e, t, r) {
- let n = r != null ? r : g.create(m.NA);
- n.isNull() && (n = g.create(m.NA));
- const s = e.isArray() ? e.getRowCount() : 1, o = e.isArray() ? e.getColumnCount() : 1, u = Math.max(
- t.isArray() ? t.getRowCount() : 1,
- n.isArray() ? n.getRowCount() : 1
- ), c = Math.max(
- t.isArray() ? t.getColumnCount() : 1,
- n.isArray() ? n.getColumnCount() : 1
- ), l = O(u, c, t, g.create(m.NA)), f = O(u, c, n, g.create(m.NA)), h = l.mapValue((d, _, C) => {
- const E = f.get(_, C);
- if (e.isError())
- return e;
- if (e.isNull())
- return g.create(m.VALUE);
- if (d.isError())
- return d;
- const b = Math.trunc(+d.getValue());
- if (s > 1 && o > 1 || Number.isNaN(b))
- return g.create(m.VALUE);
- if (b < 1)
- return g.create(m.NUM);
- const R = e.isArray() ? e.getArrayValue().flat() : [e], p = this._getWrapArray(R, b, E);
- return u > 1 || c > 1 || p.length === 1 && p[0].length === 1 ? p[0][0] : q.create({
- calculateValueList: p,
- rowCount: p.length,
- columnCount: p[0].length,
- unitId: this.unitId,
- sheetId: this.subUnitId,
- row: this.row,
- column: this.column
- });
- });
- return u === 1 && c === 1 ? h.get(0, 0) : h;
- }
- _getWrapArray(e, t, r) {
- const n = Math.ceil(e.length / t), s = n > 1 ? t : e.length, o = [];
- for (let u = 0; u < n; u++) {
- const c = [];
- for (let l = 0; l < s; l++) {
- const f = u * s + l;
- f < e.length ? c.push(e[f].isNull() ? y.create(0) : e[f]) : c.push(r);
- }
- o.push(c);
- }
- return o;
- }
- }
- class eC extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 3);
- A(this, "maxParams", 6);
- }
- // eslint-disable-next-line
- calculate(e, t, r, n, s, o) {
- let u = n != null ? n : g.create(m.NA);
- n != null && n.isNull() && (u = g.create(m.NA));
- let c = s != null ? s : y.create(0);
- s != null && s.isNull() && (c = y.create(0));
- let l = o != null ? o : y.create(1);
- if (o != null && o.isNull() && (l = y.create(1)), e.isError())
- return e;
- if (t.isError() || r.isError())
- return g.create(m.REF);
- if (!t.isArray() || !r.isArray())
- return g.create(m.VALUE);
- const f = t.getRowCount(), h = t.getColumnCount(), d = r.getRowCount(), _ = r.getColumnCount();
- if (f !== 1 && h !== 1 || f === 1 && h > 1 && h !== _ || h === 1 && f > 1 && f !== d)
- return g.create(m.VALUE);
- if (c.isError())
- return c;
- if (l.isError())
- return l;
- const C = this.getIndexNumValue(c);
- if (C instanceof g)
- return C;
- const E = this.getIndexNumValue(l);
- return E instanceof g ? E : this._getResult(
- e,
- t,
- r,
- u,
- C,
- E,
- f,
- h,
- d,
- _
- );
- }
- _getResult(e, t, r, n, s, o, u, c, l, f) {
- const h = e.isArray() ? e.getRowCount() : 1, d = e.isArray() ? e.getColumnCount() : 1;
- if (h > 1 || d > 1) {
- let b;
- return u === 1 ? b = r.slice([0, 1]) : b = r.slice(void 0, [0, 1]), b == null ? g.create(m.NA) : e.map((R) => {
- const p = this._checkErrorCombination(s, o);
- if (p)
- return p;
- const N = this._handleSingleObject(R, t, b, s, o);
- return N.isError() ? n : N;
- });
- }
- const _ = e.isArray() ? e.get(0, 0) : e;
- if (c === f && u === l) {
- const b = this._checkErrorCombination(s, o);
- if (b)
- return b;
- const R = this._handleSingleObject(_, t, r, s, o);
- return R.isError() ? n : R;
- }
- let C = 0;
- c === f && (C = 1);
- const E = this._handleExpandObject(_, t, r, s, o, C);
- return E == null ? g.create(m.NA) : E;
- }
- _handleExpandObject(e, t, r, n, s, o = 0) {
- if ((s === 2 || s === -2) && n !== 2) {
- const u = Ps(s), c = Ss(n);
- return this.binarySearchExpand(
- e,
- t,
- r,
- o,
- u,
- c
- );
- }
- return n === 2 ? this.fuzzySearchExpand(e, t, r, s !== -1, o) : n === -1 || n === 1 ? this.orderSearchExpand(
- e,
- t,
- r,
- n === 1 ? Pe.MAX : Pe.MIN,
- s === -1,
- o
- ) : this.equalSearchExpand(e, t, r, s !== -1, o);
- }
- _handleSingleObject(e, t, r, n, s) {
- if ((s === 2 || s === -2) && n !== 2) {
- const o = Ps(s), u = Ss(n);
- return this.binarySearch(e, t, r, o, u);
- }
- return n === 2 ? this.fuzzySearch(e, t, r, s !== -1) : n === -1 || n === 1 ? this.orderSearch(
- e,
- t,
- r,
- n === 1 ? Pe.MAX : Pe.MIN,
- s === -1
- ) : this.equalSearch(e, t, r, s !== -1);
- }
- /**
- * Wildcard matching and binary search cannot appear at the same time
- * @param matchModeValue
- * @param searchModeValue
- * @returns
- */
- _checkErrorCombination(e, t) {
- return e === 2 && (t === -2 || t === 2) ? g.create(m.VALUE) : null;
- }
- }
- class tC extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 4);
- }
- calculate(e, t, r, n) {
- if (e.isError())
- return e;
- if (t.isError())
- return g.create(m.REF);
- if (!t.isArray())
- return g.create(m.VALUE);
- const s = t.getRowCount(), o = t.getColumnCount();
- if (s !== 1 && o !== 1)
- return g.create(m.VALUE);
- if (r != null && r.isError() || n != null && n.isError())
- return g.create(m.NA);
- const u = this.getIndexNumValue(r || y.create(0));
- if (u instanceof g)
- return u;
- const c = this.getIndexNumValue(n || y.create(1));
- return c instanceof g ? c : e.isArray() ? e.map((l) => this._handleSingleObject(
- l,
- t,
- u,
- c
- )) : this._handleSingleObject(
- e,
- t,
- u,
- c
- );
- }
- _handleSingleObject(e, t, r, n) {
- let s;
- if ((n === 2 || n === -2) && r !== 2) {
- const o = Ps(n), u = Ss(r);
- s = t.binarySearch(e, o, u);
- } else if (r === 2) {
- const o = t.compare(e, $.EQUALS);
- let u;
- if (n !== -1 ? u = o.getFirstTruePosition() : u = o.getLastTruePosition(), u == null)
- return g.create(m.NA);
- s = t.getRowCount() === 1 ? u.column : u.row;
- } else if (r === -1 || r === 1) {
- const o = t.orderSearch(e, r === 1 ? Pe.MAX : Pe.MIN, n === -1);
- if (o == null)
- return g.create(m.NA);
- if (o instanceof g)
- return o;
- s = t.getRowCount() === 1 ? o.column : o.row;
- } else {
- const o = t.isEqual(e);
- let u;
- if (n !== -1 ? u = o.getFirstTruePosition() : u = o.getLastTruePosition(), u == null)
- return g.create(m.NA);
- s = t.getRowCount() === 1 ? u.column : u.row;
- }
- return s == null ? g.create(m.NA) : y.create(s + 1);
- }
- }
- const rC = [
- [Rd, me.ADDRESS],
- [Vd, me.AREAS],
- [Nd, me.CHOOSE],
- [Od, me.CHOOSECOLS],
- [Md, me.CHOOSEROWS],
- [wd, me.COLUMN],
- [Dd, me.COLUMNS],
- [Sd, me.DROP],
- [Pd, me.EXPAND],
- [Ld, me.FILTER],
- [xd, me.FORMULATEXT],
- [jd, me.HLOOKUP],
- [Ud, me.HSTACK],
- [vd, me.INDEX],
- [Td, me.INDIRECT],
- [Bd, me.LOOKUP],
- [Id, me.MATCH],
- [Fd, me.OFFSET],
- [kd, me.ROW],
- [$d, me.ROWS],
- [Yd, me.SORT],
- [Hd, me.SORTBY],
- [Gd, me.TAKE],
- [Qd, me.TOCOL],
- [Wd, me.TOROW],
- [qd, me.TRANSPOSE],
- [Kd, me.UNIQUE],
- [Xd, me.VLOOKUP],
- [Zd, me.VSTACK],
- [zd, me.WRAPCOLS],
- [Jd, me.WRAPROWS],
- [eC, me.XLOOKUP],
- [tC, me.XMATCH]
- ];
- class nC extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- let t = e;
- return t.isString() && (t = t.convertToNumberObjectValue()), t.isError() ? t : t.abs();
- }
- }
- class sC extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- let t = e;
- return t.isString() && (t = t.convertToNumberObjectValue()), t.isError() ? t : t.acos();
- }
- }
- class aC extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- let t = e;
- return t.isString() && (t = t.convertToNumberObjectValue()), t.isError() ? t : t.acosh();
- }
- }
- class iC extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- let t = e;
- return t.isString() && (t = t.convertToNumberObjectValue()), t.isError() ? t : t.isArray() ? t.map((r) => r.isError() ? r : Si(r)) : Si(t);
- }
- }
- function Si(i) {
- let a = i.getValue();
- if (i.isBoolean() && (a = a ? 1 : 0), !Number.isFinite(a))
- return g.create(m.VALUE);
- a = Number(a);
- let e = Math.atan(1 / a);
- return a < 0 && (e += Math.PI), Number.isNaN(e) ? g.create(m.VALUE) : y.create(e);
- }
- class oC extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- let t = e;
- return t.isString() && (t = t.convertToNumberObjectValue()), t.isError() ? t : t.isArray() ? t.map((r) => r.isError() ? r : Pi(r)) : Pi(t);
- }
- }
- function Pi(i) {
- let a = i.getValue();
- if (i.isBoolean() && (a = a ? 1 : 0), !Number.isFinite(a))
- return g.create(m.VALUE);
- if (a = Number(a), Math.abs(a) <= 1)
- return g.create(m.NUM);
- const e = 1 / 2 * Math.log((a + 1) / (a - 1));
- return Number.isNaN(e) ? g.create(m.VALUE) : y.create(e);
- }
- class uC extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- if (e.isArray()) {
- const t = e.mapValue((r) => this._handleSingleObject(r));
- return t.getRowCount() === 1 && t.getColumnCount() === 1 ? t.get(0, 0) : t;
- }
- return this._handleSingleObject(e);
- }
- // eslint-disable-next-line
- _handleSingleObject(e) {
- if (e.isError())
- return e;
- if (e.isNull())
- return y.create(0);
- if (e.isBoolean() || e.isNumber())
- return g.create(m.VALUE);
- let t = e.getValue().toLocaleString().toLocaleUpperCase();
- if (t.length > 255)
- return g.create(m.VALUE);
- const r = t.startsWith("-");
- r && (t = t.slice(1));
- let n = 0;
- for (let s = 0; s < t.length; s++) {
- const o = Xr.get(t[s]) || 0, u = Xr.get(t[s + 1]) || 0, c = Xr.get(t[s + 2]) || 0, l = Xr.get(t[s + 3]) || 0;
- if (!o || c >= u && c > o || o === u && o === c && o === l || o === u / 2)
- return g.create(m.VALUE);
- o < u ? n -= o : n += o;
- }
- return y.create(r ? -n : n);
- }
- }
- class cC extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- let t = e;
- return t.isString() && (t = t.convertToNumberObjectValue()), t.isError() ? t : t.asin();
- }
- }
- class lC extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- let t = e;
- return t.isString() && (t = t.convertToNumberObjectValue()), t.isError() ? t : t.asinh();
- }
- }
- class fC extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- let t = e;
- return t.isString() && (t = t.convertToNumberObjectValue()), t.isError() ? t : t.atan();
- }
- }
- class hC extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- let r = e, n = t;
- return r.isString() && (r = r.convertToNumberObjectValue()), r.isError() ? r : (n.isString() && (n = n.convertToNumberObjectValue()), n.isError() ? n : n.atan2(r));
- }
- }
- class mC extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- let t = e;
- return t.isString() && (t = t.convertToNumberObjectValue()), t.isError() ? t : t.atanh();
- }
- }
- class gC extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 3);
- }
- calculate(e, t, r) {
- const n = r != null ? r : y.create(0);
- if (e.isError())
- return e;
- if (t.isError())
- return t;
- if (n.isError())
- return n;
- const s = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1,
- n.isArray() ? n.getRowCount() : 1
- ), o = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1,
- n.isArray() ? n.getColumnCount() : 1
- ), u = O(s, o, e, g.create(m.NA)), c = O(s, o, t, g.create(m.NA)), l = O(s, o, n, g.create(m.NA)), f = u.map((h, d, _) => {
- const C = c.get(d, _), E = l.get(d, _);
- return this._handleSingleObject(h, C, E);
- });
- return f.getRowCount() === 1 && f.getColumnCount() === 1 ? f.getArrayValue()[0][0] : f;
- }
- _handleSingleObject(e, t, r) {
- let n = e;
- if (n.isString() && (n = n.convertToNumberObjectValue()), n.isError())
- return n;
- let s = t;
- if (s.isString() && (s = s.convertToNumberObjectValue()), s.isError())
- return s;
- let o = r;
- if (o.isString() && (o = o.convertToNumberObjectValue()), o.isError())
- return o;
- const u = Math.floor(+n.getValue()), c = Math.floor(+s.getValue()), l = Math.floor(+o.getValue());
- if (u < 0 || u >= 2 ** 53 || c < 2 || c > 36 || l < 0)
- return g.create(m.NUM);
- let f = u.toString(c);
- return f.length < l && (f = new Array(l - f.length + 1).join("0") + f), j.create(f.toLocaleUpperCase());
- }
- }
- class dC extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- if (e.isError())
- return e;
- if (t.isError())
- return t;
- const r = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1
- ), n = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1
- ), s = O(r, n, e, g.create(m.NA)), o = O(r, n, t, g.create(m.NA)), u = s.map((c, l, f) => {
- let h = c, d = o.get(l, f);
- if (h.isString() && (h = h.convertToNumberObjectValue()), h.isError())
- return h;
- if (d.isString() && (d = d.convertToNumberObjectValue()), d.isError())
- return d;
- const _ = +h.getValue(), C = +d.getValue();
- if (_ > 0 && C < 0)
- return g.create(m.NUM);
- if (_ === 0 || C === 0)
- return y.create(0);
- const E = Ye(_ / C, 0) * C;
- return y.create(E);
- });
- return u.getRowCount() === 1 && u.getColumnCount() === 1 ? u.getArrayValue()[0][0] : u;
- }
- }
- class CC extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 3);
- }
- calculate(e, t, r) {
- const n = t != null ? t : y.create(1), s = r != null ? r : y.create(0);
- if (e.isError())
- return e;
- if (n.isError())
- return n;
- if (s.isError())
- return s;
- const o = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- n.isArray() ? n.getRowCount() : 1,
- s.isArray() ? s.getRowCount() : 1
- ), u = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- n.isArray() ? n.getColumnCount() : 1,
- s.isArray() ? s.getColumnCount() : 1
- ), c = O(o, u, e, g.create(m.NA)), l = O(o, u, n, g.create(m.NA)), f = O(o, u, s, g.create(m.NA)), h = c.map((d, _, C) => {
- let E = d, b = l.get(_, C), R = f.get(_, C);
- if (E.isString() && (E = E.convertToNumberObjectValue()), E.isError())
- return E;
- if (b.isString() && (b = b.convertToNumberObjectValue()), b.isError())
- return b;
- if (R.isString() && (R = R.convertToNumberObjectValue()), R.isError())
- return R;
- const p = +E.getValue(), N = +b.getValue(), M = +R.getValue();
- return p === 0 || N === 0 ? y.create(0) : this._getResult(p, N, M);
- });
- return o === 1 && u === 1 ? h.get(0, 0) : h;
- }
- _getResult(e, t, r) {
- let n;
- 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, y.create(n);
- }
- }
- class _C extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- const r = t != null ? t : y.create(1);
- if (e.isError())
- return e;
- if (r.isError())
- return r;
- const n = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- r.isArray() ? r.getRowCount() : 1
- ), s = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- r.isArray() ? r.getColumnCount() : 1
- ), o = O(n, s, e, g.create(m.NA)), u = O(n, s, r, g.create(m.NA)), c = o.map((l, f, h) => {
- let d = u.get(f, h), _ = l;
- if (_.isString() && (_ = _.convertToNumberObjectValue()), _.isError())
- return _;
- if (d.isString() && (d = d.convertToNumberObjectValue()), d.isError())
- return d;
- const C = +_.getValue(), E = +d.getValue();
- if (C === 0 || E === 0)
- return y.create(0);
- const b = (E < 0 ? -Ye(C / Math.abs(E), 0) : Ye(C / E, 0)) * E;
- return y.create(b);
- });
- return n === 1 && s === 1 ? c.get(0, 0) : c;
- }
- }
- class AC extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- const r = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1
- ), n = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1
- ), s = O(r, n, e, g.create(m.NA)), o = O(r, n, t, g.create(m.NA)), u = s.mapValue((c, l, f) => {
- let h = c, d = o.get(l, f);
- if (h.isString() && (h = h.convertToNumberObjectValue()), d.isString() && (d = d.convertToNumberObjectValue()), h.isError())
- return h;
- if (d.isError())
- return d;
- const _ = Math.floor(+h.getValue()), C = Math.floor(+d.getValue());
- if (_ < 0 || C < 0 || _ < C)
- return g.create(m.NUM);
- const E = zt(_, C);
- return Number.isNaN(E) || !Number.isFinite(E) ? g.create(m.NUM) : y.create(E);
- });
- return r === 1 && n === 1 ? u.get(0, 0) : u;
- }
- }
- class EC extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- const r = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1
- ), n = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1
- ), s = O(r, n, e, g.create(m.NA)), o = O(r, n, t, g.create(m.NA)), u = s.mapValue((c, l, f) => {
- let h = c, d = o.get(l, f);
- if (h.isString() && (h = h.convertToNumberObjectValue()), d.isString() && (d = d.convertToNumberObjectValue()), h.isError())
- return h;
- if (d.isError())
- return d;
- const _ = Math.floor(+h.getValue()), C = Math.floor(+d.getValue());
- if (_ < 0 || C < 0 || _ === 0 && _ < C)
- return g.create(m.NUM);
- const E = zt(_ + C - 1, _ - 1);
- return Number.isNaN(E) || !Number.isFinite(E) ? g.create(m.NUM) : y.create(E);
- });
- return r === 1 && n === 1 ? u.get(0, 0) : u;
- }
- }
- class bC extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- let t = e;
- return t.isString() && (t = t.convertToNumberObjectValue()), t.isError() ? t : t.cos();
- }
- }
- class yC extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- let t = e;
- return t.isString() && (t = t.convertToNumberObjectValue()), t.isError() ? t : t.cosh();
- }
- }
- class RC extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- return e.isArray() ? e.map((t) => this._handleSingleObject(t)) : this._handleSingleObject(e);
- }
- _handleSingleObject(e) {
- let t = e;
- if (t.isString() && (t = t.convertToNumberObjectValue()), t.isError())
- return t;
- const r = +t.getValue();
- return Math.abs(r) >= 2 ** 27 ? g.create(m.NUM) : r === 0 ? g.create(m.DIV_BY_ZERO) : t.tan().getReciprocal();
- }
- }
- class pC extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- return e.isArray() ? e.map((t) => this._handleSingleObject(t)) : this._handleSingleObject(e);
- }
- _handleSingleObject(e) {
- let t = e;
- return t.isString() && (t = t.convertToNumberObjectValue()), t.isError() ? t : +t.getValue() === 0 ? g.create(m.DIV_BY_ZERO) : t.tanh().getReciprocal();
- }
- }
- class VC extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- return e.isArray() ? e.map((t) => this._handleSingleObject(t)) : this._handleSingleObject(e);
- }
- _handleSingleObject(e) {
- let t = e;
- if (t.isString() && (t = t.convertToNumberObjectValue()), t.isError())
- return t;
- const r = +t.getValue();
- return Math.abs(r) >= 2 ** 27 ? g.create(m.NUM) : r === 0 ? g.create(m.DIV_BY_ZERO) : t.sin().getReciprocal();
- }
- }
- class NC extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- return e.isArray() ? e.map((t) => this._handleSingleObject(t)) : this._handleSingleObject(e);
- }
- _handleSingleObject(e) {
- let t = e;
- if (t.isString() && (t = t.convertToNumberObjectValue()), t.isError())
- return t;
- const r = +t.getValue();
- return r === 0 ? g.create(m.DIV_BY_ZERO) : !Number.isNaN(r) && !Number.isFinite(Math.sinh(r)) ? y.create(0) : t.sinh().getReciprocal();
- }
- }
- class OC extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- if (e.isError())
- return e;
- if (t.isError())
- return t;
- const r = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1
- ), n = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1
- ), s = O(r, n, e, g.create(m.NA)), o = O(r, n, t, g.create(m.NA)), u = s.map((c, l, f) => {
- if (c.isError())
- return c;
- let h = o.get(l, f);
- if (h.isString() && (h = h.convertToNumberObjectValue()), h.isError())
- return h;
- const d = `${c.getValue()}`, _ = Math.floor(+h.getValue());
- if (Q(d) && (+d < 0 || +d >= 2 ** 53 || !Number.isInteger(+d)) || d.toLocaleLowerCase() === "true" || d.toLocaleLowerCase() === "false" || _ < 2 || _ > 36)
- return g.create(m.NUM);
- if (d.replace(/\s/g, "") === "")
- return y.create(0);
- if (!this._isValidCharForRadix(d, _))
- return g.create(m.NUM);
- const C = Number.parseInt(d, _);
- return Number.isNaN(C) ? g.create(m.NUM) : y.create(C);
- });
- return r === 1 && n === 1 ? u.get(0, 0) : u;
- }
- _isValidCharForRadix(e, t) {
- for (const r of e) {
- const n = r.toUpperCase().charCodeAt(0);
- if (t <= 10 && !(n >= 48 && n < 48 + t) || t > 10 && !(n >= 48 && n < 58 || n >= 65 && n < 65 + t - 10))
- return !1;
- }
- return !0;
- }
- }
- class MC extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- return e.isArray() ? e.map((t) => this._handleSingleObject(t)) : this._handleSingleObject(e);
- }
- _handleSingleObject(e) {
- let t = e;
- if (t.isString() && (t = t.convertToNumberObjectValue()), t.isError())
- return t;
- const r = +t.getValue();
- if (!Number.isFinite(r))
- return g.create(m.VALUE);
- const n = r * (180 / Math.PI);
- return Number.isNaN(n) ? g.create(m.VALUE) : y.create(n);
- }
- }
- class wC extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- return e.isArray() ? e.map((t) => this._handleSingleObject(t)) : this._handleSingleObject(e);
- }
- _handleSingleObject(e) {
- let t = e;
- if (t.isString() && (t = t.convertToNumberObjectValue()), t.isError())
- return t;
- const r = +t.getValue();
- if (!Number.isFinite(r))
- return g.create(m.VALUE);
- const n = (r < 0 ? -Ye(Math.abs(r) / 2, 0) : Ye(r / 2, 0)) * 2;
- return Number.isNaN(n) ? g.create(m.VALUE) : n === 0 ? y.create(0) : y.create(n);
- }
- }
- class DC extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- let t = e;
- return t.isString() && (t = t.convertToNumberObjectValue()), t.isError() ? t : t.exp();
- }
- }
- class SC extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- return e.isArray() ? e.mapValue((t) => this._handleSingleObject(t)) : this._handleSingleObject(e);
- }
- _handleSingleObject(e) {
- let t = e;
- if (t.isString() && (t = t.convertToNumberObjectValue()), t.isError())
- return t;
- const r = Math.floor(+t.getValue()), n = cr(r);
- return Number.isNaN(n) || !Number.isFinite(n) ? g.create(m.NUM) : y.create(n);
- }
- }
- class PC extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- let t = e;
- if (e.isArray()) {
- const r = e.getRowCount(), n = e.getColumnCount();
- if (r > 1 || n > 1)
- return g.create(m.VALUE);
- t = e.get(0, 0);
- }
- return this._handleSingleObject(t);
- }
- _handleSingleObject(e) {
- let t = e;
- if (t.isString() && (t = t.convertToNumberObjectValue()), t.isError())
- return t;
- const r = Math.floor(+t.getValue()), n = cr(r, 2);
- return Number.isNaN(n) || !Number.isFinite(n) ? g.create(m.NUM) : y.create(n);
- }
- }
- class LC extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- if (e.isError())
- return e;
- if (t.isError())
- return t;
- const r = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1
- ), n = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1
- ), s = O(r, n, e, g.create(m.NA)), o = O(r, n, t, g.create(m.NA)), u = s.map((c, l, f) => {
- let h = o.get(l, f), d = c;
- if (d.isString() && (d = d.convertToNumberObjectValue()), d.isError())
- return d;
- if (h.isString() && (h = h.convertToNumberObjectValue()), h.isError())
- return h;
- const _ = +d.getValue(), C = +h.getValue();
- if (_ > 0 && C < 0)
- return g.create(m.NUM);
- if (_ === 0)
- return y.create(0);
- if (C === 0)
- return g.create(m.DIV_BY_ZERO);
- const E = We(_ / C, 0) * C;
- return y.create(E);
- });
- return r === 1 && n === 1 ? u.get(0, 0) : u;
- }
- }
- class xC extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 3);
- }
- calculate(e, t, r) {
- const n = t != null ? t : y.create(1), s = r != null ? r : y.create(0), o = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- n.isArray() ? n.getRowCount() : 1,
- s.isArray() ? s.getRowCount() : 1
- ), u = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- n.isArray() ? n.getColumnCount() : 1,
- s.isArray() ? s.getColumnCount() : 1
- ), c = O(o, u, e, g.create(m.NA)), l = O(o, u, n, g.create(m.NA)), f = O(o, u, s, g.create(m.NA)), h = c.map((d, _, C) => {
- let E = d, b = l.get(_, C), R = f.get(_, C);
- if (E.isString() && (E = E.convertToNumberObjectValue()), E.isError())
- return E;
- if (b.isString() && (b = b.convertToNumberObjectValue()), b.isError())
- return b;
- if (R.isString() && (R = R.convertToNumberObjectValue()), R.isError())
- return R;
- const p = +E.getValue(), N = +b.getValue(), M = +R.getValue();
- if (p === 0 || N === 0)
- return y.create(0);
- let w;
- return p < 0 && M !== 0 ? w = (N < 0 ? We(Math.abs(p) / Math.abs(N), 0) : -We(Math.abs(p) / N, 0)) * N : w = (N < 0 ? -We(p / Math.abs(N), 0) : We(p / N, 0)) * N, y.create(w);
- });
- return o === 1 && u === 1 ? h.get(0, 0) : h;
- }
- }
- class jC extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- const r = t != null ? t : y.create(1);
- if (e.isError())
- return e;
- if (r.isError())
- return r;
- const n = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- r.isArray() ? r.getRowCount() : 1
- ), s = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- r.isArray() ? r.getColumnCount() : 1
- ), o = O(n, s, e, g.create(m.NA)), u = O(n, s, r, g.create(m.NA)), c = o.map((l, f, h) => {
- let d = u.get(f, h), _ = l;
- if (_.isString() && (_ = _.convertToNumberObjectValue()), _.isError())
- return _;
- if (d.isString() && (d = d.convertToNumberObjectValue()), d.isError())
- return d;
- const C = +_.getValue(), E = +d.getValue();
- if (C === 0 || E === 0)
- return y.create(0);
- const b = (E < 0 ? -We(C / Math.abs(E), 0) : We(C / E, 0)) * E;
- return y.create(b);
- });
- return n === 1 && s === 1 ? c.get(0, 0) : c;
- }
- }
- class UC extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 255);
- }
- calculate(...e) {
- let t = 0;
- for (let r = 0; r < e.length; r++) {
- const n = e[r];
- if (!n.isNull())
- if (n.isArray()) {
- let s = !1, o = g.create(m.VALUE);
- if (n.iterator((u) => {
- if (u != null && u.isNull())
- return !0;
- const { isError: c, errorObject: l, number: f } = this._handleSingleObject(u);
- if (c)
- return s = !0, o = l, !1;
- t = qs(t, f);
- }), s)
- return o;
- } else {
- const { isError: s, errorObject: o, number: u } = this._handleSingleObject(n);
- if (s)
- return o;
- t = qs(t, u);
- }
- }
- return y.create(t);
- }
- _handleSingleObject(e) {
- if (e.isBoolean())
- return {
- isError: !0,
- errorObject: g.create(m.VALUE),
- number: null
- };
- let t = e;
- if (e.isString() && (t = t.convertToNumberObjectValue()), t.isError())
- return {
- isError: !0,
- errorObject: t,
- number: null
- };
- const r = Math.floor(+t.getValue());
- return r < 0 || r >= 2 ** 53 ? {
- isError: !0,
- errorObject: g.create(m.NUM),
- number: null
- } : {
- isError: !1,
- errorObject: null,
- number: r
- };
- }
- }
- class vC extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- return e.isArray() ? e.mapValue((t) => this._handleSingleObject(t)) : this._handleSingleObject(e);
- }
- _handleSingleObject(e) {
- let t = e;
- if (t.isString() && (t = t.convertToNumberObjectValue()), t.isError())
- return t;
- const r = Math.floor(+t.getValue());
- return y.create(r);
- }
- }
- class TC extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 255);
- }
- calculate(...e) {
- let t = 1, r = !0;
- for (let n = 0; n < e.length; n++) {
- const s = e[n];
- if (!s.isNull())
- if (s.isArray()) {
- let o = !1, u = g.create(m.VALUE);
- if (s.iterator((c) => {
- if (c != null && c.isNull())
- return !0;
- const { isError: l, errorObject: f, number: h } = this._handleSingleObject(c);
- if (l)
- return o = !0, u = f, !1;
- t = Mi(t, h), r = !1;
- }), o)
- return u;
- } else {
- const { isError: o, errorObject: u, number: c } = this._handleSingleObject(s);
- if (o)
- return u;
- t = Mi(t, c), r = !1;
- }
- }
- return r ? y.create(0) : Number.isNaN(t) || !Number.isFinite(t) || t >= 2 ** 53 ? g.create(m.VALUE) : y.create(t);
- }
- _handleSingleObject(e) {
- if (e.isBoolean())
- return {
- isError: !0,
- errorObject: g.create(m.VALUE),
- number: null
- };
- let t = e;
- if (e.isString() && (t = t.convertToNumberObjectValue()), t.isError())
- return {
- isError: !0,
- errorObject: t,
- number: null
- };
- const r = Math.floor(+t.getValue());
- return r < 0 ? {
- isError: !0,
- errorObject: g.create(m.NUM),
- number: null
- } : {
- isError: !1,
- errorObject: null,
- number: r
- };
- }
- }
- class BC extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- let t = e;
- return t.isString() && (t = t.convertToNumberObjectValue()), t.isError() ? t : t.log();
- }
- }
- class IC extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- const r = t != null ? t : y.create(10);
- if (e.isError())
- return e;
- if (r.isError())
- return r;
- const n = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- r.isArray() ? r.getRowCount() : 1
- ), s = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- r.isArray() ? r.getColumnCount() : 1
- ), o = O(n, s, e, g.create(m.NA)), u = O(n, s, r, g.create(m.NA)), c = o.map((l, f, h) => {
- let d = u.get(f, h), _ = l;
- if (_.isString() && (_ = _.convertToNumberObjectValue()), _.isError())
- return _;
- if (d.isString() && (d = d.convertToNumberObjectValue()), d.isError())
- return d;
- const C = +_.getValue(), E = +d.getValue();
- if (C <= 0 || E <= 0)
- return g.create(m.NUM);
- const b = Math.log(E);
- if (b === 0)
- return g.create(m.DIV_BY_ZERO);
- const R = Math.log(C) / b;
- return y.create(R);
- });
- return n === 1 && s === 1 ? c.get(0, 0) : c;
- }
- }
- class FC extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- let t = e;
- return t.isString() && (t = t.convertToNumberObjectValue()), t.isError() ? t : t.log10();
- }
- }
- class kC extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- const t = e.isArray() ? e.getRowCount() : 1, r = e.isArray() ? e.getColumnCount() : 1, n = [];
- for (let o = 0; o < t; o++) {
- const u = [];
- for (let c = 0; c < r; c++) {
- let l = e.isArray() ? e.get(o, c) : e;
- if (l.isError())
- return l;
- if (l.isNull() || l.isBoolean())
- return g.create(m.VALUE);
- if (l.isString() && (l = l.convertToNumberObjectValue()), l.isError())
- return l;
- const f = +l.getValue();
- u.push(f);
- }
- n.push(u);
- }
- if (t !== r)
- return g.create(m.VALUE);
- const s = Gn(n);
- return y.create(s);
- }
- }
- class $C extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- const t = e.isArray() ? e.getRowCount() : 1, r = e.isArray() ? e.getColumnCount() : 1, n = [];
- for (let o = 0; o < t; o++) {
- const u = [];
- for (let c = 0; c < r; c++) {
- let l = e.isArray() ? e.get(o, c) : e;
- if (l.isError())
- return l;
- if (l.isNull() || l.isBoolean())
- return g.create(m.VALUE);
- if (l.isString() && (l = l.convertToNumberObjectValue()), l.isError())
- return l;
- const f = +l.getValue();
- u.push(f);
- }
- n.push(u);
- }
- if (t !== r)
- return g.create(m.VALUE);
- const s = Gh(n);
- return s === null ? g.create(m.NUM) : q.createByArray(s);
- }
- }
- class YC extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- 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;
- if (n !== s)
- return g.create(m.VALUE);
- const u = this._getMatrix(e, r, n), c = this._getMatrix(t, s, o);
- if (u instanceof g)
- return u;
- if (c instanceof g)
- return c;
- const l = lr(u, c);
- return q.createByArray(l);
- }
- _getMatrix(e, t, r) {
- const n = [];
- for (let s = 0; s < t; s++) {
- const o = [];
- for (let u = 0; u < r; u++) {
- let c = e.isArray() ? e.get(s, u) : e;
- if (c.isError())
- return c;
- if (c.isNull() || c.isBoolean())
- return g.create(m.VALUE);
- if (c.isString() && (c = c.convertToNumberObjectValue()), c.isError())
- return c;
- const l = +c.getValue();
- o.push(l);
- }
- n.push(o);
- }
- return n;
- }
- }
- class HC extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- let r = e;
- if (r.isString() && (r = r.convertToNumberObjectValue()), r.isError())
- return r;
- let n = t;
- return n.isString() && (n = n.convertToNumberObjectValue()), n.isError() ? n : r.mod(n);
- }
- }
- class GC extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- let r = e;
- if (r.isArray()) {
- const c = r.getRowCount(), l = r.getColumnCount();
- if (c > 1 || l > 1)
- return g.create(m.VALUE);
- r = r.get(0, 0);
- }
- if (r.isError())
- return r;
- let n = t;
- if (n.isArray()) {
- const c = n.getRowCount(), l = n.getColumnCount();
- if (c > 1 || l > 1)
- return g.create(m.VALUE);
- n = n.get(0, 0);
- }
- if (n.isError())
- return n;
- if (r.isBoolean() || n.isBoolean())
- return g.create(m.VALUE);
- const s = +r.getValue(), o = +n.getValue();
- if (Number.isNaN(s) || Number.isNaN(o))
- return g.create(m.VALUE);
- if (o === 0)
- return y.create(0);
- if (s > 0 && o < 0 || s < 0 && o > 0)
- return g.create(m.NUM);
- const u = vt(s / o, 0) * o;
- return y.create(u);
- }
- }
- class QC extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 255);
- }
- calculate(...e) {
- let t = 0, r = 1;
- for (let s = 0; s < e.length; s++) {
- const o = e[s];
- if (!o.isNull())
- if (o.isArray()) {
- let u = !1, c = g.create(m.VALUE);
- if (o.iterator((l) => {
- if (l != null && l.isNull())
- return !0;
- const { isError: f, errorObject: h, number: d } = this._handleSingleObject(l);
- if (f)
- return u = !0, c = h, !1;
- if (t += d, t > 170)
- return u = !0, c = g.create(m.NUM), !1;
- r *= cr(d);
- }), u)
- return c;
- } else {
- const { isError: u, errorObject: c, number: l } = this._handleSingleObject(o);
- if (u)
- return c;
- if (t += l, t > 170)
- return g.create(m.NUM);
- r *= cr(l);
- }
- }
- const n = cr(t) / r;
- return y.create(n);
- }
- _handleSingleObject(e) {
- if (e.isBoolean())
- return {
- isError: !0,
- errorObject: g.create(m.VALUE),
- number: null
- };
- let t = e;
- if (e.isString() && (t = t.convertToNumberObjectValue()), t.isError())
- return {
- isError: !0,
- errorObject: t,
- number: null
- };
- const r = Math.floor(+t.getValue());
- return r < 0 ? {
- isError: !0,
- errorObject: g.create(m.NUM),
- number: null
- } : {
- isError: !1,
- errorObject: null,
- number: r
- };
- }
- }
- class WC extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- if (e.isArray()) {
- const t = e.getRowCount(), r = e.getColumnCount(), n = e.mapValue((s) => {
- const o = this._handleSingleObject(s);
- return o.isError() ? o : t > 1 || r > 1 ? o.get(0, 0) : o;
- });
- return t === 1 && r === 1 ? n.get(0, 0) : n;
- }
- return this._handleSingleObject(e);
- }
- _handleSingleObject(e) {
- let t = e;
- if (t.isString() && (t = t.convertToNumberObjectValue()), t.isError())
- return t;
- const r = Math.floor(+t.getValue());
- if (r <= 0)
- return g.create(m.VALUE);
- const n = [];
- for (let s = 0; s < r; s++) {
- n[s] = [];
- for (let o = 0; o < r; o++)
- n[s][o] = s === o ? 1 : 0;
- }
- return q.createByArray(n);
- }
- }
- class qC extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- return e.isArray() ? e.map((t) => this._handleSingleObject(t)) : this._handleSingleObject(e);
- }
- _handleSingleObject(e) {
- let t = e;
- if (t.isString() && (t = t.convertToNumberObjectValue()), t.isError())
- return t;
- const r = +t.getValue();
- if (!Number.isFinite(r))
- return g.create(m.VALUE);
- let n = r < 0 ? -Ye(Math.abs(r), 0) : Ye(r, 0);
- return Number.isNaN(n) ? g.create(m.VALUE) : (Math.abs(n) % 2 === 0 && (r < 0 ? n-- : n++), y.create(n));
- }
- }
- class KC extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 0);
- A(this, "maxParams", 0);
- }
- calculate() {
- return y.create(Math.PI);
- }
- }
- class XC extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- let r = e;
- if (r.isString() && (r = r.convertToNumberObjectValue()), r.isError())
- return r;
- let n = t;
- return n.isString() && (n = n.convertToNumberObjectValue()), n.isError() ? n : r.pow(n);
- }
- }
- class ZC extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 255);
- }
- calculate(...e) {
- let t = y.create(1), r = !0;
- for (let n = 0; n < e.length; n++) {
- let s = e[n];
- if (s.isError())
- return s;
- if (s.isArray()) {
- let o = !1, u = null;
- if (s.iterator((c) => {
- if (c != null && c.isError())
- return o = !0, u = c, !1;
- if (!c || c.isNull() || c.isString() || c.isBoolean())
- return !0;
- t = t.multiply(c), r = !1;
- }), o)
- return u;
- } else {
- if (s.isNull())
- continue;
- if (s.isString() && (s = s.convertToNumberObjectValue()), s.isError())
- return s;
- t = t.multiply(s), r = !1;
- }
- if (t.isError())
- return t;
- }
- return r ? y.create(0) : t;
- }
- }
- class zC extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- const { isError: r, errorObject: n, variants: s } = H(e, t);
- if (r)
- return n;
- const [o, u] = s, c = +o.getValue(), l = +u.getValue();
- if (Number.isNaN(c) || Number.isNaN(l))
- return g.create(m.VALUE);
- if (l === 0)
- return g.create(m.DIV_BY_ZERO);
- const f = Math.trunc(c / l);
- return y.create(f);
- }
- }
- class JC extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- return e.isArray() ? e.map((t) => this._handleSingleObject(t)) : this._handleSingleObject(e);
- }
- _handleSingleObject(e) {
- let t = e;
- if (t.isString() && (t = t.convertToNumberObjectValue()), t.isError())
- return t;
- const r = +t.getValue();
- if (!Number.isFinite(r))
- return g.create(m.VALUE);
- const n = r * (Math.PI / 180);
- return Number.isNaN(n) ? g.create(m.VALUE) : y.create(n);
- }
- }
- class e_ extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 0);
- A(this, "maxParams", 0);
- }
- calculate() {
- return y.create(Math.random());
- }
- }
- class t_ extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 0);
- A(this, "maxParams", 5);
- A(this, "needsSheetRowColumnCount", !0);
- }
- calculate(e, t, r, n, s) {
- if (e != null && e.isError())
- return e;
- if (t != null && t.isError())
- return t;
- if (r != null && r.isError())
- return r;
- if (n != null && n.isError())
- return n;
- if (s != null && s.isError())
- return s;
- const o = e != null ? e : y.create(1), u = t != null ? t : y.create(1), c = r != null ? r : y.create(0), l = n != null ? n : y.create(1), f = s != null ? s : y.create(0);
- return this._calculateResult(o, u, c, l, f);
- }
- _calculateResult(e, t, r, n, s) {
- const o = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1,
- r.isArray() ? r.getRowCount() : 1,
- n.isArray() ? n.getRowCount() : 1,
- s.isArray() ? s.getRowCount() : 1
- ), u = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1,
- r.isArray() ? r.getColumnCount() : 1,
- n.isArray() ? n.getColumnCount() : 1,
- s.isArray() ? s.getColumnCount() : 1
- );
- if (o === 1 && u === 1)
- return this._calculateSingleCell(e, t, r, n, s);
- const c = O(o, u, e, g.create(m.NA)), l = O(o, u, t, g.create(m.NA)), f = O(o, u, r, g.create(m.NA)), h = O(o, u, n, g.create(m.NA)), d = O(o, u, s, g.create(m.NA));
- return c.map((_, C, E) => {
- const b = l.get(C, E), R = f.get(C, E), p = h.get(C, E), N = d.get(C, E), M = this._handleError(_, b, R, p, N);
- if (M.errorObject)
- return M.errorObject;
- let { minValue: w, maxValue: D, wholeNumberValue: S } = M, P;
- return S ? (w = Math.ceil(w), D = Math.floor(D), P = Math.floor(Math.random() * (D - w + 1)) + w) : P = Math.random() * (D - w) + w, P < w || P > D ? g.create(m.VALUE) : y.create(P);
- });
- }
- _calculateSingleCell(e, t, r, n, s) {
- let o = e;
- o.isArray() && (o = o.get(0, 0));
- let u = t;
- u.isArray() && (u = u.get(0, 0));
- let c = r;
- c.isArray() && (c = c.get(0, 0));
- let l = n;
- l.isArray() && (l = l.get(0, 0));
- let f = s;
- f.isArray() && (f = f.get(0, 0));
- const h = this._handleError(o, u, c, l, f);
- if (h.errorObject)
- return h.errorObject;
- let { rowsValue: d, columnsValue: _, minValue: C, maxValue: E, wholeNumberValue: b } = h;
- if (b && (C = Math.ceil(C), E = Math.floor(E), C > E))
- return g.create(m.VALUE);
- const R = [];
- for (let p = 0; p < d; p++) {
- const N = [];
- for (let M = 0; M < _; M++)
- b ? N.push(Math.floor(Math.random() * (E - C + 1)) + C) : N.push(Math.random() * (E - C) + C);
- R.push(N);
- }
- return d === 1 && _ === 1 ? y.create(R[0][0]) : q.createByArray(R);
- }
- _handleError(e, t, r, n, s) {
- let o = e;
- if (o.isString() && (o = o.convertToNumberObjectValue()), o.isError())
- return {
- errorObject: o
- };
- let u = t;
- if (u.isString() && (u = u.convertToNumberObjectValue()), u.isError())
- return {
- errorObject: u
- };
- let c = r;
- if (c.isString() && (c = c.convertToNumberObjectValue()), c.isError())
- return {
- errorObject: c
- };
- let l = n;
- if (l.isString() && (l = l.convertToNumberObjectValue()), l.isError())
- return {
- errorObject: l
- };
- let f = s;
- return f.isString() && (f = f.convertToNumberObjectValue()), f.isError() ? {
- errorObject: f
- } : this._getValue(o, u, c, l, f);
- }
- _getValue(e, t, r, n, s) {
- const o = Math.floor(+e.getValue()), u = Math.floor(+t.getValue());
- if (o === 0 || u === 0)
- return {
- errorObject: g.create(m.CALC)
- };
- const c = this._rowCount - this.row, l = this._columnCount - this.column;
- if (o < 0 || u < 0 || o * u > 10 ** 7)
- return {
- errorObject: g.create(m.VALUE)
- };
- if (o > c || u > l)
- return {
- errorObject: g.create(m.REF)
- };
- const f = +r.getValue(), h = +n.getValue(), d = +s.getValue();
- return f > h ? {
- errorObject: g.create(m.VALUE)
- } : d && (!Number.isInteger(f) || !Number.isInteger(h)) ? {
- errorObject: g.create(m.VALUE)
- } : {
- rowsValue: o,
- columnsValue: u,
- minValue: f,
- maxValue: h,
- wholeNumberValue: d
- };
- }
- }
- class r_ extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- let r = e;
- if (r.isArray()) {
- const c = r.getRowCount(), l = r.getColumnCount();
- if (c > 1 || l > 1)
- return g.create(m.VALUE);
- r = r.get(0, 0);
- }
- if (r.isError())
- return r;
- let n = t;
- if (n.isArray()) {
- const c = n.getRowCount(), l = n.getColumnCount();
- if (c > 1 || l > 1)
- return g.create(m.VALUE);
- n = n.get(0, 0);
- }
- if (n.isError())
- return n;
- if (r.isBoolean() || n.isBoolean())
- return g.create(m.VALUE);
- let s = +r.getValue(), o = +n.getValue();
- if (Number.isNaN(s) || Number.isNaN(o))
- return g.create(m.VALUE);
- if (s > o)
- return g.create(m.NUM);
- s = Math.ceil(s), o = Math.floor(o);
- const u = Math.floor(Math.random() * (o - s + 1)) + s;
- return y.create(u);
- }
- }
- class n_ extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- const r = t != null ? t : y.create(0), n = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- r.isArray() ? r.getRowCount() : 1
- ), s = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- r.isArray() ? r.getColumnCount() : 1
- ), o = O(n, s, e, g.create(m.NA)), u = O(n, s, r, g.create(m.NA)), c = o.mapValue((l, f, h) => {
- const d = u.get(f, h);
- return l.isError() ? l : d.isError() ? d : this._handleSingleObject(l, d);
- });
- return n === 1 && s === 1 ? c.get(0, 0) : c;
- }
- _handleSingleObject(e, t) {
- const { isError: r, errorObject: n, variants: s } = I(e);
- if (r)
- return n;
- const [o] = s;
- let u = Math.floor(+o.getValue()), c = t;
- if (c.isString() && (c = c.convertToNumberObjectValue(), c.isError()))
- return c;
- let l = Math.floor(+c.getValue());
- if (c.isBoolean() && (l = c.getValue() ? 0 : 4), u < 0 || u > 3999 || l < 0 || l > 4)
- return g.create(m.VALUE);
- const f = Jh[l];
- let h = f.length - 1, d = "";
- for (; u > 0; ) {
- h = this._binarySearch(u, 0, h, f);
- const _ = f[h];
- u -= _, d += zh.get(_);
- }
- return j.create(d);
- }
- _binarySearch(e, t, r, n) {
- let s = t, o = r;
- for (; o - s > 1; ) {
- const u = Math.floor((s + o) / 2), c = n[u];
- if (c === e)
- return u;
- c > e ? o = u : s = u;
- }
- return s !== o && n[o] <= e ? o : s;
- }
- }
- class s_ extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- let r = e;
- if (r.isString() && (r = r.convertToNumberObjectValue()), r.isError())
- return r;
- let n = t;
- return n.isString() && (n = n.convertToNumberObjectValue()), n.isError() ? n : r.round(n);
- }
- }
- class a_ extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- const r = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1
- ), n = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1
- ), s = O(r, n, e, g.create(m.NA)), o = O(r, n, t, g.create(m.NA)), u = s.mapValue((c, l, f) => {
- const h = o.get(l, f);
- if (c.isError())
- return c;
- if (h.isError())
- return h;
- const { isError: d, errorObject: _, variants: C } = I(c, h);
- if (d)
- return _;
- const [E, b] = C, R = +E.getValue(), p = Math.trunc(+b.getValue()), N = this._roundBank(R, p);
- return y.create(N);
- });
- return r === 1 && n === 1 ? u.get(0, 0) : u;
- }
- _roundBank(e, t) {
- if (t > 16)
- return e;
- if (t < -16)
- return 0;
- const r = 1e-8, n = 10 ** t, s = +(e * n).toFixed(8), o = Math.floor(s), u = s - o;
- let c = Math.round(s);
- return u > 0.5 - r && u < 0.5 + r && (c = o % 2 === 0 ? o : o + 1), t ? c / n : c;
- }
- }
- class i_ extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- let r = e;
- if (r.isString() && (r = r.convertToNumberObjectValue()), r.isError())
- return r;
- let n = t;
- return n.isString() && (n = n.convertToNumberObjectValue()), n.isError() ? n : r.floor(n);
- }
- }
- class o_ extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- let r = e;
- if (r.isString() && (r = r.convertToNumberObjectValue()), r.isError())
- return r;
- let n = t;
- return n.isString() && (n = n.convertToNumberObjectValue()), n.isError() ? n : r.ceil(n);
- }
- }
- class u_ extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- return e.isArray() ? e.map((t) => this._handleSingleObject(t)) : this._handleSingleObject(e);
- }
- _handleSingleObject(e) {
- let t = e;
- if (t.isString() && (t = t.convertToNumberObjectValue()), t.isError())
- return t;
- const r = +t.getValue();
- return Math.abs(r) >= 2 ** 27 ? g.create(m.NUM) : t.cos().getReciprocal();
- }
- }
- class c_ extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- return e.isArray() ? e.map((t) => this._handleSingleObject(t)) : this._handleSingleObject(e);
- }
- _handleSingleObject(e) {
- let t = e;
- if (t.isString() && (t = t.convertToNumberObjectValue()), t.isError())
- return t;
- const r = +t.getValue();
- return Number.isFinite(Math.cosh(r)) ? Math.abs(r) >= 2 ** 27 ? g.create(m.NUM) : t.cosh().getReciprocal() : y.create(0);
- }
- }
- class l_ extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 4);
- A(this, "needsSheetRowColumnCount", !0);
- }
- calculate(e, t, r, n) {
- let s = e, o = t != null ? t : y.create(1), u = r != null ? r : y.create(1), c = n != null ? n : y.create(1);
- s.isNull() && (s = y.create(1)), o.isNull() && (o = y.create(1)), u.isNull() && (u = y.create(1)), c.isNull() && (c = y.create(1));
- const l = Math.max(
- s.isArray() ? s.getRowCount() : 1,
- o.isArray() ? o.getRowCount() : 1,
- u.isArray() ? u.getRowCount() : 1,
- c.isArray() ? c.getRowCount() : 1
- ), f = Math.max(
- s.isArray() ? s.getColumnCount() : 1,
- o.isArray() ? o.getColumnCount() : 1,
- u.isArray() ? u.getColumnCount() : 1,
- c.isArray() ? c.getColumnCount() : 1
- ), h = O(l, f, s, g.create(m.NA)), d = O(l, f, o, g.create(m.NA)), _ = O(l, f, u, g.create(m.NA)), C = O(l, f, c, g.create(m.NA)), E = h.mapValue((b, R, p) => {
- const N = d.get(R, p), M = _.get(R, p), w = C.get(R, p);
- return b.isError() ? b : N.isError() ? N : M.isError() ? M : w.isError() ? w : this._getResult(b, N, M, w, l, f);
- });
- return l === 1 && f === 1 ? E.get(0, 0) : E;
- }
- _getResult(e, t, r, n, s, o) {
- const { isError: u, errorObject: c, variants: l } = I(e, t, r, n);
- if (u)
- return c;
- const [f, h, d, _] = l, C = Math.floor(+f.getValue()), E = Math.floor(+h.getValue()), b = +d.getValue(), R = +_.getValue();
- if (C < 0 || E < 0 || C * E > 10 ** 7)
- return g.create(m.VALUE);
- if (C === 0 || E === 0)
- return g.create(m.CALC);
- const p = this._rowCount - this.row, N = this._columnCount - this.column;
- if (C > p || E > N)
- return g.create(m.REF);
- const M = [];
- for (let w = 0; w < C; w++) {
- M[w] = [];
- for (let D = 0; D < E; D++)
- M[w][D] = b + (w * E + D) * R;
- }
- return s > 1 || o > 1 ? y.create(M[0][0]) : q.createByArray(M);
- }
- }
- class f_ extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 4);
- A(this, "maxParams", 4);
- }
- calculate(e, t, r, n) {
- if (e.isNull() || t.isNull() || r.isNull() || n.isNull())
- return g.create(m.NA);
- const { isError: s, errorObject: o, variants: u } = H(e, t, r);
- if (s)
- return o;
- const { isError: c, errorObject: l, variants: f } = I(...u);
- if (c)
- return l;
- const [h, d, _] = f, C = +h.getValue(), E = +d.getValue(), b = +_.getValue(), R = [];
- if (n.isArray()) {
- let N = !1, M = g.create(m.VALUE);
- if (n.iterator((w) => {
- const { isError: D, errorObject: S, coefficientsObject: P } = this._handleSingleObject(w);
- if (D)
- return N = !0, M = S, !1;
- const U = +P.getValue();
- R.push(U);
- }), N)
- return M;
- } else {
- const { isError: N, errorObject: M, coefficientsObject: w } = this._handleSingleObject(n);
- if (N)
- return M;
- const D = +w.getValue();
- R.push(D);
- }
- let p = 0;
- for (let N = 0; N < R.length; N++)
- p += R[N] * C ** (E + N * b);
- return Number.isNaN(p) || !Number.isFinite(p) ? g.create(m.NUM) : y.create(p);
- }
- _handleSingleObject(e) {
- if (e.isError())
- return {
- isError: !0,
- errorObject: e,
- coefficientsObject: null
- };
- if (e != null && e.isBoolean())
- return {
- isError: !0,
- errorObject: g.create(m.VALUE),
- coefficientsObject: null
- };
- let t = e;
- return t.isString() && (t = t.convertToNumberObjectValue()), t.isError() ? {
- isError: !0,
- errorObject: t,
- coefficientsObject: null
- } : {
- isError: !1,
- errorObject: null,
- coefficientsObject: t
- };
- }
- }
- class h_ extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- if (e.isArray()) {
- const t = e.mapValue((r) => this._handleSingleObject(r));
- return t.getRowCount() === 1 && t.getColumnCount() === 1 ? t.get(0, 0) : t;
- }
- return this._handleSingleObject(e);
- }
- _handleSingleObject(e) {
- if (e.isError())
- return e;
- const { isError: t, errorObject: r, variants: n } = I(e);
- if (t)
- return r;
- const [s] = n, o = +s.getValue();
- return o > 0 ? y.create(1) : o < 0 ? y.create(-1) : y.create(0);
- }
- }
- class m_ extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- let t = e;
- return t.isString() && (t = t.convertToNumberObjectValue()), t.isError() ? t : t.sin();
- }
- }
- class g_ extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- let t = e;
- return t.isString() && (t = t.convertToNumberObjectValue()), t.isError() ? t : t.sinh();
- }
- }
- class d_ extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- let t = e;
- return t.isString() && (t = t.convertToNumberObjectValue()), t.isError() ? t : t.sqrt();
- }
- }
- class C_ extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- let t = e;
- if (t.isArray()) {
- const s = t.getRowCount(), o = t.getColumnCount();
- if (s > 1 || o > 1)
- return g.create(m.VALUE);
- t = t.get(0, 0);
- }
- if (t.isString() && (t = t.convertToNumberObjectValue()), t.isError())
- return t;
- const r = +t.getValue();
- if (r < 0)
- return g.create(m.NUM);
- const n = Math.sqrt(r * Math.PI);
- return y.create(n);
- }
- }
- class __ extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 255);
- A(this, "needsReferenceObject", !0);
- }
- calculate(e, ...t) {
- if (e.isError())
- return e;
- if (e.isReferenceObject()) {
- const r = [];
- return e.iterator((n, s, o) => {
- r[s] == null && (r[s] = []), r[s][o] = this._handleSingleObject(
- n,
- ...t
- );
- }), tr(r, r.length, r[0].length);
- }
- return this._handleSingleObject(e, ...t);
- }
- // eslint-disable-next-line max-lines-per-function, complexity
- _handleSingleObject(e, ...t) {
- const r = this._getIndexNumValue(e);
- let n;
- if (r instanceof g)
- return r;
- switch (r) {
- case 1:
- n = this._average(!1, ...t);
- break;
- case 2:
- n = this._count(!1, ...t);
- break;
- case 3:
- n = this._counta(!1, ...t);
- break;
- case 4:
- n = this._max(!1, ...t);
- break;
- case 5:
- n = this._min(!1, ...t);
- break;
- case 6:
- n = this._product(!1, ...t);
- break;
- case 7:
- n = this._stdev(!1, ...t);
- break;
- case 8:
- n = this._stdevp(!1, ...t);
- break;
- case 9:
- n = this._sum(!1, ...t);
- break;
- case 10:
- n = this._var(!1, ...t);
- break;
- case 11:
- n = this._varp(!1, ...t);
- break;
- case 101:
- n = this._average(!0, ...t);
- break;
- case 102:
- n = this._count(!0, ...t);
- break;
- case 103:
- n = this._counta(!0, ...t);
- break;
- case 104:
- n = this._max(!0, ...t);
- break;
- case 105:
- n = this._min(!0, ...t);
- break;
- case 106:
- n = this._product(!0, ...t);
- break;
- case 107:
- n = this._stdev(!0, ...t);
- break;
- case 108:
- n = this._stdevp(!0, ...t);
- break;
- case 109:
- n = this._sum(!0, ...t);
- break;
- case 110:
- n = this._var(!0, ...t);
- break;
- case 111:
- n = this._varp(!0, ...t);
- break;
- default:
- n = g.create(m.VALUE);
- }
- return n;
- }
- _getIndexNumValue(e) {
- const t = e ? Number(e.getValue()) : 0;
- if (Number.isNaN(t))
- return g.create(m.VALUE);
- const r = Math.floor(t);
- return r >= 1 && r <= 11 || r >= 101 && r <= 111 ? r : g.create(m.VALUE);
- }
- _average(e, ...t) {
- const r = this._flattenRefArray(e, ...t);
- return r.isError() ? r : r.mean();
- }
- _count(e, ...t) {
- let r = y.create(0);
- for (let n = 0; n < t.length; n++) {
- const s = t[n];
- if (!s.isReferenceObject())
- return g.create(m.VALUE);
- const o = s.getRowData();
- s.iterator((u, c) => {
- if (e && this._isRowHidden(o, c))
- return !0;
- u != null && u.isNumber() && (r = r.plusBy(1));
- });
- }
- return r;
- }
- _counta(e, ...t) {
- let r = y.create(0);
- for (let n = 0; n < t.length; n++) {
- const s = t[n];
- if (!s.isReferenceObject())
- return g.create(m.VALUE);
- const o = s.getRowData();
- s.iterator((u, c) => {
- if (e && this._isRowHidden(o, c) || u == null || u.isNull())
- return !0;
- r = r.plusBy(1);
- });
- }
- return r;
- }
- _max(e, ...t) {
- const r = this._flattenRefArray(e, ...t);
- return r.isError() ? r : this._isBlankArrayObject(r) ? y.create(0) : r.max();
- }
- _min(e, ...t) {
- const r = this._flattenRefArray(e, ...t);
- return r.isError() ? r : this._isBlankArrayObject(r) ? y.create(0) : r.min();
- }
- _product(e, ...t) {
- const r = this._flattenRefArray(e, ...t);
- if (r.isError())
- return r;
- if (this._isBlankArrayObject(r))
- return y.create(0);
- let n = y.create(1);
- return r.iterator((s) => {
- n = n.multiply(
- s
- );
- }), n;
- }
- _stdev(e, ...t) {
- const r = this._flattenRefArray(e, ...t);
- return r.isError() ? r : this._isBlankArrayObject(r) ? g.create(m.DIV_BY_ZERO) : r.std(1);
- }
- _stdevp(e, ...t) {
- const r = this._flattenRefArray(e, ...t);
- return r.isError() ? r : this._isBlankArrayObject(r) ? g.create(m.DIV_BY_ZERO) : r.std();
- }
- _sum(e, ...t) {
- const r = this._flattenRefArray(e, ...t);
- return r.isError() ? r : r.sum();
- }
- _var(e, ...t) {
- const r = this._flattenRefArray(e, ...t);
- return r.isError() ? r : this._isBlankArrayObject(r) ? g.create(m.DIV_BY_ZERO) : r.var(1);
- }
- _varp(e, ...t) {
- const r = this._flattenRefArray(e, ...t);
- return r.isError() ? r : this._isBlankArrayObject(r) ? g.create(m.DIV_BY_ZERO) : r.var();
- }
- _flattenRefArray(e, ...t) {
- const r = [];
- r[0] = [];
- for (let n = 0; n < t.length; n++) {
- const s = t[n];
- if (s.isError())
- return s;
- if (!s.isReferenceObject())
- return g.create(m.VALUE);
- const o = s.getRowData();
- let u;
- if (s.iterator((c, l) => {
- if (e && this._isRowHidden(o, l) || c == null || c.isNull() || c.isString() || c.isBoolean())
- return !0;
- if (c.isError())
- return u = c, !1;
- r[0].push(c);
- }), u != null && u.isError())
- return u;
- }
- return tr(r, 1, r[0].length);
- }
- _isRowHidden(e, t) {
- const r = e[t];
- return r ? r.hd === Wu.TRUE : !1;
- }
- _isBlankArrayObject(e) {
- return e.getArrayValue()[0].length === 0;
- }
- }
- class A_ extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 255);
- }
- calculate(...e) {
- let t = y.create(0);
- for (let r = 0; r < e.length; r++) {
- let n = e[r];
- if (n.isString() && (n = n.convertToNumberObjectValue()), n.isError() || (n.isArray() && (n = n.sum()), n.isError()))
- return n;
- if (t = t.plus(n), t.isError())
- return t;
- }
- return t;
- }
- }
- class E_ extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 3);
- A(this, "needsReferenceObject", !0);
- }
- calculate(e, t, r) {
- let n = t;
- if (t.isReferenceObject() && (n = t.toArrayValueObject()), n.isArray()) {
- const s = n.mapValue((o) => this._handleSingleObject(e, o, r));
- return s.getRowCount() === 1 && s.getColumnCount() === 1 ? s.get(0, 0) : s;
- }
- return this._handleSingleObject(e, n, r);
- }
- _handleSingleObject(e, t, r) {
- if (e.isError())
- return e;
- if (t.isError())
- return t;
- if (r != null && r.isError())
- return r;
- if (!e.isReferenceObject() || r && !r.isReferenceObject())
- return g.create(m.VALUE);
- const n = e.toArrayValueObject();
- let s = $n(n, t);
- s = Yn(s, n, t);
- const o = n.getRowCount(), u = n.getColumnCount();
- let c = n;
- if (r) {
- c = r.toArrayValueObject();
- const l = c.getRowCount(), f = c.getColumnCount();
- if (o !== l || u !== f) {
- const h = r.getRangeData();
- h.endRow = h.startRow + o - 1, h.endColumn = h.startColumn + u - 1, r.setRangeData(h), c = r.toArrayValueObject();
- }
- }
- return c.pick(s).sum();
- }
- }
- class b_ extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 3);
- A(this, "maxParams", 255);
- }
- calculate(e, ...t) {
- if (e.isError())
- return e;
- if (!e.isArray() || t.length < 2 || t.length % 2 !== 0 || t.some((u, c) => c % 2 === 0 && !u.isArray()))
- return g.create(m.VALUE);
- const { maxRowLength: r, maxColumnLength: n } = Nr(t), s = Br(t, e, r, n);
- if (s)
- return s;
- const o = Ir(t, r, n, !0);
- return this._aggregateResults(e, o);
- }
- _aggregateResults(e, t) {
- const r = t.map((s) => s.map((o) => e.pick(o).sum())), n = {
- calculateValueList: r,
- rowCount: r.length,
- columnCount: r[0].length,
- unitId: this.unitId || "",
- sheetId: this.subUnitId || "",
- row: this.row,
- column: this.column
- };
- return q.create(n);
- }
- }
- class y_ extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 255);
- }
- calculate(e, ...t) {
- if (e.isError())
- return e;
- const r = this._initArray1(e);
- if (t.length > 0) {
- const n = r.getRowCount(), s = r.getColumnCount();
- let o = this._getResultArrayByArray1(n, s, r);
- if (o instanceof g)
- return o;
- o = o;
- for (let c = 0; c < t.length; c++) {
- if (t[c].isError())
- return t[c];
- let l = 1, f = 1;
- if (t[c].isArray() && (l = t[c].getRowCount(), f = t[c].getColumnCount()), l !== n || f !== s)
- return g.create(m.VALUE);
- for (let h = 0; h < n; h++) {
- const d = [];
- for (let _ = 0; _ < s; _++) {
- let C = t[c];
- if (t[c].isArray() && (C = t[c].get(h, _)), C.isError())
- return C;
- const E = C.getValue();
- !E || !Q(E) ? d.push(0) : d.push(+E * o[h][_]);
- }
- o[h] = d;
- }
- }
- const u = o.reduce((c, l) => c.concat(l)).reduce((c, l) => c + l, 0);
- return y.create(u);
- } else
- return r.sum();
- }
- _initArray1(e) {
- let t = e;
- return t.isArray() || (t = q.create({
- calculateValueList: [[t]],
- rowCount: 1,
- columnCount: 1,
- unitId: "",
- sheetId: "",
- row: 0,
- column: 0
- })), t;
- }
- _getResultArrayByArray1(e, t, r) {
- const n = [];
- for (let s = 0; s < e; s++) {
- const o = [];
- for (let u = 0; u < t; u++) {
- const c = r.get(s, u);
- if (c.isError())
- return c;
- const l = c.getValue();
- !l || !Q(l) ? o.push(0) : o.push(+l);
- }
- n.push(o);
- }
- return n;
- }
- }
- class R_ extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 255);
- }
- calculate(...e) {
- let t = y.create(0);
- const r = y.create(2);
- for (let n = 0; n < e.length; n++) {
- let s = e[n];
- if (s.isString() && (s = s.convertToNumberObjectValue()), s.isError())
- return s;
- if (s.isArray() ? s.iterator((o) => {
- if (o == null || o.isString() || o.isBoolean() || o.isNull())
- return !0;
- if (o.isError())
- return t = o, !1;
- t = t.plus(
- o.pow(r)
- );
- }) : t = t.plus(s.pow(r)), t.isError())
- return t;
- }
- return t;
- }
- }
- class p_ extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- if (e.isError())
- return e;
- if (t.isError())
- return t;
- 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;
- if (s !== c)
- return g.create(m.NA);
- if (s === 1)
- return this._calculateSingleCell(e, t);
- {
- const l = e.flatten(), f = t.flatten();
- let h = ie.create();
- const d = [], _ = [];
- let C = 0;
- return l.iterator((E, b, R) => {
- const p = f.get(b, R);
- if (E == null || E.isString() || E.isBoolean() || E.isNull())
- return !0;
- if (E != null && E.isError())
- return h = E, !1;
- if (p == null || p.isString() || p.isBoolean() || p.isNull())
- return !0;
- if (p != null && p.isError())
- return h = p, !1;
- const N = +E.getValue(), M = +p.getValue();
- d.push(N), _.push(M), C += N ** 2 - M ** 2;
- }), h.isError() ? h : d.length === 0 || _.length === 0 ? g.create(m.DIV_BY_ZERO) : y.create(C);
- }
- }
- _calculateSingleCell(e, t) {
- let r = e;
- if (r.isArray() && (r = r.get(0, 0)), r.isError())
- return r;
- let n = t;
- if (n.isArray() && (n = n.get(0, 0)), n.isError())
- return n;
- if (r.isNull() || n.isNull())
- return g.create(m.VALUE);
- const s = +r.getValue(), o = +n.getValue();
- if (r.isString() && !Q(s) || r.isBoolean() || n.isString() && !Q(o) || n.isBoolean())
- return g.create(m.DIV_BY_ZERO);
- const u = s ** 2 - o ** 2;
- return y.create(u);
- }
- }
- class V_ extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- if (e.isError())
- return e;
- if (t.isError())
- return t;
- 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;
- if (s !== c)
- return g.create(m.NA);
- if (s === 1)
- return this._calculateSingleCell(e, t);
- {
- const l = e.flatten(), f = t.flatten();
- let h = ie.create();
- const d = [], _ = [];
- let C = 0;
- return l.iterator((E, b, R) => {
- const p = f.get(b, R);
- if (E == null || E.isString() || E.isBoolean() || E.isNull())
- return !0;
- if (E != null && E.isError())
- return h = E, !1;
- if (p == null || p.isString() || p.isBoolean() || p.isNull())
- return !0;
- if (p != null && p.isError())
- return h = p, !1;
- const N = +E.getValue(), M = +p.getValue();
- d.push(N), _.push(M), C += N ** 2 + M ** 2;
- }), h.isError() ? h : d.length === 0 || _.length === 0 ? g.create(m.DIV_BY_ZERO) : y.create(C);
- }
- }
- _calculateSingleCell(e, t) {
- let r = e;
- if (r.isArray() && (r = r.get(0, 0)), r.isError())
- return r;
- let n = t;
- if (n.isArray() && (n = n.get(0, 0)), n.isError())
- return n;
- if (r.isNull() || n.isNull())
- return g.create(m.VALUE);
- const s = +r.getValue(), o = +n.getValue();
- if (r.isString() && !Q(s) || r.isBoolean() || n.isString() && !Q(o) || n.isBoolean())
- return g.create(m.DIV_BY_ZERO);
- const u = s ** 2 + o ** 2;
- return y.create(u);
- }
- }
- class N_ extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- if (e.isError())
- return e;
- if (t.isError())
- return t;
- 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;
- if (s !== c)
- return g.create(m.NA);
- if (s === 1)
- return this._calculateSingleCell(e, t);
- {
- const l = e.flatten(), f = t.flatten();
- let h = ie.create();
- const d = [], _ = [];
- let C = 0;
- return l.iterator((E, b, R) => {
- const p = f.get(b, R);
- if (E == null || E.isString() || E.isBoolean() || E.isNull())
- return !0;
- if (E != null && E.isError())
- return h = E, !1;
- if (p == null || p.isString() || p.isBoolean() || p.isNull())
- return !0;
- if (p != null && p.isError())
- return h = p, !1;
- const N = +E.getValue(), M = +p.getValue();
- d.push(N), _.push(M), C += (N - M) ** 2;
- }), h.isError() ? h : d.length === 0 || _.length === 0 ? g.create(m.DIV_BY_ZERO) : y.create(C);
- }
- }
- _calculateSingleCell(e, t) {
- let r = e;
- if (r.isArray() && (r = r.get(0, 0)), r.isError())
- return r;
- let n = t;
- if (n.isArray() && (n = n.get(0, 0)), n.isError())
- return n;
- if (r.isNull() || n.isNull())
- return g.create(m.VALUE);
- const s = +r.getValue(), o = +n.getValue();
- if (r.isString() && !Q(s) || r.isBoolean() || n.isString() && !Q(o) || n.isBoolean())
- return g.create(m.DIV_BY_ZERO);
- const u = (s - o) ** 2;
- return y.create(u);
- }
- }
- class O_ extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- let t = e;
- return t.isString() && (t = t.convertToNumberObjectValue()), t.isError() ? t : t.tan();
- }
- }
- class M_ extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- let t = e;
- return t.isString() && (t = t.convertToNumberObjectValue()), t.isError() ? t : t.tanh();
- }
- }
- class w_ extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- const r = t != null ? t : y.create(0), n = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- r.isArray() ? r.getRowCount() : 1
- ), s = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- r.isArray() ? r.getColumnCount() : 1
- ), o = O(n, s, e, g.create(m.NA)), u = O(n, s, r, g.create(m.NA)), c = o.map((l, f, h) => {
- let d = u.get(f, h), _ = l;
- if (_.isString() && (_ = _.convertToNumberObjectValue()), _.isError())
- return _;
- if (d.isString() && (d = d.convertToNumberObjectValue()), d.isError())
- return d;
- const C = +_.getValue(), E = +d.getValue(), b = 10 ** Math.trunc(E), R = Bn(C, b), p = Math.trunc(Vr(C, b) + R) / b;
- return y.create(p);
- });
- return n === 1 && s === 1 ? c.get(0, 0) : c;
- }
- }
- const D_ = [
- [nC, Y.ABS],
- [sC, Y.ACOS],
- [aC, Y.ACOSH],
- [iC, Y.ACOT],
- [oC, Y.ACOTH],
- [uC, Y.ARABIC],
- [cC, Y.ASIN],
- [lC, Y.ASINH],
- [fC, Y.ATAN],
- [hC, Y.ATAN2],
- [mC, Y.ATANH],
- [gC, Y.BASE],
- [dC, Y.CEILING],
- [CC, Y.CEILING_MATH],
- [_C, Y.CEILING_PRECISE],
- [AC, Y.COMBIN],
- [EC, Y.COMBINA],
- [bC, Y.COS],
- [yC, Y.COSH],
- [RC, Y.COT],
- [pC, Y.COTH],
- [VC, Y.CSC],
- [NC, Y.CSCH],
- [OC, Y.DECIMAL],
- [MC, Y.DEGREES],
- [wC, Y.EVEN],
- [DC, Y.EXP],
- [SC, Y.FACT],
- [PC, Y.FACTDOUBLE],
- [LC, Y.FLOOR],
- [xC, Y.FLOOR_MATH],
- [jC, Y.FLOOR_PRECISE],
- [UC, Y.GCD],
- [vC, Y.INT],
- [TC, Y.LCM],
- [BC, Y.LN],
- [IC, Y.LOG],
- [FC, Y.LOG10],
- [kC, Y.MDETERM],
- [$C, Y.MINVERSE],
- [YC, Y.MMULT],
- [HC, Y.MOD],
- [GC, Y.MROUND],
- [QC, Y.MULTINOMIAL],
- [WC, Y.MUNIT],
- [qC, Y.ODD],
- [KC, Y.PI],
- [XC, Y.POWER],
- [ZC, Y.PRODUCT],
- [zC, Y.QUOTIENT],
- [JC, Y.RADIANS],
- [e_, Y.RAND],
- [t_, Y.RANDARRAY],
- [r_, Y.RANDBETWEEN],
- [n_, Y.ROMAN],
- [s_, Y.ROUND],
- [a_, Y.ROUNDBANK],
- [i_, Y.ROUNDDOWN],
- [o_, Y.ROUNDUP],
- [u_, Y.SEC],
- [c_, Y.SECH],
- [f_, Y.SERIESSUM],
- [l_, Y.SEQUENCE],
- [h_, Y.SIGN],
- [m_, Y.SIN],
- [g_, Y.SINH],
- [d_, Y.SQRT],
- [C_, Y.SQRTPI],
- [__, Y.SUBTOTAL],
- [A_, Y.SUM],
- [E_, Y.SUMIF],
- [b_, Y.SUMIFS],
- [y_, Y.SUMPRODUCT],
- [R_, Y.SUMSQ],
- [p_, Y.SUMX2MY2],
- [V_, Y.SUMX2PY2],
- [N_, Y.SUMXMY2],
- [O_, Y.TAN],
- [M_, Y.TANH],
- [w_, Y.TRUNC]
- ];
- class S_ extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 2);
- A(this, "_compareType", $.EQUALS);
- }
- setCompareType(e) {
- this._compareType = e;
- }
- calculate(e, t) {
- return e.isError() ? e : t.isError() ? t : e.compare(t, this._compareType);
- }
- }
- class Fa extends kt {
- constructor(e) {
- super("");
- A(this, "_values", []);
- this._values = e;
- }
- static create(e) {
- return new Fa(e);
- }
- isCube() {
- return !0;
- }
- dispose() {
- this._values.forEach((e) => {
- e.dispose();
- }), this._values = [];
- }
- sum() {
- const e = y.create(0);
- return this._values.forEach((t) => {
- e.plus(t.sum());
- }), e;
- }
- max() {
- let e = y.create(Number.NEGATIVE_INFINITY);
- return this._values.forEach((t) => {
- const r = t.max();
- e.isLessThan(r) && (e = r);
- }), e;
- }
- min() {
- let e = y.create(Number.POSITIVE_INFINITY);
- return this._values.forEach((t) => {
- const r = t.max();
- e.isGreaterThan(r) && (e = r);
- }), e;
- }
- count() {
- const e = y.create(0);
- return this._values.forEach((t) => {
- e.plus(t.count());
- }), e;
- }
- countA() {
- const e = y.create(0);
- return this._values.forEach((t) => {
- e.plus(t.countA());
- }), e;
- }
- countBlank() {
- const e = y.create(0);
- return this._values.forEach((t) => {
- e.plus(t.countBlank());
- }), e;
- }
- }
- class P_ extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 255);
- }
- calculate(...e) {
- const t = [];
- for (let r = 0; r < e.length; r++) {
- const n = e[r];
- if (n.isError())
- return n;
- if (!n.isArray())
- return g.create(m.VALUE);
- t.push(n);
- }
- return Fa.create(t);
- }
- }
- class L_ extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- return e.isError() ? e : t.isError() ? t : !t.isArray() && t.getValue() === 0 ? g.create(m.DIV_BY_ZERO) : e.divided(t);
- }
- }
- class x_ extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- return e.isError() ? e : t.isError() ? t : e.minus(t);
- }
- }
- class j_ extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- return e.isError() ? e : t.isError() ? t : e.multiply(t);
- }
- }
- class U_ extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- return e.isError() ? e : t.isError() ? t : e.plus(t);
- }
- }
- const v_ = [
- [S_, Te.COMPARE],
- [L_, Te.DIVIDED],
- [x_, Te.MINUS],
- [j_, Te.MULTIPLY],
- [U_, Te.PLUS],
- [P_, Te.CUBE]
- ];
- class T_ extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 255);
- }
- calculate(...e) {
- let t = y.create(0), r = y.create(0);
- for (let o = 0; o < e.length; o++) {
- let u = e[o];
- if (u.isString() && (u = u.convertToNumberObjectValue()), u.isError())
- return u;
- if (u.isArray()) {
- if (u = B_(u), u.isError())
- return u;
- if (e[o] = u, t = t.plus(u.sum()), t.isError())
- return t;
- r = r.plus(u.count());
- } else u.isNull() || (t = t.plus(u), r = r.plus(y.create(1)));
- }
- if (r.getValue() === 0)
- return g.create(m.NUM);
- const n = t.divided(r);
- if (n.isError())
- return n;
- let s = y.create(0);
- for (let o = 0; o < e.length; o++) {
- let u = e[o];
- if (u.isString() && (u = u.convertToNumberObjectValue()), u.isError())
- return u;
- if (u.isArray()) {
- if (s = s.plus(u.minus(n).abs().sum()), s.isError())
- return s;
- } else u.isNull() || (s = s.plus(u.minus(n).abs()));
- }
- return s.divided(r);
- }
- }
- function B_(i) {
- const a = [];
- a[0] = [];
- let e = null;
- return i.iterator((t, r, n) => {
- if (t != null && t.isError())
- return e = t, !1;
- t != null && t.isNumber() && a[0].push(t);
- }), e || tr(a, 1, a[0].length);
- }
- class I_ extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 255);
- }
- calculate(...e) {
- let t = y.create(0), r = y.create(0);
- for (let n = 0; n < e.length; n++) {
- let s = e[n];
- if ((s.isString() || s.isBoolean()) && (s = s.convertToNumberObjectValue()), s.isError())
- return s;
- if (s.isArray()) {
- if (t = t.plus(s.sum()), t.isError())
- return t;
- r = r.plus(s.count());
- } else s.isNull() || (t = t.plus(s), r = r.plus(y.create(1)));
- }
- return t.divided(r);
- }
- }
- class F_ extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 254);
- }
- // eslint-disable-next-line
- calculate(...e) {
- let t = !1, r;
- e.length % 2 !== 0 && (t = !0, r = g.create(m.NA));
- const n = [], s = [];
- for (let o = 0; o < e.length; o += 2) {
- const u = e[o], c = u.isArray() ? u.getRowCount() : 1, l = u.isArray() ? u.getColumnCount() : 1;
- for (let _ = 0; _ < c; _++)
- for (let C = 0; C < l; C++) {
- const E = u.isArray() ? u.get(_, C) : u;
- if (E.isError())
- return E;
- if (t)
- continue;
- const b = E.isNull() ? "" : E.getValue();
- n.push(b);
- }
- if (o + 1 >= e.length)
- continue;
- const f = e[o + 1], h = f.isArray() ? f.getRowCount() : 1, d = f.isArray() ? f.getColumnCount() : 1;
- (h !== c || d !== l) && (t = !0, r = g.create(m.VALUE));
- for (let _ = 0; _ < h; _++)
- for (let C = 0; C < d; C++) {
- const E = f.isArray() ? f.get(_, C) : f;
- if (E.isError())
- return E;
- if (t)
- continue;
- const b = E.isNull() ? "" : E.getValue();
- s.push(b);
- }
- }
- return t ? r : this._getResult(n, s);
- }
- _getResult(e, t) {
- const r = e.length;
- let n = 0, s = 0;
- for (let u = 0; u < r; u++) {
- const c = e[u], l = t[u];
- if (!(typeof c != "number" && typeof l != "number")) {
- if (typeof c != "number" || typeof l != "number" || l < 0)
- return g.create(m.VALUE);
- n += c * l, s += l;
- }
- }
- if (s === 0)
- return g.create(m.DIV_BY_ZERO);
- const o = n / s;
- return y.create(o);
- }
- }
- class k_ extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 255);
- }
- calculate(...e) {
- let t = y.create(0), r = y.create(0);
- for (let n = 0; n < e.length; n++) {
- let s = e[n];
- if ((s.isString() || s.isBoolean()) && (s = s.convertToNumberObjectValue()), s.isError())
- return s;
- if (s.isArray()) {
- if (s.iterator((o) => {
- if (o == null || o.isNull())
- return !0;
- let u = o;
- if (u.isString() && (u = u.convertToNumberObjectValue(), u.isError() && (u = y.create(0))), u.isBoolean() && (u = u.convertToNumberObjectValue()), u.isError())
- return t = u, !1;
- t = t.plus(u), r = r.plus(y.create(1));
- }), t.isError())
- return t;
- } else s.isNull() || (t = t.plus(s), r = r.plus(y.create(1)));
- }
- return t.divided(r);
- }
- }
- class $_ extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 3);
- A(this, "needsReferenceObject", !0);
- }
- calculate(e, t, r) {
- if (e.isError())
- return e;
- if (t.isError())
- return t;
- if (r != null && r.isError())
- return r;
- let n = e;
- n.isReferenceObject() && (n = n.toArrayValueObject()), n.isArray() || (n = tr([[n]], 1, 1));
- let s = t;
- return s.isReferenceObject() && (s = s.toArrayValueObject()), r && !(r != null && r.isReferenceObject()) ? g.create(m.NA) : (s = s, s.isArray() ? s.map((o) => this._handleSingleObject(n, o, r)) : this._handleSingleObject(n, s, r));
- }
- _handleSingleObject(e, t, r) {
- let n = $n(e, t);
- n = Yn(n, e, t);
- let s = r ? this._createRangeReferenceObject(r, e) : e;
- if (!s)
- return g.create(m.VALUE);
- if (s.isError())
- return s;
- s.isReferenceObject() && (s = s.toArrayValueObject()), s = s;
- const o = s.pick(n), u = o.sum(), c = o.count();
- return u.divided(c);
- }
- /**
- * Create reference object, starting from the first cell in the upper left corner, the height is rowCount and the width is columnCount
- * @param averageRange
- * @param rowCount
- * @param columnCount
- * @returns
- */
- _createRangeReferenceObject(e, t) {
- const r = e.getRowCount(), n = e.getColumnCount(), s = t.isArray() ? t.getRowCount() : 1, o = t.isArray() ? t.getColumnCount() : 1;
- if (r === s && n === o)
- return e;
- const { startRow: u, startColumn: c } = e.getRangePosition(), l = {
- startRow: u,
- startColumn: c,
- endRow: u + s - 1,
- endColumn: c + o - 1
- };
- return this.createReferenceObject(e, l);
- }
- }
- class Y_ extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 3);
- A(this, "maxParams", 255);
- }
- calculate(e, ...t) {
- if (e.isError())
- return g.create(m.NA);
- if (!e.isArray() || t.length % 2 !== 0 || t.some((u, c) => c % 2 === 0 && !u.isArray()))
- return g.create(m.VALUE);
- const { maxRowLength: r, maxColumnLength: n } = Nr(t), s = Br(t, e, r, n);
- if (s)
- return s;
- const o = Ir(t, r, n, !0);
- return this._aggregateResults(e, o);
- }
- _aggregateResults(e, t) {
- const r = t.map((s) => s.map((o) => {
- const u = e.pick(o), c = u.sum(), l = u.count();
- return c.divided(l);
- })), n = {
- calculateValueList: r,
- rowCount: r.length,
- columnCount: r[0].length,
- unitId: this.unitId || "",
- sheetId: this.subUnitId || "",
- row: this.row,
- column: this.column
- };
- return q.create(n);
- }
- }
- class H_ extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 4);
- A(this, "maxParams", 6);
- }
- calculate(e, t, r, n, s, o) {
- let u = s != null ? s : y.create(0), c = o != null ? o : y.create(1);
- u.isNull() && (u = y.create(0)), c.isNull() && (c = y.create(1));
- const l = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1,
- r.isArray() ? r.getRowCount() : 1,
- n.isArray() ? n.getRowCount() : 1,
- u.isArray() ? u.getRowCount() : 1,
- c.isArray() ? c.getRowCount() : 1
- ), f = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1,
- r.isArray() ? r.getColumnCount() : 1,
- n.isArray() ? n.getColumnCount() : 1,
- u.isArray() ? u.getColumnCount() : 1,
- c.isArray() ? c.getColumnCount() : 1
- ), h = O(l, f, e, g.create(m.NA)), d = O(l, f, t, g.create(m.NA)), _ = O(l, f, r, g.create(m.NA)), C = O(l, f, n, g.create(m.NA)), E = O(l, f, u, g.create(m.NA)), b = O(l, f, c, g.create(m.NA)), R = h.mapValue((p, N, M) => {
- const w = d.get(N, M), D = _.get(N, M), S = C.get(N, M), P = E.get(N, M), U = b.get(N, M);
- return this._handleSignleObject(p, w, D, S, P, U);
- });
- return l === 1 && f === 1 ? R.get(0, 0) : R;
- }
- _handleSignleObject(e, t, r, n, s, o) {
- if (e.isError())
- return e;
- if (t.isError())
- return t;
- if (r.isError())
- return r;
- if (n.isError())
- return n;
- if (s.isError())
- return s;
- if (o.isError())
- return o;
- const { isError: u, errorObject: c, variants: l } = I(e, t, r, n, s, o);
- if (u)
- return c;
- const [f, h, d, _, C, E] = l, b = +f.getValue(), R = +h.getValue(), p = +d.getValue(), N = +_.getValue(), M = +C.getValue(), w = +E.getValue();
- if (R <= 0 || p <= 0 || b < M || b > w || M === w)
- return g.create(m.NUM);
- let D;
- return N ? D = Do((b - M) / (w - M), R, p) : D = em((b - M) / (w - M), R, p) / (w - M), y.create(D);
- }
- }
- class G_ extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 3);
- A(this, "maxParams", 4);
- }
- calculate(e, t, r, n) {
- let s = n != null ? n : r;
- s.isNull() && (s = r);
- const o = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1,
- r.isArray() ? r.getRowCount() : 1,
- s.isArray() ? s.getRowCount() : 1
- ), u = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1,
- r.isArray() ? r.getColumnCount() : 1,
- s.isArray() ? s.getColumnCount() : 1
- ), c = O(o, u, e, g.create(m.NA)), l = O(o, u, t, g.create(m.NA)), f = O(o, u, r, g.create(m.NA)), h = O(o, u, s, g.create(m.NA)), d = c.mapValue((_, C, E) => {
- const b = l.get(C, E), R = f.get(C, E), p = h.get(C, E);
- return _.isError() ? _ : b.isError() ? b : R.isError() ? R : p.isError() ? p : this._handleSignleObject(_, b, R, p);
- });
- return o === 1 && u === 1 ? d.get(0, 0) : d;
- }
- _handleSignleObject(e, t, r, n) {
- const { isError: s, errorObject: o, variants: u } = I(e, t, r, n);
- if (s)
- return o;
- const [c, l, f, h] = u, d = Math.floor(+c.getValue()), _ = +l.getValue(), C = Math.floor(+f.getValue()), E = Math.floor(+h.getValue());
- if (d < 0 || _ < 0 || _ > 1 || C < 0 || C > d || E < 0 || E < C || E > d)
- return g.create(m.NUM);
- let b = 0;
- for (let R = C; R <= E; R++)
- b += Da(R, d, _);
- return y.create(b);
- }
- }
- class Q_ extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 3);
- A(this, "maxParams", 3);
- }
- calculate(e, t, r) {
- const n = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1,
- r.isArray() ? r.getRowCount() : 1
- ), s = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1,
- r.isArray() ? r.getColumnCount() : 1
- ), o = O(n, s, e, g.create(m.NA)), u = O(n, s, t, g.create(m.NA)), c = O(n, s, r, g.create(m.NA)), l = o.mapValue((f, h, d) => {
- const _ = u.get(h, d), C = c.get(h, d);
- return f.isError() ? f : _.isError() ? _ : C.isError() ? C : this._handleSignleObject(f, _, C);
- });
- return n === 1 && s === 1 ? l.get(0, 0) : l;
- }
- _handleSignleObject(e, t, r) {
- const { isError: n, errorObject: s, variants: o } = I(e, t, r);
- if (n)
- return s;
- const [u, c, l] = o, f = +u.getValue(), h = Math.floor(+c.getValue()), d = +l.getValue();
- if (f < 0 || h < 1 || h > 10 ** 10)
- return g.create(m.NUM);
- let _;
- return d ? _ = Sa(f, h) : _ = tm(f, h), y.create(_);
- }
- }
- class W_ extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- const r = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1
- ), n = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1
- ), s = O(r, n, e, g.create(m.NA)), o = O(r, n, t, g.create(m.NA)), u = s.mapValue((c, l, f) => {
- const h = o.get(l, f);
- return c.isError() ? c : h.isError() ? h : this._handleSignleObject(c, h);
- });
- return r === 1 && n === 1 ? u.get(0, 0) : u;
- }
- _handleSignleObject(e, t) {
- const { isError: r, errorObject: n, variants: s } = I(e, t);
- if (r)
- return n;
- const [o, u] = s, c = +o.getValue(), l = Math.floor(+u.getValue());
- if (c < 0 || c > 1 || l < 1 || l > 10 ** 10)
- return g.create(m.NUM);
- const f = Po(c, l);
- return Number.isNaN(f) || !Number.isFinite(f) ? g.create(m.NUM) : y.create(f);
- }
- }
- class q_ extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 3);
- A(this, "maxParams", 3);
- }
- calculate(e, t, r) {
- const n = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1,
- r.isArray() ? r.getRowCount() : 1
- ), s = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1,
- r.isArray() ? r.getColumnCount() : 1
- ), o = O(n, s, e, g.create(m.NA)), u = O(n, s, t, g.create(m.NA)), c = O(n, s, r, g.create(m.NA)), l = o.mapValue((f, h, d) => {
- const _ = u.get(h, d), C = c.get(h, d);
- if (f.isError())
- return f;
- if (_.isError())
- return _;
- if (C.isError())
- return C;
- const { isError: E, errorObject: b, variants: R } = I(f, _, C);
- if (E)
- return b;
- const [p, N, M] = R, w = +p.getValue(), D = +N.getValue(), S = Math.floor(+M.getValue());
- if (w <= 0 || w >= 1 || D <= 0 || S < 1)
- return g.create(m.NUM);
- if (S === 1)
- return g.create(m.DIV_BY_ZERO);
- const P = Math.abs(qn(w / 2, S - 1) * D / Math.sqrt(S));
- return y.create(P);
- });
- return n === 1 && s === 1 ? l.get(0, 0) : l;
- }
- }
- class K_ extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- 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;
- let u = e;
- if (e.isArray() && r === 1 && n === 1 && (u = e.get(0, 0)), u.isError())
- return u;
- let c = t;
- if (t.isArray() && s === 1 && o === 1 && (c = t.get(0, 0)), c.isError())
- return c;
- if (r * n === 1 || s * o === 1)
- return u.isNull() || c.isNull() ? g.create(m.VALUE) : g.create(m.DIV_BY_ZERO);
- if (r * n !== s * o)
- return g.create(m.NA);
- const {
- isError: l,
- errorObject: f,
- array1Values: h,
- array2Values: d,
- noCalculate: _
- } = Je(
- e,
- t,
- r * n,
- n,
- o
- );
- return l ? f : _ ? g.create(m.DIV_BY_ZERO) : this._getResult(h, d);
- }
- _getResult(e, t) {
- const r = e.length;
- let n = 0, s = 0;
- for (let d = 0; d < r; d++)
- n += e[d], s += t[d];
- const o = n / r, u = s / r;
- let c = 0, l = 0, f = 0;
- for (let d = 0; d < r; d++) {
- const _ = e[d] - o, C = t[d] - u;
- c += _ * C, l += _ ** 2, f += C ** 2;
- }
- const h = Math.sqrt(l * f);
- return h === 0 ? g.create(m.DIV_BY_ZERO) : y.create(c / h);
- }
- }
- class X_ extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 255);
- }
- calculate(...e) {
- let t = y.create(0);
- for (let r = 0; r < e.length; r++) {
- const n = e[r];
- n.isError() || (n.isArray() ? t = t.plus(n.count()) : n.isString() ? n.convertToNumberObjectValue().isError() || (t = t.plus(y.create(1))) : n.isNull() || (t = t.plus(y.create(1))));
- }
- return t;
- }
- }
- class Z_ extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 255);
- }
- calculate(...e) {
- let t = y.create(0);
- for (let r = 0; r < e.length; r++) {
- let n = e[r];
- if (n.isError()) {
- t = t.plus(y.create(1));
- continue;
- }
- n.isArray() ? (n = n.countA(), t = t.plus(n)) : n.isNull() || (t = t.plus(y.create(1)));
- }
- return t;
- }
- }
- class z_ extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- return e.isError() ? e : e.getValue() === "" || e.isNull() ? y.create(1) : e.isArray() ? e.countBlank() : y.create(0);
- }
- }
- class J_ extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- return e.isError() || t.isError() ? g.create(m.NA) : e.isArray() ? t.isArray() ? t.mapValue((r) => this._handleSingleObject(e, r)) : this._handleSingleObject(e, t) : g.create(m.VALUE);
- }
- _handleSingleObject(e, t) {
- let r = $n(e, t);
- r = Yn(r, e, t);
- const n = e.pick(r);
- return this._countA(n);
- }
- _countA(e) {
- let t = y.create(0);
- return e.iterator((r) => {
- if (r == null)
- return !0;
- t = t.plusBy(1);
- }), t;
- }
- }
- class eA extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 255);
- }
- calculate(...e) {
- if (e.length % 2 !== 0 || e.some((o, u) => u % 2 === 0 && !o.isArray()))
- return g.create(m.VALUE);
- const { maxRowLength: t, maxColumnLength: r } = Nr(e), n = Br(e, e[0], t, r);
- if (n)
- return n;
- const s = Ir(e, t, r, !0);
- return this._aggregateResults(s);
- }
- _aggregateResults(e) {
- const t = e.map((n) => n.map((s) => tA(s))), r = {
- calculateValueList: t,
- rowCount: t.length,
- columnCount: t[0].length,
- unitId: this.unitId || "",
- sheetId: this.subUnitId || "",
- row: this.row,
- column: this.column
- };
- return q.create(r);
- }
- }
- function tA(i) {
- let a = 0;
- return i.iterator((e) => {
- e != null && e.isBoolean() && e.getValue() === !0 && a++;
- }), y.create(a);
- }
- class rA extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- 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;
- let u = e;
- if (e.isArray() && r === 1 && n === 1 && (u = e.get(0, 0)), u.isError())
- return u;
- let c = t;
- if (t.isArray() && s === 1 && o === 1 && (c = t.get(0, 0)), c.isError())
- return c;
- if ((r * n === 1 || s * o === 1) && (u.isNull() || c.isNull()))
- return g.create(m.VALUE);
- if (r * n !== s * o)
- return g.create(m.NA);
- const {
- isError: l,
- errorObject: f,
- array1Values: h,
- array2Values: d,
- noCalculate: _
- } = Je(
- e,
- t,
- r * n,
- n,
- o
- );
- return l ? f : _ ? g.create(m.DIV_BY_ZERO) : this._getResult(h, d);
- }
- _getResult(e, t) {
- if (e.length <= 1)
- return g.create(m.DIV_BY_ZERO);
- const r = e.length;
- let n = 0, s = 0;
- for (let l = 0; l < r; l++)
- n += e[l], s += t[l];
- const o = n / r, u = s / r;
- let c = 0;
- for (let l = 0; l < r; l++) {
- const f = e[l] - o, h = t[l] - u;
- c += f * h;
- }
- return y.create(c / (r - 1));
- }
- }
- class nA extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 255);
- }
- calculate(...e) {
- const t = [];
- let r = 0, n = !0;
- for (let u = 0; u < e.length; u++) {
- const c = e[u];
- if (c.isArray()) {
- let l = !1, f = g.create(m.VALUE);
- if (c.iterator((h) => {
- const d = this._handleSingleObject(h);
- if (d.isError())
- return l = !0, f = d, !1;
- if (d.isNull())
- return !0;
- const _ = d.getValue();
- t.push(_), r += _, n = !1;
- }), l)
- return f;
- } else {
- const l = this._handleSingleObject(c);
- if (l.isError())
- return l;
- if (l.isNull())
- continue;
- const f = l.getValue();
- t.push(f), r += f, n = !1;
- }
- }
- if (n)
- return g.create(m.NUM);
- const s = r / t.length;
- let o = 0;
- for (let u = 0; u < t.length; u++)
- o += (t[u] - s) ** 2;
- return y.create(o);
- }
- _handleSingleObject(e) {
- if (e.isError())
- return e;
- if (e.isNull() || e.isBoolean())
- return ie.create();
- const t = e.getValue();
- return Q(t) ? y.create(+t) : ie.create();
- }
- }
- class sA extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 4);
- A(this, "maxParams", 4);
- }
- calculate(e, t, r, n) {
- const s = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1,
- r.isArray() ? r.getRowCount() : 1,
- n.isArray() ? n.getRowCount() : 1
- ), o = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1,
- r.isArray() ? r.getColumnCount() : 1,
- n.isArray() ? n.getColumnCount() : 1
- ), u = O(s, o, e, g.create(m.NA)), c = O(s, o, t, g.create(m.NA)), l = O(s, o, r, g.create(m.NA)), f = O(s, o, n, g.create(m.NA)), h = u.mapValue((d, _, C) => {
- const E = c.get(_, C), b = l.get(_, C), R = f.get(_, C);
- return d.isError() ? d : E.isError() ? E : b.isError() ? b : R.isError() ? R : this._handleSignleObject(d, E, b, R);
- });
- return s === 1 && o === 1 ? h.get(0, 0) : h;
- }
- _handleSignleObject(e, t, r, n) {
- const { isError: s, errorObject: o, variants: u } = I(e, t, r, n);
- if (s)
- return o;
- const [c, l, f, h] = u, d = +c.getValue(), _ = Math.floor(+l.getValue()), C = Math.floor(+f.getValue()), E = +h.getValue();
- if (d < 0 || _ < 1 || _ > 10 ** 10 || C < 1 || C > 10 ** 10)
- return g.create(m.NUM);
- let b;
- return E ? b = Pa(d, _, C) : b = rm(d, _, C), Number.isNaN(b) || !Number.isFinite(b) ? g.create(m.NUM) : y.create(b);
- }
- }
- class aA extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 3);
- A(this, "maxParams", 3);
- }
- calculate(e, t, r) {
- const n = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1,
- r.isArray() ? r.getRowCount() : 1
- ), s = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1,
- r.isArray() ? r.getColumnCount() : 1
- ), o = O(n, s, e, g.create(m.NA)), u = O(n, s, t, g.create(m.NA)), c = O(n, s, r, g.create(m.NA)), l = o.mapValue((f, h, d) => {
- const _ = u.get(h, d), C = c.get(h, d);
- return f.isError() ? f : _.isError() ? _ : C.isError() ? C : this._handleSignleObject(f, _, C);
- });
- return n === 1 && s === 1 ? l.get(0, 0) : l;
- }
- _handleSignleObject(e, t, r) {
- const { isError: n, errorObject: s, variants: o } = I(e, t, r);
- if (n)
- return s;
- const [u, c, l] = o, f = +u.getValue(), h = Math.floor(+c.getValue()), d = Math.floor(+l.getValue());
- if (f < 0 || f > 1 || h < 1 || h > 10 ** 10 || d < 1 || d > 10 ** 10)
- return g.create(m.NUM);
- const _ = Lo(f, h, d);
- return Number.isNaN(_) || !Number.isFinite(_) ? g.create(m.NUM) : y.create(_);
- }
- }
- class iA extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- return e.isArray() ? e.mapValue((t) => this._handleSingleObject(t)) : this._handleSingleObject(e);
- }
- _handleSingleObject(e) {
- const { isError: t, errorObject: r, variants: n } = I(e);
- if (t)
- return r;
- const [s] = n, o = s.getValue();
- if (o <= -1 || o >= 1)
- return g.create(m.NUM);
- const u = Math.log((1 + o) / (1 - o)) / 2;
- return y.create(u);
- }
- }
- class oA extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- return e.isArray() ? e.mapValue((t) => this._handleSingleObject(t)) : this._handleSingleObject(e);
- }
- _handleSingleObject(e) {
- const { isError: t, errorObject: r, variants: n } = I(e);
- if (t)
- return r;
- const [s] = n, o = +s.getValue(), u = Math.exp(2 * o) - 1, c = Math.exp(2 * o) + 1;
- return !Number.isFinite(u) && u > 0 && !Number.isFinite(c) && c > 0 ? y.create(1) : y.create(u / c);
- }
- }
- class Li extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 3);
- A(this, "maxParams", 3);
- }
- calculate(e, t, r) {
- 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;
- let c = t;
- t.isArray() && n === 1 && s === 1 && (c = t.get(0, 0));
- let l = r;
- return r.isArray() && o === 1 && u === 1 && (l = r.get(0, 0)), e.isArray() ? e.mapValue(
- (f) => this._handleSignleObject(f, c, l, n, s, o, u)
- ) : this._handleSignleObject(e, c, l, n, s, o, u);
- }
- _handleSignleObject(e, t, r, n, s, o, u) {
- if (e.isError())
- return e;
- if (t.isError())
- return t;
- if (r.isError())
- return r;
- let c = e;
- if (e.isString() && (c = e.convertToNumberObjectValue()), c.isError())
- return c;
- const l = +c.getValue();
- if ((n * s === 1 || o * u === 1) && (t.isNull() || r.isNull()))
- return g.create(m.VALUE);
- if (n * s !== o * u)
- return g.create(m.NA);
- const {
- isError: f,
- errorObject: h,
- array1Values: d,
- array2Values: _,
- noCalculate: C
- } = Je(
- t,
- r,
- n * s,
- s,
- u
- );
- if (f)
- return h;
- if (C)
- return g.create(m.DIV_BY_ZERO);
- const E = xo(l, d, _);
- return Number.isFinite(E) ? y.create(E) : g.create(m.DIV_BY_ZERO);
- }
- }
- class uA extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- const { isError: r, errorObject: n, values: s } = this._getValues(e);
- if (r)
- return n;
- if (e.isNull() || t.isNull())
- return g.create(m.VALUE);
- let { values: o } = this._getValues(t, !0);
- o.length === 0 && (o = [0]);
- const u = this._getNewBinsArrayValues(o), c = new Array(u.length).fill(0);
- for (let l = 0; l < s.length; l++) {
- const f = s[l], h = u.findIndex((d) => f > d.start && f <= d.end);
- c[h]++;
- }
- return q.createByArray(c.map((l) => [l]));
- }
- _getValues(e, t = !1) {
- const r = [], n = e.isArray() ? e.getRowCount() : 1, s = e.isArray() ? e.getColumnCount() : 1;
- for (let o = 0; o < n; o++)
- for (let u = 0; u < s; u++) {
- const c = e.isArray() ? e.get(o, u) : e;
- if (c.isError()) {
- if (!t)
- return {
- isError: !0,
- errorObject: c,
- values: r
- };
- continue;
- }
- if (c.isNull() || c.isBoolean())
- continue;
- const l = c.getValue();
- Q(l) && r.push(+l);
- }
- return {
- isError: !1,
- errorObject: null,
- values: r
- };
- }
- _getNewBinsArrayValues(e) {
- const t = e.map((n, s) => ({
- value: n,
- index: s
- })).sort((n, s) => n.value - s.value), r = [];
- for (let n = 0; n < t.length; n++) {
- const s = t[n].index;
- if (n === 0) {
- r[s] = {
- start: -1 / 0,
- end: t[n].value
- };
- continue;
- }
- r[s] = {
- start: t[n - 1].value,
- end: t[n].value
- };
- }
- return r.push({
- start: t[t.length - 1].value,
- end: 1 / 0
- }), r;
- }
- }
- var v = /* @__PURE__ */ ((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 || {});
- class cA extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- if (e.isArray()) {
- const t = e.mapValue((r) => this._handleSingleObject(r));
- return t.getRowCount() === 1 && t.getColumnCount() === 1 ? t.get(0, 0) : t;
- }
- return this._handleSingleObject(e);
- }
- _handleSingleObject(e) {
- const { isError: t, errorObject: r, variants: n } = I(e);
- if (t)
- return r;
- const [s] = n, o = +s.getValue();
- if (o === 0 || o < 0 && o % 1 === 0)
- return g.create(m.NUM);
- const u = on(o);
- return Number.isNaN(u) || !Number.isFinite(u) ? g.create(m.NUM) : y.create(u);
- }
- }
- class xi extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- if (e.isArray()) {
- const t = e.mapValue((r) => this._handleSingleObject(r));
- return t.getRowCount() === 1 && t.getColumnCount() === 1 ? t.get(0, 0) : t;
- }
- return this._handleSingleObject(e);
- }
- _handleSingleObject(e) {
- const { isError: t, errorObject: r, variants: n } = I(e);
- if (t)
- return r;
- const [s] = n, o = +s.getValue();
- if (o <= 0)
- return g.create(m.NUM);
- const u = ct(o);
- return Math.abs(u) < 1e-15 ? y.create(0) : y.create(u);
- }
- }
- class lA extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- if (e.isArray()) {
- const t = e.mapValue((r) => this._handleSingleObject(r));
- return t.getRowCount() === 1 && t.getColumnCount() === 1 ? t.get(0, 0) : t;
- }
- return this._handleSingleObject(e);
- }
- _handleSingleObject(e) {
- const { isError: t, errorObject: r, variants: n } = I(e);
- if (t)
- return r;
- const [s] = n, o = +s.getValue(), u = kr(o, 0, 1) - 0.5;
- return y.create(u);
- }
- }
- class fA extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 255);
- }
- calculate(...e) {
- let t = 1, r = 0, n = !1;
- for (let o = 0; o < e.length; o++) {
- const u = e[o];
- if (u.isArray()) {
- let c = !1, l = g.create(m.VALUE);
- if (u.iterator((f) => {
- if (f != null && f.isError())
- return c = !0, l = f, !1;
- if (f != null && f.isNull() || f != null && f.isBoolean())
- return !0;
- const h = f.getValue();
- if (!Q(h))
- return !0;
- +h <= 0 && (n = !0), t *= +h, r++;
- }), c)
- return l;
- } else {
- if (u.isError())
- return u;
- if (u.isString()) {
- const l = u.convertToNumberObjectValue();
- if (l.isError())
- return l;
- }
- if (u.isNull() || u.isBoolean())
- continue;
- const c = u.getValue();
- if (!Q(c))
- continue;
- +c <= 0 && (n = !0), t *= +c, r++;
- }
- }
- if (r === 0 || n)
- return g.create(m.NUM);
- const s = t ** (1 / r);
- return y.create(s);
- }
- }
- class hA extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 4);
- }
- calculate(e, t, r, n) {
- const { isError: s, errorObject: o } = Kn(e, t, r);
- if (s)
- return o;
- const u = dt(e);
- if (u instanceof g)
- return u;
- const c = this._getKnownXsValues(u, t);
- if (c instanceof g)
- return c;
- const l = this._getNewXsValues(c, r);
- if (l instanceof g)
- return l;
- let f = n != null ? n : T.create(!0);
- if (f.isArray() && (f = f.get(0, 0)), f.isString() && (f = f.convertToNumberObjectValue()), f.isError())
- return f;
- const h = +f.getValue();
- return this._getResult(u, c, l, h);
- }
- _getResult(e, t, r, n) {
- 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 ? g.create(m.NA) : this._getResultByMultipleVariables(e, t, r, n) : this._getResultBySimpleVariables(e, t, r, n);
- }
- _getResultByMultipleVariables(e, t, r, n) {
- const s = e.length === 1 && e[0].length > 1, o = zn(e, t, r, n, !0);
- if (o instanceof g)
- return o;
- const { coefficients: u, newX: c } = o, l = u[0].length, f = u[0][l - 1];
- let h = [];
- for (let d = 0; d < c.length; d++) {
- h[d] = [];
- let _ = f;
- for (let C = l - 2; C >= 0; C--)
- _ *= u[0][l - 2 - C] ** c[d][C];
- h[d].push(_);
- }
- return s && (h = mt(h)), q.createByArray(h);
- }
- _getResultBySimpleVariables(e, t, r, n) {
- const s = e.flat(), o = t.flat(), { slope: u, intercept: c } = Zn(o, s, n, !0), l = r.map((f) => f.map((h) => c * u ** h));
- return q.createByArray(l);
- }
- _getKnownXsValues(e, t) {
- return !t || t.isNull() ? Xn(e.length, e[0].length) : dt(t);
- }
- _getNewXsValues(e, t) {
- return !t || t.isNull() ? e : dt(t);
- }
- }
- class mA extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 255);
- }
- calculate(...e) {
- let t = 0, r = 0, n = !1;
- for (let o = 0; o < e.length; o++) {
- const u = e[o];
- if (u.isArray()) {
- let c = !1, l = g.create(m.VALUE);
- if (u.iterator((f) => {
- if (f != null && f.isError())
- return c = !0, l = f, !1;
- if (f != null && f.isNull() || f != null && f.isBoolean())
- return !0;
- const h = f.getValue();
- if (!Q(h))
- return !0;
- +h <= 0 && (n = !0), t += 1 / +h, r++;
- }), c)
- return l;
- } else {
- if (u.isError())
- return u;
- if (u.isString()) {
- const l = u.convertToNumberObjectValue();
- if (l.isError())
- return l;
- }
- if (u.isNull() || u.isBoolean())
- continue;
- const c = u.getValue();
- if (!Q(c))
- continue;
- +c <= 0 && (n = !0), t += 1 / +c, r++;
- }
- }
- if (r === 0)
- return g.create(m.NA);
- if (n)
- return g.create(m.NUM);
- const s = r / t;
- return y.create(s);
- }
- }
- class gA extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 5);
- A(this, "maxParams", 5);
- }
- calculate(e, t, r, n, s) {
- const o = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1,
- r.isArray() ? r.getRowCount() : 1,
- n.isArray() ? n.getRowCount() : 1,
- s.isArray() ? s.getRowCount() : 1
- ), u = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1,
- r.isArray() ? r.getColumnCount() : 1,
- n.isArray() ? n.getColumnCount() : 1,
- s.isArray() ? s.getColumnCount() : 1
- ), c = O(o, u, e, g.create(m.NA)), l = O(o, u, t, g.create(m.NA)), f = O(o, u, r, g.create(m.NA)), h = O(o, u, n, g.create(m.NA)), d = O(o, u, s, g.create(m.NA)), _ = c.mapValue((C, E, b) => {
- const R = l.get(E, b), p = f.get(E, b), N = h.get(E, b), M = d.get(E, b);
- return C.isError() ? C : R.isError() ? R : p.isError() ? p : N.isError() ? N : M.isError() ? M : this._handleSignleObject(C, R, p, N, M);
- });
- return o === 1 && u === 1 ? _.get(0, 0) : _;
- }
- _handleSignleObject(e, t, r, n, s) {
- const { isError: o, errorObject: u, variants: c } = I(e, t, r, n, s);
- if (o)
- return u;
- const [l, f, h, d, _] = c, C = Math.floor(+l.getValue()), E = Math.floor(+f.getValue()), b = Math.floor(+h.getValue()), R = Math.floor(+d.getValue()), p = +_.getValue();
- if (C < 0 || C > E || C > b || C < E - R + b || E <= 0 || E > R || b <= 0 || b > R || R <= 0)
- return g.create(m.NUM);
- let N;
- return p ? N = um(C, E, b, R) : N = xa(C, E, b, R), Number.isNaN(N) && (N = 0), y.create(N);
- }
- }
- class dA extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- 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;
- let u = e;
- if (e.isArray() && r === 1 && n === 1 && (u = e.get(0, 0)), u.isError())
- return u;
- let c = t;
- if (t.isArray() && s === 1 && o === 1 && (c = t.get(0, 0)), c.isError())
- return c;
- if (r * n === 1 || s * o === 1)
- return u.isNull() || c.isNull() ? g.create(m.VALUE) : g.create(m.DIV_BY_ZERO);
- if (r * n !== s * o)
- return g.create(m.NA);
- const {
- isError: l,
- errorObject: f,
- array1Values: h,
- array2Values: d,
- noCalculate: _
- } = Je(
- e,
- t,
- r * n,
- n,
- o
- );
- return l ? f : _ ? g.create(m.DIV_BY_ZERO) : this._getResult(h, d);
- }
- _getResult(e, t) {
- const r = xo(0, e, t);
- return Number.isFinite(r) ? y.create(r) : g.create(m.DIV_BY_ZERO);
- }
- }
- class CA extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 255);
- }
- calculate(...e) {
- const t = [];
- let r = 0;
- for (let n = 0; n < e.length; n++) {
- const s = e[n];
- if (s.isError())
- return s;
- if (s.isString()) {
- const c = s.convertToNumberObjectValue();
- if (c.isError())
- return c;
- }
- const o = s.isArray() ? s.getRowCount() : 1, u = s.isArray() ? s.getColumnCount() : 1;
- for (let c = 0; c < o; c++)
- for (let l = 0; l < u; l++) {
- const f = s.isArray() ? s.get(c, l) : s;
- if (f.isError())
- return f;
- if (f.isNull() || f.isBoolean())
- continue;
- const h = f.getValue();
- Q(h) && (t.push(+h), r += +h);
- }
- }
- return t.length <= 3 ? g.create(m.DIV_BY_ZERO) : this._getResult(t, r);
- }
- _getResult(e, t) {
- const r = e.length, n = t / r;
- let s = 0;
- for (let l = 0; l < r; l++)
- s += (e[l] - n) ** 2;
- const o = Math.sqrt(s / (r - 1));
- if (o === 0)
- return g.create(m.DIV_BY_ZERO);
- let u = 0;
- for (let l = 0; l < r; l++)
- u += ((e[l] - n) / o) ** 4;
- const c = r * (r + 1) / ((r - 1) * (r - 2) * (r - 3)) * u - 3 * (r - 1) ** 2 / ((r - 2) * (r - 3));
- return y.create(c);
- }
- }
- class _A extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- const r = this._getValues(e);
- if (t.isArray()) {
- const n = t.mapValue((s) => this._handleSingleObject(r, s));
- return n.getRowCount() === 1 && n.getColumnCount() === 1 ? n.get(0, 0) : n;
- }
- return this._handleSingleObject(r, t);
- }
- _handleSingleObject(e, t) {
- if (e instanceof g)
- return e;
- const { isError: r, errorObject: n, variants: s } = I(t);
- if (r)
- return n;
- const [o] = s;
- let u = +o.getValue();
- return u < 1 || u > e.length ? g.create(m.NUM) : (u = Math.ceil(u), y.create(e[u - 1]));
- }
- _getValues(e) {
- const t = e.isArray() ? e.getRowCount() : 1, r = e.isArray() ? e.getColumnCount() : 1, n = [];
- for (let s = 0; s < t; s++)
- for (let o = 0; o < r; o++) {
- const u = e.isArray() ? e.get(s, o) : e;
- if (u.isError())
- return u;
- if (u.isNull() || u.isBoolean() || u.isString())
- continue;
- const c = u.getValue();
- Q(c) && n.push(+c);
- }
- return n.length === 0 ? g.create(m.NUM) : n.sort((s, o) => o - s);
- }
- }
- class AA extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 4);
- }
- calculate(e, t, r, n) {
- const { isError: s, errorObject: o } = Kn(e, t);
- if (s)
- return o;
- const u = dt(e);
- if (u instanceof g)
- return u;
- const c = this._getKnownXsValues(u, t);
- if (c instanceof g)
- return c;
- let l = r != null ? r : T.create(!0);
- l.isArray() && (l = l.get(0, 0));
- let f = n != null ? n : T.create(!1);
- f.isArray() && (f = f.get(0, 0));
- const { isError: h, errorObject: d, variants: _ } = I(l, f);
- if (h)
- return d;
- const [C, E] = _;
- return this._getResult(u, c, +C.getValue(), +E.getValue());
- }
- _getResult(e, t, r, n) {
- 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 ? g.create(m.NA) : this._getResultByMultipleVariables(e, t, r, n) : this._getResultBySimpleVariables(e, t, r, n);
- }
- _getResultByMultipleVariables(e, t, r, n) {
- const s = zn(e, t, t, r, !1);
- if (s instanceof g)
- return s;
- const { coefficients: o, X: u, XTXInverse: c } = s;
- let l = [];
- if (n) {
- const f = e.flat(), h = f.length, d = r ? f.reduce((x, F) => x + F, 0) / h : 0, _ = c.length, C = h - _, E = o[0].length, b = new Array(E - 2).fill(m.NA), R = o[0][E - 1], p = [];
- for (let x = 0; x < u.length; x++) {
- let F = R;
- for (let W = E - 2; W >= 0; W--)
- F += o[0][E - 2 - W] * u[x][W];
- p.push(F);
- }
- let N = 0, M = 0;
- for (let x = 0; x < h; x++)
- N += (f[x] - d) ** 2, M += (f[x] - p[x]) ** 2;
- const w = N - M, D = N === 0 ? 0 : w / N, S = [];
- for (let x = _ - 1; x >= 0; x--) {
- const F = C > 0 ? Math.sqrt(M / C * c[x][x]) : 0;
- S.push(F);
- }
- if (r) {
- const x = S.shift();
- S.push(x);
- } else
- S.push(m.NA);
- const P = C > 0 ? Math.sqrt(M / C) : 0, U = C > 0 ? w / (E - 1) / (M / C) : m.NUM;
- l = [
- o[0],
- // [mn, mn-1, ..., m1, b]
- [...S],
- // [sen, sen-1, ..., se1, seb]
- [D, P, ...b],
- // [r2, sey]
- [U, C, ...b],
- // [F, df]
- [w, M, ...b]
- // [ssreg, ssresid]
- ];
- } else
- l = [
- o[0]
- // [mn, mn-1, ..., m1, b]
- ];
- return q.createByArray(l);
- }
- _getResultBySimpleVariables(e, t, r, n) {
- const s = e.flat(), o = t.flat(), { slope: u, intercept: c } = Zn(o, s, r, !1);
- if (Number.isNaN(u))
- return g.create(m.NA);
- let l = [];
- if (n) {
- const f = s.length;
- let h = 0, d = 0, _ = f - 1;
- if (r) {
- let S = 0, P = 0;
- for (let U = 0; U < f; U++)
- S += s[U], P += o[U];
- h = S / f, d = P / f, _ = f - 2;
- }
- let C = 0, E = 0, b = 0;
- for (let S = 0; S < f; S++)
- C += (s[S] - h) ** 2, E += (s[S] - (u * o[S] + c)) ** 2, b += (o[S] - d) ** 2;
- const R = C - E, p = R === C ? 1 : R / C;
- let N = 0, M = 0, w = 0;
- _ > 0 && (b > 0 && (N = Math.sqrt(E / _ / b), M = Math.sqrt(E / _ * (1 / f + d ** 2 / b))), w = Math.sqrt(E / _));
- const D = _ > 0 ? R / 1 / (E / _) : m.NUM;
- r || (M = m.NA), l = [
- [u, c],
- // [m, b]
- [N, M],
- // [se, seb]
- [p, w],
- // [r2, sey]
- [D, _],
- // [F, df]
- [R, E]
- // [ssreg, ssresid]
- ];
- } else
- l = [
- [u, c]
- // [m, b]
- ];
- return q.createByArray(l);
- }
- _getKnownXsValues(e, t) {
- return !t || t.isNull() ? Xn(e.length, e[0].length) : dt(t);
- }
- }
- class EA extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 4);
- }
- calculate(e, t, r, n) {
- const { isError: s, errorObject: o } = Kn(e, t);
- if (s)
- return o;
- const u = dt(e);
- if (u instanceof g)
- return u;
- const c = this._getKnownXsValues(u, t);
- if (c instanceof g)
- return c;
- let l = r != null ? r : T.create(!0);
- l.isArray() && (l = l.get(0, 0));
- let f = n != null ? n : T.create(!1);
- f.isArray() && (f = f.get(0, 0));
- const { isError: h, errorObject: d, variants: _ } = I(l, f);
- if (h)
- return d;
- const [C, E] = _;
- return this._getResult(u, c, +C.getValue(), +E.getValue());
- }
- _getResult(e, t, r, n) {
- 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 ? g.create(m.NA) : this._getResultByMultipleVariables(e, t, r, n) : this._getResultBySimpleVariables(e, t, r, n);
- }
- // eslint-disable-next-line max-lines-per-function
- _getResultByMultipleVariables(e, t, r, n) {
- const s = zn(e, t, t, r, !0);
- if (s instanceof g)
- return s;
- const { coefficients: o, Y: u, X: c, XTXInverse: l } = s;
- let f = [];
- if (n) {
- const h = u.flat(), d = h.length, _ = r ? h.reduce((F, W) => F + W, 0) / d : 0, C = l.length, E = d - C, b = o[0].length, R = new Array(b - 2).fill(m.NA), p = o[0][b - 1], N = [];
- for (let F = 0; F < c.length; F++) {
- let W = p;
- for (let ne = b - 2; ne >= 0; ne--)
- W *= o[0][b - 2 - ne] ** c[F][ne];
- N.push(Math.log(W));
- }
- let M = 0, w = 0;
- for (let F = 0; F < d; F++)
- M += (h[F] - _) ** 2, !(!r && !Number.isFinite(N[F])) && (w += (h[F] - N[F]) ** 2);
- Number.isFinite(w) || (w = 0);
- const D = M - w, S = M === 0 ? 0 : D / M, P = [];
- for (let F = C - 1; F >= 0; F--) {
- const W = E > 0 ? Math.sqrt(w / E * l[F][F]) : 0;
- P.push(W);
- }
- if (r) {
- const F = P.shift();
- P.push(F);
- } else
- P.push(m.NA);
- const U = E > 0 ? Math.sqrt(w / E) : 0, x = E > 0 ? D / (b - 1) / (w / E) : m.NUM;
- f = [
- o[0],
- // [mn, mn-1, ..., m1, b]
- [...P],
- // [sen, sen-1, ..., se1, seb]
- [S, U, ...R],
- // [r2, sey]
- [x, E, ...R],
- // [F, df]
- [D, w, ...R]
- // [ssreg, ssresid]
- ];
- } else
- f = [
- o[0]
- // [mn, mn-1, ..., m1, b]
- ];
- return q.createByArray(f);
- }
- _getResultBySimpleVariables(e, t, r, n) {
- const s = e.flat(), o = t.flat(), { slope: u, intercept: c, Y: l } = Zn(o, s, r, !0);
- if (Number.isNaN(u))
- return g.create(m.NA);
- let f = [];
- if (n) {
- const h = l.length;
- let d = 0, _ = 0, C = h - 1;
- if (r) {
- let P = 0, U = 0;
- for (let x = 0; x < h; x++)
- P += l[x], U += o[x];
- d = P / h, _ = U / h, C = h - 2;
- }
- let E = 0, b = 0, R = 0;
- for (let P = 0; P < h; P++)
- E += (l[P] - d) ** 2, b += (l[P] - Math.log(c * u ** o[P])) ** 2, R += (o[P] - _) ** 2;
- const p = E - b, N = E === 0 ? 0 : p / E;
- let M = 0, w = 0, D = 0, S = 0;
- C > 0 && (R > 0 && (M = Math.sqrt(b / C / R), w = Math.sqrt(b / C * (1 / h + _ ** 2 / R))), D = Math.sqrt(b / C), S = p / 1 / (b / C)), r || (w = m.NA), f = [
- [u, c],
- // [m, b]
- [M, w],
- // [se, seb]
- [N, D],
- // [r2, sey]
- [S, C],
- // [F, df]
- [p, b]
- // [ssreg, ssresid]
- ];
- } else
- f = [
- [u, c]
- // [m, b]
- ];
- return q.createByArray(f);
- }
- _getKnownXsValues(e, t) {
- return !t || t.isNull() ? Xn(e.length, e[0].length) : dt(t);
- }
- }
- class bA extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 4);
- A(this, "maxParams", 4);
- }
- calculate(e, t, r, n) {
- const s = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1,
- r.isArray() ? r.getRowCount() : 1,
- n.isArray() ? n.getRowCount() : 1
- ), o = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1,
- r.isArray() ? r.getColumnCount() : 1,
- n.isArray() ? n.getColumnCount() : 1
- ), u = O(s, o, e, g.create(m.NA)), c = O(s, o, t, g.create(m.NA)), l = O(s, o, r, g.create(m.NA)), f = O(s, o, n, g.create(m.NA)), h = u.mapValue((d, _, C) => {
- const E = c.get(_, C), b = l.get(_, C), R = f.get(_, C);
- return d.isError() ? d : E.isError() ? E : b.isError() ? b : R.isError() ? R : this._handleSignleObject(d, E, b, R);
- });
- return s === 1 && o === 1 ? h.get(0, 0) : h;
- }
- _handleSignleObject(e, t, r, n) {
- const { isError: s, errorObject: o, variants: u } = I(e, t, r, n);
- if (s)
- return o;
- const [c, l, f, h] = u, d = +c.getValue(), _ = +l.getValue(), C = +f.getValue(), E = +h.getValue();
- if (d <= 0 || C <= 0)
- return g.create(m.NUM);
- let b;
- return E ? b = Uo(d, _, C) : b = cm(d, _, C), y.create(b);
- }
- }
- class yA extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- const r = this._getRangeValues(e);
- if (r instanceof g)
- return r;
- const n = Xt(t);
- if (n.isError())
- return n;
- const { isError: s, errorObject: o, variants: u } = I(n);
- if (s)
- return o;
- const [c] = u, l = +c.getValue();
- if (l <= 0 || l >= 1)
- return g.create(m.NUM);
- if (r.length < 2)
- return g.create(m.DIV_BY_ZERO);
- const f = 1 - l, h = r.length, d = r.reduce((b, R) => b + R, 0) / h, _ = r.reduce((b, R) => b + (R - d) ** 2, 0) / (h - 1), C = Math.sqrt(_);
- if (C <= 0)
- return g.create(m.NUM);
- const E = Math.abs(qn(f / 2, h - 1) * C / Math.sqrt(h));
- return y.create(E);
- }
- _getRangeValues(e) {
- const t = [], r = e.isArray() ? e.getRowCount() : 1, n = e.isArray() ? e.getColumnCount() : 1;
- for (let s = 0; s < r; s++)
- for (let o = 0; o < n; o++) {
- const u = e.isArray() ? e.get(s, o) : e;
- if (u.isError())
- return u;
- u.isNull() || u.isBoolean() || u.isString() || t.push(+u.getValue());
- }
- return t;
- }
- }
- class RA extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 255);
- }
- calculate(...e) {
- let t = y.create(Number.NEGATIVE_INFINITY);
- for (let r = 0; r < e.length; r++) {
- let n = e[r];
- if (!n.isNull()) {
- if ((n.isString() || n.isBoolean()) && (n = n.convertToNumberObjectValue()), n.isArray() && (n = n.max()), n.isError())
- return n;
- t = this._validator(t, n);
- }
- }
- return t.getValue() === Number.NEGATIVE_INFINITY ? y.create(0) : t;
- }
- _validator(e, t) {
- const r = e.isLessThan(t);
- let n = e;
- return r.getValue() && (n = t), n;
- }
- }
- class pA extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 255);
- }
- calculate(...e) {
- let t = y.create(Number.NEGATIVE_INFINITY);
- for (let r = 0; r < e.length; r++) {
- let n = e[r];
- if (!n.isNull()) {
- if ((n.isString() || n.isBoolean()) && (n = n.convertToNumberObjectValue()), n.isError())
- return n;
- if (n.isArray() && n.iterator((s) => {
- let o = s;
- if ((o == null || o.isNull() || o.isString()) && (o = y.create(0)), o.isBoolean() && (o = o.convertToNumberObjectValue()), o.isError())
- return t = o, !1;
- t = this._validator(t, o);
- }), t.isError())
- return t;
- t = this._validator(t, n);
- }
- }
- return t.getValue() === Number.NEGATIVE_INFINITY ? y.create(0) : t;
- }
- _validator(e, t) {
- const r = e.isLessThan(t);
- let n = e;
- return r.getValue() && (n = t), n;
- }
- }
- class VA extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 3);
- A(this, "maxParams", 255);
- }
- calculate(e, ...t) {
- if (e.isError())
- return g.create(m.NA);
- if (!e.isArray() || t.length % 2 !== 0 || t.some((u, c) => c % 2 === 0 && !u.isArray()))
- return g.create(m.VALUE);
- const { maxRowLength: r, maxColumnLength: n } = Nr(t), s = Br(t, e, r, n);
- if (s)
- return s;
- const o = Ir(t, r, n, !0);
- return this._aggregateResults(e, o);
- }
- _aggregateResults(e, t) {
- const r = t.map((s) => s.map((o) => {
- const u = e.pick(o);
- return u.getColumnCount() === 0 ? q.create("0") : u.max();
- })), n = {
- calculateValueList: r,
- rowCount: r.length,
- columnCount: r[0].length,
- unitId: this.unitId || "",
- sheetId: this.subUnitId || "",
- row: this.row,
- column: this.column
- };
- return q.create(n);
- }
- }
- class NA extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 255);
- }
- calculate(...e) {
- const t = [];
- for (let r = 0; r < e.length; r++) {
- const n = e[r];
- if (n.isArray()) {
- let s = !1, o = g.create(m.VALUE);
- if (n.iterator((u) => {
- if (u != null && u.isError())
- return s = !0, o = u, !1;
- if (u != null && u.isNull() || u != null && u.isBoolean())
- return !0;
- const c = u.getValue();
- if (!Q(c))
- return !0;
- t.push(+c);
- }), s)
- return o;
- } else {
- if (n.isError())
- return n;
- if (n.isNull() || n.isBoolean())
- continue;
- if (n.isString()) {
- const o = n.convertToNumberObjectValue();
- if (o.isError())
- return o;
- }
- const s = n.getValue();
- if (!Q(s))
- continue;
- t.push(+s);
- }
- }
- return t.length === 0 ? g.create(m.NUM) : this._getResult(t.sort((r, n) => r - n));
- }
- _getResult(e) {
- const t = e.length;
- let r;
- if (t % 2 === 0) {
- const n = t / 2;
- r = (e[n - 1] + e[n]) / 2;
- } else
- r = e[Math.floor(t / 2)];
- return y.create(r);
- }
- }
- class OA extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 255);
- }
- calculate(...e) {
- let t = y.create(Number.POSITIVE_INFINITY);
- for (let r = 0; r < e.length; r++) {
- let n = e[r];
- if (!n.isNull()) {
- if ((n.isString() || n.isBoolean()) && (n = n.convertToNumberObjectValue()), n.isArray() && (n = n.min()), n.isError())
- return n;
- t = this._validator(t, n);
- }
- }
- return t.getValue() === Number.POSITIVE_INFINITY ? y.create(0) : t;
- }
- _validator(e, t) {
- const r = e.isGreaterThan(t);
- let n = e;
- return r.getValue() && (n = t), n;
- }
- }
- class MA extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 255);
- }
- calculate(...e) {
- let t = y.create(Number.POSITIVE_INFINITY);
- for (let r = 0; r < e.length; r++) {
- let n = e[r];
- if (!n.isNull()) {
- if ((n.isString() || n.isBoolean()) && (n = n.convertToNumberObjectValue()), n.isError())
- return n;
- if (n.isArray() && n.iterator((s) => {
- let o = s;
- if ((o == null || o.isNull() || o.isString()) && (o = y.create(0)), o.isBoolean() && (o = o.convertToNumberObjectValue()), o.isError())
- return t = o, !1;
- t = this._validator(t, o);
- }), t.isError())
- return t;
- t = this._validator(t, n);
- }
- }
- return t.getValue() === Number.POSITIVE_INFINITY ? y.create(0) : t;
- }
- _validator(e, t) {
- const r = e.isGreaterThan(t);
- let n = e;
- return r.getValue() && (n = t), n;
- }
- }
- class wA extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 3);
- A(this, "maxParams", 255);
- }
- calculate(e, ...t) {
- if (e.isError())
- return g.create(m.NA);
- if (!e.isArray() || t.length % 2 !== 0 || t.some((u, c) => c % 2 === 0 && !u.isArray()))
- return g.create(m.VALUE);
- const { maxRowLength: r, maxColumnLength: n } = Nr(t), s = Br(t, e, r, n);
- if (s)
- return s;
- const o = Ir(t, r, n, !0);
- return this._aggregateResults(e, o);
- }
- _aggregateResults(e, t) {
- const r = t.map((s) => s.map((o) => {
- const u = e.pick(o);
- return u.getColumnCount() === 0 ? q.create("0") : u.min();
- })), n = {
- calculateValueList: r,
- rowCount: r.length,
- columnCount: r[0].length,
- unitId: this.unitId || "",
- sheetId: this.subUnitId || "",
- row: this.row,
- column: this.column
- };
- return q.create(n);
- }
- }
- class DA extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 255);
- }
- calculate(...e) {
- const t = {};
- let r = 0, n = 1;
- for (let s = 0; s < e.length; s++) {
- const o = e[s];
- if (o.isError())
- return o;
- if (o.isString()) {
- const l = o.convertToNumberObjectValue();
- if (l.isError())
- return l;
- }
- const u = o.isArray() ? o.getRowCount() : 1, c = o.isArray() ? o.getColumnCount() : 1;
- for (let l = 0; l < u; l++)
- for (let f = 0; f < c; f++) {
- const h = o.isArray() ? o.get(l, f) : o;
- if (h.isError())
- return h;
- if (h.isNull() || h.isBoolean() || h.isString())
- continue;
- const d = h.getValue();
- Q(d) && (t[+d] ? (t[+d].count++, t[+d].count > n && (n = t[+d].count)) : t[+d] = { count: 1, order: r++ });
- }
- }
- return r === 0 || n === 1 ? new g(m.NA) : this._getResult(t, n);
- }
- _getResult(e, t) {
- const r = Object.entries(e).filter(([n, { count: s }]) => s === t).sort((n, s) => n[1].order - s[1].order).map(([n]) => +n);
- return r.length === 1 ? y.create(r[0]) : q.createByArray(r.map((n) => [n]));
- }
- }
- class SA extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 4);
- A(this, "maxParams", 4);
- }
- calculate(e, t, r, n) {
- const s = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1,
- r.isArray() ? r.getRowCount() : 1,
- n.isArray() ? n.getRowCount() : 1
- ), o = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1,
- r.isArray() ? r.getColumnCount() : 1,
- n.isArray() ? n.getColumnCount() : 1
- ), u = O(s, o, e, g.create(m.NA)), c = O(s, o, t, g.create(m.NA)), l = O(s, o, r, g.create(m.NA)), f = O(s, o, n, g.create(m.NA)), h = u.mapValue((d, _, C) => {
- const E = c.get(_, C), b = l.get(_, C), R = f.get(_, C);
- return d.isError() ? d : E.isError() ? E : b.isError() ? b : R.isError() ? R : this._handleSignleObject(d, E, b, R);
- });
- return s === 1 && o === 1 ? h.get(0, 0) : h;
- }
- _handleSignleObject(e, t, r, n) {
- const { isError: s, errorObject: o, variants: u } = I(e, t, r, n);
- if (s)
- return o;
- const [c, l, f, h] = u, d = Math.floor(+c.getValue()), _ = Math.floor(+l.getValue()), C = +f.getValue(), E = +h.getValue();
- if (d < 0 || _ < 1 || C <= 0 || C >= 1)
- return g.create(m.NUM);
- let b;
- return E ? b = fm(d, _, C) : b = ja(d, _, C), y.create(b);
- }
- }
- class PA extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- const r = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1
- ), n = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1
- ), s = O(r, n, e, g.create(m.NA)), o = O(r, n, t, g.create(m.NA)), u = s.mapValue((c, l, f) => {
- const h = o.get(l, f);
- return c.isError() ? c : h.isError() ? h : this._handleSignleObject(c, h);
- });
- return r === 1 && n === 1 ? u.get(0, 0) : u;
- }
- _handleSignleObject(e, t) {
- const { isError: r, errorObject: n, variants: s } = I(e, t);
- if (r)
- return n;
- const [o, u] = s, c = +o.getValue(), l = +u.getValue();
- let f;
- return l ? f = kr(c, 0, 1) : f = vo(c, 0, 1), y.create(f);
- }
- }
- class LA extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- 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;
- let u = e;
- if (e.isArray() && r === 1 && n === 1 && (u = e.get(0, 0)), u.isError())
- return u;
- let c = t;
- if (t.isArray() && s === 1 && o === 1 && (c = t.get(0, 0)), c.isError())
- return c;
- if (r * n === 1 || s * o === 1)
- return u.isNull() || c.isNull() ? g.create(m.VALUE) : g.create(m.DIV_BY_ZERO);
- if (r * n !== s * o)
- return g.create(m.NA);
- const {
- isError: l,
- errorObject: f,
- array1Values: h,
- array2Values: d,
- noCalculate: _
- } = Je(
- e,
- t,
- r * n,
- n,
- o
- );
- return l ? f : _ ? g.create(m.DIV_BY_ZERO) : this._getResult(h, d);
- }
- _getResult(e, t) {
- const r = e.length;
- let n = 0, s = 0;
- for (let d = 0; d < r; d++)
- n += e[d], s += t[d];
- const o = n / r, u = s / r;
- let c = 0, l = 0, f = 0;
- for (let d = 0; d < r; d++)
- c += (e[d] - o) * (t[d] - u), l += (e[d] - o) ** 2, f += (t[d] - u) ** 2;
- if (l === 0 || f === 0)
- return g.create(m.DIV_BY_ZERO);
- const h = c / Math.sqrt(l * f);
- return y.create(h);
- }
- }
- class xA extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- const r = this._getValues(e);
- if (t.isArray()) {
- const n = t.mapValue((s) => this._handleSingleObject(r, s));
- return n.getRowCount() === 1 && n.getColumnCount() === 1 ? n.get(0, 0) : n;
- }
- return this._handleSingleObject(r, t);
- }
- _handleSingleObject(e, t) {
- if (e instanceof g)
- return e;
- const { isError: r, errorObject: n, variants: s } = I(t);
- if (r)
- return n;
- const [o] = s, u = +o.getValue(), c = e.length;
- if (u < 1 / (c + 1) || u > 1 - 1 / (c + 1))
- return g.create(m.NUM);
- const l = u * (c + 1) - 1, f = Math.floor(l), h = l - f;
- if (h === 0)
- return y.create(e[f]);
- const d = e[f] + h * (e[f + 1] - e[f]);
- return y.create(d);
- }
- _getValues(e) {
- const t = e.isArray() ? e.getRowCount() : 1, r = e.isArray() ? e.getColumnCount() : 1, n = [];
- for (let s = 0; s < t; s++)
- for (let o = 0; o < r; o++) {
- const u = e.isArray() ? e.get(s, o) : e;
- if (u.isError())
- return u;
- if (u.isNull() || u.isBoolean() || u.isString())
- continue;
- const c = u.getValue();
- Q(c) && n.push(+c);
- }
- return n.length === 0 ? g.create(m.NUM) : n.sort((s, o) => s - o);
- }
- }
- class jA extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 3);
- }
- calculate(e, t, r) {
- const n = this._getValues(e);
- let s = r != null ? r : y.create(3);
- s.isNull() && (s = y.create(3));
- const o = Math.max(
- t.isArray() ? t.getRowCount() : 1,
- s.isArray() ? s.getRowCount() : 1
- ), u = Math.max(
- t.isArray() ? t.getColumnCount() : 1,
- s.isArray() ? s.getColumnCount() : 1
- ), c = O(o, u, t, g.create(m.NA)), l = O(o, u, s, g.create(m.NA)), f = c.mapValue((h, d, _) => {
- const C = l.get(d, _);
- return h.isError() ? h : C.isError() ? C : this._handleSingleObject(n, h, C);
- });
- return o === 1 && u === 1 ? f.get(0, 0) : f;
- }
- _handleSingleObject(e, t, r) {
- if (e instanceof g)
- return e;
- const { isError: n, errorObject: s, variants: o } = I(t, r);
- if (n)
- return s;
- const [u, c] = o, l = +u.getValue(), f = Math.floor(+c.getValue()), h = e.length;
- if (h === 0 || l < e[0] || l > e[h - 1])
- return g.create(m.NA);
- if (h === 1)
- return l === e[0] ? y.create(1) : g.create(m.NA);
- let d = 0, _ = !1, C = 0;
- for (; !_ && C < h; )
- l === e[C] ? (d = (C + 1) / (h + 1), _ = !0) : l > e[C] && C + 1 < h && l < e[C + 1] && (d = (C + 1 + (l - e[C]) / (e[C + 1] - e[C])) / (h + 1), _ = !0), C++;
- return _ ? f < 1 ? g.create(m.NUM) : (d = We(d, f), y.create(d)) : g.create(m.NA);
- }
- _getValues(e) {
- const t = e.isArray() ? e.getRowCount() : 1, r = e.isArray() ? e.getColumnCount() : 1, n = [];
- for (let s = 0; s < t; s++)
- for (let o = 0; o < r; o++) {
- const u = e.isArray() ? e.get(s, o) : e;
- if (u.isError())
- return u;
- if (u.isNull() || u.isBoolean())
- continue;
- const c = u.getValue();
- Q(c) && n.push(+c);
- }
- return n.sort((s, o) => s - o);
- }
- }
- class UA extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- const r = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1
- ), n = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1
- ), s = O(r, n, e, g.create(m.NA)), o = O(r, n, t, g.create(m.NA)), u = s.mapValue((c, l, f) => {
- const h = o.get(l, f);
- if (c.isError())
- return c;
- if (h.isError())
- return h;
- const { isError: d, errorObject: _, variants: C } = I(c, h);
- if (d)
- return _;
- const [E, b] = C, R = Math.floor(+E.getValue()), p = Math.floor(+b.getValue());
- if (R < 0 || R >= 2147483647 || p < 0 || R < p)
- return g.create(m.NUM);
- let N = 1;
- for (let M = R - p + 1; M <= R; M++)
- N *= M;
- return Number.isFinite(N) ? y.create(N) : g.create(m.NUM);
- });
- return r === 1 && n === 1 ? u.get(0, 0) : u;
- }
- }
- class vA extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- const r = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1
- ), n = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1
- ), s = O(r, n, e, g.create(m.NA)), o = O(r, n, t, g.create(m.NA)), u = s.mapValue((c, l, f) => {
- const h = o.get(l, f);
- if (c.isError())
- return c;
- if (h.isError())
- return h;
- const { isError: d, errorObject: _, variants: C } = I(c, h);
- if (d)
- return _;
- const [E, b] = C, R = Math.floor(+E.getValue()), p = Math.floor(+b.getValue());
- if (R < 0 || R >= 2147483647 || p < 0)
- return g.create(m.NUM);
- if (R === 0)
- return p === 0 ? y.create(1) : y.create(0);
- const N = R ** p;
- return Number.isFinite(N) ? y.create(N) : g.create(m.NUM);
- });
- return r === 1 && n === 1 ? u.get(0, 0) : u;
- }
- }
- class TA extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- if (e.isArray()) {
- const t = e.mapValue((r) => this._handleSingleObject(r));
- return t.getRowCount() === 1 && t.getColumnCount() === 1 ? t.get(0, 0) : t;
- }
- return this._handleSingleObject(e);
- }
- _handleSingleObject(e) {
- const { isError: t, errorObject: r, variants: n } = I(e);
- if (t)
- return r;
- const [s] = n, o = +s.getValue(), u = Math.exp(-0.5 * o * o) / Math.sqrt(2 * Math.PI);
- return y.create(u);
- }
- }
- class BA extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 3);
- A(this, "maxParams", 4);
- }
- calculate(e, t, r, n) {
- const { isError: s, errorObject: o, xRangeValues: u, probRangeValues: c } = this._handleXRangeAndProbRange(e, t);
- let l = n != null ? n : r;
- n != null && n.isNull() && (l = r);
- const f = Math.max(
- r.isArray() ? r.getRowCount() : 1,
- l.isArray() ? l.getRowCount() : 1
- ), h = Math.max(
- r.isArray() ? r.getColumnCount() : 1,
- l.isArray() ? l.getColumnCount() : 1
- ), d = O(f, h, r, g.create(m.NA)), _ = O(f, h, l, g.create(m.NA)), C = d.mapValue((E, b, R) => {
- const p = _.get(b, R);
- return e.isError() ? e : t.isError() ? t : E.isError() ? E : p.isError() ? p : s ? o : this._handleSignleObject(u, c, E, p);
- });
- return f === 1 && h === 1 ? C.get(0, 0) : C;
- }
- _handleSignleObject(e, t, r, n) {
- const { isError: s, errorObject: o, variants: u } = I(r, n);
- if (s)
- return o;
- const [c, l] = u, f = +c.getValue(), h = +l.getValue();
- if (t.reduce((_, C) => _ + C, 0) !== 1)
- return g.create(m.NUM);
- let d = 0;
- for (let _ = 0; _ < e.length; _++)
- e[_] >= f && e[_] <= h && (d += t[_]);
- return y.create(d);
- }
- // eslint-disable-next-line
- _handleXRangeAndProbRange(e, t) {
- 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;
- let u = e;
- if (e.isArray() && r === 1 && n === 1 && (u = e.get(0, 0)), u.isError())
- return {
- isError: !0,
- errorObject: u,
- xRangeValues: [],
- probRangeValues: []
- };
- let c = t;
- if (t.isArray() && s === 1 && o === 1 && (c = t.get(0, 0)), c.isError())
- return {
- isError: !0,
- errorObject: c,
- xRangeValues: [],
- probRangeValues: []
- };
- if ((r * n === 1 || s * o === 1) && (u.isNull() || c.isNull()))
- return {
- isError: !0,
- errorObject: g.create(m.VALUE),
- xRangeValues: [],
- probRangeValues: []
- };
- if (r * n !== s * o)
- return {
- isError: !0,
- errorObject: g.create(m.NA),
- xRangeValues: [],
- probRangeValues: []
- };
- const {
- isError: l,
- errorObject: f,
- array1Values: h,
- array2Values: d,
- noCalculate: _
- } = Je(
- e,
- t,
- r * n,
- n,
- o
- );
- return l ? {
- isError: !0,
- errorObject: f,
- xRangeValues: [],
- probRangeValues: []
- } : _ ? {
- isError: !0,
- errorObject: g.create(m.DIV_BY_ZERO),
- xRangeValues: [],
- probRangeValues: []
- } : {
- isError: !1,
- errorObject: null,
- xRangeValues: h,
- probRangeValues: d
- };
- }
- }
- class IA extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- const r = this._getValues(e);
- if (t.isArray()) {
- const n = t.mapValue((s) => this._handleSingleObject(r, s));
- return n.getRowCount() === 1 && n.getColumnCount() === 1 ? n.get(0, 0) : n;
- }
- return this._handleSingleObject(r, t);
- }
- _handleSingleObject(e, t) {
- if (e instanceof g)
- return e;
- const { isError: r, errorObject: n, variants: s } = I(t);
- if (r)
- return n;
- const [o] = s, u = Math.floor(+o.getValue());
- if (u <= 0 || u >= 4)
- return g.create(m.NUM);
- const c = u / 4, l = e.length;
- if (c < 1 / (l + 1) || c > 1 - 1 / (l + 1))
- return g.create(m.NUM);
- const f = c * (l + 1) - 1, h = Math.floor(f), d = f - h;
- if (d === 0)
- return y.create(e[h]);
- const _ = e[h] + d * (e[h + 1] - e[h]);
- return y.create(_);
- }
- _getValues(e) {
- const t = e.isArray() ? e.getRowCount() : 1, r = e.isArray() ? e.getColumnCount() : 1, n = [];
- for (let s = 0; s < t; s++)
- for (let o = 0; o < r; o++) {
- const u = e.isArray() ? e.get(s, o) : e;
- if (u.isError())
- return u;
- if (u.isNull() || u.isBoolean())
- continue;
- const c = u.getValue();
- Q(c) && n.push(+c);
- }
- return n.length === 0 ? g.create(m.NUM) : n.sort((s, o) => s - o);
- }
- }
- class FA extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 3);
- A(this, "needsReferenceObject", !0);
- }
- calculate(e, t, r) {
- let n = e;
- n.isReferenceObject() && (n = n.toArrayValueObject());
- const { refHasError: s, refErrorObject: o, refNumbers: u } = this._checkRefReferenceObject(t);
- let c = r != null ? r : y.create(0);
- c.isReferenceObject() && (c = c.toArrayValueObject());
- const l = Math.max(
- n.isArray() ? n.getRowCount() : 1,
- c.isArray() ? c.getRowCount() : 1
- ), f = Math.max(
- n.isArray() ? n.getColumnCount() : 1,
- c.isArray() ? c.getColumnCount() : 1
- ), h = O(l, f, n, g.create(m.NA)), d = O(l, f, c, g.create(m.NA)), _ = h.map((C, E, b) => {
- const R = d.get(E, b);
- if (!e.isReferenceObject() && e.isNull())
- return g.create(m.NA);
- if (s)
- return o;
- if (R.isError())
- return R;
- const p = +C.getValue(), N = +R.getValue();
- return Number.isNaN(p) || Number.isNaN(N) ? g.create(m.VALUE) : this._getResult(p, N, u);
- });
- return l === 1 && f === 1 ? _.get(0, 0) : _;
- }
- _getResult(e, t, r) {
- const n = r.sort((c, l) => t ? c - l : l - c);
- let s = n.indexOf(e);
- const o = [];
- for (; s >= 0; ) {
- const c = s + 1;
- o.push(c), s = n.indexOf(e, c);
- }
- if (o.length === 0)
- return g.create(m.NA);
- const u = o.reduce((c, l) => c + l, 0) / o.length;
- return y.create(u);
- }
- _checkRefReferenceObject(e) {
- let t = !1, r = g.create(m.NA);
- const n = [];
- return e.isReferenceObject() ? (e.toArrayValueObject().iterator((o) => {
- const u = o;
- if (u.isError())
- return t = !0, r = u, !1;
- if (u.isNull() || u.isBoolean())
- return !0;
- const c = +u.getValue();
- if (Number.isNaN(c))
- return !0;
- n.push(c);
- }), {
- refHasError: t,
- refErrorObject: r,
- refNumbers: n
- }) : {
- refHasError: !0,
- refErrorObject: r,
- refNumbers: n
- };
- }
- }
- class kA extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 3);
- A(this, "needsReferenceObject", !0);
- }
- calculate(e, t, r) {
- let n = e;
- n.isReferenceObject() && (n = n.toArrayValueObject());
- const { refHasError: s, refErrorObject: o, refNumbers: u } = this._checkRefReferenceObject(t);
- let c = r != null ? r : y.create(0);
- c.isReferenceObject() && (c = c.toArrayValueObject());
- const l = Math.max(
- n.isArray() ? n.getRowCount() : 1,
- c.isArray() ? c.getRowCount() : 1
- ), f = Math.max(
- n.isArray() ? n.getColumnCount() : 1,
- c.isArray() ? c.getColumnCount() : 1
- ), h = O(l, f, n, g.create(m.NA)), d = O(l, f, c, g.create(m.NA)), _ = h.map((C, E, b) => {
- const R = d.get(E, b);
- if (!e.isReferenceObject() && e.isNull())
- return g.create(m.NA);
- if (s)
- return o;
- if (R.isError())
- return R;
- const p = +C.getValue(), N = +R.getValue();
- if (Number.isNaN(p) || Number.isNaN(N))
- return g.create(m.VALUE);
- const w = u.sort((D, S) => N ? D - S : S - D).indexOf(p);
- return w === -1 ? g.create(m.NA) : y.create(w + 1);
- });
- return l === 1 && f === 1 ? _.get(0, 0) : _;
- }
- _checkRefReferenceObject(e) {
- let t = !1, r = g.create(m.NA);
- const n = [];
- return e.isReferenceObject() ? (e.toArrayValueObject().iterator((o) => {
- const u = o;
- if (u.isError())
- return t = !0, r = u, !1;
- if (u.isNull() || u.isBoolean())
- return !0;
- const c = +u.getValue();
- if (Number.isNaN(c))
- return !0;
- n.push(c);
- }), {
- refHasError: t,
- refErrorObject: r,
- refNumbers: n
- }) : {
- refHasError: !0,
- refErrorObject: r,
- refNumbers: n
- };
- }
- }
- class $A extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- 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;
- let u = e;
- if (e.isArray() && r === 1 && n === 1 && (u = e.get(0, 0)), u.isError())
- return u;
- let c = t;
- if (t.isArray() && s === 1 && o === 1 && (c = t.get(0, 0)), c.isError())
- return c;
- if ((r * n === 1 || s * o === 1) && (u.isNull() || c.isNull()))
- return g.create(m.VALUE);
- if (r * n !== s * o)
- return g.create(m.NA);
- const {
- isError: l,
- errorObject: f,
- array1Values: h,
- array2Values: d,
- noCalculate: _
- } = Je(
- e,
- t,
- r * n,
- n,
- o
- );
- return l ? f : _ ? g.create(m.DIV_BY_ZERO) : this._getResult(h, d);
- }
- _getResult(e, t) {
- if (e.length === 0)
- return g.create(m.DIV_BY_ZERO);
- const r = e.length;
- let n = 0, s = 0;
- for (let d = 0; d < r; d++)
- n += e[d], s += t[d];
- const o = n / r, u = s / r;
- let c = 0, l = 0, f = 0;
- for (let d = 0; d < r; d++)
- c += (e[d] - o) * (t[d] - u), l += (e[d] - o) ** 2, f += (t[d] - u) ** 2;
- if (l === 0 || f === 0)
- return g.create(m.DIV_BY_ZERO);
- const h = (c / Math.sqrt(l * f)) ** 2;
- return y.create(h);
- }
- }
- class YA extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 255);
- }
- calculate(...e) {
- const t = [];
- let r = 0;
- for (let n = 0; n < e.length; n++) {
- const s = e[n];
- if (s.isError())
- return s;
- if (s.isString()) {
- const c = s.convertToNumberObjectValue();
- if (c.isError())
- return c;
- }
- const o = s.isArray() ? s.getRowCount() : 1, u = s.isArray() ? s.getColumnCount() : 1;
- for (let c = 0; c < o; c++)
- for (let l = 0; l < u; l++) {
- const f = s.isArray() ? s.get(c, l) : s;
- if (f.isError())
- return f;
- if (f.isNull() || f.isBoolean())
- continue;
- const h = f.getValue();
- Q(h) && (t.push(+h), r += +h);
- }
- }
- return t.length <= 2 ? g.create(m.DIV_BY_ZERO) : this._getResult(t, r);
- }
- _getResult(e, t) {
- const r = e.length, n = t / r;
- let s = 0;
- for (let l = 0; l < r; l++)
- s += (e[l] - n) ** 2;
- const o = Math.sqrt(s / (r - 1));
- if (o === 0)
- return g.create(m.DIV_BY_ZERO);
- let u = 0;
- for (let l = 0; l < r; l++)
- u += ((e[l] - n) / o) ** 3;
- const c = r / ((r - 1) * (r - 2)) * u;
- return y.create(c);
- }
- }
- class HA extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 255);
- }
- calculate(...e) {
- const t = [];
- let r = 0;
- for (let n = 0; n < e.length; n++) {
- const s = e[n];
- if (s.isError())
- return s;
- if (s.isString()) {
- const c = s.convertToNumberObjectValue();
- if (c.isError())
- return c;
- }
- const o = s.isArray() ? s.getRowCount() : 1, u = s.isArray() ? s.getColumnCount() : 1;
- for (let c = 0; c < o; c++)
- for (let l = 0; l < u; l++) {
- const f = s.isArray() ? s.get(c, l) : s;
- if (f.isError())
- return f;
- if (f.isNull() || f.isBoolean())
- continue;
- const h = f.getValue();
- Q(h) && (t.push(+h), r += +h);
- }
- }
- return t.length <= 2 ? g.create(m.DIV_BY_ZERO) : this._getResult(t, r);
- }
- _getResult(e, t) {
- const r = e.length, n = t / r;
- let s = 0;
- for (let l = 0; l < r; l++)
- s += (e[l] - n) ** 2;
- const o = Math.sqrt(s / r);
- if (o === 0)
- return g.create(m.DIV_BY_ZERO);
- let u = 0;
- for (let l = 0; l < r; l++)
- u += ((e[l] - n) / o) ** 3;
- const c = u / r;
- return y.create(c);
- }
- }
- class GA extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- 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;
- let u = e;
- if (e.isArray() && r === 1 && n === 1 && (u = e.get(0, 0)), u.isError())
- return u;
- let c = t;
- if (t.isArray() && s === 1 && o === 1 && (c = t.get(0, 0)), c.isError())
- return c;
- if (r * n === 1 || s * o === 1)
- return u.isNull() || c.isNull() ? g.create(m.VALUE) : g.create(m.DIV_BY_ZERO);
- if (r * n !== s * o)
- return g.create(m.NA);
- const {
- isError: l,
- errorObject: f,
- array1Values: h,
- array2Values: d,
- noCalculate: _
- } = Je(
- e,
- t,
- r * n,
- n,
- o
- );
- return l ? f : _ ? g.create(m.DIV_BY_ZERO) : this._getResult(h, d);
- }
- _getResult(e, t) {
- const r = e.length;
- let n = 0, s = 0;
- for (let h = 0; h < r; h++)
- n += e[h], s += t[h];
- const o = n / r, u = s / r;
- let c = 0, l = 0;
- for (let h = 0; h < r; h++)
- c += (e[h] - o) * (t[h] - u), l += (t[h] - u) ** 2;
- if (l === 0)
- return g.create(m.DIV_BY_ZERO);
- const f = c / l;
- return y.create(f);
- }
- }
- class QA extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- const r = this._getValues(e);
- if (t.isArray()) {
- const n = t.mapValue((s) => this._handleSingleObject(r, s));
- return n.getRowCount() === 1 && n.getColumnCount() === 1 ? n.get(0, 0) : n;
- }
- return this._handleSingleObject(r, t);
- }
- _handleSingleObject(e, t) {
- if (e instanceof g)
- return e;
- const { isError: r, errorObject: n, variants: s } = I(t);
- if (r)
- return n;
- const [o] = s;
- let u = +o.getValue();
- return u < 1 || u > e.length ? g.create(m.NUM) : (u = Math.floor(u), y.create(e[u - 1]));
- }
- _getValues(e) {
- const t = e.isArray() ? e.getRowCount() : 1, r = e.isArray() ? e.getColumnCount() : 1, n = [];
- for (let s = 0; s < t; s++)
- for (let o = 0; o < r; o++) {
- const u = e.isArray() ? e.get(s, o) : e;
- if (u.isError())
- return u;
- if (u.isNull() || u.isBoolean() || u.isString())
- continue;
- const c = u.getValue();
- Q(c) && n.push(+c);
- }
- return n.length === 0 ? g.create(m.NUM) : n.sort((s, o) => s - o);
- }
- }
- class WA extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 3);
- A(this, "maxParams", 3);
- }
- calculate(e, t, r) {
- const n = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1,
- r.isArray() ? r.getRowCount() : 1
- ), s = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1,
- r.isArray() ? r.getColumnCount() : 1
- ), o = O(n, s, e, g.create(m.NA)), u = O(n, s, t, g.create(m.NA)), c = O(n, s, r, g.create(m.NA)), l = o.mapValue((f, h, d) => {
- const _ = u.get(h, d), C = c.get(h, d);
- return f.isError() ? f : _.isError() ? _ : C.isError() ? C : this._handleSignleObject(f, _, C);
- });
- return n === 1 && s === 1 ? l.get(0, 0) : l;
- }
- _handleSignleObject(e, t, r) {
- const { isError: n, errorObject: s, variants: o } = I(e, t, r);
- if (n)
- return s;
- const [u, c, l] = o, f = +u.getValue(), h = +c.getValue(), d = +l.getValue();
- if (d <= 0)
- return g.create(m.NUM);
- const _ = (f - h) / d;
- return y.create(_);
- }
- }
- class qA extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 255);
- }
- calculate(...e) {
- const t = this.flattenArray(e, !1);
- return t.isError() ? t : t.std(1);
- }
- }
- class KA extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 255);
- }
- calculate(...e) {
- const t = this.flattenArray(e, !1);
- return t.isError() ? t : t.std();
- }
- }
- class XA extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- 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;
- let u = e;
- if (e.isArray() && r === 1 && n === 1 && (u = e.get(0, 0)), u.isError())
- return u;
- let c = t;
- if (t.isArray() && s === 1 && o === 1 && (c = t.get(0, 0)), c.isError())
- return c;
- if ((r * n === 1 || s * o === 1) && (u.isNull() || c.isNull()))
- return g.create(m.VALUE);
- if (r * n !== s * o)
- return g.create(m.NA);
- const {
- isError: l,
- errorObject: f,
- array1Values: h,
- array2Values: d,
- noCalculate: _
- } = Je(
- e,
- t,
- r * n,
- n,
- o
- );
- return l ? f : _ ? g.create(m.DIV_BY_ZERO) : this._getResult(h, d);
- }
- _getResult(e, t) {
- const r = e.length;
- if (r <= 2)
- return g.create(m.DIV_BY_ZERO);
- let n = 0, s = 0;
- for (let d = 0; d < r; d++)
- n += e[d], s += t[d];
- const o = n / r, u = s / r;
- let c = 0, l = 0, f = 0;
- for (let d = 0; d < r; d++)
- c += (e[d] - o) * (t[d] - u), l += (e[d] - o) ** 2, f += (t[d] - u) ** 2;
- if (f === 0)
- return g.create(m.DIV_BY_ZERO);
- const h = Math.sqrt((l - c ** 2 / f) / (r - 2));
- return Number.isNaN(h) || !Number.isFinite(h) ? g.create(m.NUM) : y.create(h);
- }
- }
- class ZA extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 3);
- A(this, "maxParams", 3);
- }
- calculate(e, t, r) {
- const n = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1,
- r.isArray() ? r.getRowCount() : 1
- ), s = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1,
- r.isArray() ? r.getColumnCount() : 1
- ), o = O(n, s, e, g.create(m.NA)), u = O(n, s, t, g.create(m.NA)), c = O(n, s, r, g.create(m.NA)), l = o.mapValue((f, h, d) => {
- const _ = u.get(h, d), C = c.get(h, d);
- return f.isError() ? f : _.isError() ? _ : C.isError() ? C : this._handleSignleObject(f, _, C);
- });
- return n === 1 && s === 1 ? l.get(0, 0) : l;
- }
- _handleSignleObject(e, t, r) {
- const { isError: n, errorObject: s, variants: o } = I(e, t, r);
- if (n)
- return s;
- const [u, c, l] = o, f = +u.getValue(), h = Math.floor(+c.getValue()), d = +l.getValue();
- if (h < 1)
- return g.create(m.NUM);
- let _;
- return d ? _ = $r(f, h) : _ = mm(f, h), Number.isNaN(_) || !Number.isFinite(_) ? g.create(m.NUM) : y.create(_);
- }
- }
- class zA extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- const r = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1
- ), n = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1
- ), s = O(r, n, e, g.create(m.NA)), o = O(r, n, t, g.create(m.NA)), u = s.mapValue((c, l, f) => {
- const h = o.get(l, f);
- return c.isError() ? c : h.isError() ? h : this._handleSignleObject(c, h);
- });
- return r === 1 && n === 1 ? u.get(0, 0) : u;
- }
- _handleSignleObject(e, t) {
- const { isError: r, errorObject: n, variants: s } = I(e, t);
- if (r)
- return n;
- const [o, u] = s, c = +o.getValue(), l = Math.floor(+u.getValue());
- if (c < 0 || l < 1 || l > 10 ** 10)
- return g.create(m.NUM);
- const f = $r(-c, l) * 2;
- return Number.isNaN(f) || !Number.isFinite(f) ? g.create(m.NUM) : y.create(f);
- }
- }
- class JA extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- const r = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1
- ), n = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1
- ), s = O(r, n, e, g.create(m.NA)), o = O(r, n, t, g.create(m.NA)), u = s.mapValue((c, l, f) => {
- const h = o.get(l, f);
- return c.isError() ? c : h.isError() ? h : this._handleSignleObject(c, h);
- });
- return r === 1 && n === 1 ? u.get(0, 0) : u;
- }
- _handleSignleObject(e, t) {
- const { isError: r, errorObject: n, variants: s } = I(e, t);
- if (r)
- return n;
- const [o, u] = s, c = +o.getValue(), l = Math.floor(+u.getValue());
- if (l < 1 || l > 10 ** 10)
- return g.create(m.NUM);
- const f = $r(-c, l);
- return Number.isNaN(f) || !Number.isFinite(f) ? g.create(m.NUM) : y.create(f);
- }
- }
- class eE extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- const r = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1
- ), n = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1
- ), s = O(r, n, e, g.create(m.NA)), o = O(r, n, t, g.create(m.NA)), u = s.mapValue((c, l, f) => {
- const h = o.get(l, f);
- return c.isError() ? c : h.isError() ? h : this._handleSignleObject(c, h);
- });
- return r === 1 && n === 1 ? u.get(0, 0) : u;
- }
- _handleSignleObject(e, t) {
- const { isError: r, errorObject: n, variants: s } = I(e, t);
- if (r)
- return n;
- const [o, u] = s, c = +o.getValue(), l = Math.floor(+u.getValue());
- if (c <= 0 || c > 1 || l < 1 || l > 10 ** 10)
- return g.create(m.NUM);
- const f = qn(c, l);
- return Number.isNaN(f) || !Number.isFinite(f) ? g.create(m.NUM) : y.create(f);
- }
- }
- class tE extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 4);
- }
- calculate(e, t, r, n) {
- const { isError: s, errorObject: o } = Kn(e, t, r);
- if (s)
- return o;
- const u = dt(e);
- if (u instanceof g)
- return u;
- const c = this._getKnownXsValues(u, t);
- if (c instanceof g)
- return c;
- const l = this._getNewXsValues(c, r);
- if (l instanceof g)
- return l;
- let f = n != null ? n : T.create(!0);
- if (f.isArray() && (f = f.get(0, 0)), f.isString() && (f = f.convertToNumberObjectValue()), f.isError())
- return f;
- const h = +f.getValue();
- return this._getResult(u, c, l, h);
- }
- _getResult(e, t, r, n) {
- 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 ? g.create(m.NA) : this._getResultByMultipleVariables(e, t, r, n) : this._getResultBySimpleVariables(e, t, r, n);
- }
- _getResultByMultipleVariables(e, t, r, n) {
- const s = e.length === 1 && e[0].length > 1, o = zn(e, t, r, n, !1);
- if (o instanceof g)
- return o;
- const { coefficients: u, newX: c } = o, l = u[0].length, f = u[0][l - 1];
- let h = [];
- for (let d = 0; d < c.length; d++) {
- h[d] = [];
- let _ = f;
- for (let C = l - 2; C >= 0; C--)
- _ += u[0][l - 2 - C] * c[d][C];
- h[d].push(_);
- }
- return s && (h = mt(h)), q.createByArray(h);
- }
- _getResultBySimpleVariables(e, t, r, n) {
- const s = e.flat(), o = t.flat(), { slope: u, intercept: c } = Zn(o, s, n, !1);
- if (Number.isNaN(u))
- return g.create(m.NA);
- const l = r.map((f) => f.map((h) => u * h + c));
- return q.createByArray(l);
- }
- _getKnownXsValues(e, t) {
- return !t || t.isNull() ? Xn(e.length, e[0].length) : dt(t);
- }
- _getNewXsValues(e, t) {
- return !t || t.isNull() ? e : dt(t);
- }
- }
- class rE extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- const r = this._getValues(e);
- if (t.isArray()) {
- const n = t.mapValue((s) => this._handleSingleObject(r, s));
- return n.getRowCount() === 1 && n.getColumnCount() === 1 ? n.get(0, 0) : n;
- }
- return this._handleSingleObject(r, t);
- }
- _handleSingleObject(e, t) {
- if (e instanceof g)
- return e;
- const { isError: r, errorObject: n, variants: s } = I(t);
- if (r)
- return n;
- const [o] = s, u = +o.getValue();
- if (u < 0 || u >= 1)
- return g.create(m.NUM);
- const c = We(e.length * u / 2, 0) * 2, l = e.slice(c / 2, e.length - c / 2), f = l.reduce((h, d) => h + d, 0) / l.length;
- return y.create(f);
- }
- _getValues(e) {
- const t = e.isArray() ? e.getRowCount() : 1, r = e.isArray() ? e.getColumnCount() : 1, n = [];
- for (let s = 0; s < t; s++)
- for (let o = 0; o < r; o++) {
- const u = e.isArray() ? e.get(s, o) : e;
- if (u.isError())
- return u;
- if (u.isNull() || u.isBoolean())
- continue;
- const c = u.getValue();
- Q(c) && n.push(+c);
- }
- return n.length === 0 ? g.create(m.NUM) : n.sort((s, o) => s - o);
- }
- }
- class nE extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 255);
- }
- calculate(...e) {
- const t = this.flattenArray(e, !1);
- return t.isError() ? t : t.var(1);
- }
- }
- class sE extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 255);
- }
- calculate(...e) {
- const t = this.flattenArray(e, !1);
- return t.isError() ? t : t.var();
- }
- }
- const aE = [
- [T_, v.AVEDEV],
- [I_, v.AVERAGE],
- [F_, v.AVERAGE_WEIGHTED],
- [k_, v.AVERAGEA],
- [$_, v.AVERAGEIF],
- [Y_, v.AVERAGEIFS],
- [H_, v.BETA_DIST],
- [Bo, v.BETA_INV],
- [Io, v.BINOM_DIST],
- [G_, v.BINOM_DIST_RANGE],
- [Fo, v.BINOM_INV],
- [Q_, v.CHISQ_DIST],
- [ko, v.CHISQ_DIST_RT],
- [W_, v.CHISQ_INV],
- [$o, v.CHISQ_INV_RT],
- [Yo, v.CHISQ_TEST],
- [Ho, v.CONFIDENCE_NORM],
- [q_, v.CONFIDENCE_T],
- [K_, v.CORREL],
- [X_, v.COUNT],
- [Z_, v.COUNTA],
- [z_, v.COUNTBLANK],
- [J_, v.COUNTIF],
- [eA, v.COUNTIFS],
- [Go, v.COVARIANCE_P],
- [rA, v.COVARIANCE_S],
- [nA, v.DEVSQ],
- [Qo, v.EXPON_DIST],
- [sA, v.F_DIST],
- [Wo, v.F_DIST_RT],
- [aA, v.F_INV],
- [qo, v.F_INV_RT],
- [Ko, v.F_TEST],
- [iA, v.FISHER],
- [oA, v.FISHERINV],
- [Li, v.FORECAST],
- [Li, v.FORECAST_LINEAR],
- [uA, v.FREQUENCY],
- [cA, v.GAMMA],
- [Xo, v.GAMMA_DIST],
- [Zo, v.GAMMA_INV],
- [xi, v.GAMMALN],
- [xi, v.GAMMALN_PRECISE],
- [lA, v.GAUSS],
- [fA, v.GEOMEAN],
- [hA, v.GROWTH],
- [mA, v.HARMEAN],
- [gA, v.HYPGEOM_DIST],
- [dA, v.INTERCEPT],
- [CA, v.KURT],
- [_A, v.LARGE],
- [AA, v.LINEST],
- [EA, v.LOGEST],
- [bA, v.LOGNORM_DIST],
- [zo, v.LOGNORM_INV],
- [yA, v.MARGINOFERROR],
- [RA, v.MAX],
- [pA, v.MAXA],
- [VA, v.MAXIFS],
- [NA, v.MEDIAN],
- [OA, v.MIN],
- [MA, v.MINA],
- [wA, v.MINIFS],
- [DA, v.MODE_MULT],
- [Jo, v.MODE_SNGL],
- [SA, v.NEGBINOM_DIST],
- [eu, v.NORM_DIST],
- [tu, v.NORM_INV],
- [PA, v.NORM_S_DIST],
- [ru, v.NORM_S_INV],
- [LA, v.PEARSON],
- [xA, v.PERCENTILE_EXC],
- [nu, v.PERCENTILE_INC],
- [jA, v.PERCENTRANK_EXC],
- [su, v.PERCENTRANK_INC],
- [UA, v.PERMUT],
- [vA, v.PERMUTATIONA],
- [TA, v.PHI],
- [au, v.POISSON_DIST],
- [BA, v.PROB],
- [IA, v.QUARTILE_EXC],
- [iu, v.QUARTILE_INC],
- [FA, v.RANK_AVG],
- [kA, v.RANK_EQ],
- [$A, v.RSQ],
- [YA, v.SKEW],
- [HA, v.SKEW_P],
- [GA, v.SLOPE],
- [QA, v.SMALL],
- [WA, v.STANDARDIZE],
- [ou, v.STDEV_P],
- [uu, v.STDEV_S],
- [qA, v.STDEVA],
- [KA, v.STDEVPA],
- [XA, v.STEYX],
- [ZA, v.T_DIST],
- [zA, v.T_DIST_2T],
- [JA, v.T_DIST_RT],
- [eE, v.T_INV],
- [cu, v.T_INV_2T],
- [lu, v.T_TEST],
- [tE, v.TREND],
- [rE, v.TRIMMEAN],
- [fu, v.VAR_P],
- [hu, v.VAR_S],
- [nE, v.VARA],
- [sE, v.VARPA],
- [mu, v.WEIBULL_DIST],
- [gu, v.Z_TEST]
- ];
- class iE extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- let r = t != null ? t : y.create(0);
- if (t != null && t.isNull() && (r = y.create(0)), r.isArray()) {
- const n = r.mapValue((s) => this._handleSingleObject(e, s));
- return n.getRowCount() === 1 && n.getColumnCount() === 1 ? n.get(0, 0) : n;
- }
- return this._handleSingleObject(e, r);
- }
- _handleSingleObject(e, t) {
- const r = this._checkArray(e);
- if (r.isError())
- return r;
- const { isError: n, errorObject: s, variants: o } = I(t);
- if (n)
- return s;
- const [u] = o, c = +u.getValue(), l = e.isArray() ? e.getRowCount() : 1, f = e.isArray() ? e.getColumnCount() : 1;
- let h = "";
- for (let d = 0; d < l; d++)
- for (let _ = 0; _ < f; _++) {
- const C = e.isArray() ? e.get(d, _) : e;
- let E = `${C.getValue()}`;
- C.isNull() && (E = ""), C.isBoolean() && (E = E.toLocaleUpperCase()), C.isString() && c ? h += `"${E}"` : h += E, d === l - 1 && _ === f - 1 || (c ? _ === f - 1 ? h += ";" : h += "," : h += ", ");
- }
- return c && (h = `{${h}}`), h.length > 32767 ? g.create(m.CALC) : j.create(h);
- }
- _checkArray(e) {
- if (e.isArray()) {
- const t = e.getRowCount(), r = e.getColumnCount();
- return t > 1 || r > 1 ? e : e.get(0, 0);
- }
- return e;
- }
- }
- class oE extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- if (e.isArray()) {
- const t = e.mapValue((r) => this._handleSingleObject(r));
- return t.getRowCount() === 1 && t.getColumnCount() === 1 ? t.get(0, 0) : t;
- }
- return this._handleSingleObject(e);
- }
- _handleSingleObject(e) {
- if (e.isError() || e.isNull() || e.isBoolean() || e.isNumber())
- return e;
- const t = e.getValue().toLocaleString();
- let r = "";
- for (let n = 0; n < t.length; n++) {
- let s = t.charCodeAt(n);
- s === 12288 ? s = 32 : s >= 65281 && s <= 65374 && (s -= 65248), r += String.fromCharCode(s);
- }
- return j.create(r);
- }
- }
- class uE extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- if (e.isArray()) {
- const t = e.mapValue((r) => this._handleSingleObject(r));
- return t.getRowCount() === 1 && t.getColumnCount() === 1 ? t.get(0, 0) : t;
- }
- return this._handleSingleObject(e);
- }
- _handleSingleObject(e) {
- const { isError: t, errorObject: r, variants: n } = I(e);
- if (t)
- return r;
- const [s] = n, o = +s.getValue(), u = Math.abs(Number.parseInt(o.toString(), 10)), c = Number.parseFloat((Math.abs(o) - u).toFixed(2));
- let l = "";
- return u === 0 ? c !== 0 ? l = `${o < 0 ? "ลบ" : ""}${this._convertNumberToThaiText(c * 100)}สตางค์` : l = "ศูนย์บาทถ้วน" : c === 0 ? l = `${o < 0 ? "ลบ" : ""}${this._convertNumberToThaiText(u)}บาทถ้วน` : l = `${o < 0 ? "ลบ" : ""}${this._convertNumberToThaiText(u)}บาท${this._convertNumberToThaiText(c * 100)}สตางค์`, j.create(l);
- }
- _convertNumberToThaiText(e) {
- const t = ["ล้าน", "สิบ", "ร้อย", "พัน", "หมื่น", "แสน", ""], r = ["ศูนย์", "หนึ่ง", "สอง", "สาม", "สี่", "ห้า", "หก", "เจ็ด", "แปด", "เก้า"], n = ["ลบ", "บาท", "ถ้วน", "สตางค์", "ยี่", "เอ็ด", ",", " ", "฿"], s = e.toString(), o = s.length;
- let u = "";
- for (let c = o; c > 0; c--) {
- const l = Number.parseInt(s.charAt(o - c), 10);
- let f = r[l];
- const h = c > 1 ? (c - 1) % 6 : 6;
- if (h === 1 && l === 2 && (f = n[4]), l === 1)
- switch (h) {
- case 0:
- case 6:
- u += c < o ? n[5] : f;
- break;
- case 1:
- break;
- default:
- u += f;
- break;
- }
- else if (l === 0) {
- h === 0 && (u += t[h]);
- continue;
- } else
- u += f;
- u += t[h];
- }
- return u;
- }
- }
- const cE = Object.values(ve).filter((i) => [
- ve.TABLE_START,
- ve.TABLE_ROW_START,
- ve.TABLE_CELL_START,
- ve.TABLE_CELL_END,
- ve.TABLE_ROW_END,
- ve.TABLE_END,
- ve.CUSTOM_BLOCK
- ].includes(i));
- class lE extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- if (e.isArray()) {
- const t = e.mapValue((r) => this._handleSingleObject(r));
- return t.getRowCount() === 1 && t.getColumnCount() === 1 ? t.get(0, 0) : t;
- }
- return this._handleSingleObject(e);
- }
- _handleSingleObject(e) {
- const { isError: t, errorObject: r, variants: n } = I(e);
- if (t)
- return r;
- const [s] = n, o = Math.floor(+s.getValue());
- if (o <= 0)
- return g.create(m.VALUE);
- let u = String.fromCharCode(o);
- return cE.some((c) => c === u) && (u = ""), j.create(u);
- }
- }
- class fE extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- if (e.isArray()) {
- const t = e.mapValue((r) => this._handleSingleObject(r));
- return t.getRowCount() === 1 && t.getColumnCount() === 1 ? t.get(0, 0) : t;
- }
- return this._handleSingleObject(e);
- }
- _handleSingleObject(e) {
- if (e.isError() || e.isBoolean() || e.isNumber())
- return e;
- if (e.isNull())
- return j.create("");
- const r = `${e.getValue()}`.replace(/[\0-\x1F]/g, "");
- return j.create(r);
- }
- }
- class hE extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- if (e.isArray()) {
- const t = e.mapValue((r) => this._handleSingleObject(r));
- return t.getRowCount() === 1 && t.getColumnCount() === 1 ? t.get(0, 0) : t;
- }
- return this._handleSingleObject(e);
- }
- _handleSingleObject(e) {
- if (e.isError())
- return e;
- if (e.isNull())
- return g.create(m.VALUE);
- let t = e.getValue().toLocaleString();
- if (e.isBoolean() && (t = t.toLocaleUpperCase()), t === "")
- return g.create(m.VALUE);
- const r = t.charCodeAt(0);
- return y.create(r);
- }
- }
- class mE extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 255);
- }
- calculate(...e) {
- let t = "", r = null;
- for (const n of e)
- if (n.isArray()) {
- if (n.iterator((s) => {
- if (s == null || s.isNull())
- return !0;
- if (s.isError())
- return r = s, !1;
- s.isBoolean() ? t += `${s.getValue()}`.toLocaleUpperCase() : (s.isString() || s.isNumber()) && (t += s.getValue());
- }), r)
- return r;
- } else !n.isError() && !n.isNull() && (t += n.getValue());
- return j.create(t);
- }
- }
- class gE extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 255);
- }
- calculate(...e) {
- let t = 0, r = 0;
- e.forEach((s) => {
- if (s.isArray()) {
- const o = s;
- t = Math.max(t, o.getRowCount()), r = Math.max(r, o.getColumnCount());
- } else
- t = Math.max(t, 1), r = Math.max(r, 1);
- });
- let n = null;
- for (const s of e)
- n = O(t, r, s, g.create(m.NA)).mapValue((u, c, l) => {
- const f = n && n.get(c, l);
- if (f != null && f.isError())
- return f;
- if (u.isError())
- return u;
- let h = f == null ? void 0 : f.getValue(), d = u == null ? void 0 : u.getValue();
- f != null && f.isBoolean() && (h = `${h}`.toLocaleUpperCase()), u != null && u.isBoolean() && (d = `${d}`.toLocaleUpperCase());
- const _ = f != null && f.isNull() ? "" : h != null ? h : "", C = u != null && u.isNull() ? "" : d != null ? d : "";
- return j.create(`${_}${C}`);
- });
- return n || g.create(m.VALUE);
- }
- }
- class dE extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- if (e.isArray()) {
- const t = e.mapValue((r) => this._handleSingleObject(r));
- return t.getRowCount() === 1 && t.getColumnCount() === 1 ? t.get(0, 0) : t;
- }
- return this._handleSingleObject(e);
- }
- _handleSingleObject(e) {
- if (e.isError())
- return e;
- if (e.isNull())
- return j.create("");
- let t = `${e.getValue()}`;
- e.isBoolean() && (t = t.toLocaleUpperCase());
- let r = "";
- for (let n = 0; n < t.length; n++) {
- const s = t.charCodeAt(n);
- s >= 33 && s <= 126 ? r += String.fromCharCode(s + 65248) : s === 32 ? r += " " : r += t.charAt(n);
- }
- return j.create(r);
- }
- }
- class CE extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 2);
- A(this, "needsLocale", !0);
- }
- calculate(e, t) {
- let r = t != null ? t : y.create(2);
- r.isNull() && (r = y.create(2));
- const n = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- r.isArray() ? r.getRowCount() : 1
- ), s = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- r.isArray() ? r.getColumnCount() : 1
- ), o = O(n, s, e, g.create(m.NA)), u = O(n, s, r, g.create(m.NA)), c = o.mapValue((l, f, h) => {
- const d = u.get(f, h);
- return l.isError() ? l : d.isError() ? d : this._handleSingleObject(l, d);
- });
- return n === 1 && s === 1 ? c.get(0, 0) : c;
- }
- _handleSingleObject(e, t) {
- const { isError: r, errorObject: n, variants: s } = I(e, t);
- if (r)
- return n;
- const [o, u] = s;
- let c = +o.getValue(), l = Math.trunc(+u.getValue());
- if (l > 127)
- return g.create(m.VALUE);
- l < 0 && (`${c}`.length < Math.abs(l) ? c = 0 : c = c < 0 ? -vt(Math.abs(c), l) : vt(c, l), l = 0);
- const f = al(this.getLocale(), c, l);
- return j.create(f);
- }
- }
- class _E extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- const r = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1
- ), n = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1
- ), s = O(r, n, e, ie.create()), o = O(r, n, t, ie.create()), u = s.mapValue((c, l, f) => {
- const h = o.get(l, f);
- return c.isError() ? c : h.isError() ? h : this._handleSingleObject(c, h);
- });
- return r === 1 && n === 1 ? u.get(0, 0) : u;
- }
- _handleSingleObject(e, t) {
- if (e.isNull() || t.isNull()) {
- const o = e.isNull() && t.isNull();
- return T.create(o);
- }
- let r = `${e.getValue()}`;
- e.isBoolean() && (r = r.toLocaleUpperCase());
- let n = `${t.getValue()}`;
- t.isBoolean() && (n = n.toLocaleUpperCase());
- const s = r === n;
- return T.create(s);
- }
- }
- const ka = (i, a) => gt.format(i, a, { throws: !1 }), De = (i) => {
- let a = `${i.getValue()}`;
- return i.isNull() && (a = ""), i.isBoolean() && (a = a.toLocaleUpperCase()), i.isNumber() && (i.getPattern() !== "" ? a = ka(i.getPattern(), +i.getValue()) : a = `${_f(+i.getValue())}`), a;
- };
- class AE extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 3);
- }
- calculate(e, t, r) {
- const n = r != null ? r : y.create(1), s = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1,
- n.isArray() ? n.getRowCount() : 1
- ), o = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1,
- n.isArray() ? n.getColumnCount() : 1
- ), u = O(s, o, e, g.create(m.NA)), c = O(s, o, t, g.create(m.NA)), l = O(s, o, n, g.create(m.NA)), f = u.mapValue((h, d, _) => {
- const C = c.get(d, _), E = l.get(d, _);
- return h.isError() ? h : C.isError() ? C : E.isError() ? E : this._handleSingleObject(h, C, E);
- });
- return s === 1 && o === 1 ? f.get(0, 0) : f;
- }
- _handleSingleObject(e, t, r) {
- const n = De(e), s = De(t), { isError: o, errorObject: u, variants: c } = I(r);
- if (o)
- return u;
- const [l] = c, f = Math.floor(+l.getValue());
- if (t.isNull() || f <= 0 || f > s.length)
- return g.create(m.VALUE);
- if (e.isNull() || n.length === 0)
- return y.create(f);
- const h = s.indexOf(n, f - 1);
- return h === -1 ? g.create(m.VALUE) : y.create(h + 1);
- }
- }
- function $a(i) {
- let a = 0;
- for (let e = 0; e < i.length; e++)
- a += Qr(i, e);
- return a;
- }
- function Qr(i, a, e = "ltr") {
- return EE(i, a, e) > 255 ? 2 : 1;
- }
- function ji(i) {
- return i >= 55296 && i <= 56319;
- }
- function Ui(i) {
- return i >= 56320 && i <= 57343;
- }
- function vi(i, a) {
- const e = (i & 1023) << 10, t = a & 1023;
- return e + t + 65536;
- }
- function EE(i, a, e = "ltr") {
- const t = i.charCodeAt(a);
- if (e === "ltr" && ji(t) && a + 1 < i.length) {
- const r = i.charCodeAt(a + 1);
- if (Ui(r))
- return vi(t, r);
- }
- if (e === "rtl" && Ui(t) && a - 1 >= 0) {
- const r = i.charCodeAt(a - 1);
- if (ji(r))
- return vi(r, t);
- }
- return t;
- }
- class bE extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 3);
- }
- calculate(e, t, r) {
- const n = r != null ? r : y.create(1), s = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1,
- n.isArray() ? n.getRowCount() : 1
- ), o = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1,
- n.isArray() ? n.getColumnCount() : 1
- ), u = O(s, o, e, g.create(m.NA)), c = O(s, o, t, g.create(m.NA)), l = O(s, o, n, g.create(m.NA)), f = u.mapValue((h, d, _) => {
- const C = c.get(d, _), E = l.get(d, _);
- return h.isError() ? h : C.isError() ? C : E.isError() ? E : this._handleSingleObject(h, C, E);
- });
- return s === 1 && o === 1 ? f.get(0, 0) : f;
- }
- _handleSingleObject(e, t, r) {
- const n = De(e), s = De(t), { isError: o, errorObject: u, variants: c } = I(r);
- if (o)
- return u;
- const [l] = c, f = Math.floor(+l.getValue());
- if (t.isNull() || f <= 0 || f > s.length)
- return g.create(m.VALUE);
- if (e.isNull() || n.length === 0)
- return y.create(f);
- const h = s.indexOf(n, f - 1);
- if (h === -1)
- return g.create(m.VALUE);
- const d = $a(s.substring(0, h)) + 1;
- return y.create(d);
- }
- }
- class yE extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 3);
- }
- calculate(e, t, r) {
- let n = t != null ? t : y.create(2);
- n.isNull() && (n = y.create(2));
- let s = r != null ? r : T.create(!1);
- s.isNull() && (s = T.create(!1));
- const o = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- n.isArray() ? n.getRowCount() : 1,
- s.isArray() ? s.getRowCount() : 1
- ), u = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- n.isArray() ? n.getColumnCount() : 1,
- s.isArray() ? s.getColumnCount() : 1
- ), c = O(o, u, e, g.create(m.NA)), l = O(o, u, n, g.create(m.NA)), f = O(o, u, s, g.create(m.NA)), h = c.mapValue((d, _, C) => {
- const E = l.get(_, C), b = f.get(_, C);
- return d.isError() ? d : E.isError() ? E : b.isError() ? b : this._handleSingleObject(d, E, b);
- });
- return o === 1 && u === 1 ? h.get(0, 0) : h;
- }
- _handleSingleObject(e, t, r) {
- const { isError: n, errorObject: s, variants: o } = I(e, t, r);
- if (n)
- return s;
- const [u, c, l] = o;
- let f = +u.getValue(), h = Math.trunc(+c.getValue());
- const d = +l.getValue();
- if (h > 127)
- return g.create(m.VALUE);
- h < 0 && (`${f}`.length < Math.abs(h) ? f = 0 : f = f < 0 ? -vt(Math.abs(f), h) : vt(f, h), h = 0);
- let _ = d ? "###0" : "#,##0";
- h > 0 && (_ += `.${"0".repeat(h)}`);
- const C = ka(_, f);
- return j.create(C);
- }
- }
- class RE extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- const r = t != null ? t : y.create(1), n = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- r.isArray() ? r.getRowCount() : 1
- ), s = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- r.isArray() ? r.getColumnCount() : 1
- ), o = O(n, s, e, g.create(m.NA)), u = O(n, s, r, g.create(m.NA)), c = o.mapValue((l, f, h) => {
- const d = u.get(f, h);
- return l.isError() ? l : d.isError() ? d : this._handleSingleObject(l, d);
- });
- return n === 1 && s === 1 ? c.get(0, 0) : c;
- }
- _handleSingleObject(e, t) {
- const r = De(e), { isError: n, errorObject: s, variants: o } = I(t);
- if (n)
- return s;
- const [u] = o, c = Math.floor(+u.getValue());
- if (c < 0)
- return g.create(m.VALUE);
- if (e.isNull() || c === 0)
- return j.create("");
- if (c >= r.length)
- return j.create(r);
- const l = r.substring(0, c);
- return j.create(l);
- }
- }
- class pE extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- const r = t != null ? t : y.create(1), n = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- r.isArray() ? r.getRowCount() : 1
- ), s = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- r.isArray() ? r.getColumnCount() : 1
- ), o = O(n, s, e, ie.create()), u = O(n, s, r, ie.create()), c = o.mapValue((l, f, h) => {
- const d = u.get(f, h);
- return l.isError() ? l : d.isError() ? d : this._handleSingleObject(l, d);
- });
- return n === 1 && s === 1 ? c.get(0, 0) : c;
- }
- _handleSingleObject(e, t) {
- const r = De(e), { isError: n, errorObject: s, variants: o } = I(t);
- if (n)
- return s;
- const [u] = o, c = Math.floor(+u.getValue());
- if (c < 0)
- return g.create(m.VALUE);
- if (e.isNull() || c === 0)
- return j.create("");
- let l = 0, f = 0, h = "";
- for (; f < c && l < r.length; )
- f += Qr(r, l), h += r.charAt(l), l++;
- return j.create(h);
- }
- }
- class VE extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- if (e.isArray()) {
- const t = e.mapValue((r) => this._handleSingleText(r));
- return t.getRowCount() === 1 && t.getColumnCount() === 1 ? t.get(0, 0) : t;
- }
- return this._handleSingleText(e);
- }
- _handleSingleText(e) {
- if (e.isError())
- return e;
- const t = De(e);
- return y.create(t.length);
- }
- }
- class NE extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- if (e.isArray()) {
- const t = e.mapValue((r) => this._handleSingleText(r));
- return t.getRowCount() === 1 && t.getColumnCount() === 1 ? t.get(0, 0) : t;
- }
- return this._handleSingleText(e);
- }
- _handleSingleText(e) {
- if (e.isError())
- return e;
- const t = De(e), r = $a(t);
- return y.create(r);
- }
- }
- class OE extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- if (e.isArray()) {
- const t = e.mapValue((r) => this._handleSingleObject(r));
- return t.getRowCount() === 1 && t.getColumnCount() === 1 ? t.get(0, 0) : t;
- }
- return this._handleSingleObject(e);
- }
- _handleSingleObject(e) {
- if (e.isError())
- return e;
- if (e.isNull())
- return j.create("");
- const t = `${e.getValue()}`.toLocaleLowerCase();
- return j.create(t);
- }
- }
- class ME extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 3);
- A(this, "maxParams", 3);
- }
- calculate(e, t, r) {
- const n = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1,
- r.isArray() ? r.getRowCount() : 1
- ), s = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1,
- r.isArray() ? r.getColumnCount() : 1
- ), o = O(n, s, e, g.create(m.NA)), u = O(n, s, t, g.create(m.NA)), c = O(n, s, r, g.create(m.NA)), l = o.mapValue((f, h, d) => {
- const _ = u.get(h, d), C = c.get(h, d);
- return f.isError() ? f : _.isError() ? _ : C.isError() ? C : this._handleSingleObject(f, _, C);
- });
- return n === 1 && s === 1 ? l.get(0, 0) : l;
- }
- _handleSingleObject(e, t, r) {
- const n = De(e), { isError: s, errorObject: o, variants: u } = I(t, r);
- if (s)
- return o;
- const [c, l] = u, f = Math.floor(+c.getValue()), h = Math.floor(+l.getValue());
- if (f <= 0 || h < 0)
- return g.create(m.VALUE);
- if (e.isNull() || f > n.length || h === 0)
- return j.create("");
- const d = n.substring(f - 1, f - 1 + h);
- return j.create(d);
- }
- }
- class wE extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 3);
- A(this, "maxParams", 3);
- }
- calculate(e, t, r) {
- const n = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1,
- r.isArray() ? r.getRowCount() : 1
- ), s = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1,
- r.isArray() ? r.getColumnCount() : 1
- ), o = O(n, s, e, g.create(m.NA)), u = O(n, s, t, g.create(m.NA)), c = O(n, s, r, g.create(m.NA)), l = o.mapValue((f, h, d) => {
- const _ = u.get(h, d), C = c.get(h, d);
- return f.isError() ? f : _.isError() ? _ : C.isError() ? C : this._handleSingleObject(f, _, C);
- });
- return n === 1 && s === 1 ? l.get(0, 0) : l;
- }
- _handleSingleObject(e, t, r) {
- let n = De(e);
- const { isError: s, errorObject: o, variants: u } = I(t, r);
- if (s)
- return o;
- const [c, l] = u, f = Math.floor(+c.getValue()), h = Math.floor(+l.getValue());
- if (f <= 0 || h < 0)
- return g.create(m.VALUE);
- if (e.isNull() || f > n.length || h === 0)
- return j.create("");
- n = n.substring(f - 1);
- let d = 0, _ = 0, C = "";
- for (; _ < h && d < n.length; )
- _ += Qr(n, d), C += n.charAt(d), d++;
- return j.create(C);
- }
- }
- class DE extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 3);
- }
- calculate(e, t, r) {
- const n = t != null ? t : j.create("."), s = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- n.isArray() ? n.getRowCount() : 1,
- r != null && r.isArray() ? r.getRowCount() : 1
- ), o = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- n.isArray() ? n.getColumnCount() : 1,
- r != null && r.isArray() ? r.getColumnCount() : 1
- ), u = O(s, o, e, g.create(m.NA)), c = O(s, o, n, g.create(m.NA)), l = r ? O(s, o, r, g.create(m.NA)) : void 0, f = u.mapValue((h, d, _) => {
- const C = c.get(d, _), E = r ? l.get(d, _) : void 0;
- return h.isError() ? h : C.isError() ? C : E != null && E.isError() ? E : C.isNull() || E != null && E.isNull() ? g.create(m.VALUE) : h.isNull() ? y.create(0) : this._handleSingleObject(h, C, E);
- });
- return s === 1 && o === 1 ? f.get(0, 0) : f;
- }
- // eslint-disable-next-line
- _handleSingleObject(e, t, r) {
- let n = `${e.getValue()}`;
- n = n.replace(/\s+/g, "");
- let s = `${t.getValue()}`;
- t.isBoolean() && (s = s.toLocaleUpperCase()), s = s.charAt(0);
- let o;
- if (r && (o = `${r.getValue()}`, r.isBoolean() && (o = o.toLocaleUpperCase()), o = o.charAt(0), s === o))
- return g.create(m.VALUE);
- if (n.trim() === "")
- return y.create(0);
- if (!n.match(/^\s*[+-]?\s*(?:(?:\d+(?:\.\d*)?)|(?:\.\d+))(?:[eE][+-]?\d+)?[ \t]*/))
- return g.create(m.VALUE);
- const u = n.split(s);
- if (u.length > 2)
- return g.create(m.VALUE);
- let c = u[0].replace(/,/g, "");
- r && (c = c.split(o).join(""));
- let l = 0;
- if (u.length === 1) {
- s === "," && (c = c.replace(/\./g, ""));
- let f = 0;
- for (; c.endsWith("%"); )
- c = c.slice(0, -1), f++;
- f > 0 ? l = +c / 100 ** f : l = +c;
- } else {
- if (!Q(c))
- return g.create(m.VALUE);
- let f = u[1], h = 0;
- for (; f.endsWith("%"); )
- f = f.slice(0, -1), h++;
- const d = `${c}.${f}`;
- if (!Q(d))
- return g.create(m.VALUE);
- h > 0 ? l = +d / 100 ** h : l = +d;
- }
- return Number.isNaN(l) ? g.create(m.VALUE) : y.create(l);
- }
- }
- class SE extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- if (e.isArray()) {
- const t = e.mapValue((r) => this._handleSingleObject(r));
- return t.getRowCount() === 1 && t.getColumnCount() === 1 ? t.get(0, 0) : t;
- }
- return this._handleSingleObject(e);
- }
- _handleSingleObject(e) {
- if (e.isError() || e.isNull() || e.isBoolean() || e.isNumber())
- return e;
- const r = e.getValue().toLocaleString().toLocaleLowerCase().replace(/(^|\b|\W|\d|_)[a-z]/g, (n) => n.toLocaleUpperCase());
- return j.create(r);
- }
- }
- const Nu = () => [
- {
- type: 4,
- from: 48,
- to: 57
- }
- ], Ou = () => [
- {
- type: 7,
- value: 95
- },
- {
- type: 4,
- from: 97,
- to: 122
- },
- {
- type: 4,
- from: 65,
- to: 90
- },
- {
- type: 4,
- from: 48,
- to: 57
- }
- ], Mu = () => [
- {
- type: 7,
- value: 9
- },
- {
- type: 7,
- value: 10
- },
- {
- type: 7,
- value: 11
- },
- {
- type: 7,
- value: 12
- },
- {
- type: 7,
- value: 13
- },
- {
- type: 7,
- value: 32
- },
- {
- type: 7,
- value: 160
- },
- {
- type: 7,
- value: 5760
- },
- {
- type: 4,
- from: 8192,
- to: 8202
- },
- {
- type: 7,
- value: 8232
- },
- {
- type: 7,
- value: 8233
- },
- {
- type: 7,
- value: 8239
- },
- {
- type: 7,
- value: 8287
- },
- {
- type: 7,
- value: 12288
- },
- {
- type: 7,
- value: 65279
- }
- ], wu = () => ({
- type: 3,
- set: Ou(),
- not: !1
- }), Du = () => ({
- type: 3,
- set: Ou(),
- not: !0
- }), Su = () => ({
- type: 3,
- set: Nu(),
- not: !1
- }), Pu = () => ({
- type: 3,
- set: Nu(),
- not: !0
- }), Lu = () => ({
- type: 3,
- set: Mu(),
- not: !1
- }), xu = () => ({
- type: 3,
- set: Mu(),
- not: !0
- }), PE = () => ({
- type: 3,
- set: [
- {
- type: 7,
- value: 10
- },
- {
- type: 7,
- value: 13
- },
- {
- type: 7,
- value: 8232
- },
- {
- type: 7,
- value: 8233
- }
- ],
- not: !0
- });
- function LE(i) {
- const a = {
- type: 0,
- stack: []
- };
- let e = a, t = a.stack;
- const r = [], n = [];
- let s = 0;
- const o = (f) => {
- throw new SyntaxError(`Invalid regular expression: /${i}/: Nothing to repeat at column ${f - 1}`);
- }, u = jE(i);
- let c = 0, l;
- for (; c < u.length; )
- switch (l = u[c++], l) {
- case "\\":
- if (c === u.length)
- throw new SyntaxError(`Invalid regular expression: /${i}/: \\ at end of pattern`);
- switch (l = u[c++], l) {
- case "b":
- t.push({
- type: 2,
- value: "b"
- });
- break;
- case "B":
- t.push({
- type: 2,
- value: "B"
- });
- break;
- case "w":
- t.push(wu());
- break;
- case "W":
- t.push(Du());
- break;
- case "d":
- t.push(Su());
- break;
- case "D":
- t.push(Pu());
- break;
- case "s":
- t.push(Lu());
- break;
- case "S":
- t.push(xu());
- break;
- default:
- if (/\d/.test(l)) {
- for (; /\d/.test(u[c]) && c < u.length; )
- l += u[c++];
- const f = Number.parseInt(l, 10);
- t.push({
- type: 6,
- value: f
- }), n.push({
- reference: {
- type: 6,
- value: f
- },
- stack: t,
- index: t.length - 1
- });
- } else
- t.push({
- type: 7,
- value: l.charCodeAt(0)
- });
- }
- break;
- case "^":
- t.push({
- type: 2,
- value: "^"
- });
- break;
- case "$":
- t.push({
- type: 2,
- value: "$"
- });
- break;
- case "[": {
- const f = u[c] === "^";
- f && c++;
- const h = xE(u.slice(c), i);
- c += h[1], t.push({
- type: 3,
- set: h[0],
- not: f
- });
- break;
- }
- case ".":
- t.push(PE());
- break;
- case "(": {
- const f = {
- type: 1,
- stack: [],
- remember: !0
- // 默认情况下,捕获组是需要记住(捕获)的
- };
- if (u[c] === "?") {
- const h = u[c + 1];
- if (c += 2, h === "=")
- f.followedBy = !0;
- else if (h === "!")
- f.notFollowedBy = !0;
- else if (h !== ":")
- throw new SyntaxError(`Invalid regular expression: /${i}/: Invalid group, character '${h}' after '?' at column ${c - 1}`);
- f.remember = !1;
- } else
- s += 1;
- t.push(f), r.push(e), e = f, t = f.stack;
- break;
- }
- case ")":
- if (r.length === 0)
- throw new SyntaxError(`Invalid regular expression: /${i}/: Unmatched ) at column ${c - 1}`);
- e = r.pop(), t = e.options ? e.options[e.options.length - 1] : e.stack;
- break;
- case "|": {
- e.options || (e.options = [e.stack], delete e.stack);
- const f = [];
- e.options.push(f), t = f;
- break;
- }
- case "{": {
- const f = /^(\d+)(,(\d+)?)?\}/.exec(u.slice(c));
- if (f) {
- t.length === 0 && o(c);
- const h = Number.parseInt(f[1], 10), d = f[2] ? f[3] ? Number.parseInt(f[3], 10) : 1 / 0 : h;
- c += f[0].length, t.push({
- type: 5,
- min: h,
- max: d,
- value: t.pop()
- });
- } else
- t.push({
- // Assuming 123 is the character code for '{'
- type: 7,
- value: 123
- });
- break;
- }
- case "?":
- t.length === 0 && o(c), t.push({
- type: 5,
- min: 0,
- max: 1,
- value: t.pop()
- });
- break;
- case "+":
- t.length === 0 && o(c), t.push({
- type: 5,
- min: 1,
- max: 1 / 0,
- value: t.pop()
- });
- break;
- case "*":
- t.length === 0 && o(c), t.push({
- type: 5,
- min: 0,
- max: 1 / 0,
- value: t.pop()
- });
- break;
- default:
- t.push({
- type: 7,
- value: l.charCodeAt(0)
- });
- }
- if (r.length > 0)
- throw new SyntaxError(`Invalid regular expression: /${i}/: Unterminated group`);
- return UE(n, s), a;
- }
- function xE(i, a) {
- let e;
- const t = [], r = /\\(?:(w)|(d)|(s)|(W)|(D)|(S))|((?:(?:\\)(.)|([^\]\\]))-(((?:\\)])|(((?:\\)?([^\]])))))|(\])|(?:\\)?([^])/g;
- for (; (e = r.exec(i)) !== null; ) {
- let n = null;
- const [, s, o, u, c, l, f, h, d, _, C] = e;
- if (s || o || u || c || l || f ? n = (() => {
- let E = {
- type: 3,
- set: [],
- not: !1
- };
- return s ? E = wu() : o ? E = Su() : u ? E = Lu() : c ? E = Du() : l ? E = Pu() : f && (E = xu()), E;
- })() : h && C ? n = {
- type: 4,
- from: (d || _).charCodeAt(0),
- to: C.charCodeAt(C.length - 1)
- } : e[16] && (n = {
- type: 7,
- value: e[16].charCodeAt(0)
- }), !n)
- return [t, r.lastIndex];
- t.push(n);
- }
- throw new SyntaxError(`Invalid regular expression: /${a}/: Unterminated character class`);
- }
- function jE(i) {
- return i.replace(
- /(\[\\b\])|(\\)?\\(?:u([A-F0-9]{4})|x([A-F0-9]{2})|c([@A-Z[\\\]^?])|([0tnvfr]))/g,
- (a, e, t, r, n, s, o) => {
- if (t)
- return a;
- let u;
- e ? u = 8 : r ? u = Number.parseInt(r, 16) : n ? u = Number.parseInt(n, 16) : s ? u = "@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^ ?".indexOf(s) : u = {
- 0: 0,
- t: 9,
- n: 10,
- v: 11,
- f: 12,
- r: 13
- }[o];
- const c = String.fromCharCode(u);
- return /[[\]{}^$.|?*+()]/.test(c) ? `\\${c}` : c;
- }
- );
- }
- function UE(i, a) {
- for (const e of i.reverse()) {
- const t = e.reference.value;
- if (a < t) {
- e.reference.type = 7;
- const r = t.toString();
- if (e.reference.value = Number.parseInt(r, 8), !/^[0-7]+$/.test(r)) {
- let n = 0;
- for (; r[n] !== "8" && r[n] !== "9" && n < r.length; )
- n += 1;
- if (n === 0 ? (e.reference.value = r.charCodeAt(0), n += 1) : e.reference.value = Number.parseInt(r.slice(0, n), 8), r.length > n) {
- const s = e.stack.splice(e.index + 1);
- for (const o of r.slice(n))
- e.stack.push({
- type: 7,
- value: o.charCodeAt(0)
- });
- e.stack.push(...s);
- }
- }
- }
- }
- }
- function Ya(i, a) {
- if (!vE(i))
- return {
- isError: !0,
- regExp: null
- };
- try {
- const e = new RegExp(i, a ? "ug" : "u");
- return TE(e) ? {
- isError: !1,
- regExp: e
- } : {
- isError: !0,
- regExp: null
- };
- } catch {
- return {
- isError: !0,
- regExp: null
- };
- }
- }
- function vE(i) {
- return !(/\(\?<=.*?\)/g.test(i) && !/\[.*?(\?<=.*?)\]/g.test(i) || /\(\?<!.*?\)/g.test(i) && !/\[.*?(\?<!.*?)\]/g.test(i));
- }
- function TE(i, a) {
- let t;
- Object.prototype.toString.call(i) === "[object RegExp]" ? t = i.source : i && typeof i != "string" && (t = `${i}`);
- let r;
- try {
- r = LE(t);
- } catch {
- return !1;
- }
- let n = 0;
- const s = (o, u) => {
- let c = u;
- if (o.type === 5 && (c++, n++, c > 1 || n > 25))
- return !1;
- if (o.options) {
- for (const f of o.options)
- if (!s({ stack: f }, c))
- return !1;
- }
- const l = o.stack || o.value && o.value.stack;
- if (!l)
- return !0;
- for (const f of l)
- if (!s(f, c))
- return !1;
- return !0;
- };
- return s(r, 0);
- }
- class BE extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- const { isError: r, errorObject: n, variants: s } = Fr(e, t);
- if (r)
- return n;
- const [o, u] = s;
- let c = o.getValue();
- o.isNull() && (c = ""), o.isBoolean() && (c = c ? "TRUE" : "FALSE"), c = `${c}`;
- let l = u.getValue();
- u.isNull() && (l = ""), u.isBoolean() && (l = l ? "TRUE" : "FALSE"), l = `${l}`;
- const { isError: f, regExp: h } = Ya(l, !1);
- if (f)
- return g.create(m.REF);
- const d = c.match(h);
- if (d === null)
- return g.create(m.NA);
- if (d.length > 1) {
- const _ = d.slice(1).map((C) => j.create(C));
- return _.length > 1 ? q.create({
- calculateValueList: [_],
- rowCount: 1,
- columnCount: _.length,
- unitId: this.unitId,
- sheetId: this.subUnitId,
- row: this.row,
- column: this.column
- }) : _[0];
- }
- return j.create(d[0]);
- }
- }
- class IE extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- const { isError: r, errorObject: n, variants: s } = Fr(e, t);
- if (r)
- return n;
- const [o, u] = s;
- let c = o.getValue();
- o.isNull() && (c = ""), o.isBoolean() && (c = c ? "TRUE" : "FALSE"), c = `${c}`;
- let l = u.getValue();
- u.isNull() && (l = ""), u.isBoolean() && (l = l ? "TRUE" : "FALSE"), l = `${l}`;
- const { isError: f, regExp: h } = Ya(l, !1);
- return f ? g.create(m.REF) : c.match(h) === null ? T.create(!1) : T.create(!0);
- }
- }
- class FE extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 3);
- A(this, "maxParams", 3);
- }
- calculate(e, t, r) {
- const { isError: n, errorObject: s, variants: o } = Fr(e, t, r);
- if (n)
- return s;
- const [u, c, l] = o;
- let f = u.getValue();
- u.isNull() && (f = ""), u.isBoolean() && (f = f ? "TRUE" : "FALSE"), f = `${f}`;
- let h = c.getValue();
- c.isNull() && (h = ""), c.isBoolean() && (h = h ? "TRUE" : "FALSE"), h = `${h}`;
- let d = l.getValue();
- l.isNull() && (d = ""), l.isBoolean() && (d = d ? "TRUE" : "FALSE"), d = `${d}`;
- const { isError: _, regExp: C } = Ya(h, !0);
- if (_)
- return g.create(m.REF);
- const E = f.replace(C, d);
- return j.create(E);
- }
- }
- class kE extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 4);
- A(this, "maxParams", 4);
- }
- calculate(e, t, r, n) {
- const s = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1,
- r.isArray() ? r.getRowCount() : 1,
- n.isArray() ? n.getRowCount() : 1
- ), o = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1,
- r.isArray() ? r.getColumnCount() : 1,
- n.isArray() ? n.getColumnCount() : 1
- ), u = O(s, o, e, g.create(m.NA)), c = O(s, o, t, g.create(m.NA)), l = O(s, o, r, g.create(m.NA)), f = O(s, o, n, g.create(m.NA)), h = u.mapValue((d, _, C) => {
- const E = c.get(_, C), b = l.get(_, C), R = f.get(_, C);
- return d.isError() ? d : E.isError() ? E : b.isError() ? b : R.isError() ? R : this._handleSingleObject(d, E, b, R);
- });
- return s === 1 && o === 1 ? h.get(0, 0) : h;
- }
- _handleSingleObject(e, t, r, n) {
- const { isError: s, errorObject: o, variants: u } = I(t, r);
- if (s)
- return o;
- const [c, l] = u, f = Math.floor(+c.getValue()), h = Math.floor(+l.getValue());
- if (f <= 0 || h < 0)
- return g.create(m.VALUE);
- const d = De(e), _ = De(n), C = d.substring(0, f - 1) + _ + d.substring(f - 1 + h);
- return j.create(C);
- }
- }
- class $E extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 4);
- A(this, "maxParams", 4);
- }
- calculate(e, t, r, n) {
- const s = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1,
- r.isArray() ? r.getRowCount() : 1,
- n.isArray() ? n.getRowCount() : 1
- ), o = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1,
- r.isArray() ? r.getColumnCount() : 1,
- n.isArray() ? n.getColumnCount() : 1
- ), u = O(s, o, e, g.create(m.NA)), c = O(s, o, t, g.create(m.NA)), l = O(s, o, r, g.create(m.NA)), f = O(s, o, n, g.create(m.NA)), h = u.mapValue((d, _, C) => {
- const E = c.get(_, C), b = l.get(_, C), R = f.get(_, C);
- return d.isError() ? d : E.isError() ? E : b.isError() ? b : R.isError() ? R : this._handleSingleObject(d, E, b, R);
- });
- return s === 1 && o === 1 ? h.get(0, 0) : h;
- }
- _handleSingleObject(e, t, r, n) {
- const { isError: s, errorObject: o, variants: u } = I(t, r);
- if (s)
- return o;
- const [c, l] = u, f = Math.floor(+c.getValue()), h = Math.floor(+l.getValue());
- if (f <= 0 || h < 0)
- return g.create(m.VALUE);
- let d = De(e);
- const _ = De(n);
- let C = d.substring(0, f - 1);
- d = d.substring(f - 1);
- let E = 0, b = 0;
- for (; b < h && E < d.length; )
- b += Qr(d, E), E++;
- return C += _ + d.substring(E), j.create(C);
- }
- }
- class YE extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- if (e.isError())
- return e;
- if (t.isError())
- return t;
- const r = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1
- ), n = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1
- ), s = O(r, n, e, g.create(m.NA)), o = O(r, n, t, g.create(m.NA)), u = s.map((c, l, f) => {
- let h = o.get(l, f);
- if (c.isError())
- return c;
- let d = c.getValue();
- if (c.isNull() && (d = ""), c.isBoolean() && (d = d ? "TRUE" : "FALSE"), d += "", h.isString() && (h = h.convertToNumberObjectValue()), h.isError())
- return h;
- const _ = 32767, C = Math.floor(+h.getValue());
- if (C < 0 || C > _ / d.length)
- return g.create(m.VALUE);
- const E = d.repeat(C);
- return j.create(E);
- });
- return r === 1 && n === 1 ? u.get(0, 0) : u;
- }
- }
- class HE extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- const r = t != null ? t : y.create(1), n = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- r.isArray() ? r.getRowCount() : 1
- ), s = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- r.isArray() ? r.getColumnCount() : 1
- ), o = O(n, s, e, g.create(m.NA)), u = O(n, s, r, g.create(m.NA)), c = o.mapValue((l, f, h) => {
- const d = u.get(f, h);
- return l.isError() ? l : d.isError() ? d : this._handleSingleObject(l, d);
- });
- return n === 1 && s === 1 ? c.get(0, 0) : c;
- }
- _handleSingleObject(e, t) {
- const r = De(e), { isError: n, errorObject: s, variants: o } = I(t);
- if (n)
- return s;
- const [u] = o, c = Math.floor(+u.getValue());
- if (c < 0)
- return g.create(m.VALUE);
- if (e.isNull() || c === 0)
- return j.create("");
- if (c >= r.length)
- return j.create(r);
- const l = r.substring(r.length - c);
- return j.create(l);
- }
- }
- class GE extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- const r = t != null ? t : y.create(1), n = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- r.isArray() ? r.getRowCount() : 1
- ), s = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- r.isArray() ? r.getColumnCount() : 1
- ), o = O(n, s, e, g.create(m.NA)), u = O(n, s, r, g.create(m.NA)), c = o.mapValue((l, f, h) => {
- const d = u.get(f, h);
- return l.isError() ? l : d.isError() ? d : this._handleSingleObject(l, d);
- });
- return n === 1 && s === 1 ? c.get(0, 0) : c;
- }
- _handleSingleObject(e, t) {
- const r = De(e), { isError: n, errorObject: s, variants: o } = I(t);
- if (n)
- return s;
- const [u] = o, c = Math.floor(+u.getValue());
- if (c < 0)
- return g.create(m.VALUE);
- if (e.isNull() || c === 0)
- return j.create("");
- let l = r.length - 1, f = 0, h = "";
- for (; f < c && l >= 0; )
- f += Qr(r, l, "rtl"), h = r.charAt(l) + h, l--;
- return j.create(h);
- }
- }
- class QE extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 3);
- }
- calculate(e, t, r) {
- const n = r != null ? r : y.create(1), s = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1,
- n.isArray() ? n.getRowCount() : 1
- ), o = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1,
- n.isArray() ? n.getColumnCount() : 1
- ), u = O(s, o, e, g.create(m.NA)), c = O(s, o, t, g.create(m.NA)), l = O(s, o, n, g.create(m.NA)), f = u.mapValue((h, d, _) => {
- const C = c.get(d, _), E = l.get(d, _);
- return h.isError() ? h : C.isError() ? C : E.isError() ? E : this._handleSingleObject(h, C, E);
- });
- return s === 1 && o === 1 ? f.get(0, 0) : f;
- }
- _handleSingleObject(e, t, r) {
- const n = De(e).toLocaleUpperCase(), s = De(t).toLocaleUpperCase(), { isError: o, errorObject: u, variants: c } = I(r);
- if (o)
- return u;
- const [l] = c, f = Math.floor(+l.getValue());
- if (t.isNull() || f <= 0 || f > s.length)
- return g.create(m.VALUE);
- if (e.isNull() || n.length === 0)
- return y.create(f);
- const h = s.indexOf(n, f - 1);
- return h === -1 ? g.create(m.VALUE) : y.create(h + 1);
- }
- }
- class WE extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 3);
- }
- calculate(e, t, r) {
- const n = r != null ? r : y.create(1), s = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1,
- n.isArray() ? n.getRowCount() : 1
- ), o = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1,
- n.isArray() ? n.getColumnCount() : 1
- ), u = O(s, o, e, g.create(m.NA)), c = O(s, o, t, g.create(m.NA)), l = O(s, o, n, g.create(m.NA)), f = u.mapValue((h, d, _) => {
- const C = c.get(d, _), E = l.get(d, _);
- return h.isError() ? h : C.isError() ? C : E.isError() ? E : this._handleSingleObject(h, C, E);
- });
- return s === 1 && o === 1 ? f.get(0, 0) : f;
- }
- _handleSingleObject(e, t, r) {
- const n = De(e).toLocaleUpperCase(), s = De(t).toLocaleUpperCase(), { isError: o, errorObject: u, variants: c } = I(r);
- if (o)
- return u;
- const [l] = c, f = Math.floor(+l.getValue());
- if (t.isNull() || f <= 0 || f > s.length)
- return g.create(m.VALUE);
- if (e.isNull() || n.length === 0)
- return y.create(f);
- const h = s.indexOf(n, f - 1);
- if (h === -1)
- return g.create(m.VALUE);
- const d = $a(s.substring(0, h)) + 1;
- return y.create(d);
- }
- }
- class qE extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 3);
- A(this, "maxParams", 4);
- }
- calculate(e, t, r, n) {
- const s = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1,
- r.isArray() ? r.getRowCount() : 1,
- n != null && n.isArray() ? n.getRowCount() : 1
- ), o = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1,
- r.isArray() ? r.getColumnCount() : 1,
- n != null && n.isArray() ? n.getColumnCount() : 1
- ), u = O(s, o, e, g.create(m.NA)), c = O(s, o, t, g.create(m.NA)), l = O(s, o, r, g.create(m.NA)), f = n ? O(s, o, n, g.create(m.NA)) : void 0, h = u.mapValue((d, _, C) => {
- const E = c.get(_, C), b = l.get(_, C);
- let R = n ? f.get(_, C) : void 0;
- return d.isError() ? d : E.isError() ? E : b.isError() ? b : R != null && R.isError() ? R : R != null && R.isNull() || R != null && R.isBoolean() ? g.create(m.VALUE) : (R != null && R.isString() && (R = R.convertToNumberObjectValue()), R != null && R.isError() ? R : this._handleSingleObject(d, E, b, R));
- });
- return s === 1 && o === 1 ? h.get(0, 0) : h;
- }
- _handleSingleObject(e, t, r, n) {
- const s = this._getObjectString(e), o = this._getObjectString(t), u = this._getObjectString(r), c = n ? Math.floor(+n.getValue()) : void 0;
- if (n && c <= 0)
- return g.create(m.VALUE);
- if (o === "")
- return j.create(s);
- let l = "", f = 0;
- for (let h = 0; h < s.length; h++) {
- const d = s.substr(h, o.length);
- if (d === o || d.length === o.length && d.trim() === o.trim()) {
- if (f++, f === c) {
- l = s.substr(0, h) + u + s.substr(h + o.length);
- break;
- }
- c === void 0 && (l += u), h += o.length - 1;
- } else
- c === void 0 && (l += s[h]);
- }
- return c && f < c && (l = s), j.create(l);
- }
- _getObjectString(e) {
- let t = `${e.getValue()}`;
- return e.isNull() && (t = ""), e.isBoolean() && (t = t.toLocaleUpperCase()), t;
- }
- }
- class KE extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- let t = e;
- return e.isArray() && (t = e.get(0, 0)), t.isError() ? t : t.isNull() || t.isBoolean() || t.isNumber() ? j.create("") : t;
- }
- }
- class XE extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- if (e.isError())
- return e;
- if (t.isError())
- return t;
- const r = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- t.isArray() ? t.getRowCount() : 1
- ), n = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- t.isArray() ? t.getColumnCount() : 1
- ), s = O(r, n, e), o = O(r, n, t);
- return s.map((u, c, l) => {
- if (u.isError())
- return u;
- let f = o.get(c, l) || j.create(" ");
- if (f.isError())
- return f;
- if (f.isBoolean())
- return g.create(m.VALUE);
- if (u.isBoolean())
- return u;
- let h = u.getValue();
- if (u.isNull() && (h = 0), u.isString()) {
- if (!Q(h))
- return u;
- h = Number(h);
- }
- f.isNull() && (f = j.create(" "));
- const d = `${f.getValue()}`, _ = ka(d, h);
- return j.create(d === " " ? _.trimEnd() : _);
- });
- }
- }
- class ZE extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 6);
- }
- calculate(e, t, r, n, s, o) {
- let u = !1, c = r != null ? r : y.create(1);
- c.isNull() && (u = !0, c = y.create(1));
- const l = !n, f = n != null ? n : y.create(0), h = s != null ? s : y.create(0), d = o != null ? o : g.create(m.NA), _ = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- c.isArray() ? c.getRowCount() : 1,
- f.isArray() ? f.getRowCount() : 1,
- h.isArray() ? h.getRowCount() : 1,
- d.isArray() ? d.getRowCount() : 1
- ), C = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- c.isArray() ? c.getColumnCount() : 1,
- f.isArray() ? f.getColumnCount() : 1,
- h.isArray() ? h.getColumnCount() : 1,
- d.isArray() ? d.getColumnCount() : 1
- ), E = O(_, C, e, g.create(m.NA)), b = O(_, C, c, g.create(m.NA)), R = O(_, C, f, g.create(m.NA)), p = O(_, C, h, g.create(m.NA)), N = O(_, C, d, g.create(m.NA)), M = this._getResultArray(E, t, b, R, p, N, u, l);
- return _ === 1 && C === 1 ? M.get(0, 0) : M;
- }
- _getResultArray(e, t, r, n, s, o, u, c) {
- return e.map((f, h, d) => {
- const _ = r.get(h, d), C = n.get(h, d), E = s.get(h, d), b = o.get(h, d), R = this._checkVariantsError(f, _, C, E);
- if (R.isError())
- return R;
- const p = this._getStringValue(f), N = this._getDelimiterValue(t);
- if (N instanceof g)
- return N;
- const M = this._getVariantsNumberFloorValue(_, C, E);
- if (M instanceof g)
- return M;
- const [w, D, S] = M;
- return w === 0 || D < 0 || D > 1 || S < 0 || S > 1 ? g.create(m.VALUE) : N.includes("") ? w > 0 ? j.create(p) : j.create("") : !u && Math.abs(w) > p.length ? g.create(m.VALUE) : N.every((P) => P.length > p.length) ? g.create(m.NA) : this._getResult(p, N, w, D, S, b, c);
- });
- }
- _checkVariantsError(...e) {
- for (let t = 0; t < e.length; t++) {
- const r = e[t];
- if (r.isError())
- return r;
- }
- return T.create(!0);
- }
- _getStringValue(e) {
- let t = `${e.getValue()}`;
- return e.isNull() && (t = ""), e.isBoolean() && (t = t.toLocaleUpperCase()), t;
- }
- _getDelimiterValue(e) {
- const t = [];
- if (e.isArray()) {
- let r = !1, n = g.create(m.VALUE);
- if (e.iterator((s) => {
- const o = s;
- if (o.isError())
- return r = !0, n = o, !1;
- t.push(this._getStringValue(o));
- }), r)
- return n;
- } else {
- if (e.isError())
- return e;
- t.push(this._getStringValue(e));
- }
- return t;
- }
- _getVariantsNumberFloorValue(...e) {
- const t = [];
- for (let r = 0; r < e.length; r++) {
- let n = e[r];
- if (n.isString() && (n = n.convertToNumberObjectValue()), n.isError())
- return n;
- const s = Math.floor(+n.getValue());
- t.push(s);
- }
- return t;
- }
- _getResult(e, t, r, n, s, o, u) {
- let c = n ? e.toLocaleLowerCase() : e;
- const l = n ? t.map((C) => C.toLocaleLowerCase()) : t;
- let f = 0, h = 0, d = 0;
- for (let C = 0; C < Math.abs(r); C++)
- if (r < 0) {
- const E = l.map((b) => ({
- index: c.lastIndexOf(b),
- length: b.length
- })).filter((b) => b.index !== -1).sort((b, R) => R.index - b.index)[0];
- if (!E)
- break;
- f = E.index, c = c.substr(0, E.index), d = E.length, h++;
- } else {
- const E = l.map((b) => ({
- index: c.indexOf(b),
- length: b.length
- })).filter((b) => b.index !== -1).sort((b, R) => b.index - R.index)[0];
- if (!E)
- break;
- f += E.index + d, c = c.substr(E.index + E.length), d = E.length, h++;
- }
- if (h && h < Math.abs(r) && u)
- return g.create(m.NA);
- if (!h || h < Math.abs(r))
- return s ? r > 0 ? j.create("") : j.create(e) : o;
- const _ = e.substr(f + d);
- return j.create(_);
- }
- }
- class zE extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 6);
- }
- calculate(e, t, r, n, s, o) {
- let u = !1, c = r != null ? r : y.create(1);
- c.isNull() && (u = !0, c = y.create(1));
- const l = !n, f = n != null ? n : y.create(0), h = s != null ? s : y.create(0), d = o != null ? o : g.create(m.NA), _ = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- c.isArray() ? c.getRowCount() : 1,
- f.isArray() ? f.getRowCount() : 1,
- h.isArray() ? h.getRowCount() : 1,
- d.isArray() ? d.getRowCount() : 1
- ), C = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- c.isArray() ? c.getColumnCount() : 1,
- f.isArray() ? f.getColumnCount() : 1,
- h.isArray() ? h.getColumnCount() : 1,
- d.isArray() ? d.getColumnCount() : 1
- ), E = O(_, C, e, g.create(m.NA)), b = O(_, C, c, g.create(m.NA)), R = O(_, C, f, g.create(m.NA)), p = O(_, C, h, g.create(m.NA)), N = O(_, C, d, g.create(m.NA)), M = this._getResultArray(E, t, b, R, p, N, u, l);
- return _ === 1 && C === 1 ? M.get(0, 0) : M;
- }
- _getResultArray(e, t, r, n, s, o, u, c) {
- return e.map((f, h, d) => {
- const _ = r.get(h, d), C = n.get(h, d), E = s.get(h, d), b = o.get(h, d), R = this._checkVariantsError(f, _, C, E);
- if (R.isError())
- return R;
- const p = this._getStringValue(f), N = this._getDelimiterValue(t);
- if (N instanceof g)
- return N;
- const M = this._getVariantsNumberFloorValue(_, C, E);
- if (M instanceof g)
- return M;
- const [w, D, S] = M;
- return w === 0 || D < 0 || D > 1 || S < 0 || S > 1 ? g.create(m.VALUE) : N.includes("") ? w > 0 ? j.create("") : j.create(p) : !u && Math.abs(w) > p.length ? g.create(m.VALUE) : N.every((P) => P.length > p.length) ? g.create(m.NA) : this._getResult(p, N, w, D, S, b, c);
- });
- }
- _checkVariantsError(...e) {
- for (let t = 0; t < e.length; t++) {
- const r = e[t];
- if (r.isError())
- return r;
- }
- return T.create(!0);
- }
- _getStringValue(e) {
- let t = `${e.getValue()}`;
- return e.isNull() && (t = ""), e.isBoolean() && (t = t.toLocaleUpperCase()), t;
- }
- _getDelimiterValue(e) {
- const t = [];
- if (e.isArray()) {
- let r = !1, n = g.create(m.VALUE);
- if (e.iterator((s) => {
- const o = s;
- if (o.isError())
- return r = !0, n = o, !1;
- t.push(this._getStringValue(o));
- }), r)
- return n;
- } else {
- if (e.isError())
- return e;
- t.push(this._getStringValue(e));
- }
- return t;
- }
- _getVariantsNumberFloorValue(...e) {
- const t = [];
- for (let r = 0; r < e.length; r++) {
- let n = e[r];
- if (n.isString() && (n = n.convertToNumberObjectValue()), n.isError())
- return n;
- const s = Math.floor(+n.getValue());
- t.push(s);
- }
- return t;
- }
- _getResult(e, t, r, n, s, o, u) {
- let c = n ? e.toLocaleLowerCase() : e;
- const l = n ? t.map((C) => C.toLocaleLowerCase()) : t;
- let f = 0, h = 0, d = 0;
- for (let C = 0; C < Math.abs(r); C++)
- if (r < 0) {
- const E = l.map((b) => ({
- index: c.lastIndexOf(b),
- length: b.length
- })).filter((b) => b.index !== -1).sort((b, R) => R.index - b.index)[0];
- if (!E)
- break;
- f = E.index, c = c.substr(0, E.index), h++;
- } else {
- const E = l.map((b) => ({
- index: c.indexOf(b),
- length: b.length
- })).filter((b) => b.index !== -1).sort((b, R) => b.index - R.index)[0];
- if (!E)
- break;
- f += E.index + d, c = c.substr(E.index + E.length), d = E.length, h++;
- }
- if (h && h < Math.abs(r) && u)
- return g.create(m.NA);
- if (!h || h < Math.abs(r))
- return s ? r > 0 ? j.create(e) : j.create("") : o;
- const _ = e.substr(0, f);
- return j.create(_);
- }
- }
- class JE extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 3);
- A(this, "maxParams", 255);
- }
- calculate(e, t, ...r) {
- const n = this._getDelimiterValues(e), s = this._getTextValues(r);
- if (t.isArray()) {
- const u = t.mapValue((c) => this._handleSingleObject(n, c, s));
- return u.getRowCount() === 1 && u.getColumnCount() === 1 ? u.get(0, 0) : u;
- }
- const o = t;
- if (o.isString()) {
- const u = `${o.getValue()}`.toLocaleUpperCase();
- if (u === "TRUE")
- return this._handleSingleObject(n, T.create(!0), s);
- if (u === "FALSE")
- return this._handleSingleObject(n, T.create(!1), s);
- }
- return this._handleSingleObject(n, t, s);
- }
- _handleSingleObject(e, t, r) {
- if (e instanceof g)
- return e;
- const { isError: n, errorObject: s, variants: o } = I(t);
- if (n)
- return s;
- if (r instanceof g)
- return r;
- const [u] = o, c = +u.getValue();
- let l = r;
- c && (l = r.filter((h) => h !== null));
- let f = "";
- for (let h = 0; h < l.length; h++)
- l[h] !== null && (f += l[h]), h < l.length - 1 && (f += e[h % e.length]);
- return j.create(f);
- }
- _getDelimiterValues(e) {
- const t = [], r = e.isArray() ? e.getRowCount() : 1, n = e.isArray() ? e.getColumnCount() : 1;
- for (let s = 0; s < r; s++)
- for (let o = 0; o < n; o++) {
- const u = e.isArray() ? e.get(s, o) : e;
- if (u.isError())
- return u;
- let c = `${u.getValue()}`;
- u.isNull() && (c = ""), u.isBoolean() && (c = c.toLocaleUpperCase()), t.push(c);
- }
- return t;
- }
- _getTextValues(e) {
- const t = [];
- for (const r of e) {
- const n = r.isArray() ? r.getRowCount() : 1, s = r.isArray() ? r.getColumnCount() : 1;
- for (let o = 0; o < n; o++)
- for (let u = 0; u < s; u++) {
- const c = r.isArray() ? r.get(o, u) : r;
- if (c.isError())
- return c;
- if (c.isNull()) {
- t.push(null);
- continue;
- }
- let l = `${c.getValue()}`;
- c.isBoolean() && (l = l.toLocaleUpperCase()), t.push(l);
- }
- }
- return t;
- }
- }
- class eb extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 2);
- A(this, "maxParams", 6);
- }
- calculate(e, t, r, n, s, o) {
- let u = r != null ? r : j.create("\\s");
- const c = n != null ? n : y.create(0), l = s != null ? s : y.create(0), f = o != null ? o : j.create(m.NA), { _variant: h, values: d } = this._getStringValues(t), { _variant: _, values: C } = this._getStringValues(u, !1);
- u = _;
- const E = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- c.isArray() ? c.getRowCount() : 1,
- l.isArray() ? l.getRowCount() : 1
- ), b = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- c.isArray() ? c.getColumnCount() : 1,
- l.isArray() ? l.getColumnCount() : 1
- ), R = O(E, b, e, g.create(m.NA)), p = O(E, b, c, g.create(m.NA)), N = O(E, b, l, g.create(m.NA)), M = this._getResultArray(
- R,
- h,
- u,
- p,
- N,
- f,
- d,
- C
- );
- return E === 1 && b === 1 ? M.get(0, 0) : M.map((w) => w.get(0, 0));
- }
- _getStringValues(e, t = !0) {
- let r = e;
- const n = [];
- if (r.isArray())
- r.iterator((s) => {
- if (s != null && s.isError())
- return r = s, !1;
- if (s != null && s.isNull() && t)
- return r = g.create(m.VALUE), !1;
- const o = this._getRegExpStringValue(s);
- if (o === "")
- return r = g.create(m.VALUE), !1;
- n.push(o);
- });
- else {
- r.isNull() && t && (r = g.create(m.VALUE));
- const s = this._getRegExpStringValue(r);
- s === "" && (r = g.create(m.VALUE)), n.push(s);
- }
- return {
- _variant: r,
- values: n
- };
- }
- _getResultArray(e, t, r, n, s, o, u, c) {
- return e.map((f, h, d) => {
- let _ = n.get(h, d), C = s.get(h, d);
- const E = this._checkVariantsError(f, t, r, _, C);
- if (E.isError())
- return E;
- if (f.isNull())
- return g.create(m.VALUE);
- let b = o;
- if (b.isArray()) {
- const w = b.getRowCount(), D = b.getColumnCount();
- if (w > 1 || D > 1)
- return g.create(m.VALUE);
- b = b.get(0, 0);
- }
- let R = `${f.getValue()}`;
- if (f.isBoolean() && (R = R.toLocaleUpperCase()), _.isString() && (_ = _.convertToNumberObjectValue(), _.isError()))
- return _;
- const p = Math.floor(+_.getValue());
- if (C.isString() && (C = C.convertToNumberObjectValue(), C.isError()))
- return C;
- const N = Math.floor(+C.getValue());
- if (N < 0 || N > 1)
- return g.create(m.VALUE);
- let M = `${b.getValue()}`;
- return b.isBoolean() && (M = M.toLocaleUpperCase()), this._getResult(R, u, c, p, N, M);
- });
- }
- _getResult(e, t, r, n, s, o) {
- const u = new RegExp(r.join("|"), `g${s ? "i" : ""}`), c = new RegExp(t.join("|"), `g${s ? "i" : ""}`), l = e.split(u);
- let f = 1, h = l.map((d) => {
- let _ = d.split(c);
- return n && (_ = _.filter((C) => C !== "")), f = Math.max(f, _.length), _;
- });
- return h = h.map((d) => {
- let _ = d;
- return _.length < f && (_ = _.concat(new Array(f - _.length).fill(o))), _;
- }), q.createByArray(h);
- }
- _checkVariantsError(...e) {
- for (let t = 0; t < e.length; t++) {
- const r = e[t];
- if (r.isError())
- return r;
- }
- return T.create(!0);
- }
- _getRegExpStringValue(e) {
- let t = e.getValue();
- return e.isNull() && (t = "\\s"), e.isBoolean() && (t = t ? "TRUE" : "FALSE"), t += "", this._escapeRegExp(t);
- }
- _escapeRegExp(e) {
- return e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
- }
- }
- class tb extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- if (e.isArray()) {
- const t = e.mapValue((r) => this._handleSingleObject(r));
- return t.getRowCount() === 1 && t.getColumnCount() === 1 ? t.get(0, 0) : t;
- }
- return this._handleSingleObject(e);
- }
- _handleSingleObject(e) {
- if (e.isError())
- return e;
- if (e.isNull())
- return j.create("");
- let t = `${e.getValue()}`;
- return e.isBoolean() && (t = t.toLocaleUpperCase()), t = t.trim().replace(/\s+/g, " "), j.create(t);
- }
- }
- const rb = Object.values(ve).filter((i) => [
- ve.TABLE_START,
- ve.TABLE_ROW_START,
- ve.TABLE_CELL_START,
- ve.TABLE_CELL_END,
- ve.TABLE_ROW_END,
- ve.TABLE_END,
- ve.CUSTOM_BLOCK
- ].includes(i));
- class nb extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- if (e.isArray()) {
- const t = e.mapValue((r) => this._handleSingleObject(r));
- return t.getRowCount() === 1 && t.getColumnCount() === 1 ? t.get(0, 0) : t;
- }
- return this._handleSingleObject(e);
- }
- _handleSingleObject(e) {
- const { isError: t, errorObject: r, variants: n } = I(e);
- if (t)
- return r;
- const [s] = n, o = Math.floor(+s.getValue());
- if (o < 1 || o > 1114111)
- return g.create(m.VALUE);
- if (o === 1114111 || o === 1114110)
- return g.create(m.NA);
- let u = String.fromCharCode(o);
- return rb.some((c) => c === u) && (u = ""), j.create(u);
- }
- }
- class sb extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- if (e.isArray()) {
- const t = e.mapValue((r) => this._handleSingleObject(r));
- return t.getRowCount() === 1 && t.getColumnCount() === 1 ? t.get(0, 0) : t;
- }
- return this._handleSingleObject(e);
- }
- _handleSingleObject(e) {
- if (e.isError())
- return e;
- if (e.isNull())
- return g.create(m.VALUE);
- let t = e.getValue().toLocaleString();
- e.isBoolean() && (t = t.toLocaleUpperCase());
- const r = t.charCodeAt(0);
- return y.create(r);
- }
- }
- class ab extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- if (e.isArray()) {
- const t = e.mapValue((r) => this._handleSingleObject(r));
- return t.getRowCount() === 1 && t.getColumnCount() === 1 ? t.get(0, 0) : t;
- }
- return this._handleSingleObject(e);
- }
- _handleSingleObject(e) {
- if (e.isError())
- return e;
- if (e.isNull())
- return j.create("");
- const t = `${e.getValue()}`.toLocaleUpperCase();
- return j.create(t);
- }
- }
- class ib extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- if (e.isArray()) {
- const t = e.mapValue((r) => this._handleSingleObject(r));
- return t.getRowCount() === 1 && t.getColumnCount() === 1 ? t.get(0, 0) : t;
- }
- return this._handleSingleObject(e);
- }
- _handleSingleObject(e) {
- if (e.isError())
- return e;
- if (e.isBoolean())
- return g.create(m.VALUE);
- let t = e;
- if (e.isString() && (t = t.convertToNumberObjectValue(), t.isError()))
- return t;
- const r = +t.getValue();
- return y.create(r);
- }
- }
- class ob extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 2);
- }
- calculate(e, t) {
- const r = t != null ? t : y.create(0), n = Math.max(
- e.isArray() ? e.getRowCount() : 1,
- r.isArray() ? r.getRowCount() : 1
- ), s = Math.max(
- e.isArray() ? e.getColumnCount() : 1,
- r.isArray() ? r.getColumnCount() : 1
- ), o = O(n, s, e, g.create(m.NA)), u = O(n, s, r, g.create(m.NA)), c = o.mapValue((l, f, h) => {
- const d = u.get(f, h);
- return l.isError() ? l : d.isError() ? d : this._handleSingleObject(l, d);
- });
- return n === 1 && s === 1 ? c.get(0, 0) : c;
- }
- _handleSingleObject(e, t) {
- const { isError: r, errorObject: n, variants: s } = I(t);
- if (r)
- return n;
- const [o] = s, u = Math.floor(+o.getValue());
- if (u < 0 || u > 1)
- return g.create(m.VALUE);
- if (e.isNull())
- return j.create("");
- if (e.isBoolean())
- return e;
- if (e.isNumber())
- return y.create(e.getValue());
- const c = u ? `"${e.getValue()}"` : `${e.getValue()}`;
- return j.create(c);
- }
- }
- const ub = [
- [oE, se.ASC],
- [iE, se.ARRAYTOTEXT],
- [uE, se.BAHTTEXT],
- [lE, se.CHAR],
- [fE, se.CLEAN],
- [hE, se.CODE],
- [mE, se.CONCAT],
- [gE, se.CONCATENATE],
- [dE, se.DBCS],
- [CE, se.DOLLAR],
- [_E, se.EXACT],
- [AE, se.FIND],
- [bE, se.FINDB],
- [yE, se.FIXED],
- [RE, se.LEFT],
- [pE, se.LEFTB],
- [VE, se.LEN],
- [NE, se.LENB],
- [OE, se.LOWER],
- [ME, se.MID],
- [wE, se.MIDB],
- [DE, se.NUMBERVALUE],
- [BE, se.REGEXEXTRACT],
- [IE, se.REGEXMATCH],
- [FE, se.REGEXREPLACE],
- [SE, se.PROPER],
- [kE, se.REPLACE],
- [$E, se.REPLACEB],
- [YE, se.REPT],
- [HE, se.RIGHT],
- [GE, se.RIGHTB],
- [QE, se.SEARCH],
- [WE, se.SEARCHB],
- [qE, se.SUBSTITUTE],
- [KE, se.T],
- [XE, se.TEXT],
- [ZE, se.TEXTAFTER],
- [zE, se.TEXTBEFORE],
- [JE, se.TEXTJOIN],
- [eb, se.TEXTSPLIT],
- [tb, se.TRIM],
- [nb, se.UNICHAR],
- [sb, se.UNICODE],
- [ab, se.UPPER],
- [ib, se.VALUE],
- [ob, se.VALUETOTEXT]
- ], cb = [];
- var lb = /* @__PURE__ */ ((i) => i)(lb || {});
- class fb extends V {
- constructor() {
- super(...arguments);
- A(this, "minParams", 1);
- A(this, "maxParams", 1);
- }
- calculate(e) {
- if (e.isArray()) {
- const t = e.mapValue((r) => this._handleSingleObject(r));
- return t.getRowCount() === 1 && t.getColumnCount() === 1 ? t.get(0, 0) : t;
- }
- return this._handleSingleObject(e);
- }
- _handleSingleObject(e) {
- if (e.isError())
- return e;
- const t = De(e), r = encodeURIComponent(t).replace(/[!~'()*]/g, (n) => `%${n.charCodeAt(0).toString(16).toLocaleUpperCase()}`);
- return j.create(r);
- }
- }
- var ju = /* @__PURE__ */ ((i) => (i.ENCODEURL = "ENCODEURL", i.FILTERXML = "FILTERXML", i.WEBSERVICE = "WEBSERVICE", i))(ju || {});
- const hb = [
- [fb, ju.ENCODEURL]
- ];
- var mb = Object.defineProperty, gb = Object.getOwnPropertyDescriptor, db = (i, a, e, t) => {
- for (var r = t > 1 ? void 0 : t ? gb(a, e) : a, n = i.length - 1, s; n >= 0; n--)
- (s = i[n]) && (r = (t ? s(a, e, r) : s(r)) || r);
- return t && r && mb(a, e, r), r;
- }, Zr = (i, a) => (e, t) => a(e, t, i);
- let wn = class extends Me {
- constructor(i, a, e, t) {
- super(), this._commandService = i, this._functionService = a, this._configService = e, this._dataSyncPrimaryController = t, this._initialize();
- }
- _initialize() {
- this._registerCommands(), this._registerFunctions();
- }
- _registerCommands() {
- [
- eo,
- bs,
- Zi,
- zi,
- Ns,
- Ji,
- sa,
- Xi,
- aa,
- ia,
- oa,
- ua,
- jc,
- Uc,
- to,
- bc
- ].forEach((i) => {
- var a;
- this._commandService.registerCommand(i), (a = this._dataSyncPrimaryController) == null || a.registerSyncingMutations(i);
- });
- }
- _registerFunctions() {
- var e;
- const i = this._configService.getConfig(fa), a = [
- ...Yh,
- ...pm,
- ...Vm,
- ...Im,
- ...Rg,
- ...O1,
- ...P0,
- ...td,
- ...yd,
- ...rC,
- ...D_,
- ...v_,
- ...aE,
- ...ub,
- ...cb,
- ...hb
- ].concat((e = i == null ? void 0 : i.function) != null ? e : []).map((t) => {
- const r = t[0], n = t[1];
- return new r(n);
- });
- this._functionService.registerExecutors(...a);
- }
- };
- wn = db([
- Zr(0, br),
- Zr(1, Yt),
- Zr(2, ta),
- Zr(3, qu(Zu))
- ], wn);
- var Cb = Object.defineProperty, _b = Object.getOwnPropertyDescriptor, Ab = (i, a, e, t) => {
- for (var r = t > 1 ? void 0 : t ? _b(a, e) : a, n = i.length - 1, s; n >= 0; n--)
- (s = i[n]) && (r = (t ? s(a, e, r) : s(r)) || r);
- return t && r && Cb(a, e, r), r;
- }, zr = (i, a) => (e, t) => a(e, t, i);
- let Dn = class extends Me {
- constructor(i, a, e) {
- super(), this._commandService = i, this._dependencyManagerService = a, this._featureCalculationManagerService = e, this._initialize();
- }
- _initialize() {
- this._commandExecutedListener(), this._featureCalculationManagerServiceListener();
- }
- _featureCalculationManagerServiceListener() {
- this.disposeWithMe(
- this._featureCalculationManagerService.onChanged$.subscribe((i) => {
- const { unitId: a, subUnitId: e, featureIds: t } = i;
- this._dependencyManagerService.removeFeatureFormulaDependency(a, e, t);
- })
- );
- }
- _commandExecutedListener() {
- this.disposeWithMe(
- this._commandService.onCommandExecuted((i) => {
- if (i.id === ia.id) {
- const a = i.params;
- if (a == null)
- return;
- const { featureIds: e, unitId: t, subUnitId: r } = a;
- this._dependencyManagerService.removeFeatureFormulaDependency(t, r, e);
- } else if (i.id === aa.id) {
- const a = i.params;
- if (a == null)
- return;
- const { featureId: e, calculationParam: t } = a, { unitId: r, subUnitId: n } = t;
- this._dependencyManagerService.removeFeatureFormulaDependency(r, n, [e]);
- } else if (i.id === ua.id) {
- const a = i.params;
- if (a == null)
- return;
- this._dependencyManagerService.removeOtherFormulaDependency(a.unitId, a.subUnitId, a.formulaIdList);
- } else if (i.id === oa.id) {
- const a = i.params;
- if (a == null)
- return;
- const e = a.formulaMap, t = [];
- Object.keys(e).forEach((r) => {
- t.push(r);
- }), this._dependencyManagerService.removeOtherFormulaDependency(a.unitId, a.subUnitId, t);
- } else if (i.id === eo.id) {
- const a = i.params.formulaData;
- Object.keys(a).forEach((e) => {
- const t = a[e];
- if (t !== void 0) {
- if (t === null) {
- this._dependencyManagerService.clearFormulaDependency(e);
- return;
- }
- Object.keys(t).forEach((r) => {
- const n = t[r];
- if (n !== void 0) {
- if (n === null)
- return this._dependencyManagerService.clearFormulaDependency(e, r), !0;
- new Ce(n).forValue((s, o) => {
- this._dependencyManagerService.removeFormulaDependency(e, r, s, o);
- });
- }
- });
- }
- });
- } else i.id === sa.id && this._handleSetDefinedName(i);
- })
- );
- }
- _handleSetDefinedName(i) {
- const a = i.params;
- if (a == null)
- return;
- const { unitId: e, name: t } = a;
- this._dependencyManagerService.removeFormulaDependencyByDefinedName(e, t);
- }
- };
- Dn = Ab([
- zr(0, br),
- zr(1, jr),
- zr(1, Hn),
- zr(2, jr)
- ], Dn);
- var Eb = Object.defineProperty, bb = Object.getOwnPropertyDescriptor, yb = (i, a, e, t) => {
- for (var r = t > 1 ? void 0 : t ? bb(a, e) : a, n = i.length - 1, s; n >= 0; n--)
- (s = i[n]) && (r = (t ? s(a, e, r) : s(r)) || r);
- return t && r && Eb(a, e, r), r;
- }, Ti = (i, a) => (e, t) => a(e, t, i);
- let Sn = class extends Me {
- constructor(i, a) {
- super(), this._commandService = i, this._featureCalculationManagerService = a, this._initialize();
- }
- _initialize() {
- this._commandExecutedListener();
- }
- _commandExecutedListener() {
- this.disposeWithMe(
- this._commandService.onCommandExecuted((i) => {
- if (i.id === aa.id) {
- const a = i.params;
- if (a == null)
- return;
- const { featureId: e, calculationParam: t } = a, { unitId: r, subUnitId: n } = t;
- this._featureCalculationManagerService.register(r, n, e, t);
- } else if (i.id === ia.id) {
- const a = i.params;
- if (a == null)
- return;
- const { featureIds: e, unitId: t, subUnitId: r } = a;
- this._featureCalculationManagerService.remove(t, r, e);
- }
- })
- );
- }
- };
- Sn = yb([
- Ti(0, br),
- Ti(1, jr)
- ], Sn);
- var Rb = Object.defineProperty, pb = Object.getOwnPropertyDescriptor, Vb = (i, a, e, t) => {
- for (var r = t > 1 ? void 0 : t ? pb(a, e) : a, n = i.length - 1, s; n >= 0; n--)
- (s = i[n]) && (r = (t ? s(a, e, r) : s(r)) || r);
- return t && r && Rb(a, e, r), r;
- }, Cs = (i, a) => (e, t) => a(e, t, i);
- let Pn = class extends Me {
- constructor(i, a, e) {
- super(), this._commandService = i, this._otherFormulaManagerService = a, this._dependencyManagerService = e, this._initialize();
- }
- _initialize() {
- this._commandExecutedListener();
- }
- _commandExecutedListener() {
- this.disposeWithMe(
- this._commandService.onCommandExecuted((i) => {
- if (i.id === oa.id) {
- const a = i.params;
- if (a == null)
- return;
- const e = { [a.unitId]: { [a.subUnitId]: a.formulaMap } };
- this._otherFormulaManagerService.batchRegister(e);
- } else if (i.id === ua.id) {
- const a = i.params;
- if (a == null)
- return;
- const e = {};
- a.formulaIdList.forEach((r) => e[r] = !0);
- const t = { [a.unitId]: { [a.subUnitId]: e } };
- this._otherFormulaManagerService.batchRemove(t);
- }
- })
- );
- }
- };
- Pn = Vb([
- Cs(0, br),
- Cs(1, ya),
- Cs(2, Hn)
- ], Pn);
- class Nb extends Me {
- constructor() {
- super(...arguments);
- // 18.5.1.2 table (Table)
- A(this, "_tableMap", /* @__PURE__ */ new Map());
- // 18.5.1.2 table (Table) for I18N
- A(this, "_tableOptionMap", /* @__PURE__ */ new Map());
- }
- dispose() {
- this._tableMap.clear(), this._tableOptionMap.clear();
- }
- remove(e, t) {
- var r;
- (r = this._tableMap.get(e)) == null || r.delete(t);
- }
- getTableMap(e) {
- return this._tableMap.get(e);
- }
- getTableOptionMap() {
- return this._tableOptionMap;
- }
- registerTable(e, t, r) {
- var n;
- this._tableMap.get(e) == null && this._tableMap.set(e, /* @__PURE__ */ new Map()), (n = this._tableMap.get(e)) == null || n.set(t, r);
- }
- registerTableOptionMap(e, t) {
- this._tableOptionMap.set(e, t);
- }
- }
- const Uu = lt("univer.formula.super-table.service");
- var Ob = Object.defineProperty, Mb = Object.getOwnPropertyDescriptor, wb = (i, a, e, t) => {
- for (var r = t > 1 ? void 0 : t ? Mb(a, e) : a, n = i.length - 1, s; n >= 0; n--)
- (s = i[n]) && (r = (t ? s(a, e, r) : s(r)) || r);
- return t && r && Ob(a, e, r), r;
- }, Bi = (i, a) => (e, t) => a(e, t, i);
- let Ln = class extends Me {
- constructor(i, a) {
- super(), this._commandService = i, this._superTableService = a, this._initialize();
- }
- _initialize() {
- this._commandExecutedListener();
- }
- _commandExecutedListener() {
- this.disposeWithMe(
- this._commandService.onCommandExecuted((i) => {
- if (i.id === sa.id) {
- const a = i.params;
- if (a == null)
- return;
- const { unitId: e, tableName: t, reference: r } = a;
- this._superTableService.registerTable(e, t, r);
- } else if (i.id === Xi.id) {
- const a = i.params;
- if (a == null)
- return;
- const { unitId: e, tableName: t } = a;
- this._superTableService.remove(e, t);
- } else if (i.id === to.id) {
- const a = i.params;
- if (a == null)
- return;
- const { tableOption: e, tableOptionType: t } = a;
- this._superTableService.registerTableOptionMap(e, t);
- }
- })
- );
- }
- };
- Ln = wb([
- Bi(0, br),
- Bi(1, Uu)
- ], Ln);
- class Db extends Me {
- constructor() {
- super(...arguments);
- A(this, "_dirtyConversionMap", /* @__PURE__ */ new Map());
- }
- dispose() {
- this._dirtyConversionMap.clear();
- }
- remove(e) {
- this._dirtyConversionMap.delete(e);
- }
- get(e) {
- return this._dirtyConversionMap.get(e);
- }
- has(e) {
- return this._dirtyConversionMap.has(e);
- }
- register(e, t) {
- this._dirtyConversionMap.set(e, t);
- }
- getDirtyConversionMap() {
- return this._dirtyConversionMap;
- }
- }
- const Sb = lt(
- "univer.formula.active-dirty-manager.service"
- );
- var Pb = Object.defineProperty, Lb = Object.getOwnPropertyDescriptor, xb = (i, a, e, t) => {
- for (var r = t > 1 ? void 0 : t ? Lb(a, e) : a, n = i.length - 1, s; n >= 0; n--)
- (s = i[n]) && (r = (t ? s(a, e, r) : s(r)) || r);
- return t && r && Pb(a, e, r), r;
- }, Ii = (i, a) => (e, t) => a(e, t, i);
- const jb = "UNIVER_ENGINE_FORMULA_PLUGIN";
- var _s;
- let Fi = (_s = class extends Ku {
- constructor(i = ai, a, e) {
- super(), this._config = i, this._injector = a, this._configService = e;
- const { ...t } = Xu(
- {},
- ai,
- this._config
- );
- this._configService.setConfig(fa, t);
- }
- onStarting() {
- this._initialize(), this._initializeWithOverride();
- }
- onReady() {
- var i;
- ts(this._injector, [
- [wn],
- [Ln]
- ]), (i = this._config) != null && i.notExecuteFormula || ts(this._injector, [
- [Pn],
- [Sn],
- [Dn],
- [Nn]
- ]);
- }
- onRendered() {
- var i;
- (i = this._config) != null && i.notExecuteFormula || ts(this._injector, [
- [Gs],
- [Ys]
- ]);
- }
- _initialize() {
- var a;
- const i = [
- // Services
- [Yt, { useClass: vf }],
- [pr, { useClass: Vs }],
- [Sb, { useClass: Db }],
- [Uu, { useClass: Nb }],
- // Models
- [Pr],
- // Engine
- [ca],
- //Controllers
- [wn],
- [Ln]
- ];
- (a = this._config) != null && a.notExecuteFormula || i.push(
- // Services
- [ya, { useClass: Oh }],
- [Nt, { useClass: Is }],
- [Ft, { useClass: ws }],
- [jr, { useClass: Nh }],
- //Controller
- [Nn],
- [Pn],
- [Dn],
- [Sn],
- // Calculation engine
- [Cr],
- [xr],
- [gr],
- // AstNode factory
- [Eo],
- [En],
- [bn],
- [Vo],
- [yn],
- [An],
- [Rn],
- [pn],
- [Vn],
- [No]
- ), i.forEach((e) => this._injector.add(e));
- }
- _initializeWithOverride() {
- var i;
- (i = this._config) != null && i.notExecuteFormula || [
- [Gs, { useClass: Qs }],
- [Hn, { useClass: Vh }],
- [Ys, { useClass: Hs }]
- ].forEach((e) => this._injector.add(e));
- }
- }, A(_s, "pluginName", jb), _s);
- Fi = xb([
- Ii(1, Ve(ki)),
- Ii(2, ta)
- ], Fi);
- export {
- Db as ActiveDirtyManagerService,
- q as ArrayValueObject,
- Eo as AstRootNodeFactory,
- xr as AstTreeBuilder,
- Of as AsyncArrayObject,
- Qb as AsyncCustomFunction,
- Nf as AsyncObject,
- V as BaseFunction,
- kn as BaseReferenceObject,
- kt as BaseValueObject,
- er as BooleanValue,
- T as BooleanValueObject,
- Nn as CalculateController,
- Qs as CalculateFormulaService,
- Om as CustomFunction,
- Uh as DEFAULT_INTERVAL_COUNT,
- Vs as DefinedNamesService,
- ph as DependencyManagerBaseService,
- Vh as DependencyManagerService,
- Hb as ENGINE_FORMULA_CYCLE_REFERENCE_COUNT,
- fa as ENGINE_FORMULA_PLUGIN_CONFIG_KEY,
- yr as ERROR_TYPE_SET,
- m as ErrorType,
- g as ErrorValueObject,
- Ws as FUNCTION_NAMES_ARRAY,
- le as FUNCTION_NAMES_COMPATIBILITY,
- Nm as FUNCTION_NAMES_CUBE,
- Qe as FUNCTION_NAMES_DATABASE,
- be as FUNCTION_NAMES_DATE,
- Z as FUNCTION_NAMES_ENGINEERING,
- ee as FUNCTION_NAMES_FINANCIAL,
- Ne as FUNCTION_NAMES_INFORMATION,
- Se as FUNCTION_NAMES_LOGICAL,
- me as FUNCTION_NAMES_LOOKUP,
- Y as FUNCTION_NAMES_MATH,
- v as FUNCTION_NAMES_STATISTICAL,
- se as FUNCTION_NAMES_TEXT,
- lb as FUNCTION_NAMES_UNIVER,
- ju as FUNCTION_NAMES_WEB,
- Nh as FeatureCalculationManagerService,
- ws as FormulaCurrentConfigService,
- Pr as FormulaDataModel,
- Hs as FormulaDependencyGenerator,
- hs as FormulaDependencyTree,
- $s as FormulaDependencyTreeType,
- Vi as FormulaDependencyTreeVirtual,
- ft as FormulaExecuteStageType,
- wr as FormulaExecutedStateType,
- Is as FormulaRuntimeService,
- En as FunctionNodeFactory,
- vf as FunctionService,
- Ju as FunctionType,
- Sb as IActiveDirtyManagerService,
- Gs as ICalculateFormulaService,
- pr as IDefinedNamesService,
- Hn as IDependencyManagerService,
- jr as IFeatureCalculationManagerService,
- Ft as IFormulaCurrentConfigService,
- Ys as IFormulaDependencyGenerator,
- Nt as IFormulaRuntimeService,
- Yt as IFunctionService,
- ya as IOtherFormulaManagerService,
- Uu as ISuperTableService,
- Cr as Interpreter,
- bn as LambdaNodeFactory,
- Vo as LambdaParameterNodeFactory,
- ba as LambdaValueObjectObject,
- gr as Lexer,
- ae as LexerNode,
- ca as LexerTreeBuilder,
- ie as NullValueObject,
- y as NumberValueObject,
- yn as OperatorNodeFactory,
- Oh as OtherFormulaManagerService,
- An as PrefixNodeFactory,
- Cn as RangeReferenceObject,
- Rn as ReferenceNodeFactory,
- bc as RegisterFunctionMutation,
- Xi as RemoveDefinedNameMutation,
- ia as RemoveFeatureCalculationMutation,
- ua as RemoveOtherFormulaMutation,
- Uc as RemoveSuperTableMutation,
- bs as SetArrayFormulaDataMutation,
- sa as SetDefinedNameMutation,
- Yb as SetDefinedNameMutationFactory,
- aa as SetFeatureCalculationMutation,
- Ns as SetFormulaCalculationNotificationMutation,
- Ji as SetFormulaCalculationResultMutation,
- Zi as SetFormulaCalculationStartMutation,
- zi as SetFormulaCalculationStopMutation,
- eo as SetFormulaDataMutation,
- oa as SetOtherFormulaMutation,
- jc as SetSuperTableMutation,
- to as SetSuperTableOptionMutation,
- j as StringValueObject,
- pn as SuffixNodeFactory,
- Nb as SuperTableService,
- Vn as UnionNodeFactory,
- Fi as UniverFormulaEnginePlugin,
- No as ValueNodeFactory,
- pt as ValueObjectFactory,
- $ as compareToken,
- oc as convertUnitDataToRuntime,
- Ih as deserializeRangeForR1C1,
- fn as deserializeRangeWithSheet,
- mr as deserializeRangeWithSheetWithCache,
- Yh as functionArray,
- pm as functionCompatibility,
- Vm as functionCube,
- Im as functionDatabase,
- Rg as functionDate,
- O1 as functionEngineering,
- P0 as functionFinancial,
- td as functionInformation,
- yd as functionLogical,
- rC as functionLookup,
- D_ as functionMath,
- v_ as functionMeta,
- aE as functionStatistical,
- ub as functionText,
- cb as functionUniver,
- hb as functionWeb,
- pi as generateAstNode,
- or as generateRandomDependencyTreeId,
- ri as generateStringWithSequence,
- kb as getAbsoluteRefTypeWitString,
- tn as getAbsoluteRefTypeWithSingleString,
- $b as getRangeWithRefsString,
- Gb as handleNumfmtInCell,
- na as handleRefStringInfo,
- rc as includeFormulaLexerToken,
- si as initSheetFormulaData,
- en as isFormulaLexerToken,
- zu as isInDirtyRange,
- Ec as isReferenceString,
- rn as isReferenceStringWithEffectiveColumn,
- Oc as isReferenceStrings,
- Fb as matchRefDrawToken,
- K as matchToken,
- Ib as normalizeSheetName,
- X as operatorToken,
- $e as sequenceNodeType,
- fr as serializeRange,
- ys as serializeRangeToRefString,
- pc as serializeRangeWithSheet,
- Vc as serializeRangeWithSpreadsheet,
- ns as singleReferenceToGrid,
- Ci as strip,
- _f as stripErrorMargin
- };
|